Repository navigation
improve: count marker-heavy transcripts without display metadata - #146382
Conversation
|
🦞👀 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 September 15, 2026, 1:59 AM ET / 05:59 UTC (Revision 3). ClawSweeper reviewWhat this changesCounts visible transcript messages and markers with a scalar query while sharing the history reader’s existing visibility rules. Merge readiness✅ Ready for maintainer review The refreshed PR resolves the prior integration blocker and measurement follow-up. No actionable correctness defect was found, and current main still performs the unnecessary metadata work. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s SQLite transcript reader turns stored session events into visible history and counts. The Gateway also uses these counts when a transcript update needs a sequence fallback. flowchart TD
A[Stored transcript events] --> B[Validated session snapshot]
B --> C[Reset-aware message total]
B --> D[Shared visible marker selection]
D --> E[Scalar marker count]
C --> F[Visible history count]
E --> F
F --> G[Gateway sequence fallback]
D --> H[Full history metadata]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +18. Total +18 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep scalar counting within the existing projection owner, sharing visibility selection with full history and preserving snapshot, reset and recovery semantics. Do we have a high-confidence way to reproduce the issue? Yes: current-main source shows the public count path constructing marker metadata before returning only its total, and the supplied paired SQLite measurements exercise that path. This read-only review did not run the benchmark. Is this the best way to solve the issue? Yes: extracting the existing selection and aggregating it avoids competing visibility logic while retaining the current snapshot and recovery owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b757ce0d5fd1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
cef1ceb to
ff8ea31
Compare
|
@clawsweeper re-review The candidate and PR evidence have been refreshed against main Maintainer assessment: the disclosed 9.8% regression in the unanalyzed 100-marker case is acceptable for this bounded optimization. All six 1,000-marker cells improve by 18.8–31.4%, reset-kept cases improve by 8.1–10.3%, and the count operation avoids display metadata materialization without changing storage or visibility. These synthetic reader measurements do not establish uniform or whole-Gateway gains. Fresh validation includes 69 existing tests, all 14 paired count/storage cells, 14 exact error/value cells, two cold restores and two short-active-branch plan checks. The initial supplemental harness mistake and its separate corrected proof are disclosed; no timed result was replaced. Required exact-head CI and independent review still apply. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
Closes #146371
What Problem This Solves
Counting a transcript with many visible markers builds display metadata that the caller discards.
User Impact
Visible-history counts become cheaper for marker-heavy sessions, including the Gateway sequence fallback when transcript updates lack a supplied sequence. Counts, errors and cold restoration remain unchanged. No migration or operator action is required. Synthetic measurements show gains of 19–31% for the 1,000-marker cases and a 9.8% regression in the unanalyzed 100-marker case; this is not a uniform or whole-Gateway speedup claim.
Why This Change Was Made
The count reader aggregates the existing marker selection and adds the existing reset-aware message total inside the same projection snapshot. It avoids marker metadata, the following-row join, ordering and next-message lookups. Full history and counting share the selection, including reset, inactive-branch and JSON guards.
Evidence
Baseline main:
ad2e57b87c7624b7b292e63d0ba8f6649c9811db, which already amortizes marker-gap lookups. Actual publicreadSessionMessageCountAsynccalls on synthetic canonical transcripts, Windows Node 26.8.2 / SQLite 3.53.4; complete captured owners with only import locations rewritten, shared dependencies and seven alternating blocks per cell:All 14 timed cells preserve exact counts, schema/typed-row and main/WAL/journal fingerprints, and integrity. Fourteen additional malformed/deep/inactive/pre-reset/compaction cells preserve exact values or errors. Two real cold archive/restore flows preserve the direct cold error and restore identical canonical events through the public async reader, returning count 4. Restoration intentionally writes through its existing owner.
A separate branch fixture stores 10,000 inactive markers with 22 active events. Both versions return 22; both use active-row driving after ANALYZE and identity driving before ANALYZE. The candidate uses a covering active index in the analyzed branch. These are plan and correctness checks, not branch latency or scanned-row measurements.
For 1,000 markers, the count query delivers one aggregate row to JavaScript instead of 1,000 metadata rows. It still evaluates the shared visibility predicate; returned rows are not SQLite rows scanned.
The paired run completed all timings, then stopped on an incorrect supplemental harness expectation that the unchanged baseline would drive from active rows before ANALYZE. Original failed artifacts and all timings are preserved. A separate supplemental-only run corrected that expectation to the existing analyzed-plan contract and passed every branch/error/cold check, without rerunning timed fixtures.
Validation: 69 existing tests passed across seven files covering the Gateway facade, history/reset/query-plan/marker-gap behavior, cold-read races and watermark isolation. Fresh independent P0–P2 review completed scoped-clean for this exact candidate; formatting and whitespace checks passed. The changed-check plan was inspected. Local lint was interrupted for shared-host capacity after identifying its type-aware default; local lint/type/schema passes are not claimed. Required exact-head hosted CI owns those integration checks and the native landing gates.
Limits: warm synthetic Windows reader measurements with uncontrolled host-wide load and OS caches; no cold-latency, p95, whole-Gateway throughput or concurrent-writer race claim. Final integrated-main remeasurement follows landing.