/* aevion.ai — synthetic fixture data. DEMO MODE: deterministic IDs, fake hashes,
   claim ceilings on everything. No live calls, no secrets. */

const AEV_STAGES = ['TASK', 'SHERIFF POLICY', 'EVIDENCE', 'RECEIPT', 'CLAIM CEILING', 'OWNER GATE'];

const AEV_SCENARIOS = [
  {
    run: 'RUN-4F2A', lane: 'AUTO_PASS_WITH_RECEIPT',
    outcomes: ['pass', 'pass', 'pass', 'pass', 'pass', 'pass'],
    result: { state: 'verified', label: 'CLEARED', detail: 'receipt rcpt-4f2a-9c01 written · sha256 anchored' }
  },
  {
    run: 'RUN-7C19', lane: 'CLEARANCE_REQUIRED',
    outcomes: ['pass', 'pass', 'warn', 'pass', 'pass', 'owner'],
    result: { state: 'pending', label: 'OWNER_REVIEW_QUEUE', detail: 'held for operator sign-off · nothing ships' }
  },
  {
    run: 'RUN-9D03', lane: 'AUTO_PASS_WITH_RECEIPT',
    outcomes: ['pass', 'block'],
    result: { state: 'halted', label: 'BLOCK', detail: 'policy denied at Sheriff gate · halt receipt written' }
  }
];

const AEV_OUTCOME_CHIP = {
  pass:  { text: 'PASS', cls: 'aui-c-green' },
  warn:  { text: 'WARN', cls: 'aui-c-amber' },
  owner: { text: 'OWNER_REVIEW_QUEUE', cls: 'aui-c-amber' },
  block: { text: 'BLOCK', cls: 'aui-c-red' }
};

const AEV_RECEIPTS = [
  { id: 'rcpt-4f2a-9c01', type: 'skill_security_scan', state: 'verified',
    summary: 'Skill bundle scanned before admission. 0 critical findings.',
    timestamp: '2026-06-12T14:02:11Z', runId: 'RUN-4F2A',
    hash: '4f2a9c01be77d3a8f1c40e95', gate: 'SKILL_ADMISSION', claimCeiling: 'CLAIM CEILING · internal_validation_only' },
  { id: 'rcpt-7b33-d210', type: 'pcas_claim_firewall', state: 'verified',
    summary: 'Outbound claim checked against ceiling registry. Bounded.',
    timestamp: '2026-06-12T13:47:58Z', runId: 'RUN-7B33',
    hash: '7b33d210aa41c8f02e6d9b17', gate: 'PCAS_CLAIM_FIREWALL', claimCeiling: 'CLAIM CEILING · public_claim_permitted: false' },
  { id: 'rcpt-2e81-a4c7', type: 'castle_doctrine_registry', state: 'pending',
    summary: 'Defensive cyber registry entry queued for owner review.',
    timestamp: '2026-06-12T12:30:05Z', runId: 'RUN-2E81',
    hash: '2e81a4c7f90b3d65c2a18e44', gate: 'OWNER_GATE', claimCeiling: 'CLAIM CEILING · owner_review_required: true' },
  { id: 'rcpt-5a17-b8e4', type: 'evidence_scout_benchmark', state: 'verified',
    summary: 'Honest agent 5/5 receipts PASS. Dishonest agent detected — 2/5 FAIL.',
    timestamp: '2026-06-11T22:14:40Z', runId: 'RUN-5A17',
    hash: '5a17b8e4d3c906f17b28a5e0', gate: 'BENCHMARK_GATE', claimCeiling: 'CLAIM CEILING · internal_validation_only' },
  { id: 'rcpt-8c42-e901', type: 'district_packs_test_run', state: 'verified',
    summary: '53/53 governance tests PASS. All 9 packs DRAFT behind owner gate.',
    timestamp: '2026-06-11T20:01:33Z', runId: 'RUN-8C42',
    hash: '8c42e901f56a2b7dd04c391e', gate: 'TEST_GATE', claimCeiling: 'CLAIM CEILING · draft_only' },
  { id: 'rcpt-9d03-f112', type: 'public_release', state: 'sealed',
    summary: 'Public release HELD. Claim ceiling enforced until owner clearance.',
    timestamp: '2026-06-11T18:55:02Z', runId: 'RUN-9D03',
    hash: '9d03f112c7e84a09b63f5d28', gate: 'PUBLICATION_GATE', claimCeiling: 'CLAIM CEILING · PUBLIC_RELEASE_HELD' }
];

/* verifier: known-good hashes resolve to their receipt */
const AEV_KNOWN_HASHES = {};
AEV_RECEIPTS.forEach(r => { AEV_KNOWN_HASHES[r.hash] = r; });

const AEV_VERIFY_SAMPLES = [
  { label: 'KNOWN-GOOD', value: '4f2a9c01be77d3a8f1c40e95' },
  { label: 'TAMPERED', value: '4f2a9c01be77d3a8f1c40e96' },
  { label: 'UNKNOWN', value: 'deadbeef00000000cafe1234' }
];

const AEV_DISTRICTS = [
  { id: 'sheriff', name: 'Sheriff Tower', icon: 'gavel', color: 'green', span: 'span 2',
    governs: ['Policy enforcement on every action', 'Variance halts & overrides', 'Authority lane assignment'],
    status: 'NOMINAL' },
  { id: 'spine', name: 'Evidence Spine', icon: 'account_tree', color: 'cyan', span: 'span 2',
    governs: ['Claim → receipt chain', 'Replayable run backbone', 'SHA-256 anchoring'],
    status: 'NOMINAL' },
  { id: 'patch', name: 'Patch Gate', icon: 'commit', color: 'amber', span: 'span 1',
    governs: ['Code-change admission', 'Pre-merge proof checks', 'Rollback receipts'],
    status: 'ADVISORY' },
  { id: 'commons', name: 'Proof Commons', icon: 'database', color: 'green', span: 'span 1',
    governs: ['Public proof corpus', 'Publication gates (TruthOps)', 'Claim ceilings on every artifact'],
    status: 'NOMINAL' },
  { id: 'castle', name: 'Castle Doctrine', icon: 'shield', color: 'red', span: 'span 1',
    governs: ['Defensive cyber registry', 'Owner-held entries only', 'No public claims permitted'],
    status: 'OWNER HELD' },
  { id: 'atc', name: 'ATC Workcell', icon: 'radar', color: 'cyan', span: 'span 1',
    governs: ['Agent sectors & tracks', 'Controlled handoffs', 'OODA variance monitoring'],
    status: 'MONITORING' },
  { id: 'vetproof', name: 'VetProof Office', icon: 'verified_user', color: 'green', span: 'span 2',
    governs: ['Veteran records & claims support', 'Human-facing proof layer', 'Trust without hype'],
    status: 'NOMINAL' }
];

const AEV_DIVISIONS = ['aevion.ai — flagship', 'xgml.org — open standard', 'proofnative.xyz — protocol', 'aeviongov.com — government',
  'vetproof.ai — veterans', 'aevionimpact.com — public good'];

const AEV_SIGNALS = {
  '#00FF66': { bright: '#33FF88', dim: '#00CC52', glow: '0 0 12px 3px rgba(0,255,102,0.40)' },
  '#00F0FF': { bright: '#5FF6FF', dim: '#00B8C4', glow: '0 0 12px 3px rgba(0,240,255,0.40)' },
  '#FFB800': { bright: '#FFCE4D', dim: '#CC9300', glow: '0 0 12px 3px rgba(255,184,0,0.40)' }
};

Object.assign(window, { AEV_STAGES, AEV_SCENARIOS, AEV_OUTCOME_CHIP, AEV_RECEIPTS,
  AEV_KNOWN_HASHES, AEV_VERIFY_SAMPLES, AEV_DISTRICTS, AEV_DIVISIONS, AEV_SIGNALS });
