Skip to content

perf(native-chat): share saved text across journal revisions - #29132

Closed
brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/native-chat-text-pieces
Closed

brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/native-chat-text-pieces

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Long chat replies repeatedly saved the same beginning as they grew. That makes more frequent progress updates expensive. This prerequisite stores shared text pieces so saved chats retain their full history with less repeated text; save timing stays unchanged here.

What Changed

Each revision keeps its original identity and metadata, while immutable text pieces share the unchanged beginning and store the changed tail. Authoritative final replacements, including shorter replies, keep their existing meaning. Transactions, ownership and cursor order retain their existing meaning. After a save commits, connected clients receive the current message from the host’s in-memory state. Reopening or explicitly reading saved history still checks the database; if saved text becomes damaged during a live reply, that damage is discovered on the next saved-history read or reopen.

The database moves atomically to schema 5. Existing raw rows remain readable, and an earlier experimental compatibility view is removed during migration. An unchanged older Orca already refuses a newer database before opening its chats; this PR uses that existing boundary. Paired and SSH clients still receive complete existing messages from the execution host and do not read its database file.

Why

Saving less often makes progress stall; keeping full copies beside pieces retains the storage cost. Sharing text beneath the logical journal preserves complete history without retaining every repeated beginning. The common pattern informs appended text and final replacement. Complete historical revisions, full existing wire messages and host-owned decoding are intended differences needed by Orca's cursor and mixed-peer contracts.

This does not promise linear network traffic or constant historical replay cost. Older binaries on a migrated profile use the existing update-required refusal. Saved-file downgrade compatibility is outside the supported contract; mixed client/server versions remain supported.

Linked Issue

Maintainer prerequisite for the save-timing work tracked in #28984.

Visual Proof

Real signed-in-agent hidden Electron comparison on M4Air is pending capacity. No current rendered result or screenshot is claimed.

Testing

  • Cumulative source review through round six; schema transition and live publication reviewed independently. The activity-only allocation finding is corrected in source; its targeted and runtime verification remains pending.
  • Native retained-database proof on Windows: all three saved inputs preserve complete rows, cursor and snapshot through migration and restart; unchanged older Orca refuses before replay; current Orca continues each chat with exact prior history and authoritative final replacement. Twelve phases passed, with all original database hashes preserved.
  • Earlier focused native run: 284 tests in eight files passed at a production-equivalent earlier source checkpoint. Current amended tests still require final validation.
  • Matched provider storage, publication, replay and memory measurements, including real subscriber cases.
  • Real remote Electron QA and screenshots.
  • Conflict resolution at final integration, followed by full PR workflow on the resulting exact head.

The retained proof ran the earlier production checkpoint c3b9759. It supports the schema transition at that checkpoint; it does not validate the newer live-publication code. Each of the 156 reported source hashes was independently matched to its pinned commit, and all 262 transferred artifact lengths and hashes were checked. The original failed scratch oracle remains failed: a new oracle follows the unchanged older binary's contract of identical main-file bytes and absent or empty WAL, while recording SHM bookkeeping.

The historical 6.6-second older-reader result on the experimental schema-4 view remains valid. This change removes that view at a supported version boundary; it does not claim to optimize that query. Wider performance acceptance remains pending.

This checkout has no dependencies or installed hook wrappers, so its pre-commit hook could not execute; no bypass flag was used. CI supplies the static-analysis gate. Current head is 75e27ce; a full current workflow is missing while the branch conflicts. Historical green runs are not evidence for this head.

AI Disclosure

Review

The first review found repeated full-prefix storage. Later review corrected unnecessary historical dependency traversal. A runtime panel then blocked the experimental compatibility view and a separate fractional-clock deadline bug. First-hand released-source inspection established the existing newer-schema refusal contract, and the decider adopted private schema-5 storage. The amended plan was independently checked before implementation. The latest review found unnecessary full-history allocation for activity-only updates; the narrow correction skips it for caught-up clients and awaits targeted checks. The unchanged subscriber performance gates, real remote QA, final integration and exact-head CI remain open, so the PR stays a draft.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source is copied or translated.

Notes

The execution host owns journal access for local, SSH and paired clients. No new wire operation, capability requirement, renderer message, setting or agent-specific policy is introduced. Windows Subsystem for Linux storage classifications include the physical tables. Remaining unmeasured platform, transport and responsiveness cases are not claimed verified.

Checklist

  • One storage prerequisite; save timing stays in the dependent PR.
  • Problem, user-facing result, mechanism and tradeoffs explained.
  • Real remote screenshots and neighboring flows checked.
  • Runtime performance acceptance complete.
  • No conflicts and required checks green on the final head.

Author: @BrennanKB5

Current verification checkpoint: a focused Windows run on the preceding head collected 122 tests and found one extra history reduction during reconnect. The current head restores lazy reconnect work reads; that unchanged test, the subscriber performance gates, real signed-in-agent Electron comparison and final CI are pending. No current readiness claim.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 21:05
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e031ac2-2cd6-47e0-aec3-675d8915ddb7
📥 Commits

Reviewing files that changed from the base of the PR and between 13b79a2 and a7269a1.

📒 Files selected for processing: 47
  • config/scripts/vitest-sqlite-runtime-files.mjs
  • src/main/codex/codex-structured-journal-settlement-rollback.test.ts
  • src/main/native-chat/agent-session-journal/command-receipt-schema.spec.ts
  • src/main/native-chat/agent-session-journal/command-receipt-transaction.spec.ts
  • src/main/native-chat/agent-session-journal/journal-atomic-terminal-settlement.spec.ts
  • src/main/native-chat/agent-session-journal/journal-committed-changes.ts
  • src/main/native-chat/agent-session-journal/journal-database-schema.ts
  • src/main/native-chat/agent-session-journal/journal-database.spec.ts
  • src/main/native-chat/agent-session-journal/journal-database.ts
  • src/main/native-chat/agent-session-journal/journal-epoch-replacement.spec.ts
  • src/main/native-chat/agent-session-journal/journal-host-database-test-support.ts
  • src/main/native-chat/agent-session-journal/journal-host-database.spec.ts
  • src/main/native-chat/agent-session-journal/journal-host-database.ts
  • src/main/native-chat/agent-session-journal/journal-open.ts
  • src/main/native-chat/agent-session-journal/journal-row-schema.ts
  • src/main/native-chat/agent-session-journal/journal-row-table.ts
  • src/main/native-chat/agent-session-journal/journal-row-writer.ts
  • src/main/native-chat/agent-session-journal/journal-store-collaborators.ts
  • src/main/native-chat/agent-session-journal/journal-store.ts
  • src/main/native-chat/agent-session-journal/journal-streamed-text-field.ts
  • src/main/native-chat/agent-session-journal/journal-text-piece-reader.ts
  • src/main/native-chat/agent-session-journal/journal-text-piece-schema.ts
  • src/main/native-chat/agent-session-journal/journal-text-pieces.test.ts
  • src/main/native-chat/agent-session-journal/journal-text-pieces.ts
  • src/main/native-chat/agent-session-journal/journal-transaction.ts
  • src/main/native-chat/agent-session-journal/journal-unknown-row-kind.spec.ts
  • src/main/native-chat/agent-session-journal/queued-message-store.spec.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-page-bounds.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-page.ts
  • src/main/native-chat/agent-session-wire/agent-session-journal-batch.ts
  • src/main/native-chat/agent-session-wire/agent-session-live-publication.test.ts
  • src/main/native-chat/agent-session-wire/agent-session-live-publication.ts
  • src/main/native-chat/agent-session-wire/agent-session-published-work.ts
  • src/main/native-chat/agent-session-wire/agent-session-subscriber-catch-up.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-append-delivery.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-clear-rewind.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-create-adoption.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-create.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-leftover-settlement.test-fixture.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-stale-turn-verdict.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-transition.test.ts
  • src/shared/wsl-move/wsl-move-dispositions.test.ts
  • src/shared/wsl-move/wsl-move-storage-dispositions.ts
  • tests/e2e/cross-version-wire/agent-session-newer-chat-refusal.unit.test.ts
  • tests/e2e/cross-version-wire/agent-session-stop-event-downgrade.unit.test.ts
  • tests/e2e/cross-version-wire/kept-card-downgrade.unit.test.ts
💤 Files with no reviewable changes: 1
  • tests/e2e/cross-version-wire/kept-card-downgrade.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The journal schema advances to version 5 and adds text-piece storage for eligible streamed text. Journal reads validate and reconstruct text pieces, and migration and persistence tests are updated. The journal store also tracks committed projection rows. Subscriber delivery captures journal and work state for history paging and frame construction. The changes add live-publication tests and remove several older-build downgrade tests.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to a7269

This change stores chat history as shared text pieces under a schema-5 migration and publishes live updates from in-memory state. The review found no concrete defects. The author still reports pending performance and end-to-end validation, which should be completed as normal before release.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 67 functions across 46 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: sharing saved text across journal revisions to reduce repeated storage.
Description check Passed The description follows the repository template and explains the user impact, implementation, rationale, issue, testing, compatibility boundaries, and open validation work. It clearly states that scre…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the repository template and explains the user impact, implementation, rationale, issue, testing, compatibility boundaries, and open validation work. It clearly states that screenshots, current-head validation, performance measurements, remote QA, and final CI remain pending.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Closing: the piece storage is careful work, but it's a one-way schema-5 migration (rolling back to an older Orca refuses to open chats) with no current-head measurements, and it conflicts in six files including #28966's journal writer changes. Please re-propose once the dependent cadence change has proven it needs it.

@nwparker nwparker closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants