Repository navigation
perf(process): avoid rescanning exited runs - #128080
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 10:26 PM ET / August 23, 2026, 02:26 UTC. ClawSweeper reviewWhat this changesThe PR maintains an exact private count of exited process-run records so finalization avoids repeatedly scanning the retained registry. Merge readinessKeep open. The private counter is maintained across the registry’s write paths, preserves insertion-order pruning, and introduces no concrete review finding; this active maintainer-owned PR should proceed through normal exact-head checks. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe process supervisor records command-run lifecycle events and retains completed records for diagnostics. Terminal transitions feed the registry, which prunes old exited records while callers can still retrieve detached snapshots. flowchart LR
A[Process lifecycle events] --> B[Supervisor]
B --> C[Run registry]
C --> D[Exited record count]
D --> E{Retention cap exceeded?}
E -->|Yes| F[Prune oldest exited records]
E -->|No| G[Retain diagnostic records]
F --> H[Run status lookup]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +38. Total +42 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the count as private registry-owned state and land it once the exact PR head has normal green checks. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: current main scans every registry value during terminal pruning. This read-only review did not execute the benchmark. Is this the best way to solve the issue? Yes. Keeping the count in the registry that owns every record mutation is the narrowest maintainable solution; moving the optimization into supervisor callers would duplicate lifecycle policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a38b88ae03e8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready review complete for exact head The process registry is the canonical mutation owner, and the private exact exited-record count is the best fix: it removes the full retained-set recount while preserving detached snapshots, first-terminal metadata, the 2,000-record cap, live-record retention, and Map insertion-order pruning. Native review artifacts validate as Verification:
ClawSweeper reviewed this exact head, found no correctness or security issue, rated patch quality platinum hermit, and agreed the private registry-owned count is the best solution. It published no Known proof gap: no live process smoke was run. This is private behavior-neutral in-memory accounting; exact semantic differential, every mutation-branch regression, the full supervisor suite, build, hosted CI, and prepare gates directly cover the changed contract. Ready to merge. |
|
Merged via squash.
|
What Problem This Solves
The process supervisor retains exited run records for diagnostics. Every completed run currently rescans the entire registry solely to recount those exited records, making repeated process completion quadratic before the 2,000-record retention cap and leaving an unnecessary full retained-set scan afterward.
Why This Change Was Made
The registry now maintains one exact private exited-record count across additions, replacements, state transitions, effective finalization, and pruning. Pruning still follows
Mapinsertion order, so the oldest created exited records leave first; live records, detached snapshots, first terminal metadata, the default cap, and all public types remain unchanged.User Impact
Long-running OpenClaw processes that supervise many commands spend less CPU finalizing completed runs. There is no user-visible behavior or configuration change.
Evidence
main: 500/1,000 completions visited 125,250/500,500 registry values before the change and 0 after it.530bb25abb5d22d3f8f4becdd42b0e6c4cf1006421950e533b7d698644bf098c) across out-of-order exits, repeated pruning, replacements, state transitions, detached snapshots, missing IDs, output touches, and idempotent finalization.node scripts/check-changed.mjs -- src/process/supervisor/registry.ts src/process/supervisor/registry.test.tspnpm buildAI-assisted: yes. @steipete reviewed the owner path, invariant, diff, and verification evidence and understands the change.