#2895·gstack

Free tests write to the developer's real $HOME (setup run in team-mode tests, prepush skip log)

Author: Jey2311Created Sep 17, 2026Updated Sep 17, 2026

What happens

Two free-tier test files write to the real $HOME of whoever runs them:

  • test/team-mode.test.ts
    • What it does: the two tests in setup --team / --no-team / -q run ${ROOT}/setup -q and setup --local -q with env: {...process.env}, so setup acts on the developer's real install.
    • What setup does there:
      • installs or re-renders the checkout's skills (into ~/.gstack/render/claude, linked from ~/.claude/skills);
      • writes the checkout's VERSION to ~/.gstack/.last-setup-version;
      • runs the checkout's pending gstack-upgrade/migrations against the real state, with GSTACK_INSTALL_DIR set to the checkout.
    • The tests only check stdout, not the exit code, so they pass either way.
  • test/redact-prepush-hook.test.ts: three tests run the pre-push hook with GSTACK_REDACT_PREPUSH=skip and no GSTACK_HOME. logSkip in bin/gstack-redact-prepush then appends env-skip lines to the real ~/.gstack/security/prepush-skip.jsonl.

Why it matters

Running bun test from a checkout that differs from the installed gstack has three effects:

  • the live skills are silently replaced by the checkout's;
  • the recorded setup version moves ahead of the installed one, so the next real upgrade skips the migrations in between;
  • the prepush-skip audit log fills with entries nobody made.

Seen on a machine with gstack 1.84.1.0 installed, while running these files from a 1.87.4.0 checkout (for #2892):

  • the live render served 1.87's skills;
  • a brain-blocks check dropped from 10/12 to 9/11;
  • ~/.gstack/.last-setup-version read 1.87.4.0;
  • prepush-skip.jsonl gained two env-skip lines per run.

Reproduce without touching your install

T=$(mktemp -d); mkdir -p "$T/.claude/skills"
HOME=$T GSTACK_HOME=$T/.gstack ./setup -q
cat "$T/.gstack/.last-setup-version"   # the checkout's VERSION
ls "$T/.claude/skills" | wc -l          # the checkout's skills

HOME=$T GSTACK_HOME=$T/.gstack bun test test/redact-prepush-hook.test.ts
cat "$T/.gstack/security/prepush-skip.jsonl"   # env-skip lines

With the real HOME, both writes land in the real install.

Suggested fix

  • Give those tests a throwaway HOME and GSTACK_HOME, plus GSTACK_USER_RENDER_DIR for setup, as most other tests already do.
  • Or have scripts/test-free-shards.ts run every file under a temporary HOME.
  • The setup tests should also assert setup's exit code: with a bare HOME, setup -q stops early and the test still passes.