Skip to content

source-control:babysit-prs: promote the assigned-worktree HEAD==origin/<pr-branch> assertion from prose to a deterministic push-safety guard #885

Description

@kyle-sexton

Follow-up from #548 (which landed the assertion + refspec-push as a prose contract in reference/safety.md).

Context

#548 fixed a near-miss where a babysit worker in a detached-HEAD / stale-local-branch worktree could git merge origin/main + push and silently revert the newest branch commit. The fix is a behavioral contract in safety.md's Checkout And Push Invariants: assert the assigned worktree's HEAD equals a freshly re-fetched origin/<pr-branch> before any merge/edit/push, and push via git push origin HEAD:<pr-branch> (fast-forward by construction, never --force).

The gap this tracks

#548's own words: "safety depended on luck, not a guard." Enforcement is still agent discipline — a worker that skips the assertion re-opens the exact hole. The repo's recent thesis (#530, #547, #613) is prevention-by-mechanism, not prose. So the open question:

Should the assertion + refspec push be a deterministic helper — e.g. a small script (or an extension of the guarded push/mutation wrappers) that resolves the assigned worktree HEAD, re-fetches origin/<pr-branch>, refuses (fail-closed) on any mismatch, and performs the fast-forward refspec push — so the guarantee holds structurally rather than relying on the worker to follow prose?

Decision needed

Build the guard helper (and where it lives — a new script vs. folding into source-control-babysit-merge/push path), or deliberately keep it as contract. Category: improvement (prevention). Surfaced in the #548 review disposition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions