@substrate-ai/sdlc 0.19.54

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 (166) hide show
  1. package/dist/events.d.ts +336 -0
  2. package/dist/events.d.ts.map +1 -0
  3. package/dist/events.js +11 -0
  4. package/dist/events.js.map +1 -0
  5. package/dist/gating/conflict-detector.d.ts +59 -0
  6. package/dist/gating/conflict-detector.d.ts.map +1 -0
  7. package/dist/gating/conflict-detector.js +101 -0
  8. package/dist/gating/conflict-detector.js.map +1 -0
  9. package/dist/gating/dispatch-gate.d.ts +42 -0
  10. package/dist/gating/dispatch-gate.d.ts.map +1 -0
  11. package/dist/gating/dispatch-gate.js +197 -0
  12. package/dist/gating/dispatch-gate.js.map +1 -0
  13. package/dist/gating/index.d.ts +9 -0
  14. package/dist/gating/index.d.ts.map +1 -0
  15. package/dist/gating/index.js +8 -0
  16. package/dist/gating/index.js.map +1 -0
  17. package/dist/gating/types.d.ts +98 -0
  18. package/dist/gating/types.d.ts.map +1 -0
  19. package/dist/gating/types.js +8 -0
  20. package/dist/gating/types.js.map +1 -0
  21. package/dist/handlers/event-bridge.d.ts +56 -0
  22. package/dist/handlers/event-bridge.d.ts.map +1 -0
  23. package/dist/handlers/event-bridge.js +140 -0
  24. package/dist/handlers/event-bridge.js.map +1 -0
  25. package/dist/handlers/index.d.ts +15 -0
  26. package/dist/handlers/index.d.ts.map +1 -0
  27. package/dist/handlers/index.js +14 -0
  28. package/dist/handlers/index.js.map +1 -0
  29. package/dist/handlers/sdlc-code-review-handler.d.ts +119 -0
  30. package/dist/handlers/sdlc-code-review-handler.d.ts.map +1 -0
  31. package/dist/handlers/sdlc-code-review-handler.js +131 -0
  32. package/dist/handlers/sdlc-code-review-handler.js.map +1 -0
  33. package/dist/handlers/sdlc-create-story-handler.d.ts +97 -0
  34. package/dist/handlers/sdlc-create-story-handler.d.ts.map +1 -0
  35. package/dist/handlers/sdlc-create-story-handler.js +91 -0
  36. package/dist/handlers/sdlc-create-story-handler.js.map +1 -0
  37. package/dist/handlers/sdlc-dev-story-handler.d.ts +121 -0
  38. package/dist/handlers/sdlc-dev-story-handler.d.ts.map +1 -0
  39. package/dist/handlers/sdlc-dev-story-handler.js +288 -0
  40. package/dist/handlers/sdlc-dev-story-handler.js.map +1 -0
  41. package/dist/handlers/sdlc-phase-handler.d.ts +32 -0
  42. package/dist/handlers/sdlc-phase-handler.d.ts.map +1 -0
  43. package/dist/handlers/sdlc-phase-handler.js +166 -0
  44. package/dist/handlers/sdlc-phase-handler.js.map +1 -0
  45. package/dist/handlers/types.d.ts +132 -0
  46. package/dist/handlers/types.d.ts.map +1 -0
  47. package/dist/handlers/types.js +10 -0
  48. package/dist/handlers/types.js.map +1 -0
  49. package/dist/index.d.ts +8 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +14 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/learning/failure-classifier.d.ts +23 -0
  54. package/dist/learning/failure-classifier.d.ts.map +1 -0
  55. package/dist/learning/failure-classifier.js +75 -0
  56. package/dist/learning/failure-classifier.js.map +1 -0
  57. package/dist/learning/finding-classifier.d.ts +25 -0
  58. package/dist/learning/finding-classifier.d.ts.map +1 -0
  59. package/dist/learning/finding-classifier.js +37 -0
  60. package/dist/learning/finding-classifier.js.map +1 -0
  61. package/dist/learning/finding-lifecycle.d.ts +69 -0
  62. package/dist/learning/finding-lifecycle.d.ts.map +1 -0
  63. package/dist/learning/finding-lifecycle.js +162 -0
  64. package/dist/learning/finding-lifecycle.js.map +1 -0
  65. package/dist/learning/finding-store.d.ts +16 -0
  66. package/dist/learning/finding-store.d.ts.map +1 -0
  67. package/dist/learning/finding-store.js +26 -0
  68. package/dist/learning/finding-store.js.map +1 -0
  69. package/dist/learning/findings-injector.d.ts +34 -0
  70. package/dist/learning/findings-injector.d.ts.map +1 -0
  71. package/dist/learning/findings-injector.js +140 -0
  72. package/dist/learning/findings-injector.js.map +1 -0
  73. package/dist/learning/index.d.ts +8 -0
  74. package/dist/learning/index.d.ts.map +1 -0
  75. package/dist/learning/index.js +10 -0
  76. package/dist/learning/index.js.map +1 -0
  77. package/dist/learning/relevance-scorer.d.ts +25 -0
  78. package/dist/learning/relevance-scorer.d.ts.map +1 -0
  79. package/dist/learning/relevance-scorer.js +49 -0
  80. package/dist/learning/relevance-scorer.js.map +1 -0
  81. package/dist/learning/types.d.ts +55 -0
  82. package/dist/learning/types.d.ts.map +1 -0
  83. package/dist/learning/types.js +36 -0
  84. package/dist/learning/types.js.map +1 -0
  85. package/dist/orchestrator/graph-orchestrator.d.ts +208 -0
  86. package/dist/orchestrator/graph-orchestrator.d.ts.map +1 -0
  87. package/dist/orchestrator/graph-orchestrator.js +213 -0
  88. package/dist/orchestrator/graph-orchestrator.js.map +1 -0
  89. package/dist/run-manifest/cli-flags.d.ts +11 -0
  90. package/dist/run-manifest/cli-flags.d.ts.map +1 -0
  91. package/dist/run-manifest/cli-flags.js +10 -0
  92. package/dist/run-manifest/cli-flags.js.map +1 -0
  93. package/dist/run-manifest/index.d.ts +10 -0
  94. package/dist/run-manifest/index.d.ts.map +1 -0
  95. package/dist/run-manifest/index.js +10 -0
  96. package/dist/run-manifest/index.js.map +1 -0
  97. package/dist/run-model/cli-flags.d.ts +27 -0
  98. package/dist/run-model/cli-flags.d.ts.map +1 -0
  99. package/dist/run-model/cli-flags.js +31 -0
  100. package/dist/run-model/cli-flags.js.map +1 -0
  101. package/dist/run-model/index.d.ts +21 -0
  102. package/dist/run-model/index.d.ts.map +1 -0
  103. package/dist/run-model/index.js +19 -0
  104. package/dist/run-model/index.js.map +1 -0
  105. package/dist/run-model/per-story-state.d.ts +62 -0
  106. package/dist/run-model/per-story-state.d.ts.map +1 -0
  107. package/dist/run-model/per-story-state.js +70 -0
  108. package/dist/run-model/per-story-state.js.map +1 -0
  109. package/dist/run-model/recovery-history.d.ts +56 -0
  110. package/dist/run-model/recovery-history.d.ts.map +1 -0
  111. package/dist/run-model/recovery-history.js +83 -0
  112. package/dist/run-model/recovery-history.js.map +1 -0
  113. package/dist/run-model/run-manifest.d.ts +146 -0
  114. package/dist/run-model/run-manifest.d.ts.map +1 -0
  115. package/dist/run-model/run-manifest.js +481 -0
  116. package/dist/run-model/run-manifest.js.map +1 -0
  117. package/dist/run-model/schemas.d.ts +117 -0
  118. package/dist/run-model/schemas.d.ts.map +1 -0
  119. package/dist/run-model/schemas.js +83 -0
  120. package/dist/run-model/schemas.js.map +1 -0
  121. package/dist/run-model/supervisor-lock.d.ts +104 -0
  122. package/dist/run-model/supervisor-lock.d.ts.map +1 -0
  123. package/dist/run-model/supervisor-lock.js +284 -0
  124. package/dist/run-model/supervisor-lock.js.map +1 -0
  125. package/dist/run-model/types.d.ts +74 -0
  126. package/dist/run-model/types.d.ts.map +1 -0
  127. package/dist/run-model/types.js +8 -0
  128. package/dist/run-model/types.js.map +1 -0
  129. package/dist/run-model/verification-result.d.ts +60 -0
  130. package/dist/run-model/verification-result.d.ts.map +1 -0
  131. package/dist/run-model/verification-result.js +55 -0
  132. package/dist/run-model/verification-result.js.map +1 -0
  133. package/dist/verification/checks/acceptance-criteria-evidence-check.d.ts +21 -0
  134. package/dist/verification/checks/acceptance-criteria-evidence-check.d.ts.map +1 -0
  135. package/dist/verification/checks/acceptance-criteria-evidence-check.js +159 -0
  136. package/dist/verification/checks/acceptance-criteria-evidence-check.js.map +1 -0
  137. package/dist/verification/checks/build-check.d.ts +52 -0
  138. package/dist/verification/checks/build-check.d.ts.map +1 -0
  139. package/dist/verification/checks/build-check.js +160 -0
  140. package/dist/verification/checks/build-check.js.map +1 -0
  141. package/dist/verification/checks/index.d.ts +15 -0
  142. package/dist/verification/checks/index.d.ts.map +1 -0
  143. package/dist/verification/checks/index.js +15 -0
  144. package/dist/verification/checks/index.js.map +1 -0
  145. package/dist/verification/checks/phantom-review-check.d.ts +29 -0
  146. package/dist/verification/checks/phantom-review-check.d.ts.map +1 -0
  147. package/dist/verification/checks/phantom-review-check.js +70 -0
  148. package/dist/verification/checks/phantom-review-check.js.map +1 -0
  149. package/dist/verification/checks/trivial-output-check.d.ts +47 -0
  150. package/dist/verification/checks/trivial-output-check.d.ts.map +1 -0
  151. package/dist/verification/checks/trivial-output-check.js +72 -0
  152. package/dist/verification/checks/trivial-output-check.js.map +1 -0
  153. package/dist/verification/index.d.ts +13 -0
  154. package/dist/verification/index.d.ts.map +1 -0
  155. package/dist/verification/index.js +13 -0
  156. package/dist/verification/index.js.map +1 -0
  157. package/dist/verification/types.d.ts +149 -0
  158. package/dist/verification/types.d.ts.map +1 -0
  159. package/dist/verification/types.js +12 -0
  160. package/dist/verification/types.js.map +1 -0
  161. package/dist/verification/verification-pipeline.d.ts +65 -0
  162. package/dist/verification/verification-pipeline.d.ts.map +1 -0
  163. package/dist/verification/verification-pipeline.js +149 -0
  164. package/dist/verification/verification-pipeline.js.map +1 -0
  165. package/graphs/sdlc-pipeline.dot +42 -0
  166. package/package.json +22 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * SdlcCodeReviewHandler — wraps the runCodeReview compiled workflow
3
+ * as a graph NodeHandler for sdlc.code-review nodes.
4
+ *
5
+ * Story 43-5.
6
+ *
7
+ * Architecture note (ADR-003): The SDLC package does not compile-time-depend on
8
+ * @substrate-ai/factory to avoid circular references. Compatible types are
9
+ * defined locally using TypeScript structural typing — they are assignable to
10
+ * the factory types when the CLI composition root wires them together at runtime.
11
+ */
12
+ import type { TypedEventBus } from '@substrate-ai/core';
13
+ import type { SdlcEvents } from '../events.js';
14
+ /** Minimal GraphNode interface needed by this handler. */
15
+ interface GraphNode {
16
+ id: string;
17
+ [key: string]: unknown;
18
+ }
19
+ /** Minimal Graph type — not used by this handler but required for NodeHandler signature. */
20
+ type Graph = object;
21
+ /** Minimal IGraphContext interface needed by this handler. */
22
+ interface IGraphContext {
23
+ getString(key: string, defaultValue?: string): string;
24
+ getList?(key: string): string[];
25
+ get?(key: string): unknown;
26
+ set?(key: string, value: unknown): void;
27
+ }
28
+ /** Terminal status values for handler outcomes. */
29
+ type OutcomeStatus = 'SUCCESS' | 'PARTIAL_SUCCESS' | 'FAILURE' | 'NEEDS_RETRY' | 'ESCALATE';
30
+ /** Structured result returned by every node handler. */
31
+ interface Outcome {
32
+ status: OutcomeStatus;
33
+ contextUpdates?: Record<string, unknown>;
34
+ failureReason?: string;
35
+ notes?: string;
36
+ /**
37
+ * Optional preferred edge label for the graph engine's edge selector.
38
+ * 'SHIP_IT' routes to exit; 'NEEDS_FIXES' routes back to dev_story.
39
+ */
40
+ preferredLabel?: string;
41
+ }
42
+ /** NodeHandler function signature — matches @substrate-ai/factory NodeHandler type. */
43
+ type NodeHandler = (node: GraphNode, context: IGraphContext, graph: Graph) => Promise<Outcome>;
44
+ /**
45
+ * A single issue from a code review.
46
+ * Using optional fields to be compatible with both the monolith's CodeReviewIssue
47
+ * (required severity/description) and the looser previousIssues shape in CodeReviewParams.
48
+ */
49
+ export interface CodeReviewIssue {
50
+ severity?: string;
51
+ description?: string;
52
+ file?: string;
53
+ line?: number;
54
+ }
55
+ /** Parameters for the code-review compiled workflow. */
56
+ export interface CodeReviewParams {
57
+ storyKey: string;
58
+ storyFilePath: string;
59
+ pipelineRunId?: string;
60
+ filesModified?: string[];
61
+ previousIssues?: CodeReviewIssue[];
62
+ }
63
+ /** Result from the code-review compiled workflow. */
64
+ export interface CodeReviewResult {
65
+ verdict: 'SHIP_IT' | 'NEEDS_MINOR_FIXES' | 'NEEDS_MAJOR_REWORK' | 'LGTM_WITH_NOTES';
66
+ issues: number;
67
+ issue_list: CodeReviewIssue[];
68
+ error?: string;
69
+ dispatchFailed?: boolean;
70
+ tokenUsage: {
71
+ input: number;
72
+ output: number;
73
+ };
74
+ }
75
+ /** Injectable function type for the runCodeReview workflow. */
76
+ export type RunCodeReviewFn = (deps: unknown, params: CodeReviewParams) => Promise<CodeReviewResult>;
77
+ /**
78
+ * Configuration options for the sdlc.code-review handler factory.
79
+ *
80
+ * The `deps` field is typed as `unknown` because WorkflowDeps is defined in the
81
+ * monolith (src/modules/compiled-workflows/types.ts) — passing it as unknown avoids
82
+ * a packages→monolith compile-time coupling. The CLI composition root injects the
83
+ * concrete WorkflowDeps instance at runtime.
84
+ *
85
+ * The `runCodeReview` field allows test injection of a mock — preferred per story
86
+ * dev notes for testability. At runtime, the CLI composition root injects the real
87
+ * runCodeReview from src/modules/compiled-workflows/code-review.ts.
88
+ */
89
+ export interface SdlcCodeReviewHandlerOptions {
90
+ /** Workflow dependencies — passed through as-is to runCodeReview. */
91
+ deps: unknown;
92
+ /** SDLC event bus for telemetry events. */
93
+ eventBus: TypedEventBus<SdlcEvents>;
94
+ /** Compiled workflow function — injectable for testing. */
95
+ runCodeReview: RunCodeReviewFn;
96
+ }
97
+ /**
98
+ * Create an sdlc.code-review node handler.
99
+ *
100
+ * The returned handler:
101
+ * 1. Validates storyKey and storyFilePath are present in GraphContext (AC4)
102
+ * 2. Reads optional context fields: pipelineRunId, filesModified, codeReviewIssueList (AC5)
103
+ * 3. Emits orchestrator:story-phase-start telemetry (AC6)
104
+ * 4. Delegates to runCodeReview(deps, params)
105
+ * 5. Emits orchestrator:story-phase-complete telemetry in finally block (AC6)
106
+ * 6. Maps the CodeReviewResult verdict to an Outcome (AC1, AC2, AC3)
107
+ *
108
+ * Verdict mapping:
109
+ * SHIP_IT / LGTM_WITH_NOTES → SUCCESS with preferredLabel: 'SHIP_IT' (AC1)
110
+ * NEEDS_MINOR_FIXES / NEEDS_MAJOR_REWORK → FAILURE with preferredLabel: 'NEEDS_FIXES' (AC2)
111
+ * dispatchFailed: true → FAILURE with escalation failureReason, no contextUpdates (AC3)
112
+ * throws → FAILURE with error message, no contextUpdates
113
+ *
114
+ * @param options - Handler configuration.
115
+ * @returns A NodeHandler function ready for registration under the 'sdlc.code-review' key.
116
+ */
117
+ export declare function createSdlcCodeReviewHandler(options: SdlcCodeReviewHandlerOptions): NodeHandler;
118
+ export {};
119
+ //# sourceMappingURL=sdlc-code-review-handler.d.ts.map
@@ -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F"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * SdlcCodeReviewHandler — wraps the runCodeReview compiled workflow
3
+ * as a graph NodeHandler for sdlc.code-review nodes.
4
+ *
5
+ * Story 43-5.
6
+ *
7
+ * Architecture note (ADR-003): The SDLC package does not compile-time-depend on
8
+ * @substrate-ai/factory to avoid circular references. Compatible types are
9
+ * defined locally using TypeScript structural typing — they are assignable to
10
+ * the factory types when the CLI composition root wires them together at runtime.
11
+ */
12
+ // ---------------------------------------------------------------------------
13
+ // Factory
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Create an sdlc.code-review node handler.
17
+ *
18
+ * The returned handler:
19
+ * 1. Validates storyKey and storyFilePath are present in GraphContext (AC4)
20
+ * 2. Reads optional context fields: pipelineRunId, filesModified, codeReviewIssueList (AC5)
21
+ * 3. Emits orchestrator:story-phase-start telemetry (AC6)
22
+ * 4. Delegates to runCodeReview(deps, params)
23
+ * 5. Emits orchestrator:story-phase-complete telemetry in finally block (AC6)
24
+ * 6. Maps the CodeReviewResult verdict to an Outcome (AC1, AC2, AC3)
25
+ *
26
+ * Verdict mapping:
27
+ * SHIP_IT / LGTM_WITH_NOTES → SUCCESS with preferredLabel: 'SHIP_IT' (AC1)
28
+ * NEEDS_MINOR_FIXES / NEEDS_MAJOR_REWORK → FAILURE with preferredLabel: 'NEEDS_FIXES' (AC2)
29
+ * dispatchFailed: true → FAILURE with escalation failureReason, no contextUpdates (AC3)
30
+ * throws → FAILURE with error message, no contextUpdates
31
+ *
32
+ * @param options - Handler configuration.
33
+ * @returns A NodeHandler function ready for registration under the 'sdlc.code-review' key.
34
+ */
35
+ export function createSdlcCodeReviewHandler(options) {
36
+ return async (_node, context, _graph) => {
37
+ // AC4: Validate required context keys before calling runCodeReview
38
+ const storyKey = context.getString('storyKey', '');
39
+ const storyFilePath = context.getString('storyFilePath', '');
40
+ if (!storyKey || !storyFilePath) {
41
+ const missingFields = [
42
+ !storyKey && 'storyKey',
43
+ !storyFilePath && 'storyFilePath',
44
+ ].filter(Boolean);
45
+ return {
46
+ status: 'FAILURE',
47
+ failureReason: `Missing required context: ${missingFields.join(', ')}`,
48
+ };
49
+ }
50
+ // AC5: Extract optional fields
51
+ // pipelineRunId: omit key when absent (exactOptionalPropertyTypes pattern)
52
+ const pipelineRunIdRaw = context.getString('pipelineRunId', '');
53
+ const pipelineRunId = pipelineRunIdRaw !== '' ? pipelineRunIdRaw : undefined;
54
+ // filesModified: string[] from context
55
+ const filesModifiedRaw = context.getList?.('filesModified') ?? [];
56
+ const filesModified = filesModifiedRaw.length > 0 ? filesModifiedRaw : undefined;
57
+ // codeReviewIssueList: complex object array — retrieved via get() not getList()
58
+ const codeReviewIssueListRaw = context.get?.('codeReviewIssueList');
59
+ const previousIssues = Array.isArray(codeReviewIssueListRaw) && codeReviewIssueListRaw.length > 0
60
+ ? codeReviewIssueListRaw
61
+ : undefined;
62
+ // Build CodeReviewParams with required + optional fields
63
+ const params = {
64
+ storyKey,
65
+ storyFilePath,
66
+ ...(pipelineRunId !== undefined ? { pipelineRunId } : {}),
67
+ ...(filesModified !== undefined ? { filesModified } : {}),
68
+ ...(previousIssues !== undefined ? { previousIssues } : {}),
69
+ };
70
+ // AC6: Emit phase-start telemetry before calling runCodeReview
71
+ options.eventBus.emit('orchestrator:story-phase-start', { storyKey, phase: 'code-review' });
72
+ // Initialize outcome to a default so finally block always has a valid status
73
+ let outcome = {
74
+ status: 'FAILURE',
75
+ failureReason: 'unexpected error in code-review handler',
76
+ };
77
+ let codeReviewVerdict;
78
+ try {
79
+ // Delegate to runCodeReview
80
+ const result = await options.runCodeReview(options.deps, params);
81
+ // AC3: Short-circuit on dispatch failure → escalation FAILURE, no contextUpdates written
82
+ if (result.dispatchFailed === true) {
83
+ outcome = {
84
+ status: 'FAILURE',
85
+ failureReason: `escalation: code-review dispatch failed: ${result.error ?? 'unknown error'}`,
86
+ };
87
+ return outcome;
88
+ }
89
+ // Capture verdict for telemetry
90
+ codeReviewVerdict = result.verdict;
91
+ // Context updates written for all non-escalation outcomes (AC1, AC2)
92
+ const contextUpdates = {
93
+ codeReviewVerdict: result.verdict,
94
+ codeReviewIssues: result.issues,
95
+ codeReviewIssueList: result.issue_list,
96
+ };
97
+ if (result.verdict === 'SHIP_IT' || result.verdict === 'LGTM_WITH_NOTES') {
98
+ // AC1: SHIP_IT or LGTM_WITH_NOTES → SUCCESS with preferredLabel: 'SHIP_IT'
99
+ outcome = {
100
+ status: 'SUCCESS',
101
+ preferredLabel: 'SHIP_IT',
102
+ contextUpdates,
103
+ };
104
+ }
105
+ else {
106
+ // AC2: NEEDS_MINOR_FIXES or NEEDS_MAJOR_REWORK → FAILURE with preferredLabel: 'NEEDS_FIXES'
107
+ outcome = {
108
+ status: 'FAILURE',
109
+ preferredLabel: 'NEEDS_FIXES',
110
+ failureReason: `${result.verdict}: ${result.issues} issue(s)`,
111
+ contextUpdates,
112
+ };
113
+ }
114
+ }
115
+ catch (err) {
116
+ // Handle unexpected throws from runCodeReview — no contextUpdates
117
+ const failureReason = err instanceof Error ? err.message : String(err);
118
+ outcome = { status: 'FAILURE', failureReason };
119
+ }
120
+ finally {
121
+ // AC6: Emit phase-complete in finally block — guaranteed even on throw
122
+ options.eventBus.emit('orchestrator:story-phase-complete', {
123
+ storyKey,
124
+ phase: 'code-review',
125
+ result: { status: outcome.status, verdict: codeReviewVerdict },
126
+ });
127
+ }
128
+ return outcome;
129
+ };
130
+ }
131
+ //# sourceMappingURL=sdlc-code-review-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdlc-code-review-handler.js","sourceRoot":"","sources":["../../src/handlers/sdlc-code-review-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA8GH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAqC;IAC/E,OAAO,KAAK,EAAE,KAAgB,EAAE,OAAsB,EAAE,MAAa,EAA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OAAO,KAAK,iBAAiB,EAAE,CAAC;gBACzE,2EAA2E;gBAC3E,OAAO,GAAG;oBACR,MAAM,EAAE,SAAS;oBACjB,cAAc,EAAE,SAAS;oBACzB,cAAc;iBACf,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,4FAA4F;gBAC5F,OAAO,GAAG;oBACR,MAAM,EAAE,SAAS;oBACjB,cAAc,EAAE,aAAa;oBAC7B,aAAa,EAAE,GAAG,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,MAAM,WAAW;oBAC7D,cAAc;iBACf,CAAA;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,kEAAkE;YAClE,MAAM,aAAa,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACtE,OAAO,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;QAChD,CAAC;gBAAS,CAAC;YACT,uEAAuE;YACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,mCAAmC,EAAE;gBACzD,QAAQ;gBACR,KAAK,EAAE,aAAa;gBACpB,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE;aAC/D,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * SdlcCreateStoryHandler — wraps the runCreateStory compiled workflow
3
+ * as a graph NodeHandler for sdlc.create-story nodes.
4
+ *
5
+ * Story 43-3.
6
+ *
7
+ * Architecture note (ADR-003): The SDLC package does not compile-time-depend on
8
+ * @substrate-ai/factory to avoid circular references. Compatible types are
9
+ * defined locally using TypeScript structural typing — they are assignable to
10
+ * the factory types when the CLI composition root wires them together at runtime.
11
+ */
12
+ import type { TypedEventBus } from '@substrate-ai/core';
13
+ import type { SdlcEvents } from '../events.js';
14
+ /** Minimal GraphNode interface needed by this handler. */
15
+ interface GraphNode {
16
+ id: string;
17
+ [key: string]: unknown;
18
+ }
19
+ /** Minimal Graph type — not used by this handler but required for NodeHandler signature. */
20
+ type Graph = object;
21
+ /** Minimal IGraphContext interface needed by this handler. */
22
+ interface IGraphContext {
23
+ getString(key: string, defaultValue?: string): string;
24
+ get(key: string): unknown;
25
+ set(key: string, value: unknown): void;
26
+ }
27
+ /** Terminal status values for handler outcomes. */
28
+ type OutcomeStatus = 'SUCCESS' | 'PARTIAL_SUCCESS' | 'FAILURE' | 'NEEDS_RETRY' | 'ESCALATE';
29
+ /** Structured result returned by every node handler. */
30
+ interface Outcome {
31
+ status: OutcomeStatus;
32
+ contextUpdates?: Record<string, unknown>;
33
+ failureReason?: string;
34
+ notes?: string;
35
+ error?: unknown;
36
+ preferredLabel?: string;
37
+ suggestedNextIds?: string[];
38
+ }
39
+ /** NodeHandler function signature — matches @substrate-ai/factory NodeHandler type. */
40
+ export type NodeHandler = (node: GraphNode, context: IGraphContext, graph: Graph) => Promise<Outcome>;
41
+ /** Parameters for the create-story compiled workflow. */
42
+ export interface CreateStoryParams {
43
+ epicId: string;
44
+ storyKey: string;
45
+ pipelineRunId?: string;
46
+ }
47
+ /** Result from the create-story compiled workflow. */
48
+ export interface CreateStoryResult {
49
+ result: 'success' | 'failed';
50
+ story_file?: string;
51
+ story_key?: string;
52
+ story_title?: string;
53
+ error?: string;
54
+ details?: string;
55
+ tokenUsage: {
56
+ input: number;
57
+ output: number;
58
+ };
59
+ }
60
+ /** Injectable function type for the runCreateStory workflow. */
61
+ export type RunCreateStoryFn = (deps: unknown, params: CreateStoryParams) => Promise<CreateStoryResult>;
62
+ /**
63
+ * Configuration options for the sdlc.create-story handler factory.
64
+ *
65
+ * The `deps` field is typed as `unknown` because WorkflowDeps is defined in the
66
+ * monolith (src/modules/compiled-workflows/types.ts) — passing it as unknown avoids
67
+ * a packages→monolith compile-time coupling. The CLI composition root injects the
68
+ * concrete WorkflowDeps instance at runtime.
69
+ *
70
+ * The `runCreateStory` field allows test injection of a mock — preferred per story
71
+ * dev notes for testability. At runtime, the CLI composition root injects the real
72
+ * runCreateStory from src/modules/compiled-workflows/create-story.ts.
73
+ */
74
+ export interface SdlcCreateStoryHandlerOptions {
75
+ /** Workflow dependencies — passed through as-is to runCreateStory. */
76
+ deps: unknown;
77
+ /** SDLC event bus for telemetry events. */
78
+ eventBus: TypedEventBus<SdlcEvents>;
79
+ /** Compiled workflow function — injectable for testing. */
80
+ runCreateStory: RunCreateStoryFn;
81
+ }
82
+ /**
83
+ * Create an sdlc.create-story node handler.
84
+ *
85
+ * The returned handler:
86
+ * 1. Validates storyKey and epicId are present in GraphContext (AC5)
87
+ * 2. Emits orchestrator:story-phase-start telemetry (AC4)
88
+ * 3. Delegates to runCreateStory(deps, { epicId, storyKey, pipelineRunId }) (AC1)
89
+ * 4. Emits orchestrator:story-phase-complete telemetry (AC4)
90
+ * 5. Maps the CreateStoryResult to an Outcome (AC2, AC3)
91
+ *
92
+ * @param options - Handler configuration.
93
+ * @returns A NodeHandler function ready for registration under the 'sdlc.create-story' key.
94
+ */
95
+ export declare function createSdlcCreateStoryHandler(options: SdlcCreateStoryHandlerOptions): NodeHandler;
96
+ export {};
97
+ //# sourceMappingURL=sdlc-create-story-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdlc-create-story-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/sdlc-create-story-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAM9C,0DAA0D;AAC1D,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,4FAA4F;AAC5F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AA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9C;AAED,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAMvG;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,6BAA6B;IAC5C,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAA;IACb,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACnC,2DAA2D;IAC3D,cAAc,EAAE,gBAAgB,CAAA;CACjC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,WAAW,CAqEhG"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * SdlcCreateStoryHandler — wraps the runCreateStory compiled workflow
3
+ * as a graph NodeHandler for sdlc.create-story nodes.
4
+ *
5
+ * Story 43-3.
6
+ *
7
+ * Architecture note (ADR-003): The SDLC package does not compile-time-depend on
8
+ * @substrate-ai/factory to avoid circular references. Compatible types are
9
+ * defined locally using TypeScript structural typing — they are assignable to
10
+ * the factory types when the CLI composition root wires them together at runtime.
11
+ */
12
+ // ---------------------------------------------------------------------------
13
+ // Factory
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Create an sdlc.create-story node handler.
17
+ *
18
+ * The returned handler:
19
+ * 1. Validates storyKey and epicId are present in GraphContext (AC5)
20
+ * 2. Emits orchestrator:story-phase-start telemetry (AC4)
21
+ * 3. Delegates to runCreateStory(deps, { epicId, storyKey, pipelineRunId }) (AC1)
22
+ * 4. Emits orchestrator:story-phase-complete telemetry (AC4)
23
+ * 5. Maps the CreateStoryResult to an Outcome (AC2, AC3)
24
+ *
25
+ * @param options - Handler configuration.
26
+ * @returns A NodeHandler function ready for registration under the 'sdlc.create-story' key.
27
+ */
28
+ export function createSdlcCreateStoryHandler(options) {
29
+ return async (_node, context, _graph) => {
30
+ // AC5: Validate required context keys before calling runCreateStory
31
+ const storyKey = context.getString('storyKey', '');
32
+ if (!storyKey) {
33
+ return { status: 'FAILURE', failureReason: 'storyKey is required in GraphContext' };
34
+ }
35
+ const epicId = context.getString('epicId', '');
36
+ if (!epicId) {
37
+ return { status: 'FAILURE', failureReason: 'epicId is required in GraphContext' };
38
+ }
39
+ // AC1: Extract optional pipelineRunId — build params without explicit undefined
40
+ // (exactOptionalPropertyTypes requires optional fields to be absent, not undefined)
41
+ const pipelineRunIdRaw = context.getString('pipelineRunId', '');
42
+ const createStoryParams = pipelineRunIdRaw !== ''
43
+ ? { epicId, storyKey, pipelineRunId: pipelineRunIdRaw }
44
+ : { epicId, storyKey };
45
+ // AC4: Emit phase-start telemetry before calling runCreateStory
46
+ options.eventBus.emit('orchestrator:story-phase-start', { storyKey, phase: 'create-story' });
47
+ let workflowResult;
48
+ try {
49
+ // AC1: Delegate to runCreateStory
50
+ workflowResult = await options.runCreateStory(options.deps, createStoryParams);
51
+ }
52
+ catch (err) {
53
+ const failureReason = err instanceof Error ? err.message : String(err);
54
+ const errorResult = {
55
+ result: 'failed',
56
+ error: failureReason,
57
+ tokenUsage: { input: 0, output: 0 },
58
+ };
59
+ // AC4: Emit phase-complete telemetry even on unexpected throw
60
+ options.eventBus.emit('orchestrator:story-phase-complete', {
61
+ storyKey,
62
+ phase: 'create-story',
63
+ result: errorResult,
64
+ });
65
+ return { status: 'FAILURE', failureReason };
66
+ }
67
+ // AC4: Emit phase-complete telemetry after runCreateStory returns
68
+ options.eventBus.emit('orchestrator:story-phase-complete', {
69
+ storyKey,
70
+ phase: 'create-story',
71
+ result: workflowResult,
72
+ });
73
+ // AC2: Map success result to SUCCESS Outcome
74
+ if (workflowResult.result === 'success') {
75
+ return {
76
+ status: 'SUCCESS',
77
+ contextUpdates: {
78
+ storyFilePath: workflowResult.story_file,
79
+ storyKey: workflowResult.story_key,
80
+ storyTitle: workflowResult.story_title,
81
+ },
82
+ };
83
+ }
84
+ // AC3: Map failure result to FAILURE Outcome
85
+ return {
86
+ status: 'FAILURE',
87
+ failureReason: workflowResult.error ?? workflowResult.details ?? 'create-story workflow failed',
88
+ };
89
+ };
90
+ }
91
+ //# sourceMappingURL=sdlc-create-story-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdlc-create-story-handler.js","sourceRoot":"","sources":["../../src/handlers/sdlc-create-story-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6FH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAsC;IACjF,OAAO,KAAK,EAAE,KAAgB,EAAE,OAAsB,EAAE,MAAa,EAAoB,EAAE;QACzF,oEAAoE;QACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,sCAAsC,EAAE,CAAA;QACrF,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAC9C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,oCAAoC,EAAE,CAAA;QACnF,CAAC;QAED,gFAAgF;QAChF,oFAAoF;QACpF,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;QAC/D,MAAM,iBAAiB,GAAsB,gBAAgB,KAAK,EAAE;YAClE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE;YACvD,CAA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ClC,UAAU,EAAE,cAAc,CAAC,WAAW;iBACvC;aACF,CAAA;QACH,CAAC;QAED,6CAA6C;QAC7C,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,aAAa,EACX,cAAc,CAAC,KAAK,IAAI,cAAc,CAAC,OAAO,IAAI,8BAA8B;SACnF,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * SdlcDevStoryHandler — wraps the runDevStory compiled workflow
3
+ * as a graph NodeHandler for sdlc.dev-story nodes.
4
+ *
5
+ * Story 43-4.
6
+ *
7
+ * Architecture note (ADR-003): The SDLC package does not compile-time-depend on
8
+ * @substrate-ai/factory to avoid circular references. Compatible types are
9
+ * defined locally using TypeScript structural typing — they are assignable to
10
+ * the factory types when the CLI composition root wires them together at runtime.
11
+ */
12
+ import type { TypedEventBus, DatabaseAdapter } from '@substrate-ai/core';
13
+ import type { SdlcEvents } from '../events.js';
14
+ /** Minimal GraphNode interface needed by this handler. */
15
+ interface GraphNode {
16
+ id: string;
17
+ [key: string]: unknown;
18
+ }
19
+ /** Minimal Graph type — not used by this handler but required for NodeHandler signature. */
20
+ type Graph = object;
21
+ /** Minimal IGraphContext interface needed by this handler. */
22
+ interface IGraphContext {
23
+ getString(key: string, defaultValue?: string): string;
24
+ getList?(key: string): string[];
25
+ get?(key: string): unknown;
26
+ set?(key: string, value: unknown): void;
27
+ }
28
+ /** Terminal status values for handler outcomes. */
29
+ type OutcomeStatus = 'SUCCESS' | 'PARTIAL_SUCCESS' | 'FAILURE' | 'NEEDS_RETRY' | 'ESCALATE';
30
+ /** Structured result returned by every node handler. */
31
+ interface Outcome {
32
+ status: OutcomeStatus;
33
+ contextUpdates?: Record<string, unknown>;
34
+ failureReason?: string;
35
+ notes?: string;
36
+ }
37
+ /** NodeHandler function signature — matches @substrate-ai/factory NodeHandler type. */
38
+ type NodeHandler = (node: GraphNode, context: IGraphContext, graph: Graph) => Promise<Outcome>;
39
+ /** Parameters for the dev-story compiled workflow. */
40
+ export interface DevStoryParams {
41
+ storyKey: string;
42
+ storyFilePath: string;
43
+ pipelineRunId?: string;
44
+ priorFiles?: string[];
45
+ taskScope?: string;
46
+ /** Learning loop findings prompt — prepended to story context for the agent (Story 53-8). */
47
+ findingsPrompt?: string;
48
+ }
49
+ /** Result from the dev-story compiled workflow. */
50
+ export interface DevStoryResult {
51
+ result: 'success' | 'failed';
52
+ ac_met: string[];
53
+ ac_failures: string[];
54
+ files_modified: string[];
55
+ tests: 'pass' | 'fail';
56
+ notes?: string;
57
+ error?: string;
58
+ }
59
+ /** Injectable function type for the runDevStory workflow. */
60
+ export type RunDevStoryFn = (deps: unknown, params: DevStoryParams) => Promise<DevStoryResult>;
61
+ /**
62
+ * Configuration options for the sdlc.dev-story handler factory.
63
+ *
64
+ * The `deps` field is typed as `unknown` because WorkflowDeps is defined in the
65
+ * monolith (src/modules/compiled-workflows/types.ts) — passing it as unknown avoids
66
+ * a packages→monolith compile-time coupling. The CLI composition root injects the
67
+ * concrete WorkflowDeps instance at runtime.
68
+ *
69
+ * The `runDevStory` field allows test injection of a mock — preferred per story
70
+ * dev notes for testability. At runtime, the CLI composition root injects the real
71
+ * runDevStory from src/modules/compiled-workflows/dev-story.ts.
72
+ */
73
+ /** Result of a build verification check (injectable). */
74
+ export interface BuildVerifyResult {
75
+ status: 'passed' | 'failed' | 'timeout' | 'skipped';
76
+ output?: string;
77
+ }
78
+ /** Injectable build verification function. */
79
+ export type BuildVerifierFn = (projectRoot: string) => BuildVerifyResult;
80
+ export interface SdlcDevStoryHandlerOptions {
81
+ /** Workflow dependencies — passed through as-is to runDevStory. */
82
+ deps: unknown;
83
+ /** SDLC event bus for telemetry events. */
84
+ eventBus: TypedEventBus<SdlcEvents>;
85
+ /** Compiled workflow function — injectable for testing. */
86
+ runDevStory: RunDevStoryFn;
87
+ /**
88
+ * Optional build verification to run after a successful dev-story.
89
+ * Injected by the CLI composition root — runs `npm run build` + `tsc --noEmit`
90
+ * to catch compile errors before code-review wastes a review cycle.
91
+ * If omitted, no build verification is performed (backward-compatible).
92
+ */
93
+ buildVerifier?: BuildVerifierFn;
94
+ /**
95
+ * Optional database adapter for the learning loop (Story 53-8).
96
+ * When provided, enables finding capture on failure, findings injection before
97
+ * dispatch, and finding retirement on success.
98
+ * When null or omitted, all learning calls are skipped gracefully.
99
+ */
100
+ db?: DatabaseAdapter | null;
101
+ }
102
+ /**
103
+ * Create an sdlc.dev-story node handler.
104
+ *
105
+ * The returned handler:
106
+ * 1. Validates storyKey and storyFilePath are present in GraphContext (AC6)
107
+ * 2. Reads optional retry remediation context from prior iteration (AC4)
108
+ * 3. Injects relevant prior-run findings into dispatch params (Story 53-8 AC2)
109
+ * 4. Emits orchestrator:story-phase-start telemetry (AC5)
110
+ * 5. Delegates to runDevStory(deps, params) (AC1)
111
+ * 6. Emits orchestrator:story-phase-complete telemetry in finally block (AC5)
112
+ * 7. Maps the DevStoryResult to an Outcome (AC2, AC3)
113
+ * 8. On failure: classifyAndPersist + emit pipeline:finding-captured (Story 53-8 AC1, AC6)
114
+ * 9. On success: retireContradictedFindings (Story 53-8 AC4)
115
+ *
116
+ * @param options - Handler configuration.
117
+ * @returns A NodeHandler function ready for registration under the 'sdlc.dev-story' key.
118
+ */
119
+ export declare function createSdlcDevStoryHandler(options: SdlcDevStoryHandlerOptions): NodeHandler;
120
+ export {};
121
+ //# sourceMappingURL=sdlc-dev-story-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdlc-dev-story-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/sdlc-dev-story-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAc9C,0DAA0D;AAC1D,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,E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