test: gate security-bench on SECURITY_BENCH=1, not model-cache existence

The existsSync gate ran ~12s of ONNX inference (plus a HuggingFace
dataset fetch) on every free-suite run on any dev box that had ever
warmed the classifier, while CI (no cache) silently skipped it. Now
explicit opt-in: SECURITY_BENCH=1 bun test browse/test/security-bench.test.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-15 08:05:22 -07:00
co-authored by Claude Fable 5
parent b63608099c
commit 43e77d84af
+5 -1
View File
@@ -33,7 +33,11 @@ const MODEL_CACHE = path.join(
'onnx', 'onnx',
'model.onnx', 'model.onnx',
); );
const ML_AVAILABLE = fs.existsSync(MODEL_CACHE); // Opt-in only (SECURITY_BENCH=1): ~12s of ONNX inference plus a HuggingFace
// dataset fetch. Gating on model-cache existence alone meant every dev box
// that had ever warmed the classifier paid this on every `bun run test`,
// while CI (no cache) silently skipped it — the worst of both.
const ML_AVAILABLE = process.env.SECURITY_BENCH === '1' && fs.existsSync(MODEL_CACHE);
const CACHE_DIR = path.join(os.homedir(), '.gstack', 'cache', 'browsesafe-bench-smoke'); const CACHE_DIR = path.join(os.homedir(), '.gstack', 'cache', 'browsesafe-bench-smoke');
const CACHE_FILE = path.join(CACHE_DIR, 'test-rows.json'); const CACHE_FILE = path.join(CACHE_DIR, 'test-rows.json');