Skip to content

fix(link): run the served install for Windows link sync and update planning (#8359) - #8781

Merged
lidge-jun merged 3 commits into
devfrom
fix/8359-windows-gated-served
Nov 16, 2026
Merged

lidge-jun merged 3 commits into
devfrom
fix/8359-windows-gated-served

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

On Windows, ocx link sync (pinned and overwrite) and update planning still picked the first runnable Desktop/PATH ocx. A stale bun-global ocx.exe could answer their version gate even though another install serves the Child. #8769 fixed discovery and ocx link probe; this PR fixes the rest of #8359 (step 3 of its plan).

  • windowsGatedOcxArgv (update plan) and windowsOverwriteSyncArgv (pinned and overwrite sync) now read the same first serving-runtimes.json record as discovery. The served install, including an npm [bun.exe, cli\index.ts] pair, comes first and answers the version gate. A runnable ocx-child still comes first while the Child has lightweight state, and the Windows plan probe still reports entry binary (Windows never applies).
  • Transport change, to make room: these scripts sat about 120 characters under cmd.exe's 8,000-character limit, and the census reader costs about 600. The deflated payload now travels 14 bits per character in U+3400..U+73FF, with its byte count, instead of one byte per character.
    • Every packed character is plain text inside a single-quoted PowerShell literal: no ASCII, none of the U+2018..U+201B smart quotes that also end such a literal, and no surrogates.
    • Every Windows command shrinks by about 2,000 characters. With the census added, the longest is now about 5,900.
    • The inflate guard is unchanged in shape: a session that cannot build the streams, such as Constrained Language Mode, still exits 126 before anything runs.
  • The six test files that each carried their own decoder now share windowsInflatedScript. The Windows served-home fixture moved to tests/helpers/windows-served-home.ts.
  • Two tests changed meaning: the longest valid Home version used to overflow the plan probe and is now asserted to fit. The named windows-command-too-long error is still tested with an argument that cannot fit, and link-child-observe now injects that builder error to cover its failed mapping (2ccd824271; PR shard 1 caught the old version).

Closes #8359

Verification

Failing tests came first. The three new Windows behavior tests fail against origin/dev's remote-windows.ts on the Windows host, because Bun's own version fails the gate (exit 121). The packing-alphabet and budget-headroom tests failed locally before the change.

Windows 11 (build 26200.9974, Bun 1.3.14, GOAT host desktop-c795oh4), at 28b624e3db:

  • The three new gated tests pass: pinned sync, overwrite sync and update plan each run the served bun.exe entry pair.
  • The five existing (#8359) discovery and inspection tests pass.
  • Every native-execution and containment test passes on the new packing: argument and stdin fidelity, the SSH channel drop killing the contained ocx, the per-builder cannot-be-contained refusals, constrained containment probes, and the inflated script's own errors staying unrelabelled.
  • Seven link test files: 104 pass / 74 skip / 1 fail. The one failure is the known junction test ("Windows discovery selects Desktop before the managed current junction…"). It also fails on origin/dev: it overruns the 5 s default timeout, and Bun 1.3.14 returns EFAULT when it removes a directory junction.
  • Against origin/dev's remote-windows.ts, all three new gated tests fail with exit 121.
  • The first push (f463d96e71) failed those three tests on Windows because the served entry shared $a with the gate loop's version parts. 28b624e3db moves it to $sx/$sy.
  • On f463d96e71, three link-recover "tombstone bound" tests timed out; they fail the same way on origin/dev 7b4b3958d.

macOS (Bun 1.4.4), light checks only because the host is under critical load:

  • bun test on link-windows-gated-served, link-ssh-argv-discovery, link-gated-ocx-argv, link-pinned-sync-overwrite, link-pinned-sync-argv, link-ephemeral-child-discovery, link-child-plant-foundations, link-recover, link-enrollment: 290 pass / 23 skip / 0 fail.
  • bun run typecheck: exit 0. bun run structure:check: passed. bun run privacy:scan: passed.
  • docs-spanish-localization, test-layout, test-layout-tooling and file-size-ratchet tests: 68 pass / 0 fail.

NOT RUN: bun run test:changed and the full suite locally (this Mac is at critical load; PR CI runs test changed).
NOT RUN: lane=all (left to the batched dev dispatch per CI policy).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (structure/remote-link.md; docs-site Remote Link guide in English and Spanish.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (The containment helper source is unchanged. The new decoder sits inside the same guard that refuses to run outside the kill-on-close job.)

Summary by CodeRabbit

  • Bug Fixes
    • Windows link syncs and update checks now select the installation most recently used to serve the Child, keeping executable selection and version checks consistent.
    • When Child state is available, its runnable executable takes priority over other installations, including global npm installations launched through Bun.
  • Documentation
    • Updated the Remote Link guides in English and Spanish to explain Windows installation selection for link sync and update planning.

…anning (#8359)

The pinned and overwrite syncs and the gated update plan on Windows now read the first serving-runtimes record like discovery and inspection, so a stale bun-global ocx can no longer answer their version gate. To fit the census under the cmd.exe command line, the packed payload now carries 14 bits per character (U+3400..U+73FF) with its byte count instead of one byte per character, cutting about 2,000 characters from every Windows command. Test decoders share windowsInflatedScript.
The Windows host showed the gated scripts handing bun.exe the version parts: the gate loop reassigns $a, which also held the served entry. The served candidate now uses $sx and $sy, which nothing else assigns.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 16, 2026 02:14
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 16, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T02:17:05.013897Z 28b624e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Windows gated sync and update commands now select the runtime recorded as serving the Child. Windows script packing now uses 14-bit characters and includes the original byte length. Tests and documentation reflect these changes.

Changes: Windows Remote Link

Layer / File(s) Summary
Windows script transport
src/link/remote-windows.ts, tests/clients/link-windows-gated-served.test.ts, tests/clients/link-child-plant-foundations.test.ts, tests/clients/link-ephemeral-child-discovery.test.ts, tests/clients/link-gated-ocx-argv.test.ts, tests/clients/link-pinned-sync-argv.test.ts, tests/clients/link-pinned-sync-overwrite.test.ts, tests/server/link-recover.test.ts
Packed scripts use 14-bit characters and include the original byte length. windowsInflatedScript provides shared script decoding for tests. Tests check packed argument round-trips, character range, and command-size limits.
Served-runtime gated commands
src/link/remote-windows.ts, tests/helpers/windows-served-home.ts, tests/clients/link-ssh-argv-discovery.test.ts, tests/clients/link-windows-gated-served.test.ts, tests/clients/link-pinned-sync-argv.test.ts, tests/clients/link-gated-ocx-argv.test.ts, scripts/test-layout/layout-clients.json, tests/fixtures/test-layout-expected.json, tests/clients/link-child-observe.test.ts, docs-site/src/content/docs/guides/remote-link.md, docs-site/src/content/docs/es/guides/remote-link.md, structure/remote-link.md
Gated commands include the runtime recorded as serving the Child. If that runtime has an entry prefix, version probes and command execution use it. Tests cover pinned sync, overwrite sync, and update-plan commands. Documentation describes the selection order and script format.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 2ccd8

Windows link sync and update planning now use the install that serves the Child. No concrete merge-blocking risk was identified in the supplied changes.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#8359] The PR claims one Windows objective: pinned sync, overwrite sync and update planning must run the install that serves the Child. At head, src/link/remote-windows.ts adds SERVED_CANDIDATE. It r… Confirm that #8769 is merged in the base and that its discovery and probe changes are present at head, using a readable base revision. Provide evidence (test or recorded run) that ocx link probe reports the serving runtime version for the m…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the Windows link sync and update-planning fix, which matches the main change: pinned/overwrite sync and the gated update-plan probe now select the install serving the Child via serving…
Out of Scope Changes check Passed Each change ties to #8359 step 3 or supports it. (1) Served-install ordering in remote-windows.ts (SERVED_CANDIDATE, A/P helpers, gated and overwrite argv) implements the objective. (2) The 14-bit U+3…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the Windows link sync and update-planning fix, which matches the main change: pinned/overwrite sync and the gated update-plan probe now select the install serving the Child via serving-runtimes.json. The title is specific and scoped to the change. The PR number in the title matches the linked issue #8359, which is the originating issue, and the title is not misleading.

Full details: Out of Scope Changes check

Explanation

Each change ties to #8359 step 3 or supports it. (1) Served-install ordering in remote-windows.ts (SERVED_CANDIDATE, A/P helpers, gated and overwrite argv) implements the objective. (2) The 14-bit U+3400..U+73FF packing with a byte-count header, in packedPowerShellArgv and unpackPowerShell, is needed because the census reader adds about 600 characters to commands that already sit near the cmd.exe limit. The PR gives the budget figures. The inflate guard still wraps only the decompression, and Invoke-Expression stays outside the try, so the exit 126 behavior is kept. (3) windowsInflatedScript and windowsScriptData are shared test decoders. They replace six local decoders, which is a test refactor that supports the packing change. (4) tests/helpers/windows-served-home.ts moves the served-home fixture out of link-ssh-argv-discovery.test.ts. Test-layout entries (scripts/test-layout/layout-clients.json, tests/fixtures/test-layout-expected.json) register the new test file. (5) The long-version test in link-gated-ocx-argv and link-child-observe changes meaning because the longer command now fits. The windows-command-too-long error is still tested with an argument that cannot fit. (6) structure/remote-link.md and the English and Spanish Remote Link guides describe the new Windows selection order. No unrelated cleanup was found in the file list. Scope is consistent with the PR description.

Full details: Linked Issues check

Explanation

[#8359] The PR claims one Windows objective: pinned sync, overwrite sync and update planning must run the install that serves the Child. At head, src/link/remote-windows.ts adds SERVED_CANDIDATE. It reads the first record's command from serving-runtimes.json (64 KiB cap, absolute path, 1 or 2 elements, entry must exist). It places that install before the fixed candidates, and keeps ocx-child first when Child state exists. windowsGatedOcxArgv and windowsOverwriteSyncArgv then probe with the same prefix (A/P helpers). This matches the issue's suggested fix, which asks for the serving binary to be preferred. The npm-prefix candidates are covered by the census path rather than by new fixed paths. The issue's acceptance criterion is different: ocx link probe must report the serving version on three layouts (macOS A, macOS B, Windows). That criterion relies on #8769, which the PR says fixed discovery and probe. The base blob for src/link/remote-windows.ts could not be read (git cat-file failed for 915a5c8), so the base state of #8769 cannot be confirmed from this checkout. No test in the PR exercises the three reported probe layouts end to end. The Windows tests were run on a Windows host, outside this review. The macOS layouts are not changed by this PR. The issue remains open, so the probe criterion cannot be confirmed as met.

Resolution

Confirm that #8769 is merged in the base and that its discovery and probe changes are present at head, using a readable base revision. Provide evidence (test or recorded run) that ocx link probe reports the serving runtime version for the macOS A, macOS B, and Windows layouts. Then this assessment can be re-run. The sync and update-planning objective itself needs no further change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 28b624e and 2ccd824.

Files selected for processing: 1

  • tests/clients/link-child-observe.test.ts

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

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

Security review (merge manager's reviewer) at 28b624e: MERGE, no security or functional blocker.

  • Packing: every packed character is in U+3400..U+73FF inside the $ocxPacked single-quoted literal (no quote, smart quote, line break or surrogate), the script reaches cmd.exe as ASCII base64 via -EncodedCommand, Home arguments still travel as base64 JSON through Quote-Native; the PowerShell decoder's 32-bit arithmetic was checked against windowsInflatedScript on 300 payloads.
  • Census reader unchanged except variable renames ($sx, $sy); containment ([OcxJob]::Run, kill-on-close, --version limits, inflate guard exit 126) intact.
  • Length: worst case 6,060 of 8,000 (plan with a 127-char version); beyond the budget powershellArgv throws windows-command-too-long before SSH, with no truncation.
  • Gated and overwrite loops now use the same served-first order as discovery/probe; with no record the script is byte-identical to the old path.

Follow-ups (not blocking): stale comments at src/link/child-gated-ocx.ts:100, src/link/child-observe.ts:111 and the new remote-windows.ts ~300 docstring (child-update-contract.ts:133 does read the pair/binary distinction; harmless because Windows apply is unsupported); a Linux-runnable string test that A/P reference only $sx/$sy; select -Unique on the overwrite loop's candidates; name link-windows-gated-served.test.ts in structure/remote-link.md coverage.

Windows-only behavior (decoder, C# helper, served-pair tests, variable-reuse regression, CLM exit 126, kill on channel drop) is first exercised by the batched lane=all after this merges.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Merge-manager note on the test 3/5 failure at 28b624e (job 133049254014): tests/gui/gui-pair-http.test.ts:416 "Desktop pairing origin policy > a localhost bind…" — the spawned ocx start exited 1 before readiness. This PR touches only src/link/remote-windows.ts and Remote Link tests, nothing on that start path. The same test passed in #8763's full run at e6cd0de (2705 ms; its merge ref includes #8769's liveness changes) and #8766's at d173811 (3983 ms). The fixture spawns the server with stderr: "ignore" after findAvailablePort, so a port taken by another job on the shared self-hosted runner (lidge-ocx-07) would look exactly like this; the log cannot show more. Re-running the failed shard once; a second failure would be treated as real. Follow-up for the test: capture the child's stderr in the readiness message.

…test (#8359)

The longest valid Home version now fits the Windows plan probe, so the test drove the windows-command-too-long mapping through a builder that no longer overflows. It now injects the builder error and checks the longest version builds.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Merge-manager note: the test 1/5 failure at 28b624e (tests/clients/link-child-observe.test.ts, "a Windows argv over the budget…") was caused by this PR — the denser packing fits the test's 127-character Home version, so observation succeeded. 2ccd824 fixes it correctly: it asserts the longest valid version builds and injects the builder's overflow error to keep the windows-command-too-long mapping covered (I reproduced the same failure locally, 16/1, and an equivalent change, 17/0). The delta from the reviewed head is test-only, so the security review stands. The test 3/5 gui-pair-http failure was unrelated; the full lane is re-running on 2ccd824.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration of #8781 at 2ccd824 (closes #8359).

  • Review: a security review found no blockers. Windows pinned and overwrite sync and update planning now pick the same serving-runtimes.json record as discovery and probe. The census reader is unchanged apart from renamed variables. The 14-bit packing cannot break out of the PowerShell literal and stays within cmd.exe's 8,000-character limit; the worst case is the plan with a 127-character version, at 6,060 characters.
  • CI on this exact head: all 33 checks passed, including enforce-target.
  • Merge check: a simulated merge onto dev 347ca0c is clean, with no file over the size cap.
  • Windows evidence: the author ran the tests on desktop-c795oh4. The Windows-only tests (the PowerShell decoder, the C# helper, the served-pair behaviour) run in the next batched lane=all on dev, which will include this merge.

@lidge-jun
lidge-jun merged commit e03e590 into dev Nov 16, 2026
39 of 41 checks passed
@lidge-jun
lidge-jun deleted the fix/8359-windows-gated-served branch November 16, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Remote Link discovery picks a different/stale ocx than the one serving the Child, and misses npm-prefix installs

1 participant