Repository navigation
fix: recover renamed legacy session transcripts - #178146
Merged
Merged
Conversation
Use the validated transcript header for identity while preserving the actual source path for import, archival, and restore. Record filename mismatches as warnings, retain conflicting originals, and keep the warning nonblocking for retained plugin-source settlement. Fixes #177987
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 20, 2026 06:18
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 21, 2026
…r session id (openclaw#178146) Fixes openclaw#177987. Migration now uses the header session id for identity, preserves the original path and bytes, and warns on filename mismatch; conflicting histories that claim the same id stay deferred and protected.
This was referenced Oct 21, 2026
RomneyDa
added a commit
that referenced
this pull request
Oct 26, 2026
…r session id (#178146) Fixes #177987. Migration now uses the header session id for identity, preserves the original path and bytes, and warns on filename mismatch; conflicting histories that claim the same id stay deferred and protected. (cherry picked from commit fd566f2) Adapted for 2026.9.x: ported only the session-sqlite-migration-readers.ts identity fix. The transcript_filename_mismatch warning, deferred-message path list, and docs hunks touch doctor-session-sqlite-discovery.ts/types.ts, which a parallel 9.35 port owns, so they are not included here. Renamed files now import under their header identity without a warning. Regression tests were rewritten on the 9.x discovery test helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #177987
What Problem This Solves
Doctor leaves valid legacy conversation history out of SQLite when a transcript was renamed or copied and its header ID differs from its filename.
User Impact
Doctor imports that history under the header's session identity and records a warning. Original transcript bytes remain protected for recovery and restore. Files claiming the same identity remain separate in the protected archive; their paths are named in the conflict warning rather than combining their histories.
Why This Change Was Made
The migration reader confused a transcript's location with its identity. Keep the actual source path for reading, fingerprinting, archival, and restoration, and use the validated header for identity. Retained shared aliases and existing logical-owner checks remain unchanged. The new warning is informational both for Doctor exit status and retained plugin-source settlement.
The simplification removes the filename-equality rejection and reuses the existing discovery/import/archive owners. No schema, configuration, CLI option, or dependency changes. Production delta: +14/-9 (net +5); tests: +39/-11 (net +28); docs: +5/-1 (net +4). The small production increase records the mismatch and names conflicting originals.
Evidence
transcript_filename_mismatch. Read-only SQLite inspection confirmed the header ID; the retained original was byte-for-byte unchanged. Doctor restore returned both original files with no conflicts; explicit validation verified 1 session / 2 events.a8bc87f1c5b, both new regressions failed onimportedEntries(0, expected 1). All four reviewed files were then restored byte-for-byte. Baseline run: 98.76s wall, 0.53s test time.git diff --check, and Madge passed (0 import cycles).doctorCommandwith its real maintenance lock and one-shot exit/finalization handling; this proves offline migration behavior, not package installation or CLI argument parsing.check:changed/ SQLite inventory was omitted under the campaign's local gate budget. Independent Codex review completed with a scoped-clean P0–P2 verdict and no actionable findings. Its initial temporary-directory preflight refusal was resolved using the OS-provided private temporary directory.Local timing details
Existing slow cases on the loaded shared host, retained under the campaign exception:
src/commands/doctor-session-sqlite.discovery.test.ts— recovers a completed old archive once, preserves bytes, and does not resurrect user-deleted history: 52.50s.src/gateway/session-startup-migration.test.ts— runStartupSessionMaintenanceForTest > admits the shared SQLite store before repair and preserves its history: 33.05s.src/gateway/session-startup-migration.test.ts— runStartupSessionMaintenanceForTest > admits the scoped SQLite store before repair and preserves its history: 31.91s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > records held stores as advisories and completes independent repairs (unknown custom owner: false): 45.66s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > records held stores as advisories and completes independent repairs (unknown custom owner: true): 40.37s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > preserves deleted state (deleteFiles=false, registered=true, location=default): 61.36s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > preserves deleted state (deleteFiles=false, registered=false, location=default): 42.04s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > preserves deleted state (deleteFiles=false, registered=false, location=custom): 44.79s.src/infra/state-migrations.retained-deleted-agent.test.ts— Doctor with a deleted agent database > preserves deleted state (deleteFiles=true, registered=true, location=default): 35.20s.src/commands/doctor-session-sqlite.deferred-plugin.test.ts— settles a retained source in the same Doctor after late plugin completion (unchanged source): 45.76s.src/commands/doctor-session-sqlite.deferred-plugin.test.ts— settles a retained source in the same Doctor after late plugin completion (changed orphan): 38.52s.src/commands/doctor-session-sqlite.deferred-plugin.test.ts— verifies canonical import and retains default originals until resolution without replay: 39.26s.src/commands/doctor-session-sqlite.deferred-plugin.test.ts— verifies canonical import and retains configured-root originals until resolution without replay: 40.29s.src/commands/doctor-config-preflight.container-upgrade.test.ts— container image replacement Doctor repair and startup readiness > preserves schema 19 at startup, then backs it up and repairs it through Doctor: 37.80s.src/commands/doctor-session-sqlite.missing-retained-source.test.ts— import settles a missing retained primary only when its recorded bytes match canonical history: 46.33s.Files exceeding 120s of summed test time (excluding transformation/import):
src/acp/runtime/session-meta.legacy-migration.test.ts: 129.07s.src/commands/doctor-session-sqlite.deferred-plugin.test.ts: 341.38s.src/commands/doctor-session-sqlite.discovery.test.ts: 180.25s.src/gateway/session-startup-migration.test.ts: 188.72s.src/infra/state-migrations.retained-deleted-agent.test.ts: 298.32s.Isolated live reproduction
Paths below are normalized:
PROOF_ROOTwas inside this worktree's.artifactsdirectory. Every invocation usedHOME=$PROOF_ROOT/home,OPENCLAW_STATE_DIR=$PROOF_ROOT/state, andTMPDIR=$PROOF_ROOT/tmp. No operator state or running Gateway was used.The synthetic
state/agents/main/sessions/sessions.jsoncontained{}.renamed.jsonlcontained:{"type": "session", "version": 3, "id": "original-id", "timestamp": "2026-04-15T00:00:00.000Z", "cwd": "/synthetic"} {"type": "message", "id": "original-message", "parentId": null, "message": {"role": "user", "content": "renamedhistoryneedle"}}The local
doctor-live.mtsharness invokes the production Doctor command, maintenance lock, and exit finalization without rebuilding/publishing runtime artifacts:Commands (with the isolated environment above):
Import before the fix:
importedEntries=0,historical_transcript_deferredwith the filename/header error. Recovery with the fix:importedEntries=1,importedTranscriptEvents=2,transcript_filename_mismatch. Restore: two original files restored, no conflicts. Validation after restore:validatedEntries=1,validatedTranscriptEvents=2. The original JSONL's SHA-256 remained44da730a621efd488d62ba9e01d86c5dc2acc5a449aef64905fea5f34c6a2838.