Harden brain pipeline: index.lock sweep, gbq exit code, lessons append-order#7
Merged
Merged
Conversation
…ns append-order) - nightly: sweep an orphan .git/index.lock before commit. A crashed git leaves it behind; the vault then never commits and 'gbrain sync' stalls on "No commits in repo", silently freezing the index (root-caused after a 17-day freeze). Only removed when no git runs in the repo and the lock is >5 min old. - gbq: propagate gbrain's real exit code instead of the trailing lock-sweep test's (false — hence exit 1 — whenever there is no stale lock, breaking 'gbq sync && ...'). - correction-detector: spell out the append order (chronological, newest at the bottom, never at the top) so tail-injection re-reads recent lessons and the file doesn't split into two regions.
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.
Three fixes to the brain maintenance pipeline, root-caused while debugging a vault whose semantic index had silently frozen for 17 days.
1. nightly — sweep orphan
.git/index.lockA crashed
gitleaves.git/index.lockbehind. The vault then can't commit, andgbrain sync(git-diff based) aborts on "No commits in repo" → the index freezes, unnoticed. The nightly already sweeps the PGLite.gbrain-lockbut not git's. Addedsweep_git_lock()— removes the lock only when no git runs in the repo and it's >5 min old (a fresh one may be a legit concurrent commit).2. gbq — propagate gbrain's real exit code
gbq's last statement is the stale-lock test[ -d "$LOCK" ], which is false (→ exit 1) whenever there's nothing to sweep. Sogbq syncsucceeded but returned 1, breakinggbq sync && …. Now captures gbrain's RC (wait/intentional-kill) andexit $RC.3. correction-detector — spell out append order
The reminder didn't state where to write. Paired with a tail-injection that reads the end of the file, ambiguity let agents write at the top → lessons.md split into two regions and the tail re-read only stale entries. Now explicit: chronological, newest at the bottom, never at the top.
All three verified locally (parse + functional tests).