shieldx/tests/unit/compliance/ComplianceRobot.test.ts
Claude 1b5f698f4c
Some checks failed
security-scan / secret-scan (push) Failing after 3s
feat(compliance): add NIS2/ISO27001/SOC2 mappers, Compliance-Robot, EU-AI-Act-Agent; docs(flexoptix-os): consolidation concept
Extends the existing ATLAS/OWASP/EU-AI-Act compliance module with three
new control-framework mappers (NIS2 Art. 21(2), ISO/IEC 27001 Annex A,
SOC 2 Trust Services Criteria), each honestly marking what ShieldX
covers vs. what remains an organizational/legal gap.

ComplianceRobot aggregates all four frameworks into a single prioritized,
owned action plan. EUAIActAgent adds active workflows on top of the
existing static reporter: Art. 6/Annex III risk pre-screening, Annex IV
technical documentation scaffolding, Art. 72 post-market monitoring plan,
and the corrected 2027/2028 enforcement timeline.

Adds docs/flexoptix-os/ — a broader consolidation concept covering the
current state (Magatama/ShieldX, EO Global Pulse), target architecture
for BEO (LibreChat/Presidio-based), a Transceiver Intelligence Platform
architecture recommendation, and RunWork OS externalization strategy,
grounded in adversarially-verified research citations.
2026-07-14 14:46:51 +00:00

58 lines
2.0 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest'
import { ComplianceRobot } from '../../../src/compliance/ComplianceRobot.js'
import type { LearningStats } from '../../../src/types/learning.js'
const stats: LearningStats = Object.freeze({
totalPatterns: 100,
builtinPatterns: 80,
learnedPatterns: 15,
communityPatterns: 5,
redTeamPatterns: 3,
totalIncidents: 42,
falsePositiveRate: 0.02,
topPatterns: Object.freeze([]),
recentIncidents: 4,
driftDetected: false,
})
describe('ComplianceRobot', () => {
let robot: ComplianceRobot
beforeEach(() => {
robot = new ComplianceRobot()
})
describe('assess()', () => {
it('should return readiness scores for all four frameworks', () => {
const assessment = robot.assess(stats)
expect(assessment.overallReadiness.nis2).toBeGreaterThan(0)
expect(assessment.overallReadiness.iso27001).toBeGreaterThan(0)
expect(assessment.overallReadiness.soc2).toBeGreaterThan(0)
expect(assessment.overallReadiness.eu_ai_act).toBeGreaterThanOrEqual(0)
})
it('should produce an action plan sorted by priority', () => {
const assessment = robot.assess(stats)
expect(assessment.actionPlan.length).toBeGreaterThan(0)
const priorityRank: Record<string, number> = { critical: 0, high: 1, medium: 2, low: 3 }
for (let i = 1; i < assessment.actionPlan.length; i++) {
expect(priorityRank[assessment.actionPlan[i].priority]).toBeGreaterThanOrEqual(
priorityRank[assessment.actionPlan[i - 1].priority],
)
}
})
it('should include NIS2, ISO27001, SOC2, and EU AI Act action items', () => {
const assessment = robot.assess(stats)
const frameworks = new Set(assessment.actionPlan.map((item) => item.framework))
expect(frameworks.has('nis2')).toBe(true)
expect(frameworks.has('iso27001')).toBe(true)
expect(frameworks.has('soc2')).toBe(true)
})
it('should work without stats (uses EU AI Act default fallback)', () => {
expect(() => robot.assess()).not.toThrow()
})
})
})