Repository navigation
Fix Windows bugs found while porting the test suite - #4737
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| if (process.platform === "win32") { | ||
| throw new Error( | ||
| "bb cannot install the background machine service on Windows. It is available on macOS and Linux.", | ||
| ); |
There was a problem hiding this comment.
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 👍 / 👎.
| process.platform === "win32" && | ||
| (await lstat(sourcePath)).isSymbolicLink() |
There was a problem hiding this comment.
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 👍 / 👎.
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]>
42865be to
7b6c337
Compare
…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]>
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
git:C:\src\my-pluginwas read as a host name and fetched fromhttps://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.\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.SKILL.mdpath from the server'spath.join(a Windows server could not load a POSIX machine's.bb/skills); the server-move checks tested for a prefix ending in/;initDbleft SQLite open when a migration threw, which keeps the file locked on Windows.EOFon Windows, notEPIPE; the bridge crashed with an uncaught error instead of reporting that Codex exited.bb plugin newrannpmby 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_NOFOLLOWdoes nothing on Windows; the source is now checked before opening and the opened handle must be the same file);bb server install-machine-servicestopped withspawn sh ENOENTand now says the service is macOS and Linux only, andbb guide machinesand the bb-cli skill say so too;BB_DATA_DIR=~\bbwas not expanded.import.meta.urlwith afile://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
bb plugin new, server archive, the ratchet test, config), as part of a full run with 19,090 passing tests.~\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