// --- SPEC-043: Hypermedia FICHA-TECNICA section ---
/**
 * Generate backend-first/hypermedia-specific fields for FICHA-TECNICA.
 */
export function getHypermediaFichaTecnicaSection(knowledge) {
    if (!knowledge) {
        return [];
    }
    const rendering = knowledge.rendering;
    if (rendering !== 'server-side') {
        return [];
    }
    const hypermediaFw = knowledge.hypermediaFramework;
    const templateEngine = knowledge.templateEngine;
    const jsComplement = knowledge.jsComplement;
    const fwLabel = hypermediaFw && hypermediaFw !== 'none' ? hypermediaFw : 'None (pure SSR)';
    const jsLabel = jsComplement && jsComplement !== 'none' ? jsComplement : 'None (no client JS)';
    const templateLabel = templateEngine ?? 'Not detected';
    return [
        '## Backend-First / Hypermedia Profile',
        '',
        '| Field | Value |',
        '|-------|-------|',
        `| Rendering | Server-Side |`,
        `| Hypermedia Framework | ${fwLabel} |`,
        `| Template Engine | ${templateLabel} |`,
        `| JS Complement | ${jsLabel} |`,
        `| Build Tooling | None required |`,
        `| Testing Strategy | Integration over Unit (HTTP + HTML assertions) |`,
        '',
    ];
}
// --- Constitution compliance ---
const ACTION_VERB_BLOCKLIST = new Set([
    'commit',
    'write',
    'delete',
    'read',
    'create',
    'update',
    'export',
    'import',
    'store',
    'send',
    'push',
    'pull',
    'sync',
    'check',
    'validate',
    'verify',
]);
const MIN_KEYWORD_LENGTH = 8;
function extractForbiddenKeywords(principle) {
    const lower = principle.toLowerCase();
    const match = /(?:never|must not|do not)\s+(.+?)(?:\.|$)/i.exec(lower);
    if (!match?.[1]) {
        return [];
    }
    return match[1]
        .split(/\s+/)
        .filter((w) => w.length >= MIN_KEYWORD_LENGTH && !ACTION_VERB_BLOCKLIST.has(w))
        .slice(0, 3);
}
export function checkConstitutionCompliance(title, tags, principles) {
    const content = `${title} ${tags.join(' ')}`.toLowerCase();
    const violations = [];
    for (const p of principles) {
        const keywords = extractForbiddenKeywords(p.principle);
        if (keywords.length > 0 && keywords.some((kw) => content.includes(kw))) {
            violations.push({
                principleId: p.id,
                description: `Spec may violate principle: "${p.principle}"`,
                severity: p.enforceLevel === 'strict' ? 'error' : 'warning',
            });
        }
    }
    return violations;
}
//# sourceMappingURL=constitution.js.map