Skip to content

merge guard owns the full merge:pr lifecycle — auto-arm + finalize-from-detected-merged (eliminate FO hand-rolling)#415

Open
clkao wants to merge 2 commits into
mainfrom
spacedock-ensign/merge-guard-owns-arm-and-finalize-under-pr
Open

merge guard owns the full merge:pr lifecycle — auto-arm + finalize-from-detected-merged (eliminate FO hand-rolling)#415
clkao wants to merge 2 commits into
mainfrom
spacedock-ensign/merge-guard-owns-arm-and-finalize-under-pr

Conversation

@clkao

@clkao clkao commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Make spacedock merge guard own the full merge:pr terminal lifecycle so the FO runs one verb per phase instead of hand-rolling the ceremony.

What changed

  • Auto-arm the merge mod-block under both merge policies on entering terminal.
  • Finalize only on a well-formed merge sentinel (pr-merge:{N} / local-merge:{sha}), fail-closed on malformed input.
  • Block a bare/open PR ref instead of prematurely finalizing.
  • Commit the archive move path-scoped, never sweeping a dirty sibling.
  • Rewrite fo-merge-core.md to the one-verb-per-phase flow.

Evidence

  • go test ./internal/status ./internal/cli: all green (14 MergeGuard tests + TestPRIndicatesMerged + suffix-validation tests).
  • Detached adversarial audit, 2 rounds on a throwaway checkout: fail-open hole closed, no fail-closed regression.

Review guidance

Focus on internal/status/merge.go prIndicatesMerged — the fail-closed sentinel validation is the high-stakes guard.


xdc

clkao and others added 2 commits June 20, 2026 00:31
…om-merge-sentinel + path-scoped archive commit

The verb now owns the whole merge:pr ceremony so the FO invokes one verb per phase:

- AUTO-ARM under both merge:local AND merge:pr (was merge:local only): entering
  terminal with an empty mod-block + a merge hook registered sets
  mod-block=merge:{hook} and signals armed.
- FINALIZE keys off a local MERGE SENTINEL in pr (pr-merge:{n} / local-merge:{sha})
  — the signal a merge landed — never raw pr-presence. A bare/open PR ref (#42)
  blocks (await-pr); finalize works EVEN from a non-armed state (the stranded case).
- The verb commits the archive move PATH-SCOPED (staging only the entity's two
  rename paths), so a sibling left dirty in the same tree is never swept in.

Fixes the premature-finalize bug (an open-PR entity archived before its PR landed)
the Codex FO surfaced. fo-merge-core.md merge-ceremony prose rewritten to the
one-verb-per-phase flow + the SPACEDOCK_BIN launcher invariant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sed)

prIndicatesMerged did a bare HasPrefix with no suffix validation, so a
garbage sentinel (pr-merge:abc, pr-merge:0, an empty suffix) drove a full
finalize+archive — a fail-OPEN hole on an irreversible action. Validate the
suffix: pr-merge: finalizes only on a positive integer, local-merge: only on
a non-empty SHA-like token; anything else returns false.

Co-Authored-By: Claude Opus 4.8 <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