Skip to content

Commit 75aeb4d

Browse files
test: verify audit provider is opt-in and modes are explicit
1 parent 755cfb4 commit 75aeb4d

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
import test from 'node:test';
22
import assert from 'node:assert/strict';
3-
import { advisoryLlmAuditSummary } from '../lib/audit-policy.mjs';
3+
import { advisoryLlmAuditSummary, auditLlmMode, deterministicOnlyAuditSummary } from '../lib/audit-policy.mjs';
44

5-
test('high-risk LLM findings are advisory by default after deterministic audit passes', () => {
5+
test('LLM audit is off for legacy and unspecified configurations', () => {
6+
assert.equal(auditLlmMode({ audit: {} }), 'off');
7+
assert.equal(auditLlmMode({ audit: { llmEnabled: true } }), 'off');
8+
});
9+
10+
test('advisory mode records high-risk findings without failing the audit', () => {
611
const result = advisoryLlmAuditSummary({
712
auditInputHash: 'audit-hash',
813
deterministicFailures: 0,
914
highRiskFindings: 3,
1015
pass: false
11-
}, { audit: {} });
16+
}, { audit: { llmMode: 'advisory' } });
1217
assert.equal(result.pass, true);
1318
assert.equal(result.llmFindingsBlocking, false);
1419
assert.equal(result.advisoryHighRiskFindings, 3);
1520
});
1621

17-
test('explicit blockOnLlmFindings preserves the hard gate', () => {
22+
test('blocking mode preserves the hard LLM gate', () => {
1823
const result = advisoryLlmAuditSummary({
1924
deterministicFailures: 0,
2025
highRiskFindings: 3,
2126
pass: false
22-
}, { audit: { blockOnLlmFindings: true } });
27+
}, { audit: { llmMode: 'blocking' } });
2328
assert.equal(result, null);
2429
});
2530

@@ -28,6 +33,18 @@ test('LLM advisory policy never hides deterministic failures', () => {
2833
deterministicFailures: 114,
2934
highRiskFindings: 3,
3035
pass: false
31-
}, { audit: { blockOnLlmFindings: false } });
36+
}, { audit: { llmMode: 'advisory' } });
3237
assert.equal(result, null);
3338
});
39+
40+
test('deterministic-only summary records zero provider audit work', () => {
41+
const result = deterministicOnlyAuditSummary({
42+
auditInputHash: 'hash', inventoryFingerprint: 'inventory', manifestHash: 'manifest',
43+
metrics: { pages: 2, claims: 4, evidenceReferences: 5, modelItems: 6, referencedModelItems: 3, modelReferenceCoverage: 0.5 },
44+
errors: [], warnings: ['warning'], pass: true
45+
});
46+
assert.equal(result.pass, true);
47+
assert.equal(result.llmAuditedPages, 0);
48+
assert.equal(result.highRiskFindings, 0);
49+
assert.equal(result.llmSkippedReason, 'llm-audit-off');
50+
});

0 commit comments

Comments
 (0)