fix(gbrain): make --full do a full code walk, not a delta one - #2406
Closed
ShahriarLak wants to merge 1 commit into
Closed
fix(gbrain): make --full do a full code walk, not a delta one#2406ShahriarLak wants to merge 1 commit into
ShahriarLak wants to merge 1 commit into
Conversation
`runCodeImport()` walked with a bare `gbrain sync --strategy code --source X`.
The strategy is right, but that walk is incremental: it only revisits files
changed since the source's checkpoint. A file missed at the ORIGINAL import is
therefore never revisited and stays out of the index indefinitely.
The reindex-code pass below cannot rescue it. It re-chunks pages that already
exist and never walks the filesystem — the same property the comment directly
above already relies on when explaining why the walk has to run first. That fix
landed one flag short: it made a fresh source get pages at all, but left
`--full` unable to discover a file the first walk skipped.
Net effect: `/sync-gbrain --full` did not perform a full walk, and re-running it
never re-detected the gap.
The failure is silent, which is what makes it expensive. Nothing errors, nothing
warns, and the verdict block still reports OK while `gbrain search` and
`gbrain code-def` answer out of a partial index. It reads as "gbrain is weak at
code questions" rather than "the index is incomplete".
Measured on two local code sources before and after this change, counting
exported functions resolvable via `gbrain code-def`: one went from 61/201 (30%)
to 180/201 (89%), importing 79 files that had no page at all; the other had
whole source files missing entirely and reached 93%. Both had been serving
search from a partial index for weeks.
Scoped to `--full` so incremental runs stay fast. `--yes` because this spawns
non-interactively and a full walk otherwise prompts to confirm import cost.
Anyone can check their own brain without applying this:
gbrain sync --source <id> --strategy code --full --dry-run
and compare "N file(s) would be imported" against that source's page_count.
Worth knowing while doing so: the default strategy is markdown and --strategy
is per-invocation, never persisted on the source, so dropping the flag reports
strategy=markdown and a handful of files.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
9 tasks
Owner
|
Thank you — this was absorbed on main (credited in the v1.6x CHANGELOG entries; roster in PR #2604). Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/sync-gbrain --fulldoes not do a full walk.runCodeImport()walks with a baregbrain sync --strategy code --source X— right strategy, but an incremental walk. It only revisits files changed since the source's checkpoint, so a file missed at the original import is never revisited and stays out of the index indefinitely.The
reindex-codepass below cannot rescue it: it re-chunks pages that already exist and never walks the filesystem. That is the same property the comment directly above the call already relies on when explaining why the walk must run first — that fix made a fresh source get pages at all, but left--fullunable to discover a file the first walk skipped. This PR is the missing half.Why it is expensive
The failure is silent. Nothing errors, nothing warns, and the verdict block still reports
OKwhilegbrain searchandgbrain code-defanswer out of a partial index. It presents as "gbrain is weak at code questions" rather than "the index is incomplete", so it survives indefinitely.Measured
Two local code sources, before and after, counting exported functions resolvable via
gbrain code-def:Both had been serving search from a partial index for weeks.
Reproduce on your own brain
Compare
N file(s) would be importedagainst that source'spage_count. To check one file:gbrain get <file-slug>returningpage_not_foundmeans it was never imported.Worth knowing while testing: the default strategy is markdown and
--strategyis per-invocation, never persisted on the source — drop the flag and the same command reportsstrategy=markdownand a handful of files.Scope
Two lines of behaviour change, gated on
args.mode === "full", so incremental runs are untouched and stay fast.--yesbecause this is spawned non-interactively and a full walk otherwise prompts to confirm import cost. The failuresummarynow echoes the real argv instead of a hardcoded string that could disagree with what ran.Verified: file parses under
bun build; an incremental--dry-runconfirms the walk does not gain--full; a--fullrun performs the discovery pass and imports the previously-missing files.🤖 Generated with Claude Code