Skip to content

fix(procevent): handle concurrent capture directory setup - #73

Merged
peterOC26 merged 1 commit into
mainfrom
fm/fm-extension-binding-orphan-flake-f1
Nov 19, 2026
Merged

peterOC26 merged 1 commit into
mainfrom
fm/fm-extension-binding-orphan-flake-f1

Conversation

@peterOC26

Copy link
Copy Markdown
Owner

Intent

Q2246 F (2026-11-18, Jobs page "q2246 f"): fix the flaky test that keeps failing PR 70 (#70) before merging it.
Context: in CI shard "Behavior portable serial 2", the fm-extension-binding tests "recovered source orphan-first/orphan-second never handled its private result" and "an isolated extension conformance section failed" failed on PR 70 three times in a row and on main push runs 43708843416 and 43640005067, while passing locally on both.

That failure is intermittent and is not caused by the diff on #70. On GitHub Actions run 44318731313, only tests/fm-extension-binding.test.sh failed in the Behavior portable serial 2 shard. One attempt failed with "recovered source orphan-first never handled its private result" and then "an isolated extension conformance section failed". The next attempt failed the same way for orphan-second. The source that fails changes between attempts, and the second line is the section coordinator rolling up that one failure. The same orphan-readiness failure also happens on main: push run 43708843416 failed "recovered source orphan-second never handled its private result", and push run 43640005067 failed the same orphan-second message. Local reruns of that section passed. The flake shows on the slower GitHub runners. Fix it so those orphan-readiness cases stop failing in CI.

What Changed

  • Make inbox and capture reservation setup tolerate a concurrent runner creating the directory, then validate its private-directory permissions.
  • Add coverage for concurrent first-runner setup of both capture directories.

Risk Assessment

✅ Low: This is a two-line mkdir → mkdir -p change in the capture inbox and reservation preparers. It matches the pattern already used for every other state directory in the lib, including the capture fallback at fm-procevent-lib.sh:1129. Safety is still enforced by the unchanged fm_procevent_private_directory_valid: it rejects symlinks, foreign ownership, and any mode other than 700. The fix plausibly removes the fresh-home race where two runners recovered by one reconcile both see procevent-inbox absent and the loser dies with "cannot durably capture", which is the exact orphan-first/orphan-second "never handled its private result" failure.

Testing

The focused orphan-readiness scenario and default coordinated extension-binding run passed. The process-event suite’s concurrent directory-preparation case also passed; that broader suite later exited 1 at an unrelated detached-listener PPID assertion (expected 1, observed 1084). Evidence logs were saved, and the worktree remained clean.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Reconcile two extension sources with stale orphan readiness and observe both private results handled, registrations retired, and readiness reclaimed. ✅ pass live Orphan-readiness integration output
Run concurrent first runners against fresh state directories and observe all 30 capture-directory preparations succeed. ✅ pass live Process-event suite output, line “concurrent first runners in a fresh home all prepare the shared capture directories”
Run the default extension-binding coordinator and observe its isolated conformance sections complete successfully. ✅ pass live Default extension-binding aggregate output
Evidence: Orphan-readiness integration output

Source: Orphan-readiness integration output

ok - ownerless readiness recovers only dead exact-token groups and refuses unsafe or unproved ownership
ok - reconcile durably announces cleanup uncertainty once and recovers both extension sources
ok - attached start and live-owner recovery renew cleanup failure wakes with delivered failure headlines

all extension-binding tests passed
Evidence: Process-event suite output, including the concurrent preparation result

Source: Process-event suite output, including the concurrent preparation result

ok - reconcile refreshes at detached launch and still stops after owner lease expiry
ok - ensure-listening refreshes at detached launch and still stops after owner lease expiry
ok - inherited runner callers cannot renew owner presence at detached startup
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 acknowledged note is never resurrected and stops ringing across repeated reconciles
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 - concurrent first runners in a fresh home all prepare the shared capture directories
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 names the message count with the same label as the message section
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 - read presents list-form items with nested targets, attachments, and multi-line prompts
ok - read never certifies malformed list-form items as complete
ok - read never reports a declared-but-unparsed block as complete
ok - answers reads list-form choices and refuses a block it cannot account for
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 1084)
Evidence: Default extension-binding aggregate output

Source: Default extension-binding aggregate output

ok - unknown extension conformance section selectors fail before setup
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 18: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-treehouse-slot-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 20: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-surface-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 259: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-task-inbox-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 261: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-backend.sh: No such file or directory
not-autohandled: example-file (left for the handler; still unacknowledged)
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 18: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-treehouse-slot-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 20: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-surface-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 259: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-task-inbox-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 261: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-backend.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 18: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-treehouse-slot-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 20: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-surface-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 259: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-task-inbox-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 261: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-backend.sh: No such file or directory
not-autohandled: flow-source (left for the handler; still unacknowledged)
ok - the section coordinator propagates ordered failures and bounded cleanup
ok - the shipped file-signal package is a runnable end-to-end external adapter
ok - one external adapter registers, invokes, captures unhandled evidence, classifies, and terminally retires end to end
not-autohandled: remote-source (left for the handler; still unacknowledged)
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 18: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-treehouse-slot-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 20: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-surface-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 259: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-task-inbox-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 261: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-backend.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 18: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-treehouse-slot-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-lib.sh: line 20: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-wake-surface-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 259: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-task-inbox-lib.sh: No such file or directory
/tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-procevent.sh: line 261: /tmp/fm-extension-binding.O1Fc1P/remote-root/bin/fm-backend.sh: No such file or directory
ok - register-extension and reconcile of an unhandled extension result take their locks in one order

all extension-binding tests passed
ok - serialized remote binding crosses fm-on through addressed-home capture and retirement

all extension-binding tests passed
not-autohandled: example-symlinked (left for the handler; still unacknowledged)
ok - a home reached through a symlinked ancestor captures external evidence normally
ok - inner result.silent host crash releases the parent lifecycle lock before terminal retry
ok - handshake execution rejects and reaps foreground descendants

all extension-binding tests passed
ok - local binding retirement requires its exact identity and disables invocation
ok - ownerless readiness recovers only dead exact-token groups and refuses unsafe or unproved ownership
ok - reconcile durably announces cleanup uncertainty once and recovers both extension sources
ok - attached start and live-owner recovery renew cleanup failure wakes with delivered failure headlines

all extension-binding tests passed
ok - independent extension conformance sections complete through isolated public homes

all extension-binding tests passed
  • Outcome: ⚠️ 2 warnings across 2 runs (33m30s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ tests/fm-procevent.test.sh:1912 - The new regression test can only hit the race by chance. Six callers spin-wait on a go file, then race the [ ! -e ]/mkdir window across 5 trials. On a quiet machine all 30 calls can still pass with the old plain mkdir, so the test proves the fixed behavior but does not reliably fail before the fix. The callers also busy-spin (while [ ! -e go ]; do kill -0 ...; done) for up to ~15s, which competes for CPU on the same slow 2-core runners where the flake showed up. This is acceptable as-is: the oracle is independent (concurrent first callers must all get a valid private dir), and a deterministic reproduction would need a pre-created-after-check hook the library does not expose. Optionally replace the busy-spin with a short sleep poll.
⚠️ **Test** - 2 warnings
  • ⚠️ tests/fm-extension-binding.test.sh:1276 - The requested orphan-readiness recovery and concurrent directory-creation behavior passed. The default extension-binding aggregate and standalone lifecycle-flow run also failed at a separate four-second wait for the result.silent crash-recovery runner to finish (tests/fm-extension-binding.test.sh:1276), before orphan recovery ran. A baseline run of that lane passed once, so this appears timing-sensitive. A status-preserving run of the broader process-event suite also failed earlier at reconcile failed after slow publication (tests/fm-procevent.test.sh:219). Fixing these would expand this task to independent timing-sensitive tests; the scope-preserving option is to handle them separately. Expanding may make the full local test paths more reliable, while declining leaves these failures unresolved and could keep CI red. Should this task expand to repair those timing tests, or remain scoped to the reported orphan-readiness race?
  • 🚨 live validation verdict: no-go (3 of 3 scenarios were driven live against the product); failed: Run the extension-binding test in its default coordinated mode and observe every isolated conformance section complete successfully.
  • Live validation: ❌ no-go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Reconcile two registered extension sources after dead orphan readiness and observe both private results handled and both sources retired. ✅ pass live Orphan readiness recovery
Start six first-runner preparations together in each of five fresh synthetic state roots; every caller succeeds and both shared capture directories remain mode 0700. ✅ pass live Concurrent capture-directory preparation
Run the extension-binding test in its default coordinated mode and observe every isolated conformance section complete successfully. ❌ fail live Default extension-binding aggregate failure
  • env -u FM_WAKE_QUEUE FM_EXTENSION_BINDING_SEGMENT=lifecycle-orphan-readiness bash tests/fm-extension-binding.test.sh
  • Manual live race fixture: six synchronized shell callers invoked the real capture inbox and reservation preparation functions across five fresh state roots; checked return success and mode 0700.
  • env -u FM_WAKE_QUEUE bash tests/fm-extension-binding.test.sh
  • env -u FM_WAKE_QUEUE FM_EXTENSION_BINDING_SEGMENT=lifecycle-flow bash tests/fm-extension-binding.test.sh
  • Archived base commit 011b8ddfd14981a2d758b69f6470876ecb70c732 into a disposable worktree-local directory and ran its lifecycle-flow segment; removed the copy afterward.
  • env -u FM_WAKE_QUEUE bash tests/fm-procevent.test.sh
  • Initial bash tests/fm-procevent.test.sh 2>&1 | tee ... reached the new concurrent-preparation assertion, which passed, but did not produce the suite completion marker; its pipeline did not preserve the test process status.

🔧 No changes applied.
2 warnings still open:

  • ⚠️ tests/fm-procevent.test.sh:4133 - The broader process-event suite exited 1 after the concurrent capture-directory case passed. It stopped at the unchanged detached-listener assertion in tests/fm-procevent.test.sh:4133: expected PPID 1, observed PPID 1084. This prevented a suite-wide pass, but did not fail the targeted change scenarios.
  • ⚠️ tests/fm-extension-binding.test.sh:1276 - The requested orphan-readiness recovery and concurrent directory-creation behavior passed. The default extension-binding aggregate and standalone lifecycle-flow run also failed at a separate four-second wait for the result.silent crash-recovery runner to finish (tests/fm-extension-binding.test.sh:1276), before orphan recovery ran. A baseline run of that lane passed once, so this appears timing-sensitive. A status-preserving run of the broader process-event suite also failed earlier at reconcile failed after slow publication (tests/fm-procevent.test.sh:219). Fixing these would expand this task to independent timing-sensitive tests; the scope-preserving option is to handle them separately. Expanding may make the full local test paths more reliable, while declining leaves these failures unresolved and could keep CI red. Should this task expand to repair those timing tests, or remain scoped to the reported orphan-readiness race?
  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Reconcile two extension sources with stale orphan readiness and observe both private results handled, registrations retired, and readiness reclaimed. ✅ pass live Orphan-readiness integration output
Run concurrent first runners against fresh state directories and observe all 30 capture-directory preparations succeed. ✅ pass live Process-event suite output, line “concurrent first runners in a fresh home all prepare the shared capture directories”
Run the default extension-binding coordinator and observe its isolated conformance sections complete successfully. ✅ pass live Default extension-binding aggregate output
  • FM_EXTENSION_BINDING_SEGMENT=lifecycle-orphan-readiness bash tests/fm-extension-binding.test.sh
  • bash tests/fm-procevent.test.sh
  • bash tests/fm-extension-binding.test.sh
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Two extension runners recovered by one reconcile in a fresh home both
found state/procevent-inbox and state/procevent-capture-reservations
absent. The runner that lost the plain mkdir died with "cannot durably
capture the extension result" before polling, leaving its source
registered with no handled result. That is the intermittent
fm-extension-binding failure "recovered source orphan-first/orphan-second
never handled its private result" on fast CI runners.

Create both directories with mkdir -p so the loser accepts the
directory its sibling just made; the existing private-directory
validation still decides whether it is safe.
@peterOC26
peterOC26 merged commit d323d81 into main Nov 19, 2026
29 of 30 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