Skip to content

A rejected git backup push is no longer reported as one that will retry - #256

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/253-push-rejected-not-deferred
Jul 31, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/253-push-rejected-not-deferred

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Addresses part 1 only of #253. Part 2 (the before_session_start restore counterpart) is a feature request and is deliberately untouched — no stub, no config flag, no groundwork.

The defect

hooks.d/after_save/50-git-backup.sh funnelled every non-zero git push into one line at three call sites (:222, :234, :244):

push deferred (will retry next backup)

Accurate for a network blip. Inaccurate for a non-fast-forward rejection, which is what the store gets the moment the remote moves ahead: that push cannot succeed on any future attempt without human action, and the backup has in fact stopped. The reporter's logs: 15 deferrals against 8 pushes, twelve days of memory never leaving the machine, nothing anywhere saying so.

Three states, not two

pushed <slug> on the remote
push deferred (will retry next backup) git never reached the remote — offline, VPN, sleeping credential helper. Unchanged.
ERROR: push REJECTED by the remote — the backup has STOPPED … git judged the commits and said no. Names the rejected refs, says the commit is local-only, names the command that shows git's own advice.

Which channel carries the verdict, and why

git push --porcelain's per-ref status lines — never free text. This is the channel claude-supertool#641 settled after _is_non_fast_forward scanned merged stdout+stderr for "fetch first" and read a pre-push hook's own advice as a remote rejection.

The parse is strict: exactly three tab-delimited fields, first field ! (a new branch is *, a forced update +, so the three cannot be confused), and only lines after the To <url> header, because a pre-push hook's output precedes it. stderr — hints, transport noise, hook chatter — is discarded outright.

The direction of the failure was the design constraint. Loudness requires positive evidence from git. An unreachable remote emits no per-ref lines at all, so it falls through to the old quiet deferral untouched. Making an ordinary flaky network noisier or fatal would have been #204 in a new place, and worse than the bug being fixed. Two tests exist only to hold that line, including one that runs five consecutive network failures and asserts the human is never interrupted.

Where the user sees it

A log line is demonstrably insufficient — that is the whole issue. After git_backup.reject_notice_after consecutive rejections (default 3, 0 disables) the next prompt carries a one-line systemMessage: the channel #200 established as "the only hook output the HUMAN sees, and a notice only the model sees is how this stayed invisible for a day".

Escalation rather than first-rejection, because that surface is the most intrusive in the codebase and one that fires often is one that gets tuned out. The delay costs nothing true: a rejection never clears itself, so the threshold can only postpone a real report, never swallow it. Any successful push resets the counter. A transient failure cannot reach the branch at all.

user-prompt-hook.sh now drains a small list of notice files rather than one hardcoded path, so #200's notice keeps its own semantics.

Not auto-resolved

At the reporter's explicit request and independently correct: recent.md and archive.md are rewritten wholesale by consolidation rather than appended, so a conflict there is real and a wrong resolution corrupts memory silently. Refusing and reporting is the deliverable. The hook still never runs fetch, pull, merge or rebase, and a structural test fails if any of them appears.

One decision, three sites

All three push paths (first push to a newly recorded remote, the allow_remote_change override, the steady state) now go through one classifier. Each is exercised functionally against a real rejection, and a structural test fails if the deferral message ever appears at more than one site.

Tests

Real repositories, no mocked git output. The whole defect is about which channel carries the truth, so the rejection is produced by a real bare remote advanced by a real second clone — claude-supertool#649 documents six mocked fixtures that passed before and after a real bug because they pinned the implementation rather than the contract. _advance_remote asserts the remote's tip actually moved before any test asserts anything about a log, and clones with -b main explicitly because a bare repo's HEAD is whatever the runner's init.defaultBranch picked — without it the fixture lands on an unborn master and proves nothing.

  • RED: 12 failed, 6 passed. The 6 that passed on the broken code are the guards (transient stays quiet, hook exits 0, never fetches/merges/rebases, a pre-push hook saying "fetch first" is not a rejection). This is why the load-bearing test is a rejection — a test that only exercises a network failure passes on the broken version.
  • GREEN: 18/18.
  • Full suite: 1147 passed, 42 skipped, coverage 94.13% (gate 80%).

The new config key is wired into the existing hoist-before-fork contract test (#135), the README table and config.example.json (both enforced by test_config_contract.py).

Docs

CHANGELOG.md (noting part 1 only), README config table, a new "When a push does not go through" section with the three states and the no-auto-resolution rationale, and .git-backup-rejected added to the suggested backup .gitignore.

Part of #253

`50-git-backup.sh` funnelled every non-zero `git push` into one line —
`push deferred (will retry next backup)` — at three call sites. True for a
network blip. False for a non-fast-forward rejection, which is what the store
gets the moment the remote moves ahead: that push cannot succeed on any later
attempt, and the backup has in fact stopped. The reporter ran twelve days on
that promise, 15 deferrals against 8 pushes, and found it only by looking.

Three states now, not two: pushed / deferred, will retry / rejected, the
backup has STOPPED and here is what to do.

The verdict comes from `git push --porcelain`'s per-ref status lines, never
from free text — the channel claude-supertool#641 settled after a pre-push
hook printing "fetch first" was read as a remote rejection. Rejected refs are
flagged `!` in tab-delimited fields; only lines after the `To <url>` header
are read, because a hook's own output precedes it; stderr is discarded.

Loudness requires positive evidence from git. An unreachable remote, an
asleep credential helper or a killed transport emit no per-ref lines at all,
so every transient failure stays the quiet retry it always was — making an
ordinary flaky network noisier would have been #204 in a new place.

A log line alone is not the fix; being invisible in a log is the issue. After
`git_backup.reject_notice_after` consecutive rejections (default 3, 0 to
disable) the next prompt carries a `systemMessage`, the channel #200
established as the only hook output the human sees. It escalates rather than
firing on the first rejection: that channel interrupts a human mid-thought,
and a rejection never clears itself, so the threshold can only postpone a
true report, never swallow it. Any successful push resets the count.

Nothing is auto-resolved, at the reporter's request and by design: recent.md
and archive.md are rewritten wholesale by consolidation, so a wrong
resolution corrupts memory silently. The hook still never fetches, pulls,
merges or rebases, and a test pins that it cannot start.

All three sites share one classifier, so the funnel cannot be reopened one
site at a time.

Tests first, red 12/18 — the six that passed on the broken code are the
guards that ordinary failures stay quiet — then green 18/18, full suite
1147 passed / 42 skipped, coverage 94.13%. The rejection is produced by a
real bare remote advanced by a real second clone, never a mocked string
(claude-supertool#649); every fixture asserts it diverged before anything is
asserted about the log.

Part of #253

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit f8267b5 into main Jul 31, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/253-push-rejected-not-deferred branch July 31, 2026 10:20
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.

1 participant