Skip to content

test(main): fail if the journal's shared no-row error returns (follow-up to #27342) - #27375

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-journal-sentinel-regression-test
Oct 11, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-journal-sentinel-regression-test

Conversation

@nwparker

@nwparker nwparker commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 0 0 0 0

ELI5

#27342 fixed a small memory retention in the agent journal, but its tests would still pass if the old code came back. This adds one test that fails on the old code.

What Changed

Adds journal-item-appender.test.ts. It runs two "resolver found nothing" appends through JournalItemAppender with a fake queue that records any error thrown inside the queued work. It asserts both appends still return null and that no single error object is thrown twice.

No production code changes, and nothing changes for users.

Why

Before #27342, one Error was created when the module loaded and thrown on every no-result append. That single object's stack kept startup code and the bundle-read buffer alive. #27342's two tests check behavior (null result, other errors propagate), which the old code also satisfied. A shared, reused error object is the only observable sign of the old pattern, so the test checks for exactly that.

Alternatives considered: counting Error construction during module load would mean replacing the global Error and depending on how the test runner evaluates modules, which is brittle. Inspecting stack contents depends on V8 and bundler frame layout. The identity check needs neither. It also stays green if a future change stops using a thrown error entirely: with nothing thrown, the check passes trivially.

Linked Issue

No linked issue. Follow-up to #27342.

Visual Proof

N/A: test-only change with no UI or behavior change.

Testing

  • New test passes on main, alongside the existing journal-write-queue.test.ts suite (12 tests across 2 files).

  • With journal-item-appender.ts temporarily restored to the pre-perf(main): release startup allocations held by journal sentinel #27342 version (bc02f3ce6ea^), the new test fails: the distinct-object count was 1 where 2 was expected, because the same error object was thrown both times. I then restored the file.

  • oxlint, oxfmt --check, and the lint-staged pre-commit tasks are clean on the new file.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

The single new test file is the whole change.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Test-only and platform-independent. No effect on SSH, mobile, wire compatibility, or performance.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Follow-up to #27342: the existing tests also pass on the old module-level
Error, so add one that fails if a single error object is reused.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The test calls appendResolved twice with a resolver that returns null. It checks that both calls return null and that errors captured while enqueue builds are distinct objects.


Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 29dab

The new regression test can pass without observing both expected enqueue errors, weakening its protection against that behavior regressing. The needed test fix is small, and the concern is bounded.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: adding a test that detects reuse of the journal's shared no-row error. It is specific and related to the follow-up work.
Description check Passed The description is mostly complete. It explains the change, rationale, testing, scope, visual-proof exception, and checklist status. It also identifies the follow-up issue context, although it does no…
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.

✨ 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

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

@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.

🧹 Nitpick comments (1)
src/main/native-chat/agent-session-journal/journal-item-appender.test.ts (1)

27-27: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert that both enqueue callbacks threw.

The fake enqueue records one error for each null resolution. The uniqueness assertion also passes when thrown is empty or contains only one error. Assert the expected count first.

Suggested assertion
+    expect(thrown).toHaveLength(2)
     expect(new Set(thrown).size).toBe(thrown.length)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66af8e11-d7cd-45f7-afb9-2bd74807512a
📥 Commits

Reviewing files that changed from the base of the PR and between 41de89a and 29dab0c.

📒 Files selected for processing (1)
  • src/main/native-chat/agent-session-journal/journal-item-appender.test.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.

@nwparker
nwparker merged commit f49d0bc into main Oct 11, 2026
29 checks passed
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