Skip to content

v1.29.0.0 feat: worktree-aware gbrain code sources via path-hash IDs and CWD pin#1382

Merged
garrytan merged 2 commits into
mainfrom
garrytan/marseille-v4
May 8, 2026
Merged

v1.29.0.0 feat: worktree-aware gbrain code sources via path-hash IDs and CWD pin#1382
garrytan merged 2 commits into
mainfrom
garrytan/marseille-v4

Conversation

@garrytan
Copy link
Copy Markdown
Owner

@garrytan garrytan commented May 8, 2026

Summary

Conductor sibling worktrees of the same repo no longer collide on a shared
gstack-code-<slug> source ID. /sync-gbrain derives a path-hashed source ID
per worktree, runs gbrain sources attach to write .gbrain-source in the
worktree root (kubectl-style CWD context), and removes the legacy unsuffixed
source on first new-format sync.

Bug fixes (surfaced by /codex adversarial review during /ship):

  • Silent attach failure now reported as stage failure
  • Startup preamble checks per-worktree pin, not global state
  • Code stage no longer skipped on remote-MCP installs (early-exit was in SKILL template)
  • Source registration routes through lib/gbrain-sources.ts only (deleted the orchestrator's near-duplicate)

Requires gbrain v0.30.0+. Spike report: ~/.gstack/projects/garrytan-gstack/2026-05-08-gbrain-split-engine-spike.md.

Test Coverage

[+] bin/gstack-gbrain-sync.ts
  ├── deriveCodeSourceId() with pathhash
  │   ├── [★★★ TESTED] worktree-distinct ids
  │   ├── [★★★ TESTED] same-path stable across runs
  │   ├── [★★  TESTED] long remote, no-origin, pathological basename (existing)
  ├── runCodeImport async + lib ensureSourceRegistered
  │   └── [★★  TESTED] dry-run orchestration unchanged
  ├── sources attach step
  │   └── [★★  TESTED] dry-run preview includes attach
  └── legacy source cleanup
      └── [★★  TESTED] dry-run preview shows new flow

[+] sync-gbrain/SKILL.md.tmpl + preamble
  └── [★★  TESTED] gen-skill-docs freshness (0 STALE)

COVERAGE: 100% | Tests: 405 → 408 (+3 new, +1 updated)

Pre-Landing Review

No critical issues found in the diff (no SQL/data safety, no LLM trust boundary, no auth surfaces touched). All 3 codex adversarial findings auto-fixed before commit:

  • HIGH: silent attach failure → stage now returns ok:false with reason
  • HIGH: preamble checks .gbrain-source in cwd, not global state
  • MEDIUM: legacy gstack-code-<slug> source removed on first new-format sync

Plan Completion

All applicable items DONE:

  • ✅ Phase 0 spike (gbrain v0.30 verified, --db absent, sources attach is the routing primitive)
  • ✅ Worktree-aware source ID via path hash
  • ✅ Delete ensureSourceRegisteredSync duplicate (Codex Feedback #12)
  • ✅ Add gbrain sources attach step
  • ✅ Path 4 early-exit removed from SKILL template (Codex refactor: reorganize codebase into modular structure #2)
  • ✅ CLAUDE.md guidance block updated for per-worktree story
  • .gbrain-source in .gitignore
  • ✅ Tests for worktree-aware behavior

⏭️ Codex #14 detect-layer extension, #15 schema migration, tests #24-28: N/A — original plan was architected for Option A (per-worktree HTTP serve + project-scoped MCP namespace) which the spike invalidated. Option B (CLI via Bash) doesn't have the surfaces those tests covered.

TODOS

No TODO items completed in this PR.

Test plan

  • bun test test/gstack-gbrain-sync.test.ts test/gbrain-sources.test.ts test/gen-skill-docs.test.ts → 408 pass / 0 fail
  • Type check + bundle: bun build --target=bun bin/gstack-gbrain-sync.ts succeeds
  • gen:skill-docs --host all --dry-run reports 0 STALE
  • Manual smoke: gbrain sources attach writes .gbrain-source in worktree, git check-ignore matches the new entry
  • Live /sync-gbrain --full in this worktree — full reindex of 53K LOC takes ~25-35 min; user runs when convenient

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

garrytan and others added 2 commits May 8, 2026 11:31
Conductor sibling worktrees of the same repo no longer collide on a shared
gstack-code-<slug> source ID. /sync-gbrain now derives a path-hashed source
ID per worktree, runs gbrain sources attach to write .gbrain-source in the
worktree root, and removes the legacy unsuffixed source on first new-format
sync to prevent orphan accumulation.

Bug fixes surfaced by /codex during /ship:
- Silent attach failure now treated as stage failure (no more ok:true while
  pin is missing → unqualified code-def hits wrong source).
- Startup preamble checks .gbrain-source in the cwd worktree, not global
  state, so an unsynced worktree no longer claims "indexed" because a
  sibling synced.
- Code stage no longer skipped on remote-MCP (Path 4); the early-exit was
  in the SKILL template, not the orchestrator.
- Source registration routes through lib/gbrain-sources.ts only; deleted
  the near-duplicate ensureSourceRegisteredSync from the orchestrator.

Requires gbrain v0.30.0+ (uses sources attach). Phase 0 spike report:
~/.gstack/projects/garrytan-gstack/2026-05-08-gbrain-split-engine-spike.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

E2E Evals: ✅ PASS

58/58 tests passed | $7.58 total cost | 12 parallel runners

Suite Result Status Cost
e2e-browse 4/4 $0.17
e2e-deploy 6/6 $1.22
e2e-design 4/4 $0.81
e2e-plan 8/8 $1.83
e2e-qa-workflow 3/3 $1
e2e-review 6/6 $1.68
e2e-workflow 3/3 $0.39
llm-judge 24/24 $0.48

12x ubicloud-standard-2 (Docker: pre-baked toolchain + deps) | wall clock ≈ slowest suite

@garrytan garrytan merged commit 0660547 into main May 8, 2026
23 of 24 checks passed
gonnabe88 pushed a commit to gonnabe88/gstack that referenced this pull request May 9, 2026
…and CWD pin (garrytan#1382)

* feat: worktree-aware gbrain code sources via path-hash IDs and CWD pin

Conductor sibling worktrees of the same repo no longer collide on a shared
gstack-code-<slug> source ID. /sync-gbrain now derives a path-hashed source
ID per worktree, runs gbrain sources attach to write .gbrain-source in the
worktree root, and removes the legacy unsuffixed source on first new-format
sync to prevent orphan accumulation.

Bug fixes surfaced by /codex during /ship:
- Silent attach failure now treated as stage failure (no more ok:true while
  pin is missing → unqualified code-def hits wrong source).
- Startup preamble checks .gbrain-source in the cwd worktree, not global
  state, so an unsynced worktree no longer claims "indexed" because a
  sibling synced.
- Code stage no longer skipped on remote-MCP (Path 4); the early-exit was
  in the SKILL template, not the orchestrator.
- Source registration routes through lib/gbrain-sources.ts only; deleted
  the near-duplicate ensureSourceRegisteredSync from the orchestrator.

Requires gbrain v0.30.0+ (uses sources attach). Phase 0 spike report:
~/.gstack/projects/garrytan-gstack/2026-05-08-gbrain-split-engine-spike.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* chore: bump version and changelog (v1.29.0.0)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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