Skip to content

perf(sessions): reuse actor facts for row projections - #169100

Merged
steipete merged 6 commits into
mainfrom
dbasync/transcript-facts
Oct 11, 2026
Merged

steipete merged 6 commits into
mainfrom
dbasync/transcript-facts

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session row refreshes reread entry, Board presence, and transcript summary facts already held by the session actor after its own writes.

User Impact

No visible behavior change. Resident session rows reuse committed actor facts with fewer SQLite statements and worker requests. Cold or incomplete rows keep the existing worker read.

Why This Change Was Made

Carry the already-hydrated Board presence in the actor postimage and expose a list-sized projection from the existing bounded replica. Use it before constructing history-worker read groups. Complete actor receipts supply transcript watermarks; same-lifecycle metadata receipts can retain Board facts but cannot certify a new summary watermark. Generic write notifications revoke row-fact coverage, including Board writes followed by metadata writes. Saved prompt snapshots are excluded before cloning, and existing SQL-side large-payload projections remain unchanged.

Removed checks and accepted cases:

  • Re-reading row entry and Board presence after complete actor publication: consume those committed facts; missing or evicted coverage uses the existing cold reader.
  • Re-reading summary watermark after a complete actor receipt: consume its cold-aware watermark; metadata-only receipts with an activity summary use the worker reader.
  • No live-authority or append-integrity check is removed. A refresh begun before actor receipt installation may still perform one worker read.

No schema, migration, retention, SDK surface, update, Doctor, plugin-loading, or service-lifecycle change.

Evidence

Three alternating pairs (M,C,M,C,M,C), shared warmed-turn harness. Measured base 599d0dec55e461775cc2a8de4ccb959098588c33, candidate 937ce9d0bbde23f26e6aed14ece78a2af30d7b1e; final changes only split the same function/test into sibling modules and integrate main.

Per warmed turn, median [min–max] Base Candidate Median delta
All-thread statements 345.8 [344.5–346.8] 336.3 [334.9–338.1] −9.5 (−2.75%)
All-thread requests 91.3 [90.5–91.8] 89.6 [89.1–89.6] −1.7
MAIN statements 0 [0–0] 0 [0–0] 0
Row-facts statements 30.5 [30.0–32.0] 21.0 [20.0–22.0] −9.5
Row-facts requests 6.1 [6.0–6.4] 4.2 [4.0–4.4] −1.9

Whole workload: 10067 [9982–10075] → 9892 [9871–9921] statements; 1733 [1729–1738] → 1708 [1704–1716] requests. First turn: 1277 [1188–1299] → 1224 [1194–1225] statements. Warm duration 1538.8 → 1472.8 ms. No extra pair needed: all candidate warmed statement samples are below every base sample.

Small non-turn fluctuations are within the ≤10-statement tolerance: connect +2 (unassigned startup), cron +1 (open), shutdown +3 (audit.writer.prune, +1 request); the changed row-fact path adds no request. The reduction is smaller than the census aim of 24–34 because cold, evicted, incomplete and uncertified summary facts still use the authoritative worker read.

T1 inventory: measured base 629 → candidate 629; final integrated raw inventory 623 → 623 (normalized 621 → 621); zero new main-thread SQLite calls. The first PR in this lane removed six T1 calls; this follow-up removes repeated worker SQL.

Proof completed before final mechanical split: 58 tests in five actor/projection suites passed (48.80 s runner wall time). The new row-projection regression fails on the base at the expected extra readRowFacts request. It covers real SDK metadata writes, a real Board write, and metadata after Board invalidation. Two Codex autoreview rounds found no P0/P1 issues. The final split is byte-identical for the moved production function and test.

Final integrated-head affected tests passed on Testbox (190.86 s wall time), including all changed suites, the incognito reader, the moved metadata/Board regression, both tooling dependency-closure regressions, and the Vitest project/configuration checks. Final-head type-aware oxlint (15 changed source files, zero warnings/errors), export-name collisions, Madge (zero cycles), line-count ratchets, T1 and dialect ratchets passed. Knip found 38 UI export entries, identical file/symbol sets on the integrated main baseline 3a0db8a3a05283c21600bc39e2772bf1432f7d0e; no changed-file or PR-only findings. The broad remote check:changed invocation was stopped after ten minutes without progress; its completed exact-head CI equivalents and the direct remote static checks supply the proof. CI run 38140428595 passed all jobs and required/security gates. CI initially exposed two split-registration errors (test host ownership and wrapper dependency inventory); both are fixed. The unrelated duplicate-scan failure was fixed by integrating its existing main fix. No published-driver update cell or SDK API diff applies.

LOC against integrated main: +543/−275 across 18 files, including a 276-line function moved into its own module and a 115-line focused regression module; no compatibility alias remains.

@clawsweeper

clawsweeper Bot commented Oct 11, 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 size: L labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses committed actor entry, Board, and transcript-watermark facts when preparing session rows.

Example: Refresh agent:main:actor-row-facts after its label changes to Committed metadata.

  • Before: The row displays Committed metadata after requesting facts from the history worker.
  • After: The row displays the same metadata from resident actor facts, while a subsequent Board write still triggers fresh preparation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused owner reuse and meaningful regression coverage support correctness; supplied behavior evidence remains at harness level.
Proof confidence 🦐 gold shrimp (3/6) The task identifies this as maintainer-authored internal work outside the ordinary contributor-proof gate; supplied evidence consists of warmed-turn harness measurements and real-owner regressions rather than a shipped-entry-point artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Session refreshes spend worker requests and SQLite statements reacquiring facts already committed by the actor.
Reason: The supplied maintainer direction, prior merged feature ownership, measured work reduction, and preserved cold-read behavior support this focused optimization.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a focused session-performance improvement that current main still needs, resolves the earlier wrapper-dependency finding, and has no actionable introduced defect identified in this review.

Priority: P2
Reviewed head: 5b1b87149991821f06321751dbb4aa2669a231b6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway sessions.list trace is supplied; the internal maintainer-authored optimization is outside the ordinary contributor-proof gate.
Agent review details

How this fits together

The Gateway row preparer combines agent-database facts with independent shared-state and runtime-ownership facts, then supplies resident rows for session presentation.

flowchart TD
  A[Agent database writer] --> B[Bounded actor replica]
  B --> D[Session row preparer]
  C[History worker fallback] --> D
  E[Shared and runtime facts] --> D
  D --> F[Resident session rows]
  F --> G[Session presentation]
Loading

Technical review

Best possible solution:

Reuse complete committed facts through the existing bounded actor replica and retain authoritative worker reads whenever coverage is missing or invalidated.

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

Current-main source establishes the redundant worker-read path, and the PR reports a baseline-failing regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The implementation fits the existing ownership model, preserves independent sharing and runtime-ownership responsibilities, and avoids introducing a competing cache.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Actor replica entry reuse keeps the original intent (3bbc221: Share bounded actor residency with entry readers while leaving physical-source and live-authority checks with callers.)
  • Worker-backed row preparation keeps the original intent (42263f8: Move dirty-row database preparation off the Gateway thread while retaining captured ownership and acceptance fences.)
  • Committed projection facts keeps the original intent (892911b: Consume complete committed postimages and invalidate uncovered or unknown facts.)
  • Accepted facts across refresh slices keeps the original intent (e77d4ad: Retain accepted row facts across presentation yields without retaining database handles or weakening lifecycle checks.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3bbc221 adds src/config/sessions/session-actor-replica.ts:102 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3bbc221d1c8c; files: src/config/sessions/session-actor-replica.ts)

PR surface

Source +93, Tests +166, Docs +8, Other +1. Total +268 across 18 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 361 268 +93
Tests 10 173 7 +166
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 18 543 275 +268

Review metrics

Metric Value Why it matters
Production versus tests Production +361/−268; tests and test support +173/−7 Most production churn moves the existing preparer; the remaining growth adds actor-fact reuse and invalidation, supported by freshness and avoided-read regressions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded session-performance improvement without an established urgent user-facing regression.
  • 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.

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 (2 earlier review cycles)
  • reviewed 2026-10-11T12:35:40.153Z sha a91dc2b :: needs changes before merge. :: [P2] Include the new activity-summary dependency in wrapper extraction
  • reviewed 2026-10-11T12:51:19.319Z sha 5b1b871 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 8:59 AM ET / 12:59 UTC (Revision 3).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 11, 2026
@clawsweeper clawsweeper Bot added 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete
steipete merged commit 2d7b1c1 into main Oct 11, 2026
167 checks passed
@steipete
steipete deleted the dbasync/transcript-facts branch October 11, 2026 13:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
* perf(sessions): reuse actor row facts during projection

* test(sessions): exercise sealed row projection receipts

* refactor(gateway): split session row database preparation

* test(sessions): retain host ownership for actor projection proof
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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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