Repository navigation
refactor(acp): migrate legacy session metadata through Doctor - #162920
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed October 3, 2026, 9:51 PM ET / October 4, 2026, 01:51 UTC (Revision 26). ClawSweeper reviewWhat this changesThe PR moves historical external-agent session metadata repair into Doctor, adds verified backups and replay protection, and makes runtime consumers read canonical SQLite metadata. Merge readiness⛔ Blocked before merge - 6 items remain This work remains distinct and necessary: current main and the latest release retain legacy metadata readers. No new actionable defect was established, but the existing upgrade and authority proof blockers remain unresolved. Priority: P2 Review scores
Verification
How this fits togetherACP connects OpenClaw sessions to external agent runtimes and stores the identifiers needed to resume their conversations. Doctor repairs historical stored metadata before Gateway admission; runtime readers then use that metadata for routing and session presentation. flowchart TD
A[Historical session metadata] --> B[Doctor repair]
B --> C[Verified backups]
B --> D[Owner and lifecycle checks]
D --> E[Canonical metadata and receipts]
E --> F[Gateway admission]
F --> G[Agent routing and session views]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Doctor as the sole repair owner, with lossless restart-safe migration and canonical runtime reads qualified against supported existing installations. Do we have a high-confidence way to reproduce the issue? Not applicable to this migration refactor; source inspection establishes the legacy paths and changed admission boundary. No runtime reproduction or tests were executed during this read-only review. Is this the best way to solve the issue? Yes, concentrating normalization in Doctor follows the existing ownership contract and removes competing runtime interpretations; the available evidence does not yet qualify the upgrade and authority boundaries for merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4a799871c1a5. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (25 earlier review cycles; latest 8 shown)
|
83fecd5 to
24af1ee
Compare
14d6b42 to
356bb4e
Compare
9ee150c to
d6b48e2
Compare
File preview identities now include the session key. The mocked files response still returned main while the pane used agent:main:main, so the active row could never match after the preview resolved. Match the response to the requested session, preserving the delayed-directory response and both content/selection assertions. No production behavior changes. Remote proof on captured main 06ac4a4 using the native UI E2E owner reproduced the one original failure across 3 tests in 47s; the reviewed correction passed all 3 in 22s. Combined fixture proof used Hetzner lease cbx_0ddfa2afe062, run run_2fdec9b8159f9fdd9a8551bc1b942607. Direct review was clean. Refs #163185, #162920.
File preview identities now include the session key. The mocked files response still returned main while the pane used agent:main:main, so the active row could never match after the preview resolved. Match the response to the requested session, preserving the delayed-directory response and both content/selection assertions. No production behavior changes. Remote proof on captured main 1311a9c using the native UI E2E owner reproduced the one original failure across 3 tests in 47s; the reviewed correction passed all 3 in 22s. Combined fixture proof used Hetzner lease cbx_0ddfa2afe062, run run_2fdec9b8159f9fdd9a8551bc1b942607. Direct review was clean. Refs openclaw#163185, openclaw#162920.
1a19238 to
8bc2260
Compare
Move legacy ACP key and embedded session normalization into the Doctor and startup migration owner, preserving opaque conversation/resume identities with backups. Runtime reads canonical metadata through the existing worker and projection owners. Integrate current async retry preparation and canonical session reloads in chat admission. Preserve commit-promise settlement through Goal reentry. Remove the superseded TUI catch and retain main's behavior. Independent P2 review is clean. Prior focused and hosted evidence remains recorded in PR #162920; the refreshed published-driver cell will run on this integrated candidate before landing.
8bc2260 to
b768f94
Compare
Merge main to resolve the account-control lane conflicts with auth-usage shutdown (#164588) and canonical ACP metadata (#162920). Retain both close-prelude owners and pass canonical ACP metadata alongside prepared personal-account selection. The released account service signatures and storage contract remain unchanged.
…aw#162920) Doctor now owns supported historical ACP keys and embedded native-session metadata, with verified backups and replay protection. Runtime consumes canonical worker-prepared facts and preserves live session authority across asynchronous reads. Opaque conversation/resume identifiers remain durable. Production: +1379/-782/net +597 (complete two-page GitHub file inventory); native-session data qualifies for the durability exception. Same-owner runtime paths shrink net -296. Validation: independent P2 review and resolved findings; exact-head CI 37167922766 passed. Hetzner lease cbx_7ebc9f3d6eb1, run run_d9e0d840af26ac29eedc30cbdf2ee0cb: 272 focused cases, two-case authority negative control, package validation, and unmodified 2026.9.7 update passed. Update took 344s; repeat Doctor 16s; closure replay Doctor 15s; Gateway health passed. Total remote command 1911.019s.
What Problem This Solves
Older ACP state can keep native conversation locators under historical keys or embedded in session entries. Runtime readers and writers currently interpret those shapes independently, repair state during ordinary requests, and can disagree about session ownership.
User Impact
Doctor becomes the single repair owner. It creates verified private SQLite backups, resolves the owning session and lifecycle, rekeys historical rows, and imports embedded ACP metadata. It records completion before removing the embedded source field so interrupted cleanup cannot reopen metadata after the canonical session was closed. Ambiguous owners, conflicting payloads, changed databases, and unmatched bindings retain their source data and receive actionable diagnostics.
Upgrade behavior and normalization
The candidate's existing update-time Doctor pass runs the repair before startup. Startup refuses restored, unmigrated ACP state before admitting the affected session store. Operators restoring older state should stop the Gateway, run
openclaw doctor --fix, and restart.Raw-key rekeying preserves every metadata column except the key. Embedded imports retain canonical identity, runtime options, lifecycle binding, and activity fields; the source session entry's update timestamp becomes the metadata update timestamp. Unknown embedded fields remain in the verified backup. Duplicate JSON properties retain the session decoder's last-value semantics. The migration fixtures and Doctor documentation describe these deliberate normalizations.
Why This Change Was Made
Runtime consumes canonical metadata. The cutover removes legacy key codecs, embedded-field fallbacks, alias cleanup, and read-time repair. Session resolution, patch responses, chat metadata/history, previews, and the embedded TUI consume prepared canonical facts. Session creation binds its committed identity to the existing mutation-authority owner; asynchronous preparation retains the post-await authority checks. The published synchronous ACP SDK reader remains available and reads canonical state.
Durable-data exception and retention
The net +597 production lines qualify for the durable-data exception because they preserve existing native conversations, including opaque physical backend and resume identifiers. This is more than a metadata label:
manager.runtime-handle-ensure.tsreconstructs the persisted handle and passesresolveRuntimeResumeSessionId(identity)intoruntime.ensureSession. That resolver usesidentity.agentSessionIdoridentity.acpxSessionId;identity.acpxRecordIdandruntimeSessionNameidentify the physical backend record. ACPX validates that locator against its owner and uses the resume ID when reopening the native session. Discarding these values can detach the existing conversation or start another native session; an OpenClaw display row or transcript cannot reconstruct those opaque identifiers or the backend's native session state. No preference, display-state, or cache migration is added.These formats have concrete shipped writers within the 2026-07-01-or-later support window:
entry.acpdb40fde88c6did not end writes of retained embedded metadata.v2026.7.1-2serializesprojectSessionStoreForPersistence(...).store. Inv2026.9.7,writeSessionEntrypasses the copied entry throughprojectCanonicalSessionEntryShape, which retainsacp, thensplitSessionEntrySnapshotsincludes it inentryJsonand the node writer persists it.v2026.7.1-2writes the suppliedsessionKeydirectly toacp_sessions.session_key. Encoded keys arrived in1ca60fbc3a3, included inv2026.8.1.v2026.8.1'ssessionscommand omitsagentIdfrom its batch metadata read. The batch read computes[null, key]and persists it when rekeying a historical row.1b5dc72557clater removed that read-time writer.These boundaries were checked with
git log -S/-Gand release-tag source. The migrations therefore remain; the date of the original format introduction is not its last-write cutoff.Same-owner offsets are included: the ordinary ACP reader/writer/key/control paths shrink +92/-388/net -296, including deletion of the 55-line
session-meta-legacy-cleanup.tsand consolidation of key/read/write paths. The ACP Doctor/migration/startup portion is +794/-124/net +670, making the ACP owner subtotal net +374. The remaining net +223 carries canonical owner facts and authority through its existing callers. No pre-July-only Doctor migration retirement is claimed as an offset for these still-supported shapes.Whole PR production: +1379/-782/net +597. Measured at
c11521f296032e57e025f8d3952639842a18e31dfrom the complete GitHub files response across two API pages: 105 files, including 56 production files insrc/**andextensions/**. Tests, test support/helpers/utils/harnesses, e2e, fixtures, anddoctor.fast-path-mocks.tsare excluded. The requested path scope includes the +1/-1 Gateway instruction edit, with zero net effect.Significant overlaps include the prepared catalog, closed-ACP provenance, and patch-response owners covered by #161456, #160851, and #161030. Main's current worker, authority, and startup behavior is retained. The earlier admission conflict preserves main's asynchronous Goal/skills preparation and queued-source cancellation release. Canonical ACP metadata survives recursive authority revalidation, and both admission branches return the async commit promise so the writer barrier stays held until preparation settles. The earlier
stringBytesintegration and retired-field removal remain unchanged. The preceding rebase preserves the ACP test consolidation from #164238: combined file/incognito joins, the single authority-revocation table, and table-driven Doctor key repair. The two removed alias-rebind cases renamed the canonical row into a historical alias before the runtime read; their assertions depended exclusively on the retired runtime alias-selection path. Durable alias payload, binding, conflict, backup, and rerun protection remain in Doctor tests, while runtime update/close still proves every historical row survives unchanged. The final integration preserves main's worker-backed retry comparison and canonical session reloads from #164313, retains ACP facts across Goal reentry, and returns both commit promises. The TUI prepared-runtime file is now byte-identical to main, so its obsolete catch no longer appears in this PR. The base includes both the Nextcloud Doctor fix96622c4and the pending-input fixture repairb02cc06; the ACP update proof retains normal plugin policy. Later main TUI fallback and session-signal worker changes were inspected and merge cleanly without changing this patch. The latest two fixture conflicts preserve the canonical ACP cases while adopting main’sagents.entriesshape. Main’s detached-maintenance custody repairb58e6e98933is retained byte-for-byte. Scoped discovery derives custom template roots before filtering target agents. Prepared metadata absence remains authoritative through defaults, rows and operator presentation; display-identity cache entries match their captured metadata snapshot. The subsequent empty-batch correction avoids dispatching an ACP read after catalog-only invalidation; it adds no cache. These bounded review repairs add net +17 production lines over the conflict-only integration. The response-race test assigns its successor owner through the canonical worker operation instead of an ignored row field, preserving the exact denial and successor-state assertions.Evidence
37167922766, attempt 1, passed forc11521f296032e57e025f8d3952639842a18e31d. Those completed source gates are reused for final proof; they do not substitute for the required published-driver update cell.c11521f296032e57e025f8d3952639842a18e31d; tree9be407b1de4d1c4686c46c6369558b124d01e525, based on main28a6f71449aa5542c9fb825dcb3423dfbb7abf82. Native staged-content and formatting hooks passed. Independent P2 reviews identified and resolved the custom-root and metadata ownership defects. The final review’s remaining startup-authority concern was rejected after inspecting the existing history owner: it revalidates session identity and sharing after the awaited projection, and again before later delta or retained-transcript publication. No duplicate authority callback was added.350727d303900c3e40bfe55b3ae656ba13a4311a. The later run37126191741at1a19238failed only the four inherited pending-input read-fixture cases and the aggregate. Their host clock mock did not control worker acceptance timestamps, and reads raced receipt settlement. Main fixed those fixtures inb02cc06, with all six cases passing in 101.83 seconds and eight operation cases passing, including a held-completion cancellation probe. This candidate includes that landed fix; current-head CI passed as recorded above. No local tests ran.cbx_0ddfa2afe062, runrun_d6e79a9991bae88e4bfa058f0b506865. Packaging took 662.64s and the unmodified published 2026.9.7 updater completed in 305s. Its postassertion then failed because it counted every receipt for the agent database path: one ACP receipt plus two older auth receipts. Read-only inspection of preserved SQLite families confirmed the exact ACP binding/source hash and unchanged auth receipts. This was a proof-query defect, not duplicate migration. All preserved source bytes stayed unchanged.8bc2260CI run37137149985failed the three inherited Doctor lease cases. A clean-main comparison reproduced those exact cases; main’sb58e6e98933repair is included in this integration. No passing baseline or completed update is inferred from that failed run.cbx_7ebc9f3d6eb1, runrun_d9e0d840af26ac29eedc30cbdf2ee0cb, exactc11521fsource/tree above. Frozen install ran first. All 272 cases across 12 remaining focused files passed, including corrected response authority; the narrow negative control failed exactly the two intended replacement/reassignment cases, then pristine source was restored. Normal build/package and tarball validation passed in 705.90s. The unmodified published 2026.9.7 updater passed in 344s, with canonical rows, exact backups and scoped ACP receipts verified before manual candidate Doctor, while prior auth receipts remained unchanged. Repeat Doctor passed in 16s; restoring the closed embedded source followed by another Doctor pass (15s) did not reopen it. The candidate Gateway started and passed its health check, then stopped. The complete published cell took 418.97s; total remote command 1911.019s. Catalog (37.05s) and custom-root discovery (50.08s) reuse their passing75cfa3fproof; the only subsequent source delta was the corrected authority test fixture. Whole-PR remotecheck-changedwas not rerun: source gates use the green exact-head CI listed above. This is isolated synthetic-state Linux proof, not a live external ACP backend conversation.Release-note context
ACP upgrades preserve existing native-agent conversation and resume bindings by migrating historical session keys and embedded state through Doctor with verified backups and replay protection. Runtime now reads canonical state only; after restoring an older session store, stop the Gateway and run
openclaw doctor --fixbefore restarting.