Skip to content

perf(agents): reduce main-thread SQLite during retirement - #167547

Merged
steipete merged 14 commits into
mainfrom
dbasync/w6retire
Oct 9, 2026
Merged

steipete merged 14 commits into
mainfrom
dbasync/w6retire

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #166889

What Problem This Solves

Agent and Claw retirement still perform SQLite work on the Gateway main thread. Moving it to workers must preserve the original cleanup authority through session purge, archive publication, workspace removal, and rollback.

User Impact

Retirement keeps the existing cleanup owner through database commit and post-commit archive publication. Agent creation, deletion, recovery, and Claw removal retain their existing data and permission contracts. There are no schema, durability, retention, permission, or configuration changes. Historical generations remain under the retention owner; deletion selects removed-entry references and preserves surviving references.

This is administrative work. Moving SQL to a worker is not a total statement saving, and this PR does not claim the warmed-turn budget has been reached. The shared workload passes the documented noise-floor qualification. The additional worker requests and longer deletion wall time are an accepted cost for this rare, user-triggered administrative operation. The retained admission work is assigned to the checkonce follow-up; it does not block this PR.

Why This Change Was Made

The existing deletion owner coordinates journal/provenance, session purge, workspace state, execution policy, and Claw bookkeeping through the shared-state writer and canonical agent executor. It retains the real cleanup lease and shared journal transaction through agent COMMIT, preserving agent-before-shared lock order, FIFO, accepted-work settlement, and acknowledged commit receipts.

Physical stores, filesystem targets, and archive plans are captured before yielding. Workers reread authoritative rows inside synchronous transactions; foreign commits, changed references, replaced stores, and lost authority refuse stale work. Post-commit archive and maintenance publication use that same captured owner. Immediate host effects retain live native final guards; config removal uses the existing awaited beforeCommit hook followed by its synchronous host guard.

The running-Gateway Claw transport from the linked change remains intact: the serving Cron owner mutates its history, while the original deletion lease retains remote begin/rollback custody. Superseded internal synchronous paths are removed with their callers.

Evidence

Six paired administrative runs reduce deletion SQL from 1,924 to 1,618 and MAIN SQL from 1,521 to 336. Logical worker operations increase 80.7 to 144.7, and median deletion wall time increases 1.745 to 3.158 seconds. The request/time increase is accepted for rare user-triggered deletion; shared turn counts are separately qualified below. Static T1 falls 787 to 748 (symmetrically classified: 769 to 748).

Source pins: baseline 54644eab32b26de36a6668fad06493bb5d1513b9; final candidate tree 1519090cd389409e178842dcdbdb1050172c934f. This includes the existing expected-schema cache fix from #167001 (77b322b07daad) plus the retirement cutover. Runtime savings from that imported dependency are attributed separately. Reviewed head: 2c49a11c6b9377c944fe0acc8f49e1a3d0f4911d.

Static retirement and size

Inventory Baseline Candidate Change
Raw T1, each revision's classifier 787 748 −39
Symmetric T1, candidate classifier on both sources 769 748 −21
T2 373 380 +7
T3 252 247 −5
Worker sites 1,071 1,100 +29

The 18-site raw/symmetric difference represents actual caller cutovers: workspace 8, legacy/session comparison 6, journal completion/handoff 2, recovery holds 1, and provenance deletion 1. Static retirement is separate from runtime savings. The imported schema cache commit changes none of these counts. Final inventory and all 43 original-site qualifications are retained in integration-54644/c218-static-refresh/.

Change size and retained native contracts
Category Files Added Removed Net
Production 130 5,861 2,410 +3,451
Tests/support 73 3,132 753 +2,379
Docs/generated inventory 3 206 127 +79
Tooling/configuration 2 66 18 +48
Total 208 9,265 3,308 +5,957

The imported upstream dependency contributes 502 additions and 19 deletions across 16 files, including 78 net production lines. The final two-file purge-loader separation adds seven net lines and keeps the same operation handlers and guard paths. The remaining growth implements typed worker contracts, retained admission and settlement, physical purge/archive plans, commit receipts, and rollback custody across existing owners. Superseded internal native paths and dead readers are removed. Tests protect freshness, live authority, surviving references/generations, publication, and accepted settlement.

Released synchronous SDK callbacks, native initialization/Doctor paths, and immediate final-effect guards retain their named contracts and removal conditions in worker-access.md. Preparation reads for recovery holds, team creation, and Claw monitor fencing now use the existing reader. OAuth polling and Cron enqueue/wake/acceptance guards remain synchronous immediately before their effects.

The upstream cache fix shares canonical comparison definitions through the existing worker launcher. Actual shared-state schema inspection remains in the existing generic admission owner; this PR adds no retirement-specific validation scan or per-call schema/version check. Its measured admission cost stays in the totals.

Shared-workload statements and requests

Three alternating pairs on the same AWS host; both revisions used Node 24.21.0, pnpm 12.5.1, canonical package builds, and identical synthetic fixtures. Cells are medians [min–max] across runs. Warmed cells normalize each run over ten turns. All threads, child processes, startup, and cleanup stay counted. Requests are canonical logical submitted operations; separately observed admission requests and transport limits are reported for direct operations.

Phase All-thread SQL, M → C MAIN SQL, M → C Logical requests, M → C Seconds, M → C (ratio)
Boot 2,667 [2,667–2,667] → 2,333 [2,332–2,333] 1,812 [1,812–1,812] → 1,945 [1,945–1,945] 58 [58–58] → 58 [58–58] 9.927 [9.899–11.312] → 9.861 [9.805–13.471] (0.993×)
Connect 375 [367–379] → 378 [373–381] 60 [60–60] → 60 [60–60] 56 [56–56] → 56 [56–56] 1.168 [1.167–1.169] → 1.171 [1.169–1.184] (1.003×)
First turn 3,509 [3,506–3,526] → 2,905 [2,869–2,921] 74 [74–74] → 74 [74–74] 389 [389–389] → 389 [388–389] 7.971 [7.948–8.304] → 7.913 [7.868–8.224] (0.993×)
Warmed turn (ten-turn mean per run) 1,343.5 [1,343.2–1,344.6] → 1,344.6 [1,344.5–1,344.9] 0 [0–0] → 0 [0–0] 311.2 [311–311.3] → 311.4 [311.4–311.4] 1.896 [1.887–1.896] → 1.889 [1.879–1.893] (0.997×)
Second session 4,589 [4,586–4,592] → 4,580 [4,571–4,582] 71 [71–71] → 71 [71–71] 911 [910–911] → 909 [909–910] 7.543 [7.481–7.972] → 7.421 [7.404–8.16] (0.984×)
Control-plane reads 40 [40–40] → 41 [40–41] 0 [0–0] → 0 [0–0] 5 [5–5] → 5 [5–5] 1.088 [1.084–1.09] → 1.087 [1.084–1.089] (0.999×)
Cron 1,843 [1,824–1,845] → 1,374 [1,374–1,405] 44 [30–44] → 44 [44–44] 212 [209–212] → 212 [212–212] 5.45 [5.446–5.474] → 5.45 [5.435–5.451] (1.000×)
Compaction 572 [572–573] → 574 [573–574] 30 [30–30] → 30 [30–30] 85 [85–85] → 85 [85–85] 1.53 [1.469–1.555] → 1.473 [1.473–1.578] (0.963×)
Shutdown 1,223 [1,222–1,223] → 1,021 [1,021–1,022] 401 [401–401] → 200 [200–200] 113 [113–113] → 113 [113–113] 2.085 [2.067–2.109] → 2.082 [2.048–2.105] (0.999×)

Qualified shared pass: warmed SQL increases by 1.1/turn (+0.0819%), below the 0.5% noise floor, with duration ratio 0.9968. Exact ten-turn SQL deltas are [+14, −1, +14]; logical-request deltas are [+2, +1, +4]. Every positive query shape exists in baseline; all 25 producing/helper blobs are unchanged. The increased row-facts requests come from the existing projection refresh/drain path. No retirement command appears. This is not a strict-decrease or warmed-saving claim.

Connect (+3 median) is unchanged deferred cron/catalog work moving from first turn; the cron mutation contributes exactly 13 statements across connect+first in every run. Control (+1) and compaction (+2) are existing content-marker/checkpoint work. All shared duration ratios are valid. The full imported expected-schema compiler subtree saves exactly 1,605 statements in each complete workload: boot −335, first turn −601, cron −468, shutdown −201. Whole-workload deltas [−1,610, −1,614, −1,578] equal that −1,605 plus residual timing/read-work deltas [−5, −9, +27]. Credit these compiler savings to #167001; no additional causal retirement saving is claimed in chat.

Evidence: final-1519090cd389/shared-attribution-audit.md, shared-savings-additive.md, exact stack partitions and source-identity receipts.

Direct owner and compiled entrypoint measurements

Six alternating owner pairs; each administrative run performs three complete create → session → delete-with-files cycles. All 18 candidate deletions passed strict archive/purge validation. Cells report median [min–max] of per-run operation means. Setup and shutdown stay counted; combined rows are descriptive and do not hide individual operation costs. Source-mode cold timings include compiler/loading costs and are distinct from the compiled CLI below.

All direct owner phases, statements, requests and duration
Flow All-thread SQL, M → C MAIN SQL, M → C Logical operations, M → C Seconds, M → C (ratio)
admin / boot+connect 3,046 [3,029–3,048] → 2,711 [2,708–2,713] 1,872 [1,872–1,872] → 2,005 [2,005–2,005] 114 [113–114] → 114 [114–114] 11.102 [11.059–11.964] → 10.993 [10.968–13.975] (0.990×)
admin / shutdown 383 [383–384] → 182 [182–182] 350 [350–350] → 149 [149–149] 7 [7–7] → 7 [7–7] 0.417 [0.401–0.429] → 0.414 [0.404–0.425] (0.993×)
admin / whole invocation 15,542 [15,533–15,556] → 12,302.5 [12,243–12,318] 7,770 [7,766–7,788] → 4,108 [4,018–4,110] 569 [569–571] → 775 [766–779] 25.648 [25.535–26.432] → 29.488 [28.657–32.622] (1.150×)
admin / create 462.333 [461.667–468] → 464.167 [464–475] 293.333 [293.333–293.333] → 280 [280–280.667] 42 [42–42.333] → 45 [45–46.667] 1.243 [1.241–1.256] → 1.249 [1.24–1.259] (1.005×)
admin / session 1,651.333 [1,651.333–1,651.333] → 1,054.667 [1,044–1,056] 35 [35–35] → 35 [34.333–35] 26.667 [26.667–26.667] → 28 [26.667–28.333] 1.708 [1.685–1.72] → 1.609 [1.599–1.649] (0.942×)
admin / delete 1,923.833 [1,921–1,928.667] → 1,617.5 [1,596.333–1,622] 1,521 [1,519.667–1,527] → 336.333 [306.333–337] 80.667 [80.667–81.333] → 144.667 [141.667–146.333] 1.745 [1.739–1.748] → 3.158 [2.909–3.5] (1.810×)
lifecycle / setup 1,640 [1,640–1,640] → 1,712 [1,712–1,712] 1,634 [1,634–1,634] → 1,616 [1,616–1,616] 1 [1–1] → 3 [3–3] 4.368 [4.358–4.379] → 9.294 [9.266–9.334] (2.128×)
lifecycle / capture first 4 [4–4] → 2 [2–2] 4 [4–4] → 0 [0–0] 0 [0–0] → 1 [1–1] 0.004 [0.004–0.004] → 0.081 [0.079–0.085] (19.068×)
lifecycle / capture warmed 4 [4–4] → 2 [2–2] 4 [4–4] → 0 [0–0] 0 [0–0] → 1 [1–1] 0.002 [0.002–0.002] → 0.003 [0.002–0.003] (1.461×)
lifecycle / preparation first 4 [4–4] → 2 [2–2] 4 [4–4] → 0 [0–0] 0 [0–0] → 1 [1–1] 0.003 [0.003–0.004] → 0.004 [0.004–0.005] (1.304×)
lifecycle / preparation warmed 4 [4–4] → 2 [2–2] 4 [4–4] → 0 [0–0] 0 [0–0] → 1 [1–1] 0.002 [0.001–0.002] → 0.003 [0.002–0.003] (1.436×)
lifecycle / final authority first 4 [4–4] → 2 [2–2] 4 [4–4] → 2 [2–2] 0 [0–0] → 0 [0–0] 0.002 [0.002–0.003] → 0.003 [0.002–0.003] (1.295×)
lifecycle / final authority warmed 4 [4–4] → 2 [2–2] 4 [4–4] → 2 [2–2] 0 [0–0] → 0 [0–0] 0.002 [0.001–0.002] → 0.002 [0.001–0.002] (0.951×)
lifecycle / preparation+final first 8 [8–8] → 4 [4–4] 8 [8–8] → 2 [2–2] 0 [0–0] → 1 [1–1] 0.005 [0.004–0.007] → 0.007 [0.006–0.008] (1.300×)
lifecycle / preparation+final warmed 8 [8–8] → 4 [4–4] 8 [8–8] → 2 [2–2] 0 [0–0] → 1 [1–1] 0.004 [0.003–0.004] → 0.005 [0.004–0.005] (1.197×)
lifecycle / capture+preparation+final first 12 [12–12] → 6 [6–6] 12 [12–12] → 2 [2–2] 0 [0–0] → 2 [2–2] 0.01 [0.008–0.011] → 0.088 [0.086–0.092] (8.939×)
lifecycle / capture+preparation+final warmed 12 [12–12] → 6 [6–6] 12 [12–12] → 2 [2–2] 0 [0–0] → 2 [2–2] 0.006 [0.004–0.006] → 0.008 [0.006–0.008] (1.290×)
lifecycle / foreign preparation+final 8 [8–8] → 5 [5–5] 8 [8–8] → 2 [2–2] 0 [0–0] → 1 [1–1] 0.004 [0.003–0.004] → 0.005 [0.004–0.005] (1.228×)
lifecycle / deletion begin 584 [584–584] → 29 [29–29] 27 [27–27] → 0 [0–0] 2 [2–2] → 2 [2–2] 3.251 [3.247–3.271] → 0.667 [0.66–1.072] (0.205×)
lifecycle / deletion capture+preparation+final 6 [6–6] → 7 [7–7] 6 [6–6] → 2 [2–2] 0 [0–0] → 2 [2–2] 0.005 [0.003–0.007] → 0.008 [0.007–0.008] (1.670×)
lifecycle / rollback 31 [31–31] → 22 [22–22] 31 [31–31] → 0 [0–0] 0 [0–0] → 2 [2–2] 0.014 [0.014–0.014] → 0.019 [0.018–0.02] (1.343×)
lifecycle / rollback recovery 8 [8–8] → 5 [5–5] 8 [8–8] → 2 [2–2] 0 [0–0] → 1 [1–1] 0.002 [0.002–0.002] → 0.003 [0.003–0.003] (1.714×)
lifecycle / whole invocation 2,420 [2,420–2,420] → 1,855 [1,855–1,855] 1,856 [1,856–1,856] → 1,650 [1,650–1,650] 5 [5–5] → 36 [36–36] 7.767 [7.74–7.793] → 10.221 [10.179–10.6] (1.316×)
team / setup 2,229 [2,229–2,229] → 2,009 [2,009–2,009] 589 [589–589] → 349 [349–349] 5 [5–5] → 6 [6–6] 10.239 [10.217–10.289] → 10.198 [10.179–10.253] (0.996×)
team / first preflight 20 [20–20] → 21 [21–21] 16 [16–16] → 4 [4–4] 2 [2–2] → 6 [6–6] 0.04 [0.038–0.061] → 3.927 [3.911–3.944] (99.090×)
team / rollback 34 [34–34] → 29 [29–29] 31 [31–31] → 0 [0–0] 1 [1–1] → 3 [3–3] 0.017 [0.017–0.017] → 0.029 [0.028–0.03] (1.736×)
team / whole invocation 2,449 [2,449–2,449] → 2,225 [2,225–2,225] 761 [761–761] → 398 [398–398] 30 [30–30] → 78 [78–78] 10.505 [10.482–10.577] → 14.436 [14.412–14.505] (1.374×)
team / warmed preflight 16 [16–16] → 16 [16–16] 12 [12–12] → 4 [4–4] 2 [2–2] → 6 [6–6] 0.017 [0.016–0.017] → 0.024 [0.024–0.025] (1.468×)
lifecycle / foreign writer 1 [1–1] → 1 [1–1] 1 [1–1] → 1 [1–1] 0 [0–0] → 0 [0–0] 0.009 [0.007–0.013] → 0.009 [0.007–0.01] (0.974×)
lifecycle / rebind 4 [4–4] → 2 [2–2] 4 [4–4] → 0 [0–0] 0 [0–0] → 1 [1–1] 0.002 [0.001–0.002] → 0.003 [0.002–0.003] (1.417×)
lifecycle / cleanup 6 [6–6] → 6 [6–6] 5 [5–5] → 5 [5–5] 2 [2–2] → 2 [2–2] 0.041 [0.039–0.043] → 0.041 [0.037–0.044] (0.995×)
team / cleanup 6 [6–6] → 6 [6–6] 5 [5–5] → 5 [5–5] 2 [2–2] → 3 [3–3] 0.044 [0.042–0.045] → 0.036 [0.035–0.041] (0.831×)

Accepted rare-administration cost: 1.745 s [1.739–1.748] → 3.158 s [2.909–3.500], ratio 1.809647 after six alternating pairs. Logical worker operations rise from 80.667 to 144.667. This wall-time increase is explicitly accepted for user-triggered agent deletion; the 1.5× duration-skew rule protects statement-comparison validity and is not an admin-operation latency gate. The values remain reported in full, with no whole-operation speedup claim. The purge receive-to-first-logged-admission interval changed from 670.451 ms to 512.661 ms; this span includes loading, scheduling and observer costs, and is not a measured import-only or whole-operation saving.

The native compiled agents team create pending-last-member refusal passes three alternating pairs: all SQL 206 [206–206] → 78 [78–78], runtime MAIN 148 [148–148] → 56 [56–56], logical operations 4 [4–4] → 9 [9–9], elapsed 6.084 s [6.082–6.139] → 5.019 s [5.013–5.064], ratio 0.825. The original journal remains held, and config bytes, workspaces and member directories remain unchanged. This proves refusal before partial publication, not successful team creation.

Compiled proof boundary All SQL M → C Combined main-thread SQL M → C Logical operations M → C
Fixture setup 2,358 → 2,138 655 → 415 14 → 15
Owner wait while CLI runs 0 → 0 0 → 0 0 → 0
CLI 206 → 78 148 → 56 4 → 9
Verify and rollback 40 → 31 35 → 0 2 → 4
Cleanup 6 → 6 5 → 5 2 → 2
Whole fixture, including CLI 2,610 → 2,253 843 → 476 22 → 30

Each count in the fixture table is constant across all three runs on its side. Source compiler exchanges are separately 4,474 → 4,495 per whole fixture; none executes SQLite.

Statement and request attribution

The compiled CLI removes 116 snapshot staging/retirement-helper statements and 12 reader admission/freshness statements (20 → 8). All four journal SELECTs remain and move from MAIN to the worker; the other 66 CLI statements are unchanged. The five added logical operations are four agentRecovery.creationJournal reads and one resource-close request. This 128-statement saving is retirement work, not imported schema-compilation savings.

The deletion table below is additive arithmetic means across all 18 operations, separately from the median gate above. It conserves the complete SQL delta; thread movement itself earns no saving.

Delete statement class Baseline mean Candidate mean Delta
deletion-journal shape probe 135.667 0.000 -135.667
foreign-commit freshness probes 494.278 342.667 -151.611
journal/lease authority and snapshot reads 440.056 412.778 -27.278
machine marker reads 374.778 200.278 -174.500
other SQL 332.611 445.389 +112.778
transaction envelope 146.889 213.333 +66.444

Savings remove per-call journal shape probes and redundant freshness/machine-marker work; live authority and foreign-commit observations remain. Extra transaction envelopes and cold admission offset part of those savings. All 18 candidate deletes still have 67 real shared-file admission statements: 5 catalogs, 12 additional shape pragmas, 19 metadata/table-existence, 10 versions, 8 marker/ownership, 11 connection/other pragmas, and 2 transaction statements. No scratch-schema compilation is included in those 67. Connection setup and live authority are not all removable; removing this repeated admission sequence belongs to the approved checkonce follow-up.

Delete exchanges per operation, median [min–max] M → C
Logical submitted operations 80.667 [80.667–81.333] → 144.667 [141.667–146.333]
Separately observed admission requests 14.667 [14.667–15] → 162.667 [161.333–162.667]
Observed transmissions, lower bound including replies 176 [176–177.667] → 452.167 [444.667–455.333]

The admission increase is +148 per deletion. Candidate admission stages are open 4, prepare 40, transaction 61.333 and commit 57.333. The 25 assertCurrent and 9 fencePaths operations are subsets of logical requests, not additional counts to sum again. Native-commit/settlement and attachment notifications, unrecognized control frames and shared-memory grants/refusals are outside the observer; no exact count of every transport message is claimed.

Lifecycle capture/preparation/final comparisons each reduce 4 → 2 SQL by combining provenance/journal reads and removing duplicate freshness probes. Preparatory reads each add one logical worker operation; the final check remains native and adds none. Warm team preflight keeps 16 SQL, moves MAIN 12 → 4, and increases logical operations 2 → 6. These are explicitly attributed administrative moves, not request savings.

Imported #167001 is separate: full expected-compiler-subtree savings are 2,339 per administrative fixture, 468 per lifecycle fixture, 201 per source team fixture, and 1,605 per shared chat fixture. It removes the 468 scratch statements induced by the earlier retirement-only candidate; baseline deletion already had zero such statements, so those 468 are not claimed as baseline-delete savings.

The baseline recorded administrative BEGIN IMMEDIATE execution-error counts [4, 5, 4, 6, 4, 4]; candidate [0, 0, 0, 0, 0, 0]. Both sides completed their operations. These diagnostics remain separate from the harness successful-statement totals.

Complete raw accounting, phases, controls, compiler qualification and timings are in final-1519090cd389/six-pair-owner-control-report.md and its JSON companions.

Correctness and checks

Proof Verified result Evidence
Cleanup owner and archive publication 29 unchanged cases passed; the corrected bulk-maintenance case passed separately (42.67 s wrapper, 6.508 s case). This is not one all-green 30-case invocation. archive-owner-regression-proof.md, archive-owner-positive.log, archive-owner-maintenance-positive-2.log
Purge and worker creation 23/23 passed; 205.33 s wrapper archive-owner-session-positive.log
Final integration: workspace state/read, alias rebind, attestation, OAuth lifecycle, worker admission 158 passed, one existing Unicode-filesystem skip; six files, 201.39 s wrapper integration-54644/focused-integration-final.log
Regression negative control Both selected cases failed for the intended defect: deleted-agent reclaimer admission refused; warm surviving store performed 38 host SQLite statements instead of zero. Positive owner routing passed. archive-owner-negative-control.log, archive-owner-regression-proof.md
Knip files/dependencies Final 1519 passed, 56.85 s final-1519090cd389/followup-result/knip.log
Madge Final 1519: zero cycles, 18.88 s final-1519090cd389/followup-result/madge.log
Independent P2 review Full integration review plus subsequent deltas passed. The full C218 Codex review and final loader-delta review are scoped-clean, with no actionable P0–P2 findings. Static review did not execute tests. integration-54644/autoreview-c218-p2-status.json
Full changed-file checks Full C218 and final loader-delta checks passed: formatting, ratchets, production types, all 27 core test-typecheck shards, export scans, lint, and guards integration-54644/check-changed-c218.log
Creation preparation regressions All 3 selected C218 checkpoint cases passed; 22 unselected. Wrapper 673.378 s, including 303.121 s worker preparation; Vitest 286.88 s. No timeout changes. local-prep-positive-c218-20261008T214418Z/result.json

The initial bulk fixture omitted explicit roster ownership, causing the documented unavailable-config fallback to select warn mode. After correcting ownership, a second fixture expectation incorrectly demanded deletion of an ordinary aged conversation. The final fixture asserts its in-place soft archive and uses a stale synthetic hook to prove physical maintenance deletion and archive publication. Neither failure justified changing production retention. The negative control restored the original positive source bytes before subsequent proof; the exact failures, restoration hash, and timings are in archive-owner-regression-proof.md.

The first loaded-Mac full creation run finished 21/25. One new assertion failed only because raw fixture config had not yet received the existing migration metadata; the fixture now publishes canonical config before capturing its bytes, and strict byte equality passes. Two existing 120-second timeouts and a following admission invalidation remain recorded. The team run was interrupted after its first passing case; the monitor file did not start. The original-order clean-host C218 run subsequently passed: 194 tests across all six complete files, with two existing query-diagnostics capability skips, in 198.61 s. A passing replay does not establish a fix for the earlier timeouts. No production change or longer timeout was used to conceal these results.

These are measured wrapper/test times, not CI seconds. Changed-test CI seconds were not yet observed; they are not inferred from local elapsed time.

Final SDK, package, and gate disposition

Final SDK compatibility passes for tree 1519090cd389: all 151 entrypoints, 3,641 direct public declarations, and 8,496 named declaration records match baseline. The canonical report has 131 reachable-only changes across 24 entrypoints (20 replaced and 271 added private namespace records), reviewed digest 964686a1; this is not a zero-diff claim. The final loader change affects exactly one private namespace, and its combined command handler types remain identical. Canonical rendering passed in 272.31 s; comparison took 0.746 s. The source tree and all saved render hashes were verified. Evidence: final-loader-1519090cd389/sdk-api-result-final.json and sdk-compatibility-review.md.

Final source validation passed: fresh Codex P2 review of the loader delta (following the clean full retirement review), changed-file checks including all 27 test typegraphs and three export scans, Madge with zero cycles (18.88 s), Knip files/dependencies (56.85 s), and all 42 cases in the three complete purge/cleanup files (135.40 s). The final package built in 433.83 s. Exact package SHA256: 6c70e17293120569415f67dd5ccd95dac2a8a366a0af776eb40a435f15347ffe.

The published 2026.9.8 driver successfully updated to that exact package in 437.42 s, preserving the fixture's durable state and reaching readyz 200 on version 2026.9.9. The running-Gateway Claw/Cron custody E2E is reused from D74 because its custody/rollback and transport code is unchanged; the final loader is exercised by the fresh compiled administrative flow and full purge suites. No final-source custody E2E rerun is claimed.

Accepted costs and follow-ups. The maintainer approved publication of this exact head with the measured rare-admin request and wall-time costs. Every final delete retains a 67-statement shared-file admission sequence, including five catalog scans, twelve further shape queries, and ten version reads. Lane checkonce owns sharing admitted physical-database facts across workers under CHECK ONCE ON LOAD; that follow-up will remove the repeated admission work when it lands. This PR retains and counts it without importing unfinished work or introducing a second admission design.

The 25 current-authority operations and nine path-fence operations span awaited work and privileged effects. Combining them safely would require a broader lifecycle/authority change; no low-risk per-item batching change was identified. Their live checks, lock order, rollback custody and COMMIT settlement remain intact. The final purge-loader separation already removes unrelated turn preparation without changing those contracts.

The compiled CLI's first proof attempt reached the correct pending-deletion refusal and preserved all config/workspace assertions, then failed in analysis because zero-SQL esbuild exchanges reused process-local IDs. A derived proof adapter namespaces only those proven compiler exchanges by PID, preserves every raw SQL byte and census event, and identifies the actual runtime MAIN process through its unique same-argv launcher chain. Canonical observer/analyzers and product assertions are unchanged. All three repaired compiled CLI pairs pass; every raw row remains retained. The report above includes those results and all six final owner pairs. The rare-admin timing and admission follow-up are accepted as described above; the shared turn proof retains its separate noise-floor qualification.

Evidence preservation and closeout

The final head and package are bound by source tree 1519090cd389409e178842dcdbdb1050172c934f; the package and raw evidence are retained locally. The sole AWS lease cbx_7c0c05fcfb0b is released with cleanup complete and no remaining host/resource; its controller and normal proof slot are released. Remote capacity waits and prior failed fixture/transport attempts are retained in the evidence.

Remote runs: source build and primary pairs (regular pairs passed; first compiled analysis failed as qualified above), final SDK/static/focused/update. The final extra-pair receipt and raw archives are retained in final-1519090cd389/extra-result.

Landing verification

Candidate: 24b9ab7b1f97f611034f7f18364d999ec85a0ce3, integrated through main ea6dff2bf5294601b370b2db652e80b38fb0359e with merge commits, without rebasing. The session reader conflict adopts main's a73ef559b23a recovery fix and native-reader custody; worker-owned retirement specifically reuses its existing executor and cleanup authority. Normal cold reads retain main's native candidate owner and release ordering. Overlaps with #167115, #166183, #167515, and #167563 preserve their policy worker, trajectory reader, creation admission, and test consolidation respectively.

ClawSweeper's completed review run of 2c49a11c6b93 found package-only durable lease takeover during awaited removal. The final apply/rollback guard now rereads the retained package lease. A real skill-removal regression passes normal removal and preserves installed or staged artifacts on takeover. The negative control failed both takeover cases for the intended unintended-uninstall result. No actionable finding remains; the completed review is reused under the authorized landing policy.

Retained native final-authority debt: src/state/agent-deletion-final-guard.ts:17, consumed by the apply/rollback hooks in src/claws/package-remove.ts:603 and :624, performs one indexed owner/expiry SELECT at the final effect. Preparation stays asynchronous. Raw/foreign package writers prevent cached authority from replacing it; removal requires complete revocation publication at the next SDK boundary. The existing agent-deletion final guard remains with the same owner.

Integration repairs preserve accepted-work settlement, creation identity checks, the awaited MCP removal guard, and complete wrapper inventories. Doctor now awaits its temporary history reader's close before returning; the new immediate-reopen regression failed on the old code and passes after repair. Worker-backed fixtures use their host project and settle resources before deleting temporary data. Main's consolidated migration suite retains the bounded worker-read and awaited-cleanup assertions. No assertions, timeouts, scanner baselines, or runtime permissions were relaxed.

The Kysely guard failure is fixed with typed value expressions instead of raw NULL snippets. Direct SQLite proof passes all four provenance/journal table-presence combinations. The retirement reader fix avoids native authority SQL only inside the exact worker-owned cleanup scope, rechecks host liveness, and retains durable journal/lease checks in worker grants. Warm and cold deletion keep the zero-host-SQL assertion, and stale cleanup rejects. Ordinary read custody stays unchanged.

Local proof: candidate a85ac736 passed 100 focused tests across six files (957.90 seconds wrapper). The subsequent history repair at 8bc89869 passed nine selected cases across four files, including requester custody, cold-source replacement and quarantine preservation (1,250.08 seconds wrapper; 52 unselected). After the latest main integration, the focused warm/cold cleanup and stale-scope cases passed 3/3 (375.43 seconds wrapper; 27 unselected), and runtime build-graph/import checks passed 11/11 (33.71 seconds wrapper). The original full retirement proof above remains source-pinned evidence, not a claim that all tests ran in one invocation. Current production types, dedicated lint, complete Kysely guard and Madge (zero cycles) pass; all 27 post-integration core test-type graphs and the final scoped lint/type refresh passed. Fresh full-candidate and subsequent focused P2 reviews are scoped-clean.

The requester E2E local attempt was refused before execution because test preparation could not verify separation from managed Gateway artifacts. No artifacts were rebuilt and the guard was not overridden; exact-head CI is its proof route. The earlier isolated Linux QA timeout reproduction proved baseline inheritance at 3f76fe0, not current-main success or failure.

CI history: 37874813911 exposed the repaired fixtures and Doctor settlement. 37885438551 tested merge 2e157b2356e9a2591ad5add812e8c9b83214468a (main fd2fa6b9 plus a85ac736): 105 jobs passed, 22 skipped, nine root failures plus the aggregate failed, no cancellations. Its Kysely and retirement SQL failures are repaired. Main a73ef559b23a repairs the independent read-only recovery and sharing-fixture failures. Remaining inherited Windows-update fixture and effort-provider failures have source/log attribution; current-head admission will use only the actual final CI attempt. The Windows package rollback case's precise refusal remains unobserved; no passing replay or baseline reproduction is claimed. Effort's identical Unknown provider "openai" failure was also inspected on main run 37871873098, job 113631794381.

Released SDK audit: the changed retirement declarations, internal callbacks and extracted types have no reachability through released SDK exports, documented subpaths, or api.runtime at v2026.9.9 / v2026.10.1-beta.1. The canonical API diff and published-driver update cell above remain valid source-pinned evidence. Approved alternating SQL proof is reused; no new measurement, package/update run, or changed release contract is claimed. No new OPENCLAW_* name is added.

Final diff against integrated main ea6dff2bf529: tooling/config +69/−16 (net +53); docs +198/−110 (net +88); tests/support +3,150/−982 (net +2,168); production +6,041/−2,683 (net +3,358).

Fix/integration commits: 40b465d37595, e96c7ab55fec, a85ac7367646, 8bc89869a1de, 9c167dd4fc22, c95df3e7970e.

Changed regression cost: the package-takeover command initially took 174.04 seconds including worker preparation (45.43 seconds Vitest; 12.899 seconds for its three cases), and those cases passed again in the integrated 172-test group (722.97 seconds wrapper). The new Doctor immediate-reopen case took 14.144 seconds locally. These are measured local times; CI seconds are not inferred from them.

Completed CI exception evidence before comment-only integration

CI 37892149344, attempt 1 tested 1a183452198d94016d015cea2e09bf78298cb6ce (main 50dd07c229e2162b0a530b53dd682b8d9d04b08e plus exact candidate c95df3e7970eef33ab61f0c0e772afd86554ec8c). It completed with 112 successful jobs, 22 skipped, five inherited root failures and the failed aggregate gate; no cancellations. Security-fast passed. These are independently attributed baseline failures, not a green CI claim:

  • Two pending-input suites retain observer-throw expectations after main da67a08b20eb deliberately made publication observers non-throwing. The tests and publication/transaction owners are unchanged in the tested merge.
  • Eighteen accepted-facts cases fail in unchanged shared fixture setup: main a73ef559 adds an inner native retention release, while the fixture counts only the outer release sequence. The retirement-only branch is inactive; failure precedes the per-case callback.
  • Seven Windows-update fixture cases use unchanged update/artifact/rollback owners and dependencies. Five log retained fixture artifact locks; the package rollback case's exact refusal remains unobserved. These mocked update paths do not exercise retirement.
  • The update-service job passes all 149 assertions but leaks one restart promise during teardown. Main 40d57f8 made the fixture restart asynchronous; the unchanged detached-handoff test does not join it before closing shared state.

The native admin evidence binds the actual checkout, ordered parents and merge tree, exact head/run/attempt, all five root jobs and the aggregate, source equality, and hashed logs/qualification receipts. No PR-caused failure or security gate is waived.

The latest merge 24b9ab7b1f97 resolves only the explanatory comment accompanying main's independently landed, identical cold-quarantine fixture correction (18cade08699b). The conflicted file is preserved exactly from main; retirement runtime code and prior focused/P2 evidence are unchanged. Post-integration production types, the affected agent-session test graph, and Madge (zero cycles) pass. CI run 37896369372 is bound to the new exact head; any inherited exception must be rebound to that attempt rather than reusing the previous head's admission.

Current-head CI disposition

CI 37896369372, attempt 1 tested b6d804d6eafcd52eca11df5def43770bd6707905, merging candidate 24b9ab7b1f97f611034f7f18364d999ec85a0ce3 into main 09fbd7b1f2836ac7a3b28a302b4306bd8018f1ee. It completed with 109 successful jobs, 22 skipped, three inherited root failures and the failed aggregate gate, no cancellations. Security-fast passed. This supersedes the earlier attempt for admission.

The remaining roots are the same seven unrelated Windows update-fixture failures and 18 accepted-facts fixture-order failures, plus the Bun orphan-recovery case preserves a newer restart marker when cold-restoring a retired accepted receipt. That last rejection occurs in unchanged subagent lifecycle-completion authority after awaiting predecessor registry work and before its transaction. The test, registry queue and recovery owners are unchanged, and no deletion cleanup scope is active. The log does not identify which lifecycle-generation/current-run/recovery-current predicate invalidated; no specific race or baseline replay is claimed.

The native evidence for this exact attempt verifies the real merge object and tree, ordered parents, unchanged relevant inputs in the actual tested merge, exhaustive three-root/aggregate accounting, and hashed artifacts. The main dependency updates are compared against the actual merge, not incorrectly against the older PR branch manifest. All PR-caused failures were repaired; no security requirement is waived.

Use the existing shared writer and canonical agent executor for retirement, with live cleanup authority and the deletion journal held through agent COMMIT. Preserve native final-effect guards, dedicated session generation selection, rollback custody, and acknowledged commit publication.
Preserve the serving Gateway Claw journal transport alongside the coordinated retirement worker owner, including synchronous safety checks within the journal transaction and captured session-store targets.
Preserve cleanup authority and the shared deletion fence through agent commit,
archive publication, workspace retirement, and rollback. Move remaining
preparation reads to the existing worker while retaining final effect guards.

Include the upstream expected-schema cache from 77b322b so cold workers
reuse canonical comparison definitions. Preserve released SDK contracts and
historical-generation selection.
Load the existing purge handlers without preparing turn-only predicates or unrelated compound operations. Preserve command types, cleanup authority, and commit settlement.
@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 24b9ab7b1f97f611034f7f18364d999ec85a0ce3
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/github-oauth-lifecycle-helpers.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/github-oauth-lifecycle.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/exec-approvals-authorization.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-cron-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-mutation.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-retirement.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-sqlite.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-store.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Moves agent and Claw removal database work into workers while preserving ownership through deletion, archive publication, and rollback.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful and supported by production-entry-point evidence, with a coherent owner-preserving implementation and no established patch finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Source-pinned deletion runs and the compiled CLI exercise the changed retirement owners, with observed archive/purge preservation and reduced main-thread SQL. Real skill-removal takeover cases cover final apply and rollback rejection. The recorded published-driver update preserves durable state, and inspected schema changes alter admission caching rather than stored formats; earlier proof remains identified as earlier-source evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Removing an agent or Claw performs synchronous database work on the Gateway's main thread.
Reason: The measured reduction in main-thread SQL serves an established worker-migration direction. The area owner explicitly accepts the additional latency and requests for rare administrative operations.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-owned performance change remains useful and is not implemented on main. No actionable patch defect was established; exact-head CI remains red.

Priority: P2
Reviewed head: 24b9ab7b1f97f611034f7f18364d999ec85a0ce3

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.

Findings

None.

Provenance

  • Legacy session comparison and migration helpers: original intent not found (unknown: Scoped history inspection found recent refactors but did not establish introduction intent; historical blob reads encountered the documented partial-clone limit.)
Agent review details

How this fits together

The Gateway coordinates agent removal across configuration, session databases, workspaces, and installed packages. Its lifecycle owner authorizes cleanup and publishes completed changes after database commits.

flowchart TD
  A[Agent or Claw removal request] --> B[Lifecycle cleanup owner]
  B --> C[Current lease and journal checks]
  C --> D[Database workers]
  D --> E[Session purge and commit]
  E --> F[Archive publication]
  B --> G[Final filesystem and config guards]
  F --> H[Completion or owned rollback]
  G --> H
Loading

Technical review

Best possible solution:

Retain the existing lifecycle owner and worker cutover, preserving current authority checks at final effects.

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

Not applicable to a functional bug: source and paired execution results establish remaining main-thread database work during retirement.

Is this the best way to solve the issue?

Yes: the inspected paths reuse the existing shared writer, agent executor, and cleanup owner rather than creating a competing removal system.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 19c968701cb6.

Provenance checked

  • src/agents/agent-lifecycle-registry.ts and deletion authority keeps the original intent (fix(agents): preserve shared history and deletion retries #141731: Give deletion one callback-scoped live owner spanning asynchronous cleanup and physical database commit, preserving shared history and retry safety.)
  • Session purge, archive publication, and maintenance keeps the original intent (fix(sessions): prevent cleanup from deleting readable transcripts #123495: Commit recoverable transcript archives with deletion and retry derived-file publication without losing readable history.)
  • Claw journal begin and rollback transport keeps the original intent (fix: allow Claw removal with a running Gateway #166889: Use the serving Cron owner while retaining the CLI's original deletion lease and uncertain-outcome custody.)
  • Workspace state and creation recovery holds keeps the original intent (refactor(agents): move workspace state operations off the Gateway thread #163496: Move preparation into existing workers while preserving recovery holds, filesystem guards, settlement, and released synchronous SDK callbacks.)
  • Execution-policy retirement keeps the original intent (fix(gateway): make agent deletion transactional #111678: Prevent a recreated agent from inheriting its predecessor's command authority and retire permissions before roster removal.)
  • GitHub identity lifecycle preparation keeps the original intent (0a86702: Authorize agent GitHub identities from Settings; preparation remains tied to the selected agent identity.)
  • src/config/sessions/session-transcript-worker-read-admission.ts keeps the original intent (a73ef55: Preserve read-only recovery and align worker tests; ordinary native read custody remains intact outside exact worker-owned cleanup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main necessity: Fetched main retains the base lifecycle-registry blob and has no agent-deletion worker at this path, so the central worker cutover remains unique to this PR. (src/agents/agent-lifecycle-registry.ts:138, 19c968701cb6)
  • Retained cleanup authority: The lifecycle owner retains the original deletion lease; worker cleanup validates the journal and lease while holding shared-state custody through the agent commit. Host admission compares transferred guards with the live cleanup owner. (src/state/agent-deletion-cleanup.worker.ts:52, 24b9ab7b1f97)
  • Prior package-lease finding repaired: Package uninstall and rollback use durable final lease checks. The added regression drives real skill removal with ownership intact, takeover before apply, and takeover after staging, and checks retained artifacts and lock state. (src/claws/package-remove.retirement.test.ts:25, 24b9ab7b1f97)
  • Final-effect guard: The package guard performs a current ownership read immediately before filesystem effects; asynchronous preparation does not replace this check. (src/state/agent-deletion-final-guard.ts:17, 24b9ab7b1f97)
  • Inspected runtime and upgrade evidence: The full REST-read body supplies source-pinned alternating deletion runs, compiled CLI refusal with unchanged config/workspaces, archive/purge outcomes, and a published 2026.9.8 updater run preserving durable state and reaching readyz 200. Its captured body identity is af7572fd5679240c96f902b28cc5509f1149c28e447f84ebf5fd4926a3429de2; earlier proof is distinguished from subsequent integration checks. (2c49a11c6b93)
  • Accepted administrative tradeoff: The area owner's PR explicitly accepts increased worker requests and longer rare deletion operations, while reporting lower main-thread SQL separately. Remaining repeated admission work belongs to the recorded checkonce follow-up and is not presented as completed here. (24b9ab7b1f97)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth Production +6,041/−2,683; tests/support +3,150/−982 Production growth supports typed worker contracts and retained lifecycle custody across existing owners; it is substantial but tied to the cutover.
Public configuration additions 0 new configuration options or environment names reported The migration keeps operator configuration and documented defaults intact.

Labels

Label changes:

  • remove status: ⏳ waiting on author: Current PR status no longer selects a status label.

Label justifications:

  • P2: This improves rare administrative operations without evidence of an urgent user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-09T01:22:08.669Z sha 2c49a11 :: needs real behavior proof before merge. :: [P2] Retain the durable package-lease check at final uninstall effects
  • reviewed 2026-10-09T02:42:28.420Z sha 40b465d :: needs changes before merge. :: [P2] Add the recovery-hold reader to the creation mock | [P2] Route newly host-dependent fixtures through the database-worker lane
  • reviewed 2026-10-09T04:10:47.523Z sha e96c7ab :: needs changes before merge. :: none
  • reviewed 2026-10-09T04:55:19.971Z sha a85ac73 :: needs changes before merge. :: none
  • reviewed 2026-10-09T05:46:06.260Z sha 8bc8986 :: blocked before merge. :: none
  • reviewed 2026-10-09T06:23:11.103Z sha c95df3e :: blocked before merge. :: none
  • reviewed 2026-10-09T06:55:37.202Z sha c95df3e :: blocked before merge. :: none

Reviewed October 9, 2026, 3:19 AM ET / 07:19 UTC (Revision 8).

Merge current main into the retirement lane, retaining its exec-policy worker and accepted-work settlement. Restore durable package custody at final uninstall and rollback effects, with real takeover regression coverage. Keep wrapper runtime dependencies complete and preserve internal API callers after integration.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
Await Doctor-owned history readers before returning from reserved-key repair. Route worker-backed lifecycle fixtures through the host project and retain bounded read and live lease assertions.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 9, 2026
Preserve creation identity and accepted-work settlement alongside retirement cleanup ordering. Keep main test consolidation and transfer the bounded worker-read and awaited-cleanup assertions. Post-integration types, lint, 100 focused tests, and P2 review pass; the unchanged model-catalog import cycle remains inherited.
Use cached handle presence only for read-lane selection; preserve worker identity, quarantine, authority, FIFO admission, and settlement. Observe the existing cold discovery lane in two fixtures. Express lifecycle NULL projections through Kysely values.
@steipete steipete changed the title improve(agents): reduce main-thread SQLite during retirement perf(agents): reduce main-thread SQLite during retirement Oct 9, 2026
Resolve the read-admission overlap with main a73ef55 unchanged, preserving its retained native-reader custody and independent recovery reads. Reuse the reviewed retirement and Kysely delta; keep main sharing-fixture repairs. Post-integration type and focused cleanup proof continue on this exact tree.
Borrow the exact live deletion executor during worker-owned cleanup instead of retaining an unrelated native read candidate. Preserve ordinary native custody, cold FIFO admission, and durable worker journal/lease grants. Warm and cold cleanup retain zero host SQL; stale cleanup rejects, and runtime import/build graph checks pass.
The only conflict was the already-equivalent discovery-lane fixture plus a main comment. Preserve main verbatim there and reuse unchanged retirement runtime proof; post-integration types and cycle checks run on the merged tree.
@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Oct 9, 2026
@steipete
steipete merged commit 24d5996 into main Oct 9, 2026
205 of 210 checks passed
@steipete
steipete deleted the dbasync/w6retire branch October 9, 2026 07:53
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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

steipete added a commit that referenced this pull request Oct 9, 2026
The read-only recovery fix in a73ef55 retained native read candidates on every discovery read, adding a second native custody pair around the projection's own read. That reordered custody release and failed the accepted-facts projection boundary (18 of 22 cases in session-row-projection.accepted-facts.test.ts).

Probe the admitted open writer instead, without custody: a refused writer (such as pending startup inspection) is treated as not resident, exactly as the retain's refusal handling did, so execution capture and cold admission re-check it and recovery reads stay unblocked. Keep the deletion-cleanup worker branch from #167547.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…67547)

* refactor: move agent retirement into database workers

Use the existing shared writer and canonical agent executor for retirement, with live cleanup authority and the deletion journal held through agent COMMIT. Preserve native final-effect guards, dedicated session generation selection, rollback custody, and acknowledged commit publication.

* refactor: retire unused deletion readers and complete fixtures

* test(state): verify retirement archive and maintenance outcomes

* perf(agents): move retirement cleanup to retained workers

Preserve cleanup authority and the shared deletion fence through agent commit,
archive publication, workspace retirement, and rollback. Move remaining
preparation reads to the existing worker while retaining final effect guards.

Include the upstream expected-schema cache from 6623b6f so cold workers
reuse canonical comparison definitions. Preserve released SDK contracts and
historical-generation selection.

* refactor(agents): isolate retirement worker command loading

Load the existing purge handlers without preparing turn-only predicates or unrelated compound operations. Preserve command types, cleanup authority, and commit settlement.

* fix(agents): settle retirement readers and align host fixtures

Await Doctor-owned history readers before returning from reserved-key repair. Route worker-backed lifecycle fixtures through the host project and retain bounded read and live lease assertions.

* fix(sessions): keep history routing outside native admission

Use cached handle presence only for read-lane selection; preserve worker identity, quarantine, authority, FIFO admission, and settlement. Observe the existing cold discovery lane in two fixtures. Express lifecycle NULL projections through Kysely values.

* fix(sessions): retain worker cleanup ownership during history reads

Borrow the exact live deletion executor during worker-owned cleanup instead of retaining an unrelated native read candidate. Preserve ordinary native custody, cold FIFO admission, and durable worker journal/lease grants. Warm and cold cleanup retain zero host SQL; stale cleanup rejects, and runtime import/build graph checks pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
The read-only recovery fix in bd46d77 retained native read candidates on every discovery read, adding a second native custody pair around the projection's own read. That reordered custody release and failed the accepted-facts projection boundary (18 of 22 cases in session-row-projection.accepted-facts.test.ts).

Probe the admitted open writer instead, without custody: a refused writer (such as pending startup inspection) is treated as not resident, exactly as the retain's refusal handling did, so execution capture and cold admission re-check it and recovery reads stay unblocked. Keep the deletion-cleanup worker branch from openclaw#167547.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant