Skip to content

fix: stop ledger tests accumulating temporary files - #1294

Merged
steipete merged 1 commit into
mainfrom
codex/action-ledger-fixture-cleanup
Aug 29, 2026
Merged

fix: stop ledger tests accumulating temporary files#1294
steipete merged 1 commit into
mainfrom
codex/action-ledger-fixture-cleanup

Conversation

@steipete

@steipete steipete commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Related: #1099

What Problem This Solves

Resolves a problem where repeated action-ledger tests accumulate temporary files on long-lived development and validation hosts, even when the tests pass. One existing aggregate-limit case leaves nine 2 MiB shards per run. A fairness-test assertion failure can also leave mock requests occupying every projection slot and cause subsequent tests to fail or hang.

Why This Change Was Made

Each test fixture now registers cleanup as soon as it creates its root, before path canonicalization can fail. Cleanup belongs to the active Node test and removes only that fixture's directory. The fairness fixture releases held requests and drains their work in finally, including callbacks arriving after cleanup starts. The existing timeouts and fairness assertions are unchanged.

This complements #1099's broader test-runner isolation and stale-run cleanup. These helpers must also clean up during direct node --test invocations and between individual tests; the changes do not overlap that PR.

User Impact

Repeated narrow ledger tests no longer leave their temporary data behind after normal completion or assertion failure. A failed fairness assertion no longer strands the following tests. There is no production behavior, configuration, schema, or dependency change. Hard process termination can still bypass Node test hooks.

OpenClaw Bay Impact

None. Only local test-fixture lifetime changes; production queues, action history, publication, and dashboard data are unchanged.

Documentation Impact

Reviewed CONTRIBUTING.md and docs/action-ledger.md. Their validation and ledger contracts remain accurate; no documentation change is needed for this test-only repair.

Evidence

Eight existing focused cases pass: aggregate byte limits, idempotent writes, exported projection concurrency, both import-race child cleanup cases, symlink defenses, and parent-chain swap detection. A fresh temporary directory contains zero retained fixture roots afterward. Formatting, git diff --check, and pre-commit and committed-branch Codex autoreviews pass. Production LOC delta is zero; test LOC is net +8, primarily cleanup scope and try/finally structure.

Real Behavior Proof

Claim and exercised surface: action-ledger test fixtures release their real filesystem directories and held projection requests when their owning test finishes or fails.

Environment: macOS, Node v24.20.0; isolated source at base db14db010bf3044be85f25fe40a587a5ca77523a. The reviewed patch is commit 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a. Required runtime modules were emitted from that source with Node's built-in TypeScript stripping. Each comparison used an isolated temporary directory; no live channel or remote projection endpoint was contacted.

Scenario and command: execute the existing disk-producing tests before and after the patch, then count directories and actual retained file bytes under the isolated TMPDIR:

node --test --test-name-pattern='state shard imports enforce aggregate byte limits before publication|action event writes are create-only and replay-idempotent' test/action-ledger-runtime.test.ts test/action-ledger.test.ts

Observed filesystem trace:

Scenario Before After
Two successful existing tests 2 roots, 10 files, 18,875,955 bytes retained 0 roots, 0 files, 0 bytes retained
Injected error immediately after the aggregate fixture's first disk write Original error plus 1 root / 2,097,152 bytes retained Same original error; 0 roots / 0 bytes retained
Injected fairness assertion failure after four requests started, followed by the existing exported-concurrency test Following test failed 0 !== 4; process remained pending Original failure remains visible; following test passes; process exits in 4.3 seconds with no roots retained
Final eight-case focused run 8 passed, 0 failed; 0 retained roots / bytes

Limits: the attempted full two-file macOS run exceeded the fairness fixture's unchanged 60-second request timeout while writing its 68 durability-backed events. That run was stopped and is not claimed green. The exact-head Linux pnpm check suite subsequently passed, along with Windows launcher, sparse-build, and CodeQL checks (CI run). No timeout was raised or assertion weakened. All temporary data from the deliberate failure and stopped proof runs was removed.

Native Review Admission

The pre-provider scanner blocker was repaired at its owner in #1296, merged as 0a46047ef6a6be7182babb6e33ed6d08df374d0a. That change retains complete scanning and classifies only the exact existing synthetic fixture; it includes native admission/refusal proof and passed the normal review and CI gates. This cleanup PR remains unchanged at 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a, so the cleanup proof above remains applicable. A fresh committed-branch Codex autoreview also passed. The current native re-review can now use the repaired owner on main.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

The body now includes exact-head full-suite CI success and the executed before/after fixture-cleanup and failure-path proof.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

The requested native review is blocked before provider invocation by the mandatory agent-input scan in run 33262270348. The PR remains unchanged at 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a; its hosted CI and separate pre-commit/committed-branch Codex reviews are green.

A local reproduction using the native scanner's flags and isolated environment identified the same existing synthetic malformed-URL fixture in both versions of test/action-ledger-runtime.test.ts:

Scanned version Line Redacted finding metadata
Base db14db010bf3044be85f25fe40a587a5ca77523a 3484 URI detector; unverified; verification error
PR head 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a 3492 Identical URI finding; unverified; verification error

No credential-shaped value is reproduced here. The native scanner deliberately scans both complete base and head blobs for changed files (src/agent-input-scan.ts:334–401) and rejects findings before invoking the provider. Consequently, rewriting only the current fixture would still leave the flagged base blob in the scan and would not resolve this gate.

This PR is left unmerged pending resolution of the synthetic-fixture classification by the scan owner. No scanner policy, source scope, timeout, or test assertion has been weakened, and no further review request is being made while this blocker remains.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The scan-owner prerequisite is merged in #1296 (0a46047ef6a6be7182babb6e33ed6d08df374d0a), with sufficient native proof, no actionable review findings, and green CI. The main PR body now records that resolution alongside the existing exact-head cleanup and failure-path evidence.

This PR's code remains unchanged at 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a; its full hosted checks and fresh committed-branch Codex review are green. Please run the current-head/current-body native review using the repaired owner on main.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 3:51 PM ET / 19:51 UTC.

ClawSweeper review

What this changes

This PR makes action-ledger test fixtures remove their temporary directories and ensures a failed projection-fairness assertion releases held mock requests before later tests run.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still has the pre-cleanup test fixtures, while this narrow test-only repair has credible exact-head filesystem and failure-path proof with no actionable patch defect found.

Priority: P3
Reviewed head: 0efc0e7d2ada1f665e5b2c00ad41c5c3d078c65a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, review-ready test-lifecycle repair with direct before/after runtime evidence and no identified correctness defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.
Evidence reviewed 5 items Introduced fixture cleanup: Both introduced helpers create a unique temp root, register an active Node test cleanup hook immediately, then canonicalize and return that root.
Failure-path pool cleanup: The introduced try/finally releases every held first-wave request, changes later queued fetches to complete, and drains pending posts before the next test can inherit the pool.
Current main does not contain this repair: Current main changes only the review-scanner paths since the PR base; its two ledger-test blobs equal the base blobs and differ from this PR head, so the central cleanup remains needed.
Findings None None.
Security None None.

How this fits together

Action-ledger tests create temporary filesystem roots to exercise durable event and shard handling. A separate projection-fairness test holds mocked requests in a shared admission pool, so its cleanup affects isolation for later tests.

flowchart LR
  A[Action-ledger tests] --> B[Temporary fixture roots]
  B --> C[Node test lifecycle hook]
  C --> D[Fixture directory cleanup]
  A --> E[Projection fairness test]
  E --> F[Finally releases held requests]
  D --> G[Clean later test runs]
  F --> G
Loading

Before merge

  • Complete next step (P2) - Current main has not absorbed the patch, and no discrete repair task remains beyond ordinary maintainer review of this proof-positive PR.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +0, tests +8 net across 2 files The change is confined to fixture lifetime and failure cleanup, with no runtime product surface added.

Technical review

Best possible solution:

Land the per-test temp-root cleanup and fairness-pool finalization while keeping the broader runner-lifecycle work in #1099 separately scoped.

Do we have a high-confidence way to reproduce the issue?

Yes — the PR body records exact-head before/after filesystem counts and an injected fairness failure; current main retains the base versions of both affected test files.

Is this the best way to solve the issue?

Yes — registering cleanup at fixture creation and draining held fairness requests in finally is the narrowest fix for the demonstrated test-lifetime failures.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0a46047ef6a6.

Labels

Label changes:

  • add P3: This is a low-risk test-hygiene repair that prevents local temporary-file accumulation and cross-test interference.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.
  • 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 changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.

Label justifications:

  • P3: This is a low-risk test-hygiene repair that prevents local temporary-file accumulation and cross-test interference.
  • 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 changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owners are the two Node test fixture helpers and the projection-fairness test; the supplied exact-head macOS Node 24 terminal evidence exercises those real tests, shows zero retained roots after normal and injected-failure paths, and records recovery of the following test. Hosted checks are supplemental.

Evidence

What I checked:

  • Introduced fixture cleanup: Both introduced helpers create a unique temp root, register an active Node test cleanup hook immediately, then canonicalize and return that root. (test/action-ledger-runtime.test.ts:48, 0efc0e7d2ada)
  • Failure-path pool cleanup: The introduced try/finally releases every held first-wave request, changes later queued fetches to complete, and drains pending posts before the next test can inherit the pool. (test/action-ledger-runtime.test.ts:2938, 0efc0e7d2ada)
  • Current main does not contain this repair: Current main changes only the review-scanner paths since the PR base; its two ledger-test blobs equal the base blobs and differ from this PR head, so the central cleanup remains needed. (test/action-ledger-runtime.test.ts:48, 0a46047ef6a6)
  • Relevant feature history: Recent merged ledger-test work includes import-race child cleanup, establishing steipete as a current contributor to this fixture-lifecycle area. (test/action-ledger-runtime.test.ts:2916, 3a094723aa36)
  • Real behavior evidence: The supplied exact-head PR body records before/after runs of the real Node tests: retained roots and bytes fall to zero on success and injected failures, and the fairness failure no longer poisons the following test; hosted exact-head pnpm check also passed. (test/action-ledger-runtime.test.ts:48, 0efc0e7d2ada)

Likely related people:

  • steipete: Current history attributes both this focused lifecycle change and the recent merged import-race child-cleanup work to this contributor. (role: recent ledger-test contributor; confidence: high; commits: 0efc0e7d2ada, 3a094723aa36; files: test/action-ledger-runtime.test.ts, test/action-ledger.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix: stop ledger tests accumulating temporary files This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit f8f4674 into main Aug 29, 2026
22 checks passed
@steipete
steipete deleted the codex/action-ledger-fixture-cleanup branch August 29, 2026 19:55
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