@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,8 +1,8 @@
1
1
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { createMethodAuthoringShell } from "../../engine/agents/lib/shells.js";
3
+ import { createMethodAuthoringShell, } from "../../engine/agents/lib/shells.js";
4
4
  import { createScratchLocalMethodPackage } from "../package/interf-method-package.js";
5
- import { CONTEXT_INTERFACE_FILE } from "../package/context-interface.js";
5
+ import { CONTEXT_INTERFACE_FILE, listContextInterfaceArtifacts } from "../package/context-interface.js";
6
6
  import { loadMethodDefinitionFromDir, validateMethodPackage, methodDefinitionPath, } from "../package/local-methods.js";
7
7
  import { runMethodEditSession } from "./method-edit-session.js";
8
8
  /**
@@ -66,29 +66,27 @@ function buildMethodAuthoringPrompt() {
66
66
  "Treat `task_prompt` as the user's preparation-and-evidence brief: source data, output shape, and evidence that should show the data is ready.",
67
67
  `Then read \`method/README.md\`, \`method/method.json\`, and \`method/${CONTEXT_INTERFACE_FILE}\`.`,
68
68
  "The `method/` directory starts as a neutral Method package scaffold, not as a suggested Method.",
69
- "Replace the scaffold purpose, inputs, context interface, stages, stage docs, proof rules, and query guidance with the Method this agent work actually needs.",
69
+ "Replace the scaffold purpose, inputs, Artifacts, stages, stage docs, checks, and query guidance with the Method this agent work actually needs.",
70
70
  "Read `runtime/source-files.json` and inspect the listed source locators before editing the package.",
71
71
  "Prefer direct file-reading and search tools over shell commands for routine file inspection.",
72
72
  "Do not use shell helpers like `cat`, `sed`, `ls`, or `find` when a native read/search tool can inspect the same files.",
73
73
  "Edit only files under `method/`.",
74
74
  "Keep the Method package valid for the current compiler API and `method.schema.json`.",
75
- "Choose stage ids, stage order, reads, writes, acceptance criteria, and stage docs from the source data and preparation-and-evidence brief.",
76
- "Use kebab-case ids everywhere: stage ids, skill_dir values, zone ids, reads/writes values, and package ids. Never use underscores.",
75
+ "Choose stage ids, stage order, artifact reads, artifact writes, artifact checks, and stage docs from the source data and preparation-and-evidence brief.",
76
+ "Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
77
77
  "Each stage MAY declare a `role`: one of `extractor`, `summarizer`, `structurer`, `verifier`, or `general`. Pick the role that best matches what the stage's prompt asks the agent to do. Omit `role` (or use `general`) when the stage doesn't fit any specialized role. Custom role names are allowed; the engine treats unknown roles as `general`.",
78
78
  "Do not preserve the placeholder `prepare` stage unless the final Method genuinely needs a stage with that exact role.",
79
- "When editing acceptance criteria: `zone_counts_at_least` maps declared zone ids to fixed numeric minimums.",
80
- "`zone_counts_at_least_counts` also maps declared zone ids to runtime count-key strings such as `source_total`; `source_total` is a value, never a zone key.",
81
- "For file output zones that replace scaffold files, add `artifacts_must_not_contain` entries that reject `Not yet compiled.` placeholder text; its keys must be artifact paths like `home.md`, not zone ids like `home`.",
82
- "Before stopping, verify every zone-count acceptance key is declared in `method.schema.json`.",
79
+ "Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
80
+ "Use only the CheckKind values listed in `runtime/authoring-context.json`; do not invent aliases.",
81
+ "Keep Artifact checks and the producing stage docs aligned: every checked output requirement must be described in the stage doc that writes that Artifact.",
83
82
  "For every stage in `method.json`, create `method/compile/stages/<skill_dir>/SKILL.md` and make the folder name exactly match that stage's kebab-case `skill_dir`.",
84
- "Every zone path in `method.schema.json` must be unique and non-overlapping. Do not declare both `knowledge/indexes` and `knowledge/indexes/some-file.md` as separate zones.",
83
+ "Every Artifact path in `method.schema.json` must be unique and non-overlapping.",
85
84
  "Make the package materially specific to this Preparation task, output shape, and proof requirement. A no-op scaffold is not acceptable.",
86
85
  "Treat the Method package as four aligned layers: purpose, inputs, context interface, and stages.",
87
- "Keep the portable-context entrypoint canonical: if the Method writes an agent entrypoint, declare zone id `home` with path `home.md` and make the final shaping stage own it.",
88
- "Do not move the main entrypoint to `knowledge/home.md` or any other nested path.",
86
+ "If the Method writes an agent entrypoint, declare it as an Artifact and make the final shaping stage own it.",
89
87
  "Prefer explicit stage-doc, stage-policy, purpose, input-contract, and context-interface edits over vague rewrites.",
90
88
  "Do not introduce wikilinks unless the Method also creates the target note by exact basename or explicit relative path.",
91
- "Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read zones.",
89
+ "Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read Artifacts.",
92
90
  "Do not make one stage point at files or notes that are only created later by another stage.",
93
91
  "Prefer conservative retrieval routing over speculative note sprawl.",
94
92
  "Do not narrate plans or ask follow-up questions.",
@@ -96,7 +94,87 @@ function buildMethodAuthoringPrompt() {
96
94
  "As soon as the Method edits are complete, stop.",
97
95
  ].join("\n");
98
96
  }
99
- function validateAuthoredMethodPackage(methodPath) {
97
+ function stableJson(value) {
98
+ if (value === null || typeof value !== "object") {
99
+ return JSON.stringify(value ?? {});
100
+ }
101
+ if (Array.isArray(value)) {
102
+ return `[${value.map((entry) => stableJson(entry)).join(",")}]`;
103
+ }
104
+ const record = value;
105
+ return `{${Object.keys(record)
106
+ .sort()
107
+ .map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
108
+ .join(",")}}`;
109
+ }
110
+ function checkMatchesRequirement(actual, required) {
111
+ return actual.id === required.id &&
112
+ actual.kind === required.kind &&
113
+ (actual.required ?? true) === (required.required ?? true) &&
114
+ stableJson(actual.params) === stableJson(required.params);
115
+ }
116
+ function producingStagesForArtifact(definition, artifactId) {
117
+ return (definition.stages ?? []).filter((stage) => Array.isArray(stage.writes) && stage.writes.includes(artifactId));
118
+ }
119
+ function readProducingStageDocs(methodPath, stages) {
120
+ return stages
121
+ .map((stage) => join(methodPath, "compile", "stages", stage.skill_dir ?? stage.id, "SKILL.md"))
122
+ .filter((filePath) => existsSync(filePath))
123
+ .map((filePath) => readFileSync(filePath, "utf8"))
124
+ .join("\n");
125
+ }
126
+ function validateMustContainStageDocs(methodPath, definition) {
127
+ const artifacts = definition.method_schema.artifacts ?? [];
128
+ const errors = [];
129
+ for (const artifact of artifacts) {
130
+ const producingStages = producingStagesForArtifact(definition, artifact.id);
131
+ if (producingStages.length === 0)
132
+ continue;
133
+ const producingStageDocs = readProducingStageDocs(methodPath, producingStages);
134
+ for (const check of artifact.checks ?? []) {
135
+ if (check.kind !== "must_contain")
136
+ continue;
137
+ const phrases = check.params?.phrases;
138
+ if (!Array.isArray(phrases))
139
+ continue;
140
+ for (const phrase of phrases) {
141
+ if (typeof phrase !== "string")
142
+ continue;
143
+ if (!producingStageDocs.includes(phrase)) {
144
+ errors.push(`Artifact \`${artifact.id}\` check \`${check.id}\` requires phrase not present in producing stage docs.`);
145
+ }
146
+ }
147
+ }
148
+ }
149
+ return errors;
150
+ }
151
+ function validateArtifactRequirements(methodPath, definition, requirements) {
152
+ const artifacts = definition.method_schema.artifacts ?? [];
153
+ const errors = [];
154
+ for (const requirement of requirements) {
155
+ const artifact = artifacts.find((candidate) => candidate.id === requirement.id);
156
+ if (!artifact) {
157
+ errors.push(`Missing required Artifact \`${requirement.id}\`.`);
158
+ continue;
159
+ }
160
+ if (artifact.shape.kind !== requirement.shape.kind ||
161
+ artifact.shape.path !== requirement.shape.path ||
162
+ artifact.shape.artifact_kind !== requirement.shape.artifact_kind) {
163
+ errors.push(`Artifact \`${requirement.id}\` does not match required shape.`);
164
+ }
165
+ for (const check of requirement.checks) {
166
+ if (!artifact.checks.some((candidate) => checkMatchesRequirement(candidate, check))) {
167
+ errors.push(`Artifact \`${requirement.id}\` is missing required check \`${check.id}\`.`);
168
+ }
169
+ }
170
+ const producingStages = producingStagesForArtifact(definition, requirement.id);
171
+ if (producingStages.length === 0) {
172
+ errors.push(`Artifact \`${requirement.id}\` is not written by any stage.`);
173
+ }
174
+ }
175
+ return errors;
176
+ }
177
+ function validateAuthoredMethodPackage(methodPath, artifactRequirements = []) {
100
178
  const validation = validateMethodPackage(methodPath);
101
179
  if (!validation.ok)
102
180
  return validation;
@@ -107,18 +185,20 @@ function validateAuthoredMethodPackage(methodPath) {
107
185
  const placeholderStage = definition.stages?.find((stage) => stage.id === "prepare" &&
108
186
  stage.contract_type === "method-draft-stage" &&
109
187
  stage.writes.includes("draft-context"));
110
- const placeholderZone = definition.method_schema.zones.find((zone) => zone.id === "draft-context");
188
+ const placeholderArtifact = listContextInterfaceArtifacts(definition.method_schema).find((artifact) => artifact.id === "draft-context");
111
189
  const placeholderPurpose = definition.purpose?.label === "From-scratch Method draft" ||
112
190
  definition.purpose?.task_hint?.includes("Replace this neutral scaffold");
113
191
  if (placeholderStage) {
114
192
  errors.push("Authored Method still contains the neutral scaffold stage `prepare`.");
115
193
  }
116
- if (placeholderZone) {
117
- errors.push("Authored Method still contains the neutral scaffold zone `draft-context`.");
194
+ if (placeholderArtifact) {
195
+ errors.push("Authored Method still contains the neutral scaffold artifact `draft-context`.");
118
196
  }
119
197
  if (placeholderPurpose) {
120
198
  errors.push("Authored Method still contains the neutral scaffold purpose.");
121
199
  }
200
+ errors.push(...validateArtifactRequirements(methodPath, definition, artifactRequirements));
201
+ errors.push(...validateMustContainStageDocs(methodPath, definition));
122
202
  return {
123
203
  ok: validation.ok && errors.length === 0,
124
204
  summary: errors.length === 0
@@ -143,13 +223,14 @@ export async function runMethodAuthoringDraft(options) {
143
223
  sourceFolderPath: options.sourceFolderPath,
144
224
  taskPrompt: options.taskPrompt,
145
225
  checks: options.checks ?? [],
226
+ artifactRequirements: options.artifactRequirements ?? [],
146
227
  });
147
228
  const session = await runMethodEditSession({
148
229
  executor: options.executor,
149
230
  methodPath,
150
231
  shell,
151
232
  prompt: buildMethodAuthoringPrompt(),
152
- validate: validateAuthoredMethodPackage,
233
+ validate: (methodPath) => validateAuthoredMethodPackage(methodPath, options.artifactRequirements ?? []),
153
234
  maxValidationRepairAttempts: 1,
154
235
  onStatus: options.onStatus,
155
236
  });
@@ -94,12 +94,12 @@ export async function runMethodEditSession(options) {
94
94
  "",
95
95
  "Rules:",
96
96
  "- Edit only files under `method/`.",
97
- "- Use kebab-case ids everywhere: stage ids, skill_dir values, zone ids, reads/writes values, and package ids. Never use underscores.",
97
+ "- Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
98
98
  "- Keep every stage `skill_dir` matched by `method/compile/stages/<skill_dir>/SKILL.md`.",
99
- "- Keep `method.schema.json` zone paths unique and non-overlapping.",
100
- "- Keep zone-count acceptance keys declared in `method.schema.json`.",
101
- "- Keep `artifacts_must_not_contain` keys as portable-context relative artifact paths such as `home.md`, not zone ids.",
102
- "- Preserve root `home.md` as the main portable-context entrypoint when the Method writes an entrypoint.",
99
+ "- Keep `method.schema.json` Artifact paths unique and non-overlapping.",
100
+ "- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
101
+ "- Use only CheckKind values listed in `runtime/authoring-context.json`; replace invented aliases with valid kinds.",
102
+ "- If the Method writes an agent entrypoint, keep it declared as an Artifact owned by the producing stage.",
103
103
  "- Stop as soon as the package should validate.",
104
104
  ].join("\n");
105
105
  appendFileSync(options.shell.promptLogPath, `\n\n---\n\n${prompt}\n`);
@@ -67,7 +67,7 @@ function buildMethodImprovementPrompt() {
67
67
  "Edit only files under `method/`.",
68
68
  "Do not edit checks, test specs, source files, or generated portable-context outputs.",
69
69
  "Keep the Method package valid for the current compiler API and `method.schema.json`.",
70
- "Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read zones.",
70
+ "Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read Artifacts.",
71
71
  "Do not make one stage point at files or notes that are only created later by another stage.",
72
72
  "Prefer small, defensible changes to Method docs, stage docs, stage policies, or schema ownership over random churn.",
73
73
  "Do not narrate plans or ask follow-up questions.",
@@ -1,37 +1,37 @@
1
- import { type CompiledZoneKind } from "../../engine/compile/method-primitives.js";
1
+ import { type CompiledArtifactKind } from "../../engine/compile/method-primitives.js";
2
2
  declare const BUILTIN_COMPILED_STAGE_IDS: {
3
3
  readonly SUMMARIZE: "summarize";
4
4
  readonly STRUCTURE: "structure";
5
5
  readonly SHAPE: "shape";
6
6
  };
7
7
  type BuiltinCompiledStageId = typeof BUILTIN_COMPILED_STAGE_IDS[keyof typeof BUILTIN_COMPILED_STAGE_IDS];
8
- export declare const BUILTIN_COMPILED_ZONE_IDS: {
8
+ export declare const BUILTIN_COMPILED_ARTIFACT_IDS: {
9
9
  readonly SUMMARIES: "summaries";
10
10
  readonly KNOWLEDGE_ENTITIES: "knowledge-entities";
11
11
  readonly KNOWLEDGE_CLAIMS: "knowledge-claims";
12
12
  readonly KNOWLEDGE_INDEXES: "knowledge-indexes";
13
- readonly HOME: "home";
13
+ readonly HOME: "atlas";
14
14
  readonly RUNTIME: "runtime";
15
15
  };
16
- export type BuiltinCompiledZoneId = typeof BUILTIN_COMPILED_ZONE_IDS[keyof typeof BUILTIN_COMPILED_ZONE_IDS];
17
- export interface BuiltinCompiledZoneSpec {
18
- id: BuiltinCompiledZoneId;
16
+ export type BuiltinCompiledArtifactId = typeof BUILTIN_COMPILED_ARTIFACT_IDS[keyof typeof BUILTIN_COMPILED_ARTIFACT_IDS];
17
+ export interface BuiltinCompiledArtifactSpec {
18
+ id: BuiltinCompiledArtifactId;
19
19
  role: "input" | "working" | "output" | "runtime";
20
20
  path: string;
21
- kind: CompiledZoneKind;
21
+ kind: CompiledArtifactKind;
22
22
  required: boolean;
23
23
  description: string;
24
24
  }
25
25
  export interface BuiltinCompiledStageAccessPattern {
26
26
  id: BuiltinCompiledStageId;
27
27
  contract_type: string;
28
- reads: BuiltinCompiledZoneId[];
29
- writes: BuiltinCompiledZoneId[];
28
+ reads: BuiltinCompiledArtifactId[];
29
+ writes: BuiltinCompiledArtifactId[];
30
30
  }
31
- export declare function listBuiltinCompiledZoneSpecs(): BuiltinCompiledZoneSpec[];
31
+ export declare function listBuiltinCompiledArtifactSpecs(): BuiltinCompiledArtifactSpec[];
32
32
  export declare function listBuiltinCompiledFallbackStages(): BuiltinCompiledStageAccessPattern[];
33
- export declare function requiredCompiledZoneOwners<TStage extends {
33
+ export declare function requiredCompiledArtifactOwners<TStage extends {
34
34
  id: string;
35
35
  writes: readonly string[];
36
- }>(stages: readonly TStage[], zoneId: BuiltinCompiledZoneId): string[];
36
+ }>(stages: readonly TStage[], artifactId: BuiltinCompiledArtifactId): string[];
37
37
  export {};
@@ -8,20 +8,20 @@ const BUILTIN_COMPILED_STAGE_IDS = {
8
8
  STRUCTURE: "structure",
9
9
  SHAPE: "shape",
10
10
  };
11
- export const BUILTIN_COMPILED_ZONE_IDS = {
11
+ export const BUILTIN_COMPILED_ARTIFACT_IDS = {
12
12
  SUMMARIES: "summaries",
13
13
  KNOWLEDGE_ENTITIES: "knowledge-entities",
14
14
  KNOWLEDGE_CLAIMS: "knowledge-claims",
15
15
  KNOWLEDGE_INDEXES: "knowledge-indexes",
16
- HOME: "home",
16
+ HOME: "atlas",
17
17
  RUNTIME: "runtime",
18
18
  };
19
- const BUILTIN_ZONE_ID_SET = new Set(Object.values(BUILTIN_COMPILED_ZONE_IDS));
19
+ const BUILTIN_ARTIFACT_ID_SET = new Set(Object.values(BUILTIN_COMPILED_ARTIFACT_IDS));
20
20
  const BUILTIN_STAGE_ID_SET = new Set(Object.values(BUILTIN_COMPILED_STAGE_IDS));
21
21
  const BuiltinMethodStageSchema = z.object({
22
22
  id: z.string(),
23
23
  contract_type: z.string(),
24
- reads: z.array(z.string()).min(1),
24
+ reads: z.array(z.string()),
25
25
  writes: z.array(z.string()).min(1),
26
26
  });
27
27
  const BuiltinMethodPackageSchema = z.object({
@@ -29,9 +29,9 @@ const BuiltinMethodPackageSchema = z.object({
29
29
  });
30
30
  let builtinCompiledContractCache = null;
31
31
  const BUILTIN_DEFAULT_METHOD_ROOT = join(PACKAGE_ROOT, "builtin-methods", "interf-default");
32
- function assertBuiltinZoneId(value) {
33
- if (!BUILTIN_ZONE_ID_SET.has(value)) {
34
- throw new Error(`Built-in Interf Method schema declares unsupported zone id "${value}".`);
32
+ function assertBuiltinArtifactId(value) {
33
+ if (!BUILTIN_ARTIFACT_ID_SET.has(value)) {
34
+ throw new Error(`Built-in Interf Method schema declares unsupported Artifact id "${value}".`);
35
35
  }
36
36
  return value;
37
37
  }
@@ -54,25 +54,28 @@ function loadBuiltinCompiledContract() {
54
54
  if (!method) {
55
55
  throw new Error(`Missing or invalid built-in Method package at ${methodPath}.`);
56
56
  }
57
- const zones = schema.zones.map((zone) => ({
58
- id: assertBuiltinZoneId(zone.id),
59
- role: zone.role,
60
- path: zone.path,
61
- kind: zone.kind,
62
- required: zone.required,
63
- description: zone.description,
64
- }));
57
+ const artifacts = schema.artifacts.map((artifact) => {
58
+ const path = artifact.shape.path;
59
+ return {
60
+ id: assertBuiltinArtifactId(artifact.id),
61
+ role: "output",
62
+ path,
63
+ kind: artifact.shape.artifact_kind,
64
+ required: true,
65
+ description: artifact.description,
66
+ };
67
+ });
65
68
  const stages = method.stages.map((stage) => ({
66
69
  id: assertBuiltinStageId(stage.id),
67
70
  contract_type: stage.contract_type,
68
- reads: stage.reads.map(assertBuiltinZoneId),
69
- writes: stage.writes.map(assertBuiltinZoneId),
71
+ reads: stage.reads.map(assertBuiltinArtifactId),
72
+ writes: stage.writes.map(assertBuiltinArtifactId),
70
73
  }));
71
- builtinCompiledContractCache = { zones, stages };
74
+ builtinCompiledContractCache = { artifacts, stages };
72
75
  return builtinCompiledContractCache;
73
76
  }
74
- export function listBuiltinCompiledZoneSpecs() {
75
- return loadBuiltinCompiledContract().zones.map((zone) => ({ ...zone }));
77
+ export function listBuiltinCompiledArtifactSpecs() {
78
+ return loadBuiltinCompiledContract().artifacts.map((artifact) => ({ ...artifact }));
76
79
  }
77
80
  export function listBuiltinCompiledFallbackStages() {
78
81
  return loadBuiltinCompiledContract().stages.map((stage) => ({
@@ -81,8 +84,8 @@ export function listBuiltinCompiledFallbackStages() {
81
84
  writes: [...stage.writes],
82
85
  }));
83
86
  }
84
- export function requiredCompiledZoneOwners(stages, zoneId) {
87
+ export function requiredCompiledArtifactOwners(stages, artifactId) {
85
88
  return Array.from(new Set(stages
86
- .filter((stage) => stage.writes.includes(zoneId))
89
+ .filter((stage) => stage.writes.includes(artifactId))
87
90
  .map((stage) => stage.id)));
88
91
  }
@@ -1,30 +1,42 @@
1
1
  import { z } from "zod";
2
- import { type MethodCompiledSchema, type MethodCompiledZone, type MethodZoneId } from "../../engine/compile/lib/schema.js";
2
+ import { type MethodCompiledSchema, type MethodCompiledArtifact, type MethodArtifactId } from "../../engine/compile/lib/schema.js";
3
3
  export declare const CONTEXT_INTERFACE_FILE = "method.schema.json";
4
4
  export declare const ContextInterfaceSchema: z.ZodObject<{
5
5
  kind: z.ZodLiteral<"method-schema">;
6
6
  version: z.ZodLiteral<1>;
7
7
  target_type: z.ZodLiteral<"compiled">;
8
8
  label: z.ZodString;
9
- zones: z.ZodArray<z.ZodObject<{
9
+ artifacts: z.ZodArray<z.ZodObject<{
10
10
  id: z.ZodString;
11
- role: z.ZodEnum<{
12
- runtime: "runtime";
13
- output: "output";
14
- input: "input";
15
- working: "working";
16
- }>;
17
- path: z.ZodString;
18
- kind: z.ZodEnum<{
19
- runtime: "runtime";
20
- file: "file";
21
- directory: "directory";
22
- }>;
23
- required: z.ZodBoolean;
24
- owned_by: z.ZodArray<z.ZodString>;
25
11
  description: z.ZodString;
26
- }, z.core.$strip>>;
27
- }, z.core.$strip>;
12
+ shape: z.ZodDiscriminatedUnion<[z.ZodObject<{
13
+ kind: z.ZodLiteral<"path">;
14
+ path: z.ZodString;
15
+ artifact_kind: z.ZodEnum<{
16
+ file: "file";
17
+ directory: "directory";
18
+ }>;
19
+ }, z.core.$strict>], "kind">;
20
+ checks: z.ZodDefault<z.ZodArray<z.ZodObject<{
21
+ id: z.ZodString;
22
+ kind: z.ZodEnum<{
23
+ file_exists: "file_exists";
24
+ min_file_count: "min_file_count";
25
+ min_file_count_matches_source: "min_file_count_matches_source";
26
+ frontmatter_valid: "frontmatter_valid";
27
+ frontmatter_required_keys: "frontmatter_required_keys";
28
+ wikilinks_valid: "wikilinks_valid";
29
+ must_not_contain: "must_not_contain";
30
+ must_contain: "must_contain";
31
+ qa_match: "qa_match";
32
+ }>;
33
+ description: z.ZodOptional<z.ZodString>;
34
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
+ required: z.ZodDefault<z.ZodBoolean>;
36
+ }, z.core.$strict>>>;
37
+ built_by_stages: z.ZodDefault<z.ZodArray<z.ZodString>>;
38
+ }, z.core.$strict>>;
39
+ }, z.core.$strict>;
28
40
  export declare const MethodInputSpecSchema: z.ZodObject<{
29
41
  id: z.ZodString;
30
42
  label: z.ZodString;
@@ -33,24 +45,25 @@ export declare const MethodInputSpecSchema: z.ZodObject<{
33
45
  examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
46
  }, z.core.$strict>;
35
47
  export type ContextInterface = MethodCompiledSchema;
36
- export type ContextInterfaceZone = MethodCompiledZone;
37
- export type ContextInterfaceZoneId = MethodZoneId;
48
+ export type ContextInterfaceArtifact = MethodCompiledArtifact;
49
+ export type ContextInterfaceArtifactId = MethodArtifactId;
38
50
  export type MethodInputSpec = z.infer<typeof MethodInputSpecSchema>;
39
51
  interface ContextInterfaceStageLike {
40
52
  id: string;
41
53
  writes: readonly string[];
42
54
  }
43
55
  interface ContextInterfaceSummary {
44
- inputZones: ContextInterfaceZone[];
45
- workingZones: ContextInterfaceZone[];
46
- outputZones: ContextInterfaceZone[];
47
- runtimeZones: ContextInterfaceZone[];
56
+ inputArtifacts: ContextInterfaceArtifact[];
57
+ workingArtifacts: ContextInterfaceArtifact[];
58
+ outputArtifacts: ContextInterfaceArtifact[];
59
+ runtimeArtifacts: ContextInterfaceArtifact[];
48
60
  }
61
+ export declare function listContextInterfaceArtifacts(contextInterface: ContextInterface): ContextInterfaceArtifact[];
49
62
  export declare function contextInterfaceFilePath(rootPath: string): string;
50
63
  export declare function resolveContextInterfacePath(rootPath: string): string | null;
51
64
  export declare function contextInterfaceExists(rootPath: string): boolean;
52
- export declare function contextInterfaceZoneAbsolutePath(compiledPath: string, zone: Pick<ContextInterfaceZone, "path">): string;
53
- export declare function contextInterfaceArtifactPath(zone: Pick<ContextInterfaceZone, "path" | "kind">): string;
65
+ export declare function contextInterfaceArtifactAbsolutePath(compiledPath: string, artifact: Pick<ContextInterfaceArtifact, "path">): string;
66
+ export declare function contextInterfaceArtifactPath(artifact: Pick<ContextInterfaceArtifact, "path" | "kind">): string;
54
67
  export declare function summarizeContextInterface(contextInterface: ContextInterface): ContextInterfaceSummary;
55
68
  export declare function deriveMethodInputsFromContextInterface(contextInterface: ContextInterface | null | undefined): MethodInputSpec[];
56
69
  export declare function buildContextInterface(stages: ContextInterfaceStageLike[], label?: string): ContextInterface;
@@ -3,8 +3,8 @@ import { join } from "node:path";
3
3
  import { z } from "zod";
4
4
  import { warnInterf } from "../../contracts/utils/logger.js";
5
5
  import { readJsonFileUnchecked } from "../../contracts/utils/parse.js";
6
- import { MethodCompiledSchemaSchema, MethodZoneIdSchema, } from "../../engine/compile/lib/schema.js";
7
- import { listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "./builtin-compiled-method.js";
6
+ import { MethodCompiledSchemaSchema, MethodArtifactIdSchema, } from "../../engine/compile/lib/schema.js";
7
+ import { listBuiltinCompiledArtifactSpecs, requiredCompiledArtifactOwners, } from "./builtin-compiled-method.js";
8
8
  // Method packages define the context interface. The compiler persists the
9
9
  // same schema on disk, but higher layers should prefer this boundary when they
10
10
  // mean "the Method-declared shape a portable context must implement."
@@ -15,7 +15,7 @@ export const ContextInterfaceSchema = MethodCompiledSchemaSchema;
15
15
  // Method expects to organize before the compiler materializes the context
16
16
  // interface on disk.
17
17
  export const MethodInputSpecSchema = z.object({
18
- id: MethodZoneIdSchema,
18
+ id: MethodArtifactIdSchema,
19
19
  label: z.string().min(1),
20
20
  description: z.string().min(1),
21
21
  required: z.boolean().default(false),
@@ -27,13 +27,23 @@ function normalizeContextInterface(contextInterface) {
27
27
  kind: "method-schema",
28
28
  };
29
29
  }
30
- function pushContextInterfaceZone(zones, zone) {
31
- if (zones.some((existing) => existing.path === zone.path))
32
- return;
33
- zones.push(zone);
30
+ function artifactToMethodArtifact(artifact) {
31
+ const path = artifact.shape.kind === "path" ? artifact.shape.path : artifact.id;
32
+ return {
33
+ id: artifact.id,
34
+ role: "output",
35
+ path,
36
+ kind: artifact.shape.kind === "path" ? artifact.shape.artifact_kind : "directory",
37
+ required: true,
38
+ owned_by: [...artifact.built_by_stages],
39
+ description: artifact.description,
40
+ };
34
41
  }
35
- function titleCaseZoneId(zoneId) {
36
- return zoneId
42
+ export function listContextInterfaceArtifacts(contextInterface) {
43
+ return contextInterface.artifacts.map(artifactToMethodArtifact);
44
+ }
45
+ function titleCaseArtifactId(artifactId) {
46
+ return artifactId
37
47
  .split("-")
38
48
  .filter(Boolean)
39
49
  .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
@@ -49,53 +59,52 @@ export function resolveContextInterfacePath(rootPath) {
49
59
  export function contextInterfaceExists(rootPath) {
50
60
  return existsSync(contextInterfaceFilePath(rootPath));
51
61
  }
52
- export function contextInterfaceZoneAbsolutePath(compiledPath, zone) {
53
- return join(compiledPath, zone.path);
62
+ export function contextInterfaceArtifactAbsolutePath(compiledPath, artifact) {
63
+ return join(compiledPath, artifact.path);
54
64
  }
55
- export function contextInterfaceArtifactPath(zone) {
56
- if (zone.kind === "file")
57
- return zone.path;
58
- return zone.path.endsWith("/") ? zone.path : `${zone.path}/`;
65
+ export function contextInterfaceArtifactPath(artifact) {
66
+ if (artifact.kind === "file")
67
+ return artifact.path;
68
+ return artifact.path.endsWith("/") ? artifact.path : `${artifact.path}/`;
59
69
  }
60
70
  export function summarizeContextInterface(contextInterface) {
71
+ const artifacts = listContextInterfaceArtifacts(contextInterface);
61
72
  return {
62
- inputZones: contextInterface.zones.filter((zone) => zone.role === "input"),
63
- workingZones: contextInterface.zones.filter((zone) => zone.role === "working"),
64
- outputZones: contextInterface.zones.filter((zone) => zone.role === "output"),
65
- runtimeZones: contextInterface.zones.filter((zone) => zone.role === "runtime"),
73
+ inputArtifacts: artifacts.filter((artifact) => artifact.role === "input"),
74
+ workingArtifacts: artifacts.filter((artifact) => artifact.role === "working"),
75
+ outputArtifacts: artifacts.filter((artifact) => artifact.role === "output"),
76
+ runtimeArtifacts: artifacts.filter((artifact) => artifact.role === "runtime"),
66
77
  };
67
78
  }
68
79
  export function deriveMethodInputsFromContextInterface(contextInterface) {
69
80
  if (!contextInterface)
70
81
  return [];
71
- return contextInterface.zones
72
- .filter((zone) => zone.role === "input")
73
- .map((zone) => ({
74
- id: zone.id,
75
- label: titleCaseZoneId(zone.id),
76
- description: zone.description,
77
- required: zone.required,
82
+ return listContextInterfaceArtifacts(contextInterface)
83
+ .filter((artifact) => artifact.role === "input")
84
+ .map((artifact) => ({
85
+ id: artifact.id,
86
+ label: titleCaseArtifactId(artifact.id),
87
+ description: artifact.description,
88
+ required: artifact.required,
78
89
  }));
79
90
  }
80
91
  export function buildContextInterface(stages, label = "Method context interface") {
81
- const zones = [];
82
- for (const zone of listBuiltinCompiledZoneSpecs()) {
83
- pushContextInterfaceZone(zones, {
84
- id: zone.id,
85
- role: zone.role,
86
- path: zone.path,
87
- kind: zone.kind,
88
- required: zone.required,
89
- owned_by: requiredCompiledZoneOwners(stages, zone.id),
90
- description: zone.description,
91
- });
92
- }
93
92
  return {
94
93
  kind: "method-schema",
95
94
  version: 1,
96
95
  target_type: "compiled",
97
96
  label,
98
- zones,
97
+ artifacts: listBuiltinCompiledArtifactSpecs().map((artifact) => ({
98
+ id: artifact.id,
99
+ description: artifact.description,
100
+ shape: {
101
+ kind: "path",
102
+ path: artifact.path,
103
+ artifact_kind: artifact.kind === "file" ? "file" : "directory",
104
+ },
105
+ checks: [],
106
+ built_by_stages: requiredCompiledArtifactOwners(stages, artifact.id),
107
+ })),
99
108
  };
100
109
  }
101
110
  export function writeContextInterfaceFile(rootPath, stages, label) {