@interf/compiler 0.4.1 → 0.5.1

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 (162) hide show
  1. package/README.md +70 -66
  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 +274 -65
  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/{workflow-abi.d.ts → builtin-compiled-workflow.d.ts} +37 -46
  44. package/dist/lib/builtin-compiled-workflow.js +153 -0
  45. package/dist/lib/compiled-compile.d.ts +52 -0
  46. package/dist/lib/compiled-compile.js +274 -0
  47. package/dist/lib/compiled-home.d.ts +5 -0
  48. package/dist/lib/compiled-home.js +32 -0
  49. package/dist/lib/compiled-paths.d.ts +39 -0
  50. package/dist/lib/compiled-paths.js +103 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +9 -8
  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 +9 -10
  64. package/dist/lib/interf-detect.js +70 -59
  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 +11 -0
  76. package/dist/lib/project-paths.js +32 -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 +7 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +94 -184
  87. package/dist/lib/runtime-runs.js +25 -119
  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 +169 -153
  92. package/dist/lib/schema.js +116 -164
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +159 -122
  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 +110 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +21 -102
  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 +19 -21
  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 +26 -11
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +32 -38
  115. package/dist/lib/test-specs.js +1 -1
  116. package/dist/lib/test-targets.d.ts +2 -2
  117. package/dist/lib/test-targets.js +11 -11
  118. package/dist/lib/test-types.d.ts +1 -1
  119. package/dist/lib/test.d.ts +1 -1
  120. package/dist/lib/test.js +1 -1
  121. package/dist/lib/util.d.ts +2 -0
  122. package/dist/lib/util.js +14 -1
  123. package/dist/lib/validate-compiled.d.ts +27 -0
  124. package/dist/lib/validate-compiled.js +238 -0
  125. package/dist/lib/validate-helpers.d.ts +0 -8
  126. package/dist/lib/validate-helpers.js +0 -30
  127. package/dist/lib/validate.d.ts +6 -4
  128. package/dist/lib/validate.js +76 -27
  129. package/dist/lib/workflow-definitions.d.ts +12 -11
  130. package/dist/lib/workflow-definitions.js +45 -55
  131. package/dist/lib/workflow-helpers.d.ts +2 -3
  132. package/dist/lib/workflow-helpers.js +9 -13
  133. package/dist/lib/workflow-improvement.d.ts +3 -3
  134. package/dist/lib/workflow-improvement.js +48 -48
  135. package/dist/lib/workflow-primitives.d.ts +2 -0
  136. package/dist/lib/workflow-primitives.js +5 -0
  137. package/dist/lib/workflow-review-paths.d.ts +3 -3
  138. package/dist/lib/workflow-review-paths.js +11 -11
  139. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  140. package/dist/lib/workflow-stage-runner.js +8 -8
  141. package/dist/lib/workflows.d.ts +9 -9
  142. package/dist/lib/workflows.js +15 -17
  143. package/package.json +13 -12
  144. package/dist/commands/workspace-flow.d.ts +0 -23
  145. package/dist/commands/workspace-flow.js +0 -109
  146. package/dist/lib/registry.d.ts +0 -16
  147. package/dist/lib/registry.js +0 -65
  148. package/dist/lib/validate-workspace.d.ts +0 -121
  149. package/dist/lib/validate-workspace.js +0 -407
  150. package/dist/lib/workflow-abi.js +0 -181
  151. package/dist/lib/workspace-compile.d.ts +0 -54
  152. package/dist/lib/workspace-compile.js +0 -476
  153. package/dist/lib/workspace-home.d.ts +0 -5
  154. package/dist/lib/workspace-home.js +0 -32
  155. package/dist/lib/workspace-layout.d.ts +0 -2
  156. package/dist/lib/workspace-layout.js +0 -60
  157. package/dist/lib/workspace-paths.d.ts +0 -41
  158. package/dist/lib/workspace-paths.js +0 -107
  159. package/dist/lib/workspace-reset.d.ts +0 -1
  160. package/dist/lib/workspace-reset.js +0 -43
  161. package/dist/lib/workspace-schema.d.ts +0 -17
  162. package/dist/lib/workspace-schema.js +0 -74
@@ -1,35 +1,41 @@
1
1
  import { z } from "zod";
2
- import { WORKSPACE_CONTRACT_TYPES, WORKSPACE_ZONE_KINDS, } from "./workflow-abi.js";
2
+ import { COMPILED_ZONE_KINDS, } from "./workflow-primitives.js";
3
3
  const JsonRecordSchema = z.record(z.string(), z.unknown());
4
- const WORKSPACE_RELATIVE_PATH_SEGMENT = /^(?!\.{1,2}$)[^/\\]+$/;
5
- function isWorkspaceRelativePath(value) {
4
+ const COMPILED_RELATIVE_PATH_SEGMENT = /^(?!\.{1,2}$)[^/\\]+$/;
5
+ function isCompiledRelativePath(value) {
6
6
  if (value.length === 0)
7
7
  return false;
8
8
  if (value.startsWith("/") || value.startsWith("\\"))
9
9
  return false;
10
10
  return value
11
11
  .split(/[\\/]+/)
12
- .every((segment) => WORKSPACE_RELATIVE_PATH_SEGMENT.test(segment));
12
+ .every((segment) => COMPILED_RELATIVE_PATH_SEGMENT.test(segment));
13
13
  }
14
- export const RuntimeTargetTypeSchema = z.enum(["workspace"]);
15
- export const TestTargetTypeSchema = z.enum(["workspace", "raw"]);
14
+ export const RuntimeTargetTypeSchema = z.enum(["compiled"]);
15
+ export const TestTargetTypeSchema = z.enum(["compiled", "raw"]);
16
16
  export const WorkflowIdPattern = /^[a-z0-9][a-z0-9-]{0,79}$/;
17
17
  export const RuntimeStageSchema = z.string().regex(WorkflowIdPattern);
18
- export const RuntimeContractTypeSchema = z.enum(WORKSPACE_CONTRACT_TYPES);
18
+ export const RuntimeContractTypeSchema = z.string().regex(WorkflowIdPattern);
19
19
  export const WorkflowIdSchema = z.string().regex(WorkflowIdPattern);
20
20
  export const WorkflowZoneIdSchema = z.string().regex(WorkflowIdPattern);
21
- export const WorkflowWorkspaceZoneKindSchema = z.enum(WORKSPACE_ZONE_KINDS);
22
- export const WorkspaceStateSchema = z.object({
23
- version: z.literal(1),
21
+ export const WorkflowCompiledZoneKindSchema = z.enum(COMPILED_ZONE_KINDS);
22
+ export const CompiledStageStatusSchema = z.enum(["idle", "running", "succeeded", "failed"]);
23
+ export const CompiledStageStateSchema = z.object({
24
+ contract_type: RuntimeContractTypeSchema.optional(),
25
+ status: CompiledStageStatusSchema.optional(),
26
+ started_at: z.string().nullable().optional(),
27
+ finished_at: z.string().nullable().optional(),
28
+ counts: z.record(z.string(), z.number()).optional(),
29
+ zone_counts: z.record(z.string(), z.number()).optional(),
30
+ artifacts: z.array(z.string()).optional(),
31
+ summary: z.string().nullable().optional(),
32
+ run_id: z.string().nullable().optional(),
33
+ });
34
+ export const CompiledStateSchema = z.object({
35
+ version: z.number().int().min(1),
24
36
  pending: z.array(z.string()),
25
- summarized: z.number(),
26
- structured: z.number().optional(),
27
- shaped: z.number().optional(),
28
- compiled: z.number(),
37
+ stages: z.record(z.string().regex(WorkflowIdPattern), CompiledStageStateSchema).optional(),
29
38
  last_add: z.string().nullable().optional(),
30
- last_summarize: z.string().nullable().optional(),
31
- last_structure: z.string().nullable().optional(),
32
- last_shape: z.string().nullable().optional(),
33
39
  last_compile: z.string().nullable().optional(),
34
40
  inventory_complete: z.boolean().optional(),
35
41
  abstracts_read: z.number().optional(),
@@ -38,7 +44,7 @@ export const WorkspaceStateSchema = z.object({
38
44
  claim_count: z.number().optional(),
39
45
  warning_count: z.number().optional(),
40
46
  error_count: z.number().optional(),
41
- });
47
+ }).strict();
42
48
  export const ViewSectionSchema = z.object({
43
49
  id: z.string(),
44
50
  type: z.enum(["status", "cards", "graph", "documents", "table"]),
@@ -53,57 +59,34 @@ export const ViewCardSchema = z.object({
53
59
  denominator_metric: z.string().optional(),
54
60
  format: z.enum(["number", "fraction", "timestamp"]),
55
61
  });
56
- export const WorkspaceHealthSchema = z.object({
57
- kind: z.literal("workspace-health"),
58
- version: z.literal(1),
62
+ export const CompiledHealthSchema = z.object({
63
+ kind: z.literal("compiled-health"),
64
+ version: z.number().int().min(1),
59
65
  generated_at: z.string(),
60
66
  target_name: z.string(),
61
67
  status: z.enum(["idle", "running", "compiled", "stale", "failed"]),
62
- stage: z.enum(["idle", "summarize", "structure", "shape", "compiled", "failed"]),
68
+ stage: z.union([
69
+ z.enum(["idle", "compiled", "failed"]),
70
+ RuntimeStageSchema,
71
+ ]),
63
72
  summary: z.string(),
64
- metrics: z.object({
65
- source_total: z.number(),
66
- source_covered: z.number(),
67
- summarized: z.number(),
68
- to_summarize: z.number(),
69
- compiled: z.number(),
70
- to_compile: z.number(),
71
- entities: z.number(),
72
- claims: z.number(),
73
- outputs: z.number(),
74
- invalid_frontmatter: z.number(),
75
- short_abstracts: z.number(),
76
- broken_links: z.number(),
77
- warnings: z.number(),
78
- errors: z.number(),
79
- }),
80
- checks: z.object({
81
- config_present: z.boolean(),
82
- config_valid: z.boolean(),
83
- config_type_match: z.boolean(),
84
- summaries_present: z.boolean(),
85
- inventory_present: z.boolean(),
86
- outputs_present: z.boolean(),
87
- home_present: z.boolean(),
88
- summary_frontmatter_valid: z.boolean(),
89
- abstracts_valid: z.boolean(),
90
- links_valid: z.boolean(),
91
- }),
73
+ metrics: z.record(z.string(), z.number()),
74
+ checks: z.record(z.string(), z.boolean()),
92
75
  });
93
- export const WorkspaceViewSpecSchema = z.object({
94
- kind: z.literal("workspace-view-spec"),
95
- version: z.literal(1),
76
+ export const CompiledViewSpecSchema = z.object({
77
+ kind: z.literal("compiled-view-spec"),
78
+ version: z.number().int().min(1),
96
79
  generated_at: z.string(),
97
80
  target_name: z.string(),
98
81
  health_source: z.string(),
99
82
  state_source: z.string(),
100
- default_note: z.string(),
83
+ default_note: z.string().nullable(),
101
84
  graph_scope: z.array(z.string()),
102
85
  cards: z.array(ViewCardSchema),
103
86
  sections: z.array(ViewSectionSchema),
104
87
  });
105
- export const WorkspaceRawSnapshotSchema = z.object({
106
- kind: z.literal("workspace-raw-snapshot"),
88
+ export const CompiledRawSnapshotSchema = z.object({
89
+ kind: z.literal("compiled-raw-snapshot"),
107
90
  version: z.literal(1),
108
91
  generated_at: z.string(),
109
92
  target_name: z.string(),
@@ -112,31 +95,31 @@ export const WorkspaceRawSnapshotSchema = z.object({
112
95
  source_total: z.number(),
113
96
  sample_files: z.array(z.string()),
114
97
  });
115
- export const WorkflowWorkspaceZoneSchema = z.object({
98
+ export const WorkflowCompiledZoneSchema = z.object({
116
99
  id: WorkflowZoneIdSchema,
117
- path: z.string().min(1).refine(isWorkspaceRelativePath, {
118
- message: "Zone paths must stay inside the workspace root",
100
+ path: z.string().min(1).refine(isCompiledRelativePath, {
101
+ message: "Zone paths must stay inside the compiled root",
119
102
  }),
120
- kind: WorkflowWorkspaceZoneKindSchema,
103
+ kind: WorkflowCompiledZoneKindSchema,
121
104
  required: z.boolean(),
122
105
  owned_by: z.array(z.string().regex(WorkflowIdPattern)),
123
106
  description: z.string().min(1),
124
107
  });
125
- export const WorkflowWorkspaceSchemaSchema = z.object({
126
- kind: z.literal("workspace-schema"),
108
+ export const WorkflowCompiledSchemaSchema = z.object({
109
+ kind: z.literal("compiled-schema"),
127
110
  version: z.literal(1),
128
- target_type: z.literal("workspace"),
111
+ target_type: z.literal("compiled"),
129
112
  label: z.string().min(1),
130
- zones: z.array(WorkflowWorkspaceZoneSchema).min(1),
113
+ zones: z.array(WorkflowCompiledZoneSchema).min(1),
131
114
  });
132
115
  export const WorkflowCompilerApiSchema = z.object({
133
- kind: z.literal("workspace"),
116
+ kind: z.literal("compiled"),
134
117
  version: z.literal(1),
135
118
  });
136
119
  export const WorkflowStageZoneAccessSchema = z.array(WorkflowZoneIdSchema).min(1);
137
120
  export const ExecutionShellZoneMountSchema = z.object({
138
121
  zone_id: WorkflowZoneIdSchema,
139
- workspace_path: z.string(),
122
+ compiled_path: z.string(),
140
123
  shell_root_path: z.string(),
141
124
  input_mount_path: z.string().nullable(),
142
125
  output_mount_path: z.string().nullable(),
@@ -160,19 +143,25 @@ export const RuntimeExecutorInfoSchema = z.object({
160
143
  timeout_ms: z.number().nullable().optional(),
161
144
  });
162
145
  export const RuntimeStageInstructionsSchema = z.object({
163
- bundled_skill: z.string(),
146
+ stage_skill_dir: z.string().regex(WorkflowIdPattern),
164
147
  effective_mode: z.enum(["builtin", "extend", "override"]),
165
148
  local_mode: z.enum(["extend", "override"]).nullable(),
166
149
  local_docs: z.array(z.string()),
167
150
  mode_sources: z.array(z.string()),
168
- });
151
+ }).strict();
169
152
  export const RuntimeStageAcceptanceSchema = z.object({
170
153
  artifacts_exist: z.array(z.string()).optional(),
171
- state_truthy: z.array(z.string()).optional(),
172
- state_equals_counts: z.record(z.string(), z.string()).optional(),
173
- state_at_least: z.record(z.string(), z.number()).optional(),
174
- state_at_least_counts: z.record(z.string(), z.string()).optional(),
175
- });
154
+ stage_truthy: z.array(z.string()).optional(),
155
+ stage_equals_counts: z.record(z.string(), z.string()).optional(),
156
+ stage_at_least: z.record(z.string(), z.number()).optional(),
157
+ stage_at_least_counts: z.record(z.string(), z.string()).optional(),
158
+ zone_counts_at_least: z.record(z.string().regex(WorkflowIdPattern), z.number()).optional(),
159
+ zone_counts_at_least_counts: z.record(z.string().regex(WorkflowIdPattern), z.string()).optional(),
160
+ markdown_frontmatter_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
161
+ markdown_abstract_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
162
+ wikilinks_valid_in_zones: z.array(WorkflowZoneIdSchema).optional(),
163
+ artifacts_must_not_contain: z.record(z.string(), z.array(z.string().min(1))).optional(),
164
+ }).strict();
176
165
  export const RuntimeStageContractSchema = z.object({
177
166
  kind: z.literal("interf-stage-contract"),
178
167
  version: z.literal(1),
@@ -240,27 +229,21 @@ export const RuntimeRunSchema = z.object({
240
229
  exit_code: z.number().nullable(),
241
230
  error: z.string().nullable(),
242
231
  });
243
- const InventoryRecordSchema = JsonRecordSchema;
244
- export const WorkspaceInventorySchema = z.union([
245
- z.object({
246
- total: z.number(),
247
- files: z.array(InventoryRecordSchema),
248
- }),
249
- z.object({
250
- summary_total: z.number(),
251
- summaries: z.array(InventoryRecordSchema),
252
- }),
253
- z.object({
254
- entries: z.array(InventoryRecordSchema),
255
- total: z.number().optional(),
256
- summary_total: z.number().optional(),
257
- }),
258
- z.object({
259
- items: z.array(InventoryRecordSchema),
260
- total: z.number().optional(),
261
- summary_total: z.number().optional(),
262
- }),
263
- ]);
232
+ export const CompiledInventoryEntrySchema = z.object({
233
+ input_zone: WorkflowZoneIdSchema,
234
+ input_path: z.string().min(1),
235
+ output_zone: WorkflowZoneIdSchema,
236
+ output_path: z.string().min(1),
237
+ state: z.string().min(1).optional(),
238
+ metadata: JsonRecordSchema.optional(),
239
+ }).strict();
240
+ export const CompiledInventorySchema = z.object({
241
+ kind: z.literal("compiled-runtime-ledger").optional(),
242
+ version: z.number().int().min(1).optional(),
243
+ stage: RuntimeStageSchema.optional(),
244
+ entries: z.array(CompiledInventoryEntrySchema),
245
+ total: z.number().int().nonnegative(),
246
+ });
264
247
  export const TestCaseExpectSchema = z.object({
265
248
  must_include: z.array(z.string().min(1)).optional(),
266
249
  must_include_one_of: z.array(z.array(z.string().min(1)).min(1)).optional(),
@@ -293,32 +276,14 @@ const TestCaseCoreSchema = z.object({
293
276
  });
294
277
  }
295
278
  });
296
- export const TestCaseSchema = z.preprocess((value) => {
297
- if (!value || typeof value !== "object" || Array.isArray(value))
298
- return value;
299
- const raw = value;
300
- return {
301
- ...raw,
302
- question: raw.question ?? raw.check ?? raw.ask,
303
- answer: raw.answer ?? raw.expected ?? raw.pass_when,
304
- };
305
- }, TestCaseCoreSchema);
279
+ export const TestCaseSchema = TestCaseCoreSchema;
306
280
  const TestSpecCoreSchema = z.object({
307
281
  type: TestTargetTypeSchema,
308
282
  name: z.string().min(1),
309
283
  description: z.string().min(1).optional(),
310
284
  cases: z.array(TestCaseSchema).min(1),
311
285
  });
312
- export const TestSpecSchema = z.preprocess((value) => {
313
- if (!value || typeof value !== "object" || Array.isArray(value))
314
- return value;
315
- const raw = value;
316
- return {
317
- ...raw,
318
- type: raw.type ?? "workspace",
319
- cases: raw.cases ?? raw.checks,
320
- };
321
- }, TestSpecCoreSchema);
286
+ export const TestSpecSchema = TestSpecCoreSchema;
322
287
  export const SourceTruthCheckSchema = z.object({
323
288
  id: z.string().regex(WorkflowIdPattern).optional(),
324
289
  question: z.string().min(1),
@@ -334,46 +299,31 @@ export const SourceTruthCheckSchema = z.object({
334
299
  });
335
300
  }
336
301
  });
337
- export const SourceWorkspaceMaxAttemptsSchema = z.number().int().min(1).max(5);
338
- export const SourceWorkspaceMaxLoopsSchema = z.number().int().min(1).max(3);
339
- export const SourceWorkspaceConfigSchema = z.preprocess((value) => {
340
- if (!value || typeof value !== "object" || Array.isArray(value))
341
- return value;
342
- const raw = value;
343
- const legacyRetryPolicy = raw.retry_policy && typeof raw.retry_policy === "object" && !Array.isArray(raw.retry_policy)
344
- ? raw.retry_policy
345
- : null;
346
- return {
347
- ...raw,
348
- max_attempts: raw.max_attempts ?? legacyRetryPolicy?.max_attempts,
349
- max_loops: raw.max_loops,
350
- };
351
- }, z.object({
302
+ export const SourceCompiledMaxAttemptsSchema = z.number().int().min(1).max(5);
303
+ export const SourceCompiledMaxLoopsSchema = z.number().int().min(1).max(3);
304
+ const DatasetNamePattern = /^[a-z0-9][a-z0-9-]*$/;
305
+ const RESERVED_DATASET_NAMES = new Set(["tests", "workflows"]);
306
+ export const DatasetNameSchema = z
307
+ .string()
308
+ .regex(DatasetNamePattern, "Dataset names must use lowercase letters, numbers, and dashes only.")
309
+ .refine((value) => !RESERVED_DATASET_NAMES.has(value), "Dataset name is reserved.");
310
+ export const SourceDatasetConfigSchema = z.object({
352
311
  id: z.string().regex(WorkflowIdPattern).optional(),
353
- name: z.string().min(1),
312
+ name: DatasetNameSchema,
313
+ path: z.string().min(1).default("."),
354
314
  about: z.string().min(1).optional(),
355
315
  workflow: WorkflowIdSchema.optional(),
356
- max_attempts: SourceWorkspaceMaxAttemptsSchema.optional(),
357
- max_loops: SourceWorkspaceMaxLoopsSchema.optional(),
316
+ max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
317
+ max_loops: SourceCompiledMaxLoopsSchema.optional(),
358
318
  checks: z.array(SourceTruthCheckSchema).default([]),
359
- }).strict());
360
- export const WorkspaceInterfConfigSchema = z.preprocess((value) => {
361
- if (!value || typeof value !== "object" || Array.isArray(value))
362
- return value;
363
- const raw = value;
364
- return {
365
- ...raw,
366
- type: "workspace",
367
- source: raw.source ?? { path: "./raw" },
368
- checks: raw.checks ?? [],
369
- };
370
- }, z.object({
371
- type: z.literal("workspace"),
372
- name: z.string(),
319
+ }).strict();
320
+ export const CompiledInterfConfigSchema = z.object({
321
+ type: z.literal("compiled"),
322
+ name: DatasetNameSchema,
373
323
  about: z.string().optional(),
374
- workflow: WorkflowIdSchema.optional(),
375
- max_attempts: SourceWorkspaceMaxAttemptsSchema.optional(),
376
- max_loops: SourceWorkspaceMaxLoopsSchema.optional(),
324
+ workflow: WorkflowIdSchema,
325
+ max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
326
+ max_loops: SourceCompiledMaxLoopsSchema.optional(),
377
327
  checks: z.array(SourceTruthCheckSchema).default([]),
378
328
  workflow_origin: z.object({
379
329
  selected: WorkflowIdSchema,
@@ -382,9 +332,10 @@ export const WorkspaceInterfConfigSchema = z.preprocess((value) => {
382
332
  source: z.object({
383
333
  path: z.string(),
384
334
  control_path: z.string().optional(),
335
+ dataset_path: z.string(),
385
336
  }),
386
- }).passthrough());
387
- export const InterfConfigSchema = WorkspaceInterfConfigSchema;
337
+ }).passthrough();
338
+ export const InterfConfigSchema = CompiledInterfConfigSchema;
388
339
  export const WorkflowImprovementLoopSummarySchema = z.object({
389
340
  variation: z.number().int().min(1),
390
341
  kind: z.enum(["baseline", "edited"]),
@@ -404,11 +355,11 @@ export const WorkflowImprovementContextSchema = z.object({
404
355
  target_name: z.string(),
405
356
  workflow_id: WorkflowIdSchema,
406
357
  loop_index: z.number().int().min(1),
407
- max_loops: SourceWorkspaceMaxLoopsSchema,
408
- max_attempts: SourceWorkspaceMaxAttemptsSchema,
358
+ max_loops: SourceCompiledMaxLoopsSchema,
359
+ max_attempts: SourceCompiledMaxAttemptsSchema,
409
360
  review_paths: z.object({
410
361
  workflow_root: z.string(),
411
- workspace_runtime: z.string().nullable(),
362
+ compiled_runtime: z.string().nullable(),
412
363
  test_comparisons: z.string().nullable(),
413
364
  execution_shells: z.string().nullable(),
414
365
  test_runs: z.string().nullable(),
@@ -473,17 +424,17 @@ export const WorkflowImprovementRunLedgerSchema = z.object({
473
424
  run_id: z.string(),
474
425
  target_name: z.string(),
475
426
  workflow_id: WorkflowIdSchema,
476
- max_loops: SourceWorkspaceMaxLoopsSchema,
477
- max_attempts: SourceWorkspaceMaxAttemptsSchema,
427
+ max_loops: SourceCompiledMaxLoopsSchema,
428
+ max_attempts: SourceCompiledMaxAttemptsSchema,
478
429
  loops: z.array(WorkflowImprovementLoopRecordSchema),
479
430
  });
480
431
  export const SourceFolderConfigSchema = z.object({
481
- workspaces: z.array(SourceWorkspaceConfigSchema).optional(),
432
+ datasets: z.array(SourceDatasetConfigSchema).optional(),
482
433
  }).strict().superRefine((value, ctx) => {
483
- if ((value.workspaces?.length ?? 0) === 0) {
434
+ if ((value.datasets?.length ?? 0) === 0) {
484
435
  ctx.addIssue({
485
436
  code: z.ZodIssueCode.custom,
486
- message: "Source-folder config needs at least one workspace.",
437
+ message: "Interf project config needs at least one dataset.",
487
438
  });
488
439
  }
489
440
  });
@@ -544,7 +495,7 @@ export const TestTargetRunSchema = z.object({
544
495
  target_count: z.number(),
545
496
  results: z.array(TestTargetResultSchema),
546
497
  });
547
- export const TestRunModeSchema = z.enum(["raw", "workspace", "both"]);
498
+ export const TestRunModeSchema = z.enum(["raw", "compiled", "both"]);
548
499
  export const TestRunTargetSummarySchema = z.object({
549
500
  label: z.string(),
550
501
  run_path: z.string(),
@@ -566,12 +517,13 @@ export const TestRunComparisonSchema = z.object({
566
517
  generated_at: z.string(),
567
518
  mode: TestRunModeSchema,
568
519
  source_path: z.string(),
569
- workspace: z.object({
570
- name: z.string(),
571
- path: z.string(),
520
+ checks_fingerprint: z.string().min(1).optional(),
521
+ dataset: z.object({
522
+ name: DatasetNameSchema,
523
+ compiled_path: z.string().nullable(),
572
524
  }),
573
525
  raw: TestRunTargetSummarySchema.nullable(),
574
- compiled_workspace: TestRunTargetSummarySchema.nullable(),
526
+ compiled: TestRunTargetSummarySchema.nullable(),
575
527
  summary: z.object({
576
528
  raw_pass_rate: z.number().nullable(),
577
529
  compiled_pass_rate: z.number().nullable(),
@@ -1,35 +1,39 @@
1
- import { type InterfConfig, type TestSpec, type TestTargetType, type SourceTruthCheck, type SourceWorkspaceConfig, type SourceFolderConfig } from "./schema.js";
2
- export declare const SOURCE_FOLDER_CONFIG_FILE = "interf.config.json";
1
+ import { type InterfConfig, type TestSpec, type TestTargetType, type SourceTruthCheck, type SourceDatasetConfig, type SourceFolderConfig } from "./schema.js";
2
+ export declare const SOURCE_FOLDER_CONFIG_FILE = "interf.json";
3
3
  export interface LoadedSourceTestSpec extends TestSpec {
4
4
  id: string;
5
5
  filePath: string;
6
6
  }
7
+ export declare function fingerprintTruthChecks(checks: SourceTruthCheck[]): string;
7
8
  export declare function loadSourceFolderConfig(sourcePath: string): SourceFolderConfig | null;
8
- export interface WritableSourceFolderConfig {
9
- workspaces?: SourceWorkspaceConfig[];
9
+ export interface WritableSourceProjectConfig {
10
+ datasets?: Array<Omit<SourceDatasetConfig, "path"> & {
11
+ path?: string;
12
+ }>;
10
13
  }
11
- export declare function listSourceWorkspaceConfigs(config: SourceFolderConfig | null): SourceWorkspaceConfig[];
12
- export declare function resolveWorkspaceCompileMaxAttempts(workspaceConfig: Pick<SourceWorkspaceConfig, "max_attempts">, override?: number | null): number | null;
13
- export declare function resolveWorkspaceCompileMaxLoops(workspaceConfig: Pick<SourceWorkspaceConfig, "max_loops">, override?: number | null): number | null;
14
- export declare function getDefaultSourceWorkspaceConfig(config: SourceFolderConfig | null): SourceWorkspaceConfig | null;
15
- export declare function findSourceWorkspaceConfig(config: SourceFolderConfig | null, workspaceName: string): SourceWorkspaceConfig | null;
16
- export declare function saveSourceFolderConfig(sourcePath: string, config: WritableSourceFolderConfig): void;
17
- export declare function appendSourceWorkspaceChecks(sourcePath: string, workspaceName: string, checks: SourceTruthCheck[]): void;
18
- export declare function upsertSourceWorkspaceConfig(sourcePath: string, workspaceConfig: SourceWorkspaceConfig, options?: {
14
+ export declare function listSourceDatasetConfigs(config: SourceFolderConfig | null): SourceDatasetConfig[];
15
+ export declare function resolveDatasetCompileMaxAttempts(datasetConfig: Pick<SourceDatasetConfig, "max_attempts">, override?: number | null): number | null;
16
+ export declare function resolveDatasetCompileMaxLoops(datasetConfig: Pick<SourceDatasetConfig, "max_loops">, override?: number | null): number | null;
17
+ export declare function getDefaultSourceDatasetConfig(config: SourceFolderConfig | null): SourceDatasetConfig | null;
18
+ export declare function findSourceDatasetConfig(config: SourceFolderConfig | null, datasetName: string): SourceDatasetConfig | null;
19
+ export declare function saveSourceFolderConfig(sourcePath: string, config: WritableSourceProjectConfig): void;
20
+ export declare function appendSourceDatasetChecks(sourcePath: string, datasetName: string, checks: SourceTruthCheck[]): void;
21
+ export declare function upsertSourceDatasetConfig(sourcePath: string, datasetConfig: SourceDatasetConfig, options?: {
19
22
  matchName?: string;
20
23
  }): void;
21
- export declare function workspaceMaxAttempts(maxAttempts: number | null | undefined): number | undefined;
22
- export declare function workspaceMaxLoops(maxLoops: number | null | undefined): number | undefined;
23
- export declare function sourceWorkspaceConfigFromInterfConfig(config: InterfConfig): SourceWorkspaceConfig;
24
- export declare function loadWorkspaceControlConfig(workspacePath: string): SourceWorkspaceConfig | null;
25
- export declare function saveWorkspaceInterfConfig(workspacePath: string, config: InterfConfig): InterfConfig;
26
- export declare function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath: string, workspaceConfig: SourceWorkspaceConfig): InterfConfig;
24
+ export declare function compiledMaxAttempts(maxAttempts: number | null | undefined): number | undefined;
25
+ export declare function compiledMaxLoops(maxLoops: number | null | undefined): number | undefined;
26
+ export declare function sourceDatasetConfigFromInterfConfig(config: InterfConfig, datasetPath?: string): SourceDatasetConfig;
27
+ export declare function loadCompiledDatasetConfig(compiledPath: string): SourceDatasetConfig | null;
28
+ export declare function saveCompiledInterfConfig(compiledPath: string, config: InterfConfig): InterfConfig;
29
+ export declare function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath: string, datasetConfig: SourceDatasetConfig): InterfConfig;
27
30
  export declare function buildTestSpecFromSourceFolderConfig(options: {
28
31
  sourcePath: string;
29
32
  targetName?: string | null;
30
33
  targetType?: TestTargetType;
31
34
  }): LoadedSourceTestSpec | null;
32
- export declare function buildTestSpecFromWorkspaceConfig(options: {
33
- workspacePath: string;
35
+ export declare function buildTestSpecFromCompiledDatasetConfig(options: {
36
+ compiledPath: string;
34
37
  targetType?: TestTargetType;
35
38
  }): LoadedSourceTestSpec | null;
39
+ export declare function resolveSourceDatasetPath(projectPath: string, datasetConfig: Pick<SourceDatasetConfig, "path">): string;