|
| 1 | +# CRAFT chrome / interaction-layer contract (canonical) |
| 2 | + |
| 3 | +**Schema:** `decision.v1` (the halt-and-handoff presentation contract) + the |
| 4 | +CRAFT output-signature blocks (`STAGE` / `DECISION` / `RESULT`). |
| 5 | +**Renderer:** `craft.chrome` (canonical at `craft-platform/src/craft/chrome.py`; |
| 6 | +each skill VENDORS a byte-identical copy — Family-F conformance). |
| 7 | +**Validator:** `craft.decision.validate_decision`. |
| 8 | +**Status:** Cycle-4 (DP6) Phase 1 — foundation. Wired into skills in Phase 2. |
| 9 | + |
| 10 | +This is the **source of record** for the chrome section that each CRAFT skill |
| 11 | +carries in its `SKILL.md`. Phase 2 vendors the "Contract text for SKILL.md" |
| 12 | +block below into each skill verbatim. Keep this doc and the per-skill SKILL.md |
| 13 | +copies in sync (they are a copy-not-share pair, like the chrome.py vendoring). |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Why this contract exists (the two facts it is built on) |
| 18 | + |
| 19 | +Both were proven empirically in the Cycle-4 Phase-0 synthetic harness |
| 20 | +(`prototypes/cycle4-chrome/`): |
| 21 | + |
| 22 | +1. **Inside Claude, the message body is the legible signal — not the box.** |
| 23 | + A skill's orchestrator runs as a non-TTY subprocess, so (a) its stdout |
| 24 | + carries **zero color** (the `chrome._color()` seam correctly no-ops when |
| 25 | + piped) and (b) the Claude transcript **folds** long tool output. The boxed |
| 26 | + STAGE/DECISION/RESULT blocks are real and useful at a bare terminal, but |
| 27 | + **inside Claude the user sees them only if Claude re-renders them as message |
| 28 | + text.** So the contract is: *Claude reconstructs the structured contract |
| 29 | + (decision.v1 / run-record) as its own message, in a consistent presentation |
| 30 | + style.* "Pass the box through verbatim" is NOT enough — folded output hides |
| 31 | + it. |
| 32 | + |
| 33 | +2. **`decision.v1` EXTENDS the existing `.handoff.json` — it does not replace |
| 34 | + it.** The `continue` CLI reads the handoff's own keys (notably **`phase`**, |
| 35 | + which authorizes `--pick`). A decision payload therefore RETAINS those keys |
| 36 | + and ADDS the presentation fields on top. `gate` MUST equal `phase`. This is |
| 37 | + why `validate_decision` checks both contracts at once. |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## The three signature classes (what the orchestrator emits) |
| 42 | + |
| 43 | +| Class | Box | When | Prominence | |
| 44 | +|---|---|---|---| |
| 45 | +| `STAGE` | single rule `┌─┐` | a pipeline stage starts/updates | quiet, present | |
| 46 | +| `DECISION` | double rule `╔═╗` | a halt-and-handoff gate | **loudest** | |
| 47 | +| `RESULT` | no box, terse glyph line | a stage/run produces a deliverable | terse | |
| 48 | + |
| 49 | +Each carries the per-skill signature: a glyph + `CRAFT · <skill>` label. |
| 50 | + |
| 51 | +| Skill | Glyph | |
| 52 | +|---|---| |
| 53 | +| presentation-maker | `◆` | |
| 54 | +| paper-writer | `✎` | |
| 55 | +| adversarial | `⚔` | |
| 56 | + |
| 57 | +Color is strictly additive (a bare-terminal bonus through the single |
| 58 | +`_color()` seam); the structural signature (box + glyph + label) carries the |
| 59 | +whole distinction with color stripped — which is the inside-Claude condition. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## `decision.v1` shape |
| 64 | + |
| 65 | +`decision.v1` is written to `<draft_dir>/.handoff.json` at a halt. It is the |
| 66 | +union of the real handoff keys and the presentation fields: |
| 67 | + |
| 68 | +```jsonc |
| 69 | +{ |
| 70 | + // --- retained handoff keys (the continue CLI reads these) --- |
| 71 | + "phase": "throughline_pick", // the halt id; AUTHORIZES --pick (required) |
| 72 | + "draft_dir": "/abs/.../talks/draft_N", |
| 73 | + // ... any other handoff fields the skill already wrote (candidates, |
| 74 | + // candidates_md, next_command, …) are retained, not stripped. |
| 75 | + |
| 76 | + // --- decision.v1 presentation fields --- |
| 77 | + "schema_version": "decision.v1", |
| 78 | + "skill": "presentation-maker", // presentation-maker | paper-writer | adversarial |
| 79 | + "gate": "throughline_pick", // MUST equal `phase` |
| 80 | + "prompt": "Pick the throughline for the deck:", |
| 81 | + "kind": "single_select", // single_select | approve_reject | free_text |
| 82 | + "options": [ |
| 83 | + {"id": "TL1", "summary": "one-line", "detail": "FULL text — show completely"} |
| 84 | + // … empty list allowed only for free_text |
| 85 | + ], |
| 86 | + "default": "TL1", // str | null; if set, must be an option id |
| 87 | + "confirm": true, // bool — gates the echo-and-confirm beat (below) |
| 88 | + "continue": {"cmd": "beril-presentation-maker continue {draft_dir} --pick {id}"} |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +`continue.cmd` MUST carry the `{id}` placeholder so Claude can splice the |
| 93 | +chosen option id. The user must NEVER see the raw `--pick` flag or the draft |
| 94 | +path. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Contract text for SKILL.md (vendor this block into each skill, Phase 2) |
| 99 | + |
| 100 | +> *(Substitute the skill's own name + glyph. The text below is for |
| 101 | +> presentation-maker; paper-writer uses `✎ paper-writer`, adversarial uses |
| 102 | +> `⚔ adversarial`.)* |
| 103 | +
|
| 104 | +### CRAFT interaction layer — how to surface this skill's output |
| 105 | + |
| 106 | +This skill's orchestrator runs as a subprocess. Inside this session its stdout |
| 107 | +is non-TTY (no color) and long output is folded out of view, so **the |
| 108 | +user-facing signal is YOUR message, not the raw tool output.** Your job is to |
| 109 | +re-render the skill's structured signals — STAGE progress, DECISION halts, |
| 110 | +RESULT deliverables — as clear, consistent message text. Follow these rules: |
| 111 | + |
| 112 | +1. **Re-render the structured contract as message text — do not rely on the |
| 113 | + raw box being visible.** When a tool result contains a CRAFT `STAGE` / |
| 114 | + `DECISION` / `RESULT` block (or the `decision.v1` / run-record JSON behind |
| 115 | + it), reconstruct it in your own message in a consistent presentation style. |
| 116 | + The boxed block in stdout is bare-terminal chrome and a data source; the |
| 117 | + legible copy the user reads is the one you write. Keep your style consistent |
| 118 | + run-to-run so the skill's "voice" is recognizable. |
| 119 | + |
| 120 | +2. **On a DECISION halt, render the choice completely + inline, honor |
| 121 | + `confirm`, then act on the reply.** When the orchestrator halts at a gate it |
| 122 | + writes a `decision.v1` to `<draft_dir>/.handoff.json` and exits; the run is |
| 123 | + paused waiting for the user. You MUST: |
| 124 | + - Present **every** option **completely** — show each option's full |
| 125 | + `detail` text, not just the `summary`, and never a file path or a "see |
| 126 | + `.handoff.json`". The user decides from what you show; show all of it. |
| 127 | + - Make choosing trivial: list the option `id`s (e.g. **TL1 / TL2 / TL3**), |
| 128 | + note which is the `default`, and ask the user to pick one. |
| 129 | + - **Honor `confirm`:** |
| 130 | + - `confirm: true` (consequential, hard-to-reverse gates — e.g. a |
| 131 | + throughline pick that sets the whole deck): after the user picks, **echo |
| 132 | + the pick back and confirm once** ("Resuming with **TL1** — go?") BEFORE |
| 133 | + running `continue.cmd`. Do not silent-auto-run. |
| 134 | + - `confirm: false` (the choice is cheap or already-spent — e.g. an |
| 135 | + image-approval where the cost is already incurred): run `continue.cmd` |
| 136 | + directly on the stated choice; no extra confirmation beat needed. |
| 137 | + - When you act, invoke the command in `continue.cmd`, substituting the |
| 138 | + chosen `id` for `{id}`. The user must NEVER see or type the raw `--pick` |
| 139 | + flag or the draft path — you translate their plain choice into the |
| 140 | + command and run it. |
| 141 | + - Do not invent options or change the `id`s; use exactly what `decision.v1` |
| 142 | + carries. For `kind: free_text`, the user's typed reply fills the `{id}` |
| 143 | + slot. |
| 144 | + |
| 145 | +3. **Report progress + cost at boundaries, from the run-record — not a |
| 146 | + continuous tick.** The STAGE banners mark stage boundaries; surface a brief |
| 147 | + "Stage N/M (<stage>) — <state>" line at those boundaries, and read |
| 148 | + stage/cost/tokens/model from the run-record (`audit/run_record.json`) when |
| 149 | + reporting them. Do **not** narrate every internal step or invent a live |
| 150 | + progress meter (continuous live ticking is deferred). A final cost/summary |
| 151 | + line when the run completes is welcome; per-step "now I'll run the next |
| 152 | + stage" narration is noise. |
| 153 | + |
| 154 | +4. **Suppress orchestrator NOISE.** Lines the orchestrator marks as internal |
| 155 | + (e.g. `[orchestrator] …` diagnostics) are written to |
| 156 | + `<audit_dir>/orchestrator.log`, not to the user. Do not surface that log |
| 157 | + content unless the user is debugging or an error/blocker requires it. |
| 158 | + |
| 159 | +5. **Speak up only when it carries signal.** A DECISION (rule 2), an |
| 160 | + error/blocker, a boundary report (rule 3), or a final summary the user asked |
| 161 | + for. A bare "Stage 5 is running." with nothing else is worse than silence — |
| 162 | + let the structured re-render do the work. |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## Conformance |
| 167 | + |
| 168 | +- **Family F** (`tests/test_conformance.py`) — each skill's vendored |
| 169 | + `chrome.py` is byte-identical to craft-platform's canonical. Graceful-skips |
| 170 | + until Phase 2 vendors the copies; fails loud after. The glyphs are multi-byte |
| 171 | + UTF-8 — copy the file verbatim (a locale/encoding slip diverges them |
| 172 | + invisibly). |
| 173 | +- **Family G** (`tests/test_conformance.py`) — each skill's shipped |
| 174 | + `decision.v1` goldens (`tests/fixtures/decision_v1/*.json`) validate against |
| 175 | + the shared `validate_decision`. Graceful-skips until Phase 2. |
| 176 | +- **Platform goldens** (`tests/test_decision.py`) — the canonical |
| 177 | + `decision.v1` goldens (`tests/fixtures/decision_v1/throughline_single_select.json`, |
| 178 | + `image_approve_reject.json`) validate clean and are the worked examples of |
| 179 | + the handoff-extension shape (single_select/confirm:true and |
| 180 | + approve_reject/confirm:false). |
| 181 | +- **Renderer** (`tests/test_chrome.py`) — display-width alignment (the |
| 182 | + must-fix: pad by visible glyph width, not `len()`), the color seam, the |
| 183 | + signature content, and the no-path/no-flag-leak guarantee. |
0 commit comments