@telora/factory 0.4.5
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.
- package/dist/audit.d.ts +69 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +376 -0
- package/dist/audit.js.map +1 -0
- package/dist/builder-completion.d.ts +35 -0
- package/dist/builder-completion.d.ts.map +1 -0
- package/dist/builder-completion.js +375 -0
- package/dist/builder-completion.js.map +1 -0
- package/dist/builder-spawner.d.ts +40 -0
- package/dist/builder-spawner.d.ts.map +1 -0
- package/dist/builder-spawner.js +493 -0
- package/dist/builder-spawner.js.map +1 -0
- package/dist/completion-gate.d.ts +52 -0
- package/dist/completion-gate.d.ts.map +1 -0
- package/dist/completion-gate.js +336 -0
- package/dist/completion-gate.js.map +1 -0
- package/dist/completion-report.d.ts +36 -0
- package/dist/completion-report.d.ts.map +1 -0
- package/dist/completion-report.js +348 -0
- package/dist/completion-report.js.map +1 -0
- package/dist/completion.d.ts +58 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +287 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/context-manager.d.ts +152 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +421 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/crash-detection.d.ts +70 -0
- package/dist/crash-detection.d.ts.map +1 -0
- package/dist/crash-detection.js +123 -0
- package/dist/crash-detection.js.map +1 -0
- package/dist/crash-recovery.d.ts +83 -0
- package/dist/crash-recovery.d.ts.map +1 -0
- package/dist/crash-recovery.js +522 -0
- package/dist/crash-recovery.js.map +1 -0
- package/dist/crash-resolution.d.ts +34 -0
- package/dist/crash-resolution.d.ts.map +1 -0
- package/dist/crash-resolution.js +382 -0
- package/dist/crash-resolution.js.map +1 -0
- package/dist/escalation.d.ts +150 -0
- package/dist/escalation.d.ts.map +1 -0
- package/dist/escalation.js +352 -0
- package/dist/escalation.js.map +1 -0
- package/dist/execution-target.d.ts +31 -0
- package/dist/execution-target.d.ts.map +1 -0
- package/dist/execution-target.js +71 -0
- package/dist/execution-target.js.map +1 -0
- package/dist/execution-unit-init.d.ts +28 -0
- package/dist/execution-unit-init.d.ts.map +1 -0
- package/dist/execution-unit-init.js +115 -0
- package/dist/execution-unit-init.js.map +1 -0
- package/dist/execution.d.ts +17 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +20 -0
- package/dist/execution.js.map +1 -0
- package/dist/factory-engine.d.ts +100 -0
- package/dist/factory-engine.d.ts.map +1 -0
- package/dist/factory-engine.js +243 -0
- package/dist/factory-engine.js.map +1 -0
- package/dist/gap-detection.d.ts +43 -0
- package/dist/gap-detection.d.ts.map +1 -0
- package/dist/gap-detection.js +149 -0
- package/dist/gap-detection.js.map +1 -0
- package/dist/gate-context.d.ts +23 -0
- package/dist/gate-context.d.ts.map +1 -0
- package/dist/gate-context.js +63 -0
- package/dist/gate-context.js.map +1 -0
- package/dist/gate-engine.d.ts +55 -0
- package/dist/gate-engine.d.ts.map +1 -0
- package/dist/gate-engine.js +191 -0
- package/dist/gate-engine.js.map +1 -0
- package/dist/gates/adversarial.d.ts +59 -0
- package/dist/gates/adversarial.d.ts.map +1 -0
- package/dist/gates/adversarial.js +426 -0
- package/dist/gates/adversarial.js.map +1 -0
- package/dist/gates/adversary-spawner.d.ts +35 -0
- package/dist/gates/adversary-spawner.d.ts.map +1 -0
- package/dist/gates/adversary-spawner.js +286 -0
- package/dist/gates/adversary-spawner.js.map +1 -0
- package/dist/gates/adversary-test-dir.d.ts +41 -0
- package/dist/gates/adversary-test-dir.d.ts.map +1 -0
- package/dist/gates/adversary-test-dir.js +150 -0
- package/dist/gates/adversary-test-dir.js.map +1 -0
- package/dist/gates/behavioral-parser.d.ts +32 -0
- package/dist/gates/behavioral-parser.d.ts.map +1 -0
- package/dist/gates/behavioral-parser.js +190 -0
- package/dist/gates/behavioral-parser.js.map +1 -0
- package/dist/gates/behavioral-runner.d.ts +36 -0
- package/dist/gates/behavioral-runner.d.ts.map +1 -0
- package/dist/gates/behavioral-runner.js +306 -0
- package/dist/gates/behavioral-runner.js.map +1 -0
- package/dist/gates/behavioral.d.ts +37 -0
- package/dist/gates/behavioral.d.ts.map +1 -0
- package/dist/gates/behavioral.js +485 -0
- package/dist/gates/behavioral.js.map +1 -0
- package/dist/gates/deterministic.d.ts +24 -0
- package/dist/gates/deterministic.d.ts.map +1 -0
- package/dist/gates/deterministic.js +186 -0
- package/dist/gates/deterministic.js.map +1 -0
- package/dist/git-factory.d.ts +59 -0
- package/dist/git-factory.d.ts.map +1 -0
- package/dist/git-factory.js +102 -0
- package/dist/git-factory.js.map +1 -0
- package/dist/guard-evaluation.d.ts +48 -0
- package/dist/guard-evaluation.d.ts.map +1 -0
- package/dist/guard-evaluation.js +416 -0
- package/dist/guard-evaluation.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/instance-completion.d.ts +34 -0
- package/dist/instance-completion.d.ts.map +1 -0
- package/dist/instance-completion.js +366 -0
- package/dist/instance-completion.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +15 -0
- package/dist/instance-lifecycle.d.ts.map +1 -0
- package/dist/instance-lifecycle.js +18 -0
- package/dist/instance-lifecycle.js.map +1 -0
- package/dist/instance-phase-dispatch.d.ts +75 -0
- package/dist/instance-phase-dispatch.d.ts.map +1 -0
- package/dist/instance-phase-dispatch.js +674 -0
- package/dist/instance-phase-dispatch.js.map +1 -0
- package/dist/instance-poll-loop.d.ts +43 -0
- package/dist/instance-poll-loop.d.ts.map +1 -0
- package/dist/instance-poll-loop.js +360 -0
- package/dist/instance-poll-loop.js.map +1 -0
- package/dist/instance-state-machine.d.ts +52 -0
- package/dist/instance-state-machine.d.ts.map +1 -0
- package/dist/instance-state-machine.js +235 -0
- package/dist/instance-state-machine.js.map +1 -0
- package/dist/log-manager.d.ts +28 -0
- package/dist/log-manager.d.ts.map +1 -0
- package/dist/log-manager.js +71 -0
- package/dist/log-manager.js.map +1 -0
- package/dist/pipeline-evaluator.d.ts +61 -0
- package/dist/pipeline-evaluator.d.ts.map +1 -0
- package/dist/pipeline-evaluator.js +107 -0
- package/dist/pipeline-evaluator.js.map +1 -0
- package/dist/pipeline-metrics.d.ts +52 -0
- package/dist/pipeline-metrics.d.ts.map +1 -0
- package/dist/pipeline-metrics.js +40 -0
- package/dist/pipeline-metrics.js.map +1 -0
- package/dist/pipeline-traversal.d.ts +43 -0
- package/dist/pipeline-traversal.d.ts.map +1 -0
- package/dist/pipeline-traversal.js +68 -0
- package/dist/pipeline-traversal.js.map +1 -0
- package/dist/plan-parser.d.ts +76 -0
- package/dist/plan-parser.d.ts.map +1 -0
- package/dist/plan-parser.js +223 -0
- package/dist/plan-parser.js.map +1 -0
- package/dist/planning-phase.d.ts +52 -0
- package/dist/planning-phase.d.ts.map +1 -0
- package/dist/planning-phase.js +444 -0
- package/dist/planning-phase.js.map +1 -0
- package/dist/planning-prompt.d.ts +64 -0
- package/dist/planning-prompt.d.ts.map +1 -0
- package/dist/planning-prompt.js +251 -0
- package/dist/planning-prompt.js.map +1 -0
- package/dist/planning.d.ts +16 -0
- package/dist/planning.d.ts.map +1 -0
- package/dist/planning.js +17 -0
- package/dist/planning.js.map +1 -0
- package/dist/process-runner.d.ts +41 -0
- package/dist/process-runner.d.ts.map +1 -0
- package/dist/process-runner.js +81 -0
- package/dist/process-runner.js.map +1 -0
- package/dist/product-config.d.ts +34 -0
- package/dist/product-config.d.ts.map +1 -0
- package/dist/product-config.js +43 -0
- package/dist/product-config.js.map +1 -0
- package/dist/queries/cycle-evaluations.d.ts +23 -0
- package/dist/queries/cycle-evaluations.d.ts.map +1 -0
- package/dist/queries/cycle-evaluations.js +37 -0
- package/dist/queries/cycle-evaluations.js.map +1 -0
- package/dist/queries/escalations.d.ts +30 -0
- package/dist/queries/escalations.d.ts.map +1 -0
- package/dist/queries/escalations.js +42 -0
- package/dist/queries/escalations.js.map +1 -0
- package/dist/queries/execution-units.d.ts +76 -0
- package/dist/queries/execution-units.d.ts.map +1 -0
- package/dist/queries/execution-units.js +109 -0
- package/dist/queries/execution-units.js.map +1 -0
- package/dist/queries/gate-results.d.ts +32 -0
- package/dist/queries/gate-results.d.ts.map +1 -0
- package/dist/queries/gate-results.js +44 -0
- package/dist/queries/gate-results.js.map +1 -0
- package/dist/queries/instances.d.ts +51 -0
- package/dist/queries/instances.d.ts.map +1 -0
- package/dist/queries/instances.js +77 -0
- package/dist/queries/instances.js.map +1 -0
- package/dist/queries/sessions.d.ts +50 -0
- package/dist/queries/sessions.d.ts.map +1 -0
- package/dist/queries/sessions.js +81 -0
- package/dist/queries/sessions.js.map +1 -0
- package/dist/queries/shared.d.ts +38 -0
- package/dist/queries/shared.d.ts.map +1 -0
- package/dist/queries/shared.js +119 -0
- package/dist/queries/shared.js.map +1 -0
- package/dist/queries/specs.d.ts +12 -0
- package/dist/queries/specs.d.ts.map +1 -0
- package/dist/queries/specs.js +21 -0
- package/dist/queries/specs.js.map +1 -0
- package/dist/queries/strategies.d.ts +14 -0
- package/dist/queries/strategies.d.ts.map +1 -0
- package/dist/queries/strategies.js +18 -0
- package/dist/queries/strategies.js.map +1 -0
- package/dist/queries/work-units.d.ts +42 -0
- package/dist/queries/work-units.d.ts.map +1 -0
- package/dist/queries/work-units.js +57 -0
- package/dist/queries/work-units.js.map +1 -0
- package/dist/queries/workflows.d.ts +29 -0
- package/dist/queries/workflows.d.ts.map +1 -0
- package/dist/queries/workflows.js +103 -0
- package/dist/queries/workflows.js.map +1 -0
- package/dist/remediation-units.d.ts +40 -0
- package/dist/remediation-units.d.ts.map +1 -0
- package/dist/remediation-units.js +263 -0
- package/dist/remediation-units.js.map +1 -0
- package/dist/replanning.d.ts +72 -0
- package/dist/replanning.d.ts.map +1 -0
- package/dist/replanning.js +403 -0
- package/dist/replanning.js.map +1 -0
- package/dist/resource-limits.d.ts +62 -0
- package/dist/resource-limits.d.ts.map +1 -0
- package/dist/resource-limits.js +322 -0
- package/dist/resource-limits.js.map +1 -0
- package/dist/scheduler.d.ts +98 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +203 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/session-adapter.d.ts +89 -0
- package/dist/session-adapter.d.ts.map +1 -0
- package/dist/session-adapter.js +108 -0
- package/dist/session-adapter.js.map +1 -0
- package/dist/sop-generator.d.ts +29 -0
- package/dist/sop-generator.d.ts.map +1 -0
- package/dist/sop-generator.js +235 -0
- package/dist/sop-generator.js.map +1 -0
- package/dist/spec-profiles.d.ts +41 -0
- package/dist/spec-profiles.d.ts.map +1 -0
- package/dist/spec-profiles.js +131 -0
- package/dist/spec-profiles.js.map +1 -0
- package/dist/strategy-design-graph.d.ts +23 -0
- package/dist/strategy-design-graph.d.ts.map +1 -0
- package/dist/strategy-design-graph.js +205 -0
- package/dist/strategy-design-graph.js.map +1 -0
- package/dist/strategy-design-prompt.d.ts +28 -0
- package/dist/strategy-design-prompt.d.ts.map +1 -0
- package/dist/strategy-design-prompt.js +108 -0
- package/dist/strategy-design-prompt.js.map +1 -0
- package/dist/strategy-design-schema.d.ts +767 -0
- package/dist/strategy-design-schema.d.ts.map +1 -0
- package/dist/strategy-design-schema.js +126 -0
- package/dist/strategy-design-schema.js.map +1 -0
- package/dist/strategy-design.d.ts +69 -0
- package/dist/strategy-design.d.ts.map +1 -0
- package/dist/strategy-design.js +411 -0
- package/dist/strategy-design.js.map +1 -0
- package/dist/strategy-gating.d.ts +31 -0
- package/dist/strategy-gating.d.ts.map +1 -0
- package/dist/strategy-gating.js +276 -0
- package/dist/strategy-gating.js.map +1 -0
- package/dist/team-prompt-builder.d.ts +47 -0
- package/dist/team-prompt-builder.d.ts.map +1 -0
- package/dist/team-prompt-builder.js +362 -0
- package/dist/team-prompt-builder.js.map +1 -0
- package/dist/trace-engine.d.ts +40 -0
- package/dist/trace-engine.d.ts.map +1 -0
- package/dist/trace-engine.js +344 -0
- package/dist/trace-engine.js.map +1 -0
- package/dist/types.d.ts +612 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/unit-session-lifecycle.d.ts +78 -0
- package/dist/unit-session-lifecycle.d.ts.map +1 -0
- package/dist/unit-session-lifecycle.js +141 -0
- package/dist/unit-session-lifecycle.js.map +1 -0
- package/dist/unit-session.d.ts +30 -0
- package/dist/unit-session.d.ts.map +1 -0
- package/dist/unit-session.js +370 -0
- package/dist/unit-session.js.map +1 -0
- package/dist/watchdogs.d.ts +33 -0
- package/dist/watchdogs.d.ts.map +1 -0
- package/dist/watchdogs.js +170 -0
- package/dist/watchdogs.js.map +1 -0
- package/dist/work-unit-scheduler.d.ts +34 -0
- package/dist/work-unit-scheduler.d.ts.map +1 -0
- package/dist/work-unit-scheduler.js +91 -0
- package/dist/work-unit-scheduler.js.map +1 -0
- package/dist/workflow-transition.d.ts +90 -0
- package/dist/workflow-transition.d.ts.map +1 -0
- package/dist/workflow-transition.js +340 -0
- package/dist/workflow-transition.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution profiles for factory spec types.
|
|
3
|
+
*
|
|
4
|
+
* Each spec type (prototype, mvp, extend_existing) maps to a different
|
|
5
|
+
* execution profile that controls which gates run, iteration limits,
|
|
6
|
+
* audit depth, operational guidance, and prompt injection for strategy
|
|
7
|
+
* design and planning phases.
|
|
8
|
+
*
|
|
9
|
+
* Used by:
|
|
10
|
+
* - strategy-design.ts to inject spec type context into the design prompt
|
|
11
|
+
* - planning.ts to inject planning emphasis into prompts
|
|
12
|
+
* - gate-engine.ts to skip disabled gate layers
|
|
13
|
+
* - instance-lifecycle.ts for resolved execution configuration
|
|
14
|
+
*/
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Profile definitions
|
|
17
|
+
// ============================================================================
|
|
18
|
+
const PROTOTYPE_PROFILE = {
|
|
19
|
+
gatesEnabled: { deterministic: true, behavioral: false, adversarial: false },
|
|
20
|
+
maxIterations: 2,
|
|
21
|
+
auditDepth: 'shallow',
|
|
22
|
+
conformanceChecks: false,
|
|
23
|
+
operationalNotes: 'Prototype mode: prioritize speed over thoroughness. ' +
|
|
24
|
+
'Skip behavioral and adversarial gates. ' +
|
|
25
|
+
'Use minimal iterations to produce a working proof-of-concept quickly.',
|
|
26
|
+
strategyDesignGuidance: 'This is a prototype spec. Prefer fewer strategies with broader scope. ' +
|
|
27
|
+
'Speed is prioritized over completeness. A single strategy covering ' +
|
|
28
|
+
'the full scope is acceptable.',
|
|
29
|
+
planningGuidance: 'Speed emphasis: plan for quick iteration, minimal test coverage, ' +
|
|
30
|
+
'focus on demonstrating core functionality.',
|
|
31
|
+
};
|
|
32
|
+
const MVP_PROFILE = {
|
|
33
|
+
gatesEnabled: { deterministic: true, behavioral: true, adversarial: true },
|
|
34
|
+
maxIterations: -1, // sentinel: use blueprint default
|
|
35
|
+
auditDepth: 'standard',
|
|
36
|
+
conformanceChecks: false,
|
|
37
|
+
operationalNotes: 'MVP mode: balance scope coverage with delivery speed. ' +
|
|
38
|
+
'Run all gate layers to ensure quality. ' +
|
|
39
|
+
'Focus on delivering a complete, shippable feature set.',
|
|
40
|
+
strategyDesignGuidance: 'This is an MVP spec. Create well-bounded strategies with clear scope ' +
|
|
41
|
+
'boundaries. Completeness within the narrow use case scope is critical. ' +
|
|
42
|
+
'Each strategy should cover a distinct functional area.',
|
|
43
|
+
planningGuidance: 'Scope emphasis: plan for complete coverage of the defined use cases. ' +
|
|
44
|
+
'Each work unit should map to a specific use case flow.',
|
|
45
|
+
};
|
|
46
|
+
const EXTEND_EXISTING_PROFILE = {
|
|
47
|
+
gatesEnabled: { deterministic: true, behavioral: true, adversarial: true },
|
|
48
|
+
maxIterations: -1, // sentinel: use blueprint default
|
|
49
|
+
auditDepth: 'deep',
|
|
50
|
+
conformanceChecks: true,
|
|
51
|
+
operationalNotes: 'Extend-existing mode: deep audit emphasis. ' +
|
|
52
|
+
'Run all gates plus conformance checks against the existing codebase. ' +
|
|
53
|
+
'Carefully verify that new work integrates without regressions.',
|
|
54
|
+
strategyDesignGuidance: 'This is an extend-existing spec. Strategies must respect existing code ' +
|
|
55
|
+
'boundaries and architecture conventions. Convention adherence is critical. ' +
|
|
56
|
+
'Align strategies to existing module/package boundaries where possible.',
|
|
57
|
+
planningGuidance: 'Audit emphasis: plan work units that integrate with existing patterns. ' +
|
|
58
|
+
'Each work unit should include conformance verification against existing ' +
|
|
59
|
+
'code style and architecture.',
|
|
60
|
+
};
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Resolver
|
|
63
|
+
// ============================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Resolve an execution profile for a given spec type and blueprint.
|
|
66
|
+
*
|
|
67
|
+
* - `prototype`: deterministic gates only, 2 iterations max, shallow audit
|
|
68
|
+
* - `mvp`: all gates, blueprint-default iterations, standard audit
|
|
69
|
+
* - `extend_existing`: all gates + conformance checks, blueprint-default iterations, deep audit
|
|
70
|
+
* - `null` / unknown: returns blueprint defaults unchanged
|
|
71
|
+
*/
|
|
72
|
+
export function resolveExecutionProfile(specType, blueprint) {
|
|
73
|
+
// Determine the base profile
|
|
74
|
+
let profile;
|
|
75
|
+
switch (specType) {
|
|
76
|
+
case 'prototype':
|
|
77
|
+
profile = { ...PROTOTYPE_PROFILE };
|
|
78
|
+
break;
|
|
79
|
+
case 'mvp':
|
|
80
|
+
profile = { ...MVP_PROFILE };
|
|
81
|
+
break;
|
|
82
|
+
case 'extend_existing':
|
|
83
|
+
profile = { ...EXTEND_EXISTING_PROFILE };
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
// null or unrecognized: derive profile entirely from blueprint defaults
|
|
87
|
+
return buildBlueprintDefaultProfile(blueprint);
|
|
88
|
+
}
|
|
89
|
+
// Replace sentinel maxIterations with the blueprint's configured value
|
|
90
|
+
if (profile.maxIterations === -1 && blueprint) {
|
|
91
|
+
profile.maxIterations = blueprint.maxIterationsPerWorkUnit ?? 5;
|
|
92
|
+
}
|
|
93
|
+
else if (profile.maxIterations === -1) {
|
|
94
|
+
profile.maxIterations = 5;
|
|
95
|
+
}
|
|
96
|
+
// Copy gatesEnabled as a new object to avoid mutating the constant
|
|
97
|
+
profile.gatesEnabled = { ...profile.gatesEnabled };
|
|
98
|
+
return profile;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build a default execution profile from blueprint configuration.
|
|
102
|
+
* Used when spec_type is null or unrecognized.
|
|
103
|
+
*/
|
|
104
|
+
function buildBlueprintDefaultProfile(blueprint) {
|
|
105
|
+
if (!blueprint) {
|
|
106
|
+
return {
|
|
107
|
+
gatesEnabled: { deterministic: true, behavioral: false, adversarial: false },
|
|
108
|
+
maxIterations: 5,
|
|
109
|
+
auditDepth: 'standard',
|
|
110
|
+
conformanceChecks: false,
|
|
111
|
+
operationalNotes: '',
|
|
112
|
+
strategyDesignGuidance: '',
|
|
113
|
+
planningGuidance: '',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const enabledSet = new Set(blueprint.gatesEnabled);
|
|
117
|
+
return {
|
|
118
|
+
gatesEnabled: {
|
|
119
|
+
deterministic: enabledSet.has('deterministic'),
|
|
120
|
+
behavioral: enabledSet.has('behavioral'),
|
|
121
|
+
adversarial: enabledSet.has('adversarial'),
|
|
122
|
+
},
|
|
123
|
+
maxIterations: blueprint.maxIterationsPerWorkUnit ?? 5,
|
|
124
|
+
auditDepth: 'standard',
|
|
125
|
+
conformanceChecks: false,
|
|
126
|
+
operationalNotes: blueprint.operationalNotes ?? '',
|
|
127
|
+
strategyDesignGuidance: '',
|
|
128
|
+
planningGuidance: '',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=spec-profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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tB,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,EAAE;YACpB,sBAAsB,EAAE,EAAE;YAC1B,gBAAgB,EAAE,EAAE;SACrB,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO;QACL,YAAY,EAAE;YACZ,aAAa,EAAE,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC;YAC9C,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC;YACxC,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC;SAC3C;QACD,aAAa,EAAE,SAAS,CAAC,wBAAwB,IAAI,CAAC;QACtD,UAAU,EAAE,UAAU;QACtB,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,IAAI,EAAE;QAClD,sBAAsB,EAAE,EAAE;QAC1B,gBAAgB,EAAE,EAAE;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy dependency graph builder and interface contract validation.
|
|
3
|
+
*
|
|
4
|
+
* Builds a validated DAG from persisted strategies, computes topological
|
|
5
|
+
* execution order, identifies independent subgraphs, and validates that
|
|
6
|
+
* consumed artifacts are produced by declared dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import type { ContractValidationResult, StrategyDependencyGraph, StrategyGraphInput } from './strategy-design-schema.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a validated dependency graph from persisted strategies.
|
|
11
|
+
*
|
|
12
|
+
* Produces a DAG with topological execution order and identifies independent
|
|
13
|
+
* subgraphs that can execute in parallel.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildStrategyDependencyGraph(strategies: StrategyGraphInput[]): StrategyDependencyGraph;
|
|
16
|
+
/**
|
|
17
|
+
* Validate interface contracts across dependency edges.
|
|
18
|
+
*
|
|
19
|
+
* For each dependency edge (A depends on B), checks whether every item
|
|
20
|
+
* in A's consumes list has a matching item in B's produces list.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateInterfaceContracts(graph: StrategyDependencyGraph): ContractValidationResult;
|
|
23
|
+
//# sourceMappingURL=strategy-design-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-design-graph.d.ts","sourceRoot":"","sources":["../src/strategy-design-graph.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEV,wBAAwB,EAExB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,6BAA6B,CAAC;AAMrC;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,kBAAkB,EAAE,GAC/B,uBAAuB,CAgGzB;AAMD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,uBAAuB,GAC7B,wBAAwB,CAyG1B"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy dependency graph builder and interface contract validation.
|
|
3
|
+
*
|
|
4
|
+
* Builds a validated DAG from persisted strategies, computes topological
|
|
5
|
+
* execution order, identifies independent subgraphs, and validates that
|
|
6
|
+
* consumed artifacts are produced by declared dependencies.
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Dependency graph builder
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Build a validated dependency graph from persisted strategies.
|
|
13
|
+
*
|
|
14
|
+
* Produces a DAG with topological execution order and identifies independent
|
|
15
|
+
* subgraphs that can execute in parallel.
|
|
16
|
+
*/
|
|
17
|
+
export function buildStrategyDependencyGraph(strategies) {
|
|
18
|
+
// Build nodes with reverse edges
|
|
19
|
+
const nodes = new Map();
|
|
20
|
+
for (const s of strategies) {
|
|
21
|
+
nodes.set(s.strategyId, {
|
|
22
|
+
strategyId: s.strategyId,
|
|
23
|
+
name: s.name,
|
|
24
|
+
dependsOn: s.dependsOn,
|
|
25
|
+
dependedOnBy: [],
|
|
26
|
+
interfaceContract: s.interfaceContract,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Compute reverse edges (dependedOnBy)
|
|
30
|
+
for (const node of nodes.values()) {
|
|
31
|
+
for (const depId of node.dependsOn) {
|
|
32
|
+
const depNode = nodes.get(depId);
|
|
33
|
+
if (depNode) {
|
|
34
|
+
depNode.dependedOnBy.push(node.strategyId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Topological sort (Kahn's algorithm)
|
|
39
|
+
const inDegree = new Map();
|
|
40
|
+
for (const node of nodes.values()) {
|
|
41
|
+
inDegree.set(node.strategyId, node.dependsOn.length);
|
|
42
|
+
}
|
|
43
|
+
const queue = [];
|
|
44
|
+
for (const [id, degree] of inDegree) {
|
|
45
|
+
if (degree === 0)
|
|
46
|
+
queue.push(id);
|
|
47
|
+
}
|
|
48
|
+
const executionOrder = [];
|
|
49
|
+
while (queue.length > 0) {
|
|
50
|
+
const current = queue.shift();
|
|
51
|
+
executionOrder.push(current);
|
|
52
|
+
const node = nodes.get(current);
|
|
53
|
+
for (const dependentId of node.dependedOnBy) {
|
|
54
|
+
const newDegree = (inDegree.get(dependentId) ?? 1) - 1;
|
|
55
|
+
inDegree.set(dependentId, newDegree);
|
|
56
|
+
if (newDegree === 0) {
|
|
57
|
+
queue.push(dependentId);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (executionOrder.length !== nodes.size) {
|
|
62
|
+
throw new Error(`Cycle detected in strategy dependency graph: ` +
|
|
63
|
+
`only ${executionOrder.length} of ${nodes.size} strategies could be ordered`);
|
|
64
|
+
}
|
|
65
|
+
// Identify independent subgraphs (connected components via union-find)
|
|
66
|
+
const parent = new Map();
|
|
67
|
+
for (const id of nodes.keys()) {
|
|
68
|
+
parent.set(id, id);
|
|
69
|
+
}
|
|
70
|
+
function find(x) {
|
|
71
|
+
while (parent.get(x) !== x) {
|
|
72
|
+
const p = parent.get(x);
|
|
73
|
+
parent.set(x, parent.get(p)); // path compression
|
|
74
|
+
x = p;
|
|
75
|
+
}
|
|
76
|
+
return x;
|
|
77
|
+
}
|
|
78
|
+
function union(a, b) {
|
|
79
|
+
const rootA = find(a);
|
|
80
|
+
const rootB = find(b);
|
|
81
|
+
if (rootA !== rootB) {
|
|
82
|
+
parent.set(rootA, rootB);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const node of nodes.values()) {
|
|
86
|
+
for (const depId of node.dependsOn) {
|
|
87
|
+
union(node.strategyId, depId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Group by root
|
|
91
|
+
const groups = new Map();
|
|
92
|
+
for (const id of nodes.keys()) {
|
|
93
|
+
const root = find(id);
|
|
94
|
+
if (!groups.has(root))
|
|
95
|
+
groups.set(root, []);
|
|
96
|
+
groups.get(root).push(id);
|
|
97
|
+
}
|
|
98
|
+
const independentSubgraphs = Array.from(groups.values());
|
|
99
|
+
return { nodes, executionOrder, independentSubgraphs };
|
|
100
|
+
}
|
|
101
|
+
// ============================================================================
|
|
102
|
+
// Interface contract validation
|
|
103
|
+
// ============================================================================
|
|
104
|
+
/**
|
|
105
|
+
* Validate interface contracts across dependency edges.
|
|
106
|
+
*
|
|
107
|
+
* For each dependency edge (A depends on B), checks whether every item
|
|
108
|
+
* in A's consumes list has a matching item in B's produces list.
|
|
109
|
+
*/
|
|
110
|
+
export function validateInterfaceContracts(graph) {
|
|
111
|
+
const errors = [];
|
|
112
|
+
const warnings = [];
|
|
113
|
+
// Pre-index produces and consumes items per strategy for O(1) lookup: strategyId -> Set<"kind:identifier">
|
|
114
|
+
const producesIndex = new Map();
|
|
115
|
+
const consumesIndex = new Map();
|
|
116
|
+
for (const node of graph.nodes.values()) {
|
|
117
|
+
if (node.interfaceContract) {
|
|
118
|
+
const pSet = new Set();
|
|
119
|
+
for (const p of node.interfaceContract.produces) {
|
|
120
|
+
pSet.add(`${p.kind}:${p.identifier}`);
|
|
121
|
+
}
|
|
122
|
+
producesIndex.set(node.strategyId, pSet);
|
|
123
|
+
const cSet = new Set();
|
|
124
|
+
for (const c of node.interfaceContract.consumes) {
|
|
125
|
+
cSet.add(`${c.kind}:${c.identifier}`);
|
|
126
|
+
}
|
|
127
|
+
consumesIndex.set(node.strategyId, cSet);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const node of graph.nodes.values()) {
|
|
131
|
+
const contract = node.interfaceContract;
|
|
132
|
+
if (!contract)
|
|
133
|
+
continue;
|
|
134
|
+
// Check: strategy has dependencies but empty consumes
|
|
135
|
+
if (node.dependsOn.length > 0 && contract.consumes.length === 0) {
|
|
136
|
+
warnings.push({
|
|
137
|
+
strategyId: node.strategyId,
|
|
138
|
+
message: `Strategy "${node.name}" depends on ${node.dependsOn.length} other strategy(ies) but declares no consumed artifacts`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// For each consumed item, check if any dependency produces it
|
|
142
|
+
for (const consumed of contract.consumes) {
|
|
143
|
+
let satisfied = false;
|
|
144
|
+
const consumedKey = `${consumed.kind}:${consumed.identifier}`;
|
|
145
|
+
for (const depId of node.dependsOn) {
|
|
146
|
+
const depNode = graph.nodes.get(depId);
|
|
147
|
+
if (!depNode) {
|
|
148
|
+
errors.push({
|
|
149
|
+
consumerStrategyId: node.strategyId,
|
|
150
|
+
producerStrategyId: depId,
|
|
151
|
+
consumedItem: consumed,
|
|
152
|
+
reason: `Strategy "${node.name}" depends on strategy "${depId}" ` +
|
|
153
|
+
`which is missing from the dependency graph`,
|
|
154
|
+
});
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const depProduces = producesIndex.get(depId);
|
|
158
|
+
if (!depProduces)
|
|
159
|
+
continue;
|
|
160
|
+
if (depProduces.has(consumedKey)) {
|
|
161
|
+
satisfied = true;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (!satisfied) {
|
|
166
|
+
const depNames = node.dependsOn
|
|
167
|
+
.map((id) => graph.nodes.get(id)?.name ?? id)
|
|
168
|
+
.join(', ');
|
|
169
|
+
errors.push({
|
|
170
|
+
consumerStrategyId: node.strategyId,
|
|
171
|
+
producerStrategyId: node.dependsOn[0] ?? '',
|
|
172
|
+
consumedItem: consumed,
|
|
173
|
+
reason: `Strategy "${node.name}" consumes ${consumed.kind} "${consumed.identifier}" ` +
|
|
174
|
+
`but none of its dependencies (${depNames}) declare it as a produced artifact`,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Check: orphaned produces (no consumer needs them) -- advisory only
|
|
179
|
+
if (node.dependedOnBy.length > 0) {
|
|
180
|
+
for (const produced of contract.produces) {
|
|
181
|
+
const producedKey = `${produced.kind}:${produced.identifier}`;
|
|
182
|
+
let isConsumed = false;
|
|
183
|
+
for (const dependentId of node.dependedOnBy) {
|
|
184
|
+
const depConsumes = consumesIndex.get(dependentId);
|
|
185
|
+
if (depConsumes?.has(producedKey)) {
|
|
186
|
+
isConsumed = true;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!isConsumed) {
|
|
191
|
+
warnings.push({
|
|
192
|
+
strategyId: node.strategyId,
|
|
193
|
+
message: `Strategy "${node.name}" produces ${produced.kind} "${produced.identifier}" but no dependent strategy consumes it`,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
valid: errors.length === 0,
|
|
201
|
+
errors,
|
|
202
|
+
warnings,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=strategy-design-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-design-graph.js","sourceRoot":"","sources":["../src/strategy-design-graph.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,+EAA+E;A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;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy design prompt builders.
|
|
3
|
+
*
|
|
4
|
+
* Constructs the AI prompts for decomposing specifications into bounded
|
|
5
|
+
* strategies with dependency edges and interface contracts.
|
|
6
|
+
*/
|
|
7
|
+
import type { FactoryBlueprint, SpecType } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Build the prompt that instructs Claude Code to decompose a specification
|
|
10
|
+
* into bounded strategies with dependency edges and interface contracts.
|
|
11
|
+
*
|
|
12
|
+
* Follows the same structure as buildPlanningPrompt() in planning.ts:
|
|
13
|
+
* role, blueprint metadata, resource limits, specification, audit results,
|
|
14
|
+
* instructions, and output format.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildStrategyDesignPrompt(specification: string, blueprint: FactoryBlueprint, auditReport?: string | null, specType?: SpecType | null, reviewGaps?: Array<{
|
|
17
|
+
area: string;
|
|
18
|
+
description: string;
|
|
19
|
+
severity: string;
|
|
20
|
+
suggestedFix: string;
|
|
21
|
+
}> | null): string;
|
|
22
|
+
/**
|
|
23
|
+
* Build a retry prompt that includes the original prompt and the validation error.
|
|
24
|
+
*
|
|
25
|
+
* Gives the AI context about what went wrong so it can correct its output.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildStrategyRetryPrompt(originalPrompt: string, validationError: string): string;
|
|
28
|
+
//# sourceMappingURL=strategy-design-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-design-prompt.d.ts","sourceRoot":"","sources":["../src/strategy-design-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM7D;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,gBAAgB,EAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC1B,UAAU,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,GACvG,MAAM,CAgQR;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,MAAM,CAaR"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy design prompt builders.
|
|
3
|
+
*
|
|
4
|
+
* Constructs the AI prompts for decomposing specifications into bounded
|
|
5
|
+
* strategies with dependency edges and interface contracts.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveExecutionProfile } from './spec-profiles.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Prompt builders
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Build the prompt that instructs Claude Code to decompose a specification
|
|
13
|
+
* into bounded strategies with dependency edges and interface contracts.
|
|
14
|
+
*
|
|
15
|
+
* Follows the same structure as buildPlanningPrompt() in planning.ts:
|
|
16
|
+
* role, blueprint metadata, resource limits, specification, audit results,
|
|
17
|
+
* instructions, and output format.
|
|
18
|
+
*/
|
|
19
|
+
export function buildStrategyDesignPrompt(specification, blueprint, auditReport, specType, reviewGaps) {
|
|
20
|
+
const parts = [
|
|
21
|
+
'You are a strategy design agent for a software factory system.',
|
|
22
|
+
'Your task is to analyze the following specification and decompose it into bounded strategies.',
|
|
23
|
+
'Each strategy represents a coherent production line -- a subset of the specification that can',
|
|
24
|
+
'be planned and executed independently (or with explicit dependency ordering).',
|
|
25
|
+
'',
|
|
26
|
+
'## Blueprint',
|
|
27
|
+
`Name: ${blueprint.name}`,
|
|
28
|
+
];
|
|
29
|
+
if (blueprint.operationalNotes) {
|
|
30
|
+
parts.push('', '## Operational Notes', blueprint.operationalNotes);
|
|
31
|
+
}
|
|
32
|
+
// Inject spec type guidance from execution profile
|
|
33
|
+
const profile = resolveExecutionProfile(specType ?? null);
|
|
34
|
+
if (profile.strategyDesignGuidance) {
|
|
35
|
+
parts.push('', '## Spec Type', profile.strategyDesignGuidance);
|
|
36
|
+
}
|
|
37
|
+
// Inject resource limits so the AI designs strategies within constraints
|
|
38
|
+
const limits = [];
|
|
39
|
+
if (blueprint.maxWorkUnits !== null) {
|
|
40
|
+
limits.push(`- Maximum work units (total across all strategies): ${blueprint.maxWorkUnits}`);
|
|
41
|
+
}
|
|
42
|
+
if (blueprint.maxTokenBudget !== null) {
|
|
43
|
+
limits.push(`- Token budget for entire instance: ${blueprint.maxTokenBudget}`);
|
|
44
|
+
}
|
|
45
|
+
if (blueprint.maxWallClockHours !== null) {
|
|
46
|
+
limits.push(`- Wall-clock time limit: ${blueprint.maxWallClockHours} hours`);
|
|
47
|
+
}
|
|
48
|
+
if (limits.length > 0) {
|
|
49
|
+
parts.push('', '## Resource Limits', ...limits);
|
|
50
|
+
}
|
|
51
|
+
parts.push('', '## Specification', specification);
|
|
52
|
+
// Inject audit results when available (from pre-designing codebase audit)
|
|
53
|
+
if (auditReport) {
|
|
54
|
+
parts.push('', '## Codebase Audit Results', '', 'The following audit was performed against the existing codebase.', 'Use this to understand what already exists and avoid duplicating work.', '', auditReport, '', 'IMPORTANT:', '- Do NOT create strategies for features that are already fully implemented', '- For partial implementations, scope strategies to complete only the missing parts', '- If the audit identifies conflicts, include strategies to resolve them');
|
|
55
|
+
}
|
|
56
|
+
// Inject review gap constraints when re-engineering after a review cycle
|
|
57
|
+
if (reviewGaps && reviewGaps.length > 0) {
|
|
58
|
+
const critical = reviewGaps.filter((g) => g.severity === 'critical');
|
|
59
|
+
const important = reviewGaps.filter((g) => g.severity === 'important');
|
|
60
|
+
const gapLines = [
|
|
61
|
+
'## Review Gaps -- Constrained Scope',
|
|
62
|
+
'',
|
|
63
|
+
'The review phase identified the following gaps. Your strategies MUST focus exclusively on',
|
|
64
|
+
'closing these gaps. Do NOT design strategies for work already completed, add new features,',
|
|
65
|
+
'or expand scope beyond what is listed here.',
|
|
66
|
+
'',
|
|
67
|
+
];
|
|
68
|
+
if (critical.length > 0) {
|
|
69
|
+
gapLines.push('### Critical (must fix)');
|
|
70
|
+
for (const g of critical) {
|
|
71
|
+
gapLines.push(`- **${g.area}**: ${g.description}`);
|
|
72
|
+
gapLines.push(` Suggested fix: ${g.suggestedFix}`);
|
|
73
|
+
}
|
|
74
|
+
gapLines.push('');
|
|
75
|
+
}
|
|
76
|
+
if (important.length > 0) {
|
|
77
|
+
gapLines.push('### Important (should fix)');
|
|
78
|
+
for (const g of important) {
|
|
79
|
+
gapLines.push(`- **${g.area}**: ${g.description}`);
|
|
80
|
+
gapLines.push(` Suggested fix: ${g.suggestedFix}`);
|
|
81
|
+
}
|
|
82
|
+
gapLines.push('');
|
|
83
|
+
}
|
|
84
|
+
parts.push('', ...gapLines);
|
|
85
|
+
}
|
|
86
|
+
parts.push('', '## Instructions', '', 'Analyze the specification and decompose it into bounded strategies.', '', '### What is a Strategy?', 'A strategy is a bounded production line -- a coherent subset of the specification', 'that can be planned into work units and executed by a single agent team.', '', 'Good strategy boundaries:', '- Each strategy has a clear, self-contained scope (e.g. "Backend API layer",', ' "Frontend dashboard UI", "Database schema and migrations")', '- Strategies map to logical subsystems, layers, or feature groups', '- Each strategy can be planned independently once its dependencies are met', '- A strategy should be substantial enough to warrant its own planning phase', ' but small enough that a single team can execute it', '', 'Bad strategy boundaries:', '- Too granular (individual functions or files)', '- Too broad (the entire specification as one strategy)', '- Overlapping scope (two strategies that modify the same files)', '- Verification-only scope (a strategy whose sole purpose is running tests,', ' confirming npm commands exit 0, or inspecting behavior)', '', '### Strategies Are BUILD Plans, Not Verification Plans', 'Every strategy must produce artifacts -- files, code, APIs, schemas.', 'A strategy that produces nothing except confirmation that something works is wrong.', '', 'The factory gate system runs verification automatically after each work unit:', 'npm test, typecheck, lint, build, and behavioral checks all execute as gates.', 'You do NOT need to design strategies or work units for any of these.', '', 'Do NOT create strategies named or scoped like:', ' "Verification and Acceptance", "Acceptance Testing", "Test Validation",', ' "End-to-End Verification", "QA", or any variant whose description involves', ' running commands to confirm the implementation works.', '', 'If the specification includes acceptance criteria, those criteria are inputs to', 'the gate configuration -- they are not a strategy to execute.', '', '### Dependency Edges', 'Use the `dependsOn` field to express ordering constraints between strategies.', 'Strategy A depends on strategy B if A needs B\'s output to proceed.', '', 'Strategies that are independent of each other should NOT have dependency edges.', 'Independent strategies can execute in parallel, which is more efficient.', '', '### Foundational Infrastructure', 'If the spec requires shared infrastructure (database connections, server entry points,', 'shared utilities, configuration, ORM setup, message queue clients, etc.), you MUST', 'create an explicit root strategy — with no dependencies — that produces these foundational', 'artifacts. All other strategies that need these artifacts must declare this root strategy', 'as a dependency and list the artifacts in their consumes array.', '', 'Example root strategy names: "Project Scaffolding", "Shared Infrastructure",', '"Foundation Layer", "Core Data Layer".', '', 'Do NOT list a file or export in a strategy\'s consumes array unless another strategy in', 'the plan explicitly produces it. If you need a file to exist, there must be a strategy', 'that produces it.', '', '### Interface Contracts', 'Each strategy must declare an interfaceContract with:', '- produces: artifacts this strategy will create (files, exports, API endpoints, DB tables, types)', '- consumes: artifacts this strategy needs from its dependencies', '', 'Valid artifact kinds: "file", "export", "api_endpoint", "db_table", "type".', 'Each artifact has a kind and identifier. Strategies with no dependencies should have', 'an empty consumes array. Terminal strategies may have an empty produces array.', '', 'Also declare top-level interfaceContracts between strategies to describe cross-strategy', 'relationships explicitly.', '', '### Technical Context', 'Each strategy should include technical context: the relevant tech stack, key files,', 'directories, and architecture notes. This context will be passed to the planning', 'phase so the agent team understands the scope.', '', '### What Belongs in Strategy Descriptions', 'Strategy descriptions and techContext must describe WHAT a component does and its', 'functional scope -- not HOW it is named internally.', '', 'Do NOT carry into strategy descriptions:', '- Specific internal method names, private function names, or internal constant names', ' (e.g. do not write "must use pressDigit() method" or "token types PLUS, MINUS, STAR")', '- Internal file organization details within a module', '- Implementation approach prescriptions that do not affect the external interface', '', 'DO include:', '- What the component is responsible for (its functional role)', '- What it exposes externally (exported API, HTTP endpoints, DB tables, CLI commands)', '- What it consumes from dependencies', '- Technology and directory context so the planning agent knows where to work', '', 'If the specification contains internal naming details, omit them. The team will make', 'appropriate naming decisions during implementation.', '', '## Output Format', 'Return ONLY a JSON object (no markdown fencing, no commentary) with this exact structure:', '```', '{', ' "strategies": [', ' {', ' "tempId": "s-0",', ' "name": "Database Schema and Migrations",', ' "description": "Implements the database layer: tables, indexes, RLS policies, and migrations",', ' "techContext": "PostgreSQL via Supabase. Key dirs: supabase/migrations/, src/integrations/supabase/",', ' "priorityRank": 0,', ' "dependsOn": [],', ' "interfaceContract": {', ' "produces": [', ' { "kind": "db_table", "identifier": "users", "description": "Users table with id, email, created_at" },', ' { "kind": "file", "identifier": "supabase/migrations/001_users.sql" }', ' ],', ' "consumes": []', ' }', ' },', ' {', ' "tempId": "s-1",', ' "name": "Backend API Endpoints",', ' "description": "Edge function handlers for the new feature",', ' "techContext": "Supabase Edge Functions (Deno). Key dir: supabase/functions/product-api/",', ' "priorityRank": 1,', ' "dependsOn": ["s-0"],', ' "interfaceContract": {', ' "produces": [', ' { "kind": "api_endpoint", "identifier": "POST /users", "description": "Create user endpoint" }', ' ],', ' "consumes": [', ' { "kind": "db_table", "identifier": "users", "description": "Needs the users table from s-0" }', ' ]', ' }', ' }', ' ],', ' "interfaceContracts": [', ' {', ' "name": "User table schema",', ' "provider": "s-0",', ' "consumer": "s-1",', ' "description": "s-1 expects a users table with columns: id, email, created_at"', ' }', ' ],', ' "summary": "Decomposed into 2 strategies: DB layer first, then API layer that depends on it."', '}', '```', '', 'Rules:', '- Each tempId must be unique (e.g. "s-0", "s-1", "s-2", ...)', '- priorityRank must start at 0 and increment by 1', '- dependsOn must only reference tempIds of other strategies in the plan', '- Every strategy must have a non-empty name, description, and techContext', '- Every strategy must have an interfaceContract with produces and consumes arrays', '- Interface contracts must reference valid strategy tempIds for provider and consumer', '- Return at least one strategy', '- If the specification is small and tightly coupled, a single strategy is acceptable', '- Return ONLY the JSON object, nothing else');
|
|
87
|
+
return parts.join('\n');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build a retry prompt that includes the original prompt and the validation error.
|
|
91
|
+
*
|
|
92
|
+
* Gives the AI context about what went wrong so it can correct its output.
|
|
93
|
+
*/
|
|
94
|
+
export function buildStrategyRetryPrompt(originalPrompt, validationError) {
|
|
95
|
+
return [
|
|
96
|
+
originalPrompt,
|
|
97
|
+
'',
|
|
98
|
+
'## RETRY -- Previous Attempt Failed',
|
|
99
|
+
'',
|
|
100
|
+
'Your previous strategy design was rejected with the following error:',
|
|
101
|
+
'',
|
|
102
|
+
validationError,
|
|
103
|
+
'',
|
|
104
|
+
'Please fix the issue and produce a corrected strategy design.',
|
|
105
|
+
'Return ONLY the JSON object, nothing else.',
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=strategy-design-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-design-prompt.js","sourceRoot":"","sources":["../src/strategy-design-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,aAAqB,EACrB,SAA2B,EAC3B,WAA2B,EAC3B,QAA0B,EAC1B,UAAwG;IAExG,MAAM,KAAK,GAAa;QACtB,gEAAgE;QAChE,+FAA+F;QAC/F,+FAA+F;QAC/F,+EAA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