Repository navigation
Conversation
The ordinary no-mistakes lifecycle requires two steps of every ship task: arm the merge poll when the PR opens, then attest the captain-call inventory. Doing both silently and permanently disarmed the poll. The attestation appended `decisions_reviewed=1` and `decision_keys=` to the end of the task record, landing them after the `pr=` line the poll had already recorded. The PR identity reader treated any unrecognised line after `pr=` as tampering, so the armed, legitimate poll failed authentication for the rest of the task's life: the merge was never detected, and the operator got a security-shaped notice naming the wrong problem instead of the merged PR. Line order is not a property a shared record can hold. A task record has several writers that legitimately rewrite or add their own keys at the end, and the reader had already been patched once to whitelist one such writer's keys. Bind the identity to what it actually depends on instead: exactly one `pr=` that parses, at most one `pr_head=`, always validated, and every other key ignored wherever it sits. That is a relaxation in one direction and a tightening in two. A head written before `pr=` used to escape validation entirely while every consumer reads it back with `tail -1`, and two valid but differing heads used to be accepted with no way to say which one the record meant. The positional rule's one real guarantee - that a forge-supplied value with an embedded line break cannot smuggle a second key into the record - now sits explicitly at bin/fm-pr-check.sh, the only writer of those values. Because the record was never actually invalid, this also repairs every record already broken in the field with no recovery path to get wrong. On the writer side, add fm_meta_set as the one owner of setting a key in a task record: it replaces prior lines for the keys it sets, publishes through the same atomic path a record change already uses, and refuses a key or value that would write an unattributable line. The attestation uses it, so the last bare append into a task record is gone along with the unbounded growth it caused on re-attestation.
bin/fm-backlog-transition-lib.sh runs under the curated PATH the spawn and teardown lifecycle scripts pin, so the staged file is named by parameter expansion, and a record path with no directory component resolves to the working directory instead of composing a path from itself.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or non-blocking defects identified in the changed behavior. The new metadata writer preserves unrelated fields under the existing lock and atomic publication boundary, while poll authentication continues to bind canonical PR identity to hashed sidecar data despite allowing unrelated metadata lines in any position. Reviews (1): Last reviewed commit: "no-mistakes(document): document shared t..." | Re-trigger Greptile |
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.
The bug
bin/fm-captain-hold.sh completeappended its two bookkeeping keys to the end ofstate/<id>.meta:When the task already carried a
pr=line - armed earlier bybin/fm-pr-check.sh- those keys landed after it.fm_pr_metadata_identity_parseinbin/fm-pr-lib.shtreated any line afterpr=that was notpr_head=or one of the whitelistedx_*keys as evidence of tampering and returned 1.fm_pr_poll_artifacts_validthen failed, andbin/fm-watch.shclassified the task's own armed merge poll as an unauthenticated check:The merge poll stayed disarmed for the rest of that task's life, so the merge was never detected or reported, and the operator was handed a security-shaped wake naming the wrong problem.
The ordinary documented lifecycle produces this every time: arm the poll when the PR opens, then attest the captain-call inventory. Both are required by
AGENTS.mdsection 7. Reproduced in the field on two consecutive tasks before this fix.The fix
fm_pr_metadata_identity_parseno longer binds a task record's PR identity to line position. Position carries no meaning in that file: a task record has several legitimate writers that add or rewrite their own unrelated keys at the end, and no reader can require an ordering that every future writer would have to know about.What the identity actually depends on is checked instead, from either side of
pr=: exactly onepr=that parses to a canonical URL, and at most onepr_head=, always validated.That is stronger than the rule it replaces, not weaker:
pr_head=written beforepr=, while every consumer reads that value withtail -1; the new rule validates it wherever it appearspr_head=was previously accepted; it is now refusedbin/fm-pr-check.sh, the only path that writes themfm_meta_setis added as the shared, tested writer for task records, replacing the last bare append. It sets keys in place atomically, so a re-attestation no longer grows the record.bin/fm-promote.shandbin/fm-x-lib.shhave the same append shape; with the reader fixed, neither can reproduce this.No recovery path is needed, and that is the point: records carrying the keys after
pr=were never invalid, the reader was wrong. They read correctly now, so nothing exists that could be tricked into accepting a genuinely untrusted check.Tests
tests/fm-captain-hold-lifecycle.test.sh- the two-step lifecycle through the real watcher, red before this change and green after (verified by reverting the fix, both with and without the writer change)tests/fm-pr-check-security.test.sh- the parser's semantics in both directions, and the write path's refusalstests/fm-backlog-atomicity.test.sh-fm_meta_set🤖 Generated with Claude Code
https://claude.ai/code/session_01VY412eng1vpDbK3Kv2vgKg