Repository navigation
fix(procevent): separate clean-false, transient, and permanent when-condition outcomes - #122
Merged
Merged
Conversation
…ondition outcomes A when-watch condition could only signal true, a clean false, or "some error", so a transient window burned the shared error budget while a permanent break could hide as an ordinary wait. The condition's exit status now carries four outcomes: 0 true, 1 clean false, 2 a permanent error that wakes on its first observation, and any other exit or a per-poll timeout as a transient error that waits with bounded backoff before the budget wakes. A permanent error never runs the action, and the terminal condition-error outcome leaves the watch for firstmate to decide on rather than re-arming it.
Ivory2024
force-pushed
the
fm/procevent-when-condition-error-20261010
branch
from
October 12, 2026 14:38
ddb82dd to
25004c5
Compare
…. The failure was not in the procevent-when change under review: tests/fm-backend-herdr-presentation-e2e.test.sh failed at its concurrent cross-home recovery case with "error: herdr presentation recovery could not acquire its session lock; refusing a concurrent resume". Invariant: the two exact-resume spawns that the test intentionally runs concurrently must serialize on the single Herdr presentation session lock and both succeed; neither may race a short bounded acquire window. Cause: exact resume defaults to a bounded lock acquire (50 x 0.1s, ~5s) and hard-refuses under contention. The winning recovery holds that lock through its Herdr reclaim, restart-binding validation, and launch staging; on the loaded CI runner the hold exceeded ~5s, so the other resume refused and the case failed. Fix (smallest, test-only): both concurrent resume spawns now pass the existing --herdr-resume-lock-wait opt-in, so the loser genuinely waits out the holder instead of racing the bounded window; the production default of refusing under contention is unchanged and remains covered by the separate lock-refuse case below it. I checked the other concurrent projected operations in the suite for the same invariant: fresh creates deliberately degrade to the ordinary flat layout under the same contention (there is no wait opt-in for them by design) and the exact-resume hard-refusal is the only path that aborts the run, so no other site needed this correction. Verified: shellcheck --norc --external-sources passes on the file; the full real-Herdr presentation suite passes locally end-to-end (exit 0), including the "concurrent cross-home recoveries replace exact husks under one session lock with no focus drift" assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Separate clean-false, transient, and permanent outcomes of a when-watch condition in bin/fm-procevent-when.sh. Exit 0 = true (fires action after --stable consecutive trues); 1 = clean false (keeps waiting at cadence); 2 = permanent error (wakes firstmate on the first observation, action never runs); any other nonzero or the per-poll timeout = transient error (bounded backoff doubling capped at 8x the interval, wakes once --error-budget consecutive transient errors accumulate). Permanent break and exhausted transient budget both end in the terminal condition-error outcome, which never runs the action and does not re-arm the watch. A failure is never treated as a false. Motivation: the 2026-10-08 when-pr107-nm-resume incident (transient provider-unreadable window burned the shared error budget and retired the watch). Includes docs/configuration.md and tests/fm-procevent-when.test.sh. Rebase conflicts with main: keep main's behavior and re-apply only this change.
What Changed
0true,1clean false that keeps waiting at the registered cadence,2permanent error that wakes firstmate on its first observation, and any other nonzero exit or per-poll timeout as a transient error.--error-budgetboth emit the terminalcondition-erroroutcome that never runs the action and is not re-armed.docs/configuration.mdanddocs/verification/process-event-sources.md, and extendtests/fm-procevent-when.test.shto cover clean false, transient retry/backoff, permanent first-poll wake, and watcher confirmation/retirement.Risk Assessment
✅ Low: Change is a well-bounded, self-contained fix to bin/fm-procevent-when.sh's exit-code handling with matching docs and new tests that exercise real condition scripts and assert durable outcomes, not source text; logic traced for exit 0/1/2/other/timeout and backoff math checks out against the stated intent.
Testing
Drove all four condition outcomes (true, clean false, permanent exit 2, transient exit 3) plus the per-poll-timeout path against the real adapter and generic process-event runner in disposable isolated FM_HOMEs, reading the captured outcome documents and the durable wake queue. Permanent wakes on poll 1 with the budget untouched, transient retries and fires on recovery, an exhausted budget wakes at exactly N polls, clean false ends only at the deadline as never-true, errors back off 0.5/1/2/4/4/4/4s (doubling capped at 8x the interval), timeout 124 is transient, and a terminal condition-error publishes a wake and does not re-arm. The action never ran on any failure path and ran exactly once on the stable true. The new scenarios also fail against the base adapter, reproducing the fix. The docs/configuration.md contract was read and matches the observed behavior. No visual surface exists, so no screenshots; evidence is CLI transcripts and outcome documents.
Evidence: Target test suite (all pass)
Source: Target test suite (all pass)
Evidence: Base (pre-fix) test suite reproduces the regression
Source: Base (pre-fix) test suite reproduces the regression
Evidence: Live outcome documents: clean-false, permanent, transient, recover
Source: Live outcome documents: clean-false, permanent, transient, recover
when-permanent: status: condition-error / detail: the condition reported a permanent failure (exit 2) on poll 1; the action was not run / condition_polls: 1 (budget 5 unused, action never ran) when-transient: status: condition-error / detail: the condition errored (exit 3) on 3 consecutive polls; the action was not run / condition_polls: 3 when-cleanfalse: status: never-true (deadline) / action never ran when-recover: status: fired / action_exit: 0 / exactly 1 invocationEvidence: Live transient backoff shape and per-poll-timeout transient path
Source: Live transient backoff shape and per-poll-timeout transient path
interval 0.5, budget 8 gaps: 0.645s, 1.122s, 2.198s, 4.167s, 4.092s, 4.066s, 4.149s (doubling capped at 8x=4s); timeout path: exit 124 counted as transient, wake after budget 2, action never ranEvidence: Terminal condition-error publishes a wake and does not re-arm
Source: Terminal condition-error publishes a wake and does not re-arm
reconcile #1: started=1; reconcile #2/#3: published=1 started=0; action never ran; exactly one captured resultEvidence: Durable wake queue rows for the condition-error
Source: Durable wake queue rows for the condition-error
check: procevent when when-permwake 1Evidence: Adversarial permanent break is terminal even if the next poll would be true
Source: Adversarial permanent break is terminal even if the next poll would be true
status: condition-error, condition_polls: 1, condition polled exactly 1 time, action never ran, fired marker absentPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-procevent-when.test.shin the change worktree (full targeted suite, 25 checks, all ok)git show 6141982b:bin/fm-procevent-when.shswapped into a disposable bin/tests copy, thenbash tests/fm-procevent-when.test.shto reproduce the pre-fix failureManual live driver ofbin/fm-procevent-when.sh arm+bin/fm-procevent.sh reconcilein a disposable FM_HOME for clean-false, permanent (exit 2), transient (exit 3), and transient-then-true conditions; read the capturedcondition-error/never-true/firedoutcome documents and action-invocation logsManual live backoff measurement with--interval 0.5 --error-budget 8and per-poll timestamping, and a--condition-timeout 1condition sleeping 3s to confirm exit 124 is transientManual live adversarial run: exit 2 on poll 1, exit 0 on any later poll, budget 9, asserting exactly one poll, no fire, no fired markerManual live durable-wake/retire check:bin/fm-procevent.sh reconcilethenpe list, repeated reconcile to confirm started=0 and thecheck: procevent when when-permwake 1row in state/.wake-queuebin/fm-procevent-when.sh --helpto confirm the documented exit-status contract is emitted✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.