"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRACE_LINK_HIERARCHY_RULES = exports.TRACE_LINK_RESOLUTION_RULES = exports.TRACE_LINK_TRAVERSAL_BOUNDARIES = exports.TRACEABLE_ARTIFACT_COVERAGE = void 0;
const cli_constants_1 = require("../config/cli-constants");
exports.TRACEABLE_ARTIFACT_COVERAGE = [
    {
        family: "specification",
        artifactType: "specification",
        traceFields: [
            {
                field: "source.ref",
                source: "front-matter",
                requirement: "required",
                valueShape: "source-reference",
                relationship: "specification-to-source",
                notes: "Markdown sources resolve as repository-local paths; declared message sources remain supported non-local provenance without remote availability checks."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions"
        ]
    },
    {
        family: "spec_index_entry",
        traceFields: [
            {
                field: "spec_path",
                source: "spec-index-entry",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "spec-index-entry-to-specification",
                notes: `Repository-relative specification path from ${cli_constants_1.CLI_SPEC_INDEX_PATH}.`
            },
            {
                field: "source.ref",
                source: "spec-index-entry",
                requirement: "required",
                valueShape: "source-reference",
                relationship: "spec-index-entry-to-source",
                notes: "Source reference is explicit index metadata: Markdown sources resolve locally, while declared message sources remain supported non-local provenance."
            },
            {
                field: "linked_slice.path",
                source: "spec-index-entry",
                requirement: "optional",
                valueShape: "single-local-path",
                relationship: "spec-index-entry-to-slice-overview",
                notes: "Missing linked_slice metadata is not a broken local trace link."
            }
        ],
        unsupportedReferences: [
            "legacy linked_slice.id without an explicit path",
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions"
        ]
    },
    {
        family: "slice_overview",
        artifactType: "slice_overview",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "slice-overview-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "body.Navigation",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "slice-overview-navigation-links",
                materializationPolicy: "markdown-link",
                notes: "Visible navigation references can be materialized as Markdown links without changing front matter metadata."
            },
            {
                field: "body.Phases",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "slice-overview-to-phase-overviews",
                materializationPolicy: "markdown-link",
                notes: "Declared phase slugs are local child-planning evidence and can be materialized to canonical phase overview links."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions"
        ]
    },
    {
        family: "phase_overview",
        artifactType: "phase_overview",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "phase-overview-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "upstream.slice_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "phase-overview-to-slice-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "body.Navigation",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "phase-overview-navigation-links",
                materializationPolicy: "markdown-link",
                notes: "Visible parent navigation references can be materialized as Markdown links without changing front matter metadata."
            },
            {
                field: "body.Milestones",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "phase-overview-to-milestone-overviews",
                materializationPolicy: "markdown-link",
                notes: "Declared milestone slugs are local child-planning evidence and can be materialized to canonical milestone overview links."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions"
        ]
    },
    {
        family: "milestone_overview",
        artifactType: "milestone_overview",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "milestone-overview-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "upstream.slice_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "milestone-overview-to-slice-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.phase_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "milestone-overview-to-phase-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "body.Navigation",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "milestone-overview-navigation-links",
                materializationPolicy: "markdown-link",
                notes: "Visible parent navigation references can be materialized as Markdown links without changing front matter metadata."
            },
            {
                field: "body.Tasks",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "milestone-overview-to-task-definitions",
                materializationPolicy: "markdown-link",
                notes: "Declared task slugs are local child-planning evidence and can be materialized to canonical task definition links."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions"
        ]
    },
    {
        family: "task_definition",
        artifactType: "task_definition",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "task-definition-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "upstream.slice_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "task-definition-to-slice-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.work_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "task-definition-to-work-overview",
                notes: "Canonical Structured parent overview link; workflow-level applicability is resolved during discovery."
            },
            {
                field: "upstream.phase_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "task-definition-to-phase-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.milestone_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "task-definition-to-milestone-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "body.Navigation",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "task-definition-navigation-links",
                materializationPolicy: "markdown-link",
                notes: "Visible parent navigation references can be materialized as Markdown links without changing front matter metadata."
            },
            {
                field: "body.Upstream Context",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "task-definition-review-evidence",
                materializationPolicy: "markdown-link",
                notes: "Intentionally cited source artifacts support review evidence but missing optional body citations are not broken-link findings."
            },
            {
                field: "body.Implementation Target Paths",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "task-definition-target-path-evidence",
                materializationPolicy: "plain-path",
                missingTargetPolicy: "planned-target",
                notes: "Implementation target paths are planned local evidence, remain plain path declarations, and are never materialized as Markdown links."
            },
            {
                field: "body.Dependencies",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "task-definition-dependency-evidence",
                materializationPolicy: "plain-path",
                missingTargetPolicy: "required",
                notes: "Artifact dependency bullets are review evidence and remain plain repository-relative path bullets; do not materialize this field to Markdown links."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions outside explicit evidence sections"
        ]
    },
    {
        family: "implementation_summary",
        artifactType: "implementation_summary",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "implementation-summary-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "upstream.slice_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "implementation-summary-to-slice-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.work_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "implementation-summary-to-work-overview",
                notes: "Canonical Structured parent overview link; workflow-level applicability is resolved during discovery."
            },
            {
                field: "upstream.phase_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "implementation-summary-to-phase-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.milestone_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "implementation-summary-to-milestone-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.task_definition",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "implementation-summary-to-task-definition",
                notes: "Explicit paired task link."
            },
            {
                field: "body.Changed Paths",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "implementation-summary-changed-path-evidence",
                materializationPolicy: "plain-path",
                notes: "Changed-path evidence is review evidence and does not widen required trace coverage; keep entries as plain repository-relative path bullets."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions outside explicit evidence sections"
        ]
    },
    {
        family: "reconciliation",
        artifactType: "reconciliation",
        traceFields: [
            {
                field: "upstream.specs",
                source: "front-matter",
                requirement: "required",
                valueShape: "multi-spec-list",
                relationship: "reconciliation-to-specifications",
                notes: "Preserves the multi-spec shape; do not collapse into one inferred source reference."
            },
            {
                field: "upstream.slice_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "reconciliation-to-slice-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.phase_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "reconciliation-to-phase-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "upstream.milestone_overview",
                source: "front-matter",
                requirement: "required",
                valueShape: "single-local-path",
                relationship: "reconciliation-to-milestone-overview",
                notes: "Explicit parent overview link."
            },
            {
                field: "body.Completed Task Summaries",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "reconciliation-to-implementation-summary-evidence",
                materializationPolicy: "markdown-link",
                notes: "Milestone rollup citations are evidence-only until later resolver work classifies them further."
            },
            {
                field: "body.Acceptance Criteria Review",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "reconciliation-to-acceptance-criteria-evidence",
                materializationPolicy: "markdown-link",
                notes: "Acceptance criteria review citations are local evidence available for review and can be materialized without changing reconciliation status."
            },
            {
                field: "body.Validation Review",
                source: "body-section",
                requirement: "evidence-only",
                valueShape: "body-reference-list",
                relationship: "reconciliation-to-validation-evidence",
                materializationPolicy: "markdown-link",
                notes: "Validation review citations are local evidence available for review and can be materialized without changing validation outcomes."
            }
        ],
        unsupportedReferences: [
            "external URLs",
            "remote provider availability",
            "package registry identifiers",
            "free-form prose mentions outside explicit evidence sections"
        ]
    }
];
exports.TRACE_LINK_TRAVERSAL_BOUNDARIES = [
    ".day-shift/specs",
    cli_constants_1.CLI_SPEC_INDEX_PATH,
    ".day-shift/planning",
    "src",
    "tests",
    "tests_v2",
    "."
];
exports.TRACE_LINK_RESOLUTION_RULES = [
    {
        status: "resolved-non-local-source",
        meaning: "The value is declared supported non-local source provenance, such as a source.type message reference, and does not require local path resolution.",
        localOnly: false,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: false,
        authorizesRepair: false
    },
    {
        status: "malformed-local-link",
        meaning: "The value is intended to be local but fails the shared repository-relative path parser, including empty, absolute, or '..' traversal values.",
        localOnly: true,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: false,
        authorizesRepair: false
    },
    {
        status: "planned-local-target",
        meaning: "The value is a well-formed repository-relative implementation target that is intentionally absent before implementation.",
        localOnly: true,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: true,
        authorizesRepair: false
    },
    {
        status: "missing-local-target",
        meaning: "The value is a well-formed repository-relative path inside the local repository, but the target file does not exist.",
        localOnly: true,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: true,
        authorizesRepair: false
    },
    {
        status: "unsupported-external-reference",
        meaning: "The value is external or remote-provider-like and is outside local links-check coverage.",
        localOnly: false,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: false,
        authorizesRepair: false
    },
    {
        status: "outside-traversal-boundary",
        meaning: "The value is a well-formed repository-relative path, but it is outside caller-provided local trace traversal roots.",
        localOnly: true,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: true,
        authorizesRepair: false
    },
    {
        status: "resolved-local-target",
        meaning: "The value is a well-formed repository-relative path inside the local repository and the target exists locally.",
        localOnly: true,
        storesOriginalValue: true,
        usesNormalizedPathForComparison: true,
        authorizesRepair: false
    }
];
exports.TRACE_LINK_HIERARCHY_RULES = [
    {
        relationship: "phase-overview-to-slice-overview",
        sourceFamily: "phase_overview",
        sourceField: "upstream.slice_overview",
        targetFamily: "slice_overview",
        expectedTarget: "explicit-upstream-field",
        mismatchStatus: "hierarchy-mismatch",
        notes: "Compare the explicit parent link against the selected slice overview; do not infer a replacement from directory layout."
    },
    {
        relationship: "milestone-overview-to-phase-overview",
        sourceFamily: "milestone_overview",
        sourceField: "upstream.phase_overview",
        targetFamily: "phase_overview",
        expectedTarget: "explicit-upstream-field",
        mismatchStatus: "hierarchy-mismatch",
        notes: "Compare the explicit parent link against the selected phase overview; do not infer a replacement from directory layout."
    },
    {
        relationship: "task-definition-to-milestone-overview",
        sourceFamily: "task_definition",
        sourceField: "upstream.milestone_overview",
        targetFamily: "milestone_overview",
        expectedTarget: "explicit-upstream-field",
        mismatchStatus: "hierarchy-mismatch",
        notes: "Task hierarchy uses declared upstream metadata, not guessed path ancestry."
    },
    {
        relationship: "implementation-summary-to-task-definition",
        sourceFamily: "implementation_summary",
        sourceField: "upstream.task_definition",
        targetFamily: "task_definition",
        expectedTarget: "paired-artifact-path",
        mismatchStatus: "stale-link",
        notes: "Compare the explicit summary task link against the canonical paired task-definition path."
    },
    {
        relationship: "reconciliation-to-milestone-overview",
        sourceFamily: "reconciliation",
        sourceField: "upstream.milestone_overview",
        targetFamily: "milestone_overview",
        expectedTarget: "paired-artifact-path",
        mismatchStatus: "stale-link",
        notes: "Compare the explicit reconciliation parent link against the canonical paired milestone overview path."
    },
    {
        relationship: "spec-index-entry-to-specification",
        sourceFamily: "spec_index_entry",
        sourceField: "spec_path",
        targetFamily: "specification",
        expectedTarget: "spec-index-entry-path",
        mismatchStatus: "stale-link",
        notes: "Spec index entries compare explicit spec_path values to known spec artifacts without remote provider checks."
    }
];
