Repository navigation
fix(update): preserve migrated default agent across restarts - #146246
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: blocked before merge. Reviewed September 13, 2026, 12:33 PM ET / 16:33 UTC (Revision 23). ClawSweeper reviewWhat this changesPreserves the saved default agent across CLI, Gateway, and Control UI operations while separating runtime selection from legacy data ownership. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain The restart fix remains useful and is not present on current main. The previously reported Doctor import defect remains on the unchanged head; the hook and ACP findings have been addressed. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw resolves agent ownership from saved configuration before listing agents, routing requests, or locating sessions. Doctor migrates older session files into agent-owned SQLite databases using that ownership information. flowchart TD
A[Saved agent configuration] --> B[Runtime default selection]
B --> C[CLI and Control UI]
B --> D[Gateway request routing]
A --> E[Legacy data ownership]
F[Legacy session files] --> G[Doctor import]
E --> G
G --> H[Agent SQLite sessions]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +648, Docs +32. Total +717 across 59 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the durable runtime default and use the separate legacy-data owner consistently throughout Doctor's import path. Do we have a high-confidence way to reproduce the issue? Yes, from source: an explicit roster containing only ops, no saved system/session-store owner, and an unqualified state-root legacy session row reaches Doctor's all-agent filter and is excluded. This read-only review did not execute that scenario. Is this the best way to solve the issue? The shared runtime/data-owner separation is appropriate, but the cutover is incomplete: Doctor's legacy import must consume the data-owner resolver too. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ab59bcfbef61. LabelsLabel 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 (22 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Protect clean TLS-enabled Gateway shutdown by covering registration of certificate renewal with the Gateway lifetime owner through real startup and close. #146267 added TLS renewal registration using an array; #146275 changed sidecar registration to variadic handles and missed that caller. Passing the renewal handle directly prevents failed production typechecks and shutdown errors (sidecar.stop is not a function). Current main already carries the one-line correction; this landing preserves the integrated regression that detects the caller-contract mismatch. The test uses isolated synthetic TLS material, closes the real Gateway, and observes the real renewal cleanup. The recorded regression failed before the repair and passed afterward; focused sibling coverage passed 22 tests. Exact-head CI and lead Codex review passed. No configuration, storage, or protocol changes. Refs #146267, #146275, #144587, #146246.
|
Merged via squash.
|
…#146708) Add a real-Gateway regression that holds model catalog discovery across an ordinary quota-recovery turn, then verifies model availability and the provider's Ready badge without restarting the Gateway. Keep quota freshness with the existing generation-bound, physical-owner-aware usage reader. The final change adds fixture support, browser coverage, and recovery documentation; the duplicate production overlay was removed during review. Refs openclaw#146317. Refs openclaw#146246. The sandbox-cache half is tracked separately in openclaw#146664. Validation: 64 focused owner/catalog tests and all three real-Gateway quota cases passed in the retained behavior proof. Exact-head CI passed at https://github.com/openclaw/openclaw/actions/runs/34755008537. The clean rebase preserves the approved patch byte-for-byte; the whitespace check and native hosted-CI prepare gates passed. Lead and ClawSweeper reviews have no actionable findings.
…w#146246) Fixes openclaw#146195 Refs openclaw#146216 Reported by @lilei0311 (openclaw#146195). Preserve the migrated default agent across restarts by reading the roster-validated systemAgent designation under explicit ownership. Agent listing, unscoped session selection, Gateway aliases and identity, and Control UI default badges and Set Default share that recorded owner. Ownerless fleets still require explicit selection. Keep durable designation separate from sole-agent operation selection and legacy-data ownership. Preserve caller repairs, the Doctor config-flow split, and main-session deletion protection. Omitted hooks honor the persisted global-store owner and its allowlist. ACP legacy metadata follows retained data ownership independently of the runtime default, while sole-agent reads and lifecycle fences remain intact. No code or tests were adopted from openclaw#146216. Validation includes failing-before regression proof, passing touched suites and full changed-file gates, and scoped-clean lead review at be5bbd4. Refreshed merge-ref CI passed at https://github.com/openclaw/openclaw/actions/runs/34767412613 after the main-side Control UI budget refresh. The published-updater campaign remains an explicitly waived validation gap.
Closes #146939. Related: #140984. ## What Problem This Solves Fixes `memory_get` returning a different file from `memory_search` when an explicitly owned multi-agent roster relies on inherited workspace paths. ## User Impact Search results and subsequent reads agree on the agent's workspace without requiring a per-agent workspace pin. Explicit workspace overrides remain authoritative. No files move, no index reset or storage migration is required, and Markdown containment and read limits are unchanged. For explicitly owned rosters, an unpinned first agent no longer implicitly reads the parent workspace merely because it appears first. A valid retained migration owner and sole-agent inheritance still follow canonical behavior. Raw reader inputs without explicit ownership keep their existing legacy behavior. ## Why This Change Was Made The prior path repair in #140984 deliberately deferred workspace-ownership alignment. This PR proposes only that bounded alignment: core and explicitly owned memory-host reads share the compatibility-owner decision through a pure internal helper. The existing private path bridge avoids importing the full agent runtime. The original config object is preserved for retained migration-owner lookup; optional legacy reader IDs remain accepted. ### Maintainer choices — proposed, not previously approved 1. **Accept explicit-roster alignment (recommended and implemented).** Search's canonical workspace ownership is authoritative for reads too. Alternatively, retain the mismatch and require explicit workspace pins; this PR does not silently change search to match the old getter. 2. **Preserve legacy reader compatibility (implemented).** Inputs without `ownership: "explicit"` retain first-agent/default-marker inheritance. Broader normalization of those inputs is intentionally deferred, rather than changing the shipped reader contract in this fix. 3. **Keep adjacent policy out of scope (recommended).** No context-limit merging changes, shared-system-agent workspace redesign, public SDK entrypoint, or broader path allowlist. Those require separate decisions. ClawSweeper's source review supports this direction but requests a compatibility decision; it is not maintainer approval. Please review the ownership choice before merge. Rollback is reverting this change; the issue's explicit-workspace-pin mitigation remains available. ## Evidence ### After-fix real Gateway proof — September 13, 2026 Built candidate `be5a589a0ee148b54c51f6876ef5281ee9b29cb5`, Node 26.8.1/macOS. Used a loopback-only Gateway, registered Memory Core tools through HTTP `POST /tools/invoke`, synthetic files and real on-disk SQLite state, `provider: none`, and vectors disabled. No test-helper imports, provider calls, or production configuration/state changes. | Setup | Actual search → get result | | --- | --- | | Fresh explicit two-agent roster, neither agent pinned; parent contains a decoy | main: `USER.md`, `status=ok`, `Orchid proof main`; other: `USER.md`, `status=ok`, `Orchid proof other` | | Fresh setup, parent traversal for each agent | `MEMORY_PATH_NOT_ALLOWED` | | Installed 2026.9.3, existing explicit workspace pins | main/other: `USER.md`, `status=ok`, matching `Orchid upgrade main` / `Orchid upgrade other` | | Same shipped-created state after candidate Doctor migration and candidate Gateway startup | Both agents return those same markers with `status=ok` | For each agent, passed the search result's path/start line/inclusive line count into `memory_get`. Stopped the shipped Gateway before switching binaries. Candidate initially refused the older session-identity database; followed its supported `doctor --fix --non-interactive` instruction (exit 0, both agent databases v19→v20), then repeated the actual HTTP flow. Both existing workspace pins were preserved exactly, and SHA-256 checks showed all three synthetic `USER.md` files unchanged. Doctor did change normal config metadata/defaults; the whole config was **not** unchanged. All proof Gateways were stopped. This is fresh-runtime and shipped-created-state/Doctor migration proof, **not** an installer, `openclaw update` driver, or live-user upgrade test. Retained legacy-owner shapes beyond these fixtures remain covered by focused tests, not claimed as live proof. The schema migration belongs to the candidate's existing upgrade path; this six-file patch introduces no schema or embedding-metadata changes. Maintainer acceptance of explicit-roster read-root alignment remains required. CI at this evidence update: the model-login catalog timing case in [large-26](https://github.com/openclaw/openclaw/actions/runs/34761804381/job/103735936253) failed, making the aggregate gate red. Its fixture disables memory and uses one pinned agent without explicit ownership; likely unrelated, but no matching base failure was verified. No CI pass is claimed. - Focused validation: 162 tests passed across six files (one existing skipped test), including the real-manager tool regression and package-boundary contracts. - Final-head `node scripts/check-changed.mjs` passed: core and test types, core/extension lint, formatting, dead-export scans, package/SDK boundaries, and runtime import-cycle checks. `git diff --check` passed. - Full `pnpm build` passed in 3m26s, including plugin SDK exports, CLI bootstrap imports, built plugin-loading checks, and Control UI build. After that build, the only patch change moved an unchanged re-export below imports for lint; the rebase added only unrelated ACP tests. The repository-wide test suite was not run. - Tests-first reproduction on upstream main: both roster orders returned the parent decoy through `memory_get` after real SQLite-backed `memory_search` found the agent marker. - The regression exercises both agents, both roster orders, returned path/line readback, and rejection of parent traversal. It uses temporary files and databases with embeddings disabled; no provider request or private installation data. - Compatibility coverage includes explicit workspace overrides, retained/removed migration owners, ignored legacy markers under explicit ownership, optional legacy IDs, sole/duplicate agents, and absent/empty rosters. Existing legacy path, file-reader, core ownership, and package-boundary coverage is retained. - Independent clean-context P0–P3 source review found no actionable findings. The repository Auto Review CLI was also attempted but could not authenticate; no successful CLI review is claimed. AI-assisted implementation and review. Maintainer approval remains required; no merge or automatic repair authority is inferred from the issue labels. --- ## Maintainer addendum — September 14, 2026 The ownership choices proposed above are accepted. This addendum records the final shared legacy-data owner, the preserved durable runtime default, and the refreshed proof. Earlier evidence remains tied to its stated revision. ### Problem Memory search finds an agent's file, but `memory_get` returns the parent's different file as success. ### Fix and impact Search and explicit memory reads now share one lightweight legacy-data owner. The two existing cached facts stay with the agent owner. Raw reader behavior, optional IDs, workspace pins, home/profile handling, and extra paths remain supported. No schema, migration, config key, protocol, or dependency changes. Owner decision: explicit-roster reads must return the searched workspace's file, never a different parent file. This ends the explicit-roster exception retained in #140984. To retain the parent as an agent's workspace, configure that workspace explicitly. Legacy data ownership remains separate from the durable runtime default, preserving #146246. Production growth is reduced from 46 to 38 net lines: - `agent-roster.ts` moves existing roster readers into a lightweight module and owns the shared data decision. - `agent-scope-config.ts` shrinks by 96 lines while preserving public exports and both cache lifetimes. - Memory-host `config-utils.ts` adds eight net lines to preserve raw-reader compatibility and use the shared owner for explicit inputs. - `openclaw-runtime-paths.ts` adds the one export needed by that call. ### Evidence - Main `5576f256da61f4708ed59ada7604702a18d8e0fc`: the three unpinned regression rows fail with `status: ok` and `text: Parent decoy`; the pinned control passes. Command: `node scripts/run-vitest.mjs extensions/memory-core/src/tools.real-manager.test.ts -t 'reads the indexed agent file with explicit ownership'`. - Retained HTTP proof at accepted `a016f35b265a96d4cdfd5d43dbf12d461ae417d2` (the rebuilt branch has identical owner files): real Gateway `POST /tools/invoke`, search then get, covers both roster orders, a non-first system agent, explicit pins, and parent traversal. Eight reads return the known agent file bytes; eight traversals are rejected. - Fresh merge `f48cf5fc4eb0e717f252fefde7929632f24d494a`, parents candidate above and main `f6d984fcbef0f00cdeee4737d70ababb869f5162`: 297 tests pass, one existing skip, across the owner, memory, session/auth, and Doctor suites below. - Local production/test type checks, changed-file type-aware lint, formatting, architecture, unused-export, line-count, and assertion checks pass. The assertion allowance only shrinks. - Retained 2026.9.3-created state proof preserves pins, file hashes, and runtime default through Doctor/restart. This proves state compatibility, not the installed update driver. - Earlier local matrix replay was stopped; its historical failures remain recorded. Current exact-head CI run [34806299349](https://github.com/openclaw/openclaw/actions/runs/34806299349) completed successfully at `1c3602c201d65ed43e45c4c1c856fe4fcc696dc8`, with every executed job passing. <details> <summary>HTTP requests and fresh-merge test command</summary> The isolated Gateway runs through `pnpm openclaw gateway run --port <isolated-port> --bind loopback`. ```json {"agentId":"main","tool":"memory_search","args":{"query":"AGENT_MAIN_ORCHID","corpus":"memory"}} {"agentId":"main","tool":"memory_get","args":{"path":"USER.md","from":1,"lines":3}} {"agentId":"main","tool":"memory_get","args":{"path":"../USER.md","from":1,"lines":2}} ``` The search-returned path and line range drive the read. The read returns two lines: `# main`, followed by `AGENT_MAIN_ORCHID searched source`. Traversal returns `MEMORY_PATH_NOT_ALLOWED`. ```sh node scripts/run-vitest.mjs \ packages/memory-host-sdk/src/host/config-utils.test.ts \ packages/memory-host-sdk/src/host/read-file.test.ts \ packages/memory-host-sdk/src/host/read-file-manager-compat.test.ts \ extensions/memory-core/src/tools.real-manager.test.ts \ src/agents/agent-scope-config.test.ts \ src/agents/legacy-inherited-auth-dir.test.ts \ src/plugins/contracts/extension-package-project-boundaries.test.ts \ src/config/legacy.roster.test.ts \ src/commands/sessions.default-agent-store.test.ts \ src/commands/doctor/shared/legacy-config-migrations.agent-rosters.test.ts \ src/commands/doctor/shared/legacy-config-migrations.runtime.system-agent.test.ts \ src/commands/doctor/shared/default-agent-role-materialization.test.ts \ src/commands/doctor/shared/default-agent-role-materialization.write.test.ts \ src/commands/doctor-config-flow.workspace-persistence.test.ts \ src/agents/agent-scope.test.ts \ src/agents/agent-scope.workspace-inference.test.ts ``` </details> ## Consumers The moved roster types retain their `index`, `key`, and `kind` fields. The following typed read sites preserve their source-location contracts; generic word matches elsewhere are not consumers of these fields. <details> <summary>Preserved roster-field callers</summary> census: generic index reviewed — 19 callers listed - `src/agents/sandbox/secret-owner.ts:53:42` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-model-validation.ts:117:90`, `src/cli/config-model-validation.ts:221:62` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:90`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:90` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:85:35` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:90`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:90` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:993:71`, `src/config/io.write-prepare.ts:1000:41` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/validation-core.ts:159:36`, `src/config/validation-core.ts:281:90`, `src/config/validation-core.ts:335:55` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:90` — Attach heartbeat target validation issues to the correct authored agent path. - `src/secrets/runtime-config-collectors-core.ts:536:35` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:90` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:90` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:50:36` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:49:40` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. census: generic key reviewed — 18 callers listed - `src/agents/sandbox/secret-owner.ts:52:45` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-model-validation.ts:117:60`, `src/cli/config-model-validation.ts:221:42` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:60`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:60` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:84:38` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:60`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:60` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:1001:44` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/validation-core.ts:158:39`, `src/config/validation-core.ts:281:60`, `src/config/validation-core.ts:334:58` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:60` — Attach heartbeat target validation issues to the correct authored agent path. - `src/secrets/runtime-config-collectors-core.ts:535:38` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:60` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:60` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:46:44` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:46:41` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. census: generic kind reviewed — 64 callers listed - `src/agents/agent-roster.ts:23:15`, `src/agents/agent-roster.ts:35:15` — Select the raw representation before projecting entries; preserve entries precedence and reject invalid representation values. - `src/agents/agent-scope-config.ts:281:15`, `src/agents/agent-scope-config.ts:294:15`, `src/agents/agent-scope-config.ts:329:15`, `src/agents/agent-scope-config.ts:334:15`, `src/agents/agent-scope-config.ts:316:47` — Preserve direct and mutable roster lookup branches; source.kind in the batch index preserves keyed clone-on-read and legacy list identity. - `src/agents/sandbox/secret-owner.ts:51:25` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-cli-roster.ts:17:21`, `src/cli/config-cli-roster.ts:35:55`, `src/cli/config-cli-roster.ts:53:19`, `src/cli/config-cli-roster.ts:58:17`, `src/cli/config-cli-roster.ts:90:22`, `src/cli/config-cli-roster.ts:107:38` — Preserve list order and keyed/list path translation across CLI mutations and canonicalization. - `src/cli/config-model-validation.ts:117:14`, `src/cli/config-model-validation.ts:220:14`, `src/cli/config-model-validation.ts:221:14` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor-config-flow.ts:255:45` — Read migrated keyed entries to persist the legacy workspace and stamp explicit ownership for multiple agents. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:14`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:14` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:83:16` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/legacy-config-core-migrate.ts:30:41`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:35:25`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:45:19`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:46:20`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:108:107` — Validate representation/value agreement, repair the selected roster in its existing shape, and name that shape in repair messages. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:14`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:14` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:892:14`, `src/config/io.write-prepare.ts:951:20`, `src/config/io.write-prepare.ts:1146:15`, `src/config/io.write-prepare.ts:1177:25`, `src/config/io.write-prepare.ts:1185:26`, `src/config/io.write-prepare.ts:1218:23`, `src/config/io.write-prepare.ts:1233:23`, `src/config/io.write-prepare.ts:1255:25`, `src/config/io.write-prepare.ts:1269:23`, `src/config/io.write-prepare.ts:1287:21`, `src/config/io.write-prepare.ts:1330:23`, `src/config/io.write-prepare.ts:1352:21`, `src/config/io.write-prepare.ts:1354:21`, `src/config/io.write-prepare.ts:1450:23`, `src/config/io.write-prepare.ts:1455:27`, `src/config/io.write-prepare.ts:1467:42`, `src/config/io.write-prepare.ts:1532:72`, `src/config/io.write-prepare.ts:1546:23`, `src/config/io.write-prepare.ts:1551:25`, `src/config/io.write-prepare.ts:993:25`, `src/config/io.write-prepare.ts:999:22` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/legacy.roster.ts:106:23`, `src/config/legacy.roster.ts:117:35` — Select legacy list conversion, then consume the keyed roster after migration. - `src/config/validation-core.ts:157:12`, `src/config/validation-core.ts:281:14`, `src/config/validation-core.ts:333:34` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:14` — Attach heartbeat target validation issues to the correct authored agent path. - `src/gateway/server-methods/config.ts:528:15`, `src/gateway/server-methods/config.ts:531:15` — Enumerate explicitly authored agent IDs in either representation before rejecting unapproved removals. - `src/plugins/provider-auth-choice-helpers.ts:304:52`, `src/plugins/provider-auth-choice-helpers.ts:306:52` — Write normalized agent model references back using the original keyed or list representation. - `src/secrets/runtime-config-collectors-core.ts:534:16` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:14` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:14` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:45:21` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:45:19` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. </details> Registered memory tools use the shared data owner for explicit workspace reads. Search manager lookup, forget/reset/backfill, session/auth data locations, and Doctor materialization retain their existing owner contracts. There is no new state writer; config-identity provenance and the separate data/runtime batch facts keep their existing lifetimes. ### Contributor-branch refresh The accepted content is rebuilt on the original contributor head `be5a589a0ee148b54c51f6876ef5281ee9b29cb5`, followed by a plain merge of main `ae5a4b4a55526a32edbc6d865af66e4a4f7dd25b` and the five maintainer commits in order. There were no conflicts or manual resolutions, and all five messages are unchanged. The resulting head `1c3602c201d65ed43e45c4c1c856fe4fcc696dc8` has the same complete tree as the accepted revision merged with that main. The 16-file command above passed again on this head: 297 tests, one existing skip, exit 0. The unchanged local preflight passed on this same head in a physical checkout with its own dependencies. It covered type-aware lint, production types, core/extension/script/root-test types, and protocol checks. The initial nested-checkout attempt failed only the declaration-input isolation guard; physical isolation resolved it without disabling any check. Co-authored-by: Ayaan Zaidi <[email protected]>
…w#147072) Closes openclaw#146939. Related: openclaw#140984. ## What Problem This Solves Fixes `memory_get` returning a different file from `memory_search` when an explicitly owned multi-agent roster relies on inherited workspace paths. ## User Impact Search results and subsequent reads agree on the agent's workspace without requiring a per-agent workspace pin. Explicit workspace overrides remain authoritative. No files move, no index reset or storage migration is required, and Markdown containment and read limits are unchanged. For explicitly owned rosters, an unpinned first agent no longer implicitly reads the parent workspace merely because it appears first. A valid retained migration owner and sole-agent inheritance still follow canonical behavior. Raw reader inputs without explicit ownership keep their existing legacy behavior. ## Why This Change Was Made The prior path repair in openclaw#140984 deliberately deferred workspace-ownership alignment. This PR proposes only that bounded alignment: core and explicitly owned memory-host reads share the compatibility-owner decision through a pure internal helper. The existing private path bridge avoids importing the full agent runtime. The original config object is preserved for retained migration-owner lookup; optional legacy reader IDs remain accepted. ### Maintainer choices — proposed, not previously approved 1. **Accept explicit-roster alignment (recommended and implemented).** Search's canonical workspace ownership is authoritative for reads too. Alternatively, retain the mismatch and require explicit workspace pins; this PR does not silently change search to match the old getter. 2. **Preserve legacy reader compatibility (implemented).** Inputs without `ownership: "explicit"` retain first-agent/default-marker inheritance. Broader normalization of those inputs is intentionally deferred, rather than changing the shipped reader contract in this fix. 3. **Keep adjacent policy out of scope (recommended).** No context-limit merging changes, shared-system-agent workspace redesign, public SDK entrypoint, or broader path allowlist. Those require separate decisions. ClawSweeper's source review supports this direction but requests a compatibility decision; it is not maintainer approval. Please review the ownership choice before merge. Rollback is reverting this change; the issue's explicit-workspace-pin mitigation remains available. ## Evidence ### After-fix real Gateway proof — September 13, 2026 Built candidate `be5a589a0ee148b54c51f6876ef5281ee9b29cb5`, Node 26.8.1/macOS. Used a loopback-only Gateway, registered Memory Core tools through HTTP `POST /tools/invoke`, synthetic files and real on-disk SQLite state, `provider: none`, and vectors disabled. No test-helper imports, provider calls, or production configuration/state changes. | Setup | Actual search → get result | | --- | --- | | Fresh explicit two-agent roster, neither agent pinned; parent contains a decoy | main: `USER.md`, `status=ok`, `Orchid proof main`; other: `USER.md`, `status=ok`, `Orchid proof other` | | Fresh setup, parent traversal for each agent | `MEMORY_PATH_NOT_ALLOWED` | | Installed 2026.9.3, existing explicit workspace pins | main/other: `USER.md`, `status=ok`, matching `Orchid upgrade main` / `Orchid upgrade other` | | Same shipped-created state after candidate Doctor migration and candidate Gateway startup | Both agents return those same markers with `status=ok` | For each agent, passed the search result's path/start line/inclusive line count into `memory_get`. Stopped the shipped Gateway before switching binaries. Candidate initially refused the older session-identity database; followed its supported `doctor --fix --non-interactive` instruction (exit 0, both agent databases v19→v20), then repeated the actual HTTP flow. Both existing workspace pins were preserved exactly, and SHA-256 checks showed all three synthetic `USER.md` files unchanged. Doctor did change normal config metadata/defaults; the whole config was **not** unchanged. All proof Gateways were stopped. This is fresh-runtime and shipped-created-state/Doctor migration proof, **not** an installer, `openclaw update` driver, or live-user upgrade test. Retained legacy-owner shapes beyond these fixtures remain covered by focused tests, not claimed as live proof. The schema migration belongs to the candidate's existing upgrade path; this six-file patch introduces no schema or embedding-metadata changes. Maintainer acceptance of explicit-roster read-root alignment remains required. CI at this evidence update: the model-login catalog timing case in [large-26](https://github.com/openclaw/openclaw/actions/runs/34761804381/job/103735936253) failed, making the aggregate gate red. Its fixture disables memory and uses one pinned agent without explicit ownership; likely unrelated, but no matching base failure was verified. No CI pass is claimed. - Focused validation: 162 tests passed across six files (one existing skipped test), including the real-manager tool regression and package-boundary contracts. - Final-head `node scripts/check-changed.mjs` passed: core and test types, core/extension lint, formatting, dead-export scans, package/SDK boundaries, and runtime import-cycle checks. `git diff --check` passed. - Full `pnpm build` passed in 3m26s, including plugin SDK exports, CLI bootstrap imports, built plugin-loading checks, and Control UI build. After that build, the only patch change moved an unchanged re-export below imports for lint; the rebase added only unrelated ACP tests. The repository-wide test suite was not run. - Tests-first reproduction on upstream main: both roster orders returned the parent decoy through `memory_get` after real SQLite-backed `memory_search` found the agent marker. - The regression exercises both agents, both roster orders, returned path/line readback, and rejection of parent traversal. It uses temporary files and databases with embeddings disabled; no provider request or private installation data. - Compatibility coverage includes explicit workspace overrides, retained/removed migration owners, ignored legacy markers under explicit ownership, optional legacy IDs, sole/duplicate agents, and absent/empty rosters. Existing legacy path, file-reader, core ownership, and package-boundary coverage is retained. - Independent clean-context P0–P3 source review found no actionable findings. The repository Auto Review CLI was also attempted but could not authenticate; no successful CLI review is claimed. AI-assisted implementation and review. Maintainer approval remains required; no merge or automatic repair authority is inferred from the issue labels. --- ## Maintainer addendum — September 14, 2026 The ownership choices proposed above are accepted. This addendum records the final shared legacy-data owner, the preserved durable runtime default, and the refreshed proof. Earlier evidence remains tied to its stated revision. ### Problem Memory search finds an agent's file, but `memory_get` returns the parent's different file as success. ### Fix and impact Search and explicit memory reads now share one lightweight legacy-data owner. The two existing cached facts stay with the agent owner. Raw reader behavior, optional IDs, workspace pins, home/profile handling, and extra paths remain supported. No schema, migration, config key, protocol, or dependency changes. Owner decision: explicit-roster reads must return the searched workspace's file, never a different parent file. This ends the explicit-roster exception retained in openclaw#140984. To retain the parent as an agent's workspace, configure that workspace explicitly. Legacy data ownership remains separate from the durable runtime default, preserving openclaw#146246. Production growth is reduced from 46 to 38 net lines: - `agent-roster.ts` moves existing roster readers into a lightweight module and owns the shared data decision. - `agent-scope-config.ts` shrinks by 96 lines while preserving public exports and both cache lifetimes. - Memory-host `config-utils.ts` adds eight net lines to preserve raw-reader compatibility and use the shared owner for explicit inputs. - `openclaw-runtime-paths.ts` adds the one export needed by that call. ### Evidence - Main `8751fab4903de6356beacef93401ad0e5f99ea02`: the three unpinned regression rows fail with `status: ok` and `text: Parent decoy`; the pinned control passes. Command: `node scripts/run-vitest.mjs extensions/memory-core/src/tools.real-manager.test.ts -t 'reads the indexed agent file with explicit ownership'`. - Retained HTTP proof at accepted `a016f35b265a96d4cdfd5d43dbf12d461ae417d2` (the rebuilt branch has identical owner files): real Gateway `POST /tools/invoke`, search then get, covers both roster orders, a non-first system agent, explicit pins, and parent traversal. Eight reads return the known agent file bytes; eight traversals are rejected. - Fresh merge `f48cf5fc4eb0e717f252fefde7929632f24d494a`, parents candidate above and main `51084d8c93db2a51a7a1aa9b6e1935f78bd0162d`: 297 tests pass, one existing skip, across the owner, memory, session/auth, and Doctor suites below. - Local production/test type checks, changed-file type-aware lint, formatting, architecture, unused-export, line-count, and assertion checks pass. The assertion allowance only shrinks. - Retained 2026.9.3-created state proof preserves pins, file hashes, and runtime default through Doctor/restart. This proves state compatibility, not the installed update driver. - Earlier local matrix replay was stopped; its historical failures remain recorded. Current exact-head CI run [34806299349](https://github.com/openclaw/openclaw/actions/runs/34806299349) completed successfully at `1c3602c201d65ed43e45c4c1c856fe4fcc696dc8`, with every executed job passing. <details> <summary>HTTP requests and fresh-merge test command</summary> The isolated Gateway runs through `pnpm openclaw gateway run --port <isolated-port> --bind loopback`. ```json {"agentId":"main","tool":"memory_search","args":{"query":"AGENT_MAIN_ORCHID","corpus":"memory"}} {"agentId":"main","tool":"memory_get","args":{"path":"USER.md","from":1,"lines":3}} {"agentId":"main","tool":"memory_get","args":{"path":"../USER.md","from":1,"lines":2}} ``` The search-returned path and line range drive the read. The read returns two lines: `# main`, followed by `AGENT_MAIN_ORCHID searched source`. Traversal returns `MEMORY_PATH_NOT_ALLOWED`. ```sh node scripts/run-vitest.mjs \ packages/memory-host-sdk/src/host/config-utils.test.ts \ packages/memory-host-sdk/src/host/read-file.test.ts \ packages/memory-host-sdk/src/host/read-file-manager-compat.test.ts \ extensions/memory-core/src/tools.real-manager.test.ts \ src/agents/agent-scope-config.test.ts \ src/agents/legacy-inherited-auth-dir.test.ts \ src/plugins/contracts/extension-package-project-boundaries.test.ts \ src/config/legacy.roster.test.ts \ src/commands/sessions.default-agent-store.test.ts \ src/commands/doctor/shared/legacy-config-migrations.agent-rosters.test.ts \ src/commands/doctor/shared/legacy-config-migrations.runtime.system-agent.test.ts \ src/commands/doctor/shared/default-agent-role-materialization.test.ts \ src/commands/doctor/shared/default-agent-role-materialization.write.test.ts \ src/commands/doctor-config-flow.workspace-persistence.test.ts \ src/agents/agent-scope.test.ts \ src/agents/agent-scope.workspace-inference.test.ts ``` </details> ## Consumers The moved roster types retain their `index`, `key`, and `kind` fields. The following typed read sites preserve their source-location contracts; generic word matches elsewhere are not consumers of these fields. <details> <summary>Preserved roster-field callers</summary> census: generic index reviewed — 19 callers listed - `src/agents/sandbox/secret-owner.ts:53:42` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-model-validation.ts:117:90`, `src/cli/config-model-validation.ts:221:62` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:90`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:90` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:85:35` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:90`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:90` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:993:71`, `src/config/io.write-prepare.ts:1000:41` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/validation-core.ts:159:36`, `src/config/validation-core.ts:281:90`, `src/config/validation-core.ts:335:55` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:90` — Attach heartbeat target validation issues to the correct authored agent path. - `src/secrets/runtime-config-collectors-core.ts:536:35` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:90` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:90` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:50:36` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:49:40` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. census: generic key reviewed — 18 callers listed - `src/agents/sandbox/secret-owner.ts:52:45` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-model-validation.ts:117:60`, `src/cli/config-model-validation.ts:221:42` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:60`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:60` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:84:38` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:60`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:60` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:1001:44` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/validation-core.ts:158:39`, `src/config/validation-core.ts:281:60`, `src/config/validation-core.ts:334:58` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:60` — Attach heartbeat target validation issues to the correct authored agent path. - `src/secrets/runtime-config-collectors-core.ts:535:38` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:60` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:60` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:46:44` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:46:41` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. census: generic kind reviewed — 64 callers listed - `src/agents/agent-roster.ts:23:15`, `src/agents/agent-roster.ts:35:15` — Select the raw representation before projecting entries; preserve entries precedence and reject invalid representation values. - `src/agents/agent-scope-config.ts:281:15`, `src/agents/agent-scope-config.ts:294:15`, `src/agents/agent-scope-config.ts:329:15`, `src/agents/agent-scope-config.ts:334:15`, `src/agents/agent-scope-config.ts:316:47` — Preserve direct and mutable roster lookup branches; source.kind in the batch index preserves keyed clone-on-read and legacy list identity. - `src/agents/sandbox/secret-owner.ts:51:25` — Report unresolved SSH secret references at the selected agent source path. - `src/cli/config-cli-roster.ts:17:21`, `src/cli/config-cli-roster.ts:35:55`, `src/cli/config-cli-roster.ts:53:19`, `src/cli/config-cli-roster.ts:58:17`, `src/cli/config-cli-roster.ts:90:22`, `src/cli/config-cli-roster.ts:107:38` — Preserve list order and keyed/list path translation across CLI mutations and canonicalization. - `src/cli/config-model-validation.ts:117:14`, `src/cli/config-model-validation.ts:220:14`, `src/cli/config-model-validation.ts:221:14` — Locate model validation issues and test whether edited paths change model ownership at the correct keyed entry or list index. - `src/commands/doctor-config-flow.ts:255:45` — Read migrated keyed entries to persist the legacy workspace and stamp explicit ownership for multiple agents. - `src/commands/doctor/shared/context-engine-host-compat.ts:113:14`, `src/commands/doctor/shared/context-engine-host-compat.ts:153:14` — Locate context-engine host compatibility warnings and repairs at the source agent path. - `src/commands/doctor/shared/exec-safe-bins.ts:83:16` — Locate executable allowlist warnings at the source agent tools.exec path. - `src/commands/doctor/shared/legacy-config-core-migrate.ts:30:41`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:35:25`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:45:19`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:46:20`, `src/commands/doctor/shared/legacy-config-core-migrate.ts:108:107` — Validate representation/value agreement, repair the selected roster in its existing shape, and name that shape in repair messages. - `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:91:14`, `src/commands/doctor/shared/plugin-tool-allowlist-warnings.ts:293:14` — Locate plugin tool allowlist warnings at the source agent path. - `src/config/io.write-prepare.ts:892:14`, `src/config/io.write-prepare.ts:951:20`, `src/config/io.write-prepare.ts:1146:15`, `src/config/io.write-prepare.ts:1177:25`, `src/config/io.write-prepare.ts:1185:26`, `src/config/io.write-prepare.ts:1218:23`, `src/config/io.write-prepare.ts:1233:23`, `src/config/io.write-prepare.ts:1255:25`, `src/config/io.write-prepare.ts:1269:23`, `src/config/io.write-prepare.ts:1287:21`, `src/config/io.write-prepare.ts:1330:23`, `src/config/io.write-prepare.ts:1352:21`, `src/config/io.write-prepare.ts:1354:21`, `src/config/io.write-prepare.ts:1450:23`, `src/config/io.write-prepare.ts:1455:27`, `src/config/io.write-prepare.ts:1467:42`, `src/config/io.write-prepare.ts:1532:72`, `src/config/io.write-prepare.ts:1546:23`, `src/config/io.write-prepare.ts:1551:25`, `src/config/io.write-prepare.ts:993:25`, `src/config/io.write-prepare.ts:999:22` — Preserve original roster representation, legacy occurrence identity, explicit writes/deletions, authored reference restoration, and source paths across config writes. - `src/config/legacy.roster.ts:106:23`, `src/config/legacy.roster.ts:117:35` — Select legacy list conversion, then consume the keyed roster after migration. - `src/config/validation-core.ts:157:12`, `src/config/validation-core.ts:281:14`, `src/config/validation-core.ts:333:34` — Locate avatar, model-policy, and sandbox environment errors at the authored keyed entry or original list index. - `src/config/validation.ts:715:14` — Attach heartbeat target validation issues to the correct authored agent path. - `src/gateway/server-methods/config.ts:528:15`, `src/gateway/server-methods/config.ts:531:15` — Enumerate explicitly authored agent IDs in either representation before rejecting unapproved removals. - `src/plugins/provider-auth-choice-helpers.ts:304:52`, `src/plugins/provider-auth-choice-helpers.ts:306:52` — Write normalized agent model references back using the original keyed or list representation. - `src/secrets/runtime-config-collectors-core.ts:534:16` — Locate agent text-to-speech secret assignments at the source agent path. - `src/secrets/runtime-config-collectors-memory.ts:125:14` — Locate memory secret assignments at the source agent path; the separate unchanged implicit-agent producer supplies the legacy key when no roster exists. - `src/secrets/runtime-config-collectors-sandbox.ts:75:14` — Carry the source agent path into sandbox secret collection candidates. - `src/security/dangerous-config-flags-core.ts:45:21` — Report dangerous flags at canonical keyed paths when an ID exists; retain original list index for an ID-less legacy row. - `src/skills/workshop/tool-policy-diagnostic.ts:45:19` — Report canonical keyed tool-policy paths when an ID exists; retain original list index for an ID-less legacy row. </details> Registered memory tools use the shared data owner for explicit workspace reads. Search manager lookup, forget/reset/backfill, session/auth data locations, and Doctor materialization retain their existing owner contracts. There is no new state writer; config-identity provenance and the separate data/runtime batch facts keep their existing lifetimes. ### Contributor-branch refresh The accepted content is rebuilt on the original contributor head `be5a589a0ee148b54c51f6876ef5281ee9b29cb5`, followed by a plain merge of main `76352103416b7c8c567c8397154af0764ce249fe` and the five maintainer commits in order. There were no conflicts or manual resolutions, and all five messages are unchanged. The resulting head `1c3602c201d65ed43e45c4c1c856fe4fcc696dc8` has the same complete tree as the accepted revision merged with that main. The 16-file command above passed again on this head: 297 tests, one existing skip, exit 0. The unchanged local preflight passed on this same head in a physical checkout with its own dependencies. It covered type-aware lint, production types, core/extension/script/root-test types, and protocol checks. The initial nested-checkout attempt failed only the declaration-input isolation guard; physical isolation resolved it without disabling any check. Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #146195
Refs #146216
Reported by @lilei0311 (#146195).
Additional instructions
This branch is in the upstream repository and maintainers can update it.
What Problem This Solves
Fixes an issue where users who migrated a legacy multi-agent roster lost their identifiable default agent after restart.
openclaw agents list --jsonreturnedisDefault: falsefor every agent, breaking integrations that use that field to select an agent. The Control UI also treated an ownerless fallback row as default and its Set Default action still wrote retired entry markers.Why This Change Was Made
Explicit-roster compatibility selection accepts only the existing
agents.defaults.systemAgent.agentIddesignation recorded by migration and verifies roster membership. Missing or blank designations never fall back to process-only migration provenance or retired default markers. CLI listing, unscoped session listing, Gateway identity and main aliases, and the Control UI use that recorded owner. The UI honorsselectionRequiredand Set Default persists the canonical designation with explicit ownership, removing retired markers.Runtime defaults and legacy data ownership remain separate. Changing the runtime default does not relocate workspaces, inherited credentials, or legacy session data. The migration WeakMap remains necessary when the original data owner differs from an authored system agent, and for explicitly supplied CLI agent selection during state migration. Doctor consumes that legacy-data context directly; it cannot designate a runtime default. Strict SDK/session APIs retain their existing explicit-context and legacy-data contract. No configuration fields, dependencies, schemas, protocol versions, or storage retention/recovery semantics change.
This PR supersedes related contributor PR #146216, which restores discovery through a listing-only helper. This PR follows the shared-owner contract across runtime consumers while preserving strict SDK and data-location semantics separately. Its implementation and regression coverage were developed independently; no code or tests were adopted from #146216.
User Impact
After the multi-agent roster migration, the migrated default agent stays the default across restarts. An explicit fleet without a designation has no default, and Doctor explains how to set one. Explicit targets, bindings, and persisted session-store owners retain precedence; auth copying still requires its existing confirmation.
Evidence
Landing validation
Approved head:
be5bbd46c9afc079dbe38fb8136fa94296964a25. Maintainer round-4 review is scoped-clean, including the retained legacy-data owner versus runtime-default regression. After the main-side Control UI startup-budget refresh in #147116, the PR was reopened without changing its source head. The refreshed merge ref includes2700b9e34e6f79afba980dac67508af4c6eb707e; its first parent matched current main at refresh and its second parent matched the approved head. Both the branch tip and PR-head ref agree.CI run 34767412613 completed successfully: 130 successful jobs, 10 intentional skips, no failures. The Control UI performance check and HTML-preview e2e passed without a rerun. The earlier failed runs below are historical. Full local changed-file gates and the 79-test final owner/sibling proof also passed. Native review artifacts are validated for this head.
Retained ACP data ownership correction
Lead round-3 review found that the ACP legacy-key fallback could bind existing legacy metadata to the runtime default instead of its retained migration owner. With explicit agents
opsandresearch, retained legacy ownerops, runtime defaultresearch, and no persisted session-store owner, the reader incorrectly admitted the legacy row forresearchand excludedopseven when both lookups matched its lifecycle.The fallback now uses
tryResolveLegacyDataOwnerAgentId. That existing owner already falls back to fleet cardinality throughtryResolveSoleAgentId, preserving sole-agent reads without consulting the runtime default. Persisted-owner precedence, retired-owner rejection, lifecycle fencing, lazy lookup for qualified keys, and reads without rekeying remain intact.The regression
batch-loads legacy bare metadata without rekeying during a read (retained owner)was run before the production change on exact headd0cb3dfa71564fc050c1de940272eb6c7624e5e7:The extended table checks both single and batch readers with the same lifecycle data for the competing owners, rejects stale lifecycle metadata, and verifies that the bare database key is retained. All 79 tests across four touched/sibling files passed without skips:
Current correction head:
be5bbd46c9afc079dbe38fb8136fa94296964a25. The fullnode scripts/check-changed.mjsgate passed (exit 0), as didgit diff --check. The single independent P1 autoreview is scoped-clean with no actionable findings. Lint initially caught the test file three lines over its limit; simplifying the fixture setup preserved every assertion, and the complete metadata suite passed all 20 tests afterward. No limit or baseline changed. Exact-head CI run 34765629705 completed with failure: 128 jobs succeeded, 10 were skipped, and the only underlying failure was control-ui-performance, plus the aggregate gate. Startup JavaScript measured 355,780 bytes gzip against a 355,719-byte enforcement limit, 61 bytes over. This round changes only the ACP metadata owner and its regression test; no UI budget was changed. Both checks-ui-e2e (2/7) and checks-node-compact-large-10 passed. No zero-step cancellation or Count-flake rerun was needed. The branch tip andrefs/pull/146246/headboth match this head, without an empty refresh commit. Maintainer round-4 review has since approved this head; current landing validation is recorded above.Fixed-store hook and ACP legacy-row corrections
Rebased reviewed head
6e351fd078572450f364a577f97540bb668dd859onto mainfc90e572a51411021d9e28e856b17b00573bffb4. Before the corrections, all 20 previously reviewed production-file deltas were identical. The rebase retained both the owner-routing cases and main's process-memory assertions.Omitted hook targets now use the persisted fixed global-store owner even when the runtime default differs. Explicitly conflicting targets still fail, and hook admission checks the effective owner's allowlist. ACP legacy-row selection now uses the existing operation-owner resolver after persisted-owner checks, so a sole explicit agent can read its existing lifecycle-matching legacy row. Single and batch reads retain the same lifecycle fence and do not rekey data. The unreachable empty encoded-key branch was removed.
The original synthetic caller probe is retained as
probe-callers-fixed-store.logand reproduced here:Regression tests were run against exact old production head
6e351fd0785: the HTTP hook returned 400 instead of 200 andowner-conflictinstead of the expected allowlist rejection; the sole-agent ACP reader returned no metadata instead oflegacy-global. The existing control rows passed. The new cases are:routes omitted hook targets by the persisted owner and its allowlist (allowed: %s)batch-loads legacy bare metadata without rekeying during a read (%s owner)(newsolerow)The hook owner helper also covers omitted request and mapping targets with a differing runtime default. After correction, the six touched/sibling suites passed 124 tests without skips; after moving the HTTP regression into the existing session-mode suite to respect the file line limit, both complete HTTP suites passed all 33 tests. No assertions or limits were weakened.
The initial correction head
6bb9eacbf013258f7698dc3f5e168b72a4196d44passed the full changed-file gate and the single independent P1 autoreview. Its exact-head CI run 34762476604 completed with failure inchecks-node-compact-large-10:session-utils.perf.test.ts:193reported 300 roster reads against its 270-read bound. This was reproduced locally, while the rebased parent2a9f6df448fpassed, establishing attribution to the ACP correction.The follow-up keeps the same legacy-key behavior but defers owner resolution until the existing qualified-key and agent checks actually require it. Already agent-qualified keys no longer incur an unnecessary roster traversal. The unchanged performance suite passes all 21 tests, and both complete ACP suites pass all 25 tests. No test limit, assertion, or baseline changed. This small follow-up is after the single P1 review and is included in the head awaiting lead re-review.
Previous correction head:
d0cb3dfa71564fc050c1de940272eb6c7624e5e7. The fullnode scripts/check-changed.mjsgate passed again (exit 0) after the lookup fix, including typechecks, lint, unchanged ratchets, export scans, storage guards, and zero runtime import cycles.git diff --checkpassed. Exact-head CI run 34763508210 completed with failure: 128 jobs succeeded, 10 were skipped, and the UI shard plus aggregate gate failed. The repaired checks-node-compact-large-10 passed. The sole underlying failure is checks-ui-e2e (2/7),chat-html-preview.e2e.test.ts:168, “renders HTML with scripts and retains Source in the same file tab”: after clicking Count, output was0rather than1. That shard passed on the preceding run; the only subsequent source delta is the ACP lookup condition. No UI test was changed or rerun. No zero-step cancellation or BuildFailed placeholder occurred. This PR remains open for lead re-review of the current head; prepare-run and merge-run were not invoked.Doctor config-flow headroom
Merged
origin/mainata2705294146into the shared branch with merge commit8e597f36878f8524a20f4144e94cb9ed96689ffb, without rebasing or conflicts. This includes the main-side Control UI budget fix.The core lint command reproduced the exact failure after the merge:
The repair at
af3184ea4e82b9de9ec281eb837963111b2d0387moves hook-config warning collection and emission into the existingdoctor-config-analysis.tsowner. Config-flow retains one call at the same point before compatibility normalization, using the samestate.cfgand snapshot path. Warning text, grouping, ordering, sanitization, and config mutations are unchanged. The flow now has 651 counted lines, leaving 49 lines of headroom. No suppression or baseline was edited for this repair.The transform-path warning test moved beside the analysis owner; the malformed internal-hook test still runs the complete Doctor flow and invokes the real extracted helper. Independent read-only review found no actionable issues.
Validation passed: 745 tests across 13 files, with one existing skip, including the 11 caller suites listed below plus both Doctor suites. Tests ran separately per owning Vitest project. The full changed-file gate and focused core lint passed:
The authored cap repair, excluding the upstream merge, changes two production files (
+57/-57) and two test files (+32/-25). Exact-head CI: completed successfully with 158 passing checks, 32 skipped checks, and zero failures or pending checks (run 34725497943).Key final job states:
All remaining selected checks are successful or intentionally skipped. No inherited failure remains in this run. The PR is not merged.
The retained-provenance regression was reproduced on reviewed head
88234667b0259c6d1be3c7115a3ad81dc976e4b9before the correction:After the correction, 648 tests pass across 23 focused owner/sibling files, with 2 existing skips and 121 unrelated migration tests excluded by the targeted filter. The four failing boundaries now pass. CLI parser coverage verifies that explicit migration
--agentremains a data owner while runtime default resolution stays undefined. The real state-migration test preserves both configured-system-agent and retained-context targets. Without the migration consumer's direct data-owner read, that preservation test failed with a deferred-migration warning; it passes with the correction. TUI and Gateway presentation distinguish pre-explicit legacy ownership from an explicit fleet with provenance but no designation.Commands use
node scripts/run-vitest.mjs <file>for agent scope, listing, sessions, Doctor analysis/flow/workspace persistence, CLI preaction, legacy auth, strict session APIs, roster and session-target migration, setup/add, Gateway listing/identity/HTTP/main aliases, routing, TUI, and the SDK. The migration boundary command is:The defect was reproduced before changing production code using an isolated synthetic legacy roster. Doctor persisted explicit ownership and
systemAgent.agentId: "main"; a separate CLI process reported both agents as non-default. The repaired code reads that same saved config correctly. The fresh legacy-to-canonical migration and ownerless-roster CLI proofs were rerun after the retained-provenance correction and passed:Both processes used isolated
OPENCLAW_STATE_DIR,OPENCLAW_CONFIG_PATH, andOPENCLAW_HOMEvalues. A separate ownerless explicit roster reports no defaults and prints Doctor's designation hint. Listing preserves the saved config bytes, explicit ownership, and absence of retired markers.Prior full proof: 661 focused tests passed, with 2 existing skips across 23 files. Owner/sibling coverage includes agent scope, legacy auth/data ownership, roster migration, Doctor flow and persistence, agent listing/add/setup, session-store selection, routing, Gateway identity/bootstrap/status, TUI, and the strict SDK contract. Tests use
node scripts/run-vitest.mjs <file>separately per owner. The browser command was:Regression evidence includes:
The original-tree failures and later tests with the designation-reading hunk removed both failed for the intended reasons. Restoring identical production bytes made the tests pass. Static requests still avoid workspace identity reads; bootstrap reads the designated identity workspace.
The full
node scripts/check-changed.mjsgate was rerun after the retained-provenance correction and passed. This covers typechecking, lint, i18n/style checks, dead exports, runtime import cycles, and storage guards. The supported CLI wrapper rebuilt runtime artifacts successfully; the browser harness built and exercised the actual Control UI.git diff --checkpassed.CI found a strict SDK regression in the first head; the unchanged guard now passes after preserving strict selection at its owner. Later CI expectations that treated a configured designation as ownerless were updated with positive recorded-owner coverage and retained missing-owner safeguards. An initial Windows file-replacement failure in unchanged managed-handoff SQLite code did not recur on the following run (initial job).
No published updater-driver campaign was run. The maintainer-reviewed production change and the landing fixup are scoped-clean at P1; the preserved-auth locator change follows secops ownership routing.
Landing fixup validation
Exact-head CI and review exposed sole-agent ambient and Gateway session regressions plus five fixtures that still treated migration provenance or an explicit sole roster as a default designation. The shared ambient resolver preserves its documented sole-agent fallback, matching its throwing counterpart. The existing Gateway session-owner helper also preserves sole-agent selection after persisted ownership and the recorded default; bare-key canonicalization consumes that same owner. Default-agent compatibility selection still requires the canonical designation in explicit fleets. The fixtures now record their intended default, and session creation, logical keys, and transcript writes retain explicit tests rejecting provenance-only selection.
The new ambient-owner regression failed on
f809970db9df882ab9e3d7f6bb252444cbc3837cwithexpected undefined to be 'solo'; both unchanged sole-agent heartbeat tests failed as well. All pass with the one-line owner correction. Replacing only the resolver with its pre-correction88234667b0259c6d1be3c7115a3ad81dc976e4b9bytes made the new provenance-only session test fail withexpected function to throw an error, but it didn't. Restoring the candidate source made all 23 session-resolution tests pass.Focused proof passes 469 distinct tests across seven files:
The registered
chat.injectregression failed before the Gateway correction withexpected false to be true; the sole-agent bare-key regression threwAGENT_SELECTION_REQUIRED. Both now pass. The full Gateway proof passes 493 tests across three files:Targeted changed-file gates and
git diff --checkpassed. Independent autoreviews of both fixups are scoped-clean at P1, including test-strength review. CI's earlier cleanup subprocess timeout did not recur:checks-node-compact-small-16passed on53f47d7d4b79853e84330a708b8431c2a21a6afc. Full CI passed on53f47d7d4b79853e84330a708b8431c2a21a6afcin run 34716139349. The subsequent caller-repair section records exact-head CI for the combined Gateway fix and caller repair.Caller repair validation
The caller repair at
e9a7395119bfe35d3a283c90b55d00e9d97508f8keeps sole-agent operation selection separate from durable default designation. CLI Gateway dispatch, hook dispatch, and outbound binding selection now call the existing shared operation owner with the complete config, includingagents.ownership. Omitted targets use the roster-validated compatibility owner or the sole agent. Explicit fleets cannot recover a default from migration provenance or retired markers, and non-explicit fleets do not promotesystemAgent.agentIdinto their legacy default.The supplied patch applied cleanly to
4ec5124b13621376acc463eeb2a726263b8a46c4. Review replaced its three consumer-local default-or-sole expressions with the shared owner. The owner now validates omitted-target designations through the canonical resolver rather than independently readingsystemAgent. Channel login/logout tests retain discovery/auth refusal for missing and stale designations through the canonical selection error. The supplied hook mock-helper consolidation preserves one-shot versus persistent behavior and keeps the test file within its existing line limit.Failing-before proof on
4ec5124b13621376acc463eeb2a726263b8a46c4:After the owner/caller correction, 633 tests passed across 11 files, with one existing skip. Commands were run separately to select each owning Vitest project:
The full changed-file gate passed on the final source, including core/test/UI typechecks, lint, unchanged baselines, export scans, storage guards, and import-cycle checks. The first lint run caught the hook test file two lines over its limit; the supplied helper consolidation removed duplicate setup without suppressions. The complete server-hook suite and the full gate passed afterward.
git diff --checkpassed.This delta changes four production files (
+11/-12) and six test files (+203/-123). Exact-head CI: completed with failure (run 34723279516).The exact-head run tested merge
cb52e6979bcd58afe789ccc71d54c3fbb595c0c8against main9717a7635a0ee83167568038e2c123943968e19d. Three non-aggregate checks failed:plugins-platform: 702 test roots exceeds the 700 limit. Read-only inventory of the main commit confirms 702 roots; this branch has 694, and the PR changes none of that shard's source/config inputs. This is a main-side failure.src/commands/doctor-config-flow.tsreaches 702 counted lines against 700 in the merge with current main. The PR's earlier Doctor hint contributes an import and a call; this caller commit does not change that file. The combined PR/main file needs a small structural reduction.The watcher returned its failing verdict, and a subsequent exact-run read confirmed
status=completed,conclusion=failure, and heade9a7395119bfe35d3a283c90b55d00e9d97508f8. No baseline, limit, suppression, or unrelated main code was changed. Those results are historical; the current main merge and successful Doctor headroom validation are recorded above.ClawSweeper review
Applied the confirmed global main-session protection finding: explicitly selecting the sole agent no longer classifies its global session as a non-default target. The registered
sessions.deleteregression reached lifecycle cleanup before the correction; after it, the request is rejected before abort, MCP cleanup, browser cleanup, or entry deletion. Applied the narrower ACP diagnostics finding: sole-agent global-session metadata reads now use the existing operation owner after explicit and persisted-owner checks.Skipped the transcript-persistence P1 claim: the inspected production writers carry an explicit agent owner, and no attributable user-facing failure was established. The previously suggested pending-delivery notice reproduction fails earlier in unchanged transcript code, so it does not prove this regression. Transcript ownership semantics remain unchanged. The additional published-updater campaign remains an expressly skipped validation gap for this maintainer-directed landing.
Both applied repairs reuse the shared operation owner; default designation remains separate. Before the fix, the new ACP case threw
AGENT_SELECTION_REQUIREDand the deletion case reached cleanup rather than the main-session protection error. After the fix, all 33 tests in these suites passed:The deletion test checks that the stored entry remains unchanged and active work, MCP state, and browser tabs are not cleaned up. Existing tests preserve retired/conflicting owner rejection and non-default global-session deletion. Independent autoreview of the fixup is scoped-clean at P1. The targeted changed-file gate and
git diff --checkpassed. Exact-head CI is required for fixupbe9f04768347c3ee66e7160dc2df6bafd1611974before landing.Visual proof
These captures contain only synthetic mock-Gateway data; the fixture version footer is not a release claim.