iaip-mcp-pde 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +187 -0
  2. package/dist/cli.d.ts +18 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +385 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +15 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +34 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/mcp-server.d.ts +59 -0
  11. package/dist/mcp-server.d.ts.map +1 -0
  12. package/dist/mcp-server.js +293 -0
  13. package/dist/mcp-server.js.map +1 -0
  14. package/dist/parser.d.ts +19 -0
  15. package/dist/parser.d.ts.map +1 -0
  16. package/dist/parser.js +89 -0
  17. package/dist/parser.js.map +1 -0
  18. package/dist/pde-engine.d.ts +54 -0
  19. package/dist/pde-engine.d.ts.map +1 -0
  20. package/dist/pde-engine.js +85 -0
  21. package/dist/pde-engine.js.map +1 -0
  22. package/dist/prompts.d.ts +10 -0
  23. package/dist/prompts.d.ts.map +1 -0
  24. package/dist/prompts.js +93 -0
  25. package/dist/prompts.js.map +1 -0
  26. package/dist/storage.d.ts +44 -0
  27. package/dist/storage.d.ts.map +1 -0
  28. package/dist/storage.js +369 -0
  29. package/dist/storage.js.map +1 -0
  30. package/dist/types.d.ts +108 -0
  31. package/dist/types.d.ts.map +1 -0
  32. package/dist/types.js +24 -0
  33. package/dist/types.js.map +1 -0
  34. package/package.json +63 -0
  35. package/rispecs/pde-data-models.rispec.md +182 -0
  36. package/rispecs/pde-overview.rispec.md +157 -0
  37. package/rispecs/pde-parent-child-schema.rispec.md +525 -0
  38. package/rispecs/pde-prompts.rispec.md +144 -0
  39. package/rispecs/pde-resources.rispec.md +101 -0
  40. package/rispecs/pde-tools.rispec.md +179 -0
  41. package/rispecs/relation-to-mcp-structural-thinking.kin.md +66 -0
  42. package/scenarios/01-simple-decomposition.md +88 -0
  43. package/scenarios/02-multi-intent-workflow.md +112 -0
  44. package/scenarios/03-ceremonial-alignment.md +155 -0
  45. package/scenarios/04-dependency-resolution.md +163 -0
  46. package/scenarios/05-checkpoint-recovery.md +171 -0
@@ -0,0 +1,163 @@
1
+ # Scenario 04: Dependency Resolution
2
+
3
+ ## Objective
4
+ Test that the PDE correctly identifies and resolves dependencies between tasks, ensuring proper execution ordering and detecting potential issues like circular dependencies.
5
+
6
+ ## Scenario Description
7
+ Complex workflows have tasks that depend on each other. The PDE must:
8
+ - Build accurate dependency graphs
9
+ - Identify the critical path
10
+ - Detect circular dependencies
11
+ - Enable parallel execution where safe
12
+
13
+ ## Test Cases
14
+
15
+ ### Case A: Linear Dependencies
16
+ ```
17
+ Research best practices, then design the architecture, then implement the solution, then write tests
18
+ ```
19
+
20
+ Expected Graph:
21
+ ```
22
+ research → design → implement → write tests
23
+ ```
24
+
25
+ ### Case B: Parallel Opportunities
26
+ ```
27
+ Create user service, create order service, create product service, then integrate all services
28
+ ```
29
+
30
+ Expected Graph:
31
+ ```
32
+ create user ─┐
33
+ create order─┼→ integrate
34
+ create product┘
35
+ ```
36
+
37
+ ### Case C: Mixed Dependencies
38
+ ```
39
+ Analyze requirements, create database schema, create API endpoints, write unit tests, write integration tests, deploy
40
+ ```
41
+
42
+ Expected Graph:
43
+ ```
44
+ analyze → create schema ─→ write unit tests ─┐
45
+ ↓ ├→ deploy
46
+ create API ──→ write integration tests┘
47
+ ```
48
+
49
+ ## Test Steps for LLM Agent
50
+
51
+ ### Test Case A: Linear Dependencies
52
+
53
+ 1. **Decompose Linear Workflow**
54
+ ```
55
+ Use tool: pde_decompose
56
+ Arguments: { "prompt": "Research best practices, then design the architecture, then implement the solution, then write tests" }
57
+ ```
58
+
59
+ 2. **Verify Ordering**
60
+ - [ ] Research task has no dependencies
61
+ - [ ] Design depends on Research
62
+ - [ ] Implement depends on Design
63
+ - [ ] Tests depend on Implement
64
+
65
+ 3. **Check Critical Path**
66
+ - [ ] Critical path includes all 4 tasks in order
67
+ - [ ] `metadata.parallelizableTasks` is 0 or very low
68
+
69
+ ### Test Case B: Parallel Opportunities
70
+
71
+ 1. **Decompose Parallel Workflow**
72
+ ```
73
+ Use tool: pde_decompose
74
+ Arguments: { "prompt": "Create user service, create order service, create product service, then integrate all services" }
75
+ ```
76
+
77
+ 2. **Verify Parallelization**
78
+ - [ ] Three create tasks have no dependencies on each other
79
+ - [ ] `metadata.parallelizableTasks` >= 3
80
+ - [ ] Integrate task depends on all create tasks
81
+
82
+ 3. **Check Execution Type**
83
+ - [ ] Stage containing create tasks has `executionType: 'parallel'`
84
+
85
+ ### Test Case C: Mixed Dependencies
86
+
87
+ 1. **Decompose Mixed Workflow**
88
+ ```
89
+ Use tool: pde_decompose
90
+ Arguments: { "prompt": "Analyze requirements, create database schema, create API endpoints, write unit tests, write integration tests, deploy" }
91
+ ```
92
+
93
+ 2. **Verify Dependency Structure**
94
+ - [ ] Analyze has no dependencies
95
+ - [ ] Schema creation depends on Analyze
96
+ - [ ] API creation depends on Schema
97
+ - [ ] Tests depend on their respective targets
98
+ - [ ] Deploy depends on all tests
99
+
100
+ 3. **Check for Cycles**
101
+ - [ ] No circular dependencies detected
102
+
103
+ ## Circular Dependency Detection
104
+
105
+ ### Case D: Intentional Cycle (Edge Case)
106
+ ```
107
+ Module A imports from Module B, Module B imports from Module A, refactor to remove cycle
108
+ ```
109
+
110
+ 1. **Decompose Potentially Cyclic Request**
111
+ - [ ] PDE should detect the cycle
112
+ - [ ] May flag as ambiguity or issue
113
+ - [ ] Should not crash or hang
114
+
115
+ ## Validation Steps
116
+
117
+ 1. **Validate Each Plan**
118
+ ```
119
+ Use tool: pde_validate_plan
120
+ Arguments: { "planId": "<planId>" }
121
+ ```
122
+
123
+ 2. **Check Validation Results**
124
+ - [ ] `isValid` reflects dependency correctness
125
+ - [ ] Missing dependencies flagged as issues
126
+ - [ ] Circular dependencies flagged if present
127
+
128
+ ## Success Criteria
129
+
130
+ - ✅ Linear dependencies correctly ordered
131
+ - ✅ Parallel opportunities correctly identified
132
+ - ✅ Mixed dependency graphs accurately represented
133
+ - ✅ Critical path correctly calculated
134
+ - ✅ No false circular dependency detection
135
+ - ✅ Actual circular dependencies detected (if any)
136
+
137
+ ## Technical Details
138
+
139
+ ### Dependency Graph Structure
140
+ ```typescript
141
+ interface DependencyGraph {
142
+ nodes: DependencyNode[]; // All tasks
143
+ edges: DependencyEdge[]; // Dependencies
144
+ parallelGroups: string[][]; // Tasks that can run together
145
+ criticalPath: string[]; // Longest dependency chain
146
+ hasCycles: boolean; // Cycle detection result
147
+ }
148
+ ```
149
+
150
+ ### Edge Types
151
+ - `must-precede`: Task A must complete before Task B
152
+ - `must-follow`: Task A must happen after Task B
153
+ - `blocks`: Task A blocks Task B from parallel execution
154
+ - `enables`: Task A enables optional path to Task B
155
+
156
+ ## Performance Considerations
157
+
158
+ For large dependency graphs:
159
+ - Graph construction should be O(n²) worst case
160
+ - Cycle detection uses DFS: O(V + E)
161
+ - Critical path: O(V + E) with topological sort
162
+
163
+ The `maxDepth` option (default: 5) limits recursion depth to prevent performance issues with deeply nested dependencies.
@@ -0,0 +1,171 @@
1
+ # Scenario 05: Checkpoint and Recovery
2
+
3
+ ## Objective
4
+ Test that the PDE creates proper checkpoints during workflow execution and enables recovery from failures.
5
+
6
+ ## Scenario Description
7
+ In real-world usage, workflows may fail partway through. The PDE must:
8
+ - Create checkpoints after each stage
9
+ - Store context snapshots for recovery
10
+ - Enable resumption from last successful checkpoint
11
+ - Provide clear recovery instructions
12
+
13
+ ## Test Workflow
14
+ ```
15
+ Create database models, generate API routes, write tests, deploy to staging
16
+ ```
17
+
18
+ ## Expected Checkpoint Structure
19
+
20
+ After each stage completes:
21
+ ```typescript
22
+ {
23
+ checkpointId: "uuid",
24
+ workflowId: "workflow-uuid",
25
+ stageId: "stage-south",
26
+ taskId: "task-3",
27
+ timestamp: "2026-01-30T10:00:00Z",
28
+ contextSnapshot: {
29
+ completedTasks: ["task-1", "task-2", "task-3"],
30
+ outputs: {...},
31
+ environment: {...}
32
+ },
33
+ resumeInstructions: "Resume from stage stage-west, task task-4"
34
+ }
35
+ ```
36
+
37
+ ## Test Steps for LLM Agent
38
+
39
+ ### Step 1: Create Initial Plan
40
+
41
+ 1. **Decompose Workflow**
42
+ ```
43
+ Use tool: pde_decompose
44
+ Arguments: {
45
+ "prompt": "Create database models, generate API routes, write tests, deploy to staging"
46
+ }
47
+ ```
48
+
49
+ 2. **Note Plan Structure**
50
+ - [ ] Record `planId` for later use
51
+ - [ ] Record `workflowId` for checkpoint retrieval
52
+ - [ ] Verify `checkpointAfter: true` on stages
53
+
54
+ ### Step 2: Simulate Stage Completion
55
+
56
+ For this test, we verify the checkpoint structure is correct. In a real execution:
57
+
58
+ 1. **Execute First Stage** (simulated)
59
+ - Stage SOUTH completes
60
+ - Checkpoint should be created
61
+
62
+ 2. **Get Checkpoint**
63
+ ```
64
+ Use tool: pde_get_checkpoint
65
+ Arguments: {
66
+ "workflowId": "<workflowId from step 1>"
67
+ }
68
+ ```
69
+
70
+ 3. **Verify Checkpoint** (if exists)
71
+ - [ ] Contains `checkpointId`
72
+ - [ ] Contains `workflowId` matching plan
73
+ - [ ] Contains `contextSnapshot`
74
+ - [ ] Contains `resumeInstructions`
75
+
76
+ ### Step 3: Verify Recovery Readiness
77
+
78
+ 1. **Check Plan for Recovery Data**
79
+ ```
80
+ Use tool: pde_get_plan
81
+ Arguments: { "planId": "<planId>" }
82
+ ```
83
+
84
+ 2. **Examine Task Recovery Strategies**
85
+ For each task in `plan.tasks`:
86
+ - [ ] Has `recoveryStrategy` defined
87
+ - [ ] `onFailure` is one of: 'retry', 'skip', 'alternative', 'abort'
88
+ - [ ] `retryCount` is reasonable (1-5)
89
+
90
+ 3. **Examine Checkpoint Data**
91
+ For each task:
92
+ - [ ] Has `checkpointData` defined
93
+ - [ ] `saves` lists expected outputs
94
+ - [ ] `restoresFrom` references valid checkpoint (if applicable)
95
+
96
+ ### Step 4: List and Verify Workflows
97
+
98
+ 1. **List All Workflows**
99
+ ```
100
+ Use tool: pde_list_workflows
101
+ Arguments: { "status": "all", "limit": 10 }
102
+ ```
103
+
104
+ 2. **Verify Workflow Appears**
105
+ - [ ] Workflow from Step 1 is in list
106
+ - [ ] Shows correct `intention`
107
+ - [ ] Shows correct `taskCount`
108
+
109
+ ## Expected Recovery Flow
110
+
111
+ When a failure occurs at Stage WEST (testing):
112
+
113
+ ```
114
+ Workflow Execution:
115
+ ✓ Stage EAST - Vision Inquiry (completed)
116
+ ✓ Stage SOUTH - Implementation (completed)
117
+ 📍 Checkpoint created: cp-123
118
+ ✗ Stage WEST - Validation (FAILED at task-5)
119
+ └─ Error: Test assertion failed
120
+ └─ Recovery: retry (attempt 1/3)
121
+ └─ Checkpoint available: cp-123
122
+
123
+ Resume Options:
124
+ 1. Retry from task-5 (same approach)
125
+ 2. Retry from task-5 (alternative approach)
126
+ 3. Skip task-5 and continue
127
+ 4. Rollback to checkpoint cp-123
128
+ ```
129
+
130
+ ## Success Criteria
131
+
132
+ - ✅ Each stage has `checkpointAfter: true`
133
+ - ✅ Tasks have valid `recoveryStrategy` definitions
134
+ - ✅ Tasks have valid `checkpointData` definitions
135
+ - ✅ Checkpoint retrieval works by workflowId
136
+ - ✅ Resume instructions are clear and actionable
137
+ - ✅ Workflow appears in list with correct metadata
138
+
139
+ ## Recovery Strategy Types
140
+
141
+ | Strategy | Use Case |
142
+ |----------|----------|
143
+ | `retry` | Transient failures (network, timeout) |
144
+ | `skip` | Non-critical tasks that can be skipped |
145
+ | `alternative` | When different approach might succeed |
146
+ | `abort` | Critical failures requiring human intervention |
147
+
148
+ ## Checkpoint Best Practices
149
+
150
+ 1. **Checkpoint Granularity**: After each stage, not each task
151
+ 2. **Context Preservation**: Save all outputs and relevant state
152
+ 3. **Clear Instructions**: Tell user exactly how to resume
153
+ 4. **Minimal Overhead**: Don't checkpoint trivially small operations
154
+
155
+ ## Error Handling Verification
156
+
157
+ 1. **Missing Workflow**
158
+ ```
159
+ Use tool: pde_get_checkpoint
160
+ Arguments: { "workflowId": "non-existent-id" }
161
+ ```
162
+ - [ ] Returns graceful "not found" message
163
+ - [ ] Does not crash or throw error
164
+
165
+ 2. **Invalid Plan ID**
166
+ ```
167
+ Use tool: pde_validate_plan
168
+ Arguments: { "planId": "invalid-id" }
169
+ ```
170
+ - [ ] Returns `isValid: false`
171
+ - [ ] Includes helpful error message