@interf/compiler 0.4.0 → 0.5.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 (160) hide show
  1. package/README.md +71 -69
  2. package/builtin-workflows/interf/README.md +6 -6
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
  6. package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
  7. package/builtin-workflows/interf/improve/SKILL.md +3 -3
  8. package/builtin-workflows/interf/use/query/SKILL.md +2 -2
  9. package/builtin-workflows/interf/workflow.json +42 -31
  10. package/dist/commands/check-draft.d.ts +19 -0
  11. package/dist/commands/check-draft.js +110 -0
  12. package/dist/commands/compile-controller.d.ts +4 -4
  13. package/dist/commands/compile-controller.js +117 -81
  14. package/dist/commands/compile.d.ts +5 -5
  15. package/dist/commands/compile.js +61 -62
  16. package/dist/commands/compiled-flow.d.ts +23 -0
  17. package/dist/commands/compiled-flow.js +112 -0
  18. package/dist/commands/create-workflow-wizard.d.ts +3 -3
  19. package/dist/commands/create-workflow-wizard.js +11 -11
  20. package/dist/commands/create.d.ts +2 -2
  21. package/dist/commands/create.js +50 -57
  22. package/dist/commands/default.js +2 -2
  23. package/dist/commands/executor-flow.d.ts +20 -1
  24. package/dist/commands/executor-flow.js +67 -7
  25. package/dist/commands/init.js +242 -289
  26. package/dist/commands/list.js +14 -10
  27. package/dist/commands/reset.js +6 -6
  28. package/dist/commands/source-config-wizard.d.ts +12 -8
  29. package/dist/commands/source-config-wizard.js +356 -119
  30. package/dist/commands/status.js +49 -26
  31. package/dist/commands/test-flow.d.ts +23 -10
  32. package/dist/commands/test-flow.js +278 -58
  33. package/dist/commands/test.d.ts +7 -1
  34. package/dist/commands/test.js +264 -65
  35. package/dist/commands/verify.js +23 -14
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +4 -4
  38. package/dist/lib/agent-args.js +2 -1
  39. package/dist/lib/agent-constants.js +1 -1
  40. package/dist/lib/agent-render.js +4 -4
  41. package/dist/lib/agent-shells.d.ts +8 -8
  42. package/dist/lib/agent-shells.js +231 -142
  43. package/dist/lib/compiled-compile.d.ts +52 -0
  44. package/dist/lib/compiled-compile.js +274 -0
  45. package/dist/lib/compiled-home.d.ts +5 -0
  46. package/dist/lib/compiled-home.js +32 -0
  47. package/dist/lib/compiled-layout.d.ts +2 -0
  48. package/dist/lib/compiled-layout.js +60 -0
  49. package/dist/lib/compiled-paths.d.ts +41 -0
  50. package/dist/lib/compiled-paths.js +111 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
  52. package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
  53. package/dist/lib/compiled-reset.d.ts +1 -0
  54. package/dist/lib/compiled-reset.js +44 -0
  55. package/dist/lib/compiled-schema.d.ts +27 -0
  56. package/dist/lib/compiled-schema.js +110 -0
  57. package/dist/lib/config.d.ts +0 -1
  58. package/dist/lib/config.js +0 -1
  59. package/dist/lib/discovery.d.ts +1 -1
  60. package/dist/lib/discovery.js +3 -3
  61. package/dist/lib/interf-bootstrap.d.ts +1 -1
  62. package/dist/lib/interf-bootstrap.js +4 -4
  63. package/dist/lib/interf-detect.d.ts +10 -10
  64. package/dist/lib/interf-detect.js +78 -56
  65. package/dist/lib/interf-scaffold.d.ts +2 -2
  66. package/dist/lib/interf-scaffold.js +90 -57
  67. package/dist/lib/interf-workflow-package.d.ts +3 -3
  68. package/dist/lib/interf-workflow-package.js +30 -30
  69. package/dist/lib/interf.d.ts +5 -5
  70. package/dist/lib/interf.js +4 -4
  71. package/dist/lib/local-workflows.d.ts +4 -4
  72. package/dist/lib/local-workflows.js +35 -70
  73. package/dist/lib/obsidian.d.ts +1 -1
  74. package/dist/lib/parse.js +92 -1
  75. package/dist/lib/project-paths.d.ts +13 -0
  76. package/dist/lib/project-paths.js +29 -0
  77. package/dist/lib/runtime-acceptance.d.ts +7 -1
  78. package/dist/lib/runtime-acceptance.js +194 -59
  79. package/dist/lib/runtime-contracts.d.ts +2 -4
  80. package/dist/lib/runtime-contracts.js +17 -161
  81. package/dist/lib/runtime-inventory.d.ts +7 -0
  82. package/dist/lib/runtime-inventory.js +29 -0
  83. package/dist/lib/runtime-paths.js +5 -5
  84. package/dist/lib/runtime-prompt.js +9 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +92 -171
  87. package/dist/lib/runtime-runs.js +30 -39
  88. package/dist/lib/runtime-types.d.ts +10 -19
  89. package/dist/lib/runtime.d.ts +2 -2
  90. package/dist/lib/runtime.js +1 -1
  91. package/dist/lib/schema.d.ts +163 -140
  92. package/dist/lib/schema.js +163 -124
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +154 -116
  95. package/dist/lib/state-artifacts.d.ts +5 -5
  96. package/dist/lib/state-artifacts.js +8 -8
  97. package/dist/lib/state-health.d.ts +4 -4
  98. package/dist/lib/state-health.js +108 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +77 -50
  101. package/dist/lib/state-paths.js +5 -5
  102. package/dist/lib/state-view.d.ts +4 -4
  103. package/dist/lib/state-view.js +52 -55
  104. package/dist/lib/state.d.ts +5 -5
  105. package/dist/lib/state.js +4 -4
  106. package/dist/lib/summarize-plan.d.ts +3 -2
  107. package/dist/lib/summarize-plan.js +18 -16
  108. package/dist/lib/test-execution.js +9 -9
  109. package/dist/lib/test-matrices.d.ts +3 -3
  110. package/dist/lib/test-matrices.js +6 -6
  111. package/dist/lib/test-paths.d.ts +4 -4
  112. package/dist/lib/test-paths.js +16 -10
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +38 -31
  115. package/dist/lib/test-targets.d.ts +2 -2
  116. package/dist/lib/test-targets.js +11 -11
  117. package/dist/lib/test-types.d.ts +1 -1
  118. package/dist/lib/test.d.ts +1 -1
  119. package/dist/lib/test.js +1 -1
  120. package/dist/lib/util.d.ts +2 -0
  121. package/dist/lib/util.js +14 -1
  122. package/dist/lib/validate-compiled.d.ts +27 -0
  123. package/dist/lib/validate-compiled.js +236 -0
  124. package/dist/lib/validate-helpers.d.ts +0 -8
  125. package/dist/lib/validate-helpers.js +0 -30
  126. package/dist/lib/validate.d.ts +4 -4
  127. package/dist/lib/validate.js +49 -15
  128. package/dist/lib/workflow-abi.d.ts +37 -46
  129. package/dist/lib/workflow-abi.js +51 -76
  130. package/dist/lib/workflow-definitions.d.ts +11 -11
  131. package/dist/lib/workflow-definitions.js +36 -53
  132. package/dist/lib/workflow-helpers.d.ts +2 -3
  133. package/dist/lib/workflow-helpers.js +9 -13
  134. package/dist/lib/workflow-improvement.d.ts +3 -3
  135. package/dist/lib/workflow-improvement.js +48 -48
  136. package/dist/lib/workflow-review-paths.d.ts +3 -3
  137. package/dist/lib/workflow-review-paths.js +11 -11
  138. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  139. package/dist/lib/workflow-stage-runner.js +8 -8
  140. package/dist/lib/workflows.d.ts +9 -9
  141. package/dist/lib/workflows.js +15 -17
  142. package/package.json +10 -9
  143. package/dist/commands/workspace-flow.d.ts +0 -23
  144. package/dist/commands/workspace-flow.js +0 -109
  145. package/dist/lib/registry.d.ts +0 -16
  146. package/dist/lib/registry.js +0 -65
  147. package/dist/lib/validate-workspace.d.ts +0 -121
  148. package/dist/lib/validate-workspace.js +0 -407
  149. package/dist/lib/workspace-compile.d.ts +0 -54
  150. package/dist/lib/workspace-compile.js +0 -476
  151. package/dist/lib/workspace-home.d.ts +0 -5
  152. package/dist/lib/workspace-home.js +0 -32
  153. package/dist/lib/workspace-layout.d.ts +0 -2
  154. package/dist/lib/workspace-layout.js +0 -60
  155. package/dist/lib/workspace-paths.d.ts +0 -41
  156. package/dist/lib/workspace-paths.js +0 -107
  157. package/dist/lib/workspace-reset.d.ts +0 -1
  158. package/dist/lib/workspace-reset.js +0 -43
  159. package/dist/lib/workspace-schema.d.ts +0 -17
  160. package/dist/lib/workspace-schema.js +0 -74
@@ -2,8 +2,8 @@ import { cpSync, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, re
2
2
  import { basename, dirname, join, relative } from "node:path";
3
3
  import { CHART_APPROXIMATION_NOTES } from "./chart-guidance.js";
4
4
  import { WORKFLOW_PACKAGE_DIR } from "./interf-detect.js";
5
- import { ensureWorkspaceZoneTargets, readWorkspaceSchemaFile, workspaceZoneAbsolutePath, } from "./workspace-schema.js";
6
- import { stageExecutionShellsRoot, workflowImprovementLoopRoot, workflowPackagePathForWorkspace, workspaceInterfConfigPath, workspaceRuntimeRoot, } from "./workspace-paths.js";
5
+ import { ensureCompiledZoneTargets, readCompiledSchemaFile, compiledZoneAbsolutePath, } from "./compiled-schema.js";
6
+ import { stageExecutionShellsRoot, workflowImprovementLoopRoot, workflowPackagePathForCompiled, compiledInterfConfigPath, compiledRuntimeRoot, } from "./compiled-paths.js";
7
7
  import { resolveWorkflowImprovementReviewSourcePaths } from "./workflow-review-paths.js";
8
8
  const LOCAL_SKILL_ROOTS = [
9
9
  ".claude/skills",
@@ -19,16 +19,25 @@ function writeNativeAgentSurface(rootPath, agentsContent, skillName, skillConten
19
19
  changed = writeNativeSkillCopies(rootPath, skillName, skillContent) || changed;
20
20
  return changed;
21
21
  }
22
- function workspaceQuerySkillSourcePath(workspacePath) {
23
- return join(workflowPackagePathForWorkspace(workspacePath), "use", "query", "SKILL.md");
22
+ function compiledQuerySkillSourcePath(compiledPath) {
23
+ return join(workflowPackagePathForCompiled(compiledPath), "use", "query", "SKILL.md");
24
24
  }
25
- export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
25
+ function compiledZoneSummaryLines(compiledPath) {
26
+ const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
27
+ if (!schema)
28
+ return ["- No compiled schema is available yet."];
29
+ return schema.zones
30
+ .filter((zone) => zone.id !== "raw" && zone.kind !== "runtime")
31
+ .map((zone) => `- \`${zone.id}\` -> \`${zone.path}\` (${zone.kind})`);
32
+ }
33
+ export function renderCompiledAgents(compiledPath, name, workflowId, about, options = {}) {
26
34
  const workflowOriginSelected = options.workflowOriginSelected ?? workflowId;
27
35
  const workflowLocalDraft = options.workflowLocalDraft === true;
36
+ const zoneLines = compiledZoneSummaryLines(compiledPath);
28
37
  return [
29
38
  `# ${name}`,
30
39
  "",
31
- "This is a compiled workspace built by Interf Compiler.",
40
+ "This is a compiled dataset built by Interf Compiler.",
32
41
  "It is a file-based layer on top of the raw files, built for agents to navigate, retrieve evidence, and answer more accurately.",
33
42
  "",
34
43
  ...(about
@@ -37,51 +46,48 @@ export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
37
46
  "",
38
47
  ]
39
48
  : []),
40
- "## How to use this workspace",
49
+ "## How to use this compiled dataset",
41
50
  "",
42
- "1. Use the local native `interf-query` skill that Interf Compiler generated for this workspace.",
43
- "2. Start from `home.md`, then use `knowledge/` and `summaries/`.",
51
+ "1. Use the local native `interf-query` skill that Interf Compiler generated for this compiled dataset.",
52
+ "2. Let the workflow docs and compiled output zones guide retrieval instead of assuming a fixed note layout.",
44
53
  "3. Use `raw/` when you need direct quotes, exact chart values, table lookups, or verification.",
45
54
  "",
46
- "## How this workspace works",
55
+ "## How this compiled dataset works",
47
56
  "",
48
- "- `.interf/interf.json` points to the workspace-local `raw/` snapshot via `source.path` and back to the dataset control plane via `source.control_path`.",
57
+ "- `.interf/interf.json` points to the local `raw/` snapshot via `source.path` and back to the dataset control plane via `source.control_path`.",
49
58
  `- Workflow seed: \`${workflowOriginSelected}\`.`,
50
59
  ...(workflowLocalDraft
51
- ? ["- This workspace now carries a local workflow draft improved from that seed. Recompiling this workspace reuses the local `.interf/workflow/` package."]
60
+ ? ["- This compiled dataset now carries a local workflow draft improved from that seed. Recompiling this compiled dataset reuses the local `.interf/workflow/` package."]
52
61
  : []),
53
62
  `- Active local workflow id: \`${workflowId}\`.`,
54
- "- `.interf/workflow/` is the local editable method package for this workspace.",
55
- "- `.interf/workflow/workspace.schema.json` is the deterministic output shape for this workspace.",
63
+ "- `.interf/workflow/` is the local editable method package for this compiled dataset.",
64
+ "- `.interf/workflow/compiled.schema.json` is the deterministic output shape for this compiled dataset.",
56
65
  "- `.interf/workflow/improve/` is the editable source for workflow-improvement loops.",
57
66
  "- `.interf/workflow/use/query/` is the editable source for the generated native query shell.",
58
67
  "- `.interf/workflow/compile/stages/` defines stage-specific docs that Interf Compiler projects into native execution shells for automated runs.",
59
68
  "- Native local query skills are generated under local agent skill directories such as `.claude/skills/` and `.codex/skills/`.",
60
- "- `raw/` contains the workspace-local raw snapshot used for evidence and verification.",
61
- "- `summaries/` contains per-file evidence objects.",
62
- "- `knowledge/` contains the cross-file knowledge layer and navigation structure.",
63
- "- `home.md` is the starting note.",
69
+ "- `raw/` contains the local raw snapshot used for evidence and verification.",
70
+ "- Compiled output zones are declared in `.interf/workflow/compiled.schema.json`.",
71
+ ...zoneLines,
64
72
  "- `.interf/runtime/` holds CLI-owned runtime artifacts.",
65
- "- `.interf/tests/` holds saved raw-vs-compiled test comparisons for this workspace.",
73
+ "- `.interf/tests/` holds saved raw-vs-compiled test comparisons for this compiled dataset.",
66
74
  "- `.interf/tests/targets/` holds detailed raw and compiled target runs plus preserved test sandboxes.",
67
75
  "",
68
76
  "## Manual query rules",
69
77
  "",
70
- "- Prefer `home.md`, `knowledge/`, and `summaries/` before `raw/`.",
78
+ "- Prefer the workflow-declared compiled outputs before `raw/`.",
71
79
  "- Use the generated native `interf-query` skill for manual querying. The editable source lives at `.interf/workflow/use/query/SKILL.md`.",
72
80
  "- Treat `.interf/` as method/runtime metadata, not answer evidence, unless explicitly asked to inspect workflow or test history.",
73
81
  "- Use `raw/` for quotes, verification, ambiguity, or evidence the compiled layer does not expose well.",
74
- "- If the compiled layer already contains a bounded chart-derived read for the exact metric and year the user asked about, answer from that compiled read first.",
75
82
  "- If exact chart, table, or image-derived evidence matters, inspect the raw source and say whether the answer was text-derived, table-derived, or chart-derived.",
76
83
  "",
77
84
  "## Commands",
78
85
  "",
79
86
  "```",
80
- "interf compile build this compiled workspace",
81
- "interf test run saved truth checks against this workspace",
82
- "interf verify summarize verify summary coverage",
83
- "interf verify structure verify cross-file structure outputs",
84
- "interf verify compile verify compile outputs",
87
+ "interf compile build this compiled dataset",
88
+ "interf test run saved truth checks against this compiled dataset",
89
+ "interf verify stage <id> verify one workflow stage",
90
+ "interf verify compiled verify the full workflow output",
85
91
  "interf status show deterministic health",
86
92
  "```",
87
93
  "",
@@ -93,7 +99,7 @@ export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
93
99
  "",
94
100
  ].join("\n");
95
101
  }
96
- export function renderWorkspaceQuerySkill() {
102
+ export function renderCompiledQuerySkill() {
97
103
  const chartNotes = CHART_APPROXIMATION_NOTES.map((note) => `- ${note.toLowerCase()}`);
98
104
  return [
99
105
  "# Manual Query Loop",
@@ -101,24 +107,19 @@ export function renderWorkspaceQuerySkill() {
101
107
  "This file is the editable authoring source for the generated native local `interf-query` skill.",
102
108
  "",
103
109
  "Default loop:",
104
- "1. Read `home.md` first.",
105
- "2. Browse `knowledge/` before `raw/`.",
106
- "3. Use `summaries/` for source-grounded evidence.",
107
- "4. Use `raw/` for direct quotes, verification, exact table lookups, and cases where the compiled layer is missing or ambiguous.",
110
+ "1. Read `workflow/README.md` and this file first.",
111
+ "2. Use the compiled output zones declared in `workflow/compiled.schema.json` before falling back to `raw/`.",
112
+ "3. Use `raw/` for direct quotes, verification, exact table lookups, and cases where the compiled layer is missing or ambiguous.",
108
113
  "",
109
114
  "Answering rule:",
110
115
  "- do not modify files under `raw/`",
116
+ "- treat the workflow package as the method layer and the compiled zones as the working retrieval surface",
111
117
  "- when a number is chart-derived, say that explicitly",
112
- "- if the compiled layer already contains a bounded chart-derived read for the exact metric and year, answer from that compiled read first",
113
- "- use `raw/` to confirm source page, metric family, or provenance, not to replace a good compiled bounded read with a second incompatible range",
114
- "- when the compiled layer preserves a bounded chart-derived range, keep that bounded range in the answer instead of collapsing it to a midpoint or pseudo-exact single value",
115
- "- when reading charts, verify you are on the correct metric family and year before answering",
116
- "- keep historical annual charts separate from current-quarter snapshots, sector splits, or nearby lookalike panels",
118
+ "- use `raw/` to confirm source page, metric family, or provenance when the compiled layer is missing or ambiguous",
117
119
  ...chartNotes,
118
- "- if multiple compiled notes mention the same chart read, keep the answer consistent with the most focused workspace note instead of synthesizing a new midpoint or shifted band",
119
120
  "- when the compiled layer is insufficient, verify in `raw/` and then answer",
120
121
  "",
121
- "You can edit this file to bias manual question-answering behavior for this workspace.",
122
+ "You can edit this file to bias manual question-answering behavior for this compiled dataset.",
122
123
  "",
123
124
  ].join("\n");
124
125
  }
@@ -128,7 +129,7 @@ function renderRawTestAgents() {
128
129
  "# Raw Test Shell",
129
130
  "",
130
131
  "This is an isolated raw-files test shell generated by Interf Compiler.",
131
- "There is no compiled workspace in this shell.",
132
+ "There is no compiled dataset in this shell.",
132
133
  "",
133
134
  "## How to use this shell",
134
135
  "",
@@ -139,7 +140,7 @@ function renderRawTestAgents() {
139
140
  "## Rules",
140
141
  "",
141
142
  "- Answer only from the files under `raw/`.",
142
- "- There is no compiled workspace here, so do not assume `home.md`, `knowledge/`, or `summaries/` exist.",
143
+ "- There is no compiled dataset here, so do not assume any compiled output zones exist.",
143
144
  "- Do not treat hidden runtime files or test artifacts as evidence.",
144
145
  ...chartNotes,
145
146
  "- Write the requested answer and trace files, then stop.",
@@ -164,14 +165,14 @@ function renderRawTestQuerySkill() {
164
165
  "1. Read `raw/` directly.",
165
166
  "2. Verify exact claims against the raw files before answering strongly.",
166
167
  ...chartNotes,
167
- "8. Do not rely on compiled workspace artifacts because they do not exist in this shell.",
168
+ "8. Do not rely on compiled dataset artifacts because they do not exist in this shell.",
168
169
  "",
169
170
  ].join("\n");
170
171
  }
171
- function readWorkspaceQuerySkillSource(workspacePath) {
172
- const filePath = workspaceQuerySkillSourcePath(workspacePath);
172
+ function readCompiledQuerySkillSource(compiledPath) {
173
+ const filePath = compiledQuerySkillSourcePath(compiledPath);
173
174
  if (!existsSync(filePath)) {
174
- throw new Error(`Missing workspace query skill source at ${filePath}. Interf compile runs the workspace-local workflow package directly, so reseed or repair this workspace instead of auto-healing query docs.`);
175
+ throw new Error(`Missing compiled query skill source at ${filePath}. Interf compile runs the local workflow package directly, so reseed or repair this compiled dataset instead of auto-healing query docs.`);
175
176
  }
176
177
  return readFileSync(filePath, "utf8").trim();
177
178
  }
@@ -224,11 +225,11 @@ function linkRelativePath(targetPath, linkPathname) {
224
225
  mkdirSync(dirname(linkPathname), { recursive: true });
225
226
  symlinkSync(relative(dirname(linkPathname), targetPath), linkPathname);
226
227
  }
227
- function loadWorkspaceSchema(workspacePath) {
228
- const workflowRoot = workflowPackagePathForWorkspace(workspacePath);
229
- const schema = readWorkspaceSchemaFile(workflowRoot);
228
+ function loadCompiledSchema(compiledPath) {
229
+ const workflowRoot = workflowPackagePathForCompiled(compiledPath);
230
+ const schema = readCompiledSchemaFile(workflowRoot);
230
231
  if (!schema) {
231
- throw new Error(`Missing workflow workspace schema at ${join(workflowRoot, "workspace.schema.json")}`);
232
+ throw new Error(`Missing workflow compiled schema at ${join(workflowRoot, "compiled.schema.json")}`);
232
233
  }
233
234
  return schema;
234
235
  }
@@ -238,29 +239,78 @@ function zoneMap(schema) {
238
239
  function zoneOrThrow(zones, zoneId) {
239
240
  const zone = zones.get(zoneId);
240
241
  if (!zone) {
241
- throw new Error(`Missing workspace schema zone "${zoneId}" for stage shell projection.`);
242
+ throw new Error(`Missing compiled schema zone "${zoneId}" for stage shell projection.`);
242
243
  }
243
244
  return zone;
244
245
  }
245
- function ensureWorkspaceExecutionSurface(workspacePath) {
246
- mkdirSync(workspaceRuntimeRoot(workspacePath), { recursive: true });
247
- mkdirSync(workflowPackagePathForWorkspace(workspacePath), { recursive: true });
248
- const schema = loadWorkspaceSchema(workspacePath);
249
- ensureWorkspaceZoneTargets(workspacePath, schema);
246
+ function normalizeArtifactRelativePath(path) {
247
+ return path
248
+ .replaceAll("\\", "/")
249
+ .replace(/^\.?\//, "")
250
+ .replace(/\/+$/g, "");
251
+ }
252
+ function relativePathEqualsOrWithin(basePath, candidatePath) {
253
+ const base = normalizeArtifactRelativePath(basePath);
254
+ const candidate = normalizeArtifactRelativePath(candidatePath);
255
+ if (base.length === 0 || candidate.length === 0)
256
+ return false;
257
+ return candidate === base || candidate.startsWith(`${base}/`);
258
+ }
259
+ function stageWriteZoneSet(schema, stage) {
260
+ return new Set(stage.writes.filter((zoneId) => schema.zones.some((zone) => zone.id === zoneId)));
261
+ }
262
+ function stageMaterializedZoneSet(schema, stage, writeArtifacts = []) {
263
+ const materialized = stageWriteZoneSet(schema, stage);
264
+ for (const zone of schema.zones) {
265
+ if (zone.kind === "runtime" && stage.reads.includes(zone.id)) {
266
+ materialized.add(zone.id);
267
+ }
268
+ }
269
+ for (const artifactPath of writeArtifacts) {
270
+ const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
271
+ if (normalizedArtifactPath.length === 0)
272
+ continue;
273
+ const owner = schema.zones.find((zone) => relativePathEqualsOrWithin(zone.path, normalizedArtifactPath));
274
+ if (owner) {
275
+ materialized.add(owner.id);
276
+ }
277
+ }
278
+ return materialized;
279
+ }
280
+ function ensureShellLocalProjection(sourcePath, targetPath, zone) {
281
+ if (existsSync(sourcePath)) {
282
+ copyResolvedTree({
283
+ sourcePath,
284
+ targetPath,
285
+ shellType: "stage-execution",
286
+ });
287
+ return;
288
+ }
289
+ if (zone.kind === "file") {
290
+ mkdirSync(dirname(targetPath), { recursive: true });
291
+ return;
292
+ }
293
+ mkdirSync(targetPath, { recursive: true });
294
+ }
295
+ function ensureCompiledExecutionSurface(compiledPath) {
296
+ mkdirSync(compiledRuntimeRoot(compiledPath), { recursive: true });
297
+ mkdirSync(workflowPackagePathForCompiled(compiledPath), { recursive: true });
298
+ const schema = loadCompiledSchema(compiledPath);
299
+ ensureCompiledZoneTargets(compiledPath, schema);
250
300
  return schema;
251
301
  }
252
- function readStageMethodDoc(workspacePath, stage) {
253
- const path = join(workflowPackagePathForWorkspace(workspacePath), "compile", "stages", stage.skillDir, "SKILL.md");
302
+ function readStageMethodDoc(compiledPath, stage) {
303
+ const path = join(workflowPackagePathForCompiled(compiledPath), "compile", "stages", stage.skillDir, "SKILL.md");
254
304
  if (!existsSync(path))
255
305
  return null;
256
306
  return readFileSync(path, "utf8").trim();
257
307
  }
258
- function stageWorkflowDocsPath(workspacePath, stage) {
259
- return join(workflowPackagePathForWorkspace(workspacePath), "compile", "stages", stage.skillDir);
308
+ function stageWorkflowDocsPath(compiledPath, stage) {
309
+ return join(workflowPackagePathForCompiled(compiledPath), "compile", "stages", stage.skillDir);
260
310
  }
261
- function renderStageExecutionAgents(workspaceName, workflowId, stage) {
311
+ function renderStageExecutionAgents(compiledName, workflowId, stage) {
262
312
  return [
263
- `# ${workspaceName} — ${stage.label} Execution Shell`,
313
+ `# ${compiledName} — ${stage.label} Execution Shell`,
264
314
  "",
265
315
  "This is an ephemeral stage-execution shell generated by Interf Compiler.",
266
316
  "It is for automated pipeline execution only, not for manual querying.",
@@ -277,16 +327,16 @@ function renderStageExecutionAgents(workspaceName, workflowId, stage) {
277
327
  "- `inputs/<zone-id>/` = read mounts for the current stage.",
278
328
  "- `outputs/<zone-id>/` = write mounts for the current stage.",
279
329
  "- For file zones, `runtime/paths.json` points to the exact file path inside those mount roots.",
280
- "- declared workspace zone paths are also projected at the shell root so workflow-relative contract paths stay valid.",
330
+ "- declared compiled zone paths are also projected at the shell root so workflow-relative contract paths stay valid.",
281
331
  "- `runtime/` = stage contract and machine-readable path map for this shell.",
282
- "- `workflow/` = workflow metadata, workspace schema, and docs for the current stage only.",
332
+ "- `workflow/` = workflow metadata, compiled schema, and docs for the current stage only.",
283
333
  "",
284
334
  "## Boundaries",
285
335
  "",
286
336
  `- Workflow: \`${workflowId}\`.`,
287
337
  `- Contract type: \`${stage.contractType}\`.`,
288
- "- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the compiled workspace query shell.",
289
- "- The compiled workspace root itself is not linked into this shell.",
338
+ "- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the compiled-dataset query shell.",
339
+ "- The compiled dataset root itself is not linked into this shell.",
290
340
  "- Do not switch into query mode or act like a user-facing assistant.",
291
341
  "- Do not modify files under `inputs/` unless the same zone is also mounted under `outputs/`.",
292
342
  "",
@@ -339,62 +389,68 @@ function renderStageExecutionSkill(stage, stageMethodDoc) {
339
389
  : []),
340
390
  ].join("\n");
341
391
  }
342
- function renderWorkspaceQueryNativeSkill(querySkillContent) {
392
+ function renderCompiledQueryNativeSkill(querySkillContent) {
343
393
  return [
344
394
  "---",
345
395
  "name: interf-query",
346
396
  "description: >",
347
- " Native local query skill for this compiled workspace built by Interf",
348
- " Compiler. Use it for manual questions against the compiled workspace and",
397
+ " Native local query skill for this compiled dataset built by Interf",
398
+ " Compiler. Use it for manual questions against the compiled dataset and",
349
399
  " its raw fallback.",
350
400
  "---",
351
401
  "",
352
402
  "# Interf Compiler Query",
353
403
  "",
354
- "This is the native local query skill for a compiled workspace built by Interf Compiler.",
355
- "Use it when reading this workspace manually.",
404
+ "This is the native local query skill for a compiled dataset built by Interf Compiler.",
405
+ "Use it when reading this compiled dataset manually.",
356
406
  "Editable source: `.interf/workflow/use/query/SKILL.md`.",
357
407
  "",
358
408
  querySkillContent.trim(),
359
409
  "",
360
410
  ].join("\n");
361
411
  }
362
- function projectWorkflowMetadata(workspacePath, shellRoot, stage) {
412
+ function projectWorkflowMetadata(compiledPath, shellRoot, stage) {
363
413
  const shellWorkflowRoot = stageShellWorkflowRoot(shellRoot);
364
414
  mkdirSync(join(shellWorkflowRoot, "compile", "stages"), { recursive: true });
365
- const workspaceWorkflowRoot = workflowPackagePathForWorkspace(workspacePath);
366
- const workflowJsonPath = join(workspaceWorkflowRoot, "workflow.json");
415
+ const compiledWorkflowRoot = workflowPackagePathForCompiled(compiledPath);
416
+ const workflowJsonPath = join(compiledWorkflowRoot, "workflow.json");
367
417
  if (existsSync(workflowJsonPath)) {
368
418
  linkPath(workflowJsonPath, join(shellWorkflowRoot, "workflow.json"));
369
419
  }
370
- const workspaceSchemaPath = join(workspaceWorkflowRoot, "workspace.schema.json");
371
- if (existsSync(workspaceSchemaPath)) {
372
- linkPath(workspaceSchemaPath, join(shellWorkflowRoot, "workspace.schema.json"));
420
+ const compiledSchemaPath = join(compiledWorkflowRoot, "compiled.schema.json");
421
+ if (existsSync(compiledSchemaPath)) {
422
+ linkPath(compiledSchemaPath, join(shellWorkflowRoot, "compiled.schema.json"));
373
423
  }
374
- const readmePath = join(workspaceWorkflowRoot, "README.md");
424
+ const readmePath = join(compiledWorkflowRoot, "README.md");
375
425
  if (existsSync(readmePath)) {
376
426
  linkPath(readmePath, join(shellWorkflowRoot, "README.md"));
377
427
  }
378
- const stageDocsPath = stageWorkflowDocsPath(workspacePath, stage);
428
+ const stageDocsPath = stageWorkflowDocsPath(compiledPath, stage);
379
429
  if (existsSync(stageDocsPath)) {
380
430
  linkPath(stageDocsPath, join(shellWorkflowRoot, "compile", "stages", stage.skillDir));
381
431
  }
382
432
  }
383
- function projectWorkspaceSchemaZones(workspacePath, shellRoot, schema, zoneIds) {
433
+ function projectCompiledSchemaZones(compiledPath, shellRoot, schema, zoneIds, materializedZoneIds) {
384
434
  const allowedZoneIds = zoneIds ? new Set(zoneIds) : null;
385
435
  for (const zone of schema.zones) {
386
436
  if (allowedZoneIds && !allowedZoneIds.has(zone.id))
387
437
  continue;
388
- linkPath(workspaceZoneAbsolutePath(workspacePath, zone), join(shellRoot, zone.path));
438
+ const sourcePath = compiledZoneAbsolutePath(compiledPath, zone);
439
+ const targetPath = join(shellRoot, zone.path);
440
+ if (materializedZoneIds?.has(zone.id)) {
441
+ ensureShellLocalProjection(sourcePath, targetPath, zone);
442
+ continue;
443
+ }
444
+ linkPath(sourcePath, targetPath);
389
445
  }
390
446
  }
391
- function buildStageZoneMounts(workspacePath, shellRoot, stage, schema) {
447
+ function buildStageZoneMounts(compiledPath, shellRoot, stage, schema) {
392
448
  const zones = zoneMap(schema);
393
449
  const mountFor = (zoneId) => {
394
450
  const zone = zoneOrThrow(zones, zoneId);
395
451
  return {
396
452
  zone_id: zone.id,
397
- workspace_path: zone.path,
453
+ compiled_path: zone.path,
398
454
  shell_root_path: zone.path,
399
455
  input_mount_path: stage.reads.includes(zoneId)
400
456
  ? describeShellZoneAliasMountPath(zone, "inputs")
@@ -409,16 +465,16 @@ function buildStageZoneMounts(workspacePath, shellRoot, stage, schema) {
409
465
  writes: stage.writes.map(mountFor),
410
466
  };
411
467
  }
412
- function projectStageZoneMountAliases(workspacePath, shellRoot, stage, schema) {
468
+ function projectStageZoneMountAliases(shellRoot, stage, schema) {
413
469
  const zones = zoneMap(schema);
414
470
  for (const zoneId of new Set([...stage.reads, ...stage.writes])) {
415
471
  const zone = zoneOrThrow(zones, zoneId);
416
- const targetPath = workspaceZoneAbsolutePath(workspacePath, zone);
472
+ const targetPath = join(shellRoot, zone.path);
417
473
  if (stage.reads.includes(zoneId)) {
418
- linkPath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "inputs"));
474
+ linkRelativePath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "inputs"));
419
475
  }
420
476
  if (stage.writes.includes(zoneId)) {
421
- linkPath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "outputs"));
477
+ linkRelativePath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "outputs"));
422
478
  }
423
479
  }
424
480
  }
@@ -433,29 +489,61 @@ function writeExecutionShellPathsFile(shellRoot, workflowId, stage, mounts) {
433
489
  };
434
490
  writeFileSync(shellRuntimePath(shellRoot, "paths.json"), `${JSON.stringify(paths, null, 2)}\n`);
435
491
  }
436
- export function syncStageExecutionShellWrites(workspacePath, shellRoot, stage) {
437
- const schema = ensureWorkspaceExecutionSurface(workspacePath);
492
+ export function syncStageExecutionShellWrites(compiledPath, shellRoot, stage, writeArtifacts = []) {
493
+ const schema = ensureCompiledExecutionSurface(compiledPath);
438
494
  const zones = zoneMap(schema);
439
- for (const zoneId of new Set(stage.writes)) {
440
- const zone = zoneOrThrow(zones, zoneId);
441
- const shellZonePath = join(shellRoot, zone.path);
495
+ const stageWriteZones = Array.from(stageWriteZoneSet(schema, stage))
496
+ .map((zoneId) => zoneOrThrow(zones, zoneId));
497
+ for (const zone of stageWriteZones) {
498
+ const canonicalShellZonePath = join(shellRoot, zone.path);
499
+ const outputAliasPath = shellZoneAliasMountPath(shellRoot, zone, "outputs");
500
+ const shellZonePath = zone.kind === "file" &&
501
+ existsSync(outputAliasPath) &&
502
+ !lstatSync(outputAliasPath).isSymbolicLink()
503
+ ? outputAliasPath
504
+ : canonicalShellZonePath;
442
505
  if (!existsSync(shellZonePath))
443
506
  continue;
444
507
  const shellZoneStat = lstatSync(shellZonePath);
445
508
  if (shellZoneStat.isSymbolicLink())
446
509
  continue;
447
- const workspaceZonePath = workspaceZoneAbsolutePath(workspacePath, zone);
510
+ const compiledZonePath = compiledZoneAbsolutePath(compiledPath, zone);
448
511
  if (shellZoneStat.isDirectory()) {
449
- rmSync(workspaceZonePath, { recursive: true, force: true });
450
- mkdirSync(dirname(workspaceZonePath), { recursive: true });
451
- cpSync(shellZonePath, workspaceZonePath, {
512
+ rmSync(compiledZonePath, { recursive: true, force: true });
513
+ mkdirSync(dirname(compiledZonePath), { recursive: true });
514
+ cpSync(shellZonePath, compiledZonePath, {
515
+ recursive: true,
516
+ force: true,
517
+ });
518
+ continue;
519
+ }
520
+ mkdirSync(dirname(compiledZonePath), { recursive: true });
521
+ copyFileSync(shellZonePath, compiledZonePath);
522
+ }
523
+ for (const artifactPath of writeArtifacts) {
524
+ const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
525
+ if (normalizedArtifactPath.length === 0 ||
526
+ stageWriteZones.some((zone) => relativePathEqualsOrWithin(zone.path, normalizedArtifactPath))) {
527
+ continue;
528
+ }
529
+ const shellArtifactPath = join(shellRoot, normalizedArtifactPath);
530
+ if (!existsSync(shellArtifactPath))
531
+ continue;
532
+ const compiledArtifactPath = join(compiledPath, normalizedArtifactPath);
533
+ const shellArtifactStat = lstatSync(shellArtifactPath);
534
+ if (shellArtifactStat.isSymbolicLink())
535
+ continue;
536
+ if (shellArtifactStat.isDirectory()) {
537
+ rmSync(compiledArtifactPath, { recursive: true, force: true });
538
+ mkdirSync(dirname(compiledArtifactPath), { recursive: true });
539
+ cpSync(shellArtifactPath, compiledArtifactPath, {
452
540
  recursive: true,
453
541
  force: true,
454
542
  });
455
543
  continue;
456
544
  }
457
- mkdirSync(dirname(workspaceZonePath), { recursive: true });
458
- copyFileSync(shellZonePath, workspaceZonePath);
545
+ mkdirSync(dirname(compiledArtifactPath), { recursive: true });
546
+ copyFileSync(shellArtifactPath, compiledArtifactPath);
459
547
  }
460
548
  }
461
549
  function preservedShellManifestPath(rootPath) {
@@ -563,12 +651,12 @@ export function renderClaudeBootstrap(content) {
563
651
  "",
564
652
  ].join("\n");
565
653
  }
566
- function improvementWorkflowDocsPath(workspacePath) {
567
- return join(workflowPackagePathForWorkspace(workspacePath), "improve");
654
+ function improvementWorkflowDocsPath(compiledPath) {
655
+ return join(workflowPackagePathForCompiled(compiledPath), "improve");
568
656
  }
569
- function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
657
+ function renderWorkflowImprovementAgents(compiledName, workflowId, loopIndex) {
570
658
  return [
571
- `# ${workspaceName} — Workflow Improvement Shell`,
659
+ `# ${compiledName} — Workflow Improvement Shell`,
572
660
  "",
573
661
  "This is an automated workflow-improvement shell generated by Interf Compiler.",
574
662
  "It exists to review failed compile/test runs and edit the workflow package for the next variation.",
@@ -576,7 +664,7 @@ function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
576
664
  "## Start Here",
577
665
  "",
578
666
  "1. Read `runtime/loop-context.json` now.",
579
- "2. Read `workflow/README.md`, `workflow/workflow.json`, and `workflow/workspace.schema.json` now.",
667
+ "2. Read `workflow/README.md`, `workflow/workflow.json`, and `workflow/compiled.schema.json` now.",
580
668
  "3. Read `workflow/improve/SKILL.md` now.",
581
669
  "4. Use the local native `interf-workflow-improver` skill now.",
582
670
  "",
@@ -585,20 +673,20 @@ function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
585
673
  `- Workflow: \`${workflowId}\`.`,
586
674
  `- Improvement loop: ${loopIndex}.`,
587
675
  "- Edit only files under `workflow/`.",
588
- "- Do not edit truth checks, test specs, raw dataset files, or generated workspace outputs.",
589
- "- Review compiled outputs under `artifacts/workspace-view/` and test/runtime evidence under `artifacts/`.",
590
- "- Keep the workflow valid for the current compiler API and workspace schema.",
676
+ "- Do not edit truth checks, test specs, raw dataset files, or generated compiled outputs.",
677
+ "- Review compiled outputs under `artifacts/compiled-view/` and test/runtime evidence under `artifacts/`.",
678
+ "- Keep the workflow valid for the current compiler API and compiled schema.",
591
679
  "",
592
680
  "## Goal",
593
681
  "",
594
682
  "- create a better workflow variation for this dataset",
595
- "- preserve deterministic workspace structure",
683
+ "- preserve deterministic compiled structure",
596
684
  "- stop after the workflow edits are complete",
597
685
  "",
598
686
  ].join("\n");
599
687
  }
600
- function readWorkflowImprovementDoc(workspacePath) {
601
- const path = join(improvementWorkflowDocsPath(workspacePath), "SKILL.md");
688
+ function readWorkflowImprovementDoc(compiledPath) {
689
+ const path = join(improvementWorkflowDocsPath(compiledPath), "SKILL.md");
602
690
  if (!existsSync(path))
603
691
  return null;
604
692
  return readFileSync(path, "utf8").trim();
@@ -616,7 +704,7 @@ function renderWorkflowImprovementSkill(workflowId, loopIndex, improvementDoc) {
616
704
  "",
617
705
  "This local native skill exists for automated workflow-improvement loops.",
618
706
  "Read `runtime/loop-context.json` first.",
619
- "Then review the linked workflow package, `artifacts/workspace-view/`, preserved stage shells, runtime logs, and saved test outputs before editing `workflow/`.",
707
+ "Then review the linked workflow package, `artifacts/compiled-view/`, preserved stage shells, runtime logs, and saved test outputs before editing `workflow/`.",
620
708
  "",
621
709
  "## Current Loop",
622
710
  "",
@@ -634,18 +722,18 @@ function renderWorkflowImprovementSkill(workflowId, loopIndex, improvementDoc) {
634
722
  : []),
635
723
  ].join("\n");
636
724
  }
637
- function projectWorkspaceReviewArtifactsSnapshot(workspacePath, shellRoot, schema) {
638
- const workspaceViewRoot = join(shellRoot, "artifacts", "workspace-view");
639
- mkdirSync(workspaceViewRoot, { recursive: true });
725
+ function projectCompiledReviewArtifactsSnapshot(compiledPath, shellRoot, schema) {
726
+ const compiledViewRoot = join(shellRoot, "artifacts", "compiled-view");
727
+ mkdirSync(compiledViewRoot, { recursive: true });
640
728
  for (const zone of schema.zones) {
641
729
  if (zone.kind === "runtime" || zone.path === "raw")
642
730
  continue;
643
- const sourcePath = workspaceZoneAbsolutePath(workspacePath, zone);
731
+ const sourcePath = compiledZoneAbsolutePath(compiledPath, zone);
644
732
  if (!existsSync(sourcePath))
645
733
  continue;
646
734
  copyResolvedTree({
647
735
  sourcePath,
648
- targetPath: join(workspaceViewRoot, zone.path),
736
+ targetPath: join(compiledViewRoot, zone.path),
649
737
  shellType: "workflow-improvement",
650
738
  });
651
739
  }
@@ -664,10 +752,10 @@ function copyIfExists(sourcePath, targetPath, shellType) {
664
752
  shellType,
665
753
  });
666
754
  }
667
- function projectWorkspaceRuntimeArtifacts(workspacePath, shellRoot) {
668
- const runtimeTarget = join(shellRoot, "artifacts", "workspace-runtime");
755
+ function projectCompiledRuntimeArtifacts(compiledPath, shellRoot) {
756
+ const runtimeTarget = join(shellRoot, "artifacts", "compiled-runtime");
669
757
  mkdirSync(runtimeTarget, { recursive: true });
670
- const runtimeRoot = workspaceRuntimeRoot(workspacePath);
758
+ const runtimeRoot = compiledRuntimeRoot(compiledPath);
671
759
  const artifactNames = [
672
760
  "run.json",
673
761
  "run-history.jsonl",
@@ -681,33 +769,34 @@ function projectWorkspaceRuntimeArtifacts(workspacePath, shellRoot) {
681
769
  copyIfExists(join(runtimeRoot, artifactName), join(runtimeTarget, artifactName), "workflow-improvement");
682
770
  }
683
771
  }
684
- export function pruneStageExecutionShells(workspacePath) {
685
- rmSync(stageExecutionShellsRoot(workspacePath), { recursive: true, force: true });
772
+ export function pruneStageExecutionShells(compiledPath) {
773
+ rmSync(stageExecutionShellsRoot(compiledPath), { recursive: true, force: true });
686
774
  }
687
- export function projectWorkspaceQueryShell(workspacePath, workspaceName, workflowId, about, options) {
688
- const agentsContent = renderWorkspaceAgents(workspaceName, workflowId, about, options);
689
- const querySkillContent = readWorkspaceQuerySkillSource(workspacePath);
690
- return writeNativeAgentSurface(workspacePath, agentsContent, "interf-query", renderWorkspaceQueryNativeSkill(querySkillContent));
775
+ export function projectCompiledQueryShell(compiledPath, compiledName, workflowId, about, options) {
776
+ const agentsContent = renderCompiledAgents(compiledPath, compiledName, workflowId, about, options);
777
+ const querySkillContent = readCompiledQuerySkillSource(compiledPath);
778
+ return writeNativeAgentSurface(compiledPath, agentsContent, "interf-query", renderCompiledQueryNativeSkill(querySkillContent));
691
779
  }
692
780
  export function projectRawTestQueryShell(rootPath) {
693
781
  return writeNativeAgentSurface(rootPath, renderRawTestAgents(), "interf-query", renderRawTestQuerySkill());
694
782
  }
695
- export function createStageExecutionShell(workspacePath, workspaceName, workflowId, stage) {
696
- const schema = ensureWorkspaceExecutionSurface(workspacePath);
697
- const shellsRoot = stageExecutionShellsRoot(workspacePath);
783
+ export function createStageExecutionShell(compiledPath, compiledName, workflowId, stage, writeArtifacts = []) {
784
+ const schema = ensureCompiledExecutionSurface(compiledPath);
785
+ const materializedZones = stageMaterializedZoneSet(schema, stage, writeArtifacts);
786
+ const shellsRoot = stageExecutionShellsRoot(compiledPath);
698
787
  const shellRoot = join(shellsRoot, `${stage.id}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`);
699
788
  mkdirSync(shellRoot, { recursive: true });
700
789
  mkdirSync(join(shellRoot, "runtime"), { recursive: true });
701
790
  mkdirSync(join(shellRoot, "inputs"), { recursive: true });
702
791
  mkdirSync(join(shellRoot, "outputs"), { recursive: true });
703
- linkPath(workspaceInterfConfigPath(workspacePath), join(shellRoot, "interf.json"));
704
- linkPath(join(workspaceRuntimeRoot(workspacePath), "stage-contract.json"), shellRuntimePath(shellRoot, "stage-contract.json"));
705
- projectWorkspaceSchemaZones(workspacePath, shellRoot, schema, new Set([...stage.reads, ...stage.writes]));
706
- projectWorkflowMetadata(workspacePath, shellRoot, stage);
707
- projectStageZoneMountAliases(workspacePath, shellRoot, stage, schema);
708
- writeExecutionShellPathsFile(shellRoot, workflowId, stage, buildStageZoneMounts(workspacePath, shellRoot, stage, schema));
709
- const agentsContent = renderStageExecutionAgents(workspaceName, workflowId, stage);
710
- writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(workspacePath, stage)));
792
+ linkPath(compiledInterfConfigPath(compiledPath), join(shellRoot, "interf.json"));
793
+ linkPath(join(compiledRuntimeRoot(compiledPath), "stage-contract.json"), shellRuntimePath(shellRoot, "stage-contract.json"));
794
+ projectCompiledSchemaZones(compiledPath, shellRoot, schema, new Set([...stage.reads, ...stage.writes]), materializedZones);
795
+ projectWorkflowMetadata(compiledPath, shellRoot, stage);
796
+ projectStageZoneMountAliases(shellRoot, stage, schema);
797
+ writeExecutionShellPathsFile(shellRoot, workflowId, stage, buildStageZoneMounts(compiledPath, shellRoot, stage, schema));
798
+ const agentsContent = renderStageExecutionAgents(compiledName, workflowId, stage);
799
+ writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(compiledPath, stage)));
711
800
  return {
712
801
  rootPath: shellRoot,
713
802
  };
@@ -716,19 +805,19 @@ export function freezeStageExecutionShell(rootPath) {
716
805
  return freezePreservedShell(rootPath, "stage-execution");
717
806
  }
718
807
  export function createWorkflowImprovementShell(options) {
719
- const schema = ensureWorkspaceExecutionSurface(options.workspacePath);
720
- const loopRootPath = workflowImprovementLoopRoot(options.workspacePath, options.runId, options.loopIndex);
808
+ const schema = ensureCompiledExecutionSurface(options.compiledPath);
809
+ const loopRootPath = workflowImprovementLoopRoot(options.compiledPath, options.runId, options.loopIndex);
721
810
  const shellRoot = join(loopRootPath, "shell");
722
811
  mkdirSync(shellRoot, { recursive: true });
723
812
  mkdirSync(join(shellRoot, "runtime"), { recursive: true });
724
813
  mkdirSync(join(shellRoot, "artifacts"), { recursive: true });
725
814
  mkdirSync(join(loopRootPath, "logs"), { recursive: true });
726
815
  writeFileSync(join(shellRoot, "runtime", "loop-context.json"), `${JSON.stringify(options.context, null, 2)}\n`);
727
- projectWorkspaceReviewArtifactsSnapshot(options.workspacePath, shellRoot, schema);
728
- linkPath(workflowPackagePathForWorkspace(options.workspacePath), join(shellRoot, "workflow"));
729
- copyIfExists(workspaceInterfConfigPath(options.workspacePath), join(shellRoot, "interf.json"), "workflow-improvement");
730
- projectWorkspaceRuntimeArtifacts(options.workspacePath, shellRoot);
731
- const reviewSources = resolveWorkflowImprovementReviewSourcePaths(options.workspacePath);
816
+ projectCompiledReviewArtifactsSnapshot(options.compiledPath, shellRoot, schema);
817
+ linkPath(workflowPackagePathForCompiled(options.compiledPath), join(shellRoot, "workflow"));
818
+ copyIfExists(compiledInterfConfigPath(options.compiledPath), join(shellRoot, "interf.json"), "workflow-improvement");
819
+ projectCompiledRuntimeArtifacts(options.compiledPath, shellRoot);
820
+ const reviewSources = resolveWorkflowImprovementReviewSourcePaths(options.compiledPath);
732
821
  if (reviewSources.executionShells) {
733
822
  copyIfExists(reviewSources.executionShells, join(shellRoot, "artifacts", "execution-shells"), "workflow-improvement");
734
823
  }
@@ -741,8 +830,8 @@ export function createWorkflowImprovementShell(options) {
741
830
  if (reviewSources.targetTestSandboxes) {
742
831
  copyIfExists(reviewSources.targetTestSandboxes, join(shellRoot, "artifacts", "test-sandboxes"), "workflow-improvement");
743
832
  }
744
- const agentsContent = renderWorkflowImprovementAgents(options.workspaceName, options.workflowId, options.loopIndex);
745
- writeNativeAgentSurface(shellRoot, agentsContent, "interf-workflow-improver", renderWorkflowImprovementSkill(options.workflowId, options.loopIndex, readWorkflowImprovementDoc(options.workspacePath)));
833
+ const agentsContent = renderWorkflowImprovementAgents(options.compiledName, options.workflowId, options.loopIndex);
834
+ writeNativeAgentSurface(shellRoot, agentsContent, "interf-workflow-improver", renderWorkflowImprovementSkill(options.workflowId, options.loopIndex, readWorkflowImprovementDoc(options.compiledPath)));
746
835
  return {
747
836
  rootPath: shellRoot,
748
837
  loopRootPath,