Skip to content

refactor(subagents): simplify queued registration recovery - #207016

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/subagent-recircuit-r4-queued-recovery
Nov 28, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/subagent-recircuit-r4-queued-recovery

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Related: #206472

What Problem This Solves

Queued subagent registration repeats recovery and row-eligibility decisions across launch, cancellation, and failure settlement. Maintaining those copies makes this already complex circuit harder to change safely.

User Impact

No intended behavior change. Queued launches still wait for kill claims, preserve the first failure for retry, and refuse cleanup or replay when a write outcome is uncertain. Existing tests are unchanged.

Why This Change Was Made

The registration owner now uses one recovery classifier, one queued-row selector, and one shared acceptance predicate. The redundant persistence uncertainty flag and three single-use admission wrappers are removed.

Circuit map

State or input Writer / owner Required effect
Queued row and accepted address Run-launch owner; persistence preserves the physical execution through rekeying Read the current row through getCurrentSubagentRunOwner.
Pending or committed kill claim Kill owner and persistence queue Wait outside row admission; re-enter when a released claim is reacquired.
Queued launch failure Queued-registration owner Retain the first cause/time, prepare collector facts, and publish one failed row.
Cancelled collector awaiting settlement Kill owner; queued-registration publishes collector completion Preserve the kill outcome and captured output while completing launch cleanup.
Known refused write Persistence reports no commit; registration retains retry state Retry settlement without replaying launch or already completed cleanup.
Unknown write or committed publication failure Persistence outcome owner; registration retains restore state Refuse replay and session cleanup until canonical recovery.
Replaced row, newer sibling, or retired runtime Registry/run owners Stop stale launch/settlement and preserve the successor.

Local state writers are also contained in this owner: the registration loop acknowledges registration; waitForClaim records restore failures; failIncompleteRegistration retains the first error and manages pending/retry state; prepareCancelled and settleCancelled own cancellation settlement; canContinueSettlement and settleFailedLaunch retire stale settlement; and publish records its own terminal execution after publication.

The retained inputs are the acknowledged row, database context, lifecycle generation, Gateway resolver, manager row/config reads, activation callback, and caller assertion. Effects remain claim waiting, collector preparation, serialized mutation, published-output cleanup, and observer activation. No durable shape changes.

Deletions and remaining decisions

  • The three inline unknown-or-committed error classifiers are replaced by requiresRegistryRestore; inline copies remaining: 0.
  • The three repeated full queued-row gates are replaced by queuedEntry; inline copies remaining: 0. Retry-state classification still distinguishes a taken-over row from an active kill claim.
  • getCurrentSubagentRunOwner already guarantees the physical-owner comparison, including queued/accepted address aliases. Re-comparisons of its selected row were removed; mutation-plan and sibling-candidate comparisons remain because those rows are not selected by that owner.
  • persistenceUncertain, exactEntry, gatewayCurrent, assertLaunchCurrent and assertRegistrationCurrent references remaining in the changed owner: 0.
  • Launch acceptance and accepted-run abort now consume the same predicate.
  • Mechanical caller updates: none. No ACP files changed; those belong to R6.

Complexity boundary

registerRequiredQueuedSubagent decreases from CC 128 to 107, and SLOC 328 to 303. This does not meet the numeric half-baseline target. The retained branches distinguish documented, tested outcomes: claim release/reacquisition, committed cancellation versus ordinary launch failure, refused versus unknown writes, registry/Gateway retirement, accepted-address rekeying, and newer sibling session ownership. They remain separate because they trigger different persistence, retry, or cleanup effects. No helper was extracted solely to move complexity out of the metric.

Evidence

@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels Nov 27, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 27, 2026 23:50
@vincentkoc
vincentkoc merged commit c6b3a88 into main Nov 28, 2026
215 of 216 checks passed
@vincentkoc
vincentkoc deleted the refactor/subagent-recircuit-r4-queued-recovery branch November 28, 2026 00:19
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…207016)

* refactor(subagents): share queued registration recovery decisions

* fix(subagents): avoid shadowing queued registration state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant