fix(gbrain-sync): add .gbrain-source to consumer repo .gitignore#1521
Open
genisis0x wants to merge 1 commit into
Open
fix(gbrain-sync): add .gbrain-source to consumer repo .gitignore#1521genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
…rytan#1384) The v1.29.0.0 changelog promised .gbrain-source would be added to the consuming repo's .gitignore so the per-worktree pin stays local, but the change actually only added it to gstack's own .gitignore. Without the consumer-side entry, the pin gets committed and Conductor sibling worktrees of the same repo + branch step on each other's pin every time anyone commits. Add ensureGbrainSourceGitignored after a successful gbrain sources attach in runCodeImport. Idempotent on repeat runs (line-trim match), creates .gitignore if missing, logs a warning and continues on permission errors so a read-only checkout doesn't fail the sync. Gate the top-level main() call behind import.meta.main so tests can import the helper without triggering a full sync run on module load. Tests in test/gbrain-source-gitignore.test.ts cover: create-when-missing, append-without-trailing-newline, append-with-trailing-newline, idempotent on repeat, recognize whitespace-surrounded entry, no-throw on read-only file. 6 pass.
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.
Summary
Closes #1384.
The v1.29.0.0 changelog claimed
.gbrain-sourcewas added to.gitignoreso per-worktree pin doesn't leak across branches. The change actually shipped only added.gbrain-sourceto gstack's own.gitignore, not the consuming repo's. Conductor sibling worktrees of the same repo + branch end up clobbering each other's pin every time anyone commits the file.Add the missing append in
bin/gstack-gbrain-sync.ts::runCodeImport, right aftergbrain sources attach <id>succeeds. The newensureGbrainSourceGitignoredhelper is:.gitignoreis created; unwritable file logs a warning and lets the rest of the sync continue. The pin failure mode is "noisy commits", not "broken sync", so we don't want to fail the whole stage.Why this matters more for Conductor users
Single-worktree users mostly don't notice — the pin tracks the only checkout, so even if committed it points at the right source. Conductor users running
/sync-gbrainin two sibling worktrees of the same repo + branch get different path-hash source IDs (correct, per v1.29.0.0). If either pin gets committed,git pullin the sibling overwrites the local pin and routes queries to the wrong worktree's source. The v1.29.0.0 changelog claimed to prevent exactly this.Verification
Six covered scenarios:
.gitignorewith the pin entry when none exists.gitignorewithout trailing newline (preserves\ndiscipline).gitignorewith trailing newline (no double newline).gitignoreis read-onlyExisting
test/gstack-gbrain-sync.test.tswas already failing in 10/20 cases on machines without a localgbrainCLI on PATH (unrelated to this PR). Pre-change baseline = post-change baseline for those.Non-changes
import.meta.maingate on the top-levelmain().catch(...)call is a small piggyback so the test file canimport { ensureGbrainSourceGitignored }without triggering a full sync run on module load. Behaviorally a no-op for the CLI path —bun bin/gstack-gbrain-sync.tsstill runsmain()because the module IS the entry there.runMemoryIngest,runBrainSync, and the dry-run path are untouched.detachpath — issue notes the gitignore entry is harmless to leave behind.No newsfragment added per
CLAUDE.md("Contributor PR authors should not edit CHANGELOG.md; maintainer/AI adds entries during landing/merge").