"use strict";
/**
 * Company-Pack Builder — assembles a CompliancePackWithClassifiers from a list of
 * declarative capability-class rules.
 *
 * Customer-facing surface: a company pack is just a list of rules of the form
 *   { capability: 'capability:mcp', action: 'BLOCK' }
 * which compile into the lower-level pack/categoryActions/categoryClassifiers
 * shapes the PackEvaluator already understands.
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-CAPABILITY-CLASS-RULES + F-NEW-PRODUCT-COMPANY-PACK-CLASS
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildCompanyPack = buildCompanyPack;
const capability_classes_js_1 = require("./capability-classes.js");
/**
 * Build a CompliancePackWithClassifiers from a list of capability rules.
 *
 * The resulting pack is marked `authority: 'org-custom'` so it can be filtered
 * out of regulatory reporting, but it flows through the same evaluator path as
 * regulatory packs and produces the same ALLOW / DENY / PENDING verdicts.
 */
function buildCompanyPack(input) {
    const categoryActions = {};
    const categoryClassifiers = {};
    for (const rule of input.rules) {
        const detector = capability_classes_js_1.CAPABILITY_DETECTORS[rule.capability];
        if (!detector) {
            throw new Error(`buildCompanyPack: unknown capability class '${rule.capability}'. ` +
                `Known classes: ${Object.keys(capability_classes_js_1.CAPABILITY_DETECTORS).join(', ')}.`);
        }
        categoryActions[rule.capability] = rule.action;
        categoryClassifiers[rule.capability] = {
            classifier: detector,
            references: [
                `F-NEW-PRODUCT-CAPABILITY-CLASS-RULES`,
                `company-pack:${input.id}`,
                ...(rule.note ? [`note:${rule.note}`] : []),
            ],
        };
    }
    const base = {
        id: input.id,
        name: input.name,
        version: input.version ?? '1.0.0',
        description: input.description ?? `Company pack for ${input.orgId}`,
        authority: 'org-custom',
        industries: [],
        requiredModules: [],
        moduleConfig: {},
        providerPolicy: { blockedProviders: [], requiredCapabilities: [], blockReasons: {} },
        dataPolicy: {
            scanCategories: Object.keys(categoryActions),
            categoryActions,
            encryptionRequired: false,
        },
        retentionPolicy: {
            auditLogRetentionDays: 90,
            sessionRetentionDays: 30,
            incidentRetentionDays: 365,
            reference: 'org-custom',
        },
        incidentPolicy: {
            notificationDeadlineHours: 0,
            reference: 'org-custom',
            requiredRecipients: [],
            formalNotificationRequired: false,
        },
        validators: [],
        requiresActionIsolation: input.isolation ?? undefined,
    };
    return { ...base, categoryClassifiers };
}
//# sourceMappingURL=company-pack-builder.js.map