Skip to content

fix(agents): require recorded subagent ownership - #167966

Merged
steipete merged 3 commits into
mainfrom
fix/w9-k1
Oct 12, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/w9-k1

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

With main/global and research/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 to bb6041345da and 64406536043; owners: src/agents/subagents/registry/subagent-child-owner-match.ts:5 and src/agents/subagents/registry/subagent-registry-run-launch.ts:123.

Send to raw global with watching enabled, then update either agent's session: a key-only cursor cannot distinguish owners, yet reports success. The cursor dates to 2bb79d10fd6; 3bde3cd0174 exposed explicit watches without rejecting ambiguous targets. Validation now belongs to src/sessions/session-state-events.watch-address.ts:1.

A creation receipt with runStarted:true but no session ID promised an undeliverable child. src/agents/tools/sessions-spawn-visible.ts:596 now 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 via 64406536043's fallback. src/agents/subagents/registry/subagent-registry-memory.ts:66 now 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 to subagent-control-session.ts:77 and subagent-registry-execution-cleanup.ts:121 in 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 in 4bf041c0d1f); K1's durable cohort preparation did not protect cleanup. src/agents/subagents/registry/subagent-registry-run-launch.ts:180 now 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 childAgentId and 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:false with 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:false with 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.

Proof Pinned base Head
Build PASS, 233s PASS, 355s
Runtime and Madge cycles Not required Both PASS, 18s each
Timeout recovery 1 failed, 225s Same completion stall, 213s; final replay also fails
Doctor ENOSPC 2 failed, 37s Same 2 failed, 28s
Deprecated config API guard Same failure, 12s Same failure, 11s
Changed-check commands Guard attribution above 38/39 PASS; inherited-red overall

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 by c26d9db0c62. 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)

  • Rebased across main's ACP terminal publishing and the subagent announce/list/reconciliation async and incognito changes. Main's behavior is kept, with this branch's ownership guards layered on top.
  • Child authority is now a closed tri-state owned by resolveSubagentChildAuthority: verified / legacy-unverified / mismatch.
    • Legacy-unverified: runs persisted by earlier releases without childSessionIdentity or 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.
    • Mismatch: a real incarnation mismatch still fails closed.
    • There is no identity backfill or schema change, and every caller routes through the tri-state.
    • Regressions cover legacy completion delivery, restart delivery, revisionless launch cleanup, legacy resume, and a policy table.
  • Rejected review finding: bulk cancellation in subagent-control-kill-scope.ts:143 was claimed to skip authorized unresolved descendants. This is a false positive. ensureSubagentControllerOwnsRun returns undefined when 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.
  • Proof for the latest head: 717 tests across 21 files, plus import cycles, core typecheck and diff checks.

@clawsweeper

clawsweeper Bot commented Oct 9, 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 October 9, 2026 21:11
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 9, 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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.

  • Before: Wildcard matching or configuration inference can select another agent's child work.
  • After: The ambiguous operation refuses to change child work and preserves the retained record.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value, but two contract regressions remain and the changed authority and upgrade behavior lack qualifying proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancellation and lifecycle operations can select another agent's work when raw session keys collide or retained ownership is incomplete.
Reason: The owned defect exists on main and stable, and the maintainer-authored direction explicitly accepts legacy task preservation with suppressed child-session mutation.

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
Reviewed head: ab98f981904173e51aa4cdf4b7080c6a138c7349

Before merge

  • Add real behavior proof - Authority-chain proof required: provide production-path traces of authorized cancellation, cleanup, and legacy resume, foreign-requester rejection, and requester revocation or child reassignment during awaited preparation, showing rejection before runtime, command, and cleanup effects. The inspected body and discussion supply tests and historical validation claims rather than these observations; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Carry the selected child owner through raw-key resume (P1) - The prior finding remains unresolved. For a paused run with childSessionKey="global", childAgentId="research", and a valid recorded identity, this index returns no candidates unless research is supplied. shouldResumeParentSubagent, requirePausedChild, and successor validation still omit that owner even though sessions_send resolves targetAgentId. Explicit resume rejects the authorized child, and automatic continuation skips adoption of its original task. Carry the selected owner through selection, binding, and successor checks without restoring wildcard lookup.
  • Declare watchError in the sessions_send output schema (P2) - The prior finding remains unresolved. An accepted send with watch:true whose watch is refused returns watchError through watchField. The applicable SessionsSendOutputSchema variants forbid additional properties and omit this field, so ToolSearchRuntime reports an output-contract failure after the message was sent. Declare the optional diagnostic in the affected result variants and validate a refused-watch result through tool execution.
  • Resolve security concern: Verify retained legacy authority at final effects - Legacy cancellation captures runtime, reply, command, and admission owners before effects; supplied observations do not establish rejection of foreign requesters or isolation after requester revocation or child reassignment during preparation.
  • Resolve merge risk - Before merge, establish that legacy exact-task Stop cannot acquire foreign, revoked, or reassigned runtime and command owners during awaited preparation.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Carry the selected child owner through raw-key resume — src/agents/subagents/registry/subagent-registry-memory.ts:652-653
  • [P2] Declare watchError in the sessions_send output schema — src/agents/tools/sessions-send-followup.ts:306-309
  • [medium] Verify retained legacy authority at final effects — src/agents/subagents/registry/subagent-control-legacy-interruption.ts:25

Provenance

  • Blank-ID fork fallback: original intent not found (unknown: Path history was inspected, but git log -S failed on an unavailable historical blob before establishing the fallback's original rationale.)

Tests

  • Missing end-to-end proof: Supply final-effect authority observations and a v2026.10.2 upgrade run, plus base-failure/head-pass coverage for raw-key resume and refused-watch output validation.
Agent review details

How this fits together

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

Technical review

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

  • [P1] Carry the selected child owner through raw-key resume — src/agents/subagents/registry/subagent-registry-memory.ts:652-653
    The prior finding remains unresolved. For a paused run with childSessionKey="global", childAgentId="research", and a valid recorded identity, this index returns no candidates unless research is supplied. shouldResumeParentSubagent, requirePausedChild, and successor validation still omit that owner even though sessions_send resolves targetAgentId. Explicit resume rejects the authorized child, and automatic continuation skips adoption of its original task. Carry the selected owner through selection, binding, and successor checks without restoring wildcard lookup.
    Confidence: 0.99
  • [P2] Declare watchError in the sessions_send output schema — src/agents/tools/sessions-send-followup.ts:306-309
    The prior finding remains unresolved. An accepted send with watch:true whose watch is refused returns watchError through watchField. The applicable SessionsSendOutputSchema variants forbid additional properties and omit this field, so ToolSearchRuntime reports an output-contract failure after the message was sent. Declare the optional diagnostic in the affected result variants and validate a refused-watch result through tool execution.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Hold for final-effect authority verification (recommended)
    Keep this PR open until authorized and forbidden requester scenarios establish isolation through legacy cancellation and cleanup effects.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: Legacy Stop requires final-effect authority verification; no concrete authorization bypass or supply-chain regression was established.

Evidence

Security concerns:

  • [medium] Verify retained legacy authority at final effects — src/agents/subagents/registry/subagent-control-legacy-interruption.ts:25
    Legacy cancellation captures runtime, reply, command, and admission owners before effects; supplied observations do not establish rejection of foreign requesters or isolation after requester revocation or child reassignment during preparation.
    Confidence: 0.94

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6440653 adds src/agents/subagents/registry/subagent-child-owner-match.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 64406536043a; files: src/agents/subagents/registry/subagent-child-owner-match.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair affects multi-agent delegation and lifecycle operations with a limited blast radius.
  • merge-risk: 🚨 compatibility: Stricter raw-key lookup breaks authorized resume callers that omit the selected owner, and refused-watch results violate the existing output schema.
  • merge-risk: 🚨 session-state: Automatic continuation can skip adoption of the original paused task and its completion obligation.
  • merge-risk: 🚨 security-boundary: Legacy cancellation consumes retained execution authority across requester and child ownership boundaries.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-09T21:20:49.561Z sha b350984 :: needs changes before merge. :: [P1] Carry the selected child owner into raw-key continuation callers
  • reviewed 2026-10-10T11:34:55.650Z sha b350984 :: needs real behavior proof before merge. :: [P1] Carry the selected child owner into raw-key continuation callers | [P2] Supply the stored incarnation in qualified-session resume fixtures | [P2] Resolve the unsupported raw-child wake-retention assertions
  • reviewed 2026-10-11T08:52:43.642Z sha d4a01a3 :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send result schema | [P2] Seed lifecycle revisions in current-run cancellation fixtures | [P2] Align cancellation-retention coverage with legacy settlement
  • reviewed 2026-10-12T07:21:08.276Z sha 149b164 :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send output schema
  • reviewed 2026-10-12T08:13:44.621Z sha 6500b8e :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send output schema | [P2] Give the recorded requester resolver a unique export | [P2] Assert the registration conflict type instead of unmatched wording | [P2] Seed the private completion cohort's requester revision
  • reviewed 2026-10-12T09:54:27.175Z sha 13f3ce8 :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send output schema
  • reviewed 2026-10-12T11:24:59.156Z sha e464670 :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send output schema
  • reviewed 2026-10-12T12:08:38.204Z sha 7d3250640a167dcd5bfb92dc45d834dbf4e9f42b :: needs real behavior proof before merge. :: [P1] Carry the selected child owner through raw-key resume | [P2] Declare watchError in the sessions_send output schema | [P2] Preserve structured stale-leaf rejection during collector Stop

Reviewed October 12, 2026, 10:05 AM ET / 14:05 UTC (Revision 9).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Oct 10, 2026
@steipete
steipete enabled auto-merge (squash) October 11, 2026 08:44
@steipete
steipete disabled auto-merge October 11, 2026 08:49
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 12, 2026
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.
@steipete
steipete merged commit 5bb035b into main Oct 12, 2026
279 of 293 checks passed
@steipete
steipete deleted the fix/w9-k1 branch October 12, 2026 14:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
* 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.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…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]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant