Repository navigation
chore(agents): let a rebased branch push without verifying again - #137
Merged
scottlovegrove merged 2 commits intoNov 27, 2026
Merged
Conversation
doistbot
reviewed
Nov 27, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR adds a rebase exemption to the agent push check: branches whose changes already passed verify (matched by git patch-id) can push after a rebase without re-running it, with patch records kept in .tmp/agents/verified-patches.json and an ancestry check ensuring the new base contains the original one.
Few things worth tightening:
- Invalidation on a failed verify only drops the HEAD patch; if the verified changes are staged/unstaged (e.g. after
git reset --soft), the working-tree patch can still satisfyhasPassedPatchafter recommitting — invalidate it too and add a regression test. - If
verified-patches.jsonis readable but not writable, invalidation failures are swallowed, so a stale entry can survive a failing verify; propagate the error or fall back to deleting the record and failing explicitly. - The regression test's deny path doesn't actually exercise the patch-forgetting logic (a missing tree record already denies the push); assert the record contents after the failed run, or keep a verified record for another branch, so the test would fail if
forgetPassedPatchwere removed.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (4)
.agents/scripts/lib/verify.ts:68: This re-implements
resolveCommitfrom./git.ts(rev-parse --verify --quiet <ref>^{commit}, returningundefinedwhen it fails), which push-check.ts already uses for exactly this.const commit = resolveCommit(root, 'HEAD')replaces both lines and drops the now-unusedgitimport from this file..agents/scripts/lib/patches.ts:77:
forgetPassedPatchcomputes the branch patch id (a fullgit diffof the branch plusgit patch-id) before reading the record, so everynpm run verifyrun pays for that diff even when.tmp/agents/verified-patches.jsonis missing or empty.hasPassedPatchalready does the cheap check first (read, return if empty). Move thereadPassedPatchescall abovebranchPatchIdand return when there's nothing recorded, so the diff only runs when there's a record to remove..agents/scripts/lib/patches.ts:59:
recordPassedPatchruns on every allowed push of a verified commit (push-check.ts calls it in thefingerprint === checkout.verifiedpath), and it always spawnsgit diff+git patch-id, reads the record, and rewrites it with a newattimestamp — even when the record already holds this patchId on this base. An agent pushing the same branch repeatedly (e.g. while iterating on a stack) pays that on each push for no effect. SincerecordPassedPatchalready receives the commit, store the commit sha in the record and return early when an entry with the same base and commit exists; that skips both spawns and the write on repeat pushes. Update thetoEqualin verify.test.ts that pins the record shape..agents/scripts/lib/push-check.test.ts:255:
describe.skipIf(!GIT_HAS_VERBATIM_PATCH_ID)silently drops these tests on git older than 2.39 without saying why —patches.test.ts:44carries that comment, this file andverify.test.ts:61/:75don't. Test rules §5 allows a conditional skip only with a comment explaining it, so add the one-line reason (nogit patch-id --verbatimbefore 2.39, so there is no exemption to test).
scottlovegrove
force-pushed
the
scottl/agent-push-rebase-exemption
branch
from
November 27, 2026 14:04
d05154f to
07caba0
Compare
scottlovegrove
force-pushed
the
scottl/agent-push-rebase-exemption
branch
from
November 27, 2026 14:09
07caba0 to
5ebad83
Compare
Adds a rebase exemption to the push check, ported from todoist/todoist-cli#676: if a branch's commits are the same changes that passed verify and only main moved under them, the push goes through without running verify again. Without it, every rebase of a verified branch, and of every branch in a stack, needs another verify before it can push. "The same changes" is a patch id: git patch-id --verbatim over the branch's diff from where it left main, with the diff's context, algorithm and prefixes set explicitly so git config can't change what it compares, and the new base must contain the one the patch passed on. Patches are recorded in .tmp/agents/verified-patches.json (last 50) when verify passes on a clean tree and when the push check lets a verified commit through. A verify run drops the branch's changes from the record before it checks, so one that fails leaves them needing verify. The check adds a note whenever it lets a push through this way.
A verify run dropped only HEAD's changes from the record of changes that passed. After `git reset --soft HEAD~1` or `git reset HEAD~1`, the same changes sat staged or uncommitted, so a failing run forgot nothing and recommitting them let the push through on the earlier pass. It now drops HEAD's changes, the staged ones and the whole working tree's, untracked files included (read through a copy of the index, so the real one is left alone). A record it can't rewrite is deleted instead of left in place, and if it can't be deleted either, verify fails. It reads the record before computing any patch, so a run with nothing recorded pays for no diff. The verify test for a failed run now checks the record itself, since a denied push alone doesn't show the forgetting happened, and each conditional skip says why.
scottlovegrove
force-pushed
the
scottl/agent-push-rebase-exemption
branch
from
November 27, 2026 14:30
e3bf0ea to
17c3371
Compare
2 tasks done
scottlovegrove
added a commit
to todoist/todoist-mcp
that referenced
this pull request
Nov 27, 2026
# Pull Request ## Short description Part 3 of 3, on top of #785. Adds the rebase exemption from todoist/todoist-cli#676: if a branch's commits are the same changes that passed verify and only `main` moved under them, the push goes through without running verify again, with a note saying so. "The same changes" is `git patch-id --verbatim` over the branch's diff from where it left `main`, and the new base must contain the one the patch passed on. Patches are recorded in `.tmp/agents/verified-patches.json` (last 50) when verify passes on a clean tree and when the check lets a verified commit through. docs/agents.md states the limit: a change elsewhere in `main` that the branch depends on isn't seen until CI runs. Fixes from the other ports, each with a test that fails without it: - Before it checks, verify forgets the branch's changes as HEAD holds them, as staged, and as the whole working tree with untracked files (read through a copy of the index), so a failing run after `git reset --soft HEAD~1` or `git reset HEAD~1` can't leave them counted as passed (comms-cli, todoist/comms-cli#137). - A run the preflight stops (old Node, `node_modules` out of step with the lockfile, as after a rebase onto new dependencies) forgets them too (outline-cli todoist/outline-cli#195, zendesk-cli todoist/zendesk-cli#284). - A record that can't be rewritten is deleted, and verify fails if it can't be deleted either, instead of the error being swallowed (comms-cli, outline-cli). - The tooling's git calls drop `GIT_DIFF_OPTS`, which would otherwise shrink the diff's context under `--unified=3` (zendesk-cli), and the diff sets `--indent-heuristic` so `diff.indentHeuristic` can't change the id either (outline-cli). - A test pins that a commit and push in one command is checked against the working tree, not an earlier passed patch (zendesk-cli). Tried with Claude Code (`claude -p`, Haiku) in a throwaway clone: after verify the push went through; after I moved `main` by hand and rebased the branch (a new commit and a different tree), the force-push went through without verify, with the note "HEAD holds changes that already passed verify" in the transcript; an unverified commit on top was then denied, and the bare repo stayed at the rebased commit. ## PR Checklist - [x] Added tests for bugs / new features - [x] Updated docs (README, etc.)
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.
Adds a rebase exemption to the push check from #135, ported from todoist/todoist-cli#676: if a branch's commits are the same changes that passed verify and only
mainmoved under them, the push goes through without running verify again. Without it, every rebase of a verified branch, and of every branch in a stack, needs another verify before it can push."The same changes" is a patch id:
git patch-id --verbatimover the branch's diff from where it leftmain, with the diff's context, algorithm and prefixes set by the tooling so git config can't change what it compares. Line numbers may shift, but the changed lines, the lines around them and their whitespace must match, and the new base must contain the one the patch passed on. Patches are recorded in.tmp/agents/verified-patches.json(last 50) when verify passes on a clean tree and when the push check lets a verified commit through. A verify run drops the branch's changes from the record before it checks, whether they're committed, staged or uncommitted (as aftergit reset HEAD~1), so one that fails, say after a rebase onto a breakingmain, leaves them needing verify. A record it can't rewrite is deleted, and verify fails if it can't be deleted either. The check adds a note whenever it lets a push through this way.The limit is in docs/agents.md: a change elsewhere in
mainthat the branch depends on, such as a renamed function it calls, isn't seen until CI runs on the pushed branch. The code started as todoist-cli's as merged, with every fix from its review. Doistbot's review here found two gaps todoist-cli has too, fixed in e3bf0ea: a failing verify forgot only HEAD's changes, so the same changes staged or uncommitted again kept their pass, and a record it couldn't rewrite was left in place.Tried with Claude Code (
claude -p) in a throwaway clone pushing to a local bare repository: after verify, the push went through; aftermainmoved by hand and the branch was rebased onto it (new commits and a different tree), the force-push went through without verify, with the note "HEAD holds changes that already passed verify, so it isn't verified again"; an unverified change committed on top was then blocked, and the bare repository's ref stayed at the rebased commit.