@aiwg/cli 2026.11.5 → 2026.11.7

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 (201) hide show
  1. package/agentic/code/providers/model-capabilities.v1.json +9 -9
  2. package/bin/aiwg.mjs +6 -4
  3. package/dist/src/activity-log/cli.js +1 -1
  4. package/dist/src/agents/agent-deployer.js +1 -1
  5. package/dist/src/artifacts/audit/types.js +1 -1
  6. package/dist/src/artifacts/browser-export.js +1 -0
  7. package/dist/src/artifacts/discover-facets.js +1 -1
  8. package/dist/src/artifacts/enrichment/prompt.js +1 -1
  9. package/dist/src/artifacts/enrichment/types.js +1 -1
  10. package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
  11. package/dist/src/artifacts/index-builder.js +1 -0
  12. package/dist/src/artifacts/query-engine-discover-output.js +1 -0
  13. package/dist/src/artifacts/query-engine-discover.js +2 -2
  14. package/dist/src/artifacts/query-engine-scoring.js +7 -0
  15. package/dist/src/artifacts/template-output-kind.js +10 -0
  16. package/dist/src/artifacts/types.js +1 -1
  17. package/dist/src/artifacts/views/definition.js +1 -1
  18. package/dist/src/artifacts/views/types.js +1 -1
  19. package/dist/src/catalog/cli.js +1 -1
  20. package/dist/src/catalog/cli.mjs +1 -1
  21. package/dist/src/catalog/loader.js +1 -1
  22. package/dist/src/catalog/loader.mjs +1 -1
  23. package/dist/src/catalog/types.js +1 -1
  24. package/dist/src/cli/cli-extension-loader.js +19 -5
  25. package/dist/src/cli/cli-extension-paths.js +65 -0
  26. package/dist/src/cli/handlers/best-practices-audit.js +1 -1
  27. package/dist/src/cli/handlers/dataset.js +11 -2
  28. package/dist/src/cli/handlers/help.js +3 -4
  29. package/dist/src/cli/handlers/index.js +1 -1
  30. package/dist/src/cli/handlers/marketplace-plugin-search.js +37 -0
  31. package/dist/src/cli/handlers/marketplace.js +3 -1
  32. package/dist/src/cli/handlers/models.js +1 -1
  33. package/dist/src/cli/handlers/ralph-launcher.js +8 -2
  34. package/dist/src/cli/handlers/ralph.js +1 -1
  35. package/dist/src/cli/handlers/runtime-info.js +1 -1
  36. package/dist/src/cli/handlers/scaffolding.js +2 -2
  37. package/dist/src/cli/handlers/script-runner.js +1 -1
  38. package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
  39. package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
  40. package/dist/src/cli/handlers/subcommands-list-format.js +19 -1
  41. package/dist/src/cli/handlers/types.js +1 -1
  42. package/dist/src/cli/handlers/update.js +26 -12
  43. package/dist/src/cli/handlers/use.js +6 -5
  44. package/dist/src/cli/handlers/utilities.js +1 -1
  45. package/dist/src/cli/handlers/version.js +1 -1
  46. package/dist/src/cli/handlers/workspace.js +1 -1
  47. package/dist/src/cli/handlers/writing.js +7 -1
  48. package/dist/src/cli/help-generator.js +9 -11
  49. package/dist/src/cli/hooks/builtin/activity-log-hook.js +1 -1
  50. package/dist/src/cli/router.js +1 -1
  51. package/dist/src/cli/workflow-orchestrator.js +1 -1
  52. package/dist/src/config/worker-context.js +37 -7
  53. package/dist/src/config/worker-parallelism.js +11 -0
  54. package/dist/src/contributors/detect.js +1 -1
  55. package/dist/src/contributors/discover.js +1 -1
  56. package/dist/src/contributors/heuristic.js +1 -1
  57. package/dist/src/contributors/index.js +1 -1
  58. package/dist/src/contributors/types.js +1 -1
  59. package/dist/src/contributors/validation.js +1 -1
  60. package/dist/src/dataset/backend-selection.d.ts +3 -0
  61. package/dist/src/dataset/backend-selection.js +11 -0
  62. package/dist/src/dataset/contract-range.d.ts +7 -0
  63. package/dist/src/dataset/contract-range.js +55 -0
  64. package/dist/src/dataset/fortemi-execution-bridge.d.ts +2 -0
  65. package/dist/src/dataset/fortemi-execution-bridge.js +12 -1
  66. package/dist/src/dataset/index.d.ts +2 -0
  67. package/dist/src/dataset/index.js +2 -0
  68. package/dist/src/dataset/orchestration-service.d.ts +1 -1
  69. package/dist/src/dataset/orchestration-service.js +7 -8
  70. package/dist/src/dataset/orchestration-types.d.ts +2 -0
  71. package/dist/src/dataset/service-binding-checkpoints.d.ts +10 -0
  72. package/dist/src/dataset/service-binding-checkpoints.js +26 -0
  73. package/dist/src/dataset/service-binding-contract.d.ts +46 -0
  74. package/dist/src/dataset/service-binding-contract.js +25 -0
  75. package/dist/src/dataset/service-binding-registry.d.ts +12 -0
  76. package/dist/src/dataset/service-binding-registry.js +118 -0
  77. package/dist/src/effects/worker-delivery.js +83 -0
  78. package/dist/src/extensions/capability-index.js +1 -1
  79. package/dist/src/extensions/commands/definitions.js +2 -2
  80. package/dist/src/extensions/deployment-registration.js +1 -1
  81. package/dist/src/extensions/index.js +1 -1
  82. package/dist/src/extensions/loader.js +1 -1
  83. package/dist/src/extensions/manifest.js +27 -9
  84. package/dist/src/extensions/project-local-activity.js +1 -1
  85. package/dist/src/extensions/project-local-discovery.js +2 -2
  86. package/dist/src/extensions/project-local-doctor.js +9 -4
  87. package/dist/src/extensions/project-local-promote.js +3 -3
  88. package/dist/src/extensions/project-local-remove.js +3 -3
  89. package/dist/src/extensions/project-local-scaffold.js +1 -1
  90. package/dist/src/extensions/project-quickref-discovery.js +11 -0
  91. package/dist/src/extensions/project-quickref.js +4 -7
  92. package/dist/src/extensions/registry.js +1 -1
  93. package/dist/src/extensions/shadow-resolver.js +1 -1
  94. package/dist/src/extensions/types.js +1 -1
  95. package/dist/src/extensions/upstream-registry.js +1 -1
  96. package/dist/src/extensions/validation.js +1 -1
  97. package/dist/src/intake/git-history-analyzer.js +1 -1
  98. package/dist/src/kb/cli.js +1 -1
  99. package/dist/src/marketplace/plugin-directory.js +36 -0
  100. package/dist/src/marketplace/plugin-search.js +180 -0
  101. package/dist/src/mcp/cli.mjs +2 -2
  102. package/dist/src/mcp/helpers.mjs +1 -1
  103. package/dist/src/mcp/http-tools.mjs +8 -6
  104. package/dist/src/mcp/http-transport.mjs +3 -1
  105. package/dist/src/mcp/server.mjs +1 -1
  106. package/dist/src/mcp/tools/command-run.mjs +1 -1
  107. package/dist/src/mcp/tools/discovery.mjs +1 -1
  108. package/dist/src/mcp/tools/subsystems.mjs +1 -1
  109. package/dist/src/mcp/tools/worker-invoke.mjs +71 -23
  110. package/dist/src/mcp/tools/worker-launch-ledger.mjs +33 -0
  111. package/dist/src/mcp/tools/worker-local-only-preflight.mjs +79 -0
  112. package/dist/src/mcp/tools/worker-recorded-launch.mjs +26 -0
  113. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +33 -6
  114. package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +49 -0
  115. package/dist/src/mcp/tools/worker-verify-deliver.mjs +25 -0
  116. package/dist/src/models/catalog-policy.js +2 -2
  117. package/dist/src/models/conductor-data-policy.mjs +83 -14
  118. package/dist/src/models/config-loader.js +2 -2
  119. package/dist/src/models/index.js +2 -2
  120. package/dist/src/models/local-endpoint-models.js +155 -0
  121. package/dist/src/models/model-capabilities.v1.json +9 -9
  122. package/dist/src/models/model-discovery.js +9 -5
  123. package/dist/src/models/opencode-worker-model.mjs +16 -0
  124. package/dist/src/models/resolver.js +2 -2
  125. package/dist/src/models/worker-installation.mjs +5 -3
  126. package/dist/src/models/worker-plan.js +1 -1
  127. package/dist/src/plugin/plugin-installer.js +2 -2
  128. package/dist/src/plugin/registry-validator.js +2 -2
  129. package/dist/src/plugin/skill-command-translator.js +1 -1
  130. package/dist/src/providers/deployment-input-session.d.mts +2 -0
  131. package/dist/src/providers/deployment-input-session.mjs +38 -0
  132. package/dist/src/rlm/cache/hash.js +1 -1
  133. package/dist/src/rlm/cache/store.js +1 -1
  134. package/dist/src/rlm/cache/types.js +1 -1
  135. package/dist/src/serve/worker-invocation-preparation.js +54 -22
  136. package/dist/src/serve/worker-invocation.js +25 -8
  137. package/dist/src/serve/worker-shell-prompt.d.mts +6 -0
  138. package/dist/src/serve/worker-shell-prompt.mjs +78 -0
  139. package/dist/src/skills/run.js +0 -11
  140. package/dist/src/smiths/agentsmith/generator.js +1 -1
  141. package/dist/src/smiths/context-pipeline/index.js +1 -1
  142. package/dist/src/smiths/context-pipeline/provider-policy.js +1 -1
  143. package/dist/src/smiths/context-pipeline/types.js +1 -1
  144. package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +2 -2
  145. package/dist/src/smiths/mcpsmith/generator.js +2 -2
  146. package/dist/src/smiths/mcpsmith/index.js +2 -2
  147. package/dist/src/smiths/mcpsmith/types.js +2 -2
  148. package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
  149. package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
  150. package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -2
  151. package/dist/src/smiths/toolsmith/types.js +2 -2
  152. package/dist/src/storage/backends/fortemi.js +1 -1
  153. package/dist/src/storage/backends/fs.js +1 -1
  154. package/dist/src/storage/backends/logseq.js +1 -1
  155. package/dist/src/storage/backends/obsidian.js +1 -1
  156. package/dist/src/storage/cli.js +2 -2
  157. package/dist/src/storage/config.js +1 -1
  158. package/dist/src/storage/index.js +1 -1
  159. package/dist/src/storage/subsystem-cli.js +1 -1
  160. package/dist/src/storage/types.js +1 -1
  161. package/dist/src/testing/generators/test-case-generator.js +1 -1
  162. package/dist/src/writing/campaign-patterns.js +96 -0
  163. package/dist/src/writing/campaign-report.js +41 -0
  164. package/dist/src/writing/contextual-diagnostics.js +29 -5
  165. package/dist/src/writing/current-patterns.catalogue.json +87 -0
  166. package/dist/src/writing/current-patterns.js +99 -0
  167. package/dist/src/writing/prose-mask.js +80 -0
  168. package/dist/src/writing/structural-patterns.js +109 -0
  169. package/dist/src/writing/validation-campaign.js +19 -0
  170. package/dist/src/writing/validation-engine.js +18 -11
  171. package/dist/src/writing/validation-rules.js +4 -3
  172. package/package.json +11 -1
  173. package/schemas/dataset/service-binding.v1.schema.json +70 -0
  174. package/schemas/models/model-catalog.v1.schema.json +6 -3
  175. package/tools/agents/providers/base-models-platforms.mjs +87 -48
  176. package/tools/agents/providers/conductor-data-guard.mjs +1 -1
  177. package/tools/agents/providers/rule-deployment-corpus-inputs.mjs +19 -0
  178. package/tools/agents/providers/rule-deployment-input-session.mjs +40 -0
  179. package/tools/agents/providers/rule-deployment-prepare.mjs +15 -6
  180. package/tools/plugin/package-plugins.mjs +2 -0
  181. package/tools/ralph-external/lib/mcp-worker-launch.mjs +67 -0
  182. package/tools/ralph-external/lib/opencode-adapter.mjs +9 -7
  183. package/tools/ralph-external/lib/trusted-verification.mjs +1021 -0
  184. package/tools/ralph-external/lib/typed-stop-delivery.mjs +55 -0
  185. package/tools/ralph-external/lib/verification-isolation.mjs +509 -0
  186. package/tools/ralph-external/lib/worker-context.mjs +3 -3
  187. package/tools/ralph-external/lib/worker-delivery-guards.mjs +141 -0
  188. package/tools/ralph-external/lib/worker-delivery-record.mjs +15 -0
  189. package/tools/ralph-external/lib/worker-final.mjs +4 -1
  190. package/tools/ralph-external/lib/worker-isolation-status.mjs +3 -0
  191. package/tools/ralph-external/lib/worker-launch-cli.mjs +8 -0
  192. package/tools/ralph-external/lib/worker-local-only-paths.mjs +45 -0
  193. package/tools/ralph-external/lib/worker-prompt.mjs +4 -1
  194. package/tools/ralph-external/lib/worker-retry-evidence.mjs +2 -1
  195. package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +2 -1
  196. package/tools/ralph-external/lib/worker-run-directory.mjs +45 -0
  197. package/tools/ralph-external/lib/worker-unit-cleanup.mjs +10 -2
  198. package/tools/ralph-external/lib/worker-verification-cli.mjs +164 -0
  199. package/tools/ralph-external/lib/worktree-preparation.mjs +417 -0
  200. package/tools/ralph-external/session-launcher.mjs +8 -15
  201. package/vscode-extension/schemas/aiwg.config.v1.json +27 -0
@@ -0,0 +1,55 @@
1
+ const VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
2
+ const COMPARATOR = /^(\^|~|>=|<=|>|<|=)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
3
+ function parse(version) {
4
+ const match = VERSION.exec(version);
5
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
6
+ }
7
+ function compare(a, b) {
8
+ for (let i = 0; i < 3; i++)
9
+ if (a[i] !== b[i])
10
+ return a[i] < b[i] ? -1 : 1;
11
+ return 0;
12
+ }
13
+ function upperBound(operator, [major, minor, patch]) {
14
+ if (operator === '~')
15
+ return [major, minor + 1, 0];
16
+ if (major > 0)
17
+ return [major + 1, 0, 0];
18
+ if (minor > 0)
19
+ return [0, minor + 1, 0];
20
+ return [0, 0, patch + 1];
21
+ }
22
+ function comparatorIncludes(version, comparator) {
23
+ const match = COMPARATOR.exec(comparator);
24
+ if (!match)
25
+ return null;
26
+ const operator = match[1] ?? '=';
27
+ const target = [Number(match[2]), Number(match[3]), Number(match[4])];
28
+ const order = compare(version, target);
29
+ switch (operator) {
30
+ case '^':
31
+ case '~': return order >= 0 && compare(version, upperBound(operator, target)) < 0;
32
+ case '>=': return order >= 0;
33
+ case '<=': return order <= 0;
34
+ case '>': return order > 0;
35
+ case '<': return order < 0;
36
+ default: return order === 0;
37
+ }
38
+ }
39
+ /**
40
+ * True when `version` (x.y.z) satisfies `range`. Supports exact versions, `^`, `~`,
41
+ * `>=`, `<=`, `>`, `<`, space-separated AND and `||` OR. Prerelease tags, wildcards,
42
+ * hyphen ranges and any other syntax return false rather than guessing.
43
+ */
44
+ export function contractRangeIncludes(version, range) {
45
+ const parsed = parse(version);
46
+ if (!parsed || typeof range !== 'string' || range.trim() === '')
47
+ return false;
48
+ return range.split('||').some((alternative) => {
49
+ const comparators = alternative.trim().split(/\s+/).filter(Boolean);
50
+ if (comparators.length === 0)
51
+ return false;
52
+ return comparators.every((comparator) => comparatorIncludes(parsed, comparator) === true);
53
+ });
54
+ }
55
+ //# sourceMappingURL=contract-range.js.map
@@ -1,4 +1,5 @@
1
1
  import type { DatasetExecutionBackend, ExecutionRequest, ExecutionResult } from "./orchestration-types.js";
2
+ import type { AdapterCheckpoint } from "./adapter-types.js";
2
3
  import type { RunReceipt } from "./types.js";
3
4
  export interface FortemiTransport {
4
5
  capabilities(): Promise<readonly {
@@ -9,6 +10,7 @@ export interface FortemiTransport {
9
10
  plan: unknown;
10
11
  records: readonly unknown[];
11
12
  signal?: AbortSignal;
13
+ priorCheckpoint?: AdapterCheckpoint;
12
14
  }): Promise<{
13
15
  result: ExecutionResult;
14
16
  receipt: RunReceipt;
@@ -1,4 +1,5 @@
1
- import { computeRunReceiptDigest, verifyRunReceiptDigest, } from "./contracts.js";
1
+ import { computeRunReceiptDigest, verifyRunReceiptDigest, validateDatasetContract, } from "./contracts.js";
2
+ import { bindingCheckpointId } from "./service-binding-checkpoints.js";
2
3
  export class FortemiExecutionBridge {
3
4
  transport;
4
5
  id = "fortemi-core";
@@ -22,8 +23,18 @@ export class FortemiExecutionBridge {
22
23
  plan: r.plan,
23
24
  records: r.records,
24
25
  signal: r.signal,
26
+ priorCheckpoint: r.priorCheckpoint,
25
27
  });
26
28
  if (response.receipt.planDigest.value !== r.plan.planDigest.value ||
29
+ response.receipt.planId !== r.plan.id ||
30
+ !validateDatasetContract(response.receipt).valid ||
31
+ (r.priorCheckpoint !== undefined && response.receipt.checkpointBeforeId !== bindingCheckpointId(r.priorCheckpoint)) ||
32
+ (response.result.outcome === "committed" && response.result.checkpoint !== undefined && response.receipt.checkpointAfterId !== bindingCheckpointId(response.result.checkpoint)) ||
33
+ response.receipt.attemptedRecords !== response.result.attemptedRecords ||
34
+ response.receipt.committedRecords !== response.result.committedRecords ||
35
+ response.receipt.rejectedRecords !== response.result.rejectedRecords ||
36
+ response.receipt.committed !== (response.result.outcome === "committed") ||
37
+ response.receipt.outcome !== (response.result.outcome === "ambiguous" ? "attempted" : response.result.outcome) ||
27
38
  !verifyRunReceiptDigest(response.receipt))
28
39
  throw new Error("DATASET_FORTEMI_RECEIPT_INVALID");
29
40
  return response.result;
@@ -22,4 +22,6 @@ export * from './orchestration-service.js';
22
22
  export * from './presentation.js';
23
23
  export * from './conformance-types.js';
24
24
  export * from './conformance.js';
25
+ export * from './service-binding-contract.js';
26
+ export * from './service-binding-registry.js';
25
27
  //# sourceMappingURL=index.d.ts.map
@@ -22,4 +22,6 @@ export * from './orchestration-service.js';
22
22
  export * from './presentation.js';
23
23
  export * from './conformance-types.js';
24
24
  export * from './conformance.js';
25
+ export * from './service-binding-contract.js';
26
+ export * from './service-binding-registry.js';
25
27
  //# sourceMappingURL=index.js.map
@@ -23,7 +23,7 @@ export declare class DatasetOrchestrationService {
23
23
  profile: CapabilityProfile;
24
24
  schemas: ProcessingPlan["schemas"];
25
25
  policy: ProcessingPlan["policy"];
26
- backend?: "local" | "fortemi-core";
26
+ backend?: string;
27
27
  fallback?: "local";
28
28
  estimates?: ProcessingPlan["estimates"];
29
29
  approvals?: ProcessingPlan["approvals"];
@@ -1,4 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { selectDatasetBackend } from "./backend-selection.js";
3
+ import { bindingReceiptCheckpoints, verifyBindingCheckpointReceipt } from "./service-binding-checkpoints.js";
2
4
  import { computeProcessingPlanDigest, computeRunReceiptDigest, datasetDigest, DatasetContractError, negotiateDatasetCapabilities, verifyProcessingPlanDigest, } from "./contracts.js";
3
5
  import { DEFAULT_ADAPTER_LIMITS, request, sha256Digest, } from "./adapter-sdk.js";
4
6
  import { DATASET_CONTRACT_VERSION, } from "./types.js";
@@ -145,9 +147,7 @@ export class DatasetOrchestrationService {
145
147
  async plan(input) {
146
148
  try {
147
149
  const c = await this.context(input.sourceId, input.offline);
148
- let backend = input.backend === "fortemi-core"
149
- ? this.deps.fortemiBackend
150
- : this.deps.localBackend;
150
+ const backend = selectDatasetBackend(this.deps, input.backend);
151
151
  if (!backend)
152
152
  throw new DatasetOrchestrationError("DATASET_FORTEMI_UNAVAILABLE", "Fortemi support requires an injected compatible bridge", "backend");
153
153
  const decision = negotiateDatasetCapabilities(input.profile, backend.capabilities());
@@ -175,7 +175,7 @@ export class DatasetOrchestrationService {
175
175
  capabilityDecision: decision,
176
176
  policy: input.policy,
177
177
  execution: {
178
- locality: backend.id === "local" ? "local" : "remote",
178
+ locality: backend.locality ?? (backend.id === "local" ? "local" : "remote"),
179
179
  backend: backend.id,
180
180
  ...(input.fallback ? { fallback: input.fallback } : {}),
181
181
  },
@@ -229,9 +229,7 @@ export class DatasetOrchestrationService {
229
229
  c.manifest.version !== plan.adapter.version ||
230
230
  c.configured.configDigest?.value !== plan.adapter.configDigest.value)
231
231
  throw new DatasetOrchestrationError("DATASET_SOURCE_COMPATIBILITY_CHANGED", "Source revision, adapter, or configuration changed after planning", "plan");
232
- const backend = plan.execution.backend === "fortemi-core"
233
- ? this.deps.fortemiBackend
234
- : this.deps.localBackend;
232
+ const backend = selectDatasetBackend(this.deps, plan.execution.backend);
235
233
  if (!backend)
236
234
  throw new DatasetOrchestrationError("DATASET_FORTEMI_UNAVAILABLE", "Fortemi support requires an injected compatible bridge", "backend");
237
235
  negotiateDatasetCapabilities({
@@ -286,6 +284,7 @@ export class DatasetOrchestrationService {
286
284
  createdAt: this.now(),
287
285
  receiptDigest: sha256Digest("pending"),
288
286
  diagnosticCodes: result.diagnostics.map((v) => v.code),
287
+ ...bindingReceiptCheckpoints(backend.id, c.source.checkpoint, result),
289
288
  };
290
289
  const receipt = {
291
290
  ...receiptDraft,
@@ -344,7 +343,7 @@ export class DatasetOrchestrationService {
344
343
  throw new DatasetOrchestrationError("DATASET_RECEIPT_NOT_FOUND", `No receipt for ${runId}`);
345
344
  const valid = computeRunReceiptDigest(run.receipt).value ===
346
345
  run.receipt.receiptDigest.value &&
347
- run.receipt.planDigest.value === run.planDigest.value;
346
+ run.receipt.planDigest.value === run.planDigest.value && await verifyBindingCheckpointReceipt(run, this.repo);
348
347
  return valid
349
348
  ? ok("verify", { runId, valid })
350
349
  : fail("verify", new DatasetOrchestrationError("DATASET_RECEIPT_INVALID", "Receipt digest or plan binding is invalid", "repository"));
@@ -68,6 +68,7 @@ export interface ExecutionResult {
68
68
  }
69
69
  export interface DatasetExecutionBackend {
70
70
  readonly id: string;
71
+ readonly locality?: "local" | "remote";
71
72
  capabilities(): readonly {
72
73
  name: string;
73
74
  version: string;
@@ -78,6 +79,7 @@ export interface DatasetOrchestrationDependencies {
78
79
  adapter(id: string, version: string): DatasetSourceAdapter;
79
80
  localBackend: DatasetExecutionBackend;
80
81
  fortemiBackend?: DatasetExecutionBackend;
82
+ selectBackend?(id?: string): DatasetExecutionBackend;
81
83
  now?: () => string;
82
84
  }
83
85
  //# sourceMappingURL=orchestration-types.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { AdapterCheckpoint } from './adapter-types.js';
2
+ import type { DatasetOrchestrationRepository } from './orchestration-repository.js';
3
+ import type { DatasetRunState, ExecutionResult } from './orchestration-types.js';
4
+ export declare function bindingCheckpointId(checkpoint: AdapterCheckpoint): string;
5
+ export declare function bindingReceiptCheckpoints(backend: string, before: AdapterCheckpoint | undefined, result: ExecutionResult): {
6
+ checkpointAfterId?: string | undefined;
7
+ checkpointBeforeId?: string | undefined;
8
+ };
9
+ export declare function verifyBindingCheckpointReceipt(run: DatasetRunState, repo: DatasetOrchestrationRepository): Promise<boolean>;
10
+ //# sourceMappingURL=service-binding-checkpoints.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { datasetDigest } from './contracts.js';
2
+ export function bindingCheckpointId(checkpoint) {
3
+ return `checkpoint:sha256:${datasetDigest(checkpoint).value}`;
4
+ }
5
+ export function bindingReceiptCheckpoints(backend, before, result) {
6
+ if (!backend.startsWith('dataset-binding:'))
7
+ return {};
8
+ return {
9
+ ...(before ? { checkpointBeforeId: bindingCheckpointId(before) } : {}),
10
+ ...(result.outcome === 'committed' && result.checkpoint ? { checkpointAfterId: bindingCheckpointId(result.checkpoint) } : {}),
11
+ };
12
+ }
13
+ export async function verifyBindingCheckpointReceipt(run, repo) {
14
+ const plan = await repo.getPlan(run.planId);
15
+ if (plan?.execution.backend.startsWith('dataset-binding:')) {
16
+ const source = await repo.getSource(plan.source.id);
17
+ if (!source || source.revisionId !== plan.source.revisionId || (source.identity ?? source.id) !== plan.source.identity)
18
+ return false;
19
+ const before = source.checkpoint ? bindingCheckpointId(source.checkpoint) : undefined;
20
+ const after = run.status === 'committed' && run.checkpoint ? bindingCheckpointId(run.checkpoint) : undefined;
21
+ return run.receipt?.checkpointBeforeId === before && run.receipt?.checkpointAfterId === after;
22
+ }
23
+ const after = run.receipt?.checkpointAfterId;
24
+ return !after || !after.startsWith('checkpoint:sha256:') || (!!run.checkpoint && bindingCheckpointId(run.checkpoint) === after);
25
+ }
26
+ //# sourceMappingURL=service-binding-checkpoints.js.map
@@ -0,0 +1,46 @@
1
+ import type { Digest } from './types.js';
2
+ export declare const DATASET_BINDING_VERSION: "aiwg.dataset.service-binding/v1";
3
+ export interface DatasetBindingComponent {
4
+ id: string;
5
+ version: string;
6
+ packageDigest: Digest;
7
+ }
8
+ export interface DatasetBindingSelection {
9
+ contractVersion: typeof DATASET_BINDING_VERSION;
10
+ kind: 'DatasetBindingSelection';
11
+ id: string;
12
+ version: string;
13
+ descriptorDigest: Digest;
14
+ }
15
+ export interface DatasetServiceBinding {
16
+ contractVersion: typeof DATASET_BINDING_VERSION;
17
+ kind: 'DatasetServiceBinding';
18
+ id: string;
19
+ version: string;
20
+ datasetContractVersion: 'aiwg.dataset/v1';
21
+ adapterContractVersion: 'aiwg.dataset.adapter/v1';
22
+ adapter: DatasetBindingComponent;
23
+ adapterManifestDigest: Digest;
24
+ backend: DatasetBindingComponent;
25
+ capabilities: Array<{
26
+ name: string;
27
+ version: string;
28
+ }>;
29
+ limits: {
30
+ maxRecords: number;
31
+ maxBytes: number;
32
+ maxRecordBytes: number;
33
+ timeoutMs: number;
34
+ };
35
+ qualification: {
36
+ fixtureRevision: string;
37
+ cells: Array<{
38
+ name: 'admission' | 'capability-version' | 'cancellation-resume' | 'replay' | 'receipt-mismatch';
39
+ passed: boolean;
40
+ evidence: string[];
41
+ }>;
42
+ };
43
+ }
44
+ export declare function requireDatasetBindingSelection(value: unknown): DatasetBindingSelection;
45
+ export declare function requireDatasetServiceBinding(value: unknown): DatasetServiceBinding;
46
+ //# sourceMappingURL=service-binding-contract.d.ts.map
@@ -0,0 +1,25 @@
1
+ // Defines and validates the versioned dataset CLI composition boundary.
2
+ import { readFileSync } from 'node:fs';
3
+ import Ajv2020 from 'ajv/dist/2020.js';
4
+ import { fortemiPinnedSchemaPath } from './fortemi-schema-path.js';
5
+ export const DATASET_BINDING_VERSION = 'aiwg.dataset.service-binding/v1';
6
+ const schema = JSON.parse(readFileSync(fortemiPinnedSchemaPath('schemas/dataset/service-binding.v1.schema.json'), 'utf8'));
7
+ const ajv = new Ajv2020({ strict: true, allErrors: true });
8
+ ajv.addSchema(schema);
9
+ const selection = ajv.compile({ $ref: `${schema.$id}#/$defs/selection` });
10
+ const descriptor = ajv.compile({ $ref: `${schema.$id}#/$defs/descriptor` });
11
+ export function requireDatasetBindingSelection(value) {
12
+ if (!selection(value))
13
+ throw new Error('DATASET_BINDING_SELECTION_INVALID');
14
+ return structuredClone(value);
15
+ }
16
+ export function requireDatasetServiceBinding(value) {
17
+ if (!descriptor(value))
18
+ throw new Error('DATASET_BINDING_CONTRACT_INVALID');
19
+ if (new Set(value.capabilities.map(item => item.name)).size !== value.capabilities.length)
20
+ throw new Error('DATASET_BINDING_CAPABILITY_DUPLICATE');
21
+ if (new Set(value.qualification.cells.map(cell => cell.name)).size !== 5 || value.qualification.cells.some(cell => !cell.passed))
22
+ throw new Error('DATASET_BINDING_UNQUALIFIED');
23
+ return structuredClone(value);
24
+ }
25
+ //# sourceMappingURL=service-binding-contract.js.map
@@ -0,0 +1,12 @@
1
+ import type { DatasetSourceAdapter } from './adapter-types.js';
2
+ import type { DatasetExecutionBackend, DatasetOrchestrationDependencies } from './orchestration-types.js';
3
+ import { type DatasetBindingComponent, type DatasetBindingSelection } from './service-binding-contract.js';
4
+ export declare class DatasetBindingRegistry {
5
+ #private;
6
+ /** Trusted bootstrap only: registration never imports code or reads evidence paths. */
7
+ register(value: unknown, adapter: DatasetSourceAdapter, backend: DatasetExecutionBackend, backendIdentity: DatasetBindingComponent): DatasetBindingSelection;
8
+ select(value: unknown): Pick<DatasetOrchestrationDependencies, 'adapter' | 'selectBackend'>;
9
+ }
10
+ /** Empty by default. Trusted installed entrypoints register statically imported implementations. */
11
+ export declare const datasetBindingRegistry: DatasetBindingRegistry;
12
+ //# sourceMappingURL=service-binding-registry.d.ts.map
@@ -0,0 +1,118 @@
1
+ // Admits trusted, preloaded adapter/backend pairs and pins their CLI execution identity.
2
+ import { contractRangeIncludes } from './contract-range.js';
3
+ import { DATASET_ADAPTER_CONTRACT_VERSION } from './adapter-types.js';
4
+ import { validateCheckpoint } from './adapter-sdk.js';
5
+ import { datasetDigest, DatasetContractError } from './contracts.js';
6
+ import { DATASET_CONTRACT_VERSION } from './types.js';
7
+ import { requireDatasetBindingSelection, requireDatasetServiceBinding, } from './service-binding-contract.js';
8
+ const same = (a, b) => datasetDigest(a).value === datasetDigest(b).value;
9
+ const offers = (backend) => [...backend.capabilities()].sort((a, b) => a.name.localeCompare(b.name));
10
+ const expectedOffers = (descriptor) => [...descriptor.capabilities].sort((a, b) => a.name.localeCompare(b.name));
11
+ function assertRegistration({ descriptor: d, adapter, backend, backendIdentity }) {
12
+ const manifest = adapter.describe();
13
+ if (manifest.contractVersion !== DATASET_ADAPTER_CONTRACT_VERSION || !contractRangeIncludes('1.0.0', manifest.datasetContractRange)
14
+ || d.datasetContractVersion !== DATASET_CONTRACT_VERSION || d.adapterContractVersion !== manifest.contractVersion
15
+ || manifest.id !== d.adapter.id || manifest.version !== d.adapter.version
16
+ || !same(manifest.packageDigest, d.adapter.packageDigest) || !same(datasetDigest(manifest), d.adapterManifestDigest)
17
+ || !backendIdentity || backendIdentity.id !== d.backend.id || backendIdentity.version !== d.backend.version
18
+ || !same(backendIdentity.packageDigest, d.backend.packageDigest)
19
+ || backend.id !== d.backend.id || !same(offers(backend), expectedOffers(d)))
20
+ throw new DatasetContractError('DATASET_BINDING_INCOMPATIBLE', 'Registered implementation differs from the qualified binding');
21
+ if (manifest.maturity === 'experimental' || manifest.trust.state === 'untrusted')
22
+ throw new DatasetContractError('DATASET_BINDING_UNQUALIFIED', 'Adapter maturity and trust must permit qualification');
23
+ }
24
+ function boundedAdapter(entry) {
25
+ const adapter = entry.adapter;
26
+ return {
27
+ describe: () => { assertRegistration(entry); return adapter.describe(); },
28
+ configure: config => { assertRegistration(entry); return adapter.configure(config); },
29
+ check: request => { assertRegistration(entry); return adapter.check(request); },
30
+ discover: request => { assertRegistration(entry); return adapter.discover(request); },
31
+ preview: request => { assertRegistration(entry); return adapter.preview({ ...request, limits: { ...request.limits, ...entry.descriptor.limits } }); },
32
+ async *read(request) {
33
+ assertRegistration(entry);
34
+ const limits = entry.descriptor.limits;
35
+ const signal = AbortSignal.any([...(request.signal ? [request.signal] : []), AbortSignal.timeout(limits.timeoutMs)]);
36
+ let count = 0;
37
+ let bytes = 0;
38
+ for await (const event of adapter.read({ ...request, signal, limits: { ...request.limits, ...limits } })) {
39
+ if (request.signal?.aborted)
40
+ return;
41
+ if (signal.aborted)
42
+ throw new DatasetContractError('DATASET_BINDING_RESOURCE_LIMIT', 'Binding read deadline exceeded');
43
+ if (event.kind === 'diagnostic' && event.diagnostic.severity === 'error')
44
+ throw new DatasetContractError(event.diagnostic.code, 'Qualified adapter read failed before execution');
45
+ if (event.kind === 'record') {
46
+ const size = Buffer.byteLength(JSON.stringify(event.record.value));
47
+ bytes += size;
48
+ count++;
49
+ if (count > limits.maxRecords || bytes > limits.maxBytes || size > limits.maxRecordBytes)
50
+ throw new DatasetContractError('DATASET_BINDING_RESOURCE_LIMIT', 'Binding record or byte limit exceeded');
51
+ }
52
+ yield event;
53
+ }
54
+ },
55
+ };
56
+ }
57
+ export class DatasetBindingRegistry {
58
+ #entries = new Map();
59
+ /** Trusted bootstrap only: registration never imports code or reads evidence paths. */
60
+ register(value, adapter, backend, backendIdentity) {
61
+ const descriptor = requireDatasetServiceBinding(value);
62
+ const key = `${descriptor.id}@${descriptor.version}`;
63
+ if (this.#entries.has(key))
64
+ throw new Error('DATASET_BINDING_DUPLICATE');
65
+ const entry = { descriptor, adapter, backend, backendIdentity: structuredClone(backendIdentity) };
66
+ assertRegistration(entry);
67
+ this.#entries.set(key, entry);
68
+ return {
69
+ contractVersion: descriptor.contractVersion, kind: 'DatasetBindingSelection',
70
+ id: descriptor.id, version: descriptor.version, descriptorDigest: datasetDigest(descriptor),
71
+ };
72
+ }
73
+ select(value) {
74
+ const selection = requireDatasetBindingSelection(value);
75
+ const entry = this.#entries.get(`${selection.id}@${selection.version}`);
76
+ if (!entry)
77
+ throw new Error('DATASET_BINDING_NOT_REGISTERED');
78
+ if (!same(selection.descriptorDigest, datasetDigest(entry.descriptor)))
79
+ throw new Error('DATASET_BINDING_DIGEST_MISMATCH');
80
+ assertRegistration(entry);
81
+ const adapter = boundedAdapter(entry);
82
+ const boundId = `dataset-binding:${selection.id}@${selection.version}:sha256:${selection.descriptorDigest.value}`;
83
+ const backend = {
84
+ id: boundId,
85
+ locality: entry.descriptor.backend.id === 'local' ? 'local' : 'remote',
86
+ capabilities: () => { assertRegistration(entry); return entry.backend.capabilities(); },
87
+ async execute(request) {
88
+ assertRegistration(entry);
89
+ if (request.plan.execution.backend !== boundId)
90
+ throw new Error('DATASET_BINDING_PLAN_MISMATCH');
91
+ if (request.signal?.aborted)
92
+ return { outcome: 'cancelled', attemptedRecords: 0, committedRecords: 0, rejectedRecords: 0, diagnostics: [] };
93
+ const signal = AbortSignal.any([...(request.signal ? [request.signal] : []), AbortSignal.timeout(entry.descriptor.limits.timeoutMs)]);
94
+ const result = await entry.backend.execute({ ...request, signal });
95
+ if (result.checkpoint && validateCheckpoint(result.checkpoint, adapter.describe(), request.plan.source.identity).length)
96
+ throw new Error('DATASET_BINDING_CHECKPOINT_MISMATCH');
97
+ return result;
98
+ },
99
+ };
100
+ return {
101
+ adapter(id, version) {
102
+ if (id !== entry.descriptor.adapter.id || version !== entry.descriptor.adapter.version)
103
+ throw new Error('DATASET_BINDING_ADAPTER_MISMATCH');
104
+ assertRegistration(entry);
105
+ return adapter;
106
+ },
107
+ selectBackend(id) {
108
+ if (id !== undefined && id !== boundId && id !== entry.descriptor.backend.id)
109
+ throw new DatasetContractError('DATASET_BINDING_BACKEND_MISMATCH', 'The plan requires its explicitly selected binding');
110
+ assertRegistration(entry);
111
+ return backend;
112
+ },
113
+ };
114
+ }
115
+ }
116
+ /** Empty by default. Trusted installed entrypoints register statically imported implementations. */
117
+ export const datasetBindingRegistry = new DatasetBindingRegistry();
118
+ //# sourceMappingURL=service-binding-registry.js.map
@@ -0,0 +1,83 @@
1
+ // Signed publication receipts and current-byte lookup for verified worker artifacts.
2
+ import { readFile, realpath } from 'node:fs/promises';
3
+ import { dirname, basename, join } from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { assertKeyring } from './keyring.js';
6
+ import { sha256Digest } from './identity.js';
7
+ import { recordIntent, recordOutcome } from './ledger.js';
8
+ import { readAllSegments, readKeyring, lineFailures } from './reader.js';
9
+ import { verifyLedger } from './verify.js';
10
+ import { ensureLedgerDirectories, withLedgerLock } from './store.js';
11
+ const canonicalDestination = async (destination) => join(await realpath(dirname(destination)), basename(destination));
12
+ /** A signed intent reserves the path even if publication crashed or bytes changed. */
13
+ async function reserveDelivery(ledger, delivery, target) {
14
+ const paths = ledger.paths();
15
+ await ensureLedgerDirectories(paths);
16
+ return withLedgerLock(paths, 'worker-delivery', ledger.lockTimeoutMs, async () => {
17
+ if (!(await verifyLedger(ledger, { checkIndex: false })).ok)
18
+ throw new Error('Delivery ledger integrity failed; publication refused');
19
+ const records = (await readAllSegments(paths)).flatMap(segment => segment.lines.flatMap(line => line.decoded ? [line.decoded] : []));
20
+ const conflict = records.some(({ statement: { predicate: p } }) => p.kind === 'file.digest' && p.target === `file:${target}`
21
+ && typeof p.context?.deliveryId === 'string' && (delivery.kind === 'typed-stop' || p.context?.kind === 'typed-stop'));
22
+ if (conflict)
23
+ throw Object.assign(new Error('TYPED_STOP_CONFLICT: a delivery record already exists for this path'), { code: 'TYPED_STOP_CONFLICT' });
24
+ const context = { artifactDigest: delivery.artifactDigest, verifierId: delivery.verifierId,
25
+ deliverablePath: target, deliveryId: randomUUID() };
26
+ if (delivery.kind)
27
+ context.kind = delivery.kind;
28
+ if (delivery.kind !== 'typed-stop') {
29
+ context.runDir = delivery.runDir;
30
+ context.invocationId = delivery.invocationId;
31
+ }
32
+ return recordIntent(ledger, { kind: 'file.digest', target: `file:${target}`, context, payloadDigest: delivery.artifactDigest });
33
+ });
34
+ }
35
+ /** Persist intent before publication, then complete only after the digest-checked rename. */
36
+ export async function prepareWorkerDelivery(ledger, delivery) {
37
+ if (delivery.kind === 'typed-stop' && (delivery.verifierId !== 'typed-stop@1' || 'runDir' in delivery || 'invocationId' in delivery)) {
38
+ throw Object.assign(new Error('TYPED_STOP_INVALID: typed stops cannot have worker lineage'), { code: 'TYPED_STOP_INVALID' });
39
+ }
40
+ const target = await canonicalDestination(delivery.deliverablePath);
41
+ const intent = await reserveDelivery(ledger, delivery, target);
42
+ return async () => {
43
+ if (sha256Digest(await readFile(target)) !== delivery.artifactDigest)
44
+ throw new Error('Published deliverable digest does not match acceptance; delivery record refused');
45
+ return recordOutcome(ledger, intent.effectId, { phase: 'completed', payloadDigest: delivery.artifactDigest,
46
+ verification: { verifier: { kind: 'file.digest', version: '1.0.0', canReportAbsent: false }, result: 'present', reason: 'digest-match', complete: true, checkedAt: ledger.now(), evidenceDigest: delivery.artifactDigest } });
47
+ };
48
+ }
49
+ /** Read-only: signatures/chains and a completed delivery must match the current bytes. */
50
+ export async function lookupWorkerDelivery(ledger, deliverablePath) {
51
+ let target, artifactDigest;
52
+ try {
53
+ target = await canonicalDestination(deliverablePath);
54
+ artifactDigest = sha256Digest(await readFile(target));
55
+ }
56
+ catch {
57
+ return { verified: false, deliverablePath, reason: 'deliverable-unreadable' };
58
+ }
59
+ const verification = await verifyLedger(ledger, { checkIndex: false });
60
+ if (!verification.ok)
61
+ return { verified: false, deliverablePath: target, artifactDigest, reason: 'ledger-integrity-failed' };
62
+ const records = (await readAllSegments(ledger.paths())).flatMap(segment => segment.lines.flatMap(line => line.decoded ? [line.decoded] : []));
63
+ const keyring = await readKeyring(ledger.paths());
64
+ if (!keyring)
65
+ return { verified: false, deliverablePath: target, artifactDigest, reason: 'ledger-empty' };
66
+ assertKeyring(keyring, ledger.scope);
67
+ const previous = new Map();
68
+ for (const record of records) {
69
+ if (lineFailures(keyring, ledger.scope, record.line.writer, record.line.seq, record, previous.get(record.line.writer) ?? null).length)
70
+ return { verified: false, deliverablePath: target, artifactDigest, reason: 'ledger-integrity-failed' };
71
+ previous.set(record.line.writer, record.line.recordHash);
72
+ }
73
+ const match = records.reverse().find(({ statement: { predicate: p } }) => p.kind === 'file.digest' && p.phase === 'completed'
74
+ && p.target === `file:${target}` && p.payloadDigest === artifactDigest && p.context?.artifactDigest === artifactDigest
75
+ && typeof p.context?.deliveryId === 'string' && typeof p.context?.verifierId === 'string'
76
+ && (p.context?.kind === 'typed-stop'
77
+ ? p.context.verifierId === 'typed-stop@1' && !('runDir' in p.context) && !('invocationId' in p.context)
78
+ : typeof p.context?.runDir === 'string' && typeof p.context?.invocationId === 'string'));
79
+ if (!match)
80
+ return { verified: false, deliverablePath: target, artifactDigest, reason: 'matching-delivery-missing' };
81
+ return { verified: true, ...match.statement.predicate.context, recordHash: match.line.recordHash };
82
+ }
83
+ //# sourceMappingURL=worker-delivery.js.map
@@ -2,7 +2,7 @@
2
2
  * CapabilityIndex - Capability-based extension discovery system
3
3
  *
4
4
  * @implements @.aiwg/requirements/use-cases/UC-004-extension-system.md
5
- * @architecture @.aiwg/architecture/software-architecture-doc.md
5
+ * @architecture @docs/architecture/cli/index.md
6
6
  * @tests @test/unit/extensions/capability-index.test.ts
7
7
  */
8
8
  /**
@@ -4,8 +4,8 @@
4
4
  * Defines Extension objects for all CLI commands. Maps command handlers to the
5
5
  * unified Extension schema for discovery, semantic search, and help generation.
6
6
  *
7
- * @implements @.aiwg/architecture/decisions/ADR-001-unified-extension-system.md
8
- * @architecture @.aiwg/architecture/unified-extension-schema.md
7
+ * @implements @docs/architecture/cli/adr-001-unified-extension-registry.md
8
+ * @architecture @docs/architecture/cli/extending-cli.md
9
9
  * @source @src/cli/handlers/index.ts
10
10
  * @tests @test/unit/extensions/commands/definitions.test.ts
11
11
  * @issue #42
@@ -5,7 +5,7 @@
5
5
  * and registers them in the extension registry for discovery.
6
6
  *
7
7
  * @implements #56, #57
8
- * @architecture @.aiwg/architecture/unified-extension-schema.md
8
+ * @architecture @docs/architecture/cli/extending-cli.md
9
9
  * @tests @test/unit/extensions/deployment-registration.test.ts
10
10
  */
11
11
  import fs from 'fs';
@@ -5,7 +5,7 @@
5
5
  * capability indexing, and loading functionality for all extension types.
6
6
  *
7
7
  * @implements @.aiwg/requirements/use-cases/UC-004-extension-system.md
8
- * @architecture @.aiwg/architecture/unified-extension-schema.md
8
+ * @architecture @docs/architecture/cli/extending-cli.md
9
9
  */
10
10
  // Core types
11
11
  export * from './types.js';
@@ -5,7 +5,7 @@
5
5
  * capability indexes for fast lookup.
6
6
  *
7
7
  * @implements @.aiwg/requirements/use-cases/UC-004-extension-system.md
8
- * @architecture @.aiwg/architecture/unified-extension-schema.md
8
+ * @architecture @docs/architecture/cli/extending-cli.md
9
9
  * @tests @test/unit/extensions/loader.test.ts
10
10
  */
11
11
  import { getRegistry, createRegistry } from './registry.js';