@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.
Files changed (203) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +90 -73
  3. package/TRADEMARKS.md +4 -4
  4. package/dist/cli/commands/mcp.d.ts +0 -34
  5. package/dist/cli/commands/mcp.js +246 -45
  6. package/dist/cli/commands/method.js +261 -15
  7. package/dist/cli/commands/prep.js +116 -15
  8. package/dist/cli/commands/runs.js +103 -9
  9. package/dist/cli/commands/status.js +4 -2
  10. package/dist/cli/commands/test.d.ts +10 -0
  11. package/dist/cli/commands/{verify.js → test.js} +24 -17
  12. package/dist/cli/commands/web.js +82 -8
  13. package/dist/cli/commands/wizard.js +158 -51
  14. package/dist/cli/index.d.ts +2 -2
  15. package/dist/cli/index.js +3 -3
  16. package/dist/compiler-ui/404.html +1 -1
  17. package/dist/compiler-ui/__next.__PAGE__.txt +5 -5
  18. package/dist/compiler-ui/__next._full.txt +13 -12
  19. package/dist/compiler-ui/__next._head.txt +3 -3
  20. package/dist/compiler-ui/__next._index.txt +5 -4
  21. package/dist/compiler-ui/__next._tree.txt +4 -3
  22. package/dist/compiler-ui/_next/static/chunks/01646j7yi.w5a.css +1 -0
  23. package/dist/compiler-ui/_next/static/chunks/{0n51hrfoufc7g.js → 02f_.8.ebn556.js} +1 -1
  24. package/dist/compiler-ui/_next/static/chunks/02r7siaw-_p5w.js +1 -0
  25. package/dist/compiler-ui/_next/static/chunks/{08m7vf5asqlsm.js → 04d0ly-7xb~-j.js} +10 -10
  26. package/dist/compiler-ui/_next/static/chunks/0fhs9psnxqd8s.js +1 -0
  27. package/dist/compiler-ui/_next/static/chunks/0mssmhpbifj15.css +2 -0
  28. package/dist/compiler-ui/_next/static/chunks/0nypu~ddwxari.js +116 -0
  29. package/dist/compiler-ui/_next/static/chunks/0p3s8iyhgcww2.js +31 -0
  30. package/dist/compiler-ui/_next/static/chunks/0tjf-vu_rz8s0.css +1 -0
  31. package/dist/compiler-ui/_next/static/chunks/0u6p3fpbbfgtl.js +1 -0
  32. package/dist/compiler-ui/_next/static/chunks/0wpx5..8dnh0w.js +1 -0
  33. package/dist/compiler-ui/_next/static/chunks/0y0uj160p0ts~.js +1 -0
  34. package/dist/compiler-ui/_next/static/chunks/10t8l~_oenf.c.js +1 -0
  35. package/dist/compiler-ui/_next/static/chunks/13gz9e7z~imx1.js +5 -0
  36. package/dist/compiler-ui/_next/static/chunks/156xed-b6czaw.js +1 -0
  37. package/dist/compiler-ui/_next/static/chunks/{turbopack-0.uq1k8c0j4s..js → turbopack-02-3e_c-yz~5g.js} +1 -1
  38. package/dist/compiler-ui/_next/static/chunks/{turbopack-10e~t1yzi4svj.js → turbopack-0apv8vb-nczuy.js} +1 -1
  39. package/dist/compiler-ui/_not-found/__next._full.txt +10 -9
  40. package/dist/compiler-ui/_not-found/__next._head.txt +3 -3
  41. package/dist/compiler-ui/_not-found/__next._index.txt +5 -4
  42. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +2 -2
  43. package/dist/compiler-ui/_not-found/__next._not-found.txt +3 -3
  44. package/dist/compiler-ui/_not-found/__next._tree.txt +3 -2
  45. package/dist/compiler-ui/_not-found.html +1 -1
  46. package/dist/compiler-ui/_not-found.txt +10 -9
  47. package/dist/compiler-ui/index.html +1 -1
  48. package/dist/compiler-ui/index.txt +13 -12
  49. package/dist/packages/contracts/index.d.ts +2 -2
  50. package/dist/packages/contracts/index.js +1 -1
  51. package/dist/packages/contracts/lib/schema.d.ts +275 -72
  52. package/dist/packages/contracts/lib/schema.js +244 -83
  53. package/dist/packages/engine/action-definitions.d.ts +174 -13
  54. package/dist/packages/engine/action-definitions.js +125 -122
  55. package/dist/packages/engine/action-planner.js +4 -11
  56. package/dist/packages/engine/agents/lib/shells.d.ts +15 -5
  57. package/dist/packages/engine/agents/lib/shells.js +134 -123
  58. package/dist/packages/engine/agents/role-executors.js +1 -1
  59. package/dist/packages/engine/cloud-seams.d.ts +115 -0
  60. package/dist/packages/engine/cloud-seams.js +84 -0
  61. package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
  62. package/dist/packages/engine/compile/artifact-counts.js +3 -3
  63. package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
  64. package/dist/packages/engine/compile/artifact-status.js +166 -0
  65. package/dist/packages/engine/compile/billing-events.d.ts +89 -0
  66. package/dist/packages/engine/compile/billing-events.js +74 -0
  67. package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
  68. package/dist/packages/engine/compile/check-evaluator.js +298 -0
  69. package/dist/packages/engine/compile/compiled-paths.js +6 -6
  70. package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
  71. package/dist/packages/engine/compile/compiled-schema.js +55 -70
  72. package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
  73. package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
  74. package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
  75. package/dist/packages/engine/compile/index.d.ts +0 -1
  76. package/dist/packages/engine/compile/index.js +0 -1
  77. package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
  78. package/dist/packages/engine/compile/lib/schema.js +35 -39
  79. package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
  80. package/dist/packages/engine/compile/method-primitives.js +1 -1
  81. package/dist/packages/engine/compile/reset.js +4 -4
  82. package/dist/packages/engine/compile/runtime-contracts.js +2 -1
  83. package/dist/packages/engine/compile/runtime-prompt.js +3 -2
  84. package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
  85. package/dist/packages/engine/compile/runtime-runs.js +0 -1
  86. package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
  87. package/dist/packages/engine/compile/runtime.d.ts +1 -2
  88. package/dist/packages/engine/compile/runtime.js +0 -1
  89. package/dist/packages/engine/compile/state-health.js +6 -6
  90. package/dist/packages/engine/compile/state-view.js +7 -6
  91. package/dist/packages/engine/compile/validate-compiled.js +61 -30
  92. package/dist/packages/engine/compile/validate.js +26 -24
  93. package/dist/packages/engine/connection-config.js +1 -1
  94. package/dist/packages/engine/execution/lib/schema.d.ts +89 -33
  95. package/dist/packages/engine/execution/lib/schema.js +13 -5
  96. package/dist/packages/engine/index.d.ts +2 -2
  97. package/dist/packages/engine/index.js +1 -1
  98. package/dist/packages/engine/instance-paths.d.ts +15 -9
  99. package/dist/packages/engine/instance-paths.js +15 -9
  100. package/dist/packages/engine/lib/schema.d.ts +1316 -351
  101. package/dist/packages/engine/lib/schema.js +99 -36
  102. package/dist/packages/engine/native-run-handlers.js +25 -15
  103. package/dist/packages/engine/preparation-store.d.ts +9 -7
  104. package/dist/packages/engine/preparation-store.js +20 -0
  105. package/dist/packages/engine/requested-artifacts.d.ts +5 -0
  106. package/dist/packages/engine/requested-artifacts.js +36 -0
  107. package/dist/packages/engine/routes.d.ts +7 -1
  108. package/dist/packages/engine/routes.js +7 -1
  109. package/dist/packages/engine/run-observability.js +4 -4
  110. package/dist/packages/engine/runtime-event-applier.js +7 -0
  111. package/dist/packages/engine/runtime-proposal-helpers.d.ts +2 -2
  112. package/dist/packages/engine/runtime-proposal-helpers.js +6 -8
  113. package/dist/packages/engine/runtime-resource-builders.d.ts +11 -6
  114. package/dist/packages/engine/runtime-resource-builders.js +18 -6
  115. package/dist/packages/engine/runtime.d.ts +70 -8
  116. package/dist/packages/engine/runtime.js +304 -49
  117. package/dist/packages/engine/server.d.ts +25 -0
  118. package/dist/packages/engine/server.js +161 -50
  119. package/dist/packages/engine/verify/index.d.ts +10 -10
  120. package/dist/packages/engine/verify/index.js +8 -8
  121. package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
  122. package/dist/packages/engine/verify/readiness-check-run.js +92 -24
  123. package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
  124. package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +3 -3
  125. package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
  126. package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
  127. package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
  128. package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
  129. package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
  130. package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
  131. package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
  132. package/dist/packages/engine/wire-schemas.d.ts +549 -0
  133. package/dist/packages/engine/wire-schemas.js +59 -0
  134. package/dist/packages/methods/authoring/method-authoring.d.ts +5 -1
  135. package/dist/packages/methods/authoring/method-authoring.js +68 -18
  136. package/dist/packages/methods/authoring/method-edit-session.js +5 -5
  137. package/dist/packages/methods/authoring/method-improvement.js +1 -1
  138. package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
  139. package/dist/packages/methods/package/builtin-compiled-method.js +26 -23
  140. package/dist/packages/methods/package/context-interface.d.ts +39 -26
  141. package/dist/packages/methods/package/context-interface.js +48 -39
  142. package/dist/packages/methods/package/interf-method-package.js +28 -47
  143. package/dist/packages/methods/package/local-methods.d.ts +4 -4
  144. package/dist/packages/methods/package/local-methods.js +53 -66
  145. package/dist/packages/methods/package/method-definitions.d.ts +4 -6
  146. package/dist/packages/methods/package/method-definitions.js +1 -5
  147. package/dist/packages/methods/package/method-helpers.d.ts +0 -2
  148. package/dist/packages/methods/package/method-helpers.js +0 -4
  149. package/dist/packages/project/interf-detect.js +6 -6
  150. package/dist/packages/project/interf-scaffold.js +12 -12
  151. package/dist/packages/project/lib/schema.d.ts +193 -0
  152. package/dist/packages/project/lib/schema.js +46 -1
  153. package/dist/packages/project/source-config.js +6 -1
  154. package/dist/packages/project/source-folders.js +1 -1
  155. package/package.json +12 -23
  156. package/public-repo/CONTRIBUTING.md +47 -0
  157. package/public-repo/LICENSE.md +1 -0
  158. package/public-repo/README.md +325 -0
  159. package/public-repo/SECURITY.md +67 -0
  160. package/public-repo/TRADEMARKS.md +8 -0
  161. package/{builtin-methods → public-repo/methods}/interf-default/README.md +10 -7
  162. package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/shape/SKILL.md +4 -8
  163. package/{builtin-methods → public-repo/methods}/interf-default/method.json +8 -69
  164. package/public-repo/methods/interf-default/method.schema.json +75 -0
  165. package/public-repo/methods/interf-default/use/query/SKILL.md +23 -0
  166. package/public-repo/plugins/README.md +9 -0
  167. package/public-repo/plugins/interf/.claude-plugin/plugin.json +21 -0
  168. package/public-repo/plugins/interf/.mcp.json +12 -0
  169. package/public-repo/plugins/interf/README.md +29 -0
  170. package/public-repo/plugins/interf/skills/interf/SKILL.md +477 -0
  171. package/public-repo/skills/interf/SKILL.md +477 -0
  172. package/agent-skills/interf-actions/SKILL.md +0 -185
  173. package/agent-skills/interf-actions/references/cli.md +0 -243
  174. package/builtin-methods/interf-default/method.schema.json +0 -73
  175. package/builtin-methods/interf-default/use/query/SKILL.md +0 -28
  176. package/dist/cli/commands/verify.d.ts +0 -8
  177. package/dist/compiler-ui/_next/static/chunks/06yhdspx~ca5-.js +0 -5
  178. package/dist/compiler-ui/_next/static/chunks/06z~l3kwb891e.js +0 -1
  179. package/dist/compiler-ui/_next/static/chunks/08g7lvje.te.u.js +0 -1
  180. package/dist/compiler-ui/_next/static/chunks/0_i-3_5l9t2qe.js +0 -1
  181. package/dist/compiler-ui/_next/static/chunks/0b-ywny_j0g~0.js +0 -1
  182. package/dist/compiler-ui/_next/static/chunks/0b52v41o1gixx.js +0 -1
  183. package/dist/compiler-ui/_next/static/chunks/0gpzgsv0w.q~m.js +0 -31
  184. package/dist/compiler-ui/_next/static/chunks/0ilwfezfvu6~-.js +0 -1
  185. package/dist/compiler-ui/_next/static/chunks/0jipmpez3_ehh.js +0 -89
  186. package/dist/compiler-ui/_next/static/chunks/0xxmf45eskdt~.css +0 -1
  187. package/dist/compiler-ui/_next/static/chunks/13awzu4tooflw.css +0 -3
  188. package/dist/compiler-ui/_next/static/chunks/14wtz~vq25~qq.js +0 -1
  189. package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
  190. package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
  191. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_buildManifest.js +0 -0
  192. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_clientMiddlewareManifest.js +0 -0
  193. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → tYHMLL9oKds1yDoNYgkPV}/_ssgManifest.js +0 -0
  194. /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
  195. /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
  196. /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
  197. /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
  198. /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
  199. /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
  200. /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +0 -0
  201. /package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/structure/SKILL.md +0 -0
  202. /package/{builtin-methods → public-repo/methods}/interf-default/compile/stages/summarize/SKILL.md +0 -0
  203. /package/{builtin-methods → public-repo/methods}/interf-default/improve/SKILL.md +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 — Preparation-declared; runs on `interf test`
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",
@@ -90,10 +280,17 @@ export const ReadinessGateSchema = z.enum([
90
280
  "preparation-config",
91
281
  "portable-context",
92
282
  "compile-run",
283
+ "artifact-checks",
93
284
  "readiness-checks",
94
285
  "checks-current",
95
286
  ]);
96
- export const ReadinessCheckSchema = z.object({
287
+ /**
288
+ * Per-gate status — one row in the readiness summary. A gate is a
289
+ * high-level layer (is config valid? is portable context built? did
290
+ * latest compile succeed?). Gate failures are aggregated alongside
291
+ * artifact-check failures into the overall `Readiness` verdict.
292
+ */
293
+ export const GateStatusSchema = z.object({
97
294
  gate: ReadinessGateSchema,
98
295
  ok: z.boolean(),
99
296
  status: ReadinessStatusSchema.optional(),
@@ -102,7 +299,7 @@ export const ReadinessCheckSchema = z.object({
102
299
  run_id: z.string().min(1).nullable().optional(),
103
300
  artifact_path: z.string().min(1).nullable().optional(),
104
301
  }).strict();
105
- export const ReadinessTargetResultSchema = z.object({
302
+ export const VerifyTargetResultSchema = z.object({
106
303
  passed: z.number().int().min(0),
107
304
  total: z.number().int().min(0),
108
305
  pass_rate: z.number().min(0).max(100).nullable(),
@@ -111,7 +308,14 @@ export const ReadinessTargetResultSchema = z.object({
111
308
  run_id: z.string().min(1).nullable().optional(),
112
309
  run_path: z.string().min(1).nullable().optional(),
113
310
  }).strict();
114
- export const ReadinessStateSchema = z.object({
311
+ /**
312
+ * Preparation-level readiness verdict.
313
+ *
314
+ * Field names retain the preparation-readiness wire shape
315
+ * (`latest_test_run_id`, `check_results`, `checks`). The exported type
316
+ * name is `Readiness`.
317
+ */
318
+ export const ReadinessSchema = z.object({
115
319
  kind: z.literal("interf-readiness-state"),
116
320
  version: z.literal(1),
117
321
  generated_at: z.string().min(1),
@@ -122,61 +326,18 @@ export const ReadinessStateSchema = z.object({
122
326
  portable_context_path: z.string().min(1).nullable(),
123
327
  latest_compile_run_id: z.string().min(1).nullable().optional(),
124
328
  latest_test_run_id: z.string().min(1).nullable().optional(),
125
- compile: ReadinessCheckSchema.nullable(),
329
+ compile: GateStatusSchema.nullable(),
126
330
  check_results: z.object({
127
331
  configured: z.number().int().min(0),
128
332
  fingerprint: z.string().min(1).nullable(),
129
- source_files: ReadinessTargetResultSchema.nullable(),
130
- portable_context: ReadinessTargetResultSchema.nullable(),
333
+ source_files: VerifyTargetResultSchema.nullable(),
334
+ portable_context: VerifyTargetResultSchema.nullable(),
131
335
  }).strict(),
132
- checks: z.array(ReadinessCheckSchema).default([]),
336
+ checks: z.array(GateStatusSchema).default([]),
133
337
  }).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
- ];
338
+ // ───────────────────────────────────────────────────────────────────────────
339
+ // User-defined verification (Q/A pairs) — the "user check" scope
340
+ // ───────────────────────────────────────────────────────────────────────────
180
341
  export const TestCaseExpectSchema = z.object({
181
342
  must_include: z.array(z.string().min(1)).optional(),
182
343
  must_include_one_of: z.array(z.array(z.string().min(1)).min(1)).optional(),
@@ -192,10 +353,23 @@ export const TestCaseExpectSchema = z.object({
192
353
  (value.must_not_include?.length ?? 0) > 0 ||
193
354
  value.min_words !== undefined ||
194
355
  value.max_words !== undefined, {
195
- message: "Test expectations must include at least one check",
356
+ message: "User check expectations must include at least one constraint",
196
357
  });
197
358
  // ───────────────────────────────────────────────────────────────────────────
198
- // 0.15 — connected agents + roles
359
+ // Executor info
360
+ // ───────────────────────────────────────────────────────────────────────────
361
+ export const RuntimeExecutorInfoSchema = z.object({
362
+ kind: z.enum(["local-agent", "connected-provider", "managed"]),
363
+ name: z.string(),
364
+ display_name: z.string(),
365
+ command: z.string().nullable(),
366
+ model: z.string().nullable().optional(),
367
+ effort: z.string().nullable().optional(),
368
+ profile: z.string().nullable().optional(),
369
+ timeout_ms: z.number().nullable().optional(),
370
+ });
371
+ // ───────────────────────────────────────────────────────────────────────────
372
+ // Connected agents + roles (0.15)
199
373
  // ───────────────────────────────────────────────────────────────────────────
200
374
  /**
201
375
  * The 5 canonical roles a Method stage can declare. Methods MAY declare
@@ -209,17 +383,14 @@ export const CANONICAL_ROLES = [
209
383
  "general",
210
384
  ];
211
385
  /**
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.
386
+ * Open-ended role identifier. Methods invent role names freely; the
387
+ * role-router maps unknown names to `general` at run time.
215
388
  */
216
389
  export const RoleSchema = z.string().min(1);
217
390
  /**
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.
391
+ * One agent in the registry. `available` is a runtime-only flag — true
392
+ * if the command's first token resolves on PATH. Stripped before
393
+ * persistence.
223
394
  */
224
395
  export const AgentRecordSchema = z.object({
225
396
  name: z.string().min(1),
@@ -228,17 +399,7 @@ export const AgentRecordSchema = z.object({
228
399
  source: z.enum(["builtin", "user"]),
229
400
  available: z.boolean().optional(),
230
401
  }).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
402
  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
403
  export const AgentsRegistrySchema = z.object({
243
404
  agents: z.array(AgentRecordSchema).default([]),
244
405
  role_map: RoleMapSchema.default({}),