/**
 * 发布问题场景注册表 — 注册函数和执行器
 */
import fs from "node:fs";
import path from "node:path";
import { ARCHITECTURE_WORKSHOP_SCENARIOS } from "./scenarios_architecture_workshop.js";
import { DECISION_WORKSHOP_SCENARIOS } from "./scenarios_decision_workshop.js";
import { DESIGN_PACK_SCENARIOS } from "./scenarios_design_pack.js";
import { TEMPLATE_CONTRACT_SCENARIOS } from "./scenarios_template_contract.js";
import { TEMPLATE_VISIBILITY_SCENARIOS } from "./scenarios_template_visibility.js";
import { CODE_OBSERVABILITY_SCENARIOS } from "./scenarios_code_observability.js";
import { WORKFLOW_NAVIGATION_SCENARIOS } from "./scenarios_workflow_navigation.js";
import { errorMessage } from "../../core/helpers.js";
const RELEASE_ISSUE_SCENARIOS = [
    ...ARCHITECTURE_WORKSHOP_SCENARIOS,
    ...DECISION_WORKSHOP_SCENARIOS,
    ...DESIGN_PACK_SCENARIOS,
    ...TEMPLATE_CONTRACT_SCENARIOS,
    ...TEMPLATE_VISIBILITY_SCENARIOS,
    ...CODE_OBSERVABILITY_SCENARIOS,
    ...WORKFLOW_NAVIGATION_SCENARIOS,
];
/** 获取全量场景定义 */
export function getReleaseIssueScenarios() {
    return RELEASE_ISSUE_SCENARIOS;
}
/**
 * 验证 发布问题场景覆盖:
 * - 所有场景必须有 runner + production_entrypoint + expected_outcome
 * - 所有引用测试文件的场景: 测试文件必须存在
 * - 返回结构化验证结果
 */
export function validateReleaseIssueScenarios(rootDir) {
    const missing_tests = [];
    const missing_runners = [];
    const missing_entrypoints = [];
    const tautology_suspects = [];
    for (const scenario of RELEASE_ISSUE_SCENARIOS) {
        if (!scenario.runner) {
            missing_runners.push(scenario.scenario_id);
        }
        if (!scenario.production_entrypoint) {
            missing_entrypoints.push(scenario.scenario_id);
        }
        if (!scenario.expected_outcome) {
            missing_entrypoints.push(`${scenario.scenario_id}: missing expected_outcome`);
        }
        for (const testFile of scenario.test_files) {
            const fullPath = path.join(rootDir, testFile);
            if (!fs.existsSync(fullPath)) {
                missing_tests.push(`${scenario.scenario_id}: ${testFile}`);
            }
        }
    }
    return {
        valid: missing_tests.length === 0 && missing_runners.length === 0 && missing_entrypoints.length === 0,
        missing_tests,
        missing_runners,
        missing_entrypoints,
        tautology_suspects,
        scenario_count: RELEASE_ISSUE_SCENARIOS.length,
    };
}
/**
 * 运行所有场景，收集执行证据。
 * 每个场景必须有 runner，无 runner 视为 fail。
 */
export async function executeReleaseIssueScenarios() {
    const results = [];
    for (const scenario of RELEASE_ISSUE_SCENARIOS) {
        const start = Date.now();
        try {
            const result = await scenario.runner();
            result.duration_ms = Date.now() - start;
            results.push(result);
        }
        catch (e) {
            results.push({ scenario_id: scenario.scenario_id, status: "fail", error: errorMessage(e), duration_ms: Date.now() - start });
        }
    }
    return results;
}
//# sourceMappingURL=registry.js.map