Skip to content

feat(doctor): report and reclaim abandoned response-state temps - #2089

Merged
lidge-jun merged 4 commits into
devfrom
codex/tmp-reclaim-2-doctor
Aug 19, 2026
Merged

feat(doctor): report and reclaim abandoned response-state temps#2089
lidge-jun merged 4 commits into
devfrom
codex/tmp-reclaim-2-doctor

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

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 doctor now reports abandoned response-state temps read-only by default, and ocx doctor --reclaim-response-temps removes them. Both work without a running proxy.

Report is the default and reclaim is opt-in on purpose: doctor is 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 dryRun mode, with eligible/eligibleBytes counted after every gate. It deliberately does not report matched, 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):

# PR Layer Review focus
2 this PR ← you are here ocx doctor operator reclaim CLI surface, dry-run accounting, operator wording
1 #2084 periodic reclaim + boot floor reclaim scheduling and safety-gate ordering

Depends on #2084. Base is codex/tmp-reclaim-1-sweeper; review this PR's diff only. After #2084 lands this retargets to dev.

Plan and three audit records: devlog/_plan/260819_response_state_temp_reclaim/.

Verification

Full suite on a separate machine (macmini-cf) at a2cec13db:

  • bun run test13397 pass, 1 fail, 850 files. The single failure is update-npm-cache-preflight, proven pre-existing at the unmodified base 59964ad77 (10 pass / 1 fail, identical); it needs a working npm config on the host.
  • bun test tests/doctor.test.ts tests/responses-state.test.ts tests/state-store-sweeper.test.ts171 pass, 0 fail, 506 assertions.
  • bun run typecheck clean; bun run privacy:scan passed.

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_HOME and 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

  • Focused regression tests added, including end-to-end coverage of the call site
  • bun run typecheck clean
  • Full suite run; the one failure attributed and proven pre-existing
  • bun run privacy:scan green
  • docs-site/ updated with a troubleshooting page and sidebar entry (English only, matching the existing windows-memory convention)
  • Stacked on fix(responses): reclaim abandoned state temps on a timer, not only at load #2084 with an explicit base

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • ^dev$
  • ^preview$

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ae835868-b8c1-419e-89c4-9b51cca90da4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 19, 2026
lidge-jun and others added 4 commits August 19, 2026 19:00
…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.
@lidge-jun
lidge-jun force-pushed the codex/tmp-reclaim-2-doctor branch from 3cb6bb4 to e298cf8 Compare August 19, 2026 10:02
@lidge-jun
lidge-jun changed the base branch from codex/tmp-reclaim-1-sweeper to dev August 19, 2026 10:08
@lidge-jun
lidge-jun merged commit c4bf833 into dev Aug 19, 2026
26 checks passed
@lidge-jun
lidge-jun deleted the codex/tmp-reclaim-2-doctor branch August 19, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant