Skip to content

fix: preserve PR merge poll authentication after relaunch - #34

Merged
peterOC26 merged 2 commits into
mainfrom
fm/fm-relaunch-pr-poll-r1
Oct 24, 2026
Merged

peterOC26 merged 2 commits into
mainfrom
fm/fm-relaunch-pr-poll-r1

Conversation

@peterOC26

@peterOC26 peterOC26 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Intent

Especially take care of the firstmate issue we have.

The firstmate issue: after bin/fm-control.sh <id> relaunch on a task that already has a PR, the watcher rejects that task's armed PR merge poll ("check: rejected unauthenticated state checks: state/.check.sh"), so a green or merged PR is never noticed. Seen 2026-10-08/09 and five times on 2026-10-23 (pv-voice-checked-readback-b1, pv-online-preview-rough-edges-e1, pv-tier2-second-runner-r1, pv-no-receipt-fee-label-f1, pv-place-by-quote-p1 earlier).
Root cause found 2026-10-23: bin/fm-spawn.sh --relaunch writes control_relaunch_tx= after the preserved pr=/pr_head= lines (around fm-spawn.sh line 5937), and fm_pr_metadata_identity_parse (bin/fm-pr-lib.sh around line 427) treats any unknown key after pr= as invalid, so fm_pr_poll_artifacts_content_valid fails. Re-running fm-pr-check.sh does not fix it while that line sits after pr=. Current manual workaround: move the control_relaunch_tx= line above pr= in state/.meta.

What Changed

  • Accept control_relaunch_tx metadata after PR identity fields so armed PR merge polls remain authenticated after relaunch.
  • Add regression coverage for the marker before and after PR identity fields, while preserving rejection of unrelated trailing keys.
  • Document that PR merge monitoring continues after relaunch without re-arming the poll.

Risk Assessment

The parser exception was chosen instead of reordering the relaunch writer because accepting this exact known key also fixes metadata already written in the broken order. Existing records with control_relaunch_tx= after pr=/pr_head= require no manual metadata edit. Unknown trailing keys, including similarly named keys, remain rejected.

Firstmate approved the full-relaunch test limitation based on the before/after parser reproduction, the regression checks, and compatibility with existing records. A live PR-task relaunch will be confirmed after merge.

✅ Low: This is a one-arm parser change. The shared metadata parser now accepts the exact control_relaunch_tx= key after pr=, which is the line fm-spawn.sh --relaunch appends (fm-spawn.sh:5951). Every poll-authentication caller goes through this parser, so the fix lands at the earliest shared boundary. The marker is never treated as PR identity, the poll registration does not hash the meta file, and duplicate pr= lines and other unknown trailing keys, including near-miss names, are still refused.

Testing

The base parser reproduced the reported rejection; the target watcher detected a real merged PR in both marker positions and preserved malformed-metadata guards. The focused regression passed only with the fix. CLI transcripts were captured and fixtures cleaned up. Full worker relaunch was blocked by Codex folder trust.

  • Live validation: ⚠️ inconclusive - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
With a relaunch marker after the preserved PR fields, the watcher detects a real merged PR, queues the merge notification, and retires its poll ✅ pass live Live watcher transcript: baseline-after and target-after
Placing the relaunch marker before the PR fields still permits merge detection ✅ pass live Live watcher transcript: target-before
Appending an unrelated key or forged relaunch-marker name causes the watcher to reject the poll without publishing a merge notification ✅ pass live Live watcher transcript: unknown-key and forged-key
Duplicate PR identity and malformed head metadata remain rejected despite an accepted relaunch marker ✅ pass live Live watcher transcript: duplicate-pr and invalid-head
Relaunch a real Codex worker with an existing armed PR poll and subsequently observe its merge ⏸️ untested no Codex stopped at folder trust. Accepting would save user-level configuration outside the permitted worktree. Provide a pretrusted, authenticated disposable CODEX_HOME inside the worktree, or authorize…
Evidence: Live watcher reproduction and guard checks

Source: Live watcher reproduction and guard checks

=== baseline-after ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
$ FM_HOME=<lab> base/bin/fm-watch.sh
check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/baseline-after/state/a-pr.check.sh
exit=0
poll retained; no merge notification published
durable wake queue:
1792773926	1	check	unauthenticated-state-checks	check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/baseline-after/state/a-pr.check.sh

=== target-after ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/target-after/state/a-pr.check.sh: merged
exit=0
persisted canonical merge notification:
fm-pr-poll-merge-notified-v1
github
github.com
peterOC26/firstmate
33
poll artifacts retired: yes
durable wake queue:
1792773933	1	check	merged-a-pr-https://github.com/peterOC26/firstmate/pull/33	check: merge landed: a-pr https://github.com/peterOC26/firstmate/pull/33 external

=== target-before ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
control_relaunch_tx=12345.20261023T120000Z.6789
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/target-before/state/a-pr.check.sh: merged
exit=0
persisted canonical merge notification:
fm-pr-poll-merge-notified-v1
github
github.com
peterOC26/firstmate
33
poll artifacts retired: yes
durable wake queue:
1792773940	1	check	merged-a-pr-https://github.com/peterOC26/firstmate/pull/33	check: merge landed: a-pr https://github.com/peterOC26/firstmate/pull/33 external

=== unknown-key ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
unrelated=value
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/unknown-key/state/a-pr.check.sh
exit=0
poll retained; no merge notification published
durable wake queue:
1792773948	1	check	unauthenticated-state-checks	check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/unknown-key/state/a-pr.check.sh

=== forged-key ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
control_relaunch_tx_forged=value
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/forged-key/state/a-pr.check.sh
exit=0
poll retained; no merge notification published
durable wake queue:
1792773954	1	check	unauthenticated-state-checks	check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/forged-key/state/a-pr.check.sh

=== duplicate-pr ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
pr=https://github.com/peterOC26/firstmate/pull/33
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/duplicate-pr/state/a-pr.check.sh
exit=0
poll retained; no merge notification published
durable wake queue:
1792773960	1	check	unauthenticated-state-checks	check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/duplicate-pr/state/a-pr.check.sh

=== invalid-head ===
$ FM_HOME=<lab> bin/fm-pr-check.sh a-pr https://github.com/peterOC26/firstmate/pull/33
exit=0
persisted PR identity and relaunch transaction:
pr=https://github.com/peterOC26/firstmate/pull/33
pr_head=f1f2394b7b114aae1618716720ab3ee9705ba612
control_relaunch_tx=12345.20261023T120000Z.6789
pr_head=not-a-commit
$ FM_HOME=<lab> target/bin/fm-watch.sh
check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/invalid-head/state/a-pr.check.sh
exit=0
poll retained; no merge notification published
durable wake queue:
1792773967	1	check	unauthenticated-state-checks	check: rejected unauthenticated state checks: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/invalid-head/state/a-pr.check.sh

private tmux server stopped; no default socket used
Evidence: Full relaunch attempt blocked at Codex folder trust

Source: Full relaunch attempt blocked at Codex folder trust

$ ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle
~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle
exit=0
$ git init -q -b main ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/repo

exit=0
$ git add README.md

exit=0
$ git -c user.name=Lab -c [email protected] commit -qm initial

exit=0
$ git clone --bare -q ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/repo ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/origin.git

exit=0
$ git remote add origin ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/origin.git

exit=0
$ treehouse get --lease --lease-holder ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/a-live/live-validation --json --no-fetch
A new version of treehouse is available: v2.3.0 → v3.1.5
Run "treehouse update" to update

🌳 Setting up worktree...
🌳 Leased worktree at ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo. Run 'treehouse return ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo' to release it.
{"path":"~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo","lease_id":"86d911e383605a01e85ea6ce373349ad","lease_holder":"~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/a-live/live-validation","leased_at":"2026-10-23T18:49:16.145536195+02:00"}
exit=0
Treehouse lease: {"path": "~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo", "lease_id": "86d911e383605a01e85ea6ce373349ad", "lease_holder": "~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/a-live/live-validation", "leased_at": "2026-10-23T18:49:16.145536195+02:00"}
$ git switch -c fm/a-live
Switched to a new branch 'fm/a-live'
exit=0
$ tmux -S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/s new-session -d -s relaunch-lab -n fm-a-live -x 120 -y 40 -c ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo

exit=0
$ bash -c . "$1/bin/fm-wake-lib.sh"; fm_treehouse_slot_owner_claim "$2" a-live "$3" bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo-f83914/1/repo ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle

exit=0
$ tmux -S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/s send-keys -t relaunch-lab:fm-a-live -l codex --dangerously-bypass-approvals-and-sandbox --disable hooks "Reply READY and wait. Do not use tools or modify files. This is a disposable CLI lifecycle check."

exit=0
$ tmux -S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/s send-keys -t relaunch-lab:fm-a-live Enter

exit=0
$ tmux -S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/s capture-pane -p -t relaunch-lab:fm-a-live -S -80
Folder access
  ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/pool/.treehouse/repo
  -f83914/1/repo

  Note: You’re in a subdirectory of a Git project. Trusting will apply to the repository root:
  ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/lifecycle/repo

  Trust this folder? Codex can read, edit, and run files here, subject to your permission settings. Folder settings
  can run code automatically, even without a model request. Continue only if you trust these files. Your trust
  decision will be saved.

› 1. Trust and continue
  2. Quit

  enter continue · esc quit
exit=0
BLOCKER: Codex is blocked at folder trust. Continuing saves trust in user tool configuration outside the worktree, which the workspace boundary forbids. Provide a pretrusted authenticated disposable CODEX_HOME inside the worktree, or authorize saving trust for this fixture.
$ tmux -S ~/.no-mistakes/worktrees/7f0ec18181b6/01M5MT6K4CYJM29EYMY18ZSE8S/.nm-test-pr/s kill-server

exit=0
- Outcome: ⚠️ 1 warning across 1 run (8m22s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (4 of 5 scenarios were driven live against the product); untested: Relaunch a real Codex worker with an existing armed PR poll and subsequently observe its merge
  • Live validation: ⚠️ inconclusive - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
With a relaunch marker after the preserved PR fields, the watcher detects a real merged PR, queues the merge notification, and retires its poll ✅ pass live Live watcher transcript: baseline-after and target-after
Placing the relaunch marker before the PR fields still permits merge detection ✅ pass live Live watcher transcript: target-before
Appending an unrelated key or forged relaunch-marker name causes the watcher to reject the poll without publishing a merge notification ✅ pass live Live watcher transcript: unknown-key and forged-key
Duplicate PR identity and malformed head metadata remain rejected despite an accepted relaunch marker ✅ pass live Live watcher transcript: duplicate-pr and invalid-head
Relaunch a real Codex worker with an existing armed PR poll and subsequently observe its merge ⏸️ untested no Codex stopped at folder trust. Accepting would save user-level configuration outside the permitted worktree. Provide a pretrusted, authenticated disposable CODEX_HOME inside the worktree, or authorize…
  • python3 .nm-test-pr/live.py: ran real PR registration and watcher commands against merged GitHub PR #33 in isolated lab homes
  • Repeated the watcher reproduction with the base parser: reproduced the exact unauthenticated-check rejection
  • TMPDIR=&#34;$PWD/.nm-test-pr&#34; bash tests/.nm-pr-focused.sh: selected test_relaunch_metadata_keeps_poll_authenticated; passed
  • TMPDIR=&#34;$PWD/.nm-test-pr&#34; bash tests/.nm-pr-baseline.sh: the same regression failed against the base parser as expected
  • python3 .nm-test-pr/relaunch.py: attempted real Codex lifecycle verification using a real Treehouse lease and a private 120×40 tmux session
  • Stopped private tmux servers, removed transient fixtures and runners, and confirmed a clean worktree
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

peterOC26 and others added 2 commits October 23, 2026 18:37
Accept the exact control_relaunch_tx metadata key after preserved PR fields. This also handles existing broken-order records while unknown trailing keys remain rejected.
@peterOC26
peterOC26 merged commit 6585597 into main Oct 24, 2026
19 of 20 checks passed
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