@aiwg/cli 2026.11.6 → 2026.11.8

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 (102) hide show
  1. package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +3 -2
  2. package/agentic/code/providers/model-capabilities.v1.json +22 -21
  3. package/agentic/code/providers/model-catalog.v1.json +11 -10
  4. package/dist/src/artifacts/browser-export.js +1 -0
  5. package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
  6. package/dist/src/artifacts/index-builder.js +1 -0
  7. package/dist/src/artifacts/query-engine-discover-output.js +1 -0
  8. package/dist/src/artifacts/query-engine-discover.js +2 -2
  9. package/dist/src/artifacts/query-engine-scoring.js +7 -0
  10. package/dist/src/artifacts/template-output-kind.js +10 -0
  11. package/dist/src/artifacts/types.js +1 -1
  12. package/dist/src/cli/handlers/dataset.js +11 -2
  13. package/dist/src/cli/handlers/refresh-managed-deployment.js +13 -3
  14. package/dist/src/cli/handlers/refresh-user-hooks.js +102 -0
  15. package/dist/src/cli/handlers/refresh.js +2 -0
  16. package/dist/src/cli/handlers/update.js +26 -12
  17. package/dist/src/cli/handlers/use.js +4 -3
  18. package/dist/src/cli/handlers/writing.js +7 -1
  19. package/dist/src/config/worker-guidance-warning.js +8 -0
  20. package/dist/src/dataset/backend-selection.d.ts +3 -0
  21. package/dist/src/dataset/backend-selection.js +11 -0
  22. package/dist/src/dataset/contract-range.d.ts +7 -0
  23. package/dist/src/dataset/contract-range.js +55 -0
  24. package/dist/src/dataset/fortemi-execution-bridge.d.ts +2 -0
  25. package/dist/src/dataset/fortemi-execution-bridge.js +12 -1
  26. package/dist/src/dataset/index.d.ts +2 -0
  27. package/dist/src/dataset/index.js +2 -0
  28. package/dist/src/dataset/orchestration-service.d.ts +1 -1
  29. package/dist/src/dataset/orchestration-service.js +7 -8
  30. package/dist/src/dataset/orchestration-types.d.ts +2 -0
  31. package/dist/src/dataset/service-binding-checkpoints.d.ts +10 -0
  32. package/dist/src/dataset/service-binding-checkpoints.js +26 -0
  33. package/dist/src/dataset/service-binding-contract.d.ts +46 -0
  34. package/dist/src/dataset/service-binding-contract.js +25 -0
  35. package/dist/src/dataset/service-binding-registry.d.ts +12 -0
  36. package/dist/src/dataset/service-binding-registry.js +118 -0
  37. package/dist/src/extensions/manifest.js +23 -7
  38. package/dist/src/extensions/project-local-doctor.js +2 -1
  39. package/dist/src/extensions/project-quickref-discovery.js +11 -0
  40. package/dist/src/extensions/project-quickref.js +4 -7
  41. package/dist/src/extensions/user-hook-diagnostics.js +16 -1
  42. package/dist/src/extensions/verified-hook-command.js +7 -0
  43. package/dist/src/mcp/tools/worker-invoke.mjs +6 -4
  44. package/dist/src/mcp/tools/worker-launch-ledger.mjs +33 -0
  45. package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +22 -6
  46. package/dist/src/mcp/tools/worker-verify-deliver.mjs +4 -6
  47. package/dist/src/models/cursor-models.js +92 -0
  48. package/dist/src/models/model-capabilities.v1.json +22 -21
  49. package/dist/src/models/model-catalog.v1.json +11 -10
  50. package/dist/src/models/model-discovery.js +4 -3
  51. package/dist/src/models/provider-policy.js +1 -1
  52. package/dist/src/models/worker-health-readiness.js +4 -0
  53. package/dist/src/models/worker-installation.d.mts +2 -0
  54. package/dist/src/models/worker-installation.mjs +8 -2
  55. package/dist/src/models/worker-invocation-policy.js +21 -1
  56. package/dist/src/models/worker-plan.js +3 -1
  57. package/dist/src/models/worker-wiring-diagnostics.js +25 -0
  58. package/dist/src/providers/deployment-input-session.d.mts +2 -0
  59. package/dist/src/providers/deployment-input-session.mjs +38 -0
  60. package/dist/src/providers/provider-context-contracts.js +3 -0
  61. package/dist/src/providers/provider-seeds-1.js +1 -1
  62. package/dist/src/serve/worker-invocation-preparation.js +52 -33
  63. package/dist/src/serve/worker-invocation.js +4 -2
  64. package/dist/src/serve/worker-shell-prompt.d.mts +6 -0
  65. package/dist/src/serve/worker-shell-prompt.mjs +78 -0
  66. package/dist/src/smiths/context-pipeline/muse-bridge.js +7 -4
  67. package/dist/src/smiths/context-pipeline/workspace-audit.js +37 -6
  68. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +3 -1
  69. package/dist/src/smiths/context-pipeline/workspace-doctor.js +16 -4
  70. package/dist/src/smiths/context-pipeline/workspace-document.js +4 -2
  71. package/dist/src/smiths/hook-bridge/codex-trust.js +56 -7
  72. package/dist/src/smiths/hook-bridge/cursor-translator.js +89 -0
  73. package/dist/src/smiths/hook-bridge/index.js +4 -1
  74. package/dist/src/writing/campaign-patterns.js +96 -0
  75. package/dist/src/writing/campaign-report.js +41 -0
  76. package/dist/src/writing/contextual-diagnostics.js +30 -5
  77. package/dist/src/writing/current-patterns.catalogue.json +87 -0
  78. package/dist/src/writing/current-patterns.js +99 -0
  79. package/dist/src/writing/prose-mask.js +80 -0
  80. package/dist/src/writing/structural-patterns.js +126 -0
  81. package/dist/src/writing/validation-campaign.js +19 -0
  82. package/dist/src/writing/validation-engine.js +17 -10
  83. package/dist/src/writing/validation-rules.js +4 -3
  84. package/package.json +1 -1
  85. package/schemas/dataset/service-binding.v1.schema.json +70 -0
  86. package/tools/agents/providers/base-models-platforms.mjs +87 -48
  87. package/tools/agents/providers/cursor-prompt-discovery.mjs +13 -0
  88. package/tools/agents/providers/cursor.mjs +2 -0
  89. package/tools/agents/providers/openclaw-context.mjs +6 -0
  90. package/tools/agents/providers/openclaw.mjs +14 -12
  91. package/tools/agents/providers/rule-delivery-surface.mjs +1 -1
  92. package/tools/agents/providers/rule-deployment-corpus-inputs.mjs +19 -0
  93. package/tools/agents/providers/rule-deployment-input-session.mjs +40 -0
  94. package/tools/agents/providers/rule-deployment-prepare.mjs +16 -6
  95. package/tools/agents/providers/rule-presentation.mjs +1 -1
  96. package/tools/agents/providers/rule-startup.mjs +3 -1
  97. package/tools/plugin/package-plugins.mjs +2 -0
  98. package/tools/ralph-external/lib/typed-stop-delivery.mjs +10 -1
  99. package/tools/ralph-external/lib/worker-delivery-guards.mjs +47 -1
  100. package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +2 -1
  101. package/tools/ralph-external/lib/worker-verification-cli.mjs +1 -1
  102. package/vscode-extension/schemas/aiwg.config.v1.json +13 -0
@@ -10,7 +10,10 @@ import { resolveOutputModes } from '../../output-modes/registry.js';
10
10
  import { resolveProjectAiwgDirForWrite } from '../../config/project-artifacts.js';
11
11
  import { readAiwgConfig } from '../../config/aiwg-config.js';
12
12
  import { resolveArtifactOutputs, recordArtifactOutputProvenance } from '../../artifacts/output-policy.js';
13
+ import { campaignReport } from '../../writing/campaign-report.js';
13
14
  async function execute(ctx) {
15
+ if (ctx.args.includes('--cross'))
16
+ return { exitCode: 0, rawOutput: true, message: await campaignReport(ctx.cwd, ctx.args) };
14
17
  const [action, ...args] = ctx.args;
15
18
  if (!['plan', 'proofread'].includes(action))
16
19
  throw new Error('Expected writing plan or proofread');
@@ -107,6 +110,7 @@ export const writingHandler = {
107
110
  return { exitCode: 0, rawOutput: true, message: [
108
111
  'aiwg writing plan --brief <brief.json> --profile <id> [--channel article|social|email|engineering|conversation] [--output <new-file>]',
109
112
  'aiwg writing proofread --brief <brief.json> --profile <id> [--correction <id>]... [--output <new-file>]',
113
+ 'aiwg writing --cross [--json] <file-or-dir>... Review one campaign without writing files',
110
114
  'Proofreading applies listed author-authorized corrections (all by default), without a model or voice rewrite.',
111
115
  'Canonical output and a receipt are written first. Optional local exports require a new file and project-policy allowance.',
112
116
  'Mode selections are inspected; this command does not claim provider response interception or publication approval.',
@@ -115,7 +119,9 @@ export const writingHandler = {
115
119
  async execute(ctx) { try {
116
120
  return await execute(ctx);
117
121
  }
118
- catch {
122
+ catch (error) {
123
+ if (error instanceof RangeError && error.message.startsWith('Campaign exceeds'))
124
+ return { exitCode: 1, message: error.message };
119
125
  return { exitCode: 1, message: 'Writing operation failed. Check the brief, profile, correction IDs, output destination and artifact policy. Private source text is omitted; any completed canonical artifacts remain available.' };
120
126
  } },
121
127
  };
@@ -20,9 +20,17 @@ export function warnStaleParallelism(cfg, projectDir, key, before) {
20
20
  ` aiwg regenerate --workspace --provider ${provider}`,
21
21
  ]),
22
22
  ' aiwg workspace-context doctor',
23
+ ...(qualificationInputsChanged(cfg, key, before)
24
+ ? ['Worker routing or qualification inputs changed; recheck approval after fixing wiring:', ' aiwg doctor --probe-workers --qualify'] : []),
23
25
  `Shared parallelism defaults and labels use primary provider '${cfg.providers?.[0] ?? 'unknown'}' (providers[0]); --provider selects the adapter/context target.`,
24
26
  ];
25
27
  console.error(lines.join('\n'));
26
28
  }
27
29
  function getDottedPath(value, key) { return key.split('.').reduce((node, part) => node?.[part], value); }
30
+ function qualificationInputsChanged(cfg, key, before) {
31
+ const fields = ['clis', 'groups', 'groupTemplates', 'worker_dispatch', 'worker_mode'];
32
+ if (key === 'parallelism')
33
+ return fields.some(field => !isDeepStrictEqual(before?.[field], cfg.parallelism?.[field]));
34
+ return fields.some(field => key === `parallelism.${field}` || key.startsWith(`parallelism.${field}.`));
35
+ }
28
36
  //# sourceMappingURL=worker-guidance-warning.js.map
@@ -0,0 +1,3 @@
1
+ import type { DatasetOrchestrationDependencies } from './orchestration-types.js';
2
+ export declare function selectDatasetBackend(deps: DatasetOrchestrationDependencies, id?: string): import("./orchestration-types.js").DatasetExecutionBackend;
3
+ //# sourceMappingURL=backend-selection.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { DatasetContractError } from './contracts.js';
2
+ export function selectDatasetBackend(deps, id) {
3
+ if (deps.selectBackend)
4
+ return deps.selectBackend(id);
5
+ if (id === undefined || id === 'local')
6
+ return deps.localBackend;
7
+ if (id === 'fortemi-core' && deps.fortemiBackend)
8
+ return deps.fortemiBackend;
9
+ throw new DatasetContractError(id === 'fortemi-core' ? 'DATASET_FORTEMI_UNAVAILABLE' : 'DATASET_BACKEND_NOT_REGISTERED', 'An explicitly selected compatible dataset backend is required');
10
+ }
11
+ //# sourceMappingURL=backend-selection.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * True when `version` (x.y.z) satisfies `range`. Supports exact versions, `^`, `~`,
3
+ * `>=`, `<=`, `>`, `<`, space-separated AND and `||` OR. Prerelease tags, wildcards,
4
+ * hyphen ranges and any other syntax return false rather than guessing.
5
+ */
6
+ export declare function contractRangeIncludes(version: string, range: string): boolean;
7
+ //# sourceMappingURL=contract-range.d.ts.map
@@ -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
@@ -267,6 +267,19 @@ export const BundleManifestSchema = z.strictObject({
267
267
  }
268
268
  return presentCount === 1 && present[m.type];
269
269
  }, { error: 'type must match its corresponding *Config block (addon→addonConfig, framework→frameworkConfig, plugin→pluginConfig, provider→providerConfig; extension may omit extensionConfig)' });
270
+ /** Format a field diagnostic consistently with `aiwg list --project-local`. */
271
+ export function formatManifestValidationError(error) {
272
+ return `${error.field}: expected ${error.expected}, got ${error.actual}`
273
+ + (error.hint ? `; hint: ${error.hint}` : '');
274
+ }
275
+ function stringifyManifestValue(value) {
276
+ try {
277
+ return JSON.stringify(value) ?? String(value);
278
+ }
279
+ catch {
280
+ return String(value);
281
+ }
282
+ }
270
283
  /**
271
284
  * Convert a Zod error into the structured ManifestValidationError shape used
272
285
  * by discovery and `aiwg validate-metadata`.
@@ -293,22 +306,25 @@ export function zodErrorToValidationErrors(err, manifestPath, input) {
293
306
  const keys = issue.keys.map((key) => `"${String(key)}"`).join(', ');
294
307
  actual = `unknown key(s): ${keys}`;
295
308
  }
296
- if (issue.code === 'invalid_type' && hasInput) {
309
+ if ((issue.code === 'invalid_type' || issue.code === 'invalid_value') && hasInput) {
297
310
  let value = input;
298
311
  for (const segment of issue.path) {
299
312
  value = value !== null && typeof value === 'object' && Object.hasOwn(value, segment)
300
313
  ? value[segment] : undefined;
301
314
  }
302
- // Emit only the former type classification, never rejected values.
303
- actual = value === null ? 'null' : Array.isArray(value) ? 'array'
304
- : typeof value === 'number' && Number.isNaN(value) ? 'nan'
305
- : issue.expected === 'int' && typeof value === 'number' ? 'float'
306
- : typeof value;
315
+ // Enum diagnostics need the rejected value; type errors retain their classification.
316
+ actual = issue.code === 'invalid_value' ? stringifyManifestValue(value)
317
+ : value === null ? 'null' : Array.isArray(value) ? 'array'
318
+ : typeof value === 'number' && Number.isNaN(value) ? 'nan'
319
+ : issue.expected === 'int' && typeof value === 'number' ? 'float'
320
+ : typeof value;
307
321
  }
308
322
  return {
309
323
  path: manifestPath,
310
324
  field: issue.path.join('.') || '(root)',
311
- expected: issue.message,
325
+ expected: issue.code === 'invalid_value' && Array.isArray(issue.values)
326
+ ? `one of ${issue.values.map(stringifyManifestValue).join('|')}`
327
+ : issue.message,
312
328
  actual,
313
329
  severity: 'error',
314
330
  };
@@ -21,6 +21,7 @@ import { buildUpstreamRegistry } from './upstream-registry.js';
21
21
  import { resolveShadows } from './shadow-resolver.js';
22
22
  import { checkBundleManifestIgnored } from './project-local-gitignore.js';
23
23
  import { sha256OfFileRawAndNormalized } from './managed-marker.js';
24
+ import { formatManifestValidationError } from './manifest.js';
24
25
  import { projectAiwgPath } from '../config/project-artifacts.js';
25
26
  import { projectRelativePathIfInside } from './project-local-paths.js';
26
27
  import { auditProjectQuickref } from './project-quickref.js';
@@ -171,7 +172,7 @@ export async function buildProjectLocalDoctorSection(opts) {
171
172
  else {
172
173
  lines.push(` Validation: ✗ ${validationErrors} error${validationErrors === 1 ? '' : 's'}`);
173
174
  for (const e of discovery.errors.slice(0, 10)) {
174
- lines.push(` ✗ ${e.path}: ${e.field} — ${e.actual}`);
175
+ lines.push(` ✗ ${e.path}: ${formatManifestValidationError(e)}`);
175
176
  }
176
177
  const quickrefShown = quickrefErrors.slice(0, Math.max(0, 10 - discovery.errors.length));
177
178
  for (const error of quickrefShown) {
@@ -0,0 +1,11 @@
1
+ // Build quickrefs from validated bundles while retaining rejected sibling diagnostics.
2
+ import { discoverProjectLocalBundles } from './project-local-discovery.js';
3
+ import { formatManifestValidationError } from './manifest.js';
4
+ export async function discoverProjectQuickrefBundles(projectDir) {
5
+ const discovery = await discoverProjectLocalBundles(projectDir);
6
+ return {
7
+ ...discovery,
8
+ warnings: discovery.errors.map(error => `${error.path}: ${formatManifestValidationError(error)}`),
9
+ };
10
+ }
11
+ //# sourceMappingURL=project-quickref-discovery.js.map
@@ -16,7 +16,7 @@ import { resolveHermesHome } from '../providers/hermes-home.js';
16
16
  import { OPERATIONAL_SHOW_TYPES } from '../artifacts/types.js';
17
17
  import { projectAiwgPath } from '../config/project-artifacts.js';
18
18
  import { appendAiwgSourceTrackBlock } from './project-local-gitignore.js';
19
- import { discoverProjectLocalBundles } from './project-local-discovery.js';
19
+ import { discoverProjectQuickrefBundles } from './project-quickref-discovery.js';
20
20
  import { enumerateBundleArtifacts } from './shadow-resolver.js';
21
21
  const OWNERSHIP_MARKER = '.aiwg-project-quickref.json';
22
22
  const ShowHintSchema = z.strictObject({
@@ -180,16 +180,13 @@ export async function resolveProjectQuickref(projectDir) {
180
180
  };
181
181
  }
182
182
  const managed = await loadManagedConfig(projectDir);
183
- const discovery = await discoverProjectLocalBundles(projectDir);
184
- if (discovery.errors.length > 0) {
185
- throw new Error(discovery.errors.map(error => `${error.path}: ${error.field}: ${error.actual}`).join('\n'));
186
- }
183
+ const discovery = await discoverProjectQuickrefBundles(projectDir);
187
184
  if (!managed.config && discovery.bundles.length === 0) {
188
- return { exists: false, sourcePath: managed.path, provenance: 'managed', warnings: [] };
185
+ return { exists: false, sourcePath: managed.path, provenance: 'managed', warnings: discovery.warnings };
189
186
  }
190
187
  const config = managed.config ?? ProjectQuickrefConfigSchema.parse({ version: '1' });
191
188
  const excluded = new Set(config.discovery.excludeBundles.map(id => id.toLowerCase()));
192
- const warnings = [];
189
+ const warnings = discovery.warnings;
193
190
  const candidates = [];
194
191
  if (config.discovery.enabled) {
195
192
  for (const bundle of discovery.bundles) {