Skip to content

perf(chat): reuse unchanged startup command catalogs - #175674

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-startup-commands-catalog-20260919
Oct 17, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-startup-commands-catalog-20260919

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Warm chat reloads retransmit the entire slash-command catalog even when transcript, pending-input, and session metadata receipts already match.

User Impact

Warm reloads retain their slash-command picker without downloading an unchanged catalog. Cold clients, missing cached commands, and changed catalogs receive the full list. Boot sequencing and command execution are unchanged.

Why This Change Was Made

Reuse the existing prepared command owner's content revision in stateRevision.commands, including its existing config/plugin/skill invalidation. Keep startup metadata revisionless: command receipts do not govern the lifetime of session worker policy. Retain commands beside the existing account-scoped chat snapshot and reconstruct receipt-matched omissions before publishing through the shared metadata store. The picker consumes that store without an additional commands.list read. No new cache owner, configuration option, database schema migration, or timer.

Evidence

A synthetic 150-command skill/plugin catalog and 820-message history reproduce the defect through the production chat.startup handler. The regression fails on the original handler because all 150 commands are retransmitted; the patched handler omits them and delivers replacements after a skill generation changes.

Four concurrent paired serialization replays of those captured handler responses ran on the Linux measurement host under the exclusive sandbox lock, swapping CPU halves 96–111 and 112–127 each pair. Every pair: 57,888 B → 517 B, paired difference −57,371 B (99.1% smaller). Start skew was at most 1 ms. CPU busy context across the measured halves was 1.03%, 11.15%, 12.46%, and 9.24%; dirty pages stayed under 14 MB. These are response-byte measurements, not end-to-end reload latency measurements. The sandbox was removed afterward.

Focused UI proof covers retained/changed/empty command catalogs, replacement sessions, a newer sibling cache arriving during a request, missing retained commands, and command parsing after picker refresh without commands.list. IndexedDB round-trip preserves the catalog and revision, including the existing privacy projection.

Production source delta is +28 authored lines plus +160 generated validator lines. The new wire receipt and retained payload require that growth; the existing revision owner and snapshot lifecycle are reused. No speculative cache, duplicate recomputation, or parallel execution path was added.

Focused checks: 49 Gateway handler/runtime/worker-policy tests pass (36.42 s combined file wall time); 71 UI metadata-store, worker-policy, and IndexedDB tests pass (2.63 s); 27 warm-startup tests pass (2.89 s); the focused Gateway integration case passes (15.54 s). Earlier unchanged-input proof also covers 18 picker tests and 12 native-session metadata tests. Total focused proof: 178 passing tests. Changed-file formatting, syntax lint, and git diff --check pass. PR CI owns broad validation, including typecheck and type-aware lint.

CI found a hand-built prepared-metadata fixture missing its required revision; the fixture is corrected. ClawSweeper then identified a real interaction: publishing a command revision in shared startup metadata could retain stale required-worker policy on an unchanged compact refresh. The new regression connects the real Gateway metadata runtime to the real UI metadata store, reproduces the stale profile before the fix, and passes after moving the command receipt outside shared metadata. This preserves the deliberate revisionless-startup behavior from #175317, including its original Gateway integration assertion. Raw pre-command-receipt IndexedDB snapshots also restore unchanged; this is additive optional cache data, with no database version or schema migration. A full application upgrade was not run.

Independent autoreview is clean through P2, including the worker-policy correction and legacy-snapshot proof. Release-note context: warm chat reloads no longer retransmit unchanged slash-command catalogs, while changed skill/plugin/config catalogs still refresh.

This is a transport/persistence change with no visual changes. Broad gates run in PR CI; no Testbox lease was used.

Inherited CI failures

Final-head CI run 39050396537 tests merge 92ae8141c9dfb42bc1c03a9d31f905a67c224176, whose parents are baseline 62cb03ac7a95f4b9cb435f8efc57f4034ba2649b and PR head daad82c9ccc5f80bbfe42e3364a5af85d368b0b4. Three jobs report defects in tests added by the baseline's snapshot-admission change:

  • check-lint-core-2 (job): the new temporary-open-failure test declares writer inside the suite's existing writer scope. Focused eslint/no-shadow on the unchanged baseline file reproduces this error at line 626.
  • checks-ui (1/3) (job): the new missing-store test raises ReferenceError: CHAT_SNAPSHOT_DB_NAME is not defined. Running only that test from the unchanged baseline file reproduces the same failure at line 639 (2.27 s file wall time). CI's other 7,064 tests in this shard pass.
  • check-test-types-core-3 (job): the same baseline test uses CHAT_SNAPSHOT_DB_NAME, CHAT_SNAPSHOT_METADATA_STORE_NAME, and SIDEBAR_SNAPSHOT_STORE_NAME despite importing them as DB, METADATA, and SIDEBAR.

The failing test bodies are unchanged by this PR. Baseline reproduction used a temporary sibling copy of the exact baseline test file; the copy was removed afterward. The automated table labels these failures new relative to older scheduled-main run 39045247512; it did not compare scope or the newer exact main parent. The direct baseline reproductions above establish attribution. All other CI jobs completed successfully or were intentionally skipped. No CI reruns or branch updates were requested to chase green. Landing uses the authorized inherited-failure exception.

Reuse the prepared command revision and retain receipt-matched catalogs in warm chat snapshots. Keep cold loads, catalog invalidation, and slash-command picker behavior intact without changing boot sequencing.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 17, 2026 16:13
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: M labels Oct 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-17T16:43:21.989058Z daad82c 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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. P2 Normal backlog priority with limited blast radius. 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. 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 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR retains slash-command catalogs in chat snapshots and omits unchanged catalogs from warm startup responses.

Example: Reload a conversation with the same 150-command catalog.

  • Before: The reported handler response retransmits the catalog in a 57,888-byte response.
  • After: The reported receipt-matched response preserves the picker while shrinking to 517 bytes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation resolves the earlier defect and has meaningful boundary coverage, with confidence limited by harness-level behavioral evidence.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; supplied evidence exercises the production handler and UI owners in process, with serialization measurements rather than a demonstrated shipped reload.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Warm chat reloads download an unchanged command catalog.
Reason: The maintainer-authored direction reduces redundant transfer using existing owners without introducing configuration or another execution path.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful startup optimization and resolves the prior worker-policy finding; no actionable introduced defect was confirmed.

Priority: P2
Reviewed head: daad82c9ccc5f80bbfe42e3364a5af85d368b0b4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate a shipped browser-to-Gateway warm reload retaining commands and receiving a changed catalog.
Agent review details

How this fits together

The Gateway prepares agent command catalogs, chat.startup returns their receipts, and the Control UI reconstructs omitted catalogs from account-scoped transcript snapshots before publishing metadata.

flowchart LR
  A[Prepared command owner] --> B[Chat startup handler]
  C[Retained chat snapshot] --> D[Startup request receipts]
  D --> B
  B --> E[Response reconstruction]
  C --> E
  E --> F[Shared metadata store]
  F --> G[Slash command picker]
Loading

Technical review

Best possible solution:

Retain the existing command revision and snapshot owners while keeping session worker policy independently refreshed.

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

Current-main source retransmits startup commands despite matching other receipts, and the supplied handler regression exercises that path; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Reusing the prepared content revision and reconstructing omissions against the request's captured payload is a focused solution that preserves invalidation and worker-policy lifetimes.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Prepared command revision keeps the original intent (92fca0f: Reuse unchanged agent-owned command metadata while authoritative config, plugin, skill, and catalog changes retain invalidation.)
  • Revisionless startup worker policy keeps the original intent (efedca4: Remove duplicate picker metadata without giving session worker policy a command-catalog lifetime.)
  • Warm snapshot receipt reconstruction keeps the original intent (b89bc0e: Retain exact authorized payloads and reconstruct receipt-matched omissions while continuing current-state reads and authorization.)
  • History module boundaries keeps the original intent (701da05: Split oversized history modules while preserving request fencing, hydration, and snapshot ownership.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 92fca0f adds src/gateway/server-methods/chat-metadata-runtime.ts:276 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 92fca0f5bfef; files: src/gateway/server-methods/chat-metadata-runtime.ts)

PR surface

Source +186, Tests +158, Docs +4, Other +2. Total +350 across 20 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 11 206 20 +186
Tests 6 168 10 +158
Docs 2 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 20 380 30 +350

Labels

Label changes:

  • 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.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Reduces redundant warm-startup transfer while preserving existing chat behavior; no urgent user-facing failure is established.
  • 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.

  • Optionally capture a shipped warm reload showing retained picker commands, an omitted unchanged catalog, and refreshed commands after a skill change.

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-17T16:26:29.701Z sha b996977 :: blocked before merge. :: [P2] Keep command revisions from retaining stale worker policy

Reviewed October 17, 2026, 12:54 PM ET / 16:54 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 17, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Fixed the worker-policy finding in daad82c. The prepared command revision now travels separately as commandsRevision and is exposed only through stateRevision.commands; shared startup metadata remains revisionless, preserving #175317's original intent and integration assertion.

The added regression connects the real Gateway metadata runtime to the UI metadata store. It reproduced retention of the old required-worker profile before the fix and passes afterward. A raw IndexedDB snapshot from before command receipts also restores unchanged. The optional cache fields require no schema/version migration; a full application upgrade was not run.

Independent review is clean through P2. Final paired byte measurements are 57,888 → 517 B (−57,371 B, 99.1%); updated proof is in the PR body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: daad82c9cc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +196 to +198
commands: response.metadata
? response.metadata.commands
: previousHistoryState?.commands,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep large command catalogs from evicting transcript snapshots

When a valid command catalog exceeds the 12 MiB per-snapshot limit, retaining it inside every ChatSessionSnapshot makes boundChatSessionSnapshot() exhaust all messages and return null, after which cacheChatSessionSnapshot() deletes the entire memory and IndexedDB entry. This is reachable within the command schema limits—for example, command arguments may each contain up to 50 choices with 200-character values and labels—and such a catalog can still fit within the 25 MiB Gateway frame limit. Before this change the same transcript remained available for warm/offline loading, so the catalog should be stored separately, deduplicated, or omitted when it cannot fit rather than evicting the transcript.

Useful? React with 👍 / 👎.

@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete
steipete merged commit 8f255dc into main Oct 17, 2026
153 of 158 checks passed
@steipete
steipete deleted the steipete/perf-micro-startup-commands-catalog-20260919 branch October 17, 2026 16:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged as 8f255dc using the authorized inherited-failure exception on exact head daad82c.

CI run 39050396537 completed. Its only root failures were check-lint-core-2, check-test-types-core-3, and checks-ui (1/3): the baseline's new snapshot-admission tests shadow writer and reference database constants imported under aliases. The exact CI main parent 62cb03a reproduces the lint and missing-name runtime failures; job links and evidence are in the PR body. All other jobs in that CI run passed or were skipped. The native merge command stopped before submission because this lane has no native PR-review worktree, so the operator-authorized exact-head API fallback was used.

Independent autoreview and final ClawSweeper review have no actionable findings. The earlier worker-policy finding is fixed and covered by a failing-before/passing-after production-owner regression. The 150-command fixture measures 57,888 → 517 B across four concurrent swapped-core pairs. This is response-byte proof, not end-to-end reload latency. Focused proof totals 178 passing tests, including legacy IndexedDB restoration; no full application upgrade was run.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
* perf(chat): reuse unchanged startup command catalogs

Reuse the prepared command revision and retain receipt-matched catalogs in warm chat snapshots. Keep cold loads, catalog invalidation, and slash-command picker behavior intact without changing boot sequencing.

* test(chat): expect the startup command revision

* test(chat): include command revision in prepared metadata fixture

* fix(chat): keep command receipts separate from worker policy
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 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: 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