Skip to content

test(advisor): close hosted-advisor-choice fixtures before temp-home teardown - #8923

Merged
lidge-jun merged 1 commit into
devfrom
fix/hosted-advisor-choice-windows-teardown
Nov 18, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/hosted-advisor-choice-windows-teardown

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The hosted exchange through policy-routed Messages failed on the dev batch at e7317b6ed8. Fixture removal returned EBUSY after 15,179.23 ms, matching the 15-second synchronous removal retry budget. Windows 7/14 job
  • Policy health scoring opened the request-history SQLite index. The fixture released its spend lease and drained the response but left the index open. An instrumented run at the old removal boundary found the database, WAL, and SHM still open in the test process.
  • Close the request-history index after releasing the spend lease and use the shared asynchronous temp-tree teardown before restoring OPENCODEX_HOME. Async retry waits let any remaining integrity worker finish releasing its handle. The fixture uses the shared teardown timeout to cover the helper's wait budgets. The diff touches only fixture lifecycle code.

Verification

  • macOS, Bun 1.4.4. bun test tests/claude-integration/claude-translated-hosted-advisor-choice.test.ts passed 15/15 once and in each of five fresh-process repetitions (90 passed, 0 failed total).
  • Temporary instrumentation ran lsof -a -p <bun-pid> +D <home> immediately before removal. The baseline policy Messages case failed the handle assertion. The patched file passed all 15 cases with empty handle listings and removal retries disabled.
  • bun test tests/ci-workflows/file-size-ratchet.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts passed 38/38.
  • bun test tests/lib/remove-tree-helper.test.ts passed 11/11.
  • bun run typecheck checked 2,569 files with zero errors. bun run privacy:scan and git diff --check passed.
  • NOT RUN: native Windows on the patch and the full local suite. Focused macOS validation covered all cases in the only changed file and the teardown helper. Windows file-lock behavior still needs a native batch run.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. This is a test fixture change.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. This change only closes the fixture-owned index and uses the existing guarded removal helper.

Summary by CodeRabbit

  • Tests
    • Improved cleanup in the hosted advisor choice integration test by ensuring request history is closed and temporary data removal completes before the environment is restored.
    • Added a bounded wait for background work during teardown, helping prevent incomplete cleanup and inconsistent test results.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 18, 2026 18:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T18:12:53.758635Z 98ab9be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Claude integration test now closes the request history index and awaits background-work-aware temporary-directory removal. It restores OPENCODEX_HOME in a finally block and uses the shared teardown timeout.

Changes: Advisor test cleanup

Layer / File(s) Summary
Test resource teardown
tests/claude-integration/claude-translated-hosted-advisor-choice.test.ts
The test closes the request history index, awaits temporary-directory removal, and restores OPENCODEX_HOME in a finally block. The test timeout uses BACKGROUND_WORK_TEARDOWN_TIMEOUT_MS.

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

Change: Other

Possibly related PRs

  • lidge-jun/opencodex#8176: Updates Windows fixture setup and teardown to use bounded asynchronous cleanup, including a shared teardown timeout.
Merge Risk: Minimal · up to 98ab9

This is a test-only teardown fix with no production behavior change. The remaining caveat is that the Windows file-lock fix still needs a native Windows run to confirm.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test file's fixture lifecycle change: closing hosted-advisor-choice fixtures before temp-home teardown. The raw summary and PR objectives both describe closing the request-history …
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: Title check

Explanation

The title names the test file's fixture lifecycle change: closing hosted-advisor-choice fixtures before temp-home teardown. The raw summary and PR objectives both describe closing the request-history index and using shared async temp-tree teardown before restoring OPENCODEX_HOME. The title is specific, concise, and follows the test(scope): convention. It omits the EBUSY/Windows motivation, but that detail is not required for a title.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e7317b6 and 98ab9be.

Files selected for processing: 1

  • tests/claude-integration/claude-translated-hosted-advisor-choice.test.ts

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

@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 18, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration (lidge-jun, dev-only path) at head 98ab9be0e69d8561f1392bddbe5b88184532d814. This is a dev fix the coordinator assigned as an exception to the current merge freeze.

  • Fixes: dev batch CI run 44353636561, windows 7/14. claude-translated-hosted-advisor-choice.test.ts hit EBUSY in removeTreeWithRetry after 15,179 ms. Policy routing opens the process-wide routing-history.sqlite index under the fixture's OPENCODEX_HOME, and the teardown never closed it. The fixture now closes the history index through the shared fixture-teardown API and awaits async removal. Test-only change; assertions unchanged.
  • Review: an independent gpt-6.2-sol review approved it with no P0–P2 findings and confirmed the root cause.
  • CI: every PR check succeeded on this head (ci:full).
  • dev union check: 1 commit behind dev f5a0004d34 with no overlapping files. A local merge is clean, and the test file passes twice (15/15) with typecheck clean.
  • macOS evidence: lsof showed the database, WAL and SHM still open at the old removal point, and none after the fix.
  • NOT RUN: native Windows. PR CI does not run Windows shards; the next dev batch run will confirm.
  • scripts/ci/assert-mergeable-review.sh --maintainer-integration 8923: OK.

@lidge-jun
lidge-jun merged commit c38d6ee into dev Nov 18, 2026
33 of 35 checks passed
@lidge-jun
lidge-jun deleted the fix/hosted-advisor-choice-windows-teardown branch November 18, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant