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: blocked before merge. Reviewed October 4, 2026, 2:00 AM ET / 06:00 UTC (Revision 13). ClawSweeper reviewWhat this changesThe branch releases completed request context from reusable Gateway resources and moves Doctor’s Gateway lease inspection into a worker that detects claims hidden by damaged indexes. Merge readiness⛔ Blocked before merge - 2 items remain This PR remains useful: current main does not cover the broader lifecycle fixes or damaged-index lease inspection. No actionable introduced defect was found, and the previous generic compatibility blocker is unsupported by the inspected diff. Priority: P2 Review scores
Verification
How this fits togetherGateway workers, timers, and queues serve many agent requests and must preserve pending work without retaining completed callers. Doctor checks Gateway ownership before allowing database maintenance. flowchart TD
A[Agent requests] --> B[Per-task authority]
B --> C[Reusable workers and queues]
D[Neutral lifecycle context] --> C
C --> E[Completed callers released]
F[Doctor maintenance request] --> G[Worker lease inspection]
G --> H[Refuse active claims or allow maintenance]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep reusable resource creation neutral while preserving per-operation authority, and retain Doctor’s bounded physical-table inspection before maintenance. Do we have a high-confidence way to reproduce the issue? Yes, source and recorded before/after fixtures establish caller retention and indexed lease lookup missing physical claims; this read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes, the patch reuses existing lifecycle, worker, and maintenance owners while preserving task context and cleanup custody. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 42b9aee33a7b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
dd4e93b to
a8b8897
Compare
78074c8 to
482cd27
Compare
Pull request was converted to draft
0162162 to
3d7d2fc
Compare
Doctor could miss an active Gateway lease when its lookup index was damaged. Inspect table rows through the shared-state read worker and reject ambiguous claims before repair, preserving the original database and quarantine receipt. Keep physical and captured read authority across awaits. Retire native work before removing the private snapshot, and retain cleanup custody on failure. Route this inspection through the existing diagnostic reader.
02707f1 to
2df48c3
Compare
…enclaw#164465) * perf(runtime): release completed caller contexts from lifecycle resources Create persistent native resources, timers, and queue orchestration in the lifecycle context while preserving per-operation authority and cleanup ownership. Drop opening callback captures and private sentinel stacks; retain measured-clean settled promise owners unchanged. * perf(runtime): migrate the new Gateway heartbeat to lifecycle context owner * test(runtime): satisfy lifecycle retention fixture lint * fix(tooling): include lifecycle helpers in PR wrapper archives * test(state): identify workers by their lifecycle owner * fix(doctor): retain maintenance authority while draining databases * fix(doctor): preserve Gateway lease authority through index corruption Doctor could miss an active Gateway lease when its lookup index was damaged. Inspect table rows through the shared-state read worker and reject ambiguous claims before repair, preserving the original database and quarantine receipt. Keep physical and captured read authority across awaits. Retire native work before removing the private snapshot, and retain cleanup custody on failure. Route this inspection through the existing diagnostic reader. * fix(runtime): complete lifecycle import and admission cutover * fix(ci): preserve native imports and SQL guard attribution * test(runtime): follow lifecycle and UI owner contracts
…ed the MCP loopback ends (#165432) Backport of fdcbcf5 (#165432) adapted for 2026.10.3. Ports the 16-line src/shared/detached-async-context.ts owner from #164465 (absent on 10.3). Vitest routing keeps only this PR's two database-worker entries; the regression expects 10.3's live-authority refusal text instead of main's later "requester authority changed". (cherry picked from commit fdcbcf5)
What Problem This Solves
Long-lived Gateway resources created during a request can keep that completed turn's prompt, transcript, and tool results alive. This completes the measured lifecycle-creation follow-ups from #164370: completed callers can collect while reusable workers, local provider services, parked Code Mode continuations, and background owners remain usable.
Doctor's maintenance preflight also needs trustworthy lease evidence before repairing state. A damaged lookup index can hide a fresh Gateway claim or allow conflicting claims. The maintenance inspection now runs in the existing shared-state read worker, reads the physical table without the damaged index, and refuses active or ambiguous claims before repair. It preserves the source database, quarantine receipt, and current maintenance authority.
User Impact
Completed callers can collect while their reusable resources remain active. Per-task authority, FIFO order, cancellation, parked continuations, scheduled work, and cleanup custody stay with their existing owners. There are no configuration, schema, stored-data-format, or operator migration changes.
Why This Change Was Made
The lifecycle changes reuse one neutral async-context owner with prepared launch facts. Browser-shared consumers import its browser-safe module, and all affected callers move together. SQLite listeners keep launch and cleanup facts instead of the opening caller's options frame; completed admission callbacks are released. Provider startup owns both the child and pooled readiness connection. Timers and continuous queue drains no longer inherit the first caller, while each admitted task restores its own authority. The redundant LLM configuration call and manual initialization cache are removed. Two module-global Error sentinels discard their import-time stacks, which otherwise retain an importer's closures even when async context is detached.
Doctor lease inspection has a narrower admission contract than an ordinary runtime read. Its existing
doctor.gatewayOwnerLease.readcommand takes an early worker branch after the existing request/freshness guards. The worker-only helper opens the captured read connection and exact Doctor schema-read admission before runtime schema validation, so newer and quarantined databases remain inspectable. It carries the expected source identity and private snapshot root, scansstate_leases NOT INDEXEDwithLIMIT 2, and uses the shared lease decoder. Successful replies recordsourceAdmitted: true; failed replies retain whether admission actually completed. Ordinary indexed lease reads keep their existing path. No new wire command, general quarantine bypass, or main-thread SQL site is introduced.The host captures its source and read context before yielding, rechecks physical custody and captured admission across awaits, and refreshes process liveness after cleanup. Native retirement must finish before the private snapshot read pin is released. Disposable snapshot-removal warnings and retry custody remain with the canonical snapshot owner; actual cleanup rejections stay visible and retain finite source custody for retry. Doctor's legacy-root drainage also runs under its still-live parent maintenance owner.
Production source is 427 lines added / 205 removed, +222 net, excluding tests, support files, and
src/test-utils. The requested filter (:!*.test.ts :!*test-support* :!docs/*) reports 472 added / 221 removed, +251 net, because it also counts fixture infrastructure and wrapper inventory. The lifecycle cutover contributes +58 lines to preserve per-task authority, independent provider startup/cancellation, and parked/scheduled-work ownership. The remaining +164 lines implement the bounded worker inspection and shared decoding, pre-runtime Doctor admission, truthful reply facts, cancellation, and native/snapshot cleanup contracts. These replace the old synchronous maintenance read; they do not add a competing fast path or lifecycle manager. The staging allocation adapter moves into a sibling module with complete caller cutover to preserve its lazy boundary and line cap.Settled fulfilled promises and tails did not retain the tested ALS callers on Node 24/26. Their speculative changes and baseline-passing tests were removed. The resource table records these unchanged rows and the remaining unproven owners.
Evidence
These are historical, source-pinned measurements of the lifecycle cutover, not measurements of the final rebased Doctor integration. The isolated Linux rig used Node 26.8.1, baseline
6cae5628b09a2e3893a02dc018f182ba6442e854, and measured candidate5f78f6aef9d3632e8d9ac8436545f44e73c4d806. Real resources use named 1 MiB caller graphs, forced GC, a collectible control, and reuse/ownership assertions. Fixed resources fail their retention assertion before the change and pass afterward. Unchanged rows below collected on the original implementation.Retained bytes include the marker object, Buffer/ArrayBuffer, and 1,048,576 payload bytes. Different resource fixtures are independent synthetic measurements and must not be summed into a production saving. The 15 fixed resource rows include two separately marked shared-state opening graphs.
scripts/heap-snapshot-diff.mjsreports named strong paths and dominators from same-process snapshot pairs. The candidate releases every named fixture graph while the resource remains usable.Representative dist Gateway
The same historical rig comparison used synthetic state/provider, loopback-only ports, two completed turns, and clean Gateway shutdown. Its
sourcePerformancebuilds passed in 1m28.2s before / 1m19.3s after. The pair includes the staging allocation extraction and heartbeat import cutover.After the first turn, the baseline agent-writer path
slot → receiveReply → context → optionsreached an options graph of 72,981 B; the shared-state slot reached 2,755 B. Both options edges are absent in the candidate, whose callbacks keep onlycarrierUrl,exited,slot, andreplyOwner. The options objects had other strong paths, so these figures are not exclusive whole-heap savings.Post-GC process totals were 262,306,208 → 262,014,936 B after one turn and 264,849,736 → 264,658,800 B after two. These single-run totals are context, not throughput or hourly leak-slope measurements. LLM initialization was already neutral during this representative Gateway startup; its cold-request defect is proved by the separate real initializer fixture. Other cold resources are likewise measured at their actual owner entry points, not claimed to have all activated during one Gateway turn. Independent provider HTTP sockets still expose request-context paths and remain a separate transport follow-up.
Validation
Final head
2df48c3c345a821a5439cb98074c41f110b6fd5d, tree677773b94b9bb044bb6e0611889198ced078732d, pinned main base4bac1493291e7d931c0eea48b8ed07e98dc37ce0. GitHub records merge65829ead96bb115b69782e6357e8b619b3add8bfat2026-10-04T06:01:05Z; its ancestry on main was verified. Independent reviews passed through P2, including each final correction. The lifecycle/Doctor code replayed unchanged during the final integration, and main supplied the duplicate formatter fix. There is no production UI diff.Current-head proof ran on blacksmith-testbox / openclaw-check, lease
tbx_01m42qfrjxbr0vyyxa4502eaja, Node 24.19.0, four logical CPUs, verified Testbox run. One active command at a time; source identities and a clean tree were checked around every phase.core-runtime-config-hosted-6CI cohort with old cleanup, via the canonical shard runnerpnpm tsgo:test:uipnpm check:architecturenode scripts/check-changed.mjs --base 5ba176891779e0a655d2bfcd6d977b29c08d749c --head 2df48c3c345a821a5439cb98074c41f110b6fd5d --timedpnpm build:ci-artifactsnode scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog ...2026.9.8updater × candidate throughscripts/e2e/published-driver-update-docker.shCurrent package SHA-256:
3b9d80464b118fceb7801ee0c3bbee581511e9d6809d8279d3961c111553f823. Packaged and running build ID:2026.9.8-2df48c3c345a-2026-10-04T06-16-15.874Z. The updater test verifies this exact build, not only the unchanged version string. It was refreshed after integration because main changed canary progress-writer admission.The complete build log reported the TypeScript 7 experimental-API notice and a CSS advisory: 50,590 B gzip, 610 B below the hard ceiling. Startup JavaScript was 372,648 B, below its 373,454 B enforced limit. No budget was changed or waived; no matched-base attribution is claimed.
CI repairs and limits
The first full CI run exposed a misplaced existing Kysely annotation and an inherited native-Node formatter import regression. The annotation now attaches to the SQL expression the guard inspects, without changing SQL, types or bindings. The formatter dependency already existed; its native
.tsimport repair was subsequently inherited from main. Both original jobs passed on the next run.That next run exposed three stale UI tests after main shared spinner keyframes and changed the MCP capability signature, plus a raw SQLite fixture cleanup race. The UI tests now require actual animation effects in the expected running/paused states and use the current capability call, retaining reduced-motion, interaction, geometry, accessibility and cursor assertions. The fixture now awaits the existing retirement owner only after the expected lineage refusal; the synchronous invalidation inside the mutation callback remains. Its original lock holder is unproven, and the single old-code cohort did not reproduce it. No production lock-leak claim is made.
All task-owned Testbox leases are stopped and confirmed absent; all rig worktrees have been removed. The final Testbox workflow's lease-holder check is cancelled after the intentional stop; all proof commands above completed successfully before teardown. No local heavy validation ran, and no operator Gateway was modified or restarted. The updater cell does not force Btrfs or legacy-root relocation; focused Doctor regressions cover those paths. No production deployment, hourly heap-slope, or throughput proof is claimed. Generic provider HTTP socket retention remains a separate follow-up.
Retained complete lifecycle checkpoint on 3d7d2fc
Full lifecycle proof used reviewed head
3d7d2fc4584ca0632f05165d554f397bca9925e0, tree5bcd08a5f6ff504165c35d17ef01ca18a4dee2a2, pinned main base8a0b0c458bbdac520a8f99b4735144722f698be7. Independent review passed through P2, including the final transcript-import and admission-reply corrections. At that checkpoint, all eight retained commits replayed patch-identically during its conflict-driven rebase; upstream's replacement fixture repair superseded our duplicate commit.That checkpoint used blacksmith-testbox / openclaw-check, lease
tbx_01m42htwn445f41jd4n4r1n4nn, Node 24.19.0, verified Testbox run. One command ran at a time, with exact source checks before and after. The earlier rig gate was interrupted after its base was superseded and is not counted as a passing gate.3d7d2fcpnpm testandnode scripts/run-vitest.mjsnode scripts/check-changed.mjs --base 8a0b0c458bbdac520a8f99b4735144722f698be7 --head 3d7d2fc4584ca0632f05165d554f397bca9925e0 --timedpnpm build:ci-artifactsnode scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog ...2026.9.8updater × candidate throughscripts/e2e/published-driver-update-docker.shfinished, readiness 200, update exit 0, and exact serving build-ID equality. Build/package/driver command completed in 376.497s.3d7d2fcCandidate package SHA-256:
2fd9f12ca45766abccaf28572b9322868188c4562a0267d18017f37d683fcd25. Packaged and running build ID both equal2026.9.8-3d7d2fc4584c-2026-10-04T04-55-54.399Z; this same-version test verifies the installed build, not only its version string.The complete build log reported the TypeScript 7 experimental-API notice and a startup-CSS advisory: 50,756 B gzip, with 444 B hard-ceiling headroom. Startup JavaScript was 372,866 B, below the 373,454 B enforced limit. No budget was changed or waived, and no matched-base attribution is claimed. A bounded full-log warning extraction passed in 4.387s on the same lease.
Regression evidence and test cost
Real damaged-index fixtures exposed both missing fresh claims and conflicting claims; the indexed maintenance implementation failed both counterexamples. The replacement requires refusal without changing source bytes or quarantine, and still accepts genuinely dead/stale owners. Existing tests preserve ordinary runtime quarantine refusal and inspection of current, newer, and quarantined schemas. Native cleanup failures remain fatal; disposable snapshot cleanup follows the snapshot owner's warning/retry contract.
Earlier gates caught a new main-thread SQL site and an oversized dispatcher. The query moved into the existing read worker; the final low-level helper preserves Doctor's distinct pre-runtime schema-admission contract. SQL and size limits were not raised. CI also caught detached-helper export inventory omissions and stale fixtures that assumed global worker counts or always-present empty runtime carriers; those fixtures now assert their actual owner and current request behavior. Upstream fixes were inherited by rebase, not copied or cherry-picked.
Historical one-worker retention proof: six files, 14 tests, 24.83s runner wall, including 14.50s shared cold subprocess compilation. Individual
pnpm test <file> --maxWorkers=1CI-environment wall times were LLM/provider 18.73s (14.59s cold compilation), lifecycle timers 6.96s, SQLite creation 6.38s, queue/timers 6.17s, native-source/question cleanup 5.59s, Code Mode 8.06s, and command queue 8.93s. All 42 command-queue tests passed. Real native resources are required to reproduce async-context retention; bounded GC yields replace sleeps.Rig proof uses the repository's compiled-subprocess preparation owner, actual resource fixtures with
--expose-gc,node --import ./scripts/tsx.mjs scripts/build-all.mts sourcePerformance, and the synthetic two-turn dist Gateway harness. Processes run at low CPU/I/O priority with task-owned state and temporary directories. No heap snapshots or private runtime data were uploaded.