Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Phase A dev-box A/B — measurement detailRun log and probe tables from the live-gateway measurement referenced in the PR body, plus the heap census and bucket aggregates derived from the snapshots with Redaction note: this ran on a private deployment. Deployment identifiers (instance id, channel id, host paths) and every string preview have been removed — the previews list customer names, internal workspace documents and private skill bodies. Only counts, sizes and shapes are reproduced. Snapshots themselves are not attached (50–137 MB gzipped each). Phase A dev-box A/B — 2026-09-15 (UTC times), dev box (identifier redacted)Build under test: v2026.8.2 + intern (b5fd1b8851) + Phase A (23199840cd, cf025d1a40, 7a6ca30949) + temporary parse probe. LoadSame 18 sends as the earlier runs (10 @mentions in new threads + 8 thread follow-ups), the test channel, 18:18:34 -> 18:25:31. Probe (parseSessionEntryJson counts; "with prompt" = a 17.5 KB skills catalog was materialized)Window = baseline dump 18:17:05 -> pre-snapshot dump 18:30:13 (13 min, 11 runs + idle).
Per-message, net of idle: prompt parses ~31.5k -> ~4.9k (-84%); JSON parsed ~690 MB -> ~84 MB (-88%). Startup finding (new)Right after start the process froze ~100 s (host timing gap 18:09:20->18:11:04, Slack socket errored, memory-pressure warning Remaining prompt-less cost~240k parses in the window came from sites below the top 8: hasStale metadata scans (2 x ~490 stale rows per write) and Regression guardAll 11 session rows written during the test still carry skillsSnapshot.prompt (17.5 KB) and systemPromptReport after drain. Heap census (analyze-heap2.mjs, strings >= 2000 B)Same 18-send protocol, same box, snapshot after drain. Earlier columns from the previous session's runs (list-only, +intern).
Baseline (Phase A, 9 min uptime, 1 message — not a fresh-process point like the earlier 23 s baselines): Caveats: 11 processed runs here vs 15 logged in the earlier runs; sends were paced 7 min instead of 16; another user's 7.6 KB Files: heap snapshots and census output retained locally; not attached (50-137 MB gzipped each). Where the remaining 150 MB of strings comes from (analyze-heap-buckets.mjs, all string nodes)
Before Phase A the small-string bucket was parsed-entry debris (17,306 copies of each skill NAME, 22,685 copies of one sha256 hash = What is left and still grows: ~2.7 MB per run of small retained records. After 12 runs: 23,400 x one channel-id string (p0: 7,253), Heap census aggregates — baseline (before load) vs after the 18-send loadString bucket breakdown after load |
|
Codex review: blocked before merge. Reviewed October 5, 2026, 8:25 PM ET / October 6, 2026, 00:25 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch makes metadata-only session scans avoid decoding saved prompts, reuses listed rows for ACP resume checks, and exposes an optional lightweight listing projection to plugins. Merge readiness⛔ Blocked before merge - 5 items remain Useful work remains beyond current main’s related optimizations. The prior SDK compatibility decision is still unresolved, and the pinned branch has merge conflicts; neither warrants closing this contribution. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s session store supplies identity, ownership, lifecycle, and saved prompt data to agent execution and plugins. Lightweight listings let metadata consumers read session facts without allocating each session’s saved prompt payload. flowchart TD
A[Agent and plugin requests] --> B[Session read owner]
C[Stored session rows] --> B
B --> D{Requested projection}
D --> E[Complete session entries]
D --> F[Lightweight metadata entries]
F --> G[Identity and ownership matching]
E --> H[Prompt consumers and complete writes]
Decision needed
Why: The existing snapshot path supports metadata-only results, but the released direct fallback returns complete entries; contributor documentation alone cannot authorize that compatibility change. Before merge
Agent review detailsSecurityNone. PR surfaceSource +44, Tests +207, Docs +4. Total +255 across 18 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep lightweight reads at metadata-only consumers, preserve current worker and indexed owners, and retain the shipped catalog fallback unless the SDK owner explicitly approves changing its result contract. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the path: current-main legacy-marker and BTW scans use complete listings for metadata matching, causing saved prompt decoding to scale with store size. No target code was executed during this read-only review. Is this the best way to solve the issue? Yes for internal metadata consumers using the existing projection; the public catalog fallback change needs a separate compatibility decision, and obsolete scans should yield to current main’s newer owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c1005a2ee593. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
…ist projection Whole-store session listings default to the "full" projection, which parses every row's skillsSnapshot (the skills-catalog prompt, 17-35 KB) and systemPromptReport on every call and bypasses the entry cache. Most of these listings only read identity, timestamp or ownership fields. Flip the twelve remaining metadata-only whole-store reads to projection: "list": the legacy-marker resolve in run-session-target, the five marker matchers (btw-transcript, compaction-successor, session-bootstrap, attempt-session-identity, trajectory export), the sibling-subagent scan in attempt-history-prepare, the ACP resume-ownership scan, both plugin session-ownership assertions, the session-catalog fallback listing, and resolveMemorySessionTargets. Each site was audited for downstream reads of the two large fields, whole-entry write-back, whole-entry equality fences, and entries crossing a plugin, RPC or CLI boundary. The session-catalog fallback now matches its own precomputed path, which already lists at "list" in session-catalog-entry-snapshot. Add an optional projection to the plugin runtime listSessionEntries params and forward it when defined. The wrapper default stays "full" on purpose: SDK consumers that read a listed entry and write it back whole would otherwise drop the two fields. Co-Authored-By: Claude Opus 5 <[email protected]>
…-reading each key validateAcpResumeSessionOwnership scans the whole session store and called readAcpSessionMeta for every key, which decoded one complete entry — including the saved skills-catalog prompt — per stored session. That per-row read, not the listing, dominated the scan, so projecting the listing alone changed nothing measurable. Pass the already-listed row to readAcpSessionMetaForEntry. Its binding input is lifecycleRevision/sessionId/sessionStartedAt, all of which the list projection retains, so the resolved ACP metadata and the ownership decision are unchanged. Measured over a 200-row store with 17.6 KB saved prompts: 200 prompt-bearing JSON parses (3.5 MB) before, 0 after. Co-Authored-By: Claude Opus 5 <[email protected]>
…tadata contract Document the optional projection on the plugin runtime listSessionEntries: the default stays "full", "list" omits the saved skillsSnapshot and systemPromptReport payloads, and a listed entry must never be written back. State that listSessionCatalogEntries returns metadata-only entries on both of its paths. The Gateway-supplied entry snapshot already listed at the metadata projection, so its fallback branch now matches rather than returning a different shape for the same helper. Consumers needing a saved prompt read that one session with a keyed getSessionEntry. Cover the guarantee with a test asserting both paths omit the two payload fields while retaining the identity, harness, ownership and pluginExtensions fields catalog adoption actually reads. Co-Authored-By: Claude Opus 5 <[email protected]>
…prompt parsing Both whole-store scans now assert zero prompt-bearing JSON parses, so a regression to the full projection — or a return to the per-key ACP metadata read — fails here instead of only showing up as heap growth on a large store. Co-Authored-By: Claude Opus 5 <[email protected]>
…solution The agent id is part of the ACP database key, so deriving it from the target agent changed which row an unscoped session key resolved to. Resolve each listed key through resolveSessionStorePathForAcp, the same owner resolution the keyed read performs, and pass its canonical store key and agent id to readAcpSessionMetaForEntry. Only the redundant per-key entry decode is removed; the resolved ACP row and the ownership decision are unchanged. Also drop a cast in the catalog contract test and assert on the typed entry. Co-Authored-By: Claude Opus 5 <[email protected]>
37df656 to
1f26c1a
Compare
|
Thanks — worked through all five items. Four new commits. 1 & 3 — catalog compatibility (P2)Took the recommended option: accept the metadata-only fallback and document it. The guarantee is now stated in three places:
The argument for accepting rather than reverting: the Gateway-supplied The maintainer decision is still yours — option 2 (drop only the 2 — incremental proof on current main (P1)Fair criticism: the live-box numbers cover the combined Phase A build. Measured this diff alone against current
One decode per stored row per call, so it scales with store size, not with the work being done. Those three sites are now covered by zero-parse assertions in The measurement found a real defect
Fixed by passing the already-listed row to 5 — data-model compatibility proofThis looks like a false positive on CI
Local on the rebased tree: |
…ll assertion The side-question marker resolve now lists at projection: "list"; its exact call-argument assertion still expected the unprojected arguments. Co-Authored-By: Claude Opus 5 <[email protected]>
|
CI update on the rebased head ( One genuine break was mine and is fixed: The remaining red is I deliberately did not fix it here. It is |
) Avoid saved-prompt decoding in metadata-only trajectory, memory-target, and catalog listings using the existing list projection. Reuse listed trajectory rows instead of two additional keyed reads, preserving canonical keys and the full runtime listing default. Supersedes #149358, thanks @DakshK-02. Evidence: saved-prompt decode regressions red on main and green after the fix; 87 distinct focused tests pass; touched-file lint and format pass; final committed-range Codex autoreview P0-P2 has no actionable findings. Production LOC net zero. Exact-head PR CI retains the inherited 443-line test-ceiling failure, reproduced on clean main in Crabbox; the change's 70 new test lines have matching allocation credit. Native attributed-failure admission preserves that failed result and enforces the other gates. Co-authored-by: DakshK-02 <[email protected]>
|
Thanks @DakshK-02! The remaining metadata-only session reads are now fixed in merged #191677, building on the projection work already on main. It also removes the redundant trajectory reads and includes red/green prompt-decoding tests. Your contribution is credited in the merge. |
…claw#191677) Avoid saved-prompt decoding in metadata-only trajectory, memory-target, and catalog listings using the existing list projection. Reuse listed trajectory rows instead of two additional keyed reads, preserving canonical keys and the full runtime listing default. Supersedes openclaw#149358, thanks @DakshK-02. Evidence: saved-prompt decode regressions red on main and green after the fix; 87 distinct focused tests pass; touched-file lint and format pass; final committed-range Codex autoreview P0-P2 has no actionable findings. Production LOC net zero. Exact-head PR CI retains the inherited 443-line test-ceiling failure, reproduced on clean main in Crabbox; the change's 70 new test lines have matching allocation credit. Native attributed-failure admission preserves that failed result and enforces the other gates. Co-authored-by: DakshK-02 <[email protected]>
What Problem This Solves
Fixes: a gateway with a large session store burns memory and CPU re-parsing every stored session's saved skills-catalog prompt when a whole-store listing only needs identity or ownership fields. On a Slack gateway with ~600 stored sessions this materialized the 17–35 KB catalog string tens of thousands of times per inbound message and kept thousands of copies live in the heap.
User Impact
User impact: operators running a gateway with a large session store see lower heap and far less per-message JSON parsing; no behavior, config, or API change. The plugin runtime gains one optional, default-unchanged
projectionparameter onlistSessionEntries.Why This Change Was Made
Whole-store session listings default to the
"full"projection, which parses every row'sskillsSnapshotandsystemPromptReportand bypasses the entry cache (readSessionEntryCachereturnsloadSessionEntrySnapshotfor"full"). Main has already moved most of this surface to"list"(62 call sites today), plus the metadata-only maintenance candidate scans and the keyed reply-init reads. This PR finishes the remaining metadata-only whole-store reads.Twelve whole-store reads now pass
projection: "list". Each site was re-audited on currentmainagainst four checks before flipping: no downstream read of the two large fields, no whole-entry write-back sourced from the listing, no whole-entry equality fence (sqliteSessionEntriesEqual/expectedEntry), and no entry crossing a plugin/RPC/CLI boundary that can observe the payload.run-session-target.tslegacy-marker resolvesessionId,updatedAt,sessionKeybtw-transcript.tsmarker matchersessionId+resolvePreferredSessionKeyForSessionIdMatches(updatedAt/key only)compaction-successor.tsmarker matcherrun/session-bootstrap.tsmarker matcherrun/attempt-session-identity.tsmarker matcherrun/attempt-history-prepare.tssibling subagentsspawnedBy,sessionId,subagentRole,statusacp-spawn-requester.tsresume-ownership scanspawnedBy,parentSessionKey(viasessionEntryIsOwnedByRequester)trajectory/export.tsmarker matchersessionId+ preferred-key helperregistry-runtime-session-ownership.ts×2sessionId,agentHarnessId,pluginOwnerId(viaassertLockedSessionEntryOwned)session-catalog.tsfallback listingsessionId,initializationPending,agentHarnessId,modelSelectionLocked,pluginExtensions,pluginOwnerIdmemory-core-host-engine-sessions.tsresolveMemorySessionTargetssessionId,sessionKey,sourceMetadata(hook source / channel / accountId / chatType / createdAt)One call site needed more than a flag.
validateAcpResumeSessionOwnershipcalledreadAcpSessionMetafor every key it scanned, decoding one complete stored entry — saved catalog prompt included — per session in the store, only to readlifecycleRevision/sessionId/sessionStartedAt. The listing was never the dominant cost there, so projecting it alone changed nothing measurable. It now resolves each key throughresolveSessionStorePathForAcp(the same owner resolution the keyed read performs, including its retired/conflicting-owner rejections) and passes the already-listed row toreadAcpSessionMetaForEntry. Only the redundant entry decode is removed; the resolved ACP row and the ownership decision are unchanged.The session-catalog fallback listing is now consistent with its own precomputed path:
session-catalog-entry-snapshot.tsalready buildsentriesForAgentatprojection: "list", so both branches oflistSessionCatalogEntriesreturn the same shape.The plugin runtime
listSessionEntriesgains an optionalprojection(types-core.ts, forwarded inruntime-agent.tsonly when defined). The wrapper default stays"full"deliberately, because SDK consumers such as theextensions/zalouserdoctor contract read a listed entry and thenupsertSessionEntry(entry), which would drop the two fields on a list-projected row. Projection is chosen per call site, never at the wrapper.Sites deliberately left at
"full": the lifecycle store read, the maintenance full pass, agent-command session resolve, usagecontextWeight(readssystemPromptReport), the plugin-SDK transcript hit, the zalouser doctor path, and the purge/rename equality fences. Each fails at least one of the four checks.Evidence
Incremental effect of this diff on current
mainCounted prompt-bearing
JSON.parseresults, and the bytes handed to them, per invocation of each changed entry point against a 200-row store with 17.6 KB saved prompts —main(eee60cd68f) versus this branch, same process and harness:mainresolveAgentRunSessionTarget(legacy marker)validateAcpResumeSessionOwnershipresolveMemorySessionTargetsOne decode per stored row per call, so the cost scales with store size rather than with the work being done. All three sites carry zero-parse assertions in
session-store-listing-projection.test.ts, so these are reproducible from the suite.Live gateway, combined Phase A build
Measured on a live Slack gateway (~600 stored sessions, avg prompt 17.5 KB, 488 stale rows),
v2026.8.2+ the complete Phase A change set, same 18-send protocol across builds, heap snapshot taken after the load drained.Parse probe (temporary instrumentation in
parseSessionEntryJson, not part of this PR), per inbound message net of idle: prompt-bearing parses ~31.5k → ~4.9k (−84%), JSON bytes parsed ~690 MB → ~84 MB (−88%), idle whole-store loads −70%, stale-candidate scan prompt bytes ~1.1 GB → 0.Write-back guard: every session row written during the test still carried
skillsSnapshot.promptandsystemPromptReportafter the run drained (11/11 rows written; 618 rows total, 615 with prompt, 604 with report). Slack stayed connected; 11/11 replies delivered.Composition of the remaining 150 MB: 67.7 MB module source text (static), 43.8 MB small strings, 16.5 MB SKILL.md bodies held ×12 at startup, 12.2 MB injected docs held once per run — none of it the catalog string. Those are separate retention paths, untouched here.
The full run log, probe tables and heap census/bucket output are posted as a comment on this PR.
Review. Three independent reviewers traced all 30 sites of the original change set (fields read, write-back, equality fence, contract boundary, cache freshness, borrowed-row mutation) and returned 30/30 list-safe. For this PR every surviving site was re-traced from scratch on current
main, becausemainhad rewritten several of the files:attempt-history.ts→attempt-history-prepare.ts,run-session-target.tsgained a newcandidateMarkerEntryread (sessionIdonly), and the plugin-catalog consumers inextensions/codexandextensions/anthropicwere re-checked for reads of the two large fields (none found).Tests. New
src/config/sessions/session-store-listing-projection.test.tscounts prompt-bearingJSON.parseresults and asserts: they are independent of store size for the legacy-marker resolve; transcript-instance listings return no prompt at"list"while"full"still does; and the ACP resume-ownership scan andresolveMemorySessionTargetsparse zero prompts. The one-time canonical-key validation scan is warmed first so the assertions measure the listing itself, the way a long-lived gateway process experiences it.session-catalog.test.tsgains a contract test that both catalog paths omit the two payload fields while retaining the fields adoption and ownership matching read, and its call-argument expectation is updated.Checks run
pnpm tsgo— clean.pnpm check:changed— all lanes pass excepttypecheck extensions, which fails identically on cleanorigin/main(extensions/qa-lab/src/crabline-transport.ts,DiscordServerManifestmissingdriverBotToken/fixture). Verified by running the same lane on a detachedorigin/main; pre-existing and unrelated.oxlintandoxfmt— clean on changed files.node scripts/run-vitest.mjs run— green for the new test plusrun-session-target,compaction-successor,acp-spawn,acp-spawn.authority,memory-core-host-engine-sessions,runtime-agent,export-trajectory,plugin-sdk/session-catalog,plugins/session-catalog, and theextensions/codex+extensions/anthropicsession-catalog consumers.Not in this PR (follow-ups)
maintenanceConfigalways set →forceMaintenance), and the lifecycle mutation still reads the whole store at full projection once per message — both needfullEntryKeys-style structural changes, not a flag flip.readSessionEntrySnapshotat depth 5.🤖 Generated with Claude Code