@ai-sdlc/orchestrator 0.1.0

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 (203) hide show
  1. package/dist/adapters.d.ts +60 -0
  2. package/dist/adapters.js +160 -0
  3. package/dist/admission.d.ts +49 -0
  4. package/dist/admission.js +90 -0
  5. package/dist/analysis/analyzer.d.ts +10 -0
  6. package/dist/analysis/analyzer.js +67 -0
  7. package/dist/analysis/complexity-scorer.d.ts +24 -0
  8. package/dist/analysis/complexity-scorer.js +39 -0
  9. package/dist/analysis/context-builder.d.ts +14 -0
  10. package/dist/analysis/context-builder.js +79 -0
  11. package/dist/analysis/convention-detector.d.ts +9 -0
  12. package/dist/analysis/convention-detector.js +177 -0
  13. package/dist/analysis/dependency-parser.d.ts +17 -0
  14. package/dist/analysis/dependency-parser.js +167 -0
  15. package/dist/analysis/file-walker.d.ts +18 -0
  16. package/dist/analysis/file-walker.js +158 -0
  17. package/dist/analysis/hotspot-analyzer.d.ts +28 -0
  18. package/dist/analysis/hotspot-analyzer.js +85 -0
  19. package/dist/analysis/index.d.ts +13 -0
  20. package/dist/analysis/index.js +12 -0
  21. package/dist/analysis/pattern-detector.d.ts +10 -0
  22. package/dist/analysis/pattern-detector.js +86 -0
  23. package/dist/analysis/types.d.ts +94 -0
  24. package/dist/analysis/types.js +5 -0
  25. package/dist/audit-archival.d.ts +48 -0
  26. package/dist/audit-archival.js +72 -0
  27. package/dist/audit-export.d.ts +45 -0
  28. package/dist/audit-export.js +100 -0
  29. package/dist/audit-extended.d.ts +28 -0
  30. package/dist/audit-extended.js +38 -0
  31. package/dist/audit-scheduler.d.ts +32 -0
  32. package/dist/audit-scheduler.js +52 -0
  33. package/dist/audit-sqlite-sink.d.ts +11 -0
  34. package/dist/audit-sqlite-sink.js +51 -0
  35. package/dist/autonomy-tracker.d.ts +76 -0
  36. package/dist/autonomy-tracker.js +277 -0
  37. package/dist/check-runs.d.ts +37 -0
  38. package/dist/check-runs.js +72 -0
  39. package/dist/cli/commands/agents.d.ts +6 -0
  40. package/dist/cli/commands/agents.js +33 -0
  41. package/dist/cli/commands/complexity.d.ts +6 -0
  42. package/dist/cli/commands/complexity.js +35 -0
  43. package/dist/cli/commands/cost.d.ts +6 -0
  44. package/dist/cli/commands/cost.js +53 -0
  45. package/dist/cli/commands/dashboard.d.ts +9 -0
  46. package/dist/cli/commands/dashboard.js +50 -0
  47. package/dist/cli/commands/health.d.ts +6 -0
  48. package/dist/cli/commands/health.js +33 -0
  49. package/dist/cli/commands/init.d.ts +6 -0
  50. package/dist/cli/commands/init.js +127 -0
  51. package/dist/cli/commands/routing.d.ts +6 -0
  52. package/dist/cli/commands/routing.js +46 -0
  53. package/dist/cli/commands/run.d.ts +6 -0
  54. package/dist/cli/commands/run.js +36 -0
  55. package/dist/cli/commands/start.d.ts +6 -0
  56. package/dist/cli/commands/start.js +26 -0
  57. package/dist/cli/commands/status.d.ts +6 -0
  58. package/dist/cli/commands/status.js +34 -0
  59. package/dist/cli/dashboard-renderer.d.ts +24 -0
  60. package/dist/cli/dashboard-renderer.js +129 -0
  61. package/dist/cli/formatters/index.d.ts +6 -0
  62. package/dist/cli/formatters/index.js +18 -0
  63. package/dist/cli/formatters/json.d.ts +5 -0
  64. package/dist/cli/formatters/json.js +7 -0
  65. package/dist/cli/formatters/minimal.d.ts +5 -0
  66. package/dist/cli/formatters/minimal.js +36 -0
  67. package/dist/cli/formatters/table.d.ts +5 -0
  68. package/dist/cli/formatters/table.js +184 -0
  69. package/dist/cli/index.d.ts +6 -0
  70. package/dist/cli/index.js +35 -0
  71. package/dist/compliance-extended.d.ts +41 -0
  72. package/dist/compliance-extended.js +58 -0
  73. package/dist/config.d.ts +26 -0
  74. package/dist/config.js +66 -0
  75. package/dist/context-enrichment.d.ts +33 -0
  76. package/dist/context-enrichment.js +125 -0
  77. package/dist/cost-governance.d.ts +22 -0
  78. package/dist/cost-governance.js +106 -0
  79. package/dist/cost-tracker.d.ts +75 -0
  80. package/dist/cost-tracker.js +177 -0
  81. package/dist/defaults.d.ts +140 -0
  82. package/dist/defaults.js +218 -0
  83. package/dist/deploy/flyio-target.d.ts +19 -0
  84. package/dist/deploy/flyio-target.js +114 -0
  85. package/dist/deploy/index.d.ts +15 -0
  86. package/dist/deploy/index.js +11 -0
  87. package/dist/deploy/kubernetes-target.d.ts +25 -0
  88. package/dist/deploy/kubernetes-target.js +124 -0
  89. package/dist/deploy/metrics-collector.d.ts +31 -0
  90. package/dist/deploy/metrics-collector.js +75 -0
  91. package/dist/deploy/rollout-controller.d.ts +42 -0
  92. package/dist/deploy/rollout-controller.js +192 -0
  93. package/dist/deploy/rollout-types.d.ts +86 -0
  94. package/dist/deploy/rollout-types.js +5 -0
  95. package/dist/deploy/types.d.ts +47 -0
  96. package/dist/deploy/types.js +5 -0
  97. package/dist/deploy/vercel-target.d.ts +16 -0
  98. package/dist/deploy/vercel-target.js +115 -0
  99. package/dist/discovery.d.ts +26 -0
  100. package/dist/discovery.js +46 -0
  101. package/dist/episodic-enhanced.d.ts +88 -0
  102. package/dist/episodic-enhanced.js +212 -0
  103. package/dist/execute.d.ts +81 -0
  104. package/dist/execute.js +703 -0
  105. package/dist/fix-ci.d.ts +61 -0
  106. package/dist/fix-ci.js +380 -0
  107. package/dist/handoff-executor.d.ts +61 -0
  108. package/dist/handoff-executor.js +119 -0
  109. package/dist/index.d.ts +70 -0
  110. package/dist/index.js +87 -0
  111. package/dist/instrumented.d.ts +27 -0
  112. package/dist/instrumented.js +34 -0
  113. package/dist/logger.d.ts +17 -0
  114. package/dist/logger.js +37 -0
  115. package/dist/multi-repo/impact-analyzer.d.ts +22 -0
  116. package/dist/multi-repo/impact-analyzer.js +95 -0
  117. package/dist/multi-repo/index.d.ts +5 -0
  118. package/dist/multi-repo/index.js +4 -0
  119. package/dist/multi-repo/monorepo-detector.d.ts +16 -0
  120. package/dist/multi-repo/monorepo-detector.js +246 -0
  121. package/dist/multi-repo/service-map-builder.d.ts +24 -0
  122. package/dist/multi-repo/service-map-builder.js +235 -0
  123. package/dist/multi-repo/types.d.ts +54 -0
  124. package/dist/multi-repo/types.js +5 -0
  125. package/dist/notifications/index.d.ts +4 -0
  126. package/dist/notifications/index.js +4 -0
  127. package/dist/notifications/notification-router.d.ts +62 -0
  128. package/dist/notifications/notification-router.js +206 -0
  129. package/dist/notifications/slack-messenger.d.ts +26 -0
  130. package/dist/notifications/slack-messenger.js +69 -0
  131. package/dist/notifications/teams-messenger.d.ts +21 -0
  132. package/dist/notifications/teams-messenger.js +85 -0
  133. package/dist/notifications.d.ts +13 -0
  134. package/dist/notifications.js +15 -0
  135. package/dist/orchestration.d.ts +20 -0
  136. package/dist/orchestration.js +53 -0
  137. package/dist/orchestrator.d.ts +160 -0
  138. package/dist/orchestrator.js +372 -0
  139. package/dist/otel-exporter.d.ts +37 -0
  140. package/dist/otel-exporter.js +128 -0
  141. package/dist/plugin.d.ts +45 -0
  142. package/dist/plugin.js +8 -0
  143. package/dist/policy-evaluators.d.ts +40 -0
  144. package/dist/policy-evaluators.js +57 -0
  145. package/dist/process-escalation.d.ts +38 -0
  146. package/dist/process-escalation.js +129 -0
  147. package/dist/progressive-gates.d.ts +54 -0
  148. package/dist/progressive-gates.js +135 -0
  149. package/dist/provenance.d.ts +29 -0
  150. package/dist/provenance.js +61 -0
  151. package/dist/reconcilers.d.ts +28 -0
  152. package/dist/reconcilers.js +37 -0
  153. package/dist/runners/claude-code.d.ts +17 -0
  154. package/dist/runners/claude-code.js +200 -0
  155. package/dist/runners/codex.d.ts +19 -0
  156. package/dist/runners/codex.js +153 -0
  157. package/dist/runners/copilot-stub.d.ts +9 -0
  158. package/dist/runners/copilot-stub.js +15 -0
  159. package/dist/runners/copilot.d.ts +15 -0
  160. package/dist/runners/copilot.js +119 -0
  161. package/dist/runners/cursor-stub.d.ts +9 -0
  162. package/dist/runners/cursor-stub.js +15 -0
  163. package/dist/runners/cursor.d.ts +20 -0
  164. package/dist/runners/cursor.js +140 -0
  165. package/dist/runners/devin-stub.d.ts +9 -0
  166. package/dist/runners/devin-stub.js +15 -0
  167. package/dist/runners/generic-llm.d.ts +51 -0
  168. package/dist/runners/generic-llm.js +125 -0
  169. package/dist/runners/index.d.ts +8 -0
  170. package/dist/runners/index.js +7 -0
  171. package/dist/runners/runner-registry.d.ts +50 -0
  172. package/dist/runners/runner-registry.js +156 -0
  173. package/dist/runners/types.d.ts +59 -0
  174. package/dist/runners/types.js +7 -0
  175. package/dist/security.d.ts +51 -0
  176. package/dist/security.js +70 -0
  177. package/dist/shared.d.ts +134 -0
  178. package/dist/shared.js +284 -0
  179. package/dist/state/index.d.ts +4 -0
  180. package/dist/state/index.js +3 -0
  181. package/dist/state/schema.d.ts +16 -0
  182. package/dist/state/schema.js +264 -0
  183. package/dist/state/store.d.ts +109 -0
  184. package/dist/state/store.js +644 -0
  185. package/dist/state/types.d.ts +190 -0
  186. package/dist/state/types.js +5 -0
  187. package/dist/structured-logger.d.ts +20 -0
  188. package/dist/structured-logger.js +64 -0
  189. package/dist/task-decomposer.d.ts +61 -0
  190. package/dist/task-decomposer.js +265 -0
  191. package/dist/telemetry-extended.d.ts +24 -0
  192. package/dist/telemetry-extended.js +31 -0
  193. package/dist/types.d.ts +9 -0
  194. package/dist/types.js +7 -0
  195. package/dist/validate-agent-output.d.ts +30 -0
  196. package/dist/validate-agent-output.js +81 -0
  197. package/dist/validate-issue.d.ts +25 -0
  198. package/dist/validate-issue.js +102 -0
  199. package/dist/watch.d.ts +43 -0
  200. package/dist/watch.js +99 -0
  201. package/dist/webhook-manager.d.ts +38 -0
  202. package/dist/webhook-manager.js +66 -0
  203. package/package.json +59 -0
@@ -0,0 +1,190 @@
1
+ /**
2
+ * State store types for the SQLite-backed persistence layer.
3
+ */
4
+ export interface ComplexityProfile {
5
+ id?: number;
6
+ repoPath: string;
7
+ score: number;
8
+ filesCount?: number;
9
+ modulesCount?: number;
10
+ dependencyCount?: number;
11
+ analyzedAt?: string;
12
+ rawData?: string;
13
+ /** JSON-serialized architectural patterns. */
14
+ architecturalPatterns?: string;
15
+ /** JSON-serialized hotspot data. */
16
+ hotspots?: string;
17
+ /** JSON-serialized module dependency graph. */
18
+ moduleGraph?: string;
19
+ /** JSON-serialized convention data. */
20
+ conventionsData?: string;
21
+ }
22
+ export interface EpisodicRecord {
23
+ id?: number;
24
+ issueNumber?: number;
25
+ prNumber?: number;
26
+ pipelineType: string;
27
+ outcome: string;
28
+ durationMs?: number;
29
+ filesChanged?: number;
30
+ errorMessage?: string;
31
+ metadata?: string;
32
+ createdAt?: string;
33
+ agentName?: string;
34
+ complexityScore?: number;
35
+ routingStrategy?: string;
36
+ gatePassCount?: number;
37
+ gateFailCount?: number;
38
+ costUsd?: number;
39
+ isRegression?: number;
40
+ relatedEpisodes?: string;
41
+ }
42
+ export interface AutonomyLedgerEntry {
43
+ id?: number;
44
+ agentName: string;
45
+ currentLevel: number;
46
+ totalTasks: number;
47
+ successCount: number;
48
+ failureCount: number;
49
+ lastTaskAt?: string;
50
+ metrics?: string;
51
+ prApprovalRate?: number;
52
+ rollbackCount?: number;
53
+ securityIncidents?: number;
54
+ promotedAt?: string;
55
+ demotedAt?: string;
56
+ timeAtLevelMs?: number;
57
+ }
58
+ export type PipelineRunStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
59
+ export interface PipelineRun {
60
+ id?: number;
61
+ runId: string;
62
+ issueNumber?: number;
63
+ prNumber?: number;
64
+ pipelineType: string;
65
+ status: PipelineRunStatus;
66
+ currentStage?: string;
67
+ startedAt?: string;
68
+ completedAt?: string;
69
+ result?: string;
70
+ gateResults?: string;
71
+ costUsd?: number;
72
+ tokensUsed?: number;
73
+ model?: string;
74
+ agentName?: string;
75
+ complexityScore?: number;
76
+ }
77
+ export interface Convention {
78
+ id?: number;
79
+ category: string;
80
+ pattern: string;
81
+ confidence?: number;
82
+ examples?: string;
83
+ detectedAt?: string;
84
+ }
85
+ export interface HotspotRecord {
86
+ id?: number;
87
+ repoPath: string;
88
+ filePath: string;
89
+ churnRate: number;
90
+ complexity: number;
91
+ commitCount?: number;
92
+ lastModified?: string;
93
+ note?: string;
94
+ analyzedAt?: string;
95
+ }
96
+ export interface RoutingDecision {
97
+ id?: number;
98
+ issueNumber?: number;
99
+ taskComplexity: number;
100
+ codebaseComplexity: number;
101
+ routingStrategy: string;
102
+ agentName?: string;
103
+ reason?: string;
104
+ decidedAt?: string;
105
+ }
106
+ export interface CostLedgerEntry {
107
+ id?: number;
108
+ runId: string;
109
+ agentName: string;
110
+ pipelineType: string;
111
+ model?: string;
112
+ inputTokens?: number;
113
+ outputTokens?: number;
114
+ totalTokens?: number;
115
+ costUsd?: number;
116
+ issueNumber?: number;
117
+ prNumber?: number;
118
+ stageName?: string;
119
+ cacheReadTokens?: number;
120
+ createdAt?: string;
121
+ }
122
+ export interface GateThresholdOverride {
123
+ id?: number;
124
+ gateName: string;
125
+ complexityBand: string;
126
+ enforcementLevel: string;
127
+ thresholdOverrides?: string;
128
+ active?: number;
129
+ createdAt?: string;
130
+ }
131
+ export type AutonomyEventType = 'promotion' | 'demotion' | 'evaluation' | 'reset';
132
+ export interface AutonomyEvent {
133
+ id?: number;
134
+ agentName: string;
135
+ eventType: AutonomyEventType;
136
+ fromLevel: number;
137
+ toLevel: number;
138
+ trigger?: string;
139
+ metricsSnapshot?: string;
140
+ unmetConditions?: string;
141
+ createdAt?: string;
142
+ }
143
+ export interface HandoffEvent {
144
+ id?: number;
145
+ runId: string;
146
+ fromAgent: string;
147
+ toAgent: string;
148
+ payloadHash?: string;
149
+ validationResult: string;
150
+ errorMessage?: string;
151
+ createdAt?: string;
152
+ }
153
+ export type DeploymentRecordState = 'pending' | 'deploying' | 'healthy' | 'unhealthy' | 'rolled-back' | 'failed';
154
+ export interface DeploymentRecord {
155
+ id?: number;
156
+ deploymentId: string;
157
+ targetName: string;
158
+ provider: string;
159
+ version: string;
160
+ environment: string;
161
+ state: DeploymentRecordState;
162
+ url?: string;
163
+ error?: string;
164
+ startedAt?: string;
165
+ completedAt?: string;
166
+ }
167
+ export interface RolloutStepRecord {
168
+ id?: number;
169
+ deploymentId: string;
170
+ stepNumber: number;
171
+ weightPercent: number;
172
+ state: string;
173
+ metricsSnapshot?: string;
174
+ startedAt?: string;
175
+ completedAt?: string;
176
+ }
177
+ export interface AuditEntryRecord {
178
+ id?: number;
179
+ entryId: string;
180
+ actor: string;
181
+ action: string;
182
+ resourceType?: string;
183
+ resourceId?: string;
184
+ detail?: string;
185
+ hash?: string;
186
+ previousHash?: string;
187
+ signature?: string;
188
+ createdAt?: string;
189
+ }
190
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * State store types for the SQLite-backed persistence layer.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Structured logger adapter — wraps the reference implementation's
3
+ * structured loggers to satisfy the Logger interface with timing.
4
+ */
5
+ import { createConsoleLogger, createBufferLogger, type LogEntry } from '@ai-sdlc/reference';
6
+ import type { Logger } from './logger.js';
7
+ /**
8
+ * Create a Logger backed by the reference createConsoleLogger.
9
+ */
10
+ export declare function createStructuredConsoleLogger(name?: string): Logger;
11
+ /**
12
+ * Create a Logger backed by the reference createBufferLogger.
13
+ * Captured entries can be retrieved for assertions.
14
+ */
15
+ export declare function createStructuredBufferLogger(name?: string): Logger & {
16
+ getEntries(): LogEntry[];
17
+ clear(): void;
18
+ };
19
+ export { createConsoleLogger, createBufferLogger };
20
+ //# sourceMappingURL=structured-logger.d.ts.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Structured logger adapter — wraps the reference implementation's
3
+ * structured loggers to satisfy the Logger interface with timing.
4
+ */
5
+ import { createConsoleLogger, createBufferLogger, } from '@ai-sdlc/reference';
6
+ /**
7
+ * Create a Logger backed by the reference createConsoleLogger.
8
+ */
9
+ export function createStructuredConsoleLogger(name = 'ai-sdlc') {
10
+ const structured = createConsoleLogger(name);
11
+ return wrapStructuredLogger(structured);
12
+ }
13
+ /**
14
+ * Create a Logger backed by the reference createBufferLogger.
15
+ * Captured entries can be retrieved for assertions.
16
+ */
17
+ export function createStructuredBufferLogger(name = 'ai-sdlc') {
18
+ const buffer = createBufferLogger(name);
19
+ const logger = wrapStructuredLogger(buffer);
20
+ return {
21
+ ...logger,
22
+ getEntries() {
23
+ return [...buffer.getEntries()];
24
+ },
25
+ clear() {
26
+ buffer.clear();
27
+ },
28
+ };
29
+ }
30
+ function wrapStructuredLogger(structured) {
31
+ const starts = new Map();
32
+ const durations = new Map();
33
+ const pipelineStart = performance.now();
34
+ return {
35
+ stage(name) {
36
+ starts.set(name, performance.now());
37
+ structured.info(`stage:start:${name}`, { stage: name });
38
+ },
39
+ stageEnd(name) {
40
+ const start = starts.get(name);
41
+ if (start !== undefined) {
42
+ const duration = Math.round(performance.now() - start);
43
+ durations.set(name, duration);
44
+ structured.info(`stage:end:${name}`, { stage: name, durationMs: duration });
45
+ }
46
+ },
47
+ info(msg) {
48
+ structured.info(msg);
49
+ },
50
+ error(msg) {
51
+ structured.error(msg);
52
+ },
53
+ summary() {
54
+ const total = Math.round(performance.now() - pipelineStart);
55
+ const stageTimings = {};
56
+ for (const [name, ms] of durations) {
57
+ stageTimings[name] = ms;
58
+ }
59
+ structured.info('pipeline-summary', { stages: stageTimings, totalMs: total });
60
+ },
61
+ };
62
+ }
63
+ export { createConsoleLogger, createBufferLogger };
64
+ //# sourceMappingURL=structured-logger.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Task decomposition — splits complex issues into parallelizable subtasks
3
+ * using deterministic rules based on module boundaries, file type, and concern.
4
+ *
5
+ * Design decision D1: Rule-based, not LLM-based. Complexity >= 6 triggers decomposition.
6
+ */
7
+ import type { ModuleGraph } from './analysis/types.js';
8
+ export interface SubTask {
9
+ id: string;
10
+ title: string;
11
+ description: string;
12
+ /** Module boundary this subtask targets, if any. */
13
+ module?: string;
14
+ /** File patterns this subtask should touch. */
15
+ filePatterns: string[];
16
+ /** Concern category. */
17
+ concern: 'code' | 'test' | 'docs' | 'config' | 'refactor';
18
+ /** Estimated relative complexity (1-5). */
19
+ estimatedComplexity: number;
20
+ /** IDs of subtasks this depends on. */
21
+ dependsOn: string[];
22
+ }
23
+ export interface TaskGraph {
24
+ issueNumber: number;
25
+ issueTitle: string;
26
+ complexity: number;
27
+ subtasks: SubTask[];
28
+ /** Whether decomposition was triggered. */
29
+ decomposed: boolean;
30
+ }
31
+ export interface DecompositionContext {
32
+ issueNumber: number;
33
+ issueTitle: string;
34
+ issueBody: string;
35
+ complexity: number;
36
+ /** Module graph from codebase analysis. */
37
+ moduleGraph?: ModuleGraph;
38
+ /** Files mentioned or likely affected. */
39
+ affectedFiles?: string[];
40
+ }
41
+ export interface DecompositionOptions {
42
+ /** Minimum complexity score to trigger decomposition. Defaults to 6. */
43
+ complexityThreshold?: number;
44
+ /** Maximum subtasks to generate. Defaults to 8. */
45
+ maxSubtasks?: number;
46
+ }
47
+ /**
48
+ * Decompose an issue into a task graph of subtasks.
49
+ * Returns a single-task graph if complexity is below threshold.
50
+ */
51
+ export declare function decomposeTask(ctx: DecompositionContext, options?: DecompositionOptions): TaskGraph;
52
+ /**
53
+ * Validate a TaskGraph for consistency (no dangling deps, no cycles).
54
+ */
55
+ export declare function validateTaskGraph(graph: TaskGraph): string[];
56
+ /**
57
+ * Get subtasks in execution order (respecting dependencies).
58
+ * Returns layers: each layer contains tasks that can run in parallel.
59
+ */
60
+ export declare function getExecutionLayers(graph: TaskGraph): SubTask[][];
61
+ //# sourceMappingURL=task-decomposer.d.ts.map
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Task decomposition — splits complex issues into parallelizable subtasks
3
+ * using deterministic rules based on module boundaries, file type, and concern.
4
+ *
5
+ * Design decision D1: Rule-based, not LLM-based. Complexity >= 6 triggers decomposition.
6
+ */
7
+ // ── Decomposition Engine ─────────────────────────────────────────────
8
+ const DEFAULT_COMPLEXITY_THRESHOLD = 6;
9
+ const DEFAULT_MAX_SUBTASKS = 8;
10
+ /**
11
+ * Decompose an issue into a task graph of subtasks.
12
+ * Returns a single-task graph if complexity is below threshold.
13
+ */
14
+ export function decomposeTask(ctx, options = {}) {
15
+ const threshold = options.complexityThreshold ?? DEFAULT_COMPLEXITY_THRESHOLD;
16
+ const maxSubtasks = options.maxSubtasks ?? DEFAULT_MAX_SUBTASKS;
17
+ // Below threshold: no decomposition
18
+ if (ctx.complexity < threshold) {
19
+ return {
20
+ issueNumber: ctx.issueNumber,
21
+ issueTitle: ctx.issueTitle,
22
+ complexity: ctx.complexity,
23
+ decomposed: false,
24
+ subtasks: [
25
+ {
26
+ id: `${ctx.issueNumber}-main`,
27
+ title: ctx.issueTitle,
28
+ description: ctx.issueBody,
29
+ filePatterns: ['**/*'],
30
+ concern: 'code',
31
+ estimatedComplexity: ctx.complexity,
32
+ dependsOn: [],
33
+ },
34
+ ],
35
+ };
36
+ }
37
+ const subtasks = [];
38
+ let taskCounter = 0;
39
+ const nextId = () => {
40
+ taskCounter++;
41
+ return `${ctx.issueNumber}-${taskCounter}`;
42
+ };
43
+ // Strategy 1: Split by module boundary
44
+ if (ctx.moduleGraph && ctx.moduleGraph.modules.length > 1) {
45
+ const affectedModules = findAffectedModules(ctx.moduleGraph, ctx.affectedFiles);
46
+ if (affectedModules.length > 1) {
47
+ // Order modules by dependency: upstream first
48
+ const ordered = topologicalSort(affectedModules, ctx.moduleGraph);
49
+ for (const mod of ordered) {
50
+ if (subtasks.length >= maxSubtasks)
51
+ break;
52
+ const deps = findModuleDependencyTasks(mod, ordered, subtasks, ctx.moduleGraph);
53
+ subtasks.push({
54
+ id: nextId(),
55
+ title: `Implement changes in ${mod.name}`,
56
+ description: `Apply changes to module "${mod.name}" at ${mod.path}`,
57
+ module: mod.name,
58
+ filePatterns: [`${mod.path}/**/*`],
59
+ concern: 'code',
60
+ estimatedComplexity: Math.min(5, Math.ceil(ctx.complexity / ordered.length) + 1),
61
+ dependsOn: deps,
62
+ });
63
+ }
64
+ }
65
+ }
66
+ // Strategy 2: Split by concern (code vs test vs docs)
67
+ if (subtasks.length === 0) {
68
+ const concerns = classifyConcerns(ctx.issueBody, ctx.affectedFiles);
69
+ for (const concern of concerns) {
70
+ if (subtasks.length >= maxSubtasks)
71
+ break;
72
+ const deps = concern.concern === 'test'
73
+ ? subtasks.filter((s) => s.concern === 'code').map((s) => s.id)
74
+ : concern.concern === 'docs'
75
+ ? subtasks.filter((s) => s.concern === 'code' || s.concern === 'test').map((s) => s.id)
76
+ : [];
77
+ subtasks.push({
78
+ id: nextId(),
79
+ ...concern,
80
+ dependsOn: deps,
81
+ });
82
+ }
83
+ }
84
+ // Fallback: single task if strategies yielded nothing
85
+ if (subtasks.length === 0) {
86
+ subtasks.push({
87
+ id: nextId(),
88
+ title: ctx.issueTitle,
89
+ description: ctx.issueBody,
90
+ filePatterns: ['**/*'],
91
+ concern: 'code',
92
+ estimatedComplexity: ctx.complexity,
93
+ dependsOn: [],
94
+ });
95
+ }
96
+ return {
97
+ issueNumber: ctx.issueNumber,
98
+ issueTitle: ctx.issueTitle,
99
+ complexity: ctx.complexity,
100
+ decomposed: subtasks.length > 1,
101
+ subtasks,
102
+ };
103
+ }
104
+ /**
105
+ * Validate a TaskGraph for consistency (no dangling deps, no cycles).
106
+ */
107
+ export function validateTaskGraph(graph) {
108
+ const errors = [];
109
+ const ids = new Set(graph.subtasks.map((s) => s.id));
110
+ for (const task of graph.subtasks) {
111
+ for (const dep of task.dependsOn) {
112
+ if (!ids.has(dep)) {
113
+ errors.push(`Task "${task.id}" depends on unknown task "${dep}"`);
114
+ }
115
+ }
116
+ }
117
+ // Check for cycles
118
+ const visited = new Set();
119
+ const visiting = new Set();
120
+ const taskMap = new Map(graph.subtasks.map((s) => [s.id, s]));
121
+ function hasCycle(id) {
122
+ if (visiting.has(id))
123
+ return true;
124
+ if (visited.has(id))
125
+ return false;
126
+ visiting.add(id);
127
+ const task = taskMap.get(id);
128
+ if (task) {
129
+ for (const dep of task.dependsOn) {
130
+ if (hasCycle(dep))
131
+ return true;
132
+ }
133
+ }
134
+ visiting.delete(id);
135
+ visited.add(id);
136
+ return false;
137
+ }
138
+ for (const task of graph.subtasks) {
139
+ visited.clear();
140
+ visiting.clear();
141
+ if (hasCycle(task.id)) {
142
+ errors.push(`Cycle detected involving task "${task.id}"`);
143
+ break;
144
+ }
145
+ }
146
+ return errors;
147
+ }
148
+ /**
149
+ * Get subtasks in execution order (respecting dependencies).
150
+ * Returns layers: each layer contains tasks that can run in parallel.
151
+ */
152
+ export function getExecutionLayers(graph) {
153
+ const layers = [];
154
+ const completed = new Set();
155
+ const remaining = new Map(graph.subtasks.map((s) => [s.id, s]));
156
+ while (remaining.size > 0) {
157
+ const layer = [];
158
+ for (const [_id, task] of remaining) {
159
+ if (task.dependsOn.every((dep) => completed.has(dep))) {
160
+ layer.push(task);
161
+ }
162
+ }
163
+ if (layer.length === 0)
164
+ break; // No progress = cycle
165
+ for (const task of layer) {
166
+ remaining.delete(task.id);
167
+ completed.add(task.id);
168
+ }
169
+ layers.push(layer);
170
+ }
171
+ return layers;
172
+ }
173
+ // ── Internal Helpers ──────────────────────────────────────────────────
174
+ function findAffectedModules(graph, files) {
175
+ if (!files || files.length === 0)
176
+ return graph.modules;
177
+ return graph.modules.filter((mod) => files.some((f) => f.startsWith(mod.path) || f.includes(`/${mod.name}/`)));
178
+ }
179
+ function topologicalSort(modules, graph) {
180
+ const nameSet = new Set(modules.map((m) => m.name));
181
+ const adjacency = new Map();
182
+ for (const mod of modules) {
183
+ adjacency.set(mod.name, []);
184
+ }
185
+ for (const edge of graph.edges) {
186
+ if (nameSet.has(edge.from) && nameSet.has(edge.to)) {
187
+ adjacency.get(edge.from)?.push(edge.to);
188
+ }
189
+ }
190
+ const sorted = [];
191
+ const visited = new Set();
192
+ const modMap = new Map(modules.map((m) => [m.name, m]));
193
+ function visit(name) {
194
+ if (visited.has(name))
195
+ return;
196
+ visited.add(name);
197
+ for (const dep of adjacency.get(name) ?? []) {
198
+ visit(dep);
199
+ }
200
+ const mod = modMap.get(name);
201
+ if (mod)
202
+ sorted.push(mod);
203
+ }
204
+ for (const mod of modules) {
205
+ visit(mod.name);
206
+ }
207
+ return sorted;
208
+ }
209
+ function findModuleDependencyTasks(mod, _orderedModules, existingTasks, graph) {
210
+ const deps = [];
211
+ for (const edge of graph.edges) {
212
+ if (edge.from === mod.name) {
213
+ const depTask = existingTasks.find((t) => t.module === edge.to);
214
+ if (depTask)
215
+ deps.push(depTask.id);
216
+ }
217
+ }
218
+ return deps;
219
+ }
220
+ function classifyConcerns(issueBody, files) {
221
+ const results = [];
222
+ const hasTests = files?.some((f) => /\.(test|spec)\.[jt]sx?$/.test(f) || f.includes('__tests__'));
223
+ const hasDocs = files?.some((f) => /\.(md|mdx|rst)$/.test(f) || f.startsWith('docs/'));
224
+ const hasConfig = files?.some((f) => /\.(json|yaml|yml|toml)$/.test(f) && !f.includes('test'));
225
+ // Code implementation subtask
226
+ results.push({
227
+ title: 'Implement code changes',
228
+ description: `Implement the core changes described in the issue.\n\n${issueBody.slice(0, 500)}`,
229
+ filePatterns: ['src/**/*'],
230
+ concern: 'code',
231
+ estimatedComplexity: 3,
232
+ });
233
+ // Test subtask
234
+ if (hasTests || issueBody.toLowerCase().includes('test')) {
235
+ results.push({
236
+ title: 'Write/update tests',
237
+ description: 'Write or update tests to cover the code changes.',
238
+ filePatterns: ['**/*.test.*', '**/*.spec.*', '**/__tests__/**'],
239
+ concern: 'test',
240
+ estimatedComplexity: 2,
241
+ });
242
+ }
243
+ // Docs subtask
244
+ if (hasDocs || issueBody.toLowerCase().includes('document')) {
245
+ results.push({
246
+ title: 'Update documentation',
247
+ description: 'Update documentation to reflect the changes.',
248
+ filePatterns: ['docs/**/*', '**/*.md'],
249
+ concern: 'docs',
250
+ estimatedComplexity: 1,
251
+ });
252
+ }
253
+ // Config subtask
254
+ if (hasConfig) {
255
+ results.push({
256
+ title: 'Update configuration',
257
+ description: 'Update configuration files as needed.',
258
+ filePatterns: ['**/*.json', '**/*.yaml', '**/*.yml'],
259
+ concern: 'config',
260
+ estimatedComplexity: 1,
261
+ });
262
+ }
263
+ return results;
264
+ }
265
+ //# sourceMappingURL=task-decomposer.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Extended telemetry integration — covers remaining OTel primitives,
3
+ * no-op logger, synchronous spans, and core utilities not yet integrated.
4
+ */
5
+ import { getTracer, getMeter, withSpan, withSpanSync, createNoOpLogger, createConsoleLogger, createBufferLogger, SPAN_NAMES, METRIC_NAMES, ATTRIBUTE_KEYS, AI_SDLC_PREFIX, validate, compareMetric, exceedsSeverity, type StructuredLogger, type BufferLogger, type LogEntry, type LogLevel } from '@ai-sdlc/reference';
6
+ /**
7
+ * Create a no-op logger (useful for suppressing output in tests).
8
+ */
9
+ export declare function createSilentLogger(): StructuredLogger;
10
+ /**
11
+ * Execute a function within a named span synchronously.
12
+ */
13
+ export declare function withPipelineSpanSync<T>(name: string, attrs: Record<string, string | number | boolean>, fn: () => T): T;
14
+ /**
15
+ * Get the OpenTelemetry tracer for custom spans.
16
+ */
17
+ export declare function getPipelineTracer(): import("@opentelemetry/api").Tracer;
18
+ /**
19
+ * Validate a resource against its JSON Schema.
20
+ */
21
+ export { validate as validateResourceSchema } from '@ai-sdlc/reference';
22
+ export { getTracer, getMeter, withSpan, withSpanSync, createNoOpLogger, createConsoleLogger, createBufferLogger, SPAN_NAMES, METRIC_NAMES, ATTRIBUTE_KEYS, AI_SDLC_PREFIX, validate, compareMetric, exceedsSeverity, };
23
+ export type { StructuredLogger, BufferLogger, LogEntry, LogLevel };
24
+ //# sourceMappingURL=telemetry-extended.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Extended telemetry integration — covers remaining OTel primitives,
3
+ * no-op logger, synchronous spans, and core utilities not yet integrated.
4
+ */
5
+ import { getTracer, getMeter, withSpan, withSpanSync, createNoOpLogger, createConsoleLogger, createBufferLogger, SPAN_NAMES, METRIC_NAMES, ATTRIBUTE_KEYS, AI_SDLC_PREFIX,
6
+ // Core utilities
7
+ validate, compareMetric, exceedsSeverity, } from '@ai-sdlc/reference';
8
+ /**
9
+ * Create a no-op logger (useful for suppressing output in tests).
10
+ */
11
+ export function createSilentLogger() {
12
+ return createNoOpLogger();
13
+ }
14
+ /**
15
+ * Execute a function within a named span synchronously.
16
+ */
17
+ export function withPipelineSpanSync(name, attrs, fn) {
18
+ return withSpanSync(name, attrs, fn);
19
+ }
20
+ /**
21
+ * Get the OpenTelemetry tracer for custom spans.
22
+ */
23
+ export function getPipelineTracer() {
24
+ return getTracer();
25
+ }
26
+ /**
27
+ * Validate a resource against its JSON Schema.
28
+ */
29
+ export { validate as validateResourceSchema } from '@ai-sdlc/reference';
30
+ export { getTracer, getMeter, withSpan, withSpanSync, createNoOpLogger, createConsoleLogger, createBufferLogger, SPAN_NAMES, METRIC_NAMES, ATTRIBUTE_KEYS, AI_SDLC_PREFIX, validate, compareMetric, exceedsSeverity, };
31
+ //# sourceMappingURL=telemetry-extended.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Comprehensive type re-exports from @ai-sdlc/reference.
3
+ * Ensures all reference types are accessible through the orchestrator package
4
+ * for downstream consumers without direct reference dependency.
5
+ */
6
+ export type { ApiVersion, Metadata, Condition, SecretRef, MetricCondition, Duration, Resource, TriggerFilter, Trigger, Provider, RoutingStrategy, ComplexityThreshold, Routing, Stage, PipelineSpec, PipelinePhase, PipelineStatus, Pipeline, AgentConstraints, HandoffContractRef, Handoff, SkillExample, Skill, AgentCard, AgentRoleSpec, AgentRoleStatus, AgentRole, GateScope, MetricRule, ToolRule, ReviewerRule, DocumentationRule, ProvenanceRule, ExpressionRule, GateRule, EnforcementLevel, Override, RetryPolicy, Evaluation, Gate, QualityGateSpec, QualityGateStatus, QualityGate, Permissions, ApprovalRequirement, Guardrails, MonitoringLevel, AutonomyLevel, PromotionCriteria, DemotionTrigger, AgentAutonomyStatus, AutonomyPolicySpec, AutonomyPolicyStatus, AutonomyPolicy, AdapterInterface, HealthCheck, AdapterBindingSpec, AdapterBindingStatus, AdapterBinding, AnyResource, ResourceKind, ValidationError, } from '@ai-sdlc/reference';
7
+ export type { GateVerdict, DemotionResult, ComplexityFactor, AuthorizationContext, AuthorizationResult, AuthIdentity, AuthenticationResult, Authenticator, MutatingGateContext, ExpressionEvaluator, ExpressionVerdict, LLMEvaluationDimension, LLMEvaluationResult, LLMGateVerdict, } from '@ai-sdlc/reference';
8
+ export type { AgentExecutionState, HandoffValidationError, SchemaResolver, SchemaValidationError, MemoryTier, MemoryEntry, WorkingMemory, ShortTermMemory, LongTermMemory, SharedMemory, EpisodicMemory, } from '@ai-sdlc/reference';
9
+ //# sourceMappingURL=types.d.ts.map
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Comprehensive type re-exports from @ai-sdlc/reference.
3
+ * Ensures all reference types are accessible through the orchestrator package
4
+ * for downstream consumers without direct reference dependency.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map