Skip to content

improve(history): reduce work for incremental transcript reads - #148956

Closed
steipete wants to merge 5 commits into
mainfrom
codex/perf-history-tail-count-7006
Closed

steipete wants to merge 5 commits into
mainfrom
codex/perf-history-tail-count-7006

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Appending to a transcript with many visible markers repeatedly materializes older marker history to number a small display delta.

User Impact

Incremental history reads perform less JavaScript row materialization while preserving the complete response, cursor, display position, and fallback behavior. No configuration or storage migration is required.

Why This Change Was Made

The existing history projection owner can number a complete, bounded active suffix backward from its cached visible-event count. It validates the suffix before using that path and retains the full projection for incomplete, non-frontier, oversized, reset, and compaction cases. The benchmark adds an opt-in delta workload with visible-marker, ordinary-message, hidden-marker, and reset controls.

Evidence

  • Original/candidate comparison: 11 cases, 58 paired observations, and 127 registered calls per arm. Complete response parity holds after separately validating the independently generated cursor generation and derived display-source identities.
  • With 1,024 historical visible markers, single-append cases reduce native rows delivered to JavaScript from 1,075 to 51; a 20-message batch falls from 1,132 to 108. All 12 required workload reductions pass. These counts do not establish lower SQLite internal scanning or end-to-end latency.
  • All 55 tests across the Gateway cursor flow, history events, marker gaps, query plans, and read windows pass, without skips.
  • Formatting, type-aware lint, and the production, scripts, and session test type graphs pass. The maintained delta benchmark passes seven synthetic cases and validates all 56 retained responses.
  • Independent P0-P2 review found no actionable findings. Two subsequent benchmark static-check repairs preserve report fields and the bootstrap read limits; a separate source review and final benchmark checks confirm those repairs.

The benchmark smoke is functional validation and does not establish a latency improvement.

Hosted CI 34951575478 remains a recorded failure on the merge of this head with main 0eff93e4be62. Its two setup expectation failures are covered by merged #149023 for the first-run UI and the Copilot fixture corrections culminating in #149038, which restores the three canonical credential metadata fields after the duplicate-field cleanup in #149016. Main 80936b0933a1 contains these repairs. Both failing owners are outside this PR. Head 073e19c2d565 integrated repaired main 80936b0933a1. The PR retains the same stable patch identity. Four complete candidate files are unchanged; the projection also incorporates the existing range binary-search optimization from merged #148833, with its incoming main delta preserved. This is source equivalence, not new runtime proof. Existing review and local evidence remain recorded. Subsequent CI 34965698418 has a tooling failure in job 104369759148: run-vitest-profile.test.ts timed out at its unchanged 120-second deadline while checking repeated --help flags. That shard passed 312 of 313 cases. The retained diagnostic records an inner process exit and one CPU profile while its outer process remained open. These tooling owners are outside this five-file diff; the underlying cause is not yet established. The failure remains recorded without a retry or timeout change. That older failed run remains preserved.
Previous head 04b911b509b9 integrates main a95382d0c2b2, including the reviewed profiler natural-drainage repair #149010. All five complete changed files and the complete history patch are identical to the previous integration. The profiler repair does not establish the cause of the historical intermittent stall. Fresh exact-head CI and native landing gates remain pending; no old failure is reclassified as a pass.
Historical CI 34979254852 failed four native QA child-bundle cases in job 104415263977; that shard passed 991 cases and failed 4. The first child producer attempt lacks its evidence receipt. These QA owners are unchanged by the five-file history patch. The underlying cause remains unresolved: the retained assertion omits command-result failure metadata, and the approximately 30-second durations alone do not establish a timeout cause. A subsequent isolated diagnostic on exact 04b911b509b9 plus instrumentation passed all 12 original-order cases with no skips. All nine commands settled, with source and installation fingerprints unchanged. The diagnostic brackets the broad API through a dynamic import, so this does not reproduce the original static-import CI failure or establish a fix. The original failed run remains recorded; deadlines and receipt assertions were unchanged. Native landing remains blocked on exact-head CI.

Previous head 62d893172612 normally integrates repaired main 22a07e0abe7f, including canonical #149243. That fixture uses the existing evidence-only API and includes the command failure alongside its log, preserving the child deadline and receipt assertions. It does not establish the cause of the old intermittent failure. The history patch retains its stable identity: all four code, test and benchmark file pairs are unchanged, while the performance page also preserves the landed multi-agent benchmark documentation from #149178. Fresh exact-head CI is pending; prior proof remains tied to its recorded base and no historical failure is reclassified.

Historical CI 34995682678 has failed the compact-large-15 and compact-small-28/31/34 tooling jobs. The common main also has native fixture failures after the repository metadata request introduced in #149230. Canonical repair owners investigated them; this run remains failed and no retry or deadline change was made. Exact-head gates remain required before landing.

Current head b85dcaaaf342 integrates main 273b6c5e11462, containing the merged native fixture repair #149294 and Codex model-attribution fixture repair #149301. Every complete original/candidate file pair and the complete binary PR patch are byte-identical to the preceding reviewed integration. Existing source review remains applicable; prior runtime evidence retains its recorded base. Fresh exact-head CI and native landing gates are pending. Historical failures remain recorded; no CI retry or deadline/assertion change was made in this PR.

New CI 35006750416 reports a Windows timeout in vitest-worker-artifacts.test.ts, in the compiled TUI provider-hook fixture (298 passed, one failed, 30 skipped in that shard). Its source-mode sibling passes, and a successful compiled scoped probe is logged before the unchanged 120-second deadline, but the prepared-scope result is absent. The exact CI merge tree matches this PR; the named fixture, compiler, runtime, and provider-hook owners are outside this history diff. The cause remains unproven, and Windows descendant-completion uncertainty is retained in the raw log. No retry or deadline change was made. Required exact-head gates remain necessary before landing.

@steipete steipete self-assigned this Sep 15, 2026
@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts labels Sep 15, 2026
@steipete
steipete marked this pull request as ready for review September 15, 2026 09:15
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@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 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 6:46 PM ET / 22:46 UTC (Revision 11).

ClawSweeper review

What this changes

The PR reduces marker materialization for small incremental transcript reads and adds an opt-in benchmark with response-parity checks.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, distinct optimization absent from current main and v2026.9.8. No actionable defect was found in the pinned patch; the protected maintainer PR should remain open.

Likely related people: steipete and vincentkoc (medium-confidence routing candidates based on merged history work).

Priority: P2
Reviewed head: b85dcaaaf3420616ab6b1456f8de30463092c8b0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with careful fallbacks and useful recorded validation; integration readiness remains separate from patch quality.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer PR is exempt from ordinary external-contributor proof. Its captured evidence maps the display-delta owner to paired SQLite reads with response parity and reduced JavaScript row delivery; these results were not rerun here. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer PR is exempt from ordinary external-contributor proof. Its captured evidence maps the display-delta owner to paired SQLite reads with response parity and reduced JavaScript row delivery; these results were not rerun here. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduction: Reviewed the merge-base-to-head delta supplied by the host, including all five introduced files. Base drift was excluded from PR ownership.
Bounded optimization and fallback: The fast path rejects incomplete, oversized, non-frontier, reset-window, discontinuity, and dual message-marker cases. It verifies suffix membership and order before numbering backward; the caller retains the full projection fallback.
Snapshot and density contracts: The unchanged snapshot owner performs reads in one deferred transaction with a current projection. Active positions and event sequences are unique; the writer records dense positions and authoritative counts. The patch changes queries and runtime numbering without changing persisted formats.
Findings None None.
Security None None.

How this fits together

The SQLite history reader converts stored transcript events into numbered display updates. Gateway chat history consumes those updates and their cursors to refresh conversations.

flowchart TD
  A[Stored transcript events] --> B[Validated SQLite snapshot]
  C[History cursor] --> B
  B --> D[Complete small active suffix]
  D -->|Eligible| E[Backward display numbering]
  D -->|Otherwise| F[Full history projection]
  E --> G[Numbered updates and cursor]
  F --> G
  G --> H[Gateway chat history]
Loading

Before merge

  • Resolve merge risk (P1) - The reported conflicting branch has not been validated against current main's extracted history-query owner and newer transcript read contracts.
  • Complete next step (P2) - Refresh the reported conflicting branch against current main's history-query owner and review the resulting integration before merge.
Agent review details

Security

None.

PR surface

Source +96, Tests +40, Other +200. Total +336 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 125 29 +96
Tests 2 45 5 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 216 16 +200
Total 5 386 50 +336

Review metrics

Metric Value Why it matters
Growth justification production +96 net lines; tests +17; benchmark tooling +200 The production growth implements guarded suffix numbering, supported by the recorded reduction in JavaScript row materialization.
Benchmark controls 1 opt-in operation, 7 workload cases, 2 benchmark-only options Visible-marker, message-only, hidden-marker, and reset controls keep the performance comparison bounded without changing product settings.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep suffix numbering within the current shared history-query owner, preserving snapshot validation, display identities, and full-projection fallbacks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep suffix numbering within the current shared history-query owner, preserving snapshot validation, display identities, and full-projection fallbacks.

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

Not applicable as a correctness bug: the performance workload is concrete and source inspection confirms full marker materialization, but this read-only review did not execute a benchmark.

Is this the best way to solve the issue?

Yes for the pinned implementation: extending the existing projection owner with verified suffix numbering is focused and preserves fallback behavior; integration must follow the owner's current location.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2a514d9920f0.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded history-read performance improvement with no demonstrated urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer PR is exempt from ordinary external-contributor proof. Its captured evidence maps the display-delta owner to paired SQLite reads with response parity and reduced JavaScript row delivery; these results were not rerun here. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the current-main integration and verify response parity through the refreshed history reader.

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-15T12:29:15.717Z sha 073e19c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T14:17:38.818Z sha 04b911b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T14:43:28.003Z sha 04b911b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T15:04:29.183Z sha 04b911b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T16:40:15.037Z sha 62d8931 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T17:01:40.613Z sha 62d8931 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T18:40:00.665Z sha b85dcaa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T18:54:08.414Z sha b85dcaa :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Superseded by the worker history-projection reuse in #174275 (e55a4e6). Current Gateway history reads retain the committed projection and extend it from new events instead of repeatedly hydrating the historical marker prefix.

Closed in a sweep of stale maintainer PRs (no activity for 7+ days). Reopen with a current reproduction if this still matters.

@steipete steipete closed this Oct 21, 2026
@RomneyDa
RomneyDa deleted the codex/perf-history-tail-count-7006 branch October 22, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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