grep in a parent-folder session answers "Found 0 matches" while a child's text index is still loading (0.64.0 regression)
Summary
In a session whose root is a folder that contains repositories (a parent folder), grep immediately after a module start returns Found 0 matches in 0 files. The answer names the child repository as not covered because its trigram index is still loading. v0.63.5 searched the files of the child directly in the same case and returned the match.
The v0.64.0 release note says: "Text search is ready about a second after a repository opens, before the call graph finishes; grep and glob walk the folder until then." In the parent-folder path, the loading child is not walked.
Reproduction
- Folder
Pcontains one git repository,large-repo(a shallow clone of this repository, 6,132 files). - Fresh AFT storage, semantic index off, AFT in daemon (subc) mode, OpenCode host.
- Start a session with root
P. Immediately callgrepwith{"pattern": "CURRENT_SCHEMA_VERSION"}, then call it again every few seconds.
| Version | Session root | First grep after a cold start |
|---|---|---|
| 0.63.5 | P |
the matching line |
| 0.64.0 | P |
Found 0 matches in 0 files (Parent folder: not covered by this answer: - large-repo: trigram index of this repository is still loading) |
| 0.64.0 | P/large-repo |
the matching line |
In this run the 0.64.0 parent-folder grep was correct from the second call (2.7 s after the start); the first call was at 0.6 s. The time to load the index increases with the size of the repository, and it is longer one time after an upgrade, when each repository builds its store again.
A second test setup with a smaller fixture repeated the result three times out of three: 0.63.5 gave the matching line with [index: building; searched all 2 files directly], and 0.64.0 gave the empty answer above. glob was not tested.
Cause (v0.64.0)
In crates/aft/src/data_layer/parent_session/query.rs (:222-240), the text plane of each child is searched only when it is Plane::Ready. Each other plane, also Plane::Loading, becomes a gap through gap_reason("trigram") (crates/aft/src/data_layer/parent_session.rs :709-715). There is no walk of the files of a loading child.
Why it is important
The first line, Found 0 matches in 0 files, looks like a negative result. An agent that reads the first line can think that the pattern is not in the code and continue; the coverage note comes after it. Sessions with a parent-folder root are frequent, for example a folder of worktrees or a folder with some repositories.
Request
One of these changes:
- Walk the files of a loading child directly, as the release note says and as v0.63.5 did.
- Or, when the answer does not include a child, do not start the answer with
Found 0 matches. Start it with a status that says the answer is not complete, for exampleIncomplete: the text index of large-repo is still loading; retry, so that a reader does not read the empty result as proof that there is no match.
Thanks, confirmed. In a parent-folder session, grep uses a child repository's text index only once it is ready; a child whose index is still loading becomes a coverage gap instead of being searched. A single-repository session walks the files directly in that state, as the release note describes, so the parent-folder path is the odd one out.
We'll make a loading child in a parent-folder session get the same bounded direct walk as a single repository, so the answer includes its matches and says the index was still building. You're also right that a reply missing a child shouldn't open with "Found 0 matches"; when a child can't be searched at all, the answer will lead with its incomplete status.
Fixed in v0.65.0, released today: grep in a folder of repositories now searches a repository whose index is still loading, instead of answering "Found 0 matches". Thanks for the report. If you still see it after updating, reply here and we'll reopen.