Repository navigation
perf(cli): reduce Windows process probes during session shutdown - #2046
techotaku39 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Review mode: initial
Requirement — Pass
Reducing repeated Windows process probes addresses a supported shutdown bottleneck while preserving process-tree termination and shared-session protection.
Evidence
- The snapshot PR description identifies archive latency from repeated PowerShell/CIM and tasklist probes.
- Base cli/src/utils/process.ts:230 queries CIM for each parent; :406 and :418 perform individual generation and exit probes.
Approach — Pass
One tree enumeration and fresh snapshots per shutdown phase reduce probe counts. Generation rechecks, conservative handling of unknown identities, and individual fallback checks preserve the termination safeguards.
Evidence
- cli/src/utils/process.ts:259 builds parent links from one CIM enumeration.
- cli/src/utils/process.ts:482 batches generation observations; :517 rechecks survivors before signalling; :549 distinguishes PID reuse from unknown identity.
- cli/src/runner/run.ts:1127 reads registry records before obtaining a fresh process snapshot for sibling protection.
Code — Reviewed
Reviewed the entire fixed-head merge-base diff and relevant callers. No concrete introduced defects found. Runtime behavior was assessed statically without executing PR code.
No reportable code issues found.
Testing
Not run (automation; PR code execution is prohibited).
- At inspection, fixed-head integration CI passed; test and windows-codex-mcp jobs remained in progress.
- Added coverage addresses snapshot validation, PID reuse, unknown generations, individual fallback behavior, single-process cleanup, parent cycles, and large Windows PIDs.
- The PR reports 154 focused tests, typecheck/build, and Windows acceptance checks passing. These results were not independently reproduced; no tests or scripts were run during review.
HAPI Bot
There was a problem hiding this comment.
Review mode: follow-up after new commits
Requirement — Pass
Reducing repeated Windows process probes addresses shutdown latency while preserving verified process-tree termination and shared-session protection.
Evidence
- The snapshot PR description identifies repeated PowerShell/CIM and tasklist probes as an archive bottleneck.
- Base cli/src/utils/process.ts:230 enumerates children separately for each parent; :406 captures generation markers individually.
Approach — Pass
A single tree enumeration and fresh snapshots per shutdown phase reduce probe costs. Individual fallback checks, generation rechecks before signalling survivors, and conservative handling of unknown identities preserve the relevant safeguards.
Evidence
- cli/src/utils/process.ts:259 builds parent links from one enumeration; :482 batches generation observations; :517 rechecks survivors before signalling; :549 distinguishes generation changes from unknown identities.
- cli/src/runner/run.ts:1127 reads registry records before obtaining a fresh snapshot for runtime liveness and sibling protection.
Code — Reviewed
Reviewed the entire fixed-head merge-base diff and relevant surrounding code, including the updated PowerShell fixtures. No concrete introduced defects found. Runtime behavior was assessed statically without executing PR code.
No reportable code issues found.
Testing
Not run (automation; PR code execution is prohibited).
- At inspection, fixed-head integration and windows-codex-mcp CI checks passed; the test check remained in progress.
- Added coverage addresses snapshot validation, unknown generations, PID reuse, individual fallback, single-process cleanup, parent cycles, and large Windows PIDs.
- The PR reports 154 focused tests, typecheck/build, and Windows acceptance checks passing on #2035 plus this patch. These results were not independently reproduced; no tests, builds, or scripts were executed during review.
HAPI Bot
Summary
Windows session shutdown repeatedly launches PowerShell/CIM and
tasklistprobes for the same process tree, adding seconds to archive requests.Validation
From
cli/, ran the following command: 154 tests passed, including generation changes, stale or unavailable snapshots, unknown identities, single-process cleanup, and actual Windows PowerShell query execution.bun run typecheck— passed.bun run buildandbun run --cwd cli build:exe:allinone— passed.bun run test:e2e -- terminal-wrap-fidelity.spec.ts, executed through the isolated task wrapper — 2 passed.Local packaged Windows acceptance, using an isolated Hub, Runner, fresh database and mock model:
2 passed using a workspace-local acceptance harness:
All validation above ran on #2035 plus this patch, without #2036.
Related Issues
Depends on #2035.
AI Assistance
Implemented and validated with assistance from OpenAI Codex (GPT-6).