Skip to content

Instantly share code, notes, and snippets.

@Enmani
Created October 25, 2026 05:51
Show Gist options
  • Select an option

  • Save Enmani/ef93424c45b06c5a4f765691a7f812b0 to your computer and use it in GitHub Desktop.

Select an option

Save Enmani/ef93424c45b06c5a4f765691a7f812b0 to your computer and use it in GitHub Desktop.
T3 Windows async executable lookup: reproducible runtime evidence
{
"node": "v26.12.1",
"platform": "win32",
"release": "10.0.26300",
"fixtureDirectories": 30,
"results": [
{
"trial": 0,
"variant": "before",
"label": "real-PATH-miss-32",
"elapsedMs": 4961.4585,
"maxGapMs": 4961.9119,
"ticks": 2,
"result": {
"found": 0
}
},
{
"trial": 0,
"variant": "before",
"label": "fixture-PATH-hit-32",
"elapsedMs": 458.47360000000026,
"maxGapMs": 459.53620000000046,
"ticks": 2,
"result": {
"found": 32
}
},
{
"trial": 0,
"variant": "before",
"label": "process-runner-miss-8",
"elapsedMs": 1461.3855999999996,
"maxGapMs": 1464.7239,
"ticks": 2,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 0,
"variant": "before",
"label": "process-runner-node-8",
"elapsedMs": 1102.1803999999993,
"maxGapMs": 90.83790000000045,
"ticks": 66,
"result": {
"successes": 8,
"spawnErrors": 0
}
},
{
"trial": 0,
"variant": "after",
"label": "real-PATH-miss-32",
"elapsedMs": 1166.8480999999992,
"maxGapMs": 13.352999999999156,
"ticks": 211,
"result": {
"found": 0
}
},
{
"trial": 0,
"variant": "after",
"label": "fixture-PATH-hit-32",
"elapsedMs": 245.45390000000043,
"maxGapMs": 20.358799999999974,
"ticks": 49,
"result": {
"found": 32
}
},
{
"trial": 0,
"variant": "after",
"label": "process-runner-miss-8",
"elapsedMs": 352.90010000000075,
"maxGapMs": 20.786000000000058,
"ticks": 49,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 0,
"variant": "after",
"label": "process-runner-node-8",
"elapsedMs": 1149.6051000000007,
"maxGapMs": 71.67000000000007,
"ticks": 87,
"result": {
"successes": 8,
"spawnErrors": 0
}
},
{
"trial": 1,
"variant": "after",
"label": "real-PATH-miss-32",
"elapsedMs": 1034.1227,
"maxGapMs": 12.418700000000172,
"ticks": 183,
"result": {
"found": 0
}
},
{
"trial": 1,
"variant": "after",
"label": "fixture-PATH-hit-32",
"elapsedMs": 219.38730000000032,
"maxGapMs": 19.651899999998932,
"ticks": 44,
"result": {
"found": 32
}
},
{
"trial": 1,
"variant": "after",
"label": "process-runner-miss-8",
"elapsedMs": 506.7443000000003,
"maxGapMs": 53.88709999999992,
"ticks": 65,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 1,
"variant": "after",
"label": "process-runner-node-8",
"elapsedMs": 1137.5342,
"maxGapMs": 56.85739999999896,
"ticks": 90,
"result": {
"successes": 8,
"spawnErrors": 0
}
},
{
"trial": 1,
"variant": "before",
"label": "real-PATH-miss-32",
"elapsedMs": 4256.732499999998,
"maxGapMs": 4256.85,
"ticks": 2,
"result": {
"found": 0
}
},
{
"trial": 1,
"variant": "before",
"label": "fixture-PATH-hit-32",
"elapsedMs": 494.3669000000009,
"maxGapMs": 494.53099999999904,
"ticks": 2,
"result": {
"found": 32
}
},
{
"trial": 1,
"variant": "before",
"label": "process-runner-miss-8",
"elapsedMs": 1100.4494999999988,
"maxGapMs": 1101.535899999999,
"ticks": 2,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 1,
"variant": "before",
"label": "process-runner-node-8",
"elapsedMs": 904.2685999999994,
"maxGapMs": 100.8227999999981,
"ticks": 56,
"result": {
"successes": 8,
"spawnErrors": 0
}
},
{
"trial": 2,
"variant": "before",
"label": "real-PATH-miss-32",
"elapsedMs": 3608.1240999999973,
"maxGapMs": 3608.4748,
"ticks": 2,
"result": {
"found": 0
}
},
{
"trial": 2,
"variant": "before",
"label": "fixture-PATH-hit-32",
"elapsedMs": 514.2606999999989,
"maxGapMs": 514.6848999999966,
"ticks": 2,
"result": {
"found": 32
}
},
{
"trial": 2,
"variant": "before",
"label": "process-runner-miss-8",
"elapsedMs": 1090.8950000000004,
"maxGapMs": 1091.5783999999985,
"ticks": 2,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 2,
"variant": "before",
"label": "process-runner-node-8",
"elapsedMs": 1368.8863999999994,
"maxGapMs": 92.64819999999963,
"ticks": 78,
"result": {
"successes": 8,
"spawnErrors": 0
}
},
{
"trial": 2,
"variant": "after",
"label": "real-PATH-miss-32",
"elapsedMs": 1044.3493999999992,
"maxGapMs": 18.992200000000594,
"ticks": 187,
"result": {
"found": 0
}
},
{
"trial": 2,
"variant": "after",
"label": "fixture-PATH-hit-32",
"elapsedMs": 186.16109999999753,
"maxGapMs": 15.87749999999869,
"ticks": 38,
"result": {
"found": 32
}
},
{
"trial": 2,
"variant": "after",
"label": "process-runner-miss-8",
"elapsedMs": 382.3641000000025,
"maxGapMs": 21.584500000000844,
"ticks": 52,
"result": {
"successes": 0,
"spawnErrors": 8
}
},
{
"trial": 2,
"variant": "after",
"label": "process-runner-node-8",
"elapsedMs": 778.9511999999995,
"maxGapMs": 16.48370000000068,
"ticks": 75,
"result": {
"successes": 8,
"spawnErrors": 0
}
}
]
}
import * as Effect from 'effect/Effect';
import * as NodeServices from '@effect/platform-node/NodeServices';
import * as fs from 'node:fs/promises';
import * as os from 'node:os';
import * as path from 'node:path';
import { performance } from 'node:perf_hooks';
import * as baseline from '../../packages/shared/src/.spawn-baseline.ts';
import * as candidate from '../../packages/shared/src/shell.ts';
import * as ProcessRunner from './src/processRunner.ts';
const before = baseline.SpawnExecutableResolution.defaultValue();
const after = candidate.SpawnExecutableResolution.defaultValue();
const fixture = await fs.mkdtemp(path.join(os.tmpdir(), 't3-pr-bench-'));
const directories = Array.from({ length: 30 }, (_, i) => path.join(fixture, String(i)));
try {
await Promise.all(directories.map(directory => fs.mkdir(directory)));
await fs.link(process.execPath, path.join(directories.at(-1)!, 't3-lookup-target.exe'));
const fixtureEnv = { PATH: directories.join(';'), PATHEXT: '.COM;.EXE;.BAT;.CMD' };
const actualEnv = { ...process.env };
const missing = 't3-pr-intentionally-missing-command';
async function measure(label, action) {
let maxGapMs = 0;
let ticks = 0;
let last = performance.now();
const interval = setInterval(() => {
const now = performance.now();
maxGapMs = Math.max(maxGapMs, now - last);
last = now;
ticks++;
}, 5);
const started = performance.now();
try {
const result = await action();
const elapsedMs = performance.now() - started;
await new Promise(resolve => setTimeout(resolve, 10));
return { label, elapsedMs, maxGapMs, ticks, result };
} finally {
clearInterval(interval);
}
}
async function raw(resolve, command, env) {
let found = 0;
for (let i = 0; i < 32; i++) {
const result = await resolve(command, 'win32', env);
if (result !== undefined) found++;
}
return { found };
}
async function processRuns(resolve, command, env, count) {
return Effect.runPromise(Effect.gen(function* () {
const runner = yield* ProcessRunner.make();
let successes = 0;
let spawnErrors = 0;
for (let i = 0; i < count; i++) {
const result = yield* runner.run({
command,
args: ['-e', "process.stdout.write('ok')"],
env,
}).pipe(
Effect.provideService(candidate.CommandResolutionCache, new Map()),
Effect.match({
onFailure: error => error._tag,
onSuccess: output => output.code === 0 && output.stdout === 'ok' ? 'ok' : 'bad-output',
}),
);
if (result === 'ok') successes++;
else if (result === 'ProcessSpawnError') spawnErrors++;
else throw new Error(String(result));
}
return { successes, spawnErrors };
}).pipe(
Effect.provideService(candidate.SpawnExecutableResolution, resolve),
Effect.provide(NodeServices.layer),
));
}
const results = [];
for (let trial = 0; trial < 3; trial++) {
for (const [variant, resolve] of trial % 2 === 0
? [['before', before], ['after', after]]
: [['after', after], ['before', before]]) {
for (const [name, action] of [
['real-PATH-miss-32', () => raw(resolve, missing, actualEnv)],
['fixture-PATH-hit-32', () => raw(resolve, 't3-lookup-target', fixtureEnv)],
['process-runner-miss-8', () => processRuns(resolve, missing, actualEnv, 8)],
['process-runner-node-8', () => processRuns(resolve, 't3-lookup-target', fixtureEnv, 8)],
]) {
const result = { trial, variant, ...await measure(name, action) };
results.push(result);
console.log(JSON.stringify(result));
}
}
}
const output = { node: process.version, platform: process.platform, release: os.release(), fixtureDirectories: 30, results };
await fs.writeFile(new URL('../../../../outputs/t3-pr-benchmark.json', import.meta.url), JSON.stringify(output, null, 2));
} finally {
await fs.rm(fixture, { recursive: true, force: true });
}

Windows executable lookup: reproduction and evidence

Base: pingdotgg/t3code main at e9d61252f6fd. Candidate: a2483937. Environment: Windows 10 build 19045, x64, Node 26.12.1, Vite+ 1.3.0.

Deterministic regression

Before applying the implementation, the new test was run against the base resolver:

vp test run packages/shared/src/shell.test.ts -t "yields while discovering a Windows executable"
FAIL: expected true to be false
1 failed; 44 tests outside the selected scope

It checks whether a native Promise microtask can run before executable discovery finishes. It uses no duration assertion, sleep, polling, retry, or custom timeout. The patched test passes. Other coverage checks installation immediately after a miss, PATH/PATHEXT precedence, inaccessible directory enumeration, Windows short-name fallback, existing cache behavior, shim escaping, and async provider lookup.

Runtime comparison

Three trials alternate baseline/candidate order. The baseline is the unmodified shared shell module from the base commit, imported beside its original HostProcess module. The candidate is the checked-in shell module. Both receive the same environment and fixture. No running T3 instance, database, provider credential, or conversation is used.

The benchmark calls the actual resolver and server ProcessRunner. Missing commands are intentionally unique and must produce ProcessSpawnError. Successful process runs execute a hard link to the test runtime's real node.exe and must return exit 0 and stdout ok. Each ProcessRunner invocation gets a fresh successful-lookup cache so it exercises a cold lookup. A 5 ms Node interval records the longest callback gap; this is a responsiveness diagnostic, not an application latency or disk-throughput measurement.

Medians of three trials, milliseconds:

Work Baseline elapsed Candidate elapsed Baseline max callback gap Candidate max callback gap
32 uncached misses, actual inherited PATH 4256.7 1044.3 4256.9 13.4
32 successful lookups, executable in last of 30 fixture directories 494.4 219.4 494.5 19.7
8 real ProcessRunner missing-command attempts 1100.4 382.4 1101.5 21.6
8 real ProcessRunner node starts 1102.2 1137.5 92.6 56.9

Every missing-command sample reported the expected misses/errors; every successful lookup/child run succeeded. Successful process startup elapsed time was comparable rather than consistently faster. Raw lookup batches deliberately bypass the existing 30-second positive cache. Other tests were running during measurement, so absolute times and callback gaps depend on host load. These results do not establish that this fixes every reconnect or measure high-concurrency agent throughput.

To reproduce, save the attached benchmark as apps/server/.t3-pr-benchmark.ts in the candidate checkout and materialize the original shared shell beside its source:

git show e9d61252f6fd:packages/shared/src/shell.ts > packages/shared/src/.spawn-baseline.ts
node apps/server/.t3-pr-benchmark.ts

Use a full Node 26.12.1 runtime on Windows. Create ../../outputs relative to the checkout before running; that is where the script writes its JSON. The script removes its temporary fixture in finally. Remove the two untracked source files after the experiment. Do not commit this PR-only evidence.

Scoped checks

The repository's unmodified scripts/check-changed.ts ran with base e9d61252f6fd. On Windows it launches a bare vp, which cannot execute the installed .cmd shim with Node spawn. The attached external preload only translates that exact command into process.execPath plus the installed Vite+ entry point; it does not change any check or arguments.

node --require ../t3-pr-vp-launcher.cjs scripts/check-changed.ts e9d61252f6fd
pass format
pass lint
pass knip 1/2
pass knip 2/2
pass GraphQL generation check
pass typecheck (29 affected packages)
test: 79 passed, 1 platform skip, 15 failed

All 15 failures are in AcpRegistrySupport.test.ts. A separate run using its unmodified source and fixtures from the base commit, with imports redirected to the unmodified baseline shell module, reproduced exactly the same 15 failing test names on this Windows host. They involve Unix fixture paths/scripts and runner availability. They were not skipped or changed to pass. The other three changed test modules passed, including the new Windows regression and short-name case.

Linux/WSL follow-up: Node 26.12.1 with the existing real npm/npx CLI available on PATH, running from packages/provider-acp-registry:

vp test run --config ../../vite.config.ts src/server/AcpRegistrySupport.test.ts
31 passed (31)

An earlier minimal Linux runtime without npm/npx had two runner-availability failures; providing those real tools resolved them without source/test changes.

The existing Claude replay-helper unused-function lint warning and existing Effect diagnostic suggestions remain non-failing. No full-repository checks or production build were run.

Model: GPT-6. Harness: Codex desktop.

const childProcess = require('node:child_process');
const path = require('node:path');
const { syncBuiltinESMExports } = require('node:module');
const originalSpawn = childProcess.spawn;
const entry = path.join(process.cwd(), 'node_modules/vite-plus/bin/vp');
childProcess.spawn = function(command, args, options) {
return command === 'vp'
? originalSpawn(process.execPath, [entry, ...args], options)
: originalSpawn(command, args, options);
};
syncBuiltinESMExports();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment