Skip to content

revert(native-chat): remove blocking live history cleanup - #37873

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/release-revert-journal-cleanup
Nov 3, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/release-revert-journal-cleanup

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Large chat histories can freeze Orca when the live-history cleanup added by #36053 runs. This release rollback removes that added compaction and vacuum work.

What Changed

Reverts #36053 (2a5ec2bd47919fc9b3c4194a541e35d5d981606e). The older retired-history cleanup remains. Saved formats, readers and writers are unchanged, including support for histories already compacted. A surviving test now cold-reopens sparse history, continues writing, and reopens again.

Why

The complete asynchronous repair in #37802 is still being finished. This is the requested temporary rollback for the release: redundant live history can grow again until that repair is ready. Older synchronous saves and retired-history cleanup remain, so this does not claim to fix every source of stalls.

Linked Issue

Tracked in STA-13374 and STA-13375. STA-13375 tracks cherry-picking this revert PR only and is assigned to Brennan.

Visual Proof

N/A — background database maintenance changes; no UI or interaction change.

Testing

  • Automated tests updated: six focused journal suites, 40 tests passed on macOS. They cover retired cleanup and retry/stop, frozen format-1 compatibility, sparse catch-up/cold reopen/continued writes, storage admission, scaling contracts and recorded Claude/Codex streams.
  • Local lint, static rules and formatting passed through the normal commit hook and again for the main merge.
  • Final-head CI passed on c9e64611f16ce65c7f0eb3dec53b8eb7fd1fde13, including cross-version compatibility, all unit shards, typecheck, packaging, persistence and WSL checks. One unit worker initially exited with SIGABRT without an assertion failure; a failed-job-only retry passed. The earlier historical setup blocker was cleared by main's test: remove 11 low-value declarations and batch historical checkout fetches #37894. No local app or build run was required.

Risk

Level: Medium. Live-history pruning and disk reclamation pause, so redundant history can grow again. Existing formats and client/SSH/mobile contracts are unchanged. Reverting this rollback restores the added cleanup and its known stall risk; neither direction recreates already-deleted intermediate revisions, which the unchanged readers do not require.

Review

Independent correctness, architecture and final comparison reviews passed without findings. The earlier main merge was also checked: the rollback diff is byte-identical to the reviewed patch, and test evidence carries across it. A second main sync brings in #37894 to address the inherited CI blocker; its narrow merge check passed with no findings, and final-head CI is green. No journal compatibility assertion failure was reported. All independent reviews and the final readiness check passed on the reviewed head.

Agent skill upstream boundary

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

Notes

No dependency, schema, wire-format, platform path, provider parser, login, or UI change. Shared recorded Claude/Codex coverage passed; no running-app QA was required for this maintenance rollback. No measured runtime latency or whole-main release-readiness claim is made.

Checklist

  • Focused rollback; user-facing result, mechanism, temporary growth and follow-up explained.
  • Risk and back-out behavior stated.
  • Visual proof N/A with reason.
  • Self-review and independent correctness, security, compatibility and performance review complete.
  • Cross-platform, SSH/remote, mobile and saved-data impact considered.
  • Final-head CI complete.
  • Final readiness check passed on the reviewed head.

Reverts 2a5ec2b for the next release. Preserve a sparse-history cold-reopen and continued-write contract for already compacted chats. The asynchronous cleanup repair remains separate.
@brennanb2025
brennanb2025 marked this pull request as ready for review November 3, 2026 18:40
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The journal sweeper now performs retired-outcome cleanup without running outcome compaction or incremental vacuum. The compaction and vacuum implementations and their associated tests were removed. Other journal tests were changed to check state preservation across reopen and to remove several cleanup and projection assertions.

Merge Risk: Minimal · up to c9e64

No actionable issue was identified in the supplied change. Merge readiness remains subject to normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… 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 names a revert of live-history cleanup in the native-chat journal, which matches the changeset. It removes the compaction and vacuum work added by #36053, and the summary confirms the delete…
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.
Description check Passed The pull request description includes all required sections and clearly explains the rollback, rationale, testing, risk, compatibility impact, visual proof, and back-out behavior. It links the tracked…
Full details: Title check

Explanation

The title names a revert of live-history cleanup in the native-chat journal, which matches the changeset. It removes the compaction and vacuum work added by #36053, and the summary confirms the deleted journal-compaction and incremental-vacuum modules. The title is short, specific, and uses the conventional revert prefix.

Full details: Description check

Explanation

The pull request description includes all required sections and clearly explains the rollback, rationale, testing, risk, compatibility impact, visual proof, and back-out behavior. It links the tracked issues and marks the non-UI visual proof as N/A with a reason.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
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
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e5cdb9f-bac6-425b-b637-dc58958d469b
Commits

Reviewing files that changed from the base of the PR and between e400eac and c9e6461.

Files selected for processing: 1
  • src/main/native-chat/agent-session-journal/journal-storage-admission.test.ts
Files with no reviewable changes: 1
  • src/main/native-chat/agent-session-journal/journal-storage-admission.test.ts

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Nitpick Retain the retired-cleanup state checks without restoring compaction assertions.

213-214: Trivial · Data Integrity & Integration · Quick win

Retain the retired-cleanup state checks without restoring compaction assertions.

The deleted test covered live-state preservation after JournalOutcomeSweeper.pass() and after a cold reopen. The surviving mixed-epoch test checks the live state before the sweep, then checks only retired rows after the sweep. Restore the focused cleanup, encoded-state, orphan-row, and final reopen assertions.

Suggested fix
 import { restoreJournal } from './journal-open'
+import { JournalOutcomeSweeper } from './journal-outcome-cleanup'
 import { applyJournalRow, renderJournalState } from './journal-reducer'
 ...
 import type { JournalHostDatabase } from './journal-host-database'
 import type { JournalRow } from './journal-row-schema'
+import { encodeJournalState } from './journal-state-codec'
 
 ...
     expect(
       restoreJournal(database.db, sessionId)?.state.appliedSettlementIds.has('stop-settlement')
     ).toBe(true)
+    await journal.replaceEpochItems('handle_forked', 1, [
+      {
+        identity: stoppedTurn,
+        body: { kind: 'turn', turnId: 'stop-turn', state: 'interrupted', completedAt: at + 1 },
+        ownerFence: 1
+      }
+    ])
+    const rewound = journal.snapshot()
+    const saved = encodeJournalState(restoreJournal(database.db, sessionId)!.state)
+    const sweeper = new JournalOutcomeSweeper({ database: () => database, delay: async () => {} })
+    disposals.push(() => sweeper.stop())
+    await sweeper.pass()
+    expect(encodeJournalState(restoreJournal(database.db, sessionId)!.state)).toEqual(saved)
+    expect(
+      database.db
+        .prepare(`SELECT COUNT(*) AS n FROM journal_outcomes WHERE generation NOT IN
+      (SELECT generation FROM journal_outcome_epochs)`)
+        .get()?.n
+    ).toBe(0)
+    await journals.closeAll()
+    expect(
+      (await journals.open({ identity, stateDirectory: root, now: () => at })).snapshot()
+    ).toEqual(rewound)
   }
 )

Open the source location

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ace7ec0-419e-4785-8d97-d14f028b7155
Commits

Reviewing files that changed from the base of the PR and between 14819eb and bdc4907.

Files selected for processing: 10
  • src/main/native-chat/agent-session-journal/journal-compaction-scaling.test.ts
  • src/main/native-chat/agent-session-journal/journal-incremental-vacuum.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-cleanup.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-compaction.test.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-compaction.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-scaling.test.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-wire.test.ts
  • src/main/native-chat/agent-session-journal/journal-projection-streams.test.ts
  • src/main/native-chat/agent-session-journal/journal-storage-admission.test.ts
  • src/main/runtime/agent-session/structured-agent-session-attachment-wiring.ts
Files with no reviewable changes: 6
  • src/main/native-chat/agent-session-journal/journal-compaction-scaling.test.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-scaling.test.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-compaction.test.ts
  • src/main/native-chat/agent-session-journal/journal-incremental-vacuum.ts
  • src/main/native-chat/agent-session-journal/journal-storage-admission.test.ts
  • src/main/native-chat/agent-session-journal/journal-outcome-compaction.ts

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

@brennanb2025

brennanb2025 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Large chat histories could freeze Orca during the live-history compaction and vacuum added by #36053. This PR removes that work for the release while preserving the older retired-history cleanup and existing saved-history readers and writers. Histories that were already compacted can still reopen and accept more writes.

Independent correctness, architecture and final reference comparisons passed with no findings. The production change is the exact inverse of #36053; the extra test covers sparse cold reopen, continued writing and a second reopen. Six focused journal suites passed all 40 tests, including recorded Claude/Codex streams, cleanup retry/stop, saved formats and scaling contracts. Final-head CI is green, including cross-version compatibility and WSL. One unit-test worker initially aborted with SIGABRT; the reviewed failed-job-only retry passed. Its underlying abort cause remains unknown.

Test/reference evidence was recorded on bdc4907. Main merges e400eac and c9e6461 preserve the reviewed rollback; narrow independent checks passed and CI ran on the current head. No app run or screenshots are required for this background-maintenance rollback under the tests QA row.

Temporary difference: redundant live history may grow until the asynchronous repair tracked in #37802 is ready. Older synchronous saves remain; this is not a claim that every source of stalls is fixed. No remaining review findings or additional scaling work were identified.

For Brennan's review: retained retired-history cleanup. Cherry-pick task STA-13375 covers this revert only. Whole-main release readiness has not been audited by this PR review.

@brennanb2025
brennanb2025 merged commit 25c6757 into main Nov 3, 2026
78 of 80 checks passed
audichuang pushed a commit to audichuang/orca that referenced this pull request Nov 4, 2026
…7873)

Revert the live-history compaction and incremental vacuum added by stablyai#36053 to remove their serving-thread stall risk for the release. Preserve retired-history cleanup, saved formats/readers/writers and already-compacted sparse histories; add sparse reopen/write/reopen coverage.

Temporary: redundant live history can grow until the separate repair tracked in stablyai#37802 is ready. Older synchronous saves remain.

Tracked in STA-13374 and STA-13375. Six focused suites / 40 tests, independent correctness/architecture/final comparison and final-head CI passed.

(cherry picked from commit 25c6757)
brennanb2025 added a commit that referenced this pull request Nov 5, 2026
Restore the live-history cleanup that #37873 temporarily removed, now on the
off-thread native writer, and port main's retained-input, logical context,
queue and ownership changes onto the asynchronous journal boundary.
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.

1 participant