Skip to content

perf(session-readers): reuse captured admission facts - #166503

Merged
steipete merged 9 commits into
mainfrom
dbasync/w6discovery-reader
Oct 7, 2026
Merged

steipete merged 9 commits into
mainfrom
dbasync/w6discovery-reader

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Temporary session discovery cleanup could close a physical reader already held by the history owner, forcing later admission work. Runtime canonical readiness also reopened a native caller-thread reader, while canonical index inspection repeated catalog queries for every table and index.

Why This Change Was Made

Reuse existing reader custody and admitted facts. The final matched integration reduces warmed-turn SQL from 2,238.8 to 1,634.3 statements (−27.0%), with MAIN unchanged at 28 and no focused-flow median increase. A five-statement connection-phase median increase is traced to unchanged background admission moving across the first-turn boundary; original counts and source attribution are retained below.

Transfer selected readers and lexical aliases through the existing history owner, retaining full retirement on failure, revocation, or deletion. Reuse completed native-runtime and canonical-definition facts through the existing worker launcher, bound to their process/runtime/source identity. Actual databases remain validated.

Carry canonical pending work's original physical source and storage environment into the existing reclamation worker. Keep row rereads, synchronous transactions, FIFO, live transaction/commit guards, and acknowledged publication. Reuse the existing transaction-local catalog reader for index fingerprints while preserving integrity, uniqueness, and atomic repair checks.

This builds on #166054's fact reuse. No new service, persistent cache, schema, durability, retention, or environment setting is introduced. Startup/Doctor retain their native readiness probe at src/config/sessions/startup-migration.ts.

User Impact

Production: +431 / -110 / net +321, 541 changed lines across 20 production files; 38 files total. The validation baseline separately changes +1/-1. Stored formats remain unchanged. The official SDK comparison has no added/removed entrypoints or direct export-signature changes; its reachable declaration changes are described below.

Overlaps: #166054, #166053, the separate restart-preflight prerequisite #166252, sqlopt-schema (#166102 / #166253), sqlopt-envelope, wave-6 entry/auth/binding/worktree/approval (#166050), P7k/P7m, and the locked-writes chain. #162433 is the inactive umbrella design. The discovery cutover is withheld: its separate fixed-store request still grows from 29 to 119 all-thread statements after this prerequisite. Its remaining amplification is maintenance admission and planning; it needs a coherent no-op/read-only maintenance protocol before it can be proposed. Main is integrated by the merge commits documented below.

Evidence

Current landing candidate: e137db4b08714a19f0ccdb329d2c8b5295bf5b86, merging main 96ccec4a1385f1554579d60dc058fb82419dbc79 without conflicts. It now incorporates main's f6e6805b99b7a repair for requester sharing authority, as well as the earlier d641ea18101f8 publication-settlement and 1d10375ee563b terminal fixture fixes. Fresh full-diff P2 review is scoped-clean. Core production, all 27 core test-type shards, extension production/tests, scripts and all four root test-type shards pass; Madge reports zero cycles. Current-head CI run 37634766972 passed on attempt 1: 97 jobs succeeded, 22 were skipped, and the required CI gate and all applicable Security High checks succeeded. The two requester-flow files and the X publication case pass in their actual test logs. The official local SDK comparison passed in 875.48s: no added/removed entrypoints or direct exported-signature changes; the same 131 reachable-only records and ten declaration deltas remain (digest a18ebce56f38d00aeeaa4a806a43880fc69af35941c649c29bb52de08d483c20). Runtime build graph plus three import-closure files pass (83.57s native); compiled-wrapper inventory passes (41.81s native). The new full 54-workload SQL comparison against this base completed successfully; all raw phase/thread totals conserve exactly. No older benchmark is presented as a measurement of this candidate.

Current matched SQL proof: exact e137db4 versus 96ccec4, unchanged 39-file workload kit, Linux Node 24.21.0 / SQLite 3.53.4, three runs per side. Warmed all-thread statements/turn are 2,238.8 → 1,634.3 (−27.0%), ranges 2,238.4–2,242.4 → 1,634.0–1,635.8; MAIN stays 28. Whole-workload medians decrease 43,153 → 33,714 all-thread and 4,075 → 3,387 MAIN. Every focused-flow median holds or decreases: fixed-store MAIN/all 29 → 16; search all 248 → 229; role-list all 89 → 75; lifecycle all 67 → 66; canonical cold MAIN 4 → 2/all 664 → 636, warm MAIN 6 → 2/all 24 → 23. Other focused flows hold. All warmed execution/prepare errors are zero; the lifecycle fixture retains exactly two matching database-locked BEGIN refusals per sample on both sides.

The original audit retains one phase-median increase: 01.connect all-thread [349, 343, 342] → [348, 348, 348], median 343 → 348, with MAIN 14 unchanged. A separate second-session MAIN raw pair increases 143 → 144, while its median remains 143 and all-thread median decreases 6,992 → 5,498. These counts are neither excluded nor relabeled. Exact SQL fingerprints and captured source stacks identify the increase: the existing plugin-registry inspection path (src/agents/runtime-plugins.ts:262 → src/plugins/runtime/load-context.ts:102 → src/plugins/bundled-discovery-state.ts:140 → src/state/config-machine-state.ts:62) performs one admission group in connect for baseline run 1 and all candidate runs, but in first-turn setup for baseline runs 2–3. The metadata-read sentinel stays exactly 20 executions in every complete workload, with connect/first-turn counts [4/2, 3/3, 3/3] → [4/2, 4/2, 4/2]. Six admission fingerprints contribute +1 each in connect; the removed native runtime probe contributes −1, accounting exactly for +5. The affected fingerprints across connect plus first-turn hold or decrease. This is unchanged background work crossing a phase boundary, not new connect SQL. Original phases/counts remain unchanged; no rerun, subtraction, relabeling, or regression waiver was used. All requested focused-flow medians hold or improve, and the warmed reduction survives the final main integration.

The requester continuation failures were inherited. All five 111e464 runs and all five ccadf6a baseline runs of chat.reset-visible-yield.test.ts passed reset but reproduced the complete-case timeout, stale-authority diagnostic, and secondary teardown ENOENT. Main's repair marks runtime-only lifecycle/observer notifications as unchanged stored facts and retains committed sharing facts independently from a retired display watermark, preserving supersession and revocation checks. Its published commit records five-run requester E2E controls and passing repaired E2E/owner proof. This integration reuses that existing owner repair; it does not weaken authority or change the assertions. Current candidate CI passes both formerly failing requester-flow files: reset and complete cases in job 112838890908, and all five requester-owner E2E cases in job 112838890948 (185.93s native invocation).

Historical 111e464/ccadf6a qualification: official SDK comparison passed in 395.87s with zero entrypoint or direct declaration changes, the same 131 reachable-only records and ten declaration changes (digest e7e34488). Its CI run 37625145546 had the two requester-flow failures now repaired on main. All 48 focused/canonical SQL workloads passed and conserved exactly, with no flow-median growth. Search repetition 3 retained raw growth 233 → 235 while the three-run median decreased 233 → 229. The six-run warmed group was interrupted at its runner deadline and remains incomplete; captured partial control-plane run 1 has all-thread growth 48 → 51, explicitly retained alongside the reduced warmed-turn count. That interrupted group is not accepted as complete proof. All of these results keep their actual inputs; the later main integration requires the fresh full comparison above.

The fresh publication comparison completed five runs per side on 3500985/fa420c6: baseline had one pass, two 404s and two 503s; the previous PR head had two 404s and three 503s. All ten were valid outcomes with identical fixture bytes. Both failures therefore occur on the base. The fixture's append checkpoint precedes final run metadata writes; those publications can invalidate anonymous-read authorization facts or an in-flight representation. Main's repair waits for the existing session work-admission release before expecting a stable 200, preserving all assertions and refusal checks. The updated ccadf6a baseline passes the real X-to-session-to-anonymous-HTTP flow (1/1, 516.59s including cold build). No diagnostic overlay or speculative production repair was applied. The subsequent 111e464 CI also passed this X flow (job 112805661272, 20.37s native invocation); the current e137 candidate also passes this flow in job 112838890629 (31.08s native invocation).

Earlier integrated proof: previous candidate 3500985339990a33d122019c86efa546a66d0b3b. Main integration 853cefe16a42d415e9e7eb45b1a9a90f4b7f11ff incorporates fa420c6eb2752a78430cef1f2e3bf15cc17d8e9e by merge commit. The only conflict was the runtime probe in src/infra/node-sqlite.ts: preserve #166265's combined version/capability query, then publish the inherited admission fact after successful close. The earlier main integration and custody repairs are in e8068730d37a8eefa7555a697942463147703475.

The initial CI exposed a cleanup race: a successful missing-database reply can clear native-reader custody while discovery awaits cleanup. That does not revoke authority. The repaired guard retains live revoked/closing checks, and candidate cleanup consumes release callbacks once when explicit close overlaps retirement. A deferred-reply regression fails on the original guard; the existing alias test also reproduced duplicate unregister before the second owner fix.

Main's #166365 moved ordered metadata reads into the projection lane. The final test-only commit retires that warmed projection cache before the existing request-leak assertions, correcting the earlier history-lane cleanup. It closes no request-owned registrations and preserves every assertion. Published-head Linux proof passes all 112 cases in the two affected suites (178.10s); the prior CI merge plus only this test patch passes 113 cases (174s). Local focused proof passes 112 cases (433.66s). Completed attribution: five repetitions of each unrepaired suite at 853cefe reproduce the same resource assertions (models: 10 failed/13 passed; metadata: 1 failed/88 passed), while five repetitions of each suite at base fa420c6 pass all 23 and 89 cases respectively. All 20 retained logs were hash-verified. The runs span Linux Node 24.19 and macOS Node 24.21, each file singly with --maxWorkers=1; total harness wall time is 3,272s, including preparation/cleanup, not CI billable time or a performance comparison. Zero-test setup failures are excluded. No non-test file differs between 853cefe and 3500985.

Fresh full-diff Codex P2 review is scoped-clean on the integrated production revision; a fresh P2 review also clears the final test-only delta. After both main integrations, production types and all 27 test-type shards pass and Madge reports zero cycles. Both conflict-affected SQLite suites pass all 88 tests. On preceding integrated e806, the five failing-flow suites pass 159 tests (--maxWorkers=1, 1,061.15s harness wall time); five canonical/reader owner suites pass 116 tests (315.53s). Runtime build graph plus three import-closure files pass 14 tests (27.90s); the compiled PR-wrapper inventory case passes (16.28s). Earlier incomplete invocations are not counted as proof.

Completed integrated SQL comparison: exact candidate 853cefe versus main fa420c6, unchanged accepted workload, Node 24.21.0 / SQLite 3.53.4, three repetitions per side. All 54 workloads succeed; raw CSV phase/thread totals conserve exactly. Every focused-flow median holds or decreases. Warmed MAIN is 28 → 28; all-thread is 2,328.3 → 1,822.7 statements/turn (−21.715%), with ranges 2,327.0–2,329.3 → 1,821.6–1,824.1. Whole warmed workload falls 44,646 → 36,626 statements. Fixed-store MAIN/all falls 29 → 16; search all 245 → 226; role-list all 89 → 75; canonical cold MAIN 4 → 2 / all 662 → 636; canonical warm MAIN 6 → 2 / all 24 → 23. Other focused medians hold. Warmed execution/prepare failures are zero. The lifecycle fixture retains the same two database-locked BEGIN refusals per sample on both sides, with zero prepare failures. Connection-phase sample ranges overlap (343–346 → 338–349), while its median decreases 344 → 343; this is not a claim that every raw sample decreases. 3500985 reuses these measurements because production and workload inputs are byte-identical; it was not separately benchmarked.

Completed integrated SDK report: official local comparison 853cefe versus fa420c6 finds no added/removed entrypoints and no direct export-signature changes, with 131 reachable-only records. This remains valid for the test-only final commit. Released surface audit against v2026.10.1-beta.1 and stable v2026.9.8 covers Plugin SDK exports, api.runtime, and documented SDK subpaths. Changed callback/deferral/reclamation signatures and the removed index-collector export are internal; released SQLite exports retain their signatures. No compatibility record is needed. No modules were extracted; required compiled-wrapper/import-closure proof passes. No new environment names, schema, durability, retention, or permission contracts are introduced.

Previous-head CI disposition: run 37605192755 completed attempt 2 with only the inherited terminal type-check root and its aggregate failing. Attempt 1 had two root failures on tested merge af55a5233de4e565bfbb4be4433bac5bffba3419 (main 3fc3205a3c5a11fbb3d81160384c11acfaf5f260 plus the exact candidate). check-test-types-core-2 rejects the extra signal property at ui/src/components/terminal/terminal-panel-fonts.test.ts:56. Neither that test nor its boot-session implementation is touched by this PR; both are unchanged on current main, where the exact type graph reproduces the same TS2353 error. Scheduled-main job 112749124678 independently reports the same error. This is inherited, not passing CI.

checks-node-changed-1 intermittently reports HTTP 404 instead of 200 in x-publication-owner-composition.e2e.test.ts (“commits and anonymously reads maintainer work; denies guest and revoked creation”). Five isolated original-PR repetitions and five merge-base repetitions all pass; the preceding integrated-head CI also passed this case. Source tracing distinguishes unavailable sharing facts (404) from worker custody errors (503); a child-finalization/readiness race is possible but unproven. No matching scheduled-main failure was found. This remains unattributed, not proven inherited or fixed. The single authorized exact-job rerun passed: job 112762776627, 490 seconds total job time; the X file passed in 19.07 seconds. Attempt 2 completed all 115 jobs, with only the inherited terminal type-check root and its aggregate failing and no cancellations. This replay is not proof of a fix. The completed additional five-by-five results and main's subsequent fixture repair are recorded above. The projection-fixture controls are complete. This previous-head admin evidence is not reused for the new candidate, which now includes both main fixes.

ClawSweeper completed the e137 exact-head review at 2026-10-07 14:25:16 UTC and found no actionable code or security defect. It requested the refreshed SQL, SDK, and import results; completed results are recorded above. Its generic SQLite banner is addressed by the unchanged stored-format contract below.

The automated SQLite table-change banner does not correspond to a schema change in this diff: no table, column, index definition, trigger, schema version, or stored format changes. Index repair consumes the same canonical fingerprints through the existing catalog reader. The source review also confirms no stored-data model change. Historical published-driver/candidate compatibility proof remains qualified below.

Thanks @hippoley for independently tracing and confirming the distinction between native custody settlement and live revocation.

Historical pre-integration proof follows.

Base: 720e7c90455439808be4794ebbf8efa6d85a71fd; final candidate: efedc3db2f14d5e5cb35cff008a13433f14fecd9. SQL and the original remaining tests ran at ee7b2cd51582c706f7407c1538dbb4fca9fb8953; SDK/package/update proof ran at d9979ca83e431585466cc0cbbf207fe25c4aacca. Later changes shrink an assertion baseline, remove only an unused export modifier, rename local bindings, explicitly coerce the existing closing-Promise predicate to Boolean, and pass an explicit empty Node transfer list in a test. Query implementations, workload, test fixtures and assertions are unchanged. The final three owner suites were rerun. This is qualified evidence reuse, not an exact-final-head SQL or package measurement.

  • Causal negatives: old index inspection uses 8/218 statements against the six-statement budget; old canonical readiness performs caller-thread SQL; old caller environment capture selects the changed root. The repaired admission/Gateway suites pass 61 tests in 725.029s.
  • Native lifecycle: 17 tests passed in its completed shard (56.33s suite duration). The later combined local command received SIGKILL after 350.411s; all of its unfinished coverage subsequently passed on the cloud lease below.
  • Core types: 18.544s. Five selected test type graphs: 72.530s. Madge: zero cycles, 109.598s.
  • Fresh complete-diff Codex review through P2, including the final lint corrections, against the pinned main base: scoped-clean (396.829s).

SQL measurements use the shared unchanged workload/observer on Linux, Node 24.21.0, SQLite 3.53.4. Counts include background, helper and in-memory SQL; prepares and failed executions are separate. Each endpoint below is the median of three runs.

Focused flow MAIN before → after All-thread before → after
Fixed store after registry removal 29 → 16 29 → 16
Attachment cleanup 6 → 6 30 → 22
Attachment download 0 → 0 27 → 27
Dirty list / describe, each 0 → 0 11 → 11
Memory metadata: custom / default / shared, each 21 → 21 21 → 21
Dirty resident-row selection 3 → 3 16 → 16
Child lifecycle event 37 → 37 66 → 66
List role filtering 3 → 3 111 → 76
Session previews 0 → 0 67 → 67
Session search 110 → 110 236 → 236
Canonical pending readiness, cold 4 → 2 666 → 638
Canonical pending readiness, warm 6 → 2 24 → 23

All 42 original focused runs and six additional canonical-readiness runs pass. CSV phase/thread totals conserve exactly, both source trees restore cleanly, and every whole-fixture median decreases. Search ranges are 231–236 before and 236 after: one paired sample rises by five because the same worker transaction falls in setup in the first baseline sample and search in the others. Whole visibility totals are invariant within each side, 4,837 → 3,912; nothing is subtracted. Child-event ranges are 66–67 on both sides, with two pre-existing database-locked BEGIN refusals per sample on each side and zero prepare failures. Other listed successful-statement counts are identical across all three repetitions.

Canonical certification itself falls to zero MAIN statements; the preceding discovery step remains two MAIN statements. Its whole fixture falls 3,953 → 3,251 all-thread statements, with no execution or prepare failures. The original seven measurement families are unchanged; the added canonical fixture tests the actual pending-work producer and certification entry point, preserving stored row bytes.

Static T1: 844 → 844 (reduction 0; official inventory, 45.927s). The native readiness probe remains with startup/Doctor (session-canonical-validation-readiness.ts:69,87, startup-migration.ts:343, Gateway startup migration and embedded TUI startup). Shared canonical kernels remain required by the released v2026.9.8 synchronous getSessionEntry and listSessionEntries contracts (src/plugin-sdk/session-store-runtime.ts:391,417 at that tag); the indirect synchronous commit guard remains in src/gateway/server-methods/shared-types.ts:477 at that tag. Native index repair retains schema admission and explicit repair callers (src/state/openclaw-agent-db-schema.ts:184, src/state/openclaw-state-db-repair.ts:203). No reclassification is added. Runtime statement reductions are separate from this static count.

Warmed turns (three complete unchanged workloads per side, ten warmed turns per run): MAIN 31 → 31; workers 2,895.9 → 2,090.3; helpers 39.0 → 31.2; all-thread 2,965.9 → 2,152.5 per turn (−813.4, −27.4%). All-thread ranges are 2,960.1–2,968.9 before and 2,149.5–2,154.9 after. Every whole-workload phase median decreases, and the complete workload falls 54,672 → 41,584 statements. Native execution and prepare failures are zero. This is a matched comparison against the pinned main above; it does not achieve the campaign's under-500 target.

Separate request-census diagnostics retain exact native phase/thread conservation and all unassigned/background SQL. Exact-entry requests stay 43/turn, with their SQL 506.2 → 220.5; target-inventory requests stay 29/turn, with SQL 247 → 73. These requests become cheaper, not fewer. Diagnostic totals are 3,000.5 → 2,161.2 and are not substituted for the unmodified workload measurements. All warmed requests have receive/completion matches; four unchanged unknown-target exchanges occur only during boot.

Instrumented workload elapsed medians are 74.958 → 68.011 seconds. Focused GNU-time maximum RSS is 5,731,236 → 5,807,040 KiB for the cold fixed-store group (including cache preparation), and 1,442,776 → 1,407,552 KiB for the remaining group; these are command maxima, not aggregate service RSS or production latency measurements.

The initial warmed build hit the cloud /tmp memory-filesystem quota before any samples. The successful pair uses the lease's existing native workspace, with unchanged source/runtime/harness inputs and no quota increase. All measurement archives are downloaded and hash-verified.

  • Remaining required tests: 48 files, 352 passing cases. Import closures: 26 files/58 cases, 206.615s; runtime build graph: 10 cases, 3.364s; exact server close-prelude case: 80.806s; remaining 20 focused/routing files: 283 cases, 249.280s. Commands use pnpm test <exact files> --maxWorkers=1; the close proof selects its required exact case. The native test command took 551.698s.
  • First changed-file check identified the required assertion-baseline shrink (50.241s); the exact metadata-only correction passes the standalone assertion check in 59.324s and fresh P2 review. The official database-worker ratchet passed in 4.476s, T1 844 → 844.
  • The next full check passed core types and all 27 selected test-type shards, then correctly rejected the unused exported index collector (1,854.912s). Making that internal helper private fixes the reported issue; the standalone dead-export scan passes all three modes with zero entries (380.377s).
  • Official SDK diff at d9979ca83e431585466cc0cbbf207fe25c4aacca against the pinned main base completed in 341.987s: zero added/removed entrypoints, zero direct signature changes, 131 reachable-only export records and 10 distinct reported declaration sections. The released v2026.9.8 Gateway context and this candidate both expose the projection as sessionRowProjectionOwner?: object with an optional () => Promise<void> initializer; prepared-row methods stay behind the private binding. No public context implementer gains a required pending-result field. The report includes optional reader-retention arguments, the preparation operation literal, internal pending-fact types, and declaration-module closure changes; it is not a zero-diff SDK claim.
  • Candidate package at d9979ca83e431585466cc0cbbf207fe25c4aacca passed in 522.788s, including artifact integrity checks.
  • Published 2026.9.8 driver against the verified d9979ca83e431585466cc0cbbf207fe25c4aacca candidate package passed in 647.215s. The package embeds that exact commit; the final lint-only commit is qualified separately above.
  • The complete d997 check passed every preceding guard, core and 27 test-type shards, and all three dead-export scans, then found three final lint issues (1,927.665s). The two-file correction passes focused lint (51.128s) and all 53 tests across the canonical-admission, history-lane and search-reader suites (313.033s including worker build). One initial focused lint invocation selected the general type config and timed out during declaration preparation; the successful invocation uses the same core lint config as check-changed.
  • Final complete node scripts/check-changed.mjs --base 720e7c90455439808be4794ebbf8efa6d85a71fd --head efedc3db2f14d5e5cb35cff008a13433f14fecd9 passed in 2,223.857s. This includes core and all 27 test-type shards, all three dead-export scans, core/script lint, the worker ratchet, import-cycle and remaining repository guards. Zero new environment names. All task-owned cloud leases are released.

@clawsweeper

clawsweeper Bot commented Oct 7, 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.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

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

  • Current SHA: e137db4b08714a19f0ccdb329d2c8b5295bf5b86
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/sqlite-read-pool.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 7, 2026
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 7, 2026, 10:25 AM ET / 14:25 UTC (Revision 11).

ClawSweeper review

What this changes

The PR preserves reusable session database readers and carries validated SQLite runtime, schema, and physical-source facts into existing workers to reduce repeated database work.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-index-schema.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 2 items remain

This maintainer-owned optimization remains useful and distinct from the merged prerequisites. The prior custody finding is fixed, and no new actionable defect was found; current-integration qualification remains outstanding.

Priority: P2
Reviewed head: e137db4b08714a19f0ccdb329d2c8b5295bf5b86

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-preserving optimization with substantial native evidence and a repaired regression; current-integration qualification remains to be recorded.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded native Gateway/worker workloads exercise reader discovery, canonical certification, search, lifecycle cleanup, and warmed turns after the optimization, with observed SQL reductions at their stated historical pins. That evidence remains useful but does not complete the current integration's matched performance gate. No stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded native Gateway/worker workloads exercise reader discovery, canonical certification, search, lifecycle cleanup, and warmed turns after the optimization, with observed SQL reductions at their stated historical pins. That evidence remains useful but does not complete the current integration's matched performance gate. No stored-data contract changes require migration proof.
Evidence reviewed 10 items Pinned scope and clean checkout: Reviewed the introduced delta from 96ccec4 to e137db4. Final tracked-worktree status remained clean. The supplied stale test merge was not used to infer merging effects.
Prior custody finding resolved: Cleanup retains exact physical readers and lexical aliases, then checks live revocation and closing state rather than treating native custody settlement as revocation. Failure still joins retirement. This matches the distinction identified in #166503 (comment).
Live authority retained at commit: Captured runtime work retains state, execution, physical-source, worker-claim, and validation-owner checks. The same assertions feed synchronous write admission and the existing commit authorization handshake; captured identity alone does not authorize a write.
Findings None None.
Security None None.

How this fits together

Session readers supply stored session metadata and transcript information to Gateway requests. Their lifecycle and validation owners coordinate worker reads, database cleanup, and canonical session certification.

flowchart TD
  A[Gateway session request] --> B[Session discovery]
  B --> C[Existing reader owner]
  C --> D[Retain selected readers]
  C --> E[Close unowned readers]
  A --> F[Captured validation facts]
  F --> G[Existing database workers]
  G --> H[Validated session results]
Loading

Before merge

  • Complete next step (P2) - Complete and record the full 54-workload matched SQL comparison for e137db4 against 96ccec4, plus the refreshed SDK comparison and import checks, retaining all outcomes and exact source pins.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +321, Tests +653, Docs +28, Other 0. Total +1002 across 38 files.

View PR surface stats
Area Files Added Removed Net
Source 20 431 110 +321
Tests 16 730 77 +653
Docs 1 28 0 +28
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 38 1190 188 +1002

Review metrics

Metric Value Why it matters
Production versus test growth production net +321; tests net +653 Production growth implements captured-source preparation and custody transfer through existing owners; tests cover lifecycle and invalidation boundaries.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/state/openclaw-state-db-audit-migration.ts, unknown-data-model-change: src/infra/sqlite-index-schema.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep reader custody and admitted facts with their existing lifecycle owners while demonstrating lower database work without weakening freshness, revocation, or commit settlement.

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

Not applicable as a new user-facing bug report. Source and recorded native workloads establish repeated database work, but this review did not execute the current candidate.

Is this the best way to solve the issue?

Yes: reusing the existing reader, admission, catalog, and reclamation owners is a focused solution that preserves current contracts; the latest integration still needs its recorded qualification results.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded session-reader efficiency improvement with useful native measurements and no newly established urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded native Gateway/worker workloads exercise reader discovery, canonical certification, search, lifecycle cleanup, and warmed turns after the optimization, with observed SQL reductions at their stated historical pins. That evidence remains useful but does not complete the current integration's matched performance gate. No stored-data contract changes require migration proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded native Gateway/worker workloads exercise reader discovery, canonical certification, search, lifecycle cleanup, and warmed turns after the optimization, with observed SQL reductions at their stated historical pins. That evidence remains useful but does not complete the current integration's matched performance gate. No stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned scope and clean checkout: Reviewed the introduced delta from 96ccec4 to e137db4. Final tracked-worktree status remained clean. The supplied stale test merge was not used to infer merging effects. (e137db4b0871)
  • Prior custody finding resolved: Cleanup retains exact physical readers and lexical aliases, then checks live revocation and closing state rather than treating native custody settlement as revocation. Failure still joins retirement. This matches the distinction identified in perf(session-readers): reuse captured admission facts #166503 (comment). (src/config/sessions/session-transcript-worker-resources.ts:553, e137db4b0871)
  • Live authority retained at commit: Captured runtime work retains state, execution, physical-source, worker-claim, and validation-owner checks. The same assertions feed synchronous write admission and the existing commit authorization handshake; captured identity alone does not authorize a write. (src/config/sessions/session-canonical-validation-readiness.ts:210, e137db4b0871)
  • Regression coverage: Introduced tests cover missing-reader settlement during cleanup, revocation with joined retirement, retained search-reader alias closure, caller-thread SQL avoidance, revoked validation receipts, and native or foreign schema drift. These exercise distinct lifecycle and storage contracts; no tests were executed during this read-only review. (src/config/sessions/session-transcript-worker-lanes.test.ts:329, e137db4b0871)
  • Complete captured body inspected: Retrieved the omitted body suffix and verified that the full body SHA-256 remains bed94a64748c4b20e30e910151035af3008bc8b4f9fdbbce5cff3da578e77958, matching the reviewed snapshot. It records completed native workloads at earlier source pins and explicitly leaves the e137db4/96ccec4 full SQL comparison, SDK comparison, and renewed import checks in progress. (e137db4b0871)
  • Historical real behavior proof: The captured body records three native runs per side for 853cefe versus fa420c6: all 54 workloads succeeded, totals conserved, focused-flow medians held or decreased, and warmed SQL fell from 2,328.3 to 1,822.7 statements per turn. These are historical measurements, not measurements of the current candidate. (853cefe16a42)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record the completed current-pair SQL comparison and refreshed SDK/import results at their exact source pins.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-07T08:34:39.207Z sha e806873 :: blocked before merge. :: none
  • reviewed 2026-10-07T09:04:37.284Z sha 853cefe :: needs changes before merge. :: none
  • reviewed 2026-10-07T10:12:51.385Z sha 3500985 :: blocked before merge. :: none
  • reviewed 2026-10-07T11:17:29.979Z sha 3500985 :: blocked before merge. :: none
  • reviewed 2026-10-07T11:34:35.369Z sha 3500985 :: blocked before merge. :: none
  • reviewed 2026-10-07T12:31:23.103Z sha 3500985 :: blocked before merge. :: none
  • reviewed 2026-10-07T13:13:03.525Z sha 111e464 :: needs changes before merge. :: none
  • reviewed 2026-10-07T13:55:31.259Z sha 111e464 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026

hippoley commented Oct 7, 2026

Copy link
Copy Markdown

I traced the exact-head custody failure in withSessionHistoryWorkerReadCandidates() and think the remaining P1 can be reduced to one predicate distinction:

https://github.com/hippoley/ClawManager/blob/main/docs/patches/openclaw-166503-custody-settlement-vs-revocation.md

The post-closeResources() check currently treats

!resource.nativeSequences.has(lane)

as revocation. But that map entry is native reader custody, not authority: successful worker replies can clear it through clearClosedDatabaseCustody(), and worker retirement clears it through releaseRetiredDatabaseCustody(), neither of which sets resource.revoked.

So the smallest repair looks like:

 [...retained.values()].some(
-  (resource) =>
-    resource.revoked || Boolean(resource.closing) || !resource.nativeSequences.has(lane),
+  (resource) => resource.revoked || Boolean(resource.closing),
 )

I would keep the earlier !resource.nativeSequences.has(lane) filter used while building retained; there it answers which resources are physically held before cleanup. The post-cleanup predicate answers a different question: whether authority was revoked while cleanup awaited.

Authority remains covered by the live candidate-resource registrations (revoked), resource-level revoked/closing, alias/current-path checks, and the final assertCurrent() before returning.

For validation, I would rerun the original failing Gateway cohorts from jobs 112676315430 / 112676315452 / 112676315265 first, then the focused lane/search and session-create-display-name suites. That proves normal settlement no longer looks revoked without weakening real revocation.

Source-reviewed against efedc3db2f14d5e5cb35cff008a13433f14fecd9; not executed on my side.

Merge current main while retaining the reader admission optimization.
Distinguish successful native-reader settlement from live revocation, and
consume candidate release callbacks once when cleanup joins retirement.

Keep alias retirement and request-leak assertions intact while allowing
lifecycle-owned warmed readers. The new missing-reader regression fails on
the original guard; overlapping retirement also reproduces duplicate release.

Validation: fresh Codex P2 review is clean; production and all 27 test-type
shards pass, Madge reports zero cycles, and worker/import closure checks pass.
Focused flow and final integration validation are recorded in PR #166503.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026
Merge current main and resolve the runtime-probe overlap with #166265.
Keep main's single SQLite version/capability query for unqualified runtimes,
and retain process/runtime-bound admission reuse for workers. Publish the
inherited fact only after the probe database closes successfully.

No public signatures, stored formats, schemas, or environment names change.
The combined probe and inherited-fact owner suites pass all 88 cases.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

…e checks

Main moved ordered metadata reads to the projection lane in #166365.
Retire that cache before checking for leaked request registrations, preserving
all existing response, authority, and no-resource assertions.

A diagnostic at the integrated head reproduced the failure and identified
only the idle projection reader's physical path and alias. Both corrected
files pass all 112 cases locally. Fresh P2 review, targeted types, lint, and
formatting pass. Production source is byte-identical to 853cefe.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The requested integrated SQL and SDK evidence is now complete and recorded in the PR body, with exact source pins. The current head is 3500985; its non-test files are byte-identical to the measured and SDK-reviewed 853cefe revision. The current CI failure investigation and one authorized single-job rerun are also documented there.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 7, 2026
Preserve the session-reader optimization while incorporating the existing child-settlement and terminal font fixture repairs. Refresh post-integration types, import-cycle, SDK, and matched SQL evidence before landing.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head is 111e464, a clean merge of main ccadf6a incorporating the existing publication-settlement and terminal fixture fixes. Fresh P2 review, all post-integration type lanes, and Madge pass. The PR body preserves earlier evidence at its actual source pins and identifies the current SDK/SQL repeats and exact-head CI still in progress.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Integrate the existing repair for requester continuation authority and the current worker-owner changes without changing the session-reader PR delta. Refresh post-integration type, cycle, SDK, behavior, and matched SQL evidence before landing.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head e137db4 cleanly integrates main 96ccec4, including the published requester sharing-authority repair f6e6805. Fresh P2 review, required post-integration type lanes, and Madge pass. The body records the new exact source pins and identifies the fresh SDK, full SQL comparison, and CI still pending; older evidence remains explicitly historical.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 7, 2026
@steipete
steipete merged commit cb01feb into main Oct 7, 2026
189 checks passed
@steipete
steipete deleted the dbasync/w6discovery-reader branch October 7, 2026 15:00
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
* perf(session-readers): reuse captured admission facts

* chore(session-readers): shrink assertion safety baseline

* refactor(session-readers): keep index collector private

* refactor(session-readers): make custody predicates explicit

* test(session-readers): retire the current projection cache in lifetime checks

Main moved ordered metadata reads to the projection lane in openclaw#166365.
Retire that cache before checking for leaked request registrations, preserving
all existing response, authority, and no-resource assertions.

A diagnostic at the integrated head reproduced the failure and identified
only the idle projection reader's physical path and alias. Both corrected
files pass all 112 cases locally. Fresh P2 review, targeted types, lint, and
formatting pass. Production source is byte-identical to 853cefe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants