You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue Type: Feature Request Priority: High Category: Validation, Performance Related Issues: #56 (Bugs #1 and #3)
Problem Statement
The current MCP server architecture has fundamental issues with plan validation and progress tracking due to the lack of a single source of truth for plan structure. This causes:
Transform the plan submission API to require explicit step count:
// Current API (vulnerable to mismatches)submitPlan(config,{agent: string,content: string,taskId?: string})// Enhanced API (validated at submission)submitPlan(config,{agent: string,content: string,stepCount: number,// NEW: Required parametertaskId?: string})
Validation Flow
1. At Plan Submission (Proactive Validation)
// In submit-plan.tsfunctionvalidatePlanWithStepCount(content: string,expectedStepCount: number){constcheckboxRegex=/^(\s*)-\s*\[([x])\]\s+/gm;// Standardized patternconstmatches=content.match(checkboxRegex)||[];if(matches.length!==expectedStepCount){thrownewError(`Step count mismatch: Expected ${expectedStepCount} steps, `+`but plan contains ${matches.length} checkboxes`);}// Store metadataconstmetadata={stepCount: expectedStepCount,createdAt: newDate().toISOString(),checkboxPattern: 'markdown',version: '2.0.0'};returnmetadata;}
// In report-progress.tsasyncfunctionvalidateStepNumber(step: number,taskDir: string){// Read metadata instead of parsing planconstmetadataPath=path.join(taskDir,'PLAN.metadata.json');constmetadata=awaitfs.readJson(metadataPath);if(step<1||step>metadata.stepCount){thrownewError(`Invalid step number ${step}: Must be between 1 and ${metadata.stepCount}`);}}
4. At Progress Tracking (Use Stored Metadata)
// In track-task-progress.tsasyncfunctioncalculateProgress(taskDir: string){constmetadataPath=path.join(taskDir,'PLAN.metadata.json');constmetadata=awaitfs.readJson(metadataPath);constplanPath=path.join(taskDir,'PLAN.md');constplanContent=awaitfs.readFile(planPath,'utf8');// Parse only checked boxes, total is from metadataconstcheckedRegex=/^(\s*)-\s*\[x\]\s+/gm;constcheckedCount=(planContent.match(checkedRegex)||[]).length;return{totalSteps: metadata.stepCount,completedSteps: checkedCount,percentage: Math.round((checkedCount/metadata.stepCount)*100)};}
Implementation Plan
Phase 1: Foundation (Week 1)
Standardize Checkbox Regex Pattern
Create src/utils/plan-parser.ts with single regex
Export consistent parsing functions
Add comprehensive tests
Add Metadata Support
Create metadata types in src/types/plan-types.ts
Add metadata read/write utilities
Update TaskContextManager to handle metadata
Phase 2: API Enhancement (Week 1-2)
Update submit-plan Tool
Add stepCount parameter (optional initially)
Validate step count matches checkboxes
Create and store metadata file
Add deprecation warning for missing stepCount
Update report-progress Tool
Check for metadata file first
Fall back to parsing if no metadata (backward compat)
Consistency: Single source of truth for plan structure
2. Performance
Current: ~100ms per validation (parse plan each time)
Enhanced: <10ms per validation (read metadata)
90% reduction in validation overhead
3. Reliability
Validation at creation: Catch errors early
Immutable step count: Prevents drift over time
Audit trail: Metadata tracks plan history
4. Maintainability
Single regex pattern: Easier to update
Centralized validation: One place to fix bugs
Clear separation: Structure (metadata) vs content (markdown)
Breaking Changes & Migration
Breaking Changes
API signature change for submitPlan
New required parameter stepCount
Metadata file requirement for new plans
Migration Strategy
Phase 1: Soft Launch (v2.1.0)
// Make stepCount optional with warningif(!args.stepCount){console.warn('DEPRECATION: stepCount will be required in v3.0.0');constcalculated=countCheckboxes(content);args.stepCount=calculated;}
Phase 2: Enforcement (v3.0.0)
// Make stepCount requiredif(!args.stepCount){thrownewError('stepCount is required for plan submission');}
Migration Script
# Script to add metadata to existing plans
npm run migrate:add-plan-metadata
Acceptance Criteria
Functional Requirements
Plans with incorrect stepCount are rejected at submission
Progress percentage calculations are always accurate
Step validation prevents out-of-bounds updates
Backward compatibility for existing plans
Migration script successfully processes all existing plans
Enhancement Issue: Plan Step Count Validation
Issue Type: Feature Request
Priority: High
Category: Validation, Performance
Related Issues: #56 (Bugs #1 and #3)
Problem Statement
The current MCP server architecture has fundamental issues with plan validation and progress tracking due to the lack of a single source of truth for plan structure. This causes:
Current Architecture Problems
1. Inconsistent Regex Patterns
Different tools use different regex patterns to parse checkboxes:
submit-plan.ts:/^- \[ \] \*\*[^:]+\*\*:/gm(requires bold title with colon)report-progress.ts:/^- \[[ x]\] \*\*.*?\*\*/gm(requires bold, any content)track-task-progress.ts:/^(\s*)-\s*\[([ x])\]\s*(.+)$/(flexible, no bold required)2. Repeated Plan Parsing
Every operation that needs step count must:
This happens in:
report-progress.ts(lines 56-57, 71-72)track-task-progress.ts(lines 94-142)3. No Plan Metadata Storage
Plans are stored as raw markdown without metadata:
Proposed Solution
Core Enhancement: Add Required
stepCountParameterTransform the plan submission API to require explicit step count:
Validation Flow
1. At Plan Submission (Proactive Validation)
2. Plan Metadata Storage
Create
PLAN.metadata.jsonalongsidePLAN.md:{ "stepCount": 5, "createdAt": "2025-09-15T10:00:00Z", "agent": "qa-test-automation-engineer", "checkboxPattern": "markdown", "version": "2.0.0", "validation": { "checksumMatch": true, "lastValidated": "2025-09-15T10:00:00Z" } }3. At Progress Reporting (Use Stored Metadata)
4. At Progress Tracking (Use Stored Metadata)
Implementation Plan
Phase 1: Foundation (Week 1)
Standardize Checkbox Regex Pattern
src/utils/plan-parser.tswith single regexAdd Metadata Support
src/types/plan-types.tsPhase 2: API Enhancement (Week 1-2)
Update submit-plan Tool
Update report-progress Tool
Update track-task-progress Tool
Phase 3: Testing & Migration (Week 2)
Comprehensive Testing
Migration Strategy
Benefits
1. Correctness
2. Performance
3. Reliability
4. Maintainability
Breaking Changes & Migration
Breaking Changes
Migration Strategy
Phase 1: Soft Launch (v2.1.0)
Phase 2: Enforcement (v3.0.0)
Migration Script
# Script to add metadata to existing plans npm run migrate:add-plan-metadataAcceptance Criteria
Functional Requirements
Performance Requirements
Quality Requirements
Testing Strategy
Unit Tests
Integration Tests
Risk Assessment
Low Risk
Mitigations
Timeline
Related Issues
References
Ready for GitHub Issue Creation
Use this content with the GitHub CLI:
gh issue create \ --title "feat: add stepCount parameter for plan validation and progress tracking" \ --body-file ./tmp/issue-56/ENHANCEMENT-ISSUE-STEP-COUNT.md \ --label enhancement,priority:high,category:validation \ --assignee @me