Skip to content

perf(sessions): retain rows across unrelated config commits - #159155

Merged
steipete merged 5 commits into
mainfrom
steipete/perf-micro-config-commit-invalidates-whole-projection-20260919
Sep 26, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/perf-micro-config-commit-invalidates-whole-projection-20260919

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session lists rebuild the entire resident projection after unrelated config commits, such as sidebar preferences, and after unchanged database admission.

User Impact

Preference changes and unchanged store admission retain prepared session rows. Agent identity edits update displayed identities without rematerializing session data. Unrelated config commits also preserve the system-event store owner instead of repeatedly retiring subagent notifications.

Why This Change Was Made

The config publisher classifies neutral, identity-display, and row-affecting changes. Admission and registry owners publish topology changes; the existing projection reconciles physical store generations and refreshes new, replaced, removed, or related rows. Sharing and delivery custody still recognize these publications. Model, roster, session-policy, and sharing changes retain broad refresh behavior, as do same-object config publication and changed resolution provenance.

No new cache, config option, schema, persistence, or update behavior is introduced.

Evidence

Synthetic 8,000-row fixture, a 247-row list, and completion of pending materialization:

Event Dirty rows before → after Materializations before → after Elapsed before → after
Sidebar preference commit 8,000 → 0 8,000 → 0 958.9 → 21.7 ms
Unchanged agent database admission 8,000 → 0 8,000 → 0 912.0 → 34.4 ms

These are single fixture timings on Blacksmith Testbox (blacksmith-testbox, openclaw-check), not production latency claims. Baseline lease: tbx_01m3fj5vqc5j4822vt5hppac6c; candidate lease: tbx_01m3fk2c10pqh4yh519tvyd4aa.

  • Baseline regression failed with the expected 8,000 dirty/materialized rows per event. Neutral reloads also incorrectly retired the store owner twice.
  • Candidate benchmark passed: OPENCLAW_PROJECTION_BENCH_ROWS=8000 node scripts/run-vitest.mjs src/gateway/session-row-projection.config-commits.test.ts --maxWorkers=1. It also verifies selected archived identity refresh and unchanged re-admission without materialization. Neutral reload retirement callbacks fell from two to zero; real store/environment changes still retire ownership.
  • Final focused validation on tbx_01m3fn0vy85s5sk6rjb4x0t80h: 246 tests passed across 22 files. Coverage includes config classification/publication, admission and recovery, registration, deletion snapshots, projection/topology, archived rows, sharing and delivery custody, list handlers, and notification store ownership. Changed-file lint passed with node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed TypeScript files>.
  • On the candidate benchmark lease, node scripts/check-changed.mjs --base 8d8bd43120f3acd7e9e596e4d12774c442000703 passed production typechecking, all 25 core-test typecheck graphs, formatting, boundary/size guards, and dead-export scans. The full gate is not green: full-tree lint reports two pre-existing violations, requester-cron-authority.integration.test.ts (1,002/1,000 lines) and openclaw-state-worker-runtime.ts (705/700). Both files are unchanged from the pinned base. The new fixture's accumulating-spread lint finding was fixed and its final lint/test rerun passed. GitHub CI's changed-code lint and type checks subsequently passed.
  • Codex autoreview: no actionable P0–P2 findings. Production delta: +94 lines, with the superseded downstream classifier removed.

Individual changed-file costs (pnpm test <file> --maxWorkers=1, including transform/startup):

Test file Wall time
runtime-snapshot.test.ts 1.90 s
session-row-projection.config-commits.test.ts 26.24 s
server-reload-handlers.hot-reload-status.test.ts 21.98 s
openclaw-agent-db.registration-commit.test.ts 7.81 s
sessions-mutations.catalog-queue.test.ts 36.08 s
session-row-projection.recovery.test.ts (explicit infra config) 13.41 s
monitor-inbox.socket-lifecycle.test.ts (explicit extension-worker config) 28.29 s cold; 10.63 s warm sample
session-row-changes.test.ts 23.66 s cold
server.sessions.store-paths.projection.test.ts (explicit Gateway-server config) 19.70 s cold; 12.34 s warm sample

The new projection regression uses 16 rows by default and took 1.439 s of test execution; the 8,000-row measurement is opt-in. Cold transforms dominate the Gateway-file wall times. Recovery used node scripts/run-vitest.mjs --config test/vitest/vitest.infra.config.ts <file> --maxWorkers=1; it and two worker-owned siblings also passed together in 20.58 s. The existing mutation-queue suite retains its full ordering/authority coverage; its observer now recognizes the topology publication.

CI follow-up: the first run was cancelled after the WhatsApp socket-timeout fixture observed one remaining fake timer. Priming waited for callback entry while durable settlement and the read receipt continued afterward. The fixture now awaits its existing inbound-drained signal before switching clocks; socket/timer assertions, deadlines, and retry policy are unchanged. The original bundle and five diagnostic probes passed on tbx_01m3fphcfb6bjps7rx594tg5w1 (not proof of a fix); one probe observed an additional query timer after the clock switch. The repair passed independent review, extension lint, 20 full-file runs (22 tests each), and three replays of the original 14-file WhatsApp plan (146 tests each) on tbx_01m3fqdq7x651avp26zbkc8gkg, using the canonical extension-worker configuration and CI shard runner with two workers. Shard runtimes were 56.02, 54.65, and 54.94 seconds.

The second CI run passed the WhatsApp shard, then stopped on a redundant ElementHandle<Node> type argument in a UI test helper added to main after this branch began. The branch was rebased onto 8e77ea0b3e5c; range-diff confirmed both reviewed commits unchanged. The helper now uses the identical default ElementHandle type. On tbx_01m3fscppx545g55ddzswqfez5, its exact lint check and 56 config, sharing, list, and projection tests passed. The refreshed 8,000-row measurement remained 0 dirty rows / 0 materializations, at 20.1 ms for preferences and 39.3 ms for unchanged admission. The type-only repair also passed independent review.

The third CI run passed the repaired lint and WhatsApp lanes, then found one missed sibling expectation in session-row-changes.test.ts: the three committed registry events still expected the former broad stores scope. It now asserts the exact agent-scoped topology payload while retaining all transaction-ordering and rollback assertions. A repository-wide audit found no other stale observer expectations. On tbx_01m3ftvmh1ht0qn07j1y4vejxq, its lint and all 23 publication, registration, admission, and projection tests passed; independent review was clean.

The fourth run found a brittle whole-process filesystem parity check in the session path-preparation test: automatic mode made zero lstat calls while pinned mode made one, with zero state-directory probes and environment captures in both. The test now requires zero conventional state-directory probes in each of all six pinned/automatic × list/search cases, retaining exact results and zero environment captures. This catches both modes regressing together, which parity could miss, and removes unrelated global syscall comparisons. The original 24-file shard replay passed (not proof of repair). On tbx_01m3fwt097pfc66h5pkdhts3kj, the correction passed lint, independent review, 20 standalone runs, and three original 24-file shard replays with 310 tests each. No production code, timeout, retry policy, or baseline exception changed.

Testbox setup required one dependency installation per lease. Leases were replaced after file-sync timeouts; no tests ran in those failed sync attempts. A fixture initially tried to restamp immutable creation attribution; it now uses the owner-assignment API. No live Gateway was modified or benchmarked.

Final CI: run 36277690754 passed on 3dfcbe2e1d5855bc666eca6ba0c21fe4cdea8a46: 153 successful jobs, 19 skipped, including openclaw/ci-gate, in 852 seconds (14m12s). The PR check rollup showed 178 passing checks, 43 skipped, and no failures or pending checks. All task-owned Testbox leases were stopped.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 20:15
@clawsweeper

clawsweeper Bot commented Sep 26, 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.

@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 Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 6:59 PM ET / 22:59 UTC (Revision 5).

ClawSweeper review

What this changes

The branch classifies config changes and scopes database topology publications so Gateway session lists retain unaffected rows; it also updates reload handling, tests, and logging documentation.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still rebuilds session rows after broad config and store publications, while this PR has focused evidence of the improvement. I found no blocking defect introduced by the branch.

Priority: P2
Reviewed head: 3dfcbe2e1d5855bc666eca6ba0c21fe4cdea8a46

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level change has direct boundary measurements, relevant regression coverage, and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports an after-fix Testbox run through the production session projection and list function with SQLite-backed rows: preference commits and unchanged admission produced zero rematerializations, compared with 8,000 on the baseline. This proves the scoped performance behavior; it is a synthetic fixture rather than a live Gateway latency claim. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports an after-fix Testbox run through the production session projection and list function with SQLite-backed rows: preference commits and unchanged admission produced zero rematerializations, compared with 8,000 on the baseline. This proves the scoped performance behavior; it is a synthetic fixture rather than a live Gateway latency claim. No stored-data contract changes.
Evidence reviewed 11 items Current main still publishes broad config changes: The current runtime snapshot emits a broad config publication for every committed config snapshot.
Current main retains broad projection invalidation: Current main treats config and store publications as broad projection changes; the branch's classification and scoped topology handling are absent.
Introduced classification: The introduced classifier preserves broad refresh for same-object publication, changed resolution provenance, and row-affecting config, while identifying presentation-only and agent-identity changes.
Findings None None.
Security None None.

How this fits together

The Gateway builds session-list rows from runtime configuration and admitted SQLite stores. Committed changes tell that projection which facts to refresh before it serves lists and session events.

flowchart LR
  A[Config commits] --> C[Change classification]
  B[Database admission] --> D[Topology publication]
  C --> E[Session row projection]
  D --> E
  E --> F[Refresh affected facts]
  F --> G[Session lists and events]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +94, Tests +198, Docs +3. Total +295 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 15 151 57 +94
Tests 10 230 32 +198
Docs 2 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 386 91 +295

Review metrics

Metric Value Why it matters
Fixture materializations 8,000 to 0 for each of 2 events The reported Testbox fixture directly measures the intended reduction in projection work.
Production and test delta production +94 lines, tests +198 lines The production growth implements publication classification and scoped reconciliation without adding a second cache.

Technical review

Best possible solution:

Keep config classification with its publisher and physical-store reconciliation with the existing projection, preserving broad refresh for changes that affect session facts.

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

Yes. Current main emits broad config changes and invalidates resident rows; the PR supplies a before/after Testbox fixture that measures the affected list path.

Is this the best way to solve the issue?

Yes. The branch classifies changes at the config publisher and lets the existing projection reconcile store generations, avoiding a competing cache or configuration setting.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1e7ec6a4f6b4.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded session-list performance improvement with measured fixture benefit and no demonstrated urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports an after-fix Testbox run through the production session projection and list function with SQLite-backed rows: preference commits and unchanged admission produced zero rematerializations, compared with 8,000 on the baseline. This proves the scoped performance behavior; it is a synthetic fixture rather than a live Gateway latency claim. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports an after-fix Testbox run through the production session projection and list function with SQLite-backed rows: preference commits and unchanged admission produced zero rematerializations, compared with 8,000 on the baseline. This proves the scoped performance behavior; it is a synthetic fixture rather than a live Gateway latency claim. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Galin Iliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-26T20:22:42.642Z sha 634e3c3 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T21:06:14.212Z sha db8358b42aacb6f63a8b50396e4de5cde1e045e2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T21:33:03.842Z sha 7f77535 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T21:58:20.473Z sha 6ac5b0d :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the channel: whatsapp-web Channel integration: whatsapp-web label Sep 26, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 26, 2026
Classify committed config changes at publication and reuse profile presentation for agent identity edits. Reconcile store topology through existing physical generations without invalidating unchanged rows, and retain notification store ownership across neutral reloads.
The priming callback can precede durable settlement and read receipt completion. Wait for the existing inbound drain before enabling fake timers so unrelated cleanup cannot enter the socket timeout timer assertions.
@steipete
steipete force-pushed the steipete/perf-micro-config-commit-invalidates-whole-projection-20260919 branch from db8358b to 7f77535 Compare September 26, 2026 21:25
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 26, 2026
@steipete
steipete enabled auto-merge (squash) September 26, 2026 21:52
Require zero conventional state-directory probes for every pinned and automatic list/search case. Process-wide syscall parity includes independent file work and can fail when automatic mode performs fewer calls.
@steipete
steipete merged commit 945ec9f into main Sep 26, 2026
226 of 228 checks passed
@steipete
steipete deleted the steipete/perf-micro-config-commit-invalidates-whole-projection-20260919 branch September 26, 2026 23:07
steipete added a commit that referenced this pull request Sep 26, 2026
Include runtime-session-changes.ts, imported by the already-extracted
runtime-snapshot.ts since 945ec9f (#159155). Its runtime dependencies
are already in the inventory. This restores trusted-anchor extraction and
native PR source provisioning without expanding the wrapper entry points.

Reproduced both closure failures and three macOS provisioning failures
before the fix. Replayed the exact failing CI shard selections through
ci-run-node-test-shard: 32 passed, one Linux-only case skipped on macOS.
The code-mode Gateway evidence file passed all five tests; its logged
harness_error is an intentional synthetic failure, not a broken test.

Validation: check:import-cycles (zero cycles), scripts typecheck,
changed-file guards and lint/format checks, and autoreview clean through P2.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…#159155)

* perf(sessions): retain rows across unrelated config commits

Classify committed config changes at publication and reuse profile presentation for agent identity edits. Reconcile store topology through existing physical generations without invalidating unchanged rows, and retain notification store ownership across neutral reloads.

* test(whatsapp): drain inbound work before switching timeout clocks

The priming callback can precede durable settlement and read receipt completion. Wait for the existing inbound drain before enabling fake timers so unrelated cleanup cannot enter the socket timeout timer assertions.

* test(ui): omit the default widget handle type argument

* test(sessions): expect scoped registry topology publications

* test(gateway): scope session path probes to state discovery

Require zero conventional state-directory probes for every pinned and automatic list/search case. Process-wide syscall parity includes independent file work and can fail when automatic mode performs fewer calls.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Include runtime-session-changes.ts, imported by the already-extracted
runtime-snapshot.ts since 6cdfaec (openclaw#159155). Its runtime dependencies
are already in the inventory. This restores trusted-anchor extraction and
native PR source provisioning without expanding the wrapper entry points.

Reproduced both closure failures and three macOS provisioning failures
before the fix. Replayed the exact failing CI shard selections through
ci-run-node-test-shard: 32 passed, one Linux-only case skipped on macOS.
The code-mode Gateway evidence file passed all five tests; its logged
harness_error is an intentional synthetic failure, not a broken test.

Validation: check:import-cycles (zero cycles), scripts typecheck,
changed-file guards and lint/format checks, and autoreview clean through P2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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