fito-tui 0.5.0 → 0.7.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.
@@ -76,7 +76,14 @@ unless marked optional:
76
76
  `exemplary` met well. They never climb from one Bloom level to the next.
77
77
  `achieved` defines the award — a score of 2 or 3 records the criterion's
78
78
  `bloom_level`, and 0 or 1 records `NOT_ACHIEVED` — so expand it with the
79
- most care. Weights must sum to exactly 100; each `evaluation_method`
79
+ most care. Expand an `automated` criterion's rungs only into outcomes its
80
+ command's exit code and output show: the reviewer scores it from that output
81
+ alone, so detail the command does not print — a named call in the code, which
82
+ test covers a behavior, an explanation — makes a rung no learner can earn.
83
+ When a sketch already asks for such detail, raise it with the author, with
84
+ the two repairs: rewrite the rung as an outcome the command shows, or move
85
+ that judgement to an `ai` criterion.
86
+ Weights must sum to exactly 100; each `evaluation_method`
80
87
  completed — `automated` needs `command` + `passing_condition` (real gate
81
88
  commands from the proposal, never guessed), `ai` needs a `prompt_hint`. On
82
89
  greenfield, where no source tree exists yet, derive the `automated` command
@@ -85,8 +92,8 @@ unless marked optional:
85
92
  post-source re-generate.
86
93
  - `quiz.yaml` (optional) — only when the proposal has quiz items: give each
87
94
  question an `id`; `multiple_choice` gets `choices` and a single `answer`
88
- choice id; `short_answer`/`code_snippet` get an `evaluation` (`ai` or
89
- `human`).
95
+ choice id; `short_answer`/`code_snippet` get an `evaluation` with method
96
+ `ai`.
90
97
  - `situation/situation.yaml` + `situation/01_intro.md` — the narrative the
91
98
  learner lands in, authored from the proposal's Scope; add further documents
92
99
  (ticket, email, log output…) when the scope calls for them, each listed in
@@ -101,6 +108,15 @@ unless marked optional:
101
108
  (`failing_tests`, `known_errors`, `build_status`, …); it carries no `branch`
102
109
  field — `.case/` describes the case on every ref, so a branch value can
103
110
  never be branch-correct (SPEC deviation #5).
111
+ - `starter_state/setup_instructions.md` (optional) — what the learner installs
112
+ before the first build, which they read when the case opens. Write it from
113
+ the proposal's `toolchain` entries with `provided_by: learner`: each tool,
114
+ its minimum line, and "or newer" (e.g. "JDK 21 or newer"). Write it exactly
115
+ when the toolchain has a `learner` entry: the build fetches every `project`
116
+ tool itself, so a toolchain of `project` entries alone leaves the learner
117
+ nothing to install. An entry that does not name who provides it — from a
118
+ proposal written before the field existed — is settled with the author
119
+ first.
104
120
  - `solution/notes.md` — the evaluator-only rationale: the intended approach
105
121
  and what each rubric criterion should see; refined again after the source
106
122
  work. `solution/notes-template.md` — the blank authoring scaffold of the
@@ -150,11 +166,12 @@ Four rules bind the content:
150
166
  Then present the contract for the author's review — a **digest**, not a file
151
167
  dump: type and duration, the learning objectives and prerequisites (ids + Bloom
152
168
  levels), each rubric criterion with its weight and evaluation method, the
153
- situation documents, whether a quiz rides along, and the **optional fields the
154
- contract leaves empty**. Run step 5's validator command now and read that last
155
- item from its `optionalFieldsNotUsed`, rather than judging emptiness by eye —
156
- an optional field is the one thing the validator can never reject, so it stays
157
- invisible unless the run reports it. **A failing run reports no inventory at
169
+ situation documents, whether a quiz rides along, the tools
170
+ `setup_instructions.md` names (or that the case has none), and the **optional
171
+ fields the contract leaves empty**. Run step 5's validator command now and read
172
+ that last item from its `optionalFieldsNotUsed`, rather than judging emptiness
173
+ by eye — an optional field is the one thing the validator can never reject, so
174
+ it stays invisible unless the run reports it. **A failing run reports no inventory at
158
175
  all**: apply step 5's failure loop here until the tree passes, so the digest
159
176
  describes a valid contract and step 4 never commits a broken tree. Each unused
160
177
  field is legal and often right; naming them here is what lets the author fill
@@ -162,10 +179,12 @@ one, or leave it, while the tree is still uncommitted. Walk through any file
162
179
  the author asks to see, and iterate on their feedback **before anything is
163
180
  committed** — the author owns every value in the contract.
164
181
 
165
- **Done when** every file above exists in `.case/` (plus `quiz.yaml` exactly
166
- when the proposal has quiz items), the four rules hold, the validator exits 0
167
- on the tree, and the author has reviewed the digest — unused optional fields
168
- included — and confirmed the contract.
182
+ **Done when** every required file above exists in `.case/` (plus `quiz.yaml`
183
+ exactly when the proposal has quiz items, and
184
+ `starter_state/setup_instructions.md` exactly when its toolchain has a
185
+ `learner` entry), the four rules hold, the validator exits 0 on the tree, and
186
+ the author has reviewed the digest — unused optional fields included — and
187
+ confirmed the contract.
169
188
 
170
189
  ## 4. Put the working directory on git
171
190
 
@@ -25,9 +25,12 @@ re-validates** the `.case/` checkout, and creates the working branch.
25
25
  - If it prints a "case source malformed" report (structural errors and **no**
26
26
  branch created), **stop here — do not orient.** Show the errors and the report
27
27
  affordance; suggest re-running `/fito-case-open $1` later or reporting the case.
28
- - It refuses to overwrite a non-empty existing checkout. If the learner has
29
- already opened this case, that is fine — point them at the existing
30
- checkout, whose path the refusal prints, and `/fito-submit $1`, and skip to step 2.
28
+ - It refuses to overwrite a non-empty existing checkout. This refusal is the
29
+ one non-zero exit that leads on to the briefing: ask the learner whether
30
+ that folder is their earlier opening of this case. If yes, point them at the
31
+ existing checkout, whose path the refusal prints, and `/fito-submit $1`, and
32
+ go on to step 2 with it. If no, relay the refusal and stop — the folder is
33
+ theirs to move or remove.
31
34
  - If it refuses because the case is **deprecated**, relay its message verbatim
32
35
  and stop — do not orient, and never work around the refusal with raw git
33
36
  commands.
@@ -45,9 +48,10 @@ re-validates** the `.case/` checkout, and creates the working branch.
45
48
  `gh auth login` with the Fito-linked GitHub account, then retry.
46
49
 
47
50
  **Done when** it prints `Case opened at:` with the checkout path and `on branch
48
- '<name>'` (or you confirmed an already-open checkout). On any non-zero exit, stop
49
- here — do not orient. Below, `<checkout>` is that path — the one after `Case opened
50
- at:`, or the one the already-open refusal names — used exactly as printed.
51
+ '<name>'` (or the learner confirmed that the folder the refusal names is their
52
+ earlier opening of this case). On any other non-zero exit, stop here — do not
53
+ orient. Below, `<checkout>` is that path — the one after `Case opened at:`, or
54
+ the one the already-open refusal names — used exactly as printed.
51
55
 
52
56
  ## 2. Brief the learner on the case
53
57
 
@@ -65,11 +69,14 @@ Present, in this order:
65
69
  learner reads it in context — a `ticket`, an `email`, a `log_output`, a
66
70
  `chat_thread`, a `pull_request_description`, or plain `prose`. Do not reorder
67
71
  or skip any.
68
- 3. **Task** — `.case/task/objective.md` (the single goal). Then, **if the file is
72
+ 3. **Setup** — if the file is present, `.case/starter_state/setup_instructions.md`:
73
+ the tools the learner installs before the first build, each at its minimum
74
+ line. It comes before the task, so the learner can install them first.
75
+ 4. **Task** — `.case/task/objective.md` (the single goal). Then, **if the file is
69
76
  present**, `.case/task/constraints.md` (rules the learner must follow) and, for
70
77
  `tutorial` cases, `.case/task/steps.md`. Then summarize
71
78
  `.case/task/deliverables.yaml` — the expected outputs.
72
- 4. **Artifacts** — point the learner at `.case/artifacts.yaml`, the annotated map
79
+ 5. **Artifacts** — point the learner at `.case/artifacts.yaml`, the annotated map
73
80
  of relevant repo files (evidence / target / reference / scaffold). Call out the
74
81
  `target` files they will most likely change.
75
82
 
@@ -77,8 +84,8 @@ Keep the briefing calm and precise — a knowledgeable peer handing off a case,
77
84
  a pitch.
78
85
 
79
86
  **Done when** every situation document has been rendered in order and the header,
80
- task (objective + any constraints/steps + deliverables), and key artifacts are
81
- all surfaced.
87
+ the setup instructions (when the case has them), task (objective + any
88
+ constraints/steps + deliverables), and key artifacts are all surfaced.
82
89
 
83
90
  ## 3. Ground the case in the knowledge vocabulary
84
91
 
@@ -40,7 +40,10 @@ case directory, else `./case-proposal.md` — where `/fito-case-design` writes
40
40
  it by default. Name the file you found when you confirm the scenario. If
41
41
  `--proposal` names a missing file, or neither default exists, ask the author
42
42
  for the proposal's path; an author without one gives each technology's
43
- declared major-line version and the toolchain instead.
43
+ declared major-line version and the toolchain instead. Every toolchain entry
44
+ names who provides it — `learner` or `project` — and the author settles any
45
+ entry that does not, such as one from a proposal written before the field
46
+ existed.
44
47
 
45
48
  If the documents already exist under `.authoring/`, this is a revision run:
46
49
  say so and ask what should change — the feedback rides along in step 2; never
@@ -58,9 +61,11 @@ scenario, the declared `{slug, version}` technology pairs and the
58
61
  in its place), and (on a revision run) the author's feedback. The pairs
59
62
  **version-scope** the planner's knowledge fetches (each component reads
60
63
  for the case's declared major line, not another); the toolchain grounds a
61
- greenfield scaffold. The planner reads the `.case/` contract — the rubric
62
- gates, `starter_state/known_state.yaml`, task, situation, `solution.yaml` —
63
- skims the source on reuse, and writes the two documents into `.authoring/`.
64
+ greenfield scaffold, and its `learner` entries — the tools the learner
65
+ installs — are the ones the build must accept at their line or newer. The
66
+ planner reads the `.case/` contract — the rubric gates,
67
+ `starter_state/known_state.yaml`, task, situation, `solution.yaml` — skims
68
+ the source on reuse, and writes the two documents into `.authoring/`.
64
69
 
65
70
  This delegation blocks — you read the child's summary from the tool result.
66
71
 
@@ -75,8 +80,10 @@ hand.
75
80
  ## 3. Review with the author
76
81
 
77
82
  Relay the worker's **digest** — scenario, both terminal states, plan-step
78
- count, gates covered, any contract conflict it surfaced, and its **toolchain
79
- cross-check** section — not a file dump. Any mismatch there is **advisory** (a
83
+ count, gates covered, the `learner` tools with their minimum lines, any plan
84
+ step that lifts a limit on one and any it flagged as a gap, any contract
85
+ conflict it surfaced, and its **toolchain cross-check** section — not a file
86
+ dump. Any mismatch there is **advisory** (a
80
87
  declared toolchain contradicting a technology version's stated requirements,
81
88
  e.g. Javalin 7 wanting Java 17+ against a Java 11 toolchain): surface it for
82
89
  the author to reconcile the declaration — it is **not** a contract conflict, so
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
63
63
 
64
64
  > "Content template not found. The Fito package installation may be incomplete."
65
65
 
66
- 7. Pull the registered `Template` **field-schema** for the `concept` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2 — no second fetch. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the backend's Template read endpoint is not yet available, use the field keys documented in the content template resolved in step 6.
66
+ 7. Pull the registered `Template` **field-schema** for the `concept` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `concept` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
67
67
 
68
68
  8. Create the output directory if it does not exist.
69
69
 
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
63
63
 
64
64
  > "Content template not found. The Fito package installation may be incomplete."
65
65
 
66
- 7. Pull the registered `Template` **field-schema** for the `execution-fact` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements, the `optional_sections_included` trigger mechanism) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2 — no second fetch. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the backend's Template read endpoint is not yet available, use the field keys documented in the content template resolved in step 6.
66
+ 7. Pull the registered `Template` **field-schema** for the `execution-fact` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements, the `optional_sections_included` trigger mechanism) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `execution-fact` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
67
67
 
68
68
  8. Create the output directory if it does not exist.
69
69
 
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
63
63
 
64
64
  > "Content template not found. The Fito package installation may be incomplete."
65
65
 
66
- 7. Pull the registered `Template` **field-schema** for the `usage-scenario` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2 — no second fetch. For this type the `any` row is the only one registered, so both kinds land on it; the variant follows from the subject, so nothing names one directly, and the push resolves it the same way, making this the schema the component is stored under. If the backend's Template read endpoint is not yet available, use the field keys documented in the content template resolved in step 6.
66
+ 7. Pull the registered `Template` **field-schema** for the `usage-scenario` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `usage-scenario` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. For this type the `any` row is the only one registered, so both kinds land on it; the variant follows from the subject, so nothing names one directly, and the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
67
67
 
68
68
  8. Create the output directory if it does not exist.
69
69
 
@@ -62,6 +62,7 @@ const KEY_DOCUMENTS = {
62
62
  starter_state: [
63
63
  { file: "starter_state/description.md", kind: "markdown" },
64
64
  { file: "starter_state/known_state.yaml", kind: "yaml" },
65
+ { file: "starter_state/setup_instructions.md", kind: "markdown" },
65
66
  ],
66
67
  knowledge_refs: [
67
68
  { file: "learning_objectives.yaml", kind: "yaml" },
@@ -96,6 +96,7 @@ const KEY_DOCUMENTS: Record<BriefingKey, readonly DocumentEntry[]> = {
96
96
  starter_state: [
97
97
  { file: "starter_state/description.md", kind: "markdown" },
98
98
  { file: "starter_state/known_state.yaml", kind: "yaml" },
99
+ { file: "starter_state/setup_instructions.md", kind: "markdown" },
99
100
  ],
100
101
  knowledge_refs: [
101
102
  { file: "learning_objectives.yaml", kind: "yaml" },
@@ -16,9 +16,9 @@ import { z } from "zod";
16
16
  * `.case/` files on disk and feeds the parsed content here.
17
17
  */
18
18
  /** Stamped into every attestation; bump when the validator implementation changes. */
19
- export const VALIDATOR_VERSION = "0.1.8";
19
+ export const VALIDATOR_VERSION = "0.1.9";
20
20
  /** Stamped into every attestation; bump when the ruleset (the rules below) changes (ADR-005 §4). */
21
- export const RULESET_VERSION = "1.8.0";
21
+ export const RULESET_VERSION = "1.9.0";
22
22
  // ── Shared building blocks ────────────────────────────────────────────────────
23
23
  /**
24
24
  * 3-level Fito Bloom taxonomy (SPEC deviation #4) — used in rubric/learning_objectives/prerequisites/quiz.
@@ -147,18 +147,14 @@ export const prerequisitesSchema = z.object({
147
147
  mandatory: z.boolean(),
148
148
  })),
149
149
  });
150
- /** `rubric.yaml` evaluation methods (automated/ai/human/hybrid). */
150
+ /**
151
+ * `rubric.yaml` evaluation methods: `automated` and `ai`. `human` and `hybrid` left at ruleset 1.9.0
152
+ * (Task 17.24): no one can score a `human` criterion yet, and a `hybrid` one can fall through to
153
+ * `human`. The evaluator still names all four (`skills/fito-evaluator/rubric.ts`).
154
+ */
151
155
  export const evaluationMethodSchema = z.discriminatedUnion("type", [
152
156
  z.object({ type: z.literal("automated"), command: z.string().min(1), passing_condition: z.string().min(1) }),
153
157
  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
158
  ]);
163
159
  export const rubricLevelSchema = z.object({
164
160
  score: z.number().int(),
@@ -284,9 +280,8 @@ export const quizSchema = z
284
280
  answer: z
285
281
  .string("a multiple_choice answer must be a single choice id; multiple answers are not supported for MVP")
286
282
  .optional(),
287
- evaluation: z
288
- .object({ method: z.enum(["ai", "human"]), prompt_hint: z.string().optional() })
289
- .optional(),
283
+ // `human` left at ruleset 1.9.0, as it did from the rubric (Task 17.24).
284
+ evaluation: z.object({ method: z.enum(["ai"]), prompt_hint: z.string().optional() }).optional(),
290
285
  }))
291
286
  .min(1),
292
287
  })
@@ -322,7 +317,7 @@ export const quizSchema = z
322
317
  ctx.addIssue({
323
318
  code: "custom",
324
319
  path: ["questions", i, "evaluation"],
325
- message: `${question.type} question "${question.id}" must define an evaluation (ai or human)`,
320
+ message: `${question.type} question "${question.id}" must define an evaluation (ai)`,
326
321
  });
327
322
  }
328
323
  });
@@ -573,8 +568,8 @@ function discriminatorKey(branches) {
573
568
  }
574
569
  /**
575
570
  * 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
571
+ * never by array index, which would label a report `evaluation_method.<1>` instead of
572
+ * `evaluation_method(ai)`. A union with no discriminator (a plain `z.union`, rendered as
578
573
  * `anyOf`) has no branch label to give and is skipped.
579
574
  */
580
575
  function matchingBranch(branches, value) {
@@ -640,10 +635,10 @@ function collectOptionalPaths(node, value, prefix, empty, filled) {
640
635
  * **An array's verdict is every-empty minus any-filled, not a per-element intersection.** A
641
636
  * field is used the moment one element fills it — three deliverables and one `path` between
642
637
  * 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
638
+ * silence a field the other elements cannot possibly fill: under rule B an element on one union
639
+ * branch reports nothing about another branch's field, and treating that silence as agreement
640
+ * once hid a `hybrid` criterion's empty `fallback_prompt_hint` entirely (caught by the Task 11.10
641
+ * mutation sweep, before Task 17.24 removed `hybrid`). Subtracting the filled paths asks only the
647
642
  * elements the field actually reaches.
648
643
  */
649
644
  export function unusedOptionalPaths(schema, value) {
@@ -18,9 +18,9 @@ import { z } from "zod";
18
18
  */
19
19
 
20
20
  /** Stamped into every attestation; bump when the validator implementation changes. */
21
- export const VALIDATOR_VERSION = "0.1.8";
21
+ export const VALIDATOR_VERSION = "0.1.9";
22
22
  /** Stamped into every attestation; bump when the ruleset (the rules below) changes (ADR-005 §4). */
23
- export const RULESET_VERSION = "1.8.0";
23
+ export const RULESET_VERSION = "1.9.0";
24
24
 
25
25
  // ── Shared building blocks ────────────────────────────────────────────────────
26
26
 
@@ -175,18 +175,14 @@ export const prerequisitesSchema = z.object({
175
175
  ),
176
176
  });
177
177
 
178
- /** `rubric.yaml` evaluation methods (automated/ai/human/hybrid). */
178
+ /**
179
+ * `rubric.yaml` evaluation methods: `automated` and `ai`. `human` and `hybrid` left at ruleset 1.9.0
180
+ * (Task 17.24): no one can score a `human` criterion yet, and a `hybrid` one can fall through to
181
+ * `human`. The evaluator still names all four (`skills/fito-evaluator/rubric.ts`).
182
+ */
179
183
  export const evaluationMethodSchema = z.discriminatedUnion("type", [
180
184
  z.object({ type: z.literal("automated"), command: z.string().min(1), passing_condition: z.string().min(1) }),
181
185
  z.object({ type: z.literal("ai"), prompt_hint: z.string().min(1) }),
182
- z.object({ type: z.literal("human"), guidance: z.string().optional() }),
183
- z.object({
184
- type: z.literal("hybrid"),
185
- automated: z.object({ command: z.string().min(1), passing_condition: z.string().min(1) }),
186
- on_pass: z.string().min(1),
187
- on_fail: z.enum(["ai", "human"]),
188
- fallback_prompt_hint: z.string().optional(),
189
- }),
190
186
  ]);
191
187
 
192
188
  export const rubricLevelSchema = z.object({
@@ -324,9 +320,8 @@ export const quizSchema = z
324
320
  answer: z
325
321
  .string("a multiple_choice answer must be a single choice id; multiple answers are not supported for MVP")
326
322
  .optional(),
327
- evaluation: z
328
- .object({ method: z.enum(["ai", "human"]), prompt_hint: z.string().optional() })
329
- .optional(),
323
+ // `human` left at ruleset 1.9.0, as it did from the rubric (Task 17.24).
324
+ evaluation: z.object({ method: z.enum(["ai"]), prompt_hint: z.string().optional() }).optional(),
330
325
  }),
331
326
  )
332
327
  .min(1),
@@ -361,7 +356,7 @@ export const quizSchema = z
361
356
  ctx.addIssue({
362
357
  code: "custom",
363
358
  path: ["questions", i, "evaluation"],
364
- message: `${question.type} question "${question.id}" must define an evaluation (ai or human)`,
359
+ message: `${question.type} question "${question.id}" must define an evaluation (ai)`,
365
360
  });
366
361
  }
367
362
  });
@@ -724,8 +719,8 @@ function discriminatorKey(branches: JsonSchemaNode[]): string | undefined {
724
719
 
725
720
  /**
726
721
  * The union branch the value actually uses, labelled by its discriminator value (rule B) —
727
- * never by array index, which would label a report `evaluation_method.<3>` instead of
728
- * `evaluation_method(hybrid)`. A union with no discriminator (a plain `z.union`, rendered as
722
+ * never by array index, which would label a report `evaluation_method.<1>` instead of
723
+ * `evaluation_method(ai)`. A union with no discriminator (a plain `z.union`, rendered as
729
724
  * `anyOf`) has no branch label to give and is skipped.
730
725
  */
731
726
  function matchingBranch(
@@ -798,10 +793,10 @@ function collectOptionalPaths(
798
793
  * **An array's verdict is every-empty minus any-filled, not a per-element intersection.** A
799
794
  * field is used the moment one element fills it — three deliverables and one `path` between
800
795
  * them is a case that uses `path`. But intersecting the elements' *empty* sets would also
801
- * silence a field the other elements cannot possibly fill: under rule B an `ai` rubric
802
- * criterion reports nothing about `evaluation_method(hybrid).fallback_prompt_hint`, and
803
- * treating that silence as agreement hid the one `hybrid` criterion's empty field entirely
804
- * (caught by the Task 11.10 mutation sweep). Subtracting the filled paths asks only the
796
+ * silence a field the other elements cannot possibly fill: under rule B an element on one union
797
+ * branch reports nothing about another branch's field, and treating that silence as agreement
798
+ * once hid a `hybrid` criterion's empty `fallback_prompt_hint` entirely (caught by the Task 11.10
799
+ * mutation sweep, before Task 17.24 removed `hybrid`). Subtracting the filled paths asks only the
805
800
  * elements the field actually reaches.
806
801
  */
807
802
  export function unusedOptionalPaths(schema: z.ZodType, value: unknown): string[] {
@@ -62,9 +62,10 @@ node "<fito-case-author skill dir>/publish.js" "<case-working-dir>" --repo <owne
62
62
  Takes a **finished** case tree (source work done, solution branch built, everything committed) and
63
63
  makes it a published Fito case in one run: re-validates the tree, pushes `main` + the frozen
64
64
  `vX.Y.Z` branch/tag + the `case/solution-vX.Y.Z` branch to the GitHub repo (created if absent,
65
- public, under the Case Creator's account or a chosen org), then registers (`POST /cases`) and
66
- publishes (`POST /cases/{id}/publish`) with the backend. Requires an authenticated `gh` **and** a
67
- Fito login (`/fito-login`).
65
+ public, under the Case Creator's account or a chosen org), makes `main` the repo's default branch
66
+ when the repo had no branch before the push, then registers (`POST /cases`) and publishes
67
+ (`POST /cases/{id}/publish`) with the backend. Requires an authenticated `gh` **and** a Fito login
68
+ (`/fito-login`).
68
69
 
69
70
  - `--repo` — `<owner>/<name>`, or a bare `<name>`: the owner then comes from
70
71
  `FITO_PUBLISH_GITHUB_OWNER`, else the authenticated `gh` login.
@@ -80,8 +81,9 @@ idempotent), and the local checkout is never modified. Backend rejections print
80
81
  **verbatim** — relay it unchanged; the fix is the author's call (a missing knowledge component →
81
82
  the knowledge pipeline + `/fito-push-knowledge`; a wrong `.case/` value → `/fito-case-generate`).
82
83
 
83
- **Done when** it prints the backend case id + `PUBLISHED` and the web URL — or the stop/rejection
84
- was relayed verbatim with its re-run affordance (`--case-id` / `--accept-gh-mismatch`).
84
+ **Done when** it prints the backend case id + `PUBLISHED` and the web URL, with any `⚠` line
85
+ relayed together with the command it names — or the stop/rejection was relayed verbatim with its
86
+ re-run affordance (`--case-id` / `--accept-gh-mismatch`).
85
87
 
86
88
  It refuses: a dirty tree (what is validated must be exactly what is pushed), a missing local
87
89
  solution branch (build it per `/fito-case-plan-source` first), and a URL that is already a
@@ -167,7 +169,7 @@ registrations — it never guesses which case the checkout is).
167
169
  | `checkout.ts` | CLI entrypoint — `runCheckout` core: fetch → status gate → direct clone of `main` → orient |
168
170
  | `publish-version.ts` | CLI entrypoint — `runPublishVersion` core: validate → staleness guards → origin route → frozen-set preflight → push → `POST /cases/{id}/versions`; `--probe` resolves initial vs update |
169
171
  | `publish-payload.ts` | Pure `.case/` → register/publish/version wire-payload mapping (+ publish facts) |
170
- | `github-publish.ts` | Pure `gh`/`git` command builders (repo create, explicit-refspec push, guards) |
172
+ | `github-publish.ts` | Pure `gh`/`git` command builders (repo create, default branch, explicit-refspec push, guards) |
171
173
  | `status-gate.ts` | One home for the case-status policy (ADR-009): the status → allow/refuse/hint mapping behind `checkout.ts`, `runPublishVersion`, and the probe's deprecated route |
172
174
  | `publish-state.ts` | `~/.fito/publish-state.json` — the draft-id retry store |
173
175
  | — | The real `gh`/`git` executor is the shared `../../shared/shell-exec/exec.ts` (ADR-006) |
@@ -39,14 +39,41 @@ export function ghAuthStatusCommand() {
39
39
  export function ghCurrentLoginCommand() {
40
40
  return { command: "gh", args: ["api", "user", "--jq", ".login"] };
41
41
  }
42
- /** `gh repo view <slug> --json name` — the existence probe; a re-run must never create a duplicate repo. */
42
+ /**
43
+ * `gh repo view <slug> --json isEmpty` — the existence probe (a re-run must never create a
44
+ * duplicate repo), which also tells whether the repo has no branch yet: `parseRepoIsEmpty` reads it.
45
+ */
43
46
  export function ghRepoViewCommand(slug) {
44
- return { command: "gh", args: ["repo", "view", slug, "--json", "name"] };
47
+ return { command: "gh", args: ["repo", "view", slug, "--json", "isEmpty"] };
48
+ }
49
+ /** Read `gh repo view --json isEmpty`'s stdout: whether the repo has no branch yet. */
50
+ export function parseRepoIsEmpty(stdout) {
51
+ let parsed;
52
+ try {
53
+ parsed = JSON.parse(stdout);
54
+ }
55
+ catch (error) {
56
+ const detail = error instanceof Error ? error.message : String(error);
57
+ throw new Error(`gh repo view returned malformed JSON: ${detail}`);
58
+ }
59
+ return parsed.isEmpty === true;
45
60
  }
46
61
  /** `gh repo create <slug> --public --description <text>` — create the case repo (MVP is public-only), titled for its storefront; no clone, no push. */
47
62
  export function ghRepoCreateCommand(slug, description) {
48
63
  return { command: "gh", args: ["repo", "create", slug, "--public", "--description", description] };
49
64
  }
65
+ /**
66
+ * `gh repo edit <slug> --default-branch main` — name `main` the default branch of a repo whose
67
+ * first push was this run's (Task 17.23). Left to itself, GitHub picks the default branch from the
68
+ * first push by a rule it does not document: the same push made `main` the default for one account
69
+ * and the solution branch for another (Task 17b.3, F1), and a solution-branch default shows the
70
+ * solution on the repo's page and checks it out on a plain `git clone`. Runs after the push, since
71
+ * GitHub cannot name a branch that does not exist yet. Needs admin rights on the repo, which
72
+ * GitHub gives whoever creates it — an organization member included.
73
+ */
74
+ export function ghRepoSetDefaultBranchCommand(slug) {
75
+ return { command: "gh", args: ["repo", "edit", slug, "--default-branch", "main"] };
76
+ }
50
77
  /** `git status --porcelain` — the clean-tree guard: what was validated must be exactly what is pushed. */
51
78
  export function gitStatusPorcelainCommand() {
52
79
  return { command: "git", args: ["status", "--porcelain"] };
@@ -56,9 +56,24 @@ export function ghCurrentLoginCommand(): ShellCommand {
56
56
  return { command: "gh", args: ["api", "user", "--jq", ".login"] };
57
57
  }
58
58
 
59
- /** `gh repo view <slug> --json name` — the existence probe; a re-run must never create a duplicate repo. */
59
+ /**
60
+ * `gh repo view <slug> --json isEmpty` — the existence probe (a re-run must never create a
61
+ * duplicate repo), which also tells whether the repo has no branch yet: `parseRepoIsEmpty` reads it.
62
+ */
60
63
  export function ghRepoViewCommand(slug: string): ShellCommand {
61
- return { command: "gh", args: ["repo", "view", slug, "--json", "name"] };
64
+ return { command: "gh", args: ["repo", "view", slug, "--json", "isEmpty"] };
65
+ }
66
+
67
+ /** Read `gh repo view --json isEmpty`'s stdout: whether the repo has no branch yet. */
68
+ export function parseRepoIsEmpty(stdout: string): boolean {
69
+ let parsed: unknown;
70
+ try {
71
+ parsed = JSON.parse(stdout);
72
+ } catch (error) {
73
+ const detail = error instanceof Error ? error.message : String(error);
74
+ throw new Error(`gh repo view returned malformed JSON: ${detail}`);
75
+ }
76
+ return (parsed as { isEmpty?: unknown }).isEmpty === true;
62
77
  }
63
78
 
64
79
  /** `gh repo create <slug> --public --description <text>` — create the case repo (MVP is public-only), titled for its storefront; no clone, no push. */
@@ -66,6 +81,19 @@ export function ghRepoCreateCommand(slug: string, description: string): ShellCom
66
81
  return { command: "gh", args: ["repo", "create", slug, "--public", "--description", description] };
67
82
  }
68
83
 
84
+ /**
85
+ * `gh repo edit <slug> --default-branch main` — name `main` the default branch of a repo whose
86
+ * first push was this run's (Task 17.23). Left to itself, GitHub picks the default branch from the
87
+ * first push by a rule it does not document: the same push made `main` the default for one account
88
+ * and the solution branch for another (Task 17b.3, F1), and a solution-branch default shows the
89
+ * solution on the repo's page and checks it out on a plain `git clone`. Runs after the push, since
90
+ * GitHub cannot name a branch that does not exist yet. Needs admin rights on the repo, which
91
+ * GitHub gives whoever creates it — an organization member included.
92
+ */
93
+ export function ghRepoSetDefaultBranchCommand(slug: string): ShellCommand {
94
+ return { command: "gh", args: ["repo", "edit", slug, "--default-branch", "main"] };
95
+ }
96
+
69
97
  /** `git status --porcelain` — the clean-tree guard: what was validated must be exactly what is pushed. */
70
98
  export function gitStatusPorcelainCommand(): ShellCommand {
71
99
  return { command: "git", args: ["status", "--porcelain"] };
@@ -10,7 +10,8 @@
10
10
  * file) → local guards (clean tree, solution branch) → gh login + Fito session → identity check →
11
11
  * published-guard → reconcile the solution branch's `.case/` with the canonical branch's (Task
12
12
  * 9a.7 parity) → create the GitHub repo if absent → push `main` + the frozen `vX.Y.Z` branch/tag
13
- * + the `case/solution-vX.Y.Z` branch → `POST /cases` (draft) → `POST /cases/{id}/publish`.
13
+ * + the `case/solution-vX.Y.Z` branch → make `main` the default branch of a repo that had no
14
+ * branch before the push → `POST /cases` (draft) → `POST /cases/{id}/publish`.
14
15
  *
15
16
  * Failure leaves the local checkout intact for fix-and-retry: backend rejections surface their
16
17
  * problem detail **verbatim**, the minted draft id is remembered in `~/.fito/publish-state.json`
@@ -26,7 +27,7 @@ import { validateCaseContent } from "../../shared/case-validation/case-schema.js
26
27
  import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.js";
27
28
  import { resolveFitoSession } from "../../shared/fito-session/session.js";
28
29
  import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.js";
29
- import { caseRepoHttpsUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghRepoCreateCommand, ghRepoViewCommand, gitCaseParityDiffCommand, gitCheckoutCommand, gitCommitCaseParityCommand, gitCurrentBranchCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitRestoreCaseDirCommand, gitStatusPorcelainCommand, parseRepoArg, withoutAuthoringHarnessPaths, } from "./github-publish.js";
30
+ import { caseRepoHttpsUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghRepoCreateCommand, ghRepoSetDefaultBranchCommand, ghRepoViewCommand, gitCaseParityDiffCommand, gitCheckoutCommand, gitCommitCaseParityCommand, gitCurrentBranchCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitRestoreCaseDirCommand, gitStatusPorcelainCommand, parseRepoArg, parseRepoIsEmpty, withoutAuthoringHarnessPaths, } from "./github-publish.js";
30
31
  import { buildCaseWritePayloads, readCasePublishFacts } from "./publish-payload.js";
31
32
  import { clearPublishState, readPublishState, writePublishState } from "./publish-state.js";
32
33
  /** A backend rejection of the register/publish call: the problem detail verbatim, plus the retry id. */
@@ -112,14 +113,19 @@ export async function runPublish(options) {
112
113
  const caseReconciled = await reconcileSolutionBranchCase(run, facts.solutionBranch);
113
114
  // Create the repo only when absent — a fix-and-retry re-run must never create a duplicate.
114
115
  let repoCreated = false;
116
+ let repoView;
115
117
  try {
116
- await run(ghRepoViewCommand(slug));
118
+ repoView = await run(ghRepoViewCommand(slug));
117
119
  }
118
120
  catch {
119
121
  await run(ghRepoCreateCommand(slug, facts.title));
120
122
  repoCreated = true;
121
123
  }
124
+ // A repo with no branch yet takes its default branch from the push below: one this run created,
125
+ // or one a failed earlier run created and never pushed to. A repo with branches keeps its own.
126
+ const repoWasEmpty = repoView === undefined || parseRepoIsEmpty(repoView);
122
127
  await run(gitPushCaseRefsCommand(repositoryUrl, facts.versionRef, facts.solutionBranch));
128
+ const defaultBranchWarning = repoWasEmpty ? await setDefaultBranchMain(run, slug) : undefined;
123
129
  // Register (or reuse the draft id): POST /cases is not idempotent, so the minted id is
124
130
  // remembered in ~/.fito/publish-state.json until the publish succeeds.
125
131
  const rememberedId = options.caseId ?? readPublishState(repositoryUrl, apiBaseUrl, home);
@@ -147,12 +153,33 @@ export async function runPublish(options) {
147
153
  repositoryUrl,
148
154
  versionRef: facts.versionRef,
149
155
  repoCreated,
156
+ defaultBranchSet: repoWasEmpty && defaultBranchWarning === undefined,
150
157
  caseReconciled,
151
158
  ghLogin,
152
159
  title: facts.title,
153
160
  webUrl: `${fitoUrl(env)}/cases/${caseId}`,
161
+ ...(defaultBranchWarning === undefined ? {} : { defaultBranchWarning }),
154
162
  };
155
163
  }
164
+ /**
165
+ * Name `main` the default branch of a repo this run pushed to first (Task 17.23). Never fatal: the
166
+ * default branch is what the repo's page shows and a plain `git clone` checks out, and no Fito
167
+ * command reads it. And a stop would be worse than the warning — a re-run finds the repo no
168
+ * longer empty and skips this step without a word. Returns the warning on a failure.
169
+ */
170
+ async function setDefaultBranchMain(run, slug) {
171
+ const command = ghRepoSetDefaultBranchCommand(slug);
172
+ try {
173
+ await run(command);
174
+ return undefined;
175
+ }
176
+ catch (error) {
177
+ const reason = error instanceof Error ? error.message : String(error);
178
+ return (`Fito couldn't make main the repo's default branch (${reason.trimEnd()})\n` +
179
+ ` GitHub picked one itself, and it may be the solution branch.\n` +
180
+ ` Set it yourself: ${command.command} ${command.args.join(" ")}`);
181
+ }
182
+ }
156
183
  /**
157
184
  * Enforce the `.case/` parity invariant (Task 9a.7, F9): `.case/` describes the case, not the
158
185
  * branch — but plan-source finalizes `artifacts.yaml` on the canonical branch after the solution
@@ -256,8 +283,14 @@ async function main() {
256
283
  console.log("✓ Reconciled the solution branch's .case/ with main (it had diverged) before the push.");
257
284
  }
258
285
  console.log(`✓ Pushed main, ${result.versionRef} (branch + tag), and the solution branch.`);
286
+ if (result.defaultBranchSet) {
287
+ console.log("✓ Made main the repo's default branch.");
288
+ }
259
289
  console.log(`✓ Published "${result.title}" — backend case id: ${result.caseId} (${result.status}).`);
260
290
  console.log(`✓ Listed at: ${result.webUrl}`);
291
+ if (result.defaultBranchWarning) {
292
+ console.error(`⚠ ${result.defaultBranchWarning}`);
293
+ }
261
294
  }
262
295
  catch (error) {
263
296
  if (error instanceof PublishRejectedError) {