Skip to content

perf(sessions): fuse cold-patch participant reads - #179164

Merged
steipete merged 3 commits into
mainfrom
dbasync/patchpath
Oct 21, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/patchpath

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold session patches read participant rows separately after already loading the entry and its write facts.

User Impact

Session patches need fewer database statements and PostgreSQL round trips. Stored data, participant ordering, patch conflicts, and snapshot retention are unchanged; no migration or configuration change is required.

Why This Change Was Made

Project ordered participant identities in the existing entry SELECT through the dialect JSON owner. Readers use that projection while preserving actor-owned participant precedence. This deletes the special CAS participant-borrowing state, wrapper, revision comparisons, and obsolete test; ordinary participant record reads and read-scope caching remain.

The cold patch entry read retains NULL-first timestamp ordering on SQLite and NULL-last ordering on PostgreSQL. Actor hydration keeps its existing NULL-first ordering on both engines. PostgreSQL still acquires its advisory lock before the authoritative read, and the existing node/window/snapshot CTE writes are unchanged. There is no new cache, freshness probe, transaction fusion, or accepted durability edge.

The attribution also found that snapshots store cold fields split out of entry JSON, and that later entry reads follow intervening writes or require different facts. Those reads and writes remain. Removing the five pure node-only transaction envelopes could save ten SQLite statements in the census workload, but the current write precedes result/receipt preparation and the final commit grant; that requires a separate terminal-statement owner redesign and is outside this bounded change.

Evidence

The unchanged base fails both exact entry/target work-count regressions: one standalone participant SELECT instead of zero. Candidate CI passes all four entry-write tests and all seven revision tests. Native SQLite/PostgreSQL conformance now passes all ten cases on the final source, covering the four-call cold patch, exact participant ordering at both reader boundaries, retained snapshots, rollback, and refused-commit publication. All nine changed input hashes match the committed files.

The prior PostgreSQL CI failure was a test-boundary error: cold entry results preserve native NULL ordering, while actor hydration normalizes NULL timestamps first. The repair asserts the actual cold-patch postimage and the actor read independently; production is unchanged.

Initial CI found a conditional callback inference error (TS2554), repaired with the existing projector ReturnType annotation without runtime or SQL changes. CI has passed type-aware lint, production types, source contracts, T1/dialect ratchets, and Madge (zero cycles). The local aggregate check was interrupted after conflict, line-cap, and assertion-safety checks passed; three UI max-lines errors match independently observed main failures with identical input files. Supplemental CI39565552123/job119107263459 passed all five canonical Knip scans with zero entries, including the full-tree export scan that timed out locally at its unchanged 600-second limit. Two isolated Codex review rounds found no actionable P0/P1 defects; the later annotation and ordering-test repair preserve the reviewed production behavior.

The census attributes six standalone participant SELECTs to 38 patch commits (171 SQLite statements total). Fusion is expected to remove those six statements with no worker-request change; this is a source estimate, not a measured result. The cold PostgreSQL patch conformance assertion expects four calls instead of five: begin/eager lock, hydrated entry SELECT, existing node/window CTE, commit. The baseline PostgreSQL regression fails at exactly five observed calls versus four expected; the candidate passes at four. Aggregate workload measurement is deferred to the shared census; no measured workload or latency saving is claimed.

Production: +65/-42 lines (net +23), covering the portable projection and decoder plumbing while deleting the borrowing machinery. Tests: +53/-45 (net +8). No SDK, schema, update, or service-lifecycle change.

Final-head CI run 39563009466 completed with all three PostgreSQL conformance shards passing. The root-tooling TS2345 failures at ci-changed-node-test-plan.test.ts:813/891 match a clean-main reproduction at 5e9c3fbfd6a2359f5980e75688c08c23a17af592; the CI main parent has identical failing test/planner blobs, neither modified here. The full X publication file passes locally on this exact head (1/1). The full orphan-recovery file reproduces the original-owner zero-call assertion (34 pass, one fail); the unchanged full file also fails on pinned current main 7d7cf4e07c55ac9e3e719b5aa23f79b388d8056f with the same zero-call assertion (34 pass, one fail), establishing inherited behavior. Both main X attempts ended at the unchanged worker/setup watchdog before any assertion verdict, including one replay after successful native worker prewarming. They are setup failures, not baseline passes or matching HTTP 503 failures. The same X case also passed on the preceding production-identical head 351ea52a920f835f518639ede5e5946d06be51aa in CI39558852021/job119086072374; the remaining nondeterministic X failure is disclosed rather than claimed fixed. No behavioral CI rerun or timeout change has been used. Two CodeQL jobs encountered GitHub installation API rate limits; their one diagnosed infrastructure rerun passed in attempt2.

The campaign coordinator folded post-landing pairs into the shared s42 census to reduce host contention. All six per-PR arms remain unrun. The source estimate of six removed statements is not a substitute for a measured aggregate; the direct PostgreSQL five-to-four-call regression and SQLite removal assertions are the completed count evidence.

Cold entry patches project ordered participant identities with the authoritative entry SELECT. Preserve native null ordering, actor precedence, patch conflicts, snapshot retention, and PostgreSQL write CTEs while removing CAS-only participant borrowing.
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T07:39:56.303595Z aac074e 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@steipete steipete changed the title improve(sessions): avoid separate participant reads for cold patches perf(sessions): fuse cold-patch participant reads Oct 21, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR projects participant identities in the existing session-entry query and removes CAS-specific participant borrowing.

Example: A cold PostgreSQL session patch updates the label while retaining three participants.

  • Before: The supplied baseline conformance result records five database calls, including a separate participant query.
  • After: The supplied candidate result records four calls, with participant identities returned by the entry query.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and no concrete defect was found, but its strongest supplied evidence is in-process conformance rather than a measured shipped workflow.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; supplied SQLite/PostgreSQL conformance exercises the changed production owners in process, while shipped-flow performance evidence remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Cold session patches spend an additional database statement and PostgreSQL round trip fetching participant identities.
Reason: The maintainer-authored direction removes identifiable repeated work within existing owners and preserves the stated storage and ordering contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a focused, maintainer-directed optimization, and review found no actionable correctness or security defect.

Priority: P2
Reviewed head: aac074ecf32cc7a846d5b58d5ebc6d96758e346c

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The declared alternating frozen workload remains unrun, so whole-flow performance improvement has not been demonstrated.
Agent review details

How this fits together

The worker-owned session store reads entry metadata and participant identities, applies a patch inside the existing transaction, and publishes the committed entry through the existing receipt owner.

flowchart LR
  A[Session patch request] --> B[Worker transaction owner]
  B --> C[Entry and participant query]
  C --> D[Canonical entry decoder]
  D --> E[Existing entry writer]
  E --> F[Commit and publication]
Loading

Technical review

Best possible solution:

Keep participant fusion in the existing entry-query and dialect owners while preserving actor precedence, native ordering, and transaction authority.

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

Current-main source shows participant projection following entry selection, and the PR reports baseline failures of the focused work-count regressions; no target code was executed during this review.

Is this the best way to solve the issue?

The change uses existing query, JSON, identity-validation, and publication owners and removes the replaced borrowing path without adding a cache or transaction layer.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • CAS participant borrowing and its dedicated regression changes intended behavior with a stated reason (d79f645: Reuse unchanged preparation facts only inside an admitted immediate CAS transaction while preserving deferred-reader snapshot establishment.)
  • Dialect-owned ordered JSON aggregation keeps the original intent (2eb3b60: Keep engine-portable projections as JSON text and preserve explicit NULL-first ordering for existing callers.)
  • Participant ordering and identity projection keeps the original intent (ef22b23: Reuse single-session participant queries with timestamp, actor-ID, and namespace ordering.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ef22b23 adds src/config/sessions/session-accessor.sqlite-participant-projection.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ef22b2300ad3; files: src/config/sessions/session-accessor.sqlite-participant-projection.ts)

PR surface

Source +23, Tests +8. Total +31 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 65 42 +23
Tests 3 53 45 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 118 87 +31

Review metrics

Metric Value Why it matters
Production versus tests Production +65/-42; tests +53/-45 The production growth adds portable query and decoder plumbing while removing borrowing state; test growth covers query reduction and distinct engine ordering.

Labels

Label changes:

  • add P2: This is a bounded session-store performance improvement with no demonstrated urgent user-facing failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This is a bounded session-store performance improvement with no demonstrated urgent user-facing failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Complete the declared alternating baseline/candidate workload and report observed statement counts and performance.

Rating scale

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

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 4:17 AM ET / 08:17 UTC.

@steipete
steipete merged commit ba1f3b2 into main Oct 21, 2026
352 of 371 checks passed
@steipete
steipete deleted the dbasync/patchpath branch October 21, 2026 10:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
Cold session patches loaded participants in a separate query after reading the entry. Project ordered identity tuples in that existing SELECT through the dialect owner and remove the CAS-only participant borrowing state, wrapper, and revision comparisons.

Keep actor participant precedence, native cold-entry ordering, expected-revision conflict handling, snapshot retention, eager PostgreSQL writer locking, and the existing writable CTEs. No schema, SDK, configuration, or durability change.

Proof: the PostgreSQL cold-patch regression observes five database calls on the unchanged base and four on the candidate. The complete changed SQLite/PostgreSQL conformance file passes all ten cases; exact-entry work-count and revision regressions pass in CI. Aggregate workload evidence is deferred to the shared census; no aggregate SQL or latency saving is claimed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant