publish.yml has been red on main since 7ebab07c (run 43011771755, and
43012668584, 43012789287 after it): 4 of gumloop's regression tests
failed with `Executable not found in $PATH: "node"`, so dist and npm
were skipped and gumloop 0.1.0 and agy-cli 0.1.19 reached neither.
Cause: bun test runs every file of the root run in one process.
packages/grok/nocli.mjs sets PATH=/usr/bin:/bin (and HOME, USERPROFILE,
GROK_HOME, GROK_BIN_DIR) for grok's files and never put them back, so
every file after grok's ran with that PATH. On ubuntu CI node is
actions/setup-node's, under /opt/hostedtoolcache, so gumloop's
spawn("node") found none whenever bun ran grok's files before
gumloop's (CI's order). Locally bun ran gumloop first, so it passed.
Change:
- grok/nocli.mjs: the first noRealGrok of a file snapshots process.env
and registers an afterAll that puts it back, removing what was added.
- gumloop/regression.test.mjs: node's absolute path is found once with
Bun.which at load and spawned by path; not found, the Node tests fail
as before (no skip).
- Siblings the same way (a file-level env change never put back), found
by a full-run env audit: chat/chat.test.mjs (XDG_CONFIG_HOME pointing
at its deleted temp dir, MAGPIE_API_KEY/GATEWAY_KEY/ADDR deleted) and
cursor/calls.test.mjs (XDG_DATA_HOME) now restore them in afterAll.
window-warmup's fake-gateway.ts/scheduler.test.ts XDG pins are left,
filed as #996 (fake-gateway is also the --serve demo's).
Other PATH writers (devin, gcp-ai, grok's own tests, sap-aicore,
agy-cli, layerfs) already restore theirs; the audit saw PATH change
only at grok's files.
Ran (magpie-desktop WSL, node only in ~/sdk/node/bin, bun 1.4.2):
- Red first, origin/main: `bun test --randomize --seed=3` (and 5) on
grok/loop-check + gumloop/regression: the 4 CI failures, same error;
also with --preload ./packages/grok/nocli.mjs.
- Same seeds with this change: 95 pass 0 fail (new gumloop test plus
origin/main's copy of it).
- Broken by hand: afterAll(putBack) commented out -> both seeds red
again, 4 fail.
- Root `HOME=$(mktemp -d) bun test` (with an env-audit preload): 8298
pass, 19 skip, 0 fail, 8317 tests, 584 files; PATH back to the start
value at the first file after grok's.
- Touched packages (chat, cursor, grok, gumloop, qoder) after the
chat/cursor change: 1117 pass 0 fail, each XDG value back to start.
Not tried: ubuntu CI itself before pushing (publish.yml runs it next);
Windows (nocli sets PATH empty there, restored the same way).
Gumloop as a provider for magpie and OpenCode: API key + user ID sign-in, the
account's own model list (bare catalog ids mapped back to provider routes, per
account), streaming and tool calls, a missing system prompt supplied for Muse
and MiniMax M3.1 Flash, and a locally calibrated credit estimate (an estimate,
not an invoice). The ledger is written only under magpie's config directory
(kept in memory in OpenCode), a failed read is unknown and never written over,
and updates go through a filesystem ticket lock (bakery) across plugin hosts.
Only a 403 that names the key reads as an expired sign-in, and only Gumloop's
assumed 403 credit_limit_exceeded reads as out of credits. The last change
checks lock contention at least once after a stall, so an uncontended update
that took more than 250 ms to publish its ticket is no longer dropped.
Ran, at the reviewed head 2173d784 (WSL magpie-desktop, Bun 1.4.2, fresh
HOME; Windows 11, Bun 1.4.2, fresh HOME and USERPROFILE):
- bun test packages/gumloop: 87 pass, 0 fail (3x WSL, 2x Windows); the
200-charge overlap test 10x WSL and 5x Windows green; check.mjs exit 0.
- Merged with origin/main 017cd73e: package 87 pass, check.mjs exit 0, root
bun test 8294 pass, 0 fail.
- A 300 ms stall injected before the contention loop in production (no test
hook): the three charge tests stay green; with the loop back to `while`
they all go red (the charge is dropped).
Broken by hand, one at a time, each restored and touched:
- loop back to `while`: 3 red, the new stall test among them;
- no staleness check, no ticket-0 wait, no ledger .tmp cleanup, a 2000 ms
wait, ENOENT counted as stale: each red, as in the earlier reviews;
- the old hook-only deadline reset put back together with `while`: the new
test stays green (the hook hid the bug), so the reset must stay out;
- retryFs back to the shared deadline: green (a Windows sharing error after
a stall; not reproducible on Linux).
Not tried: Gumloop's real API, a real magpie or OpenCode session with the
plugin. The npm first publish of the new package is the owner's.
Co-authored-by: sj1547139223 <146150939+sj1547139223@users.noreply.github.com>