@interf/compiler 0.16.0 → 0.21.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.md +1 -0
- package/README.md +90 -73
- package/TRADEMARKS.md +4 -4
- package/dist/cli/commands/mcp.d.ts +0 -34
- package/dist/cli/commands/mcp.js +246 -45
- package/dist/cli/commands/method.js +261 -15
- package/dist/cli/commands/prep.js +116 -15
- package/dist/cli/commands/runs.js +103 -9
- package/dist/cli/commands/status.js +4 -2
- package/dist/cli/commands/test.d.ts +10 -0
- package/dist/cli/commands/{verify.js → test.js} +24 -17
- package/dist/cli/commands/web.js +82 -8
- package/dist/cli/commands/wizard.js +158 -51
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +3 -3
- package/dist/compiler-ui/404.html +1 -1
- package/dist/compiler-ui/__next.__PAGE__.txt +5 -5
- package/dist/compiler-ui/__next._full.txt +13 -12
- package/dist/compiler-ui/__next._head.txt +3 -3
- package/dist/compiler-ui/__next._index.txt +5 -4
- package/dist/compiler-ui/__next._tree.txt +4 -3
- package/dist/compiler-ui/_next/static/chunks/01646j7yi.w5a.css +1 -0
- package/dist/compiler-ui/_next/static/chunks/{0n51hrfoufc7g.js → 02f_.8.ebn556.js} +1 -1
- package/dist/compiler-ui/_next/static/chunks/02r7siaw-_p5w.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/{08m7vf5asqlsm.js → 04d0ly-7xb~-j.js} +10 -10
- package/dist/compiler-ui/_next/static/chunks/0fhs9psnxqd8s.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/0mssmhpbifj15.css +2 -0
- package/dist/compiler-ui/_next/static/chunks/0nypu~ddwxari.js +116 -0
- package/dist/compiler-ui/_next/static/chunks/0p3s8iyhgcww2.js +31 -0
- package/dist/compiler-ui/_next/static/chunks/0tjf-vu_rz8s0.css +1 -0
- package/dist/compiler-ui/_next/static/chunks/0u6p3fpbbfgtl.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/0wpx5..8dnh0w.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/0y0uj160p0ts~.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/10t8l~_oenf.c.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/13gz9e7z~imx1.js +5 -0
- package/dist/compiler-ui/_next/static/chunks/156xed-b6czaw.js +1 -0
- package/dist/compiler-ui/_next/static/chunks/{turbopack-0.uq1k8c0j4s..js → turbopack-02-3e_c-yz~5g.js} +1 -1
- package/dist/compiler-ui/_next/static/chunks/{turbopack-10e~t1yzi4svj.js → turbopack-0apv8vb-nczuy.js} +1 -1
- package/dist/compiler-ui/_not-found/__next._full.txt +10 -9
- package/dist/compiler-ui/_not-found/__next._head.txt +3 -3
- package/dist/compiler-ui/_not-found/__next._index.txt +5 -4
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._not-found.txt +3 -3
- package/dist/compiler-ui/_not-found/__next._tree.txt +3 -2
- package/dist/compiler-ui/_not-found.html +1 -1
- package/dist/compiler-ui/_not-found.txt +10 -9
- package/dist/compiler-ui/index.html +1 -1
- package/dist/compiler-ui/index.txt +13 -12
- package/dist/packages/contracts/index.d.ts +2 -2
- package/dist/packages/contracts/index.js +1 -1
- package/dist/packages/contracts/lib/schema.d.ts +275 -72
- package/dist/packages/contracts/lib/schema.js +244 -83
- package/dist/packages/engine/action-definitions.d.ts +174 -13
- package/dist/packages/engine/action-definitions.js +125 -122
- package/dist/packages/engine/action-planner.js +4 -11
- package/dist/packages/engine/agents/lib/shells.d.ts +15 -5
- package/dist/packages/engine/agents/lib/shells.js +134 -123
- package/dist/packages/engine/agents/role-executors.js +1 -1
- package/dist/packages/engine/cloud-seams.d.ts +115 -0
- package/dist/packages/engine/cloud-seams.js +84 -0
- package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
- package/dist/packages/engine/compile/artifact-counts.js +3 -3
- package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
- package/dist/packages/engine/compile/artifact-status.js +166 -0
- package/dist/packages/engine/compile/billing-events.d.ts +89 -0
- package/dist/packages/engine/compile/billing-events.js +74 -0
- package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
- package/dist/packages/engine/compile/check-evaluator.js +298 -0
- package/dist/packages/engine/compile/compiled-paths.js +6 -6
- package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
- package/dist/packages/engine/compile/compiled-schema.js +55 -70
- package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
- package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
- package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
- package/dist/packages/engine/compile/index.d.ts +0 -1
- package/dist/packages/engine/compile/index.js +0 -1
- package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
- package/dist/packages/engine/compile/lib/schema.js +35 -39
- package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
- package/dist/packages/engine/compile/method-primitives.js +1 -1
- package/dist/packages/engine/compile/reset.js +4 -4
- package/dist/packages/engine/compile/runtime-contracts.js +2 -1
- package/dist/packages/engine/compile/runtime-prompt.js +3 -2
- package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
- package/dist/packages/engine/compile/runtime-runs.js +0 -1
- package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
- package/dist/packages/engine/compile/runtime.d.ts +1 -2
- package/dist/packages/engine/compile/runtime.js +0 -1
- package/dist/packages/engine/compile/state-health.js +6 -6
- package/dist/packages/engine/compile/state-view.js +7 -6
- package/dist/packages/engine/compile/validate-compiled.js +61 -30
- package/dist/packages/engine/compile/validate.js +26 -24
- package/dist/packages/engine/connection-config.js +1 -1
- package/dist/packages/engine/execution/lib/schema.d.ts +89 -33
- package/dist/packages/engine/execution/lib/schema.js +13 -5
- package/dist/packages/engine/index.d.ts +2 -2
- package/dist/packages/engine/index.js +1 -1
- package/dist/packages/engine/instance-paths.d.ts +15 -9
- package/dist/packages/engine/instance-paths.js +15 -9
- package/dist/packages/engine/lib/schema.d.ts +1316 -351
- package/dist/packages/engine/lib/schema.js +99 -36
- package/dist/packages/engine/native-run-handlers.js +25 -15
- package/dist/packages/engine/preparation-store.d.ts +9 -7
- package/dist/packages/engine/preparation-store.js +20 -0
- package/dist/packages/engine/requested-artifacts.d.ts +5 -0
- package/dist/packages/engine/requested-artifacts.js +36 -0
- package/dist/packages/engine/routes.d.ts +7 -1
- package/dist/packages/engine/routes.js +7 -1
- package/dist/packages/engine/run-observability.js +4 -4
- package/dist/packages/engine/runtime-event-applier.js +7 -0
- package/dist/packages/engine/runtime-proposal-helpers.d.ts +2 -2
- package/dist/packages/engine/runtime-proposal-helpers.js +6 -8
- package/dist/packages/engine/runtime-resource-builders.d.ts +11 -6
- package/dist/packages/engine/runtime-resource-builders.js +18 -6
- package/dist/packages/engine/runtime.d.ts +70 -8
- package/dist/packages/engine/runtime.js +304 -49
- package/dist/packages/engine/server.d.ts +25 -0
- package/dist/packages/engine/server.js +161 -50
- package/dist/packages/engine/verify/index.d.ts +10 -10
- package/dist/packages/engine/verify/index.js +8 -8
- package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
- package/dist/packages/engine/verify/readiness-check-run.js +92 -24
- package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
- package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +3 -3
- package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
- package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
- package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
- package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
- package/dist/packages/engine/wire-schemas.d.ts +549 -0
- package/dist/packages/engine/wire-schemas.js +59 -0
- package/dist/packages/methods/authoring/method-authoring.d.ts +5 -1
- package/dist/packages/methods/authoring/method-authoring.js +68 -18
- package/dist/packages/methods/authoring/method-edit-session.js +5 -5
- package/dist/packages/methods/authoring/method-improvement.js +1 -1
- package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
- package/dist/packages/methods/package/builtin-compiled-method.js +26 -23
- package/dist/packages/methods/package/context-interface.d.ts +39 -26
- package/dist/packages/methods/package/context-interface.js +48 -39
- package/dist/packages/methods/package/interf-method-package.js +28 -47
- package/dist/packages/methods/package/local-methods.d.ts +4 -4
- package/dist/packages/methods/package/local-methods.js +53 -66
- package/dist/packages/methods/package/method-definitions.d.ts +4 -6
- package/dist/packages/methods/package/method-definitions.js +1 -5
- package/dist/packages/methods/package/method-helpers.d.ts +0 -2
- package/dist/packages/methods/package/method-helpers.js +0 -4
- package/dist/packages/project/interf-detect.js +6 -6
- package/dist/packages/project/interf-scaffold.js +12 -12
- package/dist/packages/project/lib/schema.d.ts +193 -0
- package/dist/packages/project/lib/schema.js +46 -1
- package/dist/packages/project/source-config.js +6 -1
- package/dist/packages/project/source-folders.js +1 -1
- package/package.json +12 -23
- package/public-repo/CONTRIBUTING.md +47 -0
- package/public-repo/LICENSE.md +1 -0
- package/public-repo/README.md +325 -0
- package/public-repo/SECURITY.md +67 -0
- package/public-repo/TRADEMARKS.md +8 -0
- package/{builtin-methods → public-repo/methods}/interf-default/README.md +10 -7
- package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/shape/SKILL.md +4 -8
- package/{builtin-methods → public-repo/methods}/interf-default/method.json +8 -69
- package/public-repo/methods/interf-default/method.schema.json +75 -0
- package/public-repo/methods/interf-default/use/query/SKILL.md +23 -0
- package/public-repo/plugins/README.md +9 -0
- package/public-repo/plugins/interf/.claude-plugin/plugin.json +21 -0
- package/public-repo/plugins/interf/.mcp.json +12 -0
- package/public-repo/plugins/interf/README.md +29 -0
- package/public-repo/plugins/interf/skills/interf/SKILL.md +477 -0
- package/public-repo/skills/interf/SKILL.md +477 -0
- package/agent-skills/interf-actions/SKILL.md +0 -185
- package/agent-skills/interf-actions/references/cli.md +0 -243
- package/builtin-methods/interf-default/method.schema.json +0 -73
- package/builtin-methods/interf-default/use/query/SKILL.md +0 -28
- package/dist/cli/commands/verify.d.ts +0 -8
- package/dist/compiler-ui/_next/static/chunks/06yhdspx~ca5-.js +0 -5
- package/dist/compiler-ui/_next/static/chunks/06z~l3kwb891e.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/08g7lvje.te.u.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/0_i-3_5l9t2qe.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/0b-ywny_j0g~0.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/0b52v41o1gixx.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/0gpzgsv0w.q~m.js +0 -31
- package/dist/compiler-ui/_next/static/chunks/0ilwfezfvu6~-.js +0 -1
- package/dist/compiler-ui/_next/static/chunks/0jipmpez3_ehh.js +0 -89
- package/dist/compiler-ui/_next/static/chunks/0xxmf45eskdt~.css +0 -1
- package/dist/compiler-ui/_next/static/chunks/13awzu4tooflw.css +0 -3
- package/dist/compiler-ui/_next/static/chunks/14wtz~vq25~qq.js +0 -1
- package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
- package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_ssgManifest.js +0 -0
- /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
- /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
- /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
- /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +0 -0
- /package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/structure/SKILL.md +0 -0
- /package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/summarize/SKILL.md +0 -0
- /package/{builtin-methods → public-repo/methods}/interf-default/improve/SKILL.md +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
|
|
4
|
+
import { CheckKindSchema, } from "../../contracts/lib/schema.js";
|
|
5
|
+
import { countBrokenWikilinks, isOutputMarkdownFile, validateSynthFiles, } from "./validate.js";
|
|
6
|
+
/**
|
|
7
|
+
* Build a Proof envelope from an evaluator outcome. Centralizes the
|
|
8
|
+
* timestamp + required-flag plumbing so individual evaluators can
|
|
9
|
+
* focus on the pass/fail decision and a one-line summary.
|
|
10
|
+
*/
|
|
11
|
+
function makeProof(check, passed, summary, details) {
|
|
12
|
+
return {
|
|
13
|
+
check_id: check.id,
|
|
14
|
+
kind: check.kind,
|
|
15
|
+
passed,
|
|
16
|
+
required: check.required,
|
|
17
|
+
summary,
|
|
18
|
+
...(details !== undefined ? { details } : {}),
|
|
19
|
+
evaluated_at: new Date().toISOString(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function resolveTargetPath(check, context) {
|
|
23
|
+
const target = context.targetPath;
|
|
24
|
+
if (!target)
|
|
25
|
+
return null;
|
|
26
|
+
const root = resolve(context.rootPath);
|
|
27
|
+
const absolute = resolve(root, target);
|
|
28
|
+
// Defense in depth — schema-level validation already rejects path
|
|
29
|
+
// traversal, but a hand-edited Method or stale on-disk fixture could
|
|
30
|
+
// slip through. Reject anything that escapes the root.
|
|
31
|
+
if (absolute !== root && !absolute.startsWith(`${root}/`)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return absolute;
|
|
35
|
+
}
|
|
36
|
+
function listMarkdownFiles(absolutePath) {
|
|
37
|
+
if (!existsSync(absolutePath))
|
|
38
|
+
return [];
|
|
39
|
+
try {
|
|
40
|
+
const stats = statSync(absolutePath);
|
|
41
|
+
if (stats.isFile()) {
|
|
42
|
+
return isOutputMarkdownFile(absolutePath) ? [absolutePath] : [];
|
|
43
|
+
}
|
|
44
|
+
if (stats.isDirectory()) {
|
|
45
|
+
return listFilesRecursive(absolutePath, isOutputMarkdownFile);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
function countFiles(absolutePath) {
|
|
54
|
+
if (!existsSync(absolutePath))
|
|
55
|
+
return 0;
|
|
56
|
+
try {
|
|
57
|
+
const stats = statSync(absolutePath);
|
|
58
|
+
if (stats.isFile())
|
|
59
|
+
return 1;
|
|
60
|
+
if (stats.isDirectory()) {
|
|
61
|
+
return listFilesRecursive(absolutePath, () => true).length;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
const EVALUATORS = {
|
|
70
|
+
file_exists(check, context) {
|
|
71
|
+
const target = resolveTargetPath(check, context);
|
|
72
|
+
if (!target) {
|
|
73
|
+
return makeProof(check, false, "No target path provided for file_exists check.");
|
|
74
|
+
}
|
|
75
|
+
if (!existsSync(target)) {
|
|
76
|
+
return makeProof(check, false, "File or directory does not exist.", { path: context.targetPath });
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const stats = statSync(target);
|
|
80
|
+
if (stats.isFile() && stats.size === 0) {
|
|
81
|
+
return makeProof(check, false, "File exists but is empty.", { path: context.targetPath });
|
|
82
|
+
}
|
|
83
|
+
return makeProof(check, true, `Path exists (${stats.isDirectory() ? "directory" : "file"}).`);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return makeProof(check, false, "Could not stat target path.", { path: context.targetPath });
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
min_file_count(check, context) {
|
|
90
|
+
const target = resolveTargetPath(check, context);
|
|
91
|
+
if (!target) {
|
|
92
|
+
return makeProof(check, false, "No target path provided for min_file_count check.");
|
|
93
|
+
}
|
|
94
|
+
const min = typeof check.params?.min === "number" ? check.params.min : 1;
|
|
95
|
+
const actual = countFiles(target);
|
|
96
|
+
if (actual >= min) {
|
|
97
|
+
return makeProof(check, true, `${actual} file(s) (≥ ${min}).`, { actual, min });
|
|
98
|
+
}
|
|
99
|
+
return makeProof(check, false, `Found ${actual} file(s); expected at least ${min}.`, { actual, min });
|
|
100
|
+
},
|
|
101
|
+
min_file_count_matches_source(check, context) {
|
|
102
|
+
const target = resolveTargetPath(check, context);
|
|
103
|
+
if (!target) {
|
|
104
|
+
return makeProof(check, false, "No target path provided for min_file_count_matches_source check.");
|
|
105
|
+
}
|
|
106
|
+
const matchKey = typeof check.params?.match === "string" ? check.params.match : "source_total";
|
|
107
|
+
const expected = context.counts?.[matchKey];
|
|
108
|
+
if (typeof expected !== "number") {
|
|
109
|
+
return makeProof(check, false, `Cannot evaluate: count "${matchKey}" not available in context.`, { matchKey });
|
|
110
|
+
}
|
|
111
|
+
const actual = countFiles(target);
|
|
112
|
+
if (actual >= expected) {
|
|
113
|
+
return makeProof(check, true, `${actual} of ${expected} source files covered.`, { actual, expected });
|
|
114
|
+
}
|
|
115
|
+
return makeProof(check, false, `Only ${actual} of ${expected} source files covered.`, { actual, expected, matchKey });
|
|
116
|
+
},
|
|
117
|
+
frontmatter_valid(check, context) {
|
|
118
|
+
const target = resolveTargetPath(check, context);
|
|
119
|
+
if (!target) {
|
|
120
|
+
return makeProof(check, false, "No target path provided for frontmatter_valid check.");
|
|
121
|
+
}
|
|
122
|
+
const files = listMarkdownFiles(target);
|
|
123
|
+
if (files.length === 0) {
|
|
124
|
+
return makeProof(check, true, "No markdown files to validate.");
|
|
125
|
+
}
|
|
126
|
+
const validation = validateSynthFiles(files);
|
|
127
|
+
if (validation.invalid_frontmatter === 0) {
|
|
128
|
+
return makeProof(check, true, `${files.length} markdown file(s) have valid frontmatter.`);
|
|
129
|
+
}
|
|
130
|
+
return makeProof(check, false, `${validation.invalid_frontmatter} of ${files.length} markdown file(s) have invalid frontmatter.`, { invalid: validation.invalid_frontmatter, total: files.length });
|
|
131
|
+
},
|
|
132
|
+
frontmatter_required_keys(check, context) {
|
|
133
|
+
const target = resolveTargetPath(check, context);
|
|
134
|
+
if (!target) {
|
|
135
|
+
return makeProof(check, false, "No target path provided for frontmatter_required_keys check.");
|
|
136
|
+
}
|
|
137
|
+
const keys = Array.isArray(check.params?.keys) ? check.params.keys.filter((k) => typeof k === "string") : [];
|
|
138
|
+
if (keys.length === 0) {
|
|
139
|
+
return makeProof(check, false, "frontmatter_required_keys check requires `params.keys: string[]`.");
|
|
140
|
+
}
|
|
141
|
+
const files = listMarkdownFiles(target);
|
|
142
|
+
if (files.length === 0) {
|
|
143
|
+
return makeProof(check, true, "No markdown files to validate.");
|
|
144
|
+
}
|
|
145
|
+
const validation = validateSynthFiles(files, { requiredFrontmatterKeys: keys });
|
|
146
|
+
if (validation.invalid_frontmatter === 0) {
|
|
147
|
+
return makeProof(check, true, `All ${files.length} markdown file(s) have required keys: ${keys.join(", ")}.`);
|
|
148
|
+
}
|
|
149
|
+
return makeProof(check, false, `${validation.invalid_frontmatter} of ${files.length} file(s) missing required keys (${keys.join(", ")}).`, { invalid: validation.invalid_frontmatter, total: files.length, requiredKeys: keys });
|
|
150
|
+
},
|
|
151
|
+
wikilinks_valid(check, context) {
|
|
152
|
+
const target = resolveTargetPath(check, context);
|
|
153
|
+
if (!target) {
|
|
154
|
+
return makeProof(check, false, "No target path provided for wikilinks_valid check.");
|
|
155
|
+
}
|
|
156
|
+
const broken = countBrokenWikilinks(context.rootPath, [context.rootPath], [target]);
|
|
157
|
+
if (broken === 0) {
|
|
158
|
+
return makeProof(check, true, "All wikilinks resolve.");
|
|
159
|
+
}
|
|
160
|
+
return makeProof(check, false, `${broken} broken wikilink(s).`, { broken });
|
|
161
|
+
},
|
|
162
|
+
must_not_contain(check, context) {
|
|
163
|
+
const target = resolveTargetPath(check, context);
|
|
164
|
+
if (!target || !existsSync(target)) {
|
|
165
|
+
return makeProof(check, false, "Target path does not exist.", { path: context.targetPath });
|
|
166
|
+
}
|
|
167
|
+
const phrases = Array.isArray(check.params?.phrases)
|
|
168
|
+
? check.params.phrases.filter((p) => typeof p === "string")
|
|
169
|
+
: [];
|
|
170
|
+
if (phrases.length === 0) {
|
|
171
|
+
return makeProof(check, false, "must_not_contain check requires `params.phrases: string[]`.");
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const stats = statSync(target);
|
|
175
|
+
const files = stats.isFile() ? [target] : listFilesRecursive(target, () => true);
|
|
176
|
+
const offenders = [];
|
|
177
|
+
for (const file of files) {
|
|
178
|
+
const content = readFileSync(file, "utf8");
|
|
179
|
+
for (const phrase of phrases) {
|
|
180
|
+
if (content.includes(phrase)) {
|
|
181
|
+
offenders.push(`${file}: contains "${phrase}"`);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (offenders.length === 0) {
|
|
187
|
+
return makeProof(check, true, `No forbidden phrases found across ${files.length} file(s).`);
|
|
188
|
+
}
|
|
189
|
+
return makeProof(check, false, `${offenders.length} file(s) contain forbidden phrases.`, { offenders, phrases });
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
return makeProof(check, false, `Error reading target: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
must_contain(check, context) {
|
|
196
|
+
const target = resolveTargetPath(check, context);
|
|
197
|
+
if (!target || !existsSync(target)) {
|
|
198
|
+
return makeProof(check, false, "Target path does not exist.", { path: context.targetPath });
|
|
199
|
+
}
|
|
200
|
+
const phrases = Array.isArray(check.params?.phrases)
|
|
201
|
+
? check.params.phrases.filter((p) => typeof p === "string")
|
|
202
|
+
: [];
|
|
203
|
+
if (phrases.length === 0) {
|
|
204
|
+
return makeProof(check, false, "must_contain check requires `params.phrases: string[]`.");
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const stats = statSync(target);
|
|
208
|
+
// For directories, must_contain checks across ALL files (every phrase
|
|
209
|
+
// must appear in at least one file). For files, all phrases must
|
|
210
|
+
// appear in that single file.
|
|
211
|
+
if (stats.isFile()) {
|
|
212
|
+
const content = readFileSync(target, "utf8");
|
|
213
|
+
const missing = phrases.filter((phrase) => !content.includes(phrase));
|
|
214
|
+
if (missing.length === 0) {
|
|
215
|
+
return makeProof(check, true, `All ${phrases.length} required phrase(s) present.`);
|
|
216
|
+
}
|
|
217
|
+
return makeProof(check, false, `${missing.length} required phrase(s) missing.`, { missing });
|
|
218
|
+
}
|
|
219
|
+
const files = listFilesRecursive(target, () => true);
|
|
220
|
+
const remaining = new Set(phrases);
|
|
221
|
+
for (const file of files) {
|
|
222
|
+
const content = readFileSync(file, "utf8");
|
|
223
|
+
for (const phrase of [...remaining]) {
|
|
224
|
+
if (content.includes(phrase))
|
|
225
|
+
remaining.delete(phrase);
|
|
226
|
+
}
|
|
227
|
+
if (remaining.size === 0)
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
if (remaining.size === 0) {
|
|
231
|
+
return makeProof(check, true, `All ${phrases.length} required phrase(s) found across files.`);
|
|
232
|
+
}
|
|
233
|
+
return makeProof(check, false, `${remaining.size} required phrase(s) missing across all files.`, { missing: [...remaining] });
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
return makeProof(check, false, `Error reading target: ${error instanceof Error ? error.message : String(error)}`);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
qa_match(check, context) {
|
|
240
|
+
const expected = typeof check.params?.expected === "string" ? check.params.expected : "";
|
|
241
|
+
const strictness = typeof check.params?.strictness === "string" ? check.params.strictness : "loose";
|
|
242
|
+
const answer = context.agentAnswer ?? "";
|
|
243
|
+
if (!expected) {
|
|
244
|
+
return makeProof(check, false, "qa_match check requires `params.expected: string`.");
|
|
245
|
+
}
|
|
246
|
+
if (!answer) {
|
|
247
|
+
return makeProof(check, false, "No agent answer available for qa_match evaluation.");
|
|
248
|
+
}
|
|
249
|
+
if (strictness === "strict") {
|
|
250
|
+
const passed = answer.trim() === expected.trim();
|
|
251
|
+
return makeProof(check, passed, passed ? "Answer matches expected exactly." : "Answer does not match expected.");
|
|
252
|
+
}
|
|
253
|
+
// Loose: case-insensitive substring match either direction.
|
|
254
|
+
const a = answer.trim().toLowerCase();
|
|
255
|
+
const e = expected.trim().toLowerCase();
|
|
256
|
+
const passed = a.includes(e) || e.includes(a);
|
|
257
|
+
return makeProof(check, passed, passed ? "Answer matches expected (loose)." : "Answer does not match expected.");
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Evaluate a single Check against a context, returning a Proof.
|
|
262
|
+
*/
|
|
263
|
+
export function evaluateCheck(check, context) {
|
|
264
|
+
const evaluator = EVALUATORS[check.kind];
|
|
265
|
+
if (!evaluator) {
|
|
266
|
+
return {
|
|
267
|
+
check_id: check.id,
|
|
268
|
+
kind: check.kind,
|
|
269
|
+
passed: false,
|
|
270
|
+
required: check.required,
|
|
271
|
+
summary: `Unknown check kind: ${check.kind}`,
|
|
272
|
+
evaluated_at: new Date().toISOString(),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return evaluator(check, context);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Evaluate a list of checks. Aggregate ready/not_ready verdict over
|
|
279
|
+
* the proofs: `ready` if every required check passed, otherwise
|
|
280
|
+
* `not_ready`. Soft checks (required: false) that fail produce a
|
|
281
|
+
* proof but don't change the verdict.
|
|
282
|
+
*/
|
|
283
|
+
export function evaluateChecks(checks, context) {
|
|
284
|
+
const proofs = checks.map((check) => evaluateCheck(check, context));
|
|
285
|
+
const failures = proofs.filter((proof) => !proof.passed && proof.required);
|
|
286
|
+
return {
|
|
287
|
+
proofs,
|
|
288
|
+
ready: failures.length === 0,
|
|
289
|
+
failures,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Type guard for the canonical CheckKinds. Useful at parse boundaries
|
|
294
|
+
* where a string came from on-disk JSON.
|
|
295
|
+
*/
|
|
296
|
+
export function isCheckKind(value) {
|
|
297
|
+
return CheckKindSchema.safeParse(value).success;
|
|
298
|
+
}
|
|
@@ -101,17 +101,17 @@ export function compiledRuntimeStageContractPath(compiledPath) {
|
|
|
101
101
|
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_STAGE_CONTRACT_FILE);
|
|
102
102
|
}
|
|
103
103
|
export function resolveSourceControlPathForCompiled(compiledPath) {
|
|
104
|
-
// Flat
|
|
105
|
-
// `<
|
|
106
|
-
// portable context. Reject the filesystem root
|
|
107
|
-
// legacy `<
|
|
104
|
+
// Flat preparation data layout: the portable context lives at
|
|
105
|
+
// `<preparation-data-dir>/<preparation>/`, so the preparation data folder is
|
|
106
|
+
// the parent of the portable context. Reject the filesystem root and the
|
|
107
|
+
// legacy `<root>/interf/<preparation>/` shape so stale fixtures fail loudly.
|
|
108
108
|
const compiledAbsolute = resolve(compiledPath);
|
|
109
109
|
const parent = dirname(compiledAbsolute);
|
|
110
110
|
if (parent === compiledAbsolute) {
|
|
111
|
-
throw new Error(`Portable context is not under the canonical Interf
|
|
111
|
+
throw new Error(`Portable context is not under the canonical Interf preparation data layout: ${compiledPath}`);
|
|
112
112
|
}
|
|
113
113
|
if (basename(parent) === "interf") {
|
|
114
|
-
throw new Error(`Portable context is not under the canonical Interf
|
|
114
|
+
throw new Error(`Portable context is not under the canonical Interf preparation data layout: ${compiledPath}`);
|
|
115
115
|
}
|
|
116
116
|
return parent;
|
|
117
117
|
}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type MethodCompiledSchema, type MethodCompiledZone, type MethodZoneId } from "./lib/schema.js";
|
|
1
|
+
import { type MethodCompiledSchema, type MethodCompiledArtifact, type MethodArtifactId } from "./lib/schema.js";
|
|
3
2
|
export interface MethodSchemaStageLike {
|
|
4
3
|
id: string;
|
|
5
4
|
writes: readonly string[];
|
|
6
5
|
}
|
|
7
|
-
export { BUILTIN_COMPILED_ZONE_IDS } from "../../methods/package/builtin-compiled-method.js";
|
|
8
6
|
export declare const METHOD_SCHEMA_FILE = "method.schema.json";
|
|
9
7
|
export declare function methodSchemaFilePath(rootPath: string): string;
|
|
10
8
|
export declare function resolveMethodSchemaPath(rootPath: string): string | null;
|
|
11
9
|
export declare function methodSchemaExists(rootPath: string): boolean;
|
|
12
10
|
export declare function methodSchemaRelativePath(): string;
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function compiledContractArtifactPath(
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function builtinCompiledZoneAbsolutePath(compiledPath: string, zoneId: BuiltinCompiledZoneId): string;
|
|
20
|
-
export declare function compiledSummariesPath(compiledPath: string): string;
|
|
21
|
-
export declare function compiledKnowledgeEntitiesPath(compiledPath: string): string;
|
|
22
|
-
export declare function compiledKnowledgeClaimsPath(compiledPath: string): string;
|
|
23
|
-
export declare function compiledKnowledgeIndexesPath(compiledPath: string): string;
|
|
24
|
-
export declare function compiledKnowledgeRootPath(compiledPath: string): string;
|
|
25
|
-
export declare function compiledHomePath(compiledPath: string): string;
|
|
26
|
-
export declare function ensureCompiledZoneTargets(compiledPath: string, schema: MethodCompiledSchema): void;
|
|
11
|
+
export declare function listCompiledSchemaArtifacts(schema: MethodCompiledSchema): MethodCompiledArtifact[];
|
|
12
|
+
export declare function findCompiledSchemaArtifact(schema: MethodCompiledSchema, artifactId: MethodArtifactId): MethodCompiledArtifact | null;
|
|
13
|
+
export declare function compiledArtifactAbsolutePath(compiledPath: string, artifact: Pick<MethodCompiledArtifact, "path">): string;
|
|
14
|
+
export declare function compiledContractArtifactPath(artifact: Pick<MethodCompiledArtifact, "path" | "kind">): string;
|
|
15
|
+
export declare function compiledContractArtifactPathsForArtifactIds(schema: MethodCompiledSchema, artifactIds: readonly MethodArtifactId[]): string[];
|
|
16
|
+
export declare function ensureCompiledArtifactTargets(compiledPath: string, schema: MethodCompiledSchema): void;
|
|
27
17
|
export declare function buildMethodSchema(stages: MethodSchemaStageLike[], label?: string): MethodCompiledSchema;
|
|
28
18
|
export declare function writeMethodSchemaFile(rootPath: string, stages: MethodSchemaStageLike[], label?: string): MethodCompiledSchema;
|
|
29
19
|
export declare function writeMethodSchemaDocument(rootPath: string, schema: MethodCompiledSchema): MethodCompiledSchema;
|
|
@@ -2,11 +2,9 @@ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { warnInterf } from "../../contracts/utils/logger.js";
|
|
4
4
|
import { readJsonFileUnchecked } from "../../contracts/utils/parse.js";
|
|
5
|
-
import {
|
|
5
|
+
import { listBuiltinCompiledArtifactSpecs, requiredCompiledArtifactOwners, } from "../../methods/package/builtin-compiled-method.js";
|
|
6
6
|
import { MethodCompiledSchemaSchema, } from "./lib/schema.js";
|
|
7
|
-
export { BUILTIN_COMPILED_ZONE_IDS } from "../../methods/package/builtin-compiled-method.js";
|
|
8
7
|
export const METHOD_SCHEMA_FILE = "method.schema.json";
|
|
9
|
-
const BUILTIN_COMPILED_ZONE_SPEC_BY_ID = new Map(listBuiltinCompiledZoneSpecs().map((zone) => [zone.id, zone]));
|
|
10
8
|
export function methodSchemaFilePath(rootPath) {
|
|
11
9
|
return join(rootPath, METHOD_SCHEMA_FILE);
|
|
12
10
|
}
|
|
@@ -20,96 +18,83 @@ export function methodSchemaExists(rootPath) {
|
|
|
20
18
|
export function methodSchemaRelativePath() {
|
|
21
19
|
return `method/${METHOD_SCHEMA_FILE}`;
|
|
22
20
|
}
|
|
23
|
-
export function
|
|
24
|
-
return
|
|
21
|
+
export function listCompiledSchemaArtifacts(schema) {
|
|
22
|
+
return schema.artifacts.map(artifactToMethodArtifact);
|
|
25
23
|
}
|
|
26
|
-
export function
|
|
27
|
-
return schema.
|
|
24
|
+
export function findCompiledSchemaArtifact(schema, artifactId) {
|
|
25
|
+
return listCompiledSchemaArtifacts(schema).find((artifact) => artifact.id === artifactId) ?? null;
|
|
28
26
|
}
|
|
29
|
-
export function
|
|
30
|
-
return join(compiledPath,
|
|
27
|
+
export function compiledArtifactAbsolutePath(compiledPath, artifact) {
|
|
28
|
+
return join(compiledPath, artifact.path);
|
|
31
29
|
}
|
|
32
|
-
export function compiledContractArtifactPath(
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
35
|
-
return
|
|
30
|
+
export function compiledContractArtifactPath(artifact) {
|
|
31
|
+
if (artifact.kind === "file")
|
|
32
|
+
return artifact.path;
|
|
33
|
+
return artifact.path.endsWith("/") ? artifact.path : `${artifact.path}/`;
|
|
36
34
|
}
|
|
37
|
-
export function
|
|
38
|
-
return
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
throw new Error(`Compiled schema is missing declared
|
|
35
|
+
export function compiledContractArtifactPathsForArtifactIds(schema, artifactIds) {
|
|
36
|
+
return artifactIds.map((artifactId) => {
|
|
37
|
+
const artifact = findCompiledSchemaArtifact(schema, artifactId);
|
|
38
|
+
if (!artifact) {
|
|
39
|
+
throw new Error(`Compiled schema is missing declared Artifact "${artifactId}".`);
|
|
42
40
|
}
|
|
43
|
-
return compiledContractArtifactPath(
|
|
41
|
+
return compiledContractArtifactPath(artifact);
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
|
-
export function
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return zone.path;
|
|
52
|
-
}
|
|
53
|
-
export function builtinCompiledZoneAbsolutePath(compiledPath, zoneId) {
|
|
54
|
-
return join(compiledPath, builtinCompiledZoneRelativePath(zoneId));
|
|
55
|
-
}
|
|
56
|
-
export function compiledSummariesPath(compiledPath) {
|
|
57
|
-
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.SUMMARIES);
|
|
58
|
-
}
|
|
59
|
-
export function compiledKnowledgeEntitiesPath(compiledPath) {
|
|
60
|
-
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES);
|
|
61
|
-
}
|
|
62
|
-
export function compiledKnowledgeClaimsPath(compiledPath) {
|
|
63
|
-
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS);
|
|
64
|
-
}
|
|
65
|
-
export function compiledKnowledgeIndexesPath(compiledPath) {
|
|
66
|
-
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES);
|
|
67
|
-
}
|
|
68
|
-
export function compiledKnowledgeRootPath(compiledPath) {
|
|
69
|
-
return dirname(compiledKnowledgeEntitiesPath(compiledPath));
|
|
70
|
-
}
|
|
71
|
-
export function compiledHomePath(compiledPath) {
|
|
72
|
-
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.HOME);
|
|
73
|
-
}
|
|
74
|
-
export function ensureCompiledZoneTargets(compiledPath, schema) {
|
|
75
|
-
for (const zone of schema.zones) {
|
|
76
|
-
if (zone.kind === "directory" || zone.kind === "runtime") {
|
|
77
|
-
mkdirSync(compiledZoneAbsolutePath(compiledPath, zone), { recursive: true });
|
|
44
|
+
export function ensureCompiledArtifactTargets(compiledPath, schema) {
|
|
45
|
+
for (const artifact of listCompiledSchemaArtifacts(schema)) {
|
|
46
|
+
if (artifact.kind === "directory" || artifact.kind === "runtime") {
|
|
47
|
+
mkdirSync(compiledArtifactAbsolutePath(compiledPath, artifact), { recursive: true });
|
|
78
48
|
continue;
|
|
79
49
|
}
|
|
80
|
-
mkdirSync(dirname(
|
|
50
|
+
mkdirSync(dirname(compiledArtifactAbsolutePath(compiledPath, artifact)), { recursive: true });
|
|
81
51
|
}
|
|
82
52
|
}
|
|
83
|
-
function pushZone(zones, zone) {
|
|
84
|
-
if (zones.some((existing) => existing.path === zone.path))
|
|
85
|
-
return;
|
|
86
|
-
zones.push(zone);
|
|
87
|
-
}
|
|
88
53
|
function normalizeMethodSchema(schema) {
|
|
89
54
|
return {
|
|
90
55
|
...schema,
|
|
91
56
|
kind: "method-schema",
|
|
92
57
|
};
|
|
93
58
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
59
|
+
function artifactToMethodArtifact(artifact) {
|
|
60
|
+
if (artifact.shape.kind !== "path") {
|
|
61
|
+
return {
|
|
62
|
+
id: artifact.id,
|
|
63
|
+
role: "output",
|
|
64
|
+
path: artifact.id,
|
|
65
|
+
kind: "directory",
|
|
66
|
+
required: true,
|
|
67
|
+
owned_by: [...artifact.built_by_stages],
|
|
68
|
+
description: artifact.description,
|
|
69
|
+
};
|
|
106
70
|
}
|
|
71
|
+
return {
|
|
72
|
+
id: artifact.id,
|
|
73
|
+
role: "output",
|
|
74
|
+
path: artifact.shape.path,
|
|
75
|
+
kind: artifact.shape.artifact_kind,
|
|
76
|
+
required: true,
|
|
77
|
+
owned_by: [...artifact.built_by_stages],
|
|
78
|
+
description: artifact.description,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function buildMethodSchema(stages, label = "Method schema") {
|
|
107
82
|
return {
|
|
108
83
|
kind: "method-schema",
|
|
109
84
|
version: 1,
|
|
110
85
|
target_type: "compiled",
|
|
111
86
|
label,
|
|
112
|
-
|
|
87
|
+
artifacts: listBuiltinCompiledArtifactSpecs().map((artifact) => ({
|
|
88
|
+
id: artifact.id,
|
|
89
|
+
description: artifact.description,
|
|
90
|
+
shape: {
|
|
91
|
+
kind: "path",
|
|
92
|
+
path: artifact.path,
|
|
93
|
+
artifact_kind: artifact.kind === "file" ? "file" : "directory",
|
|
94
|
+
},
|
|
95
|
+
checks: [],
|
|
96
|
+
built_by_stages: requiredCompiledArtifactOwners(stages, artifact.id),
|
|
97
|
+
})),
|
|
113
98
|
};
|
|
114
99
|
}
|
|
115
100
|
export function writeMethodSchemaFile(rootPath, stages, label) {
|
|
@@ -5,6 +5,7 @@ import type { RuntimeStageInstructions } from "./lib/schema.js";
|
|
|
5
5
|
export declare function resolveStageContractArtifacts(compiledPath: string, stageDefinition: Pick<MethodStageDefinition, "id" | "reads" | "writes">): {
|
|
6
6
|
reads: string[];
|
|
7
7
|
writes: string[];
|
|
8
|
+
writeContracts: RuntimeStageContractDraft["artifacts"]["write_contracts"];
|
|
8
9
|
};
|
|
9
10
|
export declare function buildStageCounts(compiledPath: string, stageDefinition: MethodStageDefinition): Record<string, number>;
|
|
10
11
|
export declare function buildStageContract(compiledPath: string, stageDefinition: MethodStageDefinition, instructions: RuntimeStageInstructions): RuntimeStageContractDraft;
|
|
@@ -2,14 +2,14 @@ import { join } from "node:path";
|
|
|
2
2
|
import { buildRuntimeStageContract, } from "./runtime.js";
|
|
3
3
|
import { discoverSourceFiles } from "./discovery.js";
|
|
4
4
|
import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
|
|
5
|
-
import {
|
|
5
|
+
import { compiledContractArtifactPath, compiledContractArtifactPathsForArtifactIds, findCompiledSchemaArtifact, readCompiledSchemaFile, } from "./compiled-schema.js";
|
|
6
6
|
import { buildLocalSkillContractExtension, buildStageInstructions, methodCompileStageDirectory, } from "../../methods/package/method-helpers.js";
|
|
7
|
-
import { getActiveCompiledStagePolicyNotes,
|
|
7
|
+
import { getActiveCompiledStagePolicyNotes, } from "../../methods/package/method-definitions.js";
|
|
8
8
|
import { methodPackagePathForCompiled } from "./compiled-paths.js";
|
|
9
9
|
import { readInterfConfig } from "../../project/interf-detect.js";
|
|
10
10
|
import { resolveCompiledContext, } from "./compiled-target.js";
|
|
11
|
-
function
|
|
12
|
-
const absolutePath = join(compiledPath,
|
|
11
|
+
function artifactCount(compiledPath, artifactPath, kind) {
|
|
12
|
+
const absolutePath = join(compiledPath, artifactPath);
|
|
13
13
|
try {
|
|
14
14
|
if (kind === "file") {
|
|
15
15
|
return listFilesRecursive(absolutePath).length > 0 ? 1 : 0;
|
|
@@ -27,28 +27,45 @@ export function resolveStageContractArtifacts(compiledPath, stageDefinition) {
|
|
|
27
27
|
throw new Error(`Missing Method schema for stage "${stageDefinition.id}" at ${methodPackagePathForCompiled(compiledPath)}.`);
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
30
|
-
reads:
|
|
31
|
-
writes:
|
|
30
|
+
reads: compiledContractArtifactPathsForArtifactIds(schema, stageDefinition.reads),
|
|
31
|
+
writes: compiledContractArtifactPathsForArtifactIds(schema, stageDefinition.writes),
|
|
32
|
+
writeContracts: stageDefinition.writes.map((artifactId) => {
|
|
33
|
+
const artifact = schema.artifacts.find((candidate) => candidate.id === artifactId);
|
|
34
|
+
if (!artifact) {
|
|
35
|
+
throw new Error(`Compiled schema is missing declared Artifact "${artifactId}".`);
|
|
36
|
+
}
|
|
37
|
+
const path = artifact.shape.kind === "path"
|
|
38
|
+
? compiledContractArtifactPath({
|
|
39
|
+
path: artifact.shape.path,
|
|
40
|
+
kind: artifact.shape.artifact_kind,
|
|
41
|
+
})
|
|
42
|
+
: artifact.id;
|
|
43
|
+
return {
|
|
44
|
+
artifact_id: artifact.id,
|
|
45
|
+
path,
|
|
46
|
+
checks: artifact.checks ?? [],
|
|
47
|
+
};
|
|
48
|
+
}),
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
export function buildStageCounts(compiledPath, stageDefinition) {
|
|
35
52
|
const context = resolveCompiledContext(compiledPath);
|
|
36
53
|
const sourceTotal = discoverSourceFiles(context.sourcePath, compiledPath).totalCount;
|
|
37
54
|
const schema = readCompiledSchemaFile(methodPackagePathForCompiled(compiledPath));
|
|
38
|
-
const
|
|
55
|
+
const artifactCounts = {};
|
|
39
56
|
if (schema) {
|
|
40
|
-
for (const
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
57
|
+
for (const artifactId of new Set([...stageDefinition.reads, ...stageDefinition.writes])) {
|
|
58
|
+
const artifact = findCompiledSchemaArtifact(schema, artifactId);
|
|
59
|
+
if (!artifact)
|
|
43
60
|
continue;
|
|
44
|
-
|
|
61
|
+
artifactCounts[artifactId] = artifactCount(compiledPath, artifact.path, artifact.kind);
|
|
45
62
|
}
|
|
46
63
|
}
|
|
47
64
|
return {
|
|
48
65
|
source_total: sourceTotal,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
...
|
|
66
|
+
read_artifact_total: stageDefinition.reads.length,
|
|
67
|
+
write_artifact_total: stageDefinition.writes.length,
|
|
68
|
+
...artifactCounts,
|
|
52
69
|
};
|
|
53
70
|
}
|
|
54
71
|
export function buildStageContract(compiledPath, stageDefinition, instructions) {
|
|
@@ -65,10 +82,10 @@ export function buildStageContract(compiledPath, stageDefinition, instructions)
|
|
|
65
82
|
],
|
|
66
83
|
stageReadArtifacts: stageArtifacts.reads,
|
|
67
84
|
stageWriteArtifacts: stageArtifacts.writes,
|
|
85
|
+
stageWriteContracts: stageArtifacts.writeContracts,
|
|
68
86
|
methodNotes: getActiveCompiledStagePolicyNotes(compiledPath, stageDefinition.id),
|
|
69
87
|
localSkillDocs: instructions.local_docs,
|
|
70
88
|
instructions,
|
|
71
|
-
acceptance: resolveActiveCompiledStageAcceptance(compiledPath, stageDefinition.id),
|
|
72
89
|
});
|
|
73
90
|
}
|
|
74
91
|
export function buildCompiledStageExecutionPlan(compiledPath, stageDefinition) {
|
|
@@ -44,7 +44,7 @@ export async function runCompiledStage(options) {
|
|
|
44
44
|
statusLines: [
|
|
45
45
|
`Emit exactly one startup line: STATUS: loaded ${stageDefinition.label.toLowerCase()} stage.`,
|
|
46
46
|
"Emit STATUS: reading declared inputs after you confirm the shell contract and local docs.",
|
|
47
|
-
"Emit STATUS: writing declared outputs after the stage starts updating the compiled
|
|
47
|
+
"Emit STATUS: writing declared outputs after the stage starts updating the compiled Artifacts.",
|
|
48
48
|
`Emit DONE: ${stageDefinition.id} complete when the declared outputs and proof are on disk.`,
|
|
49
49
|
],
|
|
50
50
|
reporter: options.reporter,
|
|
@@ -3,7 +3,6 @@ export * as schema from "./lib/schema.js";
|
|
|
3
3
|
export * as compiledSchema from "./compiled-schema.js";
|
|
4
4
|
export * as compile from "./compiled-compile.js";
|
|
5
5
|
export * as runtime from "./runtime.js";
|
|
6
|
-
export * as runtimeAcceptance from "./runtime-acceptance.js";
|
|
7
6
|
export * as runtimeContracts from "./runtime-contracts.js";
|
|
8
7
|
export * as runtimeInventory from "./runtime-inventory.js";
|
|
9
8
|
export * as runtimePaths from "./runtime-paths.js";
|
|
@@ -3,7 +3,6 @@ export * as schema from "./lib/schema.js";
|
|
|
3
3
|
export * as compiledSchema from "./compiled-schema.js";
|
|
4
4
|
export * as compile from "./compiled-compile.js";
|
|
5
5
|
export * as runtime from "./runtime.js";
|
|
6
|
-
export * as runtimeAcceptance from "./runtime-acceptance.js";
|
|
7
6
|
export * as runtimeContracts from "./runtime-contracts.js";
|
|
8
7
|
export * as runtimeInventory from "./runtime-inventory.js";
|
|
9
8
|
export * as runtimePaths from "./runtime-paths.js";
|