Repository navigation
fix: keep registered merge polls armed across template updates - #339
Merged
Merged
Conversation
A registered poll now binds to the template generation it was armed from through the check's own recorded hash and file identity, instead of requiring byte equality with today's bin/fm-pr-poll.sh. Any Firstmate update that changed the poll template used to silently disarm every registered merge poll. Execution is unchanged: the watcher still runs the current repository poll with the validated sidecar data and never executes the registered check bytes, so a poll armed under an older generation runs today's code. The current template must still be a regular non-symlink repository file. Ports upstream PR 8069's generation binding.
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.
Summary
Ports upstream PR 8069's generation binding: a registered merge poll stays valid when the poll template changes, because the published check is authenticated against the generation it was registered with instead of against today's
bin/fm-pr-poll.sh.fm_pr_poll_prepare() { - [ -f "$template" ] || return 1 + [ -f "$template" ] && [ ! -L "$template" ] || return 1 fm_pr_poll_artifacts_valid() { ... - cmp -s "$template" "$check" || return 1 + # The repository entry point is checked here. The registration authenticates + # the published copy below. + [ -f "$template" ] && [ ! -L "$template" ] || return 1 fm_pr_poll_data_parse "$data" || return 1 template_hash=$(fm_pr_sha256 "$check") || return 1 ... [ "$FM_PR_REG_TEMPLATE_HASH" = "$template_hash" ] || return 1 [ "$FM_PR_REG_CHECK_IDENTITY" = "$check_identity" ] || return 1Execution is unchanged: the watcher runs the current repository poll with the validated sidecar identity and never runs the registered state-file bytes, so a poll armed under an older generation executes today's code.
Trust boundary
The only widening is which generation of the poll script a registration may name. Who can arm a poll is unchanged: a private
state/artifact set written by the local user, and a poll still needs a canonical registration, matching sidecar data, matching task metadata, and the check's exact recorded inode identity. The current template must still be an existing, non-symlink regular file, and arming now refuses a symlinked template before it touches the live poll artifacts.Fork divergences from upstream 8069
bin/fm-pr-lib.shkeeps its single combinedfm_pr_poll_artifacts_valid(state, id, template, metadata mode) instead of upstream's split content/identity validators and device-shift helper; the port is the generation predicate inside that function.control_relaunch_txmetadata-ordering change is not ported: this fork'sfm_pr_metadata_identity_parseis order-independent (fork PR 137), so relaunch metadata already parses.bin/fm-check-register.sh,<id>.check-trust,bin/fm-check-lib.sh) is untouched; it governs intentional custom checks, not PR merge polls.fm_pr_poll_preparerejects a symlinked template before publication, because this fork's publish-then-validate path would otherwise revoke a previously armed poll when a re-arm starts against a symlinked template.Evidence
not ok - an intact registered generation was rejected after the template changedSame suite on the pre-change head, kept as private task evidence.
After: the poll-security suite passes on the change head, including
test_registered_poll_survives_template_update(open cycle keeps the poll armed, merged cycle wakes with the current repository poll) andtest_altered_or_unregistered_checks_stay_refused(four cases; the watcher refuses and never queries the forge). Partner suitesfm-pr-check-handoff,fm-check-unregister, andfm-landingpass in the pipeline's test step.Merge Danger
Door: two-way. Reverting restores byte equality; no data migration and no state rewrite.
Blast Radius: every armed PR merge poll - watcher polling, landing records, todo projection, retirement, and teardown.
Remaining review findings
reject-unreadable-poll-templatePipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-lib.sh:615- A re-arm can delete an existing merge poll when the repository template is a symlink. This is uncommon, but deterministic if an operator temporarily symlinks the template and runs the normal re-arm command. Preparation follows the symlink at bin/fm-pr-lib.sh:470 and :511, publication replaces the three live artifacts at :546, :564, and :585, and the new check at :615 rejects the symlink and triggers revocation at :591. Restoring the regular template then leaves nothing for the watcher to resume. Reject symlinks in shared preparation before publication and keep the final validation check. This protects both the task re-arm at bin/fm-pr-check.sh:237 and the landing re-arm at bin/fm-landing.sh:115.tests/fm-pr-check-security.test.sh:1586- AC2 requires that a check that “was never registered” be refused under both template generations. Both fixture branches at tests/fm-pr-check-security.test.sh:1586 and :1590 omit the poll data sidecar as well as the registration. Every run can therefore pass at :1603 and :1615 even if the validator starts accepting valid poll data without a registration. Give both fixtures valid matching poll data and metadata, omit only the registration, and retain the watcher rejection and no-forge-call assertions. This isolates the registration requirement for the real partial-publication case.🔧 Fix applied.
2 warnings still open:
bin/fm-pr-lib.sh:615- A re-arm can delete an existing merge poll when the repository template is a symlink. This is uncommon, but deterministic if an operator temporarily symlinks the template and runs the normal re-arm command. Preparation follows the symlink at bin/fm-pr-lib.sh:470 and :511, publication replaces the three live artifacts at :546, :564, and :585, and the new check at :615 rejects the symlink and triggers revocation at :591. Restoring the regular template then leaves nothing for the watcher to resume. Reject symlinks in shared preparation before publication and keep the final validation check. This protects both the task re-arm at bin/fm-pr-check.sh:237 and the landing re-arm at bin/fm-landing.sh:115.bin/fm-pr-lib.sh:615- After a local deployment leaves the regular poll template unreadable to the watcher account, the new file-type check accepts an intact registration. Bash then fails to open the script, and the watcher discards the error, so every poll cycle skips the forge query without a rejection wake until permissions are restored. This is uncommon but deterministic. The old comparison rejected unreadable templates. Restore the readability check in the shared validator. Round 1 added early symlink rejection at bin/fm-pr-lib.sh:470, where preparation already reads the template at :511. The shared check also covers publication at bin/fm-pr-lib.sh:591 and bin/fm-pr-check.sh:270, snapshot capture and revalidation at bin/fm-pr-lib.sh:643 and :662, stale receipt handling at :859, watcher dispatch and deferral at bin/fm-watch.sh:3307 and :3322, and the armed-poll checks at bin/fm-landing.sh:173 and bin/fm-todo-project.sh:476.✅ **Test** - passed
✅ No issues found.
bash tests/fm-pr-check-security.test.shbash tests/fm-pr-check-handoff.test.shbash tests/fm-check-unregister.test.shbash tests/fm-landing.test.shRanfm-pr-check.sh <id> https://github.com/o/r/pull/1,fm-watch.sh, andfm-wake-drain.shin disposable copies of the base and target commits with synthetic forge responses. Captured CLI output, watcher exit statuses, forge calls, template execution, and poll-file preservation.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.