Repository navigation
fix(bin): retire public follow-ups in remote homes - #3479
Merged
Merged
Conversation
…te home A public-followup loop bound to a REMOTE secondmate could never be closed. `clear_public_followup_link` (bin/fm-public-followup.sh:701) required an absolute recorded `work_home_path` for a `secondmate:*` work home, but a remote route has no local path on this machine, so registration records that field empty (bin/fm-public-followup.sh:291). Every close ran that clear first, so `retire` died with "could not clear the legacy X link ... retained for reconciliation" forever, and `deliver` posted the public reply and then stranded the loop at `posted`. `--force` never covered that step. The clear now goes to the remote home over that route's SSH transport, running `fm-x-followup.sh --clear <work-id>` through `bin/fm-on.sh`. The route is decided from `data/secondmates.md` before any local path is consulted, so a same-named local directory can never stand in for a remote home, and registrations already on disk retire without needing a new field. `fm-on.sh` passes ssh's status through, so 255 stays the established "delivered but completion unknown" result this codebase already reconciles: the close is refused, the registration and the remote link are left exactly as they were, and the message names the unknown completion instead of claiming a definite failure. Local secondmate and `main` work homes are untouched, and `--force` still governs only the unresolved-obligation refusal. Three regression cases drive a remote route end to end, faking only the ssh binary at the FM_SSH_BIN seam and then running the real remote entrypoint against a local checkout, so the clear that must reach the remote home actually happens there.
Confidence Score: 4/5The PR does not yet appear safe to merge because guarded no-link retirement can still race concurrent publication and remove the only reconciliation registration before a live link is installed. The guarded path returns success at bin/fm-x-lib.sh:1007 before acquiring the metadata lock, while link publication later acquires that lock and can atomically install a link; the previously reported absence-publication race therefore remains outstanding. Files Needing Attention: bin/fm-x-lib.sh Reviews (5): Last reviewed commit: "no-mistakes(document): Clarify remote pu..." | Re-trigger Greptile |
…e is decided under the metadata lock whenever publication is possible. Added a behavioral concurrency regression test. Verified with fm-x-mode and fm-public-followup suites, Bash syntax checks, diff checks, and bin/fm-lint.sh
…ocked absence decision when a publisher already owns the metadata lock in a non-writable directory. Added a behavioral concurrency regression test. Verified with fm-x-mode, fm-public-followup, syntax/diff checks, and fm-lint
… clears when the metadata parent is non-writable, including apparent link absence. Added a behavioral regression with a publisher waiting to create the lock, updated remote-retirement expectations and verification docs. Passed fm-x-mode, fm-public-followup, fm-lint, documentation audience, Bash syntax, and diff checks
…-retire-remote-home-r1
Intent
Fix a fundamental design gap in bin/fm-public-followup.sh: retire can never complete for a public-followup loop whose work lives in a REMOTE secondmate home, and --force does not cover the failing step.
Reported symptom: 'fm-public-followup.sh retire pf-backpass-hermes --reason ...' (state=delivered, work_home=secondmate:mini-default, a REMOTE route) dies with 'could not clear the legacy X link ... retained for reconciliation', so the loop can never be retired. deliver hit the same step AFTER posting the public reply, stranding the loop at posted with the reply already public.
Root cause: clear_public_followup_link() required an absolute recorded work_home_path for a 'secondmate:*' work home, but a REMOTE secondmate route records work_home_path= (empty) at registration because a remote home has no local path on this machine.
Delivered work, in the order the user authorized it:
The clear now runs in the remote home over that route's transport via bin/fm-on.sh, with the established unknown-completion semantics (fm-on.sh passes ssh's status through; 255 means completion unknown, so the close refuses and retains rather than reporting success or a definite failure, matching bin/fm-teardown.sh and bin/fm-remote-readiness-lib.sh). Route placement is decided from data/secondmates.md BEFORE any local path is consulted, so a same-named local directory can never stand in for a remote home. The user explicitly REJECTED the alternative of persisting route identity in the registration record, because it would not retire the registrations already stuck on disk with no route recorded, which is the reported bug.
Identity guard, authorized after review: the remote clear verifies the target's Relay request identity against the registration's existing request_id before mutating. This closes a reassignment hazard where a reused stable secondmate ID could clear an unrelated replacement home's link. No new durable registration data was added; the registration's existing request_id is the only identity source.
Guarded-mode strictness, authorized after further review: readable state with no link succeeds (nothing to mutate); readable state with a matching link is cleared; identity mismatch, unreadable or unsafe state, non-writable state, and unknown transport completion all REFUSE through the existing retained-for-reconciliation path. Never clear on uncertainty, and never report success for a clear that did not happen.
Bounded lock wait, authorized explicitly as a reliability fix at cause after an advisory reviewer finding was verified against the code: the writability precondition narrows but cannot close the wedge window, because the parent can turn non-writable between that check and lock creation and a live lock holder is indistinguishable from it at the acquire. fm_lock_acquire_wait is an unbounded 'while ! try; do sleep 0.1; done', so either case retried forever and deliver/retire WEDGED with nothing reported. The guarded clear now acquires through fm_lock_acquire_wait_bounded (the primitive main gained in fix(bin): bound wake drain presentation lock waits #3475), with FMX_LINK_CLEAR_LOCK_TIMEOUT defaulting to 10 seconds, and refuses on timeout. A wedge is worse than either outcome the guard defines, and this path runs unattended over the transport. Current main was merged in to obtain that primitive.
Deliberate decisions a reviewer reading only the diff would not know:
Known residual, deliberately deferred by the user to a separate follow-up ship item and NOT to be fixed here:
Constraints honored throughout: bash 3.2 safe (macOS default), no bash-4+ constructs; bin/*.sh shellcheck-clean via bin/fm-lint.sh; one sentence per line in tracked Markdown with plain dashes, never em dashes; tests colocated in tests/ extending the existing suite rather than a new runner; the maintainer-verification record docs/verification/public-followup.md updated because behavior changed; and no co-author trailer of any kind on any commit.
Acceptance criteria met: the bug was reproduced END-TO-END FIRST (a registration with a REMOTE secondmate work home and an empty work_home_path, failing before and completing after); local-secondmate and main work-home closes behave identically to before; and the regressions exercise the remote route hermetically, faking only the ssh binary at the FM_SSH_BIN process seam (the seam tests/fm-on.test.sh already uses) and then running the REAL tracked fm-remote-entrypoint.sh against a local checkout, so the clear genuinely executes in the remote home. The bounded-wait regression holds the metadata lock with a live process while leaving the state directory writable, so its refusal can only come from the bound; against the unbounded wait that case does not terminate at all. 61 cases pass in tests/fm-public-followup.test.sh, plus fm-x-mode (110) and fm-wake-queue (32), with bin/fm-lint.sh and bin/fm-doc-audience-check.sh clean.
What Changed
fm-on.shfor remote secondmate work homes, allowing delivery and retirement without a local work path.--force, and unknown completion.Risk Assessment
✅ Low: The guarded remote clear is well-bounded, preserves local behavior, verifies identity before mutation, handles no-op absence correctly, and fails closed on unsafe state or bounded-lock failure.
Testing
The initial 180-second public-followup run exceeded its command limit, then the complete targeted suite passed with a longer limit alongside focused X-mode and wake-lock tests; a manual CLI transcript demonstrated that a remote secondmate registration with an empty local path retires successfully, clears its remote link, removes the open registration, and writes the receipt.
Evidence: Remote retirement end-to-end CLI transcript
Source: Remote retirement end-to-end CLI transcript
Evidence: Targeted public-followup behavioral test transcript
Source: Targeted public-followup behavioral test transcript
Evidence: Targeted X-mode test transcript
Source: Targeted X-mode test transcript
Evidence: Targeted wake-queue and bounded-lock test transcript
Source: Targeted wake-queue and bounded-lock test transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (2) ✅
bin/fm-x-lib.sh:996- This contradicts the required criterion that readable remote state with no link must succeed regardless of writability. A mode-0555 readable state containing an unlinked task record fails the unconditional-wcheck, so retirement retains the registration despite requiring no mutation. Apply writability only after confirming a matching link is present, and restore the corresponding success regression and verification text; the current test at tests/fm-public-followup.test.sh:2556 asserts the opposite behavior.tests/fm-public-followup.test.sh:2608- The lock-timeout regression has no independent test-harness deadline: its elapsed-time assertion runs only after the synchronous command returns. If guarded acquisition becomes unbounded again, the live holder remains unreaped and the suite stalls instead of reporting failure. Run the command under an external deadline and guarantee holder cleanup on timeout.🔧 Fix: Harden lock-timeout regression with independent deadline
1 error still open:
bin/fm-x-lib.sh:996- The intent requires “readable state with no link succeeds ... regardless of whether the state directory is writable,” but guarded clear unconditionally requires-wbefore inspecting the record. A readable mode-0555 state containing an unlinked task therefore retains the registration forever despite needing no mutation. Apply writability only when clearing a present matching link, and restore the corresponding success expectation in tests/fm-public-followup.test.sh:2592 and documentation. This directly contradicts authoritative behavior, so the correction requires user review.🔧 Fix: Restore no-op guarded clears on read-only state
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
tests/fm-public-followup.test.shwith a 180-second limit (timed out after remote reassignment coverage due to the command limit)tests/fm-public-followup.test.shrerun with a 600-second limittests/fm-x-mode.test.shtests/fm-wake-queue.test.shManual end-to-end remote-route retirement using the realfm-public-followup.sh,fm-on.sh, and tracked remote entrypoint through the fake SSH process seam; verified emptywork_home_path, remote link removal, registration removal, and persisted retirement receipt✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.