Skip to content

fix: migrate existing PR merge watches during updates - #7152

Open
0x7067 wants to merge 10 commits into
kunchenguid:mainfrom
0x7067:fm/fm-update-migrate-pr-watches
Open

0x7067 wants to merge 10 commits into
kunchenguid:mainfrom
0x7067:fm/fm-update-migrate-pr-watches

Conversation

@0x7067

@0x7067 0x7067 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Make firstmate updates migrate existing PR merge watches instead of refusing them.

After the 2026-10-12 update to 20dcbf9 (the Forgejo forge change, #4395, which rewrote bin/fm-pr-poll.sh), firstmate-dev's PR merge watches for kunchenguid/firstmate PRs 6813, 6816 and 6863 were refused by the watcher with "check: rejected unauthenticated state checks: state/.check.sh", because each armed state/<task>.check.sh held the old program bytes. Merge detection silently stopped. Re-registering each with bin/fm-pr-check.sh <task> <pr-url> restored them.
bin/fm-update.sh runs fm-procevent-when.sh rebind-all for the primary and local second-mate homes, but the remote second-mate homes did not get their watches migrated.
Expected: an update keeps every home's existing PR watches accepted, local and remote.

What Changed

  • Re-arm authenticated PR merge watches against the current poll program during updates across primary, local, registry-only, and remote secondmate homes.
  • Add guarded, idempotent migration that preserves task metadata, refuses invalid watches, and reports migration outcomes.
  • Add startup recovery, document the one-time rollout for older updaters, and cover migration, authentication safeguards, and home routing with regression tests.

Risk Assessment

✅ Low: The migration is bounded by existing authentication and publication safeguards and conforms to the accepted one-time rollout contract.

Testing

Focused regressions and live CLI scenarios passed for migration across disposable primary, local, and remote homes, documented rollout recovery, idempotence, device-record changes, and authentication guards. Captured product transcripts and cleaned all temporary workspace files.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Update primary and local homes and sync a remote home; authenticated historical watches migrate without changing task metadata. ✅ pass live live-migration.log
Repeat updates and remote sync; migrated watches remain current without another migration. ✅ pass live live-migration.log
Install the release using the old updater, then run the documented one-time session start in each home; valid watches recover and altered watches remain refused. ✅ pass live live-rollout.log
Run detect-only bootstrap against historical registrations; it leaves them unchanged. ✅ pass live live-rollout.log
Migrate a historical watch with changed recorded device numbers; its intact authenticated registration recovers. ✅ pass live live-migration.log
Attempt migration after inode replacement, byte alteration, changed PR identity, inconsistent device identities, or pending retirement; each registration is refused and preserved. ✅ pass live live-guards.log
Evidence: Live migration, repeat update, and device-change transcript

Source: Live migration, repeat update, and device-change transcript

$ FM_HOME=<primary> bin/fm-update.sh
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  2 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
firstmate: updated 28c81f5..aaf95f4 (instructions changed: bin)
no watches registered
PR watch refused: state/tampered.pr-poll-registration
PR watches: 1 migrated, 0 current, 1 refused
secondmate local: updated 28c81f5..aaf95f4 (instructions changed: bin)
no watches registered
PR watch refused: state/tampered.pr-poll-registration
PR watches: 1 migrated, 0 current, 1 refused
reread-firstmate: yes
restart-secondmates: none
nudge-secondmates: none
$ FM_HOME=<remote> bin/fm-remote-secondmate-control.sh sync remote
PR watch refused: state/tampered.pr-poll-registration
PR watches: 1 migrated, 0 current, 1 refused
synced: aaf95f4ccdfdca7dd3b4fdd46f58ce4b7cecefb0 instr=bin
primary: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
local: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
remote: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
$ FM_HOME=<primary> bin/fm-pr-check.sh migrate-all # historical poll plus renumbered device
PR watch refused: state/tampered.pr-poll-registration
PR watches: 1 migrated, 0 current, 1 refused
renumbered device: intact historical watch authenticates against current poll after migration
$ FM_HOME=<primary> bin/fm-update.sh # repeat
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
firstmate: already current
PR watch refused: state/tampered.pr-poll-registration
PR watches: 0 migrated, 1 current, 1 refused
secondmate local: already current
PR watch refused: state/tampered.pr-poll-registration
PR watches: 0 migrated, 1 current, 1 refused
reread-firstmate: no
restart-secondmates: none
nudge-secondmates: none
$ FM_HOME=<remote> bin/fm-remote-secondmate-control.sh sync remote # repeat
PR watch refused: state/tampered.pr-poll-registration
PR watches: 0 migrated, 1 current, 1 refused
current: aaf95f4ccdfdca7dd3b4fdd46f58ce4b7cecefb0
$ FM_HOME=<primary> bin/fm-session-start.sh

================================================================================
SESSION START - ~/.no-mistakes/worktrees/159e9a668321/01M4RGADZCQ2ZP4DVYY9FKMAEX/.phase-tmp/live.NEen7V/primary
================================================================================

LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 2263325

HOME ROLE
--------------------------------------------------------------------------------
fm-role: user (default)
Evidence: Old-updater rollout and one-time startup recovery

Source: Old-updater rollout and one-time startup recovery

$ FM_HOME=<primary> bin/fm-update.sh
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  2 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
firstmate: updated e01f6b1..79a4af4 (instructions changed: bin)
no watches registered
secondmate local: updated e01f6b1..79a4af4 (instructions changed: bin)
reread-firstmate: yes
restart-secondmates: none
nudge-secondmates: none
$ FM_HOME=<remote> bin/fm-remote-secondmate-control.sh sync remote
synced: 79a4af4ecc7cd35404feb21e676f31a353fcb3d8 instr=bin
primary: old updater installed the new release; intact historical watch still awaits the documented one-time step
primary: detect-only startup left the historical registration unchanged
$ FM_HOME=<primary> bin/fm-session-start.sh # documented one-time step
LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 2263325
local: old updater installed the new release; intact historical watch still awaits the documented one-time step
local: detect-only startup left the historical registration unchanged
$ FM_HOME=<local> bin/fm-session-start.sh # documented one-time step
LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 2263325
remote: old updater installed the new release; intact historical watch still awaits the documented one-time step
remote: detect-only startup left the historical registration unchanged
$ FM_HOME=<remote> bin/fm-session-start.sh # documented one-time step
LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 2263325
primary: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
local: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
remote: current watch authenticates; altered watch remains refused; task metadata and refused program unchanged
Evidence: Altered-registration refusal transcript

Source: Altered-registration refusal transcript

$ FM_HOME=<swapped-check> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
swapped-check: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<swapped-sidecar> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
swapped-sidecar: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<altered-check> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
altered-check: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<altered-sidecar> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
altered-sidecar: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<changed-pr> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
changed-pr: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<partial-device> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
partial-device: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions
$ FM_HOME=<retirement> bin/fm-pr-check.sh migrate-all
PR watch refused: state/task.pr-poll-registration
PR watches: 0 migrated, 0 current, 1 refused
retirement: exit=1; registration, program, sidecar and metadata preserved byte-for-byte with the same identities and permissions

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Update the primary and a registry-only local home; historical authenticated watches become accepted ✅ pass live live.txt: CURRENT UPDATER
Converge a remote home's checkout through its host-local handler; its historical watch becomes accepted ✅ pass live live.txt: REMOTE HOST-LOCAL SYNC
Repeat migration and remote sync; current watches remain current without re-registration ✅ pass live live.txt: REPEAT REMOTE HOST-LOCAL SYNC and repeated migrate-all output
Present altered check bytes or changed PR identity; migration refuses the watch and preserves its bytes and valid task metadata ✅ pass live live.txt; startup-guards.txt; security.txt
Install the release with the old updater, then perform the documented one-time session start; the stale watch becomes accepted without another update ✅ pass live live-rollout.txt
Run detect-only bootstrap before normal startup; detect-only leaves the watch stale and normal startup repairs it ✅ pass live startup-guards.txt
Migrate a historical watch carrying previous device bindings; the real migration command restores current authentication ✅ pass live live.txt: HISTORICAL WATCH WITH PREVIOUS DEVICE BINDINGS; security.txt
  • test_update_migrates_only_authenticated_pr_polls and test_migration_after_device_renumber_and_update, executed through a temporary targeted runner
  • test_update_routes_pr_migration_to_primary_and_local_mate and test_old_updater_rollout_migrates_watches_after_one_time_session_start, executed through a temporary targeted runner
  • bash .phase-tmp/live.sh: real updater, remote host-local sync, repeated migration, altered-watch refusal, and previous-device registration recovery
  • bash .phase-tmp/rollout.sh: old updater installs current scripts, followed by real fm-session-start.sh
  • bash .phase-tmp/startup-guards.sh: real detect-only bootstrap and normal session start
  • Removed disposable homes and temporary runners; verified clean git status --short

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Update primary and local homes and sync a remote home; authenticated historical watches migrate without changing task metadata. ✅ pass live live-migration.log
Repeat updates and remote sync; migrated watches remain current without another migration. ✅ pass live live-migration.log
Install the release using the old updater, then run the documented one-time session start in each home; valid watches recover and altered watches remain refused. ✅ pass live live-rollout.log
Run detect-only bootstrap against historical registrations; it leaves them unchanged. ✅ pass live live-rollout.log
Migrate a historical watch with changed recorded device numbers; its intact authenticated registration recovers. ✅ pass live live-migration.log
Attempt migration after inode replacement, byte alteration, changed PR identity, inconsistent device identities, or pending retirement; each registration is refused and preserved. ✅ pass live live-guards.log
  • TMPDIR=&#34;$PWD/.phase-tmp&#34; bash tests/.phase-pr.test.sh: selected migration and device-renumbering regressions.
  • TMPDIR=&#34;$PWD/.phase-tmp&#34; bash tests/.phase-update.test.sh: migration routing and old-updater rollout regressions.
  • TMPDIR=&#34;$PWD/.phase-tmp&#34; bash tests/.phase-sync.test.sh: remote migration routing; the selector also executed the scratchpad2 isolation regression.
  • bash .phase-live.sh: real updater, remote sync, migration, repeat runs, and session start in disposable homes.
  • MODE=rollout bash .phase-live.sh: old-release update followed by detect-only bootstrap and documented session-start recovery.
  • bash .phase-guards.sh: seven adversarial registration mutations against the real migration command.
  • Preserved drivers and command transcripts in the evidence directory; removed disposable homes and temporary runners; verified clean git status.
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@0x7067
0x7067 force-pushed the fm/fm-update-migrate-pr-watches branch from 248aa7c to e5b6c7f Compare October 16, 2026 03:10
@0x7067 0x7067 changed the title fix: preserve PR merge watches across firstmate updates fix: migrate existing PR merge watches during updates Oct 16, 2026
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