Skip to content

perf(sessions): remove per-commit canonical validation bookkeeping - #167932

Merged
steipete merged 6 commits into
mainfrom
dbasync/w10canonical
Oct 9, 2026
Merged

steipete merged 6 commits into
mainfrom
dbasync/w10canonical

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Canonical session commits queued their already-known row for validation, restored a validity flag cleared by a trigger, reread the row, and deleted its pending marker. This removes 55 SQLite statements per warmed chat turn, with no replacement worker requests.

User Impact

Chat turns execute less SQLite work. The paired all-thread median is 1,135.0 → 1,060.7 statements/turn; 55 of the observed 74.3 reduction are the verified removed bookkeeping classes. Remaining differences are unchanged admission/background work and timing, not additional savings claimed here. The overall campaign still has work remaining toward 500 statements/turn.

Agent schema 24 → 25 is a forward migration. Older binaries refuse schema 25; binary rollback requires the verified pre-upgrade database backup with its matching build. Session/transcript payloads, durability, retention, permissions, FIFO, effect-boundary live authority, and released SDK contracts are preserved. Low-level autocommit writers now reject invalid serialization/native-text projections before writing, closing the previous transaction-only validation gap.

Why This Change Was Made

The canonical writer validates its serialized UTF-8 row projection before side effects and writes final validity once. Schema 25 retires three validity-reset triggers and nine pending-validation triggers. No new cache, worker request, runtime format check, or foreign-commit probe is introduced.

Under the approved single-owner contract, the Gateway owns runtime SQLite writes. Other processes use the Gateway or operate offline while it is stopped. Imports and Doctor repairs that deliberately stage aliases or unvalidated rows explicitly queue those keys and revoke canonical receipts. Main-key policy changes invalidate before publication, including autocommit failure paths. Existing provenance/owner reads retain their separate contracts.

Migration validates the historical schema, seeds every existing node, clears prior canonical proof, and publishes both version markers atomically. Admission retains its bounded validation worker and exact-input settlement. The migration supports older databases missing the lazy receipt column. Backed-up schema-24 orphan-window repair remains available before upgrade or the full migration backup; only unreachable windows are removed, with original history preserved in the backup. V14 and intermediate media schemas use the same historical schema owner. Current construction never reinstalls the retired triggers.

Evidence

Base 432ade6f500de6cdb0bcd4b0948a07bf466672f1; candidate 01f857c6b37056bd47df1eae9f546bc0e8efbb2c. Six same-host runs in M,C,M,C,M,C order used the shared workload, privately copied only to add the existing transport observer. All 13 top-level turns, the native child, control RPCs, cron, compaction, and shutdown succeeded in every run. SQL/census joins conserve every successful statement; no missing SQL contexts or duplicate sends. Calibration on MAIN and a worker: 8 native calls, 2 prepares, 7 successful statements, 0 failures.

Values are median [min–max] across three runs. Warmed values are each run’s ten-turn mean; other rows are phase totals. MAIN is Gateway thread 0; all-thread totals also include workers and helper processes. Instrumentation and background work stay counted. These are execution-count observations, not unloaded-host latency measurements.

Phase Base all-thread Candidate all-thread Delta Base MAIN Candidate MAIN
01.boot 3386 [3386–3406] 3340 [3326–3357] -46.0 1998 [1996–1998] 1986 [1982–1996]
01.connect 530 [493–530] 482 [327–698] -48.0 62 [61–62] 62 [40–103]
02.first-turn 2275 [2157–2540] 2000 [1576–2027] -275.0 87 [81–126] 69 [32–84]
03.warmed 1135 [1086–1338.3] 1060.7 [1056.5–1121.9] -74.3 12.2 [8.1–26.1] 10.7 [10.1–10.7]
04.second-session 4359 [4007–4961] 3819 [3797–3950] -540.0 124 [104–169] 107 [104–114]
05.control-plane 34 [34–425] 37 [35–38] +3.0 0 [0–33] 0 [0–0]
06.cron 1267 [1262–1938] 1198 [1144–1212] -69.0 44 [44–313] 30 [7–44]
07.compaction 417 [411–510] 407 [407–454] -10.0 25 [25–50] 25 [25–48]
08.shutdown 199 [196–199] 205 [204–214] +6.0 133 [125–133] 133 [130–133]
Phase Base worker requests Candidate worker requests Candidate/base duration
01.boot 66 [66–69] 66 [66–70] 1.458
01.connect 67 [48–67] 67 [43–78] 1.014
02.first-turn 294 [291–351] 292 [250–292] 1.080
03.warmed 200.2 [195–222.7] 199.7 [199.4–201.5] 1.120
04.second-session 665 [663–788] 658 [656–686] 0.827
05.control-plane 5 [5–74] 6 [5–6] 1.000
06.cron 175 [173–263] 174 [164–175] 0.994
07.compaction 84 [83–103] 83 [83–93] 0.901
08.shutdown 15 [15–15] 15 [15–17] 1.317

Requests are logical transport requests, including resource closes; continuation/control frames are recorded separately. The warmed 200.2 → 199.7 change is observed variation, not an RPC reduction attributed to this patch. Two boot-only transport targets were unresolved; their sends remain counted, and all warmed requests completed.

Statement attribution and gates

Removed warmed class Base/turn, every run Candidate/turn, every run
Pending-key SELECT 16 0
Stored-row validation SELECT 13 0
Pending-key DELETE 13 0
Separate entry-validity UPDATE 13 0
Verified retirement 55 0

The certification stack itself loses all 42 pending/readback/delete executions, and the writer loses 13 validity updates. Nothing moves to MAIN or another worker. Retired trigger DDL also disappears from current-schema construction/comparison: median reductions are 60 boot, 48 connect, and 60 first-turn statements; its warmed median is zero on both sides. The direct bookkeeping class sums removed in first-turn/second-session/cron/compaction are 77/179/59/9. Other observed decreases are not credited as new optimization: unchanged schema/handle admission, resource lifetime, and background timing account for their variable work.

All per-phase median duration ratios are ≤1.5 (maximum 1.458). First-turn and warmed totals decrease. Control’s +3 statements/+1 request are an existing deliveryQueue.outbound recovery read (version observation, config-machine state, queue selection), present in baseline run 3 and candidate runs 1/3. Shutdown’s +6 statements come from existing integrity clean-close/lease-release and WAL owners. Every positive SQL/normalized-stack group appears in the baseline. Both increases pass the ≤10-statement non-turn tolerance, with no PR-created request path. For context, compaction+shutdown sums are M=[709,613,610], C=[612,621,658], median 613→621 (+1.3%).

Native failed attempts are retained separately: base [0,0,0]; candidate [1,0,2], all boot/connect BEGIN IMMEDIATE lock attempts in unchanged state-lease release/operator-approval cleanup. None occur in first/warmed turns; all full workloads finish successfully. They are excluded from successful-statement counts by the shared counting contract.

Correctness and static proof

  • Writer regressions cover transaction/autocommit validity, zero bookkeeping/readback, serialized identity/native UTF-8 divergence, pending settlement/rollback, and interrupted policy invalidation. Baseline negative controls fail on all four targeted query classes and the autocommit validation gap; the policy fault injection also fails before the ordering correction.
  • Frozen-schema migration tests cover prior 24, missing receipt columns, invalid rows, schema drift, rollback, copied stores, and older V14/media paths. Focused entry/transcript/deletion, import, cache/receipt, Doctor, mixed-fleet rehearsal, orphan backup, selected-read, and live worker-authority tests pass. Fixtures now explicitly identify imported unvalidated data; the obsolete raw-SQL reset-trigger assertion was removed.
  • check:changed passed all guards, formatting, package/schema baselines, SDK surface checks, all typecheck lanes, and unused-export scans. Its sole failure is 15 inherited max-lines lint errors in untouched files. All 15 reproduce, and their source/config/lock/wrapper inputs are byte-identical to origin/main at a799f4a42891eb875c7c238c22c2fa881027209f. They do not block this lane under the inherited-failure rule. The final fixture edit separately passes its selected type graph and lint.
  • Madge: 0 cycles. Knip full production/full-tree passes. SQLite worker ratchet passes with no T1 growth. Source-mapped QA build and package tarball integrity pass.
  • SDK diff: no entrypoint additions/removals or direct export declaration changes. All 148 flags are reachable declaration-closure changes from the schema constants and private canonical-validation/key helpers; no released callable contract was removed. Digest 657de9cb.
  • Final staged-tree Codex P2 review is clean, round 3. Prior index-only policy/recovery findings are resolved. No remaining P2/P3 follow-ups.

Materially expanded test owners were measured individually with pnpm test <file> --maxWorkers=1: canonical validation 25.4 s, canonical schema/migration 20.9 s, validation-cache receipts 20.5 s wall time. These exercise actual SQLite serialization, physical admission, worker handoff, and migration/rollback contracts. Final-attempt CI timing and incomplete coverage are recorded below. A timing-only attempt aborted before tests because a concurrent build changed workspace artifact topology; its sequential rerun passed. No timeout increase or weakened assertion was used.

Published-driver × candidate update cell passed in this lane: installed 2026.9.8 updater → candidate 2026.9.9 at 01f857c6b37056bd47df1eae9f546bc0e8efbb2c. The run finished/succeeded, /readyz returned 200, running version/build matched, and durable/incognito post-update checks passed. The isolated service stopped and the container/volume cleanup completed. Candidate tarball SHA-256: 2b0593c93fd7ff07946277e8ee9f1f2ab50241e821353545c9bc2b1250f9bb01.

Scope and remaining limits

Production/metadata/tooling LOC: +343/−304 (net +39). Tests/support: +1529/−348 (net +1181), dominated by the 1,039-line frozen schema-24 migration fixture. Docs: +80/−9. Historical trigger definitions remain only with migration; current writers and DDL have no competing path.

The published artifact build reported a startup-JS budget warning (364.8 KiB gzip versus 364.7 KiB); tarball integrity passed. This is backend work with no UI source changes. The shared host and background admissions explain wide run spreads; only the 55 repeated statement removals are claimed as warmed-turn savings. The landing validation below covers the integrated candidate and CI repairs.

Landing validation

Final candidate: 881ea03585a2167dabbf23393dc7468f26912e15. Main was merged without conflicts in 1bd8206d9ad3 to incorporate the already-landed recovery-fixture fix. No rebase or SQL-path conflict resolution was needed; the valid alternating SQL proof above is reused. Agent schema 25 was still free on main 7cf743ec145a (which declares 24).

The lander fixed two tooling omissions in cd88c380b583: the migration module belongs in the extracted-wrapper dependency inventory and in the existing raw-SQL schema/migration allowlist. CI also exposed raw-write test fixtures that relied on the retired triggers. Commits ad8d86fb3452 and 881ea03585a2 explicitly establish pending/validity fixture state, preserve concurrent-writer transaction boundaries, and retain refusal, snapshot, authority, and persistence assertions. The companion test's assertion for the retired validity UPDATE was removed; its persisted-label and authority checks remain.

All 236 focused tests across 18 repaired fixture files now pass, plus 31 wrapper/import/process-graph tests. Post-integration production, all 27 core-test typecheck lanes, scripts typechecking, Kysely guardrails, and Madge (zero cycles) passed. Subsequent fixture edits passed their selected type graphs. Three scoped lander Codex P2 review rounds are clean; the original lane's final P2 review remains valid for unchanged production code. Released SDK review against v2026.9.9 and v2026.10.1-beta.2 confirms the changed helpers are internal and no released callable signature was removed.

Focused proof used --maxWorkers=1. The first eight-file repair batch took 632.786 s (97 tests); ACP startup took 279.875 s, including a cold worker build, and canonical reads 188.579 s. The late eight-file batch took 314.74 s (122 passed, one fixture precondition corrected); the final schema-probes file passed all 14 tests in 67.96 s. The final late batch's Gateway suites passed 34 tests in 147.13 s. No timeout increases, sleeps, retries, or weaker behavior assertions were added.

ClawSweeper completed its review of 01f857c6b370 with zero code findings and requested latest-stable upgrade evidence beyond the lane's earlier 2026.9.8 run. That gap is now closed: the published 2026.9.9 driver → candidate 2026.9.9 at 881ea03 cell passed. The updater finished in 646.391 s; /readyz returned 200, running version/build identity matched, and both durable and incognito post-update checks passed. The isolated service stopped successfully and container/volume cleanup completed.

Command (artifact paths abbreviated): bash scripts/e2e/published-driver-update-docker.sh <candidate.tgz> <artifacts> 2026.9.9.

update: exit=0 durationMs=646391
recorded-run: exit=0
running-version: exit=0
durable-after: exit=0
incognito-after: exit=0
PASS published 2026.9.9 → candidate 2026.9.9 (881ea03585a2167dabbf23393dc7468f26912e15): finished, readyz=200, running version verified
stop-service: exit=0

The full package build and tarball integrity check passed. Candidate SHA-256: 7dcd9bae4e3d99d61e43669ad17295a904aed6ad709f0658bf132c01d8ae0b9b. The build retained the same startup-JS budget warning already recorded above (364.8 KiB versus 364.7 KiB); this PR changes no UI source.

CI infrastructure exception

CI attempt 37986402968 executed merge c97064b345f20fc3c37f5e960d6bcf9096279556, whose parents are main 7cf743ec145a and candidate 881ea03585a2. Two unchanged pinned-Bun setup downloads returned HTTP 500 on the initial request and all three built-in retries, before their Node test steps ran:

The successful fail-fast monitor cancelled 131 collateral jobs; none of those jobs has a failed step. The complete attempt has two infrastructure roots, one downstream CI-gate failure, 131 cancelled jobs, 20 skipped jobs, and six successful jobs including security-fast. Cancelled coverage remains unrun. This attempt recorded 17,490 elapsed job-seconds including cancelled jobs; that is execution timing, not a claim of complete coverage. The Bun action, installer, pin, and workflow blobs are identical to the tested main baseline, and the failure precedes this PR's code. Native admin admission is explicitly authorized for this independently inherited infrastructure failure; it must still verify current security, reviews, head identity, and the complete retained evidence. No CI rerun was requested merely to obtain green.

Checkpoint schema 25 and canonical writer cutover after a clean P2 review. Full campaign proof and the autocommit-policy and prior-schema recovery follow-ups remain pending before publication.
Revoke canonical proof before policy publication, preserve backed-up schema-24 orphan repair, and reuse historical schema definitions for older media and session migrations. Update import fixtures to use explicit admission invalidation. Final staged-tree P2 review is clean; focused regressions, typechecks, cycles, Knip, and the T1 ratchet pass. Full changed checks have only reproduced inherited max-lines failures in untouched files.
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: XL labels Oct 9, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The session store validates serialized records before writing them, removes repeated database bookkeeping, and migrates existing agent databases from schema 24 to 25.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong runtime evidence and a coherent implementation, with existing-state compatibility still incompletely demonstrated.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The submitted Gateway workload exercises the production session writer and records successful after-fix turns with 55 bookkeeping statements retired; the relevant production owners remain unchanged since that run. Data-model compatibility is incomplete: supply logs, live output, or terminal screenshots of a latest-stable 2026.9.9 upgrade preserving existing settings and session/transcript data. Redact private addresses, keys, phone numbers, and endpoints.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Chat turns spend avoidable database work repeatedly validating session records the writer already holds.
Reason: The production workload demonstrates a repeated cost worth removing. Prior merged area history establishes owner direction, and the implementation keeps the existing writer and admission owners.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR provides a distinct, measured optimization that current main still lacks. No concrete introduced correctness defect was found.

Priority: P2
Reviewed head: 881ea03585a2167dabbf23393dc7468f26912e15

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: An upgrade from published [email protected] to the candidate, preserving existing settings and session/transcript data and exercising post-update reads or turns, is not reported.
Agent review details

How this fits together

OpenClaw stores session metadata and conversation history in per-agent SQLite databases. Session writers preserve record identity, while admission workers validate imported or repaired records before runtime use.

flowchart TD
  A[Session metadata update] --> B[Validate serialized record]
  B --> C[Session writer]
  C --> D[Agent SQLite database]
  E[Offline imports and Doctor repairs] --> F[Pending validation queue]
  F --> G[Admission worker]
  G --> D
  D --> H[Session readers]
Loading

Technical review

Best possible solution:

Keep serialized validation with the existing writer and historical-state validation with migration and admission, preserving explicit offline invalidation and backup-based recovery.

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

Not applicable to a functional bug: current-main source and the submitted alternating Gateway workload establish the repeated bookkeeping this optimization removes.

Is this the best way to solve the issue?

Yes: the existing writer validates its serialized inputs before mutation, while the existing migration and admission owners handle historical or unvalidated records without a competing runtime path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned writer cutover: The introduced writer validates the serialized native-text projection before mutation, persists final validity directly, and explicitly queues alias imports. Writer certification and its separate validity update are removed. (src/config/sessions/session-accessor.sqlite-entry-store.ts:531, 881ea03585a2)
  • Current main still performs certification: Fetched main retains schema 24 and the writer's pending lookup, stored-row validation read, and pending deletion. No merged replacement owning this optimization was established. (src/config/sessions/session-canonical-validation.ts:267, e69931d6e6a2)
  • Submitted production observations: The complete PR body, captured under source revision c276a33ae15467558090b0788f3645f16dc156fb3b3443e840cd8d957eaa4aee, reports six alternating Gateway workload runs at candidate 01f857c. Every workload completed; four attributed bookkeeping classes fell from 55 statements per warmed turn to zero, without replacement worker requests. These are submitted observations, not reviewer-executed tests. (01f857c6b370)
  • Runtime proof remains applicable: Comparison with the previously reviewed candidate shows no later changes to the session writer, main-key publication, schema-25 migration, or schema migration dispatcher; subsequent changes in this scope concern tooling and fixtures. (src/config/sessions/session-accessor.sqlite-entry-store.ts:531, 881ea03585a2)
  • Historical-state migration coverage: The inspected migration regression preserves node contents, seeds all existing keys, clears prior receipts, handles an absent lazy receipt column, and verifies rollback and schema-drift refusal. The frozen schema-24 fixture and base schema have the identical Git blob f94c8f7105e9d134606c7ada6dea2a61fe19d836. (src/state/openclaw-agent-canonical-validation-schema.test.ts:549, 881ea03585a2)
  • Upgrade proof boundary: GitHub releases and the release source confirm v2026.9.9 is latest stable and uses agent schema 24. The supplied updater run starts at 2026.9.8; no subsequent discussion supplies the latest-stable upgrade with existing settings and session/transcript data preserved. The prior compatibility concern therefore remains unresolved. (src/state/openclaw-agent-db-contract.ts:30, bcfc88812a35)

Likely related people:

  • Peter Steinberger: Raw commit bc28af4 adds src/config/sessions/session-canonical-key.ts:218 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc28af41e101; files: src/config/sessions/session-canonical-key.ts)

PR surface

Source +37, Tests +1181, Docs +71, Config 0, Other +2. Total +1291 across 64 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 21 340 303 +37
Tests 36 1529 348 +1181
Docs 4 80 9 +71
Config 1 1 1 0
Generated 0 0 0 0
Other 2 2 0 +2
Total 64 1952 661 +1291

Review metrics

Metric Value Why it matters
Agent schema transition 24 → 25 Older binaries refuse upgraded stores, and rollback requires the matching pre-upgrade backup.
Attributed warmed-turn savings 55 SQLite statements removed per turn Submitted production attribution separates the deterministic reduction from variable background work.
Production versus tests Production/metadata +343/−304; tests/support +1529/−348 Production growth supports historical migration and explicit invalidation; the frozen predecessor schema accounts for most test growth.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded session-storage performance improvement without evidence of an urgent user-facing regression.
  • merge-risk: 🚨 compatibility: The owner-authored design accepts older-build refusal and backup-based rollback after schema 25.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-09T19:31:41.949Z sha 01f857c :: blocked before merge. :: none

Reviewed October 9, 2026, 4:38 PM ET / 20:38 UTC (Revision 2).

Include the schema-25 migration in extracted PR wrappers and the existing raw SQLite schema/migration allowlist. Focused import-closure and process-build graph tests, Kysely guardrails, and scoped P2 review pass.
Preserve corruption, retained-reader, label-authority, and admission failure coverage after retiring canonical validation triggers. All 113 focused cases pass on the integrated tree; production, core-test, and tooling types and Madge pass.
Explicitly publish pending state in raw repair fixtures, retain transaction snapshot boundaries, and remove the obsolete per-write validity UPDATE assertion. All 123 focused late-fixture tests pass after the targeted schema fixture correction; selected type graphs and final P2 review pass.
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling labels Oct 9, 2026
@steipete
steipete merged commit 6a8b0dc into main Oct 9, 2026
99 of 234 checks passed
@steipete
steipete deleted the dbasync/w10canonical branch October 9, 2026 20:58
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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

steipete added a commit that referenced this pull request Oct 10, 2026
…uard writes

Since 6a8b0dc (#167932) the canonical writer persists native session patches with insert into "session_nodes" (upsert) instead of update ... set, so the opaque commit-guard case still mutated natively but the SQL detector missed it. Accept both native write shapes; the prepared-guard case still asserts no native write.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…penclaw#167932)

* perf(sessions): validate canonical rows before writing

Checkpoint schema 25 and canonical writer cutover after a clean P2 review. Full campaign proof and the autocommit-policy and prior-schema recovery follow-ups remain pending before publication.

* fix(sessions): preserve offline validation and historical repairs

Revoke canonical proof before policy publication, preserve backed-up schema-24 orphan repair, and reuse historical schema definitions for older media and session migrations. Update import fixtures to use explicit admission invalidation. Final staged-tree P2 review is clean; focused regressions, typechecks, cycles, Knip, and the T1 ratchet pass. Full changed checks have only reproduced inherited max-lines failures in untouched files.

* fix(tooling): register canonical validation migration dependencies

Include the schema-25 migration in extracted PR wrappers and the existing raw SQLite schema/migration allowlist. Focused import-closure and process-build graph tests, Kysely guardrails, and scoped P2 review pass.

* test(sessions): explicitly seed imported validation fixtures

Preserve corruption, retained-reader, label-authority, and admission failure coverage after retiring canonical validation triggers. All 113 focused cases pass on the integrated tree; production, core-test, and tooling types and Madge pass.

* test(sessions): complete canonical writer fixture cutover

Explicitly publish pending state in raw repair fixtures, retain transaction snapshot boundaries, and remove the obsolete per-write validity UPDATE assertion. All 123 focused late-fixture tests pass after the targeted schema fixture correction; selected type graphs and final P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…uard writes

Since e6f6e17 (openclaw#167932) the canonical writer persists native session patches with insert into "session_nodes" (upsert) instead of update ... set, so the opaque commit-guard case still mutated natively but the SQL detector missed it. Accept both native write shapes; the prepared-guard case still asserts no native write.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 13, 2026
…#167932): schema 25 -> 26 bridge

Upstream openclaw#167932 takes agent schema 25 for canonical writer validation (retires
the entry_valid / canonical-pending triggers). Our recipient authority was also
schema 25 and is live on the fleet. Decision (🌊 + 🕯, option A): keep upstream's
numbering; recipient authority becomes schema 26.

- OPENCLAW_AGENT_SCHEMA_VERSION = 26; CANONICAL_SESSION_WRITER_VALIDATION = 25;
  AGENT_RECIPIENT_AUTHORITY_SCHEMA_VERSION = 26.
- readAgentSchema25Shape classifies a schema-25 file by its physical shape:
  authority table + legacy entry_valid trigger = the fleet's schema 25; neither =
  upstream's; any other shape throws ("unrecognized schema-25 shape ... restore its
  pre-upgrade backup") before anything is written.
- The fleet shape validates against current SQL + legacy triggers, then runs
  upstream's trigger retirement and the idempotent recipient-authority step in the
  one schema transaction; markers advance to 26 only on commit.
- getOpenClawAgentMigrationSchema composes both historical representations;
  schema.sql keeps the authority table without the retired triggers.
- agent-schema-history: upstream's 25 row, our 26 row, and the fleet-25 bridge;
  rollback is the pre-migration backup with its matching build.

Fossils (openclaw-agent-db.schema25-bridge.test.ts, 7): fleet 25->26 keeps the
authority row and drops the legacy triggers; upstream 25->26; 24->26; idempotent
reopen; mixed shape refused unchanged; a denied user_version=26 publication rolls
back to the exact fleet-25 shape. Causal: with shape detection stubbed out 4/7 RED,
restored 7/7 GREEN. The recipient-authority migration test moves to 26 and its
schema-24 fixture now carries the legacy triggers schema 24 really had.

Checks: tsgo x4 clean; 106-file schema/canonical-validation/doctor sweep green
except openclaw-agent-execution.creation-witness (7 fail), which fails identically
on plain upstream 6a8b0dc (upstream baseline on this host; not touched).

Deploy is blocked past step 13 until bootstrap#1703 (a post-migration rollback
must restore the pre-migration snapshot) lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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