@aiwg/cli 2026.11.6 → 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.
- package/dist/src/artifacts/browser-export.js +1 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
- package/dist/src/artifacts/index-builder.js +1 -0
- package/dist/src/artifacts/query-engine-discover-output.js +1 -0
- package/dist/src/artifacts/query-engine-discover.js +2 -2
- package/dist/src/artifacts/query-engine-scoring.js +7 -0
- package/dist/src/artifacts/template-output-kind.js +10 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/dataset.js +11 -2
- package/dist/src/cli/handlers/update.js +26 -12
- package/dist/src/cli/handlers/use.js +4 -3
- package/dist/src/cli/handlers/writing.js +7 -1
- package/dist/src/dataset/backend-selection.d.ts +3 -0
- package/dist/src/dataset/backend-selection.js +11 -0
- package/dist/src/dataset/contract-range.d.ts +7 -0
- package/dist/src/dataset/contract-range.js +55 -0
- package/dist/src/dataset/fortemi-execution-bridge.d.ts +2 -0
- package/dist/src/dataset/fortemi-execution-bridge.js +12 -1
- package/dist/src/dataset/index.d.ts +2 -0
- package/dist/src/dataset/index.js +2 -0
- package/dist/src/dataset/orchestration-service.d.ts +1 -1
- package/dist/src/dataset/orchestration-service.js +7 -8
- package/dist/src/dataset/orchestration-types.d.ts +2 -0
- package/dist/src/dataset/service-binding-checkpoints.d.ts +10 -0
- package/dist/src/dataset/service-binding-checkpoints.js +26 -0
- package/dist/src/dataset/service-binding-contract.d.ts +46 -0
- package/dist/src/dataset/service-binding-contract.js +25 -0
- package/dist/src/dataset/service-binding-registry.d.ts +12 -0
- package/dist/src/dataset/service-binding-registry.js +118 -0
- package/dist/src/extensions/manifest.js +23 -7
- package/dist/src/extensions/project-local-doctor.js +2 -1
- package/dist/src/extensions/project-quickref-discovery.js +11 -0
- package/dist/src/extensions/project-quickref.js +4 -7
- package/dist/src/mcp/tools/worker-invoke.mjs +6 -4
- package/dist/src/mcp/tools/worker-launch-ledger.mjs +33 -0
- package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +22 -6
- package/dist/src/mcp/tools/worker-verify-deliver.mjs +4 -6
- package/dist/src/providers/deployment-input-session.d.mts +2 -0
- package/dist/src/providers/deployment-input-session.mjs +38 -0
- package/dist/src/serve/worker-invocation-preparation.js +52 -33
- package/dist/src/serve/worker-invocation.js +4 -2
- package/dist/src/serve/worker-shell-prompt.d.mts +6 -0
- package/dist/src/serve/worker-shell-prompt.mjs +78 -0
- package/dist/src/writing/campaign-patterns.js +96 -0
- package/dist/src/writing/campaign-report.js +41 -0
- package/dist/src/writing/contextual-diagnostics.js +29 -5
- package/dist/src/writing/current-patterns.catalogue.json +87 -0
- package/dist/src/writing/current-patterns.js +99 -0
- package/dist/src/writing/prose-mask.js +80 -0
- package/dist/src/writing/structural-patterns.js +109 -0
- package/dist/src/writing/validation-campaign.js +19 -0
- package/dist/src/writing/validation-engine.js +17 -10
- package/dist/src/writing/validation-rules.js +4 -3
- package/package.json +1 -1
- package/schemas/dataset/service-binding.v1.schema.json +70 -0
- package/tools/agents/providers/base-models-platforms.mjs +87 -48
- package/tools/agents/providers/rule-deployment-corpus-inputs.mjs +19 -0
- package/tools/agents/providers/rule-deployment-input-session.mjs +40 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +15 -6
- package/tools/plugin/package-plugins.mjs +2 -0
- package/tools/ralph-external/lib/typed-stop-delivery.mjs +10 -1
- package/tools/ralph-external/lib/worker-delivery-guards.mjs +47 -1
- package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +2 -1
- package/tools/ralph-external/lib/worker-verification-cli.mjs +1 -1
|
@@ -448,6 +448,7 @@ function recordForEntry(cwd, entry, graphName, dependencyGraph, privacy, schemaV
|
|
|
448
448
|
phase: entry.phase,
|
|
449
449
|
type: entry.type,
|
|
450
450
|
frontmatter: {
|
|
451
|
+
...(entry.outputKind ? { outputKind: entry.outputKind } : {}),
|
|
451
452
|
...(entry.memoryRecord ? { aiwg_memory_record: entry.memoryRecord } : {}),
|
|
452
453
|
...(entry.kernel === undefined ? {} : { kernel: entry.kernel }),
|
|
453
454
|
...(entry.kind ? { aiwg_kind: entry.kind } : {}),
|
|
@@ -272,6 +272,8 @@ function entryFromRecord(record) {
|
|
|
272
272
|
relationship.source_path ??
|
|
273
273
|
relationship.target_id),
|
|
274
274
|
triggers: record.search?.triggers,
|
|
275
|
+
...(artifactTypeFromRecord(record) === 'template' && typeof indexedFrontmatter.outputKind === 'string'
|
|
276
|
+
? { outputKind: indexedFrontmatter.outputKind } : {}),
|
|
275
277
|
capability: record.search?.capability,
|
|
276
278
|
searchTerms: Array.isArray(indexedSearchTerms)
|
|
277
279
|
? indexedSearchTerms.filter((term) => typeof term === "string")
|
|
@@ -936,6 +936,7 @@ function extractIndexArtifact(job, bindingOnly, warnings = []) {
|
|
|
936
936
|
...(markdownLinks.length > 0 ? { markdownLinks } : {}),
|
|
937
937
|
dependents: [], // Computed after all entries are processed
|
|
938
938
|
...(name ? { name } : {}),
|
|
939
|
+
...(type === 'template' && typeof data.outputKind === 'string' && data.outputKind.trim() ? { outputKind: data.outputKind.trim() } : {}),
|
|
939
940
|
...(triggers && triggers.length > 0 ? { triggers } : {}),
|
|
940
941
|
...(capability ? { capability } : {}),
|
|
941
942
|
...(searchTerms && searchTerms.length > 0 ? { searchTerms } : {}),
|
|
@@ -121,6 +121,7 @@ export async function emitDiscoverResults(context) {
|
|
|
121
121
|
...(includePaths ? { path: resolvePath(r.entry) } : {}),
|
|
122
122
|
type: r.entry.type,
|
|
123
123
|
name: r.entry.name,
|
|
124
|
+
...(r.entry.outputKind ? { outputKind: r.entry.outputKind } : {}),
|
|
124
125
|
title: r.entry.title,
|
|
125
126
|
...orderingFor(r.entry),
|
|
126
127
|
...templateRelationFields(r.entry, ruleRelations, 3, includePaths),
|
|
@@ -288,7 +288,7 @@ export async function discoverCapability(cwd, params) {
|
|
|
288
288
|
const lexicalDiagnostics = new Map();
|
|
289
289
|
const legacyStrictScored = candidates
|
|
290
290
|
.map(entry => {
|
|
291
|
-
const detailed = scoreEntryDetailed(entry, params.phrase, { personaIdentitySuppressed });
|
|
291
|
+
const detailed = scoreEntryDetailed(entry, params.phrase, { personaIdentitySuppressed, typeFilter: params.typeFilter });
|
|
292
292
|
const legacyScore = detailed.score;
|
|
293
293
|
const fortemiScore = fortemiCoreDiscoveryScores?.get(entry.path) ?? 0;
|
|
294
294
|
lexicalDiagnostics.set(entry.path, detailed.diagnostic);
|
|
@@ -318,7 +318,7 @@ export async function discoverCapability(cwd, params) {
|
|
|
318
318
|
const strictPaths = new Set(strictScored.map(result => result.entry.path));
|
|
319
319
|
const combinedByPath = new Map(strictScored.map(result => [result.entry.path, result]));
|
|
320
320
|
for (const entry of candidates) {
|
|
321
|
-
const detailed = scoreEntryDetailed(entry, params.phrase, { relaxOverlap: true, personaIdentitySuppressed });
|
|
321
|
+
const detailed = scoreEntryDetailed(entry, params.phrase, { relaxOverlap: true, personaIdentitySuppressed, typeFilter: params.typeFilter });
|
|
322
322
|
if (detailed.score < RELAXED_MIN_SCORE)
|
|
323
323
|
continue;
|
|
324
324
|
const existing = combinedByPath.get(entry.path);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Tokenize discovery phrases and score metadata matches with lexical diagnostics.
|
|
2
2
|
import { diagnoseFacetActivations } from './discover-facets.js';
|
|
3
|
+
import { matchTemplateOutputKind } from './template-output-kind.js';
|
|
3
4
|
import { verboseQueryProfile } from './query-engine-verbose.js';
|
|
4
5
|
export function containsTokenSequence(haystack, needle) {
|
|
5
6
|
if (needle.length === 0 || haystack.length < needle.length)
|
|
@@ -210,6 +211,12 @@ export function scoreEntryDetailed(entry, text, opts = {}) {
|
|
|
210
211
|
query_token_coverage: tokens.length > 0 ? newlyMatched.length / tokens.length : 0,
|
|
211
212
|
});
|
|
212
213
|
};
|
|
214
|
+
const outputKindMatch = opts.typeFilter?.includes('template') ? matchTemplateOutputKind(entry, text) : undefined;
|
|
215
|
+
if (outputKindMatch) {
|
|
216
|
+
matches.push({ field: 'output_kind', match: 'exact', value: outputKindMatch,
|
|
217
|
+
contribution: 1.002, matched_tokens: tokens, query_token_coverage: 1 });
|
|
218
|
+
return finish(1.002, 1.002);
|
|
219
|
+
}
|
|
213
220
|
// Exact and near-name floors preserve deliberate artifact selection. The
|
|
214
221
|
// 1.001 offset sorts exact names above capped lexical matches (display: 1.0).
|
|
215
222
|
if (entry.name) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function matchTemplateOutputKind(entry, phrase) {
|
|
2
|
+
if (entry.type !== 'template' || !entry.outputKind)
|
|
3
|
+
return undefined;
|
|
4
|
+
const normalize = (value) => value.toLowerCase().replace(/[._\s-]+/g, ' ').trim();
|
|
5
|
+
const query = normalize(phrase).replace(/ templates?$/, '').trim();
|
|
6
|
+
if (!query)
|
|
7
|
+
return undefined;
|
|
8
|
+
return [entry.outputKind, ...(entry.triggers ?? [])].find(value => normalize(value) === query);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=template-output-kind.js.map
|
|
@@ -110,7 +110,7 @@ export const INDEX_VERSION = '1.0.0';
|
|
|
110
110
|
* making the serialized index schema incompatible; a mismatch simply forces a
|
|
111
111
|
* one-time content re-extraction during the next incremental build.
|
|
112
112
|
*/
|
|
113
|
-
export const INDEX_EXTRACTOR_VERSION = '2026.11.
|
|
113
|
+
export const INDEX_EXTRACTOR_VERSION = '2026.11.16.1';
|
|
114
114
|
/**
|
|
115
115
|
* Built-in graph definitions
|
|
116
116
|
*/
|
|
@@ -5,6 +5,7 @@ import { FileDatasetOrchestrationRepository } from "../../dataset/file-orchestra
|
|
|
5
5
|
import { LocalDatasetExecutionBackend } from "../../dataset/local-execution-backend.js";
|
|
6
6
|
import { DatasetOrchestrationService } from "../../dataset/orchestration-service.js";
|
|
7
7
|
import { presentDatasetResult } from "../../dataset/presentation.js";
|
|
8
|
+
import { datasetBindingRegistry } from "../../dataset/service-binding-registry.js";
|
|
8
9
|
export const DATASET_ACTIONS = [
|
|
9
10
|
"source",
|
|
10
11
|
"check",
|
|
@@ -27,6 +28,7 @@ function option(args, name) {
|
|
|
27
28
|
function positions(args) {
|
|
28
29
|
const values = new Set([
|
|
29
30
|
"--file",
|
|
31
|
+
"--binding",
|
|
30
32
|
"--count",
|
|
31
33
|
"--digest",
|
|
32
34
|
"--idempotency-key",
|
|
@@ -51,7 +53,12 @@ function input(ctx) {
|
|
|
51
53
|
throw new Error("DATASET_INPUT_REQUIRED: --file <json> is required");
|
|
52
54
|
return JSON.parse(readFileSync(resolve(ctx.cwd, file), "utf8"));
|
|
53
55
|
}
|
|
54
|
-
function
|
|
56
|
+
export function createDatasetCliService(ctx, bindings = datasetBindingRegistry) {
|
|
57
|
+
const selected = ctx.args.filter(arg => arg === "--binding").length;
|
|
58
|
+
const bindingFile = option(ctx.args, "--binding");
|
|
59
|
+
if (selected && (selected !== 1 || !bindingFile || bindingFile.startsWith("--")))
|
|
60
|
+
throw new Error("DATASET_BINDING_SELECTION_REQUIRED: --binding <json>");
|
|
61
|
+
const binding = bindingFile ? bindings.select(JSON.parse(readFileSync(resolve(ctx.cwd, bindingFile), "utf8"))) : undefined;
|
|
55
62
|
const registry = createBuiltinAdapterRegistry();
|
|
56
63
|
return new DatasetOrchestrationService(new FileDatasetOrchestrationRepository(ctx.cwd), {
|
|
57
64
|
adapter: (id, version) => {
|
|
@@ -64,6 +71,7 @@ function service(ctx) {
|
|
|
64
71
|
return adapter;
|
|
65
72
|
},
|
|
66
73
|
localBackend: new LocalDatasetExecutionBackend(),
|
|
74
|
+
...binding,
|
|
67
75
|
});
|
|
68
76
|
}
|
|
69
77
|
export async function executeDatasetCommand(ctx, providedService) {
|
|
@@ -89,7 +97,7 @@ export async function executeDatasetCommand(ctx, providedService) {
|
|
|
89
97
|
}],
|
|
90
98
|
}, ctx.args.includes("--json")),
|
|
91
99
|
};
|
|
92
|
-
const s = providedService ??
|
|
100
|
+
const s = providedService ?? createDatasetCliService(ctx);
|
|
93
101
|
let result;
|
|
94
102
|
switch (action) {
|
|
95
103
|
case "source":
|
|
@@ -172,6 +180,7 @@ export const datasetHandler = {
|
|
|
172
180
|
"preview: <source-id> [--count N] [--offline]",
|
|
173
181
|
"ingest: <plan-id> --digest <sha256> --idempotency-key <key> [--approve id,id]",
|
|
174
182
|
"status <run-id>: Inspect one run by its required ID.",
|
|
183
|
+
"All actions: --binding <json> explicitly selects a pre-registered qualified service binding.",
|
|
175
184
|
"All actions: --json for the canonical aiwg.dataset-orchestration/v1 envelope.",
|
|
176
185
|
].join("\n"),
|
|
177
186
|
};
|
|
@@ -8,6 +8,7 @@ import { bundleCopyArgs } from './bundle-deployment-mode.js';
|
|
|
8
8
|
import { bundleProviders, pruneUndeclaredBundles, pruneAfterScopedDeployments } from './bundle-reconciliation.js';
|
|
9
9
|
import { readAiwgConfig } from '../../config/aiwg-config.js';
|
|
10
10
|
import { withInstalledSelection } from '../../config/installed-selection.js';
|
|
11
|
+
import { withDeploymentInputSession } from '../../providers/deployment-input-session.mjs';
|
|
11
12
|
import { REGISTRY_ID_TO_USE_NAME } from '../../config/framework-aliases.js';
|
|
12
13
|
/**
|
|
13
14
|
* Read the installed frameworks from the on-disk registry.
|
|
@@ -131,17 +132,29 @@ export const updateHandler = {
|
|
|
131
132
|
}
|
|
132
133
|
// Step 3: Re-deploy each installed framework
|
|
133
134
|
const results = [];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
// One immutable corpus per update; target/config inputs remain per-pass.
|
|
136
|
+
let cleanupFailed = false;
|
|
137
|
+
try {
|
|
138
|
+
await withDeploymentInputSession(async () => {
|
|
139
|
+
for (const { fw, args } of deployments) {
|
|
140
|
+
console.log(`Re-deploying ${fw}...`);
|
|
141
|
+
const deploy = () => useFrameworkHandler.execute({
|
|
142
|
+
...ctx,
|
|
143
|
+
args: [fw, ...args],
|
|
144
|
+
});
|
|
145
|
+
const result = await (deployAll ? deploy() : withInstalledSelection(ctx.cwd, installed, deploy));
|
|
146
|
+
results.push({ framework: fw, exitCode: result.exitCode });
|
|
147
|
+
if (result.exitCode !== 0) {
|
|
148
|
+
console.error(`Warning: Failed to re-deploy ${fw}: ${result.message || `exit ${result.exitCode}`}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
139
151
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (results.length !== deployments.length)
|
|
155
|
+
throw error;
|
|
156
|
+
cleanupFailed = true;
|
|
157
|
+
console.error(`Warning: Deployment input cleanup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
145
158
|
}
|
|
146
159
|
if (!deployAll)
|
|
147
160
|
pruneFailures += await pruneAfterScopedDeployments(ctx.cwd, await readAiwgConfig(ctx.cwd), providerArgs[1], ctx.frameworkRoot);
|
|
@@ -157,10 +170,11 @@ export const updateHandler = {
|
|
|
157
170
|
console.log('');
|
|
158
171
|
console.log(`Updated: ${succeeded.length}/${results.length}`);
|
|
159
172
|
return {
|
|
160
|
-
exitCode: failed.length > 0 || pruneFailures ? 1 : 0,
|
|
173
|
+
exitCode: failed.length > 0 || pruneFailures || cleanupFailed ? 1 : 0,
|
|
161
174
|
message: failed.length > 0
|
|
162
175
|
? `Some frameworks failed to update: ${failed.map(f => f.framework).join(', ')}`
|
|
163
|
-
:
|
|
176
|
+
: cleanupFailed ? 'Deployment input cleanup failed'
|
|
177
|
+
: `Successfully updated ${succeeded.length} framework(s)`,
|
|
164
178
|
};
|
|
165
179
|
},
|
|
166
180
|
};
|
|
@@ -46,6 +46,7 @@ export { getAllAddons, getAllExtensions, USE_ALL_DISALLOW, USE_ALL_EXTENSIONS_DI
|
|
|
46
46
|
import { checkCollisions, formatCollisionReport, hasBlockingCollisions, } from '../../smiths/skillsmith/collision-detector.js';
|
|
47
47
|
import { discoverProjectLocalBundles, formatProjectLocalTargetErrors, } from '../../extensions/project-local-discovery.js';
|
|
48
48
|
import { PROJECT_LOCAL_TYPE_TO_DIR } from '../../extensions/project-local-paths.js';
|
|
49
|
+
import { formatManifestValidationError } from '../../extensions/manifest.js';
|
|
49
50
|
import { buildUpstreamRegistry } from '../../extensions/upstream-registry.js';
|
|
50
51
|
import { resolveShadows, formatShadowReport, } from '../../extensions/shadow-resolver.js';
|
|
51
52
|
import { appendProjectLocalActivity, emitDiscoverEventsDeduped, } from '../../extensions/project-local-activity.js';
|
|
@@ -1187,8 +1188,8 @@ async function deployOneProjectLocalBundle(opts) {
|
|
|
1187
1188
|
async function deployProjectLocalBundles(opts) {
|
|
1188
1189
|
const { ctx, frameworkRoot, projectDir, provider, target, dryRun, verbose, quiet, onlyBundleId, modelArgs = [], } = opts;
|
|
1189
1190
|
const discovery = await discoverProjectLocalBundles(projectDir);
|
|
1190
|
-
|
|
1191
|
-
ui.warn(
|
|
1191
|
+
for (const error of discovery.errors) {
|
|
1192
|
+
ui.warn(`${error.path}: ${formatManifestValidationError(error)} — run 'aiwg list --project-local' for details`);
|
|
1192
1193
|
}
|
|
1193
1194
|
const targetBundles = onlyBundleId
|
|
1194
1195
|
? discovery.bundles.filter(b => b.id === onlyBundleId)
|
|
@@ -3108,7 +3109,7 @@ export class UseHandler {
|
|
|
3108
3109
|
}
|
|
3109
3110
|
}
|
|
3110
3111
|
}
|
|
3111
|
-
if (totalDeployed > 0 &&
|
|
3112
|
+
if (totalDeployed > 0 && !dryRunSingle) {
|
|
3112
3113
|
try {
|
|
3113
3114
|
await rebuildExternalBundleIndex(projectDir, 'project', verboseSingle);
|
|
3114
3115
|
if (scopeSingle === 'user') {
|
|
@@ -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
|
};
|
|
@@ -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?:
|
|
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
|
-
|
|
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
|
|
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
|