Repository navigation
fix(#952,#953): close three reconcile regressions, 3-state rebase check - #962
Merged
Merged
Conversation
hooks.d/after_save/60-git-reconcile.sh: - #952 item 1: pass --no-autostash on every git rebase call -- without it, a dirty tracked write from another slug sharing REPO_ROOT gets silently autostashed when the rebase starts, and rebase --quit (unlike --abort) never re-applies the stash. The rebase now refuses to start while that write is present, with no stash created. - #952 item 2: the scoped abort restore no longer assumes every commit a rebase could replay is confined to $SLUG/ -- a shared REPO_ROOT's ahead/behind commit set can span other slugs too. The restore scope is now computed before the rebase starts, as the union of this run's own ahead commits and the remote's behind commits diffed against their merge-base, and covers every one of those paths on abort. - #952 item 3: before rebase --quit discards it, read git's own record of which branch the rebase started from (rebase-merge/head-name). When it differs from the configured branch, refuse the symbolic-ref switch and report the mismatch instead of silently moving HEAD. - #953: _grc_rebase_in_progress now returns a distinct could-not-tell state (rc=2) when the underlying git rev-parse --git-path check itself fails, rather than collapsing that into "not in progress". All 5 call sites branch on the 3-state result explicitly. tests/test_git_reconcile_903.py: regression tests for all of the above, 23/23 passing. Split out of the original combined #951/#952/#953 PR (#960) by the maintainer: #951's fix (Windows-only, test-only) is done and verified and was shipped separately in #961; this PR carries the still-open #952/#953 investigation, which continues to fail on macOS CI only (not locally reproducible so far -- see trap.d/951.pr960-macos-reconcile-903-not-reproducible-locally.md and the open comment on #952 documenting the same). Closes #952 Closes #953 Co-Authored-By: Claude Sonnet 5 <[email protected]>
60-git-reconcile.sh's scoped-abort restore (#952/#953) used `mapfile` to populate _GRC_TOUCHED_PATHS and _grc_existing. mapfile is a bash 4.0+ builtin, absent from this repo's documented floor (bash 3.2, stock macOS /bin/bash) -- exactly what GitHub Actions' macos-latest runner resolves plain `bash` to. There it fails as "command not found", silently leaving both arrays empty, so the scoped checkout/prune restored nothing: a real conflict left the file with merge markers, another slug's upstream-only change was never restored, and no notice or log was written -- the six macOS CI failures on PR #962. Reproduced directly against this machine's own stock /bin/bash 3.2.57 (identical interpreter to the CI runner's), both via a minimal mapfile probe and by running the hook's own conflict-abort scenario end to end; confirmed red before the fix (6 failed under a PATH forcing `bash` to resolve to the floor interpreter, matching CI exactly) and green after. Replaced each mapfile call with a while-IFS=-read loop into the array, which works on every bash version this repo supports. Adds a static guard (tests/test_git_reconcile_mapfile_floor_952.py) so no shipped shell script reintroduces mapfile/readarray, plus the same floor-bash behavioural reproduction as a regression test. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Two independent reviewers (a general diff review and oss:auditor) flagged
the same gap in test_git_reconcile_mapfile_floor_952.py's regex-based
static guard: it only recognised `mapfile`/`readarray` preceded by
`;`/`&`/`|`/`(`/`then`/`do`, missing real shell command-start shapes such
as `else mapfile ...`, `elif mapfile ...`, a `case` branch (`pat) mapfile
...`), or a brace-group (`{ mapfile ...; }`). None of the current shipped
shell happens to use those shapes, so the guard's current "clean" verdict
was still correct, but a future mapfile call written in one of them would
have passed silently. Widened the anchor set and added a positive-control
assertion for each of the four missing shapes; also reworded one
docstring line a reviewer found referred to an import that does not
exist (the win32 skip is a local re-declaration, not an import, matching
the row this file's own docs/windows-skip-triage.md entry already
describes correctly).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
fdaviddpt
added a commit
that referenced
this pull request
Oct 7, 2026
…the pre-quit snapshot (#968) * fix(#966): scope the conflict-abort restore to paths unchanged since the pre-quit snapshot `_grc_report_conflict` in `hooks.d/after_save/60-git-reconcile.sh` (since d431fb2, #952/#962) restores every path touched by this run's own commits and the remote's commits since their common base, not scoped to `$SLUG/` as #943 originally promised. `git checkout HEAD --` and `git rm -f` ran over that whole set unconditionally, with only this slug's own consolidation lock held -- not another slug's. A different slug writing a tracked file the remote side also changed, in the TOCTOU window while this slug's `git rebase --quit` runs, was silently discarded, while the hook still logged "aborted, the tree is unchanged". `git rebase --quit` touches neither the working tree, the index, nor HEAD (git-rebase(1)) -- it only drops the rebase-merge/rebase-apply state directory. So a content snapshot of every touched path taken immediately before that call, compared against the same paths right before the restore runs, can only ever differ because something else wrote to one of them in between. The restore now only acts on the subset whose content still matches that snapshot; a path that changed is left exactly as the concurrent write put it, which the existing `_grc_foreign_changes` porcelain scan already reports correctly once that write is no longer clobbered. New regression test test_write_in_the_toctou_window_inside_the_restore_set_survives_the_abort puts the foreign path INSIDE the restore set (the remote side's own commit also touches it), unlike the existing TOCTOU test which only covers a foreign path outside it -- confirmed red against current main, green after the fix. The sibling tests in TestScopedAbort (positive control: a normal scoped abort with no race) and the rest of test_git_reconcile_903.py (24/24) still pass unchanged. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(#966): self-review follow-up: HASH-ERROR sentinel, scope the race claim, log residual gap Self-review (Explore + oss:auditor spawns) on the previous commit found: - A could-not-hash sentinel ("HASH-ERROR") compared equal to itself was being treated as "content provably unchanged", so a path whose `git hash-object` failed identically before and after `rebase --quit` (e.g. a static permission/IO problem) would still be restored instead of being treated as unverifiable and left alone. Fixed: either side reading HASH-ERROR now excludes the path from the safe set. - The code comment and changelog fragment overclaimed the guarantee -- "can only ever differ because of something else writing ... in between" is only true for the window from immediately-before `rebase --quit` through the restore, not for the whole function or the rebase attempt that precedes it. Reworded both to say what is actually covered, and logged the un-closed, wider window (plus a second, much narrower gap between each path's own hash check and its own checkout/rm) to trap.d/966.residual-race.md for /oss:curate to weigh, rather than silently shipping a broader claim than the fix delivers. Re-verified: bash -n clean, python3 .oss/assemble_changelog.py --check passes (11 fragments, all parse), tests/test_git_reconcile_903.py 24/24 still green. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
Split out of the original combined #951/#952/#953 PR (#960) by the maintainer: #951's fix was Windows-only, test-only, verified working, and has already shipped separately in #961. This PR carries the remaining #952/#953 work, which closes three regressions in the git-reconcile conflict handling plus a 3-state rebase-in-progress check.
--no-autostashon everygit rebasecall -- without it, a dirty tracked write from another slug sharingREPO_ROOTgets silently autostashed when the rebase starts, andrebase --quit(unlike--abort) never re-applies the stash. The rebase now refuses to start while that write is present, with no stash created.$SLUG/-- a sharedREPO_ROOT's ahead/behind commit set can span other slugs too. The restore scope is now computed before the rebase starts, as the union of this run's own ahead commits and the remote's behind commits diffed against their merge-base, and covers every one of those paths on abort.rebase --quitdiscards it, read git's own record of which branch the rebase started from (rebase-merge/head-name). When it differs from the configured branch, refuse the symbolic-ref switch and report the mismatch instead of silently moving HEAD._grc_rebase_in_progressnow returns a distinct could-not-tell state (rc=2) when the underlyinggit rev-parse --git-pathcheck itself fails, rather than collapsing that into "not in progress". All 5 call sites branch on the 3-state result explicitly.tests/test_git_reconcile_903.py: regression tests for all of the above, 23/23 passing locally.Known open problem: macOS CI
This bundle is still failing on macos-latest CI across all 4 Python versions, in the same test file, with the conflict-restore and NDC-generation-bump test classes (and one fixture-assumption guard) failing -- not reproducible locally despite multiple runs (23/23 passing every time, including by a second independent investigating agent). See
trap.d/951.pr960-macos-reconcile-903-not-reproducible-locally.mdand the comment already posted on #952 documenting this. This PR is not ready to merge until that is resolved -- opening it now mainly to detach the already-fixed #951 from this still-open investigation, not to signal readiness.Closes #952
Closes #953
🤖 Generated with Claude Code
[AI-generated]