fix(doctor): add --fix pruning for disk-usage, skipping recent sessions#175
fix(doctor): add --fix pruning for disk-usage, skipping recent sessions#175carlkibler wants to merge 1 commit into
Conversation
check_disk_usage had no fix function, so `cozempic doctor --fix` skipped it and left only a generic "treat <session>" hint. This wires fix_disk_usage into ALL_CHECKS with a conservative, age-gated selection: - `cozempic doctor --fix` now applies the gentle prescription to sessions that are both larger than 5MB and untouched for more than 7 days, writing a .bak per session first. - Recent sessions (modified within 7 days) are skipped so an active or in-flight session is never rewritten; the fix reports treated vs skipped counts. - The check's fix_description now shows the candidate count and threshold instead of the generic placeholder. No change to the check's pass/fail status or to any other check. Co-Authored-By: Claude <noreply@anthropic.com>
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b832d43928
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| messages = load_messages(sess["path"]) | ||
| pruned, _ = run_prescription(messages, PRESCRIPTIONS["gentle"], {}) | ||
| save_messages(sess["path"], pruned, create_backup=True) |
There was a problem hiding this comment.
Preserve append-safety when pruning disk-usage candidates
In the doctor --fix disk-usage path, this rewrites session JSONL files using a plain load_messages()/save_messages() round trip without the _PruneLock and snapshot that the existing treat/guard/orphaned-fix write paths use. For an eligible old session that is resumed, appended to, or pruned by another process after the mtime candidate check but before this save_messages() call, the replace can discard those concurrent lines because save_messages() only performs append-conflict detection when a snapshot is passed. Please use load_messages_and_snapshot() plus _PruneLock and pass snapshot= here so automatic doctor --fix cannot clobber live transcript updates.
Useful? React with 👍 / 👎.




What
check_disk_usagehasNoneas its fix function inALL_CHECKS, socozempic doctor --fixskips it and leaves only a generictreat <session>hint. This wiresfix_disk_usagein with a conservative, age-gated selection:cozempic doctor --fixnow applies the gentle prescription to sessions that are both larger than 5MB and untouched for more than 7 days, writing a.bakper session first.fix_descriptionshows the candidate count and threshold instead of the generic placeholder.Why
On main (1.8.39)
disk-usageandoversized-sessionsare the only two checks still registered with aNonefix function. This one is deliberately conservative (age + size gated,.bakfirst) because disk-usage sweeps a broad set of sessions, some of which may be live.Tests
tests/test_doctor.py— 43 passed (adds coverage for the age-gate and skip-recent behavior).Companion to #174 (oversized-sessions
--fix). The two touch adjacentALL_CHECKSentries; happy to rebase whichever merges second.https://claude.ai/code/session_01UFpNbexgthmPFAcyHuVepn