Skip to content

perf(sessions): compact shared lists and apply row deltas - #164573

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-sessions-list-payload-20260919
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-sessions-list-payload-20260919

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session row events made Activity refetch the entire roster even when they already contained an authoritative update. List responses also repeated detail metadata and serialized the same rows separately for every viewer.

User Impact

Activity and Current Work update admitted rows immediately from events, with a fallback refresh after at least 60 seconds. Complete Current Work windows also accept certified session starts. Sidebar, dashboard, and Activity queries request compact rows; native clients and the Sessions management view retain the full response contract. No configuration or protocol-version change is required.

Why This Change Was Made

The existing projection owns immutable row presentations and encoded bytes across requests, while every read still checks the current viewer, runtime authority, and expiring facts. The RPC serializer reuses those bytes for both list and subscription responses. Embedded readers keep separate caller-bound authorization receipts.

Compact rows explicitly mark omitted detail fields, so a later roster response cannot erase capabilities or settings admitted by a full descriptor or chat history. History merges accepted event field receipts with overlapping authoritative reads through the shared row-provenance owner. Current Work coalesces superseded full snapshots while retaining ordered partial completions. Actual membership and generation facts replace the previous reason whitelist when deciding whether another list read is necessary. List admission and Current Work share one held-ancestor coverage check; incomplete child-only events still trigger paced catch-up for parent facts.

Production LOC: +581 (+757/−176), plus 30 net lines in scoped UI instructions. The requested non-test/non-doc stat including those instructions is +611. Growth preserves four existing contracts: the default native/full-row API and compact omission semantics; per-reader authorization despite shared immutable presentation; fresh samples for active runs and expiring facts; and generation/field continuity while events overlap authoritative reads. The previous event-local encoder, reason whitelist, duplicate Current Work field copying, and History packet-replay machinery are removed.

Evidence

Synthetic Linux rig: 5,000 persisted sessions, 20 viewers, real resident projection, sessions.list handler and Gateway serializer. Event measurements replay the real Activity controller for five virtual minutes, two row updates/second/client and 20 ms request latency. These are synthetic measurements, not production captures.

Measurement Before After Change
Sidebar response, 200 rows 351,329 B 275,329 B -21.6%
Activity response, 100 rows 254,156 B 216,156 B -15.0%
Full roster response, 5,000 rows 8,718,770 B 6,818,770 B -21.8%
List refreshes/min/client 11.8 0.8 -93.2%
Warm row traversals at transport, 20 clients × 200 rows 4,000 0 eliminated

The request reduction holds for held Current Work rows, a 20-row Current Work roster replacing one session every ten seconds, and unfiltered Activity history. All three scenarios were replayed successfully against the final candidate. A fourth replay covers the actual excluded-subagent path: 20 History clients hold 100 parents while child events carry certified parent updates. It also falls from 1,180 to 80 reads over five minutes, with the final parent label updated immediately instead of remaining 100 events stale; no excluded child enters History and no parent-child link is lost. The last changed title arrives through the event immediately. The synthetic event fixture uses full rows to measure frequency savings independently of compact payload savings.

Largest sidebar field contributions before compaction: thinking levels 39,400 B; owner 34,500 B; creator 33,900 B; agent runtime 23,000 B; display name 18,690 B; label 17,490 B; thinking options 12,800 B. Owner, title, preview, lineage, placement, and other fields used by current list views are preserved.

Negative controls fail on the old source for repeated row encoding, loss of buffered row updates, and clearing compact-omitted details. Additional controls reproduce stale timestamps after permission/run state cycles, unapplied ancestors, generation conflicts, stale unheld liveness, missing parent catch-up, and resurrection of an active row from an older overlapping snapshot. The corrected source passes those regressions.

Validation uses Blacksmith Testbox (blacksmith-testbox, profile openclaw-check). The latest lease is tbx_01m41tqn5te2a7n2mj10kfgj94: Current Work (53 cases), History and shared list-query siblings (73 cases), the resumed changed gate, and all seven Control UI browser E2E cases pass. Earlier leases tbx_01m41s4ahnntb3gasm0p6g87fp and tbx_01m41nerk3zt1sp6vnfhbxwvdh supplied Current Work and Gateway proof, respectively; tbx_01m41ackjy89bqd9x12p3af0gp supplied generated Swift/Kotlin and protocol verification. Core typechecking plus all 27 core test typecheck groups passed on the authorized Linux rig; unchanged inputs reuse that proof. Test fixture lint issues, a new-lease path mismatch, missing Playwright FFmpeg, and an overstrict negative-control report check were corrected; no test assertion or gate was waived. The parent-coverage repair passes all affected tests and the resumed changed gate. Independent Codex review is scoped-clean with no actionable P0–P2 findings; it covered presentation caching, serialization, compact-field preservation, and event reconciliation.

Limitations: filtered or unheld history membership and full/truncated Current Work windows retain authoritative refreshes. One changed row currently retires the whole shared presentation revision: the 20-client probe encoded 400 rows (200 rows × two sharing presentations), instead of traversing 4,000 rows at transport. Active subagent durations retain fresh samples instead of reusing an older runtime value. Handler timing is inconclusive because same-head rig runs varied materially; this PR does not claim a handler-latency improvement. Initial exact-head CI exposed five test jobs with outdated expectations: immutable title rows, cached sampling clocks, and compact dashboard query identities. The follow-up changes only five test files, preserves the behavior assertions, and has a clean independent review. Its staged changed gate passed on the authorized Linux rig, including all four affected test type graphs (agents-tools 91.1 s, UI-pages 115.8 s, UI-e2e 90.3 s, Gateway-methods 94.9 s), zero dead exports, and zero lint findings. Focused runtime proof passed on Blacksmith Testbox tbx_01m420s54azyt6vj9gttj1zw5v (openclaw-check): 55 tests covering title hydration, resident cache, privacy, serialization, dashboard unit/route behavior, and all four dashboard browser E2E cases. The command completed in 164.3 s. Two earlier leases were rejected by the workflow admission-age guard after queuing; the third hydrated and passed.

Remote pre-publication proof ran on base 4ed742a52184 plus the candidate; the final rebase onto 711e57e41b37 had zero overlapping files, an identical range-diff, and identical changed-file bytes. GitHub CI validates the rebased head. No live production Gateway or native application runtime was changed or tested. The optional compact mode leaves the default native full-row API unchanged.

Focused test cost

Measured with pnpm test <file> --maxWorkers=1 on Testbox. Gateway wall times include the compiled worker preparation; test execution itself was 1.56 s for the new serialization test and 1.47 s for event parity.

Test file Wall seconds Result
src/gateway/session-list-serialization.test.ts 22.19 2 passed
src/gateway/serialized-json.test.ts 2.07 4 passed
src/gateway/session-row-event-parity.test.ts 9.69 1 passed
src/gateway/server-methods/sessions-read-diagnostics.test.ts 25.17 15 passed
ui/src/lib/sessions/session-row-provenance.test.ts 1.36 19 passed
ui/src/pages/activity/current-work.test.ts 1.80 53 passed
ui/src/pages/activity/session-activity.test.ts 2.07 29 passed
ui/src/lib/sessions/session-roster-refresh.events.test.ts 2.54 28 passed
src/agents/tools/sessions-list-title.test.ts 29.21 2 passed
src/gateway/server-methods/sessions-read-cache.test.ts 39.84 26 passed
ui/src/pages/dashboards/dashboards-page.test.ts 3.20 4 passed
ui/src/pages/dashboards/route.test.ts 1.80 3 passed

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/activity-session-refresh.e2e.test.ts: 7 passed, 13.11 s including the bundled app setup. The added Current Work/history browser cases each take about 0.4–0.5 s and prove visible updates plus RPC counts at the browser boundary.

The existing dashboard E2E suite passed 4 cases in 43.56 s with the same E2E wrapper command and ui/src/e2e/dashboards-list-demand.e2e.test.ts. Its error/retry and per-tab demand assertions remain intact.

Current CI blockers inherited from main

The lane-caused title, cache, dashboard unit/route, and dashboard E2E failures are fixed and pass on the latest head. CI run 37161631895 tested merge 9b7a0e74a9f3 (head ef3ab2b3467d, base 4bcd6956b0a4) and exposed two separate main regressions:

  • check-dependencies: upstream 53eb4193d0ed renamed the Linux Node tests to test-runtime-boundary.mjs and test-stage-runtime.mjs, but config/knip.config.ts still lists their old names. The two new paths exist in the CI base and are absent from this lane head. The owner fix is to update those two executable-root entries.
  • checks-ui-e2e (5/6): upstream fix: show authoritative tool outcomes #163545 (8db9539ee84a) intentionally renders unfinished live tool cards as Running and updates the unit expectations. The unchanged chat-tool-item-outcomes.test-support.ts still expects Outcome unknown and zero running rows during its live stage. The failing assertion is exactly Running/one row; the history contract remains Outcome unknown/zero. The owner fix is to distinguish the live and history expectations.

Neither failing owner is modified by this PR. These failures are recorded, not waived or counted as green; their repairs belong on main, followed by a rebase if needed. No unrelated upstream fixes were copied into this lane.

@clawsweeper

clawsweeper Bot commented Oct 3, 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 app: web-ui App: web-ui gateway Gateway runtime size: XL labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 22:13
@steipete
steipete enabled auto-merge (squash) October 3, 2026 22:17
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 7:41 PM ET / 23:41 UTC (Revision 4).

ClawSweeper review

What this changes

This PR adds compact session-list responses, shares immutable row serialization, and applies session events directly to Activity views to reduce payload size and repeated roster reads.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: the optimization remains useful, but the previously reported compact-row reconciliation defect is still present on the pinned head.

Priority: P2
Reviewed head: ef3ab2b3467d6cb374a46eaa5bbffb7962bbb18e

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful performance work with substantial validation, but the confirmed metadata reconciliation defect still blocks merge.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts ordinary contributor proof. The body records synthetic Gateway list/serializer benchmarks and Activity controller/browser scenarios, with no live production capture claimed; the inspected screenshots concern a separate PR. This patch changes transient projections and wire responses, not stored-data contracts.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts ordinary contributor proof. The body records synthetic Gateway list/serializer benchmarks and Activity controller/browser scenarios, with no live production capture claimed; the inspected screenshots concern a separate PR. This patch changes transient projections and wire responses, not stored-data contracts.
Evidence reviewed 7 items Introduced compact-field preservation: Compact reads assign omitted detail fields revision zero. mergeRow compares each field independently, while row identity contains session identity rather than model identity; consequently a newer model can retain an older thinking profile and agentRuntime.
Observable Chat consequence: The roster projection merges held descriptor and list fields through the shared provenance owner. Chat's thinking resolver prefers session-provided thinking metadata over the selected model's catalog entry, exposing the old model's effort options after this merge.
Prior finding remains unchanged: The previous completed review identified this same defect. Comparing the earlier reviewed head with the current head produced no changes to the provenance owner; the added preservation regression covers unchanged model identity rather than a model transition.
Findings 1 actionable finding [P2] Invalidate preserved thinking metadata when compact rows change models
Security None None.

How this fits together

The Gateway projects stored session and runtime facts into authorized client rows. Control UI reconciles those rows with descriptors and events to drive session lists, Activity, and Chat settings.

flowchart TD
  A[Stored session facts] --> C[Gateway row projection]
  B[Runtime and viewer facts] --> C
  C --> D[Full or compact response]
  C --> E[Authorized session events]
  D --> F[Shared row reconciliation]
  E --> F
  F --> G[Activity and Chat settings]
Loading

Before merge

  • Invalidate preserved thinking metadata when compact rows change models (P2) - A held full descriptor for model A followed by a newer compact row for model B retains A's thinkingLevels, thinkingOptions, thinkingDefault, and agentRuntime: these omissions receive revision zero while the new model fields receive the current read receipt. The shared roster propagates that mixed row, and Chat prefers its session thinking profile over B's catalog entry. Make preservation identity-aware and prevent an older donor from restoring incompatible details. This repeats the prior blocker; the late-discovered logic is unchanged from the earlier reviewed head.
  • Resolve merge risk (P1) - A compact roster refresh can leave Chat using thinking and runtime metadata incompatible with the newly admitted model.
  • Complete next step (P2) - Make compact detail preservation identity-aware and add the held-descriptor model-transition regression before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P2] Invalidate preserved thinking metadata when compact rows change models — ui/src/lib/sessions/session-row-provenance.ts:187-189
Agent review details

Security

None.

PR surface

Source +581, Tests +1370, Docs +43. Total +1994 across 34 files.

View PR surface stats
Area Files Added Removed Net
Source 17 757 176 +581
Tests 15 1538 168 +1370
Docs 2 45 2 +43
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 34 2340 346 +1994

Review metrics

Metric Value Why it matters
Code growth production +581; tests and test support +1370 net lines The PR explicitly justifies production growth through full-row compatibility, recipient authorization, fresh runtime sampling, and overlapping-read continuity.
Protocol surface 1 optional list parameter: rowMode Compact responses are opt-in while omitted parameters retain the full native-client response contract.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/serialized-json.ts, unknown-data-model-change: src/gateway/serialized-json.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Make omission preservation identity-aware (recommended)
    Repair the shared field merge and add a held-descriptor regression proving that a compact model transition cannot retain or resurrect the previous thinking profile.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Make compact omission preservation model/runtime-identity-aware in the shared session row provenance owner. Preserve compatible details, invalidate incompatible thinking/runtime metadata, prevent older donors from restoring it, and cover the real roster-to-Chat model-change path.

Technical review

Best possible solution:

Preserve omitted details only while their owning model/runtime identity remains compatible, using the shared provenance owner to prevent incompatible metadata from returning through older donors.

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

Yes, from source: hold a full descriptor for model A, then admit a newer compact row for model B with the same session identity. The field receipts retain A's thinking metadata; no executable reproduction was run in this read-only review.

Is this the best way to solve the issue?

The optimization direction is reasonable, but the current patch is incomplete: independent field freshness must also respect the identity that owns model-specific details.

Full review comments:

  • [P2] Invalidate preserved thinking metadata when compact rows change models — ui/src/lib/sessions/session-row-provenance.ts:187-189
    A held full descriptor for model A followed by a newer compact row for model B retains A's thinkingLevels, thinkingOptions, thinkingDefault, and agentRuntime: these omissions receive revision zero while the new model fields receive the current read receipt. The shared roster propagates that mixed row, and Chat prefers its session thinking profile over B's catalog entry. Make preservation identity-aware and prevent an older donor from restoring incompatible details. This repeats the prior blocker; the late-discovered logic is unchanged from the earlier reviewed head.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded session-list performance improvement with a concrete Chat metadata regression rather than an urgent runtime outage.
  • merge-risk: 🚨 session-state: The introduced omission receipts can combine a new model identity with incompatible held session details.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied MEMBER classification exempts ordinary contributor proof. The body records synthetic Gateway list/serializer benchmarks and Activity controller/browser scenarios, with no live production capture claimed; the inspected screenshots concern a separate PR. This patch changes transient projections and wire responses, not stored-data contracts.

Evidence

Acceptance criteria:

  • [P1] pnpm test ui/src/lib/sessions/session-row-provenance.test.ts ui/src/pages/chat/chat-history-observation.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] git diff --check.

What I checked:

  • Introduced compact-field preservation: Compact reads assign omitted detail fields revision zero. mergeRow compares each field independently, while row identity contains session identity rather than model identity; consequently a newer model can retain an older thinking profile and agentRuntime. (ui/src/lib/sessions/session-row-provenance.ts:187, ef3ab2b3467d)
  • Observable Chat consequence: The roster projection merges held descriptor and list fields through the shared provenance owner. Chat's thinking resolver prefers session-provided thinking metadata over the selected model's catalog entry, exposing the old model's effort options after this merge. (ui/src/lib/chat/thinking.ts:47, ef3ab2b3467d)
  • Prior finding remains unchanged: The previous completed review identified this same defect. Comparing the earlier reviewed head with the current head produced no changes to the provenance owner; the added preservation regression covers unchanged model identity rather than a model transition. (ui/src/lib/sessions/session-row-provenance.ts:187, ef3ab2b3467d)
  • Current main still lacks the requested optimization: The fetched main revision does not contain the optional compact list parameter or the compact omission receipts. The related merged tool-outcome PR addresses separate behavior and does not supersede this work. (packages/gateway-protocol/src/schema/sessions-list.ts:6, db966d62ae0f)
  • Recipient authority remains independently checked: Shared presentations recompute viewer facts and use recipient-specific signatures; list selection applies current sharing filters, and the response callback asserts current mutation authorization. Embedded readers retain separate caller-bound receipts and revalidate them. No concrete introduced authorization bypass was found. (src/gateway/session-row-presentation.ts:265, ef3ab2b3467d)
  • Proof scope and author exemption: Repository State identifies the author as MEMBER, although the issue snapshot and live pull endpoint report CONTRIBUTOR. The supplied trusted-author classification is retained. The captured body describes synthetic production-owner benchmarks, controller replays, Testbox tests, and browser E2E validation, expressly excluding live production Gateway/native runtime proof. Inspected downloaded screenshots demonstrate the separate tool-outcome fix at fix: show authoritative tool outcomes #163545 and do not prove this optimization. No stored-data format changes were found. (ef3ab2b3467d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add a compact roster regression that changes models while a full descriptor is held and verifies Chat cannot retain or recover the previous thinking profile.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-03T22:19:37.992Z sha de68b82 :: blocked before merge. :: none
  • reviewed 2026-10-03T22:24:25.015Z sha de68b82 :: blocked before merge. :: none
  • reviewed 2026-10-03T23:31:02.172Z sha ef3ab2b :: blocked before merge. :: [P2] Invalidate preserved thinking metadata when compact rows change models

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 3, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@steipete
steipete merged commit f8a5f87 into main Oct 3, 2026
167 of 173 checks passed
@steipete
steipete deleted the steipete/perf-micro-sessions-list-payload-20260919 branch October 3, 2026 23:57
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…tead of refetching (openclaw#164573)

* perf(sessions): compact shared lists and apply row deltas

* test(sessions): align fixtures with shared compact rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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