Skip to content

fix(doctor): restore transcript normalization after database close - #170126

Merged
steipete merged 2 commits into
mainfrom
fix/doctor-migration-writer-admission
Oct 12, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/doctor-migration-writer-admission

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor can skip historical transcript normalization after the preceding database handle closes, reporting Transcript payload preparation requires admitted SQLite schema facts. The migration adapter now admits its own native connection before using transcript writers. Both callers retain their existing schema, ownership, integrity and maintenance-lease checks.

Why This Change Was Made

The trigger is the interaction between #169624, which makes payload preparation consume admitted encoding, and #169956, which retires those facts on final close. The latter is intentional: “Open siblings continue sharing validation facts; reopening after the final connection closes validates again.” Cron migration fixtures now retain a real admitted reader when asserting zero-query reuse. All existing data, rollback, downgrade-refusal and statement assertions remain; openclaw-state-db-checkonce.test.ts retains cold-reopen validation coverage.

User Impact

Update behavior: restores historical directive/media migration through a newly opened handle. It changes no schema, stored format, retention policy or dependency, and preserves failed-authority rollback. Release note: Doctor no longer skips historical transcript normalization after a database close.

Evidence

Validation: all 43 tests passed across the original cron/directive files and both media-migration siblings with --maxWorkers=1 (278.55s wrapper, 205.18s Vitest). Before the change, the two original files reproduced seven failures (205.68s wrapper). Refusal/rollback, malformed history, archive and historical-schema cases pass. Changed-file type-aware lint, formatting and independent P2 review passed. The CI artifact build passed in 218.2s, including built Doctor closures and SDK exports; production types and all 28 owner-selected test type graphs passed. Exact-head CI run 38295206040 passed (36 successful jobs, 26 skipped; 611s).

The required published-driver update cell passed on local Linux ARM64: published 2026.10.2 to this exact candidate, 632.44s. The update finished, readiness returned 200, running candidate identity matched, and durable/incognito state survived. The test service and disposable VM were removed. The Testbox request was stopped when it queued; its payload never ran. No CI rerun, dispatch or extra push for green.

Investigated local check failure: the full check-changed dead-export scan reports 34 production and 22 full-tree unused UI config exports; the script scan is clean. All reported files, their consumers, Knip configuration and scanner are unchanged from base 3c1191d. This patch adds only migration schema admission and a reader-lifetime fixture adjustment, with no new export or UI import. All other selected check-changed commands passed, including runtime cycles (zero), changed-file lint and schema/ownership guards. The UI findings remain unmodified; no claim that local check-changed is fully green. The earlier build-lock interruption was resolved and its unfinished checks resumed without repeating completed proof.

Prepare schema facts on the migration-owned handle before transcript writers consume its encoding. Final native close intentionally retires the preceding handle’s facts, so a newly opened migration connection must establish its own admission.

Preserves schema, format, integrity, lease and rollback behavior. Historical transcript normalization and both media migration siblings pass with all assertions intact.
Keep admitted readers live while testing historical snapshot versions and zero-query reopen reuse. Final-close retirement in #169956 explicitly requires readmission; the existing state checkonce tests retain that cold-lifetime contract. All migration, rollback, downgrade-refusal and statement assertions are preserved.
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 12, 2026 19:04
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR admits migration-owned SQLite connections before transcript writes and updates cron fixtures to retain admission during reuse checks.

Example: Doctor normalizes an assistant transcript containing [[reply_to: message-7]] Final answer after the previous database connection closes.

  • Before: Normalization is skipped with “Transcript payload preparation requires admitted SQLite schema facts”.
  • After: The new connection establishes admission, allowing normalization to store Final answer with replyToId message-7.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and retained regression coverage support correctness, while upgrade compatibility remains unproven.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; migration harness results are reported, but the explicitly pending published-driver upgrade run remains required for compatibility acceptance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor can skip historical transcript normalization after a database connection closes.
Reason: The source establishes a concrete failure, and the maintainer-authored change restores the existing migration contract without adding settings or changing persistence policy.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this focused repair addresses a current-main Doctor regression, and no actionable patch defect was found.

Priority: P2
Reviewed head: a8fb1f0105030569e228a09f2fb5705220adc15d

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The published v2026.10.2 driver must update to the candidate and exercise Doctor normalization with existing settings and valid data preserved.
Agent review details

How this fits together

Doctor’s offline migrations open agent databases, validate ownership and schema, and pass migration-owned handles to shared transcript writers that require admitted encoding facts.

flowchart TD
  A[Doctor migration] --> B[Maintenance ownership and schema checks]
  B --> C[Migration native connection]
  C --> D[Shared schema admission]
  D --> E[Transcript payload writer]
  E --> F[Normalized agent transcripts]
Loading

Technical review

Best possible solution:

Keep admission in the shared migration adapter while preserving final-close retirement and existing maintenance safeguards.

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

Source tracing establishes the close/reopen path into an unadmitted transcript writer; the author also reports baseline failures and passing repaired migration tests, which this read-only review did not execute.

Is this the best way to solve the issue?

The shared adapter is the appropriate boundary for establishing the writer’s required facts, and the fixture changes preserve data assertions while respecting intentional final-close retirement.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Migration-owned database adapter keeps the original intent (2d85731: Consolidated identical adapters from the media and directive migrations while preserving native connection, WAL, and close custody; the commit patch confirms both earlier inline implementations.)
  • Cron migration admission-reuse fixtures changes intended behavior with a stated reason (bb7d32e: Proved reuse of admitted schema facts across connections; the subsequent intentional final-close retirement requires a surviving admitted sibling for that reuse scenario.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2d85731 adds src/infra/state-migrations.agent-database.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2d85731967cb; files: src/infra/state-migrations.agent-database.ts)

PR surface

Source +3, Tests -1. Total +2 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 1 5 6 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 8 6 +2

Labels

Label changes:

  • add P2: Historical transcript normalization can be skipped during Doctor maintenance, with a bounded repair through the existing migration owner.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: Historical transcript normalization can be skipped during Doctor maintenance, with a bounded repair through the existing migration owner.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

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

  • Provide redacted output from the published-driver upgrade scenario showing successful normalization and preserved settings and valid data.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 12, 2026, 3:10 PM ET / 19:10 UTC.

@steipete
steipete merged commit 5f19a12 into main Oct 12, 2026
220 of 226 checks passed
@steipete
steipete deleted the fix/doctor-migration-writer-admission branch October 12, 2026 19:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…penclaw#170126)

* fix(doctor): admit migration-owned transcript writers

Prepare schema facts on the migration-owned handle before transcript writers consume its encoding. Final native close intentionally retires the preceding handle’s facts, so a newly opened migration connection must establish its own admission.

Preserves schema, format, integrity, lease and rollback behavior. Historical transcript normalization and both media migration siblings pass with all assertions intact.

* test(state): retain admission during cron migration reuse proof

Keep admitted readers live while testing historical snapshot versions and zero-query reopen reuse. Final-close retirement in openclaw#169956 explicitly requires readmission; the existing state checkonce tests retain that cold-lifetime contract. All migration, rollback, downgrade-refusal and statement assertions are preserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant