Repository navigation
feat(files): search file contents from the side panel, documents included - #10756
Conversation
|
Intent: Make the side panel's Files tab able to answer "which file contains this text" — including text inside PDF, Word, PowerPoint and Excel documents, which the dashboard cannot search at all today. Not a goal: the rest of a VS Code-style Search view (results grouped by file with per-file counts, match-case / whole-word / regex toggles, an exclude-glob input, |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify #10852 and #11052 actually carry the deferred argv-exposure and bounded-PDF work as described — the design leans on those follow-ups existing. [DESIGN-REVIEWED] 843a178 |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The repo now carries two rg+python content-search engines: the new endpoint and the file-explorer app's, each with its own sensitive-exclusion fence. Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: let a user find which project files — Office documents included — contain a string, from the chat side panel's Files tab. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 843a178 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsContent-search line numbering diverges between the ripgrep and python engines, breaking the module's own engine-parity contract. FINDING — src/kiro_crew/dashboard/handlers/files.py:740 — [OPUS-REVIEWED] 843a178 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Flip Name↔Content live once — All/Changed vanishes unanimated and no recording shows it; confirm it reads as mode change, not breakage. Suggestions
[UX-REVIEWED] 843a178 |
|
mechanism: rg argv pinned to the fallback's semantics (--fixed-strings, --ignore-case, --no-ignore-vcs)
Detail the ledger does not keep: Two tests carry it — Three sibling divergences on this span surfaced while fixing it and are fixed with |
|
self-added: yes
|
|
self-added: no
|
|
self-added: yes
|
Detail the ledger does not keep: What this PR did do is stop the copies drifting silently: the ignore, literal and |
|
mechanism: hand-written red span replaced by ErrorNotice variant=inline askAgent
Detail the ledger does not keep: The status line now keeps only the states that are not errors, and the test asserts |
|
self-added: no
|
|
mechanism: preview redaction in _grep_hit; xlsx aggregate expansion ceiling; static engine for empty responses
Detail the ledger does not keep: Previews — redaction sits at that chokepoint so a third pass cannot be added XLSX — both gates are load-bearing rather than redundant: the inventory vet bounds PATH — the more useful outcome is the guard, not the fix. The static ratchet in |
|
mechanism: rg argv gains --fixed-strings/--ignore-case; error exit and timeout split
Detail the ledger does not keep: Four behavioural tests run per engine — the literal, the unbalanced query, the case |
|
self-added: no
|
|
mechanism: capture fixture previews rewritten; driver asserts one highlight per row
Detail the ledger does not keep: Two of my first replacements still carried |
|
self-added: no
|
|
mechanism: document badge title names the location and states the viewer opens at the start
Detail the ledger does not keep: That is a panel-plumbing change across files this PR does not otherwise touch, and it |
|
self-added: no
|
|
self-added: no
|
d94e2b7 to
79d9e42
Compare
|
|
Twelve frames re-captured at head Order: results, partial, hint, empty, error, Name mode — light then dark. |
|
|
|
|
|
|
|
|
|
Twelve frames re-captured at head Order: results, partial, hint, empty, error, Name mode — light then dark. |
|
|
|
Feature-map panel fix (informational — the finding it answers no longer resolves at this head, so this is deliberately not a disposition record).
The row now reads "Chat right panel → Files tab, Name/Content toggle below the search field; Verified with the gate rather than by eye: Fixed in e92aabb. |
|
Twelve frames re-captured after this round's copy changes: the document note now leads with what the tag IS ("...the tag after its name says where the text was found — a page, a slide, a sheet and row. A Word file has no such place, so it shows no tag."), and the empty state reads "No results" rather than "No matches" so it no longer sits two words apart from the "0 results" count. Every driver assertion passes on every arm. Order: results, partial, hint, empty, error, Name mode — light then dark. |
|
Twelve frames re-captured after PDF came out of the document pass. Visible changes: the results arm has one fewer row and one fewer tag (2 tagged document rows, 7 marked runs, "7 results"), the document note now says "a slide, or a sheet and row" with no page, and the hint no longer advertises PDF. Every driver assertion passes on every arm. Order: results, partial, hint, empty, error, Name mode — light then dark. |
|
Stale-tree commit fixed (informational — the findings it answers should not resolve at the new head, so this is deliberately not a disposition record). The design and first-principles lanes were right, and the diagnosis by blob identity was exact: How it happenedThe squash sequence was The fetch advanced The part that let it through review-side checks: the How it was fixedRebuilt rather than patched, from a safety branch at the bad commit:
Verification (the invariant, not a spot check)At the pushed head
The clearing conditions the lanes stated were "the diff no longer touches |
|
Net: |
|
GPT F1 (blocking), shared-string amplification in Opus advisory, NUL detection in Still 28 files, zero deletions, |
|
Fixed by changing the method, not by arguing. Pinned by The 29 files, zero deletions, |
|
Fourteen frames, re-captured at this head. New: the in-flight state the UX lane asked for — a seventh arm ( Order: results, partial, hint, empty, error, searching, Name mode — light then dark. |
…uded
The chat side panel's Files tab could only search file NAMES. A Name/Content
toggle on its own row under the search field now asks the gateway which files
CONTAIN the text, and lists them as root-relative path, `:line`, and the matching
line with the match marked. Clicking a text hit opens the file at that line
through the reveal path the panel already has; a document hit opens the file at
its start, because a document has no line to reveal.
`POST /api/file-grep` with `{root, q}` in the body answers it -- a POST, because the query is secret-class text and a request URL is what proxies and access logs retain. A text pass runs `rg --json` where the
host has a ripgrep this endpoint may run, and an equivalent python walk where it
does not. The two are ONE contract, so ripgrep is pinned to the fallback's
semantics rather than its own defaults: `--fixed-strings` (both python passes
match `re.escape(query)`, so `config(` is a search and not a parse error),
`--ignore-case` rather than `--smart-case` (both fold case unconditionally),
`--no-ignore` (`os.walk` cannot honour ignore files), `--max-filesize` and
`--max-count 1` to match the fallback's own ceilings, and `--no-config` because
`RIPGREP_CONFIG_PATH` can carry `--pre=<binary>` and the child inherits this
process's environment.
The query is NOT in the argv. A child's arguments are readable by other accounts
through `/proc/<pid>/cmdline` and `ps`, and this handler already treats the query
as secret-class text -- it redacts it before every SEL write, because "which file
holds this key" is an ordinary reason to type a credential into a search box.
`--file -` hands the pattern over stdin instead, following the sandboxed-stdin
spawn in `cron_script.py`. That also retires the argument-terminator concern by
construction: a query starting with `-` cannot be read as a flag when it is not on
the command line. Because `--file` is line-delimited, a query containing a line
break is answered empty, joining the length bounds rather than earning a code of
its own -- both engines are line-oriented, so such a pattern matches nothing
either way, and saying so keeps the two channels equivalent.
Document containers are excluded with `--iglob`: the document pass claims a file
by `splitext(name)[1].lower()`, so a case-sensitive exclusion leaves `REPORT.DOCX`
in rg's pass and the file is reported twice. Directory skips stay case-sensitive,
matching the walk's own exact-name screen -- extensions are folded on both sides,
directory names on neither. Every glob is negated, which is load-bearing: one
non-negated glob flips ripgrep's whole set into allowlist mode.
The ripgrep it runs is resolved through
`github_runner.validate_provider_executable`, the repo's executable-provenance
chokepoint, rather than through a rule of this module's own -- the same function
`gh`, `glab`, `az`, `aws` and the terminal panel use, and the trust policy is
deliberately single-sourced there. It answers containment in the agent-writable
tree, ownership by a third account, world-writability through the whole parent
chain, symlinks, non-regular and non-executable files, a root gateway, the
Windows ACL where mode bits carry no information, and
`KIROCREW_PROVIDER_BIN_STRICT`. `require_protected` stays unset because `rg` is
handed no provider credentials, which keeps an ordinary Homebrew or
`~/.local/bin` install working; any refusal takes the python engine.
Both passes share one 2s budget and the answer says whether it was partial and
how many documents the budget did not reach, so "no matches" and "the search
stopped" stay different facts. ripgrep's records are read on a thread through a
bounded queue, because rg prints nothing for a non-matching file and an inline
read could not observe the deadline until rg chose to speak. A record over 64 KB
is skipped and marks the answer short rather than being truncated into invalid
JSON. A dead reader with an empty queue ends the search: the end-of-stream
sentinel is a non-blocking put, so a full queue drops it, and treating that as a
timeout would report a finished search as partial and hold the user for the rest
of the budget.
A document pass then extracts `.docx`/`.pptx`/`.xlsx` inside the same deadline,
re-parsing per request -- the 2 s budget already bounds what a keystroke can cost,
and an extraction cache had to carry the partial-parse flag with it to stay honest.
A parse that did not see all of a document's text marks the answer truncated.
`.pdf` is deliberately NOT in that set. Extracting PDF text has no memory ceiling
this process can enforce: pdfplumber exposes no length limit, the allocation is the
parsed character list itself, and the aggregate character cap is evaluated after a
page is appended -- so one page is unbounded, and a 25 MB input can decompress to
orders of magnitude more text. Without the extension a PDF is not a document to
this pass and both engines skip it as binary, which
`test_a_pdf_is_not_searched_at_all` pins with a `.docx` beside it so the assertion
cannot pass by finding nothing. Restoring it needs a resource-bounded extractor
shared with the identical exposure in `knowledge/readers.py:_read_pdf`, tracked in
#11052.
Every string a result row carries is redacted, asserted as a rule over the row
rather than field by field: preview, document label, and path. The path uses the
same `redact_path_segments` the tree and git listings in this module already use,
so a clean path stays byte-for-byte openable.
The All/Changed segment is hidden while Content mode is active and returns
untouched with the tree. It filters by git status, and searching the staged list
is out of scope; disabling it instead would keep its active highlight and still
assert a filter was in force. A hidden segment does not reset a Changed
selection.
The endpoint joins the off-loop ratchet -- root validation and the search both
run off the event loop, and the search takes a TRANSFER pool slot rather than a
probe slot because it holds its worker for the length of the search. `which` is
added to the ratchet's name list, repo-wide, because a `$PATH` walk is filesystem
work whose name does not look like it.
Related: #7625
|
GPT F1 (blocking, upheld), the hand-off lost the journaled context. Fixed: UX BLOCK, no frame of the in-flight state. Fixed: a seventh capture arm, Opus advisory, Windows shard 4, 30 files, zero deletions, UX Watch items (the "Ask the agent" hesitation in the shared |
|
|






























































Problem / Motivation
The chat side panel's Files tab can only search file NAMES. To find which file
mentions a string, you open files one at a time. And the text inside a Word,
PowerPoint or Excel document cannot be searched from the dashboard at all — the
name is all the panel can see.
Why it matters
Finding where a string lives is a constant task, and the panel makes you do it by
hand. Documents are worse: a rate limit written into a spreadsheet and a decision
made on slide 7 are invisible, so the panel quietly answers "not here" about text
that is right there.
What changed (motivation → approach → change)
You can now search file contents from the Files rail, documents included.
A Name / Content toggle, in words, sits on its own row under the search
field. Name is unchanged and still the default. Content asks the gateway which
files CONTAIN the text and lists them: root-relative path,
:line, and thematching line with the match marked. Clicking a text hit opens the file at that
line, through the reveal path the panel already has; clicking a document hit
opens the file at its start, because a document has no line to reveal.
Both extractor loops are bounded by the shared DEADLINE, not only by the
character cap, because the cap bounds text and not work. A crafted workbook whose
sheet is millions of EMPTY rows passes the zip-inventory vet as one small member,
yields no text, never reaches
_GREP_DOC_MAX_CHARS, and would iterate every row.So the worksheet row loop samples the clock every
_GREP_ROW_DEADLINE_STRIDErows— a stride, because a clock read per row is pure overhead on a legitimate large
sheet, and the stride still bounds the overshoot to a fixed row count rather than
to the file's size.
_grep_doc_segmentsreturns
(segments, whole), and a parse that did not see all of a document's text— deadline, mid-read failure, or the character cap — marks the answer partial.
.docx/.pptxhave no loop for the deadline to cut; their text is requested onecharacter past the cap so a cut at the cap is detectable.
There is no extraction cache. An earlier revision kept an LRU keyed by a digest of
the bytes; it needed a
cacheableflag besidewhole, carried the partial-parseflag through the cache, and drew three rounds of findings for 14 lines of code.
The shared 2 s budget already bounds what one keystroke can cost, so documents are
re-parsed per request.
The sensitive-path globs are ANCHORED under the search root, which is what keeps
that optimisation from being a divergence.
is_sensitive_path— the declaredauthority, applied per hit by both engines — is HOME-anchored:
~/.npmrcis acredential store, a project's own
.npmrcis an ordinary file, and the pythonwalk searches the latter. An unanchored
!**/.npmrcexcluded it at any depth, sothe same query answered differently depending on whether the host had ripgrep,
with the rg host quietly returning less. Each entry is now resolved to its
absolute home path and emitted only when it truly lies inside the tree being
searched, as a root-ANCHORED glob. The leading slash is what anchors it:
ripgrep follows gitignore semantics, under which a pattern containing no slash
matches a BASENAME at any depth, so a bare
!.sshwould hide every.sshin thetree — the same unanchored behaviour, reintroduced silently. A root outside HOME
emits nothing and loses nothing: there is no credential store under it for the
glob to have saved a read on. A test states the parity over the pair — no exclusion the argv carries may
hide a name the python walk would search under the same root.
The status row names the UNIT. Every engine returns at most one row per file --
--max-count 1for ripgrep, abreakafter the first matching line in the pythonwalk, one segment per document -- so a bare "7 results" beside seven single-line
rows left it open whether a result was a file or one spot inside a file, and under the second
reading the list looks like it is hiding the other matches in each file. The row now
adds "one row per file", and only when there are results, since nothing found needs
no description. The count itself is unchanged:
components.discoverySearchBar.resultis shared with two other surfaces and registered in
pluralKeys.json, so relabellingit to "8 files" would have meant either changing all three or minting a new plural key
across eleven plural systems. Naming the unit beside the count answers the ambiguity
without either.
Previous hits are kept only WITHIN a project.
placeholderDatakeeps thelast answer on screen so that refining a query narrows a visible list instead of
blanking it for the debounce plus the whole 2s budget — but the query key carries
the project directory too, so keeping it across every key change also kept it
across a PROJECT switch. Each row opens by absolute path, so those rows stayed
clickable and opened a file from the project the user had just left. The
placeholder now returns the previous answer only when the previous key names the
same project; a different project's answer is not an approximation of this one.
The status row's tooltip names the CONSEQUENCE, not the engine. "Searched with
python." reads as a claim that the search was narrowed to Python files, which is
the misreading the code comment already predicted; and the fast path needs no
gloss at all. So the tooltip appears only when the host took the slow path, and
says that this host has no ripgrep and the search used the slower built-in scan.
A document row carries NO hover tooltip. The tag beside the file name
(
slide 7,Costs · row 12) is the whole of the row's own location information,and the always-visible note above the list explains that a document opens from its
start. That note leads with what the tag IS and treats Word as the exception, rather
than opening on a condition: a blind reader parsed the condition-first wording only
tentatively ("I think it explains the tags, but I'm not certain"). It now reads
"…the tag after its name says where the text was found — a slide, or a sheet and
row. A Word file has no such place, so it shows no tag." The empty state reads "No
results" rather than "No matches", so it no longer sits two words apart from the
"0 results" count directly above it.
That note no longer promises a tag unconditionally: it
previously read "the tag after the file name shows where the text was found",
which made a tagless
.docxrow look like an anomaly — the reader could not tellwhether it meant the file's position was unknown. It now says a tag appears when
the format has a place inside it to name, which is the truth for all four
formats. A
titleon that tag restated both, and being gated on thetag existing it was absent from exactly the row a reader most wanted it on -- a
.docxhit, which has no location inside the file to name and therefore no tag.So the tooltip is gone rather than extended: one always-visible explanation, and
no row that is the odd one out. A test pins that no row carries the title and
that the visible note is still rendered.
One EXISTING control changes behaviour, which is worth stating plainly rather
than leaving to the test list: the All/Changed segment is HIDDEN while Content
mode is active, and returns untouched when the mode goes back to Name. It
filters the tree by git status, and searching the staged-changes list is an
explicit non-goal of this PR, so in Content mode it would either mislead or do
nothing. Disabling it instead was rejected: a disabled segment keeps its active
highlight, so it would still assert that a filter was in force. Hiding it does
not reset a Changed selection — the selection survives and is honoured again
when the tree returns, and a test pins exactly that.
POST /api/file-grepwith{root, q}in the body answers it -- a POST, because the query is secret-class text and a request URL is what proxies and access logs retain. A text pass runsrg --jsonwhere thehost has ripgrep and an equivalent python walk where it does not. The two are one
contract, so ripgrep is pinned to the fallback's semantics rather than its own
defaults:
--fixed-strings(the fallback matches a literal, soa.cis threecharacters and
config(is a search, not a regex parse error),--ignore-case(the fallback folds case unconditionally),
--no-ignore(os.walkcannothonour
.gitignore,.ignoreor.rgignore),--max-filesize(the fallbackskips a file over 2 MB, so ripgrep must too) and
--max-count 1(the rail listsfiles, not occurrences). The query is not in the argv. A child's arguments are readable by other
accounts on the host through
/proc/<pid>/cmdlineandps, and this handleralready treats the query as secret-class text -- it redacts it before every SEL
write, because "which file holds this key" is an ordinary reason to type a
credential into a search box. Putting it on the command line published it to the
whole host for the life of the process, contradicting the redaction two functions
away.
--file -hands the pattern list over stdin instead, which is the channelcron_script.pyalready feeds through the same sandbox launcher andpopen_limited. It also retires the argument-terminator question byconstruction: a query starting with
-cannot be misread as a flag when it isnot on the command line to be read.
One INPUT RULE follows from that channel and is worth stating because a user can
hit it: a query containing a line break is answered empty.
--fileisline-delimited, so a two-line pattern file would be two patterns OR-ed together,
while the python pass matches one literal -- the engines would answer different
questions. It joins the existing length bounds rather than earning an error code
of its own, because the answer is the same one a one-character query gets and it
is the TRUE answer either way: both engines are line-oriented, so a pattern
spanning a newline matches nothing. Trailing whitespace is still just trimmed, so
a query pasted with a newline on the end searches normally.
The argv exposure fix is deliberately scoped to this endpoint; the app
sibling is deferred.
apps/builtins/file_explorer/server.pystill passes itsuser-typed query as an argv element (
cmd += ["--", ...]), so the exposure thissection describes is still open there. That is a conscious scope decision, not an
oversight: the harm is general — process arguments are readable by other accounts
on any host — but the two searches run behind different authorization models (that
app enforces
ALLOWED_ROOTSin a separate process; this handler enforces_validate_dashboard_path+is_sensitive_pathinside the probe pool), sochanging its spawn means changing its trust boundary from a PR about the chat
rail's file search. It is recorded on #10852 with both carry-overs named — the
--file -channel plus the line-break refusal that channel requires, andvalidate_provider_executablefor its still-unvetted binary — so the follow-upstarts from two known one-line calls rather than a rediscovery. A reviewer who
thinks a general-harm finding must be fixed at every call site inside the PR that
names it should say so; that is a scope call, and this paragraph exists so it is
made against a stated position rather than a silence.
The ripgrep it runs is vetted first, by the repo's existing
executable-provenance chokepoint rather than by a rule of this module's own:
github_runner.validate_provider_executable, the same functiongh,glab,az,awsand the terminal panel resolve through. It refuses containment inthe agent-writable project or workspace tree, ownership by a third account,
world-writability anywhere in the parent chain, a symlink chain, a non-regular
or non-executable file, a root gateway, and on Windows reads the real ACL
where the mode bits carry no information;
KIROCREW_PROVIDER_BIN_STRICTescalates it.
rgtakes the default relaxed policy — it is handed no providercredentials, so
require_protectedstays unset and an ordinary Homebrew or~/.local/bininstall keeps working. Any refusal is a fallback, not an error:the python engine answers the same question. A document
pass then extracts
.docx/.pptx/.xlsx..pdfis deliberately NOT in that set, and that is the one thing this PR doesnot ship. Extracting PDF text has no memory ceiling this process can enforce:
pdfplumberexposes no length limit, the allocation is the parsed character listitself, and the aggregate character cap is evaluated only after a page is
appended — so a SINGLE page is unbounded, and a 25 MB input can decompress to
orders of magnitude more text. Without the extension a PDF is not a document to
this pass, and both engines then skip it as binary (ripgrep by its own detection,
the python walk by its NUL sniff);
test_a_pdf_is_not_searched_at_allpins thatwith a
.docxbeside it, so the assertion cannot pass by finding nothing.Restoring it needs a resource-bounded extractor, and that belongs with the
identical exposure in
knowledge/readers.py:_read_pdfrather than here alone —tracked in #11052.
Symlinked FILES are skipped by both engines. ripgrep does not follow symlinks
while traversing, so a link to a matching file is invisible to it, while
safe_read_prefixread it happily — one tree answering differently depending onwhether the host had ripgrep. The sharper half is containment: a link can point
anywhere, so the python walk was reading bytes from outside the root the caller
named (verified — a link to a file in a sibling directory was returned as a hit).
os.walkalready declines to DESCEND into a linked directory, so this is thefile-shaped half of a rule the directory half already followed. Both engines are
asserted on the same tree, with an ordinary file beside the link so the test cannot
pass by finding nothing.
Both passes share one 2s budget, and the answer says whether it was partial and
how many documents the budget did not reach, as a floor — so "no matches" and "the
search stopped" stay different facts. ripgrep's records are read INCREMENTALLY
and the child is stopped at the 200-result cap:
--max-count 1bounds recordsper file and
--max-filesizebounds one record, but neither bounds how MANYfiles match, so buffering the whole output to keep the first 200 grew with the
workspace. Streaming also makes a timeout's partial answer simply "what the
reader parsed", because the deadline is shared and the fallback would start with
nothing left.
A document row shows WHERE inside the document it matched instead of a line
number, because none of those formats has one:
slide 7orSheet1 · row 12. AWord file shows NO tag: its paragraphs carry no page or section to name, and
docbeside a
.docxfilename added nothing the filename had not. That tag is a LABEL, not a jump target, and the visible line abovethe list says so in the reader's own terms -- "the tag after the file name
shows where the text was found", not "the badge", which named nothing on
screen. Jumping a document hit to its slide or row is deliberately out of scope
(see the non-goals in the intent comment), so
revealLinekeeps one meaning -- asource line -- everywhere.
Guards bound what the response and the audit trail can carry. The root goes
through the same
_validate_dashboard_path/is_sensitive_pathchokepointevery other file handler uses. Every document is read once through
safe_read_prefix, which identity-checks the descriptor, and parsed from thosebytes, so no parser can reopen a swapped path. Every preview is redacted at the
single row builder both passes share — a search returns the matching LINE, so a
key pasted into ordinary source would otherwise travel with it — and the query
goes through the same redactors before it reaches the SEL log. A workbook is
refused before openpyxl loads if its declared members expand past the sheet endpoint's 200 MB
ceiling.
.py/.mdfile.pptxslide 7.xlsxSheet1 · row 12.docx~/.aws/credentialsunder the root.pdf🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
Not a product-shape change: Name stays the default, nothing is removed or
replaced, and no existing default moves — so no RFC under
docs/request-for-change/applies.Where the code lives:
src/kiro_crew/dashboard/handlers/files.pyapi_file_grep, both engines, the document pass and the capssrc/kiro_crew/dashboard/handlers/__init__.py,src/kiro_crew/dashboard/routes/taskrunner.py/api/file-searchdocs/feature-map/README.md/api/file-grepwebsite/src/api/fileGrep.tsapiTransportso a lapsed session raises the auth bannerwebsite/src/pages/chat/FileBrowserRail.tsxwebsite/src/pages/chat/SidePanel.tsx,website/src/pages/chat/FilesHomePanel.tsxwebsite/src/i18n/locales/en.manual.jsonand every other catalog;en-XA.jsonregenerated bynpm run i18n:pseudotest/test_file_grep.py,test/test_dashboard_files_onloop_fs.py,website/src/test/FileBrowserRail.test.tsx,website/src/test/fileGrep.test.tswebsite/capture/files-rail-content-search.*,website/scripts/capture-files-rail-content-search.mjsDeferred duplication (named, not hidden)
Two places where this change is a SECOND copy of something the repo already has.
Both are deliberate for this PR and neither is silent:
The rg + python engine duplicates
src/kiro_crew/apps/builtins/file_explorer/server.py._grep_rg/_grep_pythonhere and_search_rg(:749) /_search_python(:868)there are the same rg-or-python contract spelled twice. Unifying them is deferred
to #10852. What matters more than the tidiness: the parity and trust work is on
THIS side only —
--fixed-strings, unconditional--ignore-case,--max-filesize, timeout-partial recovery, and the absolute-path resolver thatdefers to
validate_provider_executable. The sibling still spawns a barergoff$PATH, which isthe substitution vector this copy's resolver exists to close. #10852 leads with
that, and accepts either one shared engine or the same fixes applied to the
sibling. Not folded in here because the two run behind different authorization
models — that app enforces
ALLOWED_ROOTSin a separate process, this handlerenforces
_validate_dashboard_path+is_sensitive_pathinside the probe pool —and the intent comment names sharing that model as a non-goal.
The PDF page loop that duplicated
KnowledgeReader._read_pdfis gone, becausePDF is out of this pass entirely. What remains is worth recording for #11052, which
picks it up:
knowledge/readers.py:_read_pdfloopspage.extract_text()with nopage cap and no character cap at all — strictly less bounded than the copy deleted
here — and its per-page
tryhas noexcept, so one raising page discards everypage already read. Both call sites want the same resource-bounded extractor, which
is exactly why that work is not in a file-search PR: fixing one and leaving the
other is the point-patch shape this PR has been told off for more than once.
Tests
test/test_file_grep.py— 55 tests in eight groups.Gating: a sensitive root and a validator-refused root are both 403 (not 404,
which would invite probing for an allowed spelling), a file root is 404, a
one-character query is not a search, and a sensitive hit is dropped by EITHER
engine.
Engine parity, which is where the round's real work is. Both engines are compared
against each other on one tree — same files, same lines — and then each divergence
gets its own case: a literal query (
a.cmust not matchabc), an unbalancedquery (
config(is a search, not a parse error), case folding whatever the querylooks like (
Widgetfindswidget), a.gitignored file answering the same onboth hosts, and a multi-byte line surviving intact. The argv itself is asserted
too, so the four parity flags and the all-globs-negated rule are pinned on a host
with no ripgrep.
Budgets: the result cap and a spent deadline both report
truncatedrather thanan empty list, an rg ERROR exit takes the fallback while exit 1 is accepted as a
real "no matches", a timeout returns its partial hits (decoded from the bytes
CPython actually raises), a file over the size ceiling is skipped by both
engines, the document pass leaves the walk on a spent deadline instead of
counting through the tree, an oversized document is skipped, and a busy probe
pool is a coded 503.
Trust and retention: the resolver hands
which's candidate to the provenancechokepoint and spawns only what comes back, a refusal takes the python engine,
and a secret typed as the query never reaches the audit log. The chokepoint's own verdicts are tested
against real descriptors and real mode bits in
test_source_providers.pyandtest_windows_acl.py; re-asserting them here is what produced a local subsetthat disagreed with it.
Documents: no label for
.docx,slide 3for a deck,Sheet1 row 2for aworkbook, a
.pdfnot searched at all (with a.docxbeside it so the assertioncannot pass vacuously), a bloated workbook refused before openpyxl,
no file reported twice, a symlinked document outside the root not read (with a
plain document beside it as the control), and a capped, deadline-cut or mid-read
broken parse each reported as partial.
The rg spawn: a fail-closed sandbox refusal (
SandboxUnavailableError, aRuntimeError) takes the python engine instead of raising into a 500 on a hostwith no backend,
wrap_argv's launcher temp file is unlinked on every pathincluding the timeout, and the reader stops at the cap and kills the child
rather than draining a tree it has already answered for. One test gives it a
pipe that never speaks:
rgprints nothing for a non-matching file, so arare-or-absent query used to run to
rg's own completion past the budget andthen report a COMPLETE answer — the read is now bounded by the deadline, not by
when
rgchooses to emit a line. Another runs the REAL policy as a control and a variant differing in one bit: a0755
rgin a private directory clears, and the same file refuses once itsparent is 0777 and not sticky — the case a world-writable test applied to the
binary alone let through, and the reason to delegate rather than re-spell. It
skips where the control cannot clear (an NFS home whose parents stat as the
overflow uid 65534, a root gateway) instead of passing vacuously. A third pins
that a page which fails to extract costs its own page only, not the pages
already read.
The sensitive-path fence runs INSIDE the probe, not on the event loop.
is_sensitive_pathis filesystem work whose name does not look like it: one callresolves the path and walks its ancestors, measuring 72
lstat, 8realpath, 6readlinkand 2statfor one ordinary path. Called from the coroutine it parksthe gateway's only event loop on whatever mount the caller named — the same hazard
the ratchet already records for
shutil.which. It now happens in_grep_resolve_root, which the handler reaches only through_run_path_probe,and an empty root there means REFUSED for either reason (an invalid name or a
credential store) because the endpoint already answered both with the same 403. A
test asserts the placement by thread identity rather than the outcome, since the
403 was correct before and after.
That name is deliberately NOT added to the ratchet's list in this PR: nine call
sites in this module call
is_sensitive_pathfrom a coroutine body, eight of thempre-existing, so the entry would turn a file-search change into a module-wide
refactor. It is worth its own change and the count is recorded here so the
follow-up starts from a number rather than a suspicion.
test/test_dashboard_files_onloop_fs.py— the new endpoint joins the off-loopratchet: root validation and the search both run off the event loop, and the
search takes a TRANSFER pool slot, not a probe slot. The ratchet's own name list
gains
which, becauseshutil.whichstats every$PATHentry and so isfilesystem work whose name does not look like it. That entry is REPO-WIDE and not
scoped to this endpoint: the ratchet asserts over every guarded handler, so from
this PR forward any handler calling
shutil.whichon the event loop fails it.I believe that is correct — a
$PATHwalk is filesystem work wherever ithappens, and the ratchet exists to catch exactly the calls whose names do not
look like I/O — but it is a tightening other handlers now inherit from a
file-search PR, so it should be a declared consequence rather than a surprise. No
existing handler needed changing for it; the ratchet passes as-is. The suite's
requires_rgmarker stays PURE, because a
skipifcondition is evaluated at COLLECTION and_grep_rg_executableresolves through the provenance chokepoint — which readsagent_writable_roots(), henceworkspace_root(), which doesmkdir(parents=True). Asking the resolver there made merely IMPORTING the testmodule create the operator's real workspace directory (verified directly: a bare
agent_writable_roots()call with a freshKIROCREW_WORKSPACEcreates thepath). So the marker checks
shutil.whichand a_require_rg_engine()helperruns the provenance question from the test BODY. Both halves are needed:
whichand the resolver disagree wherever the chokepoint refuses a ripgrep that is on
$PATH, and on the marker alone the rg arm of every parity pair would run thepython engine while claiming to cover ripgrep. This matches the repo's own
convention —
requires_gitandrequires_symlinksin conftest are pure for thesame reason.
website/src/test/fileGrep.test.ts— 2 tests for the wire call the rail testsmock away:
/api/file-grepwithrootandqURL-encoded (a space,&,=and(all survive), the decoded body returned as-is, a transport error surfacingrather than shaping an empty answer.
website/src/test/FileBrowserRail.test.tsx— 22 tests: the toggle's default andits survival across a remount, no request below two characters, one request for a
burst of keystrokes, the tree replaced by the hit list, shortened paths, the match
marked without changing the file's casing,
:lineversus a location badge, clickrouting for a text hit (
{ line }) and for a document hit (no line), the statusline's states — count, partial, documents skipped, empty — the engine name kept
to the tooltip, both mode words always visible, a document hit opening from the
start rather than at a line (its
slide 3badge is a label, and the test pinsthat no position is routed), the visible note for document hits, and a failure
rendering through
ErrorNoticewith the agent hand-off rather than as a redline. Three more cover the tree-mode segment and the in-flight list: All/Changed
is absent in Content mode and returns with the tree, hiding it does not silently
reset a Changed selection, and a refined query keeps the previous hits on screen
instead of blanking the list while the next answer arrives.
Manual verification
The screenshots below are Playwright frames from the real component at rail
width, captured by
website/scripts/capture-files-rail-content-search.mjs. Thedriver asserts the palette, the document badges and each arm's own visible
state, so a frame that claims a theme, a badge or a status it does not carry
fails the capture rather than shipping. Seven arms per theme: results, the partial
arm, the below-minimum hint, a search that found nothing, a failed request, the
in-flight state with the request held open, and Name mode.
Screenshots / video
Content mode, light and dark: the Name / Content row, four text hits, then two
tagged document hits (
slide 7andCosts · row 12) plus the tagless.docxrow,with the note above the list stating both halves — a text hit opens the file AT its
line, a document hit opens from the start. Saying only the second half is what left
the
:42tag reading as "line? page?".Frames re-captured at this head, and the embedded images below ARE those captures.
Checkable claims, so a future drift contradicts a specific sentence rather than a
boast: the status row reads "7 results · one row per file"; exactly two rows
carry a tag,
slide 7andCosts · row 12, with nop 3because PDF is out ofthis PR; the document note reads "…a slide, or a sheet and row"; the empty arm
reads "No results"; the in-flight arm reads "Searching…" with no row and no
count; and the tagless
docs/decision.docxrow is present in the results arm.The capped arm, and Name mode unchanged
The status line when the budget stopped the search:
4 results · partial · at least 6 documents not searched. "partial" is the same word the sentence belowthe row uses, and the skipped count says "or more" because it is a floor —
documents the budget never opened, not a tally to reconcile against the rows.
The engine name stays in the row's tooltip.
The three states a reader meets when the search does NOT return a list, each of
which previously had no frame at all — so "query too short", "ran and found
nothing" and "the request failed" all reviewed as unknown:
Below the two-character floor, no request is made and the rail says so.
A search that ran and found nothing —
0 resultsand "No results", which is whatdistinguishes it from a search that has not run. Both read the same word on
purpose: two different words for one outcome made the reader stop and compare
them.
A coded 503 from the probe pool, rendered through the shared
ErrorNoticewiththe agent hand-off rather than as a hand-rolled red line.
The in-flight state: the request held open, so the rail is mid-search — "Searching…" in the status row over the blank list region. This is what a reader sees for up to the 2 s budget on a first search.
Name mode, for contrast — the tree, exactly as before. The All/Changed segment
is here and absent from every Content frame above: it scopes a tree, and Content
mode has none.
Related Issues
Related: #7625 — its first and largest ask, content search in the side panel,
plus the document extraction it expected to inherit from #4648.
no linked issue: #7625 asks for a whole VS Code-style Search view and this is
its first phase, so closing it would drop the rest of what it asks for —
results grouped by file with per-file counts, match-case / whole-word / regex
toggles, include and exclude glob inputs,
Cmd/Ctrl+Shift+F, and searching thestaged-changes list. Those are worth their own PRs against the same issue.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)