Skip to content

Fix Windows bugs found while porting the test suite - #4737

Merged
SawyerHood merged 9 commits into
mainfrom
bb/windows-port-fixes-thr_jensq3v9th
Oct 2, 2026
Merged

SawyerHood merged 9 commits into
mainfrom
bb/windows-port-fixes-thr_jensq3v9th

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Running the full test suite on a Windows 11 VM surfaced product bugs that a Windows user, or a Windows server talking to a macOS or Linux machine, would hit. Each commit is one fix. Part of #1206.

What changed

  • Plugin install from a Windows folder. git:C:\src\my-plugin was read as a host name and fetched from https://C:\src\my-plugin. A drive-letter path is now a local repository. Its cache directory is the folder name plus a short hash of the path, because nesting the whole path under the cache exceeded the Windows path length limit during plugin builds.
  • Monaco editor plugin. File paths were joined with the server's own path module, so a Windows server asked a POSIX host for \remote\notes\file.txt, and "Copy relative path" under a POSIX root produced a backslash path on every platform. Paths now use the separator of the root they belong to.
  • Server. Project skills read from another machine got their SKILL.md path from the server's path.join (a Windows server could not load a POSIX machine's .bb/skills); the server-move checks tested for a prefix ending in /; initDb left SQLite open when a migration threw, which keeps the file locked on Windows.
  • Codex. A write to an exited Codex fails with EOF on Windows, not EPIPE; the bridge crashed with an uncaught error instead of reporting that Codex exited.
  • CLI and daemon. bb plugin new ran npm by bare name and left the scaffold without dependencies; a provider skill root resolved across parent folders was identified by a backslash path; a symbolic link given as a server-archive source was followed (O_NOFOLLOW does nothing on Windows; the source is now checked before opening and the opened handle must be the same file); bb server install-machine-service stopped with spawn sh ENOENT and now says the service is macOS and Linux only, and bb guide machines and the bb-cli skill say so too; BB_DATA_DIR=~\bb was not expanded.
  • Plugin build. A dynamic import of a file outside the plugin directory was emitted as a raw absolute path, which Node on Windows refuses, and is emitted as a file URL there; replacing a built bundle retries when another process has the old file open; the bare-package filter no longer matches a Windows entry path.
  • Scripts. The provider-literal ratchet compared import.meta.url with a file:// string that never matches a Windows path, so it checked nothing and exited 0 there; the plugin registry build and the plugin SDK's runtime-entry promotion failed on a Windows checkout.

How you verified

  • Windows 11 Enterprise VM (build 26300), on a branch combining this with the other open Windows changes: the tests that exercise each fix pass there (plugin install and update, native plugin server loading, the Monaco server test, bb plugin new, server archive, the ratchet test, config), as part of a full run with 19,090 passing tests.
  • Linux: tests added or changed with each fix pass, including parsing a Windows git source, the Monaco relative path, the ~\ expansion (Windows only), and the machine-service refusal (Windows only). On this branch before the last rebase, turbo run lint typecheck test --filter='...[origin/main]': 184 of 186 tasks passed. The failing tasks were the app and server test tasks, with tests that time out when the development machine is loaded (PromptBoxInternal.test.tsx, machine-environment.test.ts, plugin-native-server-loading.test.ts) and pass when run alone. After the rebase onto current main, lint and typecheck pass for the same filter.

Not verified: none of these were exercised by hand in the app; the evidence is the test suites on both platforms.

🤖 Generated with Claude Code

AGENT GENERATED

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T16:56:30.450178Z 42865be Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42865be8ca

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +186 to +189
if (process.platform === "win32") {
throw new Error(
"bb cannot install the background machine service on Windows. It is available on macOS and Linux.",
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Document the Windows service restriction

This makes install-machine-service unconditionally fail on Windows, but the in-CLI machine guide and plugins/bb-guide/skills/bb-cli still direct users and agents to run it after a server move without any platform qualification. Update both discoverable surfaces so Windows users are not guided into a command that cannot work.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

Comment on lines +61 to +62
process.platform === "win32" &&
(await lstat(sourcePath)).isSymbolicLink()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the opened file rather than the pathname

On Windows, if a source is replaced with a symlink between this lstat and open, O_NOFOLLOW is ineffective and the target is still followed. Because the archive planning and writing passes repeat this pattern, a process that can mutate a source path can make an external file pass both checks and be archived; validate the opened handle against the pre-open metadata or use a Windows no-follow equivalent.

Useful? React with 👍 / 👎.

SawyerHood and others added 9 commits October 2, 2026 17:25
A git plugin source that named a Windows folder, such as
git:C:\src\my-plugin, was read as a host name and fetched from
https://C:\src\my-plugin. A drive-letter path is now a local repository,
like a path that starts with a slash. Its cache directory is the folder
name plus a short hash of the path, because nesting the whole path under
the cache exceeded the Windows path length limit during plugin builds.

Co-Authored-By: Claude Code <[email protected]>
The Monaco editor plugin joined a host's root with the file path using
the server's own path module. A Windows server asked a POSIX host for
\remote-storage\notes\file.txt, and a nested file under a POSIX root
copied a backslash relative path on every platform, because the root was
classified with path.win32.isAbsolute, which accepts /x. Paths are now
joined and made relative with the separator of the root they belong to.

Co-Authored-By: Claude Code <[email protected]>
- Project skills read from another machine got their SKILL.md path from
  the server's own path.join, so a Windows server asked a Linux or macOS
  machine for a backslash path and that machine's .bb/skills did not load.
- The server move checks tested for a directory prefix ending in '/', so
  on a Windows source server plugins inside the data directory were
  treated as external paths and reported missing on the target.
- initDb left the SQLite connection open when the legacy automation
  export or a migration threw, which keeps the database file locked on
  Windows until the process exits.

Co-Authored-By: Claude Code <[email protected]>
On Windows a write to the Codex process's stdin fails with EOF, not EPIPE,
when Codex has exited. The bridge treated that as an unexpected error and
crashed with an uncaught 'write EOF' instead of reporting that Codex
exited.

Co-Authored-By: Claude Code <[email protected]>
- The provider-literal ratchet compared import.meta.url with a file://
  string built from argv, which never matches a Windows path, so the
  check printed nothing and exited 0 there.
- The plugin registry build resolved relative imports with the native
  path module and then reported an item name collision between the
  backslash and forward-slash spelling of one file.
- Promoting the plugin SDK's runtime entries renamed over a dist file
  another process had open and failed with EPERM; it now retries on
  Windows.

Co-Authored-By: Claude Code <[email protected]>
Only '~/' was expanded to the home directory, so BB_DATA_DIR=~\bb
resolved against the current directory on Windows.

Co-Authored-By: Claude Code <[email protected]>
- bb plugin new ran npm by bare name, which Windows cannot start because
  npm is npm.cmd; the scaffold was left without dependencies and the SDK
  version probe always reported the registry unreachable.
- A provider skill root resolved across parent folders was identified by
  a backslash relative path on Windows, so the same root had a different
  identity than on other platforms.
- O_NOFOLLOW does nothing on Windows, so a symbolic link given as a
  server archive source was followed instead of refused.
- The plugin server build's bare-package filter matched a Windows entry
  path and esbuild refused to mark the entry point external.

Co-Authored-By: Claude Code <[email protected]>
A plugin server that dynamically imports a file outside its own
directory had that import emitted as a raw absolute path, which Node on
Windows refuses as an unsupported URL scheme; it is emitted as a file URL
there. Replacing a built bundle renamed over a file another process had
open and failed with EPERM, reported as a failed plugin build; the
rename now retries on Windows.

Co-Authored-By: Claude Code <[email protected]>
The command runs the POSIX machine installer, so on Windows it stopped
with an unhandled 'spawn sh ENOENT'. It now says the background machine
service is available on macOS and Linux only.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/windows-port-fixes-thr_jensq3v9th branch from 42865be to 7b6c337 Compare October 2, 2026 17:29
@SawyerHood
SawyerHood merged commit 4f52cda into main Oct 2, 2026
27 checks passed
@SawyerHood
SawyerHood deleted the bb/windows-port-fixes-thr_jensq3v9th branch October 2, 2026 17:57
SawyerHood added a commit that referenced this pull request Oct 2, 2026
…4738)

## Human comments

## What was wrong

The test suites were written on macOS and Linux and assumed POSIX in
ways the product does not: `/`-separated expectations for paths the
product builds with the native `path` module, native-separator
expectations for host paths the server keeps POSIX, `sh` and Python
fixtures, `npm` and `tsc` spawned by bare name, LF-only parsing of `tar`
and `git` output, and file-mode assertions. On a Windows 11 VM the
server package had 392 failing tests and the launcher, tooling,
integration, and QA packages about 90. Part of #1206. Stacked on #4737,
which these tests need.

## What changed

Tests only, in `apps/server`, `packages/bb-app`, `packages/scripts`,
`packages/templates`, `packages/plugin-sdk/scripts`,
`tests/integration`, and `tests/qa`.

- The server test harness matched workspace file commands with the
ambient path separator. Host paths in tests are POSIX, so on Windows it
never answered them and about 200 tests timed out. It now compares with
`/`.
- Expected paths are built the way the product builds them: `path.posix`
or literals for host paths, native `join`/`resolve` for server-local
paths.
- Fixtures that were shell or Python scripts are Node scripts; npm and
tsc run through Node; listings accept CRLF; `os.tmpdir()` stubs set
`TEMP`/`TMP` as well as `TMPDIR`.
- Skipped on Windows only, each with a stated reason: the POSIX shell
machine installer suite, the `sh` enrollment pipeline, server-move
imports from POSIX paths, signal delivery, bash CI scripts, and the QA
harness's `sh` restart command. File-mode assertions (0600, 0755) are
guarded, and the rest of each test still runs.

No assertion is weaker on macOS or Linux.

## How you verified

- Windows 11 Enterprise VM (build 26300), on a branch combining this
with the other open Windows changes: full `turbo run test` had 19,090
passing tests and 2 failing, both 5-second timeouts in
`plugin-native-server-loading.test.ts` under full-run load that pass
when the file runs alone. The same run on main before any of these
changes had 830 failing tests.
- Linux: the full suite passes on the combined branch apart from
`machine-environment.test.ts` and
`plugin-native-server-loading.test.ts`, which time out under load on the
development machine and pass alone. On this branch before the last
rebase, `turbo run lint typecheck test --filter='...[origin/main]'`: 188
of 190 tasks passed. The failing tasks were the app and server test
tasks, with tests that time out when the development machine is loaded
(`PromptBoxInternal.test.tsx`, `machine-environment.test.ts`,
`plugin-native-server-loading.test.ts`) and pass when run alone. After
the rebase onto current main, lint and typecheck pass for the same
filter.

Not verified: Windows CI does not run these suites, so nothing keeps
them passing on Windows after this lands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

---------

Co-authored-by: Claude Code <[email protected]>
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