Skip to content

fix(doctor): session SQLite import drops Codex assistant messages from legacy transcripts - #140296

Merged
steipete merged 2 commits into
openclaw:mainfrom
ylcn91:fix/session-sqlite-import-codex-rows
Sep 10, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
ylcn91:fix/session-sqlite-import-codex-rows

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #140100

What Problem This Solves

Fixes an issue where users running openclaw doctor --session-sqlite import on a legacy sessions.json + transcript JSONL store would lose every assistant message the agent had produced on the Codex runtime (message.provider: "codex"), except the last one in the file, while user messages, tool results, and assistant messages from other providers imported normally. The receipt still reported the import as complete, validate and inspect stayed green, and the archived JSONL was classified as generic unknown history, so operators migrated with half a conversation and nothing pointed at the gap.

Why This Change Was Made

The legacy repair pass normalizes Codex provider metadata while streaming the staged transcript rows from a SQLite cursor, and it wrote the normalized bytes back into the same table it was iterating. node:sqlite re-delivers an updated row from an open cursor, and the identical-replay guard then saw the second delivery as a duplicate of itself and scheduled the only copy of that row for deletion. The provider check is only the trigger; there was never an intended exclusion. The rows whose bytes need normalizing are now recorded in the spool's existing per-repair scratch set (tree_sets, the same diskSet the repair already uses for repeated and reset rows) and rewritten after the scan completes, so the cursor never observes a rewrite. Until that rewrite the stored bytes are still legacy, so the replay guard normalizes a recorded row on the way out before comparing, and genuine duplicates of a normalized row still deduplicate. The spool is a private temp database that is discarded after every import; no persistent store or schema changes, and no new table.

Data-model compatibility

No persisted table changes, and no CREATE TABLE, ALTER TABLE, or new column anywhere: the scratch bookkeeping uses the spool's existing tree_sets table inside transcripts.sqlite, a private temp database that withSqliteSessionImportStage creates for one import in a private temp directory and removes in finally; nothing else opens it. The agent database (agents/<id>/agent/openclaw-agent.sqlite), migration-run manifest, archive layout, restore, and validate are untouched: git diff --stat ce174871076..3fa839c8810 is session-accessor.sqlite-import-stage.ts (+32/-3) plus two test files. Verified against an existing database in the recovery run below: an agent database written by the main build accepts the fixed importer with no migration, and the byte-exact seen-set dedupe matched the rows the older build had written. No upgrade step; downgrade remains the existing restore flow.

User Impact

openclaw doctor --session-sqlite import now imports every Codex-runtime assistant message from a legacy transcript, in order, with the provider metadata normalized as before. Operators who already migrated on an affected version still have the complete transcript in session-sqlite-import-archive/; restore followed by validate on this build reports the missing rows, and a re-run import appends them to the SQLite transcript (see the recovery run below for what that does and does not restore). Other providers and non-legacy stores are unaffected.

Evidence

Root cause reproduced directly against node:sqlite on Node v24.18.0: iterating SELECT ... FROM rows ORDER BY seq and updating the current row's event_json inside the loop delivers each updated row twice (1:codex 1:openai 2:openai 3:codex 3:openai ...).

Regression tests fail on main and pass on this branch. Both use a six-row transcript where the Codex assistant replies are not the last row, which is the shape the existing coverage happened not to exercise:

  • src/config/sessions/session-accessor.sqlite-import.test.ts "keeps legacy Codex assistant rows that precede later transcript rows during repair". On main:
AssertionError: expected { sessionId: 'codex', …(3) } to match object { transcriptEvents: 6 }
  • src/commands/doctor-session-sqlite.test.ts "imports every legacy Codex assistant message, not only the last one" (real runDoctorSessionSqlite import against a legacy store on disk). On main:
AssertionError: expected { archivedLegacyStoreFiles: 1, …(12) } to match object { importedTranscriptEvents: 6 }

On this branch both pass and loadTranscriptEventsSync returns all six ids with provider: "openai" on the normalized replies.

node scripts/check-changed.mjs: passed (exit 0). Codex autoreview (gpt-6-astra, high): no actionable findings, "patch is correct (0.98)".

Follow-up (not in this PR): the pre-archive event count check at src/commands/doctor-session-sqlite.ts compares SQLite against the post-repair spool count rather than the source JSONL line count, so a repair that drops rows can certify itself. Worth a separate fix.

Revision 33837db2f08

Answers the two red lanes on 82fbc57e81d: the check-test-types-core-2 TS18046 ('event' is of type 'unknown') by asserting the stored rows with expect.objectContaining in one pass instead of narrowing opaque TranscriptEvent rows, and checks-node-compact-small-2 (the public memory scenario seeds 100,000 toolResult events with no message.provider, so the new normalization path is a no-op there). CI on this head is green, including checks-node-compact-small-2.

Real CLI proof on 33837db2f08

Environment: Linux devbox, Node v24.18.0, no Gateway running, isolated OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH ({}) per run. Two built checkouts: main at dbf7b06342d (before the fix) and this branch at 33837db2f08 (dist/.buildstamp checked before each run). The legacy store is the shape from the issue, written by hand: agents/main/sessions/sessions.json with one agent:main:main entry pointing at session-1.jsonl, and a six-line transcript (session header, user-1, reply-1 [codex], user-2, reply-2 [codex], user-3; the two Codex replies are not the last row.)

Rows are read back with sqlite3 -readonly <state>/agents/main/agent/openclaw-agent.sqlite as seq | id | role | provider from transcript_events. Temp paths are shortened to <state>.

Before the fix (main build dbf7b06342d), first import into an empty destination

$ openclaw doctor --session-sqlite import --json        # 2026-09-06T20:16:11Z
"importedEntries": 1,
"importedTranscriptEvents": 4,
"issues": [],
"archivedTranscriptFiles": ["<state>/agents/main/session-sqlite-import-archive/agent_main_main.session-1.jsonl.imported-1788725777055"],
"archivedLegacyStoreFiles": ["<state>/agents/main/session-sqlite-import-archive/legacy-store.sessions.json.imported-1788725777105"]
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|user-2|user|-
3|user-3|user|-
rows: 4
$ openclaw doctor --session-sqlite validate --session-sqlite-agent main --json
{"mode":"validate","targets":0,"totals":{"issues":0}}      # exit 0

Both Codex replies are gone, the receipt reports no issue, the legacy files are archived, and validate selects nothing afterwards. The archived JSONL still holds all six lines.

After the fix (this branch, build 33837db2f08), first import into an empty destination

$ openclaw doctor --session-sqlite import --json        # 2026-09-06T20:27:45Z
"importedEntries": 1,
"importedTranscriptEvents": 6,
"issues": [],
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|reply-1|assistant|openai
3|user-2|user|-
4|reply-2|assistant|openai
5|user-3|user|-
rows: 6
reply-1 / reply-2 event_json: "provider":"openai","api":"openai-chatgpt-responses", content as a text block

All six rows import in file order; the Codex replies carry the same normalized provider/api bytes the legacy normalizer produced before this change. session_transcript_active_events lists five active messages (event_seq 1..5).

Recovery into an already-partial SQLite destination (one state directory, both builds)

This is the situation of an operator who already migrated on an affected version. Step 1 ran the main build, steps 2-4 ran this branch's build.

1. main  $ openclaw doctor --session-sqlite import --session-sqlite-agent main --json
         "importedTranscriptEvents": 4          -> SQLite has user-1, user-2, user-3; legacy archived
2. branch $ openclaw doctor --session-sqlite restore --session-sqlite-agent main --json
         "restoredFiles": ["<state>/agents/main/sessions/session-1.jsonl", "<state>/agents/main/sessions/sessions.json"], "conflicts": []
3. branch $ openclaw doctor --session-sqlite validate --session-sqlite-agent main --json   # exit 1
         {"code":"sqlite_transcript_count_mismatch","message":"SQLite transcript has 4 events; source has 6.","sessionKey":"agent:main:main"}
         {"code":"active_sqlite_transcript_jsonl","message":"SQLite-backed session still has an active JSONL transcript file: <state>/agents/main/sessions/session-1.jsonl","sessionKey":"agent:main:main"}
4. branch $ openclaw doctor --session-sqlite import --session-sqlite-agent main --json
         "importedEntries": 1, "importedTranscriptEvents": 2, "issues": [], "archivedTranscriptFiles": 1
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|user-2|user|-
3|user-3|user|-
4|reply-1|assistant|openai
5|reply-2|assistant|openai
rows: 6

What this shows, and what it does not:

  • restore returns the archived JSONL and sessions.json to their original paths (documented downgrade path, unchanged by this PR), and validate on the fixed build now names the gap instead of staying green.
  • The re-run import takes the existing-destination path (session-accessor.sqlite-import.ts, readTranscriptEvents branch): the seen-set matched the four rows already in SQLite byte for byte and appended only the two missing Codex replies. Nothing is duplicated and nothing existing is rewritten.
  • The recovered replies are appended after the existing rows (seq 4 and 5), not at their original positions. The transcript is complete on disk, but session_transcript_active_events then lists three active messages (event_seq 1, 2, 5) instead of five, so the active-branch projection of a recovered session does not match a fresh import. Restoring original order for an already-migrated session needs a separate repair; the User Impact wording above has been narrowed accordingly.

Revision 3fa839c

Rebased onto main (ce174871076) and reworked the deferral so the fix adds no table. The previous head stashed the normalized bytes in a new normalized table inside the spool; the review flagged that CREATE TABLE as a stored-data-model change even though the spool is disposable. The repair now records the affected row numbers in the spool's existing tree_sets scratch set and rewrites those rows after the scan, normalizing a recorded row on read when the replay guard compares against it. Same fix, same regression tests, one table fewer.

Re-verified on this head, Linux, Node v24.18.0: session-accessor.sqlite-import.test.ts 14 passed, doctor-session-sqlite.test.ts 230 passed (2 skipped), tsgo core lane clean, oxfmt clean.

Real CLI proof on 3fa839c8810

Same setup as the earlier proof: isolated OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH ({}), the six-line legacy store from the issue (session header, user-1, reply-1 [codex], user-2, reply-2 [codex], user-3), built checkouts with dist/.buildstamp checked before each run: main at dbf7b06342d (before the fix) and this branch at 3fa839c8810. Rows read back with sqlite3 -readonly as seq | id | role | provider.

Before the fix (main build dbf7b06342d), first import into an empty destination

$ openclaw doctor --session-sqlite import --session-sqlite-agent main --json
"importedEntries": 1,
"importedTranscriptEvents": 4,
"issues": [],
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|user-2|user|-
3|user-3|user|-
rows: 4

Same loss as before: both Codex replies are gone and the receipt reports no issue.

After the fix (this branch, build 3fa839c8810), first import into an empty destination

$ openclaw doctor --session-sqlite import --json        # 2026-09-07T07:49:55Z
"importedEntries": 1,
"importedTranscriptEvents": 6,
"issues": [],
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|reply-1|assistant|openai
3|user-2|user|-
4|reply-2|assistant|openai
5|user-3|user|-
rows: 6
reply-1 | openai | openai-chatgpt-responses
reply-2 | openai | openai-chatgpt-responses
session_transcript_active_events: 5 rows (event_seq 1,2,3,4,5)
$ openclaw doctor --session-sqlite validate --session-sqlite-agent main --json   # exit 0

All six rows import in file order with the normalized provider/api bytes, exactly as on the previous head.

Recovery into an already-partial SQLite destination (one state directory, both builds)

1. main   $ openclaw doctor --session-sqlite import --session-sqlite-agent main --json
          "importedTranscriptEvents": 4          -> SQLite has user-1, user-2, user-3; legacy archived
2. branch $ openclaw doctor --session-sqlite restore --session-sqlite-agent main --json
          "restoredFiles": [<state>/agents/main/sessions/session-1.jsonl, <state>/agents/main/sessions/sessions.json], "conflicts": []
3. branch $ openclaw doctor --session-sqlite validate --session-sqlite-agent main --json   # exit 1
          {"code":"sqlite_transcript_count_mismatch","message":"SQLite transcript has 4 events; source has 6."}
          {"code":"active_sqlite_transcript_jsonl","message":"SQLite-backed session still has an active JSONL transcript file: ..."}
4. branch $ openclaw doctor --session-sqlite import --session-sqlite-agent main --json
          "importedEntries": 1, "importedTranscriptEvents": 2, "issues": []
$ sqlite3 ... transcript_events
0|session-1|-|-
1|user-1|user|-
2|user-2|user|-
3|user-3|user|-
4|reply-1|assistant|openai
5|reply-2|assistant|openai
rows: 6
session_transcript_active_events: 3 rows (event_seq 1,2,5)

Identical to the recovery run on the previous head: an agent database written by the main build accepts the reworked importer with no migration, the seen-set matches the four existing rows byte for byte, only the two missing replies are appended, and the recovery-order limitation described above is unchanged.

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 7:24 AM ET / 11:24 UTC (Revision 8).

ClawSweeper review

What this changes

Doctor postpones legacy transcript metadata writes until its SQLite scan finishes, preserving assistant messages during import and adding regression coverage.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a focused, proven fix for silent transcript loss that remains present on current main and v2026.9.3. No actionable introduced defect was found, and the related draft explicitly defers to this contributor fix.

Priority: P0
Reviewed head: 3fa839c8810e5e2a32ecbf2d9522510bbc5e78eb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with convincing CLI evidence and meaningful regressions; no blocking patch defect was found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The complete, hash-matched PR body records the real Doctor CLI on this head importing all six events with both normalized replies and the correct fresh-import active history; an existing-database run also demonstrates compatibility and explicitly bounds recovery-order behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The complete, hash-matched PR body records the real Doctor CLI on this head importing all six events with both normalized replies and the correct fresh-import active history; an existing-database run also demonstrates compatibility and explicitly bounds recovery-order behavior.
Evidence reviewed 9 items Current main still contains the failing mechanism: The fetched main revision updates event_json inside the rows iterator, then treats matching repeated deliveries as removable replays. The proposed deferral is absent.
Latest release comparison: Read the staging source at v2026.9.3 through the GitHub contents API. It retains the same in-cursor metadata update and replay deletion logic; the release does not contain this repair.
Repair preserves the existing storage contract: The complete staging owner creates a private temporary database and removes it in finally. The patch uses its existing scratch set, compares normalized bytes for genuine replay detection, and applies updates after scanSessionTranscriptNavigation exhausts the iterator. No schema, durable format, authorization, or transaction boundary is added.
Findings None None.
Security None None.

How this fits together

Doctor imports older session files into OpenClaw’s SQLite conversation store. A temporary staging database normalizes transcript metadata and removes genuine replays before the resulting history reaches the agent’s database.

flowchart LR
  A[Legacy session files] --> B[Doctor import]
  B --> C[Temporary transcript staging]
  C --> D[Scan and identify genuine replays]
  D --> E[Apply deferred metadata updates]
  E --> F[Agent SQLite history]
  F --> G[Conversation context]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +29, Tests +97. Total +126 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 32 3 +29
Tests 2 97 0 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 129 3 +126

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140100
Summary: This PR is the contributor fix for the reported import loss; the related draft preserves that sequence and plans separate cleanup.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Preserve every distinct event during first import through deferred staging writes, while treating reconstruction of already-damaged active history as a separate recovery repair.

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

Yes: the six-event legacy transcript and real CLI before/after trace identify a precise reproduction, and current main retains the responsible cursor mutation. This review verified source without executing the reproduction.

Is this the best way to solve the issue?

Yes: deferring writes in the existing temporary staging owner fixes the cursor hazard while preserving normalization and genuine replay deduplication.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P0: The existing migration silently drops assistant history while reporting success; the linked official-release report identifies thousands of missing events.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The complete, hash-matched PR body records the real Doctor CLI on this head importing all six events with both normalized replies and the correct fresh-import active history; an existing-database run also demonstrates compatibility and explicitly bounds recovery-order behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The complete, hash-matched PR body records the real Doctor CLI on this head importing all six events with both normalized replies and the correct fresh-import active history; an existing-database run also demonstrates compatibility and explicitly bounds recovery-order behavior.

Evidence

What I checked:

  • Current main still contains the failing mechanism: The fetched main revision updates event_json inside the rows iterator, then treats matching repeated deliveries as removable replays. The proposed deferral is absent. (src/config/sessions/session-accessor.sqlite-import-stage.ts:173, a1b4f6f91724)
  • Latest release comparison: Read the staging source at v2026.9.3 through the GitHub contents API. It retains the same in-cursor metadata update and replay deletion logic; the release does not contain this repair. (src/config/sessions/session-accessor.sqlite-import-stage.ts:173, 1391f7cd2d40)
  • Repair preserves the existing storage contract: The complete staging owner creates a private temporary database and removes it in finally. The patch uses its existing scratch set, compares normalized bytes for genuine replay detection, and applies updates after scanSessionTranscriptNavigation exhausts the iterator. No schema, durable format, authorization, or transaction boundary is added. (src/config/sessions/session-accessor.sqlite-import-stage.ts:159, 3fa839c8810e)
  • Complete real CLI proof inspected: The fetched full PR body matches captured SHA-256 72acc1bbbab18222f37608c379fbabbdc8c99474b134b1dfcefea1e445f4c1a8. Its Linux/Node 24.18.0 CLI trace compares the older build with this exact head: fresh import improves from four to six stored events, preserves both assistant replies in order, and produces five active messages. Existing-database recovery appends only the two missing replies without a schema migration. The body explicitly records that recovery does not restore the original active-history order. (3fa839c8810e)
  • Production boundary and dependency applicability: Doctor enables legacy repair through importSqliteSessionRowsBatch; the unchanged OpenClaw normalizer only rewrites legacy provider/API strings. This patch repairs local SQLite iteration, without invoking or changing the Codex harness or protocol. A sibling Codex source inspection is therefore not required. (src/config/sessions/legacy-transcript-repair.ts:46, 3fa839c8810e)
  • Regression coverage: The added importer and Doctor cases place two legacy assistant replies before later rows and assert that all six IDs survive; the importer also checks normalized metadata. Existing sibling coverage protects distinct-row replay deduplication and idempotent reimport. Tests were inspected, not executed in this read-only review. (src/config/sessions/session-accessor.sqlite-import.test.ts:209, 3fa839c8810e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (7 earlier review cycles)
  • reviewed 2026-09-06T16:57:54.913Z sha 82fbc57e81d115849f30d2a294f7cbf64cce0c0c :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T18:57:23.004Z sha 33837db2f086e8d6db0f6b8d1c9127f7413d2231 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T20:31:20.193Z sha 33837db2f086e8d6db0f6b8d1c9127f7413d2231 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T20:37:21.318Z sha 33837db2f086e8d6db0f6b8d1c9127f7413d2231 :: blocked before merge. :: none
  • reviewed 2026-09-06T20:46:33.846Z sha 33837db2f086e8d6db0f6b8d1c9127f7413d2231 :: blocked before merge. :: none
  • reviewed 2026-09-07T07:57:38.088Z sha 3fa839c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T07:34:26.131Z sha 3fa839c :: needs maintainer review before merge. :: none

@ylcn91
ylcn91 force-pushed the fix/session-sqlite-import-codex-rows branch from 82fbc57 to 33837db Compare September 6, 2026 18:51
@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
…m legacy transcripts

The legacy transcript repair normalized Codex provider metadata by updating
the staged rows table while iterating it from an open cursor. node:sqlite
re-delivers an updated row, and the identical-replay guard then treated the
second delivery as a duplicate and deleted the only copy, so every Codex
assistant message except the last one was lost on import. Stash normalized
bytes in a scratch table inside the disposable spool and apply them after
the scan; the replay guard reads the stashed bytes first so real duplicates
still deduplicate.
The import spool already keeps per-repair scratch sets in tree_sets, so
the rows whose Codex provider metadata needs normalizing are recorded
there and rewritten after the scan instead of through a new spool table.
Readers that need the normalized form before the rewrite (the replay
guard and the final rewrite itself) normalize the stored bytes on the
way out.
@ylcn91
ylcn91 force-pushed the fix/session-sqlite-import-codex-rows branch from 33837db to 3fa839c Compare September 7, 2026 07:51
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 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:

@steipete steipete closed this Sep 10, 2026
@steipete steipete reopened this Sep 10, 2026
@steipete
steipete merged commit 6d1ba30 into openclaw:main Sep 10, 2026
415 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…m legacy transcripts (openclaw#140296)

Fixes openclaw#140100.

Preserve legacy assistant events during Doctor SQLite import by deferring
provider-metadata rewrites until the staging cursor is exhausted. Keep
byte-exact replay checks against normalized prior rows and reuse the existing
per-repair scratch set; no persistent schema or archive policy changes.

The importer and Doctor regressions cover nonterminal assistant rows. Existing
exact-head CI and the contributor's Linux CLI proof show all six events
preserved in order instead of four. Fresh maintainer review found no actionable
issue. Recovery into an already-partial destination still does not restore its
original physical order or active-history projection; that limitation remains
explicit in the PR evidence.

Co-authored-by: Yalçın Doksanbir <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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. size: S 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.

[Bug]: doctor --session-sqlite import drops every assistant message with provider "codex" (2026.9.2, legacy JSONL → SQLite)

2 participants