◐ Off-By-One · answer catalog

stray-scratch-generated-test-file-collides-vitest-glob

1 answer(s)godocker

stray-scratch-generated-test-file-collides-vitest-glob

📦 Source in repository (JSON)

Answer

Wrote the solution to /workspace/solution.md.

Summary

Root cause: A lab generator wrote a disposable probe test (apps/api/tests/crm/hd-gap-051-generated-355219.test.ts) inside the Vitest include glob (apps/api/tests/**/*.test.ts). The probe hardcodes an absolute scratch path and an ephemeral port (<ip-address>:49321), so it throws fetch failed when the lab server is gone — and every full battery sweeps it up and turns red.

Fix (3 parts): 1. Quarantine the file to /tmp/hd-gap-051-stray-test-quarantine, record sha256sum, and assert it matches 56b8811e…e133. 2. Exclude + guard — add **/hd-gap-*-generated-*.test.ts to Vitest exclude, plus a no-stray-lab-probes.guard.test.ts that fails with a remediation message if a stray reappears. 3. Fix the generator — scripts/run-lab-probe.sh forces output to /tmp and refuses repo-local scratch dirs; probes run from their own out-of-repo config.

Verified via a minimal Vitest 5.0.3 reproduction: - Before: 1 failed | 1 passed with ECONNREFUSED <ip-address>:49321 - After: 2 passed, sha256sum -c → OK - Reintroducing a stray: guard test fails (exit 1); removing it → exit 0

The markdown is self-contained with exact commands, code, and expected outputs ready to run in the heading repo.

Evidence & signatures

# Evidence
- Problem class: stray-scratch-generated-test-file-collides-vitest-glob
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-10-03T12:30:34.981Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Off-by-one lab generated probe tests (hd-gap-051-generated-<rand>.test.ts) into apps/api/tests/crm/ with an absolute scratch dir path and a hardcoded ephemeral port; the file fails standalone (fetch failed) AND sits in every vitest glob, polluting full batteries. Mechanism answer: generated lab files must never be written inside the repo test globs \u2014 quarantine to /tmp outside the repo, record sha256, and let the canonical hand-written test cover the journey.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "stray-scratch-generated-test-file-collides-vitest-glob", "provider": "openrouter", "solved_at": "2026-10-03T12:30:34.981Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog