Repository navigation
refactor(agents): make multi-agent ownership explicit (H2-1 core) - #114388
Conversation
9e39e7c to
1d64c4a
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 6:09 PM ET / 22:09 UTC. ClawSweeper reviewWhat this changesReplaces implicit multi-agent default selection with explicit ownership, migration, and agent-scoped routing across config, sessions, Gateway, task runtime, UI, and plugin discovery. Merge readinessKeep open: this is maintainer-owned, protected ownership work, and current main still selects an omitted agent through the persisted default marker. The local checkout cannot load the exact PR head, so no exact-head merge verdict is safe. Priority: P1 Review scores
Verification
How this fits togetherAgent selection begins with configuration and legacy roster migration, then feeds Gateway/session/task routing and user interfaces. The change makes ownership explicit before those consumers read or mutate agent-scoped state. flowchart LR
A[Config and legacy roster] --> B[Ownership resolution]
B --> C[Doctor migration]
B --> D[Gateway and session routing]
B --> E[Task runtime]
D --> F[UI and channel requests]
E --> G[Agent-scoped task results]
Decision needed
Why: The PR changes compatibility-sensitive ownership and invokes Codex-related behavior, but this reviewer cannot load the current head or sibling Codex source. Before merge
Findings
Agent review detailsSecurityNeeds attention: No concrete vulnerability was established, but the exact-head security-sensitive ownership and Codex CLI changes could not be inspected. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Review the exact current head after its objects and the relevant Codex source are available; retain a single explicit ownership resolver with Doctor-owned migration for released configurations. Do we have a high-confidence way to reproduce the issue? No high-confidence runtime reproduction was run. Current main source does show that omitted agent selection resolves through the default marker or first roster entry. Is this the best way to solve the issue? Unclear: explicit ownership is consistent with the preceding merged groundwork, but the exact implementation cannot be compared with current main while the PR head is unavailable. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5bcbbcf6fdd9. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (102 earlier review cycles; latest 8 shown)
|
1f039ea to
b840ee9
Compare
Related: #112678
Related: #113637
What Problem This Solves
Resolves a problem where multi-agent installations persisted an ambient
default: truemarker and then inferred that agent across sessions, channels, automation, and authorization paths. After roster changes or restart, that implicit default could select the wrong agent, lose a legacy owner, or allow colliding bare session keys such asglobalto be attributed to the requester instead of their durable owner.Why This Change Was Made
The final design removes the stored default marker and uses sole-agent-or-explicit selection. A write-once
agents.ownership: "explicit"stamp records intentional roster ownership, while a load-time WeakMap sidecar retains the legacy owner only as migration evidence and compatibility input.Before retiring the marker, compatibility ownership is materialized into the surfaces that need durable identity: channel bindings, heartbeat, system-agent and Talk settings, auth inheritance, and the configured fixed session store. Fixed-store rows follow the persisted owner contract (
configured,retired, ornone); configured ownership is authoritative, retired ownership fails closed, and authorization surfaces reject conflicting explicit agents.The same ownership ladder now covers Gateway, CLI/TUI, session aliases and IDs, task runtimes, active runs, broadcasts, transcript lookup, and migration/recovery paths. Plugin discovery uses the config-wide manifest registry. Gateway protocol additions (
ownershipandselectionRequired) remain additive, and Doctor owns the shipped config/data migrations.User Impact
Single-agent installations continue to select their sole agent without extra configuration. Multi-agent installations now receive an actionable explicit-selection response instead of silently adopting a default or another agent's session/task state. Existing installations retain and durably materialize their legacy owner during migration, including bare fixed-store sessions, while conflicting and ownerless authorization requests fail closed.
Operators also get Doctor repairs for marker retirement, fixed-store ownership, heartbeat cadence, and startup-owned cron rows. Remote clients can consume the additive ownership metadata without breaking older protocol consumers.
Evidence
376669573fa853faff8352d8777a0ece94d65493: full pull-request CI green in run 31647212132, including production tsgo,check:test-types, lint, security/CodeQL, Plugin SDK API baseline, UI/E2E, iOS, and changed test shards.node scripts/check-changed.mjsgreen on Testbox run 31335091251.pnpm tsgo:all && pnpm check:test-types && pnpm buildgreen on Testbox run 31336280194.src/tasks/task-owner-access.test.tsandsrc/plugins/runtime/runtime-tasks.test.ts.tbx_01kzvyf8dx3dmxcac08v85pvwk, run 31643290834, generated the finalinfra-runtimecontract hash; the exact-head Linux baseline gate then passed.61e8f70f246fecbf29628574b0a78fb3eb4047bcclean. Subsequent changes were a conflict-free source replay onto currentmainplus generated Plugin SDK baseline reconciliation only.ClawSweeper rank-up moves and maintainer dispositions:
agentIdis threaded from tool context and explicit task-session bindings; agent-scoped keys retain their encoded owner, and agentless bare bindings fail closed. A paired-agentglobalregression covers get, list, resolve, and cancel.