Skip to content

fix(windows): eliminate recurring PowerShell process polling - #17115

Closed
OrcaWin wants to merge 4 commits into
mainfrom
OrcaWin/aug28-sta5769-windows-powershell-polling
Closed

OrcaWin wants to merge 4 commits into
mainfrom
OrcaWin/aug28-sta5769-windows-powershell-polling

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2190 $\color{#cf222e}{\Huge{\mathbf{−}}}$​691 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1499
Prod 40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1274 $\color{#cf222e}{\Huge{\mathbf{−}}}$​810 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​464

Summary

  • replace recurring Windows PowerShell/CIM process-table and Resource Manager memory polls with one cached native process inventory
  • extend the patched @vscode/windows-process-tree rows with exact creation identity, command line, working set, private usage, and CPU ticks
  • fence PID reuse, fail closed when native identity is unavailable, and package matching x64/arm64 addons for desktop, relocated daemon, and relay/SSH runtimes
  • add a deterministic physical-Windows child-process oracle and native observer

Fixes #16905. Related to #15209 and #15749.

Root cause

The native process-tree binding did not expose all fields required by foreground/identity and memory consumers. The daemon therefore fell back to Get-CimInstance Win32_Process about every two seconds. Resource Manager independently ran another two-second CIM memory sweep. #16696 fixes retained callbacks after a wedged native read but does not remove either subprocess class.

Physical Windows validation

Byte-identical 60-second oracle (21a9cd4a3221153f6a1c79598d00350aef19e6e9eeff4957d75cdfbe4c418886), one isolated daemon, one stable terminal, 30/30 foreground responses:

Build / Resource Manager Table CIM Memory CIM Other subprocesses Total
signed 1.4.190 / off 33 0 7 40
signed 1.4.190 / on 30 30 7 67
current main / off 32 0 8 40
current main / on 31 30 8 69
candidate / off 0 0 8 8
candidate / on 0 0 9 9
independent revert / off 33 0 9 42
independent revert / on 34 30 8 72

The remaining recurring subprocess is the separate netstat -ano -p tcp port scan at about 30 seconds. Candidate working-set/private-memory and CPU histories continued updating; foreground identity remained 30/30; renderer event-loop p95 was 13.4 ms and stable main/daemon p95 was at most 32.67 ms. No GPO was enabled or modified.

Behavior and trade-offs

  • private memory is native PROCESS_MEMORY_COUNTERS_EX.PrivateUsage, not fabricated from PageFileUsage
  • missing, stale, or wedged native inventory returns unavailable data instead of restarting recurring PowerShell
  • targeted daemon-incarnation and hook-owner identity probes remain event-driven
  • stale old-daemon amplification and port scanning remain separate concerns

Validation

  • pnpm tc:node
  • 166 focused tests passed, 7 skipped
  • oracle seam passed twice, covering async, synchronous, and worker-owned child creation
  • scoped lint and format; git diff --check
  • full pnpm run build:desktop and unpacked Windows package
  • packaged daemon entry, node-pty ownership, plugin resources, x64 runtime, x64/arm64 build/PE/hash checks
  • relay/package/mixed-version/PID-reuse contracts
  • fresh performance, runtime-boundary, and Windows correctness reviews

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR replaces recurring Windows PowerShell process and memory polling with a cached native process inventory and distributes the required native addon across desktop, daemon, and SSH relay runtimes.

  • Adds native process creation identity, command-line, memory, and CPU fields.
  • Adds PID-reuse fencing and fail-closed handling for unavailable or wedged inventory reads.
  • Packages and integrity-checks pinned x64 and arm64 Windows relay addons.
  • Updates memory, foreground-process, and structured-process identity consumers.
  • Adds focused runtime, packaging, mixed-version, and physical-Windows validation tooling.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/main/windows/windows-process-table.ts Replaces the CIM fallback with a bounded, cached native inventory reader that rejects unavailable, incomplete, or wedged reads.
src/main/memory/windows-process-resource-collector.ts Derives Windows memory and CPU samples from native inventory while fencing CPU history by process creation identity.
src/main/runtime/process-start-identity.ts Introduces fresh native process-start identity lookup for Windows PID-reuse protection.
config/scripts/build-relay.mjs Makes the pinned Windows process-tree addon a required, validated relay artifact.
src/main/ssh/ssh-relay-versioned-install.ts Extends versioned Windows relay installation integrity checks to cover the native process-tree addon.
config/patches/@[email protected] Extends the native addon contract with creation identity, memory, CPU, command-line, and uncapped process enumeration fields.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  N[Native Windows process addon] --> I[Cached process inventory]
  I --> F[Foreground and agent identity]
  I --> M[Memory and CPU collection]
  I --> P[Process-start identity]
  B[Pinned x64 and arm64 prebuilds] --> D[Desktop and daemon packages]
  B --> R[Versioned SSH relay package]
  R --> V[Remote integrity validation]
Loading

Reviews (3): Last reviewed commit: "fix(windows): close process inventory re..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a68ac9d4-fe01-41fc-9778-8e00f4fff57c

📥 Commits

Reviewing files that changed from the base of the PR and between a65e257 and 3a6bce7.

📒 Files selected for processing (3)
  • src/main/runtime/agent-session-process-identity-probe.test.ts
  • src/main/runtime/agent-session-process-identity-probe.ts
  • src/main/runtime/process-start-identity.ts

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


📝 Walkthrough

Walkthrough

The change replaces Windows PowerShell and CIM process-table fallbacks with a versioned native addon. It adds memory, CPU, and process-creation identity fields, plus snapshot capture timestamps. Checked-in x64 and arm64 binaries undergo manifest, PE, hash, and runtime validation before staging and packaging. Process identity checks use exact Windows creation IDs when available. Daemon relocation records and verifies addon hashes. New Windows oracle tooling measures process polling, spawn activity, event-loop behavior, and packaged artifact integrity.

Priority: ⬆️ High

Merge Risk: 🔵 Low · up to 3a6bc

In a narrow Windows case, process selection can hide an unrelated reused process, and the polling oracle can fail when the checkout path contains spaces. These are bounded issues suitable for owner follow-up rather than evidence of a broad runtime failure.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 3a6bc

The new native dependency has compatibility and recovery controls, but one mixed-version installation can make a valid process reader unavailable. That matters because process identity is used to protect session ownership. No attacker-reachable bypass was established.

Retained concerns

  • Medium · reliability · inferred: A loadable but outdated package addon prevents the loader from trying a valid staged relay addon. In a mixed-version installation, this makes process-table identity evidence unavailable and can leave ownership decisions indeterminate.
Security review details

Security Blast Radius

  • inferred — The dependency's directly evidenced exposure is process enumeration and identity-dependent behavior on affected Windows desktop, daemon, and relay hosts. The inspected evidence does not establish a new remote entrypoint or cross-tenant reachability.

Security Findings and Attack Paths

  • inferred — No attacker-controlled route to bypass owner verification was established. The identified mixed-version failure instead removes identity evidence; the probe's indeterminate outcome limits an unsupported claim that an owner has died.

Trust Boundaries and Controls

  • observed — Build-time relay asset checks verify architecture and hash, remote Windows installation checks the deployed hash, and runtime loading rejects an addon without the expected contract version and function.

Resilience and Maintainability Implications

  • observed — Native reads have a three-second deadline and reject missing or unreadable snapshots instead of representing them as an empty process list; reservation probing likewise requires positive evidence before calling a reservation unused.

Hardening Proposals

  • proposed — Test and define the intended mixed-version fallback: if a package addon fails its contract, try a separately validated staged addon before caching unavailability.
  • proposed — For native-runtime staging, consider validating the source asset and publishing through an owned temporary path with a defined interrupted-copy recovery path.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, solution, linked issue, Windows validation, and test results. However, it omits most required template sections, including ELI5, What Changed, Why, Visual Proof, … Add the missing template sections. Include a plain-language summary, explicit before-and-after behavior and rationale, visual proof or the required N/A statement, platform-specific testing details with checklist status, AI disclosure when a…
Docstring Coverage ⚠️ Warning Docstring coverage is 18.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 139 functions across 56 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: removing recurring Windows PowerShell process polling.
Linked Issues check ✅ Passed Issue #16905 requires migration of the memory collector and identity probes from recurring Get-CimInstance Win32_Process calls to native process data. src/main/windows/windows-process-table.ts use…
Out of Scope Changes check ✅ Passed The changes remain connected to issue #16905. Native addon packaging, runtime validation, daemon and relay materialization, fail-closed behavior, identity safeguards, memory aggregation, tests, docume…
Full details: Description check

Explanation

The description explains the problem, solution, linked issue, Windows validation, and test results. However, it omits most required template sections, including ELI5, What Changed, Why, Visual Proof, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Add the missing template sections. Include a plain-language summary, explicit before-and-after behavior and rationale, visual proof or the required N/A statement, platform-specific testing details with checklist status, AI disclosure when applicable, review and boundary confirmations, notes on compatibility and security, and the completed checklist.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch OrcaWin/aug28-sta5769-windows-powershell-polling

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (1)
tests/tools/windows-process-polling-oracle/process-snapshot-watch.mjs (1)

11-15: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Validate the numeric arguments.

durationMs and intervalMs are not checked. A non-numeric value produces NaN, the poll loop never runs, and the watcher exits with code 0 and a summary that reports polls: 0. run.mjs treats that exit as a valid observation window, so the run reports no observed process starts instead of failing.

♻️ Proposed guard
 if (!outputPath || !readyPath) {
   throw new Error('--output and --ready are required')
 }
+if (!Number.isFinite(durationMs) || durationMs <= 0) {
+  throw new Error('--duration-ms must be a positive number')
+}
+if (!Number.isFinite(intervalMs) || intervalMs < 0) {
+  throw new Error('--interval-ms must be a non-negative number')
+}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03daebda-d9b9-4da9-9fa2-31e35c5c663e

📥 Commits

Reviewing files that changed from the base of the PR and between 4065d05 and 700b268.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (49)
  • .github/workflows/dev-channel-win-build.yml
  • config/patches/@[email protected]
  • config/relay-assets/windows-process-tree/arm64/windows-process-tree.node
  • config/relay-assets/windows-process-tree/manifest.json
  • config/relay-assets/windows-process-tree/x64/windows-process-tree.node
  • config/scripts/build-relay.mjs
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/ensure-native-runtime.mjs
  • config/scripts/ensure-native-runtime.test.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/rebuild-native-deps.test.mjs
  • config/scripts/windows-process-tree-patch-contract.test.mjs
  • config/scripts/windows-process-tree-relay-prebuild.test.mjs
  • config/scripts/windows-process-tree-runtime-contract.cjs
  • docs/reference/windows-process-enumeration.md
  • pnpm-workspace.yaml
  • src/main/codex/codex-structured-owner-identity.test.ts
  • src/main/codex/codex-structured-owner-identity.ts
  • src/main/daemon/daemon-host-copy-operation.ts
  • src/main/daemon/daemon-host-materialization-integrity.ts
  • src/main/daemon/daemon-host-relocation.test.ts
  • src/main/daemon/daemon-host-relocation.ts
  • src/main/daemon/daemon-host-runtime-path-filter.ts
  • src/main/memory/collector-windows-sweep.test.ts
  • src/main/memory/windows-process-resource-collector.ts
  • src/main/providers/windows-foreground-process-rows.ts
  • src/main/runtime/agent-session-process-identity-probe.test.ts
  • src/main/runtime/agent-session-process-identity-probe.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/process-start-identity.ts
  • src/main/runtime/structured-tui-process-identity.test.ts
  • src/main/runtime/structured-tui-process-identity.ts
  • src/main/ssh/relay-native-dependency-coverage.test.ts
  • src/main/windows/windows-process-table-cim-scan.test.ts
  • src/main/windows/windows-process-table-cim-scan.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
  • src/shared/agent-session-record.ts
  • src/shared/relay-artifacts.ts
  • src/shared/relay-optional-artifacts.test.ts
  • src/shared/relay-windows-process-tree-artifact.test.ts
  • tests/tools/windows-process-polling-oracle/README.md
  • tests/tools/windows-process-polling-oracle/consumer-classifier.mjs
  • tests/tools/windows-process-polling-oracle/event-loop-probe.cjs
  • tests/tools/windows-process-polling-oracle/oracle.test.mjs
  • tests/tools/windows-process-polling-oracle/process-snapshot-watch.mjs
  • tests/tools/windows-process-polling-oracle/process-start-fixture.mjs
  • tests/tools/windows-process-polling-oracle/run.mjs
  • tests/tools/windows-process-polling-oracle/spawn-call-probe.cjs
💤 Files with no reviewable changes (3)
  • src/main/windows/windows-process-table-cim-scan.test.ts
  • src/shared/relay-optional-artifacts.test.ts
  • src/main/windows/windows-process-table-cim-scan.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

native addon reachable from the relay entry is either installed on relay hosts
or listed there with the reason its absence is safe. That test exists because
or staged as a build artifact. That test exists because
#15749 shipped this gap: the relay tests injected a fake module through

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the Markdownlint violation.

Line 141 starts with #15749, which violates MD018. Prefix it with issue .

🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 141-141: No space after hash on atx style heading

(MD018, no-missing-space-atx)

Source: Linters/SAST tools

expectedSha256: marker.windowsProcessTreeSha256
})
) {
return null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not replace a directory that can contain foreign names.

When addon validation fails, line 234 starts rematerialization. materializeRelocatedDaemonHost() then removes the complete version directory before it publishes staging. The new test proves this removes sentinel files that the manifest did not create.

Publish each materialization at an owned unique path, or remove only paths recorded as prior manifest outputs.

As per coding guidelines, “No actor removes a name it did not create.”

Source: Coding guidelines

Comment on lines +100 to +106
if (platform === 'win32' && identity.processStartTimeId) {
const observed = rows.find((row) => row.pid === identity.pid)?.startTimeId
if (observed === undefined || observed === identity.processStartTimeId) {
roots.add(identity.pid)
}
continue
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- scoped repository knowledge ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target outline ---'
ast-grep outline src/main/runtime/structured-tui-process-identity.ts
printf '%s\n' '--- target implementation ---'
sed -n '1,240p' src/main/runtime/structured-tui-process-identity.ts

Repository: stablyai/orca

Length of output: 11219


🏁 Script executed:

#!/bin/bash
set -e
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/*.md /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/architecture/*.md /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/*.md; do
  [ -f "$f" ] || continue
  case "$f" in
    *runtime*|*process*|*identity*|*main*) printf '\n--- %s ---\n' "$f"; cat "$f";;
  esac
done
printf '%s\n' '--- direct symbols and call sites ---'
rg -n -C 4 'probeAgentSessionProcessIdentity|processStartTimeMs|processStartTimeId|structured-tui-process-identity' src/main src test tests 2>/dev/null | head -300

Repository: stablyai/orca

Length of output: 43636


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
cat -n src/main/runtime/structured-tui-process-identity.ts | sed -n '1,240p'
printf '%s\n' '--- repository knowledge headers ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -type f -name '*.md' -maxdepth 2 -print0 |
  xargs -0 -r -n1 sh -c 'echo "--- $0"; head -20 "$0"'

Repository: stablyai/orca

Length of output: 47786


🏁 Script executed:

#!/bin/bash
set -e
target=src/main/runtime/structured-tui-process-identity.ts
printf '%s\n' '--- target source ---'
cat -n "$target" | sed -n '1,240p'
printf '%s\n' '--- relevant repository convention and learning files ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print |
  while IFS= read -r f; do
    if grep -Eiq 'runtime|process|identity|test|review' "$f"; then
      echo "--- $f"
      cat "$f"
    fi
  done
printf '%s\n' '--- direct callers and identity construction ---'
rg -n -C 6 --glob '!node_modules' --glob '!dist' \
  'probeAgentSessionProcessIdentity|processStartTimeMs|processStartTimeId|excluded roots|roots\.add' \
  src test tests 2>/dev/null | head -500

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- exact probe and consumer bindings ---'
rg -n -l 'probeAgentSessionProcessIdentity|processStartTimeId' src/main/runtime src/shared --glob '*.ts' |
  while IFS= read -r f; do
    echo "--- $f"
    rg -n -C 10 'probeAgentSessionProcessIdentity|processStartTimeId|processStartTimeMs !== null|processStartTimeMs === null' "$f"
  done
printf '%s\n' '--- nearby structured-TUI tests ---'
find src/main/runtime -maxdepth 1 -type f -iname '*structured*tui*' -print

Repository: stablyai/orca

Length of output: 33002


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- Windows process-row contract ---'
sed -n '1,260p' src/main/providers/windows-foreground-process-rows.ts
printf '%s\n' '--- structured identity tests around Windows and exclusions ---'
sed -n '1,260p' src/main/runtime/structured-tui-process-identity.test.ts
printf '%s\n' '--- process identity probe implementation ---'
sed -n '140,220p' src/main/runtime/agent-session-process-identity-probe.ts

Repository: stablyai/orca

Length of output: 11739


Handle an exact Windows ID when the timestamp is null.

When processStartTimeMs is null and processStartTimeId is set, compare processStartTimeId before the null fallback. The current branch unconditionally adds the PID to the excluded roots, even when the observed startTimeId differs. probeAgentSessionProcessIdentity also skips process-start verification in this state and may return indeterminate. Add matching and mismatching exact-ID tests.

Comment on lines +141 to +144
cachedModule = hasCurrentProcessTableContract(addon) ? adaptAddon(addon) : null
if (!cachedModule) {
return cachedModule
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- applicable repository knowledge ---'
head -5 /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md 2>/dev/null || true
printf '%s\n' '--- target file outline ---'
ast-grep outline src/main/windows/windows-process-table.ts
printf '%s\n' '--- target file ---'
sed -n '1,175p' src/main/windows/windows-process-table.ts
printf '%s\n' '--- direct symbol references ---'
rg -n -C 3 'PACKAGE_ADDON_SPECIFIER|RELAY_ADDON_FILENAME|hasCurrentProcessTableContract|adaptAddon|windows-process-table|processTableContractVersion' src test tests 2>/dev/null || true

Repository: stablyai/orca

Length of output: 33507


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- src conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.md
printf '%s\n' '--- loader tests ---'
sed -n '1,380p' src/main/windows/windows-process-table.test.ts
printf '%s\n' '--- remaining target flow ---'
sed -n '175,370p' src/main/windows/windows-process-table.ts

Repository: stablyai/orca

Length of output: 23077


Fall through to the staged addon when the package addon fails the contract check.

When hasCurrentProcessTableContract(addon) returns false, loadWindowsProcessTree() sets cachedModule to null and returns before requiring RELAY_ADDON_FILENAME. A valid staged addon is therefore unavailable, and native process-table reads reject as unavailable. Add a test for an invalid package addon and a valid staged addon.

{
env: {
...process.env,
NODE_OPTIONS: `--require=${path.join(import.meta.dirname, 'spawn-call-probe.cjs')}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🌐 Web query:

For Node.js 24, does a --require path containing spaces need double quotes when passed through NODE_OPTIONS?

💡 Result:

Yes, if a path passed through NODE_OPTIONS contains spaces, it must be escaped using double quotes [1][2][3]. According to official Node.js documentation, when providing a value that contains a space (such as a file path for --require) within the NODE_OPTIONS environment variable, you must wrap that path in double quotes [1][3]. For example: NODE_OPTIONS='--require "./my path/file.js"' This requirement applies to Node.js 24 and other modern versions, as the parsing logic for NODE_OPTIONS explicitly supports this escaping mechanism to handle paths containing spaces correctly [4][3][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- applicable repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -type f -name '*.md' -maxdepth 3 -print 2>/dev/null | sort | while read -r f; do
  case "$f" in
    */learnings/*|*/architecture/*|*/conventions/*) printf '%s\n' "### $f"; head -80 "$f";;
  esac
done
printf '%s\n' '--- test structure and launch sites ---'
ast-grep outline tests/tools/windows-process-polling-oracle/oracle.test.mjs 2>/dev/null || true
sed -n '1,180p' tests/tools/windows-process-polling-oracle/oracle.test.mjs
printf '%s\n' '--- all NODE_OPTIONS references in the file ---'
rg -n -C 4 'NODE_OPTIONS|spawn|exec|fork' tests/tools/windows-process-polling-oracle/oracle.test.mjs

Repository: stablyai/orca

Length of output: 11091


Quote the preload path in all NODE_OPTIONS assignments.

If the checkout path contains spaces, Node can split the unquoted --require value. The child process may exit before spawn-call-probe.cjs loads. Apply this at lines 93, 121, and 148.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (1)
tests/tools/windows-process-polling-oracle/run.mjs (1)

41-41: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate the raw --exe argument before path.resolve.

Line 43 now guards --output, but line 41 still resolves --exe unconditionally. path.resolve('') returns the current working directory, so an omitted --exe produces an existing directory path. The later existsSync(exePath) check passes, label becomes the basename of the working directory, and the run fails later with an opaque launch or hashing error instead of a clear missing-argument error.

Apply the same guard used for --output.

🛠️ Proposed fix
-const exePath = path.resolve(arg('--exe', ''))
+const exeArg = arg('--exe', '')
+if (!exeArg) {
+  throw new Error('--exe is required')
+}
+const exePath = path.resolve(exeArg)
 const outputDirArg = arg('--output', '')

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de292fa6-33f5-482e-af47-f39ca0610408

📥 Commits

Reviewing files that changed from the base of the PR and between 700b268 and 8ae3e02.

📒 Files selected for processing (23)
  • config/scripts/build-relay.mjs
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/windows-process-tree-relay-asset.mjs
  • config/scripts/windows-process-tree-relay-prebuild.test.mjs
  • src/main/daemon/daemon-host-relocation.ts
  • src/main/memory/collector-windows-sweep.test.ts
  • src/main/memory/collector.test.ts
  • src/main/memory/collector.ts
  • src/main/memory/memory-snapshot-values.ts
  • src/main/memory/windows-process-resource-collector.ts
  • src/main/ssh/ssh-relay-versioned-install-windows-integrity.test.ts
  • src/main/ssh/ssh-relay-versioned-install.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
  • src/renderer/src/store/slices/memory.test.ts
  • src/shared/windows-process-tree-relay-manifest.ts
  • tests/tools/windows-process-polling-oracle/README.md
  • tests/tools/windows-process-polling-oracle/observer-spawn-cross-check.mjs
  • tests/tools/windows-process-polling-oracle/oracle-lifecycle.mjs
  • tests/tools/windows-process-polling-oracle/oracle-seam.mjs
  • tests/tools/windows-process-polling-oracle/process-snapshot-watch.mjs
  • tests/tools/windows-process-polling-oracle/renderer-window-probe.mjs
  • tests/tools/windows-process-polling-oracle/run.mjs
💤 Files with no reviewable changes (1)
  • src/main/memory/memory-snapshot-values.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/daemon/daemon-host-relocation.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

harness never launches PowerShell or WMI itself.

Each run has two non-overlapping stable windows. The first is the authoritative cadence and event-loop
evidence window. The second runs the 25ms native Toolhelp observer while exercising the same foreground

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Describe the observer polling interval accurately.

Line 10 calls this a “25ms ... observer window,” but Line 24 says --observer-duration-ms controls the window duration. State that the observer polls every 25 ms to avoid misreading the run timing.

observer exclusively creates its output and readiness files, so stale artifacts can never satisfy a
new run or be appended into its report. Use a fresh directory for every binary/state combination.

Run against an installed or unpacked packaged executable. Reports hash packaged `app.asar`, the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Clarify the packaged executable wording.

The phrase “unpacked packaged executable” is ambiguous. Use “an installed executable or an executable from an unpacked package” so the expected --exe input is clear.

🧰 Tools
🪛 LanguageTool

[grammar] ~29-~29: Use a hyphen to join words.
Context: ...packed packaged executable. Reports hash packaged app.asar, the process-table a...

(QB_NEW_EN_HYPHEN)

Source: Linters/SAST tools

new run or be appended into its report. Use a fresh directory for every binary/state combination.

Run against an installed or unpacked packaged executable. Reports hash packaged `app.asar`, the
process-table addon when present, and the materialized daemon executable, entry, and addon.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- scoped knowledge files ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- first five lines of knowledge files ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
  [ -f "$f" ] || continue
  printf '\n### %s\n' "$f"
  head -5 "$f"
done
printf '%s\n' '--- target file ---'
cat -n tests/tools/windows-process-polling-oracle/README.md
printf '%s\n' '--- related files ---'
find tests/tools/windows-process-polling-oracle -maxdepth 2 -type f -print | sort
printf '%s\n' '--- oracle-seam references ---'
rg -n -C 4 --glob '!node_modules' 'oracle-seam|process-table|addon|packaged executable|materialized' tests/tools/windows-process-polling-oracle

Repository: stablyai/orca

Length of output: 22764


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- oracle-seam outline ---'
ast-grep outline tests/tools/windows-process-polling-oracle/oracle-seam.mjs
printf '%s\n' '--- run outline ---'
ast-grep outline tests/tools/windows-process-polling-oracle/run.mjs
printf '%s\n' '--- oracle-seam source ---'
cat -n tests/tools/windows-process-polling-oracle/oracle-seam.mjs
printf '%s\n' '--- run artifact/hash/comparison sections ---'
sed -n '1,180p' tests/tools/windows-process-polling-oracle/run.mjs
sed -n '430,540p' tests/tools/windows-process-polling-oracle/run.mjs
rg -n -C 6 'oracleSha256|sha256|windows_process_tree|process-tree|artifact|hash|missing|existsSync|readFileSync' tests/tools/windows-process-polling-oracle/run.mjs tests/tools/windows-process-polling-oracle/oracle-seam.mjs

Repository: stablyai/orca

Length of output: 48461


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- report assembly and bundle files ---'
sed -n '180,315p' tests/tools/windows-process-polling-oracle/run.mjs
printf '%s\n' '--- addon packaging/build references ---'
rg -n -C 5 --glob '*.mjs' --glob '*.json' --glob '*.yml' --glob '*.yaml' --glob '*.js' \
  'build-windows-process-tree-relay-addon|windows_process_tree\.node|windows-process-tree|bundleFiles|oracleSha256|productHashes' \
  config package.json tests | head -260

Repository: stablyai/orca

Length of output: 27495


Fail closed when the packaged process-table addon is missing. run.mjs filters nonexistent addon paths before recording productHashes.packaged, so the report can omit this required artifact without failing. Require the addon or document the supported exception.

@IsidroLOlguin

Copy link
Copy Markdown

Heads up for whoever picks this back up: as of 1.4.205 the package this needs to copy alongside @vscode/windows-process-tree was renamed — windows-native-registry is now @orca/windows-registry, and it's scoped, so the destination path carries the extra level. This PR copies only the process-tree addon; without the registry one, readWindowsPathRegistry() catches the broken require and returns failed: true, so the relocated daemon's PTYs silently never pick up a PATH change made in the Windows environment variables.

Both copy ops being optional: true is what makes this quiet: a specifier that no longer names a shipped package copies zero files and keeps going. Measured on 1.4.205 with the relocated host missing both: 18 Get-CimInstance Win32_Process scans per minute out of the daemon. Details and measurements in #19522.

A row whose process denied a query handle carries creationTimeMs but no
startTimeId. Requiring an exact-id match then reported identity-mismatch
for a live owner. Compare exact ids only when both sides have one, and
fall back to the millisecond tolerance main already uses.
@OrcaWin

OrcaWin commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this. Thank you for the work here: it pinned down exactly where Orca was still starting PowerShell on Windows.

Since this was opened, main has moved past most of it, often in a different direction:

The branch is also about 2,400 commits behind and conflicts in 25 files. Several of its pieces would reintroduce problems main has since fixed:

  • the checked-in, unsigned prebuilt add-ons
  • removing the PowerShell fallback, so a stale add-on silently breaks Windows process detection
  • the full-snapshot memory read

(A small identity-matching fix was pushed here as 3a6bce7. It compares exact start-time ids only when both sides have one. It'll be carried forward if still needed.)

The launches that remain are tracked in #16905:

  • the Resource Manager's memory query
  • a few one-off identity checks

They'll be handled in a small follow-up PR that uses the add-on main already builds.

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.

[Bug]: Windows relocated terminal daemon spawns powershell.exe every ~2s (native process-tree addon missing from daemon host)

2 participants