Skip to content

fix(sessions): preserve shared history across startup and repairs - #127241

Merged
steipete merged 7 commits into
mainfrom
codex/fix-doctor-transcript-atomic-repair
Aug 28, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/fix-doctor-transcript-atomic-repair

Conversation

@steipete

@steipete steipete commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127222
Closes #129217

Related: #131179 (merged). This revision retains #131276's landed streaming import work and includes main's canonical test repair from #131627.

What Problem This Solves

Custom or shared session stores could fail during startup, lose transcript search results, or send maintenance and related state to the wrong physical database. SQLite-only installations could enter legacy migration without a legacy store present. A failed Doctor repair of older transcript files could damage the source or obscure the failure and completed backup.

Why This Change Was Made

Carry the resolved SQLite path and physical owner through startup, Doctor, cleanup, search, boards, and progress cards, separately from logical-agent selection. Runtime uses canonical SQLite; explicit Doctor owns legacy-file conversion. Both legacy transcript repair branches use the same strict atomic publication path, preserving original bytes and completed backups when publication fails.

This deletes automatic startup import/restore plumbing, obsolete legacy-file and temp-store processing, and duplicate owner resolution. It preserves #131276's streaming readers, validation callbacks, finalization, and compaction. Retired-main transfers retain transcript bytes, timestamps, and retry evidence; workspace publication follows completed cleanup.

Lifecycle testing also exposed unnecessary provider discovery when Doctor had no auth state to repair. Doctor now reads each persisted auth candidate once before discovery. Nonempty state still gets broad provider discovery; cleanup rereads authoritative state after config publication. This preserves @obviyus's persisted-retired-profile repair in #129052 (750a64e), with a net-zero production diff in the auth repair. The test fixture separately isolates canonical provider credential names before installing its synthetic credential; production consent behavior is unchanged.

User Impact

Custom/shared stores keep history and related state in their configured physical database, including when the recorded owner is retired. Unfiltered search selects the logical agent before applying its limit. Absent databases are not created by inspection, and SQLite locators are never parsed or archived as JSON.

The stable upgrade path for sessions.json and transcript JSONL remains openclaw doctor --fix. Startup no longer imports, restores, or rewrites those files. An actual legacy source produces a visible refusal with the Doctor command for the active profile. Stop the Gateway, retain a backup, and run Doctor against the same state/config before restarting. Existing --session-sqlite modes and legacy selectors remain supported. See the Doctor migration guide.

No config option, public flag, SQLite schema version, or migration format is added. This cannot recover history already lost.

Evidence

Published revision: 0e0be0d806f2e43934c65771c628e4103b900783, complete source tree 4f006da9982edd11b4824902862d06510975e80b. Local tests, build, and checks ran against that complete tree before publication; independent comparison of all 34,537 entries and the official metadata refresh bind the same source and runtime artifacts to the published head.

Validation Result
Owner and sibling tests Passed: 51 unique files / 1,091 cases. This combines the unchanged files, the corrected complete 97-case Doctor rerun with no skips, and 12 shared-auth owner cases. Retries are not counted twice.
Full build and complete 75-path changed checks Passed: build in 345.6 seconds; checks in 538.5 seconds, including types, lint, assertion baseline, database-first/schema guards, boundaries, dead exports, and runtime import cycles.
Built-CLI and generic upgrade lifecycle Passed: both cases in the original built→generic order, 100.8 seconds overall, with unchanged 60-second command and 420-second test limits. Total source-bound coverage is 53 unique files / 1,093 passing cases.
Published build identity Passed: official backend and rebuilt Control UI identify the published head. The retained runtime JavaScript inventory is unchanged: 7,723 files / 174,142,589 bytes.
Real Gateway, Control UI, Doctor, and restart Passed: all six phases. No reseed; all six retained transcript rows remained byte-identical. History/search, logical-agent isolation, progress cards, and board state survived the restart. Inspection succeeded, live compaction refused as expected, and offline compaction succeeded.
Independent review and live audit Passed: integration and alias-fixture reviews found no actionable issues; earlier whole-PR, streaming-composition, and auth-repair reviews retain their original scopes. The separate 81-check live audit verified the published source/artifacts, retained SQLite data, six screenshots, accepted restart sequence, recorded process cleanup, and released port.
Exact-head hosted CI Passed: CI run 33158605130, 169 successful / 15 skipped jobs / zero failures, on 0e0be0d.

The pinned-main comparison is complete across all 75 changed paths, with no missing objects or lazy fetch needed to materialize the patch. The four upstream overlap resolutions were independently reviewed, and the full 34,537-entry expected tree matches publication. This resolves the earlier promisor-object comparison gap for the pinned composition; it does not claim a review of every later commit on moving main.

One premature restart attempt began 107 milliseconds before artifact-binding verification finished. It was stopped successfully and excluded from the proof. A fresh binding then completed before the accepted restart; the later RPC/UI replay and cleanup passed. The failed ordering attempt remains recorded separately.

The intermediate 50-file run passed 1,078 cases and skipped one platform-alias case after main's #131313 change canonicalized TMPDIR. The final correction reuses the existing alias fixture and capability predicate, retaining all three restoration assertions and non-root symlink rejection. Its complete 97-case rerun passed without skips, and the full build was rerun with that final test input. The earlier skip is not counted as a pass.

The prior CI run 33152114028 failed with TS2459 and three runtime errors because an upstream test imported a now-private channel-restart helper. Neither affected path is in this PR's diff. Landed #131627, included here as 871b18d, moves that test to the public rollback operation; the fresh exact-head run above is green.

Historical faf2dc4 local and live proof remains archived separately. Earlier unchanged-budget Doctor timeout, fixture-consent, and stale automatic-import failures also remain recorded. The rejected all-bundled-plugin assertion was a test-design error, not proof of incorrect artifact routing or a packaged production slowdown. No timeout was enlarged and no product assertion was weakened.

Publication-failure regressions verify exact original bytes, completed backups, and visible errors across both legacy repair branches. Startup coverage includes absent databases, custom/shared stores, projections, and preserved legacy sources requiring explicit Doctor import. The empty-auth regression failed before repair while its positive cases already passed. The credential-registry source received separate direct source audits and owner tests where the managed review service excluded that path.

The refreshed ClawSweeper review covers this exact head, reports no actionable code or security findings, and passed its six startup tests. Its final upgrade/refusal lifecycle and exact-head CI requests are now complete. This maintainer-authored change accepts explicit Doctor migration as the supported upgrade path, following the requested SQLite-only runtime cleanup; automatic startup import is deliberately removed. The description records the changed behavior, validation, and remaining scalability risk requested by its Rank-up move. The live fixture uses synthetic isolated state; it does not exercise a provider turn, native macOS app, Talk, or heartbeats. The independent audit viewed the six PNGs; the maintainer separately inspected 14 distinct video frames.

Before restart, retained history:

Retained session history before restart

After restart, the same history and search result:

Retained session history after restart

Session search after restart

After-restart recording:

session-store-0e0be0-after-video.mp4

Classified against 871b18d: 75 paths; production +471/−913 (net −442), tests/support +2,593/−1,737 (net +856), docs +68/−47 (net +21), and baseline −1: whole PR net +434. The removed 651-line Gateway wrapper and src/gateway/test-helpers.server.ts are test support, not production. Pure discovery-test moves do not add coverage.

Follow-up

The retired-main handoff snapshot still materializes transcript rows in memory. No failure was reproduced there; the heap scenarios do not establish bounded memory for every Doctor operation. Streaming that snapshot remains separate scalability work, not a missing correctness repair in this PR.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 21, 2026
@steipete
steipete marked this pull request as ready for review August 21, 2026 15:28
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 6:05 AM ET / 10:05 UTC.

ClawSweeper review

What this changes

The branch preserves shared SQLite session history by keeping reads and repairs on the database’s physical owner, refusing legacy transcript stores at startup, and moving their import to explicit Doctor repair.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: current main still performs the automatic legacy-session startup path, while this branch makes the documented Doctor-mediated migration boundary explicit; source, tests, and history reveal no concrete patch defect.

Priority: P2
Reviewed head: 0e0be0d806f2e43934c65771c628e4103b900783

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has coherent owner-boundary changes and extensive source-level lifecycle coverage, with remote proof and the atomic-helper implementation not independently inspectable here.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied body nonetheless describes an isolated Gateway, Doctor, and restart proof sequence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied body nonetheless describes an isolated Gateway, Doctor, and restart proof sequence.
Evidence reviewed 7 items Startup migration boundary: Startup detects an existing non-SQLite session store and gives a visible Doctor repair instruction instead of automatically importing it.
Physical-owner preservation: Shared fixed SQLite stores keep logical-agent partitioning separate from the physical database owner used to open the database.
Failure-safe Doctor repair: Repair candidates retain a broken result through backup and atomic replacement failures, so failed repairs remain visible rather than being reported healthy.
Findings None None.
Security None None.

How this fits together

Session startup prepares durable SQLite-backed history for the Gateway and embedded TUI. Legacy JSON/JSONL sources now stop startup with a visible repair instruction, while Doctor imports them into the correctly owned SQLite database before normal history reads resume.

flowchart LR
A[Legacy JSON or JSONL store] --> B[Session startup]
B --> C{Canonical SQLite store?}
C -->|No| D[Doctor repair and import]
C -->|Yes| E[Physical SQLite database owner]
D --> E
E --> F[Gateway and TUI history reads]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally changes upgrades from automatic startup import to a visible stop-and-run-Doctor path; its refusal, import, archive, and restart sequence must remain the supported operator journey.
  • Resolve merge risk (P1) - The atomic replacement behavior relies on the existing @openclaw/fs-safe implementation, whose installed source was unavailable in this read-only dependency-less checkout; source-level fault coverage exercises the wrapper contract but not its implementation.
  • Complete next step (P2) - No concrete patch defect or bounded follow-up repair was found; this remains a normal maintainer merge decision with compatibility risk visible above.
Agent review details

Security

None.

PR surface

Source -1092, Tests +1506, Docs +21, Other -1. Total +434 across 75 files.

View PR surface stats
Area Files Added Removed Net
Source 34 475 1567 -1092
Tests 37 2589 1083 +1506
Docs 3 68 47 +21
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 75 3132 2698 +434

Review metrics

Metric Value Why it matters
Production versus test delta production +471/-913; tests/support +2,593/-1,737; docs +68/-47; baseline -1 The runtime change is net-negative while the branch adds substantial fault and migration-lifecycle coverage for durable session state.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: src/commands/doctor-auth-legacy-oauth.ts, migration/backfill/repair: src/commands/doctor-session-incognito-key-repair.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-compact.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-readers.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-recover-report.ts, and 36 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the explicit Doctor cutover (recommended)
    Keep the documented startup refusal and Doctor repair path as the single upgrade boundary, supported by the branch’s source-level lifecycle coverage.
  2. Pause if automatic migration remains required
    Do not merge if maintainers want legacy JSON or JSONL imports to continue automatically during startup, because that would require a different product boundary.

Technical review

Best possible solution:

Retain one explicit migration lifecycle: startup refuses legacy files without mutation, Doctor imports and archives them through the physical SQLite owner, and restart reads only the canonical database.

Do we have a high-confidence way to reproduce the issue?

Yes—source and focused tests define a reproducible legacy-store startup path, source preservation, Doctor import, and restart outcome; this read-only review did not execute the suite.

Is this the best way to solve the issue?

Yes—the physical-owner model plus an explicit Doctor import prevents startup mutation of legacy files and avoids per-logical-agent shared-history divergence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b576bb41cf4b.

Labels

Label justifications:

  • P2: This is a bounded correction to durable session migration and shared-history behavior, with meaningful but non-emergency operator impact.
  • merge-risk: 🚨 compatibility: Existing legacy session stores change from automatic startup import to an explicit Doctor-mediated upgrade step.
  • merge-risk: 🚨 session-state: The branch changes where shared session history is opened, repaired, and searched across logical agents.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied body nonetheless describes an isolated Gateway, Doctor, and restart proof sequence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the central session-owner and startup-migration commits and dominates recent history of the affected session files. (role: recent area contributor; confidence: high; commits: 2f2f062fbf40, faf2dc4; files: src/config/sessions/startup-migration.ts, src/config/sessions/session-transcript-search.ts, src/commands/doctor-session-transcripts.ts)
  • ampagent: Authored the earlier atomic transcript-repair work that this branch consolidates into the Doctor failure boundary. (role: atomic-repair contributor; confidence: medium; commits: 6ea01ac; files: src/commands/doctor-session-transcripts.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Retain the explicit legacy refusal → Doctor import → restart proof in the final merge record.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-21T15:35:27.927Z sha 6ea01ac :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T16:17:34.314Z sha 6ea01ac :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T22:16:46.849Z sha 6ea01ac :: needs maintainer review before merge. :: none
  • reviewed 2026-08-24T03:21:11.162Z sha 6ea01ac :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T03:53:39.252Z sha 077ebbd :: needs real behavior proof before merge. :: [P1] Preserve the automatic legacy migration upgrade path
  • reviewed 2026-08-28T04:43:15.982Z sha 1a6534b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T07:42:55.475Z sha faf2dc4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T09:21:22.995Z sha 0e0be0d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Aug 24, 2026
Resolve physical session databases once and carry that identity through startup, search, boards, maintenance, and Doctor. Remove automatic legacy JSON import from Gateway startup while preserving explicit Doctor upgrades.

Publish repaired legacy transcripts with strict atomic replacement and preserve the source when backup, write, or rename fails.
@steipete
steipete requested a review from a team as a code owner August 28, 2026 03:46
@steipete steipete self-assigned this Aug 28, 2026
@steipete steipete changed the title fix(doctor): preserve transcripts when repair publication fails fix(sessions): preserve shared history across startup and repairs Aug 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR now carries the canonical SQLite ownership repair across startup, Doctor, search, cleanup, boards, and progress cards, together with strict atomic publication for the two legacy Doctor repair paths. It removes the retired automatic file-import path and reduces production code by 442 lines.

The integrated Doctor failure-injection suite passed, and the full focused ledger covers 846 passing cases across 39 files, including the final startup rerun. Independent Codex review has no remaining actionable P0–P2 findings. The PR body records the current proof and the separate long-history import follow-up. The final build/check refresh, built Gateway replay, and exact-head hosted CI will be recorded before landing.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Aug 28, 2026
Preserve the landed streaming readers and finalization while forwarding physical
SQLite ownership and logical selection throughout startup and Doctor repair.
Avoid provider setup discovery when Doctor has no auth profile state to repair,
and isolate mock provider credentials in both session lifecycle proof modes.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated to faf2dc4: composed the landed streaming import work with physical SQLite ownership, added the verified empty-auth Doctor fast path, and isolated mock-provider credentials in both lifecycle modes. Focused regressions, the complete candidate tests/build/changed checks, and both lifecycle tests are green. Fresh published-head shared-store Gateway/UI/restart evidence and exact-head CI remain landing gates; historical proof is not substituted.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
…ries

Integrate the landed Gateway rollback test repair from main and retain
version-1 manifest recovery coverage after Vitest canonicalizes its temporary
directory. Reuse the existing platform-root alias fixture and assertions.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Final proof is complete for 0e0be0d, tree 4f006da. Native review artifacts validated, and mandatory OPENCLAW_TESTBOX=1 scripts/pr prepare-run 127241 passed its hosted gates for that exact head without rebasing or pushing a new revision. CI 33158605130 has 169 successful jobs, 15 skipped jobs and no failures.

The final source-bound suite totals 53 unique files and 1,093 passing cases. The complete 97-case Doctor rerun has no skips; full build and all 75-path changed checks pass. Built-CLI then generic upgrade proof ran in the original order with unchanged command/test budgets. It verifies refusal with preserved legacy files, explicit Doctor import, restart/history, backup restoration, downgrade/reupgrade, contention, and shared-store ownership. The real isolated Gateway/Control UI/Doctor restart replay and inspected media are in the PR body; all six retained transcript rows stayed byte-identical without reseeding.

The upgrade decision is explicit: runtime uses canonical SQLite, and openclaw doctor --fix owns supported legacy-file imports. This is the requested maintainer cleanup, now backed by the final upgrade proof and green CI. The refreshed review has no actionable code or security finding. Production is down 442 lines; useful tests/support and docs account for the whole-PR net increase of 434 lines.

Dependency implementation evidence for the latest review: I directly inspected the installed, lockfile-pinned @openclaw/[email protected], including dist/replace-file.js:18–41,183–245 and dist/replace-file-descriptor.js:55–75. The helper writes a sibling temporary file, attempts rename, and rethrows a rename error without entering the permission-copy path when copyFallbackOnPermissionError is false. Doctor completes the backup first and explicitly disables that fallback (repair owner); its six fault cases run the actual helper, injecting filesystem write, backup and rename failures for both repair variants. They verify unchanged original bytes, completed backup preservation, temporary-file cleanup and visible failure. The inspected dist/replace-file.js SHA-256 is 4285a487e2a912b299030cc46f37d85ff19824f31291cbd4ca8c14c34c5d4e09. This establishes the dependency implementation as well as the wrapper contract; it is not a power-loss durability claim (parent-directory sync is best effort).

The native merge will be checked against its actual parent and this reviewed source, including the complete resulting tree and ancestry. The scoped upstream composition inspections are static evidence; the retained live replay is not represented as runtime proof on a later main revision.

Exact final local validation commands

Run at the reviewed revision with Node 24. These are the recorded argument lists with only the host-specific Node executable path normalized to node. Tests used one worker. Earlier unchanged owner/sibling files are accounted for separately in the PR evidence; reruns are not counted twice.

node scripts/run-vitest.mjs run src/commands/doctor-session-sqlite.test.ts --reporter=verbose

node --import ./scripts/tsx.mjs scripts/build-all.mts

node scripts/check-changed.mjs --base 871b18dff5039484e86c76d282699a8defcb1654 -- \
  config/assertion-safety-baseline.txt \
  docs/cli/doctor.md \
  docs/concepts/session.md \
  docs/gateway/doctor.md \
  src/agents/tools/embedded-gateway-stub.runtime.ts \
  src/agents/tools/embedded-gateway-stub.test.ts \
  src/agents/tools/embedded-gateway-stub.ts \
  src/boards/sqlite-board-store.ts \
  src/commands/doctor-auth-flat-profiles.test.ts \
  src/commands/doctor-auth-legacy-oauth.ts \
  src/commands/doctor-auth.deprecated-cli-profiles.test.ts \
  src/commands/doctor-heartbeat-session-target.test.ts \
  src/commands/doctor-heartbeat-session-target.ts \
  src/commands/doctor-session-incognito-key-repair.test.ts \
  src/commands/doctor-session-incognito-key-repair.ts \
  src/commands/doctor-session-sqlite-compact.ts \
  src/commands/doctor-session-sqlite-readers.ts \
  src/commands/doctor-session-sqlite-recover-report.ts \
  src/commands/doctor-session-sqlite.shared-store.test.ts \
  src/commands/doctor-session-sqlite.test.ts \
  src/commands/doctor-session-sqlite.ts \
  src/commands/doctor-session-transcript-headers.test.ts \
  src/commands/doctor-session-transcript-headers.ts \
  src/commands/doctor-session-transcript-labels.test.ts \
  src/commands/doctor-session-transcript-labels.ts \
  src/commands/doctor-session-transcripts.test.ts \
  src/commands/doctor-session-transcripts.ts \
  src/commands/doctor-state-integrity.transcripts.test.ts \
  src/commands/doctor-state-integrity.ts \
  src/commands/doctor-state-migrations.test.ts \
  src/commands/doctor/shared/codex-route-session-repair.ts \
  src/commands/onboard-agent.persistence.test.ts \
  src/commands/tasks-session-registry-maintenance.test.ts \
  src/commands/tasks-session-registry-maintenance.ts \
  src/config/sessions/cleanup-service.agent-purge.test.ts \
  src/config/sessions/cleanup-service.applied-summary.test.ts \
  src/config/sessions/cleanup-service.fix-missing.test.ts \
  src/config/sessions/cleanup-service.ts \
  src/config/sessions/legacy-main-session-migration-operations.ts \
  src/config/sessions/legacy-main-session-migration.startup.test.ts \
  src/config/sessions/legacy-main-session-migration.test.ts \
  src/config/sessions/session-accessor.sqlite-import.ts \
  src/config/sessions/session-registry-maintenance.test.ts \
  src/config/sessions/session-registry-maintenance.ts \
  src/config/sessions/session-transcript-search.test.ts \
  src/config/sessions/session-transcript-search.ts \
  src/config/sessions/startup-migration.registry-recovery.test.ts \
  src/config/sessions/startup-migration.ts \
  src/config/sessions/startup-migration.worktree-workspace.test.ts \
  src/config/sessions/store-temp-cleanup.test.ts \
  src/config/sessions/store-temp-cleanup.ts \
  src/config/sessions/targets-collision.ts \
  src/config/sessions/targets-discovery.test.ts \
  src/config/sessions/targets.test.ts \
  src/config/sessions/worktree-workspace-migration.ts \
  src/gateway/board-store.test.ts \
  src/gateway/board-store.ts \
  src/gateway/progress-card-store.ts \
  src/gateway/server-methods/sessions-read.ts \
  src/gateway/server-methods/sessions-search.test.ts \
  src/gateway/server-startup-secret-owner-isolation.test.ts \
  src/gateway/server-startup-session-migration.test-support.ts \
  src/gateway/server-startup-session-migration.ts \
  src/gateway/session-startup-migration.test.ts \
  src/gateway/test-helpers.server-env.test.ts \
  src/gateway/test-helpers.server.ts \
  src/infra/state-migrations.doctor.ts \
  src/infra/state-migrations.session-store.ts \
  src/infra/state-migrations.test.ts \
  src/plugins/legacy-session-surfaces.state-migration.test.ts \
  src/tui/embedded-backend.ts \
  test/helpers/sqlite-sessions-transcripts-flip-proof-assertions.ts \
  test/helpers/sqlite-sessions-transcripts-flip-proof.ts \
  test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts \
  test/scripts/sqlite-sessions-transcripts-flip-proof.e2e.test.ts

node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts test/scripts/sqlite-sessions-transcripts-flip-proof.e2e.test.ts --reporter=verbose

Remaining proof limits: the isolated fixture does not claim a provider turn, native macOS app, Talk or heartbeat coverage. Streaming the retired-main handoff snapshot remains a named scalability follow-up; no failure was reproduced there. No timeout, assertion, approval requirement or failing CI gate was waived.

@steipete
steipete merged commit df905a6 into main Aug 28, 2026
252 of 254 checks passed
@steipete
steipete deleted the codex/fix-doctor-transcript-atomic-repair branch August 28, 2026 10:32
@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 29, 2026
…enclaw#127241)

* fix(doctor): atomically repair session transcripts

* fix(sessions): keep runtime reads and repairs on SQLite owners

Resolve physical session databases once and carry that identity through startup, search, boards, maintenance, and Doctor. Remove automatic legacy JSON import from Gateway startup while preserving explicit Doctor upgrades.

Publish repaired legacy transcripts with strict atomic replacement and preserve the source when backup, write, or rename fails.

* fix(sessions): simplify startup ownership and diagnostics

* test(sessions): migrate legacy history through Doctor in CLI proof

---------

Co-authored-by: Amp <[email protected]>
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants