Skip to content

test: tolerate a slow post-TERM fixture launch confirmation - #8220

Open
lockhartheavyindustries wants to merge 1 commit into
kunchenguid:mainfrom
lockhartheavyindustries:fm/procevent-post-term-upstream
Open

lockhartheavyindustries wants to merge 1 commit into
kunchenguid:mainfrom
lockhartheavyindustries:fm/procevent-post-term-upstream

Conversation

@lockhartheavyindustries

@lockhartheavyindustries lockhartheavyindustries commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

tests/fm-procevent.test.sh could exit silently after 76 passes with no not ok line.
In the post-TERM reuse fixture, pe "$HPOST_TERM" reconcile >/dev/null ran bare under set -e.
When the source launch was not confirmed inside the 3-second confirm window, which a loaded Mac easily misses, reconcile returned 1 with its summary discarded, and the whole suite stopped.

Tolerating a late confirmation is safe here because the next line waits for the child PID and the line after waits for the claim, so a fixture that really never starts still fails.
That failure message now carries the captured reconcile summary.

Related: the macOS setsid failure at the later tests/fm-procevent.test.sh line is not touched here and is fixed by #8217.
#8204 is related load-sensitive test timing.

Intent

B, then open the PR.

Context: the choice was between two versions of a fix for tests/fm-procevent.test.sh. A scout (report data/procevent-test-exit1/report.md, also in the vault as "Process-event test exit investigation") found that in the post-TERM reuse fixture loop (around lines 2931-2932) the pe "$HPOST_TERM" reconcile >/dev/null call runs under set -e. When the source launch is not confirmed within the 3-second window (common on a loaded Mac), reconcile returns 1 with its summary discarded, and the whole suite exits silently after 76 passes with no "not ok" line. The scout proved the fixture does start a few seconds later and all four post-TERM checks then pass. Option A only reported the slow start clearly (capture output, fail with the summary). Option B, chosen: also tolerate a slow launch confirmation as long as the fixture does start, because the next line already waits for the child PID and fails if it never appears, so a real launch failure is still caught. The separate setsid portability fix at line ~5162 is NOT part of this task: upstream PR #8217 already carries the identical change.

What Changed

  • In tests/fm-procevent.test.sh, the post-TERM reuse fixture no longer runs pe "$HPOST_TERM" reconcile bare under set -e. Before this change, a launch confirmation that missed the reconcile window made reconcile exit 1, which ended the whole suite silently with no not ok line. The call now captures reconcile's combined output and ignores its exit status (|| true).
  • The next line still waits for the fixture's child PID, so a fixture that never starts still fails the suite. That failure message now includes the captured reconcile summary, so a real non-start shows why.
  • An inline comment explains why the reconcile exit status is tolerated here.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change touches one test line and matches option B in the stated intent. If reconcile only misses its confirmation window, the suite no longer stops on that exit 1. If the fixture really never starts, the existing PID wait, claim wait and source-launch pe list check still fail it, and the PID-wait failure now includes the reconcile output. The bin/fm-procevent.sh code at lines 1632-1660 shows that a launch reconcile could not confirm keeps running and only raises a per-home check event, which none of the later post-TERM checks read.

Testing

I built a disposable harness from the real test file: the shared setup plus the exact post-TERM loop, under the same set -e. A PATH-prefixed ps shim delays or refuses the detached runner's own pgid self-check, which runs before it claims the source. That forces a launch-confirm miss on demand, so the test does not depend on a loaded Mac. - Normal launch: the new code passes all four post-TERM cases. - Runner delayed 5 seconds: the base-commit code exits 1 with no "not ok" line, which reproduces the bug. The new code passes all four cases. - Runner that never starts: the new code fails with "not ok - the post-TERM reuse fixture did not start: reconciled: ... failed=1". - Direct reconcile: run alone with the same delay, reconcile returns rc=1 with failed=1, and the claim appears a few seconds later. I stopped the full-file run of tests/fm-procevent.test.sh before it finished, at 55 ok and 0 not ok, because the turn had to end. Remote CI owns the full regression run. I deleted the temporary harness files and shim, and the worktree is clean. The only fm-procevent processes still running belong to the operator's real fleet and the outer no-mistakes run, not to this test.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Slow fixture launch (runner delayed 5s, past the 3s confirm window): the old loop kills the suite silently and the new loop passes all four post-TERM checks ✅ pass live s2-old-slow-launch.log (exit=1, no output); s2-new-slow-launch.log (4 ok, exit=0)
Real non-start (runner refuses before claiming): the new loop still fails, with a not-ok line that names reconcile's failed=1 summary ✅ pass live s3-new-never-starts.log
Normal launch: the post-TERM loop passes all four cases ✅ pass live s1-new-normal.log
Reconcile itself exits 1 with failed=1 on a slow launch, and the fixture claims a few seconds later ✅ pass live s2b-reconcile-slow-direct.log
Evidence: Old code, delayed launch: silent exit 1, no not-ok line (bug reproduced)

Source: Old code, delayed launch: silent exit 1, no not-ok line (bug reproduced)

env PT_SHIM=$S/shim PT_MODE=slow PT_DELAY=5 bash tests/.pt-$v-harness.sh  0.72s user 1.31s system 42% cpu 4.779 total
exit=1
Evidence: New code, delayed launch: all 4 post-TERM checks pass

Source: New code, delayed launch: all 4 post-TERM checks pass

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

harness: post-TERM loop completed
env PT_SHIM=$S/shim PT_MODE=slow PT_DELAY=5 bash tests/.pt-$v-harness.sh  3.36s user 5.97s system 25% cpu 36.144 total
exit=0
Evidence: New code, runner never starts: fails with reconcile summary

Source: New code, runner never starts: fails with reconcile summary

not ok - the post-TERM reuse fixture did not start: reconciled: published=0 started=0 stopped=0 uncertain=0 failed=1 exit=1

not ok - the post-TERM reuse fixture did not start: reconciled: published=0 started=0 stopped=0 uncertain=0 failed=1
env PT_SHIM=$S/shim PT_MODE=nostart bash tests/.pt-new-harness.sh  0.77s user 1.34s system 11% cpu 18.664 total
exit=1
Evidence: New code, normal launch: 4 passes

Source: New code, normal launch: 4 passes

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

harness: post-TERM loop completed
bash tests/.pt-new-harness.sh  1.81s user 2.33s system 29% cpu 13.909 total
exit=0
Evidence: Direct reconcile with delayed runner: rc=1 failed=1, claim appears later

Source: Direct reconcile with delayed runner: rc=1 failed=1, claim appears later

reconcile (runner delayed 5s, default 3s confirm window): rc=1
reconciled: published=0 started=0 stopped=0 uncertain=0 failed=1
slow-src.claim
Evidence: ps shim used to delay or refuse the runner pre-claim check

Source: ps shim used to delay or refuse the runner pre-claim check

#!/usr/bin/env bash
if [ "${1-}" = -o ] && [ "${2-}" = pgid= ] && [ "${3-}" = -p ] && [ "${4-}" = "${FM_PROCEVENT_RUNNER_GROUP-none}" ] && [ -n "${FM_HOME-}" ]; then
  case "${PT_MODE-}" in
    slow) if [ ! -e "$FM_HOME/.pt-slowed" ]; then : > "$FM_HOME/.pt-slowed"; sleep ${PT_DELAY:-5}; fi ;;
    nostart) printf 'pt-shim refused runner pgid check\n' >&2; exit 1 ;;
  esac
fi
exec /bin/ps "$@"
Evidence: Partial full-file run (stopped by tester, 55 ok / 0 not ok)

Source: Partial full-file run (stopped by tester, 55 ok / 0 not ok)

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 - 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)
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
(stopped by tester before completion: 55 ok, 0 not ok at stop time)

Pipeline

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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Slow fixture launch (runner delayed 5s, past the 3s confirm window): the old loop kills the suite silently and the new loop passes all four post-TERM checks ✅ pass live s2-old-slow-launch.log (exit=1, no output); s2-new-slow-launch.log (4 ok, exit=0)
Real non-start (runner refuses before claiming): the new loop still fails, with a not-ok line that names reconcile's failed=1 summary ✅ pass live s3-new-never-starts.log
Normal launch: the post-TERM loop passes all four cases ✅ pass live s1-new-normal.log
Reconcile itself exits 1 with failed=1 on a slow launch, and the fixture claims a few seconds later ✅ pass live s2b-reconcile-slow-direct.log
  • bash tests/.pt-new-harness.sh (temporary harness, now deleted: lines 1-157 of tests/fm-procevent.test.sh plus the real post-TERM loop, run under set -eu), with no fault injected
  • PT_SHIM=<shim> PT_MODE=slow PT_DELAY=5 bash tests/.pt-old-harness.sh: the base-commit (65a9a51f) loop with the runner's pgid self-check delayed 5s
  • PT_SHIM=<shim> PT_MODE=slow PT_DELAY=5 bash tests/.pt-new-harness.sh: the same delayed launch against the changed loop
  • PT_SHIM=<shim> PT_MODE=nostart bash tests/.pt-new-harness.sh: the runner refuses its pgid check, so it never claims and never starts
  • Direct bin/fm-procevent.sh register then reconcile in a disposable FM_HOME and claim root, with the delayed-runner shim, then a check that the claim appears late, then retire
  • bash tests/fm-procevent.test.sh: full single-file run, stopped by the tester before it finished (55 ok, 0 not ok at stop time)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

reconcile exits 1 when the launch is not confirmed inside its window, and under set -e with its summary discarded that ended the whole suite silently. The PID and claim waits that follow still fail a real non-start, now with the reconcile summary in the message.
@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Reviews (1) · Last reviewed commit: "test: tolerate a slow post-TERM fixture ..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @lockhartheavyindustries — first look at head 476eca97 against main bf05a4fc. The tip only touches tests/fm-procevent.test.sh: the post-TERM reuse fixture no longer runs pe reconcile bare under set -e, so a launch confirmation that misses the 3-second window no longer kills the suite silently. The next PID and claim waits still fail a real non-start, and that failure now carries the reconcile summary. Live evidence is go 4 of 4 (normal, delayed, never-starts, direct reconcile). The attestation binds this head with every step completed, Greptile is 5/5 with no threads, and quick checks pass after we approved the fork CI runs. No workflow, network, or credential changes. Related setsid work stays in #8217; load-sensitive timing in #8204 is separate.

Contract-class: restore. The fixture already promised to exercise post-TERM reuse; tolerating a late confirmation under load restores that regression without changing product defaults.

VISION, rule by rule: one captain (less flake noise) aligns; authority aligns (no new autonomy); scripts own mechanics aligns (PID/claim waits are exact); restart neutral here; delegation/spine aligns (field flake → coverage); fleet-outlives aligns (portable serial); scope aligns (test infra only).

Next: the author work is done. The next step is ours: we run the Full suite, and if it's green this can land as a restore. The red Full suite check before then is our label gate, so there's nothing for you to fix there.

@lockhartheavyindustries

Copy link
Copy Markdown
Contributor Author

Friendly nudge: this still merges cleanly against current main. #8217 (merged 2026-11-08) changed a different fixture in tests/fm-procevent.test.sh; the post-TERM reuse fixture still runs pe reconcile bare under set -e on main (around line 2983), so the slow-launch-confirmation flake this fixes is still live. Whenever there's a slot for the Full suite run, it's ready.

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.

2 participants