"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALIDATION_READ_ONLY_FAILURE_CONTRACT = void 0;
exports.getValidationReadOnlyFailureContract = getValidationReadOnlyFailureContract;
const VALIDATION_READ_ONLY_FAILURE_CATEGORIES = [
    {
        id: "invalid-command-input-usage",
        reportKind: "usage-error",
        commandSurfaces: ["rollup", "links-check"],
        severity: null,
        blockingReason: null,
        advisoryReason: null,
        commandEvidenceCategory: null,
        mapsToTraceLinkFindingIds: [],
        recoveryGuidance: "Correct the unsupported option, malformed option value, contradictory input, or unsafe artifact argument before rerunning. Do not inspect guessed targets.",
        noWriteBoundary: "Usage failures stop before validation traversal and must not write files or infer replacement inputs."
    },
    {
        id: "malformed-artifact",
        reportKind: "blocking-finding",
        commandSurfaces: ["rollup", "links-check"],
        severity: "error",
        blockingReason: "invalid-command-input",
        advisoryReason: null,
        commandEvidenceCategory: "validation-rollup",
        mapsToTraceLinkFindingIds: [],
        recoveryGuidance: "Correct the malformed local artifact through a separate explicit write operation, then rerun the read-only report.",
        noWriteBoundary: "Read-only validation reports malformed artifacts as evidence and must not rewrite or normalize them."
    },
    {
        id: "unsupported-artifact-family",
        reportKind: "blocking-finding",
        commandSurfaces: ["rollup", "links-check"],
        severity: "error",
        blockingReason: "invalid-command-input",
        advisoryReason: null,
        commandEvidenceCategory: "validation-rollup",
        mapsToTraceLinkFindingIds: [],
        recoveryGuidance: "Choose a supported planning artifact family or add explicit follow-up planning before rerunning.",
        noWriteBoundary: "Unsupported artifact-family reports must not create replacement artifacts or coerce metadata families."
    },
    {
        id: "malformed-local-link",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "invalid-command-input",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_MALFORMED_LOCAL_VALUE"],
        recoveryGuidance: "Correct the malformed repository-relative trace value through a separate metadata update before rerunning.",
        noWriteBoundary: "Links-check must not normalize malformed local trace values or continue with guessed paths."
    },
    {
        id: "broken-required-trace-link",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "broken-traceability",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_REQUIRED_TARGET_MISSING"],
        recoveryGuidance: "Restore the required local target or update the explicit trace field through a separate authorized write operation.",
        noWriteBoundary: "Links-check must not repair links, synchronize metadata, or generate missing targets."
    },
    {
        id: "missing-required-trace-field",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "broken-traceability",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_REQUIRED_FIELD_MISSING"],
        recoveryGuidance: "Add the required trace field only through an explicit metadata update or correct the artifact family classification.",
        noWriteBoundary: "Links-check must not synthesize missing metadata fields."
    },
    {
        id: "stale-explicit-link",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "broken-traceability",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_STALE_EXPLICIT_LINK"],
        recoveryGuidance: "Review the stale explicit link and update it only through a separate authorized metadata operation.",
        noWriteBoundary: "Links-check must not rewrite parent references or apply partial fallback updates."
    },
    {
        id: "unsupported-reference",
        reportKind: "advisory-finding",
        commandSurfaces: ["links-check"],
        severity: "warning",
        blockingReason: null,
        advisoryReason: "impact-question",
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_UNSUPPORTED_REFERENCE"],
        recoveryGuidance: "Review whether the unsupported reference should remain evidence-only or become a supported local trace field later.",
        noWriteBoundary: "Unsupported external, remote-provider, package-registry, or prose references must not trigger fetching, repair, or metadata writes."
    },
    {
        id: "out-of-hierarchy-local-link",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "broken-traceability",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_OUT_OF_HIERARCHY"],
        recoveryGuidance: "Correct the explicit parent or paired-artifact link only through a separate authorized metadata update.",
        noWriteBoundary: "Links-check must not infer hierarchy repairs from directory layout."
    },
    {
        id: "outside-traversal-boundary",
        reportKind: "blocking-finding",
        commandSurfaces: ["links-check"],
        severity: "error",
        blockingReason: "invalid-command-input",
        advisoryReason: null,
        commandEvidenceCategory: "links-check",
        mapsToTraceLinkFindingIds: ["LINKS_MALFORMED_LOCAL_VALUE"],
        recoveryGuidance: "Constrain trace-link inputs to supported local traversal roots before rerunning.",
        noWriteBoundary: "Outside-boundary paths must not be followed, fetched, moved, or rewritten."
    },
    {
        id: "attempted-write-boundary-violation",
        reportKind: "blocking-finding",
        commandSurfaces: ["rollup", "links-check"],
        severity: "error",
        blockingReason: "unsafe-scope-mismatch",
        advisoryReason: null,
        commandEvidenceCategory: "validation-rollup",
        mapsToTraceLinkFindingIds: [],
        recoveryGuidance: "Route repair, metadata synchronization, checkpoint writes, status updates, or artifact generation through explicit write-capable commands.",
        noWriteBoundary: "Read-only rollup and links-check surfaces must not repair, synchronize metadata, write checkpoints, update status, generate artifacts, stage files, or apply partial-write fallbacks."
    }
];
const VALIDATION_READ_ONLY_EXIT_BEHAVIORS = [
    {
        id: "usage-failure",
        runtimeExitCode: "USAGE",
        writesAllowed: false,
        description: "Invalid command inputs fail before guessed target inspection and before validation findings are emitted."
    },
    {
        id: "report-with-blocking-findings",
        runtimeExitCode: "ERROR",
        writesAllowed: false,
        description: "Read-only validation completes evidence collection and reports one or more error-level blocking findings."
    },
    {
        id: "report-with-advisory-findings",
        runtimeExitCode: "SUCCESS",
        writesAllowed: false,
        description: "Read-only validation completes and reports warning or informational findings that require review but do not authorize writes."
    },
    {
        id: "report-with-no-findings",
        runtimeExitCode: "SUCCESS",
        writesAllowed: false,
        description: "Read-only validation completes with no findings and no write side effects."
    }
];
exports.VALIDATION_READ_ONLY_FAILURE_CONTRACT = {
    invalidInputsUseUsageErrors: true,
    validationReportsUseSharedFindings: true,
    noWriteBoundary: "Validation rollup and links-check commands are read-only: they must not repair links, synchronize metadata, write checkpoints, update status, generate planning artifacts, stage files, or continue with partial-write fallback behavior.",
    categories: VALIDATION_READ_ONLY_FAILURE_CATEGORIES,
    exitBehaviors: VALIDATION_READ_ONLY_EXIT_BEHAVIORS
};
function getValidationReadOnlyFailureContract() {
    return {
        ...exports.VALIDATION_READ_ONLY_FAILURE_CONTRACT,
        categories: exports.VALIDATION_READ_ONLY_FAILURE_CONTRACT.categories.map((category) => ({
            ...category,
            commandSurfaces: [...category.commandSurfaces],
            mapsToTraceLinkFindingIds: [...category.mapsToTraceLinkFindingIds]
        })),
        exitBehaviors: exports.VALIDATION_READ_ONLY_FAILURE_CONTRACT.exitBehaviors.map((behavior) => ({ ...behavior }))
    };
}
