Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR requires recorded subagent ownership and incarnation checks across registration, cancellation, recovery, cleanup, and session watches. Example: Both main and research have a child session named global, and an older run has no recorded child owner.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain This PR addresses an ownership defect still present on main and stable, but two prior regressions remain unresolved. The latest change addresses the stale-Stop error-precedence finding. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherAgent tools and Gateway admission register delegated work; the subagent registry carries ownership into continuation, cancellation, completion, and SQLite cleanup, while session-state workers manage watches. flowchart TD
A[Agent tools and Gateway admission] --> B[Subagent registry]
B --> C[Recorded child authority]
C --> D[Resume and cancellation]
C --> E[Completion and cleanup]
B --> F[SQLite workers]
A --> G[Session state watches]
Technical reviewBest possible solution: Complete owner-aware continuation and preserve the tool-output contract while retaining the recorded-authority safeguards. Do we have a high-confidence way to reproduce the issue? Source establishes permissive ownership matching on main and v2026.10.2 and deterministically exposes both remaining regressions; this read-only review executed no target code. Is this the best way to solve the issue? Recorded ownership addresses the root cause, but tightening shared lookup requires coordinated continuation callers and preservation of existing output contracts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9514dbad63fc. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Legacy Stop requires final-effect authority verification; no concrete authorization bypass or supply-chain regression was established. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 12, 2026, 10:05 AM ET / 14:05 UTC (Revision 9). |
Children carry a recorded requester-owned identity; ownership checks use a closed tri-state (verified, legacy-unverified, mismatch). Legacy runs settle, deliver, and stay stoppable by their authorized requester while child-session mutation stays suppressed; real identity conflicts fail closed. Squashed onto current main (pre-squash head e464670) to drop replay-only conflicts with main's chat-leaf and async beforeSessionKill refactors.
Revalidate the original typed Stop leaf after a cancellation failure so stale child-session preparation cannot mask active-leaf-changed. Preserve ownership errors for an unchanged leaf and keep child mutation fences intact. Add an unchanged-leaf ownership negative control and document the precedence. Refs #167966, #169659.
Move the visible-spawn corrected-call formatter beside its parameter schema and name the recorded child target shared by spawn cleanup and registration.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* fix(agents): require recorded subagent ownership Children carry a recorded requester-owned identity; ownership checks use a closed tri-state (verified, legacy-unverified, mismatch). Legacy runs settle, deliver, and stay stoppable by their authorized requester while child-session mutation stays suppressed; real identity conflicts fail closed. Squashed onto current main (pre-squash head e464670) to drop replay-only conflicts with main's chat-leaf and async beforeSessionKill refactors. * fix(gateway): preserve typed Stop leaf error precedence Revalidate the original typed Stop leaf after a cancellation failure so stale child-session preparation cannot mask active-leaf-changed. Preserve ownership errors for an unchanged leaf and keep child mutation fences intact. Add an unchanged-leaf ownership negative control and document the precedence. Refs openclaw#167966, openclaw#169659. * refactor(agents): keep spawn owners under their line caps Move the visible-spawn corrected-call formatter beside its parameter schema and name the recorded child target shared by spawn cleanup and registration.
…absorb: step 71 openclaw#167966 "require recorded subagent ownership", isolated as its own step (262 files, 16 conflicts). Registration now requires an explicit child agent and the child's original sessionId; new runs record childAgentId and childSessionIdentity in payload_json (no DDL or version bump); ownership checks are verified / legacy-unverified / mismatch, and legacy-unverified runs keep settling and delivering with child-session effects suppressed. Conflicts (ours kept, upstream's change ported where the fork moved code): - subagent-spawn.ts / fork subagent-spawn-rollback.ts: accepted-spawn cleanup passes the recorded child target; cleanupAcceptedSubagentSpawn Failure takes childAgentId for attachment cleanup. - subagent-announce.ts: continuation return paths kept; childSessionIdentity added to the fork's subagent-announce.types.ts; our later stats-line read passes childAgentId. - subagent-announce.runtime.ts: async readSubagentSessionEntry owner-resolved as upstream, next to our continuation spawn helpers. - lifecycle-announce-cleanup: deletes against the recorded identity and only when the current session verifies (upstream), keeping our dispatch-time deleteCleanupDispatchedAt fence. - registry-restore: rollback-custody skip kept before upstream's legacy-unverified queued-collector settle. - registry-run-launch: imports only (upstream's prepared registration rows and generation candidates merged cleanly beside our ownership return). - sweep-cleanup: upstream's freezeSessionIdentity now returns the recorded identity, so deleteSweptSession reads the current session through loadSubagentSessionEntry to keep the reset-successor guard; the delete's isCurrent takes upstream's sweep assertCurrent. - sweeper: upstream's orderSubagentSweepEntries; its collector-group changes (mismatch/identity filter, bound deleteSession) ported into the fork's subagent-registry-sweep-collector-groups.ts. - session-cleanup: owner-resolved childAgentId guard ahead of our continuation cleanup guards. - announce tests: upstream's importOriginal-spread mocks with our continuation keys (the mock-isolation annotations and their baseline rows go, as upstream's did); fixture identities ported into the fork's resume and restore-retry test-support files; the follow-up adoption case is upstream's extracted registerPluginSubagentFollowupAdoptionCase. Fork overlay on the other 35 both-touched files unchanged (interdiff). Follow-on repairs the focused sweep found (every red rerun at 5bb035b first: context-cleanup 11/11, completion-authority 64/64, sweeper-recovery 52/52 green there, so all were ours): - deleteSweptSession is upstream's again (sweep-cleanup = upstream bytes). Our pre-read stopped the CAS delete whenever the live session differed from the frozen identity; with openclaw#167966 the identity is the recorded one and upstream requires the delete to dispatch anyway ("archives only the recorded owner and original incarnation of a raw child"). The continuation guard it served moves to the point of effect: failStagedPostCompactionDelegatesForCleanup takes an owner check, read only when a staged record exists, so a reset successor keeps its staged post-compaction delegate and the delete's CAS reports the change. - deleteSubagentSessionForCleanup reports a cleanup owner that is no longer current as "failed" with onError, as upstream's dispatch check does (new registration-ownership contract), instead of the fork's early "changed"; the fork unit test follows. - Fork fixtures register with the now-required childAgentId + original sessionEntry (H1 spawn/post-compaction acceptance custody, launch-dispatch custody, rollback/partial-ownership/resume/spawn-rollback suites); the stale-orphan cases keep a real child key (an empty key now resolves no owner); the continuation-return persistence case registers the sessionId it writes; rejection-write's logger mock gains child() (upstream's execution cleanup now loads diagnostics); dead resolveAgentIdFromSessionKey mocks go. The stale-orphan cases now reach restart recovery, so they use upstream's createMockGatewayRecoveryRuntime() instead of an empty runtime object; the fork cleanup and durable-2 suites expect the agentId upstream's sessions.delete request now carries; the context-read test drops the hookTrigger input (derived from opts, below). - Line cap: upstream's growth pushed subagent-registry.ts (702->704), sweeper-recovery.test.ts and persistence.test.ts over base. The armed-resume sweep wake moves into deferArmedSubagentResume (697); the fork's reset-sibling delegate case moves to the fork sibling subagent-registry-sweeper-recovery.orphan-collector.test.ts (the upstream suite is upstream bytes again); the continuation-return case moves to subagent-registry.persistence.continuation-return.test.ts. - agent-runner-run.ts max-lines (703 since step 61, upstream 726 raw / under cap): executePreparedReplyAgentRun derives hookTrigger from the opts it already receives, and the partial-reply observer is destructured (699). - command-queue.ts line cap (702 at base, 703 since step 61; upstream under cap): the lane-idle waiter is re-exported from its module (702 again). - Worker inventory regenerated. tsgo core 0, all 32 core test-shard graphs 0. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d identity subagent-registry.archive.continuation.e2e "keeps the session while authoritative custody is live even when the projection is clear" has been red since step 71 (scribe report at a9a0a2f; 3/3 green at dab29d6). Upstream openclaw#167966 made the archive sweep delete a child session only for a recorded child incarnation: freezeSessionIdentity needs a verified childSessionIdentity, and without one the run is legacy-unverified, session cleanup is suppressed, and the authoritative custody check the case asserts on never runs (0 calls). The fixture now records the identity, as upstream did for its own archive tests. No assertion changes. Also, as upstream's suites do since openclaw#169714 (which this lane absorbs next), the fork cases in sessions-sharing, openclaw-agent-participants-migration and session-reset-cleanup publish the runtime config first inside their withOpenClawTestState fixture. At this tree getRuntimeConfig() still cold-loads, so they are unchanged here; after openclaw#169714 it reads only the published snapshot. Proof at 1cd793c + this commit and the next: 53 files (owner path, recipient authority, both named suites), 54 executed / 770 tests, 0 failed, 0 skipped, 0 missing; archive.continuation 3/3, project84-owned-topology 9/9. tsgo core 0, 32/32 test-shard graphs 0. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
With
main/globalandresearch/global, cancel an ownerless subagent run: wildcard matching and default/requester inference can affect another owner's work. Registration perpetuated ambiguity by accepting missing ownership. These paths trace tobb6041345daand64406536043; owners:src/agents/subagents/registry/subagent-child-owner-match.ts:5andsrc/agents/subagents/registry/subagent-registry-run-launch.ts:123.Send to raw
globalwith watching enabled, then update either agent's session: a key-only cursor cannot distinguish owners, yet reports success. The cursor dates to2bb79d10fd6;3bde3cd0174exposed explicit watches without rejecting ambiguous targets. Validation now belongs tosrc/sessions/session-state-events.watch-address.ts:1.A creation receipt with
runStarted:truebut no session ID promised an undeliverable child.src/agents/tools/sessions-spawn-visible.ts:596now fails visibly. Successful main receipts supply the identity. Registration rejects missing identities, including the blank-ID fork fallback.Collector indexing could hide a collector behind a conflicting-owner row or an older collector's replacement. The single-value index predates this branch (
ccb147518cc); raw-key lookup already passed via64406536043's fallback.src/agents/subagents/registry/subagent-registry-memory.ts:66now preserves owner-qualified membership through registration, replacement, and deletion.Record only a session ID, then replace its session while rotating the lifecycle revision: cancellation incorrectly succeeded. The original-record wildcard was in branch head
c30748c3e75; selected-target and cleanup wildcards predate this branch (fd1467d4669,fdbf48d1383). Strict comparison belongs tosubagent-control-session.ts:77andsubagent-registry-execution-cleanup.ts:121in the registry directory. Recovery and resume also validate the recorded incarnation after awaited work.After restart, retain a persisted sibling outside the resident index, then refuse another registration for its session: cleanup could delete the sibling's session/transcript. The resident-only guard predates this branch (
3f761a822ad, refactored in4bf041c0d1f); K1's durable cohort preparation did not protect cleanup.src/agents/subagents/registry/subagent-registry-run-launch.ts:180now checks resident and prepared durable candidates across ordinary, refused-queued, and committed-queued cleanup. Exhausted cohort conflicts invalidate stale cleanup evidence rather than authorize deletion.Why This Change Was Made
One canonical resolver accepts an explicit child owner or, for historical rows, a valid agent-qualified key. Registration requires
childAgentIdand the original identity. Defaults and requester identity never establish ownership. Registration producers already carry the lifecycle revision; no lookup or backfill was added.Unknown-owner and unknown-incarnation records remain untouched, outside ordinary cleanup. Exact destructive operations return
found:true, killed:falsewith guidance, including beside a newer generation. A one-sided missing revision is unresolved; two absent revisions still match by session ID. Recovery diagnoses retained records. Rollback remains exact-target after a complete drain, with coordinated backups and writable-reopen proof against copies. Unresolved obligations prevent that drain. There is no owner backfill or version fence; broader Doctor diagnostics remain deferred.Main's recorded-owner reconciliation (
027dd4c7cd5) and agent-qualified browser cleanup (9c8ef6ac22e) remain intact. Owned raw children still deliver completion, wake requesters, and finish cleanup. Seven existing tests cover suppressed cleanup, durable-row and attachment retirement, and retention controls; no production change was needed.Production is +993/−473, net +520, nine net lines above Round 13. Growth carries recorded authority across lifecycle boundaries; leaf persistence/store type contracts remove both import cycles. Metadata extraction preserves the restorer's mutation context and authority. No second ownership resolver or durable sidecar was added.
User Impact
Ambiguous operations explain their refusal and preserve evidence. Raw sends remain possible, but proactive watches return
watched:falsewith qualified-target or owner-scoped reconciliation guidance. Incomplete spawns fail visibly. Valid collectors remain authorized, and stale cancellation, cleanup, recovery, or resume cannot acquire a successor incarnation.No protocol, SDK, config or schema changes, including no DDL or schema-version bump. The branch remains two commits; assertions, retries, and timeouts were not weakened.
Evidence
Final local head:
a2d2881307ef56bee184b19e0200145872fcb11f; pinned base:286fff87a2ab66cd9654a7e625e2f72465647f61. Round 14's identity failures were incomplete fixtures, not missing production identities or policy conflicts. Plugin admission already returns the canonical session. Fixture repairs preserve reset/Stop, delivery, race, and resource-retirement assertions.The canonical CI planner selected 1,474 files / 67 rows: 23,091 passed, 3 failed, 7 skipped; 65 rows pass, two retain base-reproduced failures. Forty-one rows ran on final head; 26 unaffected rows reuse fingerprint-verified earlier evidence. No failed result is counted as a pass.
Base comparisons: Actions
38001587838,38014254694; cycles:run_3bae49191ce6910c90666745ed571592; final E2E:run_90cbb2fcd720f2f535f288c3a6832060. Full changed-check:run_503f0ad56a78c4ca642ce8a41b99675f; remaining twelve canonical commands and base guard attribution:run_6d3b3f49b8eb38f91c9b0678f6a87924.The full gate remains red for untouched
agents.ts's direct config import, introduced on base byc26d9db0c62. All remaining checks pass, including dead-export scans with zero findings; earlier inherited dead exports no longer fail. Sandbox prerequisite failures were corrected without source changes. Acquired leases are released; no push or PR mutation.Upgrade path and review notes (rounds 15–18)
resolveSubagentChildAuthority: verified / legacy-unverified / mismatch.childSessionIdentityor a lifecycle revision. These still settle, deliver to the requester, finish cleanup bookkeeping, and can be resumed by their authorized requester. Only child-session-mutating effects are suppressed and logged.subagent-control-kill-scope.ts:143was claimed to skip authorized unresolved descendants. This is a false positive.ensureSubagentControllerOwnsRunreturnsundefinedwhen the controller owns the run and an error string otherwise, so!ensureSubagentControllerOwnsRun(...)admits exactly the owned descendants into the reported unresolved tree, with their authority error. The verified path uses the same predicate.