fito-tui 0.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 (179) hide show
  1. package/README.md +88 -0
  2. package/agents/fito-case-source-planner.md +265 -0
  3. package/agents/fito-performance-reviewer.md +231 -0
  4. package/agents/fito-practice-concept-content-generator.md +318 -0
  5. package/agents/fito-practice-concept-identifier.md +482 -0
  6. package/agents/fito-practice-execution-fact-content-generator.md +299 -0
  7. package/agents/fito-practice-execution-fact-identifier.md +367 -0
  8. package/agents/fito-practice-usage-scenario-content-generator.md +331 -0
  9. package/agents/fito-practice-usage-scenario-identifier.md +397 -0
  10. package/agents/fito-subagent-selftest.md +27 -0
  11. package/agents/fito-technology-generator.md +207 -0
  12. package/agents/fito-tool-concept-content-generator.md +282 -0
  13. package/agents/fito-tool-concept-identifier.md +384 -0
  14. package/agents/fito-tool-execution-fact-content-generator.md +382 -0
  15. package/agents/fito-tool-execution-fact-identifier.md +360 -0
  16. package/agents/fito-tool-usage-scenario-content-generator.md +381 -0
  17. package/agents/fito-tool-usage-scenario-identifier.md +432 -0
  18. package/agents/fito-tutor.md +185 -0
  19. package/extensions/fito-delegate.js +539 -0
  20. package/extensions/fito-delegate.ts +691 -0
  21. package/extensions/fito-fetch-tools.js +380 -0
  22. package/extensions/fito-fetch-tools.ts +419 -0
  23. package/extensions/fito-startup.js +166 -0
  24. package/extensions/fito-startup.ts +188 -0
  25. package/package.json +56 -0
  26. package/prompts/fito-auth-refresh.md +15 -0
  27. package/prompts/fito-case-design.md +506 -0
  28. package/prompts/fito-case-edit.md +91 -0
  29. package/prompts/fito-case-generate.md +222 -0
  30. package/prompts/fito-case-open.md +124 -0
  31. package/prompts/fito-case-plan-source.md +114 -0
  32. package/prompts/fito-create-or-update-competence.md +261 -0
  33. package/prompts/fito-create-or-update-technology.md +199 -0
  34. package/prompts/fito-delete-competence.md +147 -0
  35. package/prompts/fito-evaluate.md +148 -0
  36. package/prompts/fito-fetch-urls-content.md +35 -0
  37. package/prompts/fito-generate-domain-concepts.md +85 -0
  38. package/prompts/fito-generate-execution-facts.md +85 -0
  39. package/prompts/fito-generate-usage-scenarios.md +85 -0
  40. package/prompts/fito-identify-domain-concepts.md +49 -0
  41. package/prompts/fito-identify-execution-facts.md +49 -0
  42. package/prompts/fito-identify-usage-scenarios.md +49 -0
  43. package/prompts/fito-login.md +21 -0
  44. package/prompts/fito-logout.md +14 -0
  45. package/prompts/fito-publish-case.md +266 -0
  46. package/prompts/fito-push-knowledge.md +84 -0
  47. package/prompts/fito-submit.md +208 -0
  48. package/prompts/fito-tutor.md +120 -0
  49. package/shared/case-briefing/briefing.js +221 -0
  50. package/shared/case-briefing/briefing.ts +261 -0
  51. package/shared/case-quiz/scoring.js +16 -0
  52. package/shared/case-quiz/scoring.ts +61 -0
  53. package/shared/case-validation/case-loader.js +88 -0
  54. package/shared/case-validation/case-loader.ts +106 -0
  55. package/shared/case-validation/case-schema.js +716 -0
  56. package/shared/case-validation/case-schema.ts +895 -0
  57. package/shared/competences/competence-list.js +29 -0
  58. package/shared/competences/competence-list.ts +32 -0
  59. package/shared/fito-api/README.md +192 -0
  60. package/shared/fito-api/client.js +731 -0
  61. package/shared/fito-api/client.ts +1426 -0
  62. package/shared/fito-session/credentials.js +79 -0
  63. package/shared/fito-session/credentials.ts +88 -0
  64. package/shared/fito-session/session.js +16 -0
  65. package/shared/fito-session/session.ts +35 -0
  66. package/shared/github-url/parse.js +26 -0
  67. package/shared/github-url/parse.ts +35 -0
  68. package/shared/knowledge-components/component-names.js +35 -0
  69. package/shared/knowledge-components/component-names.ts +39 -0
  70. package/shared/knowledge-components/knowledge-fetch.js +46 -0
  71. package/shared/knowledge-components/knowledge-fetch.ts +57 -0
  72. package/shared/knowledge-components/knowledge-search.js +101 -0
  73. package/shared/knowledge-components/knowledge-search.ts +144 -0
  74. package/shared/knowledge-components/push-payload.js +104 -0
  75. package/shared/knowledge-components/push-payload.ts +129 -0
  76. package/shared/knowledge-components/reference.js +24 -0
  77. package/shared/knowledge-components/reference.ts +43 -0
  78. package/shared/knowledge-components/technology-fetch.js +30 -0
  79. package/shared/knowledge-components/technology-fetch.ts +38 -0
  80. package/shared/shell-exec/exec.js +22 -0
  81. package/shared/shell-exec/exec.ts +46 -0
  82. package/skills/fito-auth/SKILL.md +68 -0
  83. package/skills/fito-auth/auth-refresh.js +23 -0
  84. package/skills/fito-auth/auth-refresh.ts +25 -0
  85. package/skills/fito-auth/browser.js +35 -0
  86. package/skills/fito-auth/browser.ts +57 -0
  87. package/skills/fito-auth/callback-server.js +152 -0
  88. package/skills/fito-auth/callback-server.ts +189 -0
  89. package/skills/fito-auth/login.js +37 -0
  90. package/skills/fito-auth/login.ts +42 -0
  91. package/skills/fito-auth/logout.js +24 -0
  92. package/skills/fito-auth/logout.ts +25 -0
  93. package/skills/fito-case-author/SKILL.md +179 -0
  94. package/skills/fito-case-author/checkout.js +222 -0
  95. package/skills/fito-case-author/checkout.ts +281 -0
  96. package/skills/fito-case-author/github-publish.js +218 -0
  97. package/skills/fito-case-author/github-publish.ts +251 -0
  98. package/skills/fito-case-author/publish-payload.js +108 -0
  99. package/skills/fito-case-author/publish-payload.ts +186 -0
  100. package/skills/fito-case-author/publish-state.js +72 -0
  101. package/skills/fito-case-author/publish-state.ts +87 -0
  102. package/skills/fito-case-author/publish-version.js +364 -0
  103. package/skills/fito-case-author/publish-version.ts +495 -0
  104. package/skills/fito-case-author/publish.js +284 -0
  105. package/skills/fito-case-author/publish.ts +394 -0
  106. package/skills/fito-case-author/semver.js +55 -0
  107. package/skills/fito-case-author/semver.ts +63 -0
  108. package/skills/fito-case-author/status-gate.js +34 -0
  109. package/skills/fito-case-author/status-gate.ts +54 -0
  110. package/skills/fito-case-author/validate.js +62 -0
  111. package/skills/fito-case-author/validate.ts +64 -0
  112. package/skills/fito-case-runner/SKILL.md +119 -0
  113. package/skills/fito-case-runner/case-component-names.js +45 -0
  114. package/skills/fito-case-runner/case-component-names.ts +65 -0
  115. package/skills/fito-case-runner/case-detail.js +20 -0
  116. package/skills/fito-case-runner/case-detail.ts +20 -0
  117. package/skills/fito-case-runner/github.js +234 -0
  118. package/skills/fito-case-runner/github.ts +287 -0
  119. package/skills/fito-case-runner/manifest.js +56 -0
  120. package/skills/fito-case-runner/manifest.ts +73 -0
  121. package/skills/fito-case-runner/open.js +175 -0
  122. package/skills/fito-case-runner/open.ts +241 -0
  123. package/skills/fito-case-runner/report.js +22 -0
  124. package/skills/fito-case-runner/report.ts +24 -0
  125. package/skills/fito-case-runner/runner.js +158 -0
  126. package/skills/fito-case-runner/runner.ts +304 -0
  127. package/skills/fito-case-runner/score-quiz-mc.js +85 -0
  128. package/skills/fito-case-runner/score-quiz-mc.ts +99 -0
  129. package/skills/fito-case-runner/submit-evaluation.js +73 -0
  130. package/skills/fito-case-runner/submit-evaluation.ts +98 -0
  131. package/skills/fito-case-runner/submit-quiz-result.js +75 -0
  132. package/skills/fito-case-runner/submit-quiz-result.ts +100 -0
  133. package/skills/fito-case-runner/submit.js +85 -0
  134. package/skills/fito-case-runner/submit.ts +111 -0
  135. package/skills/fito-case-runner/workdir.js +10 -0
  136. package/skills/fito-case-runner/workdir.ts +11 -0
  137. package/skills/fito-competence-write/SKILL.md +155 -0
  138. package/skills/fito-competence-write/create.js +64 -0
  139. package/skills/fito-competence-write/create.ts +80 -0
  140. package/skills/fito-competence-write/delete.js +136 -0
  141. package/skills/fito-competence-write/delete.ts +166 -0
  142. package/skills/fito-competence-write/display.js +20 -0
  143. package/skills/fito-competence-write/display.ts +21 -0
  144. package/skills/fito-competence-write/payload.js +96 -0
  145. package/skills/fito-competence-write/payload.ts +115 -0
  146. package/skills/fito-competence-write/update.js +155 -0
  147. package/skills/fito-competence-write/update.ts +206 -0
  148. package/skills/fito-evaluator/SKILL.md +73 -0
  149. package/skills/fito-evaluator/criterion-exec.js +64 -0
  150. package/skills/fito-evaluator/criterion-exec.ts +73 -0
  151. package/skills/fito-evaluator/evaluate-automated.js +57 -0
  152. package/skills/fito-evaluator/evaluate-automated.ts +84 -0
  153. package/skills/fito-evaluator/evaluate.js +28 -0
  154. package/skills/fito-evaluator/evaluate.ts +86 -0
  155. package/skills/fito-evaluator/report.js +112 -0
  156. package/skills/fito-evaluator/report.ts +128 -0
  157. package/skills/fito-evaluator/rubric.js +90 -0
  158. package/skills/fito-evaluator/rubric.ts +170 -0
  159. package/skills/fito-knowledge-push/SKILL.md +114 -0
  160. package/skills/fito-knowledge-push/push.js +282 -0
  161. package/skills/fito-knowledge-push/push.ts +360 -0
  162. package/skills/fito-source-ingestion/SKILL.md +77 -0
  163. package/skills/fito-source-ingestion/authoring-check.js +128 -0
  164. package/skills/fito-source-ingestion/authoring-check.ts +155 -0
  165. package/skills/fito-source-ingestion/bundle.js +198 -0
  166. package/skills/fito-source-ingestion/bundle.ts +246 -0
  167. package/skills/fito-technology-write/SKILL.md +108 -0
  168. package/skills/fito-technology-write/create.js +134 -0
  169. package/skills/fito-technology-write/create.ts +161 -0
  170. package/skills/fito-technology-write/payload.js +64 -0
  171. package/skills/fito-technology-write/payload.ts +70 -0
  172. package/skills/fito-technology-write/update.js +122 -0
  173. package/skills/fito-technology-write/update.ts +171 -0
  174. package/skills/fito-url-content-fetcher/SKILL.md +213 -0
  175. package/templates/concept-practice-content-template.md +281 -0
  176. package/templates/concept-tool-content-template.md +207 -0
  177. package/templates/execution-fact-practice-content-template.md +372 -0
  178. package/templates/execution-fact-tool-content-template.md +307 -0
  179. package/templates/usage-scenario-content-template.md +248 -0
@@ -0,0 +1,716 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The `.case/` **structural** validator — the canonical executable ruleset for the
4
+ * Fito profile of Case Structure Spec v0.3 (`specs_and_tasks/SPEC.md` §Case Structure,
5
+ * the narrative spec). It enforces every `.case/` rule that is a pure function of the
6
+ * repo bytes; it does **not** resolve `knowledge_component` references against the
7
+ * backend — reference *existence* is the Case Registry's job (Task 3.3). Branch/tag
8
+ * existence is confirmed by the backend reachability ping (Task 3.3), not here.
9
+ *
10
+ * Per ADR-005 (Hybrid-H0) this runs against a **local checkout only**. It emits a
11
+ * structural attestation (stamped with `RULESET_VERSION`) plus the extracted, deduped
12
+ * `(componentId, bloomLevel)` reference set, both consumed by the backend publish
13
+ * contract (Tasks 9.2/9.3 → 3.3) and re-run as the consumption-time backstop (Task 5.2).
14
+ *
15
+ * This module is pure (no filesystem access). `case-loader.ts` reads + parses the
16
+ * `.case/` files on disk and feeds the parsed content here.
17
+ */
18
+ /** Stamped into every attestation; bump when the validator implementation changes. */
19
+ export const VALIDATOR_VERSION = "0.1.8";
20
+ /** Stamped into every attestation; bump when the ruleset (the rules below) changes (ADR-005 §4). */
21
+ export const RULESET_VERSION = "1.8.0";
22
+ // ── Shared building blocks ────────────────────────────────────────────────────
23
+ /**
24
+ * 3-level Fito Bloom taxonomy (SPEC deviation #4) — used in rubric/learning_objectives/prerequisites/quiz.
25
+ * Declared lowest to highest, and the order is load-bearing: the reachability rule in
26
+ * `validateCaseContent` compares levels by their position here.
27
+ */
28
+ export const BLOOM_LEVELS = ["KNOWLEDGE", "COMPREHENSION", "APPLICATION"];
29
+ export const bloomLevelSchema = z.enum(BLOOM_LEVELS);
30
+ /** A lowercased, dash-joined slug segment (e.g. `git`, `requires-known-good-commit`). */
31
+ const SLUG = "[a-z0-9]+(?:-[a-z0-9]+)*";
32
+ /**
33
+ * A single, well-formed knowledge-component reference: a `concept:`/`execution-fact:`/
34
+ * `usage-scenario:` prefix followed by `<tech-slug>.<component-slug>` (>= 2 dot-joined
35
+ * slug segments; the component slug may itself contain dots). Existence and type are
36
+ * resolved on the backend, never here.
37
+ */
38
+ export const KNOWLEDGE_COMPONENT_REF = new RegExp(`^(?:concept|execution-fact|usage-scenario):${SLUG}(?:\\.${SLUG})+$`);
39
+ export const knowledgeComponentRefSchema = z
40
+ .string()
41
+ .regex(KNOWLEDGE_COMPONENT_REF, "must be a single well-formed knowledge-component reference, e.g. concept:git.bisect");
42
+ /**
43
+ * **The topic-not-move rule** (`SPEC.md` §What a readable case file may say). The `description`
44
+ * fields below are prose a learner reads: the tutor is briefed from these files, and the public
45
+ * storefront pitch is drafted from `learning_objectives.yaml`. Such a description may state what is broken
46
+ * and what the goal is; it must not state the move that repairs it. The test is one question —
47
+ * *could a learner who read only this description, and nothing else from the case, apply the fix?*
48
+ * `tutorial` cases are exempt: their `task/steps.md` *is* the method, so there is no repair to
49
+ * withhold. `rubric.yaml` is exempt too — it is never served to a briefing, and a scoring level
50
+ * cannot describe an exemplary answer without naming what that answer does.
51
+ *
52
+ * **Zod cannot enforce this**, and every field the rule binds stays `z.string().optional()`: a case
53
+ * that violates it validates clean. Two things keep the check out of this file, and neither is
54
+ * "the bytes are not there" — a checkout carries `solution/notes.md`, and `validateCaseContent`
55
+ * already runs cross-file rules over it. **A mechanical comparison flags; it does not decide.**
56
+ * Overlap against the solution's wording catches a real leak and also fires on a title and tags
57
+ * that name the topic on purpose, so its output is a candidate list for an author, not a verdict.
58
+ * **And this function is the learner's backstop** — `skills/fito-case-runner/open.ts` runs
59
+ * `validateCaseDir` on every `/fito-case-open` — so a leak warning raised here would tell a learner
60
+ * that their case gives away its own answer, and where. The author-side checker is registered as
61
+ * `DI6` in the plan; until it exists the rule is carried by the authoring prompts and by review.
62
+ */
63
+ /** The three case types — validated on `manifest.type`. */
64
+ export const CASE_TYPES = ["diagnostic", "implementation", "tutorial"];
65
+ export const caseTypeSchema = z.enum(CASE_TYPES);
66
+ /** SemVer 2.0.0 grammar (matches the backend `CaseProject` version check). */
67
+ const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
68
+ // ── Per-file schemas ──────────────────────────────────────────────────────────
69
+ /**
70
+ * `manifest.yaml` — classification/presentation. The case identity is the backend-assigned id
71
+ * (a UUID), not carried in the `.case/` repo; `taxonomy_version` is dropped (deviation #1).
72
+ */
73
+ export const manifestSchema = z
74
+ .object({
75
+ title: z.string().min(1),
76
+ type: caseTypeSchema,
77
+ version: z.string().regex(SEMVER, "manifest.version must be a valid semantic version"),
78
+ status: z.enum(["draft", "review", "published", "deprecated"]),
79
+ estimated_duration_minutes: z.number().int().positive(),
80
+ language: z.string().min(2),
81
+ tags: z.array(z.string()),
82
+ authors: z
83
+ .array(z.object({ name: z.string().min(1), email: z.string().min(1), role: z.string().optional() }))
84
+ .min(1),
85
+ created_at: z.union([z.string(), z.date()]).optional(),
86
+ updated_at: z.union([z.string(), z.date()]).optional(),
87
+ submission: z.object({
88
+ method: z.literal("pull_request"),
89
+ target_branch: z.string().min(1),
90
+ student_branch: z.string().min(1),
91
+ }),
92
+ deprecated_reason: z.string().optional(),
93
+ })
94
+ .superRefine((m, ctx) => {
95
+ if (m.status === "deprecated" && !m.deprecated_reason) {
96
+ ctx.addIssue({
97
+ code: "custom",
98
+ path: ["deprecated_reason"],
99
+ message: "deprecated_reason is required when status is deprecated",
100
+ });
101
+ }
102
+ });
103
+ export const artifactRoleSchema = z.enum(["evidence", "target", "reference", "scaffold", "do-not-touch"]);
104
+ /**
105
+ * `artifacts.yaml` — annotated map of relevant repo files. Each `description` is bound by the
106
+ * topic-not-move rule above, which nothing here can check.
107
+ */
108
+ export const artifactsSchema = z.object({
109
+ artifacts: z.array(z.object({ path: z.string().min(1), role: artifactRoleSchema, description: z.string().optional() })),
110
+ });
111
+ export const learningObjectiveWeightSchema = z.enum(["primary", "secondary"]);
112
+ /**
113
+ * `learning_objectives.yaml` — skills the case develops; >= 1 must be `primary`. Each `description` is
114
+ * bound by the topic-not-move rule above, which nothing here can check — and this file's prose
115
+ * travels furthest, since the public storefront pitch is drafted from it.
116
+ */
117
+ export const learningObjectivesSchema = z
118
+ .object({
119
+ learning_objectives: z
120
+ .array(z.object({
121
+ knowledge_component: knowledgeComponentRefSchema,
122
+ bloom_level: bloomLevelSchema,
123
+ description: z.string().optional(),
124
+ weight: learningObjectiveWeightSchema,
125
+ }))
126
+ .min(1),
127
+ })
128
+ .superRefine((c, ctx) => {
129
+ if (!c.learning_objectives.some((entry) => entry.weight === "primary")) {
130
+ ctx.addIssue({
131
+ code: "custom",
132
+ path: ["learning_objectives"],
133
+ message: "at least one learning objective must have weight: primary",
134
+ });
135
+ }
136
+ });
137
+ /**
138
+ * `prerequisites.yaml` — skills the student must already have (Fito uses `knowledge_component`,
139
+ * deviation #1). Each `description` is bound by the topic-not-move rule above, which nothing here
140
+ * can check.
141
+ */
142
+ export const prerequisitesSchema = z.object({
143
+ prerequisites: z.array(z.object({
144
+ knowledge_component: knowledgeComponentRefSchema,
145
+ bloom_level: bloomLevelSchema,
146
+ description: z.string().optional(),
147
+ mandatory: z.boolean(),
148
+ })),
149
+ });
150
+ /** `rubric.yaml` evaluation methods (automated/ai/human/hybrid). */
151
+ export const evaluationMethodSchema = z.discriminatedUnion("type", [
152
+ z.object({ type: z.literal("automated"), command: z.string().min(1), passing_condition: z.string().min(1) }),
153
+ z.object({ type: z.literal("ai"), prompt_hint: z.string().min(1) }),
154
+ z.object({ type: z.literal("human"), guidance: z.string().optional() }),
155
+ z.object({
156
+ type: z.literal("hybrid"),
157
+ automated: z.object({ command: z.string().min(1), passing_condition: z.string().min(1) }),
158
+ on_pass: z.string().min(1),
159
+ on_fail: z.enum(["ai", "human"]),
160
+ fallback_prompt_hint: z.string().optional(),
161
+ }),
162
+ ]);
163
+ export const rubricLevelSchema = z.object({
164
+ score: z.number().int(),
165
+ label: z.string().min(1),
166
+ description: z.string().min(1),
167
+ });
168
+ /** `rubric.yaml` — criterion weights sum to exactly 100; each criterion's levels cover {0,1,2,3}. */
169
+ export const rubricSchema = z
170
+ .object({
171
+ criteria: z
172
+ .array(z.object({
173
+ id: z.string().min(1),
174
+ title: z.string().min(1),
175
+ knowledge_component: knowledgeComponentRefSchema,
176
+ bloom_level: bloomLevelSchema,
177
+ weight: z.number().int().positive("rubric criterion weight must be a positive integer"),
178
+ levels: z.array(rubricLevelSchema),
179
+ evaluation_method: evaluationMethodSchema,
180
+ }))
181
+ .min(1),
182
+ })
183
+ .superRefine((r, ctx) => {
184
+ const total = r.criteria.reduce((sum, c) => sum + c.weight, 0);
185
+ if (total !== 100) {
186
+ ctx.addIssue({
187
+ code: "custom",
188
+ path: ["criteria"],
189
+ message: `rubric criterion weights must sum to exactly 100 (got ${total})`,
190
+ });
191
+ }
192
+ r.criteria.forEach((c, i) => {
193
+ const scores = new Set(c.levels.map((l) => l.score));
194
+ if (![0, 1, 2, 3].every((s) => scores.has(s))) {
195
+ ctx.addIssue({
196
+ code: "custom",
197
+ path: ["criteria", i, "levels"],
198
+ message: `criterion "${c.id}" levels must cover scores 0, 1, 2, and 3`,
199
+ });
200
+ }
201
+ });
202
+ });
203
+ /** `solution.yaml` — exemplar branch reference + visibility. */
204
+ export const solutionSchema = z.object({
205
+ branch: z.string().min(1),
206
+ visibility: z.enum(["never", "post_completion", "always"]),
207
+ notes: z.string().min(1),
208
+ acceptable_solutions: z
209
+ .array(z.object({ id: z.string().min(1), branch: z.string().min(1), description: z.string().optional() }))
210
+ .optional(),
211
+ });
212
+ /** `situation/situation.yaml` — document manifest. */
213
+ export const situationFormatSchema = z.enum([
214
+ "prose",
215
+ "ticket",
216
+ "email",
217
+ "pull_request_description",
218
+ "chat_thread",
219
+ "log_output",
220
+ ]);
221
+ export const situationSchema = z.object({
222
+ documents: z
223
+ .array(z.object({ file: z.string().min(1), title: z.string().min(1), format: situationFormatSchema }))
224
+ .min(1),
225
+ });
226
+ export const deliverableTypeSchema = z.enum([
227
+ "code_change",
228
+ "new_file",
229
+ "tests_passing",
230
+ "written_explanation",
231
+ "configuration_change",
232
+ "test_written",
233
+ "refactoring",
234
+ "documentation",
235
+ "dependency_change",
236
+ ]);
237
+ /**
238
+ * `task/deliverables.yaml` — expected outputs. Each `description` is bound by the topic-not-move
239
+ * rule above, which nothing here can check.
240
+ */
241
+ export const deliverablesSchema = z.object({
242
+ deliverables: z
243
+ .array(z.object({
244
+ type: deliverableTypeSchema,
245
+ description: z.string().optional(),
246
+ path: z.string().optional(),
247
+ target: z.string().optional(),
248
+ }))
249
+ .min(1),
250
+ });
251
+ /**
252
+ * `starter_state/known_state.yaml` — machine-readable baseline (all fields optional; case-type
253
+ * rules read it). No `branch` field (SPEC deviation #5): under the `.case/` parity invariant the
254
+ * same file describes the case on every ref, so a branch value cannot be per-branch-correct.
255
+ * Deliberately non-strict — frozen refs published before the removal still carry `branch`, and
256
+ * unknown keys are stripped, never rejected.
257
+ */
258
+ export const knownStateSchema = z.object({
259
+ failing_tests: z.array(z.string()).optional(),
260
+ missing_implementations: z
261
+ .array(z.object({ path: z.string(), description: z.string().optional() }))
262
+ .optional(),
263
+ known_errors: z.array(z.object({ type: z.string(), description: z.string() })).optional(),
264
+ build_status: z.enum(["passing", "failing", "not_applicable"]).optional(),
265
+ lint_errors: z.boolean().optional(),
266
+ coverage_baseline: z.object({ path: z.string(), percentage: z.number() }).optional(),
267
+ });
268
+ /** `quiz.yaml` (OPTIONAL, Fito addition #2) — each question references >= 1 component + a Bloom level + type-specific fields. */
269
+ export const quizQuestionTypeSchema = z.enum(["multiple_choice", "short_answer", "code_snippet"]);
270
+ export const quizSchema = z
271
+ .object({
272
+ questions: z
273
+ .array(z.object({
274
+ id: z.string().min(1),
275
+ type: quizQuestionTypeSchema,
276
+ prompt: z.string().min(1),
277
+ knowledge_components: z.array(knowledgeComponentRefSchema).min(1),
278
+ bloom_level: bloomLevelSchema,
279
+ weight: z.number().int().positive("quiz question weight must be a positive integer").optional(),
280
+ choices: z.array(z.object({ id: z.string().min(1), text: z.string().min(1) })).optional(),
281
+ // MVP: a multiple_choice answer is a single choice id. Multi-select (array) answers
282
+ // are rejected — the SPEC says the answer references "one of its choices", and the
283
+ // backend `QuestionDto.answer` / domain `Question.answer` are a single string.
284
+ answer: z
285
+ .string("a multiple_choice answer must be a single choice id; multiple answers are not supported for MVP")
286
+ .optional(),
287
+ evaluation: z
288
+ .object({ method: z.enum(["ai", "human"]), prompt_hint: z.string().optional() })
289
+ .optional(),
290
+ }))
291
+ .min(1),
292
+ })
293
+ .superRefine((q, ctx) => {
294
+ q.questions.forEach((question, i) => {
295
+ if (question.type === "multiple_choice") {
296
+ if (!question.choices || question.choices.length === 0) {
297
+ ctx.addIssue({
298
+ code: "custom",
299
+ path: ["questions", i, "choices"],
300
+ message: `multiple_choice question "${question.id}" must define choices`,
301
+ });
302
+ }
303
+ if (question.answer === undefined) {
304
+ ctx.addIssue({
305
+ code: "custom",
306
+ path: ["questions", i, "answer"],
307
+ message: `multiple_choice question "${question.id}" must define an answer`,
308
+ });
309
+ }
310
+ else if (question.choices && question.choices.length > 0) {
311
+ const choiceIds = new Set(question.choices.map((choice) => choice.id));
312
+ if (!choiceIds.has(question.answer)) {
313
+ ctx.addIssue({
314
+ code: "custom",
315
+ path: ["questions", i, "answer"],
316
+ message: `multiple_choice question "${question.id}" answer "${question.answer}" does not match any choice id`,
317
+ });
318
+ }
319
+ }
320
+ }
321
+ else if (!question.evaluation) {
322
+ ctx.addIssue({
323
+ code: "custom",
324
+ path: ["questions", i, "evaluation"],
325
+ message: `${question.type} question "${question.id}" must define an evaluation (ai or human)`,
326
+ });
327
+ }
328
+ });
329
+ });
330
+ // ── Always-required `.case/` files (paths relative to `.case/`) ───────────────
331
+ /**
332
+ * The learning-objectives file and its root key, each beside the name it carried until Tasks 12a.4
333
+ * and 12a.4b renamed it.
334
+ *
335
+ * There is **no fallback read** for either — `loadCaseDir` opens the current file name and nothing
336
+ * else, and the schema knows only the current key. The old names survive here as signposts: a tree
337
+ * still carrying one fails naming the rename, rather than reporting a file missing while its
338
+ * predecessor sits unread beside it, or an array missing while its predecessor sits stripped.
339
+ */
340
+ const LEARNING_OBJECTIVES_FILE = "learning_objectives.yaml";
341
+ const FORMER_LEARNING_OBJECTIVES_FILE = "competencies.yaml";
342
+ const LEARNING_OBJECTIVES_KEY = "learning_objectives";
343
+ const FORMER_LEARNING_OBJECTIVES_KEY = "competencies";
344
+ /** Files that must always be present; `task/steps.md` is conditionally required for `tutorial` cases. */
345
+ export const REQUIRED_FILES = [
346
+ "manifest.yaml",
347
+ "artifacts.yaml",
348
+ "learning_objectives.yaml",
349
+ "prerequisites.yaml",
350
+ "rubric.yaml",
351
+ "solution.yaml",
352
+ "situation/situation.yaml",
353
+ "situation/01_intro.md",
354
+ "task/objective.md",
355
+ "task/deliverables.yaml",
356
+ "starter_state/description.md",
357
+ "starter_state/known_state.yaml",
358
+ "solution/notes.md",
359
+ "solution/notes-template.md",
360
+ ];
361
+ // ── Validation orchestration ──────────────────────────────────────────────────
362
+ /**
363
+ * Validate already-parsed `.case/` content against the structural ruleset. Collects
364
+ * *all* errors (never fail-fast) so callers see every rule violation at once. On
365
+ * success, emits the attestation + the deduped reference set.
366
+ */
367
+ export function validateCaseContent(input) {
368
+ const { content, presentFiles } = input;
369
+ const errors = [];
370
+ // Rule 1 — the learning-objectives file carries its current name (Task 12a.4). Stated before the
371
+ // required-file loop it modifies, so it also heads the error list a human reads. It fires whether
372
+ // or not the new name is also present, catching a migration that copied rather than moved.
373
+ const carriesFormerLearningObjectivesName = presentFiles.has(FORMER_LEARNING_OBJECTIVES_FILE);
374
+ if (carriesFormerLearningObjectivesName) {
375
+ errors.push({
376
+ file: FORMER_LEARNING_OBJECTIVES_FILE,
377
+ message: `${FORMER_LEARNING_OBJECTIVES_FILE} was renamed to ${LEARNING_OBJECTIVES_FILE} — rename .case/${FORMER_LEARNING_OBJECTIVES_FILE} to .case/${LEARNING_OBJECTIVES_FILE}`,
378
+ });
379
+ }
380
+ // Rule 2 — the learning-objectives file carries its current root key (Task 12a.4b). Beside the
381
+ // file-name rule because they are two halves of one rename family, and it fires whether or not
382
+ // the new key is also present — catching an edit that copied the first line rather than
383
+ // replacing it, which is the mistake Task 12a.5's four hand-edits can make.
384
+ const carriesFormerLearningObjectivesKey = isRecord(content.learningObjectives) && FORMER_LEARNING_OBJECTIVES_KEY in content.learningObjectives;
385
+ if (carriesFormerLearningObjectivesKey) {
386
+ errors.push({
387
+ file: LEARNING_OBJECTIVES_FILE,
388
+ message: `the ${FORMER_LEARNING_OBJECTIVES_KEY}: root key was renamed to ${LEARNING_OBJECTIVES_KEY}: — rename it in .case/${LEARNING_OBJECTIVES_FILE}`,
389
+ });
390
+ }
391
+ // Rule 3 — required files present on disk.
392
+ for (const file of REQUIRED_FILES) {
393
+ // The rename signpost above stands in for this file's missing-file line, rather than
394
+ // doubling it — one rule, one message.
395
+ if (file === LEARNING_OBJECTIVES_FILE && carriesFormerLearningObjectivesName)
396
+ continue;
397
+ if (!presentFiles.has(file)) {
398
+ errors.push({ file, message: `required file ${file} is missing from .case/` });
399
+ }
400
+ }
401
+ // Per-file shape (+ per-file cross-field rules live in each schema's superRefine).
402
+ const parsed = {};
403
+ const runSchema = (file, schema, raw, assign) => {
404
+ if (raw === undefined)
405
+ return; // missing required files are reported above; optional files are skipped
406
+ const result = schema.safeParse(raw);
407
+ if (result.success) {
408
+ assign(result.data);
409
+ }
410
+ else {
411
+ for (const issue of result.error.issues) {
412
+ errors.push({ file, message: issue.message, path: issue.path });
413
+ }
414
+ }
415
+ };
416
+ runSchema("manifest.yaml", manifestSchema, content.manifest, (v) => (parsed.manifest = v));
417
+ runSchema("artifacts.yaml", artifactsSchema, content.artifacts, (v) => (parsed.artifacts = v));
418
+ // The root-key signpost stands in for this file's shape errors rather than doubling them: an
419
+ // old-key file is stripped to `{}` and would otherwise also report a missing array.
420
+ if (!carriesFormerLearningObjectivesKey) {
421
+ runSchema("learning_objectives.yaml", learningObjectivesSchema, content.learningObjectives, (v) => (parsed.learningObjectives = v));
422
+ }
423
+ runSchema("prerequisites.yaml", prerequisitesSchema, content.prerequisites, (v) => (parsed.prerequisites = v));
424
+ runSchema("rubric.yaml", rubricSchema, content.rubric, (v) => (parsed.rubric = v));
425
+ runSchema("solution.yaml", solutionSchema, content.solution, (v) => (parsed.solution = v));
426
+ runSchema("situation/situation.yaml", situationSchema, content.situation, (v) => (parsed.situation = v));
427
+ runSchema("task/deliverables.yaml", deliverablesSchema, content.deliverables, (v) => (parsed.deliverables = v));
428
+ runSchema("starter_state/known_state.yaml", knownStateSchema, content.knownState, (v) => (parsed.knownState = v));
429
+ if (content.quiz !== undefined) {
430
+ runSchema("quiz.yaml", quizSchema, content.quiz, (v) => (parsed.quiz = v));
431
+ }
432
+ // Referenced situation documents must exist on disk (paths are relative to situation/).
433
+ for (const doc of parsed.situation?.documents ?? []) {
434
+ const rel = `situation/${doc.file}`;
435
+ if (!presentFiles.has(rel)) {
436
+ errors.push({
437
+ file: "situation/situation.yaml",
438
+ message: `situation document "${doc.file}" is missing from .case/ (expected ${rel})`,
439
+ });
440
+ }
441
+ }
442
+ // Every learning objective carries at least one rubric criterion (Task 17.1). The rubric is what
443
+ // scores the work, so an objective no criterion names can never award a proficiency — while the
444
+ // backend still recommends this case to a learner missing that component, on the strength of the
445
+ // learning-objective edge alone. A quiz question does not satisfy this: the quiz is optional, and
446
+ // its weights sum to nothing in particular. The match is on the component alone; the rule below
447
+ // compares Bloom levels. Stated per uncovered objective rather than once, so an author sees every
448
+ // gap in one run.
449
+ //
450
+ // Every learning objective is reachable at its own level (Task 17.10): at least one criterion on
451
+ // its component declares a `bloom_level` at least as high as the objective's. A score of 2 or 3
452
+ // awards the criterion's declared level and nothing above it, so an objective whose criteria all
453
+ // sit lower can never be certified. An ordering, not an equality — an APPLICATION criterion covers
454
+ // a COMPREHENSION objective. Only a criterion counts, for the reasons above. An objective with no
455
+ // criterion at all is reported by the coverage rule alone — one gap, one message.
456
+ if (parsed.learningObjectives && parsed.rubric) {
457
+ const criteria = parsed.rubric.criteria;
458
+ for (const objective of parsed.learningObjectives.learning_objectives) {
459
+ const onComponent = criteria.filter((c) => c.knowledge_component === objective.knowledge_component);
460
+ if (onComponent.length === 0) {
461
+ errors.push({
462
+ file: LEARNING_OBJECTIVES_FILE,
463
+ message: `learning objective "${objective.knowledge_component}" must have at least one rubric criterion`,
464
+ });
465
+ continue;
466
+ }
467
+ const needed = BLOOM_LEVELS.indexOf(objective.bloom_level);
468
+ if (!onComponent.some((c) => BLOOM_LEVELS.indexOf(c.bloom_level) >= needed)) {
469
+ const reaching = BLOOM_LEVELS.slice(needed).join(" or ");
470
+ errors.push({
471
+ file: LEARNING_OBJECTIVES_FILE,
472
+ message: `learning objective "${objective.knowledge_component}" is ${objective.bloom_level}, so at least one of its rubric criteria must declare bloom_level ${reaching} — a criterion awards no more than the level it declares`,
473
+ });
474
+ }
475
+ }
476
+ }
477
+ // Cross-file case-type constraints (run only when the manifest type validated).
478
+ const type = parsed.manifest?.type;
479
+ if (type === "diagnostic") {
480
+ const ks = parsed.knownState;
481
+ const hasFailing = (ks?.failing_tests?.length ?? 0) > 0;
482
+ const hasErrors = (ks?.known_errors?.length ?? 0) > 0;
483
+ if (!hasFailing && !hasErrors) {
484
+ errors.push({
485
+ file: "starter_state/known_state.yaml",
486
+ message: "diagnostic cases must declare at least one failing_tests or known_errors entry in known_state.yaml",
487
+ });
488
+ }
489
+ }
490
+ else if (type === "implementation") {
491
+ const hasCodeChange = (parsed.deliverables?.deliverables ?? []).some((d) => d.type === "code_change");
492
+ if (!hasCodeChange) {
493
+ errors.push({
494
+ file: "task/deliverables.yaml",
495
+ message: "implementation cases must include at least one code_change deliverable",
496
+ });
497
+ }
498
+ }
499
+ else if (type === "tutorial") {
500
+ if (!presentFiles.has("task/steps.md")) {
501
+ errors.push({ file: "task/steps.md", message: "tutorial cases must include task/steps.md" });
502
+ }
503
+ if ((parsed.knownState?.failing_tests?.length ?? 0) > 0) {
504
+ errors.push({
505
+ file: "starter_state/known_state.yaml",
506
+ message: "tutorial cases must not declare failing_tests in known_state.yaml",
507
+ });
508
+ }
509
+ }
510
+ if (errors.length > 0) {
511
+ return { ok: false, errors };
512
+ }
513
+ return {
514
+ ok: true,
515
+ attestation: { pass: true, validatorVersion: VALIDATOR_VERSION, rulesetVersion: RULESET_VERSION },
516
+ references: extractReferences(parsed),
517
+ };
518
+ }
519
+ /**
520
+ * Extract the deduped `(componentId, bloomLevel)` reference set from the four
521
+ * reference-bearing files (learning objectives + prerequisites + rubric + quiz). Only
522
+ * well-formedness has been checked; the backend resolves existence (Task 3.3).
523
+ */
524
+ function extractReferences(parsed) {
525
+ const refs = [];
526
+ for (const c of parsed.learningObjectives?.learning_objectives ?? []) {
527
+ refs.push({ componentId: c.knowledge_component, bloomLevel: c.bloom_level });
528
+ }
529
+ for (const p of parsed.prerequisites?.prerequisites ?? []) {
530
+ refs.push({ componentId: p.knowledge_component, bloomLevel: p.bloom_level });
531
+ }
532
+ for (const cr of parsed.rubric?.criteria ?? []) {
533
+ refs.push({ componentId: cr.knowledge_component, bloomLevel: cr.bloom_level });
534
+ }
535
+ for (const q of parsed.quiz?.questions ?? []) {
536
+ for (const kc of q.knowledge_components) {
537
+ refs.push({ componentId: kc, bloomLevel: q.bloom_level });
538
+ }
539
+ }
540
+ const seen = new Set();
541
+ return refs.filter((r) => {
542
+ const key = `${r.componentId}\0${r.bloomLevel}`;
543
+ if (seen.has(key))
544
+ return false;
545
+ seen.add(key);
546
+ return true;
547
+ });
548
+ }
549
+ /**
550
+ * `io: "input"` because the author writes the *input* shape. `unrepresentable: "any"` is
551
+ * **required, not cosmetic**: `manifestSchema` carries `z.union([z.string(), z.date()])` on
552
+ * `created_at`, and the default `"throw"` kills the whole derivation with
553
+ * *"Date cannot be represented in JSON Schema"*.
554
+ */
555
+ const TO_JSON_SCHEMA_OPTIONS = { io: "input", unrepresentable: "any" };
556
+ function isRecord(value) {
557
+ return typeof value === "object" && value !== null && !Array.isArray(value);
558
+ }
559
+ /**
560
+ * The union's discriminator: the one property carrying a `const` in **every** branch, with a
561
+ * distinct value in each. `z.discriminatedUnion` renders exactly that. Resolving the key first
562
+ * — rather than accepting whichever branch happens to hold a matching `const` — keeps the match
563
+ * correct for a union whose branches also carry an unrelated literal field.
564
+ */
565
+ function discriminatorKey(branches) {
566
+ const first = branches[0]?.properties;
567
+ if (!first)
568
+ return undefined;
569
+ return Object.keys(first).find((key) => {
570
+ const consts = branches.map((branch) => branch.properties?.[key]?.const);
571
+ return consts.every((value) => value !== undefined) && new Set(consts).size === branches.length;
572
+ });
573
+ }
574
+ /**
575
+ * The union branch the value actually uses, labelled by its discriminator value (rule B) —
576
+ * never by array index, which would label a report `evaluation_method.<3>` instead of
577
+ * `evaluation_method(hybrid)`. A union with no discriminator (a plain `z.union`, rendered as
578
+ * `anyOf`) has no branch label to give and is skipped.
579
+ */
580
+ function matchingBranch(branches, value) {
581
+ const key = discriminatorKey(branches);
582
+ if (key === undefined || !isRecord(value))
583
+ return undefined;
584
+ for (const branch of branches) {
585
+ const literal = branch.properties?.[key]?.const;
586
+ if (value[key] === literal)
587
+ return { branch, label: String(literal) };
588
+ }
589
+ return undefined;
590
+ }
591
+ /**
592
+ * Walk `node` against `value`, appending every optional path to `empty` or to `filled`.
593
+ * Array elements all walk under the same `[]` prefix, so one path can land in both lists —
594
+ * which is what makes an array's verdict a set subtraction rather than a per-element answer.
595
+ */
596
+ function collectOptionalPaths(node, value, prefix, empty, filled) {
597
+ const branches = node.oneOf ?? node.anyOf;
598
+ if (branches) {
599
+ const used = matchingBranch(branches, value);
600
+ // Rule B — the branches the case does not use contribute nothing.
601
+ if (!used)
602
+ return;
603
+ const base = prefix.endsWith(".") ? prefix.slice(0, -1) : prefix;
604
+ collectOptionalPaths(used.branch, value, `${base}(${used.label}).`, empty, filled);
605
+ return;
606
+ }
607
+ if (node.type === "object" && node.properties) {
608
+ const required = new Set(node.required ?? []);
609
+ for (const [key, property] of Object.entries(node.properties)) {
610
+ const child = isRecord(value) ? value[key] : undefined;
611
+ if (child === undefined) {
612
+ // Rule A — an absent optional parent is named once; its children are not walked.
613
+ // A *required* field that is absent is a validation error, never an inventory line.
614
+ if (!required.has(key))
615
+ empty.push(`${prefix}${key}`);
616
+ continue;
617
+ }
618
+ if (!required.has(key))
619
+ filled.push(`${prefix}${key}`);
620
+ collectOptionalPaths(property, child, `${prefix}${key}.`, empty, filled);
621
+ }
622
+ return;
623
+ }
624
+ if (node.type === "array" && node.items) {
625
+ if (!Array.isArray(value))
626
+ return;
627
+ const base = prefix.endsWith(".") ? prefix.slice(0, -1) : prefix;
628
+ for (const element of value) {
629
+ collectOptionalPaths(node.items, element, `${base}[].`, empty, filled);
630
+ }
631
+ }
632
+ }
633
+ /**
634
+ * The optional fields of `schema` that `value` leaves empty, as dotted paths — `[]` for an
635
+ * array's elements, `(branch)` for a discriminated-union branch. **Optionality is derived from
636
+ * the schema**, via `z.toJSONSchema`: a field is optional when it appears in `properties` and
637
+ * not in `required`, so a field made optional later surfaces here with no edit. Pure: the
638
+ * schema and the value are the only inputs.
639
+ *
640
+ * **An array's verdict is every-empty minus any-filled, not a per-element intersection.** A
641
+ * field is used the moment one element fills it — three deliverables and one `path` between
642
+ * them is a case that uses `path`. But intersecting the elements' *empty* sets would also
643
+ * silence a field the other elements cannot possibly fill: under rule B an `ai` rubric
644
+ * criterion reports nothing about `evaluation_method(hybrid).fallback_prompt_hint`, and
645
+ * treating that silence as agreement hid the one `hybrid` criterion's empty field entirely
646
+ * (caught by the Task 11.10 mutation sweep). Subtracting the filled paths asks only the
647
+ * elements the field actually reaches.
648
+ */
649
+ export function unusedOptionalPaths(schema, value) {
650
+ const root = z.toJSONSchema(schema, TO_JSON_SCHEMA_OPTIONS);
651
+ const empty = [];
652
+ const filled = [];
653
+ collectOptionalPaths(root, value, "", empty, filled);
654
+ const used = new Set(filled);
655
+ const unused = [];
656
+ for (const path of empty) {
657
+ if (used.has(path) || unused.includes(path))
658
+ continue;
659
+ unused.push(path);
660
+ }
661
+ return unused;
662
+ }
663
+ /**
664
+ * The ten `.case/` YAML files the inventory walks. `case-loader.ts` holds the same
665
+ * `key → path` mapping for reading them off disk and cannot be imported here (it imports
666
+ * *this* module), so the two are bound by a test rather than by a shared constant — a file
667
+ * added to one and not the other fails that test instead of silently reporting nothing.
668
+ */
669
+ export const CASE_FILE_SCHEMAS = [
670
+ { contentKey: "manifest", file: "manifest.yaml", schema: manifestSchema },
671
+ { contentKey: "artifacts", file: "artifacts.yaml", schema: artifactsSchema },
672
+ { contentKey: "learningObjectives", file: "learning_objectives.yaml", schema: learningObjectivesSchema },
673
+ { contentKey: "prerequisites", file: "prerequisites.yaml", schema: prerequisitesSchema },
674
+ { contentKey: "rubric", file: "rubric.yaml", schema: rubricSchema },
675
+ { contentKey: "solution", file: "solution.yaml", schema: solutionSchema },
676
+ { contentKey: "situation", file: "situation/situation.yaml", schema: situationSchema },
677
+ { contentKey: "deliverables", file: "task/deliverables.yaml", schema: deliverablesSchema },
678
+ { contentKey: "knownState", file: "starter_state/known_state.yaml", schema: knownStateSchema },
679
+ { contentKey: "quiz", file: "quiz.yaml", schema: quizSchema },
680
+ ];
681
+ export function optionalFieldsNotUsed(input) {
682
+ const { content } = input;
683
+ const manifest = isRecord(content.manifest) ? content.manifest : {};
684
+ const knownState = isRecord(content.knownState) ? content.knownState : {};
685
+ const caseType = manifest.type;
686
+ const hasFailingTests = Array.isArray(knownState.failing_tests) && knownState.failing_tests.length > 0;
687
+ const hasKnownErrors = Array.isArray(knownState.known_errors) && knownState.known_errors.length > 0;
688
+ /** Rules C and D: whether an empty optional field is worth reporting in this case's state. */
689
+ const applies = (file, path) => {
690
+ if (file === "manifest.yaml" && path === "deprecated_reason") {
691
+ return manifest.status === "deprecated"; // rule C
692
+ }
693
+ if (file === "starter_state/known_state.yaml") {
694
+ if (path === "failing_tests" && caseType === "tutorial")
695
+ return false; // rule C
696
+ if (caseType === "diagnostic") {
697
+ if (path === "known_errors" && hasFailingTests)
698
+ return false; // rule D
699
+ if (path === "failing_tests" && hasKnownErrors)
700
+ return false; // rule D
701
+ }
702
+ }
703
+ return true;
704
+ };
705
+ const report = {};
706
+ for (const { contentKey, file, schema } of CASE_FILE_SCHEMAS) {
707
+ const value = content[contentKey];
708
+ // Rule A at file level: an optional file the case does not carry reports nothing.
709
+ if (value === undefined)
710
+ continue;
711
+ const paths = unusedOptionalPaths(schema, value).filter((path) => applies(file, path));
712
+ if (paths.length > 0)
713
+ report[file] = paths;
714
+ }
715
+ return report;
716
+ }