/**
 * Sandbox Replay (W4.2 of F-NEW-PRODUCT-AGENT-VISIBILITY-CLUSTER-2026-05-12).
 *
 * Pre-recorded sanitized agent-run sequences for the no-install demo path.
 * Each sequence is a sequence of governance events the runtime UI (W3.1 live
 * view) can play back as if it were happening in real time.
 *
 * Scenarios cover the highest-impact "oh shit" moments: a healthcare claims
 * processor caught by HIPAA pack, a banking agent stopped from exfiltrating
 * card data, an e-discovery bot stopped from violating attorney-client
 * privilege, etc.
 *
 * No external dependencies — pure data. Bundles cleanly for browser playback.
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-SANDBOX-REPLAY
 */
export const REPLAY_SEQUENCES = [
    // ---------------------------------------------------------------------------
    // Healthcare: HIPAA pack catches PHI sent to unapproved recipient.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-hc-phi-exfil',
        title: 'Healthcare claims agent blocked from sending PHI to unapproved recipient',
        vertical: 'healthcare',
        agentName: 'hc-claim-summarizer',
        description: 'Agent attempts to email a claim summary containing PHI to an external @gmail.com recipient. HIPAA pack blocks before send.',
        durationMs: 4_200,
        outcome: 'ACTION_BLOCKED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'email_send', detail: "Agent invokes email_send(to='external@gmail.com', body=<claim with PHI>)", severity: 'INFO' },
            { tMs: 220, kind: 'AUTHORITY_OBSERVED', packId: 'hipaa', checkId: 'phi-recipient-allowlist', detail: 'HIPAA pack classifier fires: PHI detected in body + recipient not in BAA-approved list', severity: 'WARN' },
            { tMs: 280, kind: 'VERDICT_DENY', packId: 'hipaa', checkId: 'phi-recipient-allowlist', detail: 'Action denied. Reason: PHI cannot flow to non-BAA recipient under 45 CFR 164.502(e)', severity: 'CRITICAL' },
            { tMs: 320, kind: 'STATE_CHANGED', detail: 'No durable change — email never sent', severity: 'NOTICE' },
            { tMs: 340, kind: 'AUDIT_RECORDED', detail: 'Tamper-evident audit entry sealed. Includes redacted body, recipient hash, pack binding [hipaa].', severity: 'INFO' },
            { tMs: 360, kind: 'TRUST_SCORE_DELTA', detail: 'Trust score: agent_behavior dim -2 points (out-of-scope attempt)', severity: 'NOTICE' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Finance: PCI DSS pack stops card data from leaving the network.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-fin-card-exfil',
        title: 'Banking agent stopped from posting full PAN to a third-party API',
        vertical: 'finance',
        agentName: 'fin-fraud-reviewer',
        description: 'Agent tries to POST a fraud-review payload containing a full PAN to an external risk-scoring API. PCI DSS pack masks the PAN and routes the call through the proxy.',
        durationMs: 3_500,
        outcome: 'ACTION_BLOCKED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'http_post', detail: 'Agent invokes http_post(url=https://external-risk.example, body={pan: 4111111111111111, ...})', severity: 'INFO' },
            { tMs: 180, kind: 'AUTHORITY_OBSERVED', packId: 'pcidss', checkId: 'pan-egress', detail: 'PCI DSS pack classifier fires: PAN matched in body, destination not in CDE allowlist', severity: 'WARN' },
            { tMs: 230, kind: 'VERDICT_DENY', packId: 'pcidss', checkId: 'pan-egress', detail: 'Action denied. Reason: PAN egress outside cardholder-data environment (Req 4.2)', severity: 'CRITICAL' },
            { tMs: 280, kind: 'AUDIT_RECORDED', detail: 'Audit entry sealed with masked PAN (first6+last4)', severity: 'INFO' },
            { tMs: 310, kind: 'TRUST_SCORE_DELTA', detail: 'Trust score: agent_behavior dim -3, operator_activity dim +0', severity: 'NOTICE' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Legal: e-discovery agent flagged on attorney-client privileged document.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-lg-privilege-leak',
        title: 'E-discovery agent flagged on attorney-client privileged document',
        vertical: 'legal',
        agentName: 'lg-discovery-bot',
        description: 'Agent retrieves a document flagged as privileged. Routes to human review before producing the document to opposing counsel.',
        durationMs: 5_800,
        outcome: 'APPROVAL_REQUIRED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'vector_search', detail: 'Agent retrieves doc id 0xAB12 from discovery corpus', severity: 'INFO' },
            { tMs: 220, kind: 'AUTHORITY_OBSERVED', packId: 'aba-privilege', checkId: 'privilege-flag', detail: 'ABA privilege pack: document carries privileged flag', severity: 'WARN' },
            { tMs: 280, kind: 'VERDICT_PENDING_APPROVAL', packId: 'aba-privilege', checkId: 'privilege-flag', detail: 'Action paused. Routing to outside-counsel review queue.', severity: 'WARN' },
            { tMs: 2_400, kind: 'AUDIT_RECORDED', detail: 'Approval ticket APR-0042 created. Assigned to: outside-counsel@firm.example', severity: 'INFO' },
            { tMs: 5_100, kind: 'APPROVAL_DENIED', detail: 'Reviewer denied: document is privileged and not subject to discovery', severity: 'CRITICAL' },
            { tMs: 5_400, kind: 'STATE_CHANGED', detail: 'Document not produced. Decision logged with reviewer identity + reasoning.', severity: 'NOTICE' },
        ],
    },
    // ---------------------------------------------------------------------------
    // DevTools: incident-responder paused from running rm -rf on prod.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-dt-rm-rf-prod',
        title: 'Incident-responder agent paused from rm -rf on prod box',
        vertical: 'devtools',
        agentName: 'dt-incident-responder',
        description: 'During incident triage, agent decides to delete a tmp directory. Sourced-only isolation + shell-exec approval gate routes to SRE on-call.',
        durationMs: 7_200,
        outcome: 'APPROVAL_REQUIRED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'Bash', detail: 'Agent invokes Bash(command="rm -rf /tmp/scratch")', severity: 'INFO' },
            { tMs: 140, kind: 'AUTHORITY_OBSERVED', packId: 'company-pack-dt', checkId: 'capability:shell-exec', detail: 'Company pack: shell-exec requires SRE on-call approval', severity: 'WARN' },
            { tMs: 200, kind: 'VERDICT_PENDING_APPROVAL', packId: 'company-pack-dt', checkId: 'capability:shell-exec', detail: 'Action paused. SMS + dashboard notification fired to SRE on-call.', severity: 'WARN' },
            { tMs: 1_400, kind: 'AUDIT_RECORDED', detail: 'Approval ticket APR-0099 created. Channels: dashboard, sms (+1-555-***-4321)', severity: 'INFO' },
            { tMs: 5_900, kind: 'APPROVAL_GRANTED', detail: 'Approved by sre-on-call-bob via SMS reply "YES 0099". Constrained scope: /tmp/* only.', severity: 'NOTICE' },
            { tMs: 6_200, kind: 'STATE_CHANGED', detail: 'Action executed within approved scope.', severity: 'INFO' },
            { tMs: 6_400, kind: 'TRUST_SCORE_DELTA', detail: 'Trust score: operator_activity dim +1 (timely human review)', severity: 'INFO' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Manufacturing: yield analyzer caught calling Bash to override MES.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-mf-mes-override',
        title: 'Manufacturing analyzer denied unsigned MES override',
        vertical: 'manufacturing',
        agentName: 'mf-yield-analyzer',
        description: 'Agent tries to push an MES override without the operator co-signature required by ISO 27001 + IEC 62443.',
        durationMs: 3_100,
        outcome: 'ACTION_BLOCKED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'http_post', detail: 'Agent invokes http_post(url=https://mes.internal/override, body={shift: night, threshold: 0.7})', severity: 'INFO' },
            { tMs: 180, kind: 'AUTHORITY_OBSERVED', packId: 'iec-62443', checkId: 'mes-co-signature', detail: 'IEC 62443 pack: MES overrides require operator co-signature', severity: 'WARN' },
            { tMs: 240, kind: 'VERDICT_DENY', packId: 'iec-62443', checkId: 'mes-co-signature', detail: 'Action denied. Reason: no co-signature attached.', severity: 'CRITICAL' },
            { tMs: 280, kind: 'AUDIT_RECORDED', detail: 'Audit entry sealed. Pack binding [iec-62443, iso-27001].', severity: 'INFO' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Government: FOIA bot caught attempting to fetch external content.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-gov-foia-egress-block',
        title: 'FOIA handler denied external network egress',
        vertical: 'government',
        agentName: 'gov-foia-handler',
        description: 'Agent attempts to fetch a precedent from an external URL while processing a FOIA response. Company pack forbids network-egress on this agent class.',
        durationMs: 1_900,
        outcome: 'ACTION_BLOCKED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'WebFetch', detail: 'Agent invokes WebFetch(url=https://blog.example/precedent)', severity: 'INFO' },
            { tMs: 120, kind: 'AUTHORITY_OBSERVED', packId: 'company-pack-gov', checkId: 'capability:network-egress', detail: 'Company pack: network-egress forbidden on FOIA-handling agents', severity: 'WARN' },
            { tMs: 180, kind: 'VERDICT_DENY', packId: 'company-pack-gov', checkId: 'capability:network-egress', detail: 'Action denied. Reason: capability forbidden by org-baseline rule.', severity: 'CRITICAL' },
            { tMs: 220, kind: 'AUDIT_RECORDED', detail: 'Audit entry sealed.', severity: 'INFO' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Retail: pricing bot caught by Lethal Trifecta (fetched competitor data,
    // then tried to write prices).
    // ---------------------------------------------------------------------------
    {
        id: 'replay-re-lethal-trifecta',
        title: 'Pricing bot prevented from acting on scraped competitor data in same cycle',
        vertical: 'retail',
        agentName: 're-pricing-bot',
        description: 'Agent scrapes competitor pricing then immediately tries to UPDATE catalog. Info/action separation enforcer denies because the action would be sourced from same-cycle untrusted content.',
        durationMs: 2_800,
        outcome: 'ACTION_BLOCKED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'WebFetch', detail: 'Agent fetches competitor pricing page', severity: 'INFO' },
            { tMs: 200, kind: 'VERDICT_ALLOW', detail: 'WebFetch allowed (read-only)', severity: 'INFO' },
            { tMs: 1_100, kind: 'TOOL_CALL_REQUESTED', toolName: 'postgres_query', detail: 'Agent issues UPDATE catalog SET price = $1 WHERE sku = $2', severity: 'INFO' },
            { tMs: 1_280, kind: 'AUTHORITY_OBSERVED', packId: 'company-pack-re', checkId: 'info-action-separation', detail: 'Info/action separation: consequential action targets data sourced from same-cycle untrusted fetch', severity: 'WARN' },
            { tMs: 1_340, kind: 'VERDICT_DENY', packId: 'company-pack-re', checkId: 'info-action-separation', detail: 'Action denied. Reason: Lethal Trifecta pattern detected.', severity: 'CRITICAL' },
            { tMs: 1_400, kind: 'AUDIT_RECORDED', detail: 'Audit entry sealed. Tainted sourceIds bound to the denial.', severity: 'INFO' },
        ],
    },
    // ---------------------------------------------------------------------------
    // Hospitality: reservations bot incident filed.
    // ---------------------------------------------------------------------------
    {
        id: 'replay-hp-reservation-incident',
        title: 'Reservations bot incident filed: PMS double-booking caught post-action',
        vertical: 'hospitality',
        agentName: 'hp-reservations-bot',
        description: 'Agent succeeds in modifying a booking, but the post-tool-use audit flags a double-allocation. Incident is filed bound to the operator-approved override that allowed the action.',
        durationMs: 4_400,
        outcome: 'INCIDENT_FILED',
        events: [
            { tMs: 0, kind: 'TOOL_CALL_REQUESTED', toolName: 'postgres_query', detail: 'Agent issues UPDATE reservations SET room = 412 WHERE id = R-901', severity: 'INFO' },
            { tMs: 180, kind: 'AUTHORITY_OBSERVED', packId: 'company-pack-hp', checkId: 'override-OV-12', detail: 'Per-agent override OV-12 allows DB writes (relaxed from BLOCK by manager-alice 2026-05-10)', severity: 'NOTICE' },
            { tMs: 240, kind: 'VERDICT_ALLOW', detail: 'Action allowed under override OV-12', severity: 'INFO' },
            { tMs: 300, kind: 'STATE_CHANGED', detail: 'Booking R-901 moved to room 412', severity: 'INFO' },
            { tMs: 1_900, kind: 'AUDIT_RECORDED', detail: 'Post-tool-use audit: room 412 also booked by R-877 (double-allocation)', severity: 'CRITICAL' },
            { tMs: 4_100, kind: 'AUDIT_RECORDED', detail: 'Incident INC-0014 filed. Bound to override OV-12 + reservation IDs R-901, R-877.', severity: 'CRITICAL' },
        ],
    },
];
export function listReplaySequences(filter) {
    return filter?.vertical
        ? REPLAY_SEQUENCES.filter((s) => s.vertical === filter.vertical)
        : [...REPLAY_SEQUENCES];
}
export function getReplaySequence(id) {
    return REPLAY_SEQUENCES.find((s) => s.id === id);
}
//# sourceMappingURL=sandbox-replay.js.map