Skip to content

fix: finish compile-cache cleanup after short CLI commands exit - #173603

Merged
steipete merged 5 commits into
mainfrom
fix/node-compile-cache-maintenance
Oct 16, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/node-compile-cache-maintenance

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #173568

What Problem This Solves

Fixes: Node's compile cache can grow far beyond its 512 MiB target when short-lived CLI commands exit before cleanup finishes.

User Impact

Explicitly cached CLI commands and release prewarming can finish promptly while detached cleanup continues. Maintenance prunes the combined release cache toward 512 MiB and 4,096 files, with seven-day expiry. A large backlog needs multiple bounded passes; concurrent writers can temporarily exceed these targets. Node permission mode continues to skip maintenance.

Why This Change Was Made

The old unreferenced worker died with the CLI after advancing the hourly timestamp, before the full directory walk and sort had reached any deletion. Cleanup now survives that exit, streams and prunes incrementally, and advances the timestamp only after a completed pass. A filesystem lock serializes cleanup; abandoned locks become recoverable after five minutes. Each invocation examines at most 16,384 entries and stops scheduling scan/prune work after 30 seconds. The retained-file bound prevents tiny entries from consuming unbounded metadata or starving later entries on subsequent passes. Eviction prefers the oldest files observed so far; it does not require a complete inventory first.

Captured facts in detached work: the build-qualified path is immutable cache identity and its namespace/type boundaries are checked by the child; permission mode is checked before launch; application preloads are stripped and child caching is disabled; the child reads the current completion timestamp and lock before pruning, and file metadata during traversal; retention limits are fixed policy owned by the same module. No Gateway configuration, session binding, or credentials are used.

Simplification removes the old worker and its completion-Promise tracking. Production code grows to provide process lifetime, serialization, and bounded incremental pruning rather than leaving any of those responsibilities in callers. Exact numstat versus the merge base: production +125/-43 (net +82), tests +276/-114 (net +162), docs +17/-13 (net +4). This uses the campaign LOC escape hatch: the extra production code owns detached lifetime, serialization, and bounded incremental eviction; no unrelated deletion offsets are included.

Evidence

PR CI is the test gate per maintainer policy. It covers the changed cache owner, its regression tests, launcher integration, type checks, and repository checks. Regression tests added or updated:

  • leaves failed pruning eligible for the next invocation — an injected unlink failure leaves the completion timestamp unchanged, and the next invocation removes the oversized file.
  • makes bounded progress through tiny entries without claiming an incomplete pass — a synthetic 20,000-entry inventory shrinks across two bounded passes without creating thousands of files.
  • prunes an oversized cache after the packaged command exits — a deterministic IPC barrier holds cleanup until the launching CLI exits, then verifies deletion of a sparse 600 MiB entry.
  • remains synchronously importable from CommonJS bundles — bundles and imports the real helper to protect the build boundary exposed by the first CI run.
  • Existing combined-release size/age retention, neighboring-cache preservation, symlink boundaries, Node permissions, and preload isolation remain covered.

Changed-file node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json node-compile-cache.mjs src/infra/node-compile-cache.test.ts test/openclaw-launcher.e2e.test.ts, oxfmt, and git diff --check pass. Precommit and prescribed branch Codex autoreviews are both scoped-clean at P0–P2 with no actionable findings. The repository-local review executable is absent, so both used the installed canonical autoreview helper with the requested private temporary directory and review flags. Tests, typechecks, production negative controls, and live Gateway/Crabbox/Testbox proof were intentionally not run locally under the maintainer proof override. No leases were allocated. Local test wall time is therefore not measured; CI owns execution evidence.

The initial CI run (38831336877, UI shard 7/7) found a PR-caused CommonJS build failure from top-level await. The follow-up removes top-level await, guards the direct-entry path before evaluating import.meta.url, and adds the CommonJS regression. On corrected head 1b54e5760119454cc6a688769b5e74d9a3c93492, CI run 38832426683 has passed the formerly failing UI shard. The cache test job passed all 13 cache tests (3.26 s Vitest duration, 5.59 s wrapper wall time). The launcher job passed all 135 launcher tests (28.323 s test time, 30.40 s Vitest duration); the new cleanup-after-CLI-exit case took 100 ms. The full exact-head CI run completed successfully: 43 jobs passed, 26 skipped, and no failures, including production/test type checks and lint. ClawSweeper has acknowledged the PR; no P0–P2 code findings were posted as of this verification.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 16, 2026 00:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T01:00:34.109569Z 1b54e57 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L labels Oct 16, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves compile-cache maintenance into a detached process with bounded incremental pruning and completion-based retry scheduling.

Example: An explicitly cached short CLI command encounters a 600 MiB cache entry.

  • Before: The command can exit during the worker's scan, leaving the oversized entry and suppressing cleanup for another hour.
  • After: The command exits promptly while detached maintenance continues and removes the oversized entry.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused repair with no identified defects and green exact-head CI; behavior evidence remains fixture-based rather than a separate shipped-install demonstration.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises the shared cache owner through a copied packaged launcher, real child processes, and real filesystem deletion in CI rather than a separate deployed-install capture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Short cached CLI commands can leave disposable bytecode consuming substantial disk space because cleanup repeatedly stops before pruning.
Reason: The report establishes concrete user impact, and the maintainer-authored direction preserves prompt command exit while making cleanup progress independently.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current cache-cleanup failure with focused changes and passing exact-head CI; no actionable correctness or security findings were identified.

Priority: P1
Reviewed head: 1b54e5760119454cc6a688769b5e74d9a3c93492

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No separate shipped-install capture or base-versus-head failing run is supplied; the available evidence is the passing production-path regression harness in exact-head CI.
Agent review details

How this fits together

The shared compile-cache bootstrap serves the packaged CLI, Gateway entry, and prewarmer; it receives a build-qualified cache directory and schedules best-effort removal of disposable bytecode.

flowchart TD
  A[CLI or Gateway or prewarmer] --> B[Shared compile cache bootstrap]
  B --> C[Permission and interval checks]
  C --> D[Detached maintenance process]
  D --> E[Namespace checks and filesystem lock]
  E --> F[Bounded scan and incremental eviction]
  F --> G[Completion timestamp and lock release]
Loading

Technical review

Best possible solution:

Land the shared-owner repair while retaining nonblocking CLI exit, permission-mode isolation, and documented best-effort cache limits.

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

Current-main source establishes that CLI exit can terminate maintenance after the hourly claim but before deletion; the linked report supplies affected-release observations, and no target code was executed during this review.

Is this the best way to solve the issue?

The change addresses lifetime, retry suppression, and unbounded inventory collection at the existing owner, with a complete worker-to-process cutover and relevant regression coverage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b925e9a7b17f.

Provenance checked

  • Background maintenance lifetime changes intended behavior with a stated reason (1276071: Prevent disposable cache I/O from keeping completed commands alive, isolate application preloads, and skip maintenance under Node permissions.)
  • Hourly maintenance claim changes intended behavior with a stated reason (3fadd8c: Claim the interval before scanning so later CLI invocations do not repeat a large scan.)
  • Combined release-cache retention keeps the original intent (1b77dd5: Allow serving and prepared release namespaces to coexist while bounding their combined bytecode by age and size.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +162, Docs +4, Other +82. Total +248 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 276 114 +162
Docs 2 17 13 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 125 43 +82
Total 5 418 170 +248

Review metrics

Metric Value Why it matters
Production versus test LOC Production +125/-43; tests +276/-114 Production growth supplies detached lifetime, serialization, and bounded eviction in the existing owner; test growth covers interruption recovery, bounded progress, and CommonJS import compatibility.
Maintenance bounds 4,096 retained files; 16,384 visited entries; 30-second scheduling budget These fixed policy bounds limit metadata and work per pass without adding a user-facing configuration option.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #173568
Summary: This PR is the candidate repair for the canonical report's interrupted compile-cache maintenance failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: The linked official-release report establishes sustained disk consumption that disrupted another host job, and the interruption mechanism remains on current main.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The linked official-release report establishes sustained disk consumption that disrupted another host job, and the interruption mechanism remains on current main.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 15, 2026, 9:21 PM ET / October 16, 2026, 01:21 UTC.

@steipete
steipete merged commit c335f9c into main Oct 16, 2026
140 of 141 checks passed
@steipete
steipete deleted the fix/node-compile-cache-maintenance branch October 16, 2026 01:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (#173622)
  fix(test): preserve subprocess runtime identity (#173446)
  perf(sessions): batch transcript index reconciliation (#173620)
  fix(gateway): share GitHub options preparation during reconnects (#173589)
  perf(control-ui): open the composer model picker without list-wide work (#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (#173603)
  refactor(ui): finish native shell rendering (#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154)
  refactor: centralize agent memory host typing (#173619)
  fix: camera fallback picker opens away from the attachment button (#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (#173612)
  refactor(tests): remove duplicate speech policy test (#173606)
  refactor(ui): simplify page rendering and derivations (#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615)
  fix(update): wait for native Gateway ownership before restarting (#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…claw#173603)

* fix: finish compile-cache cleanup after short CLI commands exit

* fix: preserve synchronous compile-cache imports in CommonJS bundles
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* fix(ci): share the iOS screenshot build

* fix(ci): preserve the screenshot artifact container on download

* merge: integrate main for iOS screenshot workflow conflicts

* style(ci): format the combined screenshot evidence changes

* docs(ci): name the combined screenshot capture

* fix(ios): expose screenshot simulator creation errors

* Merge main at 56c3151 to include the UI test cleanup fix

* commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (#173622)
  fix(test): preserve subprocess runtime identity (#173446)
  perf(sessions): batch transcript index reconciliation (#173620)
  fix(gateway): share GitHub options preparation during reconnects (#173589)
  perf(control-ui): open the composer model picker without list-wide work (#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (#173603)
  refactor(ui): finish native shell rendering (#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154)
  refactor: centralize agent memory host typing (#173619)
  fix: camera fallback picker opens away from the attachment button (#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (#173612)
  refactor(tests): remove duplicate speech policy test (#173606)
  refactor(ui): simplify page rendering and derivations (#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615)
  fix(update): wait for native Gateway ownership before restarting (#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* fix(ci): share the iOS screenshot build

* fix(ci): preserve the screenshot artifact container on download

* merge: integrate main for iOS screenshot workflow conflicts

* style(ci): format the combined screenshot evidence changes

* docs(ci): name the combined screenshot capture

* fix(ios): expose screenshot simulator creation errors

* Merge main at a11e38b to include the UI test cleanup fix

* commit 'a11e38b8bb1eb58aaf392a0eab458dbb47aad30f': (23 commits)
  fix(ui): remove stale Lit cleanup from model catalog tests
  refactor(tests): consolidate iMessage discovery checks (openclaw#173624)
  fix(auto-reply): retire older collect cancellation after admission
  fix(memory): avoid rebuilding initially empty indexes after restart (openclaw#173622)
  fix(test): preserve subprocess runtime identity (openclaw#173446)
  perf(sessions): batch transcript index reconciliation (openclaw#173620)
  fix(gateway): share GitHub options preparation during reconnects (openclaw#173589)
  perf(control-ui): open the composer model picker without list-wide work (openclaw#173275)
  fix: finish compile-cache cleanup after short CLI commands exit (openclaw#173603)
  refactor(ui): finish native shell rendering (openclaw#171554)
  fix: preserve standalone CLI profiles and settle Doctor shutdown (openclaw#173154)
  refactor: centralize agent memory host typing (openclaw#173619)
  fix: camera fallback picker opens away from the attachment button (openclaw#173618)
  refactor: deduplicate existing CI runner routing with YAML anchors (openclaw#172670)
  fix(ai): preserve multiline Google replies and report malformed streams (openclaw#173612)
  refactor(tests): remove duplicate speech policy test (openclaw#173606)
  refactor(ui): simplify page rendering and derivations (openclaw#173608)
  fix(release): Linux channel promotion fails after a withdrawn Windows companion (openclaw#173615)
  fix(update): wait for native Gateway ownership before restarting (openclaw#173588)
  test(sessions): admit schema probe fixture writes behind maintenance
  ...

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

[Bug]: Node compile cache grows far past MAX_BYTES (512 MiB): maintenance never completes from short-lived CLI processes (2026.10.2, macOS)

1 participant