Skip to content

test(windows-plugin): walk the owned tree as stop does, so a reused parent number pulls in nothing - #2202

Merged
devswha merged 1 commit into
mainfrom
fix/windows-stop-tree-after-lifecycle-lock
Oct 28, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/windows-stop-tree-after-lifecycle-lock

Conversation

@devswha

@devswha devswha commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Change

What was wrong. On Windows CI, "starts after its launcher exits, stops its owned tree and restarts on Windows" sometimes failed at "wait up to ten seconds for the Windows-owned process tree to disappear" (#2185, run 40635841024; #2193, run 40638822136). stop itself had succeeded: it exited 0, and run("stop") asserts that. The test then waited for its own list of "owned" processes, and that list was wrong. It held 128 and 123 pids, starting with boot-time system pids. It also held the test runner's own pid (8248 and 2228). The earlier test in the same file prints that number in "stopped Ovis (pid N)", because it records process.pid. The runner started before the server, so it can never be part of the server's tree, and it never exits.

The test built that list with a plain parent walk (unchanged since #330). Windows keeps a dead parent's number on its children and gives that number to new processes. When a process in the server's tree got a number that long-lived processes still named as their parent, the walk pulled them in, and everything below them.

Is #2166 the cause? No. #2166 (the plugin lifecycle lock) does not change what stop waits for, and stop returned 0 in both failures. Its Windows wait already uses descendantProcesses (scripts/plugin.ts stopInTurn), the reuse-aware walk that skips a process older than its parent. The test's walk had this hole since #330. Whether it shows up depends on which numbers the runner hands out. Two hits half an hour apart, right after #2166 merged, look like timing on the hosted runners rather than something #2166 did, but that is not proven.

Fix (test only). The test builds the owned tree with descendantProcesses, the walk stop uses. After the 10 s deadline, it also drops a member whose number now belongs to a process with a different start time. A member with a missing start time, or a failed table read, stays on the list, so the check still fails closed. No product code changes.

Validation

  • The mechanism on a real PC (home-window, Windows 11), from a scratch script that is not committed: in a table of 418 processes, one stale parent number (1200) took the plain walk to 293 processes, including the bun process running the check. The reuse-aware walk reached 289 and left it out.
  • home-window loops (fresh clone under %TEMP%, throwaway profile, app data and temp folders, HERDR_TEST_MODE=unit, removed afterwards with no bun or herdr process left): the fixed test passed 30 of 30 runs. The unfixed test also passed 10 of 10 there. The failure needs a server-tree process to land on one of the few stale parent numbers, so it did not happen on this PC in 10 tries. The failures above and the walk comparison are the evidence for the cause, not a local reproduction.
  • bun run check fast: green at the head commit (7968 unit tests pass, 0 fail).
  • The Native Windows install job on this PR: see the reruns below.

Reviews

  • omo-native-code-reviewer: APPROVE, no CRITICAL, HIGH or MEDIUM. It confirmed from the CI logs that the runner's pid is process.pid from the earlier test, and that the order of the list matches a walk from boot-time system processes down to the runner. It found no way for the new check to pass while an owned process still runs. LOW notes: the test and stop now share one walk (it keeps its own unit test in server/shell-agent.test.ts); a backwards clock step between a parent's and a child's start; a reused number costing an extra table read within the 90 s timeout.
  • Codex (gpt-6.1-sol, fast, xhigh): PASS, no CRITICAL, HIGH or MEDIUM. One LOW: if an owned number is reused and the final table read then fails, the test still fails, which is fail-closed.

CodeRabbit: test-only change, so no review requested.

…arent number pulls in nothing

The Windows test "starts after its launcher exits, stops its owned tree and
restarts on Windows" built the server's tree with a plain parent walk. Windows
keeps a dead parent's number on its children and hands that number on, so when a
server process got such a number the walk took in long-lived unrelated
processes and everything below them. On runs 40635841024 (#2185) and
40638822136 (#2193) the 128 and 123 "still owned" pids included the test
runner's own pid (8248, 2228), which can never exit.

The test now uses descendantProcesses, the reuse-aware walk stop itself uses,
and after the deadline drops a member whose number a new process holds.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between f2b917a and 48e6c04.

Files selected for processing: 2
  • changelog.d/windows-stop-tree-test-pid-reuse.md
  • scripts/windows-plugin.test.ts
  • 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 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 48e6c04: omo-native-code-reviewer and Codex both pass this head. It fixes the windows-plugin.test.ts:239 flake that failed Native Windows on #2185 and #2193. The test's tree walk pulled in boot processes through a reused parent pid. It now walks the tree the way stop does, without being weakened, and a real leak still fails it. The change is test-only. The required checks are green, and CodeRabbit did not review this head. The LOW notes go to a follow-up issue.

@devswha
devswha merged commit 30cd84f into main Oct 28, 2026
30 checks passed
@devswha
devswha deleted the fix/windows-stop-tree-after-lifecycle-lock branch October 28, 2026 06:36
@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Native Windows install on this head (48e6c04), run 40640646826: attempt 1 passed, and two reruns of only that job passed too (jobs 122669490489, 122670310311). The changed test ran each time: 27.9 s, 26.1 s, 26.5 s, like main's passing runs (23-27 s).

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