"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveValidationExplanation = resolveValidationExplanation;
const architectureValidation_1 = require("./architectureValidation");
function buildWhyItMattersText(metadata) {
    switch (metadata.category) {
        case 'architecture':
            return 'This rule helps ensure the project structure matches the intended architectural style. Structural drift makes systems harder to understand, evolve, and operate.';
        case 'api':
            return 'This rule helps keep API contracts and endpoints explicit and discoverable. Missing or outdated API definitions can cause integration drift and unclear service boundaries.';
        case 'dependency':
            return 'This rule helps enforce module dependency boundaries so that teams can evolve modules independently and avoid hidden architectural coupling.';
        case 'database':
            return 'This rule helps enforce database conventions that are important for data isolation, consistency, and maintainability over time.';
        case 'documentation':
            return 'This rule helps ensure that important architecture decisions and behaviors are explicitly documented so the system remains understandable to future maintainers.';
        case 'security':
            return 'This rule helps surface security-related checks so that access control, data protection, and defenses remain aligned with the architecture.';
        default:
            return 'This rule helps keep the architecture and implementation aligned in a way that is easier to reason about and maintain.';
    }
}
function buildDefaultDocumentationHint(metadata) {
    switch (metadata.category) {
        case 'dependency':
            return '.archpilot/dependency-rules.json and .archpilot/contracts/<module>.contract.json';
        case 'architecture':
            return '.archpilot/architecture.json and docs/architecture/overview.md';
        case 'api':
            return 'contracts/openapi.yaml';
        case 'database':
            return 'db/sql/001_init.sql and architecture ADRs';
        case 'documentation':
            return 'docs/architecture/overview.md and docs/adrs/';
        case 'security':
            return 'architecture overview, ADRs, and module contracts';
        default:
            return 'docs/architecture/overview.md';
    }
}
function buildDefaultExample(metadata) {
    if (metadata.id === 'AP-DEP-004') {
        return `{
  "module": "billing",
  "dependsOn": ["inventory"]
}`;
    }
    if (metadata.id === 'AP-DEP-005') {
        return `import { listInventory } from '../inventory/public';`;
    }
    if (metadata.id === 'AP-ARCH-001') {
        return `src/modules/
  auth/
  billing/
  inventory/`;
    }
    return `Follow the recommended fix and update the nearest architecture artifact first, then update implementation code to match.`;
}
function resolveValidationExplanation(ruleId) {
    const metadata = (0, architectureValidation_1.getValidationRuleMetadataById)(ruleId);
    return {
        explanation: metadata.explanation ?? metadata.description,
        whyItMatters: metadata.whyItMatters ?? buildWhyItMattersText(metadata),
        howToFix: metadata.howToFix ?? metadata.recommendedFix,
        exampleFix: metadata.exampleFix ?? buildDefaultExample(metadata),
        documentationHint: metadata.documentationHint ?? buildDefaultDocumentationHint(metadata),
    };
}
//# sourceMappingURL=validationRuleExplanations.js.map