Skip to content

fix(bin): report a Lavish source armed only after its listener is running - #5566

Merged
kunchenguid merged 6 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-2756-lavish-listener-ready
Sep 24, 2026
Merged

kunchenguid merged 6 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/upstream-2756-lavish-listener-ready

Conversation

@tiago-peixoto

@tiago-peixoto tiago-peixoto commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2756.

What Changed

  • Added fm-procevent.sh ensure-listening <source-id>. It starts a runner for the current registration when no claim blocks a launch, then waits up to the reconcile confirm window (FM_PROCEVENT_LAUNCH_CONFIRM_SECONDS) for this registration's live claim or launch stamp. It exits 0 once that evidence appears, 3 if a listener from an earlier registration still holds the source when the window ends, and 1 otherwise.
  • fm-procevent-lavish.sh arm now calls ensure-listening after it registers the source. It prints armed only when the listener is confirmed running. If the earlier listener is still live, it prints still-listening and exits zero. If confirmation fails, it exits non-zero and retires the source, unless list shows that something may still own the source.
  • Updated the process-event-sources skill, docs/configuration.md and the verification doc to describe the new arm contract. Added tests/fm-procevent.test.sh cases for: a claim delayed by a held source lock, a runner that never claims, a re-arm over a still-live earlier listener, a re-arm whose earlier claim is released inside the window, and a stale claim whose process group is still alive.

Risk Assessment

✅ Low: The new ensure-listening step reuses reconcile's existing evidence: a live claim bound to this registration or an advanced launch stamp. Its launch rule matches reconcile's, including the undisplaceable guard, and _start still refuses a task-owned source with an open round. The Lavish retire-on-miss path keeps list-based refusals for live, orphaned and task-owned states. The only remaining edge cases found are ones the user already declined in earlier rounds.

Testing

I drove arm live against the real lavish-axi and the real process-event runner in an isolated home. Fresh arm, re-arm while the earlier listener is live, retire then re-arm, and a listener that can never claim all behaved as intended. The armed listener also really polled the board: it captured the round when I ended the Lavish session. The draining-release, undisplaceable-claim and delayed-start cases were covered only by the new behaviour tests, not live, so they are marked untested. Those tests passed in a full run of tests/fm-procevent.test.sh, using a temporary copy that accepted this host's systemd --user subreaper. An earlier run of that copy exited silently in an unchanged home-sweep section. I tried one extra adversarial setup (a read-only claim root) and dropped it: the existing register step never returned, before any new code ran. The lab directory and the temporary test copy were removed and the worktree is clean. Overall: go.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Fresh arm of a real Lavish board prints armed only once its listener is running, and that listener really polls the board ✅ pass live live-arm-real-lavish.txt: arm rc=0 in 0.9s, list shows live, the real lavish-axi poll process is running, and lavish-axi end produced a captured .1.result
Re-arm while the earlier listener is still live: exit 0 with still-listening and never armed, no error, no second poller ✅ pass live live-arm-real-lavish.txt scenario 2: rc=0 after the 2s window, still-listening line plus note, list still live, exactly 1 lavish-axi poll process
Documented adoption path: retire, then arm again, reports armed with a live listener ✅ pass live live-arm-real-lavish.txt scenario 3
Adversarial: a listener that can never claim makes arm fail after the confirm window without printing armed, and keeps the registration retire refuses to remove ✅ pass live live-arm-real-lavish.txt scenario 4: rc=1 after 2.8s, 'error: listener is not running', 0 pollers, .source kept
Worker re-arm while the earlier generation's claim is still draining: once that claim is released inside the window, the new generation launches carrying the reply and reports armed ⏸️ untested no The earlier report did not establish a live result: this case ran only as the test 're-arm launches the new generation once a draining earlier claim is released' in tests/fm-procevent.test.sh, with a…
Adversarial: arm does not launch a second poller beside a stale claim whose process group is still alive (orphaned) ⏸️ untested no The earlier report did not establish a live result: this case ran only as the test 'arm does not launch beside a stale claim whose process group is alive' in tests/fm-procevent.test.sh, with a fake la…
A failed arm retires a registration that never started ⏸️ untested no The only live fixture I could build (a read-only claim root) hung in the existing register step, which this branch did not change, before ensure-listening ran. Driving this live needs a way to mak…
Evidence: Live arm transcript against real lavish-axi

Source: Live arm transcript against real lavish-axi

$ bin/fm-procevent-lavish.sh arm board.html   # scenario 1: fresh arm
registered: lavish-1787666762184a3e (lavish)
armed: lavish-1787666762184a3e
artifact: /tmp/fm-live-lavish-2756/board.html
rc=0 elapsed=.905644124s
$ bin/fm-procevent.sh list
SOURCE                       ADAPTER      OWNER      PENDING
lavish-1787666762184a3e      lavish       live       0
$ pgrep -af "lavish-axi poll"

$ bin/fm-procevent-lavish.sh arm board.html   # scenario 2: re-arm while generation 1 listener is live (FM_PROCEVENT_LAUNCH_CONFIRM_SECONDS=2)
registered: lavish-1787666762184a3e (lavish)
still-listening: lavish-1787666762184a3e
artifact: /tmp/fm-live-lavish-2756/board.html
note: an earlier listener is still live and serving this board; this registration takes effect only after the source is retired and armed again
rc=0 elapsed=3.365136956s
$ bin/fm-procevent.sh list
SOURCE                       ADAPTER      OWNER      PENDING
lavish-1787666762184a3e      lavish       live       0
$ pgrep -af "lavish-axi poll" | wc -l   # still exactly one poller
1
$ pgrep -af "board.html"   # the armed listener, now polling the real Lavish server
2337849 bash ~/.no-mistakes/worktrees/5284051b2355/01M3AFKSMGJQ55X00CCQ2N1N98/bin/fm-procevent-lavish.sh poll /tmp/fm-live-lavish-2756/board.html
2337993 ~/.local/share/mise/installs/node/22.23.1/bin/node ~/.local/bin/lavish-axi poll /tmp/fm-live-lavish-2756/board.html
2337994 bash ~/.no-mistakes/worktrees/5284051b2355/01M3AFKSMGJQ55X00CCQ2N1N98/bin/fm-procevent-lavish.sh poll /tmp/fm-live-lavish-2756/board.html
$ lavish-axi end board.html   # end the session so the real poll returns
session:
  file: /tmp/fm-live-lavish-2756/board.html
  status: ended
$ ls state/procevent-inbox
lavish-1787666762184a3e.1.adapter
lavish-1787666762184a3e.1.handled
lavish-1787666762184a3e.1.result
$ cat captured result
session:
  file: /tmp/fm-live-lavish-2756/board.html
  status: ended
  ended_by: agent
next_step: "This Lavish Editor session for /tmp/fm-live-lavish-2756/board.html has ended. Stop polling. Deliver any remaining updates directly in this conversation, or run `lavish-axi /tmp/fm-live-lavish-2756/board.html` to open a fresh session if the user needs further visual review."
$ bin/fm-procevent.sh list
SOURCE                       ADAPTER      OWNER      PENDING
lavish-1787666762184a3e      lavish       none       0

# scenario 3: documented adoption path - retire, then arm again
$ bin/fm-procevent-lavish.sh retire board.html
retired: lavish-1787666762184a3e
rc=0
$ bin/fm-procevent-lavish.sh arm board.html
registered: lavish-1787666762184a3e (lavish)
armed: lavish-1787666762184a3e
artifact: /tmp/fm-live-lavish-2756/board.html
rc=0
$ bin/fm-procevent.sh list
SOURCE                       ADAPTER      OWNER      PENDING
lavish-1787666762184a3e      lavish       live       0
$ bin/fm-procevent-lavish.sh retire board.html
retired: lavish-1787666762184a3e
rc=0
pollers left: 0

# scenario 4 (adversarial): the listener can never claim (claim path is a directory); confirm window 2s
registered: lavish-1787666762184a3e (lavish)
error: listener is not running: lavish-1787666762184a3e
rc=1 elapsed=2.798099046s
pollers: 0
$ ls state/procevent (registration kept because retire refuses an unreadable claim)
lavish-1787666762184a3e.source

# scenario 5 (adversarial): listener dies before claiming - lavish-axi missing from listener PATH
retired: lavish-1787666762184a3e
(driven instead as: claim root made read-only so the runner cannot take its claim; nothing may still own the source)
~/.no-mistakes/worktrees/5284051b2355/01M3AFKSMGJQ55X00CCQ2N1N98/bin/fm-wake-lib.sh: line 604: [: : integer expected
bin/fm-procevent-lavish.sh: line 200: 2386229 Segmentation fault         (core dumped) FM_HOME="$FM_HOME" "$SCRIPT_DIR/fm-procevent.sh" register lavish "$id" -- "${listener[@]}"
rc=1 elapsed=125.429723116s
pollers: 0
$ ls state/procevent (unstarted registration removed)
.owner-lease
$ bin/fm-procevent.sh list
no sources registered
(scenario 5 abandoned as an invalid fixture: with a read-only claim root the pre-existing `register` step - unchanged by this branch - never returned and was killed by the tester after ~125s, so ensure-listening never ran. The "retire an unstarted registration" path is covered by tests/fm-procevent.test.sh instead.)
Evidence: Full procevent test run (subreaper-tolerant copy), all passed

Source: Full procevent test run (subreaper-tolerant copy), all passed

ok - no configured source means no generated state and no process
ok - one blocking completion yields exactly one bounded normalized event
ok - a home reached through a symlinked ancestor runs its sources normally
not-autohandled: direct-src (left for the handler; still unacknowledged)
ok - public start owns the process group recorded by its claim
ok - public start never claims an inherited caller process group
ok - an unhandled result survives restart and repeat drains, and only explicit acknowledgement stops its re-announcement
ok - publication cannot race a handled acknowledgement
ok - handled acknowledgement creation is private and fails safely
ok - automatic application waits for durable publication and failed publication remains recoverable
ok - a self-announcing adapter applies quietly and still publishes what it could not apply
not-autohandled: ends-src (left for the handler; still unacknowledged)
ok - an adapter-classified terminal result is captured once, announced, and retires its source automatically
not-autohandled: open-src (left for the handler; still unacknowledged)
ok - a source stays armed unless its own adapter classifies the result terminal
not-autohandled: replace-src (left for the handler; still unacknowledged)
ok - terminal retirement preserves and releases a concurrently replaced registration
ok - failed terminal retirement is fail-closed and idempotently recoverable
ok - one Send & End yields exactly one captured result, automatic retirement, and no recurring poll
ok - an empty board close is captured and recorded handled without ever waking the captain
ok - worker board replies and recovered listeners derive their server from the board session
ok - worker-owned Lavish rounds deliver to the worker, acknowledge on re-arm, and stop at session end
ok - a capture interrupted before its result commit does not wedge its source
ok - an orphaned capture is not acknowledged by a worker it never reached
ok - a worker-owned board is only armed for an owner its feedback can reach
ok - an open worker-owned round is re-delivered after its note was filed away
ok - acknowledging a terminal round concludes that round only
ok - an interrupted conclude leaves the ended board unpollable and finishes on retry
ok - a re-arm that cannot acknowledge its round leaves the running generation alone
ok - a worker-owned board is armed once and re-armed only to acknowledge an open round
ok - a board close carrying the captain's real answer is still announced
ok - the shipped poll governor bounds an instantly returning source
ok - a transient Lavish poll interruption is retried quietly and never announced
ok - a staged worker reply is handed to the board once across quiet poll retries
ok - a listener whose staged reply is gone polls the board without one
ok - a listener that refuses its own setup leaves the staged reply for the next one
ok - a listener whose artifact vanished leaves the staged reply for the next one
ok - an interruption that outlives the bounded retries is captured and announced
ok - only the exact interruption is retried; an unrelated SERVER_ERROR still surfaces
ok - only the literal two-line interruption enters the quiet retry policy
ok - arm rejects malformed and out-of-range retry delays before registration
ok - poll cleanup safely handles an apostrophe-containing TMPDIR
ok - Lavish classification staging stays bounded while nonmatches stream
ok - a drained-but-unhandled result survives a replacement session and is retired only by explicit handling, never twice
ok - pending results preserve numeric order and distinct wake identity
ok - one owner per canonical source across homes
ok - retiring a never-completing source stops its runner and its blocked child
ok - reconcile reaps a runner whose source registration is gone
not-autohandled: stale-src (left for the handler; still unacknowledged)
ok - stale-owner recovery removes abandoned output without displacing a live owner
not-autohandled: cross-home-src (left for the handler; still unacknowledged)
ok - cross-home stale recovery removes abandoned output from the old state directory
not-autohandled: race-src (left for the handler; still unacknowledged)
not-autohandled: race-src (left for the handler; still unacknowledged)
ok - concurrent stale-claim replacement starts exactly one runner
ok - an ambiguous leaderless group is preserved without replacement
ok - a truly dead generation with no surviving group is still safely reclaimed
ok - reconcile reclaims a dead generation whose state-root identity no longer matches
ok - retire releases a dead generation's claim instead of refusing forever
ok - a live generation is never reclaimed, drifted state root or not
ok - a reused pid never makes its surviving process group reclaimable
ok - start reclaims a reused-pid claim whose leftovers can still be tidied
ok - a launch that cannot confirm is announced once per failure episode
ok - a 64-char source id keeps the launch-failed key within the watcher's marker bound
ok - reconcile reports a launch it could not confirm instead of counting it as a start
ok - a launch that finished before confirmation looked is still reported as started
ok - a zero-padded launch confirm window is honored as base 10
ok - an unusable launch confirm window is refused by name instead of blamed on the sources
ok - a dead generation whose leftovers cannot be tidied never keeps owning its source
ok - claim replacement cannot produce a torn ownership snapshot
ok - retirement and start share one serialized lifecycle boundary
ok - detected PID reuse is refused before signalling
ok - transient identity failure preserves the live source for retry
ok - bounded home sweep preflights then retires every locally owned source
ok - home sweep leaves foreign-home claims and runners untouched
ok - home sweep refuses safely until runner identity is readable
ok - healthy runtime behavior remains registration-only
ok - registration rejects unrepresentable newline arguments
ok - nonzero exit with no output stays armed and silent
ok - oversized output is bounded rather than published whole or dropped
ok - live output stays bounded and retirement reaps the whole source group
ok - stop mismatch evidence preserves the proved-stop boundary
ok - stop unreadable evidence preserves the proved-stop boundary
ok - stop unreadable-pgid evidence preserves the proved-stop boundary
ok - stop nonleader evidence preserves the proved-stop boundary
ok - invalid output bounds fail closed
ok - the adapter derives physical identity without newline path corruption
ok - source-only homes trigger the general supervision guard
ok - the adapter classifies published poll output safely
ok - poll derives host and port from the artifact session, not ambient or configured routing
ok - quiet retries use the board session regardless of configuration changes
ok - missing or unreadable session routing preserves replies and never guesses another server
ok - the adapter owns which Lavish results end a source, and payload text cannot forge one
ok - the adapter owns which Lavish results are silent, and fails closed on everything else
ok - read distinguishes a live captain message from a session-ending message
ok - read presents every annotation and a distinct session-ending message
ok - read never certifies rows missing declared fields as complete
ok - read keeps every annotation when the session-ending message is absent
ok - read surfaces a typed comment on an annotated element
ok - read still surfaces a typed comment that matches the element text
ok - read still presents a pure annotation with no comment
ok - read does not present choice context as a comment
ok - read still presents a pure message with no selector
ok - read distinguishes a feedback capture from an ended-with-nothing close
ok - an adapter with no silence verdict keeps announcing every result
ok - the published interfaces state the loss limitation and claim no lossless delivery
registered: floor-src (lavish)
ok - an orphaned source command obeys the launch floor during its grace window
ok - a replacement registration starts with one fresh launch floor
ok - a superseded sleeping runner cannot recreate stale pacing state
ok - post-commit pacing cleanup cannot veto registration publication
ok - a pre-reboot monotonic stamp is treated as expired
ok - an expired owner lease stops a self-relaunching source generation
ok - a recreated state path does not preserve the old runner
registered: guard-fail-src (lavish)
ok - a runner fails closed when its owner guard cannot initialize
registered: attached-src (lavish)
ok - a foreground start refreshes its lease while its caller remains attached
ok - wall-clock corrections do not alter owner lease age
registered: detached-attached-src (lavish)
ok - an attached-start keeper stops refreshing after its parent exits
ok - a detected ambiguous reused-PID group is not signalled
ok - a detached listener starts reparented, with a live descendant tree under it
ok - a listener whose owning session is gone stops itself and its whole process group
ok - reaping the listener stops the process churn under it
ok - an identical listener in a home whose session is still there is untouched
ok - retiring a source reaps its reparented listener and every descendant under it
ok - a stop the guard cannot prove is retried until the expired runner is reaped
ok - retirement escalates after TERM leaves a surviving child (absent leader)
ok - retirement escalates after TERM leaves a surviving child (zombie leader)
ok - an expired runner's guard escalates past a signal-proof child
guard phase: fresh read 6.152-6.164s, expiry 8s, two full intervals could not finish before 18.152s (deadline 17s)
guard bound: lease=7s check=6s reaped 12.7s after the last owner activity, documented bound 15s
ok - an orphaned runner is reaped within the lease plus ONE check interval
decimal interval: 08 halves to 4s and its listener started
decimal interval: 010 halves to 5s and its listener started
ok - a zero-prefixed decimal interval starts its listener and halves as decimal
ok - one unreadable read does not end a live runner
ordinary stop: start status=143 retirement=399ms sampled windows=2068/2070ms
ok - a runner exits on the ordinary stop signal instead of outliving it
ok - a group whose leader died to something else is still refused, not signalled
ok - arm reports ready only after the listener is running
ok - arm waits out a delayed listener start before reporting ready
ok - arm fails when the listener cannot claim, and leaves the registration retire refused
ok - arm waits out the confirm window before reporting that the listener is not running
ok - re-arm over a live earlier listener reports it still serving the board
ok - re-arm launches the new generation once a draining earlier claim is released
ok - arm does not launch beside a stale claim whose process group is alive

all procevent tests passed

real	6m21.183s
user	1m15.994s
sys	2m49.497s
rc=0
Evidence: Unmodified procevent test run stopping at the host-dependent PPID assertion

Source: Unmodified procevent test run stopping at the host-dependent PPID assertion

ok - no configured source means no generated state and no process
ok - one blocking completion yields exactly one bounded normalized event
ok - a home reached through a symlinked ancestor runs its sources normally
not-autohandled: direct-src (left for the handler; still unacknowledged)
ok - public start owns the process group recorded by its claim
ok - public start never claims an inherited caller process group
ok - an unhandled result survives restart and repeat drains, and only explicit acknowledgement stops its re-announcement
ok - publication cannot race a handled acknowledgement
ok - handled acknowledgement creation is private and fails safely
ok - automatic application waits for durable publication and failed publication remains recoverable
ok - a self-announcing adapter applies quietly and still publishes what it could not apply
not-autohandled: ends-src (left for the handler; still unacknowledged)
ok - an adapter-classified terminal result is captured once, announced, and retires its source automatically
not-autohandled: open-src (left for the handler; still unacknowledged)
ok - a source stays armed unless its own adapter classifies the result terminal
not-autohandled: replace-src (left for the handler; still unacknowledged)
ok - terminal retirement preserves and releases a concurrently replaced registration
ok - failed terminal retirement is fail-closed and idempotently recoverable
ok - one Send & End yields exactly one captured result, automatic retirement, and no recurring poll
ok - an empty board close is captured and recorded handled without ever waking the captain
ok - worker board replies and recovered listeners derive their server from the board session
ok - worker-owned Lavish rounds deliver to the worker, acknowledge on re-arm, and stop at session end
ok - a capture interrupted before its result commit does not wedge its source
ok - an orphaned capture is not acknowledged by a worker it never reached
ok - a worker-owned board is only armed for an owner its feedback can reach
ok - an open worker-owned round is re-delivered after its note was filed away
ok - acknowledging a terminal round concludes that round only
ok - an interrupted conclude leaves the ended board unpollable and finishes on retry
ok - a re-arm that cannot acknowledge its round leaves the running generation alone
ok - a worker-owned board is armed once and re-armed only to acknowledge an open round
ok - a board close carrying the captain's real answer is still announced
ok - the shipped poll governor bounds an instantly returning source
ok - a transient Lavish poll interruption is retried quietly and never announced
ok - a staged worker reply is handed to the board once across quiet poll retries
ok - a listener whose staged reply is gone polls the board without one
ok - a listener that refuses its own setup leaves the staged reply for the next one
ok - a listener whose artifact vanished leaves the staged reply for the next one
ok - an interruption that outlives the bounded retries is captured and announced
ok - only the exact interruption is retried; an unrelated SERVER_ERROR still surfaces
ok - only the literal two-line interruption enters the quiet retry policy
ok - arm rejects malformed and out-of-range retry delays before registration
ok - poll cleanup safely handles an apostrophe-containing TMPDIR
ok - Lavish classification staging stays bounded while nonmatches stream
ok - a drained-but-unhandled result survives a replacement session and is retired only by explicit handling, never twice
ok - pending results preserve numeric order and distinct wake identity
ok - one owner per canonical source across homes
ok - retiring a never-completing source stops its runner and its blocked child
ok - reconcile reaps a runner whose source registration is gone
not-autohandled: stale-src (left for the handler; still unacknowledged)
ok - stale-owner recovery removes abandoned output without displacing a live owner
not-autohandled: cross-home-src (left for the handler; still unacknowledged)
ok - cross-home stale recovery removes abandoned output from the old state directory
not-autohandled: race-src (left for the handler; still unacknowledged)
ok - concurrent stale-claim replacement starts exactly one runner
ok - an ambiguous leaderless group is preserved without replacement
ok - a truly dead generation with no surviving group is still safely reclaimed
ok - reconcile reclaims a dead generation whose state-root identity no longer matches
ok - retire releases a dead generation's claim instead of refusing forever
ok - a live generation is never reclaimed, drifted state root or not
ok - a reused pid never makes its surviving process group reclaimable
ok - start reclaims a reused-pid claim whose leftovers can still be tidied
ok - a launch that cannot confirm is announced once per failure episode
ok - a 64-char source id keeps the launch-failed key within the watcher's marker bound
ok - reconcile reports a launch it could not confirm instead of counting it as a start
ok - a launch that finished before confirmation looked is still reported as started
ok - a zero-padded launch confirm window is honored as base 10
ok - an unusable launch confirm window is refused by name instead of blamed on the sources
ok - a dead generation whose leftovers cannot be tidied never keeps owning its source
ok - claim replacement cannot produce a torn ownership snapshot
ok - retirement and start share one serialized lifecycle boundary
ok - detected PID reuse is refused before signalling
ok - transient identity failure preserves the live source for retry
ok - bounded home sweep preflights then retires every locally owned source
ok - home sweep leaves foreign-home claims and runners untouched
ok - home sweep refuses safely until runner identity is readable
ok - healthy runtime behavior remains registration-only
ok - registration rejects unrepresentable newline arguments
ok - nonzero exit with no output stays armed and silent
ok - oversized output is bounded rather than published whole or dropped
ok - live output stays bounded and retirement reaps the whole source group
ok - stop mismatch evidence preserves the proved-stop boundary
ok - stop unreadable evidence preserves the proved-stop boundary
ok - stop unreadable-pgid evidence preserves the proved-stop boundary
ok - stop nonleader evidence preserves the proved-stop boundary
ok - invalid output bounds fail closed
ok - the adapter derives physical identity without newline path corruption
ok - source-only homes trigger the general supervision guard
ok - the adapter classifies published poll output safely
ok - poll derives host and port from the artifact session, not ambient or configured routing
ok - quiet retries use the board session regardless of configuration changes
ok - missing or unreadable session routing preserves replies and never guesses another server
ok - the adapter owns which Lavish results end a source, and payload text cannot forge one
ok - the adapter owns which Lavish results are silent, and fails closed on everything else
ok - read distinguishes a live captain message from a session-ending message
ok - read presents every annotation and a distinct session-ending message
ok - read never certifies rows missing declared fields as complete
ok - read keeps every annotation when the session-ending message is absent
ok - read surfaces a typed comment on an annotated element
ok - read still surfaces a typed comment that matches the element text
ok - read still presents a pure annotation with no comment
ok - read does not present choice context as a comment
ok - read still presents a pure message with no selector
ok - read distinguishes a feedback capture from an ended-with-nothing close
ok - an adapter with no silence verdict keeps announcing every result
ok - the published interfaces state the loss limitation and claim no lossless delivery
registered: floor-src (lavish)
ok - an orphaned source command obeys the launch floor during its grace window
ok - a replacement registration starts with one fresh launch floor
ok - a superseded sleeping runner cannot recreate stale pacing state
ok - post-commit pacing cleanup cannot veto registration publication
ok - a pre-reboot monotonic stamp is treated as expired
ok - an expired owner lease stops a self-relaunching source generation
ok - a recreated state path does not preserve the old runner
registered: guard-fail-src (lavish)
ok - a runner fails closed when its owner guard cannot initialize
registered: attached-src (lavish)
ok - a foreground start refreshes its lease while its caller remains attached
ok - wall-clock corrections do not alter owner lease age
registered: detached-attached-src (lavish)
ok - an attached-start keeper stops refreshing after its parent exits
ok - a detected ambiguous reused-PID group is not signalled
not ok - the listener under test was not reparented away from its session (ppid 5856)

real	4m48.936s
user	1m3.960s
sys	2m21.235s
rc=1
Evidence: Subreaper-tolerant run 1 that exited silently in the unchanged home-sweep section

Source: Subreaper-tolerant run 1 that exited silently in the unchanged home-sweep section

ok - no configured source means no generated state and no process
ok - one blocking completion yields exactly one bounded normalized event
ok - a home reached through a symlinked ancestor runs its sources normally
not-autohandled: direct-src (left for the handler; still unacknowledged)
ok - public start owns the process group recorded by its claim
ok - public start never claims an inherited caller process group
ok - an unhandled result survives restart and repeat drains, and only explicit acknowledgement stops its re-announcement
ok - publication cannot race a handled acknowledgement
ok - handled acknowledgement creation is private and fails safely
ok - automatic application waits for durable publication and failed publication remains recoverable
ok - a self-announcing adapter applies quietly and still publishes what it could not apply
not-autohandled: ends-src (left for the handler; still unacknowledged)
ok - an adapter-classified terminal result is captured once, announced, and retires its source automatically
not-autohandled: open-src (left for the handler; still unacknowledged)
ok - a source stays armed unless its own adapter classifies the result terminal
not-autohandled: replace-src (left for the handler; still unacknowledged)
ok - terminal retirement preserves and releases a concurrently replaced registration
ok - failed terminal retirement is fail-closed and idempotently recoverable
ok - one Send & End yields exactly one captured result, automatic retirement, and no recurring poll
ok - an empty board close is captured and recorded handled without ever waking the captain
ok - worker board replies and recovered listeners derive their server from the board session
ok - worker-owned Lavish rounds deliver to the worker, acknowledge on re-arm, and stop at session end
ok - a capture interrupted before its result commit does not wedge its source
ok - an orphaned capture is not acknowledged by a worker it never reached
ok - a worker-owned board is only armed for an owner its feedback can reach
ok - an open worker-owned round is re-delivered after its note was filed away
ok - acknowledging a terminal round concludes that round only
ok - an interrupted conclude leaves the ended board unpollable and finishes on retry
ok - a re-arm that cannot acknowledge its round leaves the running generation alone
ok - a worker-owned board is armed once and re-armed only to acknowledge an open round
ok - a board close carrying the captain's real answer is still announced
ok - the shipped poll governor bounds an instantly returning source
ok - a transient Lavish poll interruption is retried quietly and never announced
ok - a staged worker reply is handed to the board once across quiet poll retries
ok - a listener whose staged reply is gone polls the board without one
ok - a listener that refuses its own setup leaves the staged reply for the next one
ok - a listener whose artifact vanished leaves the staged reply for the next one
ok - an interruption that outlives the bounded retries is captured and announced
ok - only the exact interruption is retried; an unrelated SERVER_ERROR still surfaces
ok - only the literal two-line interruption enters the quiet retry policy
ok - arm rejects malformed and out-of-range retry delays before registration
ok - poll cleanup safely handles an apostrophe-containing TMPDIR
ok - Lavish classification staging stays bounded while nonmatches stream
ok - a drained-but-unhandled result survives a replacement session and is retired only by explicit handling, never twice
ok - pending results preserve numeric order and distinct wake identity
ok - one owner per canonical source across homes
ok - retiring a never-completing source stops its runner and its blocked child
ok - reconcile reaps a runner whose source registration is gone
not-autohandled: stale-src (left for the handler; still unacknowledged)
ok - stale-owner recovery removes abandoned output without displacing a live owner
not-autohandled: cross-home-src (left for the handler; still unacknowledged)
ok - cross-home stale recovery removes abandoned output from the old state directory
not-autohandled: race-src (left for the handler; still unacknowledged)
not-autohandled: race-src (left for the handler; still unacknowledged)
ok - concurrent stale-claim replacement starts exactly one runner
ok - an ambiguous leaderless group is preserved without replacement
ok - a truly dead generation with no surviving group is still safely reclaimed
ok - reconcile reclaims a dead generation whose state-root identity no longer matches
ok - retire releases a dead generation's claim instead of refusing forever
ok - a live generation is never reclaimed, drifted state root or not
ok - a reused pid never makes its surviving process group reclaimable
ok - start reclaims a reused-pid claim whose leftovers can still be tidied
ok - a launch that cannot confirm is announced once per failure episode
ok - a 64-char source id keeps the launch-failed key within the watcher's marker bound
ok - reconcile reports a launch it could not confirm instead of counting it as a start
ok - a launch that finished before confirmation looked is still reported as started
ok - a zero-padded launch confirm window is honored as base 10
ok - an unusable launch confirm window is refused by name instead of blamed on the sources
ok - a dead generation whose leftovers cannot be tidied never keeps owning its source
ok - claim replacement cannot produce a torn ownership snapshot
ok - retirement and start share one serialized lifecycle boundary
ok - detected PID reuse is refused before signalling
ok - transient identity failure preserves the live source for retry
ok - bounded home sweep preflights then retires every locally owned source
ok - home sweep leaves foreign-home claims and runners untouched

real	3m31.176s
user	0m50.309s
sys	1m56.818s
rc=1
Evidence: Re-arm over a live earlier listener (live)
registered: lavish-1787666762184a3e (lavish)
still-listening: lavish-1787666762184a3e
artifact: /tmp/fm-live-lavish-2756/board.html
note: an earlier listener is still live and serving this board; this registration takes effect only after the source is retired and armed again
rc=0 elapsed=3.37s
OWNER live, lavish-axi pollers: 1
- Outcome: ⚠️ 2 warnings across 1 run (16m37s)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ tests/fm-procevent.test.sh:3777 - An older assertion (commit b84e0e3, not from this branch) expects an orphaned listener's PPID to be 1. On this host, systemd --user (PID 5856) is a child subreaper, so orphans are reparented to it. The unmodified test file therefore fails at this point and never reaches the tests added by this branch. Separate from this change; it should become its own issue or PR that accepts any subreaper as the new parent.
  • ⚠️ tests/fm-procevent.test.sh:2642 - One full run of the file (subreaper-tolerant copy) exited with rc=1 and no 'not ok' line inside the unchanged 'home sweep refuses safely until runner identity is readable' section. The identical rerun passed. This is a flaky test that predates this branch and should be tracked separately.
  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Fresh arm of a real Lavish board prints armed only once its listener is running, and that listener really polls the board ✅ pass live live-arm-real-lavish.txt: arm rc=0 in 0.9s, list shows live, the real lavish-axi poll process is running, and lavish-axi end produced a captured .1.result
Re-arm while the earlier listener is still live: exit 0 with still-listening and never armed, no error, no second poller ✅ pass live live-arm-real-lavish.txt scenario 2: rc=0 after the 2s window, still-listening line plus note, list still live, exactly 1 lavish-axi poll process
Documented adoption path: retire, then arm again, reports armed with a live listener ✅ pass live live-arm-real-lavish.txt scenario 3
Adversarial: a listener that can never claim makes arm fail after the confirm window without printing armed, and keeps the registration retire refuses to remove ✅ pass live live-arm-real-lavish.txt scenario 4: rc=1 after 2.8s, 'error: listener is not running', 0 pollers, .source kept
Worker re-arm while the earlier generation's claim is still draining: once that claim is released inside the window, the new generation launches carrying the reply and reports armed ⏸️ untested no The earlier report did not establish a live result: this case ran only as the test 're-arm launches the new generation once a draining earlier claim is released' in tests/fm-procevent.test.sh, with a…
Adversarial: arm does not launch a second poller beside a stale claim whose process group is still alive (orphaned) ⏸️ untested no The earlier report did not establish a live result: this case ran only as the test 'arm does not launch beside a stale claim whose process group is alive' in tests/fm-procevent.test.sh, with a fake la…
A failed arm retires a registration that never started ⏸️ untested no The only live fixture I could build (a read-only claim root) hung in the existing register step, which this branch did not change, before ensure-listening ran. Driving this live needs a way to mak…
  • bin/fm-procevent-lavish.sh arm board.html on a board opened with the real lavish-axi, with LAVISH_AXI_STATE_DIR, FM_PROCEVENT_CLAIM_ROOT and FM_HOME isolated under /tmp
  • FM_PROCEVENT_LAUNCH_CONFIRM_SECONDS=2 bin/fm-procevent-lavish.sh arm board.html while the first listener was live, then bin/fm-procevent.sh list and a count of lavish-axi poll processes
  • lavish-axi end board.html, then checking that the armed listener captured the ended round into procevent-inbox
  • bin/fm-procevent-lavish.sh retire board.html then arm board.html (the documented way to adopt the retry policy)
  • arm with the claim path made a directory so the listener can never claim (confirm window 2s)
  • bash tests/fm-procevent.test.sh (unmodified): stopped at an older reparent-to-PID-1 assertion because of the host's systemd --user subreaper
  • Temporary copy of tests/fm-procevent.test.sh accepting the subreaper PPID: run 1 exited silently in an unchanged home-sweep section; run 2 passed everything (131 ok), including all 5 new arm tests; copy deleted
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ning

Registration alone was treated as ready, so arm could succeed before anything was collecting from the board.
The result is stored before the runner exits, so a re-arm in that gap was meeting a live claim.
…ixed with test-only edits. Lint 2 (ShellCheck SC2034): this branch removed the only use of `reply_id` (a `start "$reply_id"` call) from tests/fm-procevent.test.sh, which left the assignment at line 1450 unused. I deleted that assignment. It was the only `reply_id` in the file. ShellCheck is now clean on both test files. Behavior portable serial 4: the failing test was tests/fm-bearings-board.test.sh, in the check "registration consumed its answer before the any-origin binding existed". I reproduced it locally: the hold was still `state: queued` when the test checked it. - What must hold: the test's check that the hold is closed must run after the listener has captured the answer. - Why it broke: the test used a stand-in adapter that ran `fm-procevent.sh start` in the foreground after `arm`, so capture finished before build returned. On this branch, `arm` starts the listener itself in the background, so the real listener captures the answer and closes the hold a moment after build returns. - Fix: removed the now-redundant stand-in adapter, the copied runtime directory, and its extra environment variables. The test now runs the real build through the existing `run_board` helper and waits up to about 10s for the hold to reach `state: done`. The checks that follow are unchanged: `Resolution mode: answered` and the any-origin binding. - Other tests: this was the only test in the file that stood in for the adapter this way. The shard's other pure-contract-unit test (tests/fm-trace-context-lib.test.sh) passed unchanged. Verification: - tests/fm-bearings-board.test.sh passed 3 times in a row via bin/fm-test-run.sh, all 18 checks, about 53s per run. - tests/fm-procevent.test.sh was not rerun, because the lint fix only removed an unused assignment
@kunchenguid
kunchenguid merged commit b42d4fa into kunchenguid:main Sep 24, 2026
20 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this.

mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…ning (kunchenguid#5566)

* fix(bin): report a Lavish source armed only after its listener is running

Registration alone was treated as ready, so arm could succeed before anything was collecting from the board.

* no-mistakes(review): Guard Lavish arm launches, keep retire refusals, report live prior listener

* no-mistakes(review): Keep polling through window before reporting a still-live prior listener

* test: wait for a capture's claim to drop before the next arm

The result is stored before the runner exits, so a re-arm in that gap was meeting a live claim.

* no-mistakes(document): Record Lavish arm readiness evidence in verification doc

* no-mistakes(ci): Both failures were caused by this PR, and both are fixed with test-only edits. Lint 2 (ShellCheck SC2034): this branch removed the only use of `reply_id` (a `start "$reply_id"` call) from tests/fm-procevent.test.sh, which left the assignment at line 1450 unused. I deleted that assignment. It was the only `reply_id` in the file. ShellCheck is now clean on both test files. Behavior portable serial 4: the failing test was tests/fm-bearings-board.test.sh, in the check "registration consumed its answer before the any-origin binding existed". I reproduced it locally: the hold was still `state: queued` when the test checked it. - What must hold: the test's check that the hold is closed must run after the listener has captured the answer. - Why it broke: the test used a stand-in adapter that ran `fm-procevent.sh start` in the foreground after `arm`, so capture finished before build returned. On this branch, `arm` starts the listener itself in the background, so the real listener captures the answer and closes the hold a moment after build returns. - Fix: removed the now-redundant stand-in adapter, the copied runtime directory, and its extra environment variables. The test now runs the real build through the existing `run_board` helper and waits up to about 10s for the hold to reach `state: done`. The checks that follow are unchanged: `Resolution mode: answered` and the any-origin binding. - Other tests: this was the only test in the file that stood in for the adapter this way. The shard's other pure-contract-unit test (tests/fm-trace-context-lib.test.sh) passed unchanged. Verification: - tests/fm-bearings-board.test.sh passed 3 times in a row via bin/fm-test-run.sh, all 18 checks, about 53s per run. - tests/fm-procevent.test.sh was not rerun, because the lint fix only removed an unused assignment
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…ning (kunchenguid#5566)

* fix(bin): report a Lavish source armed only after its listener is running

Registration alone was treated as ready, so arm could succeed before anything was collecting from the board.

* no-mistakes(review): Guard Lavish arm launches, keep retire refusals, report live prior listener

* no-mistakes(review): Keep polling through window before reporting a still-live prior listener

* test: wait for a capture's claim to drop before the next arm

The result is stored before the runner exits, so a re-arm in that gap was meeting a live claim.

* no-mistakes(document): Record Lavish arm readiness evidence in verification doc

* no-mistakes(ci): Both failures were caused by this PR, and both are fixed with test-only edits. Lint 2 (ShellCheck SC2034): this branch removed the only use of `reply_id` (a `start "$reply_id"` call) from tests/fm-procevent.test.sh, which left the assignment at line 1450 unused. I deleted that assignment. It was the only `reply_id` in the file. ShellCheck is now clean on both test files. Behavior portable serial 4: the failing test was tests/fm-bearings-board.test.sh, in the check "registration consumed its answer before the any-origin binding existed". I reproduced it locally: the hold was still `state: queued` when the test checked it. - What must hold: the test's check that the hold is closed must run after the listener has captured the answer. - Why it broke: the test used a stand-in adapter that ran `fm-procevent.sh start` in the foreground after `arm`, so capture finished before build returned. On this branch, `arm` starts the listener itself in the background, so the real listener captures the answer and closes the hold a moment after build returns. - Fix: removed the now-redundant stand-in adapter, the copied runtime directory, and its extra environment variables. The test now runs the real build through the existing `run_board` helper and waits up to about 10s for the hold to reach `state: done`. The checks that follow are unchanged: `Resolution mode: answered` and the any-origin binding. - Other tests: this was the only test in the file that stood in for the adapter this way. The shard's other pure-contract-unit test (tests/fm-trace-context-lib.test.sh) passed unchanged. Verification: - tests/fm-bearings-board.test.sh passed 3 times in a row via bin/fm-test-run.sh, all 18 checks, about 53s per run. - tests/fm-procevent.test.sh was not rerun, because the lint fix only removed an unused assignment
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…ning (kunchenguid#5566)

* fix(bin): report a Lavish source armed only after its listener is running

Registration alone was treated as ready, so arm could succeed before anything was collecting from the board.

* no-mistakes(review): Guard Lavish arm launches, keep retire refusals, report live prior listener

* no-mistakes(review): Keep polling through window before reporting a still-live prior listener

* test: wait for a capture's claim to drop before the next arm

The result is stored before the runner exits, so a re-arm in that gap was meeting a live claim.

* no-mistakes(document): Record Lavish arm readiness evidence in verification doc

* no-mistakes(ci): Both failures were caused by this PR, and both are fixed with test-only edits. Lint 2 (ShellCheck SC2034): this branch removed the only use of `reply_id` (a `start "$reply_id"` call) from tests/fm-procevent.test.sh, which left the assignment at line 1450 unused. I deleted that assignment. It was the only `reply_id` in the file. ShellCheck is now clean on both test files. Behavior portable serial 4: the failing test was tests/fm-bearings-board.test.sh, in the check "registration consumed its answer before the any-origin binding existed". I reproduced it locally: the hold was still `state: queued` when the test checked it. - What must hold: the test's check that the hold is closed must run after the listener has captured the answer. - Why it broke: the test used a stand-in adapter that ran `fm-procevent.sh start` in the foreground after `arm`, so capture finished before build returned. On this branch, `arm` starts the listener itself in the background, so the real listener captures the answer and closes the hold a moment after build returns. - Fix: removed the now-redundant stand-in adapter, the copied runtime directory, and its extra environment variables. The test now runs the real build through the existing `run_board` helper and waits up to about 10s for the hold to reach `state: done`. The checks that follow are unchanged: `Resolution mode: answered` and the any-origin binding. - Other tests: this was the only test in the file that stood in for the adapter this way. The shard's other pure-contract-unit test (tests/fm-trace-context-lib.test.sh) passed unchanged. Verification: - tests/fm-bearings-board.test.sh passed 3 times in a row via bin/fm-test-run.sh, all 18 checks, about 53s per run. - tests/fm-procevent.test.sh was not rerun, because the lint fix only removed an unused assignment
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026