Skip to content

improve(reef): reduce native state database work - #168340

Merged
steipete merged 26 commits into
mainfrom
dbasync/t1reef
Oct 10, 2026
Merged

steipete merged 26 commits into
mainfrom
dbasync/t1reef

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Integrated candidate line-cap repair

Commit 90de431ea2b4d builds directly on the lander's integrated candidate 6402e739 (including Doctor fix 86d4ad2f and the main merge). Schema snapshot lifetime handling now lives in src/infra/sqlite-schema-lifetime.ts, imported by the existing schema-facts owner. The standalone content-marker migration/rollback test moves into the existing schema-version suite; its local helper is renamed to avoid shadowing that suite's helper. The function body and test behavior are preserved. Net growth is 14 lines for module/test imports and formatting; limits are unchanged.

File Counted lines before After Limit
src/infra/sqlite-schema-facts.ts 724 684 700
src/state/openclaw-state-db-read-connection.cache.test.ts 1002 927 1000

Focused proof on an isolated, hash-verified copy of this candidate:

  • Seven SQLite/schema/read-connection files: 187 passed, 3 existing native-capability skips, 330.088 s command wall time including fixture preparation.
  • Final schema-version file after the helper rename: 9 passed, 178.092 s command wall time including fixture preparation (24.39 s Vitest execution).
  • pnpm check:madge-import-cycles: 0 cycles, 114.172 s. The subsequent test-local binding rename changes no import edges.
  • Final native core lint on all four changed files: passed, 32.500 s; formatting and git diff --check also passed. The initial shadowing diagnostic is resolved.
  • Fresh Codex P1 autoreview: scoped-clean, under the campaign convergence rule. No new test cases were added; GitHub CI seconds are not claimed.
pnpm test src/infra/sqlite-schema-facts.test.ts src/infra/sqlite-schema-facts.native.test.ts src/infra/sqlite-schema-facts.temp.test.ts src/state/openclaw-state-db-read-connection.cache.test.ts src/state/openclaw-state-db-read-connection.test.ts src/state/openclaw-state-db-read-connection.nesting.test.ts src/state/openclaw-state-db-schema-version.test.ts --maxWorkers=1
pnpm test src/state/openclaw-state-db-schema-version.test.ts --maxWorkers=1
pnpm check:madge-import-cycles
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/infra/sqlite-schema-facts.ts src/infra/sqlite-schema-lifetime.ts src/state/openclaw-state-db-read-connection.cache.test.ts src/state/openclaw-state-db-schema-version.test.ts

The remote lease gate was observed. Testbox never assigned a runner, and the AWS attempt encountered a very slow full-tree sync; both leases are inactive. After more than 30 minutes of accumulated capacity waiting, the campaign's local fallback ran through the proof-slot gate in an isolated shallow checkout (one-minute host load 42.54 at the successful first invocation, 47.48 for the final correction). A frozen-lockfile install and exact file hashes bound the proof to the lane. No passing remote result is claimed for this split.

Per the coordinator, the lander's 326-test and passing published-driver × candidate update proof for 6402e739 is reused: this correction only moves existing code/tests and changes a test-local binding name. It adds no SQL statements, worker commands, schema changes, or runtime behavior. The PR remains READY for the lander; this lane does not land it.


What Problem This Solves

Reef trust, review, and delivery operations repeat SQLite work on the Gateway thread.

User Impact

This is an internal performance change: warmed Reef outbound SQL falls from 168 to 27 statements, and its native-state work leaves the Gateway main thread. Trust, review, audit, and delivery behavior is preserved. No configuration or stored-format change is required.

Why This Change Was Made

The optional PluginStateKeyedStore.createOperation capability sends complete operations to the existing shared-state worker. Each key load, trust/autonomy edit, review decision/capacity operation, and rejection reservation/completion uses one command and one synchronous transaction. Outbound uses two commands around external guard classification: prepare, then finalize the audit chain and exact delivery binding. The transport checks an in-process receipt immediately before relay initiation.

Each operation captures physical database identity, namespace handles, plugin code generation, and live authority before awaiting. Queued mutations invalidate receipts, including writes through path aliases; reads honor earlier pending mutations, and accepted writes settle after caller closure. Quota and expiry facts share one fresh aggregate. Batch queries reuse compiled SQL with fresh bindings and rows. No foreign-commit polling or per-call schema checks were added.

The current host removes the former observation/CAS and synchronous effect-read paths. Released hosts without the additive capability retain their existing adapters, selected before awaits; failures never activate a fallback. The released synchronous ChannelPlugin metadata/security-policy listCurrent contract remains a documented exception. Ordinary listings and effect authority use the worker/receipt path. Schemas, stored formats, durability, retention policy, and permissions are unchanged.

Evidence

Update-path repair: selective operation capture

The lander's built-package proof exposed an update regression: loading Reef's bundled worker module attempted to capture every dependency named by its source manifest. @noble/ciphers was already compiled into the bundle, so no standalone runtime copy existed; capture failed and Doctor exited before session migration.

The fix uses the existing selective-entry capture API for every bundled operation entry in the selected source/build family. A single captured generation follows their actual imports, including shared chunks under the source owner's dist or dist-runtime tree. Custody and native-admission identity cover the complete entry selection; SDK imports still resolve through the separately linked host. External imports retain their normal dependency requirement. No Reef exception, alternate capture mechanism, dependency-manifest change, or duplicate installed dependency was added. The plugin runtime documentation now states this capture contract and its update behavior.

Repair commit: 3872c24ac7071aeae4d3afa2505dbf1b16a9f9c9. The remote build used source carrier 4bd4ac4fe00d3b77fe7554f6e3976787bc74587a; the wrapper verified the full source snapshot and SHA-256 checks confirmed all six changed files match the committed patch before and after proof. Candidate package SHA-256: 5cb6b88fb1c98b3f3acdc2edfd293f3070fa710df5d8968747065548b9e33789.

Repair proof Result
Negative control Restoring the pre-fix loader makes the new capture regression fail with Plugin dependency bundled-away is missing
Capture/loader/native admission 78 tests across five files passed; 52.84 s
Reef focused tests 195 tests across ten files passed; 146.88 s
Combined focused invocation 273 tests passed with pnpm test <15 focused files> --maxWorkers=1; 204 s wrapper wall time; new capture cases total about 616 ms. These are measured remote test seconds, not GitHub CI seconds
Full build and candidate package Passed; build 319.2 s, build/package validation 420 s
Built-CLI session migration Passed in 180 s wrapper wall time: Doctor exit 0, legacy keys imported, at least seven session rows and thirteen transcript events, no active JSONL files
Published driver × candidate Passed: published 2026.9.9 → candidate, 491 s total cell; updater command exit 0 in 396.574 s, durable run succeeded / finished, readiness 200, candidate build identity verified, durable history preserved and incognito history cleared. Candidate Doctor exit 0 (17.996 s), post-update Doctor exit 0 (23.485 s); both lint phases exit 0. Existing fixture/config/advisory warnings remain recorded, with no lint errors
Changed checks check-changed took 641 s and exited 1 only on two inherited unused exports: PUBLIC_SESSION_ENTRY_SCRIPT and isClaudeLikeLiveAgent. Removing this repair reproduces both failures. Current main already makes them private in 06c6e83f4351f and cb1422fb0e52d. Core production and all 27 selected test type graphs passed; T1 has no growth. All nine checks after the dead-code stop point were run explicitly and passed, including zero runtime import cycles. Changed-file lint has zero errors and one 703-line size warning in plugin-generation-artifact.ts; the growth ratchet passed
Entrypoint screening Reef built import completes successfully, peak RSS 154.32 MiB. The profiler marks this as unqualified because the build carrier differs from the later source commit; file hashes match, but this is not claimed as a qualified final-commit latency profile
Review Fresh Codex P1 scoped-clean under the campaign review-convergence rule; no actionable findings; no later source edits

AWS repair proof, lease cbx_02e2d02ec100, ran under the campaign remote lease gate. Testbox first waited about 15 minutes without a runner before the authorized AWS fallback; AWS source sync took 11m19s. The AWS lease is stopped and its campaign remote slot released. The queued Testbox was also confirmed stopped. Protected local staging capsules remain with the native recovery owner; no evidence archive or package was published.

Follow-up checks on the same AWS lease verified source commit 3872c24ac7071aeae4d3afa2505dbf1b16a9f9c9, reproduced the baseline export findings, restored and hash-verified the patch, and completed the remaining checks. Command time was 319.369 s; source synchronization took 10m47s.

This repair adds 38 net production lines, 57 net test lines, and nine documentation lines. It changes capture only: no SQL statements, worker commands, SDK declarations, schema, durability, retention, or permissions change. The historical performance and T1 measurements below retain their original source attribution; they were not remeasured for this repair.

Performance evidence

The scoped performance gate passes for 4eda6352f848253eedbf7660e1c17b6a52d7fed0 against ec7c8bb9454bab03e76057ecc000bfad35897ce9. Three complete alternating M,C pairs exercised the unchanged Reef message and owner workloads on one AWS host. Every measured Reef SQL median decreases. Key loading is 1.27946 → 1.80514 ms, 1.410862513×, and rejection reservation is 2.55549 → 3.69549 ms, 1.446099433×, both below the strict 1.5 ratio. Only the three previously authorized sub-10-ms scalar-admin exceptions remain; their raw ratios are shown below.

Warmed Reef outbound drops 168 → 27 all-thread statements (−141, −83.9%) and 161 → 0 MAIN statements. Its raw worker requests rise 1 → 3.3 [3.3–3.6]: exactly two composed operation commands plus 1.3 [1.3–1.6] source-worker loader requests per send in the measured window. Every raw request remains counted. Complete inbound, receipt, and notifier request increases are also explicit below.

Per-phase statements, requests, durations, attribution, and source qualifications

Source scope and proof integrity

Evidence Baseline Candidate Paired samples Qualification
Fresh Reef messages and owners ec7c8bb9454bab03e76057ecc000bfad35897ce9 4eda6352f848253eedbf7660e1c17b6a52d7fed0 3 pairs per workload; 12 samples total New exact-head build, unchanged workloads and duration policy
Reused shared Gateway workload ec7c8bb9454bab03e76057ecc000bfad35897ce9 38e2318741c8ab11a5cfa4080efe1009d64f4f39 7 pairs; 14 shared samples Prior-head measurements, not measurements of 4eda

Shared reuse is narrow and source-bound. The only production change from 38e231 to 4eda caches compilation of selectPluginStateBatchRows; SQL text and fresh plugin/tuple/time/row bindings are unchanged. Its sole production caller is executePluginStateOperation's batched lookup, dispatched only by pluginState.executeOperation. All 14 prior shared samples have exactly zero such requests and completions, verified against their original request CSVs and raw-conservation records. Existing import edges are unchanged. The shared table remains labeled with its original head and host; no fresh shared latency claim is made. The historical 38e231 whole-matrix duration failure remains recorded and is superseded only for the freshly rerun Reef workloads.

The fresh analyzer validated exact Git commits/trees, built operation-module provenance, all 22 unchanged original input hashes and five separate scope hashes, launch order/nonoverlap, case counts, command sequences, and raw SQL/request conservation. A second local verification independently checked all 48 retained evidence/CSV hashes, recomputed every fresh phase/thread/request total and duration, and verified the compact manifest: 390 files / 167,796,230 bytes, SHA-256 1a061755d88ffa2e9b4e69c576203597853794072037c61211391b8563219690. All 12 fresh samples conserve exactly. All 1,073 selected causal witnesses are present. Fresh samples have no failed native calls, unknown targets, unmatched sends/receives, or operation SQL spilling across API boundaries.

The reused manifest is 9ba984c93f8a6eeaa390d1f93ec581ae1dc7faebedcb99fb030983c138a901bb; 24 copied source/phase/conservation/request files were independently checked. Shared-reuse receipt SHA-256 is d6d0eac9f3a39a611323ec6734f024c0c0ea664edb6298a80761ac31b0edf186; zero-operation receipt is a5109c804aec49358cb654c6faaab5789fe324b8c2de3e6a8cdb50c8fe491b4b. The prior shared instrumentation retains two typed unresolved-target boot sends and two unmatched receives per sample, plus one failed MAIN connect exec per sample; those unchanged diagnostics are not hidden or relabeled as fresh proof.

MAIN means the real Gateway process for shared, and the standalone real-owner fixture process for Reef. Each fresh sample has ten warmed operations per flow plus separately reported first-message operations. Counts and durations are divided within each sample before taking the cross-sample median and range. No operation is trimmed: the 5.89-ms key-load outlier in C1 remains included in its 2.2615-ms sample mean and the reported range. Native prepare calls and failures remain separate from successful statement counts. No evidence archive was created. The remote slot wait was 8,591.620 seconds; admitted resources were 32 effective CPUs and 65,965,027,328 bytes of memory.

Fresh 4eda phase measurements

Message flows

Counts are median [min–max] across alternating runs. Duration is milliseconds per stated unit.

Phase / unit All-thread M → C MAIN M → C Raw requests M → C Duration ms M → C C/M SQL Δ Request Δ
reefmsg.first-inbound-accepted (per operation) 376 [376–376] → 158 [158–158] 217 [217–217] → 33 [33–33] 12 [12–12] → 17 [17–17] 273.255 [272.545–275.771] → 159.079 [155.783–160.396] 0.582 -218 +5
reefmsg.first-inbound-poll-cursor (per operation) 375 [375–375] → 146 [146–146] 199 [199–199] → 15 [15–15] 14 [14–14] → 17 [17–17] 217.533 [216.97–217.763] → 120.746 [119.407–133.638] 0.555 -229 +3
reefmsg.first-outbound (per operation) 154 [154–154] → 41 [41–41] 147 [147–147] → 0 [0–0] 1 [1–1] → 6 [6–6] 81.5017 [80.4823–82.769] → 67.6367 [67.3793–68.6214] 0.830 -113 +5
reefmsg.first-receipt-accepted (per operation) 109 [109–110] → 41 [41–42] 109 [109–109] → 0 [0–0] 0 [0–0] → 6 [6–6] 40.2446 [40.1215–40.4874] → 20.3562 [20.3515–20.569] 0.506 -68 +6
reefmsg.first-receipt-rejected (per operation) 115 [114–115] → 36 [33–37] 114 [114–114] → 0 [0–0] 0 [0–0] → 5 [5–5] 40.7062 [40.5324–41.244] → 21.9509 [21.8843–23.026] 0.539 -79 +5
reefmsg.first-receipt-rejected-notify (per operation) 185 [185–185] → 93 [93–94] 156 [156–156] → 15 [15–15] 3 [3–3] → 11 [11–11] 91.9329 [88.3701–93.5112] → 70.3268 [70.1682–71.3242] 0.765 -92 +8
reefmsg.inbound-accepted (per operation) 283.9 [283.9–283.9] → 129.7 [129.6–129.7] 203 [203–203] → 5 [5–5] 11.2 [11.2–11.2] → 16.1 [16.1–16.1] 133.173 [132.154–134.243] → 80.9499 [80.3312–82.3525] 0.608 -154.2 +4.9
reefmsg.inbound-poll-cursor (per operation) 299.9 [299.9–299.9] → 135.5 [135.4–135.5] 203 [203–203] → 5 [5–5] 14.2 [14.2–14.2] → 17.1 [17.1–17.1] 140.098 [139.571–141.947] → 85.3208 [85.0885–86.3372] 0.609 -164.4 +2.9
reefmsg.outbound (per operation) 168 [168–168] → 27 [27–27] 161 [161–161] → 0 [0–0] 1 [1–1] → 3.3 [3.3–3.6] 66.6347 [66.2984–66.7522] → 19.6114 [19.398–19.9709] 0.294 -141 +2.3
reefmsg.receipt-accepted (per operation) 109.1 [109–109.1] → 31 [31–31] 109 [109–109] → 0 [0–0] 0 [0–0] → 5 [5–5] 40.8818 [40.2595–40.9382] → 18.0539 [17.9113–18.061] 0.442 -78.1 +5
reefmsg.receipt-rejected (per operation) 114 [114–114.1] → 32 [32–32] 114 [114–114] → 0 [0–0] 0 [0–0] → 5 [5–5] 39.9549 [39.9056–40.1872] → 18.7561 [17.926–18.929] 0.469 -82 +5
reefmsg.receipt-rejected-notify (per operation) 167 [167–167] → 73.2 [73.2–73.3] 144 [144–144] → 5 [5–5] 2 [2–2] → 9 [9–9] 68.4576 [67.9254–68.4696] → 44.7756 [44.6881–45.1344] 0.654 -93.8 +7

Owner operations

Counts are median [min–max] across alternating runs. Duration is milliseconds per stated unit.

Phase / unit All-thread M → C MAIN M → C Raw requests M → C Duration ms M → C C/M SQL Δ Request Δ
reef.audit-append (per operation) 49 [49–49] → 10 [10–10] 49 [49–49] → 0 [0–0] 0 [0–0] → 1 [1–1] 16.5819 [15.9448–16.588] → 6.16181 [6.07306–6.26017] 0.372 -39 +1
reef.audit-append-retention (per operation) 65 [65–65] → 11 [11–11] 65 [65–65] → 0 [0–0] 0 [0–0] → 1 [1–1] 20.6774 [19.8245–20.7551] → 5.40573 [5.39223–5.41078] 0.261 -54 +1
reef.audit-read-retained (per operation) 34 [34–34] → 4 [4–4] 34 [34–34] → 0 [0–0] 0 [0–0] → 1 [1–1] 7.55953 [7.45199–7.61842] → 2.54659 [2.51516–2.68166] 0.337 -30 +1
reef.load-keys (per operation) 6 [6–6] → 3 [3–3] 6 [6–6] → 0 [0–0] 0 [0–0] → 1 [1–1] 1.27946 [1.26675–1.2818] → 1.80514 [1.79436–2.2615] 1.411 -3 +1
reef.rejection-complete (per operation) 15 [15–15] → 7 [7–7] 15 [15–15] → 0 [0–0] 0 [0–0] → 1 [1–1] 3.84452 [3.83146–3.86063] → 3.9621 [3.94661–4.07669] 1.031 -8 +1
reef.rejection-reserve (per operation) 10 [10–10] → 6 [6–6] 10 [10–10] → 0 [0–0] 0 [0–0] → 1 [1–1] 2.55549 [2.54274–2.57495] → 3.69549 [3.6197–3.7485] 1.446 -4 +1
reef.review-decide (per operation) 8 [8–8] → 6 [6–6] 8 [8–8] → 0 [0–0] 0 [0–0] → 1 [1–1] 2.03448 [2.0231–2.05146] → 3.56796 [3.5346–3.948] 1.754 -2 +1
reef.review-request-capacity (per operation) 27 [27–27] → 8 [8–8] 27 [27–27] → 0 [0–0] 0 [0–0] → 1 [1–1] 6.41947 [6.39505–6.43565] → 4.37066 [4.36737–4.37712] 0.681 -19 +1
reef.trust-set (per operation) 8 [8–8] → 6 [6–6] 8 [8–8] → 0 [0–0] 0 [0–0] → 1 [1–1] 2.08832 [2.07813–2.10333] → 4.77955 [4.51348–7.214] 2.289 -2 +1
reef.trust-set-autonomy (per operation) 8 [8–8] → 6 [6–6] 8 [8–8] → 0 [0–0] 0 [0–0] → 1 [1–1] 1.99681 [1.98284–2.0029] → 3.65043 [3.53732–5.31277] 1.828 -2 +1

Reused shared Gateway measurements — candidate 38e231

These are the original seven-pair medians, reused under the scope qualification above. The shared warmed workload remains about 1042 statements/turn; this lane does not establish the campaign's global under-500 target.

Phase / unit All-thread M → C MAIN M → C Raw requests M → C Duration ms M → C C/M SQL Δ Request Δ
01.boot (whole phase/window) 2334 [2330–2334] → 2333 [2330–2334] 1945 [1945–1945] → 1945 [1945–1945] 58 [58–58] → 58 [58–58] 12104 [12087–12155] → 12148 [12125–12184] 1.004 -1 +0
01.connect (whole phase/window) 359 [358–364] → 361 [358–363] 68 [66–68] → 68 [68–68] 58 [57–58] → 58 [57–59] 1201 [1197–1206] → 1199 [1195–1205] 0.998 +2 +0
02.first-turn (whole phase/window) 2549 [2548–2552] → 2549 [2547–2552] 72 [72–72] → 72 [72–72] 267 [267–268] → 267 [266–268] 10062 [9970–10236] → 10034 [9993–10221] 0.997 +0 +0
03.warmed (per turn) 1042.2 [1041.2–1043.8] → 1041.7 [1040.4–1043.4] 0 [0–0] → 0 [0–0] 194.2 [194–194.4] → 194.1 [194–194.4] 1907.4 [1904.1–1921.9] → 1913.1 [1902.6–1917.4] 1.003 -0.5 -0.1
04.second-session (whole phase/window) 3704 [3697–3706] → 3697 [3681–3708] 71 [71–71] → 71 [71–71] 623 [621–623] → 621 [619–624] 7692 [7623–7704] → 7637 [7599–7720] 0.993 -7 -2
05.control-plane (whole phase/window) 34 [34–34] → 34 [34–34] 0 [0–0] → 0 [0–0] 5 [5–5] → 5 [5–5] 1113 [1111–1115] → 1112 [1100–1115] 0.999 +0 +0
06.cron (whole phase/window) 1206 [1206–1206] → 1206 [1206–1207] 30 [30–30] → 30 [30–30] 174 [174–174] → 174 [174–174] 5537 [5531–5540] → 5538 [5531–5547] 1.000 +0 +0
07.compaction (whole phase/window) 553 [553–554] → 553 [553–554] 30 [30–30] → 30 [30–30] 81 [81–81] → 81 [81–81] 1590 [1588–1659] → 1583 [1575–1599] 0.996 +0 +0
08.shutdown (whole phase/window) 1015 [1015–1015] → 1015 [1015–1016] 198 [198–198] → 198 [198–198] 113 [113–113] → 113 [113–113] 2815 [2784–2833] → 2831 [2805–2848] 1.006 +0 +0
done (whole phase/window) 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 14 [12–14] → 14 [13–14] 1.000 +0 +0
boot+connect (whole phase/window) 2693 [2691–2694] → 2694 [2690–2696] 2013 [2011–2013] → 2013 [2013–2013] 116 [115–116] → 116 [115–117] 13310 [13284–13359] → 13350 [13322–13383] 1.003 +1 +0
boot+connect+first (whole phase/window) 5242 [5240–5244] → 5243 [5241–5244] 2085 [2083–2085] → 2085 [2085–2085] 383 [383–383] → 383 [383–383] 23368 [23280–23595] → 23400 [23322–23604] 1.001 +1 +0
control+cron (whole phase/window) 1240 [1240–1240] → 1240 [1240–1241] 30 [30–30] → 30 [30–30] 179 [179–179] → 179 [179–179] 6651 [6644–6654] → 6651 [6632–6662] 1.000 +0 +0
compaction+shutdown (whole phase/window) 1568 [1568–1569] → 1568 [1568–1569] 228 [228–228] → 228 [228–228] 194 [194–194] → 194 [194–194] 4403 [4382–4479] → 4420 [4385–4447] 1.004 +0 +0

Shared first-turn is 2549→2549; warmed is 1042.2→1041.7 SQL and 194.2→194.1 requests. No turn-noise exemption or extra whole-workload pair is needed for that evidence. Connect's +2 SQL median, with unchanged 58-request median, comes from +1 existing deliveryQueue.countPending ownership read and +1 channelIngress.failedHealth schema-content read. Both have baseline witnesses; grouping by family/type/SQL leaves the same 349-statement remainder in every sample. The producing owners are unchanged, while full stacks honestly retain their touched generic wrappers. This falls within the non-turn tolerance. Combined windows are reported for context, not substituted for the first-turn gate.

Raw requests and named command budgets

All 300 fresh candidate owner operations contain exactly one expected command. All 33 first/warmed outbound sends contain exactly runReefOutboundOperation:prepare followed by runReefOutboundOperation:finish. No command or its SQL escapes its measured API interval. These limits apply to the named owner APIs and ordinary outbound; complete inbound/receipt/notifier compositions contain multiple distinct owner operations.

Every request column is per measured operation, median [min–max] across runs. Plugin command counts are a subset of raw requests. No loader, other, or outside-window work is subtracted.

Message flows

Phase Raw M → C Plugin commands M → C Loader M → C Other M → C C maximum commands/API Expected sequence
reefmsg.first-inbound-accepted 12 [12–12] → 17 [17–17] 0 [0–0] → 6 [6–6] 1 [1–1] → 1 [1–1] 11 [11–11] → 10 [10–10] 6 [6–6] no whole-flow limit assigned
reefmsg.first-inbound-poll-cursor 14 [14–14] → 17 [17–17] 0 [0–0] → 7 [7–7] 0 [0–0] → 0 [0–0] 14 [14–14] → 10 [10–10] 7 [7–7] no whole-flow limit assigned
reefmsg.first-outbound 1 [1–1] → 6 [6–6] 0 [0–0] → 2 [2–2] 0 [0–0] → 3 [3–3] 1 [1–1] → 1 [1–1] 2 [2–2] all observed
reefmsg.first-receipt-accepted 0 [0–0] → 6 [6–6] 0 [0–0] → 5 [5–5] 0 [0–0] → 0 [0–0] 0 [0–0] → 1 [1–1] 5 [5–5] no whole-flow limit assigned
reefmsg.first-receipt-rejected 0 [0–0] → 5 [5–5] 0 [0–0] → 5 [5–5] 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 5 [5–5] no whole-flow limit assigned
reefmsg.first-receipt-rejected-notify 3 [3–3] → 11 [11–11] 0 [0–0] → 8 [8–8] 0 [0–0] → 0 [0–0] 3 [3–3] → 3 [3–3] 8 [8–8] no whole-flow limit assigned
reefmsg.inbound-accepted 11.2 [11.2–11.2] → 16.1 [16.1–16.1] 0 [0–0] → 6 [6–6] 0 [0–0] → 0 [0–0] 11.2 [11.2–11.2] → 10.1 [10.1–10.1] 6 [6–6] no whole-flow limit assigned
reefmsg.inbound-poll-cursor 14.2 [14.2–14.2] → 17.1 [17.1–17.1] 0 [0–0] → 7 [7–7] 0 [0–0] → 0 [0–0] 14.2 [14.2–14.2] → 10.1 [10.1–10.1] 7 [7–7] no whole-flow limit assigned
reefmsg.outbound 1 [1–1] → 3.3 [3.3–3.6] 0 [0–0] → 2 [2–2] 0 [0–0] → 1.3 [1.3–1.6] 1 [1–1] → 0 [0–0] 2 [2–2] all observed
reefmsg.receipt-accepted 0 [0–0] → 5 [5–5] 0 [0–0] → 5 [5–5] 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 5 [5–5] no whole-flow limit assigned
reefmsg.receipt-rejected 0 [0–0] → 5 [5–5] 0 [0–0] → 5 [5–5] 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 5 [5–5] no whole-flow limit assigned
reefmsg.receipt-rejected-notify 2 [2–2] → 9 [9–9] 0 [0–0] → 7 [7–7] 0 [0–0] → 0 [0–0] 2 [2–2] → 2 [2–2] 7 [7–7] no whole-flow limit assigned

Commands outside individual API windows in measured phases: 0. They remain in phase totals and are listed in summary.json.

Every named owner phase has exactly one raw/plugin command, zero loader or other requests, and zero commands outside its API window; the per-operation SQL/duration table above retains each owner separately.

The full composite sequences explain the request increases. Inbound acceptance uses four audit appends, one trust snapshot, and one review lookup (six commands); cursor handling adds cursor.advance (seven). Accepted/rejected receipts use two audit appends, readDelivery, one trust snapshot, and consumeDelivery/rejectDelivery (five). Warmed rejection notification adds reserveRejection and completeRejection (seven total); its first use adds an initial trust snapshot (eight). Each constituent owner operation uses one command. The outbound two-command limit is not applied to these whole compositions.

Outbound removes one pluginState.lookup, adds two operation commands, and observes the loader work below. Warmed inbound removes one lookup and adds six commands, with existing maintenance requests changing 0.2→0.1 per operation, for raw 11.2→16.1. Cursor handling removes two lookups, one observe, and one compare-update, adds seven commands, with the same maintenance difference, for 14.2→17.1. Plain receipts replace native work with five commands (0→5 raw). Warmed rejection notification adds seven commands while its two existing requests remain (2→9). First notification adds eight commands while its three existing requests remain (3→11). Each named owner API replaces native work with one request. These are explicit request increases accompanying the worker cutover, not request savings.

Statement attribution

Warmed outbound's exact 141-statement saving balances below, identically in every fresh sample. Moving SQL to a worker earns no saving. The compiled-query follow-up changes CPU work and allocation only; these SQL savings come from the cross-row operation cutover and removing repeated preparation/envelopes.

Statement class Baseline/op Candidate/op Δ/op
cross-row lookup 0 6 +6
entry insert-if-absent 4 0 -4
entry upsert 12 8 -4
exact-key delete 4 0 -4
expiry sweep probe 16 0 -16
live row count 4 0 -4
point lookup 22 2 -20
quota+expiry aggregate 0 5 +5
schema/version inventory 12 0 -12
transaction envelope 32 4 -28
version observation 42 0 -42
write authority/config read 20 2 -18

Audit append commits the final linked suffix and head together instead of separate lease/staging/link/head/garbage transactions. Traversal uses one head/migration batch plus an entry scan. Review capacity combines inspection, scan, eviction and insertion in one transaction. Identity load combines three keyed reads. Rejection reserve batches peer/delivery reads; completion combines the peer notice update and delivery deletion. One namespace aggregate computes live count and expiry facts, eliminating empty-expiry probes when rows prove none are needed. Required ownership reads, transaction/commit admission and live effect assertions remain.

The following table attributes every measured flow's net SQL change by class. Each sample's classes sum exactly to its raw total; for this series their median deltas also reconcile to every displayed net delta. Exact SQL, per-run class values, request ancestry and full stacks remain in the compact evidence.

Flow All-thread SQL M → C Changed statement classes (C−M)
reefmsg.first-inbound-accepted 376 → 158 cross-row lookup +8; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -19; live row count -5; other owner SQL -46; point lookup -22; quota+expiry aggregate +8; schema/version inventory -27; transaction envelope -28; version observation -48; write authority/config read -27
reefmsg.first-inbound-poll-cursor 375 → 146 cross-row lookup +8; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -20; live row count -6; other owner SQL -46; point lookup -24; quota+expiry aggregate +9; schema/version inventory -27; transaction envelope -30; version observation -53; write authority/config read -28
reefmsg.first-outbound 154 → 41 cross-row lookup +6; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -15; live row count -5; other owner SQL +9; point lookup -18; quota+expiry aggregate +5; schema/version inventory -9; transaction envelope -22; version observation -36; write authority/config read -16
reefmsg.first-receipt-accepted 109 → 41 cross-row lookup +5; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -10; live row count -2; other owner SQL +7; point lookup -13; quota+expiry aggregate +4; schema/version inventory -6; transaction envelope -10; version observation -27; write authority/config read -10
reefmsg.first-receipt-rejected 115 → 36 cross-row lookup +5; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -11; live row count -2; other owner SQL +2; point lookup -15; quota+expiry aggregate +5; schema/version inventory -6; transaction envelope -11; version observation -30; write authority/config read -10
reefmsg.first-receipt-rejected-notify 185 → 93 cross-row lookup +7; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -13; live row count -2; other owner SQL +1; point lookup -19; quota+expiry aggregate +7; schema/version inventory -6; transaction envelope -12; version observation -38; write authority/config read -11
reefmsg.inbound-accepted 283.9 → 129.7 cross-row lookup +8; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -20; live row count -4; other owner SQL +0.1; point lookup -24; quota+expiry aggregate +8; schema/version inventory -12; transaction envelope -28.2; version observation -50.1; write authority/config read -20
reefmsg.inbound-poll-cursor 299.9 → 135.5 cross-row lookup +8; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -21; live row count -4; other owner SQL -0.1; point lookup -26; quota+expiry aggregate +9; schema/version inventory -12; transaction envelope -30.2; version observation -55.1; write authority/config read -21
reefmsg.outbound 168 → 27 cross-row lookup +6; entry insert-if-absent -4; entry upsert -4; exact-key delete -4; expiry sweep probe -16; live row count -4; point lookup -20; quota+expiry aggregate +5; schema/version inventory -12; transaction envelope -28; version observation -42; write authority/config read -18
reefmsg.receipt-accepted 109.1 → 31 cross-row lookup +5; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -10; live row count -2; other owner SQL -0.1; point lookup -13; quota+expiry aggregate +4; schema/version inventory -6; transaction envelope -12; version observation -28; write authority/config read -10
reefmsg.receipt-rejected 114 → 32 cross-row lookup +5; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -11; live row count -2; point lookup -15; quota+expiry aggregate +5; schema/version inventory -6; transaction envelope -12; version observation -30; write authority/config read -10
reefmsg.receipt-rejected-notify 167 → 73.2 cross-row lookup +7; entry insert-if-absent -2; entry upsert -2; exact-key delete -2; expiry sweep probe -13; live row count -2; other owner SQL +0.2; point lookup -19; quota+expiry aggregate +7; schema/version inventory -6; transaction envelope -14; version observation -37; write authority/config read -11
reef.audit-append 49 → 10 cross-row lookup +2; entry insert-if-absent -1; entry upsert -1; exact-key delete -1; expiry sweep probe -5; live row count -1; point lookup -6; quota+expiry aggregate +2; schema/version inventory -3; transaction envelope -8; version observation -12; write authority/config read -5
reef.audit-append-retention 65 → 11 cross-row lookup +2; entry insert-if-absent -1; entry upsert -2; exact-key delete -1; expiry sweep probe -6; live row count -1; point lookup -8; quota+expiry aggregate +2; schema/version inventory -3; transaction envelope -12; version observation -17; write authority/config read -7
reef.audit-read-retained 34 → 4 cross-row lookup +1; namespace scan +1; point lookup -17; transaction envelope +2; version observation -17
reef.load-keys 6 → 3 cross-row lookup +1; point lookup -3; transaction envelope +2; version observation -3
reef.rejection-complete 15 → 7 cross-row lookup +1; expiry sweep probe -1; point lookup -2; quota+expiry aggregate +1; transaction envelope -2; version observation -4; write authority/config read -1
reef.rejection-reserve 10 → 6 cross-row lookup +1; expiry sweep probe -1; point lookup -2; quota+expiry aggregate +1; version observation -3
reef.review-decide 8 → 6 expiry sweep probe -1; quota+expiry aggregate +1; version observation -2
reef.review-request-capacity 27 → 8 entry insert-if-absent -1; entry upsert +1; exact-key delete -1; live row count -3; point lookup -3; transaction envelope -2; version observation -9; write authority/config read -1
reef.trust-set 8 → 6 expiry sweep probe -1; quota+expiry aggregate +1; version observation -2
reef.trust-set-autonomy 8 → 6 expiry sweep probe -1; quota+expiry aggregate +1; version observation -2

“Other owner SQL” is retained explicitly rather than subtracted: first inbound/cursor each remove 46 additional admission/connection/schema statements (table/index/integrity and connection setup checks); first outbound includes nine existing session-reclamation reads; receipt cold-flow differences include existing session maintenance and periodic WAL work. Small ±0.1/0.2 warmed differences are maintenance/WAL timing. Exact SQL strings and per-request class totals identify these separately from Reef storage changes. The deterministic outbound reduction contains none of this residual category.

Loader and residual MAIN work

All six fresh message samples contain exactly 544 transforms for the existing session disk-budget worker startup. Baseline emits them in seed.outbound; candidate redistributes them across first/warmed outbound, verification and the next seed. Candidate warmed windows contain [13, 13, 16] transforms across ten sends, accounting for the 1.3 [1.3–1.6] raw loader requests per send. Their parent task is fixture session creation: replaceSessionEntry → kickSessionHistoryDiskBudgetMaintenance → measureSessionPhysicalDiskUsage, followed by source TypeScript worker/tsx/esbuild startup. Packaged JavaScript worker resolution does not add a TypeScript preload. The raw totals remain unchanged by this explanation.

Each of the nine fresh warmed inbound/cursor/notifier phase samples retains the same five MAIN statements: one version observation, schema_meta, session_key_contract, session_participants, and session_nodes plus snapshot fields. They originate in existing deliverPendingDeliveryNotice → loadSessionEntryReadOnly → session projection readers. They are not Reef plugin-state SQL. First compositions also contain cold admission work. Named Reef owners, outbound and plain receipt flows are MAIN-free; complete inbound/notifier compositions are not described that way.

Duration and gate classification

All non-exempt fresh duration ratios are ≤1.5. Key loading is 1.410862513× and reservation is 1.446099433×. The three authorized exceptions are review decision, 3.567961 ms at 1.753746191×; trust-set, 4.779546 ms at 2.288699092×; autonomy, 3.650427 ms at 1.828129682×. Each candidate median is strictly below 10 ms. Thus durationValid is true while rawDurationValid remains false; no additional exception was invented. The three valid initial pairs satisfy the frozen rule, so no recovery extension was needed.

Measurement gate Result
Fresh exact source/raw conservation Pass: 12 samples, all phase/thread/SQL/request totals verified
Fresh first/warmed message and owner SQL Pass: every named median decreases
Owner command budget Pass: 300/300 one expected command
Ordinary outbound command budget Pass: 33/33 exact prepare→finish
Full raw requests Increased in named compositions; all plugin/loader/other work shown and attributed
Fresh durations Pass under unchanged strict ratios and three named scalar-admin exceptions
Shared Gateway first/warmed and non-turn SQL Reused 38e231 proof: first equal, warmed lower; connect +2 attributed within tolerance
T1 inventory 771 → 771; no rise

T1 counts static primitive call sites, not the runtime thread. Shared plugin-state leaf SQL remains in mixed owners for released synchronous SDK contracts, Doctor/migration use and retained channel adapters. Reef extension code has no direct native-site inventory rows. The runtime tables prove Reef's cutover. The generated 4eda inventory is bound to the exact source; W is 1061 versus 1060 on baseline (the compilation refactor changes scanner primitive visibility), and T1 remains 771.

Scope and remaining qualifications

Reef fixtures exercise real storage owners, cryptography, effect-preparation checks, prepared core metadata recording, cursor persistence and notifier paths with synthetic relay/model responses. They omit the outer live Gateway/OAuth/model/dispatch-custody lifecycle. Shared is a separate fixed Gateway workload, reused at its original source. No claim is made that every sample measured 4eda, that request counts fell globally, or that the global under-500 target is reached.

The final measured source is 4eda. Tests, code checks, compatibility, package proof, review, and update acceptance are reported separately.

Private evidence: measurements-4eda-analysis/aggregate-verification.json, duration-command-verification.json, sql-class-attribution.json/.csv; attempt27's derived-attribution/summary.json, phase/request tables, exact SQL/request class CSVs, stack/source registry, compact clock/ancestry witnesses and duration witnesses; and the separately hashed shared-reuse.json, shared-zero-operation.json, and prior-shared evidence. Prior 38e231 owner failures remain diagnostic history, not current owner acceptance.

Original performance-lane validation

Original lane proof source: 4eda6352f848253eedbf7660e1c17b6a52d7fed0. AWS proof run, lease cbx_883a99656990, 32 CPUs / 61.4 GiB. The final campaign slot wait was 2 h 23 min; a prior Testbox attempt queued without a runner for over 15 minutes before the authorized AWS fallback. The lease and campaign slots are released. Raw traces were pruned only after conservation and verified compact retrieval; remote measurement worktrees and the final local transport were removed.

Gate Evidence
Full build Passed on the final head in 318.702 s, including Doctor dependency closure and all four operation artifacts
Final focused owners 146 tests across seven files passed in 138.497 s; compiled reservation smoke passed in 12.910 s
Caller/sibling coverage All 27 required files have passing coverage; seven affected owner files rerun on the final head, unchanged sibling proof reused as qualified below
FIFO and live authority Cross-handle ordering, queued-mutation/path-alias invalidation, expiry, late owner closure, lost acknowledgements, exact delivery binding, and revocation during guard classification covered
Removed statement/request classes Cross-row snapshot/rollback and coherent scan regressions; key/review/trust concurrent updates; outbound requires two commands and no host data SQL; retention regression fails on the removed empty probe/delete
Types Core/extension production and test types passed; final core and core-test graphs rerun remotely
Native changed checks Original 44 selected commands executed; final scoped invocation retained exit 1 solely for four inherited unused exports; see qualifications below
Final changed-file lint Passed on the final head with native core lint for plugin-state-store.reads.ts
Madge / Knip Zero import cycles; production file/dependency checks passed. Follow-up imports remove an unused edge and reuse existing edges
Inventory/ratchets Generated inventory current; T1 771 → 771, W 1060 → 1061; growth and boundary ratchets passed
SDK declaration diff ec7c8bb9454b → e07c82e4c4ef: no entrypoint additions/removals; 156 reachable export changes from additive store/authority types (digest 7d8187de). Subsequent repairs change no SDK declarations
Historical SDK compatibility Six final-head source/compiled cases passed: v2026.7.33, v2026.7.34, and capture-failure refusal; 19.859 s
Entrypoint profile Passed in 1.278 s
Candidate package Passed in 96.213 s; packaged build commit matches the final head
Codex autoreview Full P2 findings fixed; corrective P2 reviews clean. Subsequent bounded corrections passed fresh P1 reviews under the campaign convergence rule, including the final compilation change

The monolithic check-changed run is not green. Its final remote invocation took 638.958 s and stopped on four unrelated unused exports already reproduced on the pinned baseline: bindCliQuestionAnswerAuthority, prepareSessionEventTargetForHost, readSessionEntryCreationTransition, and RESTART_CONTINUATION_CONTEXT_PREFIX. Earlier remaining native checks were run explicitly. The separately run final-file core lint passed through a normal local proof slot; its total wait plus execution was 51 min 13 s, after the host load fell below the campaign threshold. The existing registry-runtime.ts size warning is 937 counted lines, down from 941 on the baseline; its growth ratchet passes. No suppressions or check-skip environment flags were added.

Sibling reuse is explicit: 22 unchanged files passed remotely on the earlier candidate, the corrected channel file passed 26 tests, and four remaining files passed 65 tests. The channel correction expects the earlier stale-receipt refusal while preserving its positive control and zero-dispatch/acknowledgment checks. The final seven-file owner run covers the retention and compiled-query changes. A refused local 27-file attempt ran no shards and is not counted as proof.

Test wall time: the final seven-file command was pnpm test src/plugin-state/plugin-state-store.retention.test.ts src/plugin-state/plugin-state-store.retained.test.ts src/plugin-state/plugin-state-operation.test.ts extensions/reef/src/trust-store.test.ts extensions/reef/src/flow.worker-outbound.test.ts extensions/reef/src/audit-state.test.ts extensions/reef/src/state.test.ts --maxWorkers=1 (138.497 s). The changed retention file alone passed in 39.711 s on the loaded Mac. The corrected channel file passed with pnpm test extensions/reef/src/channel.test.ts --maxWorkers=1 in 117.743 s. The remaining owner-notice, transport, direct-DM, and prepared-turn lifecycle files passed together in 149.053 s. GitHub CI seconds are pending the first PR run; these are measured test execution times, not claimed CI results.

The final package is 103,493,667 bytes, SHA-256 53c349ec6b8f4cc72b3c33861f756da4c49b087bd486c5ef8b483955e66181a4. The package bytes were verified remotely before scratch pruning; the source/build/hash receipt is retained. No package was published. The update cell was pending at that earlier proof point; the required published-driver × candidate acceptance is now complete for the capture repair above. This is separate from the completed historical SDK checks. Live relay/model service execution is not claimed; the synthetic flow and shared-workload scope limits are recorded above.

Production changes add 5,848 and remove 1,495 lines (net +4,353); tests/support add 3,993 and remove 924 (net +3,069). Documentation is +139 net and tooling +16. Growth covers the shared transaction/receipt contract, Reef handlers, released-host compatibility adapters, and authority/FIFO/settlement/expiry regressions. The old unpublished operation path is removed. T1 counts retained static native primitives; the runtime traces establish the measured MAIN reduction.

Prepare and settle Reef trust, audit, review, identity, and cursor state through source-bound plugin-state operations. Preserve released native adapters and recheck live authority at external effects and storage admission.

Reuse readonly observations for send and receipt state, and restrict metadata effect checks to mutation and commit boundaries. Keep schemas, retention, and permission behavior unchanged. Name the existing usage-health store return contract for declaration emission.
@clawsweeper

clawsweeper Bot commented Oct 10, 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 scripts Repository scripts plugin: file-transfer channel: reef Channel integration: reef extensions: browser size: XL labels Oct 10, 2026
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves Reef state operations into shared SQLite worker transactions and carries revocable receipts to subsequent effects.

Example: A warmed Reef message is sent to trusted peer alice.

  • Before: The reported workload executes 168 SQLite statements, including 161 on the main thread.
  • After: The reported workload executes 27 SQLite statements with none on the main thread.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful measured improvement with the previous defect resolved; material authority verification remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Reef state operations repeatedly perform synchronous SQLite work on the Gateway thread.
Reason: The maintainer-authored direction has concrete measured savings and uses the existing worker owner without new operator settings.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: the worker cutover has clear performance value, and the previous wrapper-inventory defect is fixed.

Priority: P2
Reviewed head: 5bdcdaf67f779e53f91bf63a3640115e3fa0ee04

Before merge

  • Add real behavior proof - Authority-chain proof required: the complete body reports real-owner performance results and published-driver update acceptance, but no inspected runtime trace connects current peer/account authority to both relay initiation and metadata commit under revocation or account replacement. The inspected negative controls use mocked fetch/dispatch or injected authority callbacks. Add allowed and nearest-forbidden final-effect observations through the real owners; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - No concrete authorization bypass was established, but the changed authority chain still needs final-effect proof.
  • Resolve merge risk - The replacement of synchronous authority reads with retained receipts needs final-effect verification against peer revocation and account replacement during awaited work.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a production-path trace showing allowed effects and revocation or account replacement during awaited preparation blocking both relay initiation and session metadata commit.
Agent review details

How this fits together

Reef connects guarded peer messaging to plugin-owned SQLite state; worker operations consume captured stores and authority, then return committed results and receipts used before delivery or session writes.

flowchart LR
  A[Reef message flow] --> B[Captured state operation]
  B --> C[Shared SQLite worker]
  C --> D[Canonical plugin state]
  C --> E[Revocable receipt]
  E --> F[Relay initiation]
  E --> G[Session metadata commit]
Loading

Technical review

Best possible solution:

Complete the worker cutover while demonstrating that current authority governs both relay initiation and session metadata commit.

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

This is a performance refactor; supplied measurements quantify the original SQLite workload, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

Composing operations in the existing shared-state worker addresses repeated transaction and lookup overhead while preserving one storage owner and explicit released-host compatibility.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 06d231d65279.

Merge-risk options

Maintainer options:

  1. Verify the authority chain before landing (recommended)
    Use the real authority owners to show allowed delivery and metadata writes, then show peer revocation or account replacement during preparation refusing each final effect.

Provenance checked

  • Reef trust and delivery authority keeps the original intent (f810fb3: Centralize peer pins, autonomy, and outbound intent in identity-scoped SQLite while fencing key rotation and removal races.)
  • Released-host Reef storage compatibility keeps the original intent (29fac14: Move supported operations to workers while retaining atomic adapters for released hosts and refusing fallback after worker failures.)
  • Physical database schema admission keeps the original intent (bb7d32e: Reuse admission across handles and workers while binding facts to physical file identity and transaction lifetime.)

Testing

Proof path: shipped entry point.

Security

Needs attention: No concrete authorization bypass was established, but the changed authority chain still needs final-effect proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 882b2fe adds extensions/reef/src/flow.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 882b2fe9004a; files: extensions/reef/src/flow.ts)
  • Alex Knight: Raw commit bbf985d adds src/plugin-state/plugin-state-store.types.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bbf985d50a64; files: src/plugin-state/plugin-state-store.types.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 security-boundary.

Label justifications:

  • P2: This is a useful internal performance improvement without an established urgent user-facing outage.
  • merge-risk: 🚨 compatibility: The additive plugin-state operation API and source-loader changes affect supported plugin hosts; documented legacy adapters and reported compatibility/update acceptance address the intended transition.
  • merge-risk: 🚨 security-boundary: Receipts now carry peer and account authority across asynchronous preparation to network and storage effects.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof showing peer revocation or account replacement during preparation prevents relay I/O and session metadata persistence.

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-10T08:28:00.986Z sha 4eda635 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T09:06:38.161Z sha c4b5cac :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T09:37:44.939Z sha 34b1d93 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T12:23:13.204Z sha 3872c24 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T16:05:42.043Z sha 90de431 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T16:32:22.091Z sha 90de431 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T16:51:19.730Z sha 68b41f2 :: needs real behavior proof before merge. :: [P1] [P1] Include the extracted lifetime module in the wrapper inventory

Reviewed October 10, 2026, 1:12 PM ET / 17:12 UTC (Revision 8).

Merge origin/main into dbasync/t1reef without rebasing. Preserve both row publication and operation acknowledgement through one native commit observer. Conflict-resolution scope; lane performance proof remains historical, focused integration and update proof follow.
Scope read-only migration resource discovery to temporary plugin source storage bound to the selected state directory. Bundled operation capture must not create the canonical destination while Doctor is preserving and relocating legacy state.
Resolve the schema-lifetime and read-cache test splits against the single-owner SQLite changes on main. Remove the superseded owned-state freshness suppression wrapper and retain worker transactions, receipt admission, and temporary-schema settlement.
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 10, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Oct 10, 2026
@steipete
steipete merged commit 2cd5dea into main Oct 10, 2026
173 of 176 checks passed
@steipete
steipete deleted the dbasync/t1reef branch October 10, 2026 17:28
@steipete

Copy link
Copy Markdown
Contributor Author

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

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
* refactor(reef): move native state work to the shared worker

Prepare and settle Reef trust, audit, review, identity, and cursor state through source-bound plugin-state operations. Preserve released native adapters and recheck live authority at external effects and storage admission.

Reuse readonly observations for send and receipt state, and restrict metadata effect checks to mutation and commit boundaries. Keep schemas, retention, and permission behavior unchanged. Name the existing usage-health store return contract for declaration emission.

* perf(reef): avoid write preparation for rejection recovery

* fix(reef): complete worker cutover validation

* refactor(reef): remove unused peer observation type

* test(reef): document intentional async authority misuse

* fix(reef): preserve receivers and settle async test setup

* test(state): isolate nested reader lifetime regression

* test(reef): keep authority fixtures lint compliant

* refactor(reef): batch native state operations in the shared worker

* fix(reef): validate review records at the worker boundary

* fix(reef): resolve state operations through the captured plugin owner

* test(reef): expect revoked operation receipts at ingress

* perf(plugin-state): share quota and expiry observations

* perf(plugin-state): reuse compiled cross-row reads

* docs(database): refresh inventory after conflict resolution

* fix(plugins): resolve source SDK imports in compiled workers

Preserve native module identity and existing JavaScript resolution when a compiled worker loads TypeScript SDK sources. Include the operation capture modules in the PR wrapper inventory.

Validation: native loader regression fails before and passes after on Node 24.19.0; native-module-require.test.ts passes 20 tests in 4.45 seconds. Scoped P0/P1 review is clean.

* fix(plugins): capture bundled operation import closures

* fix(plugins): keep backup discovery captures outside live state

Scope read-only migration resource discovery to temporary plugin source storage bound to the selected state directory. Bundled operation capture must not create the canonical destination while Doctor is preserving and relocating legacy state.

* refactor(sqlite): split schema lifetime and marker tests

* fix(pr): retain SQLite schema lifetime in wrapper sources
steipete added a commit that referenced this pull request Oct 13, 2026
…#170511)

## What Problem This Solves

Consolidate duplicate extension paths and remove speculative lifecycle defenses in Codex, Memory Core, Microsoft Teams, Matrix, Reef, and Workboard. The candidate removes **522 net production lines** (tests, fixtures, generated files, declaration files, and documentation excluded; both new production modules included). This uses the campaign's honest 500–999-line fallback after the scoped growth/largest-first pass; it does not remove features to reach a quota.

Workboard's four card actions now share one discriminated action component, its draft controls share one renderer, and menu-only pass-through components are gone. Reef's worker and released-host adapters share one pure seven-command trust-transition policy while retaining their own atomic storage boundaries. Teams reuses its Graph/context/setup owners. Memory keeps normal parallel-query and sync-generation retirement draining, expressed with simpler active-completion tracking rather than nested borrower wrappers.

An adjacent Workboard defect is fixed: conditional Solid fragments could run a popover ref before the preceding trigger entered the document, positioning the details menu at the page origin. Listener/anchor setup now runs after the DOM commit. The regression fails against the unchanged implementation and passes with this repair.

No SDK export, config, protocol, dependency, database schema, durability, retention, or permission contract is changed. The protected standalone session-memory backend is untouched. No changelog edit.

User impact: Workboard details menus anchor to their trigger instead of the page origin. Other changes simplify internal implementation, with the best-effort timing and diagnostic compromises below; no migration or operator action is required.

## Best-effort tradeoffs accepted

- Codex diagnostic accessors throwing or mutable transport identities: [#163388](#163388) adds synthetic throwing-accessor coverage, not an actual-use human report. Actual accessors are local reads and registration publishes frozen identities. Accessor programmer errors now surface; the diagnostic sink catch, disclosure allowlist, attempt isolation, and timeout/cleanup behavior remain.
- Offline Codex migration CAS conflicts: [#168479](#168479) introduced retry loops without a human competing-writer report. Gateway ownership excludes live foreign writers. One atomic attempt plus existing persisted-result validation now retains the source sidecar and reports a warning on conflict; a later Doctor run can retry.
- Retired Codex legacy JSON rewritten during migration: [#104504](#104504) added a synthetic locator-rewrite test; human [#104503](#104503) concerns fingerprint overflow, whose fix remains. Legacy indexes are offline inputs, so a second locator/lifecycle read is removed. Initial containment/malformed-owner validation and canonical session ownership checks remain; unsupported concurrent legacy edits are picked up next run.
- Memory manager acquisition repeatedly retrying failed global retirement: [#144252](#144252) has synthetic close failures, no human incident requiring recursive acquisition recovery. Acquisition now awaits the pending close once and reports its error; the retirement owner is retained and explicit close can retry.
- Abandoned, abort-ignoring memory diagnostic probes holding provider retirement indefinitely: [#113471](#113471) and [#166973](#166973) provide synthetic lifecycle proof, not a human abandoned-probe incident. Timed-out read-only diagnostics no longer retain a redundant inner borrower. Ordinary active searches, sync generations, healthy operations, and custom closable-provider draining remain protected.
- Teams simultaneous Gateway writers: [#88411](#88411) introduced the persistence migration/file lock without a human multi-Gateway incident and did not test live tenant traffic. The Gateway is the sole database owner. Removed cross-process stale-lock/backoff machinery; local FIFO remains. Unsupported simultaneous processes may overwrite each other rather than coordinate.
- Workboard stale cache publication and an exact-expiry late join: [#165896](#165896), [#165141](#165141), and [#165698](#165698) use synthetic performance/interleaving controls, not a human incident. One read may return an older projection/fallback; normal revision/age invalidation refreshes it next read. Measured caching, the 64-entry bound, and read authority remain.
- Workboard direct stop/start before asynchronous startup settles: [#146976](#146976) forces unsupported lifecycle ordering in a test. The host service owner already awaits raw startup before stop. Removed plugin-local generation/startup handoff; supported host lifecycle is unchanged, unsupported direct reentry no longer has a second lifecycle owner.
- Reef failed owner-notice dispatch/ack retry timing: [#109160](#109160) pins injected failures and exponential timers, without a human report requiring that second scheduler. Durable pending notices now retry during ordinary successful 30-second reconciliation or restart. A failed acknowledgement may redispatch conservative stop-only guidance; durable resend reservation/cooldown prevents granting a second resend. The per-peer queue also makes the removed in-flight set redundant.
- Reef synchronous intermediate lease theft: [#109380](#109380) and [#168340](#168340) describe synthetic interleavings, not human concurrent-writer incidents. SDK callbacks commit synchronously and there is no await between acquisition and settlement. Unsupported reentrant callbacks/foreign writers are no longer checked at every intermediate step. Initial acquisition, final head-owner check, staged recovery, uncertain-commit witness, rollback, and retention ordering remain.
- Workboard fabricated native event targets and repeated widget predicates: renderer port [#168606](#168606) added boilerplate without a human incident. JSX native bindings already guarantee `currentTarget` types, and the owning menu already excludes widgets. Fabricated direct handler calls may throw; real event dispatch, widget behavior, and untrusted `event.target` checks are unchanged.

## Coverage ledger

Discovery began with scoped three-day growth, then fourteen-day history and largest production owners. Each removed mechanism was checked against its introduction and current callers; no dormant/in-flight foundation was deleted. Exact and normalized duplicate scans informed structural inspection, not automatic rewrites.

| Owner / original location | Decision and evidence |
| --- | --- |
| Codex `app-server/request-diagnostics.ts:28,109,133` | Remove speculative accessor catches/identity copy; keep timeout sink and disclosure boundary (#163388). |
| Codex `command-handler-actions.ts:109` | Share sandbox/execution result assembly; preserve policy selectors, guards, currentness and release. |
| Codex `migration/session-binding-sidecars.ts:460,549,627` | Single CAS attempt and one legacy-input read; preserve sidecar on conflict and canonical effect validation (#168479, #104504). |
| Codex `installed-probe.ts:29`, native session preparation/monitor | KEEP isolated managed storage, credentials, native execution authority and ordinary write settlement. Upstream configuration/storage contract inspected directly. |
| Memory `memory/search-deadline.ts:42` | One rejected cancellation promise replaces sentinel race; preserve cancellation/error identity, abort ordering, wall-clock guard and cleanup (#95757, #147702). |
| Memory `manager-embedding-ops.ts:84`, `manager-registry.ts:264` | Simplify nested borrower bookkeeping and failed-close recovery; preserve outer leases, normal drain and documented retiring-cache fence (#113471, #166973, #144252). An initially broader removal was rejected during review. |
| Memory publication, database context, index generation, transfer and cache owners | KEEP user-data transaction/publication, Forget exclusion, bounded transfers, worker ownership, integrity, performance caches and normal shutdown settlement (#168860, #169164, #169251, #170183, #170302, #170407). |
| Memory paused deadlines, Unicode query, KNN/vector scan, watchers | KEEP human-reported SQLite stalls (#137056), dependency tokenizer behavior, external/native input validation, bounded resources and realistic cancellation. |
| Memory dreaming/REM, migration/repair, backfill and standing intents | KEEP user-facing features, privacy/source validation, persisted rollback and public formats. Phase E untouched. |
| Teams `sqlite-state.ts:27`, `graph.ts:85,177` | Remove redundant foreign-writer lock; one guarded Graph transport retains auth/SSRF, bounded parsing and release (#88411). |
| Teams `setup-surface.ts:102`, `graph-group-management.ts:32,96`, `channel.ts:267` | Consolidate identical saves/context/pending result bookkeeping; preserve provider-specific validation, labels, errors, ordering and direct results (#112811). |
| Matrix `matrix/actions/reactions.ts:135` | Remove duplicate missing-sender/empty-result guards; selector remains ownership boundary, empty list has no redactions. |
| Matrix crypto store, verification, readiness, send FIFO and thread binding owners | KEEP room-key durability, real throwing dependency getters, encryption/send authority, public compatibility and accepted writes (#160707, #70401, #163012, #168485, #169405). |
| Teams pending-upload dual owners | HOLD: persisting currently memory-only reply consent bytes would change privacy/persistence; deleting SQLite loses restart recovery. Needs an explicit policy choice, not a deslop shortcut. |
| Teams streaming, multi-account configuration and exported setup factory | KEEP Stop/partial-delivery/FIFO, credential isolation and published factory signature (#141348, #112811). |
| Reef `trust-state-operation.ts:164`, `trust-store.legacy.ts:115` | Share pure seven-command transitions, retain worker/native atomic adapters, schema checks, trust revisions and authorization (#168340). |
| Reef `owner-notice.ts:32,72,122,253`, `audit-state.legacy.ts:145–255` | Remove duplicate retry scheduler/in-flight set and synchronous intermediate lease checks; preserve durable recovery/security (#109160, #109380). |
| Reef released-host adapter and trust delivery settlement | KEEP declared host compatibility, accepted-write shutdown settlement, peer/key authority and user-data crash recovery. |
| X events/allowlist/verification | KEEP paid-event settlement, bounded polling and credential/access authority. |
| llama.cpp media/provider/install/orphan owners | KEEP confidentiality of local inputs, digest cache integrity and safe process identity before termination (#167902). |
| ClawRouter pool/dashboard | KEEP untrusted network projection, bounded responses and active features; no useful large duplicate justified added abstraction. |
| Workboard `view-card-actions.tsx:215`, `view-card.tsx:102`, `view-draft-choices.tsx:6` | Consolidate actions, menu wrappers and card/bulk draft controls; all callers migrated (#168606). |
| Workboard native handlers and `view-popover.ts:19` | Drop impossible bound-target guards; repair ordinary conditional-fragment anchor timing (#168606). |
| Workboard `sessions-board.ts:149,305`, `change-events.ts:6`, `gateway.ts:211` | Remove duplicate cache/lifecycle fences; share workspace input preparation while retaining workspace/security effect checks. |
| Workboard draft/focus/pending-write/editor, board save and label measurement owners | KEEP real unsaved input, async writes, keyboard focus, live-authority checks and measured layout batching. |

## Evidence

All local build/test/CLI commands use task-owned HOME, OpenClaw state/config and XDG directories. No real Gateway or user state is used. No timeout increases, retries, skips, new suppressions or weakened retained-behavior baselines.

Final proof receipts and exact-head CI attribution are recorded below. Cold compiled-worker preparation dominates several local timings; these are not CI timings or live-provider claims.

| Focused local proof | Result / wall cost |
| --- | --- |
| Codex request diagnostics | 14/14 pass; wrapper445.55s (cold worker/import dominated). |
| Codex commands + Doctor contract | 122/123 pass; wrapper1352.60s. Doctor contract passes. The one method-list assertion (`commands.test.ts:951`) also observes background monitor `thread/read` calls. It **reproduces with explicit clean-base source loaded from `56715acf0e5943edecd34fa6f451532cfa9d5f35`**: extra reads followed by the expected `thread/resume`, selected-case8.411s/Vitest403.28s. The affected test/support/actions/bindings/monitor files are byte-unchanged between that base and pinned main. No test skips or timing changes were added;99 unrelated cases were unselected for attribution. |
| Workboard backend (sessions-board, Gateway, change-events, registration lifecycle) | 48/48 pass, four files; wrapper587.54s, Vitest545.18s. |
| Workboard entire browser scope before final followups; final affected browser suites | 237/237 across29 files in59.03s; final103/103 across6 files in31.95s. New popover regression1/1 in9.34s; unchanged source fails intended geometry assertion in14.57s. |
| Workboard actual compiled WebKit consumer | Pass: anchored menu, filter keyboard dismissal, nested Escape preserving dialog, focus return, zero page errors. |
| Reef trust/friends/audit/receipt/outbound/notifier | 119/119 across6 files; wrapper927.25s, including cold worker compilation. Earlier unchanged channel proof25/25 pass. |
| Teams sqlite/Graph/read authority/setup | 72/72 across5 files; wrapper385.62s. |
| Teams Graph contexts/actions | 73/73 across3 files; wrapper327.91s. |
| Teams mutation callers/setup policy | 42/42 across5 files; wrapper776.30s. |
| Teams resolver + existing channel tests | Resolver4/4 pass; existing channel44 pass/2 fail, wrapper550.01s. **Both failures reproduce on full pinned main `3c63da22f046b15db9d56cf35769f20b398b8c9b`**,44 pass/2 fail, wrapper464.42s: approval-monitor startup timeout120000ms (`channel.test.ts:313`) and subsequent `MSTeams runtime not initialized` (`runtime-store.ts:85` → `monitor.ts:81` → `channel.test.ts:970`). No budgets changed; the second appears cascading, not separately diagnosed. |
| Matrix reaction ownership | 11/11 pass; wrapper339.25s. |
| Lint suppression contracts | 3/3 pass on frozen candidate; wrapper48.94s. No new suppressions. |
| Architecture | Zero runtime value cycles; zero static/Madge components. |

Memory owner/sibling proof: 108/109 pass across nine files, wrapper939.49s. The only failure was this patch's newly authored assertion expecting the provider's raw close error instead of the owner's existing normalized diagnostic. After correcting that assertion without a production change, its exact case passed (4.389s execution, Vitest350.74s, wrapper373.90s, dominated by transforms). The other twelve registry cases were unselected in that focused invocation, not skipped in source. Together the runs prove all109 selected contracts, including actual-query retirement, shutdown drain, fallback/reload, healthy probe, transport and deadline behavior.

Local tooling notes: the first changed-file run required removing one now-unused assertion-safety allowance. The corrected run passed conflict markers (27.14s), line-cap (4.43s), max-lines (69.87s), and assertion-safety (183.85s), then was intentionally stopped after the full-source SQLite worker inventory produced no result for 681.03s. This was incomplete local proof, not a passing inventory or an inherited source failure. Native production and test extension typegraphs both pass. Scoped lint could not begin analysis because SDK declaration preparation hit its unchanged 300000ms budget, both in the earlier Reef attempt and the final scoped attempt; neither produced a lint diagnostic. Final exact-head hosted CI below closes both gaps, with inventories running on the PR's frozen merge tree. Two custom-config attribution attempts were abandoned for harness setup failures; they are not behavior proof. Teams attribution above uses a normal full-main export and normal harness. No remote lease, live Teams tenant or live provider proof is claimed.

Final formatting: all changed source/test/doc files pass. Plugin boundary report passes (zero eligible compatibility removals); UI localization verification passes. No public SDK files/exports or package manifests changed, so an SDK API-surface diff is not applicable.

Independent review reported one P2 about an older Workboard read replacing newer `lastKnown` fallback facts before a subsequent backend outage. Declined as the explicitly accepted cache tradeoff, not silently ignored: fallback is presentation-only, availability remains visible, the next successful read repairs it, and `move` independently rereads authoritative facts/scope before its guarded write. The introducing controls are synthetic (#165896/#165141); no user-data, authorization, or persisted-write invariant is relaxed.

First hosted CI run `38334064250` on `dabbd9208a20068c24e6901b41a13415c04ac856` completed with two owned lint failures: `check-lint-extensions-2` (explicit boolean and exhaustive return in Reef) and `check-lint-extensions-3` (default generic argument/Promise iterable in Memory, exhaustive return/shadowed local in Workboard). Its `openclaw/ci-gate` failure aggregates those two jobs. All other planned jobs passed, including SQLite inventories, source contracts, types, extension tests, and QA smoke. The focused correction adds five production lines. The first PR-evidence run also failed because this body's headings did not match the required template; corrected headings passed in run `38334357043`. Metadata auto-response cancellations and the superseded evidence run contain no product test suite. No inherited-failure exception is being claimed for these owned failures.

**Final exact-head CI passes:** [run 38335564816](https://github.com/openclaw/openclaw/actions/runs/38335564816) on `b86c1ba06fa325f178007ba736c294cdd67a566d`, including `openclaw/ci-gate`, both extension-lint stripes, full inventories/ratchets, source contracts, typegraphs, selected extension bundles, security, and all QA smoke profiles. This closes the local inventory/lint tooling gaps described above. All exact-head check runs were enumerated; no failed, cancelled, timed-out, or pending check remains. No admin exception, manual rerun, dispatch, or rebase was used. CI job wall seconds: extension bundles 1/2/3/4-1/4-2/5 = 210/160/183/247/137/229; extension lint stripes 2/3 = 145/91; baseline ratchets = 271. These are parallel job wall times including setup, not added test execution time.

The lint-only correction also passes native production types, formatting, suppression contracts (3/3; 65.59s wrapper), runtime cycles (0), static/Madge cycles (0), Workboard actions (32/32; 17.93s) and popover (1/1; 16.16s), plus Reef trust/Memory provider lifecycle (51/51; 401.38s Vitest, 445.49s wrapper). Independent review of that delta is scoped-clean at P0–P2; the original explicitly declined display-cache tradeoff remains documented above.

## Visual proof

Before/after attachments show the actual built Workboard plugin against synthetic fixture data. Before: details menu at the page origin. After: anchored to its trigger. No pixel-identical claim across fixture timestamps.

![Before: synthetic Workboard details menu at the page origin](https://github.com/user-attachments/assets/4051b726-6af0-45fe-a0b6-e896b1c33a40)

![After: synthetic Workboard details menu anchored to its trigger](https://github.com/user-attachments/assets/26de3267-537f-46ef-b477-1adb5b0de290)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…openclaw#170511)

## What Problem This Solves

Consolidate duplicate extension paths and remove speculative lifecycle defenses in Codex, Memory Core, Microsoft Teams, Matrix, Reef, and Workboard. The candidate removes **522 net production lines** (tests, fixtures, generated files, declaration files, and documentation excluded; both new production modules included). This uses the campaign's honest 500–999-line fallback after the scoped growth/largest-first pass; it does not remove features to reach a quota.

Workboard's four card actions now share one discriminated action component, its draft controls share one renderer, and menu-only pass-through components are gone. Reef's worker and released-host adapters share one pure seven-command trust-transition policy while retaining their own atomic storage boundaries. Teams reuses its Graph/context/setup owners. Memory keeps normal parallel-query and sync-generation retirement draining, expressed with simpler active-completion tracking rather than nested borrower wrappers.

An adjacent Workboard defect is fixed: conditional Solid fragments could run a popover ref before the preceding trigger entered the document, positioning the details menu at the page origin. Listener/anchor setup now runs after the DOM commit. The regression fails against the unchanged implementation and passes with this repair.

No SDK export, config, protocol, dependency, database schema, durability, retention, or permission contract is changed. The protected standalone session-memory backend is untouched. No changelog edit.

User impact: Workboard details menus anchor to their trigger instead of the page origin. Other changes simplify internal implementation, with the best-effort timing and diagnostic compromises below; no migration or operator action is required.

## Best-effort tradeoffs accepted

- Codex diagnostic accessors throwing or mutable transport identities: [openclaw#163388](openclaw#163388) adds synthetic throwing-accessor coverage, not an actual-use human report. Actual accessors are local reads and registration publishes frozen identities. Accessor programmer errors now surface; the diagnostic sink catch, disclosure allowlist, attempt isolation, and timeout/cleanup behavior remain.
- Offline Codex migration CAS conflicts: [openclaw#168479](openclaw#168479) introduced retry loops without a human competing-writer report. Gateway ownership excludes live foreign writers. One atomic attempt plus existing persisted-result validation now retains the source sidecar and reports a warning on conflict; a later Doctor run can retry.
- Retired Codex legacy JSON rewritten during migration: [openclaw#104504](openclaw#104504) added a synthetic locator-rewrite test; human [openclaw#104503](openclaw#104503) concerns fingerprint overflow, whose fix remains. Legacy indexes are offline inputs, so a second locator/lifecycle read is removed. Initial containment/malformed-owner validation and canonical session ownership checks remain; unsupported concurrent legacy edits are picked up next run.
- Memory manager acquisition repeatedly retrying failed global retirement: [openclaw#144252](openclaw#144252) has synthetic close failures, no human incident requiring recursive acquisition recovery. Acquisition now awaits the pending close once and reports its error; the retirement owner is retained and explicit close can retry.
- Abandoned, abort-ignoring memory diagnostic probes holding provider retirement indefinitely: [openclaw#113471](openclaw#113471) and [openclaw#166973](openclaw#166973) provide synthetic lifecycle proof, not a human abandoned-probe incident. Timed-out read-only diagnostics no longer retain a redundant inner borrower. Ordinary active searches, sync generations, healthy operations, and custom closable-provider draining remain protected.
- Teams simultaneous Gateway writers: [openclaw#88411](openclaw#88411) introduced the persistence migration/file lock without a human multi-Gateway incident and did not test live tenant traffic. The Gateway is the sole database owner. Removed cross-process stale-lock/backoff machinery; local FIFO remains. Unsupported simultaneous processes may overwrite each other rather than coordinate.
- Workboard stale cache publication and an exact-expiry late join: [openclaw#165896](openclaw#165896), [openclaw#165141](openclaw#165141), and [openclaw#165698](openclaw#165698) use synthetic performance/interleaving controls, not a human incident. One read may return an older projection/fallback; normal revision/age invalidation refreshes it next read. Measured caching, the 64-entry bound, and read authority remain.
- Workboard direct stop/start before asynchronous startup settles: [openclaw#146976](openclaw#146976) forces unsupported lifecycle ordering in a test. The host service owner already awaits raw startup before stop. Removed plugin-local generation/startup handoff; supported host lifecycle is unchanged, unsupported direct reentry no longer has a second lifecycle owner.
- Reef failed owner-notice dispatch/ack retry timing: [openclaw#109160](openclaw#109160) pins injected failures and exponential timers, without a human report requiring that second scheduler. Durable pending notices now retry during ordinary successful 30-second reconciliation or restart. A failed acknowledgement may redispatch conservative stop-only guidance; durable resend reservation/cooldown prevents granting a second resend. The per-peer queue also makes the removed in-flight set redundant.
- Reef synchronous intermediate lease theft: [openclaw#109380](openclaw#109380) and [openclaw#168340](openclaw#168340) describe synthetic interleavings, not human concurrent-writer incidents. SDK callbacks commit synchronously and there is no await between acquisition and settlement. Unsupported reentrant callbacks/foreign writers are no longer checked at every intermediate step. Initial acquisition, final head-owner check, staged recovery, uncertain-commit witness, rollback, and retention ordering remain.
- Workboard fabricated native event targets and repeated widget predicates: renderer port [openclaw#168606](openclaw#168606) added boilerplate without a human incident. JSX native bindings already guarantee `currentTarget` types, and the owning menu already excludes widgets. Fabricated direct handler calls may throw; real event dispatch, widget behavior, and untrusted `event.target` checks are unchanged.

## Coverage ledger

Discovery began with scoped three-day growth, then fourteen-day history and largest production owners. Each removed mechanism was checked against its introduction and current callers; no dormant/in-flight foundation was deleted. Exact and normalized duplicate scans informed structural inspection, not automatic rewrites.

| Owner / original location | Decision and evidence |
| --- | --- |
| Codex `app-server/request-diagnostics.ts:28,109,133` | Remove speculative accessor catches/identity copy; keep timeout sink and disclosure boundary (openclaw#163388). |
| Codex `command-handler-actions.ts:109` | Share sandbox/execution result assembly; preserve policy selectors, guards, currentness and release. |
| Codex `migration/session-binding-sidecars.ts:460,549,627` | Single CAS attempt and one legacy-input read; preserve sidecar on conflict and canonical effect validation (openclaw#168479, openclaw#104504). |
| Codex `installed-probe.ts:29`, native session preparation/monitor | KEEP isolated managed storage, credentials, native execution authority and ordinary write settlement. Upstream configuration/storage contract inspected directly. |
| Memory `memory/search-deadline.ts:42` | One rejected cancellation promise replaces sentinel race; preserve cancellation/error identity, abort ordering, wall-clock guard and cleanup (openclaw#95757, openclaw#147702). |
| Memory `manager-embedding-ops.ts:84`, `manager-registry.ts:264` | Simplify nested borrower bookkeeping and failed-close recovery; preserve outer leases, normal drain and documented retiring-cache fence (openclaw#113471, openclaw#166973, openclaw#144252). An initially broader removal was rejected during review. |
| Memory publication, database context, index generation, transfer and cache owners | KEEP user-data transaction/publication, Forget exclusion, bounded transfers, worker ownership, integrity, performance caches and normal shutdown settlement (openclaw#168860, openclaw#169164, openclaw#169251, openclaw#170183, openclaw#170302, openclaw#170407). |
| Memory paused deadlines, Unicode query, KNN/vector scan, watchers | KEEP human-reported SQLite stalls (openclaw#137056), dependency tokenizer behavior, external/native input validation, bounded resources and realistic cancellation. |
| Memory dreaming/REM, migration/repair, backfill and standing intents | KEEP user-facing features, privacy/source validation, persisted rollback and public formats. Phase E untouched. |
| Teams `sqlite-state.ts:27`, `graph.ts:85,177` | Remove redundant foreign-writer lock; one guarded Graph transport retains auth/SSRF, bounded parsing and release (openclaw#88411). |
| Teams `setup-surface.ts:102`, `graph-group-management.ts:32,96`, `channel.ts:267` | Consolidate identical saves/context/pending result bookkeeping; preserve provider-specific validation, labels, errors, ordering and direct results (openclaw#112811). |
| Matrix `matrix/actions/reactions.ts:135` | Remove duplicate missing-sender/empty-result guards; selector remains ownership boundary, empty list has no redactions. |
| Matrix crypto store, verification, readiness, send FIFO and thread binding owners | KEEP room-key durability, real throwing dependency getters, encryption/send authority, public compatibility and accepted writes (openclaw#160707, openclaw#70401, openclaw#163012, openclaw#168485, openclaw#169405). |
| Teams pending-upload dual owners | HOLD: persisting currently memory-only reply consent bytes would change privacy/persistence; deleting SQLite loses restart recovery. Needs an explicit policy choice, not a deslop shortcut. |
| Teams streaming, multi-account configuration and exported setup factory | KEEP Stop/partial-delivery/FIFO, credential isolation and published factory signature (openclaw#141348, openclaw#112811). |
| Reef `trust-state-operation.ts:164`, `trust-store.legacy.ts:115` | Share pure seven-command transitions, retain worker/native atomic adapters, schema checks, trust revisions and authorization (openclaw#168340). |
| Reef `owner-notice.ts:32,72,122,253`, `audit-state.legacy.ts:145–255` | Remove duplicate retry scheduler/in-flight set and synchronous intermediate lease checks; preserve durable recovery/security (openclaw#109160, openclaw#109380). |
| Reef released-host adapter and trust delivery settlement | KEEP declared host compatibility, accepted-write shutdown settlement, peer/key authority and user-data crash recovery. |
| X events/allowlist/verification | KEEP paid-event settlement, bounded polling and credential/access authority. |
| llama.cpp media/provider/install/orphan owners | KEEP confidentiality of local inputs, digest cache integrity and safe process identity before termination (openclaw#167902). |
| ClawRouter pool/dashboard | KEEP untrusted network projection, bounded responses and active features; no useful large duplicate justified added abstraction. |
| Workboard `view-card-actions.tsx:215`, `view-card.tsx:102`, `view-draft-choices.tsx:6` | Consolidate actions, menu wrappers and card/bulk draft controls; all callers migrated (openclaw#168606). |
| Workboard native handlers and `view-popover.ts:19` | Drop impossible bound-target guards; repair ordinary conditional-fragment anchor timing (openclaw#168606). |
| Workboard `sessions-board.ts:149,305`, `change-events.ts:6`, `gateway.ts:211` | Remove duplicate cache/lifecycle fences; share workspace input preparation while retaining workspace/security effect checks. |
| Workboard draft/focus/pending-write/editor, board save and label measurement owners | KEEP real unsaved input, async writes, keyboard focus, live-authority checks and measured layout batching. |

## Evidence

All local build/test/CLI commands use task-owned HOME, OpenClaw state/config and XDG directories. No real Gateway or user state is used. No timeout increases, retries, skips, new suppressions or weakened retained-behavior baselines.

Final proof receipts and exact-head CI attribution are recorded below. Cold compiled-worker preparation dominates several local timings; these are not CI timings or live-provider claims.

| Focused local proof | Result / wall cost |
| --- | --- |
| Codex request diagnostics | 14/14 pass; wrapper445.55s (cold worker/import dominated). |
| Codex commands + Doctor contract | 122/123 pass; wrapper1352.60s. Doctor contract passes. The one method-list assertion (`commands.test.ts:951`) also observes background monitor `thread/read` calls. It **reproduces with explicit clean-base source loaded from `9b5bac5de29fac5a2df162265bbf01b6fb82e6ed`**: extra reads followed by the expected `thread/resume`, selected-case8.411s/Vitest403.28s. The affected test/support/actions/bindings/monitor files are byte-unchanged between that base and pinned main. No test skips or timing changes were added;99 unrelated cases were unselected for attribution. |
| Workboard backend (sessions-board, Gateway, change-events, registration lifecycle) | 48/48 pass, four files; wrapper587.54s, Vitest545.18s. |
| Workboard entire browser scope before final followups; final affected browser suites | 237/237 across29 files in59.03s; final103/103 across6 files in31.95s. New popover regression1/1 in9.34s; unchanged source fails intended geometry assertion in14.57s. |
| Workboard actual compiled WebKit consumer | Pass: anchored menu, filter keyboard dismissal, nested Escape preserving dialog, focus return, zero page errors. |
| Reef trust/friends/audit/receipt/outbound/notifier | 119/119 across6 files; wrapper927.25s, including cold worker compilation. Earlier unchanged channel proof25/25 pass. |
| Teams sqlite/Graph/read authority/setup | 72/72 across5 files; wrapper385.62s. |
| Teams Graph contexts/actions | 73/73 across3 files; wrapper327.91s. |
| Teams mutation callers/setup policy | 42/42 across5 files; wrapper776.30s. |
| Teams resolver + existing channel tests | Resolver4/4 pass; existing channel44 pass/2 fail, wrapper550.01s. **Both failures reproduce on full pinned main `4915e46c89b223ae4cdcdefe46fabc948b9bf7fa`**,44 pass/2 fail, wrapper464.42s: approval-monitor startup timeout120000ms (`channel.test.ts:313`) and subsequent `MSTeams runtime not initialized` (`runtime-store.ts:85` → `monitor.ts:81` → `channel.test.ts:970`). No budgets changed; the second appears cascading, not separately diagnosed. |
| Matrix reaction ownership | 11/11 pass; wrapper339.25s. |
| Lint suppression contracts | 3/3 pass on frozen candidate; wrapper48.94s. No new suppressions. |
| Architecture | Zero runtime value cycles; zero static/Madge components. |

Memory owner/sibling proof: 108/109 pass across nine files, wrapper939.49s. The only failure was this patch's newly authored assertion expecting the provider's raw close error instead of the owner's existing normalized diagnostic. After correcting that assertion without a production change, its exact case passed (4.389s execution, Vitest350.74s, wrapper373.90s, dominated by transforms). The other twelve registry cases were unselected in that focused invocation, not skipped in source. Together the runs prove all109 selected contracts, including actual-query retirement, shutdown drain, fallback/reload, healthy probe, transport and deadline behavior.

Local tooling notes: the first changed-file run required removing one now-unused assertion-safety allowance. The corrected run passed conflict markers (27.14s), line-cap (4.43s), max-lines (69.87s), and assertion-safety (183.85s), then was intentionally stopped after the full-source SQLite worker inventory produced no result for 681.03s. This was incomplete local proof, not a passing inventory or an inherited source failure. Native production and test extension typegraphs both pass. Scoped lint could not begin analysis because SDK declaration preparation hit its unchanged 300000ms budget, both in the earlier Reef attempt and the final scoped attempt; neither produced a lint diagnostic. Final exact-head hosted CI below closes both gaps, with inventories running on the PR's frozen merge tree. Two custom-config attribution attempts were abandoned for harness setup failures; they are not behavior proof. Teams attribution above uses a normal full-main export and normal harness. No remote lease, live Teams tenant or live provider proof is claimed.

Final formatting: all changed source/test/doc files pass. Plugin boundary report passes (zero eligible compatibility removals); UI localization verification passes. No public SDK files/exports or package manifests changed, so an SDK API-surface diff is not applicable.

Independent review reported one P2 about an older Workboard read replacing newer `lastKnown` fallback facts before a subsequent backend outage. Declined as the explicitly accepted cache tradeoff, not silently ignored: fallback is presentation-only, availability remains visible, the next successful read repairs it, and `move` independently rereads authoritative facts/scope before its guarded write. The introducing controls are synthetic (openclaw#165896/openclaw#165141); no user-data, authorization, or persisted-write invariant is relaxed.

First hosted CI run `38334064250` on `dabbd9208a20068c24e6901b41a13415c04ac856` completed with two owned lint failures: `check-lint-extensions-2` (explicit boolean and exhaustive return in Reef) and `check-lint-extensions-3` (default generic argument/Promise iterable in Memory, exhaustive return/shadowed local in Workboard). Its `openclaw/ci-gate` failure aggregates those two jobs. All other planned jobs passed, including SQLite inventories, source contracts, types, extension tests, and QA smoke. The focused correction adds five production lines. The first PR-evidence run also failed because this body's headings did not match the required template; corrected headings passed in run `38334357043`. Metadata auto-response cancellations and the superseded evidence run contain no product test suite. No inherited-failure exception is being claimed for these owned failures.

**Final exact-head CI passes:** [run 38335564816](https://github.com/openclaw/openclaw/actions/runs/38335564816) on `b86c1ba06fa325f178007ba736c294cdd67a566d`, including `openclaw/ci-gate`, both extension-lint stripes, full inventories/ratchets, source contracts, typegraphs, selected extension bundles, security, and all QA smoke profiles. This closes the local inventory/lint tooling gaps described above. All exact-head check runs were enumerated; no failed, cancelled, timed-out, or pending check remains. No admin exception, manual rerun, dispatch, or rebase was used. CI job wall seconds: extension bundles 1/2/3/4-1/4-2/5 = 210/160/183/247/137/229; extension lint stripes 2/3 = 145/91; baseline ratchets = 271. These are parallel job wall times including setup, not added test execution time.

The lint-only correction also passes native production types, formatting, suppression contracts (3/3; 65.59s wrapper), runtime cycles (0), static/Madge cycles (0), Workboard actions (32/32; 17.93s) and popover (1/1; 16.16s), plus Reef trust/Memory provider lifecycle (51/51; 401.38s Vitest, 445.49s wrapper). Independent review of that delta is scoped-clean at P0–P2; the original explicitly declined display-cache tradeoff remains documented above.

## Visual proof

Before/after attachments show the actual built Workboard plugin against synthetic fixture data. Before: details menu at the page origin. After: anchored to its trigger. No pixel-identical claim across fixture timestamps.

![Before: synthetic Workboard details menu at the page origin](https://github.com/user-attachments/assets/4051b726-6af0-45fe-a0b6-e896b1c33a40)

![After: synthetic Workboard details menu anchored to its trigger](https://github.com/user-attachments/assets/26de3267-537f-46ef-b477-1adb5b0de290)
RomneyDa pushed a commit that referenced this pull request Oct 16, 2026
Backport note: kept the branch's number-based statSync identities; carried the temporary-placement withPluginSourceCaptureStorage wrap for Doctor backup resource discovery (from #168340, absent on the branch) so the new copyOnly capture path applies; kept both updating.md paragraphs.

(cherry picked from commit de1531d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: reef Channel integration: reef docs Improvements or additions to documentation extensions: browser merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant