Skip to content

test(service): answer the Windows checked stop in the parent-stop fixture - #8727

Closed
lidge-jun wants to merge 2 commits into
devfrom
fix/dev-red3-stop-teardown-windows-3
Closed

lidge-jun wants to merge 2 commits into
devfrom
fix/dev-red3-stop-teardown-windows-3

Conversation

@lidge-jun

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

Copy link
Copy Markdown
Owner

Summary

windows 5/14 of dev batch run 43413601225 failed six cases of tests/service/stop-deferred-teardown.test.ts "parent CLI shared teardown completion": "PID-identified hub client keeps the 404 to signal path", "R6 connectAfterBoundary / connectDuringRestore preserves hub writes (receipt true/false)" and "R6 follow-up receipt pendingAfterGrok". In each, report.unexpectedIo held three execFileSync calls.

This is an older Windows test-assumption bug from #8573 (d1f36eda24, the checked Windows stop on every stop path); #8416 does not explain it. The fixture fakes the proxy as PID 4242 and mocks node:child_process. On a real Windows host, ordinary cases let the real Part A run windowsStopChildPid() → verifyPidIdentity(4242). The native read finds no such process, so the lookup falls back to one WMIC and two PowerShell probes, the three unexpected calls. The earlier batch's Windows logs show no run of this file, so no earlier Windows pass is established.

On Windows, tests/fixtures/parent-stop-runner.ts now answers Part A and Part B with the existing setWindowsServiceStopHooksForTests hooks for ordinary cases. Part A answers "stopped" and ends the child when managerCascades is set (a manager stopping the proxy itself), otherwise "absent"; Part B answers "freed". This way so the host's process table and service manager never see the fake PID. Cases that already install their own Windows hooks keep them.

Where the product's Windows rule differs, the tests assert that rule. On Windows a stop must record a deferred-teardown receipt (windowsStopRequiresReceipt), and claimTeardown in src/cli/index.ts refuses before any POST when it cannot. So the receipt-false cases expect no POST, kill or restoration, exit 1, and ok: false. POSIX expectations are unchanged.

OCX_TEST_WIN_STOP=1 drives the same Windows wiring on Linux. Two simulated-Windows cases use it so the isolation and the receipt rule run on every runner. The PID-identified 404 case still exercises the documented taskkill fallback after a failed graceful stop.

Verification

  • With the Windows stop wiring and command-line probes enabled on Linux, before the fix "R6 connectAfterBoundary" fails twice, each with three execFileSync calls. After: OCX_TEST_WIN_STOP=1 bun test tests/service/stop-deferred-teardown.test.ts gives 120 pass, 0 fail.
  • Focused service, update-handover and Windows-stop files: 167 pass, 0 fail. After review: tests/update/update-teardown-handover.test.ts and tests/service/stop-deferred-teardown.test.ts give 151 pass, 0 fail both normally and with OCX_TEST_WIN_STOP=1. The three manager-cascade cases now assert no stop request was sent; with the old always-absent hook they fail under the simulation. bun run test:changed: 120 pass, 0 fail. bun run typecheck: exit 0.
  • NOT RUN: a native Windows runner (next dev batch), and the full suite.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 23:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T23:59:40.166897Z d5f80c9 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 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

The tests now simulate Windows stop handling on non-Windows hosts and check receipt-refusal outcomes for runs without receipts. Receipt-backed Link-stop tests also verify service invocation, receipt clearing, skipped shared teardown, and successful exit.

Changes: Windows stop tests

Layer / File(s) Summary
Windows test setup
tests/fixtures/parent-stop-runner.ts (lines 174–180, 325–335), tests/service/stop-deferred-teardown.test.ts (lines 65–82)
The fixture configures Windows stop hooks. The test runner can simulate Windows on other platforms.
Receipt outcome assertions
tests/service/stop-deferred-teardown.test.ts (lines 98–113, 155–166, 350, 364, 378, 395, 514, 523)
The tests check refusal when a Windows stop has no receipt, with exceptions for hub clients and exit cleanup. Receipt-backed Link-stop tests check the service call and teardown results.

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

Change: Other

Suggested reviewers: luvs01

Merge Risk: Minimal · previous review d5f80

This PR changes only test fixtures and test assertions that simulate Windows stop handling. It has no production impact and no remaining merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test-fixture change that answers the Windows checked stop in the parent-stop fixture. The raw summary and objectives confirm the fixture now installs Windows stop hooks and the def…
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 Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the test-fixture change that answers the Windows checked stop in the parent-stop fixture. The raw summary and objectives confirm the fixture now installs Windows stop hooks and the deferred-teardown tests expect Windows receipt-refusal behavior. The title is specific and accurate, though it focuses on the fixture and does not mention the receipt-rule expectation changes in the test file. Its scope is narrow, so it is a reasonable description of the primary change.

  • 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 873ec9b and d5f80c9.

Files selected for processing: 2

  • tests/fixtures/parent-stop-runner.ts
  • tests/service/stop-deferred-teardown.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.

Review of #8727: the default Windows Part A hook always answered absent, so the update-handover cases where the service manager stops the proxy itself took the API POST path on Windows and still passed. The hook now ends the child and answers stopped when managerCascades is set, and those three cases assert that no stop request was sent. With the old hook they fail under OCX_TEST_WIN_STOP=1; both files pass 151/0 on Linux and simulated Windows.
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Closing as superseded by #8716 (merged as d0f197d), which fixes the same root cause in tests/fixtures/parent-stop-runner.ts: on the Windows stop wiring the fixture now answers the checked stop's Part A/Part B through setWindowsServiceStopHooksForTests, returning stopped (and marking the proxy dead) when managerCascades is set and absent otherwise. That is the same behavior this PR's corrected head ff130c1832 implemented, and the fresh review of this head passed, but rebasing it now would only duplicate merged code. Maintainer judgment: close without merging; no remaining failure in run 43413601225 depends on this branch.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 14, 2026
@lidge-jun lidge-jun closed this Nov 14, 2026
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).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant