@interf/compiler 0.16.0 → 0.18.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.
Files changed (133) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +10 -7
  3. package/TRADEMARKS.md +4 -4
  4. package/builtin-methods/interf-default/README.md +6 -7
  5. package/builtin-methods/interf-default/method.json +7 -68
  6. package/builtin-methods/interf-default/method.schema.json +52 -50
  7. package/dist/cli/commands/prep.js +58 -2
  8. package/dist/cli/commands/verify.d.ts +2 -0
  9. package/dist/cli/commands/verify.js +17 -8
  10. package/dist/cli/commands/wizard.js +122 -14
  11. package/dist/compiler-ui/404.html +1 -1
  12. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  13. package/dist/compiler-ui/__next._full.txt +3 -3
  14. package/dist/compiler-ui/__next._head.txt +1 -1
  15. package/dist/compiler-ui/__next._index.txt +2 -2
  16. package/dist/compiler-ui/__next._tree.txt +2 -2
  17. package/dist/compiler-ui/_next/static/chunks/{13awzu4tooflw.css → 0_c_tvh-cukjz.css} +1 -1
  18. package/dist/compiler-ui/_next/static/chunks/{0jipmpez3_ehh.js → 0f_geuwdesg_c.js} +42 -17
  19. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  20. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  21. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  22. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  23. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  24. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  25. package/dist/compiler-ui/_not-found.html +1 -1
  26. package/dist/compiler-ui/_not-found.txt +2 -2
  27. package/dist/compiler-ui/index.html +1 -1
  28. package/dist/compiler-ui/index.txt +3 -3
  29. package/dist/packages/contracts/index.d.ts +2 -2
  30. package/dist/packages/contracts/index.js +1 -1
  31. package/dist/packages/contracts/lib/schema.d.ts +271 -72
  32. package/dist/packages/contracts/lib/schema.js +243 -83
  33. package/dist/packages/engine/action-definitions.js +1 -1
  34. package/dist/packages/engine/agents/lib/shells.d.ts +12 -4
  35. package/dist/packages/engine/agents/lib/shells.js +127 -120
  36. package/dist/packages/engine/cloud-seams.d.ts +115 -0
  37. package/dist/packages/engine/cloud-seams.js +84 -0
  38. package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
  39. package/dist/packages/engine/compile/artifact-counts.js +3 -3
  40. package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
  41. package/dist/packages/engine/compile/artifact-status.js +166 -0
  42. package/dist/packages/engine/compile/billing-events.d.ts +89 -0
  43. package/dist/packages/engine/compile/billing-events.js +74 -0
  44. package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
  45. package/dist/packages/engine/compile/check-evaluator.js +298 -0
  46. package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
  47. package/dist/packages/engine/compile/compiled-schema.js +55 -70
  48. package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
  49. package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
  50. package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
  51. package/dist/packages/engine/compile/index.d.ts +0 -1
  52. package/dist/packages/engine/compile/index.js +0 -1
  53. package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
  54. package/dist/packages/engine/compile/lib/schema.js +35 -39
  55. package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
  56. package/dist/packages/engine/compile/method-primitives.js +1 -1
  57. package/dist/packages/engine/compile/reset.js +4 -4
  58. package/dist/packages/engine/compile/runtime-contracts.js +2 -1
  59. package/dist/packages/engine/compile/runtime-prompt.js +3 -2
  60. package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
  61. package/dist/packages/engine/compile/runtime-runs.js +0 -1
  62. package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
  63. package/dist/packages/engine/compile/runtime.d.ts +1 -2
  64. package/dist/packages/engine/compile/runtime.js +0 -1
  65. package/dist/packages/engine/compile/state-health.js +6 -6
  66. package/dist/packages/engine/compile/state-view.js +7 -6
  67. package/dist/packages/engine/compile/validate-compiled.js +61 -30
  68. package/dist/packages/engine/compile/validate.js +26 -24
  69. package/dist/packages/engine/execution/lib/schema.d.ts +79 -33
  70. package/dist/packages/engine/execution/lib/schema.js +13 -5
  71. package/dist/packages/engine/index.d.ts +2 -2
  72. package/dist/packages/engine/index.js +1 -1
  73. package/dist/packages/engine/lib/schema.d.ts +551 -242
  74. package/dist/packages/engine/lib/schema.js +53 -17
  75. package/dist/packages/engine/native-run-handlers.js +15 -7
  76. package/dist/packages/engine/preparation-store.d.ts +6 -0
  77. package/dist/packages/engine/preparation-store.js +8 -0
  78. package/dist/packages/engine/routes.d.ts +6 -0
  79. package/dist/packages/engine/routes.js +6 -0
  80. package/dist/packages/engine/run-observability.js +1 -2
  81. package/dist/packages/engine/runtime-event-applier.js +7 -0
  82. package/dist/packages/engine/runtime-proposal-helpers.js +1 -1
  83. package/dist/packages/engine/runtime-resource-builders.d.ts +6 -6
  84. package/dist/packages/engine/runtime-resource-builders.js +5 -4
  85. package/dist/packages/engine/runtime.d.ts +67 -7
  86. package/dist/packages/engine/runtime.js +159 -29
  87. package/dist/packages/engine/server.d.ts +25 -0
  88. package/dist/packages/engine/server.js +62 -3
  89. package/dist/packages/engine/verify/index.d.ts +10 -10
  90. package/dist/packages/engine/verify/index.js +8 -8
  91. package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
  92. package/dist/packages/engine/verify/readiness-check-run.js +92 -24
  93. package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
  94. package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +2 -2
  95. package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
  96. package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
  97. package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
  98. package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
  99. package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
  100. package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
  101. package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
  102. package/dist/packages/engine/wire-schemas.d.ts +545 -0
  103. package/dist/packages/engine/wire-schemas.js +59 -0
  104. package/dist/packages/methods/authoring/method-authoring.d.ts +2 -0
  105. package/dist/packages/methods/authoring/method-authoring.js +99 -18
  106. package/dist/packages/methods/authoring/method-edit-session.js +5 -5
  107. package/dist/packages/methods/authoring/method-improvement.js +1 -1
  108. package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
  109. package/dist/packages/methods/package/builtin-compiled-method.js +25 -22
  110. package/dist/packages/methods/package/context-interface.d.ts +39 -26
  111. package/dist/packages/methods/package/context-interface.js +48 -39
  112. package/dist/packages/methods/package/interf-method-package.js +28 -47
  113. package/dist/packages/methods/package/local-methods.d.ts +3 -4
  114. package/dist/packages/methods/package/local-methods.js +34 -62
  115. package/dist/packages/methods/package/method-definitions.d.ts +4 -6
  116. package/dist/packages/methods/package/method-definitions.js +0 -4
  117. package/dist/packages/methods/package/method-helpers.d.ts +0 -2
  118. package/dist/packages/methods/package/method-helpers.js +0 -4
  119. package/dist/packages/project/interf-scaffold.js +12 -12
  120. package/dist/packages/project/source-config.js +2 -1
  121. package/package.json +6 -16
  122. package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
  123. package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
  124. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
  125. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
  126. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
  127. /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
  128. /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
  129. /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
  130. /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
  131. /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
  132. /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
  133. /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +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
+ }
@@ -1,29 +1,19 @@
1
- import { type BuiltinCompiledZoneId } from "../../methods/package/builtin-compiled-method.js";
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 listCompiledSchemaZones(schema: MethodCompiledSchema): MethodCompiledZone[];
14
- export declare function findCompiledSchemaZone(schema: MethodCompiledSchema, zoneId: MethodZoneId): MethodCompiledZone | null;
15
- export declare function compiledZoneAbsolutePath(compiledPath: string, zone: Pick<MethodCompiledZone, "path">): string;
16
- export declare function compiledContractArtifactPath(zone: Pick<MethodCompiledZone, "path" | "kind">): string;
17
- export declare function compiledContractArtifactPathsForZoneIds(schema: MethodCompiledSchema, zoneIds: readonly MethodZoneId[]): string[];
18
- export declare function builtinCompiledZoneRelativePath(zoneId: BuiltinCompiledZoneId): string;
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 { BUILTIN_COMPILED_ZONE_IDS, listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "../../methods/package/builtin-compiled-method.js";
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 listCompiledSchemaZones(schema) {
24
- return [...schema.zones];
21
+ export function listCompiledSchemaArtifacts(schema) {
22
+ return schema.artifacts.map(artifactToMethodArtifact);
25
23
  }
26
- export function findCompiledSchemaZone(schema, zoneId) {
27
- return schema.zones.find((zone) => zone.id === zoneId) ?? null;
24
+ export function findCompiledSchemaArtifact(schema, artifactId) {
25
+ return listCompiledSchemaArtifacts(schema).find((artifact) => artifact.id === artifactId) ?? null;
28
26
  }
29
- export function compiledZoneAbsolutePath(compiledPath, zone) {
30
- return join(compiledPath, zone.path);
27
+ export function compiledArtifactAbsolutePath(compiledPath, artifact) {
28
+ return join(compiledPath, artifact.path);
31
29
  }
32
- export function compiledContractArtifactPath(zone) {
33
- if (zone.kind === "file")
34
- return zone.path;
35
- return zone.path.endsWith("/") ? zone.path : `${zone.path}/`;
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 compiledContractArtifactPathsForZoneIds(schema, zoneIds) {
38
- return zoneIds.map((zoneId) => {
39
- const zone = findCompiledSchemaZone(schema, zoneId);
40
- if (!zone) {
41
- throw new Error(`Compiled schema is missing declared zone "${zoneId}".`);
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(zone);
41
+ return compiledContractArtifactPath(artifact);
44
42
  });
45
43
  }
46
- export function builtinCompiledZoneRelativePath(zoneId) {
47
- const zone = BUILTIN_COMPILED_ZONE_SPEC_BY_ID.get(zoneId);
48
- if (!zone) {
49
- throw new Error(`Missing built-in compiled zone "${zoneId}".`);
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(compiledZoneAbsolutePath(compiledPath, zone)), { recursive: true });
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
- export function buildMethodSchema(stages, label = "Method schema") {
95
- const zones = [];
96
- for (const zone of listBuiltinCompiledZoneSpecs()) {
97
- pushZone(zones, {
98
- id: zone.id,
99
- role: zone.role,
100
- path: zone.path,
101
- kind: zone.kind,
102
- required: zone.required,
103
- owned_by: requiredCompiledZoneOwners(stages, zone.id),
104
- description: zone.description,
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
- zones,
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 { compiledContractArtifactPathsForZoneIds, findCompiledSchemaZone, readCompiledSchemaFile, } from "./compiled-schema.js";
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, resolveActiveCompiledStageAcceptance, } from "../../methods/package/method-definitions.js";
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 zoneArtifactCount(compiledPath, zonePath, kind) {
12
- const absolutePath = join(compiledPath, zonePath);
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: compiledContractArtifactPathsForZoneIds(schema, stageDefinition.reads),
31
- writes: compiledContractArtifactPathsForZoneIds(schema, stageDefinition.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 zoneCounts = {};
55
+ const artifactCounts = {};
39
56
  if (schema) {
40
- for (const zoneId of new Set([...stageDefinition.reads, ...stageDefinition.writes])) {
41
- const zone = findCompiledSchemaZone(schema, zoneId);
42
- if (!zone)
57
+ for (const artifactId of new Set([...stageDefinition.reads, ...stageDefinition.writes])) {
58
+ const artifact = findCompiledSchemaArtifact(schema, artifactId);
59
+ if (!artifact)
43
60
  continue;
44
- zoneCounts[zoneId] = zoneArtifactCount(compiledPath, zone.path, zone.kind);
61
+ artifactCounts[artifactId] = artifactCount(compiledPath, artifact.path, artifact.kind);
45
62
  }
46
63
  }
47
64
  return {
48
65
  source_total: sourceTotal,
49
- read_zone_total: stageDefinition.reads.length,
50
- write_zone_total: stageDefinition.writes.length,
51
- ...zoneCounts,
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 zones.",
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";