feat(doctor): report and reclaim abandoned response-state temps - #2089
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
…ly fire The budget warning keyed on eligible > removed + failed, which is unreachable outside a dry run: an entry is counted eligible and then unlinked or failed on the same iteration, so the two are always equal. An operator whose backlog exceeded the cleanup budget was told the reclaim had finished. Carry an explicit truncated flag on the scan result instead, set wherever the loop stops on a budget rather than on the end of the directory, and OR it across the swept directories. The dry-run report is bounded by the entry cap too, so a truncated report now says the count is a floor. The partial-reclaim test asserted a state production cannot reach; it now uses a reachable one and is paired with an ablation guard that fails if the warning stops depending on the flag.
3cb6bb4 to
e298cf8
Compare
Summary
Layer 2 of a two-PR stack. Layer 1 (#2084) made the temp reclaim periodic, which fixes every proxy that runs. This PR covers the case layer 1 structurally cannot reach: a proxy that will not start, which is exactly when the pile grows fastest — the in-process timer lives in the process that is failing.
ocx doctornow reports abandoned response-state temps read-only by default, andocx doctor --reclaim-response-tempsremoves them. Both work without a running proxy.Report is the default and reclaim is opt-in on purpose:
doctoris a diagnostic an operator runs to understand a machine, so deleting files as a side effect of asking a question is the wrong default even for cache files.Key design point: the report reuses the same selection predicate as the reclaim via an explicit
dryRunmode, witheligible/eligibleBytescounted after every gate. It deliberately does not reportmatched, which increments before the file-type, age, boot-floor, and liveness gates — reporting that would tell an operator that live-pid and young temps are abandoned.Stack (merge bottom-up):
ocx doctoroperator reclaimDepends on #2084. Base is
codex/tmp-reclaim-1-sweeper; review this PR's diff only. After #2084 lands this retargets todev.Plan and three audit records:
devlog/_plan/260819_response_state_temp_reclaim/.Verification
Full suite on a separate machine (
macmini-cf) ata2cec13db:bun run test→ 13397 pass, 1 fail, 850 files. The single failure isupdate-npm-cache-preflight, proven pre-existing at the unmodified base59964ad77(10 pass / 1 fail, identical); it needs a workingnpm configon the host.bun test tests/doctor.test.ts tests/responses-state.test.ts tests/state-store-sweeper.test.ts→ 171 pass, 0 fail, 506 assertions.bun run typecheckclean;bun run privacy:scanpassed.An independent audit of this layer returned 5 blockers, all fixed here. The sharpest: the formatter tests fed literal objects to a pure function, so inverting the report/reclaim ternary would have left the entire suite green — the flagship "doctor does not delete by default" property was claimed by three accept criteria and demonstrated by none. There is now an end-to-end block that seeds a real stale temp in an isolated
OPENCODEX_HOMEand asserts the default run leaves it on disk, the flag removes it, and a mistyped flag warns.Also fixed from that audit: report and reclaim used different budgets (would have said "816 reclaimable" then silently freed 512), the flag had no help text, a typo degraded silently into a report, and both the CLI and docs promised locked files "are retried automatically" — false for the very reader this command exists for.
Checklist
bun run typecheckcleanbun run privacy:scangreendocs-site/updated with a troubleshooting page and sidebar entry (English only, matching the existingwindows-memoryconvention)