/**
 * 语言策略契约 — 问题四十八 (Language Policy Contract)。
 *
 * 核心规则:
 * - 用户可见语义中文优先
 * - 机器字段、event key、API field、enum、contract id 保持英文稳定
 * - stderr/logger 不得替代 UserFeedbackMessage / status / tool return
 * - 用户必须能看到 SoloForge 是否触发、route、缺失输入、降级、阻断、下一步
 */
const SOLOFORGE_CORE_RULES = [
    // 中文优先领域
    { rule_id: "lp-user-feedback-zh", domain: "user_feedback", required_language: "zh_priority",
        description_zh: "UserFeedbackMessage 的 blocked/degraded/manual_required/completed 必须中文语义优先" },
    { rule_id: "lp-log-message-zh", domain: "log_message", required_language: "zh_priority",
        description_zh: "console.error 的 message 字段必须中文" },
    { rule_id: "lp-diagnostic-zh", domain: "diagnostic_message", required_language: "zh_priority",
        description_zh: "诊断码的 title_zh、user_message_zh、recovery_hint_zh 必须非空" },
    { rule_id: "lp-status-report-zh", domain: "status_report", required_language: "zh_priority",
        description_zh: "soloforge status 输出必须中文语义优先" },
    { rule_id: "lp-doc-comment-zh", domain: "doc_comment", required_language: "zh_priority",
        description_zh: "关键机制类、适配器类必须有中文 doc 注释" },
    { rule_id: "lp-code-comment-zh", domain: "code_comment", required_language: "zh_priority",
        description_zh: "关键治理判断、状态流转、异常处理必须有中文行注释" },
    // 英文稳定领域
    { rule_id: "lp-api-field-en", domain: "api_field", required_language: "en_stable",
        description_zh: "API 字段、DB 字段保持英文稳定，不得强制翻译" },
    { rule_id: "lp-event-key-en", domain: "event_key", required_language: "en_stable",
        description_zh: "event key、route、status、duration_ms 保持英文" },
    { rule_id: "lp-enum-value-en", domain: "enum_value", required_language: "en_stable",
        description_zh: "枚举值、代码标识符保持英文稳定" },
];
/**
 * 获取 SoloForge 核心语言规则。
 */
export function getCoreLanguageRules() {
    return [...SOLOFORGE_CORE_RULES];
}
/**
 * 评估语言策略合规性。
 */
export function evaluateLanguagePolicy(scope, checks, overrideEvidence) {
    const findings = [];
    for (const check of checks) {
        if (!check.passed) {
            const rule = SOLOFORGE_CORE_RULES.find((r) => r.rule_id === check.rule_id);
            findings.push({
                rule_id: check.rule_id,
                severity: rule?.required_language === "en_stable" ? "warning" : "advisory",
                location: check.location,
                message_zh: `语言策略违规: ${rule?.description_zh ?? check.rule_id}`,
                detail: check.detail,
            });
        }
    }
    const violations = findings.length;
    const compliant = checks.length - violations;
    let status;
    if (overrideEvidence) {
        status = "override";
    }
    else if (violations > 0) {
        status = "violation";
    }
    else {
        status = "compliant";
    }
    return {
        evaluated_at: new Date().toISOString(),
        scope,
        findings,
        total_checked: checks.length,
        violations,
        compliant,
        status,
        override_evidence: overrideEvidence,
    };
}
//# sourceMappingURL=language_policy_contract.js.map