Repository navigation
fix(bin): keep armed merge polls valid across remounts, respawns and relaunches - #6249
AgardnerAU wants to merge 9 commits into
Conversation
[Medium impact] The PR appears safe to merge; no blocking issues remain. Reviews (7) · Last reviewed commit: "no-mistakes(ci): ci-1 (Behavior portable..." · Reviewed by Greptile |
2c4a65a to
12a4fea
Compare
|
Merged current main into this branch (one conflict in bin/fm-spawn.sh, resolved by keeping both the new base_branch key and this PR's pr/pr_head keys). The branch is up to date with current main and ready for CI. |
|
Speaking as Kun's firstmate: thank you @AgardnerAU — keeping armed PR merge watches alive across APFS VISION (each rule):
Contract-class: restore. Armed PR poll authentication already promised to survive process death and relaunch; APFS device renumber was falsely rejecting unchanged files. Recorded identity now matches on inode (device still proven live via private-file checks on the state volume). Replaced files (new inode) still refuse. Security FYI (not a captain card): this touches the PR-poll authentication surface ( Where it stands: attestation MATCH |
|
Speaking as Kun's firstmate: thanks @AgardnerAU. Main has moved: #7172 landed and touched Contract-class: restore (unchanged). A restart is supposed to be a non-event, and here an armed merge watch survives a volume renumber or a relaunch instead of dying. One note for whoever reviews this later, with no change asked: a fresh spawn over an existing ship or scout record now also carries the record's Status: waiting on you for the conflict only. After that, if CI is green on a green main, this can auto-merge. It overlaps #5435, #6245 and #6760 in |
|
Speaking as Kun's firstmate: thanks @AgardnerAU — tip Contract-class: restore (unchanged). Armed merge watches surviving APFS VISION: all seven rules align. Security FYI (cron only, not a captain card): recorded PR-poll identity is inode-based with live device proof; covered by Outcome: waiting-ci. Main is red; no merge this wake. Live on this tip notes 2/7 (suites cover the rest; prior tips had fuller live). Once CI is green on a green main, this is on the auto-merge path. Overlaps |
|
Merged current main into this branch (head bcddb56f) and resolved the one conflict in bin/fm-spawn.sh. The new polytoken session binding from main now writes through the same pr=-block-preserving helper as traceparent, with a regression test. The earlier red jobs (Pi primary types, fixed upstream in #7248; remote-reply NUL capture) pass locally. Up to date with main and ready for CI; the workflow runs are awaiting maintainer approval. |
|
Speaking as Kun's firstmate: thanks @AgardnerAU for keeping this current. What changed since my 14 Oct stamp ( No-mistakes and live validation: the attestation matches Review and CI: I re-read the tip diff against main. It touches no workflows and no secrets, and it adds no new network targets. I approved the held fork runs on this head: CI Contract-class: restore (unchanged). A restart is supposed to be a non-event. Here an armed merge watch survives a volume renumber, respawn or relaunch instead of silently dying, and a replaced sidecar (new inode) is still refused. VISION.md (each rule):
Security FYI (carried, informational only): the PR-poll identity now matches on inode with a live device check. Outcome: waiting-ci. If CI and no-mistakes are green on this head, this is on the auto-merge path. It overlaps your #6245 in |
|
Merged current main into this branch (head d25d33a5) and resolved the one conflict in bin/fm-spawn.sh, keeping the pr= block preserved. It is up to date with main and ready for CI; the workflow runs are waiting for maintainer approval. |
|
Speaking as Kun's firstmate: thanks @AgardnerAU for keeping this current. The new head A correction to my earlier classification. I re-read the tip against current main rather than relying on my 14/18 Oct stamps. Main already has a device-shift path: VISION.md: one captain aligns · authority aligns (tampered/replaced artifacts still refused), but the identity relaxation is security-sensitive and is the captain's call · scripts own mechanics aligns · restart non-event aligns (the core purpose) · delegation aligns · vendor aligns · scope aligns. CI: main's own Linux portable serial jobs are red right now because the hosted ubuntu runner moved to 26.04. If the same serials go red here, that's on our side, not yours. This is not waiting on you. Once this head runs green, it goes to Kun as a merge-or-leave decision. It still overlaps your #6245 in |
|
Merged current main (including the runner-image pin from #7798) into this branch; head is now d7b0d5ae. It is up to date with main and ready for CI; the workflow runs are waiting for maintainer approval. |
|
Speaking as Kun's firstmate: thanks @AgardnerAU for bringing this up to date again. Head Waiting on you for one thing: Greptile's P2 thread on Contract-class: new-default (unchanged since my 26 Oct correction). The PR replaces main's device-shift re-record path with device-blind identity, and that's a security-relevant identity check. VISION: one captain aligns; authority aligns (replaced or tampered artifacts are still refused), but relaxing the identity check is Kun's call; scripts own the mechanics aligns; a restart is a non-event aligns (that's the core purpose); delegation, vendor and scope align. Once that thread is settled, we'll run the Full suite, and if it's green this goes to Kun as a merge-or-leave decision. Your #6245 still overlaps in |
6bc0316 to
9c38f65
Compare
…nd relaunches A merge poll registration recorded each file as device:inode, and APFS renumbers the device at every reboot, so every armed poll failed validation at once. Recorded identities now match by inode, with the file proven live on the state directory's own filesystem first. This replaces the watcher's locked re-record step, which is no longer needed, and also covers pending retirement receipts. The status presentation cursor, the open-decisions cursor, the seen markers, and the home-append ledger compared status file identities including the device, so a reboot replayed every task's whole history. Every status identity comparison now goes through one device-blind helper, mirrored in the Pi branch dispatcher. The custom check trust binding records only a content hash and needed no change. fm-spawn now ends every republished task record with the pr= block that the metadata parser requires as the tail: a relaunch writes its lifecycle keys ahead of it, and a fresh spawn over a ship or scout's existing record keeps the block, so the armed poll keeps naming the task's still-open PR. A rejected state check now names its cause in the wake, such as a task record with no pr= line, a key after the pr= block, a replaced file, or an unregistered custom check.
…d permissions). Rule that was broken: a published task record must keep owner-only mode (0600), whatever umask the caller inherits. In this file, `complete` (bin/fm-captain-hold.sh:1679) is the only path that stages and publishes a replacement for state/<id>.meta. The other staged files in that script already use `umask 077`. Fix: the staging redirection now runs in a subshell under `umask 077`, so $meta_tmp is created with 0600 before fm_backlog_atomic_transition publishes it. Test: I extended test_completion_attestation_keeps_an_armed_merge_poll_verifiable in tests/fm-captain-hold-lifecycle.test.sh. It sets the record to 0600, runs `complete --none` under `umask 022`, and asserts that the record is still exactly 0600 (`find -perm 0600`). The existing checks still pass: the pr= block stays last and the armed poll still authenticates. Before the fix, this test failed with the record at -rw-r--r--. After the fix it passes, and the full tests/fm-captain-hold-lifecycle.test.sh passes (54 ok, 0 not ok). `shellcheck -x` is clean on both files. As the user decided, I did not change ci-2
…34) that FM_PR_POLL_REJECTION in bin/fm-pr-lib.sh and FM_CUSTOM_CHECK_REJECTION in bin/fm-check-lib.sh are set but never read. Both are output variables that bin/fm-watch.sh reads after it sources the library, which shellcheck cannot see. I added the repository's usual `# shellcheck disable=SC2034 # Read by the sourcing watcher (bin/fm-watch.sh) on rejection.` comment above the flagged line in each file. FM_PR_META_REJECTION, the other new variable, is read inside its own library and needs no comment. Before the change, shellcheck 0.11.0 showed the same two warnings locally. After it, `shellcheck -x bin/fm-pr-lib.sh bin/fm-check-lib.sh bin/fm-watch.sh` passes with no warnings. Behavior portable parallel 1 is not caused by this PR, and I made no code change for it. Its only failing test is tests/fm-pi-primary-types.test.sh, with TS2339 errors ('prompt' does not exist on BeforeAgentStartEvent) in fm-branch-supervision.ts and fm-primary-pi-watch.ts. This PR does not change those files. The upstream main CI run at the base commit 6407052 (run 38316792015, job 115035229020) fails this same test with the same two errors. I did not run the behaviour tests locally; the change only adds the two comments
9c38f65 to
1a9c157
Compare
|
Speaking as Kun's firstmate: thank you @AgardnerAU for folding #8150 back in and settling the last thread. On |
…was tests/fm-watch-wedge-cap-unconfigured-parity.test.sh, and I reproduced it locally. In the upstream run, busy-rung1 showed `esc=-` where the branch showed `esc=1`. Cause: the test helper `mark_status_seen` always wrote the status "seen" marker with this branch's bin/fm-wake-lib.sh, including in the run that drives upstream main's watcher. Commit e64a0bf made `status_observed_signature` device-blind, so the branch now encodes the reported snapshot differently from upstream. Upstream's watcher therefore did not recognise the marker the branch had written. It raised a status-signal wake, and that wake hid the first busy rung, so the two traces diverged. Production code is not at fault. The rule that was broken: the fixture's seen marker must be written by the same bin/ tree as the watcher that reads it. `mark_status_seen` is the only place in the test that writes it, and `run_scenario` is its only caller. Fix (test only): `mark_status_seen` now takes a bin directory as its first argument. `run_scenario` passes `$(dirname "$watch")`, which is the upstream archive's bin/ for the baseline run and this branch's bin/ for the other runs. The device-blind remount behaviour and test_reported_status_survives_device_renumbering are unchanged. Verification: `bash tests/fm-watch-wedge-cap-unconfigured-parity.test.sh` failed before the change with the reported diff. After the change all 3 cases pass: the upstream parity, the value shapes and the configured cap. `shellcheck -x` on the test file is clean. ci-2 (Full suite) is only the aggregate gate. It failed because a lane job failed (`FM_CI_LANES_FAILED=true`), so the ci-1 fix also addresses it
|
Speaking as Kun's firstmate: thank you @AgardnerAU for the quick ci fix. The parity test now writes its seen marker with the same |
Intent
The developer (acting as captain through Firstmate steering messages) wanted the no-mistakes validation run for upstream firstmate PR 6249 to validate the commit already published on that PR, head 9c38f659 (test: reject allowed metadata key after PR line). The PR is about keeping merge polls verifiable when they survive remounts and respawns. The no-mistakes gate mirror still pointed at an older local commit, 1d1b6906, which is not on origin, so a normal rerun would have validated the wrong head. After the agent reported that no supported sync action existed, the captain authorised one action: force-update only the no-mistakes gate ref to the published 9c38 head, with a lease check, while keeping a backup of the old ref. Then the run was to proceed on the existing PR branch. The constraints were to rewrite or lose no commit, to start no other pipeline, and to process each steering inbox message in numeric order and then move it into handled/.
What Changed
fm_pr_poll_registration_device_shifted/rerecord_device_shifted_pr_poll) is removed. Status-file identity checks in the classify, wake, branch-outcome and Pi branch-dispatch code also ignore the device field (_fm_status_ident_same/statusIdentitySame).fm-spawn.shnow carries the existingpr=/pr_head=block from the task record (or the relaunch record) into the newly written record, and keeps it as the last block. A respawn or relaunch therefore keeps the poll's task record verifiable. The task-record parser rejects any key that comes after thepr=block.fm-watch.shrejects a check, it now gives the reason. Poll validation setsFM_PR_POLL_REJECTION, task-record parsing setsFM_PR_META_REJECTIONand custom-check validation setsFM_CUSTOM_CHECK_REJECTION, so the log tells a failing merge poll from a failing custom check.docs/architecture.mdand the regression tests are updated to match.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The inode-only identity match is safe because every caller (fm_pr_poll_artifacts_valid via content_valid, the three retirement validators, remove_exact and discard_obsolete) runs fm_pr_private_file_valid first, which binds the file to the state directory's live device. Recorded-to-recorded comparisons stay exact and consistent, because snapshot and receipt identities come from the registration. Status identity comparisons all go through one device-blind helper, mirrored in TypeScript. The spawn pr= block carry-forward and the rejection-cause messages behave as the commit message states.
Testing
I ran each of the PR's new or changed behaviour tests on its own. Each was a selective copy of its test file with only the chosen test calls at the end, or used FM_TEST_ONLY where the file supports it. These tests drive the real fm-pr-check, fm-watch, fm-wake-drain, fm-control, fm-captain-hold and fm-spawn scripts against fixture state. All of them passed with exit 0. They show three things. A poll armed before a device renumber keeps authenticating and detects merges. A tampered, replaced, hardlinked or foreign-device artifact is still refused. A respawn, relaunch, traced relaunch or completion attestation keeps the pr= block last, so the poll stays verifiable. I also checked the parser and identity helpers by hand against a throwaway directory, and kept the transcript. An allowed tail is accepted. A foreign key after pr= is rejected with the cause named (model after the pr= block, as in the latest commit). A renumbered device is tolerated. A byte-identical replacement with a new inode is refused. The full suite was not run, as instructed. There is no UI surface, so I captured no screenshots.
Evidence: fm-pr-check-security targeted run
Source: fm-pr-check-security targeted run
Evidence: fm-control-relaunch targeted run
Source: fm-control-relaunch targeted run
Evidence: fm-captain-hold-lifecycle targeted run
Source: fm-captain-hold-lifecycle targeted run
Evidence: fm-backlog-atomicity respawn run
Source: fm-backlog-atomicity respawn run
Evidence: fm-wake-drain renumber run
Source: fm-wake-drain renumber run
Evidence: fm-watch-triage renumber run
Source: fm-watch-triage renumber run
Evidence: Manual parser and identity transcript
Source: Manual parser and identity transcript
allowed-tail: accepted url=https://github.com/o/r/pull/7 foreign-key-after-pr: rejected - task record has key model after its pr= block two-pr-lines: rejected - task record has more than one pr= line no-pr: rejected - task record has no pr= line live identity 66306:947252: match renumbered device 67305:947252: match (remount tolerated) byte-identical replacement (new inode 947253): refused malformed recorded identity: refusedPipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash <selective copy of tests/fm-pr-check-security.test.sh>running test_device_renumbered_poll_stays_armed, test_device_renumbered_retirement_completes, test_renumbered_poll_still_refuses_tampered_artifacts, test_rejection_names_its_cause, test_direct_rearm_waits_for_poll_publication and test_registered_poll_survives_template_update_and_relaunchbash <selective copy of tests/fm-control-relaunch.test.sh>running test_relaunch_keeps_an_armed_merge_poll_verifiable and test_traced_relaunch_keeps_an_armed_merge_poll_verifiablebash <selective copy of tests/fm-captain-hold-lifecycle.test.sh>running test_completion_attestation_keeps_an_armed_merge_poll_verifiablebash <selective copy of tests/fm-backlog-atomicity.test.sh>running test_respawn_keeps_an_armed_merge_poll_verifiablebash <selective copy of tests/fm-wake-drain-unread-status.test.sh>running test_volume_renumber_does_not_replay_presented_historyFM_TEST_ONLY=test_reported_status_survives_device_renumbering bash tests/fm-watch-triage.test.shManual: sourced bin/fm-pr-lib.sh and ran fm_pr_metadata_identity_parse and fm_pr_recorded_identity_matches on a throwaway /tmp state directory✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.