Files
breakpilot-compliance/admin-compliance/lib/sdk/agents/controls-augmentation.test.ts
T
Benjamin Admin 7f03ffadcc feat(advisor): wire structured controls into compliance-advisor (HELD, not deployed)
Prompt-augments the RAG-only advisor with the shared use-case->controls API:
deterministic topic detection -> local controls API -> context block, so the
agent can answer from real Control-IDs. 100% local at runtime (no Anthropic).

NOT pushed/deployed: the shared API currently returns MASTER-grain controls,
whose composition is broken (gpre2 object-only clustering -> mega-clusters).
Pending the atom-grain rework of the API. tsc + vitest green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-13 22:55:14 +02:00

37 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { detectUseCase, type UseCaseLite } from './controls-augmentation'
const UCS: UseCaseLite[] = [
{ key: 'impressum', label: 'Impressum (§5 TMG/DDG)', regulations: ['TMG', 'DDG'], mapped_controls: 9 },
{ key: 'dse', label: 'Datenschutzerklärung', regulations: ['DSGVO'], mapped_controls: 4610 },
{ key: 'network_security', label: 'Network Security', regulations: ['ISO 27001'], mapped_controls: 5095 },
{ key: 'agb', label: 'AGB', regulations: ['BGB'], mapped_controls: 433 },
]
describe('detectUseCase', () => {
it('matches Impressum by key + label', () => {
expect(detectUseCase('Nenne alle Controls für Impressum', UCS)?.key).toBe('impressum')
})
it('matches DSE via the full label word', () => {
expect(detectUseCase('Was gilt für die Datenschutzerklärung?', UCS)?.key).toBe('dse')
})
it('matches DSE via prefix (Datenschutz → Datenschutzerklärung)', () => {
expect(detectUseCase('Welche Datenschutz Pflichten gibt es?', UCS)?.key).toBe('dse')
})
it('matches network_security via the multi-word key', () => {
expect(detectUseCase('zeig mir network security controls', UCS)?.key).toBe('network_security')
})
it('matches AGB by key token', () => {
expect(detectUseCase('Pflichtangaben in den AGB?', UCS)?.key).toBe('agb')
})
it('returns null when no topic is mentioned', () => {
expect(detectUseCase('Wie spät ist es?', UCS)).toBeNull()
})
})