@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
@@ -1,4 +1,7 @@
1
1
  import { z } from "zod";
2
+ // ───────────────────────────────────────────────────────────────────────────
3
+ // Identity primitives
4
+ // ───────────────────────────────────────────────────────────────────────────
2
5
  export const InterfIdPattern = /^[a-z0-9][a-z0-9-]{0,79}$/;
3
6
  export const PreparationNamePattern = /^[a-z0-9][a-z0-9-]*$/;
4
7
  const RESERVED_PREPARATION_NAMES = new Set(["tests", "methods"]);
@@ -7,28 +10,60 @@ export const PreparationNameSchema = z
7
10
  .regex(PreparationNamePattern, "Preparation names must use lowercase letters, numbers, and dashes only.")
8
11
  .refine((value) => !RESERVED_PREPARATION_NAMES.has(value), "Preparation name is reserved.");
9
12
  export const MethodIdSchema = z.string().regex(InterfIdPattern);
13
+ /**
14
+ * Method-declared artifact identifier. Same shape as `MethodIdSchema`
15
+ * but conceptually distinct — it identifies a produced thing inside
16
+ * one Method, while `MethodIdSchema` identifies the Method itself.
17
+ */
18
+ export const ArtifactIdSchema = z.string().regex(InterfIdPattern);
10
19
  export const RuntimeStageSchema = z.string().regex(InterfIdPattern);
11
20
  export const RuntimeContractTypeSchema = z.string().regex(InterfIdPattern);
12
21
  export const RuntimeTargetTypeSchema = z.enum(["compiled"]);
13
22
  export const TestTargetTypeSchema = z.enum(["compiled", "source-files"]);
14
- export const SourceKindSchema = z.enum(["local-folder"]);
23
+ // ───────────────────────────────────────────────────────────────────────────
24
+ // Path validation
25
+ //
26
+ // Used by Artifact paths and any other relative path the schema needs to
27
+ // validate. Rejects path traversal (`..`), absolute paths, and Windows
28
+ // drive letters. Centralized here so engine-side path checks share the
29
+ // definition with schema-level refinements.
30
+ // ───────────────────────────────────────────────────────────────────────────
31
+ const RELATIVE_PATH_SEGMENT = /^(?!\.{1,2}$)[^/\\]+$/;
32
+ export function isInterfRelativePath(value) {
33
+ if (value.length === 0)
34
+ return false;
35
+ if (value.startsWith("/") || value.startsWith("\\"))
36
+ return false;
37
+ if (/^[A-Za-z]:/.test(value))
38
+ return false;
39
+ return value
40
+ .split(/[\\/]+/)
41
+ .every((segment) => RELATIVE_PATH_SEGMENT.test(segment));
42
+ }
43
+ // ───────────────────────────────────────────────────────────────────────────
44
+ // Locator — discriminated resource address
45
+ // ───────────────────────────────────────────────────────────────────────────
15
46
  /**
16
- * Canonical locator-kind enum. A locator identifies where a resource
17
- * lives so the API and UI can route the right action without hard-coding
18
- * deployment shape:
19
- *
20
- * local-path → the engine has filesystem access; UI opens via OS shell
21
- * remote-url → a signed URL; UI opens in a browser tab
22
- * api-served → relative API route; UI fetches via the engine and renders
23
- * inline (text/markdown drawer, image preview, download)
47
+ * A locator identifies where a resource lives so the API and UI can
48
+ * route the right action without hard-coding deployment shape.
24
49
  *
25
- * All three forms carry a string `value` whose meaning depends on `kind`.
50
+ * local-path → engine has filesystem access; UI opens via OS shell
51
+ * remote-url → signed URL; UI opens in a browser tab
52
+ * api-served → relative API route; UI fetches via the engine
26
53
  */
27
54
  export const LocatorKindSchema = z.enum(["local-path", "remote-url", "api-served"]);
28
55
  export const LocatorSchema = z.object({
29
56
  kind: LocatorKindSchema,
30
57
  value: z.string().min(1),
31
58
  }).strict();
59
+ // ───────────────────────────────────────────────────────────────────────────
60
+ // Source primitives — what the user puts in
61
+ //
62
+ // `local-folder` is the only kind the local binary accepts in 0.17;
63
+ // `remote-folder` is type plumbing for the future cloud variant
64
+ // (rejected at the validator branch in server.ts).
65
+ // ───────────────────────────────────────────────────────────────────────────
66
+ export const SourceKindSchema = z.enum(["local-folder", "remote-folder"]);
32
67
  export const SourceSchema = z.object({
33
68
  id: z.string().regex(InterfIdPattern),
34
69
  kind: SourceKindSchema,
@@ -75,6 +110,161 @@ export const StageInputsSchema = z.object({
75
110
  }).strict();
76
111
  export const SourceCompiledMaxAttemptsSchema = z.number().int().min(1).max(5);
77
112
  export const SourceCompiledMaxLoopsSchema = z.number().int().min(1).max(3);
113
+ // ───────────────────────────────────────────────────────────────────────────
114
+ // Check / Proof / Ready — the locked verification vocabulary
115
+ //
116
+ // Three words doing three precise jobs:
117
+ // - Check: the rule that must pass (with a `kind` and optional params)
118
+ // - Proof: evidence a check ran (pass/fail + summary + details)
119
+ // - Ready: aggregate verdict (`ready` or `not_ready`)
120
+ //
121
+ // A check has a SCOPE (where it's declared), not a different name:
122
+ // - stage check — Method-declared per stage; runs end-of-stage
123
+ // - artifact check — Method-declared per artifact; runs end-of-compile
124
+ // - user check — ICP-declared per preparation; runs on `interf verify`
125
+ //
126
+ // Same `Check` primitive across all three scopes. Same `CheckKind`
127
+ // canonical list — methods/users/engine pick from it.
128
+ // ───────────────────────────────────────────────────────────────────────────
129
+ /**
130
+ * Canonical check kinds the engine knows how to evaluate.
131
+ *
132
+ * Adding a new kind requires an engine release (the evaluator must
133
+ * implement it). Methods and user checks pick from this list; they
134
+ * cannot invent custom kinds.
135
+ *
136
+ * file_exists — file is present and non-empty
137
+ * min_file_count — directory has ≥ N files (params: { min: number })
138
+ * min_file_count_matches_source — directory has ≥ source_total files (the "all files analyzed" check)
139
+ * frontmatter_valid — every markdown file has parseable YAML frontmatter
140
+ * frontmatter_required_keys — every markdown file has these frontmatter keys (params: { keys: string[] })
141
+ * wikilinks_valid — every wikilink resolves
142
+ * must_not_contain — file/directory does not contain forbidden phrases (params: { phrases: string[] })
143
+ * must_contain — file/directory contains required phrases (params: { phrases: string[] })
144
+ * qa_match — user-defined Q/A: agent answer matches expected (params: { question, expected, strictness })
145
+ */
146
+ export const CHECK_KINDS = [
147
+ "file_exists",
148
+ "min_file_count",
149
+ "min_file_count_matches_source",
150
+ "frontmatter_valid",
151
+ "frontmatter_required_keys",
152
+ "wikilinks_valid",
153
+ "must_not_contain",
154
+ "must_contain",
155
+ "qa_match",
156
+ ];
157
+ export const CheckKindSchema = z.enum(CHECK_KINDS);
158
+ /**
159
+ * One check declaration. Reusable across stage/artifact/user scopes.
160
+ *
161
+ * `id` is local to the declaring container (a stage's checks have ids
162
+ * scoped to the stage; an artifact's checks have ids scoped to the
163
+ * artifact). `kind` selects the canonical evaluator. `params` carries
164
+ * rule-specific config (typed at the engine evaluator).
165
+ *
166
+ * `required: true` (default) → a failed check fails the parent
167
+ * (stage/artifact/preparation). `required: false` → soft check, fails
168
+ * warn but don't block the `ready` verdict.
169
+ */
170
+ export const CheckSchema = z.object({
171
+ id: z.string().regex(InterfIdPattern),
172
+ kind: CheckKindSchema,
173
+ description: z.string().min(1).optional(),
174
+ params: z.record(z.string(), z.unknown()).optional(),
175
+ required: z.boolean().default(true),
176
+ }).strict();
177
+ /**
178
+ * Evidence a check ran. `passed` is the binary outcome; `summary` is a
179
+ * short one-line label for the UI; `details` carries rule-specific
180
+ * structured data (e.g., file count, missing keys, broken link list).
181
+ */
182
+ export const ProofSchema = z.object({
183
+ check_id: z.string().regex(InterfIdPattern),
184
+ kind: CheckKindSchema,
185
+ passed: z.boolean(),
186
+ required: z.boolean(),
187
+ summary: z.string().min(1),
188
+ details: z.record(z.string(), z.unknown()).optional(),
189
+ evaluated_at: z.string().min(1),
190
+ }).strict();
191
+ /**
192
+ * Per-thing readiness verdict. Used for an artifact, a stage, or a
193
+ * preparation. Aggregate verdict over its required checks.
194
+ */
195
+ export const ReadyVerdictSchema = z.enum(["ready", "not_ready", "failed", "skipped"]);
196
+ /**
197
+ * Standard frontmatter key list used by Methods that emit markdown
198
+ * summaries of source files. Method authors that adopt this evidence
199
+ * convention reference this constant in `frontmatter_required_keys`
200
+ * check params rather than re-typing the list.
201
+ */
202
+ export const STANDARD_EVIDENCE_FRONTMATTER_KEYS = [
203
+ "source",
204
+ "source_kind",
205
+ "evidence_tier",
206
+ "truth_mode",
207
+ "state",
208
+ ];
209
+ // ───────────────────────────────────────────────────────────────────────────
210
+ // Artifact — a produced thing the user can see and verify
211
+ //
212
+ // Every output of a Method is an Artifact. No internal/working/output
213
+ // distinction — if it's named, it's an Artifact. The engine reserves
214
+ // `.interf/runtime/` as its own namespace by convention; those paths
215
+ // are not artifacts.
216
+ // ───────────────────────────────────────────────────────────────────────────
217
+ /**
218
+ * Where an Artifact materializes. Discriminated union so future kinds
219
+ * (literal value, remote handle, confirmation-only) slot in without a
220
+ * schema break. `path` is always relative to the portable-context root,
221
+ * and `artifact_kind` tells consumers whether the target materializes
222
+ * as a file or directory.
223
+ */
224
+ export const ArtifactPathShapeSchema = z.object({
225
+ kind: z.literal("path"),
226
+ path: z.string().min(1).refine(isInterfRelativePath, {
227
+ message: "Artifact paths must stay inside the portable-context root (no `..`, no absolute paths).",
228
+ }),
229
+ artifact_kind: z.enum(["file", "directory"]),
230
+ }).strict();
231
+ export const ArtifactShapeSchema = z.discriminatedUnion("kind", [
232
+ ArtifactPathShapeSchema,
233
+ ]);
234
+ /**
235
+ * Method-declared Artifact — a produced thing.
236
+ *
237
+ * `checks[]` is the locked vocabulary: an array of `Check` (with
238
+ * `kind` from `CHECK_KINDS`). The runtime evaluates them via the
239
+ * shared check evaluator and produces `Proof[]` on each compile run.
240
+ */
241
+ export const ArtifactSchema = z.object({
242
+ id: ArtifactIdSchema,
243
+ description: z.string().min(1),
244
+ shape: ArtifactShapeSchema,
245
+ checks: z.array(CheckSchema).default([]),
246
+ built_by_stages: z.array(z.string().regex(InterfIdPattern)).default([]),
247
+ }).strict();
248
+ /**
249
+ * Per-Artifact runtime status. Lives on compile-run resources and on
250
+ * preparation resources. `proofs[]` carries the structured evidence
251
+ * emitted by the shared check evaluator.
252
+ */
253
+ export const ArtifactStatusValueSchema = ReadyVerdictSchema;
254
+ export const ArtifactStatusSchema = z.object({
255
+ artifact_id: ArtifactIdSchema,
256
+ status: ReadyVerdictSchema,
257
+ built_by_stages: z.array(z.string().regex(InterfIdPattern)).default([]),
258
+ proofs: z.array(ProofSchema).default([]),
259
+ summary: z.string().min(1).optional(),
260
+ }).strict();
261
+ // ───────────────────────────────────────────────────────────────────────────
262
+ // Readiness — preparation-level aggregate verdict
263
+ //
264
+ // Rolls up artifact statuses + user-check results + engine-level gates
265
+ // (is the prep configured, has compile run, etc.) into a single
266
+ // `ready` / `not_ready` answer for the ICP.
267
+ // ───────────────────────────────────────────────────────────────────────────
78
268
  export const ReadinessStatusSchema = z.enum([
79
269
  "not-configured",
80
270
  "not-built",
@@ -93,7 +283,13 @@ export const ReadinessGateSchema = z.enum([
93
283
  "readiness-checks",
94
284
  "checks-current",
95
285
  ]);
96
- export const ReadinessCheckSchema = z.object({
286
+ /**
287
+ * Per-gate status — one row in the readiness summary. A gate is a
288
+ * high-level layer (is config valid? is portable context built? did
289
+ * latest compile succeed?). Gate failures are aggregated alongside
290
+ * artifact-check failures into the overall `Readiness` verdict.
291
+ */
292
+ export const GateStatusSchema = z.object({
97
293
  gate: ReadinessGateSchema,
98
294
  ok: z.boolean(),
99
295
  status: ReadinessStatusSchema.optional(),
@@ -102,7 +298,7 @@ export const ReadinessCheckSchema = z.object({
102
298
  run_id: z.string().min(1).nullable().optional(),
103
299
  artifact_path: z.string().min(1).nullable().optional(),
104
300
  }).strict();
105
- export const ReadinessTargetResultSchema = z.object({
301
+ export const VerifyTargetResultSchema = z.object({
106
302
  passed: z.number().int().min(0),
107
303
  total: z.number().int().min(0),
108
304
  pass_rate: z.number().min(0).max(100).nullable(),
@@ -111,7 +307,14 @@ export const ReadinessTargetResultSchema = z.object({
111
307
  run_id: z.string().min(1).nullable().optional(),
112
308
  run_path: z.string().min(1).nullable().optional(),
113
309
  }).strict();
114
- export const ReadinessStateSchema = z.object({
310
+ /**
311
+ * Preparation-level readiness verdict.
312
+ *
313
+ * Field names retain the preparation-readiness wire shape
314
+ * (`latest_test_run_id`, `check_results`, `checks`). The exported type
315
+ * name is `Readiness`.
316
+ */
317
+ export const ReadinessSchema = z.object({
115
318
  kind: z.literal("interf-readiness-state"),
116
319
  version: z.literal(1),
117
320
  generated_at: z.string().min(1),
@@ -122,61 +325,18 @@ export const ReadinessStateSchema = z.object({
122
325
  portable_context_path: z.string().min(1).nullable(),
123
326
  latest_compile_run_id: z.string().min(1).nullable().optional(),
124
327
  latest_test_run_id: z.string().min(1).nullable().optional(),
125
- compile: ReadinessCheckSchema.nullable(),
328
+ compile: GateStatusSchema.nullable(),
126
329
  check_results: z.object({
127
330
  configured: z.number().int().min(0),
128
331
  fingerprint: z.string().min(1).nullable(),
129
- source_files: ReadinessTargetResultSchema.nullable(),
130
- portable_context: ReadinessTargetResultSchema.nullable(),
332
+ source_files: VerifyTargetResultSchema.nullable(),
333
+ portable_context: VerifyTargetResultSchema.nullable(),
131
334
  }).strict(),
132
- checks: z.array(ReadinessCheckSchema).default([]),
335
+ checks: z.array(GateStatusSchema).default([]),
133
336
  }).strict();
134
- export const RuntimeExecutorInfoSchema = z.object({
135
- kind: z.enum(["local-agent", "connected-provider", "managed"]),
136
- name: z.string(),
137
- display_name: z.string(),
138
- command: z.string().nullable(),
139
- model: z.string().nullable().optional(),
140
- effort: z.string().nullable().optional(),
141
- profile: z.string().nullable().optional(),
142
- timeout_ms: z.number().nullable().optional(),
143
- });
144
- /**
145
- * Canonical list of stage acceptance-rule keys the engine understands.
146
- *
147
- * Method packages (`method.json`) declare per-stage `acceptance: {…}` blocks
148
- * that use a flat shape with these keys as optional properties. The runtime
149
- * walks the same key set when validating a stage outcome. The list is the
150
- * single source of truth; method-authoring prompts and runtime exhaustiveness
151
- * checks should both read from it instead of duplicating string literals.
152
- */
153
- export const ACCEPTANCE_RULE_KEYS = [
154
- "artifacts_exist",
155
- "stage_truthy",
156
- "stage_equals_counts",
157
- "stage_at_least",
158
- "stage_at_least_counts",
159
- "zone_counts_at_least",
160
- "zone_counts_at_least_counts",
161
- "markdown_frontmatter_valid_zones",
162
- "frontmatter_required_keys_in_zones",
163
- "markdown_abstract_valid_zones",
164
- "wikilinks_valid_in_zones",
165
- "artifacts_must_not_contain",
166
- ];
167
- /**
168
- * Standard Interf evidence frontmatter keys used by Methods that emit
169
- * markdown summaries of source files. Method authors that adopt this
170
- * frontmatter convention should use this constant in
171
- * `frontmatter_required_keys_in_zones` rather than re-typing the list.
172
- */
173
- export const STANDARD_EVIDENCE_FRONTMATTER_KEYS = [
174
- "source",
175
- "source_kind",
176
- "evidence_tier",
177
- "truth_mode",
178
- "state",
179
- ];
337
+ // ───────────────────────────────────────────────────────────────────────────
338
+ // User-defined verification (Q/A pairs) — the "user check" scope
339
+ // ───────────────────────────────────────────────────────────────────────────
180
340
  export const TestCaseExpectSchema = z.object({
181
341
  must_include: z.array(z.string().min(1)).optional(),
182
342
  must_include_one_of: z.array(z.array(z.string().min(1)).min(1)).optional(),
@@ -192,10 +352,23 @@ export const TestCaseExpectSchema = z.object({
192
352
  (value.must_not_include?.length ?? 0) > 0 ||
193
353
  value.min_words !== undefined ||
194
354
  value.max_words !== undefined, {
195
- message: "Test expectations must include at least one check",
355
+ message: "User check expectations must include at least one constraint",
196
356
  });
197
357
  // ───────────────────────────────────────────────────────────────────────────
198
- // 0.15 — connected agents + roles
358
+ // Executor info
359
+ // ───────────────────────────────────────────────────────────────────────────
360
+ export const RuntimeExecutorInfoSchema = z.object({
361
+ kind: z.enum(["local-agent", "connected-provider", "managed"]),
362
+ name: z.string(),
363
+ display_name: z.string(),
364
+ command: z.string().nullable(),
365
+ model: z.string().nullable().optional(),
366
+ effort: z.string().nullable().optional(),
367
+ profile: z.string().nullable().optional(),
368
+ timeout_ms: z.number().nullable().optional(),
369
+ });
370
+ // ───────────────────────────────────────────────────────────────────────────
371
+ // Connected agents + roles (0.15)
199
372
  // ───────────────────────────────────────────────────────────────────────────
200
373
  /**
201
374
  * The 5 canonical roles a Method stage can declare. Methods MAY declare
@@ -209,17 +382,14 @@ export const CANONICAL_ROLES = [
209
382
  "general",
210
383
  ];
211
384
  /**
212
- * Open-ended role identifier. Methods are free to invent new role names
213
- * (e.g. `pdf-extractor`, `chart-builder`); the role-router maps unknown
214
- * names to `general` at run time.
385
+ * Open-ended role identifier. Methods invent role names freely; the
386
+ * role-router maps unknown names to `general` at run time.
215
387
  */
216
388
  export const RoleSchema = z.string().min(1);
217
389
  /**
218
- * One agent in the registry. `source` distinguishes built-in detected
219
- * agents (Claude Code, Codex, Cursor) from user-registered custom CLIs
220
- * persisted in `~/.interf/agents.json`. `available` is a runtime-only
221
- * field — true if the command's first token resolves on PATH. It is
222
- * populated when the merged registry is read and is NOT persisted.
390
+ * One agent in the registry. `available` is a runtime-only flag — true
391
+ * if the command's first token resolves on PATH. Stripped before
392
+ * persistence.
223
393
  */
224
394
  export const AgentRecordSchema = z.object({
225
395
  name: z.string().min(1),
@@ -228,17 +398,7 @@ export const AgentRecordSchema = z.object({
228
398
  source: z.enum(["builtin", "user"]),
229
399
  available: z.boolean().optional(),
230
400
  }).strict();
231
- /**
232
- * Map from role name → agent name. Updated by the user via UI / CLI;
233
- * persisted in `~/.interf/agents.json`. Roles missing from this map
234
- * fall through to the active agent at run time.
235
- */
236
401
  export const RoleMapSchema = z.record(RoleSchema, z.string().min(1));
237
- /**
238
- * Wire shape of `~/.interf/agents.json`. Built-in agents are detected
239
- * dynamically and merged in at read time, so this file persists only
240
- * the user-registered subset and the role-map.
241
- */
242
402
  export const AgentsRegistrySchema = z.object({
243
403
  agents: z.array(AgentRecordSchema).default([]),
244
404
  role_map: RoleMapSchema.default({}),
@@ -781,7 +781,7 @@ export function buildCreateMethodActionDefinition(context) {
781
781
  type: "textarea",
782
782
  rows: 3,
783
783
  help: "What this Method output should be able to prove.",
784
- context: "Guides readiness checks. Method acceptance criteria stay separate.",
784
+ context: "Guides readiness checks. Method Artifact checks stay separate.",
785
785
  placeholder: "Describe the evidence that should make this Method output ready.",
786
786
  },
787
787
  {
@@ -1,15 +1,22 @@
1
1
  import type { MethodImprovementContext } from "../../compile/lib/schema.js";
2
- import type { RuntimeContractType } from "../../../contracts/lib/schema.js";
2
+ import { type ArtifactPathShape, type Check, type RuntimeContractType } from "../../../contracts/lib/schema.js";
3
3
  import type { SourceReadinessCheck } from "../../../project/lib/schema.js";
4
- import { type ContextInterfaceZoneId as MethodZoneId } from "../../../methods/package/context-interface.js";
4
+ import { type ContextInterfaceArtifactId as MethodArtifactId } from "../../../methods/package/context-interface.js";
5
5
  export interface NativeStageDefinition {
6
6
  id: string;
7
7
  label: string;
8
8
  description: string;
9
9
  contractType: RuntimeContractType;
10
10
  skillDir: string;
11
- reads: MethodZoneId[];
12
- writes: MethodZoneId[];
11
+ reads: MethodArtifactId[];
12
+ writes: MethodArtifactId[];
13
+ }
14
+ export interface MethodAuthoringArtifactRequirement {
15
+ id: string;
16
+ description?: string;
17
+ shape: ArtifactPathShape;
18
+ checks: Check[];
19
+ stage_hint?: string;
13
20
  }
14
21
  export declare function writeNativeAgentSurface(rootPath: string, agentsContent: string, skillName: string, skillContent: string): boolean;
15
22
  export declare function renderCompiledAgents(compiledPath: string, name: string, methodId: string, about?: string, options?: {
@@ -27,6 +34,7 @@ export declare function createMethodAuthoringShell(options: {
27
34
  sourceFolderPath: string;
28
35
  taskPrompt: string;
29
36
  checks: SourceReadinessCheck[];
37
+ artifactRequirements?: MethodAuthoringArtifactRequirement[];
30
38
  }): {
31
39
  rootPath: string;
32
40
  methodBeforePath: string;