Skip to content

perf(sessions): open cold history without restoring archives (schema 39) - #188397

Merged
steipete merged 14 commits into
mainfrom
steipete/perf-cold-page-navigation-rows-20261030
Oct 31, 2026
Merged

steipete merged 14 commits into
mainfrom
steipete/perf-cold-page-navigation-rows-20261030

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening an archived conversation waits for its entire transcript to restore through the agent database writer, even when the client needs only one bounded page. A busy writer turns that unnecessary restoration into a visible session-open delay.

Archival now retains the existing navigation, identity, active-event and index facts. SQL selects the bounded page before the payload reader fetches verified archive chunks. History and subscription snapshots leave the archive intact; writes and explicit restoration retain the existing restoration owner. Branch, reset, cursor, visibility and ordered live-event delivery remain the contracts. Unsupported envelope/Unicode cases stay inline to preserve their payload semantics.

The material-change review checkpoint was completed before implementation against docs/reference/database-schemas.md, docs/reference/database-schemas/worker-access.md, the Doctor migration guide and the update implementation contract. Peter approved the retained-navigation design and schema change on 2026-10-30.

Agent schema 38→39 was explicitly approved by Peter. It adds a valid representation to the existing payload constraint, with no new table or column. SQLite/PostgreSQL, port/backup readers and historical repairs share that contract. Doctor backfill is best effort, resumable and commits one archive at a time; pending archives retain the existing restore path. Rollback requires the corresponding pre-migration backup and a compatible binary.

Rebase note — 2026-10-30

Rebased onto origin/main 9f14244a6067e9ca0e22d1a2b8c5150e9cb7c693 at head 35fcb7c494839a6cb389ea03e4e65f4a99f44f6b. Main #188090 already owns the fresh-only usage.cost cache predicate and its single-agent/all-agent regression, plus the supported final-symlink denial diagnostics. Dropped our superseded cbee978ad238 commit rather than retaining a duplicate fix or test. The conflicted usage/skills files now match main. Main's newer direct-command steering assertions also remain intact; no steering-test delta is carried by this PR.

The cold-navigation patches are unchanged by the replay. Main's agent schema is still 38, so this PR remains the next consecutive 39 (state schema stays 36). Runtime/schema production delta is now +709 net lines; the broad non-test/non-doc delta is +1,636.

All 33 touched/conflicting test files were selected with --maxWorkers=1: 380 tests passed, with the nine PostgreSQL cases initially skipped by the ordinary runner. Those 9/9 then passed separately through the canonical conformance runner against a disposable local PostgreSQL 17 container with CI's pinned image and extensions. The first disposable attempt lacked those extensions and failed setup-dependent cases; that evidence is retained. Both owned containers were stopped and verified removed. No Team access occurred.

Scoped lint exposed the rebased schema coordinator at 703 code lines against the existing 700 limit. An unchanged memory-metadata migration helper moved beside its existing detection helper in openclaw-agent-db-schema-helpers.ts, leaving all three call sites and migration order intact and the coordinator at 698. No suppression or stored-shape change was added. Codex autoreview of this two-file move is scoped-clean with no accepted findings. After the move, 51 migration/subscription/closure tests, pnpm tsgo:core, pnpm tsgo:test:root, scoped core oxlint, oxfmt and the export-name collision guard all passed. Script/extension oxlint and formatting of all other touched/conflicting files also passed in the initial check pass.

A final fetch advanced main to 1bf930c8e40a547f0e2eda87f895b2a7a00e644a. A merge-tree preview of the final head against it is conflict-free, and its agent schema is still 38. The branch was force-pushed once. New-head PR CI is separate from the historical green run below.

Performance, storage and published-upgrade receipts below retain their original pinned revisions. The owner/upgrade measurements on 9ffaabf7 and its exact-head CI are historical evidence, not measurements or CI results for this rebased head. This rebase refresh does not rerun the stress campaign or published upgrade. Prior clean implementation review is reused for the unchanged stored-navigation patches; the small helper relocation received the fresh scoped review described above. The PR remains ready and must not be merged by this lane.

Evidence before this rebase

Head 9ffaabf7de6a48ebab4a271982ba702f2ec28052, comparison base f47669efcec232b35dc74ac2d5d89b60796e6540. Exact-head CI is green: 186 passed, 44 skipped, zero pending/failing, primary run 41149130953, attempt 1. Codex reviews have no accepted P0–P2 findings. The PR stays open for maintainer review; it has not been merged.

Owner measurements on pre-rebase head 9ffaabf7

The committed owner harness measures the real subscription handler with 256-message synthetic transcripts and an 80-message/256-KiB page. Baseline is f47669ef, candidate is 9ffaabf7. The fixed-work campaign completed 4,128 measured subscriptions per revision: 3,000 hot timing requests across AB/BA plus the predeclared extra AB pair, 1,000 hot allocation requests, and 32 timing plus 32 allocation requests for each cold/busy case. Allocation uses a separate 16-KiB main-isolate sampling pass. Total process CPU and main-thread CPU are reported separately; the remainder includes runtime helper/GC/compiler threads, not just JavaScript workers.

Case Subscribe p50 ms Subscribe p99 ms Total CPU ms/request Main CPU ms/request Sampled bytes/request
Hot, synchronized AB/BA mean 7.470 → 7.501 16.107 → 16.852 (n=1,000 per arm) 13.035 → 13.135 2.264 → 2.260 1,725,278 → 1,715,513
Cold 139.372 → 12.578 154.054 → 17.346 (n=32) 152.896 → 18.983 9.192 → 3.587 2,768,362 → 1,816,957
Cold, writer held for one second 1,165.632 → 10.090 1,202.393 → 15.046 (n=32) 182.007 → 15.754 11.195 → 3.222 3,070,984 → 1,815,692

Cold/busy percentiles have 32 samples per arm and are context, not tail gates. Cold CPU falls 87.58%, allocation 34.37%; held-writer CPU falls 91.34%, allocation 40.88%. Both timing and allocation passes preserve 32/32 archives, versus 0/32 on baseline. Every held-writer candidate reply finishes before release (32/32, baseline 0/32). All page content checks pass. These deterministic work counts directly cover the original failure.

Hot-session control and contention investigation

The sequential 1,000-session timing protocol produced a material adverse tail, which is retained here. Across all three pairs, mean run p99 was 32.406 → 91.936 ms (+59.530 ms, +183.70%); mean wall time was 10.417 → 17.648 ms/request (+69.41%). Total CPU was 13.693 → 14.616 ms/request (+6.73%), main CPU 2.983 → 3.199 (+7.27%), and p50 8.734 → 9.265 ms (+6.08%). Hot sampled allocation was 1,725,278 → 1,715,513 bytes/request (−0.57%, 1,000 requests per side).

Individual pair p99s were 37.566 → 18.718, 41.632 → 41.586, and 18.021 → 215.505 ms, each with 1,000 observations per arm. Four matched identical-baseline A/A pairs followed. Neither counterbalanced control block crossed the declared adverse gate: p99 changes were +1.495 ms/+9.29% and −36.577 ms/−68.98%. These controls alone do not dismiss the candidate signal. No samples, pauses or arms were excluded.

The third sequential candidate was slower throughout the run while host one-minute load rose 25.46→39.00, versus 14.32→14.69 during its earlier baseline arm. This motivated a separately declared simultaneous comparison, not exclusion or relabeling of the old result. Both revisions use independent synthetic state, the same warmup and measurement barriers, and wait for both measurements to finish before either writes diagnostics or cleans up. Fixture preparation order is counterbalanced AB/BA. Each arm opens 1,000 distinct sessions; no extra warmup or forced GC was added. Profiling is a separate diagnostic pair and never supplies acceptance timing.

The two synchronized untraced pairs completed another 2,000 hot requests per revision, with successful content checks and stable build/tool hashes:

Pair Total CPU ms/request Main CPU ms/request p50 ms p99 ms (1,000/arm) Host load1m, shared before→after
AB fixture order 12.980 → 13.011 2.277 → 2.225 7.483 → 7.395 15.953 → 16.629 7.398 → 7.423
BA fixture order 13.090 → 13.258 2.251 → 2.296 7.457 → 7.607 16.262 → 17.074 7.101 → 7.373
Paired mean 13.035 → 13.135 2.264 → 2.260 7.470 → 7.501 16.107 → 16.852 —

Mean CPU change is +0.100 ms/request (+0.77%) total and −0.0036 ms/request (−0.16%) main-thread. Mean wall time is 7.866 → 7.948 ms/request (+0.082 ms, +1.04%). Mean p99 change is +0.744 ms (+4.62%); neither pair crosses the declared adverse thresholds. This controlled first-open comparison supports a small hot-path cost, not a hot-path speedup. It does not establish the cause of the earlier sequential anomaly or demonstrate equivalent behavior at that earlier higher host load.

Endpoint RSS was 1,602.2 → 1,883.7 MiB in AB and 1,903.1 → 1,620.4 MiB in BA: the higher value followed the second-prepared arm. Counterbalanced mean RSS was 1,752.7 → 1,752.0 MiB (−0.63 MiB), and main heap was 572.14 → 571.97 MiB (−0.16 MiB). These are ordinary endpoints, not forced-GC retained-memory measurements. No memory win is claimed. Full before/after memory, synchronization timestamps and every observation are retained in the local evidence.

The final decision uses these simultaneous, counterbalanced measurements to control shared-host timing while keeping the earlier adverse results visible. No extra A/A campaign was triggered by this non-adverse protocol. The eight sequential A/A arms and their limits remain reported above.

The diagnostic profile pair used another 1,000 requests per revision and measured total CPU 13.115 → 13.128 ms/request and main CPU 2.396 → 2.380. It preserves full main-isolate profiles, request timelines, GC events and existing worker-request metrics. It does not provide nested-worker CPU stacks. Main profiles, GC and history-worker queue timings closely match: each arm completes 2,000 history operations, with summed worker elapsed time 5,995.406 → 5,998.948 ms. Both also show optional background writer/backfill activity after warmup. This overlap is not causal proof and does not explain the earlier 215.505-ms tail; no speculative production change was made from it.

The owner timing harness does not measure untraced GC or event-loop delay. The whole-Gateway stress below is explicitly pinned to earlier revisions and does not qualify the final runtime. All final-head owner builds/harnesses were hash-verified, and all owned measurement processes drained.

Storage and code cost

The synthetic storage corpus contains 2,048 archived sessions × 1,024 events = 2,097,152 events. Raw payloads total 3,577,628,672 bytes. Compressed archive bytes remain identical at 39,377,848 bytes. These repetitive payloads compress about 91×: this is a harsh metadata-to-archive ratio, not a production storage estimate.

Live database pages, all tables and indexes Bytes
Old archive-deletion policy 3,026,944
Retained navigation 2,741,854,208
Additional storage 2,738,827,264
Additional per archived session 1,337,318

That is 1.275 MiB per archived session, or 2.551 GiB across this corpus. This all-catalog dbstat comparison applies the old deletion policy inside a rolled-back transaction on the same corpus. It is not an old-build physical-file comparison; allocated files do not shrink simply because rows are deleted. The unchanged stored representation makes this corpus applicable to the final head.

Runtime/schema production growth after this rebase is +709 net lines. The approved stored representation, resumable migration, bounded archive reader and SQLite/PostgreSQL parity require this growth. Duplicate archive replay and the restore-only read dependency are removed. Performance tooling is +902 net lines (888 in two owner scripts; native Doctor stress preparation and its guide account for the rest). The full non-test/non-doc diff, including tooling/configuration/generated outputs, is +1,636 net lines.

Tests and test support add 866 net lines after removing the duplicate. The pre-rebase ratchet passed 6,316,939 / 6,348,041, with 31,102 lines of headroom. This PR changes neither the shared test-line baseline nor allocation files.

Correctness, integration and review

The initial subscription regression was red on baseline 97225ae1: subscribing restored and removed the archive. Final baseline owner runs reproduce the same work-count failure. sessions.messages-subscribe-cold.test.ts proves archive preservation; snapshot/live-event proof covers exact ordering and exactly-once persisted delivery. Bounded history regressions cover branch/reset intervals, older/newer cursors, visibility, byte caps and placement metadata. state-migrations.cold-navigation.test.ts migrates a backed-up pre-change synthetic database, interrupts and resumes without restoring payloads; the scoped predecessor test preserves unrelated later writes.

The latest integration passed 81 focused tests across Doctor, bounded/model context, subscription and lifecycle consumers. Core typechecking, pnpm tsgo:test:root, scoped oxlint/oxfmt and the ratchet passed. Broader proof is the exact-head CI run above, including all three PostgreSQL conformance jobs. Full implementation review and scoped follow-up Codex reviews are clean.

Main #188789 introduced a batched first-header scan that bypassed this PR's existing cold-session exclusion. The integration fix filters archive-marked sessions before aggregation and decoding. Its strengthened regression is red on the rebased pre-fix owner and green with the fix, including both navigation-only and exceptional inline cold rows; hot corruption assertions are unchanged.

Earlier CI exposed a usage.cost cache bug: transient refreshing results received the outer cache's 30-second TTL after the lower refresh settled. Main #188090 now owns the same fresh-only cache fix and broader scope coverage; this rebase drops our duplicate. The earlier handler regression was red before the fix and handler/lifetime tests passed 27/27. Remaining fixture repairs use the existing complete Gateway logger and deterministic watcher notifications. Main owns the symlink-denial diagnostic adjustment. Production authority is unchanged. Earlier fallback, steering and workspace fixture repairs were also superseded by main and are absent from this diff.

A prior Android job built and verified its APK but failed when the emulator went offline during trust cleanup. Both Android jobs passed on the final head without rerunning that old attempt. No tests or assertions were weakened to obtain green.

Latest-stable upgrade on pre-rebase measured head 9ffaabf7

A fresh registry check confirmed latest stable 2026.10.9. Its published driver upgraded a restored synthetic schema-25 database through the native updater to sealed 9ffaabf7, on pinned base f47669ef, in 372,716 ms. Terminal status was ok, run status succeeded, process exit was 0, and all 19 recorded steps exited 0. This covers agent schema 25→39, native backup restore, Doctor, package swap, old-driver handoff and Gateway rehearsal.

Activation completion was verified against the retained operation journal after the updater exited: anchor-retired, unlink-helper, with matching helper identity. Repeat installed Doctor exited 0. The archived fixture gained 129 identity rows, 128 active-event rows, 128 cold-message markers and its navigation index, while retaining zero hot message payload rows. Its original generation, SHA-256 and 4,204 compressed bytes were unchanged; SQLite quick_check passed.

The installed Gateway's initial 20-message subscription/history page and older 20-message cursor page matched exact order, role, timestamp, identity and synthetic content. Requests began only after listener readiness, without transport retries. Every owned build, updater, Doctor, client and Gateway process exited successfully and drained. Cleanup conservatively retained some temporary runtime artifacts when an unrelated process could not be classified; no unrelated process was signaled.

The native package owner validated tarball integrity and imports, then restored temporary manifest preparation. Package SHA-256 is a9fa040a36d2934cbe9a338665ed768ae05087a58347cfbc8aa83770d523ec8c. The baseline used supported sourcePerformance and candidate used supported runtime-only package; both share the runtime compiler/options, with source maps and private QA disabled. Their exact identities are retained. The full receipt is .local/buf540/upgrade/final-f476-9ffaabf/published-9ffaabf-proof.md.

This upgrade fixture contains ordinary user/assistant messages. Separate integration regressions cover background-result placement, branch/reset semantics and interrupted migration resume; the upgrade smoke does not claim those cases. Earlier efecf020 and f243711f upgrades remain historical evidence, superseded here by fresh proof of the current package.

Earlier owner measurements and the short-window hot CPU signal

Previous af8 → f243 owner measurements

These results belong to pinned base af8ab708 → packaged runtime f243711f. Historical head bd361c59 differed only in its test logger fixture; the final head integrates newer main and has separate results above. All 12 arms passed and their processes drained, with runtime/harness hashes verified before every arm and after completion. Each arm used 32 distinct sessions × 256 messages, 80-message/256-KiB pages. Timing ran AB; a separate 16-KiB allocation-sampling pass ran BA. Each revision completed 192 measured subscriptions (96 timing, 96 allocation).

Case Subscribe p50 ms Subscribe p99 ms (n=32; context only) CPU ms/request Sampled main-thread bytes/request
Hot 10.304 → 9.328 18.877 → 13.467 18.849 → 21.054 1,800,139 → 1,871,920
Cold 157.206 → 10.602 703.890 → 23.480 182.070 → 19.202 2,697,082 → 1,806,783
Cold, writer held for one second 1,174.241 → 10.374 1,533.569 → 18.720 192.881 → 16.588 3,054,901 → 1,837,621

Cold CPU fell 89.45%, sampled allocation 33.01%; held-writer CPU fell 91.40%, allocation 39.85%. Cold/busy archive preservation improved 0/32 → 32/32 in both passes; busy replies before writer release improved 0/32 → 32/32. These are deterministic behavior counts, independent of latency noise.

Hot CPU rose 2.205 ms/request (+11.70%) and allocation 71,782 bytes/request (+3.99%), despite lower p50/p99. Those increases remain reported; older-head controls do not establish this head neutral. The predeclared swapped pair also raised CPU: 16.971 → 20.688 ms/request (+21.90%). Across both pairs, CPU was 17.910 → 20.871 ms/request (+2.961 ms, +16.53%), with both pairs above +10%. Four matched identical-baseline A/A pairs completed successfully. Their counterbalanced CPU blocks were −3.99% and +2.32%; neither tripped the paired gate. These controls do not dismiss the candidate CPU signal. Source inspection found no extra query, decoding, parsing or worker churn on this measured first-page path, but that does not resolve the measurement. The final-head fixed-work protocol above uses 1,000 distinct sessions per hot arm and separates main-thread from whole-process CPU; all short-window observations remain reported.

Host one-minute load ranged 10.36–35.54 across the 12 arms. Every arm's load, RSS/heap endpoints and raw observations remain in .local/buf540/owner-f243711-af8ab70/. This unchanged owner harness does not instrument GC or event-loop delay; the separately pinned prior-head whole-Gateway stress below must not be relabeled as final-runtime proof. No samples or arms were excluded.

Earlier owner measurements and controls

The real subscription regression was red on baseline 97225ae1: subscription restored and removed the archive. Previous isolated handler/WebSocket proof verified archive preservation and an exact snapshot followed by three ordered, exactly-once persisted live events. Matched owner measurements use baseline c0c068e1 and candidate ffbeb87c, with 32 distinct 256-message sessions per case and arm, 80-message/256-KiB pages, timing AB and separate 16-KiB sampled-allocation BA. These measurements precede the later fallback/fixture CI repair; they are not relabeled as measurements of a later head:

Case Subscribe p50 ms, base → candidate Subscribe p99 ms (n=32, context) CPU ms/op Sampled main-thread bytes/op
Hot 8.293 → 9.662 14.054 → 30.872 18.664 → 22.330 1,785,458 → 1,843,731
Cold 141.296 → 8.550 154.406 → 16.449 144.415 → 14.054 2,753,651 → 1,868,368
Cold with writer held for one second 1,142.224 → 9.557 1,177.507 → 15.058 163.971 → 15.639 3,086,395 → 1,846,324

Each revision completed 192 measured subscriptions across the timing and allocation cases. Cold archives survived 0/32 → 32/32 subscriptions in both passes. Held-writer replies completed before release 0/32 → 32/32. All 12 processes exited successfully after isolated-state cleanup.

Hot results prompted further fixed-work measurements; none of the earlier results were discarded. A swapped 32-session pair left paired CPU 17.961 → 22.246 ms/op (+23.85%). Four identical-baseline 32-session controls had wide individual variation, but neither counterbalanced block met the paired rejection gate, so those controls alone do not explain away the CPU rise.

A longer, explicitly different workload revisited 32 warmed sessions for 2,048 subscriptions per arm, AB/BA: CPU 11.301 → 11.400 ms/op (+0.88%), p99 15.699 → 14.631 ms, loop p99 12.825 → 12.878 ms, and GC 0.08384 → 0.09462 ms/op (+0.01079 ms). This supports the warm repeated path, not the first-open case.

The unchanged committed harness then measured 1,000 distinct sessions per arm, AB/BA plus the one predeclared extra AB pair for mixed signs. All 6,000 pages were correct. Mean CPU was 11.761 → 12.228 ms/op (+3.97%); mean p50 7.747 → 7.677 ms. Mean run p99 was 17.025 → 36.995 ms, including the first candidate's 76.449-ms p99; the other candidate p99s were 16.652 and 17.884 ms. That adverse first-open tail remains reported. Four matched identical-baseline A/A pairs completed with all eight processes successful and hashes unchanged. Their first counterbalanced block itself crossed the rejection gates: CPU +1.206 ms/op (+11.94%), and p99 +4.103 ms (+30.99%), with both pairs ≥10% adverse for each metric. The second block did not cross a gate; the four-pair signed means were CPU +8.25% and p99 +15.03%. First-open hot attribution is therefore inconclusive, not a demonstrated hot win or a discarded candidate tail. Host load is context only; no samples or arms were excluded.

The prior bounded-page microbenchmark also remains prior-head evidence; its earlier gains are not relabeled as current measurements.

Prior-head canonical Gateway stress

The completed campaign is explicitly prior-head evidence: runtime base e3c85a81, runtime candidate 60947404, tooling 96a7dc75. It does not qualify the final rebased runtime.

Eight complete ≥10-minute arms used timing AB/BA and separate sampled-allocation AB/BA, fresh 10,800-session fixtures, 40 plugins, 65 WebSocket clients, native mock-provider turns/tools/subagents and sidebar/list/search churn. 320 turns/tool pairs and 15,422 RPCs completed without errors. All state and Gateways were synthetic and local; no Team access or load occurred. All owned processes/listeners drained.

Prior-head paired mean Base → candidate Absolute change
Main-thread CPU, untraced 7.563% → 7.307% −0.256 pp (−3.38%)
Sampled JS allocation, separate pass 18.875 → 18.678 MiB/s −0.196 MiB/s (−1.04%)
Total GC, untraced 0.14989 → 0.14860 s/min −1.29 ms/min
Event-loop p99 27.582 → 27.795 ms +0.213 ms, mixed signs
Client sessions.list p99 35.321 → 32.103 ms −3.218 ms
Endpoint RSS 2677.1 → 2679.3 MiB +2.2 MiB, mixed signs
Endpoint main heap 524.8 → 557.6 MiB +32.8 MiB (+6.25%)
Natural post-major old generation 413.5 → 421.6 MiB +8.1 MiB

No retained-heap improvement is claimed. Forced GC after measurement gave 405.287→405.296 MiB old generation, diagnostic only. Timing maximum GC pauses were 34.63→38.58 ms and 34.34→40.41 ms. No material adverse timing gate triggered; no A/A controls or extra pair were required. Client tails alone did not decide acceptance. Allocation-only event-loop maxima of 3,917 and 1,100 ms remain reported as diagnostics; sampled-pass timing/GC is not acceptance evidence. Promotion bytes were not measured.

Both arms were seeded at schema 38 by baseline tooling and ran their own built Doctor before readiness/warmup/measurement; candidate migrated to 39. The reviewed harness setup avoids service repair. Both setup-smoke arms preserved 108 sessions and 116 message identities. Fixed seed 1711, fixture clock 1793378753582 and 60-second warmup were identical. A private output root supplied safe temporary-directory ancestors without changing shared permissions. Earlier setup failures were preserved and excluded, not interpreted as performance results.

The corpus contains archived session-list flags, not deliberately cold payload archives. It proves mixed-workload compatibility on those prior heads. Subscriptions attach during setup, so it supplies no measured subscribe-handler percentile. The owner and upgrade proofs cover actual cold reads.

Benchmark usage lives in each script's header and the canonical harness's own guide; the shared performance README is unchanged.

Prior-head stress: per-arm metrics, server handlers, host load and GC

All values below belong only to the pinned e3c85a8→60947404 campaign. CPU is main-thread CPU divided by actual wall time (100%=one core); RSS/main heap are endpoints. Loop quantiles use whole-window histograms, client RPC quantiles raw observations. Handler p99 is interpolated from Prometheus histogram deltas between first/last measured scrapes; each list-handler row has 1,173 observations. Host load is the duration-weighted mean of sampled 1-minute load. Allocation rows have diagnostic CPU/GC/tails/memory.

Timing

Pair/arm CPU % Alloc MiB/s GC s/min Loop p99 ms (n) List p99 ms (n) RSS/heap MiB Server list mean/p99 ms Host load1m
1/base 7.448 — 0.150 27.492 (28121) 38.173 (1204) 2762.1/545.1 7.099/30.675 13.95
1/candidate 7.418 — 0.154 28.279 (28103) 34.089 (1204) 2623.8/562.8 7.048/29.025 14.00
2/candidate 7.195 — 0.143 27.312 (28253) 30.118 (1194) 2734.8/552.5 6.837/27.612 13.25
2/base 7.677 — 0.149 27.673 (28337) 32.470 (1199) 2592.0/504.5 7.698/29.721 13.70

Allocation

Pair/arm CPU % Alloc MiB/s GC s/min Loop p99 ms (n) List p99 ms (n) RSS/heap MiB Server list mean/p99 ms Host load1m
1/base 9.081 18.787 0.306 33.784 (27662) 113.463 (1193) 2503.6/528.8 9.599/82.700 20.29
1/candidate 8.722 18.605 0.330 33.915 (27384) 224.806 (1193) 2557.9/526.1 13.009/59.336 20.86
2/candidate 8.154 18.751 0.316 29.868 (28109) 76.943 (1195) 2617.5/513.7 9.243/37.270 14.22
2/base 7.494 18.962 0.266 32.047 (27802) 76.506 (1198) 2470.5/545.2 7.668/47.567 15.55

Timing GC kinds and maxima

Major-GC tails have only 29–31 collections per arm and remain context. Both timing maximum pauses are shown per pair; no pauses were trimmed.

Pair/arm Kind Count Total ms p95/p99 ms Max ms
1/base minor 491 817.636 2.697/3.897 9.988
1/base incremental 30 23.713 1.186/1.278 1.278
1/base major 30 661.795 32.559/34.655 34.634
1/candidate minor 495 859.309 2.451/6.643 18.386
1/candidate incremental 31 22.718 0.895/1.049 1.049
1/candidate major 31 661.226 29.855/38.591 38.580
2/candidate minor 475 752.982 2.291/3.513 3.930
2/candidate incremental 29 22.202 0.995/1.027 1.027
2/candidate major 29 653.596 38.303/40.415 40.410
2/base minor 476 825.530 2.411/5.607 8.132
2/base incremental 31 25.795 1.050/1.211 1.211
2/base major 31 643.444 29.327/34.367 34.340

Each arm completed 40 turns, 40 tool calls and 40 corresponding results. Achieved RPC rate ranged from 191.50 to 193.91/min. Host-load ranges and all allocation diagnostics, raw RPC counts and per-kind GC observations remain in the retained local campaign report.

@clawsweeper

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T02:23:37.533756Z 35fcb7c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations size: XL labels Oct 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f603654889

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +33 to +36
const payload =
row.navigation_json !== null
? { event_json: null, event_zstd: null }
: prepareColdTranscriptPayload(database.db, readTranscriptPayload(row));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Materialize lazy predicates before discarding compressed bodies

For transcripts compressed by the historical payload migration, navigation_json can already exist while predicate columns retain their lazy defaults (navigation_type = NULL, navigation_display = 0). This branch discards the body without materializing those predicates. If that cold session is subsequently ported to PostgreSQL, loadAgentPortDescriptor().decodeSqlite.transcript_events cannot derive them because both payload columns are null, and rebuildAgentPortProjections now skips cold sessions. PostgreSQL's transcriptPredicateSql reads only stored predicates, so displayable custom_message entries silently disappear from history. Materialize the predicate fields from the available payload or retained navigation before clearing the body.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR retains archived transcript navigation so bounded history reads can load selected payloads without restoring the entire conversation.

Example: Open an archived 256-message conversation with an 80-message page while its writer is held for one second.

  • Before: The history request waits for writer admission and restores the archive.
  • After: The history reader selects the page independently and leaves the archive intact.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful and owner-directed, with meaningful production-owner measurements, but compatibility defects and incomplete integration prevent a merge-ready verdict.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor-proof gate; its supplied owner measurements and reported loopback subscription results cover cold snapshots, archive retention, and ordered live events, while the built-package latest-stable upgrade remains explicitly pending.
Patch quality 🦪 silver shellfish (2/6) 7 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Opening archived conversations waits behind the agent writer even when only one history page is needed.
Reason: The maintainer-authored change records acceptance of the storage tradeoff, and supplied measurements show substantial reductions in cold-read work and writer-dependent delay.

Merge readiness

⛔ Blocked before merge - 8 items remain

Keep this PR open: the performance improvement has owner backing, but cold-history compatibility and repository integration need repairs before merge.

Priority: P2
Reviewed head: f603654889b6a12cfcecc552cf0e1ac6f3f3e9b2

Before merge

  • Materialize lazy predicates before dropping archived payload bodies (P2) - Historical payload migrations can leave navigation_json populated while navigation_type and navigation_display retain lazy defaults. This branch clears both body columns without materializing those fields. After a SQLite-to-PostgreSQL port, the descriptor cannot derive predicates from event_json, and cold sessions are excluded from projection rebuilding; a displayable custom_message then disappears from PostgreSQL history. Derive and persist the predicate fields before removing the available payload. This confirms the existing review discussion.
  • Make generation claims understand retained cold payload references (P2) - Retaining transcript rows makes legacy-main migration enumerate cold references that previously had no hot rows. readSqliteSessionGenerationFacts still selects transcriptEventJsonSql for every row, which sends a null event_zstd into the compressed decoder and throws Invalid compressed transcript payload bounds. Exact-head CI observes this failure in legacy-main-session-migration.handoff.test.ts. Update the generation-claim owner to fingerprint cold navigation and archive facts without decoding absent bodies, preserving in-place migration and cross-store restoration semantics.
  • Include the new dependencies in the extracted PR wrapper (P2) - The new schema import is reachable from modules shipped in the trusted PR wrapper, but wrapper-components.txt does not include it. Wrapper provisioning consequently exits with ERR_MODULE_NOT_FOUND before performing its operation, as exact-head CI demonstrates. The new projection-reader import also brings cold-storage-payload-read.ts, cold-storage-chunks.ts, and cold-storage-codec.ts into that closure. Add the required files to the existing wrapper inventory and retain its closure checks.
  • Regenerate the sessions schema baseline for the new constraint (P2) - The added transcript_events CHECK branch changes the input hashed by sqlite:sessions-schema:check, but docs/.generated/sqlite-session-transcript-schema-baseline.sha256 remains unchanged. The exact-head source-contract check fails at this gate. Regenerate and commit the baseline for the approved schema change.
  • Update existing consumer tests for retained transcript rows (P2) - The producer now retains navigation, but consumer suites still assert that archival leaves transcript_events empty. Exact-head failures include session-cold-storage.transcript-turn.test.ts:239, session-cold-storage.lifecycle.test.ts:471, session-accessor.sqlite-import.test.ts:213, usage and persistence tests, and history-worker lifecycle tests. The memory-revision migration fixture also targets the new current schema while declaring the old migration scope. Update these consumers to assert retained navigation, archive preservation, and restoration behavior, and give historical migration fixtures the correct target or scope.
  • Declare the new migration's raw SQLite boundary (P2) - This new module calls database.exec without an applicable sqlite-allow-raw annotation or an entry in the guard's existing versioned-migration allowlist. scripts/check-kysely-guardrails.mts therefore rejects the added table rebuild; the exact-head architecture check reports the Kysely gate failing. Register this admitted structural migration through the existing narrow mechanism with its ownership rationale.
  • Add the required regression-test allocation record (P3) - The diff adds substantial regression-test code without a config/test-lines-allocations record. The applicable test-authoring contract requires a separate justified allocation for net regression growth; existing global headroom does not replace that record. Add a narrowly justified allocation after removing redundant tests, leaving the shared scalar unchanged.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Materialize lazy predicates before dropping archived payload bodies — src/config/sessions/session-cold-storage-navigation.ts:33-36
  • [P2] Make generation claims understand retained cold payload references — src/config/sessions/session-cold-storage-worker.ts:196
  • [P2] Include the new dependencies in the extracted PR wrapper — src/state/openclaw-agent-db-engine.ts:25-28

Tests

  • Low-value test src/infra/database-engine/agent-port-descriptor.test.ts: Remove the added retained-navigation helper test: object identity and projection-table membership assertions duplicate the stronger cold SQLite–PostgreSQL–SQLite preservation scenario without proving another user-visible failure.
  • Missing end-to-end proof: The author explicitly leaves the built-package upgrade from the latest stable release and final Gateway comparison pending; existing harness results do not establish that upgrade preserves settings, history, and archives.
Agent review details

How this fits together

Gateway history requests enter the existing history reader, which selects transcript navigation from the agent database and resolves selected payloads from verified cold archives.

flowchart LR
  A[Gateway history request] --> B[History reader worker]
  B --> C[Retained SQL navigation]
  C --> D[Selected event sequences]
  D --> E[Verified archive chunks]
  E --> F[Bounded history response]
  G[Doctor maintenance] --> C
Loading

Technical review

Best possible solution:

Preserve the approved archive-backed design while completing predicate materialization, migration consumers, wrapper dependencies, and schema integration.

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

Current-main archival deletes navigation and therefore requires restoration before bounded history reads; supplied measurements also demonstrate the writer-wait case.

Is this the best way to solve the issue?

Retaining navigation through the existing history and archive owners is a coherent solution, and the required migration should remain part of the change.

Full review comments:

  • [P2] Materialize lazy predicates before dropping archived payload bodies — src/config/sessions/session-cold-storage-navigation.ts:33-36
    Historical payload migrations can leave navigation_json populated while navigation_type and navigation_display retain lazy defaults. This branch clears both body columns without materializing those fields. After a SQLite-to-PostgreSQL port, the descriptor cannot derive predicates from event_json, and cold sessions are excluded from projection rebuilding; a displayable custom_message then disappears from PostgreSQL history. Derive and persist the predicate fields before removing the available payload. This confirms the existing review discussion.
    Confidence: 0.99
  • [P2] Make generation claims understand retained cold payload references — src/config/sessions/session-cold-storage-worker.ts:196
    Retaining transcript rows makes legacy-main migration enumerate cold references that previously had no hot rows. readSqliteSessionGenerationFacts still selects transcriptEventJsonSql for every row, which sends a null event_zstd into the compressed decoder and throws Invalid compressed transcript payload bounds. Exact-head CI observes this failure in legacy-main-session-migration.handoff.test.ts. Update the generation-claim owner to fingerprint cold navigation and archive facts without decoding absent bodies, preserving in-place migration and cross-store restoration semantics.
    Confidence: 0.99
  • [P2] Include the new dependencies in the extracted PR wrapper — src/state/openclaw-agent-db-engine.ts:25-28
    The new schema import is reachable from modules shipped in the trusted PR wrapper, but wrapper-components.txt does not include it. Wrapper provisioning consequently exits with ERR_MODULE_NOT_FOUND before performing its operation, as exact-head CI demonstrates. The new projection-reader import also brings cold-storage-payload-read.ts, cold-storage-chunks.ts, and cold-storage-codec.ts into that closure. Add the required files to the existing wrapper inventory and retain its closure checks.
    Confidence: 1
  • [P2] Regenerate the sessions schema baseline for the new constraint — src/state/openclaw-agent-schema.sql:463-468
    The added transcript_events CHECK branch changes the input hashed by sqlite:sessions-schema:check, but docs/.generated/sqlite-session-transcript-schema-baseline.sha256 remains unchanged. The exact-head source-contract check fails at this gate. Regenerate and commit the baseline for the approved schema change.
    Confidence: 0.99
  • [P2] Update existing consumer tests for retained transcript rows — src/config/sessions/session-cold-storage-worker.ts:196-197
    The producer now retains navigation, but consumer suites still assert that archival leaves transcript_events empty. Exact-head failures include session-cold-storage.transcript-turn.test.ts:239, session-cold-storage.lifecycle.test.ts:471, session-accessor.sqlite-import.test.ts:213, usage and persistence tests, and history-worker lifecycle tests. The memory-revision migration fixture also targets the new current schema while declaring the old migration scope. Update these consumers to assert retained navigation, archive preservation, and restoration behavior, and give historical migration fixtures the correct target or scope.
    Confidence: 0.99
  • [P2] Declare the new migration's raw SQLite boundary — src/state/openclaw-agent-cold-navigation-schema.ts:69-72
    This new module calls database.exec without an applicable sqlite-allow-raw annotation or an entry in the guard's existing versioned-migration allowlist. scripts/check-kysely-guardrails.mts therefore rejects the added table rebuild; the exact-head architecture check reports the Kysely gate failing. Register this admitted structural migration through the existing narrow mechanism with its ownership rationale.
    Confidence: 0.98
  • [P3] Add the required regression-test allocation record — src/gateway/server-methods/sessions.messages-subscribe-cold.test.ts:21-22
    The diff adds substantial regression-test code without a config/test-lines-allocations record. The applicable test-authoring contract requires a separate justified allocation for net regression growth; existing global headroom does not replace that record. Add a narrowly justified allocation after removing redundant tests, leaving the shared scalar unchanged.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Archival and restoration changes intended behavior with a stated reason (aa0ad4c: Automatic archival preserved exact history by restoring payloads before readers and lifecycle operations.)
  • Bounded chunk verification and replay keeps the original intent (d4ae3a7: Bounded, verified chunks support oversized histories while keeping restoration atomic.)
  • History-reader ownership keeps the original intent (932846b: Separate read owners allow history isolation while preserving snapshots, ordering, read fences, and payload semantics.)
  • Historical lazy predicates keeps the original intent (8ae7ef9: Avoid eager historical payload rewrites by deriving missing SQLite predicates at read time; PostgreSQL ports materialize them from canonical payloads.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/config/sessions/legacy-main-session-migration.handoff.test.ts
  • pnpm test src/infra/database-engine/agent-port.postgres.test.ts
  • pnpm test src/config/sessions/session-cold-storage.transcript-turn.test.ts src/config/sessions/session-cold-storage.lifecycle.test.ts src/config/sessions/session-accessor.sqlite-import.test.ts
  • pnpm test src/state/openclaw-agent-memory-revision-migration.test.ts src/state/openclaw-agent-cold-navigation-migration.test.ts
  • pnpm test test/scripts/eager-import-closure.test.ts test/scripts/pr-wrapper-source-closure.test.ts test/scripts/pr-worktree-provision.test.ts

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 932846b adds src/config/sessions/session-accessor.sqlite-projection-read.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 932846b521c0; files: src/config/sessions/session-accessor.sqlite-projection-read.ts)

PR surface

Source +653, Tests +728, Docs +27, Config 0, Other +878. Total +2286 across 57 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 39 936 283 +653
Tests 13 759 31 +728
Docs 1 27 0 +27
Config 1 1 1 0
Generated 0 0 0 0
Other 3 878 0 +878
Total 57 2601 315 +2286

Review metrics

Metric Value Why it matters
Persisted representation Agent schema 38 → 39; no new table or column The payload constraint gains an archive-backed representation, requiring upgrade and rollback compatibility.

Labels

Label changes:

  • add P2: This addresses visible archived-history delays, with focused compatibility and integration repairs remaining.
  • add merge-risk: 🚨 compatibility: Schema 39 changes persisted payload representation and affects existing-store migrations and database ports.
  • add merge-risk: 🚨 session-state: Historical lazy predicates can disappear from PostgreSQL history after archival and porting.
  • add merge-risk: 🚨 automation: New transitive imports are absent from the extracted PR wrapper inventory, causing provisioning to fail.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This addresses visible archived-history delays, with focused compatibility and integration repairs remaining.
  • merge-risk: 🚨 compatibility: Schema 39 changes persisted payload representation and affects existing-store migrations and database ports.
  • merge-risk: 🚨 session-state: Historical lazy predicates can disappear from PostgreSQL history after archival and porting.
  • merge-risk: 🚨 automation: New transitive imports are absent from the extracted PR wrapper inventory, causing provisioning to fail.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 30, 2026, 10:13 AM ET / 14:13 UTC.

@steipete
steipete force-pushed the steipete/perf-cold-page-navigation-rows-20261030 branch from f603654 to a37dbf2 Compare October 30, 2026 14:48
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat extensions: codex labels Oct 30, 2026
@steipete
steipete force-pushed the steipete/perf-cold-page-navigation-rows-20261030 branch from b65242e to ffbeb87 Compare October 30, 2026 19:42
@steipete
steipete force-pushed the steipete/perf-cold-page-navigation-rows-20261030 branch from ffbeb87 to f5602d1 Compare October 30, 2026 22:00
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 30, 2026
@steipete
steipete force-pushed the steipete/perf-cold-page-navigation-rows-20261030 branch from 756d14a to eda006e Compare October 30, 2026 22:54
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling and removed agents Agent runtime and tooling labels Oct 30, 2026
Record the exact 917-line regression allowance and 1,042 inherited lines over budget in the shared scalar, with zero slack. The task explicitly authorizes justified exact ceiling raises. Remove the separate allowance to avoid double credit and use the upstream performance-driver Knip wildcard.
@steipete
steipete force-pushed the steipete/perf-cold-page-navigation-rows-20261030 branch from 9ffaabf to 35fcb7c Compare October 31, 2026 02:21
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Oct 31, 2026
@steipete
steipete merged commit fce0e56 into main Oct 31, 2026
248 checks passed
@steipete
steipete deleted the steipete/perf-cold-page-navigation-rows-20261030 branch October 31, 2026 03:31
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…39) (openclaw#188397)

* perf(sessions): serve cold history without restore (schema 39)

Retain navigation and active-path facts while payloads remain archived, so
bounded history and subscription reads do not wait for writer admission.
Agent schema 39 permits cold payload references; Doctor backfills existing
archives transactionally and resumes after interruption.

* chore(perf): register cold history benchmark commands

* perf(sessions): finish cold navigation consumer cutover

* perf(sessions): preserve legacy history paging through consumer cutover

* perf(sessions): complete typed and settled upgrade consumer proof

* perf(sessions): prepare stress fixtures through each build Doctor

* perf(sessions): synchronize Gateway regression fixtures

* perf(sessions): preserve cold background placement navigation

* perf(sessions): preserve live fallback replay after operational notices

* perf(sessions): split transcript navigation metadata owner

* test(sessions): reconcile approved cold-page proof ceiling

Record the exact 917-line regression allowance and 1,042 inherited lines over budget in the shared scalar, with zero slack. The task explicitly authorizes justified exact ceiling raises. Remove the separate allowance to avoid double credit and use the upstream performance-driver Knip wildcard.

* perf(sessions): complete gateway proof logger fixture

* perf(sessions): preserve cold archive ownership in batched doctor scans

* perf(sessions): move memory metadata migration to schema helpers
VACInc pushed a commit that referenced this pull request Nov 18, 2026
…uery per row (#201374)

`openclaw database port --to postgres` rebuilt the transcript search rows with
one awaited INSERT per message. Over a link with real latency that is one round
trip per row, so a store with tens of thousands of messages kept the Gateway
offline for hours.

The port now sends up to 512 rows per statement, reusing the transcript owner's
identity allocation so rows keep their message order and identities stay paired
with their content. The compile-only PostgreSQL Kysely facade is exported so the
asynchronous port connection can run the owner's query.

Closes #201249
Related: #188397

Signed-off-by: Deepak Jain <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…uery per row (openclaw#201374)

`openclaw database port --to postgres` rebuilt the transcript search rows with
one awaited INSERT per message. Over a link with real latency that is one round
trip per row, so a store with tens of thousands of messages kept the Gateway
offline for hours.

The port now sends up to 512 rows per statement, reusing the transcript owner's
identity allocation so rows keep their message order and identities stay paired
with their content. The compile-only PostgreSQL Kysely facade is exported so the
asynchronous port connection can run the owner's query.

Closes openclaw#201249
Related: openclaw#188397

Signed-off-by: Deepak Jain <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…uery per row (#201374)

`openclaw database port --to postgres` rebuilt the transcript search rows with
one awaited INSERT per message. Over a link with real latency that is one round
trip per row, so a store with tens of thousands of messages kept the Gateway
offline for hours.

The port now sends up to 512 rows per statement, reusing the transcript owner's
identity allocation so rows keep their message order and identities stay paired
with their content. The compile-only PostgreSQL Kysely facade is exported so the
asynchronous port connection can run the owner's query.

Closes #201249
Related: #188397

Signed-off-by: Deepak Jain <[email protected]>

(cherry picked from commit bc4e269)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…uery per row (openclaw#201374)

`openclaw database port --to postgres` rebuilt the transcript search rows with
one awaited INSERT per message. Over a link with real latency that is one round
trip per row, so a store with tens of thousands of messages kept the Gateway
offline for hours.

The port now sends up to 512 rows per statement, reusing the transcript owner's
identity allocation so rows keep their message order and identities stay paired
with their content. The compile-only PostgreSQL Kysely facade is exported so the
asynchronous port connection can run the owner's query.

Closes openclaw#201249
Related: openclaw#188397

Signed-off-by: Deepak Jain <[email protected]>

(cherry picked from commit bc4e269)

Release adaptation: Preserve stable activeRows loop and metadata INSERT; replace only PG FTS loop and share allocator. Add retention assertions; runtime proof blocked.

Co-authored-by: RomneyDa <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
)

* fix(plugins): portable plugin-state keys for PostgreSQL

Use an exclusive SQL lower bound for Doctor pagination instead of a NUL-suffixed cursor. Reject new NUL keys in test-only plugin-state fixtures while retaining legacy SQLite adoption reads.

Add real PostgreSQL Doctor regression coverage and register it in conformance and database-worker lanes. Refs openclaw#184862 openclaw#188642.

* test: account for rebased plugin-state coverage

* test(clickclack): import legacy revocations before adoption

(cherry picked from commit 395cac7)

Release adaptation: Only exclusive SQL lower bound in kernel and Doctor pagination; preserve legacy SQLite keys and public validation. Regression exercises real Doctor paging and inspected executed SQL bindings; no NUL-key fixture policy, schema or unrelated tests.

Follow-up dispositions: 8253356 fix: preserve child results after source lifecycle changes (openclaw#202708); f3f89c7 fix: show saved child results when completion delivery fails (openclaw#202664); c45faa8 fix: align CI tests with admitted tool calls (openclaw#202655); 5c9389a fix: make channels add report required plugin install failures (openclaw#202091); 52b9188 fix: show hosted model details in `models list` without a Gateway (openclaw#202490); d248a76 fix: show an outcome when kept child chats return no answer (openclaw#202423); 5148804 fix(discord): check a queued message's access again when its turn starts (openclaw#202330); 2470d62 fix: let setup use account models with a fresh catalog (openclaw#202019); 9fa0b92 fix: let PostgreSQL Gateways start with plugin-backed secrets (openclaw#201063); c180824 fix(plugins): Talk and plugin-loading requests fail on PostgreSQL Gateways (openclaw#201976); cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 17c5fb0 fix(state): PostgreSQL state created before Template bootstrap deferral is refused as schema drift (openclaw#197425); b5c1277 fix: let resumed parents collect children stopped by restart (openclaw#201460); f920a7e chore(postgres): qualify cron completion during graceful shutdown (openclaw#201246); 1680f54 fix(openai): new ChatGPT subscription models missing until an OpenClaw release (openclaw#201130); 0d8820a fix(media): image descriptions use the ChatGPT OAuth route when OpenAI has no API key (openclaw#199299); ee3e16e test(agents): trim and fold low-value regression suites (openclaw#198916); b8029b4 test(agents): qualify PostgreSQL simple-completion acquisition (openclaw#200956); 703c82d fix(sessions): record queued input end causes and recover them across crashes (openclaw#200533); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); d565e17 fix(ci): retire deleted session fork test from inventory (openclaw#200611); 4cf12c6 chore(postgres): qualify prompt refresh and rebalance CI (openclaw#200488); d460273 fix(templates): release earlier Template-managed agents (openclaw#200303); ff75829 fix(update): --no-restart update fails when the Gateway restarts itself during Doctor's stop (openclaw#200181); 0b2ad60 chore(postgres): cover compaction watched-session prompts (openclaw#200117); b90c573 test: consolidate redundant coverage (198795 recut) (openclaw#198943); a042363 test: consolidate redundant coverage (198793, part 2) (openclaw#198936); 9bfad2b test: consolidate suites while retaining recovery owners (openclaw#198933); 4e9812c test: consolidate redundant coverage (198789, part 2) (openclaw#198932); 90814f5 fix(subagents): stops a finished sub-agent's chat being deleted before its parent reads the result; 799bc0b fix(ci): stabilize hourly fixtures and retire unused exports (openclaw#199851); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); a4cc2ad fix: undo cold-session compaction CPU and latency regressions (openclaw#199561); 55fec79 fix(agents): stop divergent mid-turn overflow recovery (openclaw#199636); 2c4413a fix: reduce Gateway stalls under filesystem pressure (openclaw#197510); 37d977f fix: output reducers are skipped in headless and Code Mode runs (openclaw#199434); c9ee264 fix(compaction): concurrent sessions wait for each other's summaries during compaction (openclaw#196550); 2471ddc feat: let agents review generated images before delivery (openclaw#198227); 21f7dc6 fix(github): publication fails with PostgreSQL session or state stores (openclaw#193749); 63d9e57 fix(ci): new PostgreSQL suites are omitted from conformance (openclaw#198390); 466a4b6 fix(telegram): steered answers quote the wrong input (openclaw#178124); 87b6f52 fix(delivery): resend routed Telegram finals after an ambiguous network failure (openclaw#192779); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); cff99b2 fix(agents): keep provider history append-only across runs (openclaw#197874); 8a328bf feat: add an opt-in usage-ranked tool index (openclaw#197128); 097e648 fix(ci): plan only executable infra tests (openclaw#197911); 76385fd fix(models): discovered models become "Unknown model" after restart or an ended sign-in (openclaw#197784); 89d4177 fix(plugin-state): guarded calls fail until Gateway restart after an unknown write outcome (openclaw#197790); baca36e fix(sessions): commit selected invitations with original messages (openclaw#184512); 699e538 fix(sessions): drain passive notices on sessions_send resumes; d6ded18 chore(ci): drop retired test-lines allocation records (2/3) (openclaw#197656); e0dd020 fix(agents): collect process results at suspended-run capacity; 4897740 feat(auth): preserve delegated OCE user profiles and permissions (openclaw#196856); 7197ce1 feat(templates): install bundled plugins through native management (openclaw#196349); 9c6ee9b feat: let Template automations start paused for onboarding (openclaw#196323); 79a6214 fix(message): retain local final replies in conversation history (openclaw#187795); caa978c feat(templates): open durable chat before verified setup (openclaw#196392); 78e73aa fix(sessions): cold PostgreSQL conversations fail after idle readers close (openclaw#189991); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682); 1595dd2 feat(plugins): reauthorize accepted session work (openclaw#176886); b43ad0a fix(models): avoid reloading plugins on catalog refresh (openclaw#193903); 0947d02 fix(ci): avoid unrelated PostgreSQL runs and admit owned tests (openclaw#193870); 428ca7d feat(openclaw-id): add Gateway membership authority and publication behind the Labs flag (openclaw#192335); c718583 fix(update): repair refuses forever after a verified update fails a later step (openclaw#193132); 3f64174 fix: deliver background replies after a reload retires the turn registry (openclaw#193130); 982f3b1 fix(imessage): report Automation failures after Gateway updates (openclaw#186117); 31b28e9 fix(agents): wait for a peer OAuth refresh before failing request auth (openclaw#192906); cf50d4a feat(storage): support read-only PostgreSQL standby inspection (openclaw#192645); 82fd4e6 fix(agents): retain stale session target refusal reasons (openclaw#192681); 8ac4e19 fix(worktrees): reserve capacity on PostgreSQL (openclaw#192537); 718b349 fix: reduce session startup stalls under storage contention; 08f4a19 refactor(skills): move Skill Workshop into its bundled plugin (openclaw#192471); 837402a fix(clawrouter): keep upstream credit failures off the shared key (openclaw#192575); f38495f fix(plugins): reject late routing from canceled runs (openclaw#192492); dc5d61a improve(sessions): reduce unnecessary maintenance query rows (openclaw#192023); c4bf0dc fix(sessions): avoid extra maintenance scans for embedded archives (openclaw#184507); e44b3d6 fix(team-reports): recover after database connection loss (openclaw#192020); 991fb33 fix(logbook): recover after database connection loss (openclaw#192011); e6d0d2e fix(test): include omitted PostgreSQL conformance suites (openclaw#191962); da5ff0f fix(codex): reject native hooks from a previous run (openclaw#191788); 09f0b0b feat(plugins): add skill usage runtime for plugins (openclaw#191661); 00b2ff4 fix: parent sessions miss child approvals with a custom session store (openclaw#189827); be44b10 fix: stop completed session writes retaining request data (openclaw#191197); d40aa7c fix(sessions): replay creation requests across Gateway restarts (openclaw#190862); d894035 fix: await Doctor shared-state repair preparation (openclaw#190875); b515cc7 feat: fork threaded conversations with Telegram support (openclaw#190783); def6349 feat(plugins): plugins can run a hidden forked turn of a session with their own tools (openclaw#190950); d983e34 feat(plugins): plugin commands can continue the agent with a replacement prompt, on every channel (openclaw#190908); ea3f0b8 fix(ci): provision Node test prerequisites and retain Baseten routing (openclaw#191050); 29503e1 fix(update): Gateway stays stopped after the updater process dies mid-update (openclaw#188497); fc8c2d0 fix(update): preserve unfinished handoff artifacts (openclaw#190571); 7c26e8c fix(ci): cover PostgreSQL managed update handoffs (openclaw#190336); 4913d41 fix(ci): prevent truncated PostgreSQL target listings (openclaw#189509); 8925f62 fix(gateway): start restored PostgreSQL homes on the first attempt (openclaw#190291); 177fe32 feat(models): preserve inference capabilities in opt-in catalog v3 (openclaw#189678); 7faf32d feat: retain repository disk authority through recovery (openclaw#189106); a658df3 feat(database): capture externally quiesced SQLite migrations; 0f9e7f7 feat(database): capture exact SQLite migration capsules; 4fb684e feat(backup): add PostgreSQL local companion checkpoints; c89a101 fix(doctor): migrate auth profiles on PostgreSQL stores (openclaw#189639); 799de09 fix(ci): split oversized workspace and setup files (openclaw#189356); 21ee847 fix(acp): keep completed run conversations resumable (openclaw#189273); fce0e56 perf(sessions): open cold history without restoring archives (schema 39) (openclaw#188397)

Validation: Baseline1 NUL-binding assertion failure/21passing; candidate22/22passes (188693-green.log). Real SQLite Doctor path and generated SQL proved; no native PostgreSQL server execution claimed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 0895146d8c1493146f5c6461eee0b10c329bdd1e)
(cherry picked from commit f8ccaa70bc9773d6bbb569bc0e275eee0c544ead)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: googlechat Channel integration: googlechat commands Command implementations docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant