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. |
fafd76d to
ff7aa5a
Compare
|
Codex review: blocked before merge. Reviewed October 5, 2026, 10:36 PM ET / October 6, 2026, 02:36 UTC (Revision 9). ClawSweeper reviewWhat this changesMoves bulk subagent registry reads and completion decoding into existing database workers, bounds restoration transfers, and updates callers and tests to consume prepared facts. Merge readiness⛔ Blocked before merge - 5 items remain This PR remains useful: current main retains the synchronous bulk-loading paths it replaces. No concrete introduced correctness defect was found, and the supplied production-path proof is sufficient; the previously identified performance tradeoff still lacks an explicit disposition. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry tracks delegated agent runs and their completion delivery. Gateway recovery, cancellation, and session maintenance consume its stored records to resume work and preserve sessions that active runs still need. flowchart TD
A[Stored subagent runs] --> B[Database read worker]
B --> C[Bounded snapshot pages]
C --> D[Gateway registry publication]
D --> E[Recovery and completion delivery]
D --> F[Session maintenance]
G[Current ownership and foreign commits] --> F
F --> H[Preserve or prune sessions]
Decision needed
Why: The measurements establish the costs and benefits, but do not determine the acceptable operating balance for large retained registries. Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the single-worker design and ownership safeguards, with an explicitly chosen balance between Gateway responsiveness and retained-registry recovery throughput. Do we have a high-confidence way to reproduce the issue? Yes for synthetic retained-registry stalls: current-main bulk-loading source and the supplied paired 3,000-row rig provide a concrete path. The original production incident was not reproduced. Is this the best way to solve the issue? Yes: reusing the existing worker and snapshot owners removes main-thread bulk work without introducing a competing storage owner; the remaining question is acceptance of the measured operating cost. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e72e0807acfa. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat 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 (8 earlier review cycles)
|
Pull request was converted to draft
728a019 to
ae0f0c1
Compare
Prepare registry reads through the existing worker, page canonical restore, and consume decoded completion receipts with exact physical row versions. Preserve cancellation ordering, terminal-event atomicity, and source custody. Native session maintenance observes foreign commits on one private live connection and rereads only indexed prune candidates when its worker snapshot is stale. Remove the superseded synchronous preservation API. No state schema, configuration, retention, or migration changes are introduced.
Reuse the registry freezer for canonical metadata projections and compact worker replies, preserving nested immutability and runtime ownership without repeating generic descriptor and proxy classification during publication. Move ACP spawn failure mapping into its existing result owner to keep the spawn module within its line budget while preserving its result contract.
ae0f0c1 to
c6c9752
Compare
…nts.entries (upstream openclaw#165684, openclaw#164103) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
…w#165684) * perf(agents): move bulk registry work off the Gateway thread Prepare registry reads through the existing worker, page canonical restore, and consume decoded completion receipts with exact physical row versions. Preserve cancellation ordering, terminal-event atomicity, and source custody. Native session maintenance observes foreign commits on one private live connection and rereads only indexed prune candidates when its worker snapshot is stale. Remove the superseded synchronous preservation API. No state schema, configuration, retention, or migration changes are introduced. * perf(agents): avoid generic classification of registry projections Reuse the registry freezer for canonical metadata projections and compact worker replies, preserving nested immutability and runtime ownership without repeating generic descriptor and proxy classification during publication. Move ACP spawn failure mapping into its existing result owner to keep the spawn module within its line budget while preserving its result contract. * fix(agents): preserve registry admission across worker reads * fix(agents): preserve registry callback contracts * test(agents): finish registry reader and startup clock cutover * perf(agents): bound registry restore startup and publication * test(gateway): register real owner for session activity
What Problem This Solves
Large retained subagent registries stall the Gateway during recovery and cold reads while synchronous SQLite access and JSON decoding occupy the main thread.
User Impact
Bulk registry storage work runs in the existing worker. Restore publishes complete rows and cached metadata together, and the synthetic restore/sweep/cold-read rig stays below 50 ms maximum main-thread delay. Physical row-version conflicts, cancellation ownership, and atomic terminal events remain enforced. No configuration, state schema, retention, or migration changes.
Responsiveness has a throughput cost: on the source-code rig, restore wall time is 10.158 → 17.925 s and process CPU is 9.865 → 19.961 s. One of eleven 12 MiB completion-block acknowledgments still exceeds 50 ms. This is synthetic evidence, not a reproduction of the production incident.
Why This Change Was Made
Restore consumes one stable worker snapshot in pages bounded by 128 rows and 1 MiB of stored payload; one oversized record remains whole. Workers decode records and return physical CAS versions. Activation yields and rechecks live ownership; sweeps use resident/scoped facts. The synchronous bulk fallback loaders, parsing/hashing receipts on the caller thread, duplicate preservation interface, and duplicate maintenance publication cache are removed.
Native lifecycle, replacement, and deleted-agent purge capture SQLite
data_versionon a private live read-only connection before worker preparation and check it immediately before pruning. A foreign commit triggers indexed protection rereads only for candidate child-session keys, in batches of 64. Newly protected candidates roll back pruning; unrelated commits permit it. Source identity, integrity admission, and cleanup custody remain enforced. There is no revision table, trigger, or schema bump.Restore settles each row's ownership, then notifies readers through its final atomic publication. Cold asynchronous snapshot startup prepares the existing native broker before yielding, revalidates admission, and starts the worker using the same captured owner. Shared retained staging remains synchronously serviceable: the production read and single-flight owners must be able to service retained work without caller timer/microtask progress. Broker cleanup still belongs to that same native source, including cancellation before any task starts.
Evidence
Validated tree
bb48da43105a3a4adc5d75e6893607d5f5ff681fwas committed unchanged ascba67cba259f4a910f5f78b871296bebbf19530f, against base1b7dd0b2ac92ff188537f7ec24ccd79bcfe2c22d.The fixture contains 3,000 rows, about 394.7 MB. All eight standard phases meet the 50 ms target:
All 19 recorded outcomes matched. Candidate phases observed zero main-thread registry SQL calls and record JSON parsing. Cold-full parsing fell from 394,671,907 bytes to zero; cold-maintenance parsing from 1,329,942 bytes to zero. Each cold read went from 78 observed SQL calls to zero.
The eleven 12 MiB stress cases measure
blockSubagentCompletionDelivery({storeReplaced:true})withapplied=true, not full retirement. Median maximum delay is 124.518 → 30.360 ms; worst is 202.506 → 54.034 ms, with one candidate case above 50 ms.Remote proof used provider hetzner, lease
cbx_b2954fdb4781, Node 26.10.0:run_cb2c4ae6af269bc2b30e80923e999de4: new restore-publication test overlaid alone onc6c9752pnpm test src/agents/subagents/registry/subagent-registry-state.test.ts --maxWorkers=1run_952670a85936494d0290772a6a7cb258: matched paired rignode scripts/check-changed.mjs --staged --base 1b7dd0b2ac92ff188537f7ec24ccd79bcfe2c22d --timednode scripts/run-vitest.mjs <97 remaining registry/announce unit files>OPENCLAW_BUILD_PRIVATE_QA=1 pnpm buildnode scripts/run-vitest.mjs <announce.format, registry.archive, registry.lifecycle-retry-grace, registry.requester-wake E2E files>Both native commands used
crabbox run --provider hetzner --id cbx_b2954fdb4781 --fresh-pr openclaw/openclaw#165684 --apply-local-patch --timing-json --script ..., with.local/lane461/observer-repair-first.shand.local/lane461/observer-repair-remaining.sh. Exact HEAD, staged-tree, patch, and source-byte checks ran before and after stages. No sync or gate was bypassed. All 1,771 final artifacts and 206 source hashes were verified; an independent audit checked source manifests, profile hashes, equal 3,333 µs profiling, outcomes, and cleanup. The lease was released after capture, exit 0.The same production bytes also passed 211 focused tests on lease
cbx_9326c7a31c41, runrun_a144c8d321786acf9f38273c95f4ea95; only the observer test fixture changed afterward. Those passes cover native retained servicing, snapshot identity/cleanup, ownership/ABA, and foreign-commit protection. Thirty-three overlap the current state suite, so the distinct total across current and reused proof is 2,037 passing cases, covering all 105 ordinary registry/announce files plus focused native/state/maintenance coverage. Six live-provider suites and the opt-in entry-reload benchmark remain unrun.Key behavior proof:
rechecks only native maintenance candidates after a foreign worker commitcovers insertion, reactivation, and unrelated commits between preparation and pruning. Newly protected children survive and the native transaction rolls back; unrelated commits allow pruning. These cases failed the original pre-fix overlay and pass the focused proof.publishes restored rows together after replacing ownership and cached factsproves synchronous metadata observers see one complete restored publication with superseded ownership. The accepted negative control exposes partial rows on the old code.joins a prepared broker after cancellation before any snapshot taskproves actual broker PID death under generation cleanup and rejection of the retired captured owner. It passed in 119 ms and is new lifecycle coverage, not a claimed old-code defect.Cold-full wall time is 3.898 → 17.874 s and process CPU is 2.758 → 18.790 s. Cell-lifetime peak RSS falls from 2,192.5 → 1,291.7 MiB for restore and 1,289.8 → 1,010.7 MiB for cold-full reads; maintenance rises from 443.5 → 763.5 MiB and acknowledgments from 1,267.8 → 1,363.7 MiB. These are single source-runtime pairs with advisory cache eviction, selected-outcome parity, and process-wide CPU/RSS including worker startup. Physical OS cache eviction and bytewise whole-database equivalence are not established. The original superseded-restore incident is not reproduced or attributed.
Earlier candidates missed the ordinary-phase target at 65.6, 68.3, and 59.7 ms. Timestamped profiles identified duplicate maintenance projection/freezing, same-object identity rebuilding, per-row outward notifications, and combined broker/worker startup. Those failures remain separate from the passing candidate; no unchanged-code replay was used to claim a fix.
The requested production stat, excluding
*.test.ts,*test-support*, and docs but including test utilities, is +1,328 / −782, net +546. Runtime-only is +1,252 / −721, net +531. Growth preserves the stable snapshot across bounded worker transfers, physical-row CAS and post-await ownership, native synchronous rollback/cleanup with a live foreign-commit witness, and synchronous retained servicing alongside asynchronous broker preparation. Superseded bulk-loading and duplicate-cache machinery is deleted.Hosted CI status
Previous-head run
37402164985found an inherited production dependency audit failure:source-map-js1.2.1, advisoryGHSA-68fv-2mgg-jv7q. Main commitc20c6e5822d741c03831cac8ad805aace1735de3fails identically in run37402399816. This branch changes neitherpackage.jsonnorpnpm-lock.yaml; no audit bypass or unrelated dependency change is included.The changed-test shard also exposed an inherited mock-only activity fixture after the newer workboard projector began consulting real owner inventories. The test now registers and cleans up a real embedded run, retains the
sessions.listresponse assertion, and removes unused progress mocks (net −11 test lines; production unchanged). On provider hetzner, leasecbx_2a877b8bc6f5, runrun_518d0a8258d52eb61090067efa14f786, Node 24.21.0:node scripts/run-vitest.mjs src/gateway/server-methods/sessions.abort-agent-scope.test.tson original branchcba67cbaabe74cbdf41eand its main parent0c7a83dd65c6node scripts/run-vitest.mjs src/gateway/server-methods/sessions.abort-agent-scope.test.ts src/gateway/server-methods/sessions-read-active.test.ts src/gateway/server-methods/session-active-runs.test.tson the repaired CI mergepnpm test src/gateway/server-methods/sessions.abort-agent-scope.test.ts --maxWorkers=1on the repaired branchnode scripts/check-changed.mjs --staged --base cba67cba259f4a910f5f78b871296bebbf19530f --timedThe native command was
crabbox run --provider hetzner --id cbx_2a877b8bc6f5 --fresh-pr openclaw/openclaw#165684 --timing-json --script .local/lane461/abort-repair-proof.sh. Original-source controls ran before the one-file repair was applied; source and repair hashes were checked. Fresh detached review of the test-only follow-up completed clean through P2. The validated tree1bc60ed4634fc26a74a6bbc4fe831782e4956a9cwas committed unchanged as06730b772873b8d21db64a05eafffc5cedbe3a07. The lease was released, exit 0. Earlier production/performance proof remains applicable because this follow-up changes only the fixture.Final-head CI run
37404356765completed on06730b772873b8d21db64a05eafffc5cedbe3a07. All test shards, build, type, lint, and other executed checks passed, including the previously failing Gateway shard. The only underlying failure is the same inheritedsource-map-jsproduction audit;openclaw/ci-gatefails as its aggregate. This PR is open, ready, and mergeable, but CI is not green. No merge or auto-merge command was run.