Skip to content

fix(update): preserve migrated default agent across restarts - #146246

Merged
steipete merged 14 commits into
mainfrom
steipete/upd-default-agent-after-explicit-ownership
Sep 13, 2026
Merged

steipete merged 14 commits into
mainfrom
steipete/upd-default-agent-after-explicit-ownership

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

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 --json returned isDefault: false for 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.agentId designation 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 honors selectionRequired and 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 includes 2700b9e34e6f79afba980dac67508af4c6eb707e; 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 ops and research, retained legacy owner ops, runtime default research, and no persisted session-store owner, the reader incorrectly admitted the legacy row for research and excluded ops even when both lookups matched its lifecycle.

The fallback now uses tryResolveLegacyDataOwnerAgentId. That existing owner already falls back to fleet cardinality through tryResolveSoleAgentId, 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 head d0cb3dfa71564fc050c1de940272eb6c7624e5e7:

Requested owners: [ops, research]
Expected: [legacy-global, undefined]
Received: [undefined, legacy-global]
Persisted-owner and sole-agent controls: passed

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:

node scripts/run-vitest.mjs src/acp/runtime/session-meta.test.ts src/acp/runtime/session-meta-store.test.ts src/agents/agent-scope-config.test.ts src/gateway/session-utils.perf.test.ts

Current correction head: be5bbd46c9afc079dbe38fb8136fa94296964a25. The full node scripts/check-changed.mjs gate passed (exit 0), as did git 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 and refs/pull/146246/head both 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 6e351fd078572450f364a577f97540bb668dd859 onto main fc90e572a51411021d9e28e856b17b00573bffb4. 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.log and reproduced here:

omitted-hook-target={"ok":false,"code":"owner-conflict","agentId":"research","ownerAgentId":"ops","error":"agentId \"research\" conflicts with global session-store owner \"ops\"; use agentId \"ops\" or update agents.defaults.sessionStore.agentId"}
explicit-persisted-owner={"ok":true,"selectedAgentId":"ops","effectiveAgentId":"ops"}
sole-agent-legacy-single=null
sole-agent-legacy-batch=null
legacy-unqualified-control="legacy-global"
persisted-owner-control="legacy-global"
retained-rows=[{"session_key":"global","session_id":"ops-revision"}]

Regression tests were run against exact old production head 6e351fd0785: the HTTP hook returned 400 instead of 200 and owner-conflict instead of the expected allowlist rejection; the sole-agent ACP reader returned no metadata instead of legacy-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) (new sole row)

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 6bb9eacbf013258f7698dc3f5e168b72a4196d44 passed the full changed-file gate and the single independent P1 autoreview. Its exact-head CI run 34762476604 completed with failure in checks-node-compact-large-10: session-utils.perf.test.ts:193 reported 300 roster reads against its 270-read bound. This was reproduced locally, while the rebased parent 2a9f6df448f passed, 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 full node scripts/check-changed.mjs gate passed again (exit 0) after the lookup fix, including typechecks, lint, unchanged ratchets, export scans, storage guards, and zero runtime import cycles. git diff --check passed. 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 was 0 rather than 1. 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/main at a2705294146 into the shared branch with merge commit 8e597f36878f8524a20f4144e94cb9ed96689ffb, without rebasing or conflicts. This includes the main-side Control UI budget fix.

The core lint command reproduced the exact failure after the merge:

node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/commands/doctor-config-flow.ts
src/commands/doctor-config-flow.ts:757:2: error eslint(max-lines): File has too many lines (702). help: Maximum allowed is 700.

The repair at af3184ea4e82b9de9ec281eb837963111b2d0387 moves hook-config warning collection and emission into the existing doctor-config-analysis.ts owner. Config-flow retains one call at the same point before compatibility normalization, using the same state.cfg and 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:

node scripts/run-vitest.mjs src/commands/doctor-config-flow.test.ts
node scripts/run-vitest.mjs src/commands/doctor-config-analysis.test.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/commands/doctor-config-flow.ts src/commands/doctor-config-analysis.ts
node scripts/check-changed.mjs
node scripts/watch-pr-ci.mjs 146246 af3184ea4e82b9de9ec281eb837963111b2d0387

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 88234667b0259c6d1be3c7115a3ad81dc976e4b9 before the correction:

explicit ownership + retained owner + no systemAgent designation
resolver: expected undefined, received ops
agents list: expected isDefault=false, received true
unscoped sessions: promise resolved instead of requiring agent selection
Doctor: expected designation hint, received zero notices

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 --agent remains 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:

node scripts/run-vitest.mjs src/infra/state-migrations.test.ts -t 'leaves legacy files for Doctor repair|uses the retained migration owner|keeps unresolved legacy agent files'

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:

pnpm openclaw doctor --fix --non-interactive
pnpm openclaw agents list --json
before: main isDefault=false, research isDefault=false
after:  main isDefault=true,  research isDefault=false

Both processes used isolated OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, and OPENCLAW_HOME values. 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:

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agents-set-default-persistence.e2e.test.ts

Regression evidence includes:

Before: migrated main/research expected isDefault=true, received false.
Before: recorded-owner session listing threw AgentSelectionRequiredError.
Before: Gateway identity used first entry ops instead of designated research.
Before: public main aliases rejected a recorded default.
Before: ownerless UI menu had 1 default badge; Set Default wrote entries.*.default.
After: those assertions pass; ownerless and qualified-agent guard cases remain.

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.mjs gate 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 --check passed.

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 f809970db9df882ab9e3d7f6bb252444cbc3837c with expected 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-correction 88234667b0259c6d1be3c7115a3ad81dc976e4b9 bytes made the new provenance-only session test fail with expected 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:

node scripts/run-vitest.mjs src/agents/agent-scope-config.test.ts src/infra/heartbeat-agent-resolution.test.ts src/gateway/server-cron.test.ts
node scripts/run-vitest.mjs src/agents/command/session.resolve-session-key.test.ts
node scripts/run-vitest.mjs src/gateway/health/collector.channel-discovery.test.ts src/gateway/session-utils.test.ts src/gateway/server-cron.test.ts
node scripts/run-vitest.mjs src/config/sessions/session-accessor.transcript-owner.test.ts

The registered chat.inject regression failed before the Gateway correction with expected false to be true; the sole-agent bare-key regression threw AGENT_SELECTION_REQUIRED. Both now pass. The full Gateway proof passes 493 tests across three files:

node scripts/run-vitest.mjs src/gateway/session-request-agent.test.ts src/gateway/session-utils.test.ts src/gateway/server-methods/chat.directive-tags.test.ts

Targeted changed-file gates and git diff --check passed. 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-16 passed on 53f47d7d4b79853e84330a708b8431c2a21a6afc. Full CI passed on 53f47d7d4b79853e84330a708b8431c2a21a6afc in 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 e9a7395119bfe35d3a283c90b55d00e9d97508f8 keeps 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, including agents.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 promote systemAgent.agentId into 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 reading systemAgent. 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:

CLI explicit sole agent: AGENT_SELECTION_REQUIRED, agentIds=[solo]
Hook explicit sole agent: expected 400 to be 200
Outbound sole-agent account: expected null to be alerts
Stale operation designation: expected deleted to be undefined

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:

node scripts/run-vitest.mjs src/agents/agent-scope-config.test.ts
node scripts/run-vitest.mjs src/commands/agent-via-gateway.test.ts
node scripts/run-vitest.mjs src/gateway/hooks.test.ts
node scripts/run-vitest.mjs src/gateway/server.hooks.test.ts
node scripts/run-vitest.mjs src/routing/bindings.test.ts
node scripts/run-vitest.mjs src/cli/capability-cli/shared.test.ts
node scripts/run-vitest.mjs src/cli/channel-auth.owner.integration.test.ts
node scripts/run-vitest.mjs src/gateway/session-request-agent.test.ts
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts
node scripts/run-vitest.mjs src/commands/channels.add.test.ts
node scripts/run-vitest.mjs src/commands/channels.list.test.ts
node scripts/check-changed.mjs

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 --check passed.

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 cb52e6979bcd58afe789ccc71d54c3fbb595c0c8 against main 9717a7635a0ee83167568038e2c123943968e19d. Three non-aggregate checks failed:

  • checks-node-compact-small-21: 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.
  • control-ui-performance: startup JavaScript is 355,165 bytes gzip against the 355,116-byte enforcement limit. This caller commit changes no UI files; attribution within the combined PR/main UI needs a separate headroom repair.
  • check-lint-core-1: src/commands/doctor-config-flow.ts reaches 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 head e9a7395119bfe35d3a283c90b55d00e9d97508f8. 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.delete regression 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_REQUIRED and the deletion case reached cleanup rather than the main-session protection error. After the fix, all 33 tests in these suites passed:

node scripts/run-vitest.mjs src/acp/runtime/session-meta-store.test.ts src/gateway/server.sessions.delete-lifecycle.test.ts

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 --check passed. Exact-head CI is required for fixup be9f04768347c3ee66e7160dc2df6bafd1611974 before landing.

Visual proof

These captures contain only synthetic mock-Gateway data; the fixture version footer is not a release claim.

Before: an ownerless fleet incorrectly badges Main as Default

After: an ownerless fleet has no default badge

After: the recorded Research designation owns the default badge

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 12, 2026 17:23
@steipete
steipete requested a review from a team as a code owner September 12, 2026 17:23
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 12:33 PM ET / 16:33 UTC (Revision 23).

ClawSweeper review

What this changes

Preserves the saved default agent across CLI, Gateway, and Control UI operations while separating runtime selection from legacy data ownership.

Regression provenance

Possible 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
Reviewed head: be5bbd46c9afc079dbe38fb8136fa94296964a25

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong restart evidence and extensive caller coverage support the fix, but the retained Doctor import defect blocks correctness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The matching captured PR body records real isolated Doctor migration and separate-process CLI listing, demonstrating the saved default survives restart. This supports the changed agent-selection owner; it does not resolve the separate Doctor import finding. Relevant badge images could not be reinspected through the available media paths.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The matching captured PR body records real isolated Doctor migration and separate-process CLI listing, demonstrating the saved default survives restart. This supports the changed agent-selection owner; it does not resolve the separate Doctor import finding. Relevant badge images could not be reinspected through the available media paths.
Evidence reviewed 9 items Introduced resolver change: The introduced delta makes explicit-roster compatibility selection require systemAgent.agentId, while the separate legacy-data resolver retains sole-agent and migration-provenance ownership.
Remaining Doctor import defect: Doctor's all-agent discovery creates state-root legacy targets with sqlitePath at lines 318–330. Their unqualified rows reach this filter, which still calls the runtime-default resolver. An explicit sole-agent roster without a designation therefore excludes those rows. Archive coverage retains their original files.
Public Doctor caller: The normal Doctor transcript migration invokes runDoctorSessionSqlite with allAgents:true and import mode during repair, establishing a production caller for the affected filter.
Findings 1 actionable finding [P2] Preserve sole-agent ownership in Doctor's legacy import filter
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

  • Preserve sole-agent ownership in Doctor's legacy import filter (P2) - The previous blocker remains. With agents: { ownership: "explicit", entries: { ops: {} } }, no saved system/session-store owner, and an unqualified row in state-root sessions/sessions.json, Doctor's all-agent import creates a target with sqlitePath and reaches this filter. This PR makes tryResolveLegacyCompatibilityAgentId return undefined for that configuration, so the row is skipped instead of imported under ops. Use tryResolveLegacyDataOwnerAgentId here and cover the public all-agent import boundary; the original files remain retained.
  • Resolve merge risk (P1) - The successful restart proof does not cover all-agent import of unqualified legacy rows for an explicit sole-agent roster; those sessions can remain unavailable in SQLite.
  • Complete next step (P2) - Change Doctor's legacy import filter to use legacy-data ownership and add a failing-before all-agent import regression for an explicit sole agent without a saved default.

Findings

  • [P2] Preserve sole-agent ownership in Doctor's legacy import filter — src/commands/doctor-session-sqlite.ts:788-794
Agent review details

Security

None.

PR surface

Source +37, Tests +648, Docs +32. Total +717 across 59 files.

View PR surface stats
Area Files Added Removed Net
Source 22 172 135 +37
Tests 33 1100 452 +648
Docs 4 39 7 +32
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 59 1311 594 +717

Review metrics

Metric Value Why it matters
Production versus regression coverage Net production +37 lines; tests +648 lines Production growth separates runtime and legacy-data ownership; most growth covers affected callers and migration regressions.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-config-analysis.ts, migration/backfill/repair: src/commands/doctor-config-flow.ts, unknown-data-model-change: src/commands/doctor-config-analysis.ts, unknown-data-model-change: src/commands/doctor-config-flow.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146195
Summary: This PR is an open candidate for the reported migration/default-discovery defect; the listing-only proposal overlaps but does not replace this broader fix.

Members:

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

Merge-risk options

Maintainer options:

  1. Finish the legacy-data owner cutover (recommended)
    Use the legacy-data resolver in Doctor's import filter and verify sole-agent import through the public all-agent boundary.

Technical review

Best 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:

  • [P2] Preserve sole-agent ownership in Doctor's legacy import filter — src/commands/doctor-session-sqlite.ts:788-794
    The previous blocker remains. With agents: { ownership: "explicit", entries: { ops: {} } }, no saved system/session-store owner, and an unqualified row in state-root sessions/sessions.json, Doctor's all-agent import creates a target with sqlitePath and reaches this filter. This PR makes tryResolveLegacyCompatibilityAgentId return undefined for that configuration, so the row is skipped instead of imported under ops. Use tryResolveLegacyDataOwnerAgentId here and cover the public all-agent import boundary; the original files remain retained.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs default-agent discovery after migration, with one bounded legacy-session import defect remaining.
  • merge-risk: 🚨 session-state: The changed resolver leaves Doctor's unqualified legacy-row filter without a sole-agent owner, skipping session imports.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The matching captured PR body records real isolated Doctor migration and separate-process CLI listing, demonstrating the saved default survives restart. This supports the changed agent-selection owner; it does not resolve the separate Doctor import finding. Relevant badge images could not be reinspected through the available media paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The matching captured PR body records real isolated Doctor migration and separate-process CLI listing, demonstrating the saved default survives restart. This supports the changed agent-selection owner; it does not resolve the separate Doctor import finding. Relevant badge images could not be reinspected through the available media paths.

Evidence

What I checked:

  • Introduced resolver change: The introduced delta makes explicit-roster compatibility selection require systemAgent.agentId, while the separate legacy-data resolver retains sole-agent and migration-provenance ownership. (src/agents/agent-scope-config.ts:284, be5bbd46c9af)
  • Remaining Doctor import defect: Doctor's all-agent discovery creates state-root legacy targets with sqlitePath at lines 318–330. Their unqualified rows reach this filter, which still calls the runtime-default resolver. An explicit sole-agent roster without a designation therefore excludes those rows. Archive coverage retains their original files. (src/commands/doctor-session-sqlite.ts:791, be5bbd46c9af)
  • Public Doctor caller: The normal Doctor transcript migration invokes runDoctorSessionSqlite with allAgents:true and import mode during repair, establishing a production caller for the affected filter. (src/commands/doctor-session-transcripts.ts:259, be5bbd46c9af)
  • Review continuity: The completed previous review identified the same Doctor import blocker. Both relevant files are unchanged from that reviewed head; this is a retained finding, not a new late discovery. (src/commands/doctor-session-sqlite.ts:791, be5bbd46c9af)
  • Current-main necessity: Fetched main still resolves compatibility ownership from retained provenance or legacy/sole-agent selection, without reading the persisted explicit default designation. (src/agents/agent-scope-config.ts:266, ab59bcfbef61)
  • Latest release remains affected: The v2026.9.4 source also lacks the persisted-default lookup. REST source inspection succeeded after the local release blob was unavailable. (src/agents/agent-scope-config.ts, 3a9d69db306c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • leochun92-sudo: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve sole-agent legacy-row import and add a failing-before regression through Doctor's all-agent import boundary.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-13T02:40:56.661Z sha 76b8513 :: blocked before merge. :: [P1] [P1] Preserve the fixed-store owner when a hook omits its target
  • reviewed 2026-09-13T13:16:25.610Z sha 6e351fd :: blocked before merge. :: [P1] [P1] Preserve the fixed-store owner when a hook omits its target | [P2] [P2] Preserve sole-agent lookup of legacy ACP metadata
  • reviewed 2026-09-13T14:32:04.045Z sha 6bb9eac :: blocked before merge. :: [P2] [P2] Preserve sole-agent ownership in Doctor's legacy import filter
  • reviewed 2026-09-13T14:51:31.399Z sha d0cb3df :: blocked before merge. :: [P2] [P2] Preserve sole-agent ownership in Doctor's legacy import filter
  • reviewed 2026-09-13T15:07:49.594Z sha d0cb3df :: blocked before merge. :: [P2] [P2] Preserve sole-agent ownership in Doctor's legacy import filter
  • reviewed 2026-09-13T15:36:02.342Z sha be5bbd4 :: blocked before merge. :: [P2] [P2] Preserve sole-agent ownership in Doctor's legacy import filter
  • reviewed 2026-09-13T15:56:41.242Z sha be5bbd4 :: blocked before merge. :: [P2] [P2] Preserve sole-agent ownership in Doctor's legacy import filter
  • reviewed 2026-09-13T16:10:09.611Z sha be5bbd4 :: blocked before merge. :: [P2] Preserve sole-agent ownership in Doctor's legacy import filter

@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 12, 2026
steipete added a commit that referenced this pull request Sep 12, 2026
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.
@steipete steipete reopened this Sep 13, 2026
@steipete
steipete merged commit 0517701 into main Sep 13, 2026
390 of 393 checks passed
@steipete
steipete deleted the steipete/upd-default-agent-after-explicit-ownership branch September 13, 2026 16:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…#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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…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.
obviyus added a commit that referenced this pull request Sep 14, 2026
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

1 participant