@ai-sdlc/orchestrator 0.9.0 → 0.13.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 (172) hide show
  1. package/dist/__test-helpers/git-env.d.ts +40 -0
  2. package/dist/__test-helpers/git-env.js +73 -0
  3. package/dist/adapters.d.ts +42 -3
  4. package/dist/adapters.js +133 -3
  5. package/dist/admission-composite.d.ts +134 -1
  6. package/dist/admission-composite.js +170 -6
  7. package/dist/admission-enrichment.d.ts +12 -3
  8. package/dist/admission-enrichment.js +71 -10
  9. package/dist/admission-hc.d.ts +20 -1
  10. package/dist/admission-hc.js +12 -1
  11. package/dist/admission-score.d.ts +44 -0
  12. package/dist/admission-score.js +11 -2
  13. package/dist/backlog-adapter.d.ts +45 -0
  14. package/dist/backlog-adapter.js +145 -1
  15. package/dist/calibration.d.ts +81 -0
  16. package/dist/calibration.js +76 -0
  17. package/dist/cli/commands/git-remote.d.ts +25 -0
  18. package/dist/cli/commands/git-remote.js +80 -1
  19. package/dist/cli/commands/init-features.d.ts +507 -0
  20. package/dist/cli/commands/init-features.js +1100 -0
  21. package/dist/cli/commands/init-templates.d.ts +301 -0
  22. package/dist/cli/commands/init-templates.js +1341 -0
  23. package/dist/cli/commands/init.d.ts +67 -0
  24. package/dist/cli/commands/init.js +301 -2
  25. package/dist/cli/commands/run.js +9 -1
  26. package/dist/cli/index.d.ts +11 -0
  27. package/dist/cli/index.js +42 -8
  28. package/dist/compliance/composer.d.ts +79 -0
  29. package/dist/compliance/composer.js +258 -0
  30. package/dist/compliance/errors.d.ts +64 -0
  31. package/dist/compliance/errors.js +85 -0
  32. package/dist/compliance/loader.d.ts +52 -0
  33. package/dist/compliance/loader.js +124 -0
  34. package/dist/compliance/types.d.ts +184 -0
  35. package/dist/compliance/types.js +41 -0
  36. package/dist/compliance-clearance.d.ts +269 -0
  37. package/dist/compliance-clearance.js +269 -0
  38. package/dist/config.js +17 -0
  39. package/dist/cost-tracker.d.ts +22 -0
  40. package/dist/cost-tracker.js +41 -0
  41. package/dist/database/adapters/external.js +5 -1
  42. package/dist/design-authority.d.ts +13 -0
  43. package/dist/design-authority.js +13 -0
  44. package/dist/embedding/adapters/openai-text-embedding-3-small.d.ts +71 -0
  45. package/dist/embedding/adapters/openai-text-embedding-3-small.js +190 -0
  46. package/dist/embedding/consumers/tessellation-drift.d.ts +74 -0
  47. package/dist/embedding/consumers/tessellation-drift.js +76 -0
  48. package/dist/embedding/cross-provider.d.ts +78 -0
  49. package/dist/embedding/cross-provider.js +75 -0
  50. package/dist/embedding/deprecation.d.ts +151 -0
  51. package/dist/embedding/deprecation.js +229 -0
  52. package/dist/embedding/errors.d.ts +90 -0
  53. package/dist/embedding/errors.js +150 -0
  54. package/dist/embedding/index.d.ts +29 -0
  55. package/dist/embedding/index.js +24 -0
  56. package/dist/embedding/pipeline-load.d.ts +146 -0
  57. package/dist/embedding/pipeline-load.js +178 -0
  58. package/dist/embedding/registry.d.ts +45 -0
  59. package/dist/embedding/registry.js +61 -0
  60. package/dist/embedding/stale-vector.d.ts +110 -0
  61. package/dist/embedding/stale-vector.js +92 -0
  62. package/dist/embedding/storage/index.d.ts +51 -0
  63. package/dist/embedding/storage/index.js +43 -0
  64. package/dist/embedding/storage/jsonl-backend.d.ts +150 -0
  65. package/dist/embedding/storage/jsonl-backend.js +332 -0
  66. package/dist/embedding/storage/types.d.ts +135 -0
  67. package/dist/embedding/storage/types.js +13 -0
  68. package/dist/embedding/types.d.ts +180 -0
  69. package/dist/embedding/types.js +10 -0
  70. package/dist/execute.d.ts +29 -2
  71. package/dist/execute.js +179 -35
  72. package/dist/index.d.ts +14 -2
  73. package/dist/index.js +19 -2
  74. package/dist/journey/inheritance-validator.d.ts +396 -0
  75. package/dist/journey/inheritance-validator.js +370 -0
  76. package/dist/journey/state-id-drift-rule.d.ts +137 -0
  77. package/dist/journey/state-id-drift-rule.js +245 -0
  78. package/dist/journey-sa2-router.d.ts +395 -0
  79. package/dist/journey-sa2-router.js +308 -0
  80. package/dist/models/classifier.d.ts +3 -1
  81. package/dist/models/classifier.js +61 -5
  82. package/dist/pillar-breakdown.d.ts +23 -1
  83. package/dist/pillar-breakdown.js +9 -0
  84. package/dist/runners/review-agent.js +6 -2
  85. package/dist/runners/runner-registry.d.ts +36 -0
  86. package/dist/runners/runner-registry.js +90 -0
  87. package/dist/runtime/attestations.d.ts +663 -11
  88. package/dist/runtime/attestations.js +971 -24
  89. package/dist/runtime/index.d.ts +1 -1
  90. package/dist/runtime/index.js +1 -1
  91. package/dist/runtime/parallelism-flag.d.ts +21 -3
  92. package/dist/runtime/parallelism-flag.js +27 -6
  93. package/dist/runtime/port-allocator.d.ts +11 -0
  94. package/dist/runtime/port-allocator.js +30 -0
  95. package/dist/sa-scoring/layer3-llm.js +6 -1
  96. package/dist/sa-scoring/revision-proposal-config.d.ts +178 -0
  97. package/dist/sa-scoring/revision-proposal-config.js +198 -0
  98. package/dist/sa-scoring/revision-proposal.d.ts +285 -0
  99. package/dist/sa-scoring/revision-proposal.js +417 -0
  100. package/dist/signal-ingestion/adapters/community-thread.d.ts +43 -0
  101. package/dist/signal-ingestion/adapters/community-thread.js +55 -0
  102. package/dist/signal-ingestion/adapters/in-app-feedback.d.ts +67 -0
  103. package/dist/signal-ingestion/adapters/in-app-feedback.js +51 -0
  104. package/dist/signal-ingestion/adapters/manual.d.ts +78 -0
  105. package/dist/signal-ingestion/adapters/manual.js +112 -0
  106. package/dist/signal-ingestion/adapters/support-ticket.d.ts +47 -0
  107. package/dist/signal-ingestion/adapters/support-ticket.js +51 -0
  108. package/dist/signal-ingestion/classifier.d.ts +205 -0
  109. package/dist/signal-ingestion/classifier.js +494 -0
  110. package/dist/signal-ingestion/clustering-types.d.ts +36 -0
  111. package/dist/signal-ingestion/clustering-types.js +14 -0
  112. package/dist/signal-ingestion/clustering.d.ts +200 -0
  113. package/dist/signal-ingestion/clustering.js +413 -0
  114. package/dist/signal-ingestion/config.d.ts +351 -0
  115. package/dist/signal-ingestion/config.js +587 -0
  116. package/dist/signal-ingestion/d1.d.ts +252 -0
  117. package/dist/signal-ingestion/d1.js +235 -0
  118. package/dist/signal-ingestion/errors.d.ts +73 -0
  119. package/dist/signal-ingestion/errors.js +108 -0
  120. package/dist/signal-ingestion/governance-events.d.ts +181 -0
  121. package/dist/signal-ingestion/governance-events.js +189 -0
  122. package/dist/signal-ingestion/index.d.ts +35 -0
  123. package/dist/signal-ingestion/index.js +53 -0
  124. package/dist/signal-ingestion/manual-share-metric.d.ts +93 -0
  125. package/dist/signal-ingestion/manual-share-metric.js +106 -0
  126. package/dist/signal-ingestion/registry.d.ts +40 -0
  127. package/dist/signal-ingestion/registry.js +137 -0
  128. package/dist/signal-ingestion/residency.d.ts +227 -0
  129. package/dist/signal-ingestion/residency.js +238 -0
  130. package/dist/signal-ingestion/significance.d.ts +554 -0
  131. package/dist/signal-ingestion/significance.js +555 -0
  132. package/dist/signal-ingestion/types.d.ts +191 -0
  133. package/dist/signal-ingestion/types.js +8 -0
  134. package/dist/substrate/drift-composition.d.ts +270 -0
  135. package/dist/substrate/drift-composition.js +306 -0
  136. package/dist/substrate/drift-tui-surface.d.ts +61 -0
  137. package/dist/substrate/drift-tui-surface.js +102 -0
  138. package/dist/substrate/identity-class.d.ts +176 -0
  139. package/dist/substrate/identity-class.js +201 -0
  140. package/dist/tessellation/cross-soul-provenance-rule.d.ts +133 -0
  141. package/dist/tessellation/cross-soul-provenance-rule.js +171 -0
  142. package/dist/tessellation/inter-soul-embedding-distance-rule.d.ts +61 -0
  143. package/dist/tessellation/inter-soul-embedding-distance-rule.js +67 -0
  144. package/dist/tessellation/rule-registry.d.ts +269 -0
  145. package/dist/tessellation/rule-registry.js +92 -0
  146. package/dist/tessellation/soul-slug-ast-scan-rule.d.ts +90 -0
  147. package/dist/tessellation/soul-slug-ast-scan-rule.js +158 -0
  148. package/dist/tessellation-admission.d.ts +162 -0
  149. package/dist/tessellation-admission.js +146 -0
  150. package/dist/tessellation-drift.d.ts +246 -0
  151. package/dist/tessellation-drift.js +250 -0
  152. package/dist/validate-config.js +13 -0
  153. package/dist/validate-issue.js +2 -2
  154. package/dist/variant/cardinality-activation.d.ts +126 -0
  155. package/dist/variant/cardinality-activation.js +101 -0
  156. package/dist/variant/deprecation-lifecycle.d.ts +184 -0
  157. package/dist/variant/deprecation-lifecycle.js +208 -0
  158. package/dist/variant/drift-extension.d.ts +136 -0
  159. package/dist/variant/drift-extension.js +164 -0
  160. package/dist/variant/engineering-review.d.ts +185 -0
  161. package/dist/variant/engineering-review.js +142 -0
  162. package/dist/variant/index.d.ts +32 -0
  163. package/dist/variant/index.js +32 -0
  164. package/dist/variant/inheritance-validator.d.ts +165 -0
  165. package/dist/variant/inheritance-validator.js +139 -0
  166. package/dist/variant/internal-adopter/index.d.ts +11 -0
  167. package/dist/variant/internal-adopter/index.js +10 -0
  168. package/dist/variant/internal-adopter/products.d.ts +156 -0
  169. package/dist/variant/internal-adopter/products.js +366 -0
  170. package/dist/variant-admission.d.ts +316 -0
  171. package/dist/variant-admission.js +247 -0
  172. package/package.json +11 -8
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Hermetic git env for orchestrator test fixtures (AISDLC-257).
3
+ *
4
+ * Cross-link: mirrors `pipeline-cli/src/__test-helpers/git-env.ts` (AISDLC-253).
5
+ * See that file for the canonical rationale. This copy exists so orchestrator
6
+ * tests don't take a cross-package import dependency on pipeline-cli's test
7
+ * helpers.
8
+ *
9
+ * Why this exists
10
+ * ───────────────
11
+ * Test fixtures that shell out to `git` (e.g. `execSync('git init', { cwd: d })`)
12
+ * are vulnerable to env-var bleed from the parent shell:
13
+ *
14
+ * - `GIT_DIR=...` overrides cwd-based repo discovery — every git command
15
+ * writes into the parent shell's GIT_DIR, NOT the fixture's `cwd`.
16
+ * - `GIT_WORK_TREE=...` ditto for the working tree.
17
+ * - `core.hooksPath` from system/global config can fire husky hooks during
18
+ * fixture commits.
19
+ * - `commit.gpgsign=true` from operator config can break unattended commits.
20
+ *
21
+ * The `cleanGitEnv()` helper in `orchestrator/src/runtime/git-env.ts` strips
22
+ * GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE but still inherits `process.env`
23
+ * in full, meaning `git config user.email` writes still land wherever git
24
+ * resolves config (which may be a polluted GIT_DIR or the operator's global
25
+ * config). AISDLC-257 identified `worktree-pool.integration.test.ts` as the
26
+ * confirmed leak source.
27
+ *
28
+ * `makeGitEnv()` uses an ALLOW-LIST approach rather than a DENY-LIST: it
29
+ * constructs a minimal env from scratch, deliberately omitting GIT_DIR and
30
+ * GIT_WORK_TREE. Identity is provided via `GIT_AUTHOR_*` / `GIT_COMMITTER_*`
31
+ * env vars so fixtures never need `git config user.email`.
32
+ *
33
+ * Pattern (matches pipeline-cli AISDLC-253 + orchestrator AISDLC-241/246):
34
+ *
35
+ * const env = makeGitEnv();
36
+ * execSync('git init -b main', { cwd: repoDir, env, stdio: 'pipe' });
37
+ * // No `git config user.email` needed — identity comes from GIT_AUTHOR_*
38
+ */
39
+ export declare function makeGitEnv(): NodeJS.ProcessEnv;
40
+ //# sourceMappingURL=git-env.d.ts.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Hermetic git env for orchestrator test fixtures (AISDLC-257).
3
+ *
4
+ * Cross-link: mirrors `pipeline-cli/src/__test-helpers/git-env.ts` (AISDLC-253).
5
+ * See that file for the canonical rationale. This copy exists so orchestrator
6
+ * tests don't take a cross-package import dependency on pipeline-cli's test
7
+ * helpers.
8
+ *
9
+ * Why this exists
10
+ * ───────────────
11
+ * Test fixtures that shell out to `git` (e.g. `execSync('git init', { cwd: d })`)
12
+ * are vulnerable to env-var bleed from the parent shell:
13
+ *
14
+ * - `GIT_DIR=...` overrides cwd-based repo discovery — every git command
15
+ * writes into the parent shell's GIT_DIR, NOT the fixture's `cwd`.
16
+ * - `GIT_WORK_TREE=...` ditto for the working tree.
17
+ * - `core.hooksPath` from system/global config can fire husky hooks during
18
+ * fixture commits.
19
+ * - `commit.gpgsign=true` from operator config can break unattended commits.
20
+ *
21
+ * The `cleanGitEnv()` helper in `orchestrator/src/runtime/git-env.ts` strips
22
+ * GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE but still inherits `process.env`
23
+ * in full, meaning `git config user.email` writes still land wherever git
24
+ * resolves config (which may be a polluted GIT_DIR or the operator's global
25
+ * config). AISDLC-257 identified `worktree-pool.integration.test.ts` as the
26
+ * confirmed leak source.
27
+ *
28
+ * `makeGitEnv()` uses an ALLOW-LIST approach rather than a DENY-LIST: it
29
+ * constructs a minimal env from scratch, deliberately omitting GIT_DIR and
30
+ * GIT_WORK_TREE. Identity is provided via `GIT_AUTHOR_*` / `GIT_COMMITTER_*`
31
+ * env vars so fixtures never need `git config user.email`.
32
+ *
33
+ * Pattern (matches pipeline-cli AISDLC-253 + orchestrator AISDLC-241/246):
34
+ *
35
+ * const env = makeGitEnv();
36
+ * execSync('git init -b main', { cwd: repoDir, env, stdio: 'pipe' });
37
+ * // No `git config user.email` needed — identity comes from GIT_AUTHOR_*
38
+ */
39
+ export function makeGitEnv() {
40
+ return {
41
+ // Minimal OS plumbing.
42
+ PATH: process.env['PATH'] ?? '/usr/bin:/bin',
43
+ HOME: process.env['HOME'] ?? '/tmp',
44
+ ...(process.env['TMPDIR'] ? { TMPDIR: process.env['TMPDIR'] } : {}),
45
+ ...(process.env['TEMP'] ? { TEMP: process.env['TEMP'] } : {}),
46
+ ...(process.env['TMP'] ? { TMP: process.env['TMP'] } : {}),
47
+ // Locale — prevent non-ASCII error strings in git output.
48
+ LANG: process.env['LANG'] ?? 'en_US.UTF-8',
49
+ LC_ALL: 'C',
50
+ // Git identity — supplied via env so `git config user.email/user.name`
51
+ // is never needed inside the fixture (those writes would land in either
52
+ // the fixture's .git/config or, if GIT_DIR is polluted, in the host
53
+ // worktree's config).
54
+ GIT_AUTHOR_NAME: 'Test',
55
+ GIT_AUTHOR_EMAIL: 'test@test.invalid',
56
+ GIT_COMMITTER_NAME: 'Test',
57
+ GIT_COMMITTER_EMAIL: 'test@test.invalid',
58
+ // Disable system + global git config to prevent gpgsign / hookPath /
59
+ // user-config bleed from the operator's machine.
60
+ GIT_CONFIG_NOSYSTEM: '1',
61
+ GIT_CONFIG_GLOBAL: '/dev/null',
62
+ // Disable husky so the calling project's pre-commit hooks don't fire.
63
+ HUSKY: '0',
64
+ // Suppress credential helpers / interactive prompts.
65
+ GIT_TERMINAL_PROMPT: '0',
66
+ GIT_SSH_COMMAND: 'ssh -o BatchMode=yes',
67
+ // Note: deliberately NO `GIT_DIR` / `GIT_WORK_TREE` keys — by omitting
68
+ // them from the returned object, child processes inherit nothing for
69
+ // those vars (the env REPLACES the parent's env when passed to execSync,
70
+ // it doesn't merge). That's the load-bearing guarantee against the leak.
71
+ };
72
+ }
73
+ //# sourceMappingURL=git-env.js.map
@@ -4,7 +4,7 @@
4
4
  * into the dogfood pipeline.
5
5
  */
6
6
  import type { AiSdlcConfig } from './config.js';
7
- import { type IssueTracker, type AdapterRegistry, type ScanOptions, type ScanResult, type WebhookBridge, type GitAdapterFetcher, type GitResolveResult, type AuditLog, type AuditSink, type Sandbox, type SecretStore, type MemoryStore, type EventBus, type CIPipeline } from '@ai-sdlc/reference';
7
+ import { type IssueTracker, type SourceControl, type AdapterRegistry, type ScanOptions, type ScanResult, type WebhookBridge, type GitAdapterFetcher, type GitResolveResult, type AuditLog, type AuditSink, type Sandbox, type SecretStore, type MemoryStore, type EventBus, type CIPipeline } from '@ai-sdlc/reference';
8
8
  /**
9
9
  * Create an adapter registry pre-loaded with all built-in and community adapters.
10
10
  */
@@ -70,6 +70,45 @@ export declare function resolveIssueTrackerFromConfig(config: AiSdlcConfig, fall
70
70
  secretRef: string;
71
71
  };
72
72
  }): IssueTracker;
73
- export { createGitHubCIPipeline, createDockerSandbox, createLinearIssueTracker, resolveSecret, createGitLabSourceControl, createGitLabCIPipeline, createJiraIssueTracker, createBacklogMdIssueTracker, createWebhookServer, createGitHubWebhookProvider, verifyGitHubSignature, createGitLabWebhookProvider, verifyGitLabToken, createJiraWebhookProvider, createLinearWebhookProvider, verifyLinearSignature, createAdapterRegistry, validateAdapterMetadata, parseMetadataYaml, scanLocalAdapters, createStubCodeAnalysis, createStubMessenger, createStubDeploymentTarget, createStubGitLabCI, createStubGitLabSource, createStubJira, createStubBitbucket, createStubSonarQube, createStubSemgrep, createInMemoryAuditSink, createFileSink, createEnvSecretStore, createInMemoryMemoryStore, createInProcessEventBus, createStubSandbox, createCompositeIssueTracker, createWebhookBridge, parseGitAdapterRef, buildRawUrl, createGitAdapterFetcher, createStubGitAdapterFetcher, resolveGitAdapter, } from '@ai-sdlc/reference';
74
- export type { AdapterRegistry, AdapterMetadata, AdapterStability, AdapterFactory, MetadataValidationResult, ScanOptions, ScanResult, WebhookBridge, WebhookTransformer, GitAdapterReference, GitAdapterFetcher, GitResolveResult, CIPipeline, CodeAnalysis, Messenger, DeploymentTarget, EventBus, IssueTracker, LinearClientLike, IssueComment, AdapterInterfaces, EventStream, IssueFilter, CommitStatus, TestResults, CoverageReport, Finding, SeveritySummary, DeploymentStatus, StubCodeAnalysisConfig, StubCodeAnalysisAdapter, NotificationLogEntry, StubMessengerAdapter, StubDeploymentTargetAdapter, StubGitLabCIAdapter, StubGitLabSourceAdapter, StubJiraAdapter, StubBitbucketAdapter, StubSonarQubeConfig, StubSonarQubeAdapter, StubSemgrepConfig, StubSemgrepAdapter, AuditSink, AuditLog, InMemoryAuditSink, SecretStore, Sandbox, MemoryStore, InMemoryMemoryStore, InProcessEventBus, DockerSandboxConfig, BuildStatus, GitLabConfig, JiraConfig, BacklogMdConfig, BacklogFs, WebhookServer, WebhookServerConfig, WebhookProviderConfig, GitHubWebhookConfig, GitHubWebhookBridges, GitLabWebhookConfig, JiraWebhookConfig, LinearWebhookConfig, CompositeIssueTrackerConfig, BackendRoute, } from '@ai-sdlc/reference';
73
+ /**
74
+ * A no-op SourceControl adapter for local-only repositories (no remote).
75
+ *
76
+ * When an adopter has no 'origin' remote (or sets `type: local` in their
77
+ * AdapterBinding), the pipeline must not block on API calls. This adapter:
78
+ *
79
+ * - `createBranch` — delegates to the local git command-line (via execute.ts)
80
+ * so the branch checkout path works unchanged.
81
+ * - `createPR` — resolves immediately with a sentinel local PR object; the
82
+ * caller (execute.ts step 15) should check `pr.url` to detect the skip.
83
+ * - All other methods are no-ops.
84
+ *
85
+ * Callers detect local-only mode by checking `pr.url === 'local'` and skip
86
+ * tracker comments + Slack notifications for the PR URL.
87
+ */
88
+ export declare function createLocalSourceControl(): SourceControl;
89
+ /**
90
+ * Resolve a SourceControl adapter from the AdapterBinding whose
91
+ * `spec.interface === 'SourceControl'`.
92
+ *
93
+ * Resolution order (first wins):
94
+ * 1. `type: github` → existing GitHub adapter using `spec.config` or fallback.
95
+ * 2. `type: gitlab` → GitLab adapter with `spec.config.url` (required for
96
+ * self-hosted) and optional `spec.config.token.secretRef`.
97
+ * 3. `type: local` → local-only no-op adapter that skips push/create-pr.
98
+ * 4. No SourceControl AdapterBinding present → GitHub (current default, no regression).
99
+ *
100
+ * When multiple SourceControl bindings exist, the FIRST one wins. This is an
101
+ * intentional design choice — multiple SourceControl bindings are unusual and
102
+ * the pipeline has a single active remote. If this constraint is too tight,
103
+ * escalate to the Decision Catalog before changing it.
104
+ */
105
+ export declare function resolveSourceControlFromConfig(config: AiSdlcConfig, fallbackGitHubConfig: {
106
+ org: string;
107
+ repo: string;
108
+ token: {
109
+ secretRef: string;
110
+ };
111
+ }): SourceControl;
112
+ export { createGitHubCIPipeline, createGitHubSourceControl, createDockerSandbox, createLinearIssueTracker, resolveSecret, createGitLabSourceControl, createGitLabCIPipeline, createJiraIssueTracker, createBacklogMdIssueTracker, createWebhookServer, createGitHubWebhookProvider, verifyGitHubSignature, createGitLabWebhookProvider, verifyGitLabToken, createJiraWebhookProvider, createLinearWebhookProvider, verifyLinearSignature, createAdapterRegistry, validateAdapterMetadata, parseMetadataYaml, scanLocalAdapters, createStubCodeAnalysis, createStubMessenger, createStubDeploymentTarget, createStubGitLabCI, createStubGitLabSource, createStubJira, createStubBitbucket, createStubSonarQube, createStubSemgrep, createInMemoryAuditSink, createFileSink, createEnvSecretStore, createInMemoryMemoryStore, createInProcessEventBus, createStubSandbox, createCompositeIssueTracker, createWebhookBridge, parseGitAdapterRef, buildRawUrl, createGitAdapterFetcher, createStubGitAdapterFetcher, resolveGitAdapter, } from '@ai-sdlc/reference';
113
+ export type { AdapterRegistry, AdapterMetadata, AdapterStability, AdapterFactory, MetadataValidationResult, ScanOptions, ScanResult, WebhookBridge, WebhookTransformer, GitAdapterReference, GitAdapterFetcher, GitResolveResult, CIPipeline, SourceControl, CodeAnalysis, Messenger, DeploymentTarget, EventBus, IssueTracker, LinearClientLike, IssueComment, AdapterInterfaces, EventStream, IssueFilter, CommitStatus, TestResults, CoverageReport, Finding, SeveritySummary, DeploymentStatus, StubCodeAnalysisConfig, StubCodeAnalysisAdapter, NotificationLogEntry, StubMessengerAdapter, StubDeploymentTargetAdapter, StubGitLabCIAdapter, StubGitLabSourceAdapter, StubJiraAdapter, StubBitbucketAdapter, StubSonarQubeConfig, StubSonarQubeAdapter, StubSemgrepConfig, StubSemgrepAdapter, AuditSink, AuditLog, InMemoryAuditSink, SecretStore, Sandbox, MemoryStore, InMemoryMemoryStore, InProcessEventBus, DockerSandboxConfig, BuildStatus, GitLabConfig, JiraConfig, BacklogMdConfig, BacklogFs, WebhookServer, WebhookServerConfig, WebhookProviderConfig, GitHubWebhookConfig, GitHubWebhookBridges, GitLabWebhookConfig, JiraWebhookConfig, LinearWebhookConfig, CompositeIssueTrackerConfig, BackendRoute, } from '@ai-sdlc/reference';
75
114
  //# sourceMappingURL=adapters.d.ts.map
package/dist/adapters.js CHANGED
@@ -24,8 +24,10 @@ createWebhookBridge,
24
24
  createStubGitAdapterFetcher, createGitAdapterFetcher, resolveGitAdapter,
25
25
  // GitHub CI adapter
26
26
  createGitHubCIPipeline,
27
- // GitHub issue tracker
28
- createGitHubIssueTracker,
27
+ // GitHub source control + issue tracker
28
+ createGitHubSourceControl, createGitHubIssueTracker,
29
+ // GitLab source control
30
+ createGitLabSourceControl,
29
31
  // Composite issue tracker
30
32
  createCompositeIssueTracker,
31
33
  // Production adapters (for resolveIssueTrackerFromConfig)
@@ -228,10 +230,138 @@ export function resolveIssueTrackerFromConfig(config, fallbackGitHubConfig) {
228
230
  }
229
231
  return createCompositeIssueTracker({ backends });
230
232
  }
233
+ // ── Source-control resolution from config ────────────────────────────
234
+ /**
235
+ * A no-op SourceControl adapter for local-only repositories (no remote).
236
+ *
237
+ * When an adopter has no 'origin' remote (or sets `type: local` in their
238
+ * AdapterBinding), the pipeline must not block on API calls. This adapter:
239
+ *
240
+ * - `createBranch` — delegates to the local git command-line (via execute.ts)
241
+ * so the branch checkout path works unchanged.
242
+ * - `createPR` — resolves immediately with a sentinel local PR object; the
243
+ * caller (execute.ts step 15) should check `pr.url` to detect the skip.
244
+ * - All other methods are no-ops.
245
+ *
246
+ * Callers detect local-only mode by checking `pr.url === 'local'` and skip
247
+ * tracker comments + Slack notifications for the PR URL.
248
+ */
249
+ export function createLocalSourceControl() {
250
+ return {
251
+ async createBranch(input) {
252
+ // Branches are created via git CLI in execute.ts; this is a passthrough stub.
253
+ return { name: input.name, sha: '' };
254
+ },
255
+ async createPR(_input) {
256
+ // Sentinel URL signals to the pipeline that we are in local-only mode and
257
+ // no remote PR was created. The pipeline checks for this and skips the
258
+ // "PR created" comment + Slack notification (avoiding noise).
259
+ return {
260
+ id: 'local',
261
+ title: _input.title,
262
+ sourceBranch: _input.sourceBranch,
263
+ targetBranch: _input.targetBranch ?? 'main',
264
+ status: 'open',
265
+ author: 'local',
266
+ url: 'local',
267
+ };
268
+ },
269
+ async mergePR(_id, _strategy) {
270
+ return { sha: '', merged: false };
271
+ },
272
+ async getFileContents(_path, _ref) {
273
+ throw new Error('getFileContents: local-only source control has no remote to read from');
274
+ },
275
+ async listChangedFiles(_prId) {
276
+ return [];
277
+ },
278
+ async setCommitStatus(_sha, _status) {
279
+ /* no-op: no remote to post status to */
280
+ },
281
+ watchPREvents(_filter) {
282
+ return {
283
+ async *[Symbol.asyncIterator]() {
284
+ /* no-op: no remote events in local-only mode */
285
+ },
286
+ };
287
+ },
288
+ };
289
+ }
290
+ /**
291
+ * Resolve a SourceControl adapter from the AdapterBinding whose
292
+ * `spec.interface === 'SourceControl'`.
293
+ *
294
+ * Resolution order (first wins):
295
+ * 1. `type: github` → existing GitHub adapter using `spec.config` or fallback.
296
+ * 2. `type: gitlab` → GitLab adapter with `spec.config.url` (required for
297
+ * self-hosted) and optional `spec.config.token.secretRef`.
298
+ * 3. `type: local` → local-only no-op adapter that skips push/create-pr.
299
+ * 4. No SourceControl AdapterBinding present → GitHub (current default, no regression).
300
+ *
301
+ * When multiple SourceControl bindings exist, the FIRST one wins. This is an
302
+ * intentional design choice — multiple SourceControl bindings are unusual and
303
+ * the pipeline has a single active remote. If this constraint is too tight,
304
+ * escalate to the Decision Catalog before changing it.
305
+ */
306
+ export function resolveSourceControlFromConfig(config, fallbackGitHubConfig) {
307
+ const bindings = (config.adapterBindings ?? []).filter((b) => b.spec.interface === 'SourceControl');
308
+ if (bindings.length === 0) {
309
+ // No SourceControl binding — default to GitHub exactly as before (AC #2).
310
+ return createGitHubSourceControl(fallbackGitHubConfig);
311
+ }
312
+ // First binding wins (see JSDoc above for rationale).
313
+ const binding = bindings[0];
314
+ const cfg = binding.spec.config ?? {};
315
+ switch (binding.spec.type) {
316
+ case 'github': {
317
+ // Honor spec.config.token.secretRef when present (consistent with the GitLab case).
318
+ // Fall back to the fallback token so existing GitHub adopters are unaffected.
319
+ const tokenSecretRef = cfg.token?.secretRef ??
320
+ fallbackGitHubConfig.token.secretRef;
321
+ return createGitHubSourceControl({
322
+ org: cfg.org ?? fallbackGitHubConfig.org,
323
+ repo: cfg.repo ?? fallbackGitHubConfig.repo,
324
+ token: { secretRef: tokenSecretRef },
325
+ });
326
+ }
327
+ case 'gitlab': {
328
+ // `url` is required for self-hosted GitLab; defaults to gitlab.com for SaaS.
329
+ const baseUrl = cfg.url ?? 'https://gitlab.com';
330
+ // projectId is required — an empty value produces confusing API responses
331
+ // (encodeURIComponent('') → '' → the request hits /api/v4/projects/ which
332
+ // returns the list of all projects, not the configured one).
333
+ const projectId = cfg.projectId;
334
+ if (!projectId && projectId !== 0) {
335
+ throw new Error(`SourceControl AdapterBinding '${binding.metadata.name}' (type: gitlab) is missing a required ` +
336
+ `spec.config.projectId. Set it to the numeric project ID or the URL-encoded path ` +
337
+ `(e.g. "group%2Fsubgroup%2Fproject" or 12345).`);
338
+ }
339
+ // Token: use secretRef from config if present, else fall back to env GITLAB_TOKEN.
340
+ const tokenSecretRef = cfg.token?.secretRef ?? 'gitlab-token';
341
+ const gitLabCfg = {
342
+ baseUrl,
343
+ projectId,
344
+ token: { secretRef: tokenSecretRef },
345
+ };
346
+ return createGitLabSourceControl(gitLabCfg);
347
+ }
348
+ case 'local': {
349
+ return createLocalSourceControl();
350
+ }
351
+ default: {
352
+ // Unknown type — emit a warning so mistyped types (e.g. 'bitbucket') surface
353
+ // visibly, then fall back to GitHub so the pipeline keeps running.
354
+ console.warn(`[ai-sdlc] SourceControl AdapterBinding '${binding.metadata.name}' has unknown type ` +
355
+ `'${binding.spec.type}'. Falling back to the GitHub adapter. ` +
356
+ `Supported types: github, gitlab, local.`);
357
+ return createGitHubSourceControl(fallbackGitHubConfig);
358
+ }
359
+ }
360
+ }
231
361
  // Direct re-exports (passthrough)
232
362
  export {
233
363
  // Core adapters
234
- createGitHubCIPipeline, createDockerSandbox, createLinearIssueTracker, resolveSecret,
364
+ createGitHubCIPipeline, createGitHubSourceControl, createDockerSandbox, createLinearIssueTracker, resolveSecret,
235
365
  // Production adapters
236
366
  createGitLabSourceControl, createGitLabCIPipeline, createJiraIssueTracker,
237
367
  // Backlog.md adapter
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Admission-subset composite (RFC-0008 §A.6).
2
+ * Admission-subset composite (RFC-0008 §A.6 + RFC-0009 Phase 2.1).
3
3
  *
4
4
  * The admission gate uses a subset of the full PPA composite:
5
5
  *
@@ -23,10 +23,18 @@
23
23
  * The `override` bypass is preserved at position 1: when the input has
24
24
  * `override: true`, we return `composite = Infinity` without running
25
25
  * the admission math — identical to the legacy PPA behaviour.
26
+ *
27
+ * **RFC-0009 Phase 2.1 tessellation extension:**
28
+ * When `AdmissionCompositeOptions.tessellationContext` is provided, the
29
+ * composite routes SA and Eρ₄ (designSystemReadiness) through soul scope
30
+ * per RFC-0009 §6. See `tessellation-admission.ts` for the routing algorithm.
26
31
  */
27
32
  import type { PriorityConfig, PriorityInput, PriorityScore } from '@ai-sdlc/reference';
28
33
  import type { AdmissionInput } from './admission-score.js';
29
34
  import { type AdmissionHumanCurveResult } from './admission-hc.js';
35
+ import { type TessellationContext, type TessellatedSaResult } from './tessellation-admission.js';
36
+ import { type VariantContext, type VariantScopedSaResult } from './variant-admission.js';
37
+ import { type ComplianceClearanceContext, type ComplianceClearanceResult } from './compliance-clearance.js';
30
38
  /**
31
39
  * Result of the admission composite — returns a `PriorityScore`
32
40
  * (backward-compatible with `scoreIssueForAdmission` consumers) plus
@@ -44,6 +52,33 @@ export interface AdmissionComposite {
44
52
  designSystemReadiness: number;
45
53
  executionReality: number;
46
54
  humanCurve: AdmissionHumanCurveResult;
55
+ /**
56
+ * RFC-0009 Phase 2.1 — tessellation routing result.
57
+ * Present when `AdmissionCompositeOptions.tessellationContext` was
58
+ * supplied. Absent (undefined) when the single-DID path was used.
59
+ */
60
+ tessellation?: TessellatedSaResult;
61
+ /**
62
+ * RFC-0017 Phase 2 — variant routing result.
63
+ * Present when `AdmissionCompositeOptions.variantContext` was supplied.
64
+ * Absent (undefined) when the single-soul path was used (backward-compat).
65
+ *
66
+ * `variantScopedSa` represents the variant-resolved soul-alignment value
67
+ * that REPLACED the tessellation/soul-aggregate `soulAlignment` when the
68
+ * work item declared `targetedVariants` of one of the affected souls.
69
+ */
70
+ variant?: VariantScopedSaResult;
71
+ /**
72
+ * RFC-0009 Phase 4.1 — Eρ₅ Compliance Clearance result.
73
+ * Present when `AdmissionCompositeOptions.complianceClearanceContext`
74
+ * was supplied AND the adopter has opted in (`enabled: true`).
75
+ *
76
+ * When `er5 === 0` the composite is GATED to zero — the work item cannot
77
+ * proceed without resolving the violation. The `routingPath` field
78
+ * surfaces the decision branch for audit purposes; when the adopter has
79
+ * not opted in, the breakdown field is elided (backward-compat).
80
+ */
81
+ complianceClearance?: ComplianceClearanceResult;
47
82
  };
48
83
  }
49
84
  export interface AdmissionCompositeOptions {
@@ -62,6 +97,104 @@ export interface AdmissionCompositeOptions {
62
97
  * cannot extract. Only fields with defined values overwrite.
63
98
  */
64
99
  priorityInputOverrides?: Partial<PriorityInput>;
100
+ /**
101
+ * RFC-0009 Phase 2.1 — Tessellated DID context.
102
+ *
103
+ * When present, SA and Eρ₄ (designSystemReadiness) are computed using
104
+ * soul-scope routing per RFC-0009 §6 instead of the platform-aggregate
105
+ * DSB. The routing algorithm:
106
+ *
107
+ * resolveAffectedSouls(w) → scope filter from dep-graph snapshot
108
+ * |souls| == 0 → min over ALL souls (substrate-only degenerate)
109
+ * |souls| == 1 → score against that soul's DSB
110
+ * |souls| > 1 → crossSoulScoringRule (default `min`) over affected souls
111
+ *
112
+ * @see tessellation-admission.ts + spec/rfcs/RFC-0009 §6
113
+ */
114
+ tessellationContext?: TessellationContext;
115
+ /**
116
+ * RFC-0017 Phase 2 — variant-scope routing context.
117
+ *
118
+ * When present AND the work item declares `targetedVariants[]` of one of
119
+ * the affected souls, the composite's `soulAlignment` value is REFINED
120
+ * by per-variant Sα₁ + Sα₂ scoring per RFC-0017 §5.4:
121
+ *
122
+ * resolveTargetedVariants(w) → variant scope filter from work-item targeting
123
+ * |targets| == 0 → backward-compat: soul-aggregate Sα/Eρ₄ unchanged
124
+ * |targets| == 1 → variant's per-variant Sα₁ + Sα₂ replaces soul-aggregate
125
+ * |targets| > 1 → crossVariantAggregation (default `min`) over targeted variants
126
+ *
127
+ * Composes cleanly with `tessellationContext` — soul-scope tessellation runs
128
+ * first, then variant routing refines the resulting Sα/Eρ₄ to variant scope.
129
+ * Work items WITHOUT `targetedVariants` preserve the tessellation result
130
+ * unchanged (backward-compat per RFC-0017 §7).
131
+ *
132
+ * @see variant-admission.ts + spec/rfcs/RFC-0017 §5.4 + §6.2
133
+ */
134
+ variantContext?: VariantContext;
135
+ /**
136
+ * RFC-0009 Phase 4.1 — Eρ₅ Compliance Clearance context.
137
+ *
138
+ * When present AND `enabled: true`, the admission composite applies the
139
+ * Eρ₅ multiplier (categorical 0/1 gating) per RFC-0009 §7.1:
140
+ *
141
+ * Eρ₅ = 0 if any declared regime is violated → composite gated to 0
142
+ * Eρ₅ = 1 otherwise → composite unchanged
143
+ *
144
+ * When absent OR `enabled: false`, Eρ₅ is not applied — backward-compatible
145
+ * with Phase 2/3 behavior. The opt-in gate is intentional per RFC-0009 §10
146
+ * Phase 4; promotion to default-on is subject to ecosystem feedback.
147
+ *
148
+ * The regime set is the union of (a) each affected soul's
149
+ * `triad.engineering.complianceRegimes` (passed through
150
+ * `perSoulRegimes`) and (b) any RFC-0022 `CompliancePosture` regimes
151
+ * (passed through `posture`). Both pass the OQ-5 hard-regulatory scope
152
+ * filter; soft regimes are filtered at declaration time.
153
+ *
154
+ * Composes with `tessellationContext` — the soul scope from tessellation
155
+ * routing is used to select which souls' regimes apply to this work item.
156
+ *
157
+ * @see compliance-clearance.ts + spec/rfcs/RFC-0009 §7.1 + §10
158
+ * @see spec/rfcs/RFC-0022 (consumption surface)
159
+ */
160
+ complianceClearanceContext?: ComplianceClearanceContext;
65
161
  }
66
162
  export declare function computeAdmissionComposite(input: AdmissionInput, config?: PriorityConfig, options?: AdmissionCompositeOptions): AdmissionComposite;
163
+ /**
164
+ * Combine variant-scope Sα₁ (audience resonance) + Sα₂ (vibe coherence) into
165
+ * a single soul-alignment value for the admission composite's SA pillar.
166
+ *
167
+ * The legacy admission composite uses a single `soulAlignment` scalar that
168
+ * conceptually rolls Sα₁ + Sα₂ together (RFC-0008 §A.6 SA pillar). When
169
+ * variant routing splits them out per RFC-0017 §5.4, we recombine via the
170
+ * arithmetic mean — equal weighting matches the soul-aggregate combination
171
+ * implied by `pillar-breakdown.ts` and avoids favouring one Sα facet over
172
+ * the other when both are equally variant-bounded.
173
+ *
174
+ * Exported for unit testing + so downstream callers can replicate the
175
+ * combination logic if they need to surface the constituent pieces.
176
+ */
177
+ export declare function combineVariantSaForSoulAlignment(sa1: number, sa2: number): number;
178
+ /**
179
+ * Compute admission confidence in [0, 1] as a 50/50 blend of two
180
+ * independent evidence channels:
181
+ *
182
+ * 1. **Mapper coverage** — fraction of `ADMISSION_MAPPER_FIELDS`
183
+ * explicitly populated on the derived `PriorityInput`. Captures
184
+ * "how much issue/backlog signal did `mapIssueToPriorityInput`
185
+ * extract".
186
+ *
187
+ * 2. **Enrichment loaded** — fraction of RFC-0008 enrichment slots
188
+ * present on the input (or supplied via `options`). Captures "how
189
+ * much external context did the enrichment readers contribute".
190
+ *
191
+ * Bug fixed (AISDLC-172 / RFC-0009 §13 OQ-9): previously
192
+ * `computeConfidence(priorityInput)` from `priority.ts` was used, which
193
+ * counts against the full 16-field `SCORABLE_FIELDS` list and ignores
194
+ * enrichment success entirely. The result was a hard ~0.5 ceiling on
195
+ * admit confidence even when DID + DSB + maintainers + soul-tracks all
196
+ * loaded — those four positive observations contributed exactly zero
197
+ * to the formula's denominator and zero to its numerator.
198
+ */
199
+ export declare function computeAdmissionConfidence(input: AdmissionInput, priorityInput: PriorityInput, options?: AdmissionCompositeOptions): number;
67
200
  //# sourceMappingURL=admission-composite.d.ts.map