Skip to content

feat(doctor): v4 home-residue detection + --fix, diagnostics age filter - #2532

Merged
namastex888 merged 1 commit into
devfrom
wish/v4-home-residue-doctor
Jul 5, 2026
Merged

namastex888 merged 1 commit into
devfrom
wish/v4-home-residue-doctor

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Wish: v4-home-residue-doctor

Extends the shipped v4 cleanup to ~/.genie daemon-era residue and puts it in every user's hands via genie doctor.

  • Manifest: 13 src-proven entries (serve.pid, genie-serve.config.cjs, relay/, spawn-scripts/, state/, model-a/, data/, hook-fallback.log, role-cutover-events.jsonl, .role-cutover-*.json, config.json.bak-pre-omni, logs/scheduler.log, Genie.config.cjs) — each with grep-evidence; uncertain paths are KEPT and reported, never touched. lstat-only, symlinks never followed, full-content backup-first.
  • Doctor: v4 residue check (count/bytes split by genie-home vs claude buckets); --fix opt-in runs the backup-first cleanup; --fix --json is contract-safe (chatter → stderr via logSink; subprocess test parses stdout as JSON).
  • Diagnostics: summarizeJsonlSignals age-filters at 48h — a June-22 disk-full no longer resurfaces as "Recent scheduler signals" on healthy machines (observed tonight).

Review: FIX-FIRST (json contract) → fixed → all prescriptions verified. 164 tests/0 fail across the 4 suites; destructive surface independently re-proven (symlink attack, byte-identical live files, near-miss globs). check:fast green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N1FLEV2Qse3jbX5Wz1sjWE

13 src-proven ~/.genie residue entries join the legacy-v4 manifest
(lstat-only, symlinks never followed, full-content backup-first);
genie doctor gains a v4-residue check with opt-in --fix (json-safe via
logSink; uncertain keeps reported, never touched); update diagnostics
age-filter scheduler signals at 48h so stale incidents stop resurfacing.
Wish v4-home-residue-doctor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1FLEV2Qse3jbX5Wz1sjWE
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Important

Review skipped

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

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

Run ID: fb6c2ff5-d244-49dd-b71b-bc904b74c283

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wish/v4-home-residue-doctor

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.

@namastex888
namastex888 merged commit 0758b8c into dev Jul 5, 2026
11 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9eaa151c2

ℹ️ 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".

mkdirSync(dirname(backupPath), { recursive: true });
cpSync(relic.path, backupPath, { recursive: true });
ctx.backupDirUsed = true;
rmSync(relic.path, { recursive: true, force: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid deleting through symlinked residue parents

When a manifest path has a symlinked parent, e.g. ~/.genie/logs -> /somewhere/else, the detector records logs/scheduler.log because lstatSync() only checks the leaf path after the parent symlink has already been traversed. The cleanup then calls rmSync(relic.path), which deletes the target file outside GENIE_HOME; this can happen automatically during install/update cleanup, not just doctor --fix. Resolve and validate each candidate against the real genie home, or reject any symlink in the ancestor chain, before removing it.

Useful? React with 👍 / 👎.

Comment on lines +234 to +235
for (const entry of readdirSync(path, { withFileTypes: true })) {
total += sizeOfPathTree(join(path, entry.name));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep doctor from crashing on unreadable residue trees

If a detected residue directory such as ~/.genie/relay exists but contains an unreadable subdirectory or entry, readdirSync() throws while computing sizeBytes; because detectV4HomeResidue() does not catch this per relic, plain genie doctor can abort instead of reporting diagnostics, and install cleanup can fail before reaching the per-relic error handling. Treat size calculation as best-effort here, similar to safeSizeOf() in the doctor output path.

Useful? React with 👍 / 👎.

@automagik-genie
automagik-genie deleted the wish/v4-home-residue-doctor branch September 25, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant