"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.reviewPhasePlanning = reviewPhasePlanning;
exports.buildPhaseReviewMetadataProjection = buildPhaseReviewMetadataProjection;
exports.computePhaseReviewReceiptId = computePhaseReviewReceiptId;
exports.revisionOfRepositoryFile = revisionOfRepositoryFile;
exports.requirePhaseReviewTimestamp = requirePhaseReviewTimestamp;
exports.buildAdministrativeStatusDriftFindings = buildAdministrativeStatusDriftFindings;
exports.buildPhaseEvidenceLanes = buildPhaseEvidenceLanes;
exports.resolutionHistorySuppressesIssue = resolutionHistorySuppressesIssue;
const node_crypto_1 = require("node:crypto");
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const errors_1 = require("../../errors");
const lifecycle_run_context_1 = require("../../lifecycle-run-context");
const output_1 = require("../../output");
const authoring_policy_1 = require("../authoring-policy");
const implementation_summary_reconciliation_1 = require("../implementation-summary-reconciliation");
const milestone_generation_1 = require("../milestone-generation");
const phase_scaffold_migration_1 = require("../phase-scaffold-migration");
const mode_balance_1 = require("../mode-balance");
const planning_document_utils_1 = require("../planning-document-utils");
const reconciliation_resolution_1 = require("../reconciliation-resolution");
const child_drift_1 = require("./child-drift");
const contracts_1 = require("./contracts");
const documentation_loop_1 = require("./documentation-loop");
const lifecycle_evidence_1 = require("./lifecycle-evidence");
const rendering_1 = require("./rendering");
const task_lifecycle_timestamps_1 = require("../task-lifecycle-timestamps");
function reviewPhasePlanning(repositoryRoot, options) {
    const metadataPosture = (0, lifecycle_run_context_1.parseLifecycleMetadataPosture)(options.metadataPosture ?? 'read-only');
    const reviewedAt = requirePhaseReviewTimestamp(options.reviewedAt ?? new Date().toISOString());
    const phaseOverviewPath = (0, lifecycle_evidence_1.resolveRepositoryPath)(repositoryRoot, options.phaseOverviewPath, 'phase-overview');
    const phaseDocument = (0, lifecycle_evidence_1.readRequiredDocument)(phaseOverviewPath.absolute, phaseOverviewPath.relative, 'phase_overview');
    const phaseStatus = (0, planning_document_utils_1.readTopLevelField)(phaseDocument.frontMatterLines, 'status')?.trim() ?? null;
    const milestoneOverviewPaths = (0, documentation_loop_1.collectMilestoneOverviewPaths)(repositoryRoot, phaseOverviewPath.relative);
    const declaredMilestoneSlugs = (0, child_drift_1.parseDeclaredChildSlugs)(phaseDocument.sections.get('Milestones'));
    const observedMilestoneSlugs = milestoneOverviewPaths.map((overviewPath) => node_path_1.default.basename(node_path_1.default.dirname(overviewPath)));
    const milestoneStates = milestoneOverviewPaths.map((overviewPath) => {
        return (0, child_drift_1.readMilestoneArtifactState)(repositoryRoot, overviewPath);
    });
    const reconciledMilestonePaths = milestoneStates
        .filter((state) => state.reconciliationPath !== null)
        .map((state) => state.overviewPath);
    const reviewMode = options.reviewMode === 'readiness'
        ? 'readiness'
        : reconciledMilestonePaths.length > 0 ? 'evidence' : 'readiness';
    const phaseAuthoringInspection = reviewMode === 'readiness'
        ? (0, milestone_generation_1.inspectPhaseMilestoneAuthoringReadiness)(repositoryRoot, {
            phaseOverviewPath: phaseOverviewPath.relative,
        })
        : null;
    const blockingIssues = [];
    const warnings = [];
    const metadataHygieneFollowUps = [];
    const reconciliationEvidence = [];
    const eligibleMilestoneMetadataPaths = new Set();
    const resolutionHistory = (0, reconciliation_resolution_1.reviewReconciliationResolutionHistory)(repositoryRoot, milestoneStates.flatMap((state) => state.reconciliationPath === null ? [] : [state.reconciliationPath]));
    warnings.push(...(0, authoring_policy_1.formatPlanningAuthoringIssues)((0, authoring_policy_1.auditPlanningArtifactAuthoring)({
        artifactPath: phaseOverviewPath.relative,
        artifactType: 'phase_overview',
        markdownText: phaseDocument.rawText,
        allowLegacyManualAlias: true,
        allowMissingProvenance: true,
    })));
    warnings.push(...(0, authoring_policy_1.formatParentDecompositionIssues)((0, authoring_policy_1.auditParentDecomposition)({
        artifactPath: phaseOverviewPath.relative,
        markdownText: phaseDocument.rawText,
        childKind: 'milestone',
        declaredChildSlugs: declaredMilestoneSlugs,
    })));
    const modeBalanceEvaluations = milestoneOverviewPaths.map((milestoneOverviewPath) => {
        return (0, mode_balance_1.evaluateMilestoneModeBalance)(repositoryRoot, {
            milestoneOverviewPath,
            requireBreakoutForCloseout: true,
        });
    });
    if (reviewMode === 'readiness') {
        (0, lifecycle_evidence_1.collectReadinessSectionIssues)(phaseDocument, phaseOverviewPath.relative, contracts_1.PHASE_REQUIRED_SECTIONS, blockingIssues);
        (0, child_drift_1.collectPhaseChildDriftIssues)({
            repositoryRoot,
            phaseOverviewPath: phaseOverviewPath.relative,
            phaseStatus,
            declaredMilestoneSlugs,
            observedMilestoneSlugs,
            milestoneStates,
            blockingIssues,
            warnings,
            allowMissingDeclaredChildren: true,
        });
        const phaseAuthoringBlockingIssues = (phaseAuthoringInspection?.findings ?? []).map((finding) => `${finding.path ?? phaseOverviewPath.relative}: ${finding.message}`);
        for (const issue of phaseAuthoringBlockingIssues) {
            if (!blockingIssues.includes(issue))
                blockingIssues.push(issue);
        }
        for (const milestoneOverviewPath of milestoneOverviewPaths) {
            const milestoneDocument = (0, lifecycle_evidence_1.readRequiredDocument)(node_path_1.default.join(repositoryRoot, milestoneOverviewPath), milestoneOverviewPath, 'milestone_overview');
            const modeBalance = modeBalanceEvaluations.find((entry) => {
                return entry.milestoneOverviewPath === milestoneOverviewPath;
            });
            const declaredTaskSlugs = (0, child_drift_1.parseDeclaredChildSlugs)(milestoneDocument.sections.get('Tasks'));
            const issues = modeBalance.optedIn
                ? modeBalance.blockingIssues
                : [
                    ...(0, lifecycle_evidence_1.collectContractToRuntimeHandoffIssues)({
                        repositoryRoot,
                        milestoneOverviewPath,
                        declaredTaskSlugs,
                    }),
                    ...(0, documentation_loop_1.collectDocumentationLoopIssues)({
                        repositoryRoot,
                        milestoneOverviewPath,
                        milestoneDocument,
                        declaredTaskSlugs,
                    }),
                ];
            blockingIssues.push(...issues.map((issue) => `${milestoneOverviewPath}: ${issue}`));
        }
        const readinessReceiptWithoutId = {
            schemaVersion: 1,
            phaseOverviewPath: phaseOverviewPath.relative,
            metadataPosture,
            reviewedAt,
            reviewMode: 'readiness',
            blockerCount: blockingIssues.length,
            complete: false,
            metadataStatusTransitions: [],
            reconciliationEvidence: [],
            authorizes: [],
        };
        const readinessPhaseReviewReceipt = {
            ...readinessReceiptWithoutId,
            reviewId: computePhaseReviewReceiptId(readinessReceiptWithoutId),
        };
        const phaseAuthoringReceipt = (0, authoring_policy_1.createPhaseAuthoringReadinessReceipt)({
            phaseOverviewPath: phaseOverviewPath.relative,
            phaseRevision: phaseAuthoringInspection?.phaseRevision
                ?? revisionOfRepositoryFile(repositoryRoot, phaseOverviewPath.relative),
            reviewedAt,
            blockerCount: phaseAuthoringBlockingIssues.length,
            inspectionComplete: phaseAuthoringInspection?.complete === true,
            declaredMilestoneSlugs: phaseAuthoringInspection?.declaredMilestoneSlugs
                ?? declaredMilestoneSlugs,
            normalizedScaffoldEvidence: phaseAuthoringInspection?.normalizedScaffoldEvidence ?? [],
            contractImpactFingerprints: phaseAuthoringInspection?.contractImpactCoverage.tasks.map((task) => ({
                milestoneSlug: task.milestoneSlug,
                taskSlug: task.taskSlug,
                fingerprint: task.fingerprint,
            })) ?? [],
            materializedScaffoldRevisions: phaseAuthoringInspection?.materializedScaffoldRevisions ?? [],
        });
        const scaffoldMigration = inspectScaffoldMigrationAvailability(repositoryRoot, phaseOverviewPath.relative, phaseAuthoringInspection);
        const recoveryGuidance = (0, rendering_1.buildPlanningRecoveryGuidance)({
            repositoryRoot,
            artifactPath: phaseOverviewPath.relative,
            reviewKind: 'phase',
            blockingIssues,
            warnings,
            metadataHygieneFollowUps,
            modeBalanceEvaluations,
        });
        if (scaffoldMigration !== null) {
            recoveryGuidance.push(`Recognized legacy scaffold evidence can be migrated without a clean destination-schema review: ${scaffoldMigration.previewArgv.join(' ')}`);
        }
        return {
            reviewMode,
            metadataPosture,
            reviewedAt,
            phaseOverviewPath: phaseOverviewPath.relative,
            milestoneOverviewPaths,
            reconciledMilestonePaths: [],
            blockingIssues,
            phaseAuthoringBlockingIssues,
            warnings,
            metadataHygieneFollowUps,
            evidenceLanes: {
                liveWarnings: [],
                historicalResolved: [],
                acceptedResidual: [],
                metadataHygiene: [],
                administrativeStatusDrift: [],
            },
            administrativeStatusDrift: [],
            metadataStatusTransitions: [],
            reconciliationEvidence: [],
            phaseReviewReceipt: readinessPhaseReviewReceipt,
            phaseAuthoringReceipt,
            contractImpactCoverage: phaseAuthoringInspection?.contractImpactCoverage ?? null,
            materializedScaffoldPaths: phaseAuthoringInspection?.materializedScaffoldPaths ?? [],
            normalizedScaffoldEvidence: phaseAuthoringInspection?.normalizedScaffoldEvidence ?? [],
            scaffoldProjectionDrift: phaseAuthoringInspection?.scaffoldProjectionDrift ?? [],
            scaffoldMigration,
            modeBalanceEvaluations,
            recoveryGuidance,
            findings: (0, rendering_1.buildPlanningReviewFindings)({
                artifactPath: phaseOverviewPath.relative,
                reviewKind: 'phase',
                blockingIssues,
                warnings,
                metadataHygieneFollowUps,
            })
                .concat(phaseAuthoringInspection?.findings ?? [])
                .concat(buildAdministrativeStatusDriftFindings([])),
        };
    }
    if (milestoneOverviewPaths.length === 0) {
        blockingIssues.push('No milestone overview artifacts were found beneath this phase.');
    }
    (0, child_drift_1.collectPhaseChildDriftIssues)({
        repositoryRoot,
        phaseOverviewPath: phaseOverviewPath.relative,
        phaseStatus,
        declaredMilestoneSlugs,
        observedMilestoneSlugs,
        milestoneStates,
        blockingIssues,
        warnings,
    });
    if (reconciledMilestonePaths.length === 0) {
        blockingIssues.push('No milestone reconciliation artifacts were found for this phase.');
    }
    let allReviewedMilestonesCompleted = declaredMilestoneSlugs.length > 0
        && declaredMilestoneSlugs.every((slug) => observedMilestoneSlugs.includes(slug))
        && reconciledMilestonePaths.length > 0;
    for (const milestoneState of milestoneStates) {
        const modeBalance = modeBalanceEvaluations.find((entry) => {
            return entry.milestoneOverviewPath === milestoneState.overviewPath;
        });
        if (modeBalance.optedIn) {
            blockingIssues.push(...modeBalance.blockingIssues.map((issue) => {
                return `${milestoneState.overviewPath}: ${issue}`;
            }));
        }
        if (milestoneState.reconciliationPath === null) {
            reconciliationEvidence.push({
                milestoneOverviewPath: milestoneState.overviewPath,
                reconciliationPath: null,
                reconciliationRevision: null,
                completedNonPlaceholder: false,
            });
            warnings.push(`Milestone overview '${milestoneState.overviewPath}' does not have a paired reconciliation artifact yet.`);
            allReviewedMilestonesCompleted = false;
            continue;
        }
        const reconciliationResult = (0, implementation_summary_reconciliation_1.reviewReconciliation)(repositoryRoot, {
            milestoneOverviewPath: milestoneState.overviewPath,
        });
        const milestoneDocument = (0, lifecycle_evidence_1.readRequiredDocument)(node_path_1.default.join(repositoryRoot, milestoneState.overviewPath), milestoneState.overviewPath, 'milestone_overview');
        const declaredTaskSlugs = (0, child_drift_1.parseDeclaredChildSlugs)(milestoneDocument.sections.get('Tasks'));
        if (!modeBalance.optedIn) {
            blockingIssues.push(...(0, lifecycle_evidence_1.collectContractToRuntimeHandoffIssues)({
                repositoryRoot,
                milestoneOverviewPath: milestoneState.overviewPath,
                declaredTaskSlugs,
            }).map((issue) => {
                return `${milestoneState.overviewPath}: ${issue}`;
            }), ...(0, documentation_loop_1.collectDocumentationLoopIssues)({
                repositoryRoot,
                milestoneOverviewPath: milestoneState.overviewPath,
                milestoneDocument,
                declaredTaskSlugs,
            }).map((issue) => {
                return `${milestoneState.overviewPath}: ${issue}`;
            }));
        }
        const adjustedAlignmentIssues = reconciliationResult.alignmentIssues.filter((issue) => !resolutionHistorySuppressesIssue(resolutionHistory, milestoneState.reconciliationPath, issue));
        const adjustedReviewConcerns = reconciliationResult.reviewConcerns.filter((issue) => !resolutionHistorySuppressesIssue(resolutionHistory, milestoneState.reconciliationPath, issue));
        const resolutionAdjustedClosureSufficient = reconciliationResult.evidenceGaps.length === 0 &&
            reconciliationResult.placeholderResidue.length === 0 &&
            adjustedAlignmentIssues.length === 0 &&
            ((reconciliationResult.reconciliationStatus === 'ready_for_review' &&
                reconciliationResult.artifactStatus === 'active') ||
                (reconciliationResult.reconciliationStatus === 'completed' &&
                    reconciliationResult.artifactStatus === 'completed'));
        const completedNonPlaceholder = reconciliationResult.reconciliationStatus === 'completed'
            && reconciliationResult.artifactStatus === 'completed'
            && reconciliationResult.evidenceGaps.length === 0
            && reconciliationResult.placeholderResidue.length === 0
            && adjustedAlignmentIssues.length === 0;
        reconciliationEvidence.push({
            milestoneOverviewPath: milestoneState.overviewPath,
            reconciliationPath: milestoneState.reconciliationPath,
            reconciliationRevision: revisionOfRepositoryFile(repositoryRoot, milestoneState.reconciliationPath),
            completedNonPlaceholder,
        });
        if (completedNonPlaceholder) {
            eligibleMilestoneMetadataPaths.add(milestoneState.overviewPath);
        }
        if (!resolutionAdjustedClosureSufficient) {
            allReviewedMilestonesCompleted = false;
        }
        blockingIssues.push(...reconciliationResult.evidenceGaps.map((issue) => {
            return `${milestoneState.overviewPath}: ${issue}`;
        }), ...adjustedAlignmentIssues.map((issue) => {
            return `${milestoneState.overviewPath}: ${issue}`;
        }));
        warnings.push(...reconciliationResult.placeholderResidue.map((issue) => {
            return `${milestoneState.overviewPath}: ${issue}`;
        }), ...adjustedReviewConcerns.map((issue) => {
            return `${milestoneState.overviewPath}: ${issue}`;
        }));
        if (reconciliationResult.reconciliationStatus === 'completed' &&
            reconciliationResult.artifactStatus === 'completed' &&
            milestoneState.status !== 'completed') {
            metadataHygieneFollowUps.push(`Expected administrative status drift: milestone overview '${milestoneState.overviewPath}' remains '${milestoneState.status ?? '(missing)'}' after completed non-placeholder reconciliation evidence. Preview the phase-scoped transaction with metadata sync-status-from-review; phase review remains read-only.`);
        }
    }
    if (allReviewedMilestonesCompleted && phaseStatus !== 'completed') {
        metadataHygieneFollowUps.push(`Expected administrative status drift: phase overview '${phaseOverviewPath.relative}' remains '${phaseStatus ?? '(missing)'}' after every declared milestone has completed non-placeholder reconciliation evidence. Preview the phase-scoped transaction with metadata sync-status-from-review; phase review remains read-only.`);
    }
    warnings.push(...resolutionHistory.issues);
    const metadataProjection = buildPhaseReviewMetadataProjection({
        repositoryRoot,
        phaseOverviewPath: phaseOverviewPath.relative,
        phaseStatus,
        milestoneStates,
        metadataPosture,
        reviewedAt,
        reviewMode,
        blockingIssues,
        reconciliationEvidence,
        eligibleMilestoneMetadataPaths,
        phaseMetadataEligible: allReviewedMilestonesCompleted,
    });
    return {
        reviewMode,
        metadataPosture,
        reviewedAt,
        phaseOverviewPath: phaseOverviewPath.relative,
        milestoneOverviewPaths,
        reconciledMilestonePaths,
        blockingIssues,
        phaseAuthoringBlockingIssues: [],
        warnings,
        metadataHygieneFollowUps,
        evidenceLanes: buildPhaseEvidenceLanes(resolutionHistory, metadataHygieneFollowUps, metadataProjection.administrativeStatusDrift),
        administrativeStatusDrift: metadataProjection.administrativeStatusDrift,
        metadataStatusTransitions: metadataProjection.metadataStatusTransitions,
        reconciliationEvidence: metadataProjection.reconciliationEvidence,
        phaseReviewReceipt: metadataProjection.phaseReviewReceipt,
        phaseAuthoringReceipt: null,
        contractImpactCoverage: null,
        materializedScaffoldPaths: [],
        normalizedScaffoldEvidence: [],
        scaffoldProjectionDrift: [],
        scaffoldMigration: null,
        modeBalanceEvaluations,
        recoveryGuidance: (0, rendering_1.buildPlanningRecoveryGuidance)({
            repositoryRoot,
            artifactPath: phaseOverviewPath.relative,
            reviewKind: 'phase',
            blockingIssues,
            warnings,
            metadataHygieneFollowUps,
            modeBalanceEvaluations,
        }),
        findings: (0, rendering_1.buildPlanningReviewFindings)({
            artifactPath: phaseOverviewPath.relative,
            reviewKind: 'phase',
            blockingIssues,
            warnings,
            metadataHygieneFollowUps,
        }).concat(buildAdministrativeStatusDriftFindings(metadataProjection.administrativeStatusDrift)),
    };
}
function inspectScaffoldMigrationAvailability(repositoryRoot, phaseOverviewPath, inspection) {
    if (inspection === null
        || !inspection.findings.some((finding) => finding.code.startsWith('PLANNING_SCAFFOLD_'))) {
        return null;
    }
    try {
        const preview = (0, phase_scaffold_migration_1.previewPhaseScaffoldMigrationSync)({
            repositoryRoot,
            phaseOverviewPath,
        });
        if (!preview.legacyEvidenceDetected)
            return null;
        return {
            legacyEvidenceDetected: true,
            planDigest: preview.planDigest,
            intendedPaths: [...preview.intendedPaths],
            affectedArtifacts: preview.affectedArtifacts.length,
            previewArgv: [
                'day-shift', 'phase', 'scaffold-migrate',
                '--phase-overview', phaseOverviewPath,
                '--dry-run', '--format', 'json',
            ],
        };
    }
    catch {
        return null;
    }
}
function buildPhaseReviewMetadataProjection(options) {
    const metadataStatusTransitions = [
        {
            artifactPath: options.phaseOverviewPath,
            artifactType: 'phase_overview',
            oldStatus: options.phaseStatus,
            newStatus: 'completed',
            artifactRevision: revisionOfRepositoryFile(options.repositoryRoot, options.phaseOverviewPath),
            eligible: options.phaseMetadataEligible,
            changed: options.phaseStatus !== 'completed',
        },
        ...options.milestoneStates.map((state) => ({
            artifactPath: state.overviewPath,
            artifactType: 'milestone_overview',
            oldStatus: state.status,
            newStatus: 'completed',
            artifactRevision: revisionOfRepositoryFile(options.repositoryRoot, state.overviewPath),
            eligible: options.eligibleMilestoneMetadataPaths.has(state.overviewPath),
            changed: state.status !== 'completed',
        })),
    ].sort((left, right) => left.artifactPath.localeCompare(right.artifactPath));
    const reconciliationEvidence = [...options.reconciliationEvidence]
        .sort((left, right) => left.milestoneOverviewPath.localeCompare(right.milestoneOverviewPath));
    const administrativeStatusDrift = metadataStatusTransitions
        .filter((transition) => transition.eligible && transition.changed)
        .map((transition) => ({
        artifactPath: transition.artifactPath,
        artifactType: transition.artifactType,
        observedStatus: transition.oldStatus,
        expectedStatus: 'completed',
        classification: 'expected-administrative-state',
        reason: options.metadataPosture === 'read-only'
            ? 'The review evidence is complete, but read-only posture preserves deterministic status updates as expected administrative state.'
            : 'The review evidence is complete; an explicit metadata sync preview may propose this deterministic status update.',
    }));
    const complete = options.reviewMode === 'evidence'
        && options.blockingIssues.length === 0
        && reconciliationEvidence.length === options.milestoneStates.length
        && reconciliationEvidence.every((entry) => entry.completedNonPlaceholder)
        && metadataStatusTransitions.every((transition) => transition.eligible);
    const receiptWithoutId = {
        schemaVersion: 1,
        phaseOverviewPath: options.phaseOverviewPath,
        metadataPosture: options.metadataPosture,
        reviewedAt: options.reviewedAt,
        reviewMode: options.reviewMode,
        blockerCount: options.blockingIssues.length,
        complete,
        metadataStatusTransitions,
        reconciliationEvidence,
        authorizes: complete ? ['metadata-sync-preview'] : [],
    };
    const phaseReviewReceipt = {
        ...receiptWithoutId,
        reviewId: computePhaseReviewReceiptId(receiptWithoutId),
    };
    return {
        administrativeStatusDrift,
        metadataStatusTransitions,
        reconciliationEvidence,
        phaseReviewReceipt,
    };
}
function computePhaseReviewReceiptId(receipt) {
    const digest = (0, node_crypto_1.createHash)('sha256')
        .update(JSON.stringify(receipt))
        .digest('hex');
    return `phase-review-${digest.slice(0, 24)}`;
}
function revisionOfRepositoryFile(repositoryRoot, repositoryPath) {
    return `sha256:${(0, node_crypto_1.createHash)('sha256')
        .update(node_fs_1.default.readFileSync(node_path_1.default.join(repositoryRoot, repositoryPath)))
        .digest('hex')}`;
}
function requirePhaseReviewTimestamp(value) {
    const parsed = Date.parse(value);
    if (!Number.isFinite(parsed)) {
        throw (0, errors_1.createUsageError)('Phase review time must be a valid ISO-8601 timestamp.');
    }
    const normalized = new Date(parsed).toISOString();
    (0, task_lifecycle_timestamps_1.requireObservedLifecycleTimestamp)({
        value,
        field: 'reviewed_at',
        label: 'Phase review time',
    });
    return normalized;
}
function buildAdministrativeStatusDriftFindings(entries) {
    return entries.map((entry) => (0, output_1.createAdvisoryValidationFinding)({
        code: 'PHASE_REVIEW_ADMINISTRATIVE_STATUS_DRIFT',
        message: `${entry.artifactPath}: observed status '${entry.observedStatus ?? '(missing)'}'; expected '${entry.expectedStatus}'.`,
        path: entry.artifactPath,
        advisoryReason: 'weak-evidence',
        level: 'informational',
        recovery: 'Preserve this as expected administrative state under read-only posture, or use an explicit revision-bound metadata sync preview under sync-on-clean-review posture.',
    }));
}
function buildPhaseEvidenceLanes(resolutionHistory, metadataHygieneFollowUps, administrativeStatusDrift) {
    return {
        liveWarnings: resolutionHistory.liveWarnings,
        historicalResolved: resolutionHistory.historicalResolved,
        acceptedResidual: resolutionHistory.acceptedResidual,
        metadataHygiene: [...metadataHygieneFollowUps],
        administrativeStatusDrift: [...administrativeStatusDrift],
    };
}
function resolutionHistorySuppressesIssue(resolutionHistory, reconciliationPath, issue) {
    return resolutionHistory.fullyResolvedSections.some((entry) => {
        return entry.reconciliationPath === reconciliationPath
            && issue.includes(entry.section);
    });
}
