Skip to content

test(mecatui): replace lifecycle sleeps with observed barriers - #2630

Merged
jbeda merged 2 commits into
mainfrom
test/lifecycle-flake-barriers
Oct 31, 2026
Merged

jbeda merged 2 commits into
mainfrom
test/lifecycle-flake-barriers

Conversation

@jbeda

@jbeda jbeda commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace two sleep-based lifecycle-test assumptions with observed barriers:

  • Agent-hook retirement: observe the actual successor payload and retired worker exit before checking the settled delivery history; release and close both notifier fixtures during cleanup.
  • Render serialization: a testing/synctest test holds a cancelled renderer past replacement debounce readiness, settles the goroutines, and proves replacement work cannot start until the predecessor returns. Release then proves replacement progress and latest-result publication.
  • Real Unix process lifecycle: the background descendant announces startup through a test-owned FIFO. After replacement cancellation and latest publication, that FIFO must reach EOF independently of the command's stdout and WaitDelay. A second FIFO releases even an orphaned descendant during failure cleanup, without PID probes or survival sleeps.

These address the two remaining hardening candidates in the local handoff. Neither was reproduced as a current CI flake. This is test hardening only, not a claim that a newly reproduced production or CI failure is fixed. Related flake tracker: #2327; this PR does not close it.

Why

The hook test's 200ms sleep could allow a negative assertion before retired-worker activity settled. It now waits on actual worker completion.

The status test's 300ms sleep could let submissions coalesce before the first command started. Its one-second invocation timeout could also rescue broken replacement cancellation. The real-process test now observes descendant startup and disables that independent invocation deadline.

The initial panel found two further coverage gaps: debounce could mask missing render serialization, and stdout WaitDelay could mask a surviving descendant. Both are resolved by the split fake-time serialization test and independent descendant-owned FIFO EOF assertion.

Verification

All passed locally on the revised change:

  • task test (1800-second outer bound)
  • task lint (600-second outer bound; zero issues across all modules)
  • task test:race (1800-second outer bound)
  • go run ./cmd/mecademo — tool call, permission ask/approval, and final result observed
  • git diff --check
  • Darwin/arm64 cross-compilation of the customization tests (compile only; not a macOS runtime claim)

Focused stress: 150 race-enabled executions each of the new serialization test and revised real-process test across CPU settings 1, 2, and 4:

go test -race -count=50 -cpu=1,2,4 \
  -run '^(TestStatusLineReplacementWaitsForRenderJoin|TestStatusLine_Scenario4_ProcessLifecycleAndGenerationGuard)$' \
  ./cmd/mecatui/customization

The unchanged agent-hook hardening also passed 150 race executions across those CPU settings during the initial verification.

Mutation checks

New mutations directly exercise the two panel findings; all production edits were restored before the revised full gates:

  1. Mark rendering inactive immediately after replacement cancellation, allowing concurrent replacement entry: the fake-time test fails immediately with replacement "latest" started before the first renderer joined.
  2. Remove procgroup.Configure while retaining WaitDelay: the real-process test reaches replacement publication but fails on the independent FIFO read with descendant retained its pipe after cancellation. Failure cleanup releases the orphan.

The initial version also detected removal of replacement cancellation, stale-generation filtering, and revoked-worker delivery suppression. Those initial results are supplementary; the two checks above were run against the revised tests.

Panel review

Re-reviewed the complete four-file diff against original base cca18a37e48ba95a9003fb993c3ce8eb360a01ae, including the authorized follow-up fixes:

Axis Result
Spec — handoff candidates and practical panel fixes No findings
Standards — repository conventions and test isolation No findings
Independent test adequacy No findings; both prior findings confirmed resolved
Domain — software architect, pure-test scope No findings

PANEL: ship_blockers=0 important=0 advisory=0 reviewer_failures=0

API compatibility

No wire, Go-source API, stored-data, or runtime behavior changes: only test fixtures and assertions change. No API major bump, feature identifier, client changes, or upgrade steps are required. The real FIFO/process test is Unix-scoped; the deterministic serialization test is platform-independent.

jbeda and others added 2 commits October 31, 2026 12:50
Wait for retired notifier completion and actual command startup before lifecycle assertions. Prevent the invocation deadline from masking broken replacement cancellation.

Co-authored-by: Mecatl <[email protected]>
Hold cancelled rendering beyond debounce readiness under synctest. Use an independent descendant-owned FIFO to verify process-group cancellation cannot be masked by WaitDelay, with a cleanup release path for orphaned fixtures.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda force-pushed the test/lifecycle-flake-barriers branch from 2993329 to f22359d Compare October 31, 2026 19:50
@jbeda
jbeda enabled auto-merge (squash) October 31, 2026 19:53
@jbeda
jbeda merged commit 43f621d into main Oct 31, 2026
41 checks passed
@jbeda
jbeda deleted the test/lifecycle-flake-barriers branch October 31, 2026 20:00
@jbeda jbeda mentioned this pull request Oct 31, 2026
10 of 14 tasks
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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