mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-10 15:09:00 +02:00
The L4b Haiku transcript classifier and the opt-in DeBERTa ensemble
(GSTACK_SECURITY_ENSEMBLE=deberta, a documented 721MB download) had ZERO
production callers since the chat-path agent that invoked them was ripped.
The only live ML path is scanPageContent (testsavant) inside the security
sidecar subprocess. Deleted by import graph:
- security-classifier.ts 614 -> 265 lines: HAIKU_MODEL, checkTranscript,
shouldRunTranscriptCheck, loadDeberta, scanPageContentDeberta, ToolCallInput,
all DEBERTA_* consts + load state. Header now states the live truth
(imported only by security-sidecar-entry.ts). downloadFile kept, name
intact — it is an enumerated egress sink (HF model download).
- security-bunnative.ts + test: a research skeleton self-described as 'NOT a
production replacement', shipped into src/ with zero importers.
- security-bench-ensemble{,-live}.test.ts + the Haiku response fixture: a
paid live-model benchmark for a layer that could not fire. The
security-classifier-tdz test's only case exercised checkTranscript — gone.
- security.ts: layer-model header rewritten to the live architecture;
StatusDetail.layers -> {testsavant, canary}; getStatus() no longer requires
the impossible transcript==='ok' for 'protected' (old on-disk session state
with a transcript key is tolerated on read, never re-emitted).
- security-sidecar-entry.ts needed zero changes: it serializes
getClassifierStatus() verbatim and no consumer read .transcript (verified
in sidecar-client + server.ts).
- BROWSER.md security section matches reality (ensemble knob gone, 112MB not
22MB, sidecar hosting documented). combineVerdict/THRESHOLDS retained as
the pure, tested combiner of record — comments now flag transcript/deberta
votes as producer-less.
Net: 26 pass in security.test.ts incl. a NEW regression test for stale-
transcript disk tolerance; egress-receipt tripwire green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
/**
|
|
* Unit tests for browse/src/security-classifier.ts pure functions.
|
|
*
|
|
* Scope: functions that do NOT require model download or network access.
|
|
* Model-dependent behavior (loadTestsavant inference via scanPageContent)
|
|
* is covered by security-bench.test.ts and security-live-playwright.test.ts,
|
|
* which gate on the cached model being present.
|
|
*/
|
|
|
|
import { describe, test, expect } from 'bun:test';
|
|
import { getClassifierStatus } from '../src/security-classifier';
|
|
|
|
describe('getClassifierStatus — pre-load state', () => {
|
|
test('returns testsavant=off before loadTestsavant has been called', () => {
|
|
// Before any warmup has started, the classifier reports off.
|
|
// (This test runs in fresh-module state; if another test already
|
|
// loaded the classifier, status would be 'ok' — but this file runs
|
|
// before model loads in typical CI.)
|
|
const s = getClassifierStatus();
|
|
expect(['ok', 'degraded', 'off']).toContain(s.testsavant);
|
|
});
|
|
|
|
test('status shape contract — exactly one key (testsavant)', () => {
|
|
// The sidecar's `status` op serializes this object verbatim onto the
|
|
// NDJSON wire — pin the shape so accidental additions are deliberate.
|
|
const s = getClassifierStatus();
|
|
expect(Object.keys(s).sort()).toEqual(['testsavant']);
|
|
});
|
|
});
|