Skip to content

refactor(subagents): simplify prepared registry postimages - #175604

Merged
steipete merged 1 commit into
mainfrom
deslop/r03-09-registry-publish-20261015
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/r03-09-registry-publish-20261015

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Registry transitions were deep-copying owner-prepared records even when they only replaced the root or freshly constructed nested state. The codec likewise copied the entire run to normalize a small set of containers, and Stop repeated authority checks inside non-yielding code. This area-only refactor removes that duplicate work; it does not claim a measured speedup or change public configuration, stored formats, retention, or permissions.

User Impact

No user-visible behavior change is intended. Registry recovery, accepted Stop settlement, and persisted records retain their existing contracts; no migration or configuration change is required.

Why This Change Was Made

Reuse owner-prepared facts and existing comparison helpers instead of copying unchanged nested state or repeating same-frame authority checks. Preserve the actual trust, effect, and settlement boundaries.

Best-effort tradeoffs accepted

  • Registry postimages share unchanged nested prepared facts instead of deep-copying them (recovered donor 0ed453a7c436). All modified nested containers are replaced before mutation; unsupported internal mutation after handoff would now be shared. Current owners do not perform it, and no human incident requiring that private mutation contract is established. The termination plan retains its deep clone because normal collector completion does mutate nested completion.
  • Codec encoding copies only the root and completion after canonical validation (ba9c803ae214); terminal reply normalization constructs its own value. It no longer isolates unrelated private nested facts from unsupported mutation. The new codec case protects persisted restart-cleanup normalization and unchanged live/shared reply state; every invalid encoding case remains.
  • Stop removes only the opening duplicate native session/kill-owner pair and two authority calls inside its non-yielding termination plan (f68a44810046). There is no intervening await requiring another currentness read. Checks after awaits, before abort/queue effects, after synchronous abort callbacks, at native transaction/commit grants, and during settlement remain; revoked authority is not accepted as best effort.
  • Kill intents use the existing six-field semantic comparator rather than JSON representation equality (f68a44810046). Reordered keys and absent versus undefined optional fields now compare equal; incidental object representation is not an intent distinction. No claim field or live row/session/generation predicate is removed. Accepted Stop custody, normal write settlement, unknown-write escalation, FIFO, and durable receipts remain.
  • Typed spawn parentConversationId/to/accountId lose only nullish-to-undefined no-ops (0ed453a7c436). These private constructors already supply optional non-null strings; unsupported untyped null calls no longer receive this extra normalization. Raw/public boundaries and all snapshot behavior remain. Newer main's queue logging deletion, missing-completion-source Gateway recovery settlement, and unavailable legacy wake/yield cleanup are preserved.

Scope, provenance, and review

Recovered exact hunks from 0ed453a (seven registry and two typed spawn files), f68a448 (three cancellation files), and ba9c803 (codec and its test). Recovered on fresh main dca14ad; the prior independently reviewed packet used base 1761140. Fourteen files: thirteen production files +29/-34 (five net removed), one test +20/-0. Total +49/-34. No LSP privacy, Telegram, standalone session-memory Phase E, audit, cron, or other queued area changes.

Cancellation/recovery mechanisms from #133076/#131553/#163195 remain protected; their ownership, reselect, admission drain, FIFO publication, and accepted settlement are not retired. These PR references are mechanism history, not evidence of human actual-use incidents; #163195's publication/interleaving controls are synthetic. Author simplification and test-value audit completed: no new owner, compatibility path, test seam, suppression, baseline exception, or redundant test family. Independent P0-P2 review completed assessment and final source verification with one P1, not a scoped-clean verdict. The finding alleged absent completion could become an empty object and persist; declined after checking that isCanonicalSubagentRunRecord requires a completion record with boolean required, and bindSubagentRunRecord throws before the spread for absent completion. The unchanged normalizer never supplies missing completion either. No accepted/actionable findings remain; no source repair or cosmetic review rerun. The root coordinator owns final acceptance and publication.

Evidence

Exact donor hunks applied cleanly; git diff --check passes. No tests, typechecks, lint, install, build, broad checks, or remote leases were run by the preparation worker. Focused codec, worker claim/accepted-stop/publication/metadata, sweeper recovery, persistence, launch, and spawn owner proof was pending at preparation; the current hosted proof and retained local limitation are recorded below. Historical donor proof is not a new-head pass.

Fresh-main transfer: all 13 other postimages match the reviewed packet exactly. Gateway recovery keeps its newer missing-source and legacy continuation handling verbatim; its only packet change remains the root-only postimage copy. Current binary patch SHA256: 7a06d8d19b7602d6c4a678a6abd61aec8b299aefa4fe78950c50d410effc1688. Formatting passes all 14 TypeScript files and diff-check passes. The only new runtime import targets the existing six-field comparator leaf, which has no runtime import of its own, so it introduces no cycle component. Fresh functional/type proof is not qualified by the once-installed task dependency version; exact-head CI owns broad proof.

Pre-publication source freshness through main 6e7b10f4a05: the only later target change is the sender-profile restoration in restoreSubagentCompletionSource, separate from this packet's root-copy change in recoverSubagentRunGatewayOwner. That sender/accepted-hash binding must remain intact. This is source inspection, not a new functional or merge-result claim.

The mandatory serial suppression audit completed in 54.83 seconds (Vitest 37.69 seconds; tests 16.37 seconds): four passed, one failed. The explicit allowlist expects 94 entries but current source yields 95: unchanged backup-restore has two preserve-caught-error directives rather than one, and unchanged native-bridge has an unlisted post-message-target-origin directive. This packet modifies no directive-bearing file: all 14 paths are modifications only, with no oxlint-disable or eslint-disable text on base or candidate. The complete suppression-bearing input set is therefore unchanged. The scanner/test/helpers and both reported files retain the same blobs. This is source/input attribution, not an executed baseline replay or a passing audit; no allowlist or suppression was added.

Exact-head hosted CI 39041005289, attempt 1 passed for 0fe2973816543906dbebdcf5d2dd7bf18b26e61d. The complete census has 194 exact-head completed checks: 69 success, 122 skipped, one neutral CodeQL, and two historical side-workflow cancellations with successful same-head replacements; no failure or active check remains. The actual workflow has 69 jobs: 41 success and 28 unselected skips. The aggregate gate confirms all 13 selected logical lanes passed, with no selected proof gap: changed Node tests, UI E2E, ratchets, lint, test types, extension boundaries, and additional checks. Build artifacts were not selected, so no build pass is claimed. This does not retroactively turn the earlier local inventory audit into a pass.

Preflight attests tested merge 4a4cb1d32c068b9b6613722707be7afd1080c9f5, with ordered parents cc271f85709b3bea38fffecfc1c53ebc9a404109 and the exact head, tree 73a2eb08c6b5556a864aef3024d2fd5108818880. Independent commit/compare checks confirm precisely the 14 reviewed paths and production +29/-34 (five candidate net lines removed), with 20 test lines added. These describe the tested checkout, not a landed-result or unique-production-credit claim. No CI rerun, source push, or rebase was used to obtain green.

@clawsweeper

clawsweeper Bot commented Oct 17, 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 17, 2026 14:29
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T14:32:59.786656Z 0fe2973 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces redundant deep copies, reuses semantic kill-intent comparison, and removes duplicate checks within synchronous Stop planning.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported refactor with passing exact-head CI and useful codec coverage; runtime evidence remains at the test-harness level.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied evidence covers hosted tests, not a fresh shipped Gateway run, and source inspection found no material expansion of authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: The established area owner explicitly chose this narrow reduction of duplicate work, preserving public behavior and documenting the private sharing tradeoffs.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful maintainer-directed simplification with no actionable introduced defect found and passing exact-head CI.

Priority: P3
Reviewed head: 0fe2973816543906dbebdcf5d2dd7bf18b26e61d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head shipped Gateway Stop or restart-recovery trace is supplied; ordinary contributor runtime proof is exempt for this maintainer-authored refactor.
Agent review details

How this fits together

Subagent registry owners receive prepared spawn, completion, recovery, and cancellation facts, persist canonical records through SQLite workers, and publish acknowledged state to lifecycle consumers.

flowchart TD
A[Spawn and Stop requests] --> B[Registry mutation owner]
B --> C[Canonical record codec]
C --> D[SQLite worker]
D --> E[Commit receipts]
E --> F[Published lifecycle state]
Loading

Technical review

Best possible solution:

Merge the focused simplification while retaining the existing immutable publication, encoding, and Stop settlement boundaries.

Do we have a high-confidence way to reproduce the issue?

This PR claims behavior-preserving cleanup rather than a reproducible user bug; review used source and supplied CI evidence without executing target code.

Is this the best way to solve the issue?

The change fits the existing owners: modified nested containers are replaced before mutation, publication retains isolation, and removed authority checks remain enforced at meaningful boundaries.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Registry postimage preparation keeps the original intent (3f761a8: Ordered mutation planning and immutable acknowledged publication protect overlapping completion and cancellation writes.)
  • Failed queued-run construction keeps the original intent (d8e684e: Lifecycle consolidation placed queued failure construction under a shared owner; this patch preserves its state transitions while replacing only containers it modifies.)
  • Codec copy isolation changes intended behavior with a stated reason (5b20c04: The prior codec normalized a deep copy before validation; this PR explicitly narrows isolation to containers normalization writes, retaining canonical rejection and serialized output.)
  • Stop authority and kill-intent matching keeps the original intent (3f761a8: Cancellation retains exact ownership through asynchronous persistence and settlement; the patch removes synchronous duplication while preserving effect and commit checks.)
  • Typed spawn target fields changes intended behavior with a stated reason (5284408: Earlier spawn splits preserved optional target handling; inspected typed callers and canonical conversation normalization support removing the redundant nullish conversions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced change: The pinned introduction changes only prepared-record copying, semantic comparison, duplicate synchronous checks, typed optional fields, and codec contract coverage. (0fe297381654)
  • Immutable planning and isolated publication remain: The persistence owner freezes planning inputs, checks authority before synchronous planning, and still deep-copies postimages before worker persistence; transaction and commit admission retain currentness checks. (src/agents/subagents/registry/subagent-registry-persistence.ts:324, 0fe297381654)
  • Stop effect boundaries remain checked: Session, caller, and kill-owner checks remain before runtime abort and queue cleanup, including revalidation after synchronous abort callbacks; failure settlement also checks its retained owner. (src/agents/subagents/registry/subagent-control-kill-runtime.ts:625, 0fe297381654)
  • Encoding compatibility: Canonical validation still rejects absent completion state; normalization changes the copied root and completion container or constructs replacement values, while indexed columns, payload envelope, and readers remain unchanged. (src/agents/subagents/registry/subagent-registry.store.codec.ts:92, 0fe297381654)
  • Maintainer-accepted tradeoffs: The maintainer-authored body explicitly accepts sharing unchanged private prepared facts and treating kill-intent key ordering and absent-versus-undefined fields as equivalent; it preserves revoked-authority rejection. (0fe297381654)
  • Exact-head CI: Hosted run 39041005289 completed successfully for the reviewed head, including changed Node tests, production and test types, lint, architecture checks, and the aggregate CI gate; historical cancelled side checks are not test failures. (0fe297381654)

PR surface

Source -5, Tests +20. Total +15 across 14 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 13 29 34 -5
Tests 1 20 0 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 49 34 +15

Review metrics

Metric Value Why it matters
Production versus test changes Production +29/-34; tests +20/-0 Production shrinks slightly, and the added test protects stored cleanup normalization without mutating live completion state.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal cleanup with no intended user-visible behavior change or urgent runtime defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 17, 2026, 11:01 AM ET / 15:01 UTC.

@steipete
steipete merged commit 8ccbd4b into main Oct 17, 2026
218 of 220 checks passed
@steipete
steipete deleted the deslop/r03-09-registry-publish-20261015 branch October 17, 2026 17:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant