Skip to content

D268 — the pre-push hook fetches the default branch before refusing (#484) - #496

Merged
napkinstack-agent[bot] merged 2 commits into
mainfrom
d268-push-hook-fetches-before-refusing
Nov 23, 2026
Merged

napkinstack-agent[bot] merged 2 commits into
mainfrom
d268-push-hook-fetches-before-refusing

Conversation

@napkinstack-agent

@napkinstack-agent napkinstack-agent Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Workstream

D268, from #484 (its CONFIRM failed on v0.34.5). Its row is in docs/governance/workstreams.md.

What it changes

In an agent's session, the pre-push hook refuses any commit the remote does not hold yet whose author or committer is not the agent. D264 counted what nstack claim fetched (refs/nstack-remote/base) as the remote's. Downstream, a forge's squash merge took another route: a merge of main made in a git clone --shared, fetched into the agent's clone as FETCH_HEAD, then pushed by its sha. origin/main was stale, so the forge's commit (committer noreply@github.com) counted as unpublished and foreign:

FAIL [nstack] 1 commit(s) the remote does not hold yet are not agent sam's identity
flowchart LR
  A[count foreign commits] -->|0| P[judge the project]
  A -->|>0| F[fetch remote HEAD into refs/nstack-remote/base]
  F -->|fetched| B[count again]
  F -->|failed| R[refuse, as before]
  B -->|0| P
  B -->|>0| R
Loading

Now, on the refusal path only, .nstack/fitness-before-push.sh fetches the default branch of the remote it pushes to (PRE_COMMIT_REMOTE_NAME, origin by default) into refs/nstack-remote/base, which is the same ref claim writes, and counts again. Properties:

  • A clean push fetches nothing.
  • No remote-tracking branch moves.
  • Neither a remote-tracking branch nor FETCH_HEAD moves (--no-write-fetch-head).
  • GIT_TERMINAL_PROMPT=0 and ssh in batch mode: the fetch never asks for a credential.
  • If the fetch fails, the push is refused as before, with the plain git fetch Action.

The refusal's Action now says this fetch was already made, so that only a forge merge on another branch needs a git fetch.

Not taken: following each route by which a forge's commit can arrive. One fetch on the refusal path covers all of them.

Fresh verifier

Findings fixed in the second commit:

  • the refusal said the fetch was made even when it had failed;
  • the fetch overwrote FETCH_HEAD, the very ref of the downstream route;
  • two mutants survived: a fetch on every push, and the remote's name ignored. A test now kills each of them.

Checked fine: pre-commit sets PRE_COMMIT_REMOTE_NAME (a URL when the push names one, which git fetch accepts); POSIX sh; refs/nstack-remote/base is rewritten by claim's own fetch before every read in hold.py.

What a project receives

One file: .nstack/fitness-before-push.sh. Nothing that was green turns red. A push that was refused only because of a stale origin/main now passes.

Definition of Done

  • The behaviour is covered by a test that failed before: the downstream route (merge in a --shared clone → FETCH_HEAD → push by sha, origin/main stale) was refused with the downstream message, and passes now. A second test checks that a made-up identity on top of a stale origin/main is still refused after the fetch.
  • Every failure names the rule, the place and the action (P6)
  • uv run bash platform/tests/run.sh green, on a committed tree
  • uv run nstack fitness green
  • Affected documentation updated
  • The workstream's row updated in the register
  • No private project named, no path of a workstation, no link into an assistant's session

🤖 Generated with Claude Code

…484)

A merge of main made in another clone and fetched into FETCH_HEAD carried a
squash merge the forge committed, through no ref the identity check reads;
origin/main was stale, so the push was refused as another's identity. D264
covered claim's fetch only.

On the refusal path only, .nstack/fitness-before-push.sh fetches the default
branch of the remote it pushes to into refs/nstack-remote/base, as claim does,
and counts again. A clean push fetches nothing; no remote-tracking branch
moves; a failed fetch leaves the refusal as it was.

Agent-Session: napkinstack-os-77
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@napkinstack-agent
napkinstack-agent Bot requested a review from a team as a code owner November 22, 2026 23:58
…TCH_HEAD kept

The refusal said the hook had fetched even when the fetch failed; it now
gives the plain git fetch Action then. The fetch no longer writes FETCH_HEAD,
which the agent may push again, and runs ssh in batch mode. Two surviving
mutants are killed: a fetch on every push, the remote's name ignored.

Agent-Session: napkinstack-os-77
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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