Skip to content

fix(windows): reject a node-pty addon that predates the MSYS breakaway denial - #20047

Merged
nwparker merged 12 commits into
mainfrom
inv18191-msys-job-breakaway
Sep 17, 2026
Merged

nwparker merged 12 commits into
mainfrom
inv18191-msys-job-breakaway

Conversation

@nwparker

@nwparker nwparker commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​935 $\color{#cf222e}{\Huge{\mathbf{−}}}$​35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​900
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​712 $\color{#cf222e}{\Huge{\mathbf{−}}}$​69 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​643

Why this exists: a 5/5 "deterministic product defect" that was not real

A compiled conpty.node built before a shipped fix produced a clean, reproducible, 5-out-of-5 failure that read as a deterministic product defect. It was not one. The source was already correct. The binary was stale.

That is not a one-off slip, it is the normal state of this tree:

  • Of 32 locally built addons on the Windows host, exactly 1 carried the patch.
  • The shared main checkout did not carry it — and every worktree with symlinked node_modules inherits that checkout.
  • Pinning source to a SHA does not pin the addon. Nothing in the repo made the difference observable.

So an agent or a developer could bisect a real-looking defect to a commit that never contained it.

What the gate checked before, and why it passed a broken addon

The native-runtime gate asserted only that terminateJob, listJobProcessIds and assignCurrentProcessToJob were exported. All three predate the Cygwin/MSYS breakaway denial. So an addon built before it passes every gate, isPtyJobOwnershipAvailable() returns true, and windows-pty-job.win32.test.ts passes 6/6 — while every Git Bash child is created outside its pane's job and survives terminatePtyJob.

A gate that looked like it checked.

What it does now

Read the resolved .node and require the wide msys-2.0.dll literal that usesCygwinRuntime holds — the same technique stagedRelayAddonIsUnpatched() already uses to tell a patched windows-process-tree addon from a published one.

An addon the caller cannot name is refused rather than skipped: a gate that cannot see its subject is not a gate.

Three call sites, because covered-by-another-path is not this-path-checks:

  1. ensure-native-runtime.mjs — the Electron probe.
  2. rebuild-native-deps.mjs — the rebuild path. The Electron probe's marker check lives inside probeElectronNativeModules, which returns early whenever the Electron package binary is unusable. The rebuild path produces the addon that gets copied into the packaged app, so it asserts for itself, beside the windows-process-tree assertion that exists for the same reason. It also asserts the addon's PE machine matches the arch the rebuild targeted, so a --arch that node-gyp ignored is reported where the command that fixes it is.
  3. verify-packaged-node-pty-job-ownership.cjs — packaging, for every Windows slice rather than only the branch the export check skips.

The packaged check resolves the addon the way its loader does

loadNativeModule tries build/Release, then build/Debug, then prebuilds/win32-<arch>, each relative to node-pty's root and then to lib/, swallowing every failure in between. A require of a wrong-architecture .node is one of those failures, so the addon that runs is the first candidate the target arch can load — which is not always build/Release:

package build/Release prebuild pruned? what the app loads
same host, same arch patched yes build/Release
cross host absent, cannot be cross-built no the prebuild
cross arch, rebuild honoured --arch patched, target arch no build/Release
cross arch, rebuild did not the host's arch no the prebuild

prunePackagedNodePty drops the published prebuild only when a same-process.arch build/Release exists to replace it, so in the last three rows the unpatched fallback stays in the package. Measured, not assumed: both published Windows prebuilds in the node-pty tarball contain neither msys-2.0.dll nor cygwin1.dll in any encoding.

Reading one hard-coded path therefore warned on row two and printed OK on row four. Requiring the marker on every file present instead would have failed row three — a correct package whose leftover prebuild is never reached — with advice to change hosts that no runner here can offer. Only the PE IMAGE_FILE_HEADER.Machine separates rows three and four, so the gate reads it.

Why it fell back decides the remedy, and naming the wrong one costs a build:

  • a stale source build → rebuild it here (the existing message).
  • a wrong-arch source build beside the prebuild → re-run rebuild-native-deps.mjs --platform=win32 --arch=<target>, quoting each machine field found.
  • no source build at all → package the slice on a host that can build node-pty for that arch.
  • nothing loadable, or nothing at all → refused, naming every path tried and what was read at it, including not a PE image for a truncated or quarantined artifact.

The marker constant is tied to the C++ that produces it

The literal was re-typed in four places, and nothing connected it to config/patches/[email protected]. Editing that patch would have left a gate that fails every correctly rebuilt addon and tells the developer to do the one thing that cannot help. The fixtures now take the constant from the gate, and a test asserts the patch still adds L"msys-2.0.dll" to conpty.cc — failing on drift in either direction.

Verification

Against real binaries on a Windows 11 host, not fixtures:

addon result
shared checkout's pre-#19068 build errors
build from current patched source passes
marker-stripped binary errors
missing path errors (refused, not skipped)

Proven to fail as packaging exit 1 on a real stale addon and on a marker-stripped one, with a control passing on a good addon.

The PE reader was checked against the real published Windows addons rather than fixtures: win32-x64/conpty.node → 0x8664, win32-arm64/conpty.node → 0xaa64, a Mach-O and a text file → not a PE image.

Windows CI actually runs these now, and that is how three of the defects below were found. rebuild-native-deps-node-pty.test.mjs carries four skipIf(platform !== 'win32') tests; the full suite runs on ubuntu, and the Windows job runs an explicit file list that never named the file — so those tests were skipped on Linux and never reached anywhere else. Three of them predate this branch and had never executed on any machine. The Windows job is given the four node-pty addon suites plus the module-walker one.

On the first Windows run they went red immediately, on things no amount of macOS testing could have shown:

red on Windows cause
nodePtyAddonPath ×2 compared against a literal POSIX path; resolve returns D:\...\ with backslashes
repairs a missing ConPTY runtime… mkTempProject never staged windows-process-tree-creation-time.cjs, which the script reaches through projectRequire
does not rebuild a healthy node-pty… cascade of the above, plus writeFakeWindowsProcessTree exporting {}, which the creation-time gate correctly calls "the tarball prebuilt"
rebuilds a loadable ConPTY native… asked for a node-pty rebuild in a tree with none of the payload node-pty's package ships

Measured on the Windows runner after the repairs — verify-packaged-node-pty-job-ownership 37, ensure-native-runtime-job-ownership 28, rebuild-native-deps-node-pty 18 (3 skipped), windows-pe-machine 12, script-module-dependencies 8; job total 464 passed, 22 skipped, green. The 3 skipped in rebuild-native-deps-node-pty are its skipIf(platform === 'win32') cases, so the four Windows-only tests all executed there; on macOS the complement skips. Every test in the file runs on exactly one of the two.

Teeth proven by mutation, not assumed: 38 mutations, each re-introducing one regression an assertion claims to catch. 37 fail the suite on macOS; the one survivor is the Windows-only process-tree fixture, which Windows CI killed for real. They include reverting the packaged check to one hard-coded path, reverting it to "every present file must be marked", resolving the first candidate instead of the first loadable one, swapping the PE machine table, reading the PE offset from a fixed position, dropping the afterPack call, wrapping the marker verdict in try {} catch {}, swapping the two fallback remedies for each other, and drifting the patch literal or the gate constant apart.

Fixtures write a real PE image through one shared builder. They previously wrote MZ fake addon or the literal string native addon, which cannot exercise a gate that reads a machine field.

Docs

docs/reference/windows-msys-job-breakaway.md records the measured mechanism, referenced from AGENTS.md.

Rebase record (2026-09-11)

Rebased onto main at 5fa62feda7c264c6eda99ba4788ffebab9aae26c. No conflicts.

SHA
old head f9850f9bc574b75daaa0993da94b661f8572e2fa
new head dfc25f9872a42d1cba125ff26687516d837f6727

#20048 stacks on this branch and was replayed onto the new head.


Rebased onto main @ 231e805b1e1e49c765e96b9409f88e09d117346a (2026-09-15).

  • Old head: dfc25f9872a42d1cba125ff26687516d837f6727
  • New head: c28a0a4f4695f55b66b16371325b12d73cf8cbb5

Rebase only; all three commits are byte-identical under git range-diff. The rebase also picks up main's deterministic-clock fix for structured-session-worktree-teardown.test.ts, which is what the previously failing test / tests node 24 3/8 shard was reporting -- an unrelated wall-clock race, not this PR. CI on the rebased head is green.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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 PR adds PE architecture and breakaway-marker checks for Windows node-pty ConPTY addons. Runtime, rebuild, and packaged verification paths now inspect resolved addons and reject incompatible or unpatched binaries. Tests cover loader paths, architecture mismatches, missing artifacts, and stale addons. Contributor guidance and a reference document describe Windows MSYS process-tree behavior and diagnostics.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 2a73e

Malformed or Debug-only native addons can evade or incorrectly fail validation, potentially leaving MSYS child processes running. These gaps should be fixed before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 16 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description gives a detailed explanation of the problem, implementation, testing, platform coverage, and documentation. However, it does not follow the required template and omits the mandatory Li… Add the required template sections. Provide a Linked Issue reference after "Fixes #"; write "N/A" with a reason under Visual Proof; complete or explain the Testing and Checklist items; and address AI Disclosure, Review, Agent skill upstream…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: rejecting node-pty addons that predate the MSYS breakaway denial fix.
Full details: Docstring Coverage

Explanation

Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 16 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description gives a detailed explanation of the problem, implementation, testing, platform coverage, and documentation. However, it does not follow the required template and omits the mandatory Linked Issue entry, explicit Visual Proof response, checklist confirmations, AI Disclosure, Review, Agent skill upstream boundary, and Notes sections.

Resolution

Add the required template sections. Provide a Linked Issue reference after "Fixes #"; write "N/A" with a reason under Visual Proof; complete or explain the Testing and Checklist items; and address AI Disclosure, Review, Agent skill upstream boundary, and Notes.

✨ 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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f67e8780-8163-446a-970a-4cf57b212e09

📥 Commits

Reviewing files that changed from the base of the PR and between b3e0a33 and f9850f9.

📒 Files selected for processing (12)
  • .gitignore
  • AGENTS.md
  • config/electron-builder.config.cjs
  • config/scripts/ensure-native-runtime-job-ownership.test.mjs
  • config/scripts/ensure-native-runtime.mjs
  • config/scripts/node-pty-job-ownership.cjs
  • config/scripts/rebuild-native-deps-node-pty.test.mjs
  • config/scripts/rebuild-native-deps-test-fixtures.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/verify-packaged-node-pty-job-ownership.cjs
  • config/scripts/verify-packaged-node-pty-job-ownership.test.mjs
  • docs/reference/windows-msys-job-breakaway.md

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

Comment thread AGENTS.md
- **Windows setup scripts**: the setup/issue-command runner is a `.cmd` batch file unless the script starts with a `#!` line — never derive that from the user's terminal-shell preference, and never launch a `.cmd` runner with a bare `cmd.exe /c` from a Git Bash pane (MSYS rewrites the `/c`). See [`docs/reference/windows-setup-shell.md`](./docs/reference/windows-setup-shell.md).
- **Windows child processes**: start them through `runProcess`/`spawnProcess` in `src/shared/child-process/` — never `child_process` directly. It pins `windowsHide`, refuses `shell: true`, and encodes `.cmd`/`.bat` arguments so neither `CommandLineToArgvW` nor `cmd.exe` mangles them. A ratchet test fails on any new direct import. Recognised npm/pnpm `.cmd` shims are resolved to their real target so the spawn skips `cmd.exe` entirely; see [`docs/reference/windows-cmd-shim-resolution.md`](./docs/reference/windows-cmd-shim-resolution.md) before adding a shim shape or debugging one.
- **Windows process enumeration**: read the table through `src/main/windows/windows-process-table.ts`, never by forking `powershell.exe`. See [`docs/reference/windows-process-enumeration.md`](./docs/reference/windows-process-enumeration.md).
- **Windows MSYS/Git Bash panes**: their children break away from the per-PTY job unless it is created without `JOB_OBJECT_LIMIT_BREAKAWAY_OK`, and a `conpty.node` built before that fix passes every existing gate. Before changing the per-PTY job or debugging `windows-msys-job.win32.test.ts`, read [`docs/reference/windows-msys-job-breakaway.md`](./docs/reference/windows-msys-job-breakaway.md).

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

Qualify the historical gate claim.

After this PR adds marker validation, a pre-fix conpty.node does not pass every existing gate. Say that it passed the legacy export-only gates so this guidance does not contradict the new validation.

Comment on lines +3 to +4
Every child started from a Git Bash / MSYS2 / Cygwin pane leaves the pane's job
object unless the job is created **without** `JOB_OBJECT_LIMIT_BREAKAWAY_OK`.

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

Use one precise MSYS escape condition in both documents.

The measured process trees show that MSYS runtime-created children can break away. The launcher and forked shell remain in the per-PTY job.

  • docs/reference/windows-msys-job-breakaway.md#L3-L4: replace “Every child” with qualified MSYS runtime spawn/exec wording.
  • AGENTS.md#L58-L58: use the same qualified wording in the Cross-Platform Support bullet.
📍 Affects 2 files
  • docs/reference/windows-msys-job-breakaway.md#L3-L4 (this comment)
  • AGENTS.md#L58-L58

— `+J` / `-J` is membership of the per-PTY job, read with
`QueryInformationJobObject(JobObjectBasicProcessIdList)`:

```

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

Add language identifiers to both fenced blocks.

The Markdown linter reports MD040. Use text for these process-tree diagrams.

Proposed fix
-```
+```text

Also applies to: 44-44

🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 28-28: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Source: Linters/SAST tools

@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

  • Binary marker gate — assertCygwinBreakawayDenied now sniffs the resolved conpty.node for the UTF-16LE msys-2.0.dll literal held by usesCygwinRuntime (#19068), so a stale addon that still exports every job function is refused instead of passing on symbol presence alone.
  • Caller plumbing — ensure-native-runtime.mjs (Electron probe) and rebuild-native-deps.mjs (loadNativeModule) now compute addonPath via the new nodePtyAddonPath, which resolves native.dir against node-pty/lib — the only base the install, staged-rebuild, and packaged layouts share.
  • Rebuild-path self-check — assertNodePtyConptyDeniesMsysBreakaway asserts the artifact the rebuild just produced (absent warns, present-and-unmarked fatal), mirroring the existing assertWindowsProcessTreeAddonIsPatched.
  • Packaging cross-host closure — verifyPackagedConptyBreakawayMarker is a file read that runs when the export check cannot load the addon (cross-host/cross-arch), closing the skip that could ship the orphan bug from a Windows release built off-host.
  • Fixtures + docs — fixtures now write a real addon with the marker bytes; docs/reference/windows-msys-job-breakaway.md records the measured mechanism, allow-listed in .gitignore and cross-referenced from AGENTS.md.

The technique is sound and grounded: I confirmed usesCygwinRuntime (with L"msys-2.0.dll", called unconditionally in PtyStartProcess) is present in config/patches/[email protected], so every patched build embeds the marker, and loadNativeModule returns dir relative to lib/, matching nodePtyAddonPath. The three affected suites pass (36 passed, 3 Windows-gated skips), and the tests assert exact error text rather than loose truthiness.

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

@nwparker
nwparker force-pushed the inv18191-msys-job-breakaway branch from f9850f9 to dfc25f9 Compare September 11, 2026 08:16
The per-PTY job already denies JOB_OBJECT_LIMIT_BREAKAWAY_OK for Cygwin/MSYS
shells (#19068), but nothing records why, and a conpty.node built before that
commit fails windows-msys-job.win32.test.ts in a way that reads as a source
defect. Measured on a real Windows 11 host: both the plain and the exec-
replacement Git Bash shapes leak, the escape is the MSYS runtime's own
spawn/exec (fork keeps membership), and a single-variable A/B on
usesCygwinRuntime flips the result 0/2 -> 4/4.

Also names the gap the failure hid behind: node-pty-job-ownership.cjs asserts
symbol presence, which cannot distinguish patch revisions.
…y denial

The native-runtime gate asserted only that terminateJob, listJobProcessIds and
assignCurrentProcessToJob were exported. All three predate the Cygwin/MSYS
breakaway denial, so an addon built before it passes every gate,
isPtyJobOwnershipAvailable() returns true, and windows-pty-job.win32.test.ts
passes 6/6 -- while every Git Bash child is created outside its pane's job and
survives terminatePtyJob.

Read the resolved .node and require the wide msys-2.0.dll literal that
usesCygwinRuntime holds, the way stagedRelayAddonIsUnpatched() already tells a
patched windows-process-tree addon from a published one. An addon the caller
cannot name is refused rather than skipped: a gate that cannot see its subject
is not a gate.

Verified against real binaries on a Windows 11 host: the shared checkout's
pre-#19068 build errors, a build from current patched source passes, a missing
path errors.

Also closes the cross-host packaging skip. The export half has to load the
addon so it cannot run when the packaging host is not the target, which is how
a Windows release built elsewhere could ship this. The marker is a file read
and needs neither; an unrecognised layout warns rather than fails a release
that was packaging fine.
The Electron probe carried the marker check, but it lives inside
probeElectronNativeModules, which returns early whenever the Electron package
binary is unusable. Covered by another path is not this path checks -- and the
defect this whole change closes was a gate that looked like it checked.

Reading the binary needs neither a loadable Electron nor an executable target
arch, so assert it after the rebuild, beside the windows-process-tree
assertion that exists for the same reason: this is the addon copied into the
packaged app. Absent warns (a cross-platform rebuild need not leave a win32
addon on this disk); present and unmarked is fatal.

The fixtures now write a real addon file, because the gate reads the binary it
was told about rather than trusting the exports. Verified against the two real
binaries measured on the Windows host: the pre-#19068 build fails this path,
the build from current patched source passes.
@nwparker
nwparker force-pushed the inv18191-msys-job-breakaway branch from dfc25f9 to c28a0a4 Compare September 15, 2026 09:33
…can load

The packaged marker check read one hard-coded path, `build/Release/conpty.node`,
and warned when it was absent. `loadNativeModule` tries `build/Release`, then
`build/Debug`, then `prebuilds/win32-<arch>`, swallowing each failure, and
`prunePackagedNodePty` drops the published prebuild only when a same-arch
`build/Release` exists to replace it. So the two packages the check was added for
were the two it could not see:

- cross-host: no host but Windows can build conpty.node, so there is no
  `build/Release` and the prebuild is what ships. The check warned and returned.
- cross-arch: `build/Release` is the packaging host's own arch, patched and
  marked, so the check printed OK -- while the target app cannot load it and
  falls through to the unmarked prebuild underneath.

Measured, not assumed: both published Windows prebuilds in the node-pty tarball
contain neither `msys-2.0.dll` nor `cygwin1.dll` in any encoding. They are the
binary that leaks every MSYS pane child out of its job.

It now sweeps every candidate present for the *target* arch and refuses a package
with no candidate at all, which is a package with no ConPTY backend rather than a
layout to shrug at. It runs for every Windows slice instead of only the branch
the export check skips, so deleting the export check cannot silently take it too.
A stale source build keeps the rebuild advice; the prebuild gets the advice that
actually works, which is to package the slice on a Windows host of that arch.

Also: the marker constant was re-typed in four places and was tied to the C++
literal that produces it by nothing at all, so editing the patch would have left
a gate that fails every correctly rebuilt addon and tells the developer to do the
one thing that cannot help. The fixtures now take the constant from the gate, and
a test asserts the patch still adds `L"msys-2.0.dll"` to conpty.cc.

And the rebuild path treated a missing addon as a warning even on the host that
will run the install, where node-pty would fall through to that same prebuild.
The verdict is now a value, so it is tested without a platform gate.

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

Run ID: ee2ce205-7a16-49e0-991e-9e862e8689ce

📥 Commits

Reviewing files that changed from the base of the PR and between c28a0a4 and 2de0829.

📒 Files selected for processing (10)
  • config/electron-builder.config.cjs
  • config/packaged-runtime-node-modules.cjs
  • config/scripts/ensure-native-runtime-job-ownership.test.mjs
  • config/scripts/node-pty-job-ownership.cjs
  • config/scripts/rebuild-native-deps-node-pty.test.mjs
  • config/scripts/rebuild-native-deps-test-fixtures.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/verify-packaged-node-pty-job-ownership.cjs
  • config/scripts/verify-packaged-node-pty-job-ownership.test.mjs
  • docs/reference/windows-msys-job-breakaway.md

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

Comment thread config/scripts/rebuild-native-deps.mjs Outdated
'./node-pty-job-ownership.cjs'
)
const nodePtyDir = resolve(projectDir, 'node_modules', 'node-pty')
const addonPath = join(nodePtyDir, 'build', 'Release', 'conpty.node')

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 | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '225,285p' config/scripts/rebuild-native-deps.mjs
rg -n "build.*Debug|build.*Release|conpty\.node|prebuilds" node_modules/node-pty config scripts package.json 2>/dev/null | head -160
sed -n '1,150p' config/scripts/node-pty-job-ownership.cjs

Repository: stablyai/orca

Length of output: 28435


🏁 Script executed:

sed -n '1,90p' node_modules/node-pty/lib/utils.js
rg -n -C 8 "assertNodePtyConptyDeniesMsysBreakaway|restoreNodePtyWindowsConptyRuntime" config/scripts/rebuild-native-deps.mjs
sed -n '285,325p' config/scripts/rebuild-native-deps.mjs

Repository: stablyai/orca

Length of output: 6722


Check build/Debug/conpty.node before treating the addon as absent.

node_modules/node-pty/lib/utils.js checks build/Release, then build/Debug, then the prebuild fallback. When Release is absent but Debug exists, this validation skips the Debug addon.

A cross-host rebuild can accept an unmarked Debug addon with only a warning. A host-local rebuild can reject a marked Debug addon with an incorrect missing-Release/prebuild diagnostic.

Inspect both build candidates before applying conptyAddonMayBeAbsent in config/scripts/rebuild-native-deps.mjs.

Proposed fix
-  const addonPath = join(nodePtyDir, 'build', 'Release', 'conpty.node')
-  if (existsSync(addonPath)) {
+  const addonCandidates = ['Release', 'Debug'].map((configuration) =>
+    join(nodePtyDir, 'build', configuration, 'conpty.node')
+  )
+  const addonPath = addonCandidates.find((candidate) => existsSync(candidate))
+  if (addonPath) {
     assertCygwinBreakawayDenied(addonPath, { dir: addonPath })
     return
   }
   const crossHost = rebuildPlatform !== osPlatform() || rebuildArch !== process.arch
   if (conptyAddonMayBeAbsent({ crossHost, nodePtyInstalled: existsSync(nodePtyDir) })) {
     console.warn(
-      `[rebuild] no addon at ${addonPath}; could not check the MSYS job-breakaway denial.`
+      `[rebuild] no addon at ${addonCandidates.join(' or ')}; ` +
+        'could not check the MSYS job-breakaway denial.'
     )
     return
   }
   const prebuildPath = join(nodePtyDir, 'prebuilds', `win32-${rebuildArch}`, 'conpty.node')
   throw new Error(
-    `the rebuild reported success but ${addonPath} is not there, so node-pty would load ` +
+    `the rebuild reported success but neither ${addonCandidates.join(' nor ')} is there, ` +
+      'so node-pty would load ' +
       `${prebuildPath} instead. That published prebuild predates the Cygwin/MSYS ` +

@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

Reviewed the delta since the prior pullfrog review (c28a0a4..2de0829, commit 2de0829da6) against the full PR diff.

  • Marker sweep across every ConPTY load path — verifyPackagedConptyBreakawayMarker now takes the target arch and checks build/Release, build/Debug and prebuilds/win32-<arch> in loadNativeModule order, so a cross-arch package whose build/Release is the host's own arch can no longer pass on the unpatched prebuild underneath.
  • Refuse rather than skip a package with no ConPTY backend — no candidate present is now fatal, and the error names every path tried.
  • Marker check moved out of the host gate — electron-builder.config.cjs runs the file-read sweep for every Windows slice; only the addon-loading export check stays behind process.platform === 'win32' && canExecuteTargetArch.
  • Same-host rebuild refusal — assertNodePtyConptyDeniesMsysBreakaway now fails a same-host Win32 rebuild that leaves no build/Release/conpty.node, naming the prebuild that would load, via the new conptyAddonMayBeAbsent predicate; cross-host or node-pty-absent still warns.
  • Shared marker constant + fixtures — CYGWIN_BREAKAWAY_MARKER_TEXT / conptyDeniesCygwinBreakaway are exported, and the rebuild fixtures import the gate's marker instead of re-typing it.

I verified the loader order in node-pty/lib/utils.js, prunePackagedNodePty's same-arch-only prebuild deletion, and that CI packages Windows x64 on x64 only (--arm64 is used solely for the windows-process-tree relay addon), so the new fatal cross-arch path is intentional and not a live regression. The three suites pass (55 passed, 4 Windows-gated skips), and the new assertions pin exact error text rather than loose truthiness.

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

Sweeping every candidate and demanding the marker on all of them was wrong in
the one case it was meant to make safe. `beforeBuild` runs
`rebuild-native-deps.mjs --platform=win32 --arch=<target>`, so a cross-arch slice
normally does get a patched `build/Release` for the target; `prunePackagedNodePty`
keeps the prebuild anyway because its guard is `electronArch === process.arch`
rather than the arch of the binary. That package is correct and its leftover
prebuild is never reached, and the sweep failed it -- telling whoever ran it to
package on a Windows arm64 host, which is both the wrong remedy and one no runner
here can offer.

Presence cannot separate that package from the one whose cross-arch rebuild
quietly emitted the host's architecture, because the only difference is the arch
of `build/Release`. So the gate now resolves the addon the way `loadNativeModule`
does -- first candidate whose PE `IMAGE_FILE_HEADER.Machine` matches the target,
walking root-then-lib for each layout in node-pty's own order -- and checks the
marker on the one that will actually run. A package with no candidate, or none of
the target's architecture, is refused: it has no ConPTY backend either way, and
the second is exactly what a silently host-arch cross-build looks like.

The PE machine reader already existed, privately, in the relay addon builder that
needed the same "a cross-build cannot silently emit host arch" guarantee. It is
now shared rather than copied.

Two seams were unreachable from anything but Windows, so nothing tested them:

- the afterPack hook's win32 block was an inline if/else that only a source-text
  assertion could inspect, and that assertion could not tell the difference
  between the check running and the check being wrapped in `try {} catch {}`. It
  is now `verifyPackagedWindowsNodePty`, and "the marker check runs even where
  the export check cannot" is four spied assertions instead of a string match.
- the rebuild path's verdict read `process` directly, so the branch that fires
  only on the host being rebuilt for was dead on every other host. It now takes
  the host as arguments, and the fs checks, the warning and the failure are all
  exercised from macOS.

Fixtures write a real PE header rather than `MZ fake addon`, since the gate now
reads one. The machine table is pinned to the documented IMAGE_FILE_MACHINE
values, because every fixture builds its header from that table and a table wrong
in both entries would otherwise agree with itself.

@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 critical issues — one minor robustness suggestion inline.

Reviewed changes

Reviewed the delta since the prior pullfrog review (2de0829..5d9697b, commit 5d9697b6ba) against the full PR diff.

  • Resolve the packaged ConPTY the way its loader does — verifyPackagedConptyBreakawayMarker now walks packagedConptyCandidates (each layout relative to node-pty's root then lib/, matching loadNativeModule) and checks the marker only on the first candidate the target arch can load, judged by a new PE IMAGE_FILE_HEADER.Machine read. This removes the 2de0829 false positive on a correct cross-arch package whose unpruned prebuild is never reached.
  • New windows-pe-machine.cjs — readPeMachine / isLoadableByArch / PE_MACHINE, with build-windows-process-tree-relay-addon.mjs importing the shared reader instead of its private copy.
  • Per-slice orchestration in one function — verifyPackagedWindowsNodePty owns both halves (marker first, export check only on a same-host executable target), so "the marker runs even when the export check cannot" is a unit-tested claim rather than an if/else shape in the afterPack hook.
  • Rebuild verdict extracted — conptyAddonMayBeAbsent became assertRebuiltConptyDeniesMsysBreakaway, taking the host as arguments so the same-host-missing-addon branch is reachable off Windows; isCrossHostRebuild is hoisted once.

I confirmed loadNativeModule's order in node_modules/node-pty/lib/utils.js (nested dirs × ['..', '.'] loop) matches the pinned candidate list, and the new fixtures carry a real PE header plus the marker bytes so both the arch and marker halves can fail. The four affected suites pass (81 passed, 4 Windows-gated skips) and oxlint is clean on the changed files.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

… did

The previous commit resolved the addon by architecture but still had one message
for every way the resolution could land on the published prebuild. Those ways
want opposite remedies, and the one it printed was the remedy the commit before
it had just called wrong:

- no source build in the package at all — the slice has to be built somewhere
  that can build node-pty for the target arch.
- a source build that is there but is the packaging host's architecture, because
  the cross-arch rebuild did not honour `--arch` — re-running that rebuild is the
  fix, and "package on a Windows arm64 host" is neither necessary nor possible.

The second is the common one, since node-pty publishes a prebuild for both
Windows arches and prune keeps the target's on every cross-arch package. So the
old text fired mostly on the case it described least. It now reports which source
builds were skipped and the machine field each carried, and names the rebuild
command.

"Nothing the target can load" had the same problem in reverse: a zero-length or
truncated `conpty.node` got a cross-architecture diagnosis. Every candidate is
now named with what was actually read, including "not a PE image".

The rebuild path asserts the architecture too. A rebuild that ignored `--arch`
was otherwise only visible at packaging, two steps from the command that fixes
it. Arches with no known machine value are left unjudged rather than guessed at.

Two things the extraction broke or nearly broke, both found by mutation:

- the shared PE reader answers `null` where the relay builder's private copy
  returned a number, which would have turned its "node-gyp ignored --arch" error
  into a `TypeError`. Both callers now go through `describePeMachine`.
- the rebuild fixtures stage a script's co-located modules by walking its
  imports, and the walker only understood `from '...'` — so the gate's new
  `require('./windows-pe-machine.cjs')` was left behind and every subprocess test
  failed with a resolution error, which is the exact failure its own comment
  warns about. It now follows `require` and bare side-effect `import` as well,
  and has tests; the fixture stages the gate by walking it rather than by naming
  one file.

Fixtures write real PE headers through one shared builder instead of three
hand-rolled ones.

@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 critical issues — one minor cross-platform robustness suggestion inline.

Reviewed changes

Reviewed the delta since the prior pullfrog review (5d9697b..2a73e6b, commit 2a73e6b) against the full PR diff.

  • Packaging blames the right cause — verifyPackagedConptyBreakawayMarker now names every present candidate with its PE machine and separates "no source build in the package" (change hosts) from "source build of the wrong architecture" (re-run the rebuild), naming the exact command; a non-PE file is reported as such rather than diagnosed as cross-arch.
  • Rebuild path asserts the target arch — the new assertRebuiltConptyMatchesArch fails a Windows rebuild whose build/Release/conpty.node is not the requested architecture, leaving arches with no known machine value unjudged.
  • Shared PE reads — describePeMachine renders a null machine as "not a PE image", fixing the relay builder's machine.toString(16) null deref, and three hand-rolled PE fixtures collapse into windows-pe-image-fixture.mjs.
  • Walker follows require — copyScriptWithLocalModules now walks require, dynamic import and side-effect import, not just from, so the gate's require('./windows-pe-machine.cjs') is staged; covered by the new script-module-dependencies.test.mjs, and the rebuild fixture stages the gate by walking it.

I confirmed the fix for the prior review's null-deref finding. All five affected suites pass (99 passed, 4 Windows-gated skips) and oxlint is clean on the changed files.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f57e6a75-eab1-4c23-9689-861b9574cf0e

📥 Commits

Reviewing files that changed from the base of the PR and between 2de0829 and 2a73e6b.

📒 Files selected for processing (14)
  • config/electron-builder.config.cjs
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/ensure-native-runtime-job-ownership.test.mjs
  • config/scripts/node-pty-job-ownership.cjs
  • config/scripts/rebuild-native-deps-test-fixtures.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/script-module-dependencies.mjs
  • config/scripts/script-module-dependencies.test.mjs
  • config/scripts/verify-packaged-node-pty-job-ownership.cjs
  • config/scripts/verify-packaged-node-pty-job-ownership.test.mjs
  • config/scripts/windows-pe-image-fixture.mjs
  • config/scripts/windows-pe-machine.cjs
  • config/scripts/windows-pe-machine.test.mjs
  • docs/reference/windows-msys-job-breakaway.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/reference/windows-msys-job-breakaway.md

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

Comment on lines +28 to +30
/(?:\bfrom|\brequire\s*\(|\bimport\s*\(|\bimport)\s*'(\.\/[^']+)'/g
)
for (const [, specifier] of specifiers) {

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

Support double-quoted local specifiers.

The matcher only accepts '. A valid dependency such as require("./windows-pe-machine.cjs") is not copied. The staged script then fails module resolution. Match both quote delimiters and use a backreference.

Proposed fix
   const specifiers = source.matchAll(
-    /(?:\bfrom|\brequire\s*\(|\bimport\s*\(|\bimport)\s*'(\.\/[^']+)'/g
+    /(?:\bfrom|\brequire\s*\(|\bimport\s*\(|\bimport)\s*(["'])(\.\/[^"']+)\1/g
   )
-  for (const [, specifier] of specifiers) {
+  for (const [, , specifier] of specifiers) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/(?:\bfrom|\brequire\s*\(|\bimport\s*\(|\bimport)\s*'(\.\/[^']+)'/g
)
for (const [, specifier] of specifiers) {
/(?:\bfrom|\brequire\s*\(|\bimport\s*\(|\bimport)\s*(["'])(\.\/[^"']+)\1/g
)
for (const [, , specifier] of specifiers) {

) {
return null
}
return peHeader.readUInt16LE(4)

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.

🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

sed -n '1,220p' config/scripts/windows-pe-machine.cjs
sed -n '1,230p' config/scripts/verify-packaged-node-pty-job-ownership.cjs
rg -n "build/Release|build/Debug|prebuilds|require\\(" node_modules/node-pty/lib node_modules/node-pty/src 2>/dev/null | head -160

Repository: stablyai/orca

Length of output: 18929


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- node-pty loader ---'
cat -n node_modules/node-pty/lib/utils.js
printf '%s\n' '--- bound marker/loading helpers ---'
rg -n -A45 -B10 "function (conptyDeniesCygwinBreakaway|assertCygwinBreakawayDenied)|conptyDeniesCygwinBreakaway|assertCygwinBreakawayDenied" config/scripts/node-pty-job-ownership.cjs
printf '%s\n' '--- verifier tests ---'
rg -n -A35 -B15 "verifyPackagedConptyBreakawayMarker|malformed|fallback|prebuilt|deniesBreakaway|peMachine" config/scripts/rebuild-native-deps-node-pty.test.mjs config/scripts/windows-pe-machine.test.mjs

Repository: stablyai/orca

Length of output: 9221


🏁 Script executed:

set -eu
cat -n node_modules/node-pty/lib/utils.js
rg -n -A50 -B10 "conptyDeniesCygwinBreakaway|assertCygwinBreakawayDenied" config/scripts/node-pty-job-ownership.cjs
rg -n -A40 -B15 "verifyPackagedConptyBreakawayMarker|malformed|fallback|deniesBreakaway|peMachine" config/scripts/rebuild-native-deps-node-pty.test.mjs config/scripts/windows-pe-machine.test.mjs

Repository: stablyai/orca

Length of output: 9137


Security Misconfiguration

Reachability: Internal
Exploitability: Difficult
CWE: CWE-693

Reject PE candidates that node-pty cannot load.

readPeMachine validates only the PE signatures and Machine field. The packaging verifier selects the first present matching candidate and scans that file for the breakaway marker without loading it. node-pty catches native require failures and continues to later candidates.

A malformed matching candidate with the marker can therefore pass the cross-host packaging check. At runtime, node-pty can skip that candidate and load a stale prebuild. That prebuild retains JOB_OBJECT_LIMIT_BREAKAWAY_OK, so MSYS children survive terminatePtyJob. This is a packaging security-control failure, not a direct attacker-controlled runtime bypass; it requires a malformed or tampered build artifact.

Validate PE structure sufficiently to reject unloadable candidates, or fail closed. Add an ordered-candidate test with a malformed marked candidate before an unmarked fallback.

`rebuild-native-deps-node-pty.test.mjs` carries four `skipIf(platform !== 'win32')`
tests. The full suite runs on ubuntu, and the Windows PR job runs an explicit
file list that never named this file -- so those tests were skipped on Linux and
never reached anywhere else. Three of them predate this branch. The Windows job
is added the four node-pty addon suites plus the module-walker one; the comment
above that list already says why it is the right place, which is that the addon
assertions only hold once natives have been rebuilt. Running the path-joining
suites there also covers the separator this gate's candidate list is built from.

The rest is round-three review:

- the rebuild-time arch assertion told a reader "node-gyp did not honour --arch"
  about a file that was not a PE image at all, which is a truncated or
  quarantined artifact and a different command to run. The two now read
  differently, and neither claims the other's cause. Same fix the packaged gate
  had one commit ago, in the place that had not had it yet.
- the missing-addon error said node-pty "would load" a prebuild without checking
  it is there. It says "fall through to" now, which is true either way.
- `isLoadableByArch` had no caller left once the packaged gate started needing
  the raw machine field for its message. Removed rather than kept warm.
- each candidate's header is read once instead of up to three times.
- the module walker's comment claimed every shape that reaches a co-located
  module; it does not follow `projectRequire`/`requireLocal`, and it must not --
  those specifiers resolve against the project root, so following one stages the
  wrong path and the copy fails. Proven by trying: widening the pattern to
  require-shaped names broke nine tests on
  `projectRequire('./config/scripts/...')`. The comment now says what it follows
  and why it stops there.
- a new test resolved a file URL with `.pathname`, which keeps the drive-letter
  slash on Windows -- the very job this commit adds it to.
It describes what used to pass a broken addon, so present tense reads as a
description of the gate the same document then explains replacing it.

@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 critical issues — one minor CI wiring suggestion inline.

Reviewed changes

Reviewed the delta since the prior pullfrog review (2a73e6b..ad0ccf8, commit ad0ccf8) against the full PR diff.

  • Ran the addon gates on the Windows job — the four node-pty suites plus the module-walker one are now named in the package_windows job's explicit test list, closing the gap where their skipIf(win32) assertions were skipped on Linux and reached nowhere else.
  • Rebuild diagnosis matches the failure — a conpty.node that is not a PE image at all now reports a truncated or quarantined artifact, while the --arch diagnosis is kept for a genuine cross-arch build.
  • Missing-addon wording — "fall through to" replaces "would load", which is true whether or not the prebuild is present.
  • Dropped isLoadableByArch — no caller remained once the packaged gate needed the raw machine field for its message.
  • One PE read per candidate — the packaged gate caches each candidate's machine instead of re-reading it up to three times.
  • fileURLToPath fix — the module-walker test now resolves its own URL through fileURLToPath (with the import), addressing the prior review's finding on local Windows checkouts.
  • Walker comment — documents that projectRequire/requireLocal specifiers are deliberately not followed because they resolve against the project root.

I confirmed the fix for the prior review's finding. All five affected suites pass (96 passed, 4 Windows-gated skips) and oxlint is clean on the changed files.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread .github/workflows/pr.yml Resolved
Putting these files on the Windows job turned four assertions red on the first
run. Three of them were in tests that carried `skipIf(platform !== 'win32')` and
had therefore never executed anywhere, on any branch.

- `writeFakeElectronRebuild` emitted the `windows-process-tree` addon a real
  rebuild leaves but never node-pty's, so every Windows test of the rebuild path
  ran against a tree no real rebuild can produce: node-pty "rebuilt" with nothing
  in `build/Release`. The new same-host check reads that state correctly and said
  so. The fake rebuild now writes `build/Release/conpty.node` when it was asked
  to rebuild node-pty for win32, with the marker and the target machine.
- `mkTempProject` never staged `windows-process-tree-creation-time.cjs`. The
  rebuild script reaches it through `projectRequire`, which resolves against the
  project root, so the module walker cannot follow it and must not try. Staged by
  name, with a comment saying which of the two it is. Without it the
  windows-process-tree probe failed to load its own checker and the module joined
  `modulesToRebuild`, which is the second and third red assertion.
- the two `nodePtyAddonPath` cases compared against a literal POSIX string.
  `resolve` returns a drive letter and backslashes on Windows, so they could only
  ever pass off it. Built from segments now, which still pins the `..` traversal
  that is the point of the test.

Verified on macOS: ensure-native-runtime-job-ownership,
verify-packaged-node-pty-job-ownership, windows-pe-machine,
script-module-dependencies, rebuild-native-deps-node-pty, rebuild-native-deps,
rebuild-native-deps-windows-process-tree, ensure-native-runtime -- 109 passed, 6
skipped. The 6 are the Windows-gated rebuild tests, which is the job this change
is aimed at; Windows CI is the arbiter.
…that is no image

The packaged gate had two remedies for landing on the published prebuild and
picked between them on `!prebuilt`, which puts a truncated, empty or quarantined
`build/Release/conpty.node` in the cross-arch bucket: "the source build beside it
is the wrong architecture ... re-run with --arch". It is not the wrong
architecture, it is not an architecture, and `--arch` is not the command. The
rebuild-path gate was split for exactly this a commit ago; this is the same split
in the place that had not had it.

Also from review of the settled state:

- the stale-source-build branch ended in a call that happened to throw, so a
  reader could not see it was terminal and the file was read twice to get there.
  The verdict is now an Error the caller throws, built once from the read it
  already did, and shared with `assertCygwinBreakawayDenied` rather than copied.
- four injection seams had no consumer in production or in tests
  (`deniesBreakaway`, `peMachine`, and `exists`/`peMachine` on the rebuild
  verdict). An unused seam is a way for the tested path and the real one to drift
  apart; the tests drive both with real files. Removed.
- the loader table existed in a docblock and in the reference doc, already
  disagreeing about row four. The docblock cites the doc now.
- `peImage` stamped machine `0x0000` for an arch it had no value for, because
  `writeUInt16LE(undefined)` coerces to zero. A fixture that quietly invents the
  field the gates read is the same species of silent lie the gates exist to
  catch; it throws, and a test holds it to that.
- a test named for refusing an unreadable candidate asserted only that something
  threw. Renamed to what it proves.

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

Important

The Windows package job is still red on this head: four tests in config/scripts/rebuild-native-deps-node-pty.test.mjs fail on the same two fixture gaps this commit set out to close. Details inline.

Reviewed changes

Reviewed the delta since the prior pullfrog review (ad0ccf8): 2d623d7 is a docs-only tense correction, and b5ee1b09 responds to the first Windows run of the newly-wired node-pty suites.

  • Fake win32 rebuild now emits a ConPTY addon — writeFakeElectronRebuild writes build/Release/conpty.node (a real PE machine for the target arch plus the marker) when a win32 rebuild targets node-pty; rebuild(options) now receives the options object it reads.
  • Creation-time checker staged by name — mkTempProject copies windows-process-tree-creation-time.cjs, which the rebuild script reaches through projectRequire and the module walker cannot follow.
  • nodePtyAddonPath tests are cross-platform — the two cases build their expected paths with resolve/join instead of literals that could only pass off Windows.

The intent is right and the OS-independent suites still pass (96 passed, 4 Windows-gated skips locally). But the arbiter named in the commit message disagrees: package (windows) at b5ee1b09 fails fails a same-host Windows rebuild that left no addon (:497), rebuilds a loadable ConPTY native that lacks Orca job ownership (:270), does not rebuild a healthy node-pty when another Windows addon fails its probe (:244), and repairs a missing ConPTY runtime before probing without recompiling node-pty (:46). The first two fail on the new emitNodePty writing an addon whose runtime payload is never staged; the middle two fail because the fake @vscode/windows-process-tree still cannot satisfy the checker the commit just staged.

ℹ️ Unrelated failure in the same Windows job

src/main/browser/browser-client-page-renderer-lifecycle.electron.test.ts also fails in package (windows) with a browser_client_page_renderer_attach_timeout, which is outside this PR's files. Flagging it only so the red job is not wholly attributed to the four node-pty tests.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Second round of what running these suites on Windows exposed. The module the
walker could not stage is now staged, so the probe reached its own checker and
the real reasons surfaced:

- `writeFakeWindowsProcessTree` exported `{}`. The creation-time gate reads
  `supportedProcessDataFlags` off the addon and calls its absence "the tarball
  prebuilt, not a build of the patched source" — correctly. The fixture predates
  that gate and, being Windows-only, never met it. The healthy fake now reports
  the flag, taken from the gate's own constant. Two tests were failing on this,
  the second only because the module then joined `modulesToRebuild`.
- `rebuilds a loadable ConPTY native that lacks Orca job ownership` asked for a
  node-pty rebuild in a tree where node-pty had none of the payload its package
  ships. It gets `writeFakeNodePtyConptyPayload` like its two siblings.

I also tried making the fake rebuild emit `build/Release/conpty.node` the way a
real one does, and backed it out: `restoreNodePtyWindowsConptyRuntime` keys off
that file and then reads `third_party/conpty`, so emitting it in a tree without
the package payload turns one honest gap into an ENOENT two steps away. The
payload fixture is where "node-pty has its addon" belongs.

macOS: ensure-native-runtime-job-ownership, verify-packaged-node-pty-job-ownership,
windows-pe-machine, script-module-dependencies, rebuild-native-deps-node-pty,
rebuild-native-deps, rebuild-native-deps-windows-process-tree,
ensure-native-runtime — 112 passed, 6 skipped. The 6 are the Windows-gated
rebuild tests; Windows CI is the arbiter and is why they are on that job now.

@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 in this delta. The two fixture findings from the prior review (emitNodePty writing a ConPTY addon without the runtime payload, and writeFakeWindowsProcessTree lacking supportedProcessDataFlags) are unchanged by this commit; this head's Windows job was cancelled before it ran.

Reviewed changes

Reviewed the delta since the prior pullfrog review (b5ee1b09..8217a9f, commit 8217a9f) against the full PR diff.

  • Third packaged verdict for a non-PE source build — verifyPackagedConptyBreakawayMarker no longer routes a truncated or quarantined build/Release/conpty.node down the "wrong architecture, re-run --arch" path; it names the file as not a PE image and asks for a rebuild instead.
  • Stale-source verdict built once and shared — staleConptySourceBuildError replaces the copy inside assertCygwinBreakawayDenied; both it and the packaged gate now throw that shared Error rather than relying on a call that happened to throw.
  • Unused injection seams removed — peMachine / exists / deniesBreakaway are gone from assertRebuiltConptyMatchesArch, assertRebuiltConptyDeniesMsysBreakaway and the packaged marker gate, so the tested path and the production path can no longer drift apart through them.
  • peImage refuses to invent a machine — the shared fixture throws for an arch with no PE_MACHINE entry instead of coercing to 0x0000, with a test holding it to that.
  • Docs and test naming — the verifyPackagedConptyBreakawayMarker docblock now cites the reference-doc table, and the unreadable-candidate test is renamed to what it actually proves.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (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 — this commit addresses both fixture findings from the prior review. Approval is withheld only because an earlier thread (the WINDOWS_PACKAGE_TESTS trigger scope) remains open and untouched.

Reviewed changes

Reviewed the delta since the prior pullfrog review (8217a9f..9ae11c9, commit 9ae11c9) against the full PR diff.

  • Fake rebuild no longer emits a ConPTY addon — writeFakeElectronRebuild and FAKE_CONPTY_BY_ARCH are reverted; the tests that need a node-pty addon stage it through writeFakeNodePtyConptyPayload, which is where the runtime payload restoreNodePtyWindowsConptyRuntime() reads belongs.
  • Healthy windows-process-tree fixture — writeFakeWindowsProcessTree now reports supportedProcessDataFlags taken from the gate's own CREATION_TIME_FLAG, so the creation-time probe it has to satisfy passes instead of landing in modulesToRebuild.
  • Test wiring — rebuilds a loadable ConPTY native that lacks Orca job ownership now stages the ConPTY payload beside its prebuild, matching its two siblings.

The OS-independent suites pass locally (99 passed, 4 Windows-gated skips). The package (windows) job is in progress on this head, so the arbiter has not reported yet.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Putting the five suites in the Windows lane's vitest argv gets them run once the
job starts; `WINDOWS_PACKAGE_TESTS` in `pr-code-change-scope.mjs` is what decides
whether the job starts at all. Only the argv was updated, so a PR touching just
`rebuild-native-deps-node-pty.test.mjs` would not have started the Windows job,
and its four Windows-only cases — including the same-host-absent one added here —
would have run on no machine for that PR. Exactly the shape of gap this branch is
about. Both lists now name all five, and `windows-pe-machine`,
`windows-pe-image-fixture` and `script-module-dependencies` join
`NATIVE_RUNTIME_PREFIXES` so a change to the modules themselves starts it too.

`win32-test-lane-registration.test.mjs` exists to catch precisely this and did
not, because its matcher only recognises suite-level gates (`describe.runIf` /
`describe.skipIf`) and a `.win32.` filename. These tests gate per `it`. Widening
it is not this branch's change to make: about thirty files across the repo carry
per-`it` Windows gates and are unregistered, so the ratchet would move far beyond
node-pty. Flagged rather than done.

Message repairs from the same review:

- the non-PE arm of the rebuild-time arch error read "... is not a PE image, so
  nothing can load it, so node-pty would fall back ...". The shared consequence
  clause already opens with ", so".
- the no-source-build packaging error ended "Package this Windows slice on such a
  host", which is wrong advice for the case where the host IS such a host and the
  rebuild simply left nothing — reachable when the artifact is removed before
  prune runs. It now names both readings and points at the beforeBuild output.
- the relay-addon builder blamed `--arch` for a build output that is not a PE at
  all, the same guess the node-pty gate was taught to stop making.
- the patch-drift assertion was a bare `toBe(true)`, so a real drift read as
  "expected false to be true". It now names the two things that can have drifted
  and what happens until they agree.

@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 — this commit closes the WINDOWS_PACKAGE_TESTS trigger gap raised in the prior review and repairs three user-facing error messages.

Reviewed changes

Reviewed the delta since the prior pullfrog review (9ae11c9..c9e1240, commit c9e1240) against the full PR diff.

  • package_windows now starts for these suites — the five node-pty/addon suites are added to WINDOWS_PACKAGE_TESTS, so a PR touching only one of them still starts the Windows job, and windows-pe-machine, windows-pe-image-fixture and script-module-dependencies join NATIVE_RUNTIME_PREFIXES. This closes the .github/workflows/pr.yml:874 thread from review 5218913403 (replied and resolved this run).
  • Rebuild error wording — the non-PE arm of the --arch error drops the redundant "so nothing can load it" (the shared consequence clause already opens with ", so"), and the no-source-build packaging error no longer tells a capable Windows host to change hosts; it names both readings and points at the beforeBuild output.
  • Relay builder blames the right cause — a non-PE build output is now described as truncated or quarantined rather than as node-gyp ignoring --arch, matching the node-pty gate's same correction.
  • Patch-drift assertion carries a message — the bare toBe(true) now names the two things that can have drifted and what happens until they agree.
  • Second remedy sentence pinned — the new does not assume the packaging host is the wrong one test asserts the If this IS a Windows x64 host half of the shared error, so the wording fix cannot silently revert.

I verified classifyPrJobs returns package_windows: true for each newly registered suite (isProductBundlePath returns false for .test.*, so the explicit list is the only trigger), and that all five names are also present in the Windows lane's vitest argv. The six affected suites pass locally (131 passed, 4 Windows-gated skips), including win32-test-lane-registration.test.mjs.

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

@nwparker
nwparker merged commit ea01cd0 into main Sep 17, 2026
33 checks passed
@nwparker
nwparker deleted the inv18191-msys-job-breakaway branch September 17, 2026 05:23
@nwparker
nwparker restored the inv18191-msys-job-breakaway branch September 17, 2026 05:25
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…y denial (stablyai#20047)

* docs(windows): record the measured MSYS job-breakaway mechanism

The per-PTY job already denies JOB_OBJECT_LIMIT_BREAKAWAY_OK for Cygwin/MSYS
shells (stablyai#19068), but nothing records why, and a conpty.node built before that
commit fails windows-msys-job.win32.test.ts in a way that reads as a source
defect. Measured on a real Windows 11 host: both the plain and the exec-
replacement Git Bash shapes leak, the escape is the MSYS runtime's own
spawn/exec (fork keeps membership), and a single-variable A/B on
usesCygwinRuntime flips the result 0/2 -> 4/4.

Also names the gap the failure hid behind: node-pty-job-ownership.cjs asserts
symbol presence, which cannot distinguish patch revisions.

* fix(windows): reject a node-pty addon that predates the MSYS breakaway denial

The native-runtime gate asserted only that terminateJob, listJobProcessIds and
assignCurrentProcessToJob were exported. All three predate the Cygwin/MSYS
breakaway denial, so an addon built before it passes every gate,
isPtyJobOwnershipAvailable() returns true, and windows-pty-job.win32.test.ts
passes 6/6 -- while every Git Bash child is created outside its pane's job and
survives terminatePtyJob.

Read the resolved .node and require the wide msys-2.0.dll literal that
usesCygwinRuntime holds, the way stagedRelayAddonIsUnpatched() already tells a
patched windows-process-tree addon from a published one. An addon the caller
cannot name is refused rather than skipped: a gate that cannot see its subject
is not a gate.

Verified against real binaries on a Windows 11 host: the shared checkout's
pre-stablyai#19068 build errors, a build from current patched source passes, a missing
path errors.

Also closes the cross-host packaging skip. The export half has to load the
addon so it cannot run when the packaging host is not the target, which is how
a Windows release built elsewhere could ship this. The marker is a file read
and needs neither; an unrecognised layout warns rather than fails a release
that was packaging fine.

* fix(windows): check the MSYS breakaway denial on the rebuild path too

The Electron probe carried the marker check, but it lives inside
probeElectronNativeModules, which returns early whenever the Electron package
binary is unusable. Covered by another path is not this path checks -- and the
defect this whole change closes was a gate that looked like it checked.

Reading the binary needs neither a loadable Electron nor an executable target
arch, so assert it after the rebuild, beside the windows-process-tree
assertion that exists for the same reason: this is the addon copied into the
packaged app. Absent warns (a cross-platform rebuild need not leave a win32
addon on this disk); present and unmarked is fatal.

The fixtures now write a real addon file, because the gate reads the binary it
was told about rather than trusting the exports. Verified against the two real
binaries measured on the Windows host: the pre-stablyai#19068 build fails this path,
the build from current patched source passes.

* fix(windows): check the marker on every ConPTY path the packaged app can load

The packaged marker check read one hard-coded path, `build/Release/conpty.node`,
and warned when it was absent. `loadNativeModule` tries `build/Release`, then
`build/Debug`, then `prebuilds/win32-<arch>`, swallowing each failure, and
`prunePackagedNodePty` drops the published prebuild only when a same-arch
`build/Release` exists to replace it. So the two packages the check was added for
were the two it could not see:

- cross-host: no host but Windows can build conpty.node, so there is no
  `build/Release` and the prebuild is what ships. The check warned and returned.
- cross-arch: `build/Release` is the packaging host's own arch, patched and
  marked, so the check printed OK -- while the target app cannot load it and
  falls through to the unmarked prebuild underneath.

Measured, not assumed: both published Windows prebuilds in the node-pty tarball
contain neither `msys-2.0.dll` nor `cygwin1.dll` in any encoding. They are the
binary that leaks every MSYS pane child out of its job.

It now sweeps every candidate present for the *target* arch and refuses a package
with no candidate at all, which is a package with no ConPTY backend rather than a
layout to shrug at. It runs for every Windows slice instead of only the branch
the export check skips, so deleting the export check cannot silently take it too.
A stale source build keeps the rebuild advice; the prebuild gets the advice that
actually works, which is to package the slice on a Windows host of that arch.

Also: the marker constant was re-typed in four places and was tied to the C++
literal that produces it by nothing at all, so editing the patch would have left
a gate that fails every correctly rebuilt addon and tells the developer to do the
one thing that cannot help. The fixtures now take the constant from the gate, and
a test asserts the patch still adds `L"msys-2.0.dll"` to conpty.cc.

And the rebuild path treated a missing addon as a warning even on the host that
will run the install, where node-pty would fall through to that same prebuild.
The verdict is now a value, so it is tested without a platform gate.

* fix(windows): resolve the packaged ConPTY the way its loader does

Sweeping every candidate and demanding the marker on all of them was wrong in
the one case it was meant to make safe. `beforeBuild` runs
`rebuild-native-deps.mjs --platform=win32 --arch=<target>`, so a cross-arch slice
normally does get a patched `build/Release` for the target; `prunePackagedNodePty`
keeps the prebuild anyway because its guard is `electronArch === process.arch`
rather than the arch of the binary. That package is correct and its leftover
prebuild is never reached, and the sweep failed it -- telling whoever ran it to
package on a Windows arm64 host, which is both the wrong remedy and one no runner
here can offer.

Presence cannot separate that package from the one whose cross-arch rebuild
quietly emitted the host's architecture, because the only difference is the arch
of `build/Release`. So the gate now resolves the addon the way `loadNativeModule`
does -- first candidate whose PE `IMAGE_FILE_HEADER.Machine` matches the target,
walking root-then-lib for each layout in node-pty's own order -- and checks the
marker on the one that will actually run. A package with no candidate, or none of
the target's architecture, is refused: it has no ConPTY backend either way, and
the second is exactly what a silently host-arch cross-build looks like.

The PE machine reader already existed, privately, in the relay addon builder that
needed the same "a cross-build cannot silently emit host arch" guarantee. It is
now shared rather than copied.

Two seams were unreachable from anything but Windows, so nothing tested them:

- the afterPack hook's win32 block was an inline if/else that only a source-text
  assertion could inspect, and that assertion could not tell the difference
  between the check running and the check being wrapped in `try {} catch {}`. It
  is now `verifyPackagedWindowsNodePty`, and "the marker check runs even where
  the export check cannot" is four spied assertions instead of a string match.
- the rebuild path's verdict read `process` directly, so the branch that fires
  only on the host being rebuilt for was dead on every other host. It now takes
  the host as arguments, and the fs checks, the warning and the failure are all
  exercised from macOS.

Fixtures write a real PE header rather than `MZ fake addon`, since the gate now
reads one. The machine table is pinned to the documented IMAGE_FILE_MACHINE
values, because every fixture builds its header from that table and a table wrong
in both entries would otherwise agree with itself.

* fix(windows): say why the packaged ConPTY fell back, not just that it did

The previous commit resolved the addon by architecture but still had one message
for every way the resolution could land on the published prebuild. Those ways
want opposite remedies, and the one it printed was the remedy the commit before
it had just called wrong:

- no source build in the package at all — the slice has to be built somewhere
  that can build node-pty for the target arch.
- a source build that is there but is the packaging host's architecture, because
  the cross-arch rebuild did not honour `--arch` — re-running that rebuild is the
  fix, and "package on a Windows arm64 host" is neither necessary nor possible.

The second is the common one, since node-pty publishes a prebuild for both
Windows arches and prune keeps the target's on every cross-arch package. So the
old text fired mostly on the case it described least. It now reports which source
builds were skipped and the machine field each carried, and names the rebuild
command.

"Nothing the target can load" had the same problem in reverse: a zero-length or
truncated `conpty.node` got a cross-architecture diagnosis. Every candidate is
now named with what was actually read, including "not a PE image".

The rebuild path asserts the architecture too. A rebuild that ignored `--arch`
was otherwise only visible at packaging, two steps from the command that fixes
it. Arches with no known machine value are left unjudged rather than guessed at.

Two things the extraction broke or nearly broke, both found by mutation:

- the shared PE reader answers `null` where the relay builder's private copy
  returned a number, which would have turned its "node-gyp ignored --arch" error
  into a `TypeError`. Both callers now go through `describePeMachine`.
- the rebuild fixtures stage a script's co-located modules by walking its
  imports, and the walker only understood `from '...'` — so the gate's new
  `require('./windows-pe-machine.cjs')` was left behind and every subprocess test
  failed with a resolution error, which is the exact failure its own comment
  warns about. It now follows `require` and bare side-effect `import` as well,
  and has tests; the fixture stages the gate by walking it rather than by naming
  one file.

Fixtures write real PE headers through one shared builder instead of three
hand-rolled ones.

* fix(windows): run the node-pty addon gates on the Windows job that can

`rebuild-native-deps-node-pty.test.mjs` carries four `skipIf(platform !== 'win32')`
tests. The full suite runs on ubuntu, and the Windows PR job runs an explicit
file list that never named this file -- so those tests were skipped on Linux and
never reached anywhere else. Three of them predate this branch. The Windows job
is added the four node-pty addon suites plus the module-walker one; the comment
above that list already says why it is the right place, which is that the addon
assertions only hold once natives have been rebuilt. Running the path-joining
suites there also covers the separator this gate's candidate list is built from.

The rest is round-three review:

- the rebuild-time arch assertion told a reader "node-gyp did not honour --arch"
  about a file that was not a PE image at all, which is a truncated or
  quarantined artifact and a different command to run. The two now read
  differently, and neither claims the other's cause. Same fix the packaged gate
  had one commit ago, in the place that had not had it yet.
- the missing-addon error said node-pty "would load" a prebuild without checking
  it is there. It says "fall through to" now, which is true either way.
- `isLoadableByArch` had no caller left once the packaged gate started needing
  the raw machine field for its message. Removed rather than kept warm.
- each candidate's header is read once instead of up to three times.
- the module walker's comment claimed every shape that reaches a co-located
  module; it does not follow `projectRequire`/`requireLocal`, and it must not --
  those specifiers resolve against the project root, so following one stages the
  wrong path and the copy fails. Proven by trying: widening the pattern to
  require-shaped names broke nine tests on
  `projectRequire('./config/scripts/...')`. The comment now says what it follows
  and why it stops there.
- a new test resolved a file URL with `.pathname`, which keeps the drive-letter
  slash on Windows -- the very job this commit adds it to.

* docs(windows): put the superseded export-only gate in the past tense

It describes what used to pass a broken addon, so present tense reads as a
description of the gate the same document then explains replacing it.

* fix(windows): repair what running the node-pty suites on Windows exposed

Putting these files on the Windows job turned four assertions red on the first
run. Three of them were in tests that carried `skipIf(platform !== 'win32')` and
had therefore never executed anywhere, on any branch.

- `writeFakeElectronRebuild` emitted the `windows-process-tree` addon a real
  rebuild leaves but never node-pty's, so every Windows test of the rebuild path
  ran against a tree no real rebuild can produce: node-pty "rebuilt" with nothing
  in `build/Release`. The new same-host check reads that state correctly and said
  so. The fake rebuild now writes `build/Release/conpty.node` when it was asked
  to rebuild node-pty for win32, with the marker and the target machine.
- `mkTempProject` never staged `windows-process-tree-creation-time.cjs`. The
  rebuild script reaches it through `projectRequire`, which resolves against the
  project root, so the module walker cannot follow it and must not try. Staged by
  name, with a comment saying which of the two it is. Without it the
  windows-process-tree probe failed to load its own checker and the module joined
  `modulesToRebuild`, which is the second and third red assertion.
- the two `nodePtyAddonPath` cases compared against a literal POSIX string.
  `resolve` returns a drive letter and backslashes on Windows, so they could only
  ever pass off it. Built from segments now, which still pins the `..` traversal
  that is the point of the test.

Verified on macOS: ensure-native-runtime-job-ownership,
verify-packaged-node-pty-job-ownership, windows-pe-machine,
script-module-dependencies, rebuild-native-deps-node-pty, rebuild-native-deps,
rebuild-native-deps-windows-process-tree, ensure-native-runtime -- 109 passed, 6
skipped. The 6 are the Windows-gated rebuild tests, which is the job this change
is aimed at; Windows CI is the arbiter.

* fix(windows): give the packaged fallback a third verdict, for a file that is no image

The packaged gate had two remedies for landing on the published prebuild and
picked between them on `!prebuilt`, which puts a truncated, empty or quarantined
`build/Release/conpty.node` in the cross-arch bucket: "the source build beside it
is the wrong architecture ... re-run with --arch". It is not the wrong
architecture, it is not an architecture, and `--arch` is not the command. The
rebuild-path gate was split for exactly this a commit ago; this is the same split
in the place that had not had it.

Also from review of the settled state:

- the stale-source-build branch ended in a call that happened to throw, so a
  reader could not see it was terminal and the file was read twice to get there.
  The verdict is now an Error the caller throws, built once from the read it
  already did, and shared with `assertCygwinBreakawayDenied` rather than copied.
- four injection seams had no consumer in production or in tests
  (`deniesBreakaway`, `peMachine`, and `exists`/`peMachine` on the rebuild
  verdict). An unused seam is a way for the tested path and the real one to drift
  apart; the tests drive both with real files. Removed.
- the loader table existed in a docblock and in the reference doc, already
  disagreeing about row four. The docblock cites the doc now.
- `peImage` stamped machine `0x0000` for an arch it had no value for, because
  `writeUInt16LE(undefined)` coerces to zero. A fixture that quietly invents the
  field the gates read is the same species of silent lie the gates exist to
  catch; it throws, and a test holds it to that.
- a test named for refusing an unreadable candidate asserted only that something
  threw. Renamed to what it proves.

* fix(windows): make the rebuild fixtures represent a tree that can exist

Second round of what running these suites on Windows exposed. The module the
walker could not stage is now staged, so the probe reached its own checker and
the real reasons surfaced:

- `writeFakeWindowsProcessTree` exported `{}`. The creation-time gate reads
  `supportedProcessDataFlags` off the addon and calls its absence "the tarball
  prebuilt, not a build of the patched source" — correctly. The fixture predates
  that gate and, being Windows-only, never met it. The healthy fake now reports
  the flag, taken from the gate's own constant. Two tests were failing on this,
  the second only because the module then joined `modulesToRebuild`.
- `rebuilds a loadable ConPTY native that lacks Orca job ownership` asked for a
  node-pty rebuild in a tree where node-pty had none of the payload its package
  ships. It gets `writeFakeNodePtyConptyPayload` like its two siblings.

I also tried making the fake rebuild emit `build/Release/conpty.node` the way a
real one does, and backed it out: `restoreNodePtyWindowsConptyRuntime` keys off
that file and then reads `third_party/conpty`, so emitting it in a tree without
the package payload turns one honest gap into an ENOENT two steps away. The
payload fixture is where "node-pty has its addon" belongs.

macOS: ensure-native-runtime-job-ownership, verify-packaged-node-pty-job-ownership,
windows-pe-machine, script-module-dependencies, rebuild-native-deps-node-pty,
rebuild-native-deps, rebuild-native-deps-windows-process-tree,
ensure-native-runtime — 112 passed, 6 skipped. The 6 are the Windows-gated
rebuild tests; Windows CI is the arbiter and is why they are on that job now.

* fix(windows): register the node-pty addon suites in the scope list too

Putting the five suites in the Windows lane's vitest argv gets them run once the
job starts; `WINDOWS_PACKAGE_TESTS` in `pr-code-change-scope.mjs` is what decides
whether the job starts at all. Only the argv was updated, so a PR touching just
`rebuild-native-deps-node-pty.test.mjs` would not have started the Windows job,
and its four Windows-only cases — including the same-host-absent one added here —
would have run on no machine for that PR. Exactly the shape of gap this branch is
about. Both lists now name all five, and `windows-pe-machine`,
`windows-pe-image-fixture` and `script-module-dependencies` join
`NATIVE_RUNTIME_PREFIXES` so a change to the modules themselves starts it too.

`win32-test-lane-registration.test.mjs` exists to catch precisely this and did
not, because its matcher only recognises suite-level gates (`describe.runIf` /
`describe.skipIf`) and a `.win32.` filename. These tests gate per `it`. Widening
it is not this branch's change to make: about thirty files across the repo carry
per-`it` Windows gates and are unregistered, so the ratchet would move far beyond
node-pty. Flagged rather than done.

Message repairs from the same review:

- the non-PE arm of the rebuild-time arch error read "... is not a PE image, so
  nothing can load it, so node-pty would fall back ...". The shared consequence
  clause already opens with ", so".
- the no-source-build packaging error ended "Package this Windows slice on such a
  host", which is wrong advice for the case where the host IS such a host and the
  rebuild simply left nothing — reachable when the artifact is removed before
  prune runs. It now names both readings and points at the beforeBuild output.
- the relay-addon builder blamed `--arch` for a build output that is not a PE at
  all, the same guess the node-pty gate was taught to stop making.
- the patch-drift assertion was a bare `toBe(true)`, so a real drift read as
  "expected false to be true". It now names the two things that can have drifted
  and what happens until they agree.
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