@ai-sdlc/orchestrator 0.5.0 → 0.9.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 (227) hide show
  1. package/dist/action-enforcement.d.ts +26 -0
  2. package/dist/action-enforcement.js +70 -0
  3. package/dist/admission-composite.d.ts +67 -0
  4. package/dist/admission-composite.js +158 -0
  5. package/dist/admission-enrichment.d.ts +142 -0
  6. package/dist/admission-enrichment.js +331 -0
  7. package/dist/admission-hc.d.ts +62 -0
  8. package/dist/admission-hc.js +83 -0
  9. package/dist/admission-score.d.ts +148 -0
  10. package/dist/admission-score.js +237 -0
  11. package/dist/analysis/analyzer.js +3 -2
  12. package/dist/analysis/convention-detector.d.ts +85 -2
  13. package/dist/analysis/convention-detector.js +375 -70
  14. package/dist/analysis/diff-analyzer.d.ts +33 -0
  15. package/dist/analysis/diff-analyzer.js +122 -0
  16. package/dist/analysis/hotspot-analyzer.js +3 -1
  17. package/dist/analysis/index.d.ts +2 -1
  18. package/dist/analysis/index.js +2 -1
  19. package/dist/artifacts/index.d.ts +65 -0
  20. package/dist/artifacts/index.js +142 -0
  21. package/dist/backlog-adapter.d.ts +121 -0
  22. package/dist/backlog-adapter.js +438 -0
  23. package/dist/calibration.d.ts +43 -0
  24. package/dist/calibration.js +76 -0
  25. package/dist/cli/commands/agents.d.ts +24 -0
  26. package/dist/cli/commands/agents.js +66 -1
  27. package/dist/cli/commands/git-remote.d.ts +49 -0
  28. package/dist/cli/commands/git-remote.js +91 -0
  29. package/dist/cli/commands/health.d.ts +4 -0
  30. package/dist/cli/commands/health.js +13 -1
  31. package/dist/cli/commands/init.d.ts +26 -0
  32. package/dist/cli/commands/init.js +164 -22
  33. package/dist/cli/commands/mcp-setup.d.ts +31 -0
  34. package/dist/cli/commands/mcp-setup.js +78 -8
  35. package/dist/cli/formatters/table.js +15 -2
  36. package/dist/cli/index.d.ts +14 -1
  37. package/dist/cli/index.js +81 -20
  38. package/dist/cli/versions.d.ts +57 -0
  39. package/dist/cli/versions.js +128 -0
  40. package/dist/code-area-classifier.d.ts +21 -0
  41. package/dist/code-area-classifier.js +48 -0
  42. package/dist/config.d.ts +33 -1
  43. package/dist/config.js +78 -8
  44. package/dist/cycle-utils.d.ts +51 -0
  45. package/dist/cycle-utils.js +77 -0
  46. package/dist/database/adapters/external.d.ts +24 -0
  47. package/dist/database/adapters/external.js +80 -0
  48. package/dist/database/adapters/neon.d.ts +41 -0
  49. package/dist/database/adapters/neon.js +98 -0
  50. package/dist/database/adapters/pg-snapshot-restore.d.ts +28 -0
  51. package/dist/database/adapters/pg-snapshot-restore.js +68 -0
  52. package/dist/database/adapters/sqlite-copy.d.ts +32 -0
  53. package/dist/database/adapters/sqlite-copy.js +145 -0
  54. package/dist/database/connection-injection.d.ts +35 -0
  55. package/dist/database/connection-injection.js +93 -0
  56. package/dist/database/index.d.ts +12 -0
  57. package/dist/database/index.js +23 -0
  58. package/dist/database/registry.d.ts +13 -0
  59. package/dist/database/registry.js +27 -0
  60. package/dist/database/topology.d.ts +52 -0
  61. package/dist/database/topology.js +44 -0
  62. package/dist/database/types.d.ts +89 -0
  63. package/dist/database/types.js +26 -0
  64. package/dist/defaults.d.ts +5 -0
  65. package/dist/defaults.js +5 -0
  66. package/dist/design-authority.d.ts +40 -0
  67. package/dist/design-authority.js +71 -0
  68. package/dist/design-lookahead.d.ts +64 -0
  69. package/dist/design-lookahead.js +86 -0
  70. package/dist/design-quality-trend.d.ts +87 -0
  71. package/dist/design-quality-trend.js +190 -0
  72. package/dist/design-system-context.d.ts +46 -0
  73. package/dist/design-system-context.js +80 -0
  74. package/dist/design-system-correction-loop.d.ts +64 -0
  75. package/dist/design-system-correction-loop.js +128 -0
  76. package/dist/design-system-metrics.d.ts +61 -0
  77. package/dist/design-system-metrics.js +104 -0
  78. package/dist/design-system-stewardship.d.ts +22 -0
  79. package/dist/design-system-stewardship.js +85 -0
  80. package/dist/design-system-validation.d.ts +37 -0
  81. package/dist/design-system-validation.js +88 -0
  82. package/dist/dispatch/index.d.ts +4 -0
  83. package/dist/dispatch/index.js +4 -0
  84. package/dist/dispatch/merge-gate.d.ts +46 -0
  85. package/dist/dispatch/merge-gate.js +90 -0
  86. package/dist/dispatch/requeue.d.ts +57 -0
  87. package/dist/dispatch/requeue.js +131 -0
  88. package/dist/dispatch/worker-pool.d.ts +62 -0
  89. package/dist/dispatch/worker-pool.js +60 -0
  90. package/dist/execute.d.ts +40 -0
  91. package/dist/execute.js +295 -30
  92. package/dist/fix-ci.js +40 -3
  93. package/dist/fix-review.d.ts +66 -0
  94. package/dist/fix-review.js +448 -0
  95. package/dist/harness/adapters/claude-code.d.ts +29 -0
  96. package/dist/harness/adapters/claude-code.js +191 -0
  97. package/dist/harness/adapters/codex.d.ts +25 -0
  98. package/dist/harness/adapters/codex.js +61 -0
  99. package/dist/harness/independence.d.ts +51 -0
  100. package/dist/harness/independence.js +67 -0
  101. package/dist/harness/index.d.ts +14 -0
  102. package/dist/harness/index.js +20 -0
  103. package/dist/harness/registry.d.ts +17 -0
  104. package/dist/harness/registry.js +31 -0
  105. package/dist/harness/types.d.ts +123 -0
  106. package/dist/harness/types.js +8 -0
  107. package/dist/harness/version-probe.d.ts +14 -0
  108. package/dist/harness/version-probe.js +123 -0
  109. package/dist/index.d.ts +39 -5
  110. package/dist/index.js +48 -3
  111. package/dist/models/classifier.d.ts +76 -0
  112. package/dist/models/classifier.js +221 -0
  113. package/dist/models/index.d.ts +3 -0
  114. package/dist/models/index.js +3 -0
  115. package/dist/models/registry.d.ts +97 -0
  116. package/dist/models/registry.js +173 -0
  117. package/dist/pillar-breakdown.d.ts +63 -0
  118. package/dist/pillar-breakdown.js +153 -0
  119. package/dist/pipeline-cycle-detector.d.ts +70 -0
  120. package/dist/pipeline-cycle-detector.js +111 -0
  121. package/dist/priority.d.ts +7 -76
  122. package/dist/priority.js +18 -5
  123. package/dist/review-meta.d.ts +65 -0
  124. package/dist/review-meta.js +149 -0
  125. package/dist/review.d.ts +35 -0
  126. package/dist/review.js +84 -0
  127. package/dist/runners/claude-code-sdk.d.ts +31 -0
  128. package/dist/runners/claude-code-sdk.js +238 -0
  129. package/dist/runners/claude-code.d.ts +3 -0
  130. package/dist/runners/claude-code.js +319 -73
  131. package/dist/runners/codex.js +4 -1
  132. package/dist/runners/copilot.js +4 -1
  133. package/dist/runners/cursor.js +4 -1
  134. package/dist/runners/git-utils.d.ts +81 -0
  135. package/dist/runners/git-utils.js +201 -0
  136. package/dist/runners/index.d.ts +5 -1
  137. package/dist/runners/index.js +4 -0
  138. package/dist/runners/review-agent.d.ts +67 -0
  139. package/dist/runners/review-agent.js +350 -0
  140. package/dist/runners/runner-registry.js +10 -0
  141. package/dist/runners/sdk-review-runner.d.ts +65 -0
  142. package/dist/runners/sdk-review-runner.js +185 -0
  143. package/dist/runners/security-triage.d.ts +20 -4
  144. package/dist/runners/security-triage.js +42 -14
  145. package/dist/runners/types.d.ts +25 -0
  146. package/dist/runtime/attestations.d.ts +274 -0
  147. package/dist/runtime/attestations.js +460 -0
  148. package/dist/runtime/git-env.d.ts +53 -0
  149. package/dist/runtime/git-env.js +60 -0
  150. package/dist/runtime/index.d.ts +7 -0
  151. package/dist/runtime/index.js +7 -0
  152. package/dist/runtime/parallelism-flag.d.ts +10 -0
  153. package/dist/runtime/parallelism-flag.js +18 -0
  154. package/dist/runtime/port-allocator.d.ts +21 -0
  155. package/dist/runtime/port-allocator.js +66 -0
  156. package/dist/runtime/worktree-pool.d.ts +86 -0
  157. package/dist/runtime/worktree-pool.js +204 -0
  158. package/dist/runtime/worktree.d.ts +25 -0
  159. package/dist/runtime/worktree.js +111 -0
  160. package/dist/sa-scoring/auto-calibrate.d.ts +69 -0
  161. package/dist/sa-scoring/auto-calibrate.js +107 -0
  162. package/dist/sa-scoring/c1-sa2-computable.d.ts +42 -0
  163. package/dist/sa-scoring/c1-sa2-computable.js +59 -0
  164. package/dist/sa-scoring/composite.d.ts +107 -0
  165. package/dist/sa-scoring/composite.js +139 -0
  166. package/dist/sa-scoring/depparse-client.d.ts +79 -0
  167. package/dist/sa-scoring/depparse-client.js +187 -0
  168. package/dist/sa-scoring/did-compiler.d.ts +122 -0
  169. package/dist/sa-scoring/did-compiler.js +286 -0
  170. package/dist/sa-scoring/drift-monitor.d.ts +84 -0
  171. package/dist/sa-scoring/drift-monitor.js +186 -0
  172. package/dist/sa-scoring/exemplar-bank.d.ts +78 -0
  173. package/dist/sa-scoring/exemplar-bank.js +154 -0
  174. package/dist/sa-scoring/feedback-store.d.ts +100 -0
  175. package/dist/sa-scoring/feedback-store.js +156 -0
  176. package/dist/sa-scoring/index.d.ts +71 -0
  177. package/dist/sa-scoring/index.js +158 -0
  178. package/dist/sa-scoring/layer1-deterministic.d.ts +115 -0
  179. package/dist/sa-scoring/layer1-deterministic.js +298 -0
  180. package/dist/sa-scoring/layer2-structural.d.ts +71 -0
  181. package/dist/sa-scoring/layer2-structural.js +151 -0
  182. package/dist/sa-scoring/layer3-llm.d.ts +86 -0
  183. package/dist/sa-scoring/layer3-llm.js +282 -0
  184. package/dist/sa-scoring/rescore-orchestrator.d.ts +52 -0
  185. package/dist/sa-scoring/rescore-orchestrator.js +47 -0
  186. package/dist/scheduling/burn-down.d.ts +27 -0
  187. package/dist/scheduling/burn-down.js +43 -0
  188. package/dist/scheduling/calibration.d.ts +42 -0
  189. package/dist/scheduling/calibration.js +150 -0
  190. package/dist/scheduling/index.d.ts +8 -0
  191. package/dist/scheduling/index.js +8 -0
  192. package/dist/scheduling/ledger.d.ts +59 -0
  193. package/dist/scheduling/ledger.js +216 -0
  194. package/dist/scheduling/off-peak.d.ts +27 -0
  195. package/dist/scheduling/off-peak.js +112 -0
  196. package/dist/scheduling/schedule-decision.d.ts +39 -0
  197. package/dist/scheduling/schedule-decision.js +89 -0
  198. package/dist/scheduling/tier-analysis.d.ts +47 -0
  199. package/dist/scheduling/tier-analysis.js +81 -0
  200. package/dist/scheduling/types.d.ts +140 -0
  201. package/dist/scheduling/types.js +11 -0
  202. package/dist/shared.d.ts +13 -0
  203. package/dist/shared.js +32 -0
  204. package/dist/state/index.d.ts +1 -1
  205. package/dist/state/schema.d.ts +6 -1
  206. package/dist/state/schema.js +276 -1
  207. package/dist/state/store.d.ts +71 -1
  208. package/dist/state/store.js +464 -7
  209. package/dist/state/types.d.ts +174 -0
  210. package/dist/types.d.ts +1 -1
  211. package/dist/validate-agent-output.js +4 -1
  212. package/dist/watch.js +6 -0
  213. package/dist/workflow-patterns/artifact-writer.d.ts +16 -0
  214. package/dist/workflow-patterns/artifact-writer.js +34 -0
  215. package/dist/workflow-patterns/classifiers.d.ts +10 -0
  216. package/dist/workflow-patterns/classifiers.js +72 -0
  217. package/dist/workflow-patterns/detector.d.ts +27 -0
  218. package/dist/workflow-patterns/detector.js +186 -0
  219. package/dist/workflow-patterns/index.d.ts +8 -0
  220. package/dist/workflow-patterns/index.js +7 -0
  221. package/dist/workflow-patterns/proposal-generator.d.ts +15 -0
  222. package/dist/workflow-patterns/proposal-generator.js +183 -0
  223. package/dist/workflow-patterns/telemetry-ingest.d.ts +27 -0
  224. package/dist/workflow-patterns/telemetry-ingest.js +103 -0
  225. package/dist/workflow-patterns/types.d.ts +61 -0
  226. package/dist/workflow-patterns/types.js +11 -0
  227. package/package.json +2 -2
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Autonomous correction loop for design system gates (RFC-0006 §8.4)
3
+ * and Design Review feedback pipeline (RFC-0006 §8.5).
4
+ */
5
+ import type { VisualRegressionFailure } from '@ai-sdlc/reference';
6
+ export interface CorrectionIteration {
7
+ attempt: number;
8
+ failures: VisualRegressionFailure[];
9
+ codeDiff?: string;
10
+ visualDiff?: string;
11
+ costUsd: number;
12
+ tokenReferencesChanged: boolean;
13
+ timestamp: string;
14
+ }
15
+ export interface CorrectionLoopConfig {
16
+ maxRetries: number;
17
+ costSoftLimitUsd: number;
18
+ }
19
+ export type CorrectionExitReason = 'max-retries' | 'token-reference-changed' | 'cost-limit-exceeded' | 'design-review-triggered' | 'success';
20
+ export interface CorrectionLoopResult {
21
+ converged: boolean;
22
+ exitReason: CorrectionExitReason;
23
+ iterations: CorrectionIteration[];
24
+ totalCostUsd: number;
25
+ }
26
+ /**
27
+ * Check whether the correction loop should exit.
28
+ */
29
+ export declare function checkExitConditions(iterations: CorrectionIteration[], config: CorrectionLoopConfig, designReviewTriggered: boolean): CorrectionExitReason | null;
30
+ /**
31
+ * Run the autonomous correction loop.
32
+ *
33
+ * @param runAttempt - Function that executes the agent and returns failures + cost
34
+ * @param config - Loop configuration (maxRetries, cost limit)
35
+ * @param checkDesignReviewTrigger - Function that checks if design review conditions are met
36
+ */
37
+ export declare function runCorrectionLoop(runAttempt: (failures: VisualRegressionFailure[], attempt: number) => Promise<{
38
+ failures: VisualRegressionFailure[];
39
+ costUsd: number;
40
+ tokenReferencesChanged: boolean;
41
+ codeDiff?: string;
42
+ }>, config: CorrectionLoopConfig, checkDesignReviewTrigger?: () => boolean): Promise<CorrectionLoopResult>;
43
+ export type FeedbackSignal = 'accepted' | 'dismissed' | 'overridden' | 'escalated';
44
+ export interface FeedbackEntry {
45
+ prNumber: number;
46
+ category: string;
47
+ signal: FeedbackSignal;
48
+ reviewer: string;
49
+ comment?: string;
50
+ timestamp: string;
51
+ }
52
+ export interface CategoryAnalysis {
53
+ category: string;
54
+ dismissRate: number;
55
+ }
56
+ export interface DesignReviewFeedbackStore {
57
+ record(entry: FeedbackEntry): void;
58
+ precision(): number;
59
+ highFalsePositiveCategories(): CategoryAnalysis[];
60
+ falseNegativeCategories(): CategoryAnalysis[];
61
+ getEntries(): FeedbackEntry[];
62
+ }
63
+ export declare function createDesignReviewFeedbackStore(): DesignReviewFeedbackStore;
64
+ //# sourceMappingURL=design-system-correction-loop.d.ts.map
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Autonomous correction loop for design system gates (RFC-0006 §8.4)
3
+ * and Design Review feedback pipeline (RFC-0006 §8.5).
4
+ */
5
+ /**
6
+ * Check whether the correction loop should exit.
7
+ */
8
+ export function checkExitConditions(iterations, config, designReviewTriggered) {
9
+ // Condition 1: maxRetries reached
10
+ if (iterations.length >= config.maxRetries) {
11
+ return 'max-retries';
12
+ }
13
+ // Condition 2: agent changed a token reference
14
+ const last = iterations[iterations.length - 1];
15
+ if (last?.tokenReferencesChanged) {
16
+ return 'token-reference-changed';
17
+ }
18
+ // Condition 3: cumulative cost exceeds soft limit
19
+ const totalCost = iterations.reduce((sum, it) => sum + it.costUsd, 0);
20
+ if (totalCost >= config.costSoftLimitUsd) {
21
+ return 'cost-limit-exceeded';
22
+ }
23
+ // Condition 4: design review trigger conditions met
24
+ if (designReviewTriggered) {
25
+ return 'design-review-triggered';
26
+ }
27
+ return null;
28
+ }
29
+ /**
30
+ * Run the autonomous correction loop.
31
+ *
32
+ * @param runAttempt - Function that executes the agent and returns failures + cost
33
+ * @param config - Loop configuration (maxRetries, cost limit)
34
+ * @param checkDesignReviewTrigger - Function that checks if design review conditions are met
35
+ */
36
+ export async function runCorrectionLoop(runAttempt, config, checkDesignReviewTrigger = () => false) {
37
+ const iterations = [];
38
+ let currentFailures = [];
39
+ for (let attempt = 0; attempt < config.maxRetries; attempt++) {
40
+ const result = await runAttempt(currentFailures, attempt);
41
+ iterations.push({
42
+ attempt,
43
+ failures: result.failures,
44
+ codeDiff: result.codeDiff,
45
+ costUsd: result.costUsd,
46
+ tokenReferencesChanged: result.tokenReferencesChanged,
47
+ timestamp: new Date().toISOString(),
48
+ });
49
+ // Check if converged (no more failures)
50
+ if (result.failures.length === 0) {
51
+ return {
52
+ converged: true,
53
+ exitReason: 'success',
54
+ iterations,
55
+ totalCostUsd: iterations.reduce((s, it) => s + it.costUsd, 0),
56
+ };
57
+ }
58
+ currentFailures = result.failures;
59
+ // Check exit conditions
60
+ const exitReason = checkExitConditions(iterations, config, checkDesignReviewTrigger());
61
+ if (exitReason) {
62
+ return {
63
+ converged: false,
64
+ exitReason,
65
+ iterations,
66
+ totalCostUsd: iterations.reduce((s, it) => s + it.costUsd, 0),
67
+ };
68
+ }
69
+ }
70
+ return {
71
+ converged: false,
72
+ exitReason: 'max-retries',
73
+ iterations,
74
+ totalCostUsd: iterations.reduce((s, it) => s + it.costUsd, 0),
75
+ };
76
+ }
77
+ export function createDesignReviewFeedbackStore() {
78
+ const entries = [];
79
+ return {
80
+ record(entry) {
81
+ entries.push(entry);
82
+ },
83
+ precision() {
84
+ const accepted = entries.filter((e) => e.signal === 'accepted').length;
85
+ const dismissed = entries.filter((e) => e.signal === 'dismissed').length;
86
+ const total = accepted + dismissed;
87
+ return total > 0 ? accepted / total : 1;
88
+ },
89
+ highFalsePositiveCategories() {
90
+ const categoryStats = new Map();
91
+ for (const entry of entries) {
92
+ const stats = categoryStats.get(entry.category) ?? { dismissed: 0, total: 0 };
93
+ stats.total++;
94
+ if (entry.signal === 'dismissed')
95
+ stats.dismissed++;
96
+ categoryStats.set(entry.category, stats);
97
+ }
98
+ return [...categoryStats.entries()]
99
+ .map(([category, stats]) => ({
100
+ category,
101
+ dismissRate: stats.total > 0 ? stats.dismissed / stats.total : 0,
102
+ }))
103
+ .filter((c) => c.dismissRate > 0)
104
+ .sort((a, b) => b.dismissRate - a.dismissRate);
105
+ },
106
+ falseNegativeCategories() {
107
+ const categoryStats = new Map();
108
+ for (const entry of entries) {
109
+ const stats = categoryStats.get(entry.category) ?? { escalated: 0, total: 0 };
110
+ stats.total++;
111
+ if (entry.signal === 'escalated')
112
+ stats.escalated++;
113
+ categoryStats.set(entry.category, stats);
114
+ }
115
+ return [...categoryStats.entries()]
116
+ .map(([category, stats]) => ({
117
+ category,
118
+ dismissRate: stats.total > 0 ? stats.escalated / stats.total : 0,
119
+ }))
120
+ .filter((c) => c.dismissRate > 0)
121
+ .sort((a, b) => b.dismissRate - a.dismissRate);
122
+ },
123
+ getEntries() {
124
+ return [...entries];
125
+ },
126
+ };
127
+ }
128
+ //# sourceMappingURL=design-system-correction-loop.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Design system metrics for autonomy promotion/demotion (RFC-0006 §13.2, §A.10).
3
+ *
4
+ * Computes six design review metrics from state store data and integrates
5
+ * them into the autonomy evaluation system.
6
+ */
7
+ import type { DesignReviewEventRecord, TokenComplianceRecord, VisualRegressionResultRecord, UsabilitySimulationResultRecord } from './state/types.js';
8
+ export interface DesignMetrics {
9
+ /** Percentage of Design CI runs that pass on first attempt. */
10
+ designCiPassRate: number;
11
+ /** Percentage of usability simulations that complete successfully. */
12
+ usabilitySimulationPassRate: number;
13
+ /** Percentage of design reviews approved (any decision except rejected). */
14
+ designReviewApprovalRate: number;
15
+ /** Percentage of design reviews approved without any rejection cycle. */
16
+ designReviewFirstPassRate: number;
17
+ /** Percentage of Design CI failures auto-fixed by correction loop. */
18
+ designCiAutoFixRate: number;
19
+ /** Precision of usability findings (accepted / (accepted + dismissed)). */
20
+ usabilityFindingAccuracy: number;
21
+ }
22
+ /**
23
+ * Compute design review approval rate from review events.
24
+ */
25
+ export declare function computeDesignReviewApprovalRate(events: DesignReviewEventRecord[]): number;
26
+ /**
27
+ * Compute design review first-pass rate (approved without rejection cycles).
28
+ * Groups events by PR and checks if the first review for each PR was an approval.
29
+ */
30
+ export declare function computeDesignReviewFirstPassRate(events: DesignReviewEventRecord[]): number;
31
+ /**
32
+ * Compute usability simulation pass rate from simulation results.
33
+ */
34
+ export declare function computeUsabilitySimulationPassRate(results: UsabilitySimulationResultRecord[]): number;
35
+ /**
36
+ * Compute token compliance trend from compliance history.
37
+ */
38
+ export declare function computeTokenComplianceTrend(history: TokenComplianceRecord[]): {
39
+ current: number;
40
+ trend: 'improving' | 'stable' | 'declining';
41
+ };
42
+ /**
43
+ * Compute visual regression pass rate from results.
44
+ */
45
+ export declare function computeVisualRegressionPassRate(results: VisualRegressionResultRecord[]): number;
46
+ /**
47
+ * Compute all six design metrics from state store data.
48
+ */
49
+ export declare function computeDesignMetrics(data: {
50
+ reviewEvents: DesignReviewEventRecord[];
51
+ complianceHistory: TokenComplianceRecord[];
52
+ visualRegressionResults: VisualRegressionResultRecord[];
53
+ usabilitySimulationResults: UsabilitySimulationResultRecord[];
54
+ designCiPassCount?: number;
55
+ designCiTotalCount?: number;
56
+ designCiAutoFixCount?: number;
57
+ designCiFailCount?: number;
58
+ findingsAccepted?: number;
59
+ findingsDismissed?: number;
60
+ }): DesignMetrics;
61
+ //# sourceMappingURL=design-system-metrics.d.ts.map
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Design system metrics for autonomy promotion/demotion (RFC-0006 §13.2, §A.10).
3
+ *
4
+ * Computes six design review metrics from state store data and integrates
5
+ * them into the autonomy evaluation system.
6
+ */
7
+ // ── Metric Computation ───────────────────────────────────────────────
8
+ /**
9
+ * Compute design review approval rate from review events.
10
+ */
11
+ export function computeDesignReviewApprovalRate(events) {
12
+ if (events.length === 0)
13
+ return 1;
14
+ const approved = events.filter((e) => e.decision === 'approved' || e.decision === 'approved-with-comments').length;
15
+ return approved / events.length;
16
+ }
17
+ /**
18
+ * Compute design review first-pass rate (approved without rejection cycles).
19
+ * Groups events by PR and checks if the first review for each PR was an approval.
20
+ */
21
+ export function computeDesignReviewFirstPassRate(events) {
22
+ if (events.length === 0)
23
+ return 1;
24
+ const prGroups = new Map();
25
+ for (const e of events) {
26
+ if (e.prNumber === undefined)
27
+ continue;
28
+ const group = prGroups.get(e.prNumber) ?? [];
29
+ group.push(e);
30
+ prGroups.set(e.prNumber, group);
31
+ }
32
+ if (prGroups.size === 0)
33
+ return 1;
34
+ let firstPassCount = 0;
35
+ for (const [, group] of prGroups) {
36
+ // Sort by created_at, check if first is approved
37
+ const sorted = group.sort((a, b) => (a.createdAt ?? '').localeCompare(b.createdAt ?? ''));
38
+ if (sorted[0].decision === 'approved' || sorted[0].decision === 'approved-with-comments') {
39
+ firstPassCount++;
40
+ }
41
+ }
42
+ return firstPassCount / prGroups.size;
43
+ }
44
+ /**
45
+ * Compute usability simulation pass rate from simulation results.
46
+ */
47
+ export function computeUsabilitySimulationPassRate(results) {
48
+ if (results.length === 0)
49
+ return 1;
50
+ const passed = results.filter((r) => r.completed).length;
51
+ return passed / results.length;
52
+ }
53
+ /**
54
+ * Compute token compliance trend from compliance history.
55
+ */
56
+ export function computeTokenComplianceTrend(history) {
57
+ if (history.length === 0)
58
+ return { current: 0, trend: 'stable' };
59
+ if (history.length === 1)
60
+ return { current: history[0].coveragePercent, trend: 'stable' };
61
+ const sorted = [...history].sort((a, b) => (a.scannedAt ?? '').localeCompare(b.scannedAt ?? ''));
62
+ const current = sorted[sorted.length - 1].coveragePercent;
63
+ const previous = sorted[sorted.length - 2].coveragePercent;
64
+ const delta = current - previous;
65
+ let trend;
66
+ if (delta > 1)
67
+ trend = 'improving';
68
+ else if (delta < -1)
69
+ trend = 'declining';
70
+ else
71
+ trend = 'stable';
72
+ return { current, trend };
73
+ }
74
+ /**
75
+ * Compute visual regression pass rate from results.
76
+ */
77
+ export function computeVisualRegressionPassRate(results) {
78
+ if (results.length === 0)
79
+ return 1;
80
+ const threshold = 0.01; // default diff threshold
81
+ const passed = results.filter((r) => r.diffPercentage <= threshold).length;
82
+ return passed / results.length;
83
+ }
84
+ /**
85
+ * Compute all six design metrics from state store data.
86
+ */
87
+ export function computeDesignMetrics(data) {
88
+ const ciTotal = data.designCiTotalCount ?? 0;
89
+ const ciPass = data.designCiPassCount ?? ciTotal;
90
+ const ciAutoFix = data.designCiAutoFixCount ?? 0;
91
+ const ciFail = data.designCiFailCount ?? 0;
92
+ const findingsAccepted = data.findingsAccepted ?? 0;
93
+ const findingsDismissed = data.findingsDismissed ?? 0;
94
+ const findingsTotal = findingsAccepted + findingsDismissed;
95
+ return {
96
+ designCiPassRate: ciTotal > 0 ? ciPass / ciTotal : 1,
97
+ usabilitySimulationPassRate: computeUsabilitySimulationPassRate(data.usabilitySimulationResults),
98
+ designReviewApprovalRate: computeDesignReviewApprovalRate(data.reviewEvents),
99
+ designReviewFirstPassRate: computeDesignReviewFirstPassRate(data.reviewEvents),
100
+ designCiAutoFixRate: ciFail > 0 ? ciAutoFix / ciFail : 1,
101
+ usabilityFindingAccuracy: findingsTotal > 0 ? findingsAccepted / findingsTotal : 1,
102
+ };
103
+ }
104
+ //# sourceMappingURL=design-system-metrics.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Stewardship enforcement for DesignSystemBinding resources (RFC-0006 §5.3).
3
+ *
4
+ * Validates that changes to authority-scoped fields are submitted by
5
+ * authorized principals. Changes to sharedAuthority fields require
6
+ * approval from both disciplines when requireBothDisciplines is true.
7
+ */
8
+ import type { DesignSystemBinding } from '@ai-sdlc/reference';
9
+ export interface StewardshipDecision {
10
+ allowed: boolean;
11
+ reason: string;
12
+ requiredApprovals?: string[];
13
+ }
14
+ /**
15
+ * Enforce stewardship constraints on a proposed change to a DesignSystemBinding.
16
+ *
17
+ * @param changedFields - The field paths being modified
18
+ * @param principal - The identity of the person/agent making the change
19
+ * @param binding - The DesignSystemBinding being modified
20
+ */
21
+ export declare function enforceStewardship(changedFields: string[], principal: string, binding: DesignSystemBinding): StewardshipDecision;
22
+ //# sourceMappingURL=design-system-stewardship.d.ts.map
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Stewardship enforcement for DesignSystemBinding resources (RFC-0006 §5.3).
3
+ *
4
+ * Validates that changes to authority-scoped fields are submitted by
5
+ * authorized principals. Changes to sharedAuthority fields require
6
+ * approval from both disciplines when requireBothDisciplines is true.
7
+ */
8
+ /**
9
+ * Determine which authority scope a field belongs to.
10
+ */
11
+ function findAuthorityScope(stewardship, field) {
12
+ if (stewardship.sharedAuthority?.scope?.includes(field))
13
+ return 'shared';
14
+ if (stewardship.designAuthority.scope.includes(field))
15
+ return 'design';
16
+ if (stewardship.engineeringAuthority.scope.includes(field))
17
+ return 'engineering';
18
+ return 'none';
19
+ }
20
+ /**
21
+ * Check if a principal is authorized for a given authority scope.
22
+ */
23
+ function isAuthorized(stewardship, principal, scope) {
24
+ const authorityType = findAuthorityScope(stewardship, scope);
25
+ switch (authorityType) {
26
+ case 'design':
27
+ return stewardship.designAuthority.principals.includes(principal);
28
+ case 'engineering':
29
+ return stewardship.engineeringAuthority.principals.includes(principal);
30
+ case 'shared':
31
+ return (stewardship.designAuthority.principals.includes(principal) ||
32
+ stewardship.engineeringAuthority.principals.includes(principal) ||
33
+ (stewardship.sharedAuthority?.principals?.includes(principal) ?? false));
34
+ case 'none':
35
+ return true; // Unscoped fields are unrestricted
36
+ }
37
+ }
38
+ /**
39
+ * Enforce stewardship constraints on a proposed change to a DesignSystemBinding.
40
+ *
41
+ * @param changedFields - The field paths being modified
42
+ * @param principal - The identity of the person/agent making the change
43
+ * @param binding - The DesignSystemBinding being modified
44
+ */
45
+ export function enforceStewardship(changedFields, principal, binding) {
46
+ const stewardship = binding.spec.stewardship;
47
+ const requireBoth = stewardship.changeApproval?.requireBothDisciplines ?? true;
48
+ for (const field of changedFields) {
49
+ const scope = findAuthorityScope(stewardship, field);
50
+ // Shared authority fields may require both disciplines
51
+ if (scope === 'shared' && requireBoth) {
52
+ const isDesign = stewardship.designAuthority.principals.includes(principal);
53
+ const isEngineering = stewardship.engineeringAuthority.principals.includes(principal);
54
+ const isShared = stewardship.sharedAuthority?.principals?.includes(principal) ?? false;
55
+ if (!isDesign && !isEngineering && !isShared) {
56
+ return {
57
+ allowed: false,
58
+ reason: `Principal "${principal}" is not authorized for shared-authority field "${field}"`,
59
+ };
60
+ }
61
+ // Identify which discipline still needs to approve
62
+ const needed = [];
63
+ if (!isDesign && !isShared)
64
+ needed.push('design');
65
+ if (!isEngineering && !isShared)
66
+ needed.push('engineering');
67
+ if (needed.length > 0) {
68
+ return {
69
+ allowed: false,
70
+ reason: `Shared-authority field "${field}" requires approval from both disciplines. Pending: ${needed.join(', ')}`,
71
+ requiredApprovals: needed,
72
+ };
73
+ }
74
+ }
75
+ // Design/engineering scoped fields
76
+ if (!isAuthorized(stewardship, principal, field)) {
77
+ return {
78
+ allowed: false,
79
+ reason: `Principal "${principal}" is not authorized for ${scope}-authority field "${field}"`,
80
+ };
81
+ }
82
+ }
83
+ return { allowed: true, reason: 'All changed fields are within principal authority' };
84
+ }
85
+ //# sourceMappingURL=design-system-stewardship.js.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Validates DesignSystemBinding inheritance constraints (RFC-0006 §5.6).
3
+ *
4
+ * Multi-brand inheritance uses the `extends` field. Validation enforces:
5
+ * - Child compliance thresholds >= parent thresholds
6
+ * - Child cannot remove parent disallowHardcoded categories
7
+ * - Inheritance depth limited to two levels (parent → child)
8
+ */
9
+ import type { DesignSystemBinding } from '@ai-sdlc/reference';
10
+ export interface InheritanceError {
11
+ field: string;
12
+ message: string;
13
+ }
14
+ export interface InheritanceValidationResult {
15
+ valid: boolean;
16
+ errors: InheritanceError[];
17
+ }
18
+ /**
19
+ * Resolve the parent binding from the collection by name.
20
+ */
21
+ export declare function resolveParent(child: DesignSystemBinding, bindings: DesignSystemBinding[]): DesignSystemBinding | undefined;
22
+ /**
23
+ * Validate that a child DesignSystemBinding conforms to its parent's constraints.
24
+ *
25
+ * Rules:
26
+ * 1. Child compliance.coverage.minimum >= parent compliance.coverage.minimum
27
+ * 2. Child compliance.coverage.target >= parent compliance.coverage.target (if both defined)
28
+ * 3. Child must not remove any parent disallowHardcoded categories
29
+ * 4. Two-level depth limit: parent must not itself have an `extends` field
30
+ */
31
+ export declare function validateDesignSystemInheritance(child: DesignSystemBinding, parent: DesignSystemBinding): InheritanceValidationResult;
32
+ /**
33
+ * Validate all DesignSystemBinding inheritance relationships in a collection.
34
+ * Returns errors for any invalid inheritance chains.
35
+ */
36
+ export declare function validateAllInheritance(bindings: DesignSystemBinding[]): InheritanceValidationResult;
37
+ //# sourceMappingURL=design-system-validation.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Validates DesignSystemBinding inheritance constraints (RFC-0006 §5.6).
3
+ *
4
+ * Multi-brand inheritance uses the `extends` field. Validation enforces:
5
+ * - Child compliance thresholds >= parent thresholds
6
+ * - Child cannot remove parent disallowHardcoded categories
7
+ * - Inheritance depth limited to two levels (parent → child)
8
+ */
9
+ /**
10
+ * Resolve the parent binding from the collection by name.
11
+ */
12
+ export function resolveParent(child, bindings) {
13
+ if (!child.spec.extends)
14
+ return undefined;
15
+ return bindings.find((b) => b.metadata.name === child.spec.extends);
16
+ }
17
+ /**
18
+ * Validate that a child DesignSystemBinding conforms to its parent's constraints.
19
+ *
20
+ * Rules:
21
+ * 1. Child compliance.coverage.minimum >= parent compliance.coverage.minimum
22
+ * 2. Child compliance.coverage.target >= parent compliance.coverage.target (if both defined)
23
+ * 3. Child must not remove any parent disallowHardcoded categories
24
+ * 4. Two-level depth limit: parent must not itself have an `extends` field
25
+ */
26
+ export function validateDesignSystemInheritance(child, parent) {
27
+ const errors = [];
28
+ // Depth limit: parent must not extend another binding
29
+ if (parent.spec.extends) {
30
+ errors.push({
31
+ field: 'extends',
32
+ message: `Inheritance depth exceeds two levels: "${child.metadata.name}" extends "${parent.metadata.name}" which extends "${parent.spec.extends}". Only parent → child is supported in v1alpha1.`,
33
+ });
34
+ }
35
+ // Coverage minimum: child >= parent
36
+ const parentMin = parent.spec.compliance.coverage.minimum;
37
+ const childMin = child.spec.compliance.coverage.minimum;
38
+ if (childMin < parentMin) {
39
+ errors.push({
40
+ field: 'compliance.coverage.minimum',
41
+ message: `Child minimum coverage (${childMin}) is less than parent minimum (${parentMin}). Child thresholds can only tighten, not loosen.`,
42
+ });
43
+ }
44
+ // Coverage target: child >= parent (if both defined)
45
+ const parentTarget = parent.spec.compliance.coverage.target;
46
+ const childTarget = child.spec.compliance.coverage.target;
47
+ if (parentTarget !== undefined && childTarget !== undefined && childTarget < parentTarget) {
48
+ errors.push({
49
+ field: 'compliance.coverage.target',
50
+ message: `Child target coverage (${childTarget}) is less than parent target (${parentTarget}). Child thresholds can only tighten, not loosen.`,
51
+ });
52
+ }
53
+ // disallowHardcoded: child must not remove parent categories
54
+ const parentCategories = new Set((parent.spec.compliance.disallowHardcoded ?? []).map((r) => r.category));
55
+ const childCategories = new Set((child.spec.compliance.disallowHardcoded ?? []).map((r) => r.category));
56
+ for (const category of parentCategories) {
57
+ if (!childCategories.has(category)) {
58
+ errors.push({
59
+ field: 'compliance.disallowHardcoded',
60
+ message: `Child removes parent disallowHardcoded category "${category}". Child bindings may add categories but must not remove parent categories.`,
61
+ });
62
+ }
63
+ }
64
+ return { valid: errors.length === 0, errors };
65
+ }
66
+ /**
67
+ * Validate all DesignSystemBinding inheritance relationships in a collection.
68
+ * Returns errors for any invalid inheritance chains.
69
+ */
70
+ export function validateAllInheritance(bindings) {
71
+ const allErrors = [];
72
+ for (const binding of bindings) {
73
+ if (!binding.spec.extends)
74
+ continue;
75
+ const parent = resolveParent(binding, bindings);
76
+ if (!parent) {
77
+ allErrors.push({
78
+ field: 'extends',
79
+ message: `Binding "${binding.metadata.name}" extends "${binding.spec.extends}" but no binding with that name exists.`,
80
+ });
81
+ continue;
82
+ }
83
+ const result = validateDesignSystemInheritance(binding, parent);
84
+ allErrors.push(...result.errors);
85
+ }
86
+ return { valid: allErrors.length === 0, errors: allErrors };
87
+ }
88
+ //# sourceMappingURL=design-system-validation.js.map
@@ -0,0 +1,4 @@
1
+ export { runWorkerPool, type WorkItem, type WorkerPoolDeps, type WorkerPoolEvent, type WorkerPoolResult, } from './worker-pool.js';
2
+ export { withMergeGate, forceReleaseMergeGate, isBranchUpToDate, MergeGateLockTimeoutError, type MergeGateDeps, } from './merge-gate.js';
3
+ export { decideRequeue, appendTriageHistory, type FailureEvent, type RequeueTrigger, type RequeueDecision, type RequeueDecisionInput, type TriageHistoryEntry, type FailureClassification, } from './requeue.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { runWorkerPool, } from './worker-pool.js';
2
+ export { withMergeGate, forceReleaseMergeGate, isBranchUpToDate, MergeGateLockTimeoutError, } from './merge-gate.js';
3
+ export { decideRequeue, appendTriageHistory, } from './requeue.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * File-based merge gate per RFC-0010 §10. Single mutex (<pool>/.merge-gate.lock)
3
+ * serializes the merge-eligibility/rebase step across parallel agents. Stale-base
4
+ * detection + rebase-on-conflict per §10.2.
5
+ *
6
+ * Per project policy (feedback_never_merge_prs.md): the orchestrator MUST NOT execute
7
+ * `gh pr merge`. The merge gate ensures a PR is in known-mergeable state when the
8
+ * human reviewer hits merge — it does NOT perform the merge itself.
9
+ */
10
+ export declare class MergeGateLockTimeoutError extends Error {
11
+ readonly lockPath: string;
12
+ constructor(lockPath: string);
13
+ }
14
+ export interface MergeGateDeps {
15
+ /** Override for tests. */
16
+ now?: () => number;
17
+ }
18
+ /**
19
+ * Acquire the merge gate, run `work`, release. The lock is a sentinel file; if it
20
+ * already exists, the caller polls until it's released or the timeout elapses.
21
+ *
22
+ * Caveat: this is a cooperative file lock, not a kernel lock. Crashes can leave a
23
+ * stale lock; the caller is expected to forcibly remove and retry as a recovery step.
24
+ */
25
+ export declare function withMergeGate<T>(poolDir: string, work: () => Promise<T>, options?: {
26
+ timeoutMs?: number;
27
+ }, deps?: MergeGateDeps): Promise<T>;
28
+ /**
29
+ * Force-remove a stale merge gate lock. Operators run this manually when an agent
30
+ * crashed mid-merge-gate and the lock file is orphaned.
31
+ */
32
+ export declare function forceReleaseMergeGate(poolDir: string): Promise<void>;
33
+ /**
34
+ * Test helper: write a sentinel lock file in an unexpected state (used by tests
35
+ * verifying the timeout path).
36
+ */
37
+ export declare function _testWriteSentinel(poolDir: string): Promise<void>;
38
+ /**
39
+ * Stale-base detection per RFC §10.2. Compares a branch's base SHA to the current
40
+ * remote target's HEAD; returns true when the branch is up-to-date.
41
+ *
42
+ * The actual git logic is delegated to the caller via `headOfRemote` so this stays
43
+ * unit-testable without shelling out.
44
+ */
45
+ export declare function isBranchUpToDate(branchBaseSha: string, targetBranch: string, headOfRemote: (target: string) => Promise<string>): Promise<boolean>;
46
+ //# sourceMappingURL=merge-gate.d.ts.map