Skip to content

test(native-chat): close queued-message journal DB before fixture cleanup - #25478

Merged
nwparker merged 1 commit into
stablyai:mainfrom
toodeceptive:pp/windows-queue-fixture-cleanup-20261005
Oct 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
toodeceptive:pp/windows-queue-fixture-cleanup-20261005

Conversation

@toodeceptive

@toodeceptive toodeceptive commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A test helper was deleting its scratch folder while a database file inside it was still open. Windows won't delete a file that's still open, so the tests failed during cleanup. Now the helper closes the database first and then deletes the folder.

What Changed

  • Before: createQueuedMessageTestRig().dispose() flushed the host's streamed events and then ran rm(root, { recursive: true, force: true }). The journal SQLite database opened for that root by openTestJournalHostDatabase was still open. On Windows that rm fails with EBUSY on the database or its WAL file.
  • After: dispose() calls the existing closeTestJournalHostDatabase(root) after the host drains and before the rm. That closes the handle registered for this rig's root and removes it from the shared test registry. Errors from flushing or closing still surface before anything is deleted.

The change is one test fixture file: structured-agent-session-queued-message-rig.test-fixture.ts. No production code is touched.

Why

The fixture opens the database through the shared test-support registry, so it should also close it through that registry. That helper already exists, so this adds no new cleanup path. The other options were retrying rm on EBUSY or relying on a global after-all close. Both would hide the problem rather than fix the order of teardown.

Linked Issue

None. This is test-only cleanup and no issue is filed for it.

Visual Proof

N/A. This is a test fixture teardown fix with no UI or user-facing behavior change.

Testing

  • I manually tested these changes locally

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

  • macOS: ran all 41 test files that use createQueuedMessageTestRig. All 382 tests passed.

  • Windows (contributor's run, Node 24.21.0): the baseline case reproduced EBUSY during teardown. With the fix, that case and all 33 tests in the file pass.

  • No new test was added. The existing suites that use this fixture are the regression coverage, and they fail on Windows without the fix.

  • Static gates on the touched file pass: anti-slop oxlint, code-quality native plugins, ast-grep, changed-code quality, and oxfmt.

Review

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 change. It improves Windows test reliability and doesn't affect remote SSH, mobile, or backwards compatibility.

Original fix by @toodeceptive in #25478. Their authorship is kept on the landing commit.

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)

@toodeceptive
toodeceptive marked this pull request as ready for review October 5, 2026 08:44
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

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: e2c5b0bb-899c-4d5a-974c-a72e256d3b7f
Commits

Reviewing files that changed from the base of the PR and between b99d4ac and f7220d5.

Files selected for processing: 1
  • src/main/native-chat/agent-session-wire/structured-agent-session-queued-message-rig.test-fixture.ts

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

Walkthrough

The test fixture now imports closeTestJournalHostDatabase. During disposal, it flushes streamed events, closes the journal host database, and then removes the temporary root.

Priority: Low

Merge Risk: Minimal · up to f7220

The teardown fix is mergeable; no actionable merge-blocking risk remains.

Architecture risk: Low · up to b99d4

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/native-chat/agent-session-wire/structured-agent-session-queued-message-rig.test-fixture.ts: Adds the journal host database cleanup helper import.
  • observed — Modified behavior in src/main/native-chat/agent-session-wire/structured-agent-session-queued-message-rig.test-fixture.ts: dispose now closes the test journal host database after flushing streamed events and before deleting the temporary root.
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. Documentation-only edits and deletions within survi… 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 and concisely describes the main change: closing the queued-message journal database before fixture cleanup.
Description check Passed The description is complete and focused. It explains the Windows EBUSY failure, the teardown order change, the reason for using the existing close helper, testing performed, and the lack of UI impact.…
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 is complete and focused. It explains the Windows EBUSY failure, the teardown order change, the reason for using the existing close helper, testing performed, and the lack of UI impact. It also records that no linked issue exists, which is acceptable if the author is a maintainer.

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. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.

Resolution

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

  • Autopilot · 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.

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

✅ No new issues found.

Reviewed changes — one file, test-only: the shared queued-message test fixture now closes its journal database before deleting its temporary directory.

  • Close the journal handle before rm — dispose() calls closeTestJournalHostDatabase(root) between host.flushAllStreamedEvents() and rm(root, { recursive, force }), so the Windows EBUSY on the SQLite DB/WAL no longer blocks teardown.

The fix is correct and complete for its scope. The record store opened by openTestAgentSessionRecordStore(root) is rows in the same journal host database, so closing by root covers both handles; closeTestJournalHostDatabase is idempotent, so the double-dispose() cases stay safe; and a close failure still propagates before deletion, as the description states. crashRestartHostProcess re-opens through the same tracked root, so a single close in teardown is right.

ℹ️ The same open-handle teardown remains in the sibling REST rig

The structurally identical fixture structured-agent-session-rest-test-rig.ts deletes its temp root without closing the journal database it opened, so the same Windows EBUSY class likely persists there. Out of scope for this PR (which explicitly does not claim a full-suite result) — noting it only so the class isn't assumed fully retired.

Technical details
# Same open-DB-before-rm shape in the REST test rig

## Affected sites
- `src/main/native-chat/agent-session-wire/structured-agent-session-rest-test-rig.ts:199` — `dispose()` flushes streamed events then `rm(root)`, but never calls `closeTestJournalHostDatabase(root)`, though `hostFor` opened that root's DB at line 173.

## Required outcome
- The REST rig's teardown closes `root`'s journal host database before removing the directory, matching the queued rig.

## Open questions for the human
- Is chasing the full Windows teardown class intended, or is this PR deliberately limited to the queued fixture (sibling tracked separately)?

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…anup

The queued-message test rig deleted its temp state directory while the
shared journal SQLite handle was still open, so teardown failed with
EBUSY on Windows. Close the rig root's journal database after the host
drains, then remove the directory.
@nwparker
nwparker force-pushed the pp/windows-queue-fixture-cleanup-20261005 branch from b99d4ac to f7220d5 Compare October 27, 2026 08:55
@nwparker nwparker changed the title test: close queued-message journal before fixture cleanup test(native-chat): close queued-message journal DB before fixture cleanup Oct 27, 2026
@nwparker
nwparker merged commit 04f5104 into stablyai:main Oct 27, 2026
43 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.

2 participants