Repository navigation
fix: let CLI commands exit during cache maintenance - #157884
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 2:01 AM ET / 06:01 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch moves packaged CLI compile-cache maintenance to an unreferenced worker, skips maintenance under Node permission mode, documents that lifecycle, and adds launcher regression coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Current main still starts cache maintenance in the CLI process, so this PR remains useful. The earlier preload and timer-polling findings are addressed at the pinned head, and this review found no current-head correctness defect. Priority: P2 Review scores
Verification
How this fits togetherThe packaged CLI enables a build-scoped Node compile cache before loading commands. Cache maintenance removes old bytecode; its work can affect when a short CLI process exits. flowchart LR
CLI[Packaged CLI command] --> Bootstrap[Compile cache bootstrap]
Bootstrap --> Guard{Node permission mode?}
Guard -- Yes --> Skip[Skip maintenance]
Guard -- No --> Worker[Unreferenced maintenance worker]
Worker --> Cache[Prune old cache entries]
Bootstrap --> Exit[Command can exit]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +221, Docs +3, Other +25. Total +249 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one cache-maintenance owner that lets packaged commands exit promptly, prunes during longer-running processes, and never bypasses Node permission restrictions. Do we have a high-confidence way to reproduce the issue? Yes. Current main invokes the filesystem cleanup in the CLI process, and the event-stalled packaged-launcher fixture directly exercises that path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The existing cache owner retains pruning responsibility, while the unreferenced worker limits command lifetime and the permission-mode guard prevents restricted callers from launching an unrestricted cleanup worker. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1976a166443f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
c4caf2b to
c6c81c8
Compare
|
@clawsweeper re-review Head The chosen behavior preserves quick command exit and best-effort cleanup: a short-lived CLI may exit before pruning finishes, while a sufficiently long-lived process can complete it. Existing age/size targets are soft maintenance targets; this repair does not promise a hard CLI-only retention bound. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Head All 72 selected launcher/cache/SQLite tests passed, fresh P2 review found no actionable findings, and targeted lint/format checks passed. The body records the interrupted broad local scan and pending final hosted CI accurately. Quick CLI exit and interruptible best-effort pruning remain the documented behavior; no hard CLI-only retention guarantee is introduced. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Head Before the fix, a denied-write process's worker deleted a synthetic retired cache. All 16 selected launcher cases now pass, including restricted-mode no-worker/sentinel preservation and unrestricted actual pruning. Fresh P2 review and targeted lint/format checks pass. The previous config-patch CI timeout did not recur on the preceding head; final-head CI remains pending. The body retains the proof limits accurately. |
|
🦞👀 Re-review progress:
|
* fix: let CLI commands exit during cache maintenance * test: declare empty data in synthetic worker fixture * test: declare thread context in heartbeat fixtures * test(cli): coordinate stalled cleanup through events * fix(cli): isolate cache maintenance worker preloads * fix(cli): respect Node permissions during cache maintenance
What Problem This Solves
Packaged CLI commands can finish their work but remain alive while compile-cache maintenance traverses or removes filesystem entries.
Why This Change Was Made
Run best-effort maintenance in an unreferenced worker using the existing shipped cache module. The maintenance worker starts without inherited CLI preloads or application loaders, preventing a supported
--import openclaw/cli-entryinvocation from replaying the CLI and creating nested workers. Node permission mode skips maintenance entirely: worker permissions do not inherit the parent's filesystem restrictions, and copying startup grants would not preserve later revocation.User Impact
Cache cleanup no longer extends command lifetime. Long-lived processes can finish pruning; short commands can exit without waiting for disposable cache I/O. Existing namespace ownership, age, and size maintenance targets remain intact. Cleanup interrupted by exit may leave the cache above its soft maintenance target until a later process runs long enough to complete pruning. Under Node permission mode, cache entries remain until an unrestricted invocation or the operator removes them. This intentional skip neither starts a denied worker nor performs forbidden writes. This repair preserves quick command exit and best-effort cleanup; it does not provide a hard CLI-only retention guarantee.
Evidence
--importarguments andNODE_OPTIONS) reproduced CLI replay and nested maintenance before the isolation fix. The bounded regressions now pass, observe only main-thread CLI effects, await real worker completion, and verify stale-cache removal.65862b9d3fa; its exact shard passed. The earlier Gmail timeout also did not recur. Their causes remain unconfirmed, and final-head hosted CI remains required.