Repository navigation
Description
Symptom
test/gstack-gbrain-sync.test.ts > gstack-gbrain-sync CLI > keeps a symlink-equivalent pinned source registered as-is fails locally at expect(r.status).toBe(0) (Expected 0, Received 1). CI is green, so it looks machine-specific — and it is.
Reproduces on a clean checkout of main at v1.69.0.0 (ad84005), and identically at v1.68.3.0 (85fd9db), so this is not a v1.69.0.0 regression. macOS 15 (arm64), bun 1.3.11.
Root cause
The test spawns bin/gstack-gbrain-sync.ts as a subprocess. That script routes through the #1734 data-loss guards, which refuse while gbrain autopilot is live. The test asserts only on r.status, so the refusal never reaches the output. Re-running the same fixture without --quiet shows it:
gstack-gbrain-sync (incremental):
ERR code refused: gbrain autopilot active (process:gbrain autopilot). Stop autopilot, then re-run /sync-gbrain. (0.1s)
0 ok, 1 error, 0 skipped
The signal is the primary process probe in lib/gbrain-guards.ts:
const r = spawnSync("pgrep", ["-f", "gbrain autopilot"], { encoding: "utf-8", timeout: 3_000 });
...
if (running) return { active: true, signal: "process:gbrain autopilot" };So the test passes or fails depending on whether the developer happens to have gbrain autopilot running. The refusal itself is correct and intended (#1734) — the gap is that the test never neutralizes it.
detectAutopilot(env, probe) is injectable, and test/gbrain-guards.test.ts does the right thing by passing processRunning: () => false. But this test spawns the script in a child process, so it cannot inject, and env is only consulted for gbrainHome() lock paths — there is no env escape hatch for the process probe.
Two red herrings, in case anyone chases them: the error: No such remote 'origin' lines on stderr are benign (originUrl() catches and falls back to the repo basename), and the failure is unrelated to the symlink the test name is about. Neutralizing GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM changes nothing.
Why it is worth fixing rather than ignoring
sync-gbrain/SKILL.md recommends exactly the thing that reds the suite:
for ongoing auto-sync across all worktrees, run
gbrain autopilot --installonce per machine
So a contributor who follows the documented setup gets a red suite with a failure message that points at symlinks and pinned sources, none of which is the cause.
Suggested fix (test-only, no production change)
The fixture already prepends its fake-binary dir to PATH:
PATH: `${bindir}:${process.env.PATH || ""}`,and defaultProcessRunning invokes bare pgrep, which is PATH-resolved. Dropping a stub pgrep into that same bindir that exits non-zero neutralizes the primary signal for this test with no change to the guard and no new env hatch on a data-loss check:
#!/bin/sh
exit 1 # no matching processIf an env override is preferred instead, it would want to be scoped so it cannot weaken the guard in real use — the stub is the smaller blast radius.
Happy to send a PR for the stub if that is the direction you want.
Activity