Skip to content

perf(sessions): persist active transcript facts for hydration - #193682

Merged
steipete merged 5 commits into
mainfrom
steipete/perf-active-event-facts-schema-20261105
Nov 7, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/perf-active-event-facts-schema-20261105

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Approved by Peter (2026-11-06) together with a separately reviewed, paced after-ready backfill follow-up.

Cold transcript hydration reads small byte-count and dependency-navigation values stored after the payload in transcript_events. SQLite traverses payload overflow chains to reach those columns. Actor hydration also totals the entire active path, so a 512-event request can incur this cost across tens of thousands of events.

User Impact

Agent schema 41 adds an initially empty session_transcript_active_event_facts companion keyed by (session_id, seq). A fact stores exactly coalesce(event_utf8_bytes, octet_length(event_json)) + 1 and the existing guarded dependency projection. {} means a known non-candidate; a missing row means unknown. CASE-gated readers use facts when present and retain the exact previous expressions otherwise. There is no reader backfill.

On the synthetic 34,153-event path, full coverage reduces actor hydration CPU by 79.0% and VFS spans by 96.6%. Cron-context CPU and sampled allocation are approximately neutral. Existing rows do not receive this benefit immediately: 512 ordinary, well-formed appends cover a recent 512-row window, but historical dependency candidates and full-path totals remain uncovered until a normal rewrite/rebuild. Cold transitions clear facts; restored rows start unknown.

Older readers are not allowed through an additive-table exception: their writers cannot maintain these facts. Older schema-40 admission refuses schema 41. Rollback requires restoring the verified scoped migration backup and then using the matching older build.

Why This Change Was Made

The empty table avoids ADD COLUMN validation scans on existing STRICT tables. Payloads remain authoritative; the companion is a derived projection owned by the active-row lifecycle. SQLite uses STRICT, WITHOUT ROWID; PostgreSQL receives the same primary/foreign-key contract through the existing schema generator and migration owner.

Mutation owner Facts lifecycle in the same transaction
Normal append and full replacement Reuse prepared payload/byte facts; ordinary rows use a compact insert.
Rebuild/import/branch selection Carry compact facts through the existing source read, prepared chunks, and catch-up.
PostgreSQL append Insert through a writable CTE dependent on the active-row RETURNING relation.
Payload rewrite and direct payload updater Clear changed facts, including index-preserving rewrites.
Eligibility changes Replace the active projection and its facts through the existing rebuild owner.
Cold transition/restoration Clear facts before representation changes; restored rows remain unknown.
Branch retirement, reset, compaction, suffix replacement, deletion Cascade from retired active rows; new uncovered suffix rows retain fallback.
Cross-engine port Omit derived facts and use destination-native fallback; do not copy encoding-dependent projections.

Malformed/deep legacy input retains its previous acceptance and reader-error behavior. A review caught eager projection of scalar placement data failing at append time; the writer now leaves those facts unknown, with an append/rebuild regression. Connection-owned prepared templates retain only single-row/full-chunk shapes and bind fresh session IDs and values.

Runtime growth is necessary for the approved schema and transactional lifecycle across both engines. The shared metadata reader replaces the old payload-backed accounting queries, and the guarded dependency expression has one owner. Runtime source is +797/−152 (+645 net), generated catalogs +108, scripts (proof, inventory, and wrapper closure) +1,554, and tests +890. The requested non-test/non-doc diff is +2,310 net including tooling. This is an additive schema/lifecycle change, not a net-deletion optimization; the initially empty upgrade and exact legacy fallback require the additional writer, invalidation, migration, and engine-port contracts.

Evidence

Original measurement baseline: ac008ae0b850ff5082a247924e5b9e636edbb1ce, agent schema 40; original published candidate: b411052a21bc9c417b996d80a9e71889e8a815b6. The PR was rebased onto main d5d54833f9e4c2a38dec517804a057bc71af5d3e; reviewed head: 441bd5686cb75b07aa015832679ddfb41c15d12e. Fresh proof used main 1f7035c15f3d6f89b7336c0d273ddcb18b8ff060; the final rebase is patch-identical across all five PR commits, with no intervening session/state/database-engine changes or migration-path changes. Original owner/70 GB measurements below are retained evidence, not re-measurements on the rebased head. Synthetic data only: 6.3M active rows across 25,130 sessions, including 20k–50k-event paths, on a physically allocated 70.010 GB fragmented SQLite file (about 54.32 GB non-free pages). No Team database was opened/copied and no load was sent to Team. Large fixtures were deleted after proof; reports, profiles, and small scoped backups were retained.

The reproducible fixture, VFS extension, real-owner runner, and commands are in scripts/perf/transcript-active-facts.{py,ts,md} and transcript-active-facts-vfs.c. Both arms enable the native statement cache used by the production database owner. Earlier uncached/fixture-setup runs remain diagnostic evidence and are not pooled with final results.

Rebased upgrade and integration proof (2026-11-06): main remains agent schema 40 and the candidate is 41. A fresh synthetic 1M-row, 1.335 GB database upgraded through the real owner in 36.366 ms, with 86,116 logical read bytes / 22 VFS spans and 28,872 WAL bytes/growth; the companion remained empty. Scoped backup took 100.859 ms, retaining a 12,288-byte snapshot. This rerun reports migration WAL writes before outer connection-close checkpoint writes, so it is not a write-volume reduction claim against the earlier table. The exact 40→41 DDL, preflight/finalizer, integrity scope, and backup owners are unchanged; the 70 GB fixture was therefore not regenerated. Fresh main-40 admission refused schema 41. Scoped restore recovered both markers to 40, removed facts, and preserved checked payloads in 9,164.782 ms. Restore wall time includes maintenance admission on a host at roughly 81 load; without matched controls this is neither attributed to a regression nor presented as a speedup. The 1.33 GB fixture was deleted.

The rebase preserves #194359's exact published v16 memory FTS/shadow admission and memory-before-transcript migration order, plus 7bc0ae7/dc16abf7's lazy FTS streaming, byte-bounded sync batches, streaming manual trimming, and digest checks. Writer-history audit across sessions/state/database-engine found no new writer owner: existing active-row chunks still carry facts; manual trim still replaces rows transactionally; cross-engine port rebuilds FTS while leaving facts unknown. Extended the existing sync-batch and manual-trim tests with exact facts and rollback assertions. A small cleanup moves pure facts derivation into the existing projection-append preparation owner without adding SQL runtime imports. The fresh regression against current main 1f7035c fails with one native dependency projection; the final candidate passes with zero, preserving three facts, identical events, and 441 serialized bytes.

Upgrade through the real migration and scoped-backup owners:

Active rows / file Backup wall Migration wall Main bytes read Total bytes written WAL growth Backup size
1M / 1.336 GB 60.07 ms 30.53 ms 94,308 82,192 41,232 12,288 B
10M / 13.479 GB 75.38 ms 35.92 ms 86,116 57,544 28,872 12,288 B
6.3M / 70.010 GB 126.52 ms 28.18 ms 98,404 73,976 37,112 12,288 B

The original campaign 1M result is the named canonical rerun; the earlier 1M run was 33.68 ms and is retained. All scales show bounded page work. Existing-data work consists of the single schema_meta record, version markers, and schema-catalog validation. The backup records schema_meta, the prior user version, and the companion's absence. There is no ALTER, existing-row index build, transcript scan, or transcript copy. Exact 40→41 quick finalization checks the new empty table/FK; earlier crossings and explicit FULL verification retain global foreign-key validation. Separate whole-update backups/maintenance are outside these version-phase timings. PostgreSQL's existing backup scope is unchanged.

Real hydration owners, five untraced samples per arm/state: actor hydration runs inside BEGIN IMMEDIATE with its 513-row navigation window and full active-path total; cron-context is the actual bounded-context core with a 512-event limit, not the entire cron job or RPC.

Facts / owner CPU base → candidate Wall base → candidate VFS spans base → candidate Pager visits base → candidate
Empty / actor 596.736 → 183.936 ms 2264.438 → 248.128 ms 84,188 → 84,189 337,803 → 406,108
Empty / cron-context 75.659 → 68.112 ms 76.333 → 83.232 ms 6,348 → 6,350 91,155 → 93,968
Latest 512 / actor 133.069 → 139.198 ms 130.631 → 137.266 ms 84,188 → 82,978 337,803 → 435,185
Latest 512 / cron-context 58.324 → 56.029 ms 53.929 → 51.247 ms 6,348 → 5,134 91,155 → 89,561
Full / actor 130.740 → 27.419 ms 129.970 → 25.664 ms 84,188 → 2,826 337,803 → 142,672
Full / cron-context 59.406 → 59.844 ms 53.955 → 50.001 ms 6,348 → 4,465 91,155 → 86,682

SQLite page caches were cold (mmap off, 2 MiB cache), while OS cache was uncontrolled. The empty/base mean includes a large first cold-OS-cache outlier; all samples are retained, and no empty-coverage speedup is claimed. VFS spans count requested 4 KiB intersections, not physical disk I/O. Mean host load was 34.2/32.2/31.2 for empty/partial/full. Five samples do not establish p95/p99 or an adverse tail result.

For full coverage, metadata spans per requested row fall 2.432→0.057, actor spans normalized to 512 rows fall 164.430→5.520, and cron-context spans fall 12.398→8.721. Dependency scanning remains necessary: spans per selected candidate fall 16.142→11.819 across 155 candidates. General actor navigation still reads its latest 513 payload rows.

Separate allocation and append measurements:

Owner Iterations per side CPU base → candidate Sampled JS allocation base → candidate
Actor hydration, full facts 200 allocation calls; 5 untraced calls 130.740 → 27.419 ms/call 1,600,619 → 1,599,478 B/call (neutral)
Cron-context, full facts 200 allocation calls; 5 untraced calls 59.406 → 59.844 ms/call 20,644,870 → 20,655,593 B/call (neutral)
Append, mixed payload sizes 25,000 timing; 10,000 allocation 2.824699 → 2.890754 ms/op (+0.066055 ms, +2.34%) 1,380,655 → 1,388,032 B/op (+0.53%)

Append timing uses five AB/BA pairs and four fresh identical-code A/A pairs, 5,000 operations per arm. A/A signed spread was −5.51% CPU and −10.90% wall, larger than the candidate's +2.34% CPU/+3.52% wall. The small measured cost is within these controls, rather than a proven regression. Retained file growth adds 29.49 B/append; cumulative native writes rise 396,081→403,254 B/op (+1.81%). Allocation uses separate counterbalanced sampling passes with collected allocations included; these are not GC or retained-heap measurements.

Correctness, plans, and recovery: full/partial/absent facts return identical actor/context outputs, including reset, compaction, branch changes, pending automation, ineligible assistants, malformed/legacy rows, rewrites, cold storage, and rollback. Both engines use the companion primary key. PostgreSQL EXPLAIN ANALYZE shows all four payload fallback subplans never executed under full coverage; partial/no coverage exercises the old expressions. The work-count regression runs the frozen main reader against the same real-writer fixture: main performs one native dependency projection and fails the zero-projection assertion; candidate performs zero and passes, with identical events and 441 serialized bytes.

The actual pinned schema-40 admission implementation rejects schema 41 before data reads. In the original campaign, the real scoped restore returned both markers to 40, removed the companion, and preserved selected payload bytes in 103.35 ms; the fresh rebased restore and its host-load caveat are reported above. This proves the old admission path, not startup of a packaged older Gateway binary. With owners stopped, use openclaw database restore-migration-backup with the verified pre-upgrade scoped snapshot before starting the matching older build; manually lowering version markers is not a rollback.

Adoption/backfill decision: a recent window takes approximately 512 / active-appends-per-second seconds to cover; historical totals and dependencies do not age out merely because that window is covered. A proposal-only synthetic probe populated 34,153 facts in 67 batches of at most 512: 25.0 s wall, 4.0 s CPU, 345.5 MB logical reads, 3.0 MB cumulative writes, with a 2.42 s maximum batch. Straight-line 6.3M extrapolation is about 63.7 GB logical reads, 548 MB writes, 12.3 minutes CPU and 77 minutes wall before pacing—not a production forecast. Peter approved a paced after-ready backfill as a separately reviewed follow-up. Another lane will implement it after this PR merges; this PR implements none.

Rebased local proof: the initial six session files passed 79 tests; after the pure-helper move, the final cold-storage/rebuild/eligibility run passed 48 tests. SQLite migration/index/admission/FTS proof passed 54 tests. Real PostgreSQL migration/portability passed 11 tests with one intentional skip; Doctor and append passed two selected cases, and append passed again on the final owner. Generator/catalog/descriptor/JSON checks passed 211 tests. PostgreSQL artifacts were regenerated and verified byte-identical. Scoped lint/format, root test types, session/state/infra test types, wrapper closure, worker registry, and the exact 890-line test allocation passed. The allocation covers the existing distinct migration/lifecycle/cross-engine contracts plus 40 lines checking facts through the newly bounded sync-rebuild and manual-trim paths. Exact-head CI run 42340986616 completed on 441bd5686cb75b07aa015832679ddfb41c15d12e: 151 jobs passed, including all three PostgreSQL conformance shards, all test-type partitions, and the Node test shards. Two checks failed as detailed below, so the aggregate openclaw/ci-gate is failed. This is not an exact-head green result. The PR remains open and unmerged for the TS session; the local worktree is clean.

The first CI run exposed three lifecycle cases in addition to two static guards; all have focused red/green proof and review. Canonical-index repair now handles an FK-backed unique index only after physical verification, with complete integrity revalidation inside the repair transaction; orphans, duplicates, unknown mismatches and physical corruption remain refusals (21 owner tests plus the real reopen regression). Historical PostgreSQL Doctor rebuilds consume admitted predecessor schema facts, while a missing current-schema table remains an error. Schema38/39 upgrades retain their metadata-only precheck and global post-migration FK validation (12 migration tests). SQL annotation placement and the exact worker-only invalidation classification satisfy their guards without raising a baseline. The exceptional damaged-index repair may repeat an integrity scan; the normal upgrade and hydration measurement paths are unchanged.

The third CI run caught three migration test hooks still matching the old version-publication SQL punctuation after adoption of the shared writer. Updated those hooks (including the creator-migration sibling) to match the canonical statement. Both focused files pass all seven tests, preserving independent-reader atomicity, injected-failure rollback, and real maintenance-lease loss. This is a test-only repair with zero net line growth; fresh independent review is clean.

The later dialect guard also caught raw JSON and schema-version sites. These now use the existing engine JSON path/type helpers and canonical version writer. The SQLite predicate and bindings are byte-identical to the measured version; the guard passes with design constructs unchanged and engine-maintenance sites reduced by one. Four focused files pass 25 tests, and a real PostgreSQL probe verifies 12 native JSON type cases. No dialect exemption or baseline was added.

Rebased CI findings: Architecture guard fails on the inherited control-ui-static.ts ↔ server-control-ui-root.ts type/value import cycle introduced in #191935. The same guard, limited to those two pinned-main source files through its native resolver, reproduces the exact cycle and exits 1 on base d5d54833. Both files and the guard are byte-identical between base and this PR. Main's successful run skipped architecture checks; it is not a passing baseline for this guard. The final upstream read at main f231ad6693d808e8da6008ca2643058072ebbb3a still has the same two file blobs and both cycle edges; no dedicated repair PR or merged fix was available. Runtime value-cycle and Kysely guards passed.

UI E2E shard 1 also fails gateway-fresh-visit.http.e2e.test.ts:204 waiting 15 seconds for the unknown app-bundle failure heading. The fallback HTML and test are byte-identical to main. A bounded headless probe of the exact inline fallback with a five-second CSS delay shows the heading at 17.358 s on main and 17.367 s on candidate; neither loads schema/session modules. This demonstrates a shared timing susceptibility, not the actual CI failure's cause. Counter-evidence: the owning UI PR's earlier job passed this case in 13.274 s. A complete single-file reproduction unconditionally builds the production UI and has no supported prebuilt override, so it was not run under this lane's no-local-build rule. This failure is unresolved, not waived or conclusively classified as inherited. CI has not been rerun to chase green.

Review: Codex autoreview completed all 16 passes with no accepted/actionable P0–P2 findings, including the rebased working tree and the final preparation-owner cleanup. The helper verified the captured source before publishing its scoped-clean result.

Limits: no whole-Gateway main-thread CPU, allocation rate, GC seconds/min, event-loop p99, sessions.list p99, RSS, or heap result is claimed. These are synthetic owner measurements; OS-cold physical I/O and full older-binary startup were not measured.

@clawsweeper

clawsweeper Bot commented Nov 5, 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 Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T05:05:28.884323Z 441bd56 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 scripts Repository scripts size: XL labels Nov 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR persists derived transcript byte counts and dependency navigation so hydration can avoid reading covered payload metadata.

Example: Hydrating a synthetic 34,153-event active transcript with complete facts.

  • Before: Reported actor hydration CPU averages 130.740 ms and 84,188 VFS spans.
  • After: Reported CPU averages 27.419 ms and 2,826 VFS spans, with identical actor output.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Coherent implementation with meaningful owner-level measurements and lifecycle coverage; release-to-head compatibility proof remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) The ordinary proof gate is exempt for this maintainer-authored PR; supplied measurements cover real hydration, append, schema-40 migration, and restore owners in synthetic fixtures. Required data-model compatibility remains insufficient because those fixtures do not exercise the published v2026.11.1 schema-27 upgrade chain.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large retained conversations can spend substantial CPU and database work hydrating a small context window.
Reason: The maintainer-authored direction has measurable value under complete coverage and explicitly documents delayed adoption for existing history.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR provides a measured hydration optimization, and source review found no concrete introduced correctness defect.

Priority: P2
Reviewed head: 8d9592f0195303f0e20c6abd94df2aeeef423ed9

Before merge

  • 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

None.

Tests

  • Missing end-to-end proof: The PR owner should supply a fresh-install and v2026.11.1-to-candidate upgrade through the shipped CLI/Gateway, showing retained transcript bytes, session behavior, and settings remain intact, with sensitive values redacted.
Agent review details

How this fits together

Session transcript writers maintain canonical payloads and active projections; actor and context readers consume their metadata to select and account for conversation history.

flowchart TD
  A[Transcript mutations] --> B[Existing projection owner]
  B --> C[Canonical payloads]
  B --> D[Active rows and derived facts]
  D --> E[Hydration metadata reader]
  C --> F[Missing fact fallback]
  F --> E
  E --> G[Actor state and bounded context]
Loading

Technical review

Best possible solution:

Land the transactional companion projection with exact missing-row fallback and the existing backup-based rollback contract.

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

Source confirms payload-backed metadata reads on main, and the supplied synthetic measurements exercise the actual hydration owners; this review did not run the workload.

Is this the best way to solve the issue?

The companion avoids an existing-row rewrite, carries prepared facts through current writers, and preserves fallback semantics; simplification review found no clearly unnecessary production layer.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Exact introduced change: Reviewed the pinned parent-to-head changes, including transcript writers, readers, migrations, generated contracts, tests, and measurement tooling; fetched main has no intervening changes in the inspected session and state paths. (8d9592f01953)
  • Exact fallback: The shared metadata reader uses stored facts only when a companion row exists; otherwise its correlated lookup retains the previous byte-accounting expression. (src/config/sessions/session-accessor.sqlite-projection-read.ts:159, 8d9592f01953)
  • Transactional lifecycle: Facts follow active-row insertion and cascading deletion; payload rewrites and cold transitions clear them, while malformed legacy placement data remains uncovered rather than failing eagerly. (src/config/sessions/session-transcript-active-facts.ts:236, 8d9592f01953)
  • Bounded migration scope: Only the exact schema-40-to-41 quick migration narrows foreign-key validation to the new empty companion; earlier crossings and explicit full verification retain global validation. (src/state/openclaw-agent-db-schema.ts:415, 8d9592f01953)
  • Supplied proof and accepted rollback contract: The full REST body describes synthetic production-owner measurements, schema-40 migration and scoped restoration, adoption limits, and deliberate refusal by older readers; rollback requires a verified backup and matching older build. (scripts/perf/transcript-active-facts.ts:176, 8d9592f01953)
  • Published upgrade starting point: The published v2026.11.1 package declares agent schema 27, whereas the supplied new migration measurements start at schema 40. (package.json:13, 4ffdd2047d19)

PR surface

Source +671, Tests +738, Docs +197, Config 0, Other +1396. Total +3002 across 54 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 30 877 206 +671
Tests 14 775 37 +738
Docs 4 202 5 +197
Config 1 1 1 0
Generated 0 0 0 0
Other 5 1396 0 +1396
Total 54 3251 249 +3002

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Persisted schema change Agent schema 40 → 41; one initially empty derived table The version migration performs no historical facts backfill, so existing sessions initially retain fallback costs.

Labels

Label changes:

  • add P2: This improves hydration work for large conversations without an established urgent user-facing regression.
  • add merge-risk: 🚨 compatibility: Schema 41 deliberately prevents older writers from opening the database; the maintainer-authored PR records backup restoration with a matching binary as the rollback path.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This improves hydration work for large conversations without an established urgent user-facing regression.
  • merge-risk: 🚨 compatibility: Schema 41 deliberately prevents older writers from opening the database; the maintainer-authored PR records backup restoration with a matching binary as the rollback path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

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 November 5, 2026, 2:04 PM ET / 19:04 UTC.

@steipete
steipete force-pushed the steipete/perf-active-event-facts-schema-20261105 branch 3 times, most recently from 94564c4 to b411052 Compare November 5, 2026 21:11
Add agent schema 41 with an initially empty companion projection, transactional writer maintenance, and exact legacy reader fallbacks on SQLite and PostgreSQL. Preserve old-reader refusal and scoped restore behavior. Include synthetic upgrade, hydration, append, and cross-engine proof; historical facts remain uncovered until rewritten or rebuilt.
Keep historical PostgreSQL rebuilds on admitted predecessor facts, preserve schema-only preflight through agent41, and repair canonical FK parent indexes transactionally after physical integrity checks. Retain orphan, duplicate-key, current-schema missing-table, and corruption refusals. Correct exact SQL guard annotations and worker-owned invalidation classification.
Keep native JSON member classification in the shared engine helper and reuse the schema-version writer. The SQLite facts predicate compiles to identical SQL and bindings; scoped migration foreign-key checks are unchanged. Cover scalar strings, JSON null and absent members without broadening the dialect guard.
@steipete
steipete force-pushed the steipete/perf-active-event-facts-schema-20261105 branch from b411052 to 441bd56 Compare November 7, 2026 05:02
@steipete
steipete merged commit b6ed907 into main Nov 7, 2026
253 of 258 checks passed
@steipete
steipete deleted the steipete/perf-active-event-facts-schema-20261105 branch November 7, 2026 05:33
steipete added a commit that referenced this pull request Nov 7, 2026
…94531)

Register the schema-41 PostgreSQL migration test added by #193682 so the existing completeness guard and conformance shards cover it.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…aw#193682)

* perf(sessions): persist active transcript facts for hydration

Add agent schema 41 with an initially empty companion projection, transactional writer maintenance, and exact legacy reader fallbacks on SQLite and PostgreSQL. Preserve old-reader refusal and scoped restore behavior. Include synthetic upgrade, hydration, append, and cross-engine proof; historical facts remain uncovered until rewritten or rebuilt.

* perf(sessions): preserve migration and index recovery with active facts

Keep historical PostgreSQL rebuilds on admitted predecessor facts, preserve schema-only preflight through agent41, and repair canonical FK parent indexes transactionally after physical integrity checks. Retain orphan, duplicate-key, current-schema missing-table, and corruption refusals. Correct exact SQL guard annotations and worker-owned invalidation classification.

* perf(sessions): reuse engine owners for active facts checks

Keep native JSON member classification in the shared engine helper and reuse the schema-version writer. The SQLite facts predicate compiles to identical SQL and bindings; scoped migration foreign-key checks are unchanged. Cover scalar strings, JSON null and absent members without broadening the dialect guard.

* perf(sessions): align migration proof with version writer

* perf(sessions): preserve facts through bounded transcript repairs
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…enclaw#194531)

Register the schema-41 PostgreSQL migration test added by openclaw#193682 so the existing completeness guard and conformance shards cover it.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: steipete <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 10, 2026
Release adaptation: Keep the release SQLite planner helper private and omit
agent-port-projections.ts, which does not exist on this release line. Preserve
all baseline assertions by materializing four small test fixtures, and exercise
lazy payload reads through the actual SQLite planner rather than a fake source.
Allocate the exact 64 net test lines. No schema, config, or authority changes.

Later same-path followups through 568d89f: 8633af9 (#194591) is the
non-applicable PostgreSQL surrogate repair; b6ed907 (#193682) is the
non-applicable schema41 hydration migration. Neither is a streaming prerequisite.
Existing #195028 and #196277 repair contracts remain intact.

Verified: baseline lazy-read regression fails; 32 focused tests pass across
five suites, including compiled-worker publication and authority boundaries.
Targeted types, lint, format, and whitespace checks pass. Fresh independent
read-only review found no P0-P2 issues.

(cherry picked from commit 7bc0ae7)

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

(cherry picked from commit b6ed907)

Release adaptation: Only sqlite-index-schema.ts and focused index-drift tests: defer precisely recognized foreign-key parent-index mismatch when a matching unique canonical index can be repaired; atomic rollback/refusal and final full integrity check retained. No active-event persistence, schema/version/generated data, migration or benchmark changes. Target already has canonical index owner and integrity error contract.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c97698c708535fb73dd2b5e5ccd55ead56dd2a69)
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#194384)

* docs: clarify PostgreSQL conformance coverage

* fix(cron): keep one-shot finalization working on PostgreSQL 16

* test(database): reuse cron conformance for JSON conversion regression

* test(postgres): accept fractional explain row counts

(cherry picked from commit 7ab0143)

Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline.

Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682)

Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 38fdd9b52704d588d9ca24ef8e391d644961c985)
(cherry picked from commit fb935e6912388314851b05cb698ef038b83bbd07)
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

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant