Skip to content

refactor(doctor): retire unused transcript writer - #143772

Merged
steipete merged 1 commit into
mainfrom
codex/doctor-preserve-legacy-transcript-events
Sep 10, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/doctor-preserve-legacy-transcript-events

Conversation

@steipete

@steipete steipete commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140296.

What Problem This Solves

Reduces duplicate maintenance code in Doctor while preserving its supported session-import behavior.

Why This Change Was Made

Public Doctor already repairs legacy transcripts through staged SQLite import. Remove the unused explicit-directory JSONL rewrite/backup path, its persistence-only projection, and the tests that kept that second writer alive. Retained branch and provider cases now exercise the canonical importer; advisory inspection remains nonmutating.

This builds on @ylcn91’s #140296. Its deferred-normalization implementation and both six-event regressions remain unchanged.

User Impact

The supported CLI behavior stays the same: branch/provider repair happens during staged import, and original JSONL files are archived intact. Two documentation passages now describe that behavior accurately. The existing limitation for already-partial destinations remains: recovery does not reconstruct original physical order or active-history projection.

Evidence

  • Baseline: the combined importer cases passed against unchanged main production code (17 tests), along with two selected real Doctor cases for six-event preservation and intact archival.
  • Candidate: 88 focused tests passed across the importer, transcript tree, advisory inspection, SQLite orchestration, incident, execution-policy, reader, and selected real Doctor boundaries.
  • The complete changed-file gate passed before the patch-identical rebase, including production/test types, core lint, formatting, export checks, and storage/import guards.
  • After integrating the main-branch docs correction at 1670c5a1, all 88 focused owner/Doctor tests, both repaired docs suites (32 tests), and four additional transcript-reader tests passed. The full reviewed patch, all ten changed-file blobs, the staging owner, and both contributor regressions remain byte-identical. Fresh hosted CI is required for the refreshed head.
  • Against integrated main 1670c5a1: 128 fewer production code lines and 165 fewer test/support code lines; 338 fewer physical lines across ten files. The SQLite staging owner has zero diff.

Compatibility evidence: The SQLite staging module and the canonical noteSessionSqliteMigrationHealth, normalizeLegacyOpenAICodexTranscriptMetadata, and transcriptRepairUserKey bodies are byte-identical to both baseline main 71b21c88 and integrated main 1670c5a1; no schema or canonical stored-row transformation changes. The same 17 importer cases and two real Doctor cases passed before and after retirement. They verify branch/provider repair, complete event and parent links, opaque/parentless append cursors, reopen/append continuity, unchanged source bytes, and intact original archival. Both contributor six-event regressions remain unchanged. The already-partial history ordering limitation described above remains in place.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 10, 2026 06:27
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 10, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 9:21 AM ET / 13:21 UTC (Revision 5).

ClawSweeper review

What this changes

Removes Doctor’s unused standalone transcript writer, moves retained repair tests to SQLite import, and corrects documentation about preserving original transcript files.

Merge readiness

⛔ Blocked before merge - 1 item remains

Useful cleanup remains absent from current main, and no introduced correctness defect was found. The previous compatibility blocker is resolved: the supported migration path and stored-data transformations are unchanged.

Priority: P3
Reviewed head: fb7900cfa18301cf22233b18b0938584ff32ad5e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused cleanup with preserved production behavior, meaningful retained coverage, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author status exempts this cleanup from external-contributor proof. Source inspection confirms unchanged canonical import behavior; reported importer and Doctor runs are supplemental validation, not reviewer-executed live proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author status exempts this cleanup from external-contributor proof. Source inspection confirms unchanged canonical import behavior; reported importer and Doctor runs are supplemental validation, not reviewer-executed live proof.
Evidence reviewed 8 items Introduced production change: The pinned merge-base-to-head diff removes the explicit-directory writer and its persistence projection. The canonical migration function remains unchanged; a read-only comparison also confirmed identical provider normalization and branch-key function bodies.
Production caller already selects SQLite: The production health-flow caller supplies config, environment, repair authorization, and receipts without sessionDirs. Before this patch, that call already selected the SQLite migration branch; explicit-directory writer calls were confined to tests.
Current-main implementation boundary: The staging module has the identical blob 12c4075063a6956f7bf156c4ea96af232cb63471 on the PR head, merge base, and fetched main. Current main retains the standalone writer. Staging imports only OpenClaw’s unchanged normalization and branch-key helpers from the affected module; this retirement does not depend on the external Codex runtime or protocol.
Findings None None.
Security None None.

How this fits together

Doctor imports legacy conversation files into OpenClaw’s SQLite session store. Advisory inspection reports problems, while the canonical importer repairs eligible history and archives the original files.

flowchart TD
  A[Legacy conversation files] --> B[Advisory inspection]
  B --> C[Health findings]
  A --> D[Doctor repair command]
  D --> E[SQLite staging and repair]
  E --> F[Canonical session database]
  F --> G[Archive original files]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -134, Tests -203, Docs -1. Total -338 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 2 20 154 -134
Tests 6 290 493 -203
Docs 2 2 3 -1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 312 650 -338

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-session-transcripts.ts, migration/backfill/repair: src/config/sessions/legacy-transcript-repair.ts, unknown-data-model-change: src/commands/doctor-session-transcripts.ts, unknown-data-model-change: src/config/sessions/legacy-transcript-repair.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep SQLite import as the sole repair owner, with nonmutating inspection and regression coverage at the importer boundary.

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

Not applicable: the current proposal retires unused code rather than fixing a newly demonstrated runtime failure.

Is this the best way to solve the issue?

Yes. Removing the unused writer and exercising retained contracts through the existing importer is the narrowest maintainable approach.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c973fe7e7219.

Labels

Label justifications:

  • P3: This is bounded maintenance cleanup that preserves supported Doctor behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author status exempts this cleanup from external-contributor proof. Source inspection confirms unchanged canonical import behavior; reported importer and Doctor runs are supplemental validation, not reviewer-executed live proof.

Evidence

What I checked:

  • Introduced production change: The pinned merge-base-to-head diff removes the explicit-directory writer and its persistence projection. The canonical migration function remains unchanged; a read-only comparison also confirmed identical provider normalization and branch-key function bodies. (src/commands/doctor-session-transcripts.ts:187, fb7900cfa183)
  • Production caller already selects SQLite: The production health-flow caller supplies config, environment, repair authorization, and receipts without sessionDirs. Before this patch, that call already selected the SQLite migration branch; explicit-directory writer calls were confined to tests. (src/flows/doctor-health-contribution-runners.state.ts:133, 1670c5a1cc37)
  • Current-main implementation boundary: The staging module has the identical blob 12c4075063a6956f7bf156c4ea96af232cb63471 on the PR head, merge base, and fetched main. Current main retains the standalone writer. Staging imports only OpenClaw’s unchanged normalization and branch-key helpers from the affected module; this retirement does not depend on the external Codex runtime or protocol. (src/config/sessions/session-accessor.sqlite-import-stage.ts:11, c973fe7e7219)
  • Shipped routing contract: The latest supplied release already routes calls without sessionDirs to canonical SQLite migration. Removing the test-only alternative therefore does not remove the supported CLI upgrade path. (src/commands/doctor-session-transcripts.ts:228, 1391f7cd2d40)
  • Retained behavioral coverage: Importer tests cover five branch/cursor variants, exact persisted events and parent links, reopening and appending, unchanged source bytes, and both legacy provider aliases. The six-event regression remains present. Tests were inspected, not executed; the captured PR body reports baseline/candidate runs and focused validation. (src/config/sessions/session-accessor.sqlite-import.test.ts:343, fb7900cfa183)
  • Storage checkpoint applicability: The material-change checkpoint concerns changed persistence semantics, migration behavior, schemas, and ownership. This patch preserves those production contracts and removes an unused alternative; the captured body explicitly documents compatibility and the unchanged partial-recovery limitation. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md, fb7900cfa183)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ylcn91: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-10T06:35:52.980Z sha 7302cde :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T06:52:56.029Z sha 7302cde :: blocked before merge. :: none
  • reviewed 2026-09-10T12:44:14.761Z sha 0bfc502 :: blocked before merge. :: none
  • reviewed 2026-09-10T12:58:34.848Z sha 0bfc502 :: blocked before merge. :: none

@steipete
steipete marked this pull request as draft September 10, 2026 06:45
@steipete
steipete force-pushed the codex/doctor-preserve-legacy-transcript-events branch from 7302cde to 0bfc502 Compare September 10, 2026 12:35
@steipete steipete changed the title fix(doctor): preserve events during legacy transcript repair refactor(doctor): retire unused transcript writer Sep 10, 2026
@steipete
steipete marked this pull request as ready for review September 10, 2026 12:37
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. labels Sep 10, 2026
@steipete
steipete force-pushed the codex/doctor-preserve-legacy-transcript-events branch from 0bfc502 to fb7900c Compare September 10, 2026 13:14
@steipete
steipete merged commit bc6faf1 into main Sep 10, 2026
184 checks passed
@steipete
steipete deleted the codex/doctor-preserve-legacy-transcript-events branch September 10, 2026 13:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant