@yourtechbudstudio/isagi-workflow-verifier 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -4
- package/README.md +4 -4
- package/dist/cli.js +107 -31
- package/dist/cli.js.map +1 -1
- package/dist/closed-bundle.d.ts +2 -0
- package/dist/closed-bundle.js +393 -0
- package/dist/closed-bundle.js.map +1 -0
- package/dist/receipt.d.ts +16 -4
- package/dist/receipt.js +35 -5
- package/dist/receipt.js.map +1 -1
- package/dist/structure.d.ts +84 -0
- package/dist/structure.js +580 -0
- package/dist/structure.js.map +1 -0
- package/package.json +15 -6
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { parse } from 'acorn';
|
|
2
|
+
import { analyze } from 'eslint-scope';
|
|
3
|
+
/**
|
|
4
|
+
* Checks that a built artifact is closed: everything it executes is already inside it.
|
|
5
|
+
*
|
|
6
|
+
* The canonical build command passes `--log-override:unsupported-dynamic-import=error`, but nothing
|
|
7
|
+
* in the receipt attests to the flags an author actually used — `requirePins` checks package
|
|
8
|
+
* versions, not how the bundle was produced. So the guarantee is checked on the artifact itself.
|
|
9
|
+
*
|
|
10
|
+
* The check parses the module rather than scanning text. Text scanning was wrong in both
|
|
11
|
+
* directions: it misses a residual `import` statement entirely, and it rejects a prompt string or a
|
|
12
|
+
* comment that happens to contain `eval(`.
|
|
13
|
+
*
|
|
14
|
+
* Whether a *call* reaches a loader is a lexical question — `var` hoisting out of blocks,
|
|
15
|
+
* default-parameter scopes, named function expressions, declaration order — and successive
|
|
16
|
+
* hand-written resolvers answered it wrongly in both directions. `eslint-scope` answers it
|
|
17
|
+
* properly, which is why it is a dependency: it resolves each callee to the binding actually
|
|
18
|
+
* visible there, and reports which bindings came from `node:module` in the first place.
|
|
19
|
+
*
|
|
20
|
+
* It covers ordinary residual dependencies and deferred-load constructs, **not** adversarial
|
|
21
|
+
* indirection: computed member access can still reach a loader. Workflow code is trusted,
|
|
22
|
+
* in-process, and unsandboxed, and this check does not change that.
|
|
23
|
+
*/
|
|
24
|
+
const nodeModuleSpecifier = 'node:module';
|
|
25
|
+
/**
|
|
26
|
+
* Assignment operators that can give a binding its right-hand value.
|
|
27
|
+
*
|
|
28
|
+
* The logical forms are conditional — `cr ||= createRequire` assigns only when `cr` is falsy — but
|
|
29
|
+
* which branch a given run takes is not a question this check answers, so a right-hand side that
|
|
30
|
+
* carries a loader makes the target one. That fails closed, and it matches how a plain `=` is
|
|
31
|
+
* already treated. Arithmetic compound operators cannot yield a loader and are not candidates.
|
|
32
|
+
*/
|
|
33
|
+
const aliasingAssignmentOperators = new Set(['=', '||=', '&&=', '??=']);
|
|
34
|
+
/** Exports of `node:module` that hand back a way to load code outside the artifact. */
|
|
35
|
+
const moduleLoaderExports = new Set(['createRequire']);
|
|
36
|
+
/** Methods that load natively, read as `process.<name>(…)`. */
|
|
37
|
+
const processLoaderMethods = new Set(['binding', 'dlopen']);
|
|
38
|
+
/** The single declared exception. Bare `fs`/`path` are not exempt: by specifier alone they are
|
|
39
|
+
* indistinguishable from an unbundled package, and the scaffold and guide use the `node:` form. */
|
|
40
|
+
function isNodeBuiltin(specifier) {
|
|
41
|
+
return specifier.startsWith('node:');
|
|
42
|
+
}
|
|
43
|
+
export function scanDeferredExecutableDependencies(artifactSource) {
|
|
44
|
+
let program;
|
|
45
|
+
try {
|
|
46
|
+
program = parse(artifactSource, {
|
|
47
|
+
ecmaVersion: 'latest',
|
|
48
|
+
sourceType: 'module',
|
|
49
|
+
locations: true,
|
|
50
|
+
ranges: true,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
return [unparseable(cause)];
|
|
55
|
+
}
|
|
56
|
+
let scopeManager;
|
|
57
|
+
try {
|
|
58
|
+
scopeManager = analyze(program, { ecmaVersion: 2024, sourceType: 'module' });
|
|
59
|
+
}
|
|
60
|
+
catch (cause) {
|
|
61
|
+
return [unparseable(cause)];
|
|
62
|
+
}
|
|
63
|
+
const { loaders, resolvedAt } = analyzeBindings(scopeManager, program);
|
|
64
|
+
const diagnostics = [];
|
|
65
|
+
const report = (node, message) => {
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
code: 'deferred_executable_dependency',
|
|
68
|
+
message: `${message} (${position(node)})`,
|
|
69
|
+
at: {},
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
walk(program, (node) => {
|
|
73
|
+
switch (node.type) {
|
|
74
|
+
case 'ImportDeclaration':
|
|
75
|
+
case 'ExportAllDeclaration':
|
|
76
|
+
case 'ExportNamedDeclaration': {
|
|
77
|
+
const source = node.source;
|
|
78
|
+
if (!source || typeof source.value !== 'string')
|
|
79
|
+
return;
|
|
80
|
+
// Importing a `node:` built-in is permitted, including `node:module`. Acquiring a binding is
|
|
81
|
+
// not the failure; calling a loader through it is, and that is checked at the call site.
|
|
82
|
+
if (isNodeBuiltin(source.value))
|
|
83
|
+
return;
|
|
84
|
+
report(source, `dist/index.js still imports "${source.value}" at run time, so the bundle is not closed. Rebuild without --external so every executable dependency is inside the artifact`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
case 'ImportExpression': {
|
|
88
|
+
const source = node.source;
|
|
89
|
+
if (source?.type === 'Literal' && typeof source.value === 'string') {
|
|
90
|
+
if (isNodeBuiltin(source.value))
|
|
91
|
+
return;
|
|
92
|
+
report(source, `dist/index.js defers loading "${source.value}" through import(), so the bundle is not closed`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
report(node, 'dist/index.js calls import() with a computed specifier, so the verifier cannot tell what it would load');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
case 'NewExpression':
|
|
99
|
+
case 'CallExpression': {
|
|
100
|
+
const callee = node.callee;
|
|
101
|
+
if (!callee)
|
|
102
|
+
return;
|
|
103
|
+
const invoked = calledLoader(callee, loaders, resolvedAt);
|
|
104
|
+
if (invoked) {
|
|
105
|
+
report(callee, `dist/index.js calls ${invoked}, which can load code the artifact does not contain`);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return diagnostics;
|
|
114
|
+
}
|
|
115
|
+
function unparseable(cause) {
|
|
116
|
+
return {
|
|
117
|
+
code: 'deferred_executable_dependency',
|
|
118
|
+
message: `dist/index.js could not be analyzed as an ES module, so the verifier cannot confirm the bundle is closed: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
119
|
+
at: {},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function analyzeBindings(scopeManager, program) {
|
|
123
|
+
const loaders = new Map();
|
|
124
|
+
const resolvedAt = new Map();
|
|
125
|
+
const candidates = [];
|
|
126
|
+
for (const scope of scopeManager.scopes) {
|
|
127
|
+
for (const reference of scope.references) {
|
|
128
|
+
resolvedAt.set(reference.identifier, reference.resolved ?? null);
|
|
129
|
+
}
|
|
130
|
+
for (const variable of scope.variables) {
|
|
131
|
+
for (const def of variable.defs) {
|
|
132
|
+
if (def?.type === 'ImportBinding') {
|
|
133
|
+
const imported = importedLoader(def);
|
|
134
|
+
if (imported)
|
|
135
|
+
loaders.set(variable, imported);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (def?.type === 'Variable') {
|
|
139
|
+
candidates.push({
|
|
140
|
+
variable,
|
|
141
|
+
init: def.node?.init,
|
|
142
|
+
pattern: def.node?.id,
|
|
143
|
+
name: def.name,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// A plain assignment is an alias too. `let cr; cr = createRequire;` binds exactly what
|
|
150
|
+
// `const cr = createRequire` binds, and reading only declarator initializers missed it.
|
|
151
|
+
collectAssignmentAliases(program, resolvedAt, candidates);
|
|
152
|
+
// Aliases can be written after the code that uses them, so iterate to a fixpoint. A binding that
|
|
153
|
+
// is ever assigned a loader stays one: if it is later reassigned to something harmless, which of
|
|
154
|
+
// the two a given call sees is not a question this check answers, and it fails closed.
|
|
155
|
+
for (let changed = true; changed;) {
|
|
156
|
+
changed = false;
|
|
157
|
+
for (const candidate of candidates) {
|
|
158
|
+
if (loaders.has(candidate.variable))
|
|
159
|
+
continue;
|
|
160
|
+
const binding = aliasedLoader(candidate, loaders, resolvedAt);
|
|
161
|
+
if (!binding)
|
|
162
|
+
continue;
|
|
163
|
+
loaders.set(candidate.variable, binding);
|
|
164
|
+
changed = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { loaders, resolvedAt };
|
|
168
|
+
}
|
|
169
|
+
/** Every `x = …` write, as an alias candidate resolved the same way a declaration is. */
|
|
170
|
+
function collectAssignmentAliases(program, resolvedAt, into) {
|
|
171
|
+
walk(program, (node) => {
|
|
172
|
+
if (node.type !== 'AssignmentExpression')
|
|
173
|
+
return;
|
|
174
|
+
if (typeof node.operator !== 'string' || !aliasingAssignmentOperators.has(node.operator))
|
|
175
|
+
return;
|
|
176
|
+
const left = node.left;
|
|
177
|
+
const init = node.right;
|
|
178
|
+
const add = (identifier) => {
|
|
179
|
+
const variable = resolvedAt.get(identifier);
|
|
180
|
+
if (variable)
|
|
181
|
+
into.push({ variable, init, pattern: left, name: identifier });
|
|
182
|
+
};
|
|
183
|
+
if (left?.type === 'Identifier') {
|
|
184
|
+
add(left);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (left?.type !== 'ObjectPattern')
|
|
188
|
+
return;
|
|
189
|
+
for (const property of left.properties ?? []) {
|
|
190
|
+
if (property?.computed === true)
|
|
191
|
+
continue;
|
|
192
|
+
const bound = property?.value?.type === 'AssignmentPattern' ? property.value.left : property?.value;
|
|
193
|
+
if (bound?.type === 'Identifier')
|
|
194
|
+
add(bound);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Whether an expression denotes the `node:module` namespace.
|
|
200
|
+
*
|
|
201
|
+
* Either a name that resolves to a namespace binding, or an awaited `import('node:module')` used
|
|
202
|
+
* directly. The second has no intermediate binding at all, so resolution alone never sees it, and
|
|
203
|
+
* `(await import('node:module')).createRequire(…)` is ordinary syntax rather than indirection.
|
|
204
|
+
*/
|
|
205
|
+
function isNodeModuleNamespace(expression, loaders, resolvedAt) {
|
|
206
|
+
const unwrapped = unwrapAwait(expression);
|
|
207
|
+
if (!unwrapped)
|
|
208
|
+
return false;
|
|
209
|
+
if (unwrapped.type === 'ImportExpression') {
|
|
210
|
+
return unwrapped.source?.type === 'Literal' && unwrapped.source.value === nodeModuleSpecifier;
|
|
211
|
+
}
|
|
212
|
+
if (unwrapped.type !== 'Identifier')
|
|
213
|
+
return false;
|
|
214
|
+
const resolved = resolvedAt.get(unwrapped);
|
|
215
|
+
return resolved ? loaders.get(resolved)?.kind === 'namespace' : false;
|
|
216
|
+
}
|
|
217
|
+
/** A binding introduced by `import … from 'node:module'`, if it carries a loader. */
|
|
218
|
+
function importedLoader(def) {
|
|
219
|
+
const source = def?.parent?.source;
|
|
220
|
+
if (source?.value !== nodeModuleSpecifier)
|
|
221
|
+
return null;
|
|
222
|
+
const specifier = def.node;
|
|
223
|
+
if (specifier?.type === 'ImportSpecifier') {
|
|
224
|
+
const name = specifier.imported?.name;
|
|
225
|
+
return typeof name === 'string' && moduleLoaderExports.has(name)
|
|
226
|
+
? { kind: 'loader', exportName: name }
|
|
227
|
+
: null;
|
|
228
|
+
}
|
|
229
|
+
// A namespace or default import carries every export, loaders included.
|
|
230
|
+
return specifier?.type === 'ImportNamespaceSpecifier' ||
|
|
231
|
+
specifier?.type === 'ImportDefaultSpecifier'
|
|
232
|
+
? { kind: 'namespace' }
|
|
233
|
+
: null;
|
|
234
|
+
}
|
|
235
|
+
/** The ordinary static aliases authors write, resolved through the scope analysis. */
|
|
236
|
+
function aliasedLoader(candidate, loaders, resolvedAt) {
|
|
237
|
+
const init = unwrapAwait(candidate.init);
|
|
238
|
+
if (!init)
|
|
239
|
+
return null;
|
|
240
|
+
const sourceBinding = (identifier) => {
|
|
241
|
+
const resolved = resolvedAt.get(identifier);
|
|
242
|
+
return resolved ? loaders.get(resolved) : undefined;
|
|
243
|
+
};
|
|
244
|
+
// `const m = await import('node:module')`
|
|
245
|
+
if (init.type === 'ImportExpression' && init.source?.value === nodeModuleSpecifier) {
|
|
246
|
+
return patternBinding(candidate, { kind: 'namespace' });
|
|
247
|
+
}
|
|
248
|
+
// `const cr = createRequire` / `const alias = ns` / `const { createRequire: cr } = ns`
|
|
249
|
+
if (init.type === 'Identifier') {
|
|
250
|
+
const binding = sourceBinding(init);
|
|
251
|
+
return binding ? patternBinding(candidate, binding) : null;
|
|
252
|
+
}
|
|
253
|
+
// `const cr = ns.createRequire`, and the same off an awaited import.
|
|
254
|
+
if (init.type === 'MemberExpression' && init.computed !== true) {
|
|
255
|
+
if (!isNodeModuleNamespace(init.object, loaders, resolvedAt))
|
|
256
|
+
return null;
|
|
257
|
+
const name = init.property?.type === 'Identifier' ? init.property.name : undefined;
|
|
258
|
+
return typeof name === 'string' && moduleLoaderExports.has(name)
|
|
259
|
+
? { kind: 'loader', exportName: name }
|
|
260
|
+
: null;
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
/** Applies a source binding to whichever name of the declaration this variable is. */
|
|
265
|
+
function patternBinding(candidate, source) {
|
|
266
|
+
const pattern = candidate.pattern;
|
|
267
|
+
if (pattern?.type === 'Identifier')
|
|
268
|
+
return source;
|
|
269
|
+
if (source.kind !== 'namespace' || pattern?.type !== 'ObjectPattern')
|
|
270
|
+
return null;
|
|
271
|
+
for (const property of pattern.properties ?? []) {
|
|
272
|
+
if (property?.computed === true)
|
|
273
|
+
continue;
|
|
274
|
+
// `const { createRequire: cr = fallback } = ns` binds `cr` inside an assignment pattern.
|
|
275
|
+
const bound = property?.value?.type === 'AssignmentPattern' ? property.value.left : property?.value;
|
|
276
|
+
if (bound !== candidate.name)
|
|
277
|
+
continue;
|
|
278
|
+
const key = property.key?.type === 'Identifier' ? property.key.name : undefined;
|
|
279
|
+
if (typeof key === 'string' && moduleLoaderExports.has(key)) {
|
|
280
|
+
return { kind: 'loader', exportName: key };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The value an initializer ultimately takes.
|
|
287
|
+
*
|
|
288
|
+
* `await import(…)` yields the module; `a = b = createRequire` gives `a` the same value as `b`,
|
|
289
|
+
* because assignment is right-associative and evaluates to its right-hand side; a logical
|
|
290
|
+
* assignment is followed the same way and for the same fail-closed reason; a sequence evaluates to
|
|
291
|
+
* its last expression. Each is ordinary non-computed syntax, so each is followed.
|
|
292
|
+
*/
|
|
293
|
+
function unwrapAwait(value) {
|
|
294
|
+
let current = value;
|
|
295
|
+
for (;;) {
|
|
296
|
+
if (current?.type === 'AwaitExpression') {
|
|
297
|
+
current = current.argument;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (current?.type === 'AssignmentExpression' &&
|
|
301
|
+
aliasingAssignmentOperators.has(current.operator)) {
|
|
302
|
+
current = current.right;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (current?.type === 'SequenceExpression' && Array.isArray(current.expressions)) {
|
|
306
|
+
const last = current.expressions.at(-1);
|
|
307
|
+
if (last) {
|
|
308
|
+
current = last;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return current;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The loader a call invokes, named for the diagnostic, or null.
|
|
317
|
+
*
|
|
318
|
+
* A callee that resolves to a binding is that binding — an author's own `process`, a parameter
|
|
319
|
+
* named `createRequire`, a named function expression called `process`. Only an unresolved name is
|
|
320
|
+
* the global of that name.
|
|
321
|
+
*/
|
|
322
|
+
function calledLoader(callee, loaders, resolvedAt) {
|
|
323
|
+
if (callee.type === 'Identifier') {
|
|
324
|
+
const name = callee.name;
|
|
325
|
+
if (typeof name !== 'string')
|
|
326
|
+
return null;
|
|
327
|
+
const resolved = resolvedAt.get(callee);
|
|
328
|
+
const binding = resolved ? loaders.get(resolved) : undefined;
|
|
329
|
+
if (binding?.kind === 'loader') {
|
|
330
|
+
return binding.exportName === name
|
|
331
|
+
? `"${name}" imported from ${nodeModuleSpecifier}`
|
|
332
|
+
: `"${name}" (${binding.exportName} from ${nodeModuleSpecifier})`;
|
|
333
|
+
}
|
|
334
|
+
if (resolved)
|
|
335
|
+
return null;
|
|
336
|
+
if (name === 'eval')
|
|
337
|
+
return 'the global "eval"';
|
|
338
|
+
if (name === 'Function')
|
|
339
|
+
return 'the Function constructor';
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
if (callee.type !== 'MemberExpression' || callee.computed === true)
|
|
343
|
+
return null;
|
|
344
|
+
const object = callee.object;
|
|
345
|
+
const property = callee.property;
|
|
346
|
+
if (property?.type !== 'Identifier' || typeof property.name !== 'string')
|
|
347
|
+
return null;
|
|
348
|
+
const propertyName = property.name;
|
|
349
|
+
if (isNodeModuleNamespace(object, loaders, resolvedAt) && moduleLoaderExports.has(propertyName)) {
|
|
350
|
+
const receiver = object?.type === 'Identifier' ? String(object.name) : nodeModuleSpecifier;
|
|
351
|
+
return `"${receiver}.${propertyName}" from ${nodeModuleSpecifier}`;
|
|
352
|
+
}
|
|
353
|
+
if (object?.type !== 'Identifier' || typeof object.name !== 'string')
|
|
354
|
+
return null;
|
|
355
|
+
// Only an unresolved name is the global of that name.
|
|
356
|
+
if (resolvedAt.get(object))
|
|
357
|
+
return null;
|
|
358
|
+
if (object.name === 'process' && processLoaderMethods.has(propertyName)) {
|
|
359
|
+
return `"process.${propertyName}"`;
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
function position(node) {
|
|
364
|
+
return node.loc
|
|
365
|
+
? `line ${node.loc.start.line}, column ${node.loc.start.column}`
|
|
366
|
+
: `offset ${node.start}`;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A generic AST walk. Strings and comments are not nodes, which is exactly why the parsed check
|
|
370
|
+
* accepts a prompt containing `eval(` that a text scan would reject.
|
|
371
|
+
*/
|
|
372
|
+
function walk(node, visit) {
|
|
373
|
+
visit(node);
|
|
374
|
+
for (const key of Object.keys(node)) {
|
|
375
|
+
if (key === 'loc' || key === 'type')
|
|
376
|
+
continue;
|
|
377
|
+
const value = node[key];
|
|
378
|
+
if (Array.isArray(value)) {
|
|
379
|
+
for (const entry of value)
|
|
380
|
+
if (isNode(entry))
|
|
381
|
+
walk(entry, visit);
|
|
382
|
+
}
|
|
383
|
+
else if (isNode(value)) {
|
|
384
|
+
walk(value, visit);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function isNode(value) {
|
|
389
|
+
return (typeof value === 'object' &&
|
|
390
|
+
value !== null &&
|
|
391
|
+
typeof value.type === 'string');
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=closed-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closed-bundle.js","sourceRoot":"","sources":["../src/closed-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAExE,uFAAuF;AACvF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,C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b,CAAC,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,YAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE;QAChE,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAS,IAAI,CAAC,IAAe,EAAE,KAAgC;IAC7D,KAAK,CAAC,IAAI,CAAC,CAAC;IACZ,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM;YAAE,SAAS;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,KAAK,IAAI,KAAK;gBAAE,IAAI,MAAM,CAAC,KAAK,CAAC;oBAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnE,CAAC;aAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC"}
|
package/dist/receipt.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { workflowStructureDescriptorVersion } from './structure.js';
|
|
2
|
+
export declare const workflowBuildManifestVersion: 2;
|
|
3
|
+
export declare const supportedWorkflowContractVersion: 4;
|
|
3
4
|
export declare const workflowSdkPackage: '@yourtechbudstudio/isagi-workflow-sdk';
|
|
4
5
|
export declare const workflowVerifierPackage: '@yourtechbudstudio/isagi-workflow-verifier';
|
|
5
|
-
export declare const workflowSdkVersion: '0.0
|
|
6
|
-
export declare const workflowVerifierVersion: '0.0
|
|
6
|
+
export declare const workflowSdkVersion: '0.1.0';
|
|
7
|
+
export declare const workflowVerifierVersion: '0.1.0';
|
|
7
8
|
export declare const workflowBuilderPackage: 'esbuild';
|
|
8
9
|
export declare const workflowBuilderVersion: '0.28.0';
|
|
9
10
|
export declare const workflowBuildCommand: 'esbuild src/index.ts --bundle --format=esm --platform=node --target=node22 --log-override:unsupported-dynamic-import=error --outfile=dist/index.js';
|
|
@@ -27,6 +28,17 @@ export interface WorkflowBuildManifest {
|
|
|
27
28
|
readonly entry: 'dist/index.js';
|
|
28
29
|
readonly sha256: string;
|
|
29
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* The structure the artifact actually declares. The runtime re-derives this from the imported
|
|
33
|
+
* bundle and compares hashes, so an edited receipt cannot describe a different graph than the one
|
|
34
|
+
* that will execute.
|
|
35
|
+
*/
|
|
36
|
+
readonly structure: {
|
|
37
|
+
readonly descriptorVersion: typeof workflowStructureDescriptorVersion;
|
|
38
|
+
readonly sha256: string;
|
|
39
|
+
readonly rootGraphKey: string;
|
|
40
|
+
readonly graphCount: number;
|
|
41
|
+
};
|
|
30
42
|
}
|
|
31
43
|
export interface HashInput {
|
|
32
44
|
readonly path: string;
|
package/dist/receipt.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
export const
|
|
2
|
+
import { workflowStructureDescriptorVersion } from './structure.js';
|
|
3
|
+
export const workflowBuildManifestVersion = 2;
|
|
4
|
+
export const supportedWorkflowContractVersion = 4;
|
|
4
5
|
export const workflowSdkPackage = '@yourtechbudstudio/isagi-workflow-sdk';
|
|
5
6
|
export const workflowVerifierPackage = '@yourtechbudstudio/isagi-workflow-verifier';
|
|
6
|
-
export const workflowSdkVersion = '0.0
|
|
7
|
-
export const workflowVerifierVersion = '0.0
|
|
7
|
+
export const workflowSdkVersion = '0.1.0';
|
|
8
|
+
export const workflowVerifierVersion = '0.1.0';
|
|
8
9
|
export const workflowBuilderPackage = 'esbuild';
|
|
9
10
|
export const workflowBuilderVersion = '0.28.0';
|
|
10
11
|
export const workflowBuildCommand = 'esbuild src/index.ts --bundle --format=esm --platform=node --target=node22 --log-override:unsupported-dynamic-import=error --outfile=dist/index.js';
|
|
@@ -55,7 +56,15 @@ export function serializeWorkflowBuildManifest(manifest) {
|
|
|
55
56
|
export function parseWorkflowBuildManifest(input) {
|
|
56
57
|
if (!isRecord(input))
|
|
57
58
|
throw new Error('Build manifest must be an object.');
|
|
58
|
-
assertExactKeys(input, [
|
|
59
|
+
assertExactKeys(input, [
|
|
60
|
+
'manifestVersion',
|
|
61
|
+
'workflowContractVersion',
|
|
62
|
+
'sdk',
|
|
63
|
+
'verifier',
|
|
64
|
+
'source',
|
|
65
|
+
'artifact',
|
|
66
|
+
'structure',
|
|
67
|
+
], 'manifest');
|
|
59
68
|
if (input.manifestVersion !== workflowBuildManifestVersion)
|
|
60
69
|
throw new Error(`Unsupported manifestVersion ${JSON.stringify(input.manifestVersion)}; this verifier supports ${workflowBuildManifestVersion}.`);
|
|
61
70
|
if (input.workflowContractVersion !== supportedWorkflowContractVersion)
|
|
@@ -71,6 +80,7 @@ export function parseWorkflowBuildManifest(input) {
|
|
|
71
80
|
const artifactHash = requiredString(input.artifact.sha256, 'artifact.sha256');
|
|
72
81
|
if (!sha256Pattern.test(artifactHash))
|
|
73
82
|
throw new Error('artifact.sha256 must be a lowercase SHA-256 digest.');
|
|
83
|
+
const structure = structureIdentity(input.structure);
|
|
74
84
|
return {
|
|
75
85
|
manifestVersion: workflowBuildManifestVersion,
|
|
76
86
|
workflowContractVersion: supportedWorkflowContractVersion,
|
|
@@ -78,6 +88,7 @@ export function parseWorkflowBuildManifest(input) {
|
|
|
78
88
|
verifier,
|
|
79
89
|
source,
|
|
80
90
|
artifact: { entry: 'dist/index.js', sha256: artifactHash },
|
|
91
|
+
structure,
|
|
81
92
|
};
|
|
82
93
|
}
|
|
83
94
|
export function parseWorkflowBuildManifestJson(json) {
|
|
@@ -96,6 +107,25 @@ function packageIdentity(value, field, expectedName) {
|
|
|
96
107
|
throw new Error(`${field}.name must be ${expectedName}.`);
|
|
97
108
|
return { name: expectedName, version: requiredString(value.version, `${field}.version`) };
|
|
98
109
|
}
|
|
110
|
+
function structureIdentity(value) {
|
|
111
|
+
if (!isRecord(value))
|
|
112
|
+
throw new Error('structure must be an object.');
|
|
113
|
+
assertExactKeys(value, ['descriptorVersion', 'sha256', 'rootGraphKey', 'graphCount'], 'structure');
|
|
114
|
+
if (value.descriptorVersion !== workflowStructureDescriptorVersion)
|
|
115
|
+
throw new Error(`Unsupported structure.descriptorVersion ${JSON.stringify(value.descriptorVersion)}; this verifier supports ${workflowStructureDescriptorVersion}.`);
|
|
116
|
+
const sha256 = requiredString(value.sha256, 'structure.sha256');
|
|
117
|
+
if (!sha256Pattern.test(sha256))
|
|
118
|
+
throw new Error('structure.sha256 must be a lowercase SHA-256 digest.');
|
|
119
|
+
const graphCount = value.graphCount;
|
|
120
|
+
if (typeof graphCount !== 'number' || !Number.isInteger(graphCount) || graphCount < 1)
|
|
121
|
+
throw new Error('structure.graphCount must be a positive integer.');
|
|
122
|
+
return {
|
|
123
|
+
descriptorVersion: workflowStructureDescriptorVersion,
|
|
124
|
+
sha256,
|
|
125
|
+
rootGraphKey: requiredString(value.rootGraphKey, 'structure.rootGraphKey'),
|
|
126
|
+
graphCount,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
99
129
|
function digestObject(value, field) {
|
|
100
130
|
if (!isRecord(value))
|
|
101
131
|
throw new Error(`${field} must be an object.`);
|
package/dist/receipt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receipt.js","sourceRoot":"","sources":["../src/receipt.ts"],"names":[],"mappings":"AAAA,OAA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AAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,sBAAsB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9E,CAAC;IACF,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC;AACD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single structural inspection algorithm, shared by the verifier CLI, the runtime loader, and
|
|
3
|
+
* tests. It is pure: it never calls `init`, `run`, `choose`, `parameters`, `onResult`, `output`, or
|
|
4
|
+
* `label`. It only reads plain data off an already-imported module object.
|
|
5
|
+
*
|
|
6
|
+
* Importing a bundle still executes trusted module-level JavaScript. This is a structural contract
|
|
7
|
+
* check, not sandboxed static analysis of untrusted source.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workflowStructureDescriptorVersion: 1;
|
|
10
|
+
export interface WorkflowStructureDescriptor {
|
|
11
|
+
readonly descriptorVersion: typeof workflowStructureDescriptorVersion;
|
|
12
|
+
readonly workflowContractVersion: 4;
|
|
13
|
+
readonly rootGraphKey: string;
|
|
14
|
+
/** Sorted by key, so one structure always canonicalizes to the same bytes. */
|
|
15
|
+
readonly graphs: readonly GraphDescriptor[];
|
|
16
|
+
}
|
|
17
|
+
export interface GraphDescriptor {
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly intent?: 'business' | 'logical' | 'operational';
|
|
22
|
+
readonly stateFields: readonly string[];
|
|
23
|
+
readonly entry: string;
|
|
24
|
+
readonly nodes: readonly NodeDescriptor[];
|
|
25
|
+
readonly edges: readonly EdgeDescriptor[];
|
|
26
|
+
readonly outcomes: readonly OutcomeDescriptor[];
|
|
27
|
+
}
|
|
28
|
+
export type NodeDescriptor = {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly kind: 'operation';
|
|
31
|
+
readonly title?: string;
|
|
32
|
+
readonly description?: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly kind: 'subgraph';
|
|
36
|
+
readonly graphKey: string;
|
|
37
|
+
readonly title?: string;
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly kind: 'checkpoint';
|
|
42
|
+
readonly title?: string;
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
};
|
|
45
|
+
export interface EdgeDescriptor {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly from: string;
|
|
48
|
+
/** The author's declared order, which is descriptive only. Duplicates are a diagnostic. */
|
|
49
|
+
readonly to: readonly string[];
|
|
50
|
+
readonly title?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface OutcomeDescriptor {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly kind: 'success' | 'failure';
|
|
55
|
+
readonly reason?: string;
|
|
56
|
+
readonly title?: string;
|
|
57
|
+
}
|
|
58
|
+
export type StructureDiagnosticCode = 'invalid_export' | 'unsupported_contract' | 'missing_callback' | 'invalid_identifier' | 'missing_title' | 'invalid_intent' | 'missing_init' | 'invalid_state_field' | 'empty_state' | 'empty_graph' | 'identifier_collision' | 'unknown_node_kind' | 'subgraph_missing_graph' | 'missing_entry' | 'entry_not_executable' | 'edge_source_unknown' | 'duplicate_edge_source' | 'missing_outgoing_edge' | 'empty_destination_set' | 'duplicate_destination' | 'edge_destination_unknown' | 'no_outcomes' | 'invalid_label' | 'duplicate_graph_key' | 'recursive_graph_containment' | 'too_many_graphs' | 'too_many_nodes' | 'too_many_edges' | 'too_many_outcomes' | 'containment_too_deep' | 'deferred_executable_dependency' | 'graph_missing' | 'subgraph_registration_changed' | 'node_missing' | 'node_kind_changed' | 'edge_identity_changed' | 'destination_no_longer_declared' | 'outcome_missing' | 'outcome_kind_changed';
|
|
59
|
+
export interface StructureDiagnosticLocation {
|
|
60
|
+
readonly graphKey?: string;
|
|
61
|
+
readonly nodeId?: string;
|
|
62
|
+
readonly edgeId?: string;
|
|
63
|
+
readonly outcomeId?: string;
|
|
64
|
+
readonly field?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface StructureDiagnostic {
|
|
67
|
+
readonly code: StructureDiagnosticCode;
|
|
68
|
+
readonly message: string;
|
|
69
|
+
readonly at: StructureDiagnosticLocation;
|
|
70
|
+
}
|
|
71
|
+
export type StructureResult = {
|
|
72
|
+
readonly ok: true;
|
|
73
|
+
readonly descriptor: WorkflowStructureDescriptor;
|
|
74
|
+
} | {
|
|
75
|
+
readonly ok: false;
|
|
76
|
+
readonly diagnostics: readonly StructureDiagnostic[];
|
|
77
|
+
};
|
|
78
|
+
export declare function describeWorkflowModule(moduleNamespace: unknown): StructureResult;
|
|
79
|
+
/**
|
|
80
|
+
* Writes the descriptor with a fixed key order, already-sorted arrays, and absent optional keys
|
|
81
|
+
* omitted, so the verifier and the runtime loader hash identical bytes for identical structure.
|
|
82
|
+
*/
|
|
83
|
+
export declare function canonicalizeDescriptor(descriptor: WorkflowStructureDescriptor): string;
|
|
84
|
+
export declare function hashDescriptor(descriptor: WorkflowStructureDescriptor): string;
|