Skip to content

fix: scope /sync-gbrain's forced dream cycle to resolve_symbol_edges - #2783

Open
liutiming wants to merge 3 commits into
garrytan:mainfrom
liutiming:codex/gbrain-dream-phase-scope
Open

fix: scope /sync-gbrain's forced dream cycle to resolve_symbol_edges#2783
liutiming wants to merge 3 commits into
garrytan:mainfrom
liutiming:codex/gbrain-dream-phase-scope

Conversation

@liutiming

@liutiming liutiming commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • gstack-gbrain-sync --dream (and --full's auto-dream) was invoking gbrain's full multi-phase overnight maintenance cycle (extract_atoms, synthesize, drift, skillopt, ...) when this stage only needs resolve_symbol_edges — the phase that actually builds the call graph consumed by gbrain code-callers/code-callees.
  • Pins gbrain dream --phase resolve_symbol_edges on both the source-scoped invocation and the no-source fallback (verified empirically that --source and --phase compose independently in gbrain's arg parser).
  • Updates the --dry-run preview text and --help docs to match.
  • Adds three argv-recording tests against a fake gbrain binary with a strict command allowlist that fails the test if any unscoped dream invocation (bare dream, or dream --source <id> without --phase) is ever spawned — the source-scoped --dream path, the no-source-id fallback, and (added in review follow-up) the --full auto-chain path (cycle never built -> runDream), which is the OTHER trigger for this spawn and wasn't covered by the first two.
  • Regenerated sync-gbrain/SKILL.md from sync-gbrain/SKILL.md.tmpl (added in review follow-up) — the skill docs previously described the dream cycle as bare gbrain dream --source <id>, pre-dating this fix; the --full, --dream, and D2-prompt prose now name the pinned --phase resolve_symbol_edges invocation.
  • No new memory-consolidation engine is introduced; this only narrows which phase of gbrain's existing dream cycle we invoke.

Evidence

  • bun test test/gstack-gbrain-sync.test.ts test/gbrain-dream-stage.test.ts test/gbrain-cycle-completed.test.ts test/gbrain-sync-skip.test.ts — 87 pass / 0 fail (real bun footer, not truncated).
  • bun test test/catalog-budget.test.ts test/context-budget-ratchet.test.ts test/gen-skill-docs.test.ts — 427 pass / 0 fail (skill-doc regeneration mechanism + budget ratchets, since this PR touches a .tmpl + generated SKILL.md pair).
  • bun run gen:skill-docs — regenerated sync-gbrain/SKILL.md from the edited .tmpl; git status shows only the two intended files changed, no stray drift.
  • test/e2e-tier-alignment.test.ts — unaffected, 3 pass.

Disclosure: unrelated full-suite red in this environment

A full bun run test pass in this shared dev box surfaced pre-existing failures in unrelated areas (repo-mode slug caching, gstack-learnings-search, alias-install byte-parity, skill-census) — none of these touch gbrain-sync, dream, or any file this PR changes. One contributing factor: this dev checkout has .claude/skills/gstack symlinked live back to the working tree (per CLAUDE.md's "Dev symlink awareness" section), so a full test run's own skill-doc regeneration mutated all SKILL.md files in place mid-run (prefix flipped) before I reverted that side effect — that alone explains the skill-census/alias-parity failures. I did not attempt to fix any of this; it's out of scope for this change and flagged here per the "don't claim unrelated without proof" project convention. The targeted test runs above are clean and used real bun summary footers.

Test plan

  • bun test test/gstack-gbrain-sync.test.ts test/gbrain-dream-stage.test.ts test/gbrain-cycle-completed.test.ts test/gbrain-sync-skip.test.ts
  • bun test test/catalog-budget.test.ts test/context-budget-ratchet.test.ts test/gen-skill-docs.test.ts
  • bun run gen:skill-docs (regenerated SKILL.md, verified no stray diffs)
  • CI (fork PR — gate-tier eval jobs will show empty-env auth failures per this repo's fork-PR convention; free-tests workflow should still run)

🤖 Generated with Claude Code

`gbrain dream --dream` (and --full's auto-dream) invoked the full
multi-phase overnight maintenance cycle (extract_atoms, synthesize,
drift, skillopt, ...) when all this stage actually needs is the
resolve_symbol_edges phase that builds the call graph
(code-callers/code-callees). That's minutes of unnecessary work on
every forced/auto dream and effectively bolts a second maintenance
engine onto gbrain's own `autopilot`, which already owns full-cycle
scheduling.

Pin `gbrain dream --phase resolve_symbol_edges` on both the
source-scoped invocation and the no-source fallback (verified against
gbrain's own arg parser that --source and --phase compose
independently). Updates the dry-run preview text and --help docs to
match, and adds argv-recording tests against a fake gbrain binary
whose strict allowlist fails the test if any full-cycle `dream`
invocation (bare `dream`, or `dream --source <id>` without --phase)
is ever spawned.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKBKETdxHdkM83Maw1JFeo
@trunk-io

trunk-io Bot commented Sep 2, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

liutiming and others added 2 commits September 2, 2026 16:27
The two existing #2860-class argv tests only exercised the explicit
--dream flag. Add a third exercising the --full auto-chain path (cycle
never built -> runDream), with a strict-allowlist fake gbrain that
fails on any dream invocation missing --phase resolve_symbol_edges.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018px2ZBEeBDAGyzqwme4Dxp
sync-gbrain/SKILL.md.tmpl still described the dream cycle as bare
`gbrain dream --source <id>`, pre-dating the phase-scoping fix. Update
the --full, --dream, and D2-prompt prose to name the pinned
--phase resolve_symbol_edges invocation, and regenerate SKILL.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018px2ZBEeBDAGyzqwme4Dxp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant