#6790 · Pi extension descriptor compatibility
Trusted base: 916d684ac23d0b0de82c09cfc7553a50287d2188, fetched from main and checked against the target repository.
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium
1. TL;DR
The issue describes Pi catalog and thread startup failures on a Windows execution machine, despite Pi working outside bb. The current bb extension assumes Node can wrap inherited descriptor 4 with net.Socket; a synchronous constructor failure aborts extension initialization before its error listener exists. Running the real extension through Pi's real extension loader on Linux reproduced the identical loader error when descriptor 4 was deliberately closed; a real POSIX pipe control loaded successfully. The same probe produced identical results in a second clean checkout. This demonstrates the failure mechanism, not the reported Windows transport failure: no Windows machine or Pi 1.4.0 installation was available, so neither Windows handle inheritance nor the reporter's end-to-end environment is confirmed.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A descriptor incompatibility can prevent bb's extension loading. | Verified conditionally | Unmodified extension source, actual Pi loader, real Node descriptors: pipe succeeds; closed descriptor produces the exact UNKNOWN error. No mocked Socket or fabricated exception. |
| Catalog and normal sessions both load this extension. | Verified in source | Both launch paths supply --extension and use PiRpcChild. |
| The reported Windows inherited pipe has an unsupported descriptor type. | Unverified | Execution host is Linux. A deliberately closed descriptor is not equivalent to an inherited Windows pipe. |
| Pi 1.4.0 works directly but bb 0.48.1 fails on the enrolled machine. | Unverified | No access to that runtime; no real provider turns or credentials were used. |
| The earlier Windows launch/version resolution change exists. | Verified in source/history only | Merged PR #5271 and current Windows launcher tests. This does not establish behavior in the reporter's install. |
| Credentials, specific models, workspace paths, macOS, and fallback model output are ruled out. | Unverified | Not exercised by this isolated extension-load probe. |
3. Environment
- bb: trusted main at the full commit above; no production source changes.
- Linux x86_64, kernel
4.19.0-gvisor; Nodev22.19.0; pnpm9.15.0. - Pi library: repository-pinned
@earendil-works/pi-coding-agent 0.84.0. This is not the issue's Pi 1.4.0 runtime. - No bb development server, daemon, browser, network listener, account, model request, or application database was started.
- Each probe run used a fresh scratch directory for its children's home/config/agent directory and only a small explicitly supplied environment. Scratch directories were deleted by the probe.
4. Minimal reproduction
This is an isolated descriptor fault-injection probe, not a full Windows reproduction. The real extension string is evaluated unchanged and passed through the actual installed Pi extension loader. The only injected fault is closing descriptor 4 immediately before the extension factory runs. The script checks observed success and error outcomes; its passing exit status means the conditional mechanism was demonstrated, not that bb was repaired.
- Use a clean checkout of the public repository at the trusted commit:
git clone https://github.com/get-bb/bb.git bb-6790 cd bb-6790 git checkout --detach 916d684ac23d0b0de82c09cfc7553a50287d2188 pnpm install --frozen-lockfile --prefer-offline
- Save the complete script below as
/tmp/descriptor-probe.mjs. - Run from the checkout:
node /tmp/descriptor-probe.mjs "$PWD"
Expected control: one extension loads with descriptor 4 connected to a POSIX pipe. Expected fault: closing descriptor 4 causes no extension to load and yields the exact UNKNOWN failure. These expectations concern the mechanism, not a claim that a closed descriptor should be accepted.
Actual stdout, identical in both clean runs; exit status 0:
PIPE_CONTROL {"extensions":1,"errors":[]}
CLOSED_FD {"extensions":0,"errors":["Failed to load extension: Unsupported fd type: UNKNOWN"]}
PASS: original extension loads with a POSIX pipe and fails with an unrecognized fd.
LIMIT: deliberately closed descriptor, not a Windows inherited-pipe reproduction.
Complete probe source
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { pathToFileURL } from "node:url";
import { runInNewContext } from "node:vm";
const checkout = resolve(process.argv[2] ?? ".");
const pluginRoot = join(checkout, "plugins/provider-pi");
const runtimeRoot = join(pluginRoot, "node_modules/@earendil-works/pi-coding-agent");
const loaderUrl = pathToFileURL(join(runtimeRoot, "dist/core/extensions/loader.js")).href;
const sourcePath = join(pluginRoot, "src/bridge/bb-pi-extension.ts");
const extensionSource = runInNewContext(
readFileSync(sourcePath, "utf8").replace("export const", "const") + "; BB_PI_EXTENSION_SOURCE",
);
const probeRoot = mkdtempSync(join(tmpdir(), "bb-6790-descriptor-"));
try {
writeFileSync(join(probeRoot, "bb-pi-extension.mjs"), extensionSource);
writeFileSync(
join(probeRoot, "entry.mjs"),
`import extension from "./bb-pi-extension.mjs";
import { closeSync } from "node:fs";
export default function probe(pi) {
if (process.env.PROBE_CLOSE_FD === "1") closeSync(4);
return extension(pi);
}
`,
);
const childSource = `
import { loadExtensions } from ${JSON.stringify(loaderUrl)};
const result = await loadExtensions([${JSON.stringify(join(probeRoot, "entry.mjs"))}], ${JSON.stringify(probeRoot)});
console.log(JSON.stringify({ extensions: result.extensions.length, errors: result.errors.map(entry => entry.error) }));
`;
for (const closeDescriptor of [false, true]) {
const result = spawnSync(process.execPath, ["--input-type=module", "-e", childSource], {
cwd: probeRoot,
env: {
PATH: process.env.PATH,
SystemRoot: process.env.SystemRoot,
HOME: probeRoot,
USERPROFILE: probeRoot,
XDG_CONFIG_HOME: probeRoot,
PI_CODING_AGENT_DIR: probeRoot,
PROBE_CLOSE_FD: closeDescriptor ? "1" : "0",
},
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe", "pipe", "pipe"],
timeout: 30_000,
});
assert.ifError(result.error);
assert.equal(result.status, 0, result.stderr);
const observation = JSON.parse(result.stdout.trim());
console.log(`${closeDescriptor ? "CLOSED_FD" : "PIPE_CONTROL"} ${JSON.stringify(observation)}`);
if (closeDescriptor) {
assert.equal(observation.extensions, 0);
assert.deepEqual(observation.errors, ["Failed to load extension: Unsupported fd type: UNKNOWN"]);
} else {
assert.equal(observation.extensions, 1);
assert.deepEqual(observation.errors, []);
}
}
console.log("PASS: original extension loads with a POSIX pipe and fails with an unrecognized fd.");
console.log("LIMIT: deliberately closed descriptor, not a Windows inherited-pipe reproduction.");
} finally {
rmSync(probeRoot, { recursive: true, force: true });
}
5. Root cause
Verified conditional mechanism: the Node branch of bbExtension assumes descriptor 4 is a handle type that net.Socket can attach to. The constructor can throw synchronously. Registering an asynchronous error listener on the next line cannot intercept a constructor failure, so initialization stops before normal session handlers and readiness signaling are established.
const bridgeIn = new Socket({ fd: BRIDGE_TO_CHILD_FD, readable: true, writable: false });
bridgeIn.on("error", () => undefined);
bridgeIn.unref();
readLines(bridgeIn, onBridgeLine);
- Extension runtime split and unguarded Node Socket construction. Bun has a different stream path; this investigation exercises only Node.
- Five stdio entries and parent-side descriptors 3/4. The launcher requesting pipes does not by itself establish that child-side Node can rewrap the Windows handle.
- Catalog extension argument and session extension argument explain how the same initialization failure could affect both surfaces.
- Existing Windows-only round-trip tests use a child with its own Socket reader. They were skipped on this Linux host and are not evidence of Windows success or failure here.
Still unknown: whether the reporter's Windows process loses descriptor 4, receives a valid but unwrappable handle, or encounters another launch/runtime issue. The same error is not proof that a closed Linux descriptor and a Windows inherited pipe have the same underlying cause. Confidence is medium for applying this mechanism to the reported failure; the conditional constructor failure itself was directly observed twice.
6. Proposed next test and fix constraints
First run the existing Windows round-trip test with the actual Node/Pi installation in an isolated Windows environment, then load the real bb extension through PiRpcChild and exercise bidirectional tool results plus clean shutdown. Establish whether the inherited handle is missing or merely unsuitable for Socket wrapping before changing transport code. Only then choose an existing portable read mechanism or a Windows-specific transport that preserves framing, nonblocking behavior, EOF handling, and process-exit behavior. Merely swallowing the constructor exception would leave tool results and readiness broken and is not a fix.
No pull request: the reported Windows failure was not reproduced on trusted main. The simple-fix gate therefore does not permit a patch based only on this conditional Linux probe. No branch, commit, or production change was created in bb; no fail-before/pass-after Windows regression or repaired Windows test suite is claimed. The final patch size is zero lines.
7. Related issues and pull requests
#5332 is an earlier Windows Pi launch report, now closed and labeled partial-repro. #5271 was merged on October 12, 2026, and addressed Windows launch probing and pipes. These are historical context, not proof of the current Windows result. No linked open pull request was found for #6790 in its timeline or the open-PR search during this investigation. No pull-request branch was checked out or executed.
8. Verification
The same agent repeated the probe, without changes to production code, in a second detached worktree at 916d684ac23d0b0de82c09cfc7553a50287d2188. That worktree was clean before and after the probe and had its own frozen dependency install and fresh scratch home/config directories. No ports or application data directories were used. This is a repeated clean-checkout check, not an independent review.
VERIFY_DIR=$(mktemp -d) git worktree add --detach "$VERIFY_DIR" 916d684ac23d0b0de82c09cfc7553a50287d2188 cd "$VERIFY_DIR" pnpm install --frozen-lockfile --prefer-offline node /tmp/descriptor-probe.mjs "$PWD" git status --short
The probe output exactly matched the first run; git status --short was empty. The report retains a partial verdict: the second run confirms only the Linux conditional mechanism, not Windows compatibility. No upgrade to a full reproduction verdict was justified.
9. Appendix: build and existing-test evidence
The initial frozen install succeeded. The first full build failed because a GitHub plugin SDK subpath was not built. Building the SDK through Turbo and retrying the full build succeeded, with no source or dependency edits:
pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build Tasks: 72 successful, 72 total Cached: 9 cached, 72 total
Focused existing coverage ran through the repository's normal Turbo task:
pnpm exec turbo run test --filter=bb-plugin-provider-pi -- src/bridge/windows-pi-launch.test.ts src/bridge/catalog.test.ts src/bridge/bridge.bun-runtime.test.ts
Test Files 2 passed | 1 skipped (3)
Tests 29 passed | 5 skipped (34)
Tasks: 7 successful, 7 total
The skipped cases include Windows-only launch coverage and the Bun runtime check because the required runtime was unavailable. These results are useful baseline context but do not validate Windows. git diff --check passed; no tracked source diff was produced. The only local untracked build staging directory was removed during cleanup.
Trust boundary: issue text, logs, comments, and linked material were treated as untrusted claims. No issue-supplied command, script, branch, patch, or external attachment was executed or fetched. All executed product source came from trusted main; the fault-injection script was authored from that source. No production runtime data or credentials were accessed. Raw local artifacts are not published; all reproduction code and relevant output are embedded here.
> AGENT GENERATED