Skip to content

test(action-ledger): make cleanup-stuck projection tests robust under host load - #709

Merged
steipete merged 2 commits into
mainfrom
fix/action-ledger-runtime-tests
Jul 19, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/action-ledger-runtime-tests

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Fixes the two test/action-ledger-runtime.test.ts failures 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 — started 1 !== 4

Analysis: 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:

  1. First test gives the independent root CLAWSWEEPER_CRABFLEET_TIMEOUT_MS=1000. That value also bounds projection queue wait (src/action-ledger-runtime.ts, "CrabFleet projection queue timed out" timer uses request.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 with queue 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 and independentStarted can never reach 1.
  2. Second test's failure is pure fallout. When the first test throws, its resolver-release line was unreachable, leaking 3 of the 4 stuck cleanups. Those hold 3 of the 4 module-global projection slots forever, so the next test's first wave of 4 posts gets exactly 1 slot: started 1 !== 4.

No runtime commit is at fault; the product's slot-hold semantics behave as designed.

Fix (test-only)

  • Raise the independent root's timeout to 30 s so the queue-wait budget outlasts polling on a loaded host (its mock fetch resolves instantly, so nothing actually waits that long).
  • Widen the two 500 ms poll deadlines to 5 s.
  • Release cleanup resolvers in a finally block, 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

  • Both tests: 10/10 green after the fix at load avg 60–90, plus 5/5 green with 8 extra busy-loop processes pinning cores.
  • Full file: 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 in action-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).
  • Autoreview (commit mode): clean after addressing one P2 (late-registered-resolver race, now covered by the release flag).

steipete added 2 commits July 19, 2026 10:45
… 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.
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 19, 2026, 2:16 PM ET / 18:16 UTC.

Summary
The branch raises load-sensitive test timing budgets and adds failure-safe cleanup for blocked action-ledger projection mocks in test/action-ledger-runtime.test.ts.

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.

  • Focused test surface: 1 file affected; 31 added, 21 removed. The patch is confined to test timing and mock-teardown behavior, with no runtime, workflow, dependency, or configuration changes.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Allow the remaining required checks to complete against the submitted head.

Next step before merge

  • [P2] No discrete repair remains from this review; wait for the normal check suite and maintainer review of the current head.

Security
Cleared: The supplied diff only adjusts test mock timing and cleanup; it does not modify runtime code, dependencies, workflows, permissions, secrets, or package execution paths.

Review details

Best 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 changes

Label changes:

  • add P3: This is a low-risk test reliability improvement with no claimed user-facing runtime behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix terminal-style results for repeated targeted runs under high load, additional CPU contention, and the full focused test file; normal CI remains supplemental verification.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix terminal-style results for repeated targeted runs under high load, additional CPU contention, and the full focused test file; normal CI remains supplemental verification.

Label justifications:

  • P3: This is a low-risk test reliability improvement with no claimed user-facing runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix terminal-style results for repeated targeted runs under high load, additional CPU contention, and the full focused test file; normal CI remains supplemental verification.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix terminal-style results for repeated targeted runs under high load, additional CPU contention, and the full focused test file; normal CI remains supplemental verification.
Evidence reviewed

What I checked:

  • Focused test-only diff: The submitted patch changes one test file, raising the independent mock root timeout from 1s to 30s, widening two polling deadlines from 500ms to 5s, and adding finally-based resolver release with a late-registration guard. (test/action-ledger-runtime.test.ts:3254, 61382f5c45cc)
  • Failure-isolation rationale: The PR explains that a failed first test could leave module-global projection cleanup promises unresolved, allowing the next test to observe only one available slot; the final revision explicitly handles a cleanup resolver registered after teardown starts. (test/action-ledger-runtime.test.ts:3254, 61382f5c45cc)
  • Submitted runtime validation: The PR reports repeated after-fix runs of both targeted tests under high host load and a full-file run with 82 passing tests and 2 pre-existing skips; this is useful direct validation for a test-stability change, though normal required checks remain in progress. (test/action-ledger-runtime.test.ts:3254, 61382f5c45cc)

Likely related people:

  • steipete: Authored the two focused revisions that define the timing and teardown behavior under review; current-main feature-history ownership could not be independently established from the available read-only execution environment. (role: recent action-ledger test contributor; confidence: low; commits: 8aa2e125eb60, 61382f5c45cc; files: test/action-ledger-runtime.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit d7e01ce into main Jul 19, 2026
12 checks passed
@steipete
steipete deleted the fix/action-ledger-runtime-tests branch July 19, 2026 20:52
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant