Repository navigation
fix(host-core): use wall clock for Windows descendant cleanup - #1970
Conversation
Use current FILETIME before enumeration rather than Host creation time. Otherwise every later runner and escaped descendant is classified as a recycled PID and skipped. Add an owned-child clock regression and preserve both branches of the children-first fixture instead of overwriting its duplicate parent key.
vastsa
left a comment
There was a problem hiding this comment.
Independently confirmed #1969 against main 70b3354 and reviewed head 3bcc90e. I executed the production module with only the Windows API boundary controlled (Host creation=100, descendant creation=200, current FILETIME=1000): main terminates [] instead of [11,10], while this head terminates [11,10]. The existing child-order fixture also fails on main because of the duplicate map key; all five controlled checks pass on this head, including unrelated/cyclic trees and the newer-creation predicate.
The change addresses the actual clock mismatch with a small scope. GetSystemTimeAsFileTime supplies current UTC FILETIME as documented by Microsoft (https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime). Sampling before enumeration conservatively preserves the recycled-PID cutoff. Held handles, error propagation and child-first termination remain intact.
Validation: cargo build -p host-core --locked and cargo fmt --all -- --check passed on macOS; the candidate Host passed scripts/e2e-background-tasks-host.mjs (10 tasks, 202 MB output, bounded streams, turn-abort survival and final output retained). git diff --check passed. All six remote checks passed, including Windows compilation/clippy. Latest main is an ancestor, and merge candidate 28f06c2 has the identical executable tree 25d5fbe5 as the tested head.
Qualification: I did not execute the new native Windows owned-child test or a native Windows process-stop E2E. The current Windows CI runs only transcript/visualization test filters, so its green status does not imply this new test ran. The deterministic production-module regression is the direct behavioral evidence for this clock fix; the macOS Host E2E covers neighboring shared behavior. Scheduling the native process-tree suite in Windows CI would improve ongoing coverage.
Stopping a Windows background task could leave escaped descendants alive: the snapshot watermark used the Host's creation time, so every process started afterwards was treated as a recycled PID. Sample current FILETIME before enumeration, retaining the existing held-handle, PID-reuse, child-first and error-reporting guards.
Add a native owned-child clock regression and fix the children-first test's duplicate HashMap key, which silently discarded one branch. Synchronize the tool contract and Windows qualification scenario.
Validation: the original production module fails the controlled Windows API fixture; the corrected module passes all five checks. Windows x64 GNU target compilation includes the native regression, the macOS Host builds, and
pnpm check:pr-basepasses. Native Windows execution and Desktop E2E were not run.Fixes #1969