Skip to content

fix(windows): unblock structured native chat by exposing process creation time - #18986

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/windows-creationtime-guard
Sep 6, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/windows-creationtime-guard

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​98 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​640 $\color{#cf222e}{\Huge{\mathbf{−}}}$​324 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​316

What this fixes

Structured Claude native chat is unavailable on Windows, and nothing in the Claude code path is at fault. supportsClaudeStructuredLocation reduces on win32 to isWindowsProcessStartTimeAvailable(), which needs a process creation time from @vscode/windows-process-tree. Our pinned patch never added that field, so the gate failed closed and every structured session on Windows silently fell back to the legacy terminal path.

Fixing that surfaced three further defects in the same family, each of which would have made the fix look correct while leaving it broken.

The change

The dependency. The patch gains CreationTime (flag 4) — GetProcessCreationTime opens PROCESS_QUERY_LIMITED_INFORMATION and converts GetProcessTimes' FILETIME to Unix ms. A process that denies the handle is emitted with the field absent, never zero, so callers can distinguish "cannot identify" from a timestamp.

The binary describes itself. The patch also exports supportedProcessDataFlags from src/addon.cc. This package publishes its prebuilt at the exact path node-gyp writes to, and the field is only discoverable through an async call — so there was no synchronous way to tell a patched binary from a stock one. isWindowsProcessStartTimeAvailable() now reads that export rather than the JS enum.

The build actually rebuilds it. ensure-native-runtime.mjs proved nothing but require(), which succeeds against upstream's prebuilt, so the patched C++ was never compiled in the node-runtime lane. A shared config/scripts/windows-process-tree-creation-time.cjs now asserts the capability and routes into the existing failure→rebuild path, mirroring node-pty-job-ownership.cjs. rebuildNodeRuntimeModules also could not have rebuilt this package even when asked — the patched binding.gyp includes deps/node-addon-api, which the tarball does not ship — so headers are staged and the realpath resolved first.

The relay path asked for nothing. PROCESS_DATA_FLAG omitted CreationTime, so flags = CommandLine | (CreationTime ?? 0) resolved to 2. A relay host would compile the addon with support and never request it, leaving verifyWindowsProcessIdentity permanently false and terminateIdentifiedWindowsProcessTree unable to kill.

A guard that runs on the platform it guards. windows-process-table.test.ts pins the predicate through an injected fake loader, so it can never observe the real addon. The new *.win32.test.ts uses the existing it.runIf(process.platform === 'win32') idiom and asserts the gate opens, that rows carry creationTimeMs, and that our own row's value is between 2020 and now — an unconverted 100ns tick lands astronomically high, a 1601 epoch below the floor.

Measured on real Windows hardware

Two-point ablation, same box and worktree, only the patch differing:

before after
addon size / mtime 152064 / 23:45:44Z 152576 / 23:50:19Z
ProcessDataFlag None, Memory, CommandLine + CreationTime: 4
isWindowsProcessStartTimeAvailable() false true
rows carrying creationTimeMs — 402 / 540

Both binaries differ in size and mtime, ruling out the case where patched JS opens the gate while a stale .node returns nothing.

CI proved that case is not hypothetical. The guard's first run failed with expected 0 to be greater than 0 while the gate assertion passed — exactly the stale-binary state, caused by the rebuild gap above. An enum-only assertion would have gone green.

Parity sweep on Windows

Structured chat driven end to end in a running app: routing to agent-session, multi-turn state carried across turns, a real tool call reading a repo file, interrupt leaving the composer usable, transcript surviving tab switches, and teardown leaving no orphaned descendants (claude and its conhost child both reaped, no reparented stream-json processes).

Three platform differences worth knowing, none blocking: Windows spawns a conhost.exe child per agent that orphan logic must expect; the capability gate has no macOS/Linux analogue; tool-call paths render with native backslashes.

Note for the Windows Codex lane

Once this lands, supportsCodexStructuredLocation also answers supported: true on Windows. Codex still routes to legacy because of the client-side term in src/renderer/src/lib/agent-launch-routing.ts, which is that lane's to lift. Measured: host gate true, routing still legacy-native-chat. No Codex behaviour changes here.

Deliberately excluded

CLAUDE_SECURESTORAGE_CONFIG_DIR is absent from CLAUDE_AUTH_ENV_VARS, so an inherited value overrides the pinned account home for credential lookup; nothing normalizes config-dir path separators; refreshLocalRuntimeCapabilities() is async and an agent launched before it settles sees empty capabilities and silently routes legacy; the .gitattributes comment on config/patches/*.patch describes pnpm as hashing "byte-for-byte" when it normalizes line endings first. All real, none required here, all filed rather than bundled.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Windows process-tree addon now retrieves and exposes process creation times in Unix milliseconds. Process enumeration continues beyond 1024 entries. The addon reports its supported process-data flags. Build scripts repair and validate the patched sources and native binary. Windows process-table logic checks the reported capability bitmask. Tests and documentation cover patched and stale addon behavior.

Merge Risk: 🟡 Moderate · up to 72df8

Windows process-tree enumeration now supplies creation times, but a PID reused during collection can be misidentified as a descendant and lead cleanup to target an unrelated process. Resolve the snapshot consistency issue before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a detailed technical explanation and validation summary, but it does not follow the required template. It omits the required Linked Issue, Testing, AI Disclosure, Review, Agent s… Add all required template sections. Include a real issue reference after Fixes #, document testing steps and platforms, complete the required checklists, address AI disclosure and review details, and add visual proof or state N/A with a…
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (3 skipped:… 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 Windows fix and its primary purpose: exposing process creation time to unblock structured native chat.
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.
Full details: Description check

Explanation

The description gives a detailed technical explanation and validation summary, but it does not follow the required template. It omits the required Linked Issue, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and it does not provide the required visual-proof statement for this behavior change.

Resolution

Add all required template sections. Include a real issue reference after Fixes #, document testing steps and platforms, complete the required checklists, address AI disclosure and review details, and add visual proof or state N/A with a reason if no visual or interaction change applies.

Full details: Docstring Coverage

Explanation

Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 67bdb106-f350-4aaa-a7ce-48b9bbaf6214

📥 Commits

Reviewing files that changed from the base of the PR and between 84432d3 and f9d9a4d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .github/workflows/pr.yml
  • config/patches/@[email protected]
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/pr-code-change-scope.mjs
  • src/main/windows/windows-process-table-native-addon.win32.test.ts

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • @vscode/[email protected] patch — Adds a CreationTime = 4 data flag and a creationTimeMs field across the native snapshot (process.h/process.cc), worker emission (process_worker.cc), the shipped lib/index.js enum, and the typings, matching the value windows-process-table.ts already reads.
  • Relay addon build script — Extends applyWindowsProcessTreeBuildFixes to repair un-applied creation-time hunks and assertPatchApplied to verify them, so a relay binary compiled from a partially-patched package cannot silently omit the field.
  • Real-addon guard test — A Windows-only test that asserts isWindowsProcessStartTimeAvailable() is true and that a fresh snapshot actually carries creationTimeMs rows, pinning both the enum and the native binary rather than only one.
  • CI wiring — Registers the test in the Windows job and the change-scope map, and bumps the patch hash in pnpm-lock.yaml (sha256 verified to match the patch file).

ℹ️ Creation-time patch is encoded in three places

The patch content now lives in the .patch file, the repairCreationTimeSources() rewrite, and the assertPatchApplied() verification strings. That redundancy is load-bearing — it is what keeps a relay binary from shipping stale when pnpm materializes the CRLF package without applying the patch — but a future native edit (renaming GetProcessCreationTime, changing the epoch math, adjusting the emission guard) now has to be synced across three sites by hand. No action needed for this PR; flagging so the next change to this addon knows to keep them in lockstep.

Technical details
# Creation-time patch has three sources of truth

## Affected sites
- config/patches/@[email protected] — authoritative pnpm patch
- config/scripts/build-windows-process-tree-relay-addon.mjs:112 `repairCreationTimeSources()` — JS reimplementation applied before build
- config/scripts/build-windows-process-tree-relay-addon.mjs:92 `assertPatchApplied()` — substring checks run after repair

## Open questions for the human
- Is the repair+verify redundancy worth maintaining vs. trusting pnpm and letting the build fail loudly on a missing hunk?

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Extended the relay bare-addon reader to request creation times — readNativeRows now asks for CommandLine | CreationTime (flag 6) on the relay addon path as well as the desktop package path, so a relay host's own teardown and identity probe can PID-reuse-safely re-identify descendants instead of treating every row as a bare pid.
  • Named CreationTime: 4 in the relay's PROCESS_DATA_FLAG — documented why the bit is hardcoded rather than probed on the relay path (content-hashed artifact shipped in the same immutable relay directory as the bundle).
  • Tightened the real-addon guard test — asserts the querying process's own row carries a creation time bounded by 2020-01-01 and Date.now(), so a raw FILETIME or unconverted 100ns tick can no longer satisfy the check.
  • Updated the relay-reader unit test and enumeration docs — the injected-addon test now expects flag 6 and isWindowsProcessStartTimeAvailable() === true, and the docs reflect the new creationTimeMs capability.

The extension is well-reasoned: isWindowsProcessStartTimeAvailable() returning true on the relay is inert (its only consumers require LOCAL_EXECUTION_HOST_ID), and the teardown/identity consumers read actual row fields and fail safe when creationTimeMs is absent, so a stale addon cannot fail open.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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.

♻️ Duplicate comments (1)
config/scripts/build-windows-process-tree-relay-addon.mjs (1)

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

Fix the TypeScript destructuring repair.

Line 257 matches the JavaScript parameter shape only. It does not match children }: IProcessInfoNode in lib/index.ts.

When the repair path runs, lines 259-262 add creationTimeMs, to the returned object without adding it to the TypeScript destructuring. lib/index.ts then references an undeclared identifier, and assertPatchApplied() still passes.

Proposed fix
-      next = next.replace(/(memory, commandLine)( \}, children \})/, '$1, creationTimeMs$2')
+      const buildNodeDestructure = isTs
+        ? /(memory, commandLine)( \}, children \}:)/
+        : /(memory, commandLine)( \}, children \})/
+      next = next.replace(buildNodeDestructure, '$1, creationTimeMs$2')

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 3cfb0d81-b0c0-4e39-8d08-a560aa4ef978

📥 Commits

Reviewing files that changed from the base of the PR and between 408fe94 and 41a1309.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • config/patches/@[email protected]
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/ensure-native-runtime.mjs
  • config/scripts/pr-code-change-scope.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/windows-process-tree-creation-time.cjs
  • docs/reference/windows-process-enumeration.md
  • src/main/claude/claude-structured-location-support.test.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/windows/windows-process-table.ts
  • docs/reference/windows-process-enumeration.md

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Added a binary self-report for creation-time support — the patch now makes addon.cc export supportedProcessDataFlags (MEMORY | COMMANDLINE | CREATIONTIME), re-exported through lib/index.js and lib/index.ts, and isWindowsProcessStartTimeAvailable() now reads that bit instead of the patched enum. This closes the hole the previous enum gate left open: pnpm patches the source tree over the tarball's prebuilt .node, so a host could hold CreationTime: 4 in the enum while the binary silently ignored flag 4.
  • Wired an install-time guard that forces a source rebuild — the new windows-process-tree-creation-time.cjs asserts the binary reports bit 4, and both ensure-native-runtime.mjs (Node check) and rebuild-native-deps.mjs (Electron probe) call it, so a stale prebuilt is rebuilt rather than trusted.
  • Extended the relay addon repair/verify to the new export — build-windows-process-tree-relay-addon.mjs repairs and asserts supportedProcessDataFlags across addon.cc, both lib/index* files, and the typings, keeping the repair and the verification in lockstep.
  • Tightened the tests — the unit test now covers the enum-present-but-binary-stale shape (supportedProcessDataFlags: 3), the no-export shape, and a relay "trust the addon's own report" case; the real-addon test keeps pinning both the gate and the bounded self-row.

The mechanism is sound on both deployment paths: on desktop the assert/rebuild flow guarantees the .node and the package's re-export agree, and on the relay the addon and reader are content-hashed into the same immutable bundle, so there is no cross-version window.

One informational note, not blocking: the PR description still cites the previous patch hash (c8de5dc3…) in its "sha256 is the patch_hash" verification claim, but the lockfile now records 76fc1512…. Worth updating so the self-verification claim stays accurate for reviewers.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — one follow-up commit since the last Pullfrog review.

  • Kept the process-tree patch LF-only — stripped the 154 CR bytes that pnpm patch-commit emitted for the CRLF-shipped source files (src/addon.cc, lib/index.js, lib/index.ts, the typings), restoring compliance with the main-branch windows-process-tree-patch-contract.test.mjs contract while the pnpm patch hash stays 76fc1512… (equal to the file's plain sha256).
  • Staged the native-runtime siblings in the test harness — ensure-native-runtime.test.mjs now copies windows-process-tree-creation-time.cjs and windows-process-tree-gyp-rebuild.mjs into its temp project alongside node-pty-job-ownership.cjs, so the module-scope imports in ensure-native-runtime.mjs resolve and the suite stops dying at import.

Verified the patch is byte-clean (0 CR bytes, sha256 matches the lockfile) and that the sibling list is complete against all three module-scope imports.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Status: green and validated on real Windows hardware

CI: run 34007244479 — 29 pass, 2 conditional skips, 0 red. package (windows) is green through all 13 steps, including 7–13 (Build package inputs → Package unpacked app → Smoke packaged PTY → Smoke packaged CLI). An earlier run stopped at step 6, so there was no evidence the packaged app got a capable addon; there is now.

The review found three defects beyond the original one

The PR started as a dependency patch. Reviewing it surfaced three more problems in the same family — each would have left the fix looking correct while it was broken:

trusted reality
"the module loads" it loads on the stock prebuilt; the patched C++ was never compiled
"the JS enum has the flag" the binary may not — the gate now reads supportedProcessDataFlags
"the flag constant is complete" the relay adapter requested flags=2, so identity verification was permanently false
"enum present ⇒ patch applied" an includes() early-out skipped the buildNode splat in the repair path

Three of those four would have shipped a Windows build where the gate opens and structured chat is admitted, but the child-tree reaper can never prove an exit — degraded silently, not loudly.

The guard caught the real one, in CI, on its first run

✗ reads creation times from the real Windows process-tree addon
AssertionError: expected 0 to be greater than 0

The gate assertion passed; the row assertion failed. That is precisely the patched-JS/stale-binary state, and an enum-only test would have gone green. The fix is visible in the current log:

[native-runtime] @vscode/windows-process-tree does not report CreationTime support
                 (supportedProcessDataFlags=undefined). That is the tarball prebuilt.
[native-runtime] Rebuilding @vscode/windows-process-tree with node-gyp.
✓ src/main/windows/windows-process-table-native-addon.win32.test.ts (1 test) 16ms

Parity sweep, driven through the running app on Windows

Structured routing to agent-session; multi-turn state carried across turns; a real tool call reading a repo file; interrupt leaving the composer usable; transcript surviving tab switches; and teardown leaving no orphaned descendants — claude and its conhost child both reaped, no reparented stream-json processes.

Three platform differences documented, none blocking: Windows spawns a conhost.exe child per agent that orphan logic must expect; the capability gate has no macOS/Linux analogue; tool-call paths render with native backslashes.

Verification notes

  • Patch is LF-only (0 CR bytes); raw and LF-normalized sha256 coincide at 76fc1512… and match the lockfile at all sites. A cold-store install — materialized package deleted — re-applies every hunk; flipping one hex digit of the recorded hash produces ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, so that check is not vacuous.
  • The gate fails closed: absent export → 0 & 4 → false, so an incapable binary refuses structured chat rather than admitting it.
  • The 1024-process cap removal in process.cc is pre-existing on main, not this PR.

Known-excluded, filed not bundled

CLAUDE_SECURESTORAGE_CONFIG_DIR missing from CLAUDE_AUTH_ENV_VARS; no config-dir separator normalization; refreshLocalRuntimeCapabilities() racing an early agent launch into a silent legacy route; and the .gitattributes comment describing pnpm as hashing patches "byte-for-byte" when it normalizes line endings first.

For the Windows Codex lane

Once this lands, supportsCodexStructuredLocation also answers supported: true on Windows. Codex still routes to legacy because of the client-side term in src/renderer/src/lib/agent-launch-routing.ts — that term is yours to lift, and nothing in your own diff will explain why it is there.

Merge Sim added 4 commits September 6, 2026 12:49
The relay addon build now emits creationTimeMs, but the runtime binding
for the bare addon still declared only CommandLine, so a Windows relay
host requested flag 2 and every row came back without a creation time.
That leaves captureWindowsDescendantSnapshot returning null and
verifyWindowsProcessIdentity false forever on those hosts -- the relay
half of the patch was unreachable.

Naming CreationTime in the adapter is safe because the bare addon is a
content-hashed relay artifact: it ships in the same immutable relay
directory as the bundle reading it, so it can never be older than the
code asking for the bit.

Also bound the win32 guard test on our own row, which the addon can
never fail to answer, so an unconverted FILETIME or a 1601-epoch stamp
fails instead of satisfying a bare count.
CI caught the real defect: the win32 guard test read
isWindowsProcessStartTimeAvailable() as true and then found 0 rows
carrying creationTimeMs. Unlike node-pty, this package publishes a
prebuilt .node at the same build/Release path node-gyp writes to, so
pnpm patches the source tree and leaves that binary alone. A host then
holds a patched lib/index.js -- ProcessDataFlag.CreationTime and all --
over a binary that ignores flag 4, and neither a load check nor a path
check can see the difference.

So the binary now says so itself: addon.cc exports
supportedProcessDataFlags, lib/index.js re-exports it, and

  - windows-process-tree-creation-time.cjs asserts it during install,
    which is what forces a from-source rebuild. It is shared by the Node
    probe in ensure-native-runtime.mjs and the Electron probe in
    rebuild-native-deps.mjs, exactly as node-pty-job-ownership.cjs is --
    the Electron half matters because that probe decides onlyModules, so
    without it the packaged app would ship the stale prebuilt.
  - isWindowsProcessStartTimeAvailable() gates on the reported bit, not
    the enum. Believing the enum is worse than reporting false: the
    descendant snapshot returns null forever and the exit proof latches
    unverifiable while structured chat believes it has a reaper.

rebuildNodeRuntimeModules could not actually have rebuilt this package:
the patched binding.gyp includes deps/node-addon-api, which the tarball
does not ship, and node-gyp must run from the physical dir.

Also closes the relay repair path's divergence: repairCreationTimeSources
wrote the C++ but not the buildNode splat or the tree-node typing, and
assertPatchApplied checked neither, so a repaired tree passed as patched
with buildProcessTree silently dropping the field.

The guard test is unchanged.
windows-process-tree-patch-contract.test.mjs requires the patch file to
carry no CR bytes. Regenerating through pnpm patch-commit emitted 199 of
them, because the creation-time change is the first to touch files the
package ships as CRLF (src/process.h, src/process_worker.cc,
src/addon.cc, lib/index.js, lib/index.ts, the typings) -- and #17886's
own hunks over binding.gyp and src/process_commandline.cc carry the rest.

Stripping them is safe and changes nothing the lockfile records: pnpm
hashes patches CRLF-normalized, so the digest stays
e66202cc623996d02040c93449eb9ae353fddadf426cb53202a59ee710ee6fe7 and now
equals the file's plain sha256 too. It also still applies -- verified
against a deleted store entry, not a warm one -- and the precedent was
already there: the previous patch was LF-only and had been patching
those same CRLF files all along.

ensure-native-runtime.test.mjs stages the siblings the script loads at
module scope into its temp project. The import walk added by #17886 sees
`from './x.mjs'` only, so the createRequire'd .cjs siblings still have to
be named, and this PR adds a second one.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/windows-creationtime-guard branch from cc0d94a to 72df82c Compare September 6, 2026 19:52
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 792b3d29-e102-48b7-bff5-af63f9a33dab

📥 Commits

Reviewing files that changed from the base of the PR and between d07c475 and 72df82c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .github/workflows/pr.yml
  • config/patches/@[email protected]
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/ensure-native-runtime.mjs
  • config/scripts/ensure-native-runtime.test.mjs
  • config/scripts/pr-code-change-scope.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/windows-process-tree-creation-time.cjs
  • docs/reference/windows-process-enumeration.md
  • src/main/claude/claude-structured-location-support.test.ts
  • src/main/windows/windows-process-table-native-addon.win32.test.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
  • src/main/windows/windows-process-tree-command-line-patch.test.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • .github/workflows/pr.yml
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/ensure-native-runtime.test.mjs
  • config/scripts/ensure-native-runtime.mjs
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/windows-process-tree-creation-time.cjs
  • src/main/windows/windows-process-table-native-addon.win32.test.ts
  • config/scripts/pr-code-change-scope.mjs
  • src/main/claude/claude-structured-location-support.test.ts
  • src/main/windows/windows-process-table.test.ts
  • docs/reference/windows-process-enumeration.md

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

Comment on lines +130 to +131
+ if (CREATIONTIME & process_data_flags) {
+ GetProcessCreationTime(pinfo);

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 | 🟠 Major | 🏗️ Heavy lift

Keep ppid and creationTimeMs from one process instance.

Line 131 opens the PID after Toolhelp captured process_entry. If that process exits and Windows reuses its PID before this call, creationTimeMs belongs to the replacement process while ppid and name belong to the old process. Descendant cleanup can then classify an unrelated replacement process as a descendant.

Use one native snapshot that supplies parent PID and creation time together, such as SystemProcessInformation, before treating this tuple as PID-safe identity.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — one rebase + cleanup commit since the prior Pullfrog review.

  • Regenerated the process-tree patch cleanly after a rebase. The branch was rebased onto main after #17886 landed its command-line/EDR-posture work in the same .patch file, which left pnpm patch-commit's 199 CR bytes and literal merge-conflict markers (<<<<<<< HEAD / >>>>>>>) baked into config/patches/@[email protected]. This commit strips all of it and resolves the merge correctly, so the patch now carries both the creation-time hunks and #17886's hunks in one coherent file.
  • Re-synced the lockfile patch hash from f8ea2453… to e66202cc…, which equals the patch file's plain sha256.
  • Refactored the test-harness sibling staging into a named REQUIRED_CJS_SIBLINGS list (node-pty-job-ownership.cjs, windows-process-tree-creation-time.cjs) with an explanatory comment.

Verified the current patch is byte-clean and hash-synced: 0 CR bytes, no conflict markers, sha256 e66202cc… == the lockfile patch_hash, satisfying the main-branch windows-process-tree-patch-contract.test.mjs contract; and that the two createRequire'd CJS siblings (plus the walked ESM sibling) cover every module-scope import in ensure-native-runtime.mjs.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 merged commit 1478101 into main Sep 6, 2026
34 checks passed
gaberudy added a commit to goldenhelix/vsagent that referenced this pull request Sep 12, 2026
…ball

Symptom: config/scripts/release-tarball-staged-config.test.mjs failed after the
v1.4.200 rebase — "stages the whole import closure of the shipped postinstall"
derived 8 scripts from source but POSTINSTALL_STAGED_SCRIPTS listed 7.

Root cause: upstream 1478101 (stablyai#18986, new in v1.4.198-200) added
config/scripts/windows-process-tree-creation-time.cjs and made it part of the
shipped postinstall's dependency graph — rebuild-native-deps.mjs require()s it
from the @vscode/windows-process-tree arm of the Electron load probe (line 626).
The fork's S38 tarball builder hardcoded the staged list before that file
existed, so the test's closure walker correctly picked up a file the constant
did not name.

Approach: add it to POSTINSTALL_STAGED_SCRIPTS next to the other require()d
.cjs (node-pty-job-ownership.cjs) with a one-line note on why a require, not an
import, reaches it. Without the entry the tarball would ship a postinstall that
dies with a missing module the moment a host hits the windows-process-tree arm.

Verified: release-tarball-staged-config.test.mjs 16/16 green;
check:code-quality:changed clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tion time (stablyai#18986)

* fix(windows): guard process creation times

* fix(windows): ask the relay's bare addon for creation times too

The relay addon build now emits creationTimeMs, but the runtime binding
for the bare addon still declared only CommandLine, so a Windows relay
host requested flag 2 and every row came back without a creation time.
That leaves captureWindowsDescendantSnapshot returning null and
verifyWindowsProcessIdentity false forever on those hosts -- the relay
half of the patch was unreachable.

Naming CreationTime in the adapter is safe because the bare addon is a
content-hashed relay artifact: it ships in the same immutable relay
directory as the bundle reading it, so it can never be older than the
code asking for the bit.

Also bound the win32 guard test on our own row, which the addon can
never fail to answer, so an unconverted FILETIME or a 1601-epoch stamp
fails instead of satisfying a bare count.

* fix(windows): make the compiled addon prove its own CreationTime support

CI caught the real defect: the win32 guard test read
isWindowsProcessStartTimeAvailable() as true and then found 0 rows
carrying creationTimeMs. Unlike node-pty, this package publishes a
prebuilt .node at the same build/Release path node-gyp writes to, so
pnpm patches the source tree and leaves that binary alone. A host then
holds a patched lib/index.js -- ProcessDataFlag.CreationTime and all --
over a binary that ignores flag 4, and neither a load check nor a path
check can see the difference.

So the binary now says so itself: addon.cc exports
supportedProcessDataFlags, lib/index.js re-exports it, and

  - windows-process-tree-creation-time.cjs asserts it during install,
    which is what forces a from-source rebuild. It is shared by the Node
    probe in ensure-native-runtime.mjs and the Electron probe in
    rebuild-native-deps.mjs, exactly as node-pty-job-ownership.cjs is --
    the Electron half matters because that probe decides onlyModules, so
    without it the packaged app would ship the stale prebuilt.
  - isWindowsProcessStartTimeAvailable() gates on the reported bit, not
    the enum. Believing the enum is worse than reporting false: the
    descendant snapshot returns null forever and the exit proof latches
    unverifiable while structured chat believes it has a reaper.

rebuildNodeRuntimeModules could not actually have rebuilt this package:
the patched binding.gyp includes deps/node-addon-api, which the tarball
does not ship, and node-gyp must run from the physical dir.

Also closes the relay repair path's divergence: repairCreationTimeSources
wrote the C++ but not the buildNode splat or the tree-node typing, and
assertPatchApplied checked neither, so a repaired tree passed as patched
with buildProcessTree silently dropping the field.

The guard test is unchanged.

* fix(windows): keep the process-tree patch LF-only

windows-process-tree-patch-contract.test.mjs requires the patch file to
carry no CR bytes. Regenerating through pnpm patch-commit emitted 199 of
them, because the creation-time change is the first to touch files the
package ships as CRLF (src/process.h, src/process_worker.cc,
src/addon.cc, lib/index.js, lib/index.ts, the typings) -- and stablyai#17886's
own hunks over binding.gyp and src/process_commandline.cc carry the rest.

Stripping them is safe and changes nothing the lockfile records: pnpm
hashes patches CRLF-normalized, so the digest stays
e66202cc623996d02040c93449eb9ae353fddadf426cb53202a59ee710ee6fe7 and now
equals the file's plain sha256 too. It also still applies -- verified
against a deleted store entry, not a warm one -- and the precedent was
already there: the previous patch was LF-only and had been patching
those same CRLF files all along.

ensure-native-runtime.test.mjs stages the siblings the script loads at
module scope into its temp project. The import walk added by stablyai#17886 sees
`from './x.mjs'` only, so the createRequire'd .cjs siblings still have to
be named, and this PR adds a second one.

---------

Co-authored-by: Merge Sim <sim@local>
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