Skip to content

perf(sessions): retain materialized rows for fact-only refreshes - #169724

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-materialize-session-row-self-20260919
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-materialize-session-row-self-20260919

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Runtime activity-summary changes and certified transcript updates rebuilt an unchanged session display row, adding main-thread work during agent turns.

User Impact

No intended behavior change. Summary state and transcript previews continue to update; session lists reuse the current materialization for these fact-only refreshes.

Why This Change Was Made

Keep activity-summary refresh in its existing facts owner. The projection refreshes that facet and schedules existing transcript backfill without replacing the entry-derived row. Dirty, cold, unready, and uncertified rows retain full preparation. Remove the superseded dirty-marking helper. No new cache, schema, configuration, or retained history.

Production delta is +12 lines (36 added / 24 removed): the growth preserves the current summary-watermark and preview-backfill contracts while separating them from full row materialization. The retained closure captures facts and scalar target fields, never a resident row or previous materialization.

Evidence

Synthetic Linux rig measurement, Node 24.19.0, measurement baseline e15926132cd9, one Gateway/agent database, 20 sessions, one warmup turn each, then 100 verified tool turns with history reads, subscriptions, and list probes. Counter runs and CPU-profile runs are separate; SELF excludes descendants.

Measurement Before After
Materializations per turn 18.07 14.99
Unchanged-entry materializations per turn 11.09 8.00
materializeSessionRow SELF / 100 turns 590.054 ms 501.153 ms
Clean lists / sidebar calls (100 each), source-owner probe 0 materializations unchanged

This is a 17.0% materialization reduction and 15.1% sampled SELF reduction. Remaining full publications still materialize; this does not claim elimination of every equal-entry input or an end-to-end latency improvement on a shared rig.

  • Both changed regressions fail on unchanged production code for the intended extra-materialization counts.
  • Focused local proof: 24 accepted-facts tests passed; 14 backfill tests passed after updating the replacement case to verify its new preview; 2 existing retention tests passed. Final rebased combined run: 38 tests passed in 191.28 s; existing retention file: 2 tests passed in 23.42 s. Cold compilation dominates this host. CI seconds will be recorded by the attached PR run.
  • Changed-file oxfmt, repository oxlint, and git diff --check passed.
  • Independent Codex autoreview: scoped-clean through P2.
  • Retention sampling: 20 samples across 581 seconds, with 233 verified turns before the 500-turn workload timed out waiting for agent.wait. Last-half post-collection heap: 332.85–363.37 MiB; median 344.87 MiB. Live materializations stayed bounded (22–50 in the last half; final 22 for 20 resident sessions). This is bounded-retention evidence, not a successful full soak or a claim that total Gateway heap is flat. The run included expensive forced collections; normal 100-turn runs both completed cleanly. The branch was rebased for an overlapping main change that removed a synchronous activity-summary argument; the 38 affected tests and independent review passed again. No Team access. No Testbox/Crabbox lease, per the lane validation policy. Broad gates are delegated to PR CI.

CI at the exact head completed the selected projection tests and sibling coverage successfully, including accepted-facts, backfill, retention, prepared reads, runtime ownership, invalidation, recovery, and topology. The corresponding changed-test shard wall times were 272 s (accepted-facts group), 266 s (backfill group), and 231 s (retention group); these are whole-shard times. The built-artifact lifecycle failure is inherited: main at 5a1f8c692e9474323c8cbbf6c4d985ed2a1b6f0b independently failed the same test with the same agent.wait result (status: error, AbortError: agent run aborted, no stopReason) during concurrent session deletion. Main job; PR job. The lifecycle test, helper, cancellation dispatch/outcome, and termination code are unchanged between the PR test baseline, tested merge, and independently failing main. Fail-fast cancelled check-prod-types and check-test-types-core-5; those checks remain incomplete. Landing under the authorized inherited-failure exception; no CI rerun or dispatch was requested.

@clawsweeper

clawsweeper Bot commented Oct 12, 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 gateway Gateway runtime size: S labels Oct 12, 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR refreshes activity-summary facts and transcript previews without rebuilding unchanged resident session rows.

Example: A streaming session receives assistant messages through “Update 11” without changing its stored entry.

  • Before: Transcript refresh windows rebuild the session row.
  • After: The existing materialization remains while background backfill updates its preview to “Update 11”.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; confidence in its runtime benefit rests on reported measurements and inspected owner-level regression coverage.
Proof confidence 🦐 gold shrimp (3/6) The host identifies maintainer authorship, outside the ordinary contributor proof gate; supplied synthetic Linux Gateway measurements cover agent turns and list probes, while inspected tests exercise summary freshness and previews through the production projection in process.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Agent turns spend avoidable Gateway CPU rebuilding session displays whose entry-derived content has not changed.
Reason: The established feature owner proposes a small, measured optimization while preserving summary freshness, preview updates, and conservative invalidation.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it provides a focused performance improvement that current main lacks, with no actionable source defect found. The previous merge conflict is resolved.

Priority: P2
Reviewed head: dea4f3f7c6d18a949b6f208f5d989c33d760358e

Before merge

  • Complete next step - Classify the built-CLI lifecycle agent.wait AbortError against the base or an independent matching failure, then address it only if caused by this diff.

Findings

None.

Agent review details

How this fits together

The Gateway session-row projection consumes committed database facts and runtime notifications, then supplies session lists, descriptions, and event snapshots.

flowchart TD
  A[Committed session facts] --> C[Resident row projection]
  B[Runtime notifications] --> C
  C --> D[Activity summary facts]
  C --> E[Transcript preview backfill]
  D --> F[Session lists and snapshots]
  E --> F
Loading

Technical review

Best possible solution:

Retain the existing projection and certification owners while refreshing only the changed summary and preview facets.

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

Current main visibly dirties unchanged rows for these notifications; source inspection establishes the redundant materialization path, supported by reported baseline-negative regressions and Gateway measurements.

Is this the best way to solve the issue?

The approach is appropriately narrow: it reuses existing facts and backfill owners, preserves conservative preparation, and removes the superseded helper.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Runtime presentation updates changes intended behavior with a stated reason (838bbcf: Preserve committed resident facts across status notifications while rebuilding affected presentation.)
  • Transcript refresh and preview scheduling changes intended behavior with a stated reason (2a3b917: Bound streaming allocation work while retaining summary-watermark freshness and background previews.)
  • Certified transcript fact reuse keeps the original intent (9afa39c: Reuse usable committed facts while preserving conservative handling of uncertified summary and metadata state.)
  • Automation dirty marking keeps the original intent (34c735e: Refresh only resident logical rows affected by changed automation bindings.)
  • Worker-prepared activity-summary contract keeps the original intent (af0c38c: Remove the physical-store argument from summary presentation while moving metadata reads to workers.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +12, Tests +10. Total +22 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 36 24 +12
Tests 2 21 11 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 57 35 +22

Review metrics

Metric Value Why it matters
Production versus test growth Production +12 LOC; tests +10 LOC The modest growth separates summary refresh from materialization and preserves observable preview and replacement coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded Gateway performance improvement without evidence of an urgent user-facing outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-12T07:45:00.269Z sha d29f2a728c28ce12c66f139e070522001f483577 :: needs changes before merge. :: none

Reviewed October 12, 2026, 4:03 AM ET / 08:03 UTC (Revision 2).

@steipete
steipete force-pushed the steipete/perf-micro-materialize-session-row-self-20260919 branch from d29f2a7 to dea4f3f Compare October 12, 2026 07:51
@steipete

Copy link
Copy Markdown
Contributor Author

The remaining CI failure is independently reproduced on main. The scheduled main run at 5a1f8c692e9474323c8cbbf6c4d985ed2a1b6f0b failed test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts with the same concurrent-delete result: agent.wait did not settle acceptably, terminal status: error, and AbortError: agent run aborted without stopReason.

Baseline: https://github.com/openclaw/openclaw/actions/runs/38220958692/job/114717130399
PR: https://github.com/openclaw/openclaw/actions/runs/38220131244/job/114714453343

The test, helper, cancellation dispatch/outcome and termination code are unchanged across the tested merge baseline (5f27b4e9182d48e47be6980d130e72896f32405d), tested merge (5815e630a523948b2f6d7878fa5fb17d5a41d44c), and failing main. The PR only changes row-fact refresh and existing projection tests. The exact reviewed head is dea4f3f7c6d18a949b6f208f5d989c33d760358e; independent review found no actionable source defects.

All selected projection test shards passed, including both changed files and sibling retention, prepared-read, membership, runtime-ownership, recovery, invalidation, topology and record tests. No new module, export or test file was added. Fail-fast cancelled check-prod-types and check-test-types-core-5; these are incomplete, not passing proof. Security, lint, architecture, and UI checks passed.

This resolves the hosted review's remaining baseline-classification request. Landing via the authorized inherited-failure exception with the exact head pinned; no CI reruns or dispatches.

@steipete
steipete merged commit e099f44 into main Oct 12, 2026
136 of 141 checks passed
@steipete
steipete deleted the steipete/perf-micro-materialize-session-row-self-20260919 branch October 12, 2026 08:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
First-parent upstream fa23864..e099f44 (100 commits, including
openclaw#169594 lifecycle/mention bookkeeping in workers, openclaw#169573 input completion,
openclaw#169724 fact-only refresh rows, openclaw#169598 target discovery).

Conflicts:
- session-entry-patch-source.ts: upstream routes host-only commit guards
  through the worker (`!commitGuard?.nativeSource`); kept our condition that
  a patch with afterPersistInTransaction (a main-thread closure) stays on
  the native writer.
- compact.types.ts: our "volitional" trigger plus upstream's
  modelCallUrgency.
- session-accessor.ts: upstream dropped the sync
  updateSessionProfileInvolvement export (no fork caller); recipient
  authority exports kept.
- worker inventory regenerated.

Auto-merged files carrying continuation overlay (21) keep it byte-for-byte.

Refs #1475

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

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant