fix(sync-gbrain): gate code-search guidance on real page_count, not the markdown capability check (#1844)#1850
Conversation
…he markdown capability check (garrytan#1844) On a markdown-only brain (no registered code source), /sync-gbrain Step 4 wrote the `## GBrain Search Guidance` block claiming working `.gbrain-source` pins and `code-def`/`code-refs`/`code-callers` symbol search. None of that resolves — the code source never registered (and structurally can't, when its path overlaps the `default` markdown source). The block then instructs the agent to use tools that return nothing, and silently overwrites any hand-corrected version on every run. Root cause: Step 4 gated the code-search template on the *markdown* capability round-trip (`CAPABILITY_OK`), which only proves `put`/`search`/`delete` work — nothing about symbol search. Step 3 already computes the code source page_count but only used it to prompt for a `--full` reindex. - Compute the cwd source's `CODE_PAGES` in Step 4's check and branch on it: `CAPABILITY_OK=1 AND CODE_PAGES>0` → full code+memory block (unchanged); `CAPABILITY_OK=1 AND CODE_PAGES==0/empty` → new markdown-only block that advertises semantic/keyword search + `~/.gstack/` memory and routes all code-symbol questions to Grep (no false `.gbrain-source`/`code-def` claims); `CAPABILITY_OK=0` → remove block (unchanged). - Drop stale `gbrain autopilot --install` guidance: the command is gone in gbrain 0.42.x, and on pglite a background sync daemon can't coexist with an always-on MCP `gbrain serve`. The `/sync-gbrain`-after-changes guidance and the still-valid `sources add --path` safety note remain. Edited the source-of-truth `SKILL.md.tmpl`; regenerated `SKILL.md` via `bun run gen:skill-docs` (idempotent — re-run is a no-op). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
❌ This pull request has been removed from the merge queue because required statuses are not defined in
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 |
|
Independently reviewed against current Confirmed the bug on One thing worth calling out as correct, not a smell: the PR recomputes Both |
|
/trunk merge |
|
These look ready from my side — the branch is clean/mergeable and an independent review confirmed the fix is correct and complete. The only red check is the Trunk merge-queue gate, which from what I can tell just needs a maintainer to enqueue it (no code/test failure). @garrytan whenever you have a moment, could these be added to the merge queue? Happy to rebase if anything is needed. Thanks! |
Summary
On a markdown-only brain (a standard
/setup-gbrainoutcome — the repo path registered as the markdowndefaultsource, no code source),/sync-gbrainStep 4 writes the## GBrain Search Guidanceblock into CLAUDE.md claiming working.gbrain-sourcepins andcode-def/code-refs/code-callerssymbol search. None of that resolves: the code source never registered (and structurally can't — it overlaps thedefaultmarkdown source at the same path, which gbrain rejects). The agent is then told to use tools that return nothing, and the block silently overwrites any hand-corrected version on every run.Closes #1844.
Root cause
Step 4 gated the code-search template on the markdown capability round-trip (
CAPABILITY_OK) — aput/search/deletecheck that says nothing about symbol search. Step 3 already computes the code source'spage_countbut only used it to prompt for a--fullreindex; it never fed the Step 4 branch. Sopage_count=0still produced full code-search guidance.What this changes (
sync-gbrain/SKILL.md.tmpl, the source of truth)Gate on the real code corpus. Step 4's capability check now also computes the cwd source's
CODE_PAGES(reusing Step 3's exact query) and branches on it:CAPABILITY_OK=1ANDCODE_PAGES > 0→ the existing full code + memory block.CAPABILITY_OK=1ANDCODE_PAGESis0/empty → a new markdown-only block: advertises semantic/keyword search +~/.gstack/curated memory, and explicitly routes all code-symbol questions to Grep — no false.gbrain-source/code-def/code-refs/code-callersclaims.CAPABILITY_OK=0→ remove the block (unchanged).Drop stale
gbrain autopilot --installguidance. That command is gone in gbrain 0.42.x (replaced bysync --watch/sync --install-cron), and on pglite (single-writer) a background sync daemon can't coexist with an always-on MCPgbrain serve. The/sync-gbrain-after-changes guidance and the still-validsources add --pathsafety note remain.Verification
SKILL.md.tmpl; regeneratedSKILL.mdwithbun run gen:skill-docs. The diff is confined to the twosync-gbrainfiles, and regeneration is idempotent (a second run is a no-op).bash -n.gen-skill-docs,gen-skill-docs-idempotency,gstack-gbrain-sync,no-stale-gstack-brain-refs,audit-compliance,section-manifest-consistency,preamble-compose— 453 tests, 0 fail.🤖 Generated with Claude Code