Repository navigation
A rejected git backup push is no longer reported as one that will retry - #256
Merged
Merged
Conversation
`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>
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.
Addresses part 1 only of #253. Part 2 (the
before_session_startrestore 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.shfunnelled every non-zerogit pushinto one line at three call sites (:222,:234,:244):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>push deferred (will retry next backup)ERROR: push REJECTED by the remote — the backup has STOPPED …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_forwardscanned 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 theTo <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_afterconsecutive rejections (default 3,0disables) the next prompt carries a one-linesystemMessage: 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.shnow 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.mdandarchive.mdare 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 runsfetch,pull,mergeorrebase, 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_changeoverride, 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_remoteasserts the remote's tip actually moved before any test asserts anything about a log, and clones with-b mainexplicitly because a bare repo's HEAD is whatever the runner'sinit.defaultBranchpicked — without it the fixture lands on an unbornmasterand proves nothing.The new config key is wired into the existing hoist-before-fork contract test (#135), the README table and
config.example.json(both enforced bytest_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-rejectedadded to the suggested backup.gitignore.Part of #253