Repository navigation
perf(sessions): read lifecycle and timestamp-only session facts through the list projection - #164125
Conversation
Avoid cold snapshot selection, decoding, and worker transfer for metadata-only reconciliation and activity timestamps. Preserve the existing session owner, canonical validation, public full-read defaults, and mutation fences.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:10 AM ET / 09:10 UTC (Revision 2). ClawSweeper reviewWhat this changesUse existing metadata-only session reads for subagent lifecycle reconciliation and activity timestamps, avoiding unnecessary saved prompt and diff payloads. Merge readiness✅ Ready for maintainer review The optimization remains useful: current main and the latest release still perform full reads at the affected sites. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw stores session identity, lifecycle facts, and larger snapshots in SQLite. Reconciliation and inbound-message timestamp consumers need the metadata but do not need those snapshots. flowchart TD
A[Subagent reconciliation] --> C[Session read owner]
B[Inbound timestamp lookup] --> C
C --> D[Metadata projection]
E[SQLite session storage] --> D
D --> F[Lifecycle results]
D --> G[Previous activity timestamp]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +81. Total +81 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep projection selection at audited metadata consumers while preserving full reads for snapshot consumers and mutation fences. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that current-main metadata consumers select and decode unused cold snapshots; the supplied regression scenarios target that path. Execution was not repeated in this read-only review. Is this the best way to solve the issue? Yes, selecting the existing projection at these audited consumers is a narrow solution that preserves storage ownership, validation, and public full-read defaults. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4bf041c0d1f7. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…on-read-projection
|
Merged via squash.
|
openclaw#164125) Avoid cold snapshot selection, decoding, and worker transfer for metadata-only reconciliation and activity timestamps. Preserve the existing session owner, canonical validation, public full-read defaults, and mutation fences.
What Problem This Solves
Subagent lifecycle reconciliation and inbound session timestamps load saved prompts and diff baselines even though their consumers need only metadata.
User Impact
Lifecycle results and timestamps stay the same while these reads avoid cold snapshot lookups, decoding, and worker transfer. No migration, configuration, schema, durability, or retention change is required.
Why This Change Was Made
Select the existing
listprojection at the two reconciliation read sites and the timestamp accessor. The synchronous loader replaces its unusedclone: falseoption. Audited consumers use hot identity, lifecycle, recovery, status, and timestamp fields. Existing canonical validation and physical/incognito owner selection remain authoritative; public full-read defaults and mutation/equality fences are untouched.This does not move the synchronous sweeper or SDK timestamp surface off the host thread. Related: #149358 addresses whole-store listing consumers; this change covers only keyed reconciliation and timestamp reads.
Evidence
For each affected canonical target-row read, the data statement count stays 1 SELECT → 1 SELECT, with 3 → 0 correlated
session_entry_snapshotssubqueries and up to 3 → 0 cold JSON parses. Participant and admission/freshness reads are additional and variable. SQL spies verify the selected statement; a target row with three large cold fields verifies preserved completion/start facts and no cold worker-message payload. The real-store timestamp case returns exactly42. Both regressions fail on the original production code and pass with the projection changes.Existing opt-in component benchmark, 128 rows and a 35,054-byte fixture: full-entry control 0.21765 ms/read, 102,137 sampled allocation bytes/read (100 calls); list 0.08513 ms/read, 16,678 bytes/read (1,000 calls). Phase RSS was 259.07→263.57 MB for full and 257.75→262.52 MB for list. These are local component measurements with unequal sample counts and allocation sampling, not end-to-end latency or a production timing guarantee.
Production +3/−3 (net 0); tests +82/−1 (net +81) against the branch merge base. Four files changed.
pnpm test src/agents/subagents/registry/subagent-session-reconciliation.metadata-read.test.ts --maxWorkers=1pnpm test src/config/sessions/session-accessor.conformance.test.ts --maxWorkers=1pnpm test src/agents/subagents/registry/subagent-session-reconciliation.test.ts src/channels/session-envelope.test.ts --maxWorkers=1OPENCLAW_SESSION_ENTRY_SNAPSHOTS_BENCH=1 pnpm test src/config/sessions/session-entry-snapshots.benchmark.test.ts --maxWorkers=1Wall times include worker preparation and cleanup. The changed lifecycle test took 7.766 s; the new timestamp case took 0.571 s. The existing conformance file spends 212 s exercising entry/transcript writes, lifecycle cleanup, and maintenance; this PR adds only the focused timestamp case. CI seconds are not yet available; this handoff stops at exact-head CI attachment.
Gateway setup, changed-file
oxfmt, coreoxlint, andgit diff --checkpassed. No broad typecheck was run under the scoped work order. Codex autoreview: scoped-clean through P2, no accepted/actionable findings. An initial baseline attempt failed before collection because setup was still generating plugin assets; serializing setup and tests resolved that tooling failure.