Repository navigation
test(action-ledger): make cleanup-stuck projection tests robust under host load - #709
Conversation
… host load
The scoped-rejection test gave the independent root a 1000ms CrabFleet
timeout, which also bounds projection queue wait. On a loaded host the
5ms polling loops can consume more than 1s of wall clock before the test
frees a slot, so the queued independent projection settled with 'queue
timed out after 1000ms' and could never start. Raise it to 30s and widen
the 500ms poll deadlines to 5s.
On failure the test also leaked its stuck cleanup resolvers, permanently
holding 3 of 4 global projection slots and cascading into the next test
('hold slots until response cleanup settles' saw started 1 !== 4).
Release the resolvers in a finally block so a failure stays scoped.
…lure teardown Autoreview: after the finally block drains the resolver array, a queued blocked post can still start and register a new stuck cleanup on a later microtask, hanging the flush. Gate the mock on a release flag so any cancel after teardown begins resolves immediately.
|
Codex review: needs maintainer review before merge. Reviewed July 19, 2026, 2:16 PM ET / 18:16 UTC. Summary Reproducibility: no. independent current-main run was completed in this review, but the PR gives a concrete load-sensitive path: run the two named action-ledger tests while global projection cleanup slots are delayed. The supplied diagnosis and paired-failure mechanism make the source-level reproduction path reasonably clear. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the narrow test-isolation change once the remaining required checks complete successfully and normal review confirms the enlarged test budgets remain limited to this load-sensitive mock scenario. Do we have a high-confidence way to reproduce the issue? No independent current-main run was completed in this review, but the PR gives a concrete load-sensitive path: run the two named action-ledger tests while global projection cleanup slots are delayed. The supplied diagnosis and paired-failure mechanism make the source-level reproduction path reasonably clear. Is this the best way to solve the issue? Yes. Keeping the production slot-hold semantics unchanged while extending only the test’s queue-wait budget and ensuring teardown releases every mock cleanup is the narrowest maintainable fix for the described host-load flake. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3beb5f044d25. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
… host load (openclaw#709) * test(action-ledger): make cleanup-stuck projection tests robust under host load The scoped-rejection test gave the independent root a 1000ms CrabFleet timeout, which also bounds projection queue wait. On a loaded host the 5ms polling loops can consume more than 1s of wall clock before the test frees a slot, so the queued independent projection settled with 'queue timed out after 1000ms' and could never start. Raise it to 30s and widen the 500ms poll deadlines to 5s. On failure the test also leaked its stuck cleanup resolvers, permanently holding 3 of 4 global projection slots and cascading into the next test ('hold slots until response cleanup settles' saw started 1 !== 4). Release the resolvers in a finally block so a failure stays scoped. * test(action-ledger): release late-registered cleanup resolvers in failure teardown Autoreview: after the finally block drains the resolver array, a queued blocked post can still start and register a new stuck cleanup on a later microtask, hanging the flush. Gate the mock on a release flag so any cancel after teardown begins resolves immediately.
Summary
Fixes the two
test/action-ledger-runtime.test.tsfailures reported on main:cleanup-stuck projection rejection is scoped to the affected spool root— "independent root did not start after a projection slot recovered"CrabFleet timeouts hold slots until response cleanup settles—started1 !== 4Analysis: timing-budget encoding, not a product regression
The failures are load-sensitive, not deterministic. On this host (load averages 60–160 from concurrent sessions) the pair failed roughly 1 in 4 runs on pristine main; the same tree passes repeatedly when load subsides. They always fail together, which is the tell:
CLAWSWEEPER_CRABFLEET_TIMEOUT_MS=1000. That value also bounds projection queue wait (src/action-ledger-runtime.ts, "CrabFleet projection queue timed out" timer usesrequest.config.timeoutMs). Under load, the test's 5 ms polling loops plus the 20 ms settle sleep consume more than 1 s of wall clock while all four global projection slots are still held by the stuck-cleanup posts. The queue timer settles the independent request withqueue timed out after 1000ms(visible verbatim in the failing run's stderr), so when the test finally frees a slot there is nothing left to start andindependentStartedcan never reach 1.started1 !== 4.No runtime commit is at fault; the product's slot-hold semantics behave as designed.
Fix (test-only)
finallyblock, gated by a release flag so a cleanup registered on a late microtask after teardown begins resolves immediately — a failure now stays scoped to its own test instead of starving the global slot pool for the rest of the file.Validation
pnpm run build:all && node --test test/action-ledger-runtime.test.ts— 84 tests, 82 pass, 2 skipped (pre-existing skips), 0 fail.pnpm run check: lint, builds, format, repair suite green; unit run had 1396/1406 pass with 8 failures, all pre-existing load flakes in unrelated suites (apply-runtime-budget,dashboard-worker,failed-review-retry, and the same-second process-identity test inaction-ledger-runtime). Both tests fixed here passed inside the check run, and each of the 8 flaky suites passes on isolated rerun on the same host (they fail nondeterministically under load avg 60-160; previously documented as environmental on this machine).