@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,26 @@
1
+ /**
2
+ * Action enforcement — checks shell commands against blockedActions
3
+ * patterns from AgentRole constraints. Prevents agents from executing
4
+ * dangerous operations like merging PRs, force-pushing, or dismissing reviews.
5
+ */
6
+ import type { AuditLog } from '@ai-sdlc/reference';
7
+ export interface ActionEnforcementResult {
8
+ allowed: boolean;
9
+ /** The pattern that matched, if blocked. */
10
+ matchedPattern?: string;
11
+ /** The full command that was checked. */
12
+ command: string;
13
+ }
14
+ /**
15
+ * Check if a shell command is allowed by the blocked actions policy.
16
+ */
17
+ export declare function checkAction(command: string, blockedActions: string[]): ActionEnforcementResult;
18
+ /**
19
+ * Check an action and record the result in the audit log if blocked.
20
+ */
21
+ export declare function enforceAction(command: string, blockedActions: string[], auditLog?: AuditLog, agentName?: string): ActionEnforcementResult;
22
+ /**
23
+ * Default blocked actions for all agents.
24
+ */
25
+ export declare const DEFAULT_BLOCKED_ACTIONS: string[];
26
+ //# sourceMappingURL=action-enforcement.d.ts.map
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Action enforcement — checks shell commands against blockedActions
3
+ * patterns from AgentRole constraints. Prevents agents from executing
4
+ * dangerous operations like merging PRs, force-pushing, or dismissing reviews.
5
+ */
6
+ /**
7
+ * Convert a glob-like blocked action pattern to a regex.
8
+ * Supports * (any characters) anywhere in the pattern.
9
+ */
10
+ function patternToRegex(pattern) {
11
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
12
+ const regexStr = escaped.replace(/\*/g, '.*');
13
+ return new RegExp(`^${regexStr}$`, 'i');
14
+ }
15
+ /**
16
+ * Check if a shell command is allowed by the blocked actions policy.
17
+ */
18
+ export function checkAction(command, blockedActions) {
19
+ const trimmed = command.trim();
20
+ if (!trimmed)
21
+ return { allowed: true, command: trimmed };
22
+ for (const pattern of blockedActions) {
23
+ const regex = patternToRegex(pattern);
24
+ if (regex.test(trimmed)) {
25
+ return {
26
+ allowed: false,
27
+ matchedPattern: pattern,
28
+ command: trimmed,
29
+ };
30
+ }
31
+ }
32
+ return { allowed: true, command: trimmed };
33
+ }
34
+ /**
35
+ * Check an action and record the result in the audit log if blocked.
36
+ */
37
+ export function enforceAction(command, blockedActions, auditLog, agentName) {
38
+ const result = checkAction(command, blockedActions);
39
+ if (!result.allowed && auditLog) {
40
+ auditLog.record({
41
+ actor: agentName ?? 'agent',
42
+ action: 'execute',
43
+ resource: `command/${result.command.slice(0, 100)}`,
44
+ decision: 'denied',
45
+ details: {
46
+ reason: 'blocked-action',
47
+ pattern: result.matchedPattern,
48
+ command: result.command,
49
+ },
50
+ });
51
+ }
52
+ return result;
53
+ }
54
+ /**
55
+ * Default blocked actions for all agents.
56
+ */
57
+ export const DEFAULT_BLOCKED_ACTIONS = [
58
+ 'gh pr merge*',
59
+ 'git merge*',
60
+ 'git push --force*',
61
+ 'git push -f*',
62
+ 'gh pr close*',
63
+ 'gh issue close*',
64
+ 'git branch -D*',
65
+ 'git branch -d*',
66
+ 'git reset --hard*',
67
+ 'git checkout -- .',
68
+ 'git restore .',
69
+ ];
70
+ //# sourceMappingURL=action-enforcement.js.map
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Admission-subset composite (RFC-0008 §A.6).
3
+ *
4
+ * The admission gate uses a subset of the full PPA composite:
5
+ *
6
+ * P_admission = SA × D-pi_adjusted × ER × (1 + HC)
7
+ *
8
+ * where:
9
+ * SA = soulAlignment (0–1)
10
+ * D-pi_adjusted = rawDP × (1 − defectRiskFactor)
11
+ * rawDP = (demand + consensus + conviction + drift) / 4
12
+ * ER = min(baseER × autonomyFactor, designSystemReadiness)
13
+ * baseER = 1 − complexity / 10
14
+ * HC = tanh(weighted sum — see §A.6 Amendment 4)
15
+ *
16
+ * M-phi, E-tau, C-kappa are **deferred to runtime scoring** (§A.6 table):
17
+ * they apply once the issue is admitted and picked up by an executor,
18
+ * not at the admission gate. To keep the returned `PriorityScore`
19
+ * shape consistent with downstream consumers, we fill those dimensions
20
+ * with neutral values: marketForce=1, entropyTax=0, calibration=1
21
+ * (or the configured calibration coefficient if supplied, for display).
22
+ *
23
+ * The `override` bypass is preserved at position 1: when the input has
24
+ * `override: true`, we return `composite = Infinity` without running
25
+ * the admission math — identical to the legacy PPA behaviour.
26
+ */
27
+ import type { PriorityConfig, PriorityInput, PriorityScore } from '@ai-sdlc/reference';
28
+ import type { AdmissionInput } from './admission-score.js';
29
+ import { type AdmissionHumanCurveResult } from './admission-hc.js';
30
+ /**
31
+ * Result of the admission composite — returns a `PriorityScore`
32
+ * (backward-compatible with `scoreIssueForAdmission` consumers) plus
33
+ * the admission-specific breakdown for auditability.
34
+ */
35
+ export interface AdmissionComposite {
36
+ score: PriorityScore;
37
+ breakdown: {
38
+ soulAlignment: number;
39
+ rawDemandPressure: number;
40
+ defectRiskFactor: number;
41
+ demandPressureAdjusted: number;
42
+ baseExecutionReality: number;
43
+ autonomyFactor: number;
44
+ designSystemReadiness: number;
45
+ executionReality: number;
46
+ humanCurve: AdmissionHumanCurveResult;
47
+ };
48
+ }
49
+ export interface AdmissionCompositeOptions {
50
+ /**
51
+ * Optional override for the soulAlignment dimension — when present
52
+ * (typically a Phase 2b/2c/3 SA-1 from `scoreSoulAlignment`), it
53
+ * replaces the label-based heuristic. In Phase 2a shadow mode,
54
+ * callers pass undefined and the label-based fallback applies.
55
+ */
56
+ soulAlignmentOverride?: number;
57
+ /**
58
+ * Partial PriorityInput overrides applied AFTER `mapIssueToPriorityInput`.
59
+ * Used by non-GitHub trackers (e.g. Backlog.md adapter) to inject
60
+ * tracker-specific signals — `priority:p*` labels, AC-derived
61
+ * complexity, `qualityFlags` — that the GitHub-shaped mapper
62
+ * cannot extract. Only fields with defined values overwrite.
63
+ */
64
+ priorityInputOverrides?: Partial<PriorityInput>;
65
+ }
66
+ export declare function computeAdmissionComposite(input: AdmissionInput, config?: PriorityConfig, options?: AdmissionCompositeOptions): AdmissionComposite;
67
+ //# sourceMappingURL=admission-composite.d.ts.map
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Admission-subset composite (RFC-0008 §A.6).
3
+ *
4
+ * The admission gate uses a subset of the full PPA composite:
5
+ *
6
+ * P_admission = SA × D-pi_adjusted × ER × (1 + HC)
7
+ *
8
+ * where:
9
+ * SA = soulAlignment (0–1)
10
+ * D-pi_adjusted = rawDP × (1 − defectRiskFactor)
11
+ * rawDP = (demand + consensus + conviction + drift) / 4
12
+ * ER = min(baseER × autonomyFactor, designSystemReadiness)
13
+ * baseER = 1 − complexity / 10
14
+ * HC = tanh(weighted sum — see §A.6 Amendment 4)
15
+ *
16
+ * M-phi, E-tau, C-kappa are **deferred to runtime scoring** (§A.6 table):
17
+ * they apply once the issue is admitted and picked up by an executor,
18
+ * not at the admission gate. To keep the returned `PriorityScore`
19
+ * shape consistent with downstream consumers, we fill those dimensions
20
+ * with neutral values: marketForce=1, entropyTax=0, calibration=1
21
+ * (or the configured calibration coefficient if supplied, for display).
22
+ *
23
+ * The `override` bypass is preserved at position 1: when the input has
24
+ * `override: true`, we return `composite = Infinity` without running
25
+ * the admission math — identical to the legacy PPA behaviour.
26
+ */
27
+ import { mapIssueToPriorityInput } from './admission-score.js';
28
+ import { computeAutonomyFactor, computeDefectRiskFactor, computeReadinessFromDesignSystemContext, } from './admission-enrichment.js';
29
+ import { computeAdmissionHumanCurve } from './admission-hc.js';
30
+ import { computeConfidence } from './priority.js';
31
+ const DEFAULT_SIGNAL = 0.5;
32
+ export function computeAdmissionComposite(input, config, options) {
33
+ const timestamp = new Date().toISOString();
34
+ const baseInput = mapIssueToPriorityInput(input);
35
+ const priorityInput = options?.priorityInputOverrides
36
+ ? mergePriorityInputOverrides(baseInput, options.priorityInputOverrides)
37
+ : baseInput;
38
+ // ── Override path: position-1 bypass (§6 / AC #4) ─────────────
39
+ if (priorityInput.override) {
40
+ const score = {
41
+ composite: Infinity,
42
+ dimensions: {
43
+ soulAlignment: 1,
44
+ demandPressure: 1.5,
45
+ marketForce: 3.0,
46
+ executionReality: 1,
47
+ entropyTax: 0,
48
+ humanCurve: 1,
49
+ calibration: clampCalibration(config?.calibrationCoefficient),
50
+ },
51
+ confidence: 1,
52
+ timestamp,
53
+ override: {
54
+ reason: priorityInput.overrideReason ?? 'No reason provided',
55
+ expiry: priorityInput.overrideExpiry,
56
+ },
57
+ };
58
+ return {
59
+ score,
60
+ breakdown: {
61
+ soulAlignment: 1,
62
+ rawDemandPressure: 1,
63
+ defectRiskFactor: 0,
64
+ demandPressureAdjusted: 1,
65
+ baseExecutionReality: 1,
66
+ autonomyFactor: 1,
67
+ designSystemReadiness: 1,
68
+ executionReality: 1,
69
+ humanCurve: {
70
+ hcExplicit: 0,
71
+ hcConsensus: 0,
72
+ hcDecision: 0,
73
+ hcDesign: 0,
74
+ hcRaw: 0,
75
+ hcComposite: 1,
76
+ },
77
+ },
78
+ };
79
+ }
80
+ // ── SA (soul alignment) — SA-1 override (M5) or label-based fallback ──
81
+ const soulAlignment = clamp01(options?.soulAlignmentOverride ?? priorityInput.soulAlignment ?? DEFAULT_SIGNAL);
82
+ // ── D-pi_adjusted ─────────────────────────────────────────────
83
+ const demand = priorityInput.demandSignal ?? DEFAULT_SIGNAL;
84
+ const consensus = priorityInput.teamConsensus ?? DEFAULT_SIGNAL;
85
+ const conviction = priorityInput.builderConviction ?? DEFAULT_SIGNAL;
86
+ const drift = priorityInput.competitiveDrift ?? 0;
87
+ const rawDemandPressure = clamp01((demand + consensus + conviction + drift) / 4);
88
+ const defectRiskFactor = computeDefectRiskFactor(input.codeAreaQuality);
89
+ const demandPressureAdjusted = rawDemandPressure * (1 - defectRiskFactor);
90
+ // ── ER (execution reality) ─────────────────────────────────────
91
+ // baseER = 1 - complexity/10; complexity defaults to neutral midpoint.
92
+ const complexity = priorityInput.complexity ?? 5;
93
+ const baseExecutionReality = clamp01(1 - complexity / 10);
94
+ const autonomyFactor = computeAutonomyFactor(input.autonomyContext);
95
+ const designSystemReadiness = computeReadinessFromDesignSystemContext(input.designSystemContext);
96
+ const executionReality = Math.min(baseExecutionReality * autonomyFactor, designSystemReadiness);
97
+ // ── HC (tanh-compressed with HC_design) ───────────────────────
98
+ const humanCurve = computeAdmissionHumanCurve(input);
99
+ // ── §A.6 admission subset composite ───────────────────────────
100
+ const composite = soulAlignment * demandPressureAdjusted * executionReality * (1 + humanCurve.hcComposite);
101
+ const score = {
102
+ composite,
103
+ dimensions: {
104
+ soulAlignment,
105
+ demandPressure: demandPressureAdjusted,
106
+ // M-phi deferred to runtime — neutral for admission.
107
+ marketForce: 1,
108
+ executionReality,
109
+ // E-tau deferred to runtime — admission does not apply the
110
+ // entropy tax (competitiveDrift feeds rawDP instead).
111
+ entropyTax: 0,
112
+ humanCurve: humanCurve.hcComposite,
113
+ // C-kappa deferred to runtime — expose configured value for
114
+ // display continuity but do not multiply it into `composite`.
115
+ calibration: clampCalibration(config?.calibrationCoefficient),
116
+ },
117
+ confidence: computeConfidence(priorityInput),
118
+ timestamp,
119
+ };
120
+ return {
121
+ score,
122
+ breakdown: {
123
+ soulAlignment,
124
+ rawDemandPressure,
125
+ defectRiskFactor,
126
+ demandPressureAdjusted,
127
+ baseExecutionReality,
128
+ autonomyFactor,
129
+ designSystemReadiness,
130
+ executionReality,
131
+ humanCurve,
132
+ },
133
+ };
134
+ }
135
+ function clamp01(value) {
136
+ return Math.min(1, Math.max(0, value));
137
+ }
138
+ function clampCalibration(value) {
139
+ if (value === undefined)
140
+ return 1.0;
141
+ return Math.min(1.3, Math.max(0.7, value));
142
+ }
143
+ /**
144
+ * Apply non-GitHub tracker overrides on top of the GitHub-shaped
145
+ * `mapIssueToPriorityInput` output. A field's override wins iff it is
146
+ * not `undefined`; this preserves the GitHub mapper's defaults for
147
+ * any field the override does not specify.
148
+ */
149
+ function mergePriorityInputOverrides(base, overrides) {
150
+ const merged = { ...base };
151
+ for (const [key, value] of Object.entries(overrides)) {
152
+ if (value !== undefined) {
153
+ merged[key] = value;
154
+ }
155
+ }
156
+ return merged;
157
+ }
158
+ //# sourceMappingURL=admission-composite.js.map
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Bridge between stateless admission scoring and the stateful orchestrator
3
+ * (RFC-0008 Addendum A §A.2 – §A.5).
4
+ *
5
+ * `enrichAdmissionInput()` reads from the orchestrator's state store and
6
+ * resolved resources to populate the RFC-0008 context fields on
7
+ * `AdmissionInput`, then `computeDesignSystemReadiness()` produces the
8
+ * Eρ₄ scalar that feeds the admission composite in §A.6.
9
+ *
10
+ * Scope for AISDLC-43: implement C2 (Eρ₄) only. C3/C4/C5 are populated
11
+ * by later tasks (AISDLC-44/45/46).
12
+ */
13
+ import type { AutonomyPolicy, DesignIntentDocument, DesignSystemBinding } from '@ai-sdlc/reference';
14
+ import type { StateStore } from './state/store.js';
15
+ import type { AdmissionInput, AutonomyContext, CodeAreaQuality, DesignAuthoritySignal, DesignSystemContext } from './admission-score.js';
16
+ /**
17
+ * Minimum data points required before `code_area_metrics` is trusted
18
+ * enough to drive defect-risk penalties (RFC-0008 §7.4 Open Question 4).
19
+ */
20
+ export declare const CODE_AREA_METRICS_MIN_DATA_POINTS = 10;
21
+ export type LifecyclePhase = 'preDesignSystem' | 'catalogBootstrap' | 'postDesignSystem';
22
+ export interface EnrichmentContext {
23
+ /** State store for reading visual baselines and code-area metrics. */
24
+ stateStore?: StateStore;
25
+ /** Resolved DesignSystemBinding referenced by the DID (absent ⇒ preDesignSystem). */
26
+ designSystemBinding?: DesignSystemBinding;
27
+ /** Resolved DesignIntentDocument. Unused in C2 but threaded through for future connections. */
28
+ designIntentDocument?: DesignIntentDocument;
29
+ /** ISO timestamp when the DSB was adopted — used for age-based lifecycle detection. */
30
+ dsbAdoptedAt?: string;
31
+ /** Catalog gaps supplied by a catalog-provider adapter (AISDLC-43 accepts these pre-computed). */
32
+ catalogGaps?: string[];
33
+ /** Code area for the issue (e.g. "orchestrator/src/priority"), used by C3. */
34
+ codeArea?: string;
35
+ /** Resolved AutonomyPolicy — used by C4. */
36
+ autonomyPolicy?: AutonomyPolicy;
37
+ /**
38
+ * Agent expected to handle the issue. Used to pick a specific entry
39
+ * from `autonomyPolicy.status.agents`. When absent, the most
40
+ * permissive currently-earned level across all agents is used.
41
+ */
42
+ agentName?: string;
43
+ /**
44
+ * Task complexity in [0, 10] for mapping to a required autonomy level.
45
+ * When omitted, C4 falls back to the most permissive level for the
46
+ * resolved agent (requiredLevel = currentEarnedLevel → gap = 0).
47
+ */
48
+ complexity?: number;
49
+ /**
50
+ * Compliance score for the issue's area in [0, 1]. When present,
51
+ * `designAuthorityWeight` is modulated by `(1.2 - areaComplianceScore)`.
52
+ * When absent, the base weight applies unmodulated.
53
+ */
54
+ areaComplianceScore?: number;
55
+ /** Clock injection for deterministic tests. Defaults to `Date.now`. */
56
+ now?: () => number;
57
+ }
58
+ /**
59
+ * Populate `designSystemContext` on the admission input using the
60
+ * resolved DSB and state store. Returns the input unchanged when no DSB
61
+ * is available (preDesignSystem phase — caller falls through to the
62
+ * stateless path).
63
+ */
64
+ export declare function enrichAdmissionInput(input: AdmissionInput, ctx: EnrichmentContext): AdmissionInput;
65
+ /**
66
+ * Compute the C3 defect-risk factor per §A.5. Returns 0 when
67
+ * `codeAreaQuality` is absent (insufficient data → no penalty).
68
+ *
69
+ * !hasFrontendComponents → 0.5×dd + 0.3×churn + 0.2×prRej
70
+ * hasFrontendComponents
71
+ * no designQuality → same as pure code (no blend target)
72
+ * with designQuality → 0.7 × code + 0.3 × design
73
+ * where design = 0.4×(1-ciPass)
74
+ * + 0.4×reviewRej
75
+ * + 0.2×(1-usabPass)
76
+ *
77
+ * Final value is clamped to [0, 0.5].
78
+ */
79
+ export declare function computeDefectRiskFactor(quality: CodeAreaQuality | undefined): number;
80
+ /**
81
+ * Map task complexity to the required autonomy level per §A.4:
82
+ * complexity ≤ 3 → level 1
83
+ * complexity ≤ 6 → level 2
84
+ * else → level 3
85
+ */
86
+ export declare function complexityToAutonomyLevel(complexity: number): number;
87
+ /**
88
+ * Compute the C4 autonomy factor per §A.5:
89
+ * gap = requiredLevel - currentEarnedLevel
90
+ * gap > 0 → max(0.1, 1.0 - gap × 0.4)
91
+ * gap ≤ 0 → 1.0
92
+ */
93
+ export declare function computeAutonomyFactor(ctx: AutonomyContext | undefined): number;
94
+ /**
95
+ * Compute the C5 design-authority weight per §A.5.
96
+ *
97
+ * non-authority → 0.0
98
+ * authority + positive → +0.6 × modulation
99
+ * authority + negative → -0.4 × modulation
100
+ * authority + no type → +0.3 × modulation
101
+ *
102
+ * where `modulation = 1.2 - areaComplianceScore` when the score is
103
+ * supplied, else `1.0` (unmodulated base weight).
104
+ */
105
+ export declare function computeDesignAuthorityWeight(signal: DesignAuthoritySignal | undefined): number;
106
+ /**
107
+ * Compute the C2 Eρ₄ design-system readiness scalar in [0, 1] per §A.5.
108
+ *
109
+ * preDesignSystem: 1.0 (no DSB → no penalty)
110
+ * catalogBootstrap: max(0.3, 0.4×cat + 0.3×tok + 0.3×baseline)
111
+ * postDesignSystem: 0.4×cat + 0.3×tok + 0.3×baseline
112
+ */
113
+ export declare function computeDesignSystemReadiness(ctx: EnrichmentContext): number;
114
+ /**
115
+ * Compute the C2 Eρ₄ scalar directly from the DesignSystemContext
116
+ * already populated on an `AdmissionInput` (no DSB/state lookups).
117
+ *
118
+ * undefined (preDesignSystem) → 1.0
119
+ * inBootstrapPhase → max(0.3, computed)
120
+ * else → computed
121
+ *
122
+ * Used by the admission composite (§A.6) to avoid re-reading the state
123
+ * store on every score call.
124
+ */
125
+ export declare function computeReadinessFromDesignSystemContext(context: DesignSystemContext | undefined): number;
126
+ export declare function detectLifecyclePhase(binding: DesignSystemBinding | undefined, normalizedCatalogCoverage: number, ageDays: number): LifecyclePhase;
127
+ /**
128
+ * Days since the DSB was adopted. Returns 0 when no adoption timestamp
129
+ * is supplied — the conservative default (treats DSB as brand-new and
130
+ * favours the bootstrap floor).
131
+ */
132
+ export declare function computeDsbAgeDays(adoptedAt: string | undefined, now?: () => number): number;
133
+ /**
134
+ * Fraction of the UI under visual-regression monitoring for this binding,
135
+ * derived from approved baselines in `visual_regression_results`.
136
+ *
137
+ * Definition (§A.5 proxy): `approvedBaselines / totalBaselines`. Returns
138
+ * 0 when no history exists (bootstrap protection: avoids over-crediting
139
+ * readiness when the monitor hasn't run yet).
140
+ */
141
+ export declare function computeBaselineCoverage(store: StateStore, bindingName: string): number;
142
+ //# sourceMappingURL=admission-enrichment.d.ts.map