@yourtechbudstudio/isagi-workflow-verifier 0.0.1 → 0.1.1

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 CHANGED
@@ -1,7 +1,201 @@
1
- ISC License
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
2
4
 
3
- Copyright (c) 2026 YourTechBud
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
6
 
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
7
+ 1. Definitions.
6
8
 
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -6,12 +6,12 @@ Verify an already-built Isagi workflow package and write its build receipt:
6
6
  isagi-workflow-verify --workflow .
7
7
  ```
8
8
 
9
- The verifier has one job: raise the probability that the Isagi runtime loads the workflow build without errors. It checks ahead of time exactly what the runtime checks at load time — exact SDK and verifier pins, symlink-free sources, and a `dist/index.js` bundle that default-exports a loadable workflow definition with a valid `command()` manifest (validated in a bounded child process). When every gate passes it fingerprints the sources and the artifact into `dist/isagi-workflow-build.json`; the runtime re-checks that receipt and refuses to run a workflow whose source or artifact no longer matches it. How the package installs dependencies is deliberately outside this contract.
9
+ The verifier has one job: raise the probability that the Isagi runtime loads the workflow build without errors. It checks ahead of time what the runtime checks at load time — exact SDK and verifier pins, symlink-free sources, a `dist/index.js` bundle that default-exports a loadable workflow definition, and a structurally valid graph — and also that `command()` returns a valid manifest, importing the bundle in a bounded child process. When every gate passes it fingerprints the sources, the artifact, and the declared structure into `dist/isagi-workflow-build.json`; the runtime re-checks that receipt and refuses to run a workflow whose source or artifact no longer matches it. How the package installs dependencies is deliberately outside this contract.
10
10
 
11
- The workflow package owns compilation and quality. Run the canonical `build` script before verification, and run your own `typecheck` and `test` scripts before that: the verifier never compiles, installs dependencies, or runs package scripts, and it does not gate on tests. The current versions are `@yourtechbudstudio/isagi-workflow-sdk@0.0.1`, `@yourtechbudstudio/isagi-workflow-verifier@0.0.1`, and `esbuild@0.28.0`. For the full authoring guide, use Isagi's installed `isagi-docs` skill.
11
+ The workflow package owns compilation and quality. Run the canonical `build` script before verification, and run your own `typecheck` and `test` scripts before that: the verifier never compiles, installs dependencies, or runs package scripts, and it does not gate on tests. The current versions are `@yourtechbudstudio/isagi-workflow-sdk@0.1.1`, `@yourtechbudstudio/isagi-workflow-verifier@0.1.1`, and `esbuild@0.28.0`. For the full authoring guide, use Isagi's installed `isagi-docs` skill.
12
12
 
13
13
  ## Trust boundary
14
14
 
15
- A verified artifact is self-contained with respect to its statically discoverable package import graph. Workflows remain trusted Node.js code and may intentionally access runtime files, processes, network resources, and Node built-ins. Verification is lifecycle containment, not a sandbox.
15
+ The verifier imports a copy of `dist/index.js` on its own, from an empty temporary directory, in a child process with a time limit and an output limit, so a bundle whose top-level imports still name a package it did not inline fails verification. It checks that the workflow loads and declares a valid shape; it does not inspect what the workflow code does. Workflows remain trusted Node.js code and may intentionally access runtime files, processes, network resources, and Node built-ins. Verification is lifecycle containment, not a sandbox.
16
16
 
17
- The `./receipt` export contains pure manifest parsing, canonical serialization, path policy, compatibility constants, and hash primitives for consumers that need to check a receipt without executing verifier operations.
17
+ The `./receipt` export contains pure manifest parsing, canonical serialization, path policy, compatibility constants, and hash primitives for consumers that need to check a receipt without executing verifier operations. The `./structure` export contains the single structural inspection algorithm — descriptor extraction, validation diagnostics, canonicalization, and hashing — which the Isagi runtime re-runs against the imported artifact so a receipt cannot describe a different graph than the one that executes. It also exports the `command()` manifest check the verifier applies.
package/dist/cli.d.ts CHANGED
@@ -13,9 +13,9 @@ export interface ProcessResult {
13
13
  export type ProcessRunner = (spec: ProcessSpec) => Promise<ProcessResult>;
14
14
  export declare function runProcess(spec: ProcessSpec): Promise<ProcessResult>;
15
15
  /**
16
- * The verifier front-runs the runtime loader: every gate here mirrors a check the Isagi runtime
17
- * performs before importing a workflow, so failures surface at authoring time instead of load
18
- * time. Quality gates (typecheck, tests) are deliberately absent — they are the author's
16
+ * The verifier front-runs the runtime loader: its gates mirror the checks the Isagi runtime
17
+ * performs before importing a workflow, and it also checks the command() manifest, so failures
18
+ * surface at authoring time instead of load or launch time. Quality gates (typecheck, tests) are deliberately absent — they are the author's
19
19
  * responsibility and do not affect whether the runtime can load the artifact.
20
20
  */
21
21
  export declare function verifyWorkflow(workflowArgument: string, runner?: ProcessRunner): Promise<void>;
package/dist/cli.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from 'node:child_process';
3
3
  import { randomUUID } from 'node:crypto';
4
- import { lstat, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
4
+ import { lstat, mkdtemp, readFile, readdir, rename, rm, stat, unlink, writeFile, } from 'node:fs/promises';
5
5
  import { tmpdir } from 'node:os';
6
- import { join, resolve } from 'node:path';
7
- import { pathToFileURL } from 'node:url';
6
+ import { dirname, join, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
8
  import { hashArtifact, hashWorkflowInputs, isWorkflowSourcePath, serializeWorkflowBuildManifest, supportedWorkflowContractVersion, workflowBuildManifestVersion, workflowSdkPackage, workflowSdkVersion, workflowVerifierPackage, workflowVerifierVersion, } from './receipt.js';
9
+ import { hashDescriptor, } from './structure.js';
9
10
  const outputLimit = 128 * 1024;
10
11
  const subprocessTimeoutMs = 120_000;
11
12
  class VerificationError extends Error {
@@ -83,19 +84,23 @@ function terminateTree(pid) {
83
84
  }, 1_000).unref();
84
85
  }
85
86
  /**
86
- * The verifier front-runs the runtime loader: every gate here mirrors a check the Isagi runtime
87
- * performs before importing a workflow, so failures surface at authoring time instead of load
88
- * time. Quality gates (typecheck, tests) are deliberately absent — they are the author's
87
+ * The verifier front-runs the runtime loader: its gates mirror the checks the Isagi runtime
88
+ * performs before importing a workflow, and it also checks the command() manifest, so failures
89
+ * surface at authoring time instead of load or launch time. Quality gates (typecheck, tests) are deliberately absent — they are the author's
89
90
  * responsibility and do not affect whether the runtime can load the artifact.
90
91
  */
91
92
  export async function verifyWorkflow(workflowArgument, runner = runProcess) {
92
93
  const root = resolve(workflowArgument);
94
+ // Remove any receipt an earlier run left behind before any work that can fail, so a failed
95
+ // verification can never leave a previous success standing as if it certified this attempt. The
96
+ // explicit --workflow argument already scopes this to one path, and nothing else is touched.
97
+ await removeStaleReceipt(root);
93
98
  const packageJson = await readPackageJson(root);
94
99
  requirePins(packageJson);
95
100
  const sourceHash = hashWorkflowInputs(await readSourceInputs(root));
96
101
  const artifactPath = join(root, 'dist', 'index.js');
97
102
  const artifactBytes = await readArtifact(artifactPath);
98
- await validateArtifact(root, artifactPath, runner);
103
+ const descriptor = await validateArtifact(root, artifactPath, runner);
99
104
  const manifest = {
100
105
  manifestVersion: workflowBuildManifestVersion,
101
106
  workflowContractVersion: supportedWorkflowContractVersion,
@@ -103,8 +108,56 @@ export async function verifyWorkflow(workflowArgument, runner = runProcess) {
103
108
  verifier: { name: workflowVerifierPackage, version: workflowVerifierVersion },
104
109
  source: { sha256: sourceHash },
105
110
  artifact: { entry: 'dist/index.js', sha256: hashArtifact(artifactBytes) },
111
+ structure: {
112
+ descriptorVersion: descriptor.descriptorVersion,
113
+ sha256: hashDescriptor(descriptor),
114
+ rootGraphKey: descriptor.rootGraphKey,
115
+ graphCount: descriptor.graphs.length,
116
+ },
106
117
  };
107
- await writeReceipt(root, manifest);
118
+ await writeAtomic(join(root, 'dist', 'isagi-workflow-build.json'), serializeWorkflowBuildManifest(manifest), 'the build receipt');
119
+ }
120
+ function receiptPath(root) {
121
+ return join(root, 'dist', 'isagi-workflow-build.json');
122
+ }
123
+ async function removeStaleReceipt(root) {
124
+ try {
125
+ await unlink(receiptPath(root));
126
+ }
127
+ catch (cause) {
128
+ // Absence is the normal case. Anything else — a permission problem, a directory in its place —
129
+ // must fail here rather than leave a misleading receipt in reach.
130
+ if (cause.code === 'ENOENT')
131
+ return;
132
+ throw new VerificationError(`Could not remove the previous build receipt ${receiptPath(root)}: ${message(cause)}`);
133
+ }
134
+ }
135
+ function formatDiagnostics(diagnostics) {
136
+ return diagnostics
137
+ .map((diagnostic) => {
138
+ const at = [
139
+ diagnostic.at.graphKey && `graph ${diagnostic.at.graphKey}`,
140
+ diagnostic.at.nodeId && `node ${diagnostic.at.nodeId}`,
141
+ diagnostic.at.edgeId && `edge ${diagnostic.at.edgeId}`,
142
+ diagnostic.at.outcomeId && `outcome ${diagnostic.at.outcomeId}`,
143
+ diagnostic.at.field && `field ${diagnostic.at.field}`,
144
+ ]
145
+ .filter(Boolean)
146
+ .join(' · ');
147
+ return ` [${diagnostic.code}]${at ? ` ${at}:` : ''} ${diagnostic.message}`;
148
+ })
149
+ .join('\n');
150
+ }
151
+ async function writeAtomic(path, contents, what) {
152
+ const temporary = `${path}.${randomUUID()}.tmp`;
153
+ try {
154
+ await writeFile(temporary, contents, { flag: 'wx' });
155
+ await rename(temporary, path);
156
+ }
157
+ catch (cause) {
158
+ await rm(temporary, { force: true }).catch(() => undefined);
159
+ throw new VerificationError(`Could not write ${what} ${path}: ${message(cause)}`);
160
+ }
108
161
  }
109
162
  async function readPackageJson(root) {
110
163
  const path = join(root, 'package.json');
@@ -198,10 +251,10 @@ async function readArtifact(path) {
198
251
  return readFile(path);
199
252
  }
200
253
  /**
201
- * Imports the built artifact in an isolated child process the way the runtime loader will, and
202
- * checks the exported workflow definition and its command() manifest. The child reports through a
203
- * result file rather than stdout, so workflow code that logs during import or command() cannot
204
- * corrupt the report.
254
+ * Imports the built artifact in an isolated child process the way the runtime loader will, reads
255
+ * its declared structure, and checks the exported workflow definition and its command() manifest.
256
+ * The child (`validate-artifact.ts`) reports through a result file rather than stdout, so workflow
257
+ * code that logs during import or command() cannot corrupt the report.
205
258
  */
206
259
  async function validateArtifact(root, artifact, runner) {
207
260
  const isolatedRoot = await mkdtemp(join(tmpdir(), 'isagi-workflow-validation-'));
@@ -209,12 +262,10 @@ async function validateArtifact(root, artifact, runner) {
209
262
  const isolatedArtifact = join(isolatedRoot, 'index.mjs');
210
263
  await writeFile(isolatedArtifact, await readFile(artifact));
211
264
  const resultPath = join(isolatedRoot, 'result.json');
212
- const validatorPath = join(isolatedRoot, 'validate.mjs');
213
- await writeFile(validatorPath, validatorSource(isolatedArtifact, resultPath, root));
214
265
  try {
215
266
  await runner({
216
267
  command: process.execPath,
217
- args: [validatorPath],
268
+ args: [validatorPath(), isolatedArtifact, resultPath, root],
218
269
  cwd: isolatedRoot,
219
270
  timeoutMs: 10_000,
220
271
  });
@@ -229,62 +280,32 @@ async function validateArtifact(root, artifact, runner) {
229
280
  catch {
230
281
  throw new VerificationError('dist/index.js failed the artifact check: the bundle terminated the validation process (for example via process.exit) before the check finished. Workflow code must not exit the process.');
231
282
  }
232
- if (!report || typeof report !== 'object' || report.ok !== true)
233
- throw new VerificationError(`dist/index.js failed the artifact check that mirrors how the Isagi runtime loads workflows:\n${String(report?.error ?? 'The validation report is malformed.')}\nFix the workflow source, rebuild, and re-run verification.`);
283
+ if (!report || typeof report !== 'object' || report.ok !== true) {
284
+ const diagnostics = report?.diagnostics;
285
+ const detail = Array.isArray(diagnostics) && diagnostics.length > 0
286
+ ? formatDiagnostics(diagnostics)
287
+ : String(report?.error ?? 'The validation report is malformed.');
288
+ throw new VerificationError(`dist/index.js failed the artifact check that mirrors how the Isagi runtime loads workflows:\n${detail}\nFix the workflow source, rebuild, and re-run verification.`);
289
+ }
290
+ // The child returns the descriptor as data. The parent canonicalizes and hashes it itself
291
+ // rather than trusting a hash produced inside the process that imported workflow code.
292
+ const descriptor = report.descriptor;
293
+ if (!descriptor || typeof descriptor !== 'object') {
294
+ throw new VerificationError('dist/index.js failed the artifact check: the validation process reported success without a structure description.');
295
+ }
296
+ return descriptor;
234
297
  }
235
298
  finally {
236
299
  await rm(isolatedRoot, { recursive: true, force: true });
237
300
  }
238
301
  }
239
- function validatorSource(artifactPath, resultPath, worktreePath) {
240
- return [
241
- `import { writeFileSync } from 'node:fs';`,
242
- `const finish = (report) => { writeFileSync(${JSON.stringify(resultPath)}, JSON.stringify(report)); process.exit(0); };`,
243
- `const describe = (value) => (Array.isArray(value) ? 'an array' : value === null ? 'null' : typeof value);`,
244
- `const cause = (error) => String((error && error.stack) || error);`,
245
- `let artifact;`,
246
- `try { artifact = await import(${JSON.stringify(pathToFileURL(artifactPath).href)}); }`,
247
- `catch (error) { finish({ ok: false, error: 'Importing the bundle threw before any workflow definition could be read:\\n' + cause(error) }); }`,
248
- `const workflow = artifact.default;`,
249
- `if (!workflow || typeof workflow !== 'object') finish({ ok: false, error: 'The bundle must default-export the workflow definition object returned by defineWorkflow(); its default export is ' + describe(workflow) + '.' });`,
250
- `const missing = ['command', 'validate', 'init', 'step'].filter((name) => typeof workflow[name] !== 'function');`,
251
- `if (missing.length) finish({ ok: false, error: 'The default-exported workflow definition is missing required function(s): ' + missing.join(', ') + '. Default-export the object returned by defineWorkflow() from src/index.ts.' });`,
252
- `let manifest;`,
253
- `try { manifest = await workflow.command({ worktreeId: 0, worktreePath: ${JSON.stringify(worktreePath)}, surfaceId: 0, paneId: null, agentSessionId: null }); }`,
254
- `catch (error) { finish({ ok: false, error: 'command() threw when called with a minimal launch context. command() must succeed without optional pane or agent-session context.\\n' + cause(error) }); }`,
255
- `const problems = [];`,
256
- `if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) problems.push('command() must return a manifest object; it returned ' + describe(manifest) + '.');`,
257
- `else {`,
258
- ` if (typeof manifest.title !== 'string' || !manifest.title) problems.push('command() must return a manifest with a non-empty string title; found ' + describe(manifest.title) + '.');`,
259
- ` if (manifest.description !== undefined && typeof manifest.description !== 'string') problems.push('command() manifest description must be a string when present; found ' + describe(manifest.description) + '.');`,
260
- ` if (manifest.inputs !== undefined && !Array.isArray(manifest.inputs)) problems.push('command() manifest inputs must be an array when present; found ' + describe(manifest.inputs) + '.');`,
261
- ` for (const [index, input] of (Array.isArray(manifest.inputs) ? manifest.inputs : []).entries()) {`,
262
- ` const where = 'inputs[' + index + ']' + (input && typeof input.key === 'string' && input.key ? ' (key "' + input.key + '")' : '');`,
263
- ` if (!input || typeof input !== 'object') { problems.push('command() ' + where + ' must be an input object; found ' + describe(input) + '.'); continue; }`,
264
- ` if (!['text', 'select', 'multi-select', 'confirm'].includes(input.kind)) problems.push('command() ' + where + ' has kind ' + JSON.stringify(input.kind) + '; expected "text", "select", "multi-select", or "confirm".');`,
265
- ` if (typeof input.key !== 'string' || !input.key) problems.push('command() ' + where + ' needs a non-empty string key.');`,
266
- ` if (typeof input.label !== 'string' || !input.label) problems.push('command() ' + where + ' needs a non-empty string label.');`,
267
- ` if (input.kind === 'select' || input.kind === 'multi-select') {`,
268
- ` if (!Array.isArray(input.options)) problems.push('command() ' + where + ' is a ' + input.kind + ' input and needs an options array.');`,
269
- ` else for (const [optionIndex, option] of input.options.entries()) if (!option || typeof option.value !== 'string') problems.push('command() ' + where + ' options[' + optionIndex + '] needs a string value.');`,
270
- ` }`,
271
- ` }`,
272
- `}`,
273
- `finish(problems.length ? { ok: false, error: problems.join('\\n') } : { ok: true });`,
274
- ``,
275
- ].join('\n');
276
- }
277
- async function writeReceipt(root, manifest) {
278
- const receiptPath = join(root, 'dist', 'isagi-workflow-build.json');
279
- const temporary = `${receiptPath}.${randomUUID()}.tmp`;
280
- try {
281
- await writeFile(temporary, serializeWorkflowBuildManifest(manifest), { flag: 'wx' });
282
- await rename(temporary, receiptPath);
283
- }
284
- catch (cause) {
285
- await rm(temporary, { force: true }).catch(() => undefined);
286
- throw new VerificationError(`Could not write the build receipt ${receiptPath}: ${message(cause)}`);
287
- }
302
+ /**
303
+ * The installed validation child (`validate-artifact.ts`), resolved as a real file path next to
304
+ * this module so a packed installation works outside this monorepo. CLI integration tests therefore
305
+ * run against the built CLI, whose sibling is `dist`.
306
+ */
307
+ function validatorPath() {
308
+ return join(dirname(fileURLToPath(import.meta.url)), 'validate-artifact.js');
288
309
  }
289
310
  async function exists(path) {
290
311
  try {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,EAC9B,gCAAgC,EAChC,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GAGxB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/B,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAcpC,MAAM,iBAAkB,SAAQ,KAAK;CAAG;AAExC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAiB;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,KAAK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ACnD,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC;AAC/E,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AACD,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,IAAI,iBAAiB,CAAC,2DAA2D,CAAC,CAAC;IAC3F,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;AACvE,CAAC"}
package/dist/receipt.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- export declare const workflowBuildManifestVersion: 1;
2
- export declare const supportedWorkflowContractVersion: 1;
1
+ import { workflowStructureDescriptorVersion } from './structure.js';
2
+ export declare const workflowBuildManifestVersion: 2;
3
+ export declare const supportedWorkflowContractVersion: 5;
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.1';
6
- export declare const workflowVerifierVersion: '0.0.1';
6
+ export declare const workflowSdkVersion: '0.1.1';
7
+ export declare const workflowVerifierVersion: '0.1.1';
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
- export const workflowBuildManifestVersion = 1;
3
- export const supportedWorkflowContractVersion = 1;
2
+ import { workflowStructureDescriptorVersion } from './structure.js';
3
+ export const workflowBuildManifestVersion = 2;
4
+ export const supportedWorkflowContractVersion = 5;
4
5
  export const workflowSdkPackage = '@yourtechbudstudio/isagi-workflow-sdk';
5
6
  export const workflowVerifierPackage = '@yourtechbudstudio/isagi-workflow-verifier';
6
- export const workflowSdkVersion = '0.0.1';
7
- export const workflowVerifierVersion = '0.0.1';
7
+ export const workflowSdkVersion = '0.1.1';
8
+ export const workflowVerifierVersion = '0.1.1';
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, ['manifestVersion', 'workflowContractVersion', 'sdk', 'verifier', 'source', 'artifact'], 'manifest');
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.`);