@sanity/ailf 2.0.2 → 2.2.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_vendor/ailf-core/examples/index.d.ts +50 -1
  3. package/dist/_vendor/ailf-core/examples/index.js +66 -1
  4. package/dist/agent-harness/assertions-runtime.d.ts +49 -0
  5. package/dist/agent-harness/assertions-runtime.js +138 -0
  6. package/dist/agent-harness/provider.d.ts +58 -0
  7. package/dist/agent-harness/provider.js +104 -0
  8. package/dist/cli.js +0 -0
  9. package/dist/commands/init.js +3 -0
  10. package/dist/orchestration/steps/generate-configs-step.d.ts +7 -0
  11. package/dist/orchestration/steps/generate-configs-step.js +35 -2
  12. package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.js +39 -25
  13. package/dist/pipeline/compiler/compiler-to-yaml.js +78 -7
  14. package/dist/pipeline/compiler/mode-handlers/agent-harness/assertions.d.ts +9 -0
  15. package/dist/pipeline/compiler/mode-handlers/agent-harness/assertions.js +28 -85
  16. package/dist/pipeline/compiler/mode-handlers/agent-harness/compiler.js +22 -15
  17. package/dist/pipeline/compiler/mode-handlers/agent-harness/sandbox.d.ts +8 -1
  18. package/dist/pipeline/compiler/mode-handlers/agent-harness/sandbox.js +42 -12
  19. package/package.json +25 -24
  20. package/dist/_vendor/ailf-core/__tests__/comparison-formatters.test.d.ts +0 -10
  21. package/dist/_vendor/ailf-core/__tests__/comparison-formatters.test.js +0 -185
  22. package/dist/_vendor/ailf-core/artifact-capture/__tests__/noop-collector.test.d.ts +0 -6
  23. package/dist/_vendor/ailf-core/artifact-capture/__tests__/noop-collector.test.js +0 -42
  24. package/dist/_vendor/ailf-tasks/cli.d.ts +0 -8
  25. package/dist/_vendor/ailf-tasks/cli.js +0 -61
  26. package/dist/_vendor/ailf-tasks/index.d.ts +0 -13
  27. package/dist/_vendor/ailf-tasks/index.js +0 -16
  28. package/dist/_vendor/ailf-tasks/parser.d.ts +0 -27
  29. package/dist/_vendor/ailf-tasks/parser.js +0 -73
  30. package/dist/_vendor/ailf-tasks/schemas.d.ts +0 -198
  31. package/dist/_vendor/ailf-tasks/schemas.js +0 -180
  32. package/dist/_vendor/ailf-tasks/validation.d.ts +0 -47
  33. package/dist/_vendor/ailf-tasks/validation.js +0 -162
  34. package/dist/adapters/task-sources/yaml-task-source.d.ts +0 -18
  35. package/dist/adapters/task-sources/yaml-task-source.js +0 -139
  36. package/dist/agent-observer/test-imports.d.ts +0 -7
  37. package/dist/agent-observer/test-imports.js +0 -185
  38. package/dist/commands/update-quality-scores.d.ts +0 -5
  39. package/dist/commands/update-quality-scores.js +0 -20
  40. package/dist/lib/agent-behavior-report.d.ts +0 -8
  41. package/dist/lib/agent-behavior-report.js +0 -185
  42. package/dist/lib/baseline.d.ts +0 -19
  43. package/dist/lib/baseline.js +0 -153
  44. package/dist/lib/calculate-scores.d.ts +0 -23
  45. package/dist/lib/calculate-scores.js +0 -42
  46. package/dist/lib/compare.d.ts +0 -18
  47. package/dist/lib/compare.js +0 -170
  48. package/dist/lib/coverage-audit.d.ts +0 -4
  49. package/dist/lib/coverage-audit.js +0 -42
  50. package/dist/lib/discovery-report.d.ts +0 -13
  51. package/dist/lib/discovery-report.js +0 -57
  52. package/dist/lib/fetch-docs.d.ts +0 -30
  53. package/dist/lib/fetch-docs.js +0 -171
  54. package/dist/lib/generate-configs.d.ts +0 -25
  55. package/dist/lib/generate-configs.js +0 -42
  56. package/dist/lib/grader-api.d.ts +0 -21
  57. package/dist/lib/grader-api.js +0 -34
  58. package/dist/lib/grader-compare.d.ts +0 -19
  59. package/dist/lib/grader-compare.js +0 -91
  60. package/dist/lib/grader-consistency.d.ts +0 -27
  61. package/dist/lib/grader-consistency.js +0 -79
  62. package/dist/lib/grader-sensitivity.d.ts +0 -19
  63. package/dist/lib/grader-sensitivity.js +0 -75
  64. package/dist/lib/grader-validate.d.ts +0 -19
  65. package/dist/lib/grader-validate.js +0 -78
  66. package/dist/lib/measure-retrieval.d.ts +0 -14
  67. package/dist/lib/measure-retrieval.js +0 -71
  68. package/dist/lib/pr-comment.d.ts +0 -16
  69. package/dist/lib/pr-comment.js +0 -28
  70. package/dist/lib/readiness-report.d.ts +0 -13
  71. package/dist/lib/readiness-report.js +0 -108
  72. package/dist/lib/webhook-server.d.ts +0 -11
  73. package/dist/lib/webhook-server.js +0 -24
  74. package/dist/lib/weekly-digest.d.ts +0 -24
  75. package/dist/lib/weekly-digest.js +0 -148
  76. package/dist/orchestration/env-bridge.d.ts +0 -21
  77. package/dist/orchestration/env-bridge.js +0 -66
  78. package/dist/orchestration/steps/fetch-docs-shell.d.ts +0 -17
  79. package/dist/orchestration/steps/fetch-docs-shell.js +0 -30
  80. package/dist/pipeline/compiler/__tests__/task-bridge.test.d.ts +0 -9
  81. package/dist/pipeline/compiler/__tests__/task-bridge.test.js +0 -339
  82. package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.d.ts +0 -70
  83. package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.js +0 -485
  84. package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.d.ts +0 -76
  85. package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.js +0 -245
  86. package/dist/pipeline/compiler/mode-handlers/literacy-handler.d.ts +0 -89
  87. package/dist/pipeline/compiler/mode-handlers/literacy-handler.js +0 -379
  88. package/dist/pipeline/compiler/mode-handlers/mcp-assertions.d.ts +0 -50
  89. package/dist/pipeline/compiler/mode-handlers/mcp-assertions.js +0 -334
  90. package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.d.ts +0 -69
  91. package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.js +0 -307
  92. package/dist/pipeline/compiler/mode-handlers/mcp-tool-provider.d.ts +0 -65
  93. package/dist/pipeline/compiler/mode-handlers/mcp-tool-provider.js +0 -368
  94. package/dist/pipeline/compiler/task-bridge.d.ts +0 -41
  95. package/dist/pipeline/compiler/task-bridge.js +0 -92
  96. package/dist/pipeline/expand-tasks.d.ts +0 -232
  97. package/dist/pipeline/expand-tasks.js +0 -467
  98. package/dist/pipeline/generate-configs.d.ts +0 -92
  99. package/dist/pipeline/generate-configs.js +0 -445
  100. package/dist/pipeline/steps/calculate-scores-step.d.ts +0 -11
  101. package/dist/pipeline/steps/calculate-scores-step.js +0 -89
  102. package/dist/pipeline/steps/compare-step.d.ts +0 -18
  103. package/dist/pipeline/steps/compare-step.js +0 -90
  104. package/dist/pipeline/steps/eval-step.d.ts +0 -53
  105. package/dist/pipeline/steps/eval-step.js +0 -347
  106. package/dist/pipeline/steps/fetch-docs-step.d.ts +0 -11
  107. package/dist/pipeline/steps/fetch-docs-step.js +0 -84
  108. package/dist/pipeline/steps/generate-configs-step.d.ts +0 -11
  109. package/dist/pipeline/steps/generate-configs-step.js +0 -98
  110. package/dist/pipeline/steps/grader-consistency-step.d.ts +0 -21
  111. package/dist/pipeline/steps/grader-consistency-step.js +0 -74
  112. package/dist/pipeline/steps/publish-report-step.d.ts +0 -57
  113. package/dist/pipeline/steps/publish-report-step.js +0 -243
  114. package/dist/pipeline/steps/report-step.d.ts +0 -13
  115. package/dist/pipeline/steps/report-step.js +0 -56
  116. package/dist/pipeline/steps/update-scores-step.d.ts +0 -11
  117. package/dist/pipeline/steps/update-scores-step.js +0 -42
  118. package/dist/scripts/agent-behavior-report.d.ts +0 -19
  119. package/dist/scripts/agent-behavior-report.js +0 -315
  120. package/dist/scripts/baseline.d.ts +0 -43
  121. package/dist/scripts/baseline.js +0 -267
  122. package/dist/scripts/calculate-scores.d.ts +0 -166
  123. package/dist/scripts/calculate-scores.js +0 -1296
  124. package/dist/scripts/compare.d.ts +0 -22
  125. package/dist/scripts/compare.js +0 -334
  126. package/dist/scripts/coverage-audit.d.ts +0 -44
  127. package/dist/scripts/coverage-audit.js +0 -209
  128. package/dist/scripts/debug-eval.d.ts +0 -19
  129. package/dist/scripts/debug-eval.js +0 -73
  130. package/dist/scripts/discovery-report.d.ts +0 -58
  131. package/dist/scripts/discovery-report.js +0 -250
  132. package/dist/scripts/fetch-docs.d.ts +0 -35
  133. package/dist/scripts/fetch-docs.js +0 -472
  134. package/dist/scripts/generate-configs.d.ts +0 -66
  135. package/dist/scripts/generate-configs.js +0 -459
  136. package/dist/scripts/grader-api.d.ts +0 -27
  137. package/dist/scripts/grader-api.js +0 -206
  138. package/dist/scripts/grader-compare.d.ts +0 -22
  139. package/dist/scripts/grader-compare.js +0 -368
  140. package/dist/scripts/grader-consistency.d.ts +0 -20
  141. package/dist/scripts/grader-consistency.js +0 -313
  142. package/dist/scripts/grader-sensitivity.d.ts +0 -22
  143. package/dist/scripts/grader-sensitivity.js +0 -354
  144. package/dist/scripts/grader-validate.d.ts +0 -19
  145. package/dist/scripts/grader-validate.js +0 -267
  146. package/dist/scripts/measure-retrieval.d.ts +0 -10
  147. package/dist/scripts/measure-retrieval.js +0 -145
  148. package/dist/scripts/migrate-tasks-to-content-lake.d.ts +0 -24
  149. package/dist/scripts/migrate-tasks-to-content-lake.js +0 -328
  150. package/dist/scripts/pipeline.d.ts +0 -76
  151. package/dist/scripts/pipeline.js +0 -1031
  152. package/dist/scripts/pr-comment.d.ts +0 -10
  153. package/dist/scripts/pr-comment.js +0 -510
  154. package/dist/scripts/readiness-report.d.ts +0 -88
  155. package/dist/scripts/readiness-report.js +0 -342
  156. package/dist/scripts/update-quality-scores.d.ts +0 -15
  157. package/dist/scripts/update-quality-scores.js +0 -184
  158. package/dist/scripts/validate-task-sources.d.ts +0 -21
  159. package/dist/scripts/validate-task-sources.js +0 -210
  160. package/dist/scripts/validate.d.ts +0 -13
  161. package/dist/scripts/validate.js +0 -79
  162. package/dist/scripts/webhook-server.d.ts +0 -26
  163. package/dist/scripts/webhook-server.js +0 -147
  164. package/dist/scripts/weekly-digest.d.ts +0 -24
  165. package/dist/scripts/weekly-digest.js +0 -144
  166. package/dist/sinks/format-slack.d.ts +0 -64
  167. package/dist/sinks/format-slack.js +0 -306
  168. package/dist/sinks/slack-sink.d.ts +0 -27
  169. package/dist/sinks/slack-sink.js +0 -78
  170. package/dist/sinks/webhook-sink.d.ts +0 -19
  171. package/dist/sinks/webhook-sink.js +0 -50
  172. package/tasks/.expanded.agentic.yaml +0 -280
  173. package/tasks/.expanded.yaml +0 -565
@@ -1,198 +0,0 @@
1
- /**
2
- * schemas.ts — Zod schemas for repo-based task definitions.
3
- *
4
- * Validates .ailf/tasks/*.yaml task files from external repositories.
5
- * These schemas are the contract between external repos and the AILF eval
6
- * pipeline — they define exactly what fields are accepted, with friendly
7
- * error messages for authors writing task YAML by hand.
8
- *
9
- * This module is the single source of truth for task schemas. The eval
10
- * package re-exports from here to avoid duplication.
11
- *
12
- * @see docs/exec-plans/tasks-as-content/phase-4-repo-based-tasks.md
13
- */
14
- import { z } from "zod";
15
- /**
16
- * The set of assertion types allowed in repo-based task files.
17
- *
18
- * This is a curated subset of Promptfoo assertion types — we expose only the
19
- * types that are stable, well-documented, and useful for external authors.
20
- */
21
- export declare const CURATED_ASSERTION_TYPES: readonly ["llm-rubric", "contains", "contains-any", "contains-all", "not-contains", "icontains", "icontains-any", "regex", "javascript", "similar", "cost", "latency"];
22
- export type CuratedAssertionType = (typeof CURATED_ASSERTION_TYPES)[number];
23
- /**
24
- * Valid rubric template names — must match keys in config/rubrics.yaml.
25
- */
26
- export declare const RUBRIC_TEMPLATE_NAMES: readonly ["task-completion", "code-correctness", "doc-coverage"];
27
- export type RubricTemplateName = (typeof RUBRIC_TEMPLATE_NAMES)[number];
28
- /**
29
- * Zod schema for a single repo-based task definition.
30
- *
31
- * This is the external-author-facing contract. Field names are camelCase
32
- * to match the Content Lake document schema (ailf.task).
33
- */
34
- export declare const RepoTaskSchema: z.ZodObject<{
35
- id: z.ZodString;
36
- description: z.ZodString;
37
- status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
38
- active: "active";
39
- draft: "draft";
40
- paused: "paused";
41
- archived: "archived";
42
- }>>>;
43
- featureArea: z.ZodString;
44
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
- canonicalDocs: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
46
- id: z.ZodString;
47
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
48
- slug: z.ZodOptional<z.ZodString>;
49
- path: z.ZodOptional<z.ZodString>;
50
- }, z.core.$strip>, z.ZodObject<{
51
- slug: z.ZodString;
52
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
- }, z.core.$strip>, z.ZodObject<{
54
- path: z.ZodString;
55
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
56
- }, z.core.$strip>, z.ZodObject<{
57
- perspective: z.ZodString;
58
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
59
- }, z.core.$strip>]>>>>;
60
- vars: z.ZodOptional<z.ZodObject<{
61
- task: z.ZodString;
62
- }, z.core.$loose>>;
63
- assert: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
64
- type: z.ZodLiteral<"llm-rubric">;
65
- template: z.ZodEnum<{
66
- "task-completion": "task-completion";
67
- "code-correctness": "code-correctness";
68
- "doc-coverage": "doc-coverage";
69
- }>;
70
- criteria: z.ZodArray<z.ZodString>;
71
- weight: z.ZodOptional<z.ZodNumber>;
72
- }, z.core.$strip>, z.ZodObject<{
73
- type: z.ZodEnum<{
74
- "llm-rubric": "llm-rubric";
75
- contains: "contains";
76
- "contains-any": "contains-any";
77
- "contains-all": "contains-all";
78
- "not-contains": "not-contains";
79
- icontains: "icontains";
80
- "icontains-any": "icontains-any";
81
- regex: "regex";
82
- javascript: "javascript";
83
- similar: "similar";
84
- cost: "cost";
85
- latency: "latency";
86
- }>;
87
- value: z.ZodOptional<z.ZodUnknown>;
88
- threshold: z.ZodOptional<z.ZodNumber>;
89
- weight: z.ZodOptional<z.ZodNumber>;
90
- }, z.core.$loose>]>>;
91
- baseline: z.ZodOptional<z.ZodObject<{
92
- enabled: z.ZodOptional<z.ZodBoolean>;
93
- rubric: z.ZodOptional<z.ZodEnum<{
94
- abbreviated: "abbreviated";
95
- full: "full";
96
- none: "none";
97
- }>>;
98
- }, z.core.$strip>>;
99
- docCoverage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
100
- referenceSolution: z.ZodOptional<z.ZodString>;
101
- execution: z.ZodOptional<z.ZodObject<{
102
- enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
103
- blocking: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
104
- threshold: z.ZodOptional<z.ZodObject<{
105
- score: z.ZodOptional<z.ZodNumber>;
106
- }, z.core.$strip>>;
107
- trigger: z.ZodOptional<z.ZodObject<{
108
- branches: z.ZodOptional<z.ZodArray<z.ZodString>>;
109
- paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
110
- }, z.core.$strip>>;
111
- source: z.ZodOptional<z.ZodString>;
112
- }, z.core.$strip>>;
113
- }, z.core.$strip>;
114
- export type RepoTask = z.infer<typeof RepoTaskSchema>;
115
- /**
116
- * Schema for an array of repo tasks — what a single .ailf/tasks/*.yaml file
117
- * contains. Each file must define at least one task.
118
- */
119
- export declare const RepoTaskFileSchema: z.ZodArray<z.ZodObject<{
120
- id: z.ZodString;
121
- description: z.ZodString;
122
- status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
123
- active: "active";
124
- draft: "draft";
125
- paused: "paused";
126
- archived: "archived";
127
- }>>>;
128
- featureArea: z.ZodString;
129
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
- canonicalDocs: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
131
- id: z.ZodString;
132
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
133
- slug: z.ZodOptional<z.ZodString>;
134
- path: z.ZodOptional<z.ZodString>;
135
- }, z.core.$strip>, z.ZodObject<{
136
- slug: z.ZodString;
137
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
138
- }, z.core.$strip>, z.ZodObject<{
139
- path: z.ZodString;
140
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
141
- }, z.core.$strip>, z.ZodObject<{
142
- perspective: z.ZodString;
143
- reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
144
- }, z.core.$strip>]>>>>;
145
- vars: z.ZodOptional<z.ZodObject<{
146
- task: z.ZodString;
147
- }, z.core.$loose>>;
148
- assert: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
149
- type: z.ZodLiteral<"llm-rubric">;
150
- template: z.ZodEnum<{
151
- "task-completion": "task-completion";
152
- "code-correctness": "code-correctness";
153
- "doc-coverage": "doc-coverage";
154
- }>;
155
- criteria: z.ZodArray<z.ZodString>;
156
- weight: z.ZodOptional<z.ZodNumber>;
157
- }, z.core.$strip>, z.ZodObject<{
158
- type: z.ZodEnum<{
159
- "llm-rubric": "llm-rubric";
160
- contains: "contains";
161
- "contains-any": "contains-any";
162
- "contains-all": "contains-all";
163
- "not-contains": "not-contains";
164
- icontains: "icontains";
165
- "icontains-any": "icontains-any";
166
- regex: "regex";
167
- javascript: "javascript";
168
- similar: "similar";
169
- cost: "cost";
170
- latency: "latency";
171
- }>;
172
- value: z.ZodOptional<z.ZodUnknown>;
173
- threshold: z.ZodOptional<z.ZodNumber>;
174
- weight: z.ZodOptional<z.ZodNumber>;
175
- }, z.core.$loose>]>>;
176
- baseline: z.ZodOptional<z.ZodObject<{
177
- enabled: z.ZodOptional<z.ZodBoolean>;
178
- rubric: z.ZodOptional<z.ZodEnum<{
179
- abbreviated: "abbreviated";
180
- full: "full";
181
- none: "none";
182
- }>>;
183
- }, z.core.$strip>>;
184
- docCoverage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
185
- referenceSolution: z.ZodOptional<z.ZodString>;
186
- execution: z.ZodOptional<z.ZodObject<{
187
- enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
188
- blocking: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
189
- threshold: z.ZodOptional<z.ZodObject<{
190
- score: z.ZodOptional<z.ZodNumber>;
191
- }, z.core.$strip>>;
192
- trigger: z.ZodOptional<z.ZodObject<{
193
- branches: z.ZodOptional<z.ZodArray<z.ZodString>>;
194
- paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
- }, z.core.$strip>>;
196
- source: z.ZodOptional<z.ZodString>;
197
- }, z.core.$strip>>;
198
- }, z.core.$strip>>;
@@ -1,180 +0,0 @@
1
- /**
2
- * schemas.ts — Zod schemas for repo-based task definitions.
3
- *
4
- * Validates .ailf/tasks/*.yaml task files from external repositories.
5
- * These schemas are the contract between external repos and the AILF eval
6
- * pipeline — they define exactly what fields are accepted, with friendly
7
- * error messages for authors writing task YAML by hand.
8
- *
9
- * This module is the single source of truth for task schemas. The eval
10
- * package re-exports from here to avoid duplication.
11
- *
12
- * @see docs/exec-plans/tasks-as-content/phase-4-repo-based-tasks.md
13
- */
14
- import { z } from "zod";
15
- // ---------------------------------------------------------------------------
16
- // Constants — curated assertion types and rubric template names
17
- // ---------------------------------------------------------------------------
18
- /**
19
- * The set of assertion types allowed in repo-based task files.
20
- *
21
- * This is a curated subset of Promptfoo assertion types — we expose only the
22
- * types that are stable, well-documented, and useful for external authors.
23
- */
24
- export const CURATED_ASSERTION_TYPES = [
25
- "llm-rubric",
26
- "contains",
27
- "contains-any",
28
- "contains-all",
29
- "not-contains",
30
- "icontains",
31
- "icontains-any",
32
- "regex",
33
- "javascript",
34
- "similar",
35
- "cost",
36
- "latency",
37
- ];
38
- /**
39
- * Valid rubric template names — must match keys in config/rubrics.yaml.
40
- */
41
- export const RUBRIC_TEMPLATE_NAMES = [
42
- "task-completion",
43
- "code-correctness",
44
- "doc-coverage",
45
- ];
46
- // ---------------------------------------------------------------------------
47
- // Assertion schemas
48
- // ---------------------------------------------------------------------------
49
- /**
50
- * Polymorphic canonical doc reference — discriminated by key presence.
51
- * Exactly one resolution key (slug, path, id, or perspective) must be present.
52
- *
53
- * @see docs/design-docs/canonical-doc-resolution.md
54
- */
55
- const SlugDocRefSchema = z.object({
56
- slug: z.string().min(1),
57
- reason: z.string().optional().default(""),
58
- });
59
- const PathDocRefSchema = z.object({
60
- path: z.string().min(1),
61
- reason: z.string().optional().default(""),
62
- });
63
- const IdDocRefSchema = z.object({
64
- id: z.string().min(1),
65
- reason: z.string().optional().default(""),
66
- /** Human-readable slug annotation (not used for resolution) */
67
- slug: z.string().optional(),
68
- /** Human-readable path annotation (not used for resolution) */
69
- path: z.string().optional(),
70
- });
71
- const PerspectiveDocRefSchema = z.object({
72
- perspective: z.string().min(1),
73
- reason: z.string().optional().default(""),
74
- });
75
- // Order matters: IdDocRefSchema first because it may also carry `slug`
76
- // and `path` as optional annotations. Zod tries schemas in order, so
77
- // entries like `{ id: "...", slug: "..." }` must match IdDocRefSchema
78
- // (not SlugDocRefSchema).
79
- const CanonicalDocRefSchema = z.union([
80
- IdDocRefSchema,
81
- SlugDocRefSchema,
82
- PathDocRefSchema,
83
- PerspectiveDocRefSchema,
84
- ]);
85
- /**
86
- * A templated LLM-rubric assertion — uses one of the predefined rubric
87
- * templates with author-supplied criteria.
88
- */
89
- const TemplatedAssertionSchema = z.object({
90
- type: z.literal("llm-rubric"),
91
- template: z.enum(RUBRIC_TEMPLATE_NAMES),
92
- criteria: z.array(z.string().min(1)).min(1),
93
- weight: z.number().optional(),
94
- });
95
- /**
96
- * A value-based assertion (contains, regex, cost, etc.). Uses .passthrough()
97
- * to allow extra fields for future extension without schema breakage.
98
- */
99
- const ValueAssertionSchema = z
100
- .object({
101
- type: z.enum(CURATED_ASSERTION_TYPES),
102
- value: z.unknown().optional(),
103
- threshold: z.number().optional(),
104
- weight: z.number().optional(),
105
- })
106
- .passthrough();
107
- /** Union of all supported assertion shapes. */
108
- const AssertionSchema = z.union([
109
- TemplatedAssertionSchema,
110
- ValueAssertionSchema,
111
- ]);
112
- // ---------------------------------------------------------------------------
113
- // Nested config schemas
114
- // ---------------------------------------------------------------------------
115
- const BaselineConfigSchema = z
116
- .object({
117
- enabled: z.boolean().optional(),
118
- rubric: z.enum(["abbreviated", "full", "none"]).optional(),
119
- })
120
- .optional();
121
- const ExecutionConfigSchema = z
122
- .object({
123
- enabled: z.boolean().optional().default(true),
124
- blocking: z.boolean().optional().default(false),
125
- threshold: z
126
- .object({
127
- score: z.number().min(0).max(100).optional(),
128
- })
129
- .optional(),
130
- trigger: z
131
- .object({
132
- branches: z.array(z.string()).optional(),
133
- paths: z.array(z.string()).optional(),
134
- })
135
- .optional(),
136
- source: z.string().optional(),
137
- })
138
- .optional();
139
- // ---------------------------------------------------------------------------
140
- // RepoTaskSchema — a single task definition from .ailf/tasks/*.yaml
141
- // ---------------------------------------------------------------------------
142
- /**
143
- * Zod schema for a single repo-based task definition.
144
- *
145
- * This is the external-author-facing contract. Field names are camelCase
146
- * to match the Content Lake document schema (ailf.task).
147
- */
148
- export const RepoTaskSchema = z.object({
149
- id: z
150
- .string()
151
- .min(1)
152
- .regex(/^[a-z0-9][a-z0-9-]*$/, "Task ID must be lowercase alphanumeric with hyphens"),
153
- description: z.string().min(1),
154
- status: z
155
- .enum(["active", "draft", "paused", "archived"])
156
- .optional()
157
- .default("active"),
158
- featureArea: z
159
- .string()
160
- .min(1)
161
- .regex(/^[a-z0-9][a-z0-9-]*$/, "Feature area must be lowercase alphanumeric with hyphens"),
162
- tags: z.array(z.string()).optional(),
163
- canonicalDocs: z.array(CanonicalDocRefSchema).optional().default([]),
164
- vars: z
165
- .object({
166
- task: z.string().min(1),
167
- })
168
- .passthrough()
169
- .optional(),
170
- assert: z.array(AssertionSchema).min(1),
171
- baseline: BaselineConfigSchema,
172
- docCoverage: z.boolean().optional().default(false),
173
- referenceSolution: z.string().optional(),
174
- execution: ExecutionConfigSchema,
175
- });
176
- /**
177
- * Schema for an array of repo tasks — what a single .ailf/tasks/*.yaml file
178
- * contains. Each file must define at least one task.
179
- */
180
- export const RepoTaskFileSchema = z.array(RepoTaskSchema).min(1);
@@ -1,47 +0,0 @@
1
- /**
2
- * validation.ts — Semantic validation for repo-based tasks.
3
- *
4
- * Checks that go beyond Zod schema parsing:
5
- * - Assertion types are in the curated set
6
- * - Rubric template names resolve to known templates
7
- * - Feature area strings are well-formed
8
- * - Canonical doc slugs look reasonable (slugs, not URLs)
9
- *
10
- * These produce warnings, not errors — the pipeline can still run
11
- * with imperfect tasks. Only structural failures (caught by Zod) block.
12
- */
13
- import { type RepoTask } from "./schemas.js";
14
- export interface ValidationResult {
15
- valid: boolean;
16
- errors: ValidationMessage[];
17
- warnings: ValidationMessage[];
18
- }
19
- export interface ValidationMessage {
20
- taskId: string;
21
- field: string;
22
- message: string;
23
- }
24
- /**
25
- * Run semantic validation on an array of parsed repo tasks.
26
- *
27
- * Returns warnings for issues that don't block execution (unknown feature
28
- * areas, unresolved slugs) and errors for issues that would cause pipeline
29
- * failures (completely missing required fields — though Zod catches most).
30
- */
31
- export declare function validateRepoTasks(tasks: RepoTask[]): ValidationResult;
32
- /**
33
- * Format validation results for console output.
34
- */
35
- export declare function formatValidationResult(result: ValidationResult): string;
36
- /**
37
- * Detect snake_case field names in raw task YAML data.
38
- *
39
- * This runs BEFORE Zod parsing to provide a user-friendly error message
40
- * when authors use framework-internal snake_case names instead of the
41
- * camelCase names expected in repo task files.
42
- *
43
- * @param raw - Raw parsed YAML (before Zod validation)
44
- * @param filename - Source filename for error messages
45
- * @returns Array of warning messages (empty if no issues)
46
- */
47
- export declare function detectSnakeCaseFields(raw: unknown, filename: string): string[];
@@ -1,162 +0,0 @@
1
- /**
2
- * validation.ts — Semantic validation for repo-based tasks.
3
- *
4
- * Checks that go beyond Zod schema parsing:
5
- * - Assertion types are in the curated set
6
- * - Rubric template names resolve to known templates
7
- * - Feature area strings are well-formed
8
- * - Canonical doc slugs look reasonable (slugs, not URLs)
9
- *
10
- * These produce warnings, not errors — the pipeline can still run
11
- * with imperfect tasks. Only structural failures (caught by Zod) block.
12
- */
13
- import { CURATED_ASSERTION_TYPES, RUBRIC_TEMPLATE_NAMES, } from "./schemas.js";
14
- // ---------------------------------------------------------------------------
15
- // Public API
16
- // ---------------------------------------------------------------------------
17
- /**
18
- * Run semantic validation on an array of parsed repo tasks.
19
- *
20
- * Returns warnings for issues that don't block execution (unknown feature
21
- * areas, unresolved slugs) and errors for issues that would cause pipeline
22
- * failures (completely missing required fields — though Zod catches most).
23
- */
24
- export function validateRepoTasks(tasks) {
25
- const errors = [];
26
- const warnings = [];
27
- // Check for duplicate IDs
28
- const seenIds = new Set();
29
- for (const task of tasks) {
30
- if (seenIds.has(task.id)) {
31
- errors.push({
32
- taskId: task.id,
33
- field: "id",
34
- message: `Duplicate task ID "${task.id}"`,
35
- });
36
- }
37
- seenIds.add(task.id);
38
- }
39
- for (const task of tasks) {
40
- // Check assertion types
41
- for (let i = 0; i < task.assert.length; i++) {
42
- const assertion = task.assert[i];
43
- if (!CURATED_ASSERTION_TYPES.includes(assertion.type)) {
44
- warnings.push({
45
- taskId: task.id,
46
- field: `assert[${i}].type`,
47
- message: `Unknown assertion type "${assertion.type}". ` +
48
- `Valid types: ${CURATED_ASSERTION_TYPES.join(", ")}`,
49
- });
50
- }
51
- // Check rubric template for llm-rubric assertions
52
- if (assertion.type === "llm-rubric" && "template" in assertion) {
53
- const template = assertion.template;
54
- if (!RUBRIC_TEMPLATE_NAMES.includes(template)) {
55
- warnings.push({
56
- taskId: task.id,
57
- field: `assert[${i}].template`,
58
- message: `Unknown rubric template "${template}". ` +
59
- `Valid templates: ${RUBRIC_TEMPLATE_NAMES.join(", ")}`,
60
- });
61
- }
62
- }
63
- }
64
- // Check canonical doc refs look reasonable
65
- for (let i = 0; i < (task.canonicalDocs?.length ?? 0); i++) {
66
- const doc = task.canonicalDocs[i];
67
- // Slug refs: warn if they look like URLs or paths
68
- if ("slug" in doc && !("id" in doc) && typeof doc.slug === "string") {
69
- if (doc.slug.includes("/") || doc.slug.includes("http")) {
70
- warnings.push({
71
- taskId: task.id,
72
- field: `canonicalDocs[${i}].slug`,
73
- message: `Slug "${doc.slug}" looks like a URL or path — use 'path' type for paths or 'slug' for document slugs (e.g., "groq-introduction")`,
74
- });
75
- }
76
- }
77
- }
78
- // Check task has at least one llm-rubric assertion (recommended but not required)
79
- const hasLlmRubric = task.assert.some((a) => a.type === "llm-rubric");
80
- if (!hasLlmRubric) {
81
- warnings.push({
82
- taskId: task.id,
83
- field: "assert",
84
- message: "No llm-rubric assertion found. Tasks should have at least one scored rubric for meaningful evaluation.",
85
- });
86
- }
87
- // Check taskPrompt exists in vars (vars.task)
88
- if (!task.vars?.task) {
89
- warnings.push({
90
- taskId: task.id,
91
- field: "vars.task",
92
- message: "No task prompt found in vars.task. The LLM will receive an empty implementation request.",
93
- });
94
- }
95
- }
96
- return {
97
- valid: errors.length === 0,
98
- errors,
99
- warnings,
100
- };
101
- }
102
- /**
103
- * Format validation results for console output.
104
- */
105
- export function formatValidationResult(result) {
106
- const lines = [];
107
- if (result.errors.length > 0) {
108
- lines.push("❌ Errors:");
109
- for (const e of result.errors) {
110
- lines.push(` [${e.taskId}] ${e.field}: ${e.message}`);
111
- }
112
- }
113
- if (result.warnings.length > 0) {
114
- lines.push("⚠️ Warnings:");
115
- for (const w of result.warnings) {
116
- lines.push(` [${w.taskId}] ${w.field}: ${w.message}`);
117
- }
118
- }
119
- if (result.valid && result.warnings.length === 0) {
120
- lines.push("✅ All repo tasks pass validation");
121
- }
122
- return lines.join("\n");
123
- }
124
- // ---------------------------------------------------------------------------
125
- // Snake_case detection (pre-parse helper)
126
- // ---------------------------------------------------------------------------
127
- /** Known snake_case → camelCase field mappings for common errors */
128
- const SNAKE_TO_CAMEL = {
129
- feature_area: "featureArea",
130
- canonical_docs: "canonicalDocs",
131
- doc_coverage: "docCoverage",
132
- reference_solution: "referenceSolution",
133
- };
134
- /**
135
- * Detect snake_case field names in raw task YAML data.
136
- *
137
- * This runs BEFORE Zod parsing to provide a user-friendly error message
138
- * when authors use framework-internal snake_case names instead of the
139
- * camelCase names expected in repo task files.
140
- *
141
- * @param raw - Raw parsed YAML (before Zod validation)
142
- * @param filename - Source filename for error messages
143
- * @returns Array of warning messages (empty if no issues)
144
- */
145
- export function detectSnakeCaseFields(raw, filename) {
146
- const warnings = [];
147
- if (!Array.isArray(raw))
148
- return warnings;
149
- for (let i = 0; i < raw.length; i++) {
150
- const entry = raw[i];
151
- if (typeof entry !== "object" || entry === null)
152
- continue;
153
- const obj = entry;
154
- const taskId = typeof obj.id === "string" ? obj.id : `task[${i}]`;
155
- for (const [snake, camel] of Object.entries(SNAKE_TO_CAMEL)) {
156
- if (snake in obj) {
157
- warnings.push(`[${filename}] ${taskId}: Found "${snake}" — repo tasks use camelCase. Did you mean "${camel}"?`);
158
- }
159
- }
160
- }
161
- return warnings;
162
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Adapter: Load task definitions from tasks/*.yaml files.
3
- *
4
- * This adapter reads the raw YAML task definitions (before Promptfoo
5
- * expansion) and maps them to GeneralizedTaskDefinition
6
- * (LiteracyTaskDefinition variant) from @sanity/ailf-core. It handles
7
- * area filtering (filename stem) and task ID filtering.
8
- *
9
- * Unlike loadAndExpandTasks() — which produces Promptfoo-specific
10
- * ExpandedTestEntry objects — this adapter produces domain-level
11
- * GeneralizedTaskDefinition objects suitable for the pipeline orchestrator.
12
- */
13
- import type { FilterOptions, GeneralizedTaskDefinition, TaskSource } from "../../_vendor/ailf-core/index.d.ts";
14
- export declare class YamlTaskSource implements TaskSource {
15
- private readonly rootDir;
16
- constructor(rootDir: string);
17
- loadTasks(filter?: FilterOptions): Promise<GeneralizedTaskDefinition[]>;
18
- }