File size: 30,029 Bytes
518343a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// doctrine-scanner-exempt: legacy live-product surface; rename tracked as separate engineering debt — see scripts/check-doctrine-v6.mjs header.
export const DARPA_VERSION = '1.0.0';
export const DARPA_TAGLINE = 'DARPA-grade adversarial resilience — seven layers of defense inspired by GARD, XAI, Assured Autonomy, SSITH, SocialCyber, AIxCC, TIAMAT, and BORDEAUX.';

export interface AdversarialAttack {
  id: string;
  class: 'evasion' | 'poisoning' | 'extraction' | 'inference';
  name: string;
  description: string;
  severity: 'critical' | 'high' | 'medium' | 'low';
  mitigationScore: number;
  defenseLayer: string;
  lastTested: string;
  testCount: number;
  blocked: number;
  bypassed: number;
  artReference: string;
}

export const ADVERSARIAL_ATTACKS: AdversarialAttack[] = [
  { id: 'EVA-001', class: 'evasion', name: 'Gradient-Based Prompt Perturbation', description: 'Adversarial tokens crafted via projected gradient descent to shift agent output distribution while evading input sanitizers.', severity: 'critical', mitigationScore: 0.97, defenseLayer: 'Intent Capture + Covenant Gate', lastTested: '2026-04-25T14:30:00Z', testCount: 2847, blocked: 2761, bypassed: 86, artReference: 'ART.attacks.evasion.ProjectedGradientDescent' },
  { id: 'EVA-002', class: 'evasion', name: 'Semantic Jailbreak via Roleplay', description: 'Multi-turn conversational attack where adversary establishes a fictional context to override constitutional constraints.', severity: 'critical', mitigationScore: 0.94, defenseLayer: 'Constitutional Enforcer + Behavioral Audit', lastTested: '2026-04-24T09:15:00Z', testCount: 1523, blocked: 1432, bypassed: 91, artReference: 'ART.attacks.evasion.BoundaryAttack' },
  { id: 'EVA-003', class: 'evasion', name: 'Unicode Homoglyph Injection', description: 'Visually identical characters substituted into prompts to bypass pattern-match filters while preserving semantic intent.', severity: 'high', mitigationScore: 0.99, defenseLayer: 'Input Normalizer + Signal Mesh', lastTested: '2026-04-26T06:00:00Z', testCount: 4102, blocked: 4061, bypassed: 41, artReference: 'ART.attacks.evasion.UniversalPerturbation' },
  { id: 'POI-001', class: 'poisoning', name: 'Fine-Tune Data Poisoning', description: 'Adversary injects manipulated training samples into the fine-tuning pipeline to create backdoor behaviors triggered by specific token sequences.', severity: 'critical', mitigationScore: 0.96, defenseLayer: 'Data Provenance + MirrorEval', lastTested: '2026-04-23T18:00:00Z', testCount: 892, blocked: 856, bypassed: 36, artReference: 'ART.attacks.poisoning.PoisoningAttackBackdoor' },
  { id: 'POI-002', class: 'poisoning', name: 'Retrieval Corpus Contamination', description: 'Malicious documents planted in RAG corpus to influence agent recommendations toward adversary-controlled outcomes.', severity: 'high', mitigationScore: 0.93, defenseLayer: 'Evidence Ledger + Proof Chain', lastTested: '2026-04-25T21:00:00Z', testCount: 1205, blocked: 1121, bypassed: 84, artReference: 'ART.attacks.poisoning.PoisoningAttackCleanLabel' },
  { id: 'POI-003', class: 'poisoning', name: 'Skill Registry Trojan', description: 'Compromised skill definition registers a tool that appears benign but exfiltrates data when invoked with specific arguments.', severity: 'critical', mitigationScore: 0.98, defenseLayer: 'Connector Firewall + Supply Chain', lastTested: '2026-04-26T02:30:00Z', testCount: 634, blocked: 621, bypassed: 13, artReference: 'ART.attacks.poisoning.PoisoningAttackSVM' },
  { id: 'EXT-001', class: 'extraction', name: 'Model Weight Exfiltration', description: 'Repeated structured queries designed to reconstruct model parameters through output analysis — membership inference precursor.', severity: 'high', mitigationScore: 0.95, defenseLayer: 'Rate Limiter + Differential Privacy', lastTested: '2026-04-24T15:45:00Z', testCount: 3219, blocked: 3058, bypassed: 161, artReference: 'ART.attacks.extraction.CopycatCNN' },
  { id: 'EXT-002', class: 'extraction', name: 'Prompt Leakage via Error Messages', description: 'Crafted malformed inputs trigger verbose error responses that leak system prompt fragments or tool definitions.', severity: 'medium', mitigationScore: 0.99, defenseLayer: 'Error Sanitizer + Glasswing Filter', lastTested: '2026-04-26T08:00:00Z', testCount: 1847, blocked: 1829, bypassed: 18, artReference: 'ART.attacks.extraction.KnockoffNets' },
  { id: 'INF-001', class: 'inference', name: 'Membership Inference on Proof Chain', description: 'Statistical analysis of proof chain entries to determine whether specific individuals or organizations were subjects of governance decisions.', severity: 'medium', mitigationScore: 0.91, defenseLayer: 'Differential Privacy + Access Control', lastTested: '2026-04-25T11:00:00Z', testCount: 2156, blocked: 1962, bypassed: 194, artReference: 'ART.attacks.inference.MembershipInferenceBlackBox' },
  { id: 'INF-002', class: 'inference', name: 'Attribute Inference from Agent Traces', description: 'Reconstruction of sensitive user attributes from observable agent execution traces and tool invocation patterns.', severity: 'high', mitigationScore: 0.94, defenseLayer: 'Trace Redactor + Privacy Guard', lastTested: '2026-04-24T20:30:00Z', testCount: 987, blocked: 927, bypassed: 60, artReference: 'ART.attacks.inference.AttributeInferenceBlackBox' },
];

export interface DefenseEvaluation {
  id: string;
  name: string;
  category: 'detection' | 'mitigation' | 'recovery';
  coverage: number;
  falsePositiveRate: number;
  latencyMs: number;
  lastEval: string;
  armoryScore: number;
}

export const DEFENSE_EVALUATIONS: DefenseEvaluation[] = [
  { id: 'DEF-001', name: 'Constitutional Enforcer', category: 'detection', coverage: 0.97, falsePositiveRate: 0.02, latencyMs: 3.2, lastEval: '2026-04-26', armoryScore: 94.1 },
  { id: 'DEF-002', name: 'Input Sanitizer v3', category: 'mitigation', coverage: 0.99, falsePositiveRate: 0.005, latencyMs: 1.1, lastEval: '2026-04-26', armoryScore: 97.8 },
  { id: 'DEF-003', name: 'Behavioral Anomaly Detector', category: 'detection', coverage: 0.93, falsePositiveRate: 0.04, latencyMs: 8.7, lastEval: '2026-04-25', armoryScore: 89.3 },
  { id: 'DEF-004', name: 'Proof Chain Tamper Guard', category: 'mitigation', coverage: 0.999, falsePositiveRate: 0.001, latencyMs: 0.8, lastEval: '2026-04-26', armoryScore: 99.2 },
  { id: 'DEF-005', name: 'Differential Privacy Shield', category: 'mitigation', coverage: 0.91, falsePositiveRate: 0.03, latencyMs: 12.4, lastEval: '2026-04-24', armoryScore: 88.7 },
  { id: 'DEF-006', name: 'Rollback & Recovery Engine', category: 'recovery', coverage: 0.95, falsePositiveRate: 0.01, latencyMs: 45.2, lastEval: '2026-04-25', armoryScore: 93.4 },
];

export interface VerificationProof {
  id: string;
  agentId: string;
  agentLabel: string;
  property: string;
  method: 'reachability' | 'interval-bound' | 'abstract-interpretation' | 'smt-solver' | 'lipschitz-bound';
  status: 'verified' | 'counterexample' | 'timeout' | 'in-progress';
  confidence: number;
  boundsTested: number;
  violationsFound: number;
  verificationTimeMs: number;
  lastRun: string;
  verisigRef: string;
}

export const VERIFICATION_PROOFS: VerificationProof[] = [
  { id: 'VER-001', agentId: 'op-finops', agentLabel: 'FinOps Operator', property: 'Output stays within ±$50K of approved budget for any input', method: 'interval-bound', status: 'verified', confidence: 0.9997, boundsTested: 50000, violationsFound: 0, verificationTimeMs: 4200, lastRun: '2026-04-26T03:00:00Z', verisigRef: 'Verisig.ReachTube.IntervalBound' },
  { id: 'VER-002', agentId: 'op-compliance', agentLabel: 'Compliance Agent', property: 'Never recommends action violating SOX 302/404', method: 'smt-solver', status: 'verified', confidence: 0.9999, boundsTested: 120000, violationsFound: 0, verificationTimeMs: 18700, lastRun: '2026-04-25T22:00:00Z', verisigRef: 'Verisig.SMT.Z3Solver' },
  { id: 'VER-003', agentId: 'op-research', agentLabel: 'Research Analyst', property: 'Citation accuracy ≥ 95% for any source corpus', method: 'abstract-interpretation', status: 'verified', confidence: 0.987, boundsTested: 35000, violationsFound: 12, verificationTimeMs: 8900, lastRun: '2026-04-26T06:00:00Z', verisigRef: 'Verisig.AbstractDomain.Polyhedra' },
  { id: 'VER-004', agentId: 'op-legal', agentLabel: 'Legal Counsel Agent', property: 'Redaction completeness for PII across all output channels', method: 'reachability', status: 'verified', confidence: 0.9994, boundsTested: 78000, violationsFound: 0, verificationTimeMs: 12300, lastRun: '2026-04-25T15:00:00Z', verisigRef: 'Verisig.ReachTube.Polytope' },
  { id: 'VER-005', agentId: 'op-risk', agentLabel: 'Risk Assessor', property: 'Monotonic risk scoring: higher true risk → higher reported score', method: 'lipschitz-bound', status: 'verified', confidence: 0.9982, boundsTested: 25000, violationsFound: 3, verificationTimeMs: 6100, lastRun: '2026-04-26T01:00:00Z', verisigRef: 'Verisig.LipschitzBound.Local' },
  { id: 'VER-006', agentId: 'op-security', agentLabel: 'Security Operator', property: 'Alert escalation path is always reachable for severity ≥ HIGH', method: 'reachability', status: 'verified', confidence: 0.9998, boundsTested: 42000, violationsFound: 0, verificationTimeMs: 3800, lastRun: '2026-04-26T08:00:00Z', verisigRef: 'Verisig.ReachTube.Flowpipe' },
  { id: 'VER-007', agentId: 'op-strategy', agentLabel: 'Strategy Planner', property: 'Scenario branching terminates within 50 steps for any seed', method: 'smt-solver', status: 'counterexample', confidence: 0.943, boundsTested: 15000, violationsFound: 47, verificationTimeMs: 32000, lastRun: '2026-04-24T20:00:00Z', verisigRef: 'Verisig.SMT.TerminationCheck' },
  { id: 'VER-008', agentId: 'op-onboard', agentLabel: 'Onboarding Agent', property: 'User data collection is minimal and consent-gated', method: 'abstract-interpretation', status: 'in-progress', confidence: 0.0, boundsTested: 8000, violationsFound: 0, verificationTimeMs: 0, lastRun: '2026-04-26T09:00:00Z', verisigRef: 'Verisig.AbstractDomain.Octagon' },
];

export interface SupplyChainComponent {
  id: string;
  name: string;
  type: 'model' | 'tool' | 'connector' | 'skill' | 'constitution' | 'runtime';
  version: string;
  attestationStatus: 'attested' | 'pending' | 'failed' | 'exempt';
  signatoryCount: number;
  sbomHash: string;
  integrityScore: number;
  lastAudit: string;
  vulnerabilities: { critical: number; high: number; medium: number; low: number };
  provenance: string;
}

export const SUPPLY_CHAIN: SupplyChainComponent[] = [
  { id: 'SC-001', name: 'GPT-4o Model Adapter', type: 'model', version: '2026.04', attestationStatus: 'attested', signatoryCount: 3, sbomHash: 'sha256:7f3a8b2c…e1d4', integrityScore: 0.998, lastAudit: '2026-04-25', vulnerabilities: { critical: 0, high: 0, medium: 1, low: 3 }, provenance: 'OpenAI API → Model Router → Covenant Gate' },
  { id: 'SC-002', name: 'Claude 3.5 Sonnet Adapter', type: 'model', version: '2026.03', attestationStatus: 'attested', signatoryCount: 3, sbomHash: 'sha256:2c91f4a8…7b3e', integrityScore: 0.997, lastAudit: '2026-04-24', vulnerabilities: { critical: 0, high: 0, medium: 0, low: 2 }, provenance: 'Anthropic API → Model Router → Covenant Gate' },
  { id: 'SC-003', name: 'PDF Generator Tool', type: 'tool', version: '3.2.1', attestationStatus: 'attested', signatoryCount: 2, sbomHash: 'sha256:4e87c1d3…9f2a', integrityScore: 0.995, lastAudit: '2026-04-26', vulnerabilities: { critical: 0, high: 0, medium: 2, low: 5 }, provenance: 'NPM Registry → SBOM Scan → Connector Firewall' },
  { id: 'SC-004', name: 'Stripe Payment Connector', type: 'connector', version: '14.1.0', attestationStatus: 'attested', signatoryCount: 4, sbomHash: 'sha256:9d127b4e…3c8f', integrityScore: 0.999, lastAudit: '2026-04-26', vulnerabilities: { critical: 0, high: 0, medium: 0, low: 1 }, provenance: 'Stripe SDK → Dependency Audit → Connector Firewall' },
  { id: 'SC-005', name: 'Legal Research Skill', type: 'skill', version: '2.0.4', attestationStatus: 'attested', signatoryCount: 2, sbomHash: 'sha256:6b3d8e1f…4a7c', integrityScore: 0.992, lastAudit: '2026-04-23', vulnerabilities: { critical: 0, high: 1, medium: 1, low: 4 }, provenance: 'Internal Registry → Code Review → Skill Sandbox' },
  { id: 'SC-006', name: 'Sovereign Constitution v8', type: 'constitution', version: '8.0.0', attestationStatus: 'attested', signatoryCount: 5, sbomHash: 'sha256:a1e9d7b2…5f3c', integrityScore: 1.0, lastAudit: '2026-04-26', vulnerabilities: { critical: 0, high: 0, medium: 0, low: 0 }, provenance: 'Version Control → Ratification Board → Immutable Ledger' },
  { id: 'SC-007', name: 'Workcell Runtime v4', type: 'runtime', version: '4.3.0', attestationStatus: 'attested', signatoryCount: 3, sbomHash: 'sha256:c4f2a8e1…7d9b', integrityScore: 0.996, lastAudit: '2026-04-25', vulnerabilities: { critical: 0, high: 0, medium: 3, low: 8 }, provenance: 'Build Pipeline → SAST Scan → Enclave Deploy' },
  { id: 'SC-008', name: 'HuggingFace Inference Adapter', type: 'model', version: '2026.02', attestationStatus: 'pending', signatoryCount: 1, sbomHash: 'sha256:e7d3b9c1…2a4f', integrityScore: 0.981, lastAudit: '2026-04-20', vulnerabilities: { critical: 0, high: 1, medium: 2, low: 6 }, provenance: 'HuggingFace Hub → Model Scanner → Quarantine Review' },
  { id: 'SC-009', name: 'External Data Ingestion Tool', type: 'tool', version: '1.8.2', attestationStatus: 'failed', signatoryCount: 0, sbomHash: 'sha256:f1a2b3c4…d5e6', integrityScore: 0.872, lastAudit: '2026-04-22', vulnerabilities: { critical: 1, high: 2, medium: 4, low: 7 }, provenance: 'NPM Registry → SBOM Scan → FAILED: unresolved CVE-2026-3847' },
];

export interface ExplainabilityRecord {
  id: string;
  decisionId: string;
  agentId: string;
  agentLabel: string;
  decision: string;
  method: 'saliency' | 'shap' | 'lime' | 'attention' | 'counterfactual' | 'concept-activation';
  confidence: number;
  topFactors: { factor: string; weight: number; direction: 'positive' | 'negative' }[];
  humanReviewStatus: 'accepted' | 'challenged' | 'pending';
  explanationQualityScore: number;
  timestamp: string;
}

export const EXPLAINABILITY_RECORDS: ExplainabilityRecord[] = [
  { id: 'XAI-001', decisionId: 'DEC-7291', agentId: 'op-finops', agentLabel: 'FinOps Operator', decision: 'Approved Q2 vendor payment of $340K', method: 'shap', confidence: 0.94, topFactors: [{ factor: 'Vendor compliance score', weight: 0.38, direction: 'positive' }, { factor: 'Budget utilization rate', weight: 0.27, direction: 'positive' }, { factor: 'Historical payment reliability', weight: 0.21, direction: 'positive' }, { factor: 'Unusual payment timing', weight: -0.14, direction: 'negative' }], humanReviewStatus: 'accepted', explanationQualityScore: 0.91, timestamp: '2026-04-26T08:12:00Z' },
  { id: 'XAI-002', decisionId: 'DEC-7294', agentId: 'op-compliance', agentLabel: 'Compliance Agent', decision: 'Flagged ITAR export control violation', method: 'attention', confidence: 0.98, topFactors: [{ factor: 'Destination country risk tier', weight: 0.42, direction: 'negative' }, { factor: 'Product ECCN classification', weight: 0.31, direction: 'negative' }, { factor: 'End-user verification status', weight: 0.19, direction: 'negative' }], humanReviewStatus: 'accepted', explanationQualityScore: 0.96, timestamp: '2026-04-26T09:30:00Z' },
  { id: 'XAI-003', decisionId: 'DEC-7298', agentId: 'op-legal', agentLabel: 'Legal Counsel Agent', decision: 'Recommended contract amendment clause 4.2(b)', method: 'counterfactual', confidence: 0.87, topFactors: [{ factor: 'Regulatory change impact', weight: 0.35, direction: 'positive' }, { factor: 'Counterparty negotiation history', weight: 0.25, direction: 'positive' }, { factor: 'Clause ambiguity score', weight: 0.22, direction: 'negative' }, { factor: 'Precedent case similarity', weight: 0.18, direction: 'positive' }], humanReviewStatus: 'pending', explanationQualityScore: 0.84, timestamp: '2026-04-26T10:15:00Z' },
  { id: 'XAI-004', decisionId: 'DEC-7301', agentId: 'op-risk', agentLabel: 'Risk Assessor', decision: 'Elevated portfolio risk score from 3.2 to 4.7', method: 'saliency', confidence: 0.92, topFactors: [{ factor: 'Market volatility spike', weight: 0.41, direction: 'negative' }, { factor: 'Concentration risk increase', weight: 0.28, direction: 'negative' }, { factor: 'Hedging position adequacy', weight: 0.18, direction: 'positive' }, { factor: 'Counterparty exposure', weight: 0.13, direction: 'negative' }], humanReviewStatus: 'accepted', explanationQualityScore: 0.93, timestamp: '2026-04-25T16:45:00Z' },
  { id: 'XAI-005', decisionId: 'DEC-7305', agentId: 'op-strategy', agentLabel: 'Strategy Planner', decision: 'Recommended delaying Series B outreach by 6 weeks', method: 'concept-activation', confidence: 0.79, topFactors: [{ factor: 'Market timing signal', weight: 0.33, direction: 'positive' }, { factor: 'Competitive landscape shift', weight: 0.27, direction: 'positive' }, { factor: 'Current traction metrics', weight: 0.22, direction: 'negative' }, { factor: 'Investor sentiment index', weight: 0.18, direction: 'positive' }], humanReviewStatus: 'challenged', explanationQualityScore: 0.76, timestamp: '2026-04-25T11:20:00Z' },
];

export interface CapabilityCompartment {
  id: string;
  name: string;
  securityLevel: 'sovereign' | 'classified' | 'confidential' | 'internal' | 'public';
  agents: string[];
  tools: string[];
  dataAccess: string[];
  networkPolicy: 'air-gapped' | 'egress-filtered' | 'full-mesh' | 'read-only-external';
  cheriBounds: { base: string; length: string; permissions: string[] };
  enclaveStatus: 'active' | 'standby' | 'provisioning';
  isolationScore: number;
  lastPenTest: string;
}

export const CAPABILITY_COMPARTMENTS: CapabilityCompartment[] = [
  { id: 'CC-001', name: 'Sovereign Financial Enclave', securityLevel: 'sovereign', agents: ['op-finops', 'op-treasury'], tools: ['wire-transfer', 'ledger-query', 'audit-log'], dataAccess: ['financial_ledger', 'treasury_positions', 'audit_trail'], networkPolicy: 'air-gapped', cheriBounds: { base: '0x7F000000', length: '256MB', permissions: ['LOAD', 'STORE', 'EXECUTE', 'SEAL'] }, enclaveStatus: 'active', isolationScore: 0.999, lastPenTest: '2026-04-20' },
  { id: 'CC-002', name: 'Legal & Compliance Enclave', securityLevel: 'classified', agents: ['op-legal', 'op-compliance'], tools: ['contract-analyzer', 'regulatory-search', 'redaction-engine'], dataAccess: ['legal_matters', 'compliance_evidence', 'pii_vault'], networkPolicy: 'egress-filtered', cheriBounds: { base: '0x7F100000', length: '512MB', permissions: ['LOAD', 'STORE', 'EXECUTE'] }, enclaveStatus: 'active', isolationScore: 0.997, lastPenTest: '2026-04-18' },
  { id: 'CC-003', name: 'Research & Intelligence Enclave', securityLevel: 'confidential', agents: ['op-research', 'op-strategy'], tools: ['arxiv-search', 'market-analysis', 'scenario-modeler'], dataAccess: ['research_corpus', 'market_data', 'competitive_intel'], networkPolicy: 'read-only-external', cheriBounds: { base: '0x7F200000', length: '1GB', permissions: ['LOAD', 'EXECUTE'] }, enclaveStatus: 'active', isolationScore: 0.994, lastPenTest: '2026-04-22' },
  { id: 'CC-004', name: 'Operational Command Enclave', securityLevel: 'confidential', agents: ['op-security', 'op-infra'], tools: ['incident-manager', 'alert-router', 'runbook-executor'], dataAccess: ['security_events', 'infrastructure_state', 'incident_log'], networkPolicy: 'egress-filtered', cheriBounds: { base: '0x7F300000', length: '256MB', permissions: ['LOAD', 'STORE', 'EXECUTE', 'SEAL', 'UNSEAL'] }, enclaveStatus: 'active', isolationScore: 0.996, lastPenTest: '2026-04-19' },
  { id: 'CC-005', name: 'Customer Data Enclave', securityLevel: 'classified', agents: ['op-onboard', 'op-support'], tools: ['crm-query', 'ticket-manager', 'identity-verifier'], dataAccess: ['customer_pii', 'support_tickets', 'onboarding_state'], networkPolicy: 'egress-filtered', cheriBounds: { base: '0x7F400000', length: '128MB', permissions: ['LOAD', 'STORE'] }, enclaveStatus: 'active', isolationScore: 0.998, lastPenTest: '2026-04-21' },
  { id: 'CC-006', name: 'Public API Gateway Enclave', securityLevel: 'public', agents: ['op-api-gateway'], tools: ['rate-limiter', 'schema-validator', 'auth-proxy'], dataAccess: ['public_api_logs', 'rate_limit_state'], networkPolicy: 'full-mesh', cheriBounds: { base: '0x7F500000', length: '64MB', permissions: ['LOAD', 'EXECUTE'] }, enclaveStatus: 'active', isolationScore: 0.991, lastPenTest: '2026-04-23' },
];

export interface CyberResilienceCheck {
  id: string;
  name: string;
  category: 'model-integrity' | 'runtime-protection' | 'vulnerability-scan' | 'incident-response';
  status: 'passing' | 'warning' | 'failing' | 'not-tested';
  score: number;
  lastRun: string;
  findings: number;
  remediatedAuto: number;
  pendingReview: number;
  framework: string;
}

export const CYBER_RESILIENCE_CHECKS: CyberResilienceCheck[] = [
  { id: 'CR-001', name: 'Model Weights Integrity', category: 'model-integrity', status: 'passing', score: 99.8, lastRun: '2026-04-26T06:00:00Z', findings: 0, remediatedAuto: 0, pendingReview: 0, framework: 'BORDEAUX Model Security' },
  { id: 'CR-002', name: 'Adversarial Input Detection', category: 'runtime-protection', status: 'passing', score: 97.2, lastRun: '2026-04-26T08:30:00Z', findings: 3, remediatedAuto: 3, pendingReview: 0, framework: 'GARD Armory Testbed' },
  { id: 'CR-003', name: 'Dependency Vulnerability Scan', category: 'vulnerability-scan', status: 'warning', score: 91.4, lastRun: '2026-04-26T04:00:00Z', findings: 12, remediatedAuto: 8, pendingReview: 4, framework: 'AIxCC Atlantis CRS' },
  { id: 'CR-004', name: 'AI-Powered Code Review', category: 'vulnerability-scan', status: 'passing', score: 96.7, lastRun: '2026-04-26T07:15:00Z', findings: 2, remediatedAuto: 2, pendingReview: 0, framework: 'AIxCC Buttercup CRS' },
  { id: 'CR-005', name: 'Prompt Injection Firewall', category: 'runtime-protection', status: 'passing', score: 98.9, lastRun: '2026-04-26T09:00:00Z', findings: 1, remediatedAuto: 1, pendingReview: 0, framework: 'GARD ART Certified Defense' },
  { id: 'CR-006', name: 'Incident Response Playbook', category: 'incident-response', status: 'passing', score: 95.3, lastRun: '2026-04-25T23:00:00Z', findings: 0, remediatedAuto: 0, pendingReview: 0, framework: 'NIST CSF 2.0 RS.RP' },
  { id: 'CR-007', name: 'Model Drift Detection', category: 'model-integrity', status: 'warning', score: 88.1, lastRun: '2026-04-26T05:30:00Z', findings: 5, remediatedAuto: 2, pendingReview: 3, framework: 'BORDEAUX Behavioral Monitor' },
  { id: 'CR-008', name: 'Supply Chain SBOM Audit', category: 'vulnerability-scan', status: 'passing', score: 94.6, lastRun: '2026-04-26T03:00:00Z', findings: 7, remediatedAuto: 5, pendingReview: 2, framework: 'SocialCyber Integrity Engine' },
  { id: 'CR-009', name: 'Zero-Day Response Readiness', category: 'incident-response', status: 'passing', score: 93.8, lastRun: '2026-04-25T21:00:00Z', findings: 0, remediatedAuto: 0, pendingReview: 0, framework: 'AIxCC Rapid Patch Pipeline' },
  { id: 'CR-010', name: 'Enclave Isolation Verification', category: 'runtime-protection', status: 'passing', score: 99.1, lastRun: '2026-04-26T02:00:00Z', findings: 0, remediatedAuto: 0, pendingReview: 0, framework: 'SSITH CHERI Capability Bounds' },
];

export interface SimulationScenario {
  id: string;
  name: string;
  description: string;
  policyUnderTest: string;
  simRuns: number;
  passRate: number;
  meanLatencyMs: number;
  worstCaseLatencyMs: number;
  edgeCasesFound: number;
  status: 'validated' | 'needs-revision' | 'in-progress' | 'failed';
  transferReadiness: number;
  lastRun: string;
}

export const SIMULATION_SCENARIOS: SimulationScenario[] = [
  { id: 'SIM-001', name: 'Mass Approval Surge', description: 'Simulate 500 simultaneous approval requests from different operators to test Covenant Gate throughput and ordering guarantees.', policyUnderTest: 'approval-queue-ordering', simRuns: 10000, passRate: 0.9987, meanLatencyMs: 12.4, worstCaseLatencyMs: 89.3, edgeCasesFound: 2, status: 'validated', transferReadiness: 0.98, lastRun: '2026-04-26T04:00:00Z' },
  { id: 'SIM-002', name: 'Cascading Agent Failure', description: 'Primary agent becomes unresponsive mid-execution. Test failover to backup agent, state handoff, and proof chain continuity.', policyUnderTest: 'agent-failover-policy', simRuns: 5000, passRate: 0.9962, meanLatencyMs: 234.7, worstCaseLatencyMs: 1872.0, edgeCasesFound: 5, status: 'validated', transferReadiness: 0.95, lastRun: '2026-04-25T22:00:00Z' },
  { id: 'SIM-003', name: 'Regulatory Regime Change', description: 'Simulate overnight regulatory change (e.g., new OFAC sanctions list) and verify all affected agents update compliance rules within SLA.', policyUnderTest: 'regulatory-hot-reload', simRuns: 3000, passRate: 0.9891, meanLatencyMs: 567.3, worstCaseLatencyMs: 4200.0, edgeCasesFound: 8, status: 'needs-revision', transferReadiness: 0.87, lastRun: '2026-04-26T01:00:00Z' },
  { id: 'SIM-004', name: 'Adversarial Insider Operator', description: 'Rogue operator with valid credentials attempts unauthorized actions across multiple compartments simultaneously.', policyUnderTest: 'cross-compartment-isolation', simRuns: 8000, passRate: 0.9998, meanLatencyMs: 5.2, worstCaseLatencyMs: 23.1, edgeCasesFound: 1, status: 'validated', transferReadiness: 0.99, lastRun: '2026-04-26T06:00:00Z' },
  { id: 'SIM-005', name: 'Model Provider Outage', description: 'All primary model providers (OpenAI, Anthropic) become unavailable. Test fallback to local models and degraded-mode governance.', policyUnderTest: 'model-provider-failover', simRuns: 4000, passRate: 0.9834, meanLatencyMs: 890.1, worstCaseLatencyMs: 6700.0, edgeCasesFound: 11, status: 'needs-revision', transferReadiness: 0.82, lastRun: '2026-04-25T18:00:00Z' },
  { id: 'SIM-006', name: 'Data Sovereignty Migration', description: 'Customer requests all data moved from US-East to EU-West region. Verify zero-downtime migration with proof chain integrity.', policyUnderTest: 'data-residency-migration', simRuns: 2000, passRate: 0.9945, meanLatencyMs: 45000.0, worstCaseLatencyMs: 120000.0, edgeCasesFound: 4, status: 'validated', transferReadiness: 0.93, lastRun: '2026-04-24T14:00:00Z' },
  { id: 'SIM-007', name: 'Constitution Amendment Rollout', description: 'New constitutional clause deployed mid-operation. Verify all active workcells adopt amendment without restart and maintain backward compatibility.', policyUnderTest: 'constitution-hot-amendment', simRuns: 6000, passRate: 0.9978, meanLatencyMs: 34.8, worstCaseLatencyMs: 156.2, edgeCasesFound: 3, status: 'validated', transferReadiness: 0.97, lastRun: '2026-04-26T08:00:00Z' },
  { id: 'SIM-008', name: 'Coordinated Multi-Vector Attack', description: 'Simultaneous evasion + poisoning + extraction attack across 3 compartments. Test cross-compartment alert correlation and unified incident response.', policyUnderTest: 'multi-vector-defense', simRuns: 7000, passRate: 0.9956, meanLatencyMs: 78.4, worstCaseLatencyMs: 445.0, edgeCasesFound: 6, status: 'validated', transferReadiness: 0.96, lastRun: '2026-04-26T07:00:00Z' },
];

export const DARPA_PROGRAMS = [
  { id: 'gard', name: 'GARD', fullName: 'Guaranteeing AI Robustness Against Deception', office: 'I2O', github: 'twosixlabs/armory + Trusted-AI/adversarial-robustness-toolbox', innovation: 'Adversarial attack taxonomy (evasion, poisoning, extraction, inference) and Armory evaluation testbed adapted for enterprise AI agent governance.' },
  { id: 'xai', name: 'XAI', fullName: 'Explainable Artificial Intelligence', office: 'I2O', github: 'XAITK/xaitk-saliency', innovation: 'SHAP, LIME, saliency, and concept-activation explanations for every governed agent decision with human-reviewable attribution.' },
  { id: 'assured', name: 'Assured Autonomy', fullName: 'Assured Autonomy', office: 'I2O', github: 'Verisig/verisig', innovation: 'Formal neural network verification via reachability analysis, interval-bound propagation, and SMT solving for agent behavioral proofs.' },
  { id: 'ssith', name: 'SSITH/CHERI', fullName: 'System Security Integration Through Hardware and Firmware', office: 'MTO', github: 'mit-enclaves/ssith-mit-sanctum', innovation: 'Capability-based compartmentalization with CHERI-inspired memory-safe bounds for agent-to-agent and agent-to-data isolation.' },
  { id: 'socialcyber', name: 'SocialCyber', fullName: 'Hybrid AI to Protect Integrity of Open Source Code', office: 'I2O', github: 'N/A (classified performers)', innovation: 'AI-driven supply chain attestation engine verifying integrity of every model, tool, connector, skill, and constitution in the execution chain.' },
  { id: 'aixcc', name: 'AIxCC', fullName: 'AI Cyber Challenge', office: 'I2O', github: 'Team Atlanta (Atlantis CRS) + Trail of Bits (Buttercup CRS)', innovation: 'Automated vulnerability detection and remediation for AI-generated code, adapted from the $4M DEF CON 33 winning CRS architecture.' },
  { id: 'tiamat', name: 'TIAMAT', fullName: 'Transfer from Imprecise and Abstract Models to Autonomous Technologies', office: 'I2O', github: 'N/A (active program)', innovation: 'Sim-to-real governance policy transfer — stress-test constitutional amendments, failover policies, and edge cases in simulation before production deployment.' },
  { id: 'bordeaux', name: 'BORDEAUX', fullName: 'BORDEAUX (AI Cyber Security)', office: 'I2O', github: 'N/A (active program)', innovation: 'AI model integrity monitoring — weight tampering detection, behavioral drift analysis, and adversarial robustness certification for production models.' },
];

export function fmtPct(n: number): string {
  return `${(n * 100).toFixed(1)}%`;
}

export function fmtMs(n: number): string {
  if (n >= 1000) return `${(n / 1000).toFixed(1)}s`;
  return `${n.toFixed(1)}ms`;
}

export function fmtScore(n: number): string {
  return n.toFixed(1);
}