"use strict";
/**
 * RED-GREEN tests for F-NEW-PRODUCT-SANDBOX-REPLAY (W4.2).
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-SANDBOX-REPLAY
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const assert = __importStar(require("node:assert/strict"));
const sandbox_replay_1 = require("./sandbox-replay");
(0, node_test_1.describe)('F-NEW-PRODUCT-SANDBOX-REPLAY (W4.2)', () => {
    (0, node_test_1.it)('ships at least 8 replay sequences', () => {
        assert.ok(sandbox_replay_1.REPLAY_SEQUENCES.length >= 8);
    });
    (0, node_test_1.it)('every sequence has a unique id', () => {
        const ids = new Set(sandbox_replay_1.REPLAY_SEQUENCES.map((s) => s.id));
        assert.equal(ids.size, sandbox_replay_1.REPLAY_SEQUENCES.length);
    });
    (0, node_test_1.it)('every sequence has at least 3 events', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            assert.ok(seq.events.length >= 3, `${seq.id} has < 3 events`);
        }
    });
    (0, node_test_1.it)('events are time-ordered (non-decreasing tMs)', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            for (let i = 1; i < seq.events.length; i++) {
                assert.ok(seq.events[i].tMs >= seq.events[i - 1].tMs, `${seq.id} event ${i} tMs=${seq.events[i].tMs} < prev ${seq.events[i - 1].tMs}`);
            }
        }
    });
    (0, node_test_1.it)('last event tMs <= sequence durationMs', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            const lastT = seq.events[seq.events.length - 1].tMs;
            assert.ok(lastT <= seq.durationMs, `${seq.id} last event ${lastT} > duration ${seq.durationMs}`);
        }
    });
    (0, node_test_1.it)('every sequence starts with TOOL_CALL_REQUESTED', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            assert.equal(seq.events[0].kind, 'TOOL_CALL_REQUESTED', `${seq.id} should start with TOOL_CALL_REQUESTED`);
        }
    });
    (0, node_test_1.it)('outcome ACTION_BLOCKED sequences carry a VERDICT_DENY event', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            if (seq.outcome !== 'ACTION_BLOCKED')
                continue;
            const deny = seq.events.find((e) => e.kind === 'VERDICT_DENY');
            assert.ok(deny, `${seq.id} (ACTION_BLOCKED) is missing VERDICT_DENY`);
        }
    });
    (0, node_test_1.it)('outcome APPROVAL_REQUIRED sequences carry a VERDICT_PENDING_APPROVAL event', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            if (seq.outcome !== 'APPROVAL_REQUIRED')
                continue;
            const pending = seq.events.find((e) => e.kind === 'VERDICT_PENDING_APPROVAL');
            assert.ok(pending, `${seq.id} (APPROVAL_REQUIRED) is missing VERDICT_PENDING_APPROVAL`);
        }
    });
    (0, node_test_1.it)('outcome INCIDENT_FILED sequences carry a CRITICAL AUDIT_RECORDED', () => {
        for (const seq of sandbox_replay_1.REPLAY_SEQUENCES) {
            if (seq.outcome !== 'INCIDENT_FILED')
                continue;
            const incident = seq.events.find((e) => e.kind === 'AUDIT_RECORDED' && e.severity === 'CRITICAL');
            assert.ok(incident, `${seq.id} (INCIDENT_FILED) is missing a CRITICAL AUDIT_RECORDED`);
        }
    });
    (0, node_test_1.it)('listReplaySequences filters by vertical', () => {
        const hc = (0, sandbox_replay_1.listReplaySequences)({ vertical: 'healthcare' });
        assert.ok(hc.length >= 1);
        assert.ok(hc.every((s) => s.vertical === 'healthcare'));
    });
    (0, node_test_1.it)('getReplaySequence finds by id', () => {
        const first = sandbox_replay_1.REPLAY_SEQUENCES[0];
        const found = (0, sandbox_replay_1.getReplaySequence)(first.id);
        assert.equal(found?.id, first.id);
        assert.equal((0, sandbox_replay_1.getReplaySequence)('does-not-exist'), undefined);
    });
    (0, node_test_1.it)('covers at least 5 distinct outcomes / verticals between them', () => {
        const verticals = new Set(sandbox_replay_1.REPLAY_SEQUENCES.map((s) => s.vertical));
        const outcomes = new Set(sandbox_replay_1.REPLAY_SEQUENCES.map((s) => s.outcome));
        assert.ok(verticals.size >= 5);
        assert.ok(outcomes.size >= 3);
    });
});
//# sourceMappingURL=sandbox-replay.test.js.map