Skip to main content

vitrify_cli/help/
verbs.rs

1//! Each command's `--help` block, printed after its options: `Reads:`,
2//! `Writes:`, `Prints:`, `Exit status:`, `Config:`, `Examples:` and
3//! `Procedure:`, in that order, the last three where they apply.
4
5pub const LOCATE: &str = "\
6Reads:   SDD discovery (specs/*/sdd.md, specs/*.sdd.md, then the files git would commit);
7         with --units, the SDD's units and their front matter, and — for a pin in
8         depends_on — the units of other SDDs it waits on; with --graph, every SDD's units
9         and contracts
10Writes:  nothing
11Prints:  one line per SDD: root, shape, slug, version, status, unit count
12         --json: [{root, shape, sdd, title, version, status, scope_roots, units}]
13         --units: one line per unit: status, parallel group, claim_seq, claimable
14         --units --json: {sdd, shape, version, status, units: [{unit, status, parallel_group,
15           depends_on, claimed_by, claim_expires, claim_seq, lease_live, claimable, file}]}
16         --graph: per SDD, `<sdd> → <sdd>  via <pins>` and its unit edges, or `(depends on
17           no other SDD)`; then each cycle and each unit waiting behind one
18         --graph --json: {sdds, sdd_edges: [{from, to, pins, units}], unit_edges: [{from, to,
19           via}], order, cycles, waiting}, each unit {sdd, unit}
20Exit status: 0 listed · 4 no SDD; with --units, several and no --sdd · 2 usage error
21         An SDD of a schema version this vitrify does not read is still listed (--graph
22         leaves it out, named on stderr).
23Examples:
24  vitrify locate
25  vitrify locate --units --sdd specs/calc
26  vitrify locate --units --json
27  vitrify locate --graph";
28
29pub const READSET: &str = "\
30Reads:   the core file's Ground Rules and Technology Decisions; the unit's entry; each
31         consumed contract, and the body a pinned contract stands for
32Writes:  nothing
33Prints:  one path per line in reading order, `  ::  <region>` for a region of a shared file
34         --json: {unit, sdd, shape, consumes, readings: [{path, region}]}
35Exit status: 0 resolved (and within budget) · 2 over the --budget limit, or a usage error
36         · 4 no SDD, unknown unit, a missing section or contract, a pin that does not
37         resolve or whose hash is not its authority's
38Config:  lint.readset_budget_bytes (VITRIFY_LINT_READSET_BUDGET_BYTES), for a bare --budget
39Examples:
40  vitrify readset --unit U-002 --sdd specs/calc
41  vitrify readset --unit U-002 --json
42  vitrify readset --unit U-002 --budget
43Procedure: vitrify brief build-unit (workers) · vitrify brief authoring (sizing a unit)";
44
45pub const CLAIM: &str = "\
46A protocol verb for workers, the integrator and authored baselines; not run by hand while
47`vitrify run` builds the SDD.
48Reads:   the mainline head (checked out into a throwaway .vitrify/tx-<pid>-<n> worktree);
49         the unit's front matter there, and the units of other SDDs a pin in its
50         depends_on waits on
51Writes:  a published mainline commit `sdd: claim <unit> (c<seq>) by <holder>`: status Claimed,
52         claimed_by, claim_expires = now + lease, claim_seq + 1; a claim event; the ledger.
53         The primary checkout is fast-forwarded when it has mainline checked out.
54Prints:  one JSON line: {unit, op, holder, claim_seq, claim_expires, commit, mainline}
55Exit status: 0 published · 1 git failure · 2 usage error · 4 unit missing or not claimable
56         (the reason is named) · 5 lost the publish race after 3 attempts
57Config:  mainline (VITRIFY_MAINLINE), after --mainline; --lease-minutes defaults to 60
58         and does not read run.lease_minutes
59Examples:
60  vitrify claim --unit U-003 --holder w1 --sdd specs/calc
61  vitrify claim --unit U-003 --holder w1 --lease-minutes 90 --mainline main
62Procedure: vitrify brief build-unit · vitrify brief kickoff";
63
64pub const RENEW: &str = "\
65A protocol verb for workers, the integrator and authored baselines; not run by hand while
66`vitrify run` builds the SDD.
67Reads:   the mainline head (throwaway .vitrify/tx-<pid>-<n> worktree); the unit's lease
68Writes:  a published mainline commit: claim_expires = now + lease; a renew event; the ledger
69Prints:  one JSON line: {unit, op, holder, claim_seq, claim_expires, commit, mainline}
70Exit status: 0 published · 1 git failure · 2 usage error · 4 unit missing, or not Claimed
71         by this holder · 5 lost the publish race after 3 attempts · 6 the lease has
72         already expired (renew refused: claim again)
73Config:  mainline (VITRIFY_MAINLINE), after --mainline; --lease-minutes defaults to 60
74Examples:
75  vitrify renew --unit U-003 --holder w1 --sdd specs/calc
76Procedure: vitrify brief build-unit";
77
78pub const RELEASE: &str = "\
79A protocol verb for workers, the integrator and authored baselines; not run by hand while
80`vitrify run` builds the SDD.
81Reads:   the mainline head (throwaway .vitrify/tx-<pid>-<n> worktree); the unit's claim
82Writes:  a published mainline commit: status Ready, holder and expiry cleared, claim_seq kept;
83         a release event; the ledger
84Prints:  one JSON line: {unit, op, holder, claim_seq, claim_expires, commit, mainline}
85Exit status: 0 published · 1 git failure · 2 usage error · 4 unit missing, or not Claimed
86         by this holder · 5 lost the publish race after 3 attempts
87Config:  mainline (VITRIFY_MAINLINE), after --mainline
88Examples:
89  vitrify release --unit U-003 --holder w1 --sdd specs/calc
90Procedure: vitrify brief build-unit · vitrify brief integrate";
91
92pub const TRACE: &str = "\
93Protocol verbs for workers, the integrator and authored baselines; not run by hand while
94`vitrify run` builds the SDD.
95Subcommands: record (write a unit's trace and stamp it Built or Verified) · verify (compare
96         a unit's recorded trace with its current inputs)
97Exit status: 2 without a subcommand; see each subcommand's --help
98Examples:
99  vitrify trace record --unit U-003 --stamp built --sdd specs/calc
100  vitrify trace verify --unit U-003 --json";
101
102pub const TRACE_RECORD: &str = "\
103A protocol verb for workers, the integrator and authored baselines; not run by hand while
104`vitrify run` builds the SDD. A change entry's re-stamps are vitrify change apply's.
105Reads:   the unit's entry, its consumed contracts, Ground Rules and Technology Decisions;
106         git HEAD for the default commit
107Writes:  the working tree: the unit's trace map; built sets status Built and
108         built: <date> @ SDD <version>, commit <sha>; verified sets status Verified and
109         verified:, and clears claimed_by and claim_expires. No journal event, no ledger.
110Prints:  one JSON object: {unit, recorded, stamp, file}
111Exit status: 0 recorded · 2 usage error · 4 no SDD, the unit or a consumed contract missing
112Examples:
113  vitrify trace record --unit U-003 --stamp built --sdd specs/calc
114  vitrify trace record --unit U-003 --stamp verified --commit 3f2a9c1
115Procedure: vitrify brief build-unit · vitrify brief integrate";
116
117pub const TRACE_VERIFY: &str = "\
118Reads:   the unit's recorded trace and its current inputs
119Writes:  nothing
120Prints:  `U-###: trace matches`, or `U-###: STALE — mismatched keys: …`
121         --json: {unit, match, mismatches: [{key, recorded, current}]}
122Exit status: 0 matches · 3 a key differs · 4 no SDD, unknown unit, or no recorded trace
123         · 2 usage error
124Examples:
125  vitrify trace verify --unit U-003 --sdd specs/calc
126  vitrify trace verify --unit U-003 --json
127Procedure: vitrify brief integrate";
128
129pub const LEDGER: &str = "\
130Subcommands: progress (the one-line progress summary) · regen (rewrite or --check the
131         derived ledger; a protocol verb for the integrator and authored baselines, not
132         run by hand while `vitrify run` builds the SDD)
133Exit status: 2 without a subcommand; see each subcommand's --help
134Examples:
135  vitrify ledger progress --all
136  vitrify ledger regen --check --sdd specs/calc";
137
138pub const LEDGER_REGEN: &str = "\
139A protocol verb for the integrator and authored baselines; not run by hand while
140`vitrify run` builds the SDD.
141Reads:   unit front matter; with --check, the ledger on disk
142Writes:  the working tree: ledger.md (bundle) or the ## State Ledger section (single file);
143         nothing with --check
144Prints:  the progress line, and the written path on stderr
145         --check: `ledger current (<path>)`, or the first differing line, derived and found
146Exit status: 0 written, or current · 3 --check found a difference, or no ledger · 4 no SDD,
147         or several and no --sdd · 2 usage error
148Examples:
149  vitrify ledger regen --sdd specs/calc
150  vitrify ledger regen --all --check
151Procedure: vitrify brief integrate";
152
153pub const LEDGER_PROGRESS: &str = "\
154Reads:   unit front matter
155Writes:  nothing
156Prints:  Progress: <V>/<total> Verified · <n> <Status> · … (Retired not in the total);
157         with --all one line per SDD, prefixed with its slug
158Exit status: 0 printed · 4 no SDD, or several and no --sdd · 2 usage error
159Examples:
160  vitrify ledger progress --sdd specs/calc
161  vitrify ledger progress --all";
162
163pub const JOURNAL: &str = "\
164Subcommands: append (add one event; a protocol verb for workers, the integrator and
165         authored baselines, not run by hand while `vitrify run` builds the SDD) · replay
166         (check the journal against front matter)
167Exit status: 2 without a subcommand; see each subcommand's --help
168Examples:
169  vitrify journal replay --all
170  vitrify journal append --event built --unit U-003 --sdd specs/calc";
171
172pub const JOURNAL_APPEND: &str = "\
173A protocol verb for workers, the integrator and authored baselines; not run by hand while
174`vitrify run` builds the SDD. A change entry's events are vitrify change apply's.
175Reads:   the journal's last seq; the SDD's version
176Writes:  the working tree: one line appended to journal.ndjson (bundle) or the ## Journal
177         block (single file), created on first use; seq = last + 1, at = now (UTC)
178Prints:  the appended event line
179Exit status: 0 appended · 2 usage error, or a kind other than change or audit without --unit
180         · 4 no SDD, or several and no --sdd
181Examples:
182  vitrify journal append --event built --unit U-003 --actor w1 --claim-seq 2 --sdd specs/calc
183  vitrify journal append --event audit --findings 0
184Procedure: vitrify brief integrate · vitrify brief kickoff";
185
186pub const JOURNAL_REPLAY: &str = "\
187Reads:   the journal (journal.ndjson, or the ## Journal block) and unit front matter
188Writes:  nothing
189Prints:  `journal consistent (N events)`, or one `order: …` or
190         `mismatch U.field: journal projects …, front matter says …` line per problem;
191         --all prefixes each line with the slug, `calc: no journal yet` where none
192         --json: {events, consistent, order_findings, mismatches, projection};
193         --all: an array of the same, each led by sdd and root
194Exit status: 0 consistent · 3 an order finding or mismatch · 4 no SDD, several and no --sdd,
195         or no journal (an SDD with no journal does not fail --all) · 2 usage error
196Examples:
197  vitrify journal replay --sdd specs/calc
198  vitrify journal replay --all --json
199Procedure: vitrify brief kickoff";
200
201pub const AUDIT: &str = "\
202Reads:   the SDD, its journal, the working tree under scope_roots; check 4 runs Verified
203         units' Verification commands (sh -c from the repository root)
204Writes:  nothing by default. --fix-leases, --apply-stale and --journal edit the working tree:
205         unit front matter, journal events, the ledger
206Prints:  `audit clean (7/7 checks)`, or one `[check N] subject: cause → remediation` line
207         per finding; --all prefixes each line with the slug
208         --json: {clean, findings: [{check, subject, cause, remediation}]};
209         --all: an array of {sdd, root, clean, findings}
210Exit status: 0 clean · 2 a finding (a fixing run still exits 2: re-run to confirm), or a
211         usage error · 4 no SDD, or several and no --sdd
212Config:  run.gate_jobs (VITRIFY_RUN_GATE_JOBS), for check 4
213Examples:
214  vitrify audit --sdd specs/calc
215  vitrify audit --all --skip-rotten --json
216  vitrify audit --apply-stale --journal --sdd specs/calc
217Procedure: vitrify brief kickoff · vitrify brief integrate";
218
219pub const BRIEF: &str = "\
220Reads:   ~/.vitrify/briefs/<task>.md ($VITRIFY_HOME; an override on disk wins); build-unit
221         with --unit --holder also reads the SDD, the unit's reading set and its claim
222Writes:  nothing in the repository; restores or refreshes its copy under ~/.vitrify/
223Prints:  no task: the procedure index (task, what it is for, who follows it)
224         a task: that procedure, filled with this vitrify's version and values
225         build-unit --unit --holder: the whole worker prompt vitrify run hands a worker
226Exit status: 0 printed · 2 --unit and --holder not given together, or not to build-unit,
227         or a usage error · 4 unknown unit, no SDD, or several and no --sdd
228Config:  run.status_check_seconds (VITRIFY_RUN_STATUS_CHECK_SECONDS), in brief run;
229         authoring.approval (VITRIFY_AUTHORING_APPROVAL), in brief authoring and change;
230         run.worktree_dir (VITRIFY_RUN_WORKTREE_DIR); run.lease_minutes
231         (VITRIFY_RUN_LEASE_MINUTES), in the worker prompt; VITRIFY_HOME
232Examples:
233  vitrify brief
234  vitrify brief change
235  vitrify brief build-unit --unit U-003 --holder w1 --sdd specs/calc";
236
237pub const INIT: &str = "\
238Sets up this machine, once: no other command creates ~/.vitrify/, and every other command
239refuses until this has run. Not a repository's step: run it in your own terminal.
240Reads:   git and the harness CLIs on PATH (claude, codex, opencode: one real model call
241         each, and one per role that adds flags)
242Writes:  ~/.vitrify/config.toml — every setting at its default, the harness role profiles,
243         and the probe record (the working streaming spellings); materializes the briefs,
244         schemas and templates under ~/.vitrify/
245Prints:  one `status: text` line per check, status ok, FAIL, untested or note, ending
246         `ok: recorded the probe in ~/.vitrify/config.toml`
247         --json: {green, checks: [{status, text}], harnesses: [{name, present, version,
248           headless, failure}]}
249Exit status: 0 set up, nothing failed · 2 a FAIL (git missing, a harness that does not
250         accept its spelling, a role probe that fails), or ~/.vitrify/config.toml exists
251         (vitrify probe updates it)
252Config:  VITRIFY_PROBE_TIMEOUT_SECS (per probe, default 60); VITRIFY_HOME
253Examples:
254  vitrify init
255  vitrify init --json";
256
257pub const PROBE: &str = "\
258Probes the machine again — after installing or upgrading vitrify or a harness CLI, or editing
259a role profile — and brings the probe record in ~/.vitrify/config.toml up to date. Asks
260before it changes the file (-y answers yes); changes nothing else in it.
261Reads:   ~/.vitrify/config.toml (the role profiles and the probe record); git and the harness
262         CLIs on PATH (one real model call each, and one per role that adds flags)
263Writes:  the [probe] tables of ~/.vitrify/config.toml, when there is a change and you agree;
264         restores or refreshes the briefs, schemas and templates under ~/.vitrify/
265Prints:  one `status: text` line per check, status ok, FAIL, untested or note; then one
266         `change: <key>: <recorded> → <found>` line per difference, and either
267         `ok: ~/.vitrify/config.toml: no changes`, `ok: updated ~/.vitrify/config.toml (N
268         changes)`, or `note: ~/.vitrify/config.toml: nothing changed`
269         stderr: the question, `apply N changes to ~/.vitrify/config.toml? [y/N]`
270         --json: {green, checks, harnesses, changes: [{key, from, to}], applied}
271Exit status: 0 the record is up to date, nothing failed · 2 a FAIL, the changes not applied
272         (declined, or no answer on stdin), or ~/.vitrify/config.toml does not parse
273Config:  VITRIFY_PROBE_TIMEOUT_SECS (per probe, default 60); VITRIFY_HOME
274Examples:
275  vitrify probe
276  vitrify probe -y
277  vitrify probe --json --assume-yes";
278
279pub const RUN: &str = "\
280Builds until Complete or Blocked: claims, dispatches workers, integrates, publishes.
281With several SDDs and no --sdd it is a project run: every Active SDD is a lane, one scheduler
282dispatches across them critical path first, and each SDD's dependents re-check after the
283merge. --sdd builds one SDD as a single lane; --upstream adds the SDDs it depends on.
284Interrupt it (Ctrl-C, kill -INT <pid>), never its workers; running it again resumes.
285Reads:   the SDDs on mainline; ~/.vitrify/config.toml (the recorded harness spelling and
286         the role profiles); the §5 commands it runs; with run.priority = \"history\",
287         earlier runs' records
288Writes:  published mainline commits (claims, renewals, releases, each Verified unit, the
289           re-checks it made: `verified` events by recheck, suite: \"pass\");
290         .vitrify/run.json, the latest run's snapshot, its report null until it ends;
291         .vitrify/logs/<job>/: run.json, project.json (the plan, each lane's state and
292           records path, the critical path as it ran), events.jsonl (one line per event,
293           a lane's naming it; in a project run a `pass` line per change in the slots),
294           report.txt (the final report);
295         .vitrify/logs/<job>/<slug>/, one per lane: gate.json, worker-<holder>.out, .err
296           and .prompt.md, escalation-<n>.json;
297         under run.worktree_dir: unit worktrees, and per SDD its integration checkout
298           (mainline-<slug>, made anew each run) with its lock, its base checkout
299           (base-<slug>) and its culprit probe checkout (probe-<slug>).
300         --dry-run publishes nothing and touches no file of the repository.
301Prints:  stdout, a project run: Project build job — <n> SDDs: <lane states>  [<job>], Plan,
302         Critical path, Capacity, Watch; one [<slug>] line per event; the final report:
303         Complete. or Blocked., then one line per SDD — its slug, its state (Complete,
304         Up to date or Blocked) and why — each further blocker indented below.
305         Lane states: idle, build, recheck, up to date, complete, blocked.
306         stdout, one SDD: the job header (SDD build job — <sdd> @ <version>  [<job>],
307         Done-condition, Mainline, Plan, Workers, Roles, Worktrees, Parameters), then,
308         before anything is dispatched:
309           Watch: vitrify run status --job <job> [--follow] · once it ends, the same command
310           prints the report · procedure: vitrify brief run
311         then one line per event — [<slug>] <unit> adopted (built attempt c<n>) → gate,
312         [<slug>] <unit> rotten: …, [<slug>] <culprit finding> among them — then one final
313         report: Complete. or Blocked., the progress line, each blocker (a rotten unit
314         with its culprit), the journal tail (replay: exit 0 (consistent)).
315         Only the rows of units a change reached since their last recorded check run, at
316           the start and in each gate; with nothing to build or re-check, none run.
317         --recheck: every Verified unit's rows and the §5 Test command run again.
318         --dry-run: the header and any claim it would recover (a project run: the whole
319           plan, lane by lane — the same for the same repository and configuration),
320           ending Start: vitrify run <the flags given, without --dry-run>
321         stderr: worker reports, gate failures, notes, warnings, and each
322           preflight failed: <cause> → <fix>
323Exit status: 0 Complete. (--dry-run: preflight passed) · 2 Blocked., a preflight failure,
324         an abort verdict, or a usage error · 1 an error, its message last on stderr ·
325         4 a project run with an SDD at schema 2.0 whose units consume pins.
326         An interrupted run cleans up and ends by the signal it received.
327Config:  mainline (VITRIFY_MAINLINE) · run.worker_cap (VITRIFY_RUN_WORKER_CAP, --cap)
328         · run.lease_minutes · run.renew_fraction · run.abort_failed_waves
329         · run.worker_timeout_minutes · run.gate_jobs (--gate-jobs)
330         · run.poll_seconds · run.lane_cap · run.priority · run.worktree_dir
331         · harness.preferred
332         · lint.readset_budget_bytes;
333         each key's variable is VITRIFY_<SECTION>_<KEY> (VITRIFY_RUN_GATE_JOBS, …)
334Examples:
335  vitrify run --dry-run
336  vitrify run --sdd specs/api --upstream
337  vitrify run --dry-run --sdd specs/calc
338  vitrify run --sdd specs/calc
339  vitrify run --cap 2 --gate-jobs 1 --wait
340  vitrify run --recheck
341Procedure: vitrify brief run";
342
343pub const RUN_STATUS: &str = "\
344Read-only: writes no file, takes no lock, runs git only with --no-optional-locks; point it at
345a live run from another terminal.
346Reads:   .vitrify/run.json (the latest job) or the --job's .vitrify/logs/<job>/: run.json,
347         project.json, events.jsonl, report.txt, and each lane's <slug>/: gate.json, the
348         worker logs; process liveness; each worker worktree's git state and front matter
349Writes:  nothing
350Prints:  the run's state (alive, died or ended), the progress line, one line per worker
351         with its stage, the gate's step; once the run has ended, its final report under
352         Report:; warnings as `! <text>` lines. A run of several SDDs shows, in place of
353         the progress line, one line per lane: slug, state (idle, build, recheck, up to
354         date, complete, blocked), Verified/total, in flight, waiting, and what an idle or
355         blocked lane waits on (units of other lanes)
356         Stages: reading · editing · stamped · exited · ? (unknown) while running;
357           queued · gate · integrating while integrating; else the outcome itself
358         Warnings: an empty log after --quiet-after; no output for --quiet-after; 90% of
359           worker_timeout_minutes used; a run that died, with a kill -9 -- -<pid> line for
360           each worker process group still running
361         --json, in order: job_id, pid, sdd, harness, started_at, at, state, terminated,
362           report, progress, params, workers, gate, warnings, logs, lanes: [{slug, root,
363           state, verified, total, in_flight, waiting, waits_on}]
364         --follow: the view once, then one line per change until the run ends, a lane's
365           change of state included, lines naming their lane `[<slug>]` when there are
366           several; --json one event object per line; --since-start first replays
367           events.jsonl
368Exit status: without --follow: 0 a run is shown, whatever its state · 4 no run recorded, or
369         --job names none · 2 usage error.
370         --follow exits with the followed run: 0 complete · 2 blocked · 1 error, interrupted,
371         or died · 4 no run recorded. A reader that goes away (| head) stops it with 0.
372Examples:
373  vitrify run status
374  vitrify run status --follow --job <job>
375  vitrify run status --json
376Procedure: vitrify brief run";
377
378pub const LINT: &str = "\
379Reads:   the SDD; the other SDDs it pins (L9); its changelog (L10); its TDD (L11); for a
380         pin in depends_on, every SDD's units and contracts (L12)
381Writes:  nothing
382Prints:  `lint clean (L1–L12)`, or one `[L#] subject: cause → remediation` line per finding;
383         --all prefixes each line with the slug
384         --json: {clean, findings: [{check, subject, cause, remediation}]};
385         --all: an array of {sdd, root, clean, findings}
386Exit status: 0 clean · 2 a finding, or a usage error · 4 no SDD, or several and no --sdd
387Config:  lint.readset_budget_bytes (VITRIFY_LINT_READSET_BUDGET_BYTES), for L5
388Examples:
389  vitrify lint --sdd specs/calc
390  vitrify lint --all --built --json
391Procedure: vitrify brief authoring (before Active) · vitrify brief change (after)";
392
393pub const CHECK: &str = "\
394Runs every read-only check over one SDD, or with --all the repository: lint (--built once
395any unit has build state or a journal exists), audit (check 4 unless --skip-rotten), journal
396replay (where a journal exists), ledger regen --check (where a ledger or journal exists) and
397the pin states. In a git repository it also lists the dirty units: Verified units whose
398checked-against paths a commit changed since their last recorded check (their files, those
399of every unit they depend on, unmanaged and outside-scope paths), or whose anchor git cannot
400resolve. Dirty units are not findings and nothing re-checks them here; vitrify run does.
401Runs no §5 command; vitrify run --dry-run does.
402Reads:   each SDD, its journal and ledger, the SDDs it pins, its changelog and TDD; for the
403         dirty units every SDD of the repository and git history up to HEAD
404Writes:  nothing
405Prints:  one `<slug>: [<source> <check>] subject: cause → remediation` line per finding,
406         then `<slug>: note: Q-### is open (blocks …)` notes, then one
407         `<slug>: dirty U-###: <path> (<owner>), …` line per dirty unit, then
408         `check clean: N SDDs`, or `check: N findings in M of K SDDs`, ending
409         `; N units dirty` when there are any
410         stderr: `note: dirty units not computed: …` when an SDD cannot be read or the
411           unit graph has a cycle
412         --json: {sdd, root, clean, findings: [{source, check, subject, cause, remediation}],
413           notes, dirty: [{unit, anchor, why, paths: [{path, owner}]}]}; an array with --all.
414           source: lint, audit, journal, ledger or pin; check: \"L4\", \"5\" or null;
415           why: changed, no-anchor or unresolved-anchor
416Exit status: the worst component (an error, 1, wins; else the highest): 0 clean · 2 a lint,
417         audit or pin finding, or a usage error · 3 a journal or ledger mismatch · 4 no SDD,
418         several and no --sdd, a schema version this vitrify does not read
419Config:  lint.readset_budget_bytes (VITRIFY_LINT_READSET_BUDGET_BYTES) · run.gate_jobs
420         (VITRIFY_RUN_GATE_JOBS), for audit check 4
421Examples:
422  vitrify check --sdd specs/calc
423  vitrify check --all --skip-rotten
424  vitrify check --all --json
425Procedure: vitrify brief change";
426
427pub const CHANGE: &str = "\
428Subcommands: apply (a change entry's bookkeeping in one step: re-stamp or mark Stale, the
429         journal, the ledger)
430Exit status: 2 without a subcommand; see each subcommand's --help
431Examples:
432  vitrify change apply --sdd specs/calc
433  vitrify change apply --all --dry-run";
434
435pub const CHANGE_APPLY: &str = "\
436For each Active SDD whose last change entry has no change event yet: PATCH re-records the
437moved units' traces (status and stamps kept) and appends change --entry CH-###; MINOR or
438MAJOR appends change --entry CH-### --stale <units> and marks each Stale; then the ledger is
439regenerated. Re-running is safe: a recorded entry is skipped.
440Reads:   the changelog's last entry, front matter version and updated, the journal, unit
441         traces (audit check 5), the pin states
442Writes:  the working tree: unit front matter, journal events, the ledger (the commit is
443         yours); nothing with --dry-run
444Prints:  per SDD, label-prefixed: `calc: CH-004 1.2.0 → 1.3.0 (minor): U-002 marked Stale`
445         and `calc: - Staleness applied: U-002 → Stale`, or why nothing applies (already
446         recorded, Draft, no change entry). stderr: `next: copy the Staleness applied line
447         into CH-### (<changelog>), then run vitrify check`; with --dry-run
448         `dry run: nothing written`
449         --json: {sdd, root, entry, from, to, bump, action, restamped, stale,
450           staleness_line, dry_run}; an array with --all. bump: patch, minor, major or
451           null; action: applied, already-recorded, draft or no-entry
452Exit status: 0 applied, or nothing to do · 2 refused (version or updated does not match the
453         entry, a stale pin, a single file's entry outside ## Changelog), or a usage error
454         · 4 no SDD, or several and no --sdd · 1 error
455Examples:
456  vitrify change apply --sdd specs/calc --dry-run
457  vitrify change apply --all
458  vitrify change apply --sdd specs/calc --commit 3f2a9c1 --json
459Procedure: vitrify brief change";
460
461pub const PIN: &str = "\
462Subcommands: list (every external contract, its kind and state) · sync (rewrite stale pins'
463         hashes)
464Exit status: 2 without a subcommand; see each subcommand's --help
465Examples:
466  vitrify pin list --all
467  vitrify pin sync --sdd specs/beta";
468
469pub const PIN_LIST: &str = "\
470Reads:   the SDD's external contracts (Producer: external); for each pin, its authority's
471         body in the SDD that owns it
472Writes:  nothing
473Prints:  one line per contract: `beta C-001  ok  pin of alpha C-001  <file>`, a transcription
474         reading `transcription`, then `N external contracts: 2 ok · 1 stale · …`
475         States: ok · stale · missing-authority · invalid · unchecked (a transcription)
476         --json: {clean, contracts: [{sdd, contract, file, kind, state, authority, bytes,
477           consumers, detail}], counts}. kind: pin or transcription; authority:
478           {sdd, contract, file, bytes}, or null
479Exit status: 0 nothing stale, missing-authority or invalid · 2 one is, or a usage error
480         · 4 no SDD, or several and no --sdd
481Examples:
482  vitrify pin list --sdd specs/beta
483  vitrify pin list --all --json
484Procedure: vitrify brief change";
485
486pub const PIN_SYNC: &str = "\
487Reads:   as pin list; the consumers' unit traces
488Writes:  the working tree: each stale pin's hash, in its contract file. No status, journal
489         event or version: the change entry, vitrify change apply and the commit are yours.
490         Nothing with --dry-run
491Prints:  `synced beta C-002 ← alpha C-002  <file>` per pin; per consumer SDD
492         `beta: - Staleness applied: U-001 → Stale (consume C-002)`; then the count line.
493         stderr: `not synced: …` for what it cannot put right, and per consumer
494         `next: write beta's change entry around its line, then run vitrify change apply
495         --sdd specs/beta`; with --dry-run the same lines, and on stderr
496         `dry run: nothing written` in place of the next: lines
497         --json: {synced, staleness, unresolved, dry_run}
498Exit status: 0 every stale pin synced · 2 something could not be synced (a missing
499         authority, an invalid declaration), or a usage error · 4 no SDD, or several and
500         no --sdd
501Examples:
502  vitrify pin sync --sdd specs/beta
503  vitrify pin sync --all --dry-run
504  vitrify pin sync --all --json
505Procedure: vitrify brief change";
506
507pub const QUESTIONS: &str = "\
508Reads:   the Decision Log (decisions.md, or ## Decisions & Open Questions) and the units'
509         OPEN(Q-###) markers
510Writes:  nothing
511Prints:  one line per question: `Q-001  open  blocks U-003, U-004  <text>`, then
512         `N open, M resolved`; --open lists only the open ones
513         --json: {open, resolved, questions: [{sdd, q, status, blocks, noted, text}]}
514Exit status: 0 listed, whatever is open (lint L8 is the check that fails) · 4 no SDD, or
515         several and no --sdd · 2 usage error
516Examples:
517  vitrify questions --sdd specs/calc --open
518  vitrify questions --all --json
519Procedure: vitrify brief change (answer one) · vitrify brief run (a blocker naming Q-###)";
520
521pub const NEW: &str = "\
522Reads:   ~/.vitrify/templates/ ($VITRIFY_HOME; an override on disk wins)
523Writes:  the working tree, in the current directory: tdd → NAME.md (default tdd.md);
524         sdd → NAME/ bundle with sdd.md, units/, contracts/, changelog.md, decisions.md;
525         sdd --single → NAME.sdd.md (default NAME scope). An SDD declares
526         schema_version: 2.2. Never overwrites.
527Prints:  the created path; stderr: `next: fill <path> per vitrify schema show, then run
528         vitrify lint --sdd <path>` (sdd), `next: fill <path> per vitrify schema show --tdd`
529         (tdd)
530Exit status: 0 created · 2 the target exists, or a usage error
531Config:  VITRIFY_HOME
532Examples:
533  vitrify new tdd calc-tdd
534  vitrify new sdd calc
535  vitrify new sdd --single calc
536Procedure: vitrify brief authoring";
537
538pub const SCHEMA: &str = "\
539Subcommands: show (print the normative SDD schema, or the TDD schema with --tdd)
540Exit status: 2 without a subcommand; see each subcommand's --help
541Examples:
542  vitrify schema show
543  vitrify schema show --tdd";
544
545pub const SCHEMA_SHOW: &str = "\
546Reads:   ~/.vitrify/schemas/ ($VITRIFY_HOME; an override on disk wins)
547Writes:  nothing in the repository; restores or refreshes its copy under ~/.vitrify/
548Prints:  the SDD schema (schema_version 2.2), or with --tdd the TDD schema
549Exit status: 0 printed · 1 the file cannot be read · 2 usage error
550Config:  VITRIFY_HOME
551Examples:
552  vitrify schema show
553  vitrify schema show --tdd
554Procedure: vitrify brief authoring";
555
556#[cfg(test)]
557mod tests {
558    use super::*;
559
560    const ALL: [(&str, &str); 31] = [
561        ("LOCATE", LOCATE),
562        ("READSET", READSET),
563        ("CLAIM", CLAIM),
564        ("RENEW", RENEW),
565        ("RELEASE", RELEASE),
566        ("TRACE", TRACE),
567        ("TRACE_RECORD", TRACE_RECORD),
568        ("TRACE_VERIFY", TRACE_VERIFY),
569        ("LEDGER", LEDGER),
570        ("LEDGER_REGEN", LEDGER_REGEN),
571        ("LEDGER_PROGRESS", LEDGER_PROGRESS),
572        ("JOURNAL", JOURNAL),
573        ("JOURNAL_APPEND", JOURNAL_APPEND),
574        ("JOURNAL_REPLAY", JOURNAL_REPLAY),
575        ("AUDIT", AUDIT),
576        ("BRIEF", BRIEF),
577        ("INIT", INIT),
578        ("PROBE", PROBE),
579        ("RUN", RUN),
580        ("RUN_STATUS", RUN_STATUS),
581        ("LINT", LINT),
582        ("CHECK", CHECK),
583        ("CHANGE", CHANGE),
584        ("CHANGE_APPLY", CHANGE_APPLY),
585        ("PIN", PIN),
586        ("PIN_LIST", PIN_LIST),
587        ("PIN_SYNC", PIN_SYNC),
588        ("QUESTIONS", QUESTIONS),
589        ("NEW", NEW),
590        ("SCHEMA", SCHEMA),
591        ("SCHEMA_SHOW", SCHEMA_SHOW),
592    ];
593
594    #[test]
595    fn every_block_has_exit_status_and_examples() {
596        for (name, text) in ALL {
597            assert!(!text.trim().is_empty(), "{name} is empty");
598            assert!(text.contains("Exit status:"), "{name} lacks Exit status:");
599            assert!(text.contains("Examples:"), "{name} lacks Examples:");
600        }
601    }
602
603    #[test]
604    fn headings_come_in_order() {
605        let order = [
606            "Reads:",
607            "Writes:",
608            "Prints:",
609            "Exit status:",
610            "Config:",
611            "Examples:",
612            "Procedure:",
613        ];
614        for (name, text) in ALL {
615            let mut last = 0;
616            for heading in order {
617                if let Some(at) = text.find(heading) {
618                    assert!(at >= last, "{name}: {heading} out of order");
619                    last = at;
620                }
621            }
622        }
623    }
624
625    #[test]
626    fn every_example_is_a_vitrify_line() {
627        for (name, text) in ALL {
628            let examples = text
629                .split("Examples:\n")
630                .nth(1)
631                .unwrap_or_else(|| panic!("{name}: no Examples: line"));
632            let lines: Vec<&str> = examples
633                .lines()
634                .take_while(|l| l.starts_with("  "))
635                .collect();
636            assert!(!lines.is_empty(), "{name}: no example");
637            for l in lines {
638                assert!(l.starts_with("  vitrify "), "{name}: {l}");
639            }
640        }
641    }
642}