/** * Completion Calculator - Verifies actual work completion from markdown checkboxes * * CRITICAL FIX: Prevents premature GitHub issue closure by verifying actual * AC and Task completion state, not just frontmatter status. * * Problem: * - OLD: Issues closed based on frontmatter `status: complete` * - Issue #574: Closed with 0/5 ACs complete! * * Solution: * - NEW: Parse actual checkbox states ([x] vs [ ]) * - Close ONLY when ALL ACs and ALL tasks are verified [x] * * Architecture: * - Acceptance Criteria: Read from us-*.md files * - Tasks: Read from increment's tasks.md * - Verification Gate: 100% completion required */ /** * Acceptance Criteria with completion status */ export interface AcceptanceCriteria { id: string; description: string; completed: boolean; } /** * Implementation Task with completion status */ export interface Task { id: string; title: string; completed: boolean; userStories: string[]; } /** * Complete verification status */ export interface CompletionStatus { acsTotal: number; acsCompleted: number; acsPercentage: number; tasksTotal: number; tasksCompleted: number; tasksPercentage: number; overallComplete: boolean; blockingAcs: string[]; blockingTasks: string[]; frontmatterStatus?: 'complete' | 'completed' | 'active' | 'planning' | 'not-started' | string; } export declare class CompletionCalculator { private projectRoot; constructor(projectRoot: string); /** * Calculate ACTUAL completion from markdown checkboxes * * Returns true only if: * - All ACs have [x] (not [ ]) * - All Tasks have **Status**: [x] (not [ ]) * - At least 1 AC exists (no empty user stories) * * @param userStoryPath - Path to us-*.md file * @returns Completion status with detailed metrics */ calculateCompletion(userStoryPath: string): Promise; /** * Parse User Story frontmatter */ private parseUserStoryFrontmatter; /** * Extract Acceptance Criteria with checkbox state * * Supports TWO formats: * - Format 1 (preferred): AC-US1-01, AC-US1-02 (project-specific) * - Format 2 (legacy): AC-001, AC-002, AC-020 (global) * * Patterns: * - [x] **AC-US1-01**: Description (completed) * - [ ] **AC-US1-01**: Description (not completed) * - **AC-US1-01**: Description (no checkbox, default to not completed) */ private extractAcceptanceCriteria; /** * Extract tasks from increment's tasks.md that map to this User Story * * Process: * 1. Find increment link in user story's "Implementation" section * 2. Read increment's tasks.md * 3. Filter tasks that reference this user story (via **User Story** field OR AC-IDs) * 4. Extract completion status from **Status**: [x] or [ ] * * IMPORTANT: Checks **User Story** field FIRST (handles multi-story tasks like "US-001, US-002"), * then falls back to AC-based filtering. Also handles "Satisfies ACs: All" correctly. */ private extractTasks; /** * Build completion comment for GitHub issue closure * * Used when closing issue after verification */ buildCompletionComment(completion: CompletionStatus): string; /** * Build progress comment for GitHub issue update * * Used when issue stays open (not 100% complete) */ buildProgressComment(completion: CompletionStatus): string; /** * Build reopen comment for GitHub issue * * Used when reopening prematurely closed issue */ buildReopenComment(completion: CompletionStatus, reason?: string): string; } //# sourceMappingURL=completion-calculator.d.ts.map