/**
 * @internal
 * consistency/rules/r2-subtask-progress.mjs — R2 (C15).
 *
 * Every subtask in implementation_plan.json must have a matching status
 * entry in build-progress.json. Warn-severity — never blocks ship.
 *
 * Stages: verify, ship.
 * Skip when: build-progress.json is absent (empty parsed progress).
 */
import { registerRule } from '../registry.mjs';
const rule = {
    id: 'r2-subtask-progress',
    severity: 'warn',
    stages: ['verify', 'ship'],
    description: 'Every plan subtask has a build-progress entry.',
    async check({ parsed }) {
        const subtasks = parsed?.plan?.subtasks ?? [];
        const progressMap = parsed?.progress?.subtasks ?? {};
        if (subtasks.length === 0) {
            return { status: 'skip', drift: [], reason: 'no subtasks in plan' };
        }
        if (!parsed?.progress?.present) {
            return {
                status: 'skip',
                drift: [],
                reason: 'build-progress.json not present',
            };
        }
        const drift = [];
        for (const s of subtasks) {
            if (!progressMap[s.id]) {
                drift.push({ subtask_id: s.id, title: s.title, reason: 'no build-progress entry' });
            }
        }
        if (drift.length > 0) {
            return {
                status: 'fail',
                drift,
                reason: `${drift.length} of ${subtasks.length} subtasks missing from build-progress.json`,
            };
        }
        return {
            status: 'pass',
            drift: [],
            reason: `all ${subtasks.length} subtasks have progress entries`,
        };
    },
};
registerRule(rule);
export default rule;
//# sourceMappingURL=r2-subtask-progress.mjs.map