Repository navigation
perf(sessions): open cold history without restoring archives (schema 39) - #188397
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| const payload = | ||
| row.navigation_json !== null | ||
| ? { event_json: null, event_zstd: null } | ||
| : prepareColdTranscriptPayload(database.db, readTranscriptPayload(row)); |
There was a problem hiding this comment.
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 👍 / 👎.
|
Codex review: blocked before merge. What this changesThis 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.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway 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
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c69c15f291c9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +653, Tests +728, Docs +27, Config 0, Other +878. Total +2286 across 57 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 10:13 AM ET / 14:13 UTC. |
f603654 to
a37dbf2
Compare
b65242e to
ffbeb87
Compare
ffbeb87 to
f5602d1
Compare
756d14a to
eda006e
Compare
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.
9ffaabf to
35fcb7c
Compare
…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
…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]>
…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]>
…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]>
…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]>
) * 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)
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/main9f14244a6067e9ca0e22d1a2b8c5150e9cb7c693at head35fcb7c494839a6cb389ea03e4e65f4a99f44f6b. Main #188090 already owns the fresh-onlyusage.costcache predicate and its single-agent/all-agent regression, plus the supported final-symlink denial diagnostics. Dropped our supersededcbee978ad238commit 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
9ffaabf7and 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 basef47669efcec232b35dc74ac2d5d89b60796e6540. 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
9ffaabf7The committed owner harness measures the real subscription handler with 256-message synthetic transcripts and an 80-message/256-KiB page. Baseline is
f47669ef, candidate is9ffaabf7. 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.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:
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.
That is 1.275 MiB per archived session, or 2.551 GiB across this corpus. This all-catalog
dbstatcomparison 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.tsproves 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.tsmigrates 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.costcache bug: transientrefreshingresults 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
9ffaabf7A 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 basef47669ef, in 372,716 ms. Terminal status wasok, run statussucceeded, 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; SQLitequick_checkpassed.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 supportedsourcePerformanceand candidate used supported runtime-onlypackage; 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
efecf020andf243711fupgrades 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 runtimef243711f. Historical headbd361c59differed 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).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 baselinec0c068e1and candidateffbeb87c, 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: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 candidate60947404, tooling96a7dc75. 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.
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
Allocation
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.
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.