Skip to content

test(sessions): build the rollback-journal fixture without setup syncs - #1578

Merged
devswha merged 1 commit into
mainfrom
test/session-history-journal-speed
Oct 21, 2026
Merged

devswha merged 1 commit into
mainfrom
test/session-history-journal-speed

Conversation

@devswha

@devswha devswha commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Change

Reduce the setup cost of never reads a crashed writer's uncommitted change from a rollback-journal store in server/session-history.test.ts.

The existing setup already used one transaction, but enabled a one-page cache before inserting 2,000 padded rows. That made setup spill pages to disk unnecessarily. Build the existing Hermes SQL fixture and eight padded rows in one transaction with the normal cache and synchronous=OFF. Restore synchronous=FULL, then enable the one-page cache and cache spilling for the uncommitted transaction under test. The smaller dataset still spills the changed user-message page, as demonstrated by the mutation test below.

The real SQLite DELETE journal, uncommitted updates, copied database and hot journal, and original assertions are unchanged. Disk syncs are disabled only for committed setup writes, not the crash scenario. No fixed sleeps, timeout increases, production changes, or changelog fragment.

Validation

Measured on the same loaded Linux PC with Bun 1.4.3, based on main 90b66e85:

Rollback-journal test Test duration
Before (targeted run) 16,685.15 ms
After (full-file run, default timeout) 639.50 ms

The baseline measurement used --timeout 120000 solely to obtain a completed timing (16.90 s command wall time). An intermediate 32-row version passed alone but took 10.39 s under heavier disk load in a full-file run, so it was not sufficient. The final revision also removes all committed setup syncs and reduces the padding to eight rows.

Regression proof: temporarily changed openDatabase in server/session-history.ts from mayBeImmutable && wal && !logged to mayBeImmutable && !logged, making rollback-journal databases open immutable and ignore recovery. The optimized test failed its original assertion:

Expected to not contain: "uncommitted prompt"
Received: [ "uncommitted prompt", "uncommitted prompt" ]
0 pass, 1 fail (2,133.91 ms; exit 1; 2.36 s wall)

Restored the production guard immediately afterward; the final diff changes only the test.

  • HERDR_TEST_MODE=unit bun test ./server/session-history.test.ts: 69 passed, 0 failed; 65.71 s (65.77 s wall). The rollback-journal test passed in 639.50 ms with the default timeout, about 26 times faster than baseline.
  • bun test ./scripts/conventions.test.ts ./server/conventions.test.ts: 19 passed, 0 failed; 4.46 s (4.52 s wall).
  • Language-server diagnostics: no errors. git diff --check: clean.

The earlier full-file run of the intermediate 32-row revision also timed out five unchanged SQLite tests during heavier disk contention. None of those tests were edited; the final full-file run above passed all 69 tests.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a6375f3c-3814-402a-9e02-689db121aefa
📥 Commits

Reviewing files that changed from the base of the PR and between 90b66e8 and 71a562c.

📒 Files selected for processing: 1
  • server/session-history.test.ts

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

📝 Summary

Summary by CodeRabbit

  • Tests
    • Improved coverage for database crash recovery and rollback scenarios.
    • Added setup validation for transactions involving multiple assistant messages and uncommitted changes.
    • Confirmed that crash-copy behavior remains consistent under the tested synchronization and caching conditions.

The rollback-journal crash test now creates and initializes the Hermes database directly. It inserts eight padded assistant messages and applies setup synchronization settings before configuring the crash-test settings.

Changes: Rollback-journal crash test

Layer / File(s) Summary
Database and crash-test setup
server/session-history.test.ts
The test initializes the Hermes database from fixture SQL and inserts eight padded messages instead of 2,000. Setup synchronization settings are separate from the later crash-test settings.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related issues

Merge Risk: ⚪ Minimal · up to 71a56

The test-only setup change preserves the rollback-journal scenario and introduces no established merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: building the rollback-journal test fixture without setup synchronization overhead.
Description check Passed The description includes the required Change and Validation sections. It explains the performance problem, implementation changes, unchanged crash scenario, regression proof, and test results.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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.

@devswha
devswha merged commit cae813f into main Oct 21, 2026
17 checks passed
@devswha
devswha deleted the test/session-history-journal-speed branch October 21, 2026 23:19
devswha added a commit that referenced this pull request Oct 22, 2026
Brings in #1578, which builds the rollback-journal fixture without setup syncs and fixes the
Fast checks timeout seen on this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 22, 2026
## Change

Makes five tests that failed on CI pass reliably. All five failures were
in the tests' own setup, not in product code; no product code changes.
No timeout, retry, fixed sleep or weakened assertion was added.

- **omo multiline paste** (`server/core/omo-pane-send.test.ts`, failed
on main 10-22 05:29Z and 08:15Z: expected bracketed paste, received bare
`a\nb`).
- Cause: the fixture shell printed "ready" and then `exec`'d `sleep`.
During that exec, Linux can briefly show an empty `/proc/<pid>/environ`,
so the composer missed `OMO_CODING_AGENT_DIR` and the holder record.
- Fix: the ready shell now stays blocked on stdin, and cleanup waits for
it to exit.
  - Under load: 7 failures in 500 runs before, 0 in 500 after.
- **Heavy paging tests** (`opencode.test.ts` 1.x and long-session paging
and /undo, `conversation.test.ts` Devin cache and Agy ledger; 60 s
timeouts at 65-108 s on CI).
- Cause: the SQLite fixtures synced every row to disk. Devin alone spent
11.2 s in 496 `fsync` calls.
- Fix: the throwaway fixture writers set `PRAGMA synchronous = OFF`;
committed visibility, locking, data volume and assertions are unchanged.
This follows #1578.
  - Per test, alone: 5-20 s before, under 0.2 s after.
  - With eight heavy files at once: 1,506 pass, 0 fail.
- **OpenCode v2 contract tests** (`opencode.contract.test.ts`: `@effect`
queued while the pane works, failed 3 times, once on main; first key
never waits on the event stream).
- Cause: the pending receipt confirmed the PTY write before the stand-in
had read Enter, and cases moved on before the previous send was
consumed.
- Fix: each case waits for the stand-in's byte reports to confirm
consumption, and matches reports by their offset in the shared log.
- Results: 1 failure in 5 runs before, 0 in 13 after. The whole file run
3 times: 60 pass.

Also checked: the Portal "unrelated process" failures on main (10-22
06:17Z and 06:33Z) predate #1638, which fixed them. That fixture fails 3
times in 500 runs without #1638's change and never with it.

## Validation
- `bun run check fast`: passes.
- The changed files on this branch: unit 170 pass, contract 20 pass.

Test-only changes; no changelog fragment.
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