Repository navigation
fix(bin): support pipeline-owned rebase restamps in receipt sealing - #111
Merged
Merged
Conversation
The no-mistakes rebase step re-commits every branch commit with a fresh committer stamp. Every tree stays byte-identical, but the whole chain gets new object ids, so the planned implementation head stops being an ancestor of anything the run reports. `--bind-run` then refused the run because its head no longer resolved to the planned head, and `--complete` refused it because the current head was not a descendant of the planned head. A genuinely passed run could not seal without a replan and a fresh run. Accept that shape through content identity. `fm_nm_head_content_identical` compares the tree object Git already computes for each commit: it holds for a pure restamp and breaks on any change to any tracked file. `--bind-run` now accepts a run head recording the planned head's tree and records that restamped head; `--complete` accepts a run head recording the current head's tree, and a current head recording the planned head's tree. Every other requirement is unchanged. The run must still be the bound run at the current generation, still be genuinely passed or checks-green, still report the current worktree branch with pipeline ownership while active, and still be terminal PASSED otherwise. The descendant-advance path added for commits landed on top of the validated head keeps its exact behavior. Claude-Session: https://claude.ai/code/session_01WGckfiJn9GAx7n4jCJYntc
…ith Bash-compatible loop
…base only for full-no-mistakes completion, preserving direct-PR/local completion paths that legitimately lack it. Verified with fm-pr-check-security, fm-receipt-check, bin/fm-lint.sh, and git diff --check
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.
Intent
Fix bin/fm-receipt-check.sh so --bind-run and --complete can seal a genuinely-passed full-no-mistakes run when the no-mistakes pipeline's rebase step RE-STAMPS the entire commit chain (same trees, new committer stamps, therefore new SHAs), which the already-merged PR #105 does not cover.
Context: PR #105 handles only the head advancing by NEW commits landed ON TOP of the validated head, permitting current_head != validated_head when validated_head is still an ancestor of current_head. This distinct facet: the rebase step re-commits every branch commit with the same tree and a new committer stamp, producing new SHAs for the whole chain, so validated_head is no longer an ancestor of current_head at all, the descendant check fails, and --bind-run also fails earlier because the run's observed head no longer resolves to the planned validated head. Hit live on task port-3690-3614-e2e-test: run 01M1RW6JNH5C5VN15PPRYDW3J0 reported head bd8aaff5 while the planned head was 874ce334; both carry tree f7d8fa3a and git merge-base --is-ancestor 874ce334 bd8aaff5 exits 1.
Required behavior: recognize a PIPELINE-OWNED rebase-restamp as authoritative. When the bound, genuinely-passed run reports a rewritten head whose CONTENT is identical to the validated chain, accept it for both bind and complete.
CRITICAL safety invariant that must be preserved and tested: still REFUSE when the rewritten or advanced chain's content is NOT identical to the validated content (any foreign change), when the run did not genuinely pass, or when the rewrite is not owned by the bound pipeline run. This must not become a hole that lets unvalidated content complete. Do NOT weaken PR #105's existing on-top-descendant path; add the rewrite case alongside it.
Acceptance criteria:
Constraints: this edits firstmate's shared tracked bin/, so the firstmate-coding-guidelines apply (shellcheck-clean bin scripts via bin/fm-lint.sh, colocated tests in tests/ extending the existing runner, one sentence per line in tracked Markdown, plain dash, no agent commit co-author, maintainer-verification evidence under docs/verification/).
Firstmate-Validation-Generation: 4a06de7b3bb4869c8c688896b75f1033
What Changed
Risk Assessment
Testing
Ran the focused fm-receipt-check behavioral suite, including accepted pipeline restamps, provenance/foreign-content refusals, ownership refusals, non-passed runs, and existing descendant paths; all completed successfully with exit code 0. CLI transcript saved as evidence.
Evidence: Receipt-check behavioral test transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (3) ✅
bin/fm-receipt-check.sh:833- The new tree-equality fallback does not prove that a rewritten head is the bound pipeline run's restamped chain. For example, create an unrelated commit from another parent with the same tip tree asvalidated_head, bind a passed run reporting that commit, and leave the worktree at it: lines 832-834 accept it becausefm_nm_head_content_identicalpasses, then the same-branch/terminal checks complete it even though the run does not own that rewrite. The same tip-tree check also permits foreign changes that are later reverted. This contradicts the required safety invariant: “still REFUSE ... when the rewrite is not owned by the bound pipeline run” and “any foreign change.” The rewrite path needs provenance/chain-content validation at the earliest shared boundary, not only final-tip tree identity.🔧 Fix: Enforce faithful chain provenance for restamped heads
1 error still open:
bin/fm-receipt-check.sh:827- The rewrite ownership checks are skipped whenevercurrent_head == validated_head(lines 827-854). A bound run can report a faithful restamped head, while custody has returned the worktree to the validated head, andrun_out.branchcan name another branch (or an active run can have non-pipeline_ownedsync); the accounting predicate passes and the branch/ownership checks are never reached, so--completeseals a rewrite the bound pipeline run does not own. This contradicts the required safety invariant to refuse “when the rewrite is not owned by the bound pipeline run.” Apply the ownership/branch checks to the restamp case even when the current head equals the validated head, or otherwise establish an equivalent shared ownership proof.🔧 Fix: Enforce ownership checks for custody-returned restamps
2 issues (1 error, 1 warning) still open:
bin/fm-nm-run-lib.sh:114-fm_nm_head_is_faithful_restamppopulates arrays with Bashmapfile, which is unavailable in the stock macOS Bash 3.2 supported by this repository. Any genuine restamp bind/complete on macOS therefore fails closed despite valid input; replace this with a Bash-3.2-compatible read loop.tests/fm-receipt-check.test.sh:1116- The required regression coverage is incomplete: the new tests do not exercise refusal of (1) an unrelated same-tree tip from a different parent, (2) a foreign commit later reverted so the tip tree matches, or (3) a rebase onto a newer base with changed trees. These cases are specifically required to validate the chain-provenance invariant beyond the single foreign-tip edit covered here.🔧 Fix: Ensure Bash 3.2 compatibility and adversarial restamp coverage
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-receipt-check.test.sh✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Replaced unsafe cherry-pick command substitution with Bash-compatible loop
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.