Skip to content

fix(doctor): stop flagging lazily-created session dirs as missing - #130704

Merged
steipete merged 2 commits into
mainfrom
steipete/doctor-sessions-dir-false-critical
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/doctor-sessions-dir-false-critical

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw doctor reports a false alarm on every fresh profile onboarded through the gateway RPC path (openclaw.setup.activate — the path the Mac app uses):

◇  State integrity ─────
│  - CRITICAL: Session store dir missing
│    (~/.openclaw-obt833/agents/main/sessions).

The profile is healthy: sessions and transcripts are SQLite-backed in agents/main/agent/openclaw-agent.sqlite, agent turns work, restart persistence works. The agents/<id>/sessions directory simply has not been needed yet. A CRITICAL that fires on the default out-of-box path erodes trust in doctor (severity miscalibration on the default path).

Why This Change Was Made

The check's invariant is stale. Since the SQLite transcript migration:

  • Every runtime writer creates the directory lazily: src/config/sessions/session-accessor.sqlite-archive.ts:172 and :245 (fs.mkdirSync(archiveDirectory, { recursive: true, mode: 0o700 }) before publishing transcript archives; resolveSqliteTranscriptArchiveDirectory maps the agent DB path to agents/<id>/sessions).
  • Every reader tolerates ENOENT (e.g. listUsageCountedTranscriptFileStats in src/infra/session-cost-usage-collection.ts returns []).
  • Only the CLI setup/onboard flows scaffold the directory eagerly (src/commands/setup.ts, src/commands/onboard-helpers.ts); the gateway setup.activate RPC does not and must not need to.

The fix removes the missing-dir finding (structured missing-runtime-dir and legacy interactive CRITICAL + create prompt) for Sessions dir and Session store dir. The missing-runtime-dir label union is narrowed to "OAuth dir" so the removed states are unrepresentable. Existing-but-unwritable session directories are still flagged (runtime-dir-not-writable), and OAuth dir behavior is unchanged (it has its own shouldRequireOAuthDir gate and lifecycle).

Production LOC delta: net -4 (+16/-20 in src/commands/doctor-state-integrity.ts); tests +70.

User Impact

Operators who onboard via the Mac app (or any gateway-RPC activation) no longer see a bogus CRITICAL in doctor on a healthy fresh install. Real problems (unwritable existing dirs, missing OAuth dir when pairing channels are configured) are still reported exactly as before.

Evidence

  • Found during a live product test campaign on main: fresh profile → openclaw.setup.activate (codex-cli, inference verified live) → real agent turns → doctor printed the false CRITICAL while sessions.list showed the healthy SQLite store (1 session, 8 transcript events).
  • New regressions in src/commands/doctor-state-integrity.test.ts: fresh RPC-onboarded profile produces no session-related structured issue, no CRITICAL warning, no create prompt (both fail on pre-fix code); existing-but-unwritable sessions dir still produces runtime-dir-not-writable; OAuth tests unchanged.
  • node scripts/run-vitest.mjs src/commands/doctor-state-integrity: 55 tests green (re-run after rebase onto latest origin/main).
  • node scripts/check-changed.mjs -- <changed files>: guards, formatting, dead-export scan, production typecheck, focused tests green. Autoreview: clean.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 27, 2026 04:53
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete merged commit 9f266ed into main Aug 27, 2026
201 checks passed
@steipete
steipete deleted the steipete/doctor-sessions-dir-false-critical branch August 27, 2026 05:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…enclaw#130704)

* fix(doctor): stop flagging lazily-created session dirs as missing

* test(doctor): split state-integrity suite to satisfy max-lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant