@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.
- package/README.md +71 -69
- package/builtin-workflows/interf/README.md +6 -6
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
- package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
- package/builtin-workflows/interf/improve/SKILL.md +3 -3
- package/builtin-workflows/interf/use/query/SKILL.md +2 -2
- package/builtin-workflows/interf/workflow.json +42 -31
- package/dist/commands/check-draft.d.ts +19 -0
- package/dist/commands/check-draft.js +110 -0
- package/dist/commands/compile-controller.d.ts +4 -4
- package/dist/commands/compile-controller.js +117 -81
- package/dist/commands/compile.d.ts +5 -5
- package/dist/commands/compile.js +61 -62
- package/dist/commands/compiled-flow.d.ts +23 -0
- package/dist/commands/compiled-flow.js +112 -0
- package/dist/commands/create-workflow-wizard.d.ts +3 -3
- package/dist/commands/create-workflow-wizard.js +11 -11
- package/dist/commands/create.d.ts +2 -2
- package/dist/commands/create.js +50 -57
- package/dist/commands/default.js +2 -2
- package/dist/commands/executor-flow.d.ts +20 -1
- package/dist/commands/executor-flow.js +67 -7
- package/dist/commands/init.js +242 -289
- package/dist/commands/list.js +14 -10
- package/dist/commands/reset.js +6 -6
- package/dist/commands/source-config-wizard.d.ts +12 -8
- package/dist/commands/source-config-wizard.js +356 -119
- package/dist/commands/status.js +49 -26
- package/dist/commands/test-flow.d.ts +23 -10
- package/dist/commands/test-flow.js +278 -58
- package/dist/commands/test.d.ts +7 -1
- package/dist/commands/test.js +264 -65
- package/dist/commands/verify.js +23 -14
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/lib/agent-args.js +2 -1
- package/dist/lib/agent-constants.js +1 -1
- package/dist/lib/agent-render.js +4 -4
- package/dist/lib/agent-shells.d.ts +8 -8
- package/dist/lib/agent-shells.js +231 -142
- package/dist/lib/compiled-compile.d.ts +52 -0
- package/dist/lib/compiled-compile.js +274 -0
- package/dist/lib/compiled-home.d.ts +5 -0
- package/dist/lib/compiled-home.js +32 -0
- package/dist/lib/compiled-layout.d.ts +2 -0
- package/dist/lib/compiled-layout.js +60 -0
- package/dist/lib/compiled-paths.d.ts +41 -0
- package/dist/lib/compiled-paths.js +111 -0
- package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
- package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
- package/dist/lib/compiled-reset.d.ts +1 -0
- package/dist/lib/compiled-reset.js +44 -0
- package/dist/lib/compiled-schema.d.ts +27 -0
- package/dist/lib/compiled-schema.js +110 -0
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +0 -1
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +3 -3
- package/dist/lib/interf-bootstrap.d.ts +1 -1
- package/dist/lib/interf-bootstrap.js +4 -4
- package/dist/lib/interf-detect.d.ts +10 -10
- package/dist/lib/interf-detect.js +78 -56
- package/dist/lib/interf-scaffold.d.ts +2 -2
- package/dist/lib/interf-scaffold.js +90 -57
- package/dist/lib/interf-workflow-package.d.ts +3 -3
- package/dist/lib/interf-workflow-package.js +30 -30
- package/dist/lib/interf.d.ts +5 -5
- package/dist/lib/interf.js +4 -4
- package/dist/lib/local-workflows.d.ts +4 -4
- package/dist/lib/local-workflows.js +35 -70
- package/dist/lib/obsidian.d.ts +1 -1
- package/dist/lib/parse.js +92 -1
- package/dist/lib/project-paths.d.ts +13 -0
- package/dist/lib/project-paths.js +29 -0
- package/dist/lib/runtime-acceptance.d.ts +7 -1
- package/dist/lib/runtime-acceptance.js +194 -59
- package/dist/lib/runtime-contracts.d.ts +2 -4
- package/dist/lib/runtime-contracts.js +17 -161
- package/dist/lib/runtime-inventory.d.ts +7 -0
- package/dist/lib/runtime-inventory.js +29 -0
- package/dist/lib/runtime-paths.js +5 -5
- package/dist/lib/runtime-prompt.js +9 -6
- package/dist/lib/runtime-reconcile.d.ts +2 -3
- package/dist/lib/runtime-reconcile.js +92 -171
- package/dist/lib/runtime-runs.js +30 -39
- package/dist/lib/runtime-types.d.ts +10 -19
- package/dist/lib/runtime.d.ts +2 -2
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/schema.d.ts +163 -140
- package/dist/lib/schema.js +163 -124
- package/dist/lib/source-config.d.ts +24 -20
- package/dist/lib/source-config.js +154 -116
- package/dist/lib/state-artifacts.d.ts +5 -5
- package/dist/lib/state-artifacts.js +8 -8
- package/dist/lib/state-health.d.ts +4 -4
- package/dist/lib/state-health.js +108 -126
- package/dist/lib/state-io.d.ts +8 -8
- package/dist/lib/state-io.js +77 -50
- package/dist/lib/state-paths.js +5 -5
- package/dist/lib/state-view.d.ts +4 -4
- package/dist/lib/state-view.js +52 -55
- package/dist/lib/state.d.ts +5 -5
- package/dist/lib/state.js +4 -4
- package/dist/lib/summarize-plan.d.ts +3 -2
- package/dist/lib/summarize-plan.js +18 -16
- package/dist/lib/test-execution.js +9 -9
- package/dist/lib/test-matrices.d.ts +3 -3
- package/dist/lib/test-matrices.js +6 -6
- package/dist/lib/test-paths.d.ts +4 -4
- package/dist/lib/test-paths.js +16 -10
- package/dist/lib/test-sandbox.d.ts +1 -1
- package/dist/lib/test-sandbox.js +38 -31
- package/dist/lib/test-targets.d.ts +2 -2
- package/dist/lib/test-targets.js +11 -11
- package/dist/lib/test-types.d.ts +1 -1
- package/dist/lib/test.d.ts +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/util.d.ts +2 -0
- package/dist/lib/util.js +14 -1
- package/dist/lib/validate-compiled.d.ts +27 -0
- package/dist/lib/validate-compiled.js +236 -0
- package/dist/lib/validate-helpers.d.ts +0 -8
- package/dist/lib/validate-helpers.js +0 -30
- package/dist/lib/validate.d.ts +4 -4
- package/dist/lib/validate.js +49 -15
- package/dist/lib/workflow-abi.d.ts +37 -46
- package/dist/lib/workflow-abi.js +51 -76
- package/dist/lib/workflow-definitions.d.ts +11 -11
- package/dist/lib/workflow-definitions.js +36 -53
- package/dist/lib/workflow-helpers.d.ts +2 -3
- package/dist/lib/workflow-helpers.js +9 -13
- package/dist/lib/workflow-improvement.d.ts +3 -3
- package/dist/lib/workflow-improvement.js +48 -48
- package/dist/lib/workflow-review-paths.d.ts +3 -3
- package/dist/lib/workflow-review-paths.js +11 -11
- package/dist/lib/workflow-stage-runner.d.ts +1 -1
- package/dist/lib/workflow-stage-runner.js +8 -8
- package/dist/lib/workflows.d.ts +9 -9
- package/dist/lib/workflows.js +15 -17
- package/package.json +10 -9
- package/dist/commands/workspace-flow.d.ts +0 -23
- package/dist/commands/workspace-flow.js +0 -109
- package/dist/lib/registry.d.ts +0 -16
- package/dist/lib/registry.js +0 -65
- package/dist/lib/validate-workspace.d.ts +0 -121
- package/dist/lib/validate-workspace.js +0 -407
- package/dist/lib/workspace-compile.d.ts +0 -54
- package/dist/lib/workspace-compile.js +0 -476
- package/dist/lib/workspace-home.d.ts +0 -5
- package/dist/lib/workspace-home.js +0 -32
- package/dist/lib/workspace-layout.d.ts +0 -2
- package/dist/lib/workspace-layout.js +0 -60
- package/dist/lib/workspace-paths.d.ts +0 -41
- package/dist/lib/workspace-paths.js +0 -107
- package/dist/lib/workspace-reset.d.ts +0 -1
- package/dist/lib/workspace-reset.js +0 -43
- package/dist/lib/workspace-schema.d.ts +0 -17
- package/dist/lib/workspace-schema.js +0 -74
package/dist/lib/schema.js
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { COMPILED_ZONE_KINDS, } from "./workflow-abi.js";
|
|
3
3
|
const JsonRecordSchema = z.record(z.string(), z.unknown());
|
|
4
|
-
const
|
|
5
|
-
function
|
|
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) =>
|
|
12
|
+
.every((segment) => COMPILED_RELATIVE_PATH_SEGMENT.test(segment));
|
|
13
13
|
}
|
|
14
|
-
export const RuntimeTargetTypeSchema = z.enum(["
|
|
15
|
-
export const TestTargetTypeSchema = z.enum(["
|
|
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.
|
|
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
|
|
22
|
-
export const
|
|
23
|
-
|
|
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
|
-
|
|
37
|
+
stages: z.record(z.string().regex(WorkflowIdPattern), CompiledStageStateSchema).optional(),
|
|
38
|
+
last_add: z.string().nullable().optional(),
|
|
39
|
+
last_compile: z.string().nullable().optional(),
|
|
40
|
+
summarized: z.number().optional(),
|
|
26
41
|
structured: z.number().optional(),
|
|
27
42
|
shaped: z.number().optional(),
|
|
28
|
-
compiled: z.number(),
|
|
29
|
-
last_add: z.string().nullable().optional(),
|
|
43
|
+
compiled: z.number().optional(),
|
|
30
44
|
last_summarize: z.string().nullable().optional(),
|
|
31
45
|
last_structure: z.string().nullable().optional(),
|
|
32
46
|
last_shape: z.string().nullable().optional(),
|
|
33
|
-
last_compile: z.string().nullable().optional(),
|
|
34
47
|
inventory_complete: z.boolean().optional(),
|
|
35
48
|
abstracts_read: z.number().optional(),
|
|
36
49
|
full_reads: z.number().optional(),
|
|
@@ -53,57 +66,34 @@ export const ViewCardSchema = z.object({
|
|
|
53
66
|
denominator_metric: z.string().optional(),
|
|
54
67
|
format: z.enum(["number", "fraction", "timestamp"]),
|
|
55
68
|
});
|
|
56
|
-
export const
|
|
57
|
-
kind: z.literal("
|
|
58
|
-
version: z.
|
|
69
|
+
export const CompiledHealthSchema = z.object({
|
|
70
|
+
kind: z.literal("compiled-health"),
|
|
71
|
+
version: z.number().int().min(1),
|
|
59
72
|
generated_at: z.string(),
|
|
60
73
|
target_name: z.string(),
|
|
61
74
|
status: z.enum(["idle", "running", "compiled", "stale", "failed"]),
|
|
62
|
-
stage: z.
|
|
75
|
+
stage: z.union([
|
|
76
|
+
z.enum(["idle", "compiled", "failed"]),
|
|
77
|
+
RuntimeStageSchema,
|
|
78
|
+
]),
|
|
63
79
|
summary: z.string(),
|
|
64
|
-
metrics: z.
|
|
65
|
-
|
|
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
|
-
}),
|
|
80
|
+
metrics: z.record(z.string(), z.number()),
|
|
81
|
+
checks: z.record(z.string(), z.boolean()),
|
|
92
82
|
});
|
|
93
|
-
export const
|
|
94
|
-
kind: z.literal("
|
|
95
|
-
version: z.
|
|
83
|
+
export const CompiledViewSpecSchema = z.object({
|
|
84
|
+
kind: z.literal("compiled-view-spec"),
|
|
85
|
+
version: z.number().int().min(1),
|
|
96
86
|
generated_at: z.string(),
|
|
97
87
|
target_name: z.string(),
|
|
98
88
|
health_source: z.string(),
|
|
99
89
|
state_source: z.string(),
|
|
100
|
-
default_note: z.string(),
|
|
90
|
+
default_note: z.string().nullable(),
|
|
101
91
|
graph_scope: z.array(z.string()),
|
|
102
92
|
cards: z.array(ViewCardSchema),
|
|
103
93
|
sections: z.array(ViewSectionSchema),
|
|
104
94
|
});
|
|
105
|
-
export const
|
|
106
|
-
kind: z.literal("
|
|
95
|
+
export const CompiledRawSnapshotSchema = z.object({
|
|
96
|
+
kind: z.literal("compiled-raw-snapshot"),
|
|
107
97
|
version: z.literal(1),
|
|
108
98
|
generated_at: z.string(),
|
|
109
99
|
target_name: z.string(),
|
|
@@ -112,31 +102,31 @@ export const WorkspaceRawSnapshotSchema = z.object({
|
|
|
112
102
|
source_total: z.number(),
|
|
113
103
|
sample_files: z.array(z.string()),
|
|
114
104
|
});
|
|
115
|
-
export const
|
|
105
|
+
export const WorkflowCompiledZoneSchema = z.object({
|
|
116
106
|
id: WorkflowZoneIdSchema,
|
|
117
|
-
path: z.string().min(1).refine(
|
|
118
|
-
message: "Zone paths must stay inside the
|
|
107
|
+
path: z.string().min(1).refine(isCompiledRelativePath, {
|
|
108
|
+
message: "Zone paths must stay inside the compiled root",
|
|
119
109
|
}),
|
|
120
|
-
kind:
|
|
110
|
+
kind: WorkflowCompiledZoneKindSchema,
|
|
121
111
|
required: z.boolean(),
|
|
122
112
|
owned_by: z.array(z.string().regex(WorkflowIdPattern)),
|
|
123
113
|
description: z.string().min(1),
|
|
124
114
|
});
|
|
125
|
-
export const
|
|
126
|
-
kind: z.literal("
|
|
115
|
+
export const WorkflowCompiledSchemaSchema = z.object({
|
|
116
|
+
kind: z.literal("compiled-schema"),
|
|
127
117
|
version: z.literal(1),
|
|
128
|
-
target_type: z.literal("
|
|
118
|
+
target_type: z.literal("compiled"),
|
|
129
119
|
label: z.string().min(1),
|
|
130
|
-
zones: z.array(
|
|
120
|
+
zones: z.array(WorkflowCompiledZoneSchema).min(1),
|
|
131
121
|
});
|
|
132
122
|
export const WorkflowCompilerApiSchema = z.object({
|
|
133
|
-
kind: z.literal("
|
|
123
|
+
kind: z.literal("compiled"),
|
|
134
124
|
version: z.literal(1),
|
|
135
125
|
});
|
|
136
126
|
export const WorkflowStageZoneAccessSchema = z.array(WorkflowZoneIdSchema).min(1);
|
|
137
127
|
export const ExecutionShellZoneMountSchema = z.object({
|
|
138
128
|
zone_id: WorkflowZoneIdSchema,
|
|
139
|
-
|
|
129
|
+
compiled_path: z.string(),
|
|
140
130
|
shell_root_path: z.string(),
|
|
141
131
|
input_mount_path: z.string().nullable(),
|
|
142
132
|
output_mount_path: z.string().nullable(),
|
|
@@ -159,20 +149,48 @@ export const RuntimeExecutorInfoSchema = z.object({
|
|
|
159
149
|
profile: z.string().nullable().optional(),
|
|
160
150
|
timeout_ms: z.number().nullable().optional(),
|
|
161
151
|
});
|
|
162
|
-
export const RuntimeStageInstructionsSchema = z.
|
|
163
|
-
|
|
152
|
+
export const RuntimeStageInstructionsSchema = z.preprocess((value) => {
|
|
153
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
154
|
+
return value;
|
|
155
|
+
const raw = value;
|
|
156
|
+
const legacyBundledSkill = typeof raw.bundled_skill === "string" && raw.bundled_skill.length > 0
|
|
157
|
+
? raw.bundled_skill.split(/[\\/]/).filter(Boolean).pop()
|
|
158
|
+
: undefined;
|
|
159
|
+
return {
|
|
160
|
+
...raw,
|
|
161
|
+
stage_skill_dir: raw.stage_skill_dir ?? legacyBundledSkill,
|
|
162
|
+
};
|
|
163
|
+
}, z.object({
|
|
164
|
+
stage_skill_dir: z.string().regex(WorkflowIdPattern),
|
|
164
165
|
effective_mode: z.enum(["builtin", "extend", "override"]),
|
|
165
166
|
local_mode: z.enum(["extend", "override"]).nullable(),
|
|
166
167
|
local_docs: z.array(z.string()),
|
|
167
168
|
mode_sources: z.array(z.string()),
|
|
168
|
-
});
|
|
169
|
-
export const RuntimeStageAcceptanceSchema = z.
|
|
169
|
+
}));
|
|
170
|
+
export const RuntimeStageAcceptanceSchema = z.preprocess((value) => {
|
|
171
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
172
|
+
return value;
|
|
173
|
+
const raw = value;
|
|
174
|
+
return {
|
|
175
|
+
...raw,
|
|
176
|
+
stage_truthy: raw.stage_truthy ?? raw.state_truthy,
|
|
177
|
+
stage_equals_counts: raw.stage_equals_counts ?? raw.state_equals_counts,
|
|
178
|
+
stage_at_least: raw.stage_at_least ?? raw.state_at_least,
|
|
179
|
+
stage_at_least_counts: raw.stage_at_least_counts ?? raw.state_at_least_counts,
|
|
180
|
+
};
|
|
181
|
+
}, z.object({
|
|
170
182
|
artifacts_exist: z.array(z.string()).optional(),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
183
|
+
stage_truthy: z.array(z.string()).optional(),
|
|
184
|
+
stage_equals_counts: z.record(z.string(), z.string()).optional(),
|
|
185
|
+
stage_at_least: z.record(z.string(), z.number()).optional(),
|
|
186
|
+
stage_at_least_counts: z.record(z.string(), z.string()).optional(),
|
|
187
|
+
zone_counts_at_least: z.record(z.string().regex(WorkflowIdPattern), z.number()).optional(),
|
|
188
|
+
zone_counts_at_least_counts: z.record(z.string().regex(WorkflowIdPattern), z.string()).optional(),
|
|
189
|
+
markdown_frontmatter_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
190
|
+
markdown_abstract_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
191
|
+
wikilinks_valid_in_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
192
|
+
artifacts_must_not_contain: z.record(z.string(), z.array(z.string().min(1))).optional(),
|
|
193
|
+
}));
|
|
176
194
|
export const RuntimeStageContractSchema = z.object({
|
|
177
195
|
kind: z.literal("interf-stage-contract"),
|
|
178
196
|
version: z.literal(1),
|
|
@@ -240,27 +258,43 @@ export const RuntimeRunSchema = z.object({
|
|
|
240
258
|
exit_code: z.number().nullable(),
|
|
241
259
|
error: z.string().nullable(),
|
|
242
260
|
});
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
export const CompiledInventoryEntrySchema = z.preprocess((value) => {
|
|
262
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
263
|
+
return value;
|
|
264
|
+
const raw = value;
|
|
265
|
+
if (typeof raw.source !== "string" && typeof raw.summary !== "string")
|
|
266
|
+
return raw;
|
|
267
|
+
return {
|
|
268
|
+
input_zone: raw.input_zone ?? "raw",
|
|
269
|
+
input_path: raw.input_path ?? raw.source,
|
|
270
|
+
output_zone: raw.output_zone ?? "summaries",
|
|
271
|
+
output_path: raw.output_path ?? raw.summary,
|
|
272
|
+
state: raw.state,
|
|
273
|
+
metadata: {
|
|
274
|
+
source_kind: raw.source_kind,
|
|
275
|
+
evidence_tier: raw.evidence_tier,
|
|
276
|
+
truth_mode: raw.truth_mode,
|
|
277
|
+
status: raw.status,
|
|
278
|
+
abstract: raw.abstract,
|
|
279
|
+
frontmatter_scanned: raw.frontmatter_scanned,
|
|
280
|
+
abstract_read: raw.abstract_read,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}, z.object({
|
|
284
|
+
input_zone: WorkflowZoneIdSchema,
|
|
285
|
+
input_path: z.string().min(1),
|
|
286
|
+
output_zone: WorkflowZoneIdSchema,
|
|
287
|
+
output_path: z.string().min(1),
|
|
288
|
+
state: z.string().min(1).optional(),
|
|
289
|
+
metadata: JsonRecordSchema.optional(),
|
|
290
|
+
}));
|
|
291
|
+
export const CompiledInventorySchema = z.object({
|
|
292
|
+
kind: z.literal("compiled-runtime-ledger").optional(),
|
|
293
|
+
version: z.number().int().min(1).optional(),
|
|
294
|
+
stage: RuntimeStageSchema.optional(),
|
|
295
|
+
entries: z.array(CompiledInventoryEntrySchema),
|
|
296
|
+
total: z.number().int().nonnegative(),
|
|
297
|
+
});
|
|
264
298
|
export const TestCaseExpectSchema = z.object({
|
|
265
299
|
must_include: z.array(z.string().min(1)).optional(),
|
|
266
300
|
must_include_one_of: z.array(z.array(z.string().min(1)).min(1)).optional(),
|
|
@@ -315,7 +349,7 @@ export const TestSpecSchema = z.preprocess((value) => {
|
|
|
315
349
|
const raw = value;
|
|
316
350
|
return {
|
|
317
351
|
...raw,
|
|
318
|
-
type: raw.type ?? "
|
|
352
|
+
type: raw.type ?? "compiled",
|
|
319
353
|
cases: raw.cases ?? raw.checks,
|
|
320
354
|
};
|
|
321
355
|
}, TestSpecCoreSchema);
|
|
@@ -334,46 +368,49 @@ export const SourceTruthCheckSchema = z.object({
|
|
|
334
368
|
});
|
|
335
369
|
}
|
|
336
370
|
});
|
|
337
|
-
export const
|
|
338
|
-
export const
|
|
339
|
-
|
|
371
|
+
export const SourceCompiledMaxAttemptsSchema = z.number().int().min(1).max(5);
|
|
372
|
+
export const SourceCompiledMaxLoopsSchema = z.number().int().min(1).max(3);
|
|
373
|
+
const DatasetNamePattern = /^[a-z0-9][a-z0-9-]*$/;
|
|
374
|
+
const RESERVED_DATASET_NAMES = new Set(["tests", "workflows"]);
|
|
375
|
+
export const DatasetNameSchema = z
|
|
376
|
+
.string()
|
|
377
|
+
.regex(DatasetNamePattern, "Dataset names must use lowercase letters, numbers, and dashes only.")
|
|
378
|
+
.refine((value) => !RESERVED_DATASET_NAMES.has(value), "Dataset name is reserved.");
|
|
379
|
+
export const SourceDatasetConfigSchema = z.preprocess((value) => {
|
|
340
380
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
341
381
|
return value;
|
|
342
382
|
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
383
|
return {
|
|
347
384
|
...raw,
|
|
348
|
-
|
|
349
|
-
max_loops: raw.max_loops,
|
|
385
|
+
path: raw.path ?? ".",
|
|
350
386
|
};
|
|
351
387
|
}, z.object({
|
|
352
388
|
id: z.string().regex(WorkflowIdPattern).optional(),
|
|
353
|
-
name:
|
|
389
|
+
name: DatasetNameSchema,
|
|
390
|
+
path: z.string().min(1),
|
|
354
391
|
about: z.string().min(1).optional(),
|
|
355
392
|
workflow: WorkflowIdSchema.optional(),
|
|
356
|
-
max_attempts:
|
|
357
|
-
max_loops:
|
|
393
|
+
max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
|
|
394
|
+
max_loops: SourceCompiledMaxLoopsSchema.optional(),
|
|
358
395
|
checks: z.array(SourceTruthCheckSchema).default([]),
|
|
359
396
|
}).strict());
|
|
360
|
-
export const
|
|
397
|
+
export const CompiledInterfConfigSchema = z.preprocess((value) => {
|
|
361
398
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
362
399
|
return value;
|
|
363
400
|
const raw = value;
|
|
364
401
|
return {
|
|
365
402
|
...raw,
|
|
366
|
-
type: "
|
|
403
|
+
type: "compiled",
|
|
367
404
|
source: raw.source ?? { path: "./raw" },
|
|
368
405
|
checks: raw.checks ?? [],
|
|
369
406
|
};
|
|
370
407
|
}, z.object({
|
|
371
|
-
type: z.literal("
|
|
372
|
-
name:
|
|
408
|
+
type: z.literal("compiled"),
|
|
409
|
+
name: DatasetNameSchema,
|
|
373
410
|
about: z.string().optional(),
|
|
374
411
|
workflow: WorkflowIdSchema.optional(),
|
|
375
|
-
max_attempts:
|
|
376
|
-
max_loops:
|
|
412
|
+
max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
|
|
413
|
+
max_loops: SourceCompiledMaxLoopsSchema.optional(),
|
|
377
414
|
checks: z.array(SourceTruthCheckSchema).default([]),
|
|
378
415
|
workflow_origin: z.object({
|
|
379
416
|
selected: WorkflowIdSchema,
|
|
@@ -382,9 +419,10 @@ export const WorkspaceInterfConfigSchema = z.preprocess((value) => {
|
|
|
382
419
|
source: z.object({
|
|
383
420
|
path: z.string(),
|
|
384
421
|
control_path: z.string().optional(),
|
|
422
|
+
dataset_path: z.string().optional(),
|
|
385
423
|
}),
|
|
386
424
|
}).passthrough());
|
|
387
|
-
export const InterfConfigSchema =
|
|
425
|
+
export const InterfConfigSchema = CompiledInterfConfigSchema;
|
|
388
426
|
export const WorkflowImprovementLoopSummarySchema = z.object({
|
|
389
427
|
variation: z.number().int().min(1),
|
|
390
428
|
kind: z.enum(["baseline", "edited"]),
|
|
@@ -404,11 +442,11 @@ export const WorkflowImprovementContextSchema = z.object({
|
|
|
404
442
|
target_name: z.string(),
|
|
405
443
|
workflow_id: WorkflowIdSchema,
|
|
406
444
|
loop_index: z.number().int().min(1),
|
|
407
|
-
max_loops:
|
|
408
|
-
max_attempts:
|
|
445
|
+
max_loops: SourceCompiledMaxLoopsSchema,
|
|
446
|
+
max_attempts: SourceCompiledMaxAttemptsSchema,
|
|
409
447
|
review_paths: z.object({
|
|
410
448
|
workflow_root: z.string(),
|
|
411
|
-
|
|
449
|
+
compiled_runtime: z.string().nullable(),
|
|
412
450
|
test_comparisons: z.string().nullable(),
|
|
413
451
|
execution_shells: z.string().nullable(),
|
|
414
452
|
test_runs: z.string().nullable(),
|
|
@@ -473,17 +511,17 @@ export const WorkflowImprovementRunLedgerSchema = z.object({
|
|
|
473
511
|
run_id: z.string(),
|
|
474
512
|
target_name: z.string(),
|
|
475
513
|
workflow_id: WorkflowIdSchema,
|
|
476
|
-
max_loops:
|
|
477
|
-
max_attempts:
|
|
514
|
+
max_loops: SourceCompiledMaxLoopsSchema,
|
|
515
|
+
max_attempts: SourceCompiledMaxAttemptsSchema,
|
|
478
516
|
loops: z.array(WorkflowImprovementLoopRecordSchema),
|
|
479
517
|
});
|
|
480
518
|
export const SourceFolderConfigSchema = z.object({
|
|
481
|
-
|
|
519
|
+
datasets: z.array(SourceDatasetConfigSchema).optional(),
|
|
482
520
|
}).strict().superRefine((value, ctx) => {
|
|
483
|
-
if ((value.
|
|
521
|
+
if ((value.datasets?.length ?? 0) === 0) {
|
|
484
522
|
ctx.addIssue({
|
|
485
523
|
code: z.ZodIssueCode.custom,
|
|
486
|
-
message: "
|
|
524
|
+
message: "Interf project config needs at least one dataset.",
|
|
487
525
|
});
|
|
488
526
|
}
|
|
489
527
|
});
|
|
@@ -544,7 +582,7 @@ export const TestTargetRunSchema = z.object({
|
|
|
544
582
|
target_count: z.number(),
|
|
545
583
|
results: z.array(TestTargetResultSchema),
|
|
546
584
|
});
|
|
547
|
-
export const TestRunModeSchema = z.enum(["raw", "
|
|
585
|
+
export const TestRunModeSchema = z.enum(["raw", "compiled", "both"]);
|
|
548
586
|
export const TestRunTargetSummarySchema = z.object({
|
|
549
587
|
label: z.string(),
|
|
550
588
|
run_path: z.string(),
|
|
@@ -566,12 +604,13 @@ export const TestRunComparisonSchema = z.object({
|
|
|
566
604
|
generated_at: z.string(),
|
|
567
605
|
mode: TestRunModeSchema,
|
|
568
606
|
source_path: z.string(),
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
607
|
+
checks_fingerprint: z.string().min(1).optional(),
|
|
608
|
+
dataset: z.object({
|
|
609
|
+
name: DatasetNameSchema,
|
|
610
|
+
compiled_path: z.string().nullable(),
|
|
572
611
|
}),
|
|
573
612
|
raw: TestRunTargetSummarySchema.nullable(),
|
|
574
|
-
|
|
613
|
+
compiled: TestRunTargetSummarySchema.nullable(),
|
|
575
614
|
summary: z.object({
|
|
576
615
|
raw_pass_rate: z.number().nullable(),
|
|
577
616
|
compiled_pass_rate: z.number().nullable(),
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { type InterfConfig, type TestSpec, type TestTargetType, type SourceTruthCheck, type
|
|
2
|
-
export declare const SOURCE_FOLDER_CONFIG_FILE = "interf.
|
|
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
|
|
9
|
-
|
|
9
|
+
export interface WritableSourceProjectConfig {
|
|
10
|
+
datasets?: Array<Omit<SourceDatasetConfig, "path"> & {
|
|
11
|
+
path?: string;
|
|
12
|
+
}>;
|
|
10
13
|
}
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function saveSourceFolderConfig(sourcePath: string, config:
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
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
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
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
|
|
33
|
-
|
|
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;
|