Skip to content

fix(acp): Doctor drops retained ACP metadata after archiving legacy session stores - #169759

Merged
RomneyDa merged 1 commit into
mainfrom
fix/acp-archived-retained-metadata
Oct 12, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/acp-archived-retained-metadata

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

Related: forward-port of 16398dcb4a (via 9686536ceb) and eff7e0b4a2 from release/2026.10.1 (shipped in stable 2026.10.1).

What Problem This Solves

Fixes: openclaw doctor --fix silently drops legacy ACP session metadata when core session import has already archived the legacy sessions.json (for example, the ACP-owning plugin is installed after the first core import).

User Impact

User impact: upgraders whose ACP metadata was retained for a not-yet-installed plugin get it imported into shared SQLite once the plugin resolves, even after Doctor archived the original session store. The archived file is never rewritten, and an archived source still cannot be replayed into a session that was replaced since the core import. This matches shipped stable 2026.10.1 behavior.

Why This Change Was Made

  • Root cause: migrateLegacyAcpSessionMetadata skipped any target whose storePath was missing. Core import removes the store as soon as the deferred plugin resolves, so the retained metadata had no reader.
  • Owner fix: resolveDeferredPluginSessionStoreSource (src/infra/deferred-plugin-session-sources.ts) reads the canonical import receipt, including retired custody. It returns the hash-verified live or archived index through the existing resolveVerifiedSessionSource. The ACP migration reads that file as preserved input: completion is recorded and the file is never rewritten.
  • No-replay binding (eff7e0b4a2): prepareDeferredPluginSessionImportReader previously dropped the import binding once receipt.removedSource was set. That returned absent, which skips the canonical session binding check. Once archived sources become readable, an archived source would first-import into a replaced session. Retired custody now keeps the binding.
  • Not ported: the pre-agent shared-store target from 16398dcb4a. Main retired pre-agent session migration (acfd767f15), so core import never archives that store.
  • Not changed: readDeferredPluginSessionImport semantics. Only the new resolver reads retired receipts, so plugin-doctor identity evidence for a recreated store is unchanged.
  • Pure moves: captureDeferredPluginSessionSources moves to deferred-plugin-session-verification.ts and resolveLegacyAcpMetadataSessionStoreTargets moves to state-migrations.session-store-paths.ts. Both moves keep their owners under the line-cap ratchet, matching the release layout.

Evidence

  • New imports retained ACP metadata after core session sources are archived fails on pre-fix main: expected undefined to deeply equal { backend: 'fixture-backend', … }. It passes with the fix, and the archives stay byte-identical.
  • New archived variants of does not first-import ACP after the canonical sessionId/lifecycleRevision was replaced fail when only the binding change is reverted (expected { count: 1 } to deeply equal { count: 0 }). They pass with the full fix.
  • pnpm test src/acp/runtime/session-meta.legacy-migration.test.ts: 13/13 pass.
  • Sibling suites pass, 9 files and 124 tests: src/infra/state-migrations.acp-session-metadata.test.ts, src/infra/state-migrations.test.ts, and the src/commands/doctor-session-sqlite.{shared-orphan,receipt-retirement,retained-source-verification,stale-receipt,indexless}.test.ts suites, plus doctor-state-integrity and legacy-runtime-session-migration.
  • node scripts/check-changed.mjs: typecheck, lint, import-cycle, and line-cap lanes are green. The dead-export scan fails on main-only exports this PR does not touch (src/auto-reply/reply/memory-flush.ts:resolveEffectivePromptTokens, ui/src/pages/chat/components/chat-pane-versions-menu.tsx:ChatPaneVersionsMenu, and others).
  • Autoreview (codex, P1): scoped-clean (0.84).
  • Production delta: +181/-143 (net +38), mostly pure moves. The new logic is about 30 lines. Tests: +61/-8.

@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 complete

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

View the workflow run.

@RomneyDa
RomneyDa marked this pull request as ready for review October 12, 2026 08:24
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 imports retained ACP metadata from verified archives while preserving canonical session binding and replay protection.

Example: The plugin becomes available after Doctor archives sessions.json containing agent:main:retained-acp with runtimeSessionName legacy-runtime.

  • Before: Doctor skips the missing index, leaving legacy-runtime unavailable.
  • After: Doctor imports the metadata from its verified archive without rewriting it, and rejects import into a replaced session.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful patch with meaningful production-owner regressions and no actionable findings; installed-state compatibility is not yet established.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Retained ACP conversation metadata remains unavailable when its plugin resolves after Doctor archives the legacy session index.
Reason: Maintainer-authored direction restores the existing preservation contract without adding configuration, schema, or public API behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this maintainer-authored PR open: current main still skips archived ACP metadata, and the introduced patch has no actionable code findings.

Priority: P1
Reviewed head: 446367e5b51464f0a6fc2ee3dde930fbd9560738

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: No supplied latest-stable-to-candidate upgrade run demonstrates archived ACP import with existing settings, history, archive bytes, and canonical replacement or closure state intact.
Agent review details

How this fits together

Doctor converts legacy session files into agent SQLite and ACP metadata into shared SQLite; import receipts identify preserved archives and prevent historical metadata from replacing current session state.

flowchart TD
  A[Doctor session migration] --> B[Canonical import receipt]
  B --> C[Verified legacy archive]
  C --> D[ACP metadata importer]
  D --> E[Canonical binding and completion checks]
  E --> F[Shared SQLite ACP metadata]
Loading

Technical review

Best possible solution:

Land the receipt-owned archive reader and retained canonical binding once existing-state compatibility is demonstrated.

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

Current-main source shows the missing-index skip after core archival, and the body reports a matching pre-fix regression failure; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch restores archive reading through the existing receipt owner and preserves transactional binding and completion checks rather than replaying historical metadata unconditionally.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Deferred ACP preservation and supersession keeps the original intent (dac3cb6: Deferred inputs remain available while canonical session edits, deletions, and ACP closures prevent historical replay.)
  • Retired receipt binding changes intended behavior with a stated reason (6ced196: Verified archival retires active source custody so new history can import; this PR explains why canonical no-replay evidence must survive that retirement.)
  • Migration helper placement keeps the original intent (8aab4ff: Migration modules were split by responsibility while preserving behavior; both relocated helpers retain their operations and production callers.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Raw commit 8ab22e9 adds src/commands/doctor-session-sqlite.ts:996 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8ab22e9b28af; files: src/commands/doctor-session-sqlite.ts)

PR surface

Source +38, Tests +53. Total +91 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 181 143 +38
Tests 1 61 8 +53
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 242 151 +91

Review metrics

Metric Value Why it matters
Production versus test LOC Production +181/-143; tests +61/-8 Production growth mainly relocates existing helpers and adds focused archive resolution; the tests protect persisted migration outcomes.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Affected upgrades silently leave retained ACP conversation bindings unavailable after core archival.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-12T08:32:45.157Z sha 9a9dea611d5dbc7d14cbedad67069e4ee5f8ff17 :: blocked before merge. :: none

Reviewed October 12, 2026, 5:20 AM ET / 09:20 UTC (Revision 2).

Doctor's ACP legacy metadata migration skipped any session store whose
legacy index no longer existed. Once the deferred plugin resolved, core
session import archived and removed sessions.json, so retained ACP
metadata was never imported (silent loss of ACP session bindings for
upgraders).

Resolve the verified archived index from the canonical import receipt
(retired custody included) and read it as preserved input. Keep the
canonical no-replay binding in the ACP import reader after source
retirement so an archived source cannot first-import into a replaced
session.

Forward-ports release fixes from release/2026.10.1:
- 16398dc fix(acp): migrate metadata from retained sessions (via 9686536)
- eff7e0b fix(release): preserve archived import bindings

The pre-agent shared-store target from 16398dc is omitted: main
retired pre-agent session migration (acfd767), so core import never
archives that store. Pure moves of captureDeferredPluginSessionSources
and resolveLegacyAcpMetadataSessionStoreTargets keep both owners under
the line cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RomneyDa
RomneyDa force-pushed the fix/acp-archived-retained-metadata branch from 9a9dea6 to 446367e Compare October 12, 2026 09:13
@RomneyDa
RomneyDa enabled auto-merge (squash) October 12, 2026 09:15
@RomneyDa
RomneyDa merged commit 25f739c into main Oct 12, 2026
121 checks passed
@RomneyDa
RomneyDa deleted the fix/acp-archived-retained-metadata branch October 12, 2026 09:25
@RomneyDa

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

RomneyDa added a commit that referenced this pull request Oct 13, 2026
…169759)

Doctor's ACP legacy metadata migration skipped any session store whose
legacy index no longer existed. Once the deferred plugin resolved, core
session import archived and removed sessions.json, so retained ACP
metadata was never imported (silent loss of ACP session bindings for
upgraders).

Resolve the verified archived index from the canonical import receipt
(retired custody included) and read it as preserved input. Keep the
canonical no-replay binding in the ACP import reader after source
retirement so an archived source cannot first-import into a replaced
session.

Forward-ports release fixes from release/2026.10.1:
- 16398dc fix(acp): migrate metadata from retained sessions (via 9686536)
- eff7e0b fix(release): preserve archived import bindings

The pre-agent shared-store target from 16398dc is omitted: main
retired pre-agent session migration (acfd767), so core import never
archives that store. Pure moves of captureDeferredPluginSessionSources
and resolveLegacyAcpMetadataSessionStoreTargets keep both owners under
the line cap.

(cherry picked from commit 25f739c)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…penclaw#169759)

Doctor's ACP legacy metadata migration skipped any session store whose
legacy index no longer existed. Once the deferred plugin resolved, core
session import archived and removed sessions.json, so retained ACP
metadata was never imported (silent loss of ACP session bindings for
upgraders).

Resolve the verified archived index from the canonical import receipt
(retired custody included) and read it as preserved input. Keep the
canonical no-replay binding in the ACP import reader after source
retirement so an archived source cannot first-import into a replaced
session.

Forward-ports release fixes from release/2026.10.1:
- 16398dc fix(acp): migrate metadata from retained sessions (via 9686536)
- eff7e0b fix(release): preserve archived import bindings

The pre-agent shared-store target from 16398dc is omitted: main
retired pre-agent session migration (0719b87), so core import never
archives that store. Pure moves of captureDeferredPluginSessionSources
and resolveLegacyAcpMetadataSessionStoreTargets keep both owners under
the line cap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant