Repository navigation
Rebuild the decision snapshot from the merged log when two machines' syncs conflict (#4174) - #4220
Merged
Merged
Conversation
…syncs conflict (#4174) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
The jsonl-append merge driver takes the union of base, ours and theirs, so a log that lost lines on one side (--compact expunging a redacted decision) would get them back. The snapshot rebuild now runs only when every base line of the log is still on both sides; otherwise the merge aborts as before. A conflicted snapshot when local edits are put back after the merge is now rebuilt from the working-tree log instead of left at the merged version. Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Rebuilding a conflicted decision snapshot after stash pop made a decision that another machine redacted and compacted away consistent and publishable, because stash pop merges the log as a union. Without the rebuild the mismatched log and snapshot stay held, as on main. The redaction guard on the merge-retry rebuild stays. A new test shows the brought-back decision stays held and never reaches the remote. Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/adversarial-native#1 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
1 task done
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.
Two machines that each log a decision between pushes no longer stop one of them from syncing, so gbrain-sync keeps every machine's decision memory in step without a hand repair.
What changed
Before, the second machine's push was rejected, its fetch-and-merge retry conflicted on
projects/<slug>/decisions.active.json, andgstack-brain-syncaborted the merge and wrotepush_failedon every later drain until someone repaired the clone by hand. Now the merge finishes and the push goes out, with a snapshot rebuilt from the mergeddecisions.jsonl.bin/gstack-brain-sync: when a stopped retry merge's only conflicts areprojects/*/decisions.active.jsonfiles whosedecisions.jsonlmerged cleanly, each snapshot is rebuilt from the merged log, staged, and the merge is committed. The rebuild runs only when every line of the log at the merge base is still on both sides. The log merge driver takes the union of both sides, so a log that lost lines on one side (--compactexpunging a redacted decision) would get them back; that merge aborts as before. A conflict in any other file, a log that did not merge cleanly, a missing bun or a failed rebuild also still aborts.bin/gstack-decision-log --rebuild-snapshot <project-slug>: rewrites one project's snapshot from its log with the samerebuildSnapshotevery decision write uses. It refuses an empty slug, a path,./.., or a project with no log.bin/gstack-artifacts-init: new repositories getprojects/*/decisions.active.json merge=binaryin.gitattributes, so a merge run by hand leaves no conflict markers in the snapshot. The brain-sync fix does not depend on this line.docs/gbrain-sync.mdsays how the snapshot is resolved, when brain-sync still aborts, and how to finish a hand-run merge.Why
"Two machines' syncs conflict and one of them stays push_failed for good" (#4174). The snapshot is derived from the event log, and the log already merges through the jsonl-append driver, so rebuilding from the merged log is the one correct resolution, as long as neither side deleted log lines.
Blast radius
Only brain-sync's retry merge after a rejected push, and only when every conflict is a decision snapshot. The stash recovery path after that merge is unchanged from main, so a mismatched log and snapshot there stay held by the decisions-active coupled-group check (tested). A clone whose peer ran
--compactsince they last agreed still aborts, as on main.Test Coverage
test/brain-sync.test.ts, the brain-sync: a derived decisions.active.json conflicts in the retry merge and stops a machine from publishing #4174 block, 6 tests: two machines each log a decision (current and pre-fix.gitattributes), a clone already holding a conflicting commit recovers, a merge that would bring back a redacted and compacted decision still aborts, a decision log that stash pop brings back with an expunged decision stays held and never reaches the remote, and a conflict in another file still aborts.push_failedandCONFLICT (content): Merge conflict in projects/acme-app/decisions.active.json. The redaction test was red without its guard (statusok, expectedpush_failed). The hold test was red with the reverted stash-pop rebuild put back (statusok).test/gstack-decision-bins.test.tscovers--rebuild-snapshotand its refusals; all 26 green.Pre-Landing Review
Pre-Landing Review: 3 blocking found across 2 full passes and 1 fix-check, all fixed; 4 noted, 0 deferred.
--compactrebuilt the snapshot from the union log and republished a redacted decision. Fixed by the base-line guard.Gate edits: none detected (2 listed, 0 read).
Exploratory QA
Smoke only through the failing-first repro tests above; the QA method sections were not run.
Documentation
Scope: I audited the 7 selected files in the candidate (base 324135d, head fa75630, 4 commits, with nothing staged, unstaged or untracked) against reviewed tree 68807149491999a53fd125c0207a11ffdb9640ff.
Result: The docs are current, and I made no edits.
docs/gbrain-sync.mdalready describes the snapshot rebuild, the exception for logs that lost lines, themerge=binaryattribute and the manual--rebuild-snapshotrecovery. All of it matchesbin/gstack-brain-sync,bin/gstack-decision-logandbin/gstack-artifacts-init. The banned-terms check found nothing, and there are no blockers.Debt: The new
--rebuild-snapshotflag is documented only in the CLI usage text and indocs/gbrain-sync.md. The decision-log CLI has no reference doc.Test plan
bun test test/brain-sync.test.ts -t 4174: all 6 greenbun test test/gstack-decision-bins.test.ts: all 26 greenIssues
Refs #4174
Agent notes
Lane GSTA-445 for GStack Minder. Decision trail: reports/GSTA-445-decisions.tsv in the Captain drive.
Approvals
Approved: yes (record r-26365ae18dad). The full approval record stays private.
Plan: exempt: bug fix
REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=4 fixed=4 scope=frozen ledgers_read=3 fix_checks=1 dispatches=4
Agent notes