Skip to content

fix(#976): stop the reconcile kill switch's two deferred side effects - #979

Merged
fdaviddpt merged 2 commits into
mainfrom
fix-976-reconcile-side-effects
Oct 8, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix-976-reconcile-side-effects

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #976.

The v0.42.1 hard-disable of hooks.d/after_save/60-git-reconcile.sh (#969/#970) landed the kill switch itself, but left two downstream effects unaddressed, both logged as trap.d fragments during #969's own self-review.

1. The kill-switch notice polluted hook-errors.log for every user, every save. The report_error "disabled pending #969" call ran unconditionally, before the git_reconcile.enabled config read, so it fired for the default-disabled majority who never opted into reconcile at all -- permanently tripping /remember:doctor's "Recent errors" WARN. Fixed by moving the config read above the kill switch and gating only the report_error call on it; the exit 0 immediately after stays unconditional and outside that if-block, so the hard-disable's own guarantee never depends on a config read succeeding.

2. Stale prose promised automatic resolution that cannot happen. 50-git-backup.sh, 50-git-restore.sh, and scripts/user-prompt-hook.sh's internal doc comments still said that when git_reconcile.enabled=true, the next 60-git-reconcile.sh run "may fetch/rebase and push this automatically" -- false, since that hook now exits before ever reading the flag. Rewrote the true-branch prose in all three to say the hook is hard-disabled pending #969, so nothing resolves automatically right now; the disabled/default-off branch is unchanged.

Follow-up commit fixes the same stale 'it exits before reading git_reconcile.enabled' phrasing in the test suite's own comments/skip-reasons (found by self-review), swept across both affected test files.

Tests

  • New tests/test_git_reconcile_903.py::TestTheKillSwitchNoticeRespectsTheFlag: confirmed RED (disabled user still got a hook-errors.log entry) before the fix, GREEN after.
  • Rewrote the backup/restore notice test classes to assert the old 'may fetch, rebase and push' string is gone and '969' is present when git_reconcile.enabled=true, keeping the disabled-reconcile case as an unchanged positive control. RED before, GREEN after in both files.
  • Targeted suite after both commits: 98 passed, 23 skipped (all pre-existing skips, now with corrected prose). Full pytest not run (not required for this scope); CI covers the matrix.

Docs

README.md carries no git_reconcile/hook-errors references; no change needed (checked by grep).

Co-Authored-By: Claude Sonnet 5 [email protected]

[AI-generated]

fdaviddpt and others added 2 commits October 8, 2026 01:59
#969 hard-disabled 60-git-reconcile.sh but left two things unaddressed,
both logged as trap.d fragments during that lane's own self-review:

1. The kill-switch notice (report_error "disabled pending #969"...) ran
   unconditionally, before the git_reconcile.enabled read, so it reached
   hook-errors.log on every save for every installed user -- including the
   default-disabled majority who never opted into reconcile. That
   permanently tripped /remember:doctor's "Recent errors" WARN. The read
   now happens first and gates the notice only; the exit itself stays
   unconditional either way, so the kill switch's own guarantee never
   depends on a config read succeeding.

2. 50-git-backup.sh and 50-git-restore.sh still promised, when
   git_reconcile.enabled=true, that "the next after_save run
   (60-git-reconcile.sh) may fetch/rebase and push this automatically" --
   false, since that hook now exits before ever reading the flag. Both
   notices (and scripts/user-prompt-hook.sh's internal documentation of
   them) now say reconcile is inert pending #969 instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…skip reasons

Self-review (Explore reviewer) caught that the #969 kill-switch's own
exit 0 fires unconditionally regardless of git_reconcile.enabled's
value -- the previous commit fixed this exact framing in the hooks
themselves but left eight skip-reason/docstring copies of the old
"exits before ever reading git_reconcile.enabled" claim untouched in
these two test files.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@fdaviddpt
fdaviddpt merged commit 1d14862 into main Oct 8, 2026
19 checks passed
@fdaviddpt
fdaviddpt deleted the fix-976-reconcile-side-effects branch October 8, 2026 00:45
fdaviddpt added a commit that referenced this pull request Oct 8, 2026
…ouched-path scope, fix stale reconcile doc wording (#985)

* fix(#972,#975,#982): anchor v1 cache substitution, harden reconcile touched-path scope, fix stale reconcile doc wording

#972: scripts/log.sh's pre-#864 orphan-cache-path derivation used a bare
`${var/-v2-/-}` substring substitution over the full path instead of the
filename's own -v2- segment, so a TMPDIR containing the literal substring
-v2- diverted the substitution away from the real orphan. Anchored to the
basename at both call sites.

#975: two of the four known defects in the hard-disabled
60-git-reconcile.sh are fixed ahead of its eventual re-enable -- a
git diff --name-only failure while computing the touched-paths restore
scope is now logged and falls back to the pre-#952 scope instead of
silently narrowing to nothing, and that diff output is now unquoted the
same way the conflict-reporting path already was. The two residual TOCTOU
windows and the partial _grc_rebase_in_progress test coverage are
re-verified still present and still out of scope for a same-diff fix (the
code is entirely unreachable while #969's kill switch holds, and the
existing test suite for this file is fully skipped for the same reason).

#982: docs/configuration.md's git_reconcile.enabled row said the hook
"exits immediately, before even reading this flag" -- false since #979,
which made the hook read the flag first (only to decide whether to log a
hook-errors.log notice) before its unconditional exit. Same stale wording
corrected in two test files' own prose (#979 missed those, not just the
doc); the now-stale trap.d/969 bookkeeping fragment is removed since #979
did fix all three files it names.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* continue fix(#972,#975,#982): remaining code, test and changelog files

Second half of the combined #972/#975/#982 fix -- the trap.d bookkeeping
removal landed in the previous commit; this one carries the actual code
fixes (scripts/log.sh, hooks.d/after_save/60-git-reconcile.sh,
docs/configuration.md), the two stale-wording corrections in test prose,
the two new regression test files, and the three changelog fragments.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#975): decode core.quotePath's interior escaping, not just the outer quotes

Self-review finding (Explore spawn): the shared _grc_unquote_porcelain_path
helper added in the previous commit stripped only the leading/trailing
double-quote characters git's porcelain output wraps a path in -- it left
git's own C-style escaping of the path's interior untouched (an escaped
quote, an escaped backslash, a tab/newline, or octal for a non-ASCII/
control byte), so the exact case #975 item 2 names (a touched path with
non-ASCII bytes) still would not match the real file on disk after
"unquoting". Verified directly: the pre-fix helper turned the porcelain
token for cafe-with-accent.txt into the literal escape text, not the
real UTF-8 bytes.

Fixed by decoding the escapes properly: a literal escaped backslash is
protected behind a sentinel before printf %b decodes the rest (the
escaped quote and the octal/control escapes bash's own %b already
understands), then the sentinel is restored to a literal backslash.
Verified against four cases directly in bash: the non-ASCII octal case,
an embedded quote, a plain unquoted path, and the pathological case of a
literal backslash immediately followed by a literal quote in the real
filename (which a naive single-pass substitution gets wrong).

No new pytest regression test for this helper specifically -- the whole
hook (and its own test suite) is unreachable while #969's kill switch
holds, same constraint noted in the prior commit; bash -n syntax-checks
clean and the active (non-skipped) test classes in
tests/test_git_reconcile_903.py, tests/test_git_backup_push_rejected_253.py
and tests/test_git_restore_hook_253.py still pass (68 passed, 21 skipped,
no change in skip count).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#975): CI -- rewrite escape handling without the forbidden backslash-quote shape

CI on PR #985 failed 10 legs (pytest ubuntu/windows x python 3.9-3.12, plus
"hook tests (compiled)" on ubuntu/windows). Root cause: this repo's own
built-tree shape checker (tests/test_scanner_shapes_source_898.py,
.github/scripts/check_release_tree.py's BACKSLASH_QUOTE/ESCAPED_QUOTE,
#898 round 7/8) forbids a literal backslash-then-quote shape in a shipped
.sh file -- a sed/awk-style escape-replacement pattern the real Anthropic
directory portal scanner holds submissions on. The previous commit's
_grc_unquote_porcelain_path wrote exactly that shape twice
(${_grc_up_path//\\\"/\"}).

Rewrote the same two escape-replacement steps using variables built from
single characters (_grc_up_bs, _grc_up_bsbs, _grc_up_bsq) instead of a
literal backslash-quote sequence in the source -- the same convention
this file's own _grc_foreign_changes already uses for its outer-quote
strip (a `_grc_dq='"'` variable rather than an inline `\"`). Verified:

- All 5 decode cases (non-ASCII octal, embedded quote, plain path,
  pathological backslash-before-quote, tab control char) re-run directly
  in bash -- unchanged output, confirming the rewrite is behavior-
  preserving.
- bash -n syntax-checks clean.
- tests/test_scanner_shapes_source_898.py: 389 passed, both against the
  worktree directly and against a disposable local clone compiled with
  .github/scripts/compile_hooks.py --apply (the exact step the failing
  "hook tests (compiled)" CI job runs) -- zero BACKSLASH_QUOTE/
  ESCAPED_QUOTE hits either way.
- Full previously-targeted test set re-run: 465 passed, 21 skipped (no
  change in skip count -- the kill-switch-disabled reconcile suite is
  unaffected).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

git-reconcile hard-disable (#969/#970) left two user-facing side effects unaddressed

1 participant