@dialecte/cli 0.7.0 → 0.8.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.
package/README.md CHANGED
@@ -24,81 +24,9 @@ code from the one map the code declares (each command's `verbs` and `flags` deri
24
24
  shape. Exit codes: 0 an answer or green, 1 nothing found or a failed check,
25
25
  2 usage or refused; a command's help says when it differs.
26
26
 
27
- ```
28
- Discover api members schema explain standard facts ask
29
- Use run fixture new
30
- Grow lot
31
- Plan plan
32
- Check gate tdd rules contrib mutants
33
- Hand over handover
34
- Workspace worktree doctor models skills
35
- Maintain bench coverage narrowing audit text
36
- ```
37
-
38
- ```
39
- dialecte api find "<need>" # find a method by what you need; api show <path>: one method's contract
40
- dialecte members <expr> # what an expression of the live types holds
41
- dialecte schema <Tag> # what an element may hold and where
42
- dialecte explain <code> # what an error or diagnostic code means, when it is raised, the usual fix
43
- dialecte standard index|find|show|eval # index and search the standards kept on this machine, outside every repository
44
- dialecte facts list|show|forget # the facts recorded in your data folder: their state now, their history; forget one
45
- dialecte ask "<question>" # answer from a fact, the definition, the catalogues and api indexes, else the standard's slices for readers
46
- dialecte run <script.ts> # run a script on an in-memory project of the installed dialecte: one structured outcome
47
- dialecte fixture <Tag> # the smallest valid XML document holding an element, built by the dialecte's engine
48
- dialecte new verb <namespace> <query|transaction> <name>
49
- dialecte lot start <brief.json> # a lot from its brief: the lot folder in the store, the numbered worktree, .dialecte/lot
50
- dialecte lot status <id> # its state derived from the records, the checks, the next station and its exact command; reads only
51
- dialecte lot risk <id|folder> [--effort <level> --by <who>] # the risk class derived now, the effort and its cap; --effort records a person's effort
52
- dialecte lot wait <id> [--timeout <seconds>] # until the lot needs someone: ready, a question, failed, a limit
53
- dialecte lot answer <id> <question> "<answer>" [--by <who>] # answer an open question of the lot, once
54
- dialecte lot result <id> # the hand-over (card, show and run lines) of a ready lot, or why it stopped; writes nothing
55
- dialecte lot stop <id> --reason <text> # end the lot: its pending hand-over abandoned first, then canceled
56
- dialecte inbox # what waits on someone across every lot store: questions, ready hand-overs, failed lots
57
- dialecte plan next|check|mark <plan.md> # what can start now in a plan's lot block; the block checked; a person's mark
58
- dialecte lot exempt|accept|revised|gone|mutation # the lot declaration .dialecte/lot.json
59
- dialecte lot finding|decide|snapshot|choice|standard|verify <id|folder> ... # a lot's review rounds and late fixes, in its lot or hand-over folder
60
- dialecte lot delta <id|folder> --round <n> # the fix diff since round n-1; --worktree: the old code to run a test on
61
- dialecte lot recap <id|folder> # the pull request's expandable part, built from the hand-over's records only
62
- dialecte lot close <name|index> # a finished lot: node_modules to the pool, its worktree to the trash
63
- dialecte gate [--full] # the package's Definition of Done, with the real counts
64
- dialecte gate --hook # in a commit hook: the suite, unless a green gate --full of the committed tree answers it
65
- dialecte tdd red|green|status # receipts: each new test failed on an assertion before the code, then passed untouched
66
- dialecte rules # code-rules self-check of the changed files
67
- dialecte contrib # the contributor checks, after gate --full and before the hand-over
68
- dialecte mutants run|status|schedule|abandon|migrate|judge|record|drop # mutation testing of the declared scope
69
- dialecte handover write <lots.json> # the guarded commit-by-lots hand-over a human runs (handover <lots.json> too)
70
- dialecte handover show|review|run|abandon|list|--legend
71
- dialecte worktree add|prune # a worktree ready to work in; what a merge left behind
72
- dialecte doctor # versions, core API generation, skills and station agents in sync, local checkouts
73
- dialecte models # which model each tier (fast, standard, strong, frontier) means for your vendor
74
- dialecte skills sync|generate|check|changed # the agent skills your dependencies ship, and this package's own
75
- dialecte bench [--check] # measure the type-instantiation cost of your own types; --check gates CI
76
- dialecte coverage # generate complete, schema-driven type-coverage probes
77
- dialecte narrowing # assert schema-derived type narrowing still holds
78
- dialecte audit # render the public type surface and flag readability issues (C1-C6)
79
- dialecte text check <file> # the human part of a GitHub text: its fixed headings and its word cap
80
- ```
81
-
82
- ### Renamed in 1.0
83
-
84
- The review rounds' commands moved under `lot`. The old forms run nothing and write nothing: each answers
85
- `renamed: dialecte <old> is now dialecte <new>` on stderr, exit 2, until 2.0. Its second line is the full new
86
- command with the same arguments, or, with no arguments, the new form's usage line; `record` or `review`
87
- without a verb lists every form that replaced it. Asked with `--help`, an old form prints the same answer on
88
- stdout, with the words given before `--help`, exit 0; with `--help --json` it prints
89
- `{ renamed: [{ old, new }] }`, the words after `dialecte` (`record` lists its five forms).
90
-
91
- | 1.0 | Before |
92
- | ----------------------------------------------------------------------------------------- | -------------------------- |
93
- | `dialecte lot finding <id\|folder> --round <n> --severity <s> --at <file:line> <finding>` | `dialecte record review` |
94
- | `dialecte lot decide <id\|folder> <finding> <state>` | `dialecte record decision` |
95
- | `dialecte lot snapshot <id\|folder> --round <n>` | `dialecte record snapshot` |
96
- | `dialecte lot choice <id\|folder> --by <who> <decision>` | `dialecte record choice` |
97
- | `dialecte lot standard <id\|folder> consulted <note> \| not-consulted <reason>` | `dialecte record standard` |
98
- | `dialecte lot delta <id\|folder> --round <n> [--worktree] [--json]` | `dialecte review delta` |
99
- | `dialecte lot recap <id\|folder>` | `dialecte recap` |
100
-
101
- `dialecte handover write <lots.json>` names what `dialecte handover <lots.json>` does; the old form stays.
27
+ Every command has its page in [`doc/commands/`](doc/commands/index.md): the help the cli prints, generated from the
28
+ command map (`npm run doc:generate`), then what the command does in full. The index lists the commands by family
29
+ and the forms renamed in 1.0.
102
30
 
103
31
  ## Zero-config
104
32
 
@@ -116,87 +44,6 @@ Everything is overridable per `package.json` `"dialecte"` field (odd layouts) or
116
44
 
117
45
  Env: `RUNS=5 dialecte bench` (repetitions kept as the min); `COVERAGE_CHILD_CAP=N` (cap child edges).
118
46
 
119
- ## Agent skills
120
-
121
- Every Dialecte package ships the agent skills that describe it in `skills/<name>/SKILL.md` (open
122
- [Agent Skills](https://agentskills.io) format), versioned with its code.
123
-
124
- - **In an app**: `npx @dialecte/cli skills sync` links the consumer skills of your `@dialecte/*` (and any
125
- other) dependencies into `.claude/skills` and `.agents/skills` (Codex, Cursor, Gemini CLI, Copilot read the
126
- latter; add `--agent copilot` for `.github/skills`). Links follow your installed versions; rerun after
127
- adding a dependency. `--copy` writes copies instead of links.
128
- - **Consumer and contributor skills**: a skill whose frontmatter says `metadata:` / `audience: contributor` is
129
- for changing a dialecte package (core's `dialecte-contributing`, `dialecte-lot`); a skill without one is a
130
- consumer skill. A sync installs the consumer skills only and names the contributor skills it left out;
131
- `--contributing` installs them too and is remembered (`contributing` in `.dialecte-skills.json`) until
132
- `--no-contributing` removes them. `dialecte doctor` expects the skills of the audience the manifest says;
133
- `skills check` refuses another audience value.
134
- - **Station agents (Claude Code)**: when Claude Code is a target (the default), the contributor skills are
135
- installed and the project's model vendor is anthropic, `skills sync` also writes one agent per station of `dialecte-lot` into
136
- `.claude/agents/dialecte-<station>.md`: `implementer` and `fixer` (standard tier), `implementer-strong` and
137
- `reviewer` and `grader` (strong), `eval-runner` and `standard-reader` (standard), `searcher` (fast). Each file
138
- sets the model (from the `dialecte models` map, as the alias Claude Code accepts: `sonnet`, `opus`,
139
- `haiku`) and the tools: the reviewer holds the read tools and Bash (it runs the tests) and no Write or Edit,
140
- the searcher and the grader hold read tools only. These files are adapters: a station's tier and access
141
- (`read`, `review`, `edit`) are the cli's, its definition is the `dialecte-lot` skill's `references/stations.md`
142
- (one `### <station>` section with a `- Tier:` and an `- Access:` line), and the Claude tool names are only the
143
- Claude form of the access. The body is a few lines naming the station and its section in the installed
144
- `.claude/skills/dialecte-lot/references/stations.md`, the skills to load and the never-list; it never copies a skill.
145
- The `eval-runner` and the `grader` read neither the page nor a lot skill (they judge the skill under test): their
146
- brief carries their definition and names the only skill text they read. `skills check`, in a package shipping `dialecte-lot`, refuses a
147
- `references/stations.md` that is missing, lacks a station, has an unknown section or a `Tier:` / `Access:` line out of
148
- line with the cli. The files are owned through the manifest: replaced on
149
- every sync, removed when no longer produced, and a file of your own with the same name is reported, never
150
- overwritten. `dialecte doctor` warns about a stale or missing one. Other hosts (Copilot / VS Code, Codex,
151
- Gemini) get no agent files from this command yet: the tier of each station comes from `dialecte models`
152
- there, as the `Tier:` line of a brief says.
153
- - **Session-start check, every agent**: when `dialecte-lot` is installed by the sync (whatever the targets),
154
- `skills sync` writes a section in the project's root `AGENTS.md`, between `<!-- dialecte-skills:session-check -->`
155
- and `<!-- /dialecte-skills:session-check -->`, telling the agent to run `npx --no-install @dialecte/cli doctor --brief`
156
- at a session start. It is written with a blank line inside each marker, the form a markdown formatter keeps, so a
157
- formatted `AGENTS.md` stays formatted. An existing `AGENTS.md` gets it appended after one blank line; the body
158
- between the markers is compared tolerantly (whitespace does not matter: line ends, blank lines, a wrapped
159
- sentence), and only the marked block is replaced when an older release wrote another sentence: every byte outside
160
- it stays, line ends included. A missing `AGENTS.md` is created only when you answer yes on a terminal or pass `--agents-file`; without
161
- either, the sync says it was not created. The section and the file are never removed nor deleted by a sync:
162
- `--no-session-check`, `--no-contributing` or a sync without `dialecte-lot` leave them in place (delete the section
163
- by hand if you do not want it). `--no-agents-file` leaves `AGENTS.md` alone altogether (it excludes
164
- `--agents-file`). A marker without its pair, or a doubled one, leaves the file alone with a warning.
165
- An `AGENTS.md` holding only the section is no evidence of a vendor.
166
- - **Session-start check (Claude Code)**: the same check as an adapter: `skills sync` adds a `SessionStart` hook running
167
- `npx --no-install @dialecte/cli doctor --brief` (the installed cli: no download at a session start) to
168
- `.claude/settings.json`, inserted by a minimal text edit (the rest of your file stays byte for byte), never
169
- duplicated, removed when you drop the claude target. If you edited the hook's text since, removal cuts only
170
- our handler (a comment right next to it may go with it) and writes nothing when anything else would change. Agents and hook are written only when `dialecte-lot`
171
- is installed for Claude Code. `doctor --brief` prints nothing when the skills, the
172
- versions and the station agents are in sync, otherwise one line per problem with its fix, and always exits 0.
173
- `--no-session-check` leaves the hook out (and removes the one a sync added). Elsewhere, the `dialecte` skill
174
- tells the agent to run `doctor` first.
175
- - **Working on Dialecte**: `npx @dialecte/cli skills sync --from ../ --contributing` takes them from your local
176
- checkouts, the contributor skills included.
177
- - **In a package**: `dialecte skills generate` rewrites the `<!-- dialecte-skills:generated <kind> -->`
178
- blocks (`extensions`, `core-methods`, `hooks`, `api`, `intents`) from the source; the `api` block lists
179
- the methods, then one section per package entry (each `exports` subpath shipping a `.d.ts`) with the
180
- functions it exports.
181
- `dialecte skills check` verifies every API, path and npm script a page cites, and that every public
182
- method and every function an entry exports (not `@internal`) has a JSDoc summary and an `@intent` tag; it warns when a summary or an
183
- intent quotes a sentence, since the generated pages republish the JSDoc. A page about several
184
- repositories declares `<!-- dialecte-skills workspace -->` and is fully verified with
185
- `--workspace <folder>`; a deliberate outside mention goes in `<!-- dialecte-skills ignore: token -->`.
186
- It also verifies every cli invocation a page cites in code (inline code, fenced blocks tagged `sh`, `bash` or
187
- `shell`, and in an untagged fence only a line starting `dialecte ` and a command of the map; a fence with any
188
- other tag - `text`, `mermaid`, a diagram, a sample - is never read; never prose; generated blocks left out): one starting with `dialecte` or `@dialecte/cli`, after `npx`, a
189
- `$ ` prompt or a shell operator. Its command, its verb and each `--flag` must be in the command map of the
190
- cli the package uses (the cli's own map in the cli itself, else what the installed `@dialecte/cli` answers to
191
- `dialecte --help --json`); an unknown one, or an old form of a command renamed in 1.0 (see "Renamed in
192
- 1.0"), is an error at `page:line` naming the closest valid form, or the new form, on a workspace page too. A quoted word, a
193
- `<placeholder>` and what follows a bare `--` are not checked; `ignore:` takes the offending word (`record`,
194
- `--fats`). With no installed cli, or one before the map, the invocations are not checked: one warning says
195
- why and the summary line says so. Inside a `<placeholder>`, an option group `[...]` or a flag group
196
- `(--a | --b)` a `|` is no pipe; each kind of group is counted on its own (a `)` never closes a `<`), and a
197
- process substitution `<(dialecte ...)` is read like any invocation. A versioned `@dialecte/cli@<version>` and
198
- what follows an unclosed `<`, `[` or `(--` are not read.
199
-
200
47
  ## What the cli prints
201
48
 
202
49
  Every text the cli prints passes one boundary: each printed line is escaped once, so a value from a record, a
@@ -214,283 +61,10 @@ every other control in them is escaped.
214
61
  Each answers in a few lines, the same with or without the Dialecte repositories, and takes `--json`.
215
62
  Exit codes: 0 an answer, 1 nothing found (or a warning for `doctor`), 2 a usage error.
216
63
 
217
- - `dialecte api find "<need>" [--package <name>] [--limit 5]` searches the `api.json` every installed
218
- package ships next to its skill's `api.md` (written by `skills generate`): one line per method - route,
219
- `q | tx | doc | project | export`, the intent that matched, the package. Ranking, in order: how many words of the
220
- need the method's `@intent` tags hold, then its summary, then its name - one intent word beats any number
221
- of summary words; stop words dropped, word forms reduced to a light stem (`copied`, `copies`, `copying`
222
- → `copy`); ties put a dialecte's verb before core's, then sort by route.
223
- - `dialecte api find --source "<need>"` also searches the exported functions of the package you are in (the
224
- nearest `package.json` at or above the folder): every exported function declaration, arrow or function-expression
225
- `const` of its tracked and untracked-not-ignored `src/**/*.ts` files, tests left out, read from the syntax alone
226
- (a local `export { name }` counts, a re-export does not; an overload set is one function, at its first overload).
227
- A source row prints `<file>#<name> source <file>:<line>`, then the intent that matched, its summary or
228
- `(no summary)`. A function without `@intent` ranks on the words its summary and name hold together; at equal
229
- hits an indexed method comes first, and a function the package's `api.json` already lists is shown once, by its
230
- route. A file that does not parse is left out with a `note:` line. What each file holds is cached by its content
231
- hash in `dialecte-source-index.json` in the worktree's git folder, shared by the packages of the repository and
232
- rebuilt by another cli version (outside a git work tree, every file is read).
233
- `dialecte api show <file>#<name>` (`src/lib/git.ts#readGit`) prints one source function's signature, summary,
234
- intents and declaration, with or without `--source`; an unknown name in a file that was read names up to five of
235
- that file's functions, the closest first; an unknown file names the closest source paths, or the
236
- `api find --source` call that lists them.
237
- - `dialecte api show <path>` (`info.of`, `doc.query.info.of`, `tx.reference.applyUuidRemap`): signature as
238
- declared, summary, intents, other routes, where it is declared in its repository, and one call: the
239
- method's JSDoc `@example` when it is short and calls the method, else a call from the test next to it
240
- whose arguments a caller can copy (written-out values first; never a test case field, a fixture constant
241
- or a cast). No such call, no example.
242
- - `dialecte members <expression>` (`doc.query`, `doc.query.reference`, `tx.lifecycle.extract`): the
243
- IntelliSense walk on demand, from the live types of the package where it runs. In an app it reads the
244
- installed dialecte (a dependency built on `@dialecte/core` exporting `./<version>` with its `./<version>/test`
245
- entry: its namespace is its name capitalized, `Scl` from `@dialecte/scl/v2019C1`); with several, it lists them and
246
- `--package <name>` / `--version <v>` picks one. `--namespace <Name> --entry <module>` override.
247
- - `dialecte schema <Tag> [--under <Parent>] [--package <name>]`: parents, children in order with how often each
248
- may appear, attributes (required, identity, default, fixed, enumeration, pattern), text, xsi:type variants,
249
- the declared type and documentation - read through the readers of the core each installed dialecte depends on
250
- (how often a child may appear is core's `childOccurrences`). A tag declared several ways prints each declaration
251
- with the parents that hold it; `--under <Parent>` prints the one that parent holds (or those it holds, when it
252
- does not decide), and a tag that is not a child of that parent answers its parents (exit 1). With `--json` each
253
- element carries `declarations` and `resolved`, and when known `type`, `documentation`, `declaration` (the key
254
- of the declaration described, when the tag is declared several ways) and `ways` (when unresolved). A dialecte
255
- names the standard it implements in its `package.json`, `"dialecte": { "standard": "<public name>" }` (the
256
- usual public name, no part or clause); a value that is not a non-empty string skips the dialecte, naming
257
- `dialecte.standard`. An unknown tag
258
- answers the closest; a dialecte not built is reported as skipped.
259
- - `dialecte doctor`: installed `@dialecte/*` versions, the core API generation of each dialecte (read from
260
- the core it resolves; a dialecte on another core than your app's is a warning), whether the synced skills match node_modules (a skill missing; a copied skill of
261
- another version than the one installed - linked skills follow node_modules), local checkouts (siblings,
262
- `$DIALECTE_ROOT`); each warning with the one command that fixes it.
263
-
264
- - `dialecte models [--vendor <id>] [--json]`: the model each tier means for the vendor the project uses
265
- (`anthropic`, `openai`, `google`), one line per tier, the date the rows were checked and what each tier
266
- is for. Agents name a tier (`standard`) and ask this command which model that is. The vendor is the one
267
- `dialecte skills sync` remembered as `vendor` in `.dialecte-skills.json`, in every skill folder of the
268
- project. Sync detects it from the project (`.claude/`, `AGENTS.md` + `.codex/`, `.gemini/`; a folder holding
269
- only the skills a sync wrote is no evidence) and asks on a terminal when several agents, a multi-vendor host
270
- (Copilot, Cursor) or none are found. Without a terminal, a sync that cannot tell installs the skills without a vendor (`models` stays
271
- unset: the skills need none) and says how to set it: `--vendor <id>`, which also sets it without asking. When manifests disagree, `models` warns on stderr, naming them, and uses the
272
- most recently written; an unknown vendor id in a manifest is ignored with a warning. Exit 1 for an unknown
273
- `--vendor`, 2 when no vendor is known.
64
+ The lookups: [`api`](doc/commands/api.md), [`members`](doc/commands/members.md), [`schema`](doc/commands/schema.md), [`explain`](doc/commands/explain.md), [`doctor`](doc/commands/doctor.md), [`models`](doc/commands/models.md).
274
65
 
275
66
  Run outside a package (no `package.json`), each answers a usage error.
276
67
 
277
- ## The standard index
278
-
279
- `dialecte standard` indexes the standards you hold on your machine and answers from them, in slices of whole
280
- lines with their original line numbers. The cli ships no standard and never copies one into a repository.
281
-
282
- **Where the standards are.** `DIALECTE_STANDARD` names one root folder holding one folder per standard; the
283
- folder's name, lowercased, is the standard's id, and its top-level, non-hidden `.md` files are the standard
284
- (subfolders are ignored; a symlink to a folder or a file counts). A file's id is `<standard id>/<file name
285
- without .md>`, lowercased.
286
-
287
- ```
288
- $DIALECTE_STANDARD/
289
- <standard id>/
290
- <part>.md
291
- <amendment>.md
292
- <other standard id>/
293
- <part>.md
294
- ```
295
-
296
- Refused with exit 2, nothing built: `DIALECTE_STANDARD` not set, empty or naming a path that does not exist; a
297
- root that is a file, that holds `.md` files directly (they are named, with the expected layout) or that holds no
298
- standard folder; two folders,
299
- or two files of a folder, whose ids differ only by case (both named); a `--standard <id>` with no folder (the
300
- known ids named); the root, a standard folder or the cache inside a git work tree. A folder with no `.md` file
301
- is reported as `no indexable file` and skipped.
302
-
303
- **Where the index is.** In the cache only: `$XDG_CACHE_HOME/dialecte/standard/<standard id>/<manifest hash>/`
304
- (else `~/.cache/dialecte/...`), one folder per standard and per set of file contents (the manifest hash is the
305
- sha256 of the index format and each file's id and sha256). A folder is built into `<hash>.tmp-<pid>/` and renamed
306
- into place once complete: a file changed during the build aborts it (exit 1, the file named, nothing kept); a
307
- second builder reuses the first one's folder; a temporary folder left by a process that is gone is removed at the
308
- next build. A complete folder is reused, never rebuilt, unless `--rebuild` (the old folder is moved aside, the new
309
- one renamed in, then the old one removed: a reader never sees a half-removed index); the links to the vocabulary of the
310
- installed dialectes are a file of their own, written beside the rest when the selected dialectes change.
311
- Old folders are kept. While a build runs, a running line with its elapsed time goes to stderr on a terminal.
312
-
313
- **The vocabulary.** The tags, attributes and enumeration values of the dialectes installed where the command runs
314
- (every one, or the one `--package <name>` names) are exact names: case kept, never stemmed, then scored like a
315
- word (1 per clause or table, doubled in its heading or caption, weighted by the lines naming it). An attribute under three
316
- characters counts only as `@name`, `name=` or a table cell equal to it, an enumeration value under three
317
- characters only as a table cell equal to it; a name in lowercase letters only, from three characters, is searched
318
- as an ordinary word. The tags file is named by the hash of the selected dialectes' `name@version` list. `index`,
319
- `find` and `eval` print `vocabulary <name@version>[, ...]` (or `vocabulary none (no dialecte installed)`) as their
320
- first line, and `vocabulary: { packages }` in `--json`. A `--package` that is not installed answers exit 2 with
321
- the installed ones named.
322
-
323
- **Words.** Other words are searched by their stem: lowercased, the plural removed, then `-ied` and `-ying` to `-y`,
324
- a final `-ing` or `-ed` (with its doubled consonant) and a final `e` removed; common English, modal and question
325
- words are not searched. A word in capitals and digits with two capitals or more (an acronym) is kept from two
326
- characters, never split nor stemmed; its plural (the acronym and one lowercase `s`) is searched as the acronym.
327
-
328
- - `dialecte standard index [--standard <id>] [--package <name>] [--rebuild] [--json]`: builds or reuses the index of each standard
329
- (or of `--standard <id>` only), then per standard `<id> <n> files built|reused in <time> manifest <hash>`,
330
- per file its lines, quality verdict, noise share, headings kept over candidates, tables and definitions, and
331
- the lines repeated often enough to be a watermark (information only: nothing is dropped for being repeated).
332
- Exit 1 when no selected folder holds a `.md` file.
333
- - `dialecte standard find "<terms>" [--standard <id>] [--package <name>] [--about <Tag>] [--limit <n>] [--json]`:
334
- the slices that hold the terms, ranked over every selected standard (each slice names its file id): a header
335
- `<file id>:<from>-<to> <clause> <title> score <s>`, then the normalised text. A slice starts at the first hit
336
- of its clause's or table's densest run of terms (at most 60 lines holding the most distinct terms, weighted as
337
- in the score) and runs to the last hit, 60 lines at most; a table starts at its caption when that run ends
338
- within 60 lines of it. After the `--limit` (10)
339
- direct slices come the clauses and tables they refer to, marked `[linked]`. `--about <Tag>` adds a tag of the
340
- installed dialectes (an unknown one answers the closest; none installed is a usage error). Exit 1 when nothing
341
- matches.
342
- - `dialecte standard show <file id>:<from>-<to> [--json]`: the normalised text of the logical lines overlapping
343
- the range, each with its original lines. Exit 1 when the range holds only blank or dropped lines; 2 for a
344
- malformed range, an unknown file id (the known ones named), a start after its end or an end after the file's
345
- last line.
346
- - `dialecte standard eval <gold.jsonl> [--standard <id>] [--package <name>] [--json]`: recall at 5 and at 10 of `find` over a gold
347
- file you keep, one `{ "question": ..., "about"?: ..., "expected": [{ "file": "<file id>", "quote": ... }] }` per
348
- line (other fields are ignored). The expected quotes of an item are alternatives: the item is found at the best
349
- rank of any of them. A quote is matched in plain words: table pipes, `<br>` tags, `**`/`__` and a leading `#`
350
- run are left out on both sides, then the text is normalised and case is ignored. Each missed item names its
351
- closest quote and why (`ranked <r>`, `not found by find`, `not in the text`, `unknown file <id>`). Items with
352
- no expected quote are counted apart. Exit 1 when no item has one; 2 for a gold file that cannot be read or a
353
- malformed line (its number named).
354
- - `dialecte standard eval <gold.jsonl> --angles [...]`: the same recall, each question run through the `ask` ladder
355
- instead of `find` alone (kind `semantic`, no fact read or written, no ask kept, no event): find's own list for
356
- the whole question first and untouched, then at most 3 slices the angles found in clauses that list does not
357
- cover, then the linked slices. A question the ladder refuses (an `about` no dialecte declares, a tag of several
358
- dialectes without `--package`) scores find's own list. The answer adds `added +<n>` (`added` in `--json`): the
359
- items whose quote only the added slices hold. Run from a package (exit 2 outside one).
360
-
361
- `show`, `find` and `eval` build the index first when it is missing. Every verb answers exit 2 with how to set
362
- `DIALECTE_STANDARD` when no standard is configured.
363
-
364
- ## The facts ledger
365
-
366
- `dialecte facts` reads the facts an agent recorded when it answered a question about a dialecte or a standard,
367
- and retires the ones that no longer hold. A fact is a question (its words, its subject, its kind), its answer,
368
- where the answer comes from (`schema`, `dialecte`, `standard`, `person` or `outside`), the effort it took, the
369
- evidence and the sources it rests on. One question has one current fact; a better answer replaces it (an answer
370
- checked against the documents always replaces an unchecked one, whatever the efforts), and the replaced fact is
371
- kept, marked `superseded by F-<n>`.
372
-
373
- **Where the ledger is.** In your data folder only: `$XDG_DATA_HOME/dialecte/facts/` (else
374
- `$HOME/.local/share/dialecte/facts/`), one ledger per person, shared by every repository you work in. Each fact is a
375
- file `F-<n>.json` and its history `F-<n>.history.jsonl`, one line per event (`created`, `reused`, `stale`,
376
- `superseded`, `forgotten`, `rechecked`); `by-key/` holds one pointer per question to its current fact. Nothing is
377
- ever deleted: a fact file is written once, afterwards only its state, its `supersededBy` and its sources change,
378
- and its history only grows (a history line is at most 4,096 bytes: longer lists and strings in it are cut, and
379
- a line still too long has each list replaced by its length, `fromCount` for `from`; the line marked `cut`, the
380
- fact file always holding its sources whole). Every verb refuses (exit 2, nothing written) a ledger inside a git work tree, naming
381
- the folder, the work tree and the fix: set `XDG_DATA_HOME` to a folder outside the repository. Only the data
382
- folder counts, never the folder the command runs in.
383
-
384
- **States.** A fact's state is the state now, checked on every read:
385
-
386
- - `valid` - its sources still hold;
387
- - `stale` - a source moved since it was recorded: the files of the standard it quotes (any file changed, added or
388
- removed), or the definition of the dialecte it read. Written to the fact once, with a `stale` line holding why
389
- (the source that failed and the fix), which every later read shows;
390
- - `unverifiable` - a source cannot be compared now (no standard configured, its folder gone, the dialecte not
391
- installed). Shown only, never written;
392
- - `unchecked` - an answer from outside the documents; a person's answer given without them is `valid` and marked
393
- `unchecked` on its line;
394
- - `forgotten` - retired by `facts forget`.
395
-
396
- A person's fact is never checked. A fact file no question points to (a record a crash stopped) is an `orphan`; a
397
- file that is not readable JSON is `unreadable`. A read repairs what a crash or two writers at once left: the
398
- previous fact of a question gets its `supersededBy`, with a `superseded` line marked `repaired`.
399
-
400
- - `dialecte facts list [--about <Tag>] [--state <state>|all] [--json]`: one line per question, its current fact
401
- whatever its state: `<id> <state> <effort> <source> <question>` (the question cut). A `stale` fact (found by
402
- this read, or by an earlier one: the reason its `stale` line keeps) or one this read found `unverifiable` ends
403
- its line with `- <why>`: the source that failed and the fix (for example: set `DIALECTE_STANDARD`, the expected
404
- layout of a refused standard root, run from the package that installs the dialecte). `--state valid`, `stale`, `unverifiable`,
405
- `unchecked` or `forgotten`: the current facts in that state now; `--state orphan`: the fact files no question
406
- points to; `--state all`: every fact file, superseded, orphan and unreadable ones (with their path) included, a
407
- superseded fact's line holding `superseded by F-<n>` before its question:
408
- `<id> <state> <effort> <source> superseded by F-<n> <question>`. `--about <Tag>`: the facts whose subject
409
- holds that tag. `--json` answers `{ facts: [{ id, path, fact?, state, current, reason? }] }` (no `fact` for an
410
- unreadable file). An unknown state is
411
- a usage error naming the states. The schema sources are compared with the dialectes installed in the folder the
412
- command runs in; run from a folder with no `package.json`, they are `unverifiable`, never an error.
413
- - `dialecte facts show <id> [--json]`: the fact's question, answer, source, effort, state now (with `- <why>` when
414
- stale or unverifiable), sources and number of pieces of evidence, then its history in order; `--json` answers
415
- `{ fact, state, current, reason?, history }`.
416
- - `dialecte facts forget <id> --reason <text> [--json]`: marks the fact `forgotten` and appends a `forgotten` line
417
- holding the reason (cut at 200 characters, the line then marked `cut`); the file is kept. Forgetting it again says so and writes nothing.
418
- `--json` answers `{ id, state, already }`. No reason, or a blank one, is a usage error.
419
-
420
- `show` and `forget` answer exit 1 for an id with no fact (the closest ids named) or a fact file that is not
421
- readable JSON (its path named).
422
-
423
- ## Ask
424
-
425
- `dialecte ask "<question>" [--about [<Parent>/]<Tag>[@<attr>] | --code <code> | --method <path>] [--kind <kind>]
426
- [--decision] [--package <name>] [--effort low|medium|high] [--lot <id|folder>] [--limit <n>] [--no-facts]
427
- [--no-standard] [--person-only] [--json]` answers a question about the installed dialecte from the cheapest
428
- source that holds the answer, and never answers from anything else: past the dialecte's own files it hands the
429
- question on (to readers of the documents, or a person) instead of guessing.
430
-
431
- The question's subject is read from the names of the installed dialectes it holds (tags, attributes, catalogue
432
- codes, api methods: exact names, case kept; a name that is also an ordinary word counts only as `@name`, `name=`
433
- or through `--about`). `--about`, `--code` and `--method` name the subject instead; `--kind` forces the kind
434
- (`children`, `parents`, `required`, `values`, `default`, `fixed`, `type`, `variants`, `documentation`, `code`,
435
- `method`, `semantic`). A tag of several installed dialectes needs `--package` unless the folder is one of them.
436
-
437
- **The rungs**, in order; the first that answers ends the ask:
438
-
439
- - 0, a fact: the current fact of the same question in the facts ledger, reused when it is valid at the asked
440
- effort or above (a person's fact at any effort). A fact that does not answer (lower effort, stale,
441
- unverifiable, unchecked) is listed as a candidate, never the answer. `--no-facts` reads and records none.
442
- - 1, the definition: a structural question whose element resolves to one declaration (`--about <Parent>/<Tag>`
443
- for a tag declared several ways), answered from the dialecte's definition. `--decision` skips it as an
444
- answer and reads it as the boundary (below).
445
- - 2, the dialecte's files: a code answered by the one catalogue entry that explains it, a method by the api
446
- index entry whose intents hold every content word of the need (else the closest five listed).
447
- - 3, the documents: the slices of the standard for the question (find's own list, then the slices its angles
448
- add), handed to readers.
449
-
450
- A rung 1 or 2 answer is recorded as a fact at the ask's effort. A fact recorded from the definition is checked
451
- again when the definition changes: answering the same, it is kept with the new hash; else it is stale and a new
452
- fact replaces it.
453
-
454
- **The boundary (`--decision`).** The definition (the XSD) is what validates, so on a `--decision` ask it is the
455
- hard limit of what is valid, never the answer: it is read live (`boundary` in `--json`, `boundary: <answer>
456
- (definition)` in the text) when the question is structural and its element resolves to one declaration. A stored
457
- fact recorded from the definition is a candidate only; the answer comes from the prose inside the boundary (a
458
- standard or person fact, or the readers). The values of an attribute with no enumeration are open (any value of its
459
- type is valid): the prose values stand, no conflict. Prose naming what the definition rejects (a list item it does
460
- not hold, an enumeration value it does not list, another yes/no, another value) is answered within it: the list cut to the boundary's items, else the boundary's
461
- own answer; `conflict` in `--json` names the fact and what it named outside (`{ kind: 'standard-vs-xsd', fact,
462
- outside }`), the text adds `! conflict: the standard names <items> the XSD rejects; the XSD wins - fix the XSD and
463
- ask again`, and the ask still exits 0. Without `--decision` neither is read (`boundary` and `conflict` null).
464
-
465
- **The documents.** The `DIALECTE_STANDARD` folder whose id has the key of the dialecte's declared standard name
466
- (both lowercased, letters and digits only); every folder when the dialecte declares none. With none, the ask
467
- skips rung 3 and goes to outside readers (when the root holds other folders, a line on stderr names the
468
- declared name, its key and those folders).
469
- `--no-standard` is refused while documents are readable for the dialecte (outside readers run only when the
470
- documents cannot answer), and is the outside route without them. `--person-only` sends the ask to a person after
471
- rung 2. Once documents exist, each `unchecked` fact of the dialecte's standard is asked again, once: a new ask
472
- holding its question and `reask: <fact id>` (never its answer), and a `rechecked` line on the fact.
473
-
474
- **States and exit codes.** `answered` exit 0; `needs-person` exit 1 (next: `dialecte ask answer <id> ...`);
475
- `needs-readers` exit 3 (next: `dialecte ask pack <id>`, with `--outside` without documents); exit 2 for usage and
476
- refusals, nothing written: an unknown `--about` tag or attribute (the closest named), an attribute the element
477
- lacks, several dialectes without `--package`, two standard folders of one key, `--no-standard` with documents,
478
- an `--effort` other than the lot's, a `--lot` folder inside a repository.
479
-
480
- **The ask folder.** Each ask is a folder `A-<n>` holding `ask.json` (the `--json` object, versioned by its `schema`
481
- member, now `1`: the subject, kind, rung, state, answer, fact, source, boundary, conflict, candidates, methods,
482
- angles, slices, effort, next and what was read of the documents). With `--lot <id|folder>` (a store lot by index, name or folder, or a hand-over folder outside every
483
- repository) it is in `<lot folder>/asks/`; run in a lot's worktree, in that lot; else in
484
- `$XDG_STATE_HOME/dialecte/asks/`. An ask of a lot that reaches the documents or the outside route rewrites the
485
- lot's `standard.json` (`consulted`, a note listing every ask of the lot and its state). A lot's ask takes the
486
- lot's effort; elsewhere `--effort`, else `medium`.
487
-
488
- **Events.** `ask.parsed`, `ask.rung` (one per rung run, with its time), `ask.fact` and `ask.state` go to the
489
- lot's `events.jsonl`, else `$XDG_STATE_HOME/dialecte/asks/events.jsonl`; they hold the question's length and key
490
- hash, never its text, a quote or a slice's text; `ask.state` says `conflict: true|false`, never what
491
- conflicts. An event that cannot be written prints one line on stderr and
492
- never changes the exit code.
493
-
494
68
  ## MCP server
495
69
 
496
70
  The MCP server of the read-only lookups is its own package: [`@dialecte/mcp`](https://github.com/dialecte/mcp) (`npx @dialecte/mcp`). It builds on the pure answer functions this package exports at `@dialecte/cli/lookups`.
@@ -565,1788 +139,44 @@ The hand-over follows the profile:
565
139
  install, the linked dependencies), no record can answer the real run: the rehearsal says which part, and
566
140
  does not run contrib.
567
141
  - Both profiles get the card's `standard` line (see the hand-over card below) and
568
- `dialecte lot standard <id|folder> consulted <note> | not-consulted <reason>`.
142
+ `dialecte lot standard <id|folder> consulted <note> | not-consulted <reason> | outside <note>`.
569
143
 
570
144
  ## Contributing to a Dialecte package
571
145
 
572
- Twelve commands for whoever changes a Dialecte package, a person or an agent. Each answers the same way
146
+ Fourteen commands for whoever changes a Dialecte package, a person or an agent. Each answers the same way
573
147
  every time: exit 0 when green, 1 when a check fails, 2 on a usage error; `--json` where a program reads
574
148
  the answer.
575
149
 
576
- - `dialecte rules [<files...>] [--json]` checks the code rules on the syntax tree of the changed files
577
- (or the files given): exported types outside a `*.types.ts` file, module constants outside a
578
- `*.constants.ts` file, functions declared as `const`, an `await` inside an argument, standard
579
- citations and the package's `referencePatterns` (and, in a contributor, plan tags, acceptance criteria
580
- and ticket numbers: see [Profiles](#profiles)) are errors, and so is a test that takes the system's temporary folder itself as
581
- its root (`tmpdir()` handed to a call that lists or scans a folder, or given as `root` / `cwd` /
582
- `scratchRoot`...: other tests and processes share it; `mkdtempSync(join(tmpdir(), '<prefix>-'))`
583
- gives the test a folder of its own); positional parameters (beyond a leading `query` / `tx`, a
584
- symmetric pair aside) and abbreviated names are warnings. A file it cannot read (a file given that is not
585
- there, no read permission) or a script that does not parse is an error of that file (`unreadable-file`),
586
- never a silent skip. Without file arguments it reads the changed list a scoped gate step hands
587
- (`DIALECTE_GATE_CHANGED`: its text files still on disk; a list it cannot read is an error) and writes the
588
- gate's selection (the files it checked); outside a gate, the files changed against HEAD and the new ones,
589
- that result recorded in the worktree's git folder (`dialecte-rules.json`: when, HEAD, the state hash, the
590
- files, the errors and warnings), which `dialecte lot recap` reads; a run on named files records nothing.
591
- Quality rules, on implementation files (a test-shaped file is exempt):
592
- - `argument-mutation` (error): a function changes what a parameter refers to (a mutating method such as
593
- `.push` or `.add`, an assignment to a property, `delete`, `++`, `Object.assign` with it first); return the
594
- new value instead. Rebinding the parameter, a copy, a write through `query` / `tx`, a `reduce` accumulator
595
- are not flagged.
596
- - `query-in-loop` (error): a query read (a method of the API indexes' `q` entries, `perf` and writes aside)
597
- called on a query binding inside a loop or a loop callback (`map`, `forEach`, ...); read them in one query
598
- before the loop. A call through a `perf` segment (`doc.query.perf.getRecord()`) is never a query read. Without an API index the rule does not run.
599
- - `long-function` (warning): a function body over 60 lines that are neither blank nor comment-only; split it.
600
-
601
- Test-shape rules, on test-shaped files (a test file, a name ending `-fixtures.ts`, `.test-fixtures.ts` or
602
- `-cases.ts`, a file under the package's top-level `test/` folder):
603
- - `table-branch` (error): an act or a per-case callback branches on a field of its case; one table per
604
- behaviour.
605
- - `without-export-xml` (error): a `.withoutExport(` act reads exported XML; use `withExport` with
606
- `expectedQueries`.
607
- - `export-without-queries` (error): a case of a `.withExport(` table with no (or empty) `expectedQueries`
608
- and `unexpectedQueries`; give it one.
609
- - `fixture-builder` (warning): a function returns XML built with a substitution (a value inside the XML, or
610
- the element name itself: `` `<${tag} .../>` ``); write each fixture as inline XML.
611
- - `plan-tag` (error): a title, a table key or the file name carries a plan or round tag; say what the case
612
- checks.
613
-
614
- An opt-out silences one of these eight rules: `// dialecte-allow <rule>[, <rule>]: <reason>`, the reason at
615
- least 15 characters, on the finding's line or the line before it (for `argument-mutation` and
616
- `long-function`, also anywhere in the comments right before the function, its doc comment included). A
617
- malformed opt-out, a rule it cannot silence or a reason too short is an `invalid-allow` error; an opt-out
618
- that covers no finding is an `unused-allow` warning (never for a rule that did not run). `--json` (and the
619
- rules record) counts the findings the opt-outs silenced, per rule, in `allowed`. With the gate base (a
620
- scoped gate step), an error of these rules on a line the change did not add is a warning ending
621
- `(not added by this change)`; an empty-tree base (the release list, or no base branch found) knows no
622
- change, so every error of these rules is such a warning. A plain `rules` run (no gate base) keeps them
623
- errors. An API index that cannot be read (not JSON, a skill shipped twice) fails
624
- nothing: `query-in-loop` does not run and one line names the file and why. Not judged: an alias of a
625
- parameter (`const set = params.items; set.add(x)`), a read in a function the loop calls (`query-in-loop` is
626
- syntactic: it sees the reads written inside the loop), a table imported from a sibling file. `plan-tag`
627
- flags `round` or `step` followed by a number in a title (`step 2 of the import`): reword it, or opt out.
628
- `fixture-builder` reads `<` followed by a letter as XML, so a returned text with a `<word>` placeholder and a
629
- substitution (`` `usage: <name> ${value}` ``) is flagged too: opt out with the reason.
630
-
631
- - `dialecte gate [--fast | --full] [--base <ref>] [--no-reuse] [--declare <path>]... [--json]` runs the Definition of Done: `--fast` (default) `check`,
632
- `skills:check` and the tests of the changed files; `--full` adds `build` and the whole suite (the
633
- runner's defaults: every file in parallel); both default lists end with a scoped `rules` step
634
- (`dialecte rules` on the changed files, judged against the gate base); a step whose command starts with the word
635
- `dialecte` runs as the cli that runs the gate (its own node and entry file, never the package's
636
- `node_modules/.bin/dialecte`, so a package without the cli installed runs it too), its line ending
637
- `(dialecte <version>)`; then the steps derived from the package's scripts after its
638
- own (declared or default): `type-narrowing` (`npm run type-narrowing`, a check a publish workflow runs)
639
- when the package has that script and no step runs it; without the script, one line
640
- `skip type-narrowing no npm script "type-narrowing"` and no step of the record. The docs build and the type bench are contributor checks:
641
- `dialecte contrib` runs them (see [Profiles](#profiles)). Each step runs unfiltered, with
642
- `GIT_OPTIONAL_LOCKS=0` (a `git status` inside it never takes the index lock), and is judged on its exit
643
- code and on the counts it printed: a step exiting non-zero fails whatever it says, a test step that
644
- counts no test fails - except `--fast` on a change that touches no test (a doc edit): the changed-tests
645
- step passes with the note "no test file is affected by the change". A step running an npm script the package lacks
646
- is _not wired_, judged for the whole list before any step runs (every wiring problem shows at once, and a
647
- failed one leaves every other step unrun): a step of the default list (the package declares no list for the
648
- mode) fails `gate --full` and `--release` (`FAIL skills not wired (no npm script "skills:check")`, then the
649
- line `add the script, or opt out with dialecte.gate.skip: "dialecte": { "gate": { "skip": { "skills": "<reason>" } } }` under it;
650
- `dialecte contrib` names `"contrib"` there) and is skipped by `--fast` (`skip skills not wired (...)`, the gate stays green); a step the package declares
651
- fails in every mode, `--fast` included (`declared but not wired (no npm script "<x>")`). The fix is the
652
- script, the step removed from the list, or, for a default step, an opt-out with a reason (below). The
653
- hand-over card shows `✗ <step> not wired (no npm script; or dialecte.gate.skip)` for a full or release record
654
- (`dialecte.contrib.skip` for a contrib one) and `! <step> not
655
- wired (no npm script)` for a fast one, and `! <step> opted out: <reason>` for an opt-out (a warning). The
656
- `type-narrowing` step is derived from the package's scripts and is never unwired. A repository without
657
- package.json has no default list: the gate infers its steps from its files (`pyproject.toml` + `uv.lock` at
658
- the root: a `tests` step `uv run pytest` for fast and full, counted from pytest's summary line), and a root
659
- `dialecte.json` (`{ "schema": 1, "gate": { "fast": [...], "full": [...] } }`, the keys of package.json's
660
- `dialecte.gate` without `skip`) overrides it list by list (its refusals name the lists as package.json's
661
- `dialecte.gate.<list>`); with neither, the gate refuses naming both. A repository with a
662
- package.json never reads `dialecte.json`. A gate record written
663
- before this check is not reused for a package with an unwired or opted-out step (the key changes). While a hand-over
664
- holds the repository (`dialecte handover <lots.json>` wrote its lock), the gate runs only under the
665
- hand-over written for this repository - the script the lock names exists and the `lots.json` beside it
666
- names this repository, real paths compared - and says so in one line with the command that refreshes
667
- the hand-over once the gate is green (`dialecte handover <lots.json> --rehash`): an author re-gates
668
- after a late edit without touching the lock. It refuses under a hand-over of another repository, a
669
- script that is gone, a folder without a lots file, and while a real `handover run` of that folder is
670
- in progress (its `running.json` names a live process; that refusal names the marker file, in the
671
- hand-over folder, so a person can tell a pid reused by another process). A refusal names the script and the lock and
672
- says what to do: run the hand-over first (its last commit releases the lock), or hand the lock's path
673
- to the person who runs the repository, who decides. A run that reaches its steps records its result in the
674
- worktree's git folder, `dialecte-gate-fast.json` or `dialecte-gate-full.json`: when it ran, HEAD, the
675
- state hash and each step (the tdd step first) with its status, its counts and its note or reason, the
676
- tdd step with the cases of the change it judged (`cases`: label and status); a run refused at the hygiene records nothing. The state hash is that of the tree the
677
- worktree would commit (HEAD's tree with the changed and untracked files on top, the deleted ones
678
- removed, `.dialecte/` left out): committing the lots leaves it the same, any other edit changes it.
679
- The record also holds its `key`, what the run checked: `tree` (the git tree id the state hash is the
680
- sha256 of), `lockHash` (sha256 of `node_modules/.package-lock.json`, what npm installed; `none` without
681
- it), `commandHash` (sha256 of the steps' names and commands in order, and HEAD's commit when a step
682
- runs only the tests the change affects, which depend on the diff against HEAD; `--base` is no part of
683
- it: it reads the `tdd` step only) and `linked` (sha256 over the package's `file:` dependencies as node
684
- loads them - the folder `node_modules/<name>` links to, else the path package.json names - each file
685
- they publish, their package.json and the paths of its `files`, with its path, size and modification
686
- time; an exclusion (`!…`) is left out and a glob is walked from the folder before its wildcard, a
687
- superset of what npm packs; a dependency without package.json or `files` is taken whole;
688
- `node_modules` and `.git` are always left out). The key is taken before the steps and again after
689
- them: when they differ (a step edited a file, an install or a rebuilt dependency during the run) the
690
- record is written without a key, with the state hash of the tree the steps started on, and not stored;
691
- the gate says so in one line before its verdict (`"stored": false` with `--json`). A run whose steps
692
- ran is also stored by its tree in the repository's common git folder, `dialecte-checks/<tree>.json`
693
- (`git rev-parse --git-common-dir`), which every worktree of the repository reads (the newest record
694
- kept per mode and key). Before its steps, a gate looks there: a green record of the same mode and the
695
- same key answers instead of running them -
696
- `reused: gate --<mode> green on this tree at <time> (HEAD <sha>)`, the record's step lines, then
697
- `gate --<mode>: green (reused)` (`"reused": true` with `--json`) - and the worktree's record is
698
- written marked `reused` with the time and HEAD of the run it reuses. The hygiene and the `tdd` step
699
- run every time: they are about the worktree (what is staged, the receipts, `.dialecte/lot.json`, the
700
- base), not the tree, and a `tdd` step failing now is a failed gate. A record that failed, that ran no
701
- step, of another mode (`--fast` never answers `--full` nor the reverse) or written by an older cli
702
- (no key) is never reused; a stored entry of another shape is ignored. A test step that passed only on its
703
- serial rerun is green: it is reused with its `flaky in parallel` note. `--no-reuse` runs the steps
704
- whatever the store holds. The key leaves out the Node version and the environment (a path given
705
- through an environment variable); a `file:` dependency edited and restored to the same size within
706
- the same modification time is not seen either. `--full` and `--release` hold the machine awake while they
707
- run (on macOS a `caffeinate -i -w <the cli's pid>` started at their start, detached, ending with the cli;
708
- nothing on another system, nor when `caffeinate` is not on `PATH`, nor with `DIALECTE_KEEP_AWAKE=0`), and
709
- measure their wall and monotonic time: a run whose wall time passed its monotonic time by over 60 s spanned
710
- a sleep of the machine all the same, its record keeps `sleptMs`, and the hand-over card's gates print
711
- `! slept <duration> during gate --full` for a record of the tree it checks.
712
- - `dialecte gate --hook [--no-reuse]` runs in a commit hook: the test steps of `--full` (its steps counting
713
- tests), unless a green `--full` record of what is committed answers them. Its key is the one a `--full` run of
714
- that state stores - the tree, what npm installed, the `file:` dependencies, the full gate's command hash - with
715
- the tree taken from the index git hands the hook (`GIT_INDEX_FILE`, else the worktree's index), never from the
716
- working files: a merge commit and a partial commit check what they record. A green record of that key prints
717
- one line, `gate --hook: tests reused from gate --full green on tree <tree> at <time> (HEAD <sha>)`, and runs
718
- nothing; otherwise `gate --hook: no green gate --full of tree <tree> with this install: running the tests`, the
719
- test steps (rerun serially on a failure, as the gate does), then one vitest summary line of their summed counts (what the hand-over's hook reader counts),
720
- and `gate --hook: green` or `gate --hook: failed at <step>` (exit 1). It runs no hygiene and no tdd step,
721
- reads no hand-over hold (it runs inside `handover run`'s own commit) and records nothing: `handover run`
722
- records the hook. `--no-reuse` runs the tests whatever the store holds, and so does a hook whose git variables name another
723
- repository than its folder's (the cli ignores them, so what is committed is unknown); `--hook` with `--fast` or `--full` is
724
- refused (exit 2). Write it in the hook as an npm script (`"test:hook": "dialecte gate --hook"`), so the
725
- hand-over reads it as a test step of its own: its card line reads `reused by the hook` when the hook answered
726
- from a record. The cli's own hook runs `npm run check` (type-check, lint, format; no suite), `npm run
727
- test:hook`, then `npm run build`.
728
- - A running step looks running. Each `gate` step and `tdd`'s vitest run is announced before its work:
729
- off a terminal a start line `▶ <step>` (then a line every 30 s of silence and the result), on a
730
- terminal one spinner line `⠋ <step> - <what runs> <elapsed>` that the step's result line replaces (the
731
- gate's summary then leaves out the lines already shown; off a terminal and with `--json` it keeps them).
732
- A silent hook gets the waiting-for-input / watch-mode hint once, at 90 s of silence, on both. The
733
- `handover` card is as wide as the terminal's columns, else `$COLUMNS`, else 80: the box is exactly that
734
- wide and every line wraps inside it with a hanging indent under its text column, never into fewer
735
- than 20 columns of text: a hang that would leave less is reduced; a commit line whose columns
736
- (`<sha> <files> <+->`) leave its subject less puts the subject, and a merge lot's merge line, on their
737
- own rows under it, 2 columns in; a line kept to one row with `…` is wrapped whole when its cut would
738
- keep less; a word wider than the room after the hang (a long path) takes a row of its own, 2 columns
739
- in. Colour only on a
740
- terminal (and never with `NO_COLOR`); the `✓` `!` `✗` marks read the same without it. The command
741
- follows the box whole on one line, to copy: `cd <folder> && bash commit.sh`, or
742
- `node <this cli> handover run <folder>` when the repository's own cli does not answer
743
- `handover run --probe` within 60 s. "This cli" is the script that runs: when it is a temporary one
744
- (`npx` from the registry, `tsx` on the sources), install `@dialecte/cli` in the repository so the
745
- card names its own bin.
746
- - No runner hangs silently. Every child that `dialecte gate` (its steps), `tdd` (its vitest runs) and
747
- `handover run` (each commit and its hooks, `--rehearse` too) start runs in a process group of its own,
748
- with its stdin closed (a command that reads it, such as `grep` with no file, gets end-of-file at once),
749
- and under a stall watchdog. Any output, a part of a line included, counts as activity; so does CPU time
750
- gained by any process of the child's tree (its descendants and its process group, sampled with `ps`
751
- every 5 s, macOS and Linux). After 10 minutes with neither, the tree is printed one line per process
752
- (pid, state, CPU time, command), stopped (SIGTERM to the group and every pid, SIGKILL to what is left
753
- after 2 s) and the run ends only once its processes are gone, as `stalled`: the gate's step fails with
754
- `stalled: no output, no CPU for 10 m 0 s` and the tree in its tail, `tdd`'s run fails with the tree, a
755
- hand-over lot is not committed and its files are unstaged (waiting a few seconds for a stopped git's
756
- `index.lock`; when the lock stays, the run says the files are still staged, names the lock and says
757
- to hand its path to the person who runs the repository, who decides once no git runs in it). A
758
- `ps` that fails or times out gives no verdict on that sample; failing for the whole 10 minutes is a
759
- stall of its own. Ctrl-C, SIGTERM or SIGHUP received by the cli is passed on to every running child's group.
760
- A child that asks the terminal (a gpg or ssh passphrase prompt) runs in a background group: it
761
- stops (state `T`) and is reported as stalled.
762
- - `dialecte contrib [--no-reuse] [--json]` runs the contributor checks of a package whose profile is
763
- `contributor`, after `gate --full` and before `dialecte handover`, one line per row: `rules` on the files
764
- changed against HEAD (recorded as `dialecte rules` records it), judged against the gate base (the scoped
765
- gate step's: the base branch's merge-base with HEAD; a rehearsal's run against the last merge lot's tip, else
766
- the base the repository resolves at the lots file's HEAD): an error of a quality rule on a line the base already
767
- holds is a warning ending `(not added by this change)`. No base branch found: the base is the empty tree, which
768
- knows no change, so every quality error is that warning. No base, every error kept, only without a scoped gate
769
- step or with a `dialecte.baseBranch` that names no branch. Then the package's
770
- `dialecte.contrib.steps` (default: `docs`, `npm run doc:build` with the `generatedDocs` restored, and `type-bench`,
771
- `npm run type-bench:check`; `[]` keeps the built-in rows only) run as the gate runs its steps (a default
772
- step whose npm script is missing fails the run before any row, the built-in `rules` and `release` rows
773
- included, unless `dialecte.contrib.skip` opts it out with a reason; a declared one fails too), `type-narrowing` (`npm run type-narrowing`) when the package has that script and
774
- none of its steps runs it (without the script, one line `skip type-narrowing no npm script
775
- "type-narrowing"` before `release`, no row), `release` (no dependency named by a local folder), then `mutation` when the
776
- package declares a mutation scope (read from the mutation store now, never recorded). A package step a
777
- green `gate --full` record of this tree and install passed with the same name and command is not run
778
- again: its row says `reused from gate --full at <time>`. The run is recorded as `dialecte-gate-contrib.json`
779
- in the worktree's git folder and stored by tree like a gate record, its key holding HEAD too (the rules
780
- row reads the changed files against it); a green record of the same key answers the rows
781
- (`reused: contrib green on this tree at <time> (HEAD <sha>)`), `--no-reuse` runs them and every step a
782
- `gate --full` passed. Exit 0 green, 1 a row failed, 2 refused (a consumer, where nothing is written, or
783
- a value of package.json no command accepts). `--json`: `{ profile, rows: [{ name, status, detail }],
784
- reused?: { at, head } }`.
785
- - `dialecte tdd red|green|status [<test file> | <test file>::<case name>]... [--base <ref>] [--json]` makes
786
- the order of the work visible: tests written from the spec before any code, red for a real reason, then
787
- made green by an implementation that did not touch them. The ledger lives in the worktree's git folder,
788
- never in the tree. Runs use the package's own vitest (each project's run of a case is a case of its own),
789
- with snapshots never written
790
- (`--update=none`, CI): a snapshot test's snapshot is written by the test station before the red.
791
- - `red` runs every case of the changed test files (or of the files named). A case that fails on an
792
- assertion (a snapshot mismatch included), on a stub's error (a message starting with
793
- `not implemented`) or on an error existing code throws, inside an `expect(...)` a matcher completes,
794
- gets a red. Refused, each with its reason: a passing case that is new or changed ("it ran green: this
795
- test proves nothing yet"); a passing case with a receipt whose own test call changed; a passing case
796
- still waiting for its green whose test file, or test code it imports, changed since its red ("test
797
- code changed since its red and it passes"); a failure on a missing export, a type or syntax error, a
798
- timeout, a stub thrown at import or before the assertion; a file holding `.only` or `only: true`; a
799
- file whose run reports no case, `red` and `green` alike, with why the package's vitest configs (every
800
- `vitest*.config.*` and their `projects`, read as files) give: `ran no case: the file belongs to
801
- <config>, which the default config does not list (projects)`, `ran no case of the file` (the default
802
- config holds it: an empty describe, no test call; or a config cannot be fully read - an `include`,
803
- `exclude` or `projects` entry that is no string literal or inline object, such as an imported constant,
804
- a spread, a call or a glob of config files - and may hold it), `every case is skipped` (only `.skip` /
805
- `.todo` / `.skipIf(true)` cases; the gate, which only collects, maps each case the run reports to its
806
- test call, so a case a helper registers counts as run). A refused file is never frozen, and the gate's
807
- tdd step fails on it with the same reason. A file
808
- no vitest config includes (a Playwright spec, a type test) is no vitest test file: it leaves the
809
- selection with `outside <file> not a vitest test file (no vitest config includes it)`, is never
810
- refused nor frozen, and never fails the gate. A
811
- case the same as at the base is marked unchanged; a case the lot accepts is marked accepted, unless
812
- it is proven red then green at its current test call (an acceptance never overrides a proof: it goes
813
- the normal path, no accepted receipt, and the line adds `acceptance not needed (proven red → green): it
814
- can be removed from the lot file`); a green
815
- case whose test code changed around it is kept and flagged `test code changed around it` (the next
816
- step adding a case to a green file); a case never proven green (only unchanged, accepted or revised)
817
- is kept without a flag, and no receipt. A file with a refusal still records its other cases'
818
- receipts, the refusals kept as evidence; it is frozen when one of its cases is red (those need no re-red;
819
- the refused case stays unproven), else not frozen; the gate fails on it until no case of it is refused.
820
- - Two cases of one run sharing a file, a project and a name share one id, and a receipt names one case: every
821
- case of such a group is refused (`red` and `green`), whatever its state, with `2 cases share this id
822
- (lines 12, 12): <hint>` (a case without a location prints `?`). The hint is `rename one` for two plain
823
- calls; for a case of an `.each` / `.for` table (or under one) it says to spell each title in full:
824
- vitest cuts a `$` field of an each-title at its `truncateThreshold` and prints any array as `[ Array(n) ]`, so
825
- two rows can read the same; `truncateThreshold: 0` in the package's vitest config is the other fix. A member
826
- the run does not judge (skipped, filtered out by `-t`, not targeted by `green`) gets a `duplicate <case>
827
- <reason>` line and no receipt. The cases of the group stay out of the move matching, the rest of the file is
828
- judged as usual, and the exit is 1. `--json` holds `duplicates: [{ file, project, name, lines }]` (empty when
829
- none). The `gate`'s tdd step fails (`duplicate case ids in <n> file(s): <files>`) and the card's tdd section
830
- lists `✗ duplicate id <file>::<name> lines 12, 12` per group, so the hand-over is BLOCKED. A receipt
831
- recorded before under an id now shared never counts.
832
- - A red records the case (file, full name, project), the hashes of its test file, of its own test call
833
- and of the production files, the failing message and the time. It is flagged `rollback` at a
834
- production state the case, or the lot, had already left: a production file moved back from the
835
- newest content the lot reached to its content at the base or at an earlier receipt (the run prints
836
- one `rollback:` line naming the files). The ledger keeps, per base and per production state a receipt
837
- names, the content of each production file changed since that base. The receipts are walked in
838
- order: a green, or a receipt at a state moving nothing back, makes its state's contents the newest; a
839
- put back only reds, refusals or unchanged receipts saw stays put back and adds no content, so a
840
- later red there is flagged again, a restore is not, and a step a green proved (an experiment undone
841
- and kept) is the new newest. A green run taken at code put back still makes its state the newest;
842
- its receipts are flagged `rollback`, with the same line, only when a case the run proves had no
843
- green receipt before (of the same file, name, project and test call; a refused run is no green, an
844
- earlier green counts whatever its flags): a refactor that keeps proven cases green (drops a file the
845
- lot added, puts a file back to its content at the base) is not flagged, a green run proving a case
846
- for the first time there is. Content the refactor
847
- moved away stays reached: bringing it back later flags the reds and the first greens taken there.
848
- A state read at another
849
- base, a lot committed since, is not compared;
850
- `red after green` when the case's own last receipt is a green at the same production state.
851
- - The run freezes each test file without a refusal, and a changed helper, fixture or snapshot only when
852
- a case of a file depending on it went red, or was recorded revised, in that run: what it imports
853
- (relative, tsconfig `paths` or vite alias, barrels and re-exports followed through test code; a
854
- package name is a dependency, not test code), a changed file whose name its test code mentions, or
855
- the text of a production module its test code imports directly (a constant naming a fixture; one hop
856
- into production, never further, and the module itself is production), its own snapshot. Every
857
- dependency found by import is followed in turn, and one found by a name written with its folder
858
- (`fixtures/scan.ts`, a full path): it brings the files it imports (`import type` included). A bare
859
- file name (`index.ts`) may be another file: the changed file it names is a dependency, not followed. The
860
- `setupFiles` of the package's vite or vitest configs (test code no test imports) are a dependency of every
861
- test file, followed as an import: a red freezes a changed one, a `revised` entry naming it lets a red
862
- freeze it. A helper no red covers stays unfrozen, and the gate fails on it, unless a `revised` entry names it
863
- (below). A Vite import query or fragment (`./x.worker?worker&url`, `?raw`, `?url`, `?inline`, `#part`) is
864
- left out of the file the import names; a specifier starting with `#` is a subpath import. The files of
865
- the change an `import.meta.glob(...)` of its test code matches (a pattern relative to the file, `/` for
866
- the package root, or a vite alias; a negated `!pattern` leaves its files out and names none) are
867
- dependencies too, followed like an import. An import that looks local (`@/`, `~/`,
868
- `#`, a `paths` or alias prefix) and resolves nowhere refuses its file, naming the import as written.
869
- - A test-code file moved with its bytes as at the base (git's R100: a deleted path and a new one,
870
- added or untracked, holding the same blob) is no change: a moved test file's cases are `unchanged`
871
- with no receipt to hold, its old path lists no deleted case, a moved helper or fixture waits for no
872
- freeze. A move stays within one kind (a test file to a test file, other test code to other test code;
873
- an empty file never pairs): a test file renamed off (`a.test.ts.off`) lists its cases deleted, one
874
- renamed on is a new file. A move with an edit is a new file and a deleted one. A change that only
875
- deletes test files lists their cases `deleted` in the gate's `tdd` step.
876
- - Cases moved out of a test file (a file split in several, a case cut out into another file) keep the
877
- base's proof with no declaration. A case of a new or changed test file is `moved` when its test call,
878
- by tokens (those its case hash reads), under the same describe path, is in the base text of a test
879
- file the change deletes, or of a changed one that no longer holds that call under that path, and its
880
- own file's base did not hold it; a case of the same name and project matched in two files is moved
881
- from neither (`ambiguous <case> in <files>: moved from none of them`). A moved case is a case of the
882
- base: `tdd red` records it `unchanged` when it passes (and freezes the helpers its file depends on),
883
- and with no receipt yet `status`, the gate and the card read it `unchanged`. `status` and the gate's
884
- details print one line per source file, `moved <n> case(s) <old file> → <k> file(s)`, with
885
- ` · test code changed around them` when a target's code outside its test calls (imports, hooks, helpers,
886
- under the describe paths it keeps) differs from the source's base, read by the same tokens; the card's
887
- tdd section shows the line, and a deleted source is reported by it instead of as deleted. A case a
888
- helper registers (the call at its location is no test call: `checkRow(row)`) is `moved by name` when a
889
- test file the change deletes, or that registers fewer cases now, registered one case of the same name
890
- and project through a runner at the base:
891
- `moved by name <n> case(s) <old file> → <k> file(s) · runner changed: <base call> → <new call>`. Those
892
- base names come from one collect-only run of the base files (no test executes), paid only when a split
893
- is detected statically (a test file deleted, or a changed one whose base ran a registering statement
894
- outside its test calls, by tokens, that it no longer runs; a row added to a table is no split), in a
895
- scratch copy of the base tree outside the worktree removed after it, bounded
896
- at 5 minutes; `status` prints its duration (`base collect <n> file(s) <duration>`).
897
- - `green` runs the changed test files: each case needs a red receipt, its file, its test call and its
898
- test code as frozen, production changed since its red ("nothing in production changed since red"),
899
- and a pass.
900
- - `status` prints each case (red, green, unchanged, accepted, missing receipt, test edited after red,
901
- with its flags), one `skipped <case> <receipts>` line per case with receipts the read rule skips
902
- (below; the gate's details too), the test code changed outside `tdd red`, and the cases the change
903
- deletes. A test
904
- call of the base gone without a title (an `it(name, ...)` whose title is a variable: an edited call
905
- looks deleted) prints `deleted <file> a test call of the base is gone`; when a `gone` entry of
906
- `.dialecte/lot.json` names its file (a path or a glob), it prints
907
- `gone <file> a test call of the base is gone (<reason>)` instead, in the gate's details too. A titled
908
- test gone and a deleted test file stay `deleted`. A changed test file whose run reports no case prints
909
- `refused <file> <reason>` (the reasons of `red` above), one no vitest config includes `outside <file>
910
- not a vitest test file (no vitest config includes it)`. A ledger that cannot be read is refused with its
911
- path. `--json` answers the state: `cases`, `duplicates`, `unfrozen`, `findings`, `unlisted`, and, only
912
- when there are some, `zeroCases: [{ file, reason }]` (the refused files) and `notVitest: [<file>]` (the
913
- files out of the selection).
914
- - `status --flags` prints only the cases whose receipts carry a flag, with their flags.
915
- - `status --legend` prints the tdd terms of the hand-over card, each in two lines: what it means, and
916
- whether to look. It needs no package: it works from any folder.
917
- - The lot is the uncommitted work: the change is measured from HEAD, so the cases of lots already
918
- committed on the branch are not asked again. `--base <ref>` (`tdd` and `gate`) gives the
919
- whole-branch view; `gate --full` (and `--release`) measures the tdd step from the lot's base: the
920
- branch the lot was started on (the store lot's base, else the branch `worktree add` recorded it was cut
921
- from; a base given as a commit id stands for the resolved base branch), from where HEAD now leaves it,
922
- so a lot that merged or rebased onto its base's new commits is not asked for them. When that base is
923
- not found, is behind the cut, never held the cut (a stacked lot), was rewritten or has merged the lot's own commits, it measures from the
924
- worktree's cut and says why; a worktree with no recorded base measures from its cut, one not made by
925
- `worktree add` from where the branch left its base branch. The first details line of the gate's tdd step
926
- (none when the step is skipped) reads `tdd base: <short sha> (<source>)`, the source one of `--base`,
927
- `lot base <ref>`, `worktree from <ref>`, `base branch <b> (the lot's base is a commit)`, `worktree cut`,
928
- `base branch <b>`, `HEAD`; a fallback reads `tdd base: the worktree's cut (<why>)`, the why one of `no
929
- base branch recorded`, `<ref> not found`, `<ref> is behind the cut`, `<ref> does not hold the cut: a
930
- stacked lot` (the ref's reflog never reached the cut), `<ref> was rewritten: the cut <sha>
931
- is no ancestor of the merge-base <sha>`, `<ref> holds the lot's own commits`.
932
- - Test code is compared by the leaves of the parser's syntax tree, each file parsed by its extension
933
- (a `.ts` file is no TSX): whitespace, comments (except the ones a tool reads:
934
- `@vitest-environment`, `@jest-environment`, `@vite-ignore`), quote style, statement semicolons,
935
- trailing commas after an element and the order of import statements between side-effect imports
936
- are formatting (a formatter pass needs no new red); template literals count by their raw text; any
937
- other edit is a change. The receipts are a version-3 ledger: an older one is refused, to be moved
938
- aside. A repository without a commit is refused in one line.
939
- - A package whose test entry is production code declares it:
940
- `"dialecte": { "tdd": { "production": ["src/test"] } }`; the test files, fixtures, snapshots and
941
- `*.script.ts` under such a folder stay test code. `testCase.only ? it.only : it` is no focus marker.
942
- - A case edited at review after it was proven is declared in `.dialecte/lot.json`
943
- (`"revised": [{ "case": "<file>::<name>", "reason": "<why>" }]`). It needs an earlier receipt of
944
- the case (a red, an unchanged, an accepted one), not necessarily a red, or to be a case of the base:
945
- its file exists at the base, every title of its name written as a string now is written there too,
946
- and, when its own title is the literal title of an `it` / `test` call at the base or now, the base
947
- holds such a call with its describe path (a computed describe title, a `describe.each` /
948
- `describe.for` format, matches any; a `describe.skipIf` / `describe.runIf` suite counts by its
949
- title) and the file now no more of them (a test moved to another describe, or a string of that title
950
- removed elsewhere, is no proof); otherwise (a table row, a computed title) its own title is written
951
- as a string there and no more times now. A new case (a new file, a new title, a row added to a table)
952
- still needs a red; a case whose title the file computes and the base does not write is refused
953
- ("not provably a case of the base: accept it or prove it red"). The `case` may also be a file path or
954
- a glob over file paths (`scripts/**/*.test.ts`: `**` any folders, `*` and `?` within one), relative
955
- to the package root, without `::`: it applies to every case of the matching files, with one reason.
956
- A file or glob entry never covers a case whose last proof is a red still waiting for its green, and
957
- keeps the `red after green` flag of a case made red again; an exact entry covers both. An `accept`
958
- entry stays one exact case. The next `tdd red` records it as revised when it passes (a
959
- red when it fails) and freezes its file and the changed test code it depends on. A file or glob entry
960
- may also name a test helper (test code that is not a test file: a helper, a fixture, a constant beside
961
- the tests) edited at review while its dependent cases stay green: the next `tdd red` freezes it at its
962
- new hash and prints `revised <helper> <reason>`, when every changed test file depending on it
963
- is in the run and frozen by it with no case red (a refused file, a red still waiting for
964
- its green, or a changed dependent outside a targeted run leaves it unfrozen, named on an
965
- `unfrozen <helper>` line). A helper that no changed test file depends on (its dependents are all
966
- unchanged since the base) is frozen by any `tdd red` whatever its files, with the entry's reason. The new freeze makes the dependent
967
- cases' earlier green stale: `tdd green` proves them again. Without that red run the gate fails on the
968
- edit; `status` lists the revised cases, the gate and the hand-over card list the revisions (cases
969
- and helpers) with their reason, an entry (exact, file or glob) no revised case or helper used as a
970
- note. A `revised` entry covering a proven case nothing changed since its proof (same test call, test
971
- code as frozen) records nothing: the line reads `kept <case> proven before (<kind>) revision not
972
- needed (nothing changed since its proof): <reason>`, and the entry stays unused.
973
- - A receipt counts only while its declaration holds (the read rule of `tdd red`, `tdd green`,
974
- `tdd status`, the gate and the card): an `accepted` receipt whose `accept` entry the lot file no longer
975
- holds, or that a red then a green of the same test call precede, and a `revised` receipt no `revised`
976
- entry (exact, file or glob) covers any more, are skipped, and the case reads from its earlier proof (a
977
- case whose file was frozen again after its green owes a fresh `tdd green`). Nothing in the ledger is
978
- rewritten; the flags are read from every receipt. A skipped receipt is named:
979
- `skipped <case> 1 accepted receipt (no longer declared)`, or `(proven red → green before it)`.
980
- - What it cannot see: the receipts can be written by an agent with a shell; a deliberate throw in
981
- production looks like a stub; code written first, hidden, then a red taken at the base state, cannot
982
- be told from an honest red (at the first step the red's production is the base's). The flags and the
983
- refusals make the rest visible; the review reads the diff.
984
- - `dialecte new verb <namespace> <query|transaction> <name> [--version <v>]` writes a verb of a dialecte
985
- package in the house style: the function (query or transaction first, one params object), its
986
- `.types.ts`, a table-driven test with one red case (no `only`: `tdd red` refuses a focus marker; while
987
- iterating, run the case with `npx vitest run <file> -t "<case>"`), its barrel export and, for a new
988
- namespace, the namespace module and its registration. Its JSDoc summary and `@intent` start with
989
- `FILL:`, which `skills check` refuses until written; the command prints every placeholder left.
990
- - `dialecte handover write <lots.json> [--release] [--target <branch>] [--out <id|folder>] [--rehash] [--json]` (or `dialecte handover <lots.json>`) prepares the commit-by-lots
991
- hand-over a human runs. `--target <branch>` names the branch the hand-over must not be behind (default: the
992
- [base branch](#the-base-branch)); it is written as `target` in the lots file. A branch with no ref, local or on
993
- origin (`--target nope: no such branch, local or on origin`), a `--target` with no branch after it, or no base
994
- branch to default to, is refused (exit 2, nothing written). `--release` marks it a release hand-over (`"release": true` in the lots file): its card
995
- then holds a required `gate release` row, green only with a green `gate --release` record of the tree it commits.
996
- The lots file names the repository, the branch and HEAD expected, and the lots (paths, message):
997
-
998
- ```json
999
- {
1000
- "repository": "/path/to/the/repository",
1001
- "branch": "feat/names",
1002
- "head": "d4b1c04",
1003
- "gates": "the scl cases need DIALECTE_SCL_DIR: skipped here",
1004
- "lots": [
1005
- { "paths": ["src/names/"], "message": "feat(names): names stay unique among siblings" },
1006
- { "paths": ["CHANGELOG.md"], "message": "docs(changelog): unique names" }
1007
- ]
1008
- }
1009
- ```
1010
-
1011
- `gates` is optional free text, the caveats for the person about to run the hand-over: the cards printed
1012
- before a run (this one, a rehearsal's) show it as their notes; the card a real run prints after it has
1013
- none. The card reads the gates from their records.
1014
- It refuses (and writes nothing) when the branch or HEAD differ, `core.hooksPath` names a folder that
1015
- does not exist (git would skip every hook; it says how to restore it), something is staged, a changed
1016
- file is in no lot or in two, or a lot file (evals included) or message holds a standard citation, one
1017
- of the package's `referencePatterns`, or, in a contributor, a tag (see [Profiles](#profiles)). Otherwise it writes the hand-over folder - the lots file, the snapshot (`files.txt`,
1018
- `files.sha256`, `files.deleted`, and `lots.sha256`: the lots file as reviewed) and a one-line
1019
- `commit.sh` that runs
1020
- `npx --no-install @dialecte/cli handover run <folder>` (bash, also run with `sh`; when the repository
1021
- installs no cli that can, it says so in one line with the fix) - and prints the hand-over card, the
1022
- command with its absolute `cd` under it. The folder is the lots file's, or `--out <id|folder>`: a lot (its
1023
- index, full name, a path to its folder or `.dialecte/lot`) writes into the lot folder, any other word is a
1024
- folder; either way the folder is taken by its real path (a folder not made yet: the real path of its nearest
1025
- existing ancestor, then the rest) before anything is written, so `commit.sh`, the lock, the card, `--json`'s
1026
- `folder` and the registry all hold it. A word naming both an existing folder and a lot is the folder: the
1027
- card's output starts with the note saying so (`outNote` in `--json`). Refused (exit 2, nothing written), when the folder is a lot folder, in
1028
- this order: a damaged lot (`<name> is damaged (<reason>): ...`, naming `lot stop`), a simulated lot (`a simulated lot has no hand-over`), a `canceled` or `failed` lot, an open
1029
- question (`answer q<k> first: dialecte lot answer <full name> q<k> "<answer>" ...`), a lots file whose
1030
- repository is not the lot's worktree or whose branch is not the lot's (both named); and for any folder whose
1031
- registered hand-over is `committed` (`<name> is committed: a committed hand-over is never rewritten`). Every hand-over
1032
- written is registered in the repository's store, `<git common dir>/dialecte-handover/`: shared by every
1033
- worktree of the repository, kept when a worktree is removed, never in the working tree. The store holds
1034
- one entry per hand-over, `<name>.json` = `{ folder, branch, worktree, index, written, state }` (the folder's
1035
- absolute path, the lots file's branch and repository, the worktree's index when its folder is numbered
1036
- (`0171` for `.worktrees/0171-cli-x`, absent otherwise), when it was written, and its state as last
1037
- recorded: `pending` when written, `committed` by a real run that commits every lot, `abandoned` by
1038
- `handover abandon`); the folder stays where it was written. The name is `<yyyy-mm-dd>-<branch slug>[-<n>]` -
1039
- the local date, the branch with every run of characters outside `[A-Za-z0-9._-]` (the `/` included)
1040
- turned into one `-`, then `-2`, `-3`... when that name has an entry already. A folder registered already
1041
- (the same real path) keeps its name: `--rehash` updates its entry, never a second one, and never one
1042
- recorded `committed`. An entry is written whole (a reader sees the old entry or the new one; on a file
1043
- system without hard links a new entry is written exclusively instead) and stays writable, so an older cli
1044
- can still record its state. A rehearsal and `show` write no entry. `--json` answers the card as data: the verdict, `profile`,
1045
- `failedGates`, `otherTreeGates`, `declarations` (the entries to read), `gates` (the gate lines: name,
1046
- status, detail), `contrib` (a contributor's contrib rows, one per row: name, status, detail, and `stale`
1047
- or `source` - `rehearsal`, `from <commit>` - when they apply), `tdd` (the tdd lines as the text a person reads, no layout and no padding), `notes`, `name` (the
1048
- hand-over's registered name; absent for a folder with no entry), `worktree` (absolute), `index` (a
1049
- numbered worktree's), and each lot with
1050
- `pending` until it is committed. Edited a file after the review? `--rehash` (also after
1051
- editing `lots.json`). The repository stays held until every lot is committed: `dialecte gate` runs
1052
- only under this hand-over (see `gate`), and a hand-over of another folder is refused, naming the script
1053
- that holds the repository and its lock.
1054
-
1055
- - The hand-over card is what a person reads before running the hand-over, and again at its end. Its title
1056
- is `hand-over: <repository folder> <branch>`, with the worktree's index first from a numbered worktree
1057
- (`hand-over: 0171 cli feat/x`: the repository's own folder name, so the number is shown once). The commit
1058
- section ends with the `worktree` line: the worktree the lots are committed in, relative to the workspace
1059
- when it is inside it (`.worktrees/0171-cli-x`, `cli` for the main checkout), else its absolute path; both
1060
- compared by real path, so a side reached through a link (`/var` and `/private/var`) reads the same. Its
1061
- first line is the verdict: `READY` when no gate line failed and none ran on another tree, `BLOCKED` with
1062
- `<n> gates failed: <names>` and `gates ran on another tree: <names>`, `DONE` once a real run committed
1063
- every lot; then the lots, files and `+<added> −<removed>` (`all gates green` when nothing blocks), and
1064
- `<n> declarations to read (below)` on a second line. Its sections:
1065
- - `commit`: one line per lot - its sha, or `pending`; its files, lines added and removed, and subject. A
1066
- merge lot's line follows (`merge <branch> at <tip> · <n> conflicts · tree <sha>`, or
1067
- `tree not recorded: rehearse first`); a merge lot is sized from the tree it was trial-merged on to
1068
- the tree a rehearsal recorded, else says `size after rehearse`. Then `HEAD <sha>`, after a run
1069
- `HEAD <base> → <tip> · nothing pushed`.
1070
- - `gates`: one line per gate step from the gate records (the latest record of each step over `--fast`,
1071
- `--full` and the commit hook's record, a line of the hook's ending with `commit hook`:
1072
- `✓ test:run 1214/1214 · commit hook`; a gate record newer than the hook's replaces its lines whole,
1073
- since the hook names its own scripts, not the gate's steps; the other way round, a hook record of the
1074
- tree the hand-over commits, not dropped by a newer gate record of that tree, replaces the lines of
1075
- every gate record of another tree it answers - a step of the same name, or a step counting tests when
1076
- the hook counts tests: a merge hand-over rehearsed or committed reads the hook's lines of the merged
1077
- tree, the worktree's `tests` of its tree before the merge left out. No check leaves silently: a step
1078
- the hook did not run reads `! skills not run on the merged tree` (a warning, not of another tree), a
1079
- failed one stays `✗ ... (the tree changed since)`, and `tdd` stays the worktree's: on the DONE card of a
1080
- merge hand-over the tdd verdict is judged on the worktree's own lot tree (the tree its first merge lot
1081
- merged onto), current while the hook record of the merged tree stands, so no `gates ran on another tree`
1082
- for it), then, in a consumer, `mutation` when the package declares a mutation scope (below), then
1083
- `review` from the hand-over folder's findings ledger and `round-<n>/` snapshots (below), then `effort`
1084
- (below; none on a release hand-over), then `late fixes` on a card still to run (below), then `standard`. `✓`
1085
- passed; `!` to look at (a step not run here, with its reason, or not run after a failure; no
1086
- findings ledger, or one holding no row yet: `no findings recorded`; only nits open); `✗` failed (a
1087
- failed step, a blocking or should-fix finding open, no independent review after the last round, `gate
1088
- never run on this tree` when there is no record).
1089
- - `review`: the review rounds are the `round-<n>/` snapshots only, against the cap of the folder's effort
1090
- and risk class (the rounds of the higher of the two, below `lot risk`), then the independent
1091
- review, then the open findings: `✓ review 2 review rounds of 2 · independent review approve · approved`.
1092
- The independent review must come after the last snapshot: an `independent-reviewer` station end with a
1093
- verdict strictly after the snapshot's time (`round-<n>.state`'s `at`, else `round-<n>.base`'s mtime; a
1094
- tie is not after), shown `independent review <verdict>`; or, for a folder without step events (no
1095
- `events.jsonl`, or events saying the worktree's cli writes none), a ledger row of a round above it,
1096
- shown `independent review: round 3 in the ledger` (`rounds 3-4`). None: `✗ review no independent
1097
- review after round <n>`, the card BLOCKED. Beyond the cap each round names its first go-ahead row
1098
- (`3 review rounds (cap 1, round 2 by <who>, round 3 by <who>)`), a round without one gives `! review
1099
- 3 review rounds, cap 2, no go-ahead recorded` (a warning); no effort recorded: `2 review rounds (no
1100
- effort recorded)`. A folder with step events and no review round snapshot reads `✗ review no review
1101
- round snapshot: dialecte lot snapshot <lot> --round 1` (the ledger never stands in there). A folder with
1102
- no snapshot, no ledger row and no independent end, a folder without step events and with no snapshot
1103
- (its ledger rows claim no independent review), and a release hand-over keep the ledger-only line
1104
- (`<n> rounds · approved · findings ledger`).
1105
- - `effort`: the effort against the risk class, from the folder's `risk.jsonl`: `✓ effort high · risk class
1106
- high at handover write (src/cleanup.ts:2: rmSync) · 2 review rounds of 3` (`risk class unknown` with no
1107
- derived line); an effort below the class `! effort medium below risk class high (by <who>: <reason>)`, or
1108
- `(no go-ahead recorded)` when no reason is recorded (an effort line without one, or the lot's own effort), a
1109
- warning that never changes the verdict; `no effort recorded` without one.
1110
- - `late fixes`: a change of the tree after the last snapshot (the worktree's state hash against
1111
- `round-<n>.state`'s) reads `! late fixes unverified since round <n> (<k> files): dialecte lot verify
1112
- <lot> --by <who> --note <text>`, a `lot verify` of the current state `✓ late fixes verified by <who>:
1113
- <note>`, a last snapshot without `.state` (an older cli) `! late fixes not checked (round <n> has no
1114
- state)`; the last snapshot's tree, or no snapshot, prints no line. A warning only: `handover run`'s
1115
- `verify` guard refuses. The records read are the worktree's last runs and the store's records of the tree the
1116
- hand-over commits - the worktree's tree, or for a hand-over holding a merge lot the tree its last lot
1117
- leaves (the trial merge with its resolutions) - the newest record of each step winning; a tdd step
1118
- another worktree recorded is left out (its verdict is that worktree's), and a stored record counts
1119
- only when it ran against what is installed here now (the same `node_modules` and `file:`
1120
- dependencies) with the command of its mode now. A line from a record made at a commit outside the
1121
- history of HEAD ends `· from <sha>` (the branch commit's hook record read for a merge on main; a
1122
- record of an earlier commit of this line carries none), a rehearsal's record `· rehearsal`. A record
1123
- of another tree than the one checked ends with `(the tree changed since)`: its line turns `!` and
1124
- blocks the hand-over; a failed step stays `✗`. The `tdd` line is the worktree's: it is stale only when
1125
- its record is of another tree than the worktree's now, never because the tree checked is a merge's;
1126
- once a merge hand-over is committed, its card keeps `! tdd ... (the tree changed since)` and `gates ran
1127
- on another tree: tdd`, since the worktree took the merge after its tdd verdict.
1128
- The `mutation` line is what the package still owes its mutation runs, read from the mutation store when
1129
- the card is written. `✗` (blocks): `new` survivors or died runs of the package, whatever their lot
1130
- (`2 new survivors · 1 died run: dialecte mutants status`); a run of the branch still running when the
1131
- hand-over merges a branch (`run <id> still running (pid <pid>): the merge waits for it`, a run of a
1132
- merged branch too) or when the lot's mutation switch is `gate` (`...: a gate lot waits for it`); a gate
1133
- lot with no run of its branch (or a merged one) reported on the tree the hand-over commits
1134
- (`gate lot: run dialecte mutants run on this tree first`); an invalid `dialecte.mutation` or lot switch,
1135
- with its reason. `!` (does not block): a run of the branch still running on a plain hand-over
1136
- (`...: its survivors are not in yet`). Otherwise `✓ mutation nothing pending`. To unblock: kill each
1137
- survivor with a test, record its reason
1138
- (`dialecte mutants record --key <key> --family <family> --reason <why>`), or
1139
- `dialecte mutants schedule <follow-up> <key>`; rerun a died run or `dialecte mutants abandon <run id>`;
1140
- wait for a running run; run `dialecte mutants run` on the tree for a gate lot. The switch is the
1141
- hand-over folder's `lot.json` when it holds one, else `.dialecte/lot.json`.
1142
- The `standard` line says whether the standard was consulted. A standard is configured when
1143
- `DIALECTE_STANDARD` names a file or folder that exists (the environment only: no committed file names
1144
- it). `✓ standard consulted · <note>` when one is configured and the station recorded a consultation;
1145
- `✗ standard configured, not consulted: dialecte lot standard <folder> consulted <note>` (blocks) when
1146
- one is configured and none is recorded; `! standard not consulted: none configured (DIALECTE_STANDARD)`
1147
- otherwise, with the recorded not-consulted reason when there is one: a warning that never blocks. A DONE card
1148
- (committed) shows the state recorded on the lot, never one read from the shell that ran the hand-over:
1149
- `✓ standard consulted · <note>`, `! standard not consulted · <reason>`, or
1150
- `! standard not consulted: none recorded on the lot`. The station records it
1151
- with `dialecte lot standard <id|folder> consulted <note>` or `not-consulted <reason>` (the card's line
1152
- names the hand-over's folder).
1153
- - `contrib` (a contributor's): the rows of the `dialecte contrib` record of the tree the hand-over commits,
1154
- read as gate lines (`rules` with its errors and warnings, the package's steps, `release`), then the live
1155
- `mutation` row. A stored record counts when its key is the one the `contrib` guard asks for: a run at
1156
- the lots file's HEAD on that tree, against what is installed now, with the package's contrib rows. Else
1157
- the worktree's last contrib record, each row stale and saying what changed: `(the tree changed since)`,
1158
- `(HEAD moved since: run dialecte contrib again)`, or `(the install or the contrib rows changed since)`;
1159
- else `✗ contrib never run: dialecte contrib`. Every row green prints one line naming the rows, with the
1160
- record's source; any other row expands the section to one line per row. A failed or stale row counts
1161
- with the failed gates and the gates of another tree.
1162
- - `tdd`: the lot's exemption; only the cases of the change count, those the gate's tdd step listed on
1163
- this tree (a retitled or removed case's receipts are not counted under the old title); without a gate
1164
- record of this tree that lists them, one line `counts from the last gate: run the gate on this tree`
1165
- replaces the counts, groups, entries and flags; each case counted once by the status the gate gave
1166
- it (red then green as proven, kept when its last receipt is a kept after a green; accepted and
1167
- revised only in their groups)
1168
- (`<n> proven red → green · <m> unchanged`, and `· <k> kept` when any); the accepted cases: a head
1169
- line `<n> accepted`, then one row per reason of the lot file (`<count> <reason>`, the largest group
1170
- first, a tie in the lot file's order, each reason wrapped under itself); the accepted and revised receipts
1171
- of earlier lots (cases outside the change), which the lot file no longer names, on one line
1172
- (`earlier lots: 410 accepted, 12 revised (not in the lot file)`); then
1173
- `<n> revised · <m> gone · <k> unused · <j> skipped` with `to read ↓` at its right edge and one entry each: a revised case `<file> › <title>` (named by the lot file exactly, or by a file or glob entry)
1174
- with its reason under it, a helper a red run froze for a `revised` entry as `revised <helper>` with its
1175
- reason under it, a `gone` entry with its reason (whether one covers a finding is the gate's
1176
- to say), an `accept` or `revised` entry no case used, a case of the change whose receipts the read
1177
- rule skips (`skipped <file> › <title>: 1 accepted receipt (no longer declared)`). Then one line per kind of flag with its count of
1178
- cases (`dialecte tdd status --flags` lists them); cases whose only flag is `test code changed around it`
1179
- and whose receipts are otherwise only unchanged are counted apart (a case flagged rollback or red after
1180
- green never is), as
1181
- `helper code changed near unchanged cases (noise)`.
1182
- - `notes`: the lots file's `gates` text, as written; only on the cards printed before a run (the
1183
- written card, a rehearsal's), never on the card after a real run.
1184
-
1185
- Its closing rule names the hand-over, so a part of the card copied alone still says which one it is:
1186
- `dialecte handover show <id> · run <id> · --legend · details: dialecte tdd status`, `<id>` the
1187
- hand-over's registered name, or its folder's absolute path when it has no entry (a folder written by an
1188
- earlier cli; in a box too narrow for it, that
1189
- text is printed inside, above a plain closing rule) - on the written card, `show`'s, a run's and a
1190
- rehearsal's. The command stays under the box until every lot is committed. `dialecte handover --legend` prints every term the card can
1191
- print, each in two lines: what it means, and whether to look.
1192
-
1193
- - `dialecte handover run <folder>` (and `--rehearse`) holds the machine awake while it runs, as `gate --full`
1194
- does, and writes `last-run.json` in the hand-over folder when it ends (before the card of a real run):
1195
- `sleptMs` when its wall time passed its monotonic time by over 60 s; the DONE card then prints
1196
- `! slept <duration> during handover run` in its gates.
1197
- - A hand-over written behind its target branch is not run. The card (READY or BLOCKED, `handover show <one>`)
1198
- prints `! main moved: merge main first (3 commit(s) on main, now 1a2b3c4d)` under its verdict, which reads
1199
- BLOCKED (`--json`: `targetMoved: { branch, ref, tip, behind }`). The target is held when its tip is an
1200
- ancestor of the lots file's HEAD or of a merge lot's tip. When some lots are committed already the line adds
1201
- `: write a new hand-over on the current HEAD with a merge lot of main`. A hand-over onto the target itself, a
1202
- committed one and an abandoned one are not judged; a lots file written before `target` existed is judged
1203
- against the base branch; a `target` that names no ref gives a `!` line with the refusal and BLOCKED.
1204
- - The card also lists the processes working in the worktree (`handover show <one>`, READY or BLOCKED; `lot
1205
- result`, the run picker and `handover list` never look): `✗ processes 2 left running in the worktree: 4123 node
1206
- …vitest --watch, 4177 npm run dev (stop them: kill 4123 4177)` blocks, `! processes open on the worktree:
1207
- code, zsh` and `! processes not known (<why>)` warn (`--json`: `processes: { leftBehind, tools, unknown? }`).
1208
- The run itself, its shell or agent, what it started and every process of its own process group (the other
1209
- commands of its pipeline, such as a `| grep` after it) are never listed: a leftover started in the same process
1210
- group as the cli (the same non-interactive shell command) therefore counts as the run's own. A process with a terminal, one
1211
- whose command (or an ancestor's) is a known editor or the one `git config dialecte.editor` names, and one
1212
- named in `git config dialecte.personProcesses` (a comma list of command names, never committed) is one of the
1213
- person's tools; every other process is left behind.
1214
- - `dialecte handover run <folder>` is what `commit.sh` runs. Three of its guards, `target` (the target branch's tip is held, as above),
1215
- `processes` (read at run time, never from the card: a process left behind, or a list that cannot be read,
1216
- refuses; tools only pass with `!`) and `verify` (late fixes nobody verified: `✗ verify late fixes
1217
- unverified since round <n>`; `! verify late fixes not checked (round <n> has no state)` never refuses;
1218
- `✓ verify no late fixes`, or `verified by <who>: <note>`), come after the merges guard. Each refusal
1219
- exits 2 with nothing committed, where every other guard exits 1; `--rehearse` prints `!` for each and goes
1220
- on. The merges guard's note for a merge lot of the target that moved reads `lot <n>: merges main at <sha>; main
1221
- is now <sha> (see target)`. The install guard runs at each lot instead, once its files are staged (after the
1222
- lock sync below): `node_modules` read against the lock the commit holds, the index's `package-lock.json`. A
1223
- package at another version, missing or a link elsewhere, a lock that cannot be read or a check that cannot be
1224
- made refuses the lot (`✗ lot <n> not committed: node_modules do not match package-lock.json: run npm ci in
1225
- <worktree>`, the packages under it; when the working lock is a later lot's, `... the package-lock.json lot <n>
1226
- commits (a later lot changes it): run npm ci with that lock, or commit the lock change first`) with exit 2, under `--rehearse` too: no `!` there, a rehearsal checks its
1227
- clone's `node_modules`. No lock in the index: nothing checked. Each check replaces `install.json` in the
1228
- hand-over folder (`{ at, lock, working, ok, mismatched }`, `laterLock: true` for a later-lot refusal); the card shows it as its `install` line (`✓ install
1229
- node_modules match package-lock.json (<hash>)`, or `✗` with the count, which blocks a card still to run) while
1230
- the worktree's `package-lock.json` is the one the check saw (`working`), else no line. Each guard prints one line with its result
1231
- and its time (`✓ snapshot 110 file(s) 0.4 s`): repository, the lots file as reviewed, hooks
1232
- folder, branch, HEAD, empty index, the files against the snapshot, deleted files, files outside the
1233
- lots, references (citations, declared patterns, and the tags of a contributor), `contrib` in a contributor
1234
- (a green `dialecte contrib` record of the tree the lots leave, at the lots file's HEAD, against what is
1235
- installed now; a rehearsal never stops there), and last `mutation`: the card's `mutation` verdict computed again when the
1236
- guard runs (never taken from the card), so a run that reported a survivor, or died, after the card was
1237
- written refuses the run with exit 1 and nothing committed (`✗ mutation <detail>`, each survivor and died
1238
- run indented under it, then what to do with each); a run still running on a plain hand-over passes with
1239
- its warning; `✓ mutation no mutation scope declared` for a package without one. A rehearsal runs the
1240
- same guard. When the staged files are exactly the next lot's (a run stopped after
1241
- staging it), the index guard prints the command that unstages them, with its `cd`.
1242
- Then each lot announced before its work: off a terminal `▶ lot n/N` with its files and subject, and a
1243
- line every 30 s in which nothing of the lot was shown (`… <lot> running 2 m 10 s`: hook lines the view
1244
- leaves out do not count); on a terminal one spinner line naming the lot,
1245
- what runs and the time. The commit's hook output is read as steps, from npm's script headers: a script
1246
- that runs others (`npm run`, `run-p`, `run-s`, `npm-run-all`) is their parent, and the lines of the
1247
- scripts a parent runs in parallel stay the parent's. While the hook runs, only the current step and the
1248
- warning and error lines show (lint, format, type-check and build warnings and errors, failing tests),
1249
- each labelled by the step that printed it (`[lint:check] <line>`): on a terminal the step with its
1250
- elapsed time and those lines live under the spinner, off one `│ ▶ <step>` per step and those lines
1251
- behind `│`. A test step (a `test` segment in its name: `test`, `test:run`, `unit:test`; or a test
1252
- runner on its command line: `vitest`, `jest`, `node --test`) shows its failing tests and failed scripts
1253
- only: the warnings its tests print are theirs, not the repository's. A line its step printed already
1254
- (the same text: Vite's `configLoader` notice, 2-3 times per build) is not a new line: on a terminal
1255
- the first one carries the count, `<line> (×3)`, updated in place; off a terminal (a log) a line is
1256
- written as it is read, its identical repeats right after it are counted, and when that run of repeats
1257
- ends (another warning or error line, the next step, the hook's end) a run of two or more is written
1258
- again as `<line> (×<n>)`. Lines of different steps never merge. Every byte goes to the hook's full
1259
- log as it comes. After a passing hook, one summary line
1260
- (`check ✓ · test:run ✓ 1214 · build ✓ · 1 lint warning in lint:check`: the scripts the hook runs, a
1261
- script they run only when it printed counts or failed; the warnings counted per step and kind, in the
1262
- order first printed, each distinct line once: the same text printed again in its step counts once),
1263
- the labelled warning lines (each once, where it was first printed, with its step's total as
1264
- `(×<n>)` from 2) and `full log: <path>`; after a failing hook, the
1265
- summary with `✗`, the labelled error lines not among the failing step's last 30 lines (each once, with
1266
- its count), those 30 lines
1267
- and the log's path. A hook that ended (passed or failed; not one stopped as stalled) is recorded in
1268
- the git folder of the repository it committed in (`dialecte-gate-hook.json`, mode `hook`): HEAD after
1269
- it (the new commit, or the base when it failed), the state hash of the tree before the commit and the
1270
- steps its summary names with their status and counts; the card reads it with the gate records, so a
1271
- lot committed where no `dialecte gate` ran still shows its gates, until a newer gate record replaces
1272
- it. The record holds its key too (the tree the hook ran on, what npm installed, the `file:` dependencies,
1273
- and for `commandHash` the hook files git runs: husky's `.husky/<hook>` scripts, else the hooks folder's
1274
- executable files) and goes to the repository's store of records by tree. A rehearsal writes it in its
1275
- scratch clone's git folder and in the repository's store, marked `origin: "rehearsal"`, never in the
1276
- repository's own `dialecte-gate-hook.json`. A hook that prints nothing gets `hook ✓` (or
1277
- `hook ✗`) and the log's path; a repository with no commit hook prints none of it (in husky's `.husky/_`,
1278
- which holds a wrapper for every hook name, a hook counts only when its script exists in `.husky/`). Then the commit with
1279
- its stat; the total time and the card at the end. A lot whose `git add` or commit fails is unstaged again: once the cause is fixed, the same command
1280
- finds the lots already committed on top of the recorded HEAD (same message, same paths, the bytes of the
1281
- reviewed snapshot `files.sha256`, not the working tree) and resumes at the next one; anything else on top
1282
- of HEAD is refused with what was found. When every lot is committed, the `head` line says the hand-over is
1283
- already committed and the guards after it (they read the working tree, which later work may change) are
1284
- not run: the run exits 0. It never
1285
- pushes. `--rehearse` first decides, per lot and before any clone, whether rehearsing it can find
1286
- something new, and prints one line per lot: `lot <n>/<N> reused <reason>` or
1287
- `lot <n>/<N> rehearse <reason>`. A plain lot is reused when the store holds a green `gate --full` of
1288
- the tree its commit will hold (HEAD with every lot up to it on top) with the key of now - the same
1289
- `node_modules`, `file:` dependencies and `--full` steps - the lot does not change `package-lock.json`,
1290
- and the commit hook stages no files of its own (its text names `git add`, `git stage`, `lint-staged` or
1291
- `git update-index`): `green gate --full on tree <tree>`. A merge lot is reused when the tree it leaves
1292
- (its trial merge with its resolutions) is its tip's tree and a green record of that tree - the branch
1293
- commit's hook record or a `gate --full`, with the key of now - is in the store, under the same
1294
- conditions: `green hook record of the tip's tree <tree>`. Otherwise the line says the first reason that
1295
- holds: `no green gate --full on tree <tree>`, `the lot changes package-lock.json`,
1296
- `the hook stages files (<match>)`, `node_modules changed since the record`,
1297
- `a linked dependency changed since the record`,
1298
- `<branch> moved: the merge leaves tree <tree>, the tip holds <tree>` (`<branch>` the one the hand-over
1299
- commits on: `main moved: ...`), `no green record of the tip's tree <tree>`; `--rehearse --full`
1300
- rehearses every lot (`--full`). The decisions go to `rehearsal.json` in the hand-over folder
1301
- (when, and per lot its tree, `reused` or `rehearsed`, the reason and the record reused: mode, time,
1302
- HEAD, and `contrib: "run"` on a contributor's last lot whose tree has no green contrib record). When every
1303
- lot is reused and no contrib run is needed, no clone is made: the guards, a reused merge's `tree <sha>`,
1304
- then `rehearsal skipped: every lot's tree has a green record` and the card. Otherwise the clone is made
1305
- (`▶ rehearsal contrib` then runs `dialecte contrib` in it at the lots file's HEAD on the tree the lots
1306
- leave, before any commit, its rules row judged against the last merge lot's tip (only the last one: the lines
1307
- an earlier merge of another branch brought in count as added), so only the lines the lots add can fail it;
1308
- without a merge lot against the base the repository resolves at the lots file's HEAD, as `dialecte contrib`
1309
- there would, never the clone's own base branch; its record going to the repository's store as a rehearsal's; the clone is put
1310
- back after it, the files the run left removed) and
1311
- the reused lots are committed in it with `--no-verify` (their hook skipped, in the clone only), the
1312
- others with their hook. A real run (no `--rehearse`) runs every commit's hook, whatever the store holds.
1313
- The rehearsal clone (`▶ rehearsal clone`) warns naming the untracked files outside
1314
- `.gitignore` and `.git/info/exclude` a hook could read (they are not in the clone), and runs the lots in a scratch clone that looks like your tree - the repository at
1315
- HEAD, your working tree on top, the hooks folder, a copy-on-write copy of `node_modules` - so the hooks
1316
- run as they will for real. The clone sits in a rehearsal folder under a short root, `/tmp` on macOS
1317
- and Linux (the system's temporary folder on Windows):
1318
- `/tmp/dialecte-rehearse-<random>/<repository folder name>`, so a tool's socket under the hook's
1319
- temporary folder stays within the system's path limit; the hook runs with `TMPDIR` set to a folder
1320
- inside the rehearsal folder. Beside the clone, a link per relative `file:` / `link:` dependency of the
1321
- repository's package.json that leaves the repository, to the folder the same path reaches from the
1322
- repository (`file:../core`: `<rehearsal folder>/core` -> the repository's `../core`), so the clone
1323
- resolves it as the checkout does; one line names the links, and a path that leaves the rehearsal
1324
- folder too, or whose target is missing, is not linked (a line says why). In a workspace (the
1325
- repository's parent holds `.worktrees/`) the clone stays fresh but its `node_modules` is taken from the
1326
- pool when an entry matches its lockfile (`node_modules: pooled _pool-<repository>-<n>`), parked back at
1327
- the end, and the rehearsal folder goes to `.worktrees/_trash/`, removed in the background (removed here
1328
- when the trash is on another file system). Elsewhere the whole rehearsal folder is
1329
- removed at the end - its links unlinked, never what they reach - (`--keep` keeps it and names it:
1330
- `kept the rehearsal folder: <path>`), and on Ctrl-C or SIGTERM, with the hook and every process it
1331
- started stopped. The clone's git folder holds a marker naming the process that made it
1332
- (`dialecte-rehearsal.json`). A real run marks its hand-over folder with `running.json` (its pid and
1333
- start time) while it runs, removed at its end, on a failure, and on Ctrl-C, SIGTERM or SIGHUP received
1334
- while a commit (its hook) or an install runs; a run stopped at another moment leaves it, and a marker whose
1335
- process is gone counts as no run.
1336
- - A lot of `lots.json` can be a merge (git 2.38 or later, for its trial merge):
1337
- `{ "kind": "merge", "branch": "<branch or tag>", "tip": "<sha>", "resolved": { "<path>": "<file>" | null }, "message": "...", "tree": "<sha>" }`
1338
- (`null`: the merge removes the file). Merge lots are trial-merged in sequence: each on the tree the lots
1339
- before it leave - HEAD's, each earlier plain lot's files as they are in the working tree, each earlier
1340
- merge's trial tree with its resolutions - so a conflict that appears only on top of an earlier merge is
1341
- found at the write and needs a resolution, instead of stopping the run. The write refuses a branch that
1342
- is gone or moved since its tip was reviewed, a missing resolution file, a resolution holding conflict
1343
- markers, a conflict of the trial merge without a resolution or on a symlink or a submodule, and a file
1344
- the merge changes that has working-tree changes outside the resolutions (a file an earlier lot commits
1345
- aside). It records the conflicts, each resolution's hash and the tree the merge was trial-merged on
1346
- (`onTree`) in `merges.json`, under the review hash like `lots.json` (`--rehash` after a review). A resolution may
1347
- cover a file that merges cleanly (the lot changes it on top of the merge). Rehearse first:
1348
- `--rehearse` prints the merge's `tree <sha>` (a reused merge too), which goes into the lot as `tree`;
1349
- a real run requires it ("tree not recorded: rehearse first"). Before merging, the run refuses the lot
1350
- when HEAD's tree is not its `onTree` - an earlier lot committed other content (a hook staged files of
1351
- its own) - naming both trees, with nothing merged, and the next step (see what the lots before it
1352
- committed, then write the hand-over again from this HEAD for the lots left). A `merges.json` without
1353
- `onTree` (written by an earlier cli) is refused at the read: write the hand-over again, then
1354
- `--rehash` after a review. The run merges the recorded tip (`git merge --no-ff --no-commit`; a branch
1355
- moved since is a note) and refuses a merge in progress, leaving it - except one of the lot's own tip
1356
- that this cli started (its marker in the git folder) or with `--resume-merge`, aborted and redone. It
1357
- checks the conflicts against the recorded ones, copies the resolutions (hash-checked), refuses
1358
- conflict markers in the result, and checks the staged tree against the recorded one before the commit
1359
- (else the merge is aborted) and the commit's tree after it (a hook may stage files). A merge whose
1360
- hook refuses it is aborted, for a clean rerun. A rerun recognises a done merge by its subject, the
1361
- tip as its second parent and its tree. Before any commit whose staged `package-lock.json` differs
1362
- from HEAD's, `node_modules` are brought to it: the staged lock and `package.json` written over the
1363
- working copies (the working ones saved first in the git folder's `dialecte-install-backup`, put back
1364
- after the install, on an interrupt too; a backup a crash left is restored by the next run when the
1365
- files still hold the staged bytes, else refused naming it),
1366
- `npm ci --ignore-scripts --prefer-offline --no-audit --no-fund` (no install script runs: a `prepare`
1367
- or `postinstall` could change git config, hooks or any file; `npm ci` reinstalls every package, so
1368
- the note after the sync names each installed package of the staged lock that has one,
1369
- `install scripts not run: <names>`: each package once by its name, a nested copy too, five named then
1370
- `and <n> more`), the working copies put back byte for byte;
1371
- refused when the install changed the staged files or the versions still differ (the sync leaves absent dev,
1372
- peer and optional packages aside; the install guard right after it checks dev and peer ones, and refuses the
1373
- lot when one is missing). A real run that leaves every lot committed then moves the worktree's `.dialecte/lot.json`
1374
- into the hand-over folder as `lot.json`, after the card is built, and leaves an empty declaration
1375
- (`{}`) in its place, saying so in one line (`lot file archived: <folder>/lot.json`): the next lot on
1376
- the branch does not inherit its entries. No lot file, an empty one, a rehearsal, a stopped run, or a
1377
- folder that holds a `lot.json` already (a second run) leave the lot file as it is.
1378
- - `dialecte handover show [<name|folder>] [--json]` prints a hand-over's card again, recomputed from its
1379
- folder (the lots file, the snapshot) and the records - the lots found committed from the lots file's HEAD
1380
- to the tip of its branch, `DONE` when every lot is - and writes nothing: not in the folder, the store,
1381
- the worktree or its index, nor a lock or a run marker. A word without a path separator that names an
1382
- entry of the store is that entry's folder; else a number (`0171`, or unpadded `171`) names the newest
1383
- entry of the worktree of that index (ranked by name as below, never by when it was written) - `run` and
1384
- `abandon` take it the same way; anything else is a path (relative to the current folder: `./0171` is a
1385
- folder), and
1386
- a registered folder given by its path still gets its name on the card. Without an argument: the newest
1387
- registered hand-over of the current branch (the latest date, then the highest counter, from the name),
1388
- whatever its state; none for the branch: the store's entries, one `name branch state` line each, exit
1389
- 1 (an empty or missing store says so, exit 1). While the folder exists its state is the folder's own
1390
- (abandoned, pending, partly committed, committed, stale); a folder removed is `gone`: listed, never run,
1391
- never shown as a card (exit 1, naming the missing folder). After the box, when a file of a lot not yet committed
1392
- (or `lots.json`) differs from what was reviewed, a deleted one included:
1393
- `<n> file(s) differ from the reviewed snapshot: re-gate, then dialecte handover <folder>/lots.json --rehash`;
1394
- then the run command on its own line, none once done or abandoned. Colour and width as the written
1395
- card. An unknown name, or a folder that is no hand-over: exit 2, naming it. `--json` answers the card
1396
- as data with its `folder` and `name`, as `dialecte handover --json` does, and `changedSinceReview` (the
1397
- count of that line).
1398
- - `dialecte handover review <name|index|folder> [--json] [--print]` opens the hand-over's worktree (the lots
1399
- file's `repository`) in one new editor window and returns at once: the editor is started detached, its output
1400
- ignored, never waited for. The hand-over is named as `show` names it. For a hand-over holding a merge lot it
1401
- first writes `<hand-over folder>/review/lot.diff`, the lot's own change against the lots file's `head` (what is
1402
- committed on top of it, staged, unstaged, and the untracked files git would add; ignored files left out; no
1403
- colour whatever the git config), read through a scratch index so the repository is left as it was, and opens it
1404
- in the same window. The editor: the worktree's `git config dialecte.editor` when set (its words, split as a
1405
- shell splits them, then the paths; no flag added), else the first editor of a fixed list the cli knows found as
1406
- an executable file on `PATH` (searched by the cli, no shell; opened with its new-window flag), else
1407
- `code --new-window`; `$EDITOR` and `$VISUAL` are never read. `--print` prints the command line it would run (each word that needs it shell-quoted, so
1408
- it runs as copied) and starts nothing; with `--json` too it prints that answer and starts nothing; `--json` answers `{ editor, command, opened }`. Exit 2: no
1409
- argument, an unknown hand-over, a worktree that is gone (naming it), or an editor that is no executable file
1410
- (`editor <word> not found: set git config dialecte.editor`), nothing started; with `--json` a refusal answers
1411
- `{ error }`, the message as written. Every READY card gets a `review`
1412
- section after the gates, `dialecte handover review <name> (opens <editor>)` (`review: { command, editor }` in
1413
- `--json`), read from `PATH` when the card is built; BLOCKED, DONE and ABANDONED cards have none.
1414
- - `dialecte handover run` without a folder runs the one registered hand-over still to run (its folder
1415
- pending or partly committed; `--rehearse` too): an abandoned, committed, stale or gone one is skipped.
1416
- Two or more: refused, nothing run and no run marker, one `name branch verdict` line each (`READY` or
1417
- `BLOCKED`, computed as `show` does), exit 2; none: says so, exit 1. `handover run <name>` runs that
1418
- registered hand-over (a gone one: exit 2, naming its folder). A hand-over in the folder of a `canceled` lot
1419
- is not run, however it is named (exit 2 before any guard, naming the lot, nothing written).
1420
- - `dialecte handover abandon [<name|folder>]` gives up a hand-over that will not run: it writes
1421
- `abandoned.json` (when) in its folder, records its entry `abandoned`, then removes the lock of its worktree when the lock names this
1422
- folder's `commit.sh` (a lock naming another hand-over is left, said in one line). Without an argument:
1423
- the hand-over the current worktree's lock names; no lock: says nothing is held, exit 1. Refused (exit 2,
1424
- nothing written) while a real run of it is in progress, and once every lot is committed; a partly
1425
- committed one may be abandoned, its commits stay. A lot folder is refused too (exit 2, nothing written):
1426
- `<full name> is a lot: its hand-over is redone with dialecte handover write --rehash --out <full name>; to
1427
- end the lot: dialecte lot stop <full name>`. It never touches the index, a ref or a commit. An
1428
- abandoned hand-over is `abandoned` in `list` and `show`'s listing, `ABANDONED` on its card (no run
1429
- command); `run` without a folder skips it, `run <it>` refuses (exit 2, naming the marker); abandoning it
1430
- again says it already is (exit 0), and `dialecte handover <lots.json> --rehash` of its folder is refused
1431
- (exit 2, nothing written, naming `abandoned.json`): write a new hand-over into a new folder instead. A run
1432
- and an abandon started at the same moment never both go on: each reads the other's marker again after
1433
- writing its own, and one that finds it refuses (exit 2), nothing committed or abandoned.
1434
- - `dialecte handover list [--root <dir>] [--json]` lists every hand-over folder under the workspace's
1435
- `_commit-plan/` (or the folder given, or the current one): repository, worktree, branch, lots, age, and
1436
- its state - pending, partly committed, committed, abandoned, or stale when something else moved the branch. A
1437
- folder holding a hand-written `commit*.sh` and no lots file shows as "legacy script, state unknown".
1438
- - `dialecte worktree add <repository> <branch> [--from <ref>] [--json]` makes a worktree under the
1439
- workspace's `.worktrees/<index>-<repository>-<branch tail>` (the last segment of the branch:
1440
- `0171-core-depth` for `feat/depth`; a new branch starts from `--from`, else the base
1441
- branch; a `<repository>` that is no folder, or a folder in no git repository, is refused in one line, exit
1442
- 2): it copies the hooks folder `core.hooksPath` names (husky's `.husky/_` is ignored by git, so a
1443
- plain worktree misses it), takes a `node_modules` from the workspace's pool when one matches (below), else
1444
- copies the main checkout's `node_modules` copy-on-write where the file system
1445
- can (links kept, a relative link to a sibling re-pointed so it still reaches it) - from the worktree that
1446
- has the `--from` branch checked out when it has one, else from the main checkout - lists `.dialecte/`
1447
- once in the exclude file of the repository's common git folder (so for the main checkout and every
1448
- worktree of it), and writes the hygiene baseline `gate --fast` compares with; it prints a card.
1449
- The index is 4 digits at least (`0001`, past `9999` it grows), one counter per workspace so the latest
1450
- worktree sorts last: 1 + the highest of the claims in `.worktrees/.index/` (one empty file per index ever
1451
- taken) and the numbered folders and links of `.worktrees/`. A claim is created only where none exists,
1452
- so two runs at the same moment, of any repositories, never take the same index (the other takes the
1453
- next), and a number stays taken after its worktree is removed. Unnumbered folders and the sibling links
1454
- (`.worktrees/core`) count for nothing and are never renamed. `--json` carries `index`.
1455
- The pool: a finished checkout's `node_modules` waits in `.worktrees/_pool-<repository>-<n>/node_modules`,
1456
- with a `pool.json` beside it (`{ repository, lockHash, parkedAt }`, `lockHash` the sha256 of the
1457
- `package-lock.json` it was checked against), at most two entries per repository (parking a third sends
1458
- the oldest to the trash). A park (`lot close`, the end of a rehearsal) takes only a `node_modules` that
1459
- matches its `package-lock.json` (as `worktree add` reads it), rewrites absolute, in place, every link inside
1460
- it whose relative target leaves its checkout (a sibling repository; a link into the checkout itself, an npm
1461
- workspace package, stays relative and reaches the taker's own package), renames the folder into a new entry (no file is copied),
1462
- sends `node_modules/.vite` and `node_modules/.cache` to the trash (or leaves them in the folder already
1463
- going there), then writes `pool.json`; a `_pool-*` folder without one is a park that never finished,
1464
- never taken, and `worktree prune` names it as left over. `worktree add` takes the newest entry of the
1465
- repository whose `lockHash` is the new worktree's `package-lock.json` hash (a rename: two takers never
1466
- share one, the second goes on to the next entry), then reads it against the lockfile as it reads a copy.
1467
- No match, an empty pool or a rename across file systems: the copy. The card's `node_modules` row says
1468
- which and how long (`pooled _pool-cli-1 0.1 s`, `copy-on-write 46.2 s`); `--json` carries
1469
- `nodeModules: { method, from?, seconds }`. The trash: `.worktrees/_trash/` - a worktree goes there by
1470
- `git worktree move` (git keeps it registered) then a background `git worktree remove --force`, a folder
1471
- by a rename then a background `rm -rf` of that one path; nobody waits for either. A folder left there (a
1472
- sleep, a crash) stays for you to look at. The pool and the trash are used only where the repository's
1473
- parent holds `.worktrees/`.
1474
- Before the copy it makes the links the worktree's `file:` and `link:` dependencies need (`dependencies`,
1475
- `devDependencies`, `optionalDependencies`, `peerDependencies`): a relative path that leaves the worktree
1476
- into the workspace's `.worktrees/` (`file:../core` from `.worktrees/cli-x` reaches `.worktrees/core`)
1477
- gets a relative link there to the folder the same path reaches from the main checkout
1478
- (`.worktrees/core -> ../core`). Each dependency gets one outcome, in the card's `links` row and the
1479
- JSON's `siblingLinks` (`dependency`, `link`, `target`, `outcome`): `created`; `present` (a link that
1480
- already reaches it: a second worktree changes nothing); `skipped: <target> missing`;
1481
- `skipped: <folder> missing` for a path into a sibling whose own folder is not under `.worktrees/` yet
1482
- (`file:../core/sub/pkg` without `.worktrees/core`); `skipped: outside .worktrees/`;
1483
- `skipped: cannot make the link (<code>)` when the file system refuses it (`EACCES`, ...);
1484
- `kept: points to <its text>, not <target>` or `kept: a real folder` (or file): what is there is never
1485
- replaced. A path inside the repository needs no link and is not listed. After the copy it reads
1486
- `node_modules` against the worktree's `package-lock.json` (its `packages` map, lockfileVersion 2 or 3,
1487
- nested packages included, bundled ones left out): each package installed at its locked version
1488
- (`missing`, `<installed> installed, lock <locked>`, `package.json unreadable`), each link reaching what
1489
- the lockfile resolves it to (`link to <path> missing`, `… points elsewhere`). A package npm may leave
1490
- out of this machine's install is not missing when absent: `optional`, or an `os` / `cpu` list this
1491
- platform does not match (`!x` excluding x); a `devOptional` one is, since a development install puts it
1492
- in. The card's `lockfile` row says
1493
- `✓ node_modules matches package-lock.json (<n> packages)`, or the count of packages that differ with the
1494
- first five, and a `next` row holds the command that puts it right, `cd '<worktree>' && npm ci`. Without
1495
- a lockfile it says `no package-lock.json: not checked`; a lockfile that is not JSON, or has no `packages`
1496
- map (lockfileVersion 1), is not checked either (`package-lock.json unreadable: not checked`,
1497
- `package-lock.json has no packages map: not checked`). The JSON carries it as `nodeModulesCheck`
1498
- (`lockfile`, `notChecked`, `problems`: `package`, `problem`; `command` when there are problems). The
1499
- exit code stays 0 whatever the links and the lockfile say: the worktree exists, and its card says what
1500
- to run.
1501
- - `dialecte lot start <brief.json> [--effort low|medium|high] [--by <who> --reason <text>] [--dry-run] [--simulate <scenario>] [--json]` starts a lot from its brief
1502
- (`schema`, `feature`, `repository`, `branch`, `base`, `goal`, `plan`, `scope`, `steps`, `lots`, `effort`).
1503
- Every check runs first and every refusal is printed at once (`<field>: <rule> - <detail>`, `{ refused }` with
1504
- `--json`, exit 2), before anything is created: the fields, the repository's main checkout, a new valid branch,
1505
- a base that resolves to a commit, the plan and each step's heading in it, the scope and the lots covering it
1506
- (a lot path is inside a scope entry by path segments: `lib/x` is inside `lib/`, `lib-other/x` and `libx` are
1507
- not; an entry whose glob cuts a name, `src/data*`, compares by string prefix), no
1508
- overlap with an open lot of the same store. Then it claims the next worktree index, publishes the lot folder
1509
- `<git common folder>/dialecte-lots/<index>-<repository>-<branch tail>/` (the brief, a copy of the plan, the
1510
- first transition, `identity.json` last; every record written once, read-only), makes the numbered worktree at
1511
- the recorded base commit and its `.dialecte/lot` link to the lot folder. The store is appended to the user's
1512
- store list (`$XDG_STATE_HOME/dialecte/lot-stores`, else `~/.local/state/dialecte/lot-stores`), refused when
1513
- that list sits inside a git work tree. `--dry-run` runs the checks (the store-list refusal included, no
1514
- hard-link probe), names the lot and the start to run next (`next: dialecte lot start <brief path as given>`),
1515
- writing and claiming nothing. A worktree that cannot be made leaves the lot
1516
- `failed` (exit 1), nothing removed, with `next: dialecte lot stop <full name> --reason <text>`; a link that
1517
- cannot be made leaves the lot working (exit 0, a `note:` line, `notes` in JSON; `lot status` reports the link
1518
- missing). Every `--json` exit is JSON: `{ lot, folder, worktree, runner, notes, next }` started,
1519
- `{ dryRun: true, lot, worktree, next }` dry run, `{ lot, folder, state, reason, next }` failed,
1520
- `{ refused, next: null }` a refused brief, `{ error, usage, next: null }` a usage error (exit 2),
1521
- `{ error, next: null }` any other exit before a lot exists.
1522
- The effort: the risk class of the scope sets the default (high when a scope entry reaches the package's
1523
- `dialecte.risk.high` list, or may reach it: `src/**` holds `src/lib/store/**`; `effort high (risk) · risk class
1524
- high: ...`). On a terminal, without `--json` or `--dry-run`, the effort is asked with that default
1525
- (`effort for risk class high [high]: `). An effort below the class, from `--effort`, the brief or the answer,
1526
- is refused (exit 2, nothing written, also on `--dry-run`) unless `--by <who> --reason <text>` give the
1527
- go-ahead (both or neither); given, they are recorded on an effort line in the lot's `risk.jsonl` and the start
1528
- prints `! effort medium below risk class high (by <who>: <reason>)`.
1529
- - `dialecte lot risk <id|folder> [--json]` reads the folder's `risk.jsonl` and derives the risk class now from
1530
- the worktree's diff against the lot's base, writing nothing: `lot risk: class <c> · effort <e> · cap <n>`, a
1531
- `! effort <e> below risk class <c> (by <who>: <reason>)` line when it is (`(no go-ahead recorded)` when no
1532
- reason is recorded), then one line per reason (`<file>:<line>: <detail>`; a declared file reads `<file>:
1533
- declared` when the list names it, else `<file>: declared <glob>`).
1534
- High: a changed file in the package's `dialecte.risk.high` list (the base's and the worktree's together, so
1535
- a change that drops a glob still counts it; the cli declares its store, events, cleanup, review rounds and
1536
- hand-over commit paths), an added destructive call or git argument in a source file (a line
1537
- that is a comment alone, starting with `//`, `/*` or `*`, is not read), or a runtime package (one with an
1538
- `exports` map) whose API index changed, or whose export source changed against the base while its index did
1539
- not or there is none; light: docs, a version bump, the lockfile, or at most 40 changed lines in at most 3
1540
- files; medium otherwise. A derivation that cannot run (a repository with no commit yet) falls back to the
1541
- last derived line, else `class unknown`, and the read ends with `! risk class not derived: <reason>`, exit 0.
1542
- `--json` prints the read as one object `{ class, reasons, effort, below, cap }`, versioned by the JSON schema
1543
- `src/commands/lot-risk.schema.json` (draft 2020-12, version 1). `dialecte lot risk <id|folder> --effort low|medium|high [--class
1544
- high|medium|light] --by <who> [--reason <text>]` appends `{ schema: 1, kind: "effort", at, effort, class?, by,
1545
- reason? }` to `risk.jsonl` (the last line wins; the same effort, class and reason again: `already`, nothing
1546
- written, so a reason given after the class rose is a new line);
1547
- an effort below the class needs `--reason`; when the derivation cannot run, the effort is compared to the last
1548
- derived line, or to nothing, and recorded. Exit 0 read or recorded; 2 for a usage error, an unknown id, a
1549
- damaged store lot (`lot risk: <name> damaged: <reason>`, read or write), no `--by`, below without `--reason`,
1550
- a forbidden word or a committed, canceled or failed lot, nothing written; 1 when the line cannot be
1551
- written. `lot snapshot` (only when it goes ahead) and `handover write` append a `{ kind: "derived", class,
1552
- reasons, from }` line; a derivation that cannot run prints `! risk class not derived: <reason>` and appends
1553
- nothing.
1554
- - `dialecte lot status <id> [--json]` derives the lot's state from its records (`working`, `input-required`,
1555
- `ready`, `committed`, `canceled`, `failed`), with the worktree and link checks and the exact next command (the
1556
- text form adds an `also:` line when there is one, five lines at most); it
1557
- reads files only, runs no git and writes nothing. A real working lot's next station is walked from its
1558
- records (`nextStation`: per step test-writer, `tdd red`, test-reviewer at medium or high effort,
1559
- implementer, `tdd green` and `gate --fast`; per review round its snapshot, reviewer, fixer or adjudicator
1560
- and `gate --fast`; then `gate --full` after the last edit station, `contrib` for a producer, the
1561
- independent review, the hand-over to write; the first unmet one wins): the text form prints it after the
1562
- state line, `station implementer step 2 of 3 · round -/2 · effort medium` (`<what>` may be `reviewer
1563
- round 1`, `tdd green and gate --fast (implementer step 2 ended, claim unchecked)`, `implementer running
1564
- since <at> (run <run>)`, `lot snapshot round 2`, `question to the person (round cap 2 reached)`, `handover write (no
1565
- hand-over written)`, `unknown (<why>)`), the position line given up first, and `next` is that station's
1566
- command (`dialecte lot station <name> start implementer --step 2`, `... end <station> --run <run>`, the
1567
- check's command, `dialecte lot snapshot <name> --round <r>`, at the cap its `--beyond-cap` form), `also`
1568
- keeping the manual line; a hand-over to write and an unknown position keep the manual line. A station
1569
- is ended by an end with exit 0 or none and a verdict other than `failed` or `limit`; a start with no end
1570
- is running until a later station start or end or a snapshot comes (a check never closes it: the
1571
- station's own `tdd red`, `tdd green` and `gate --fast` run inside it), `no end` after; an end that names
1572
- its run and gives no `--step`/`--round` takes its start's; an end of another name, or one with no start
1573
- that places it, is `unplaced`. A claim is checked by a later `step.end` of its kind with exit 0 in
1574
- the lot's own worktree (never `throwaway`, no later failed run of the kind, no newer failed gate
1575
- record), or by one inside the station's run whose `stateHash` is the one its end recorded (the tree it
1576
- handed over); when the events say the worktree's cli writes no step events, its tdd ledger and green gate
1577
- records after the end stand in (a later green record of a gate mode covers every earlier claim of that
1578
- mode), else `unknown (the worktree's cli records no steps)`. A reviewer or test-reviewer end approves only
1579
- with `approve`: none or another word reads `unknown (<station> ended without a verdict)` or `unknown
1580
- (<station> ended with <word>)`. `--json` adds `station` (`{ kind, station, check, step, round, why,
1581
- unplaced, noEnd }`, `null` for a simulated lot) and `rounds` (`{ review, cap, effort, steps, beyondCap:
1582
- [{ round, by, reason }], independent }`, `effort` the level the cap is taken from or `null`, `steps` the
1583
- brief's count; the text form prints from them) and `effort` (`{ level, source, riskClass, below }`,
1584
- `source` `risk-line` for an effort recorded by `lot risk`, `riskClass` the last derived line or `null`; the
1585
- text form adds `! effort <e> below risk class <c> (by <who>: <reason>)` when it is below, `(no go-ahead
1586
- recorded)` when no reason is recorded). Other states, a
1587
- simulated lot and `lot start` keep their next. A damaged lot (a folder of the store whose name has a lot
1588
- name's shape and whose records do not hold: no readable `identity.json`, one naming another folder, or a record
1589
- that fails its check) answers `<name> damaged: <reason>` then `next: dialecte lot stop <name> --reason <text>`
1590
- (`{ lot, state: "damaged", reason, next }` with `--json`), exit 6, never `no lot`; the reason is a fixed word
1591
- of the cli, never a field of the record, and a lot with an unreadable identity is named by its folder. Exit 0 for a lot found, 2 for an unknown or ambiguous id
1592
- (`{ error, next: null }` with `--json`) or a usage error (`{ error, usage, next: null }`). An
1593
- `<id>` is an index (`171` = `0171`), a full name, a lot folder or `.dialecte/lot`; a word naming an existing
1594
- folder is that folder; a damaged lot is named by its id (index or full name), a path to it does not find it. The review rounds' verbs take `<id|folder>` the same way (a write needs an index
1595
- unique across every store of the list), and a lot folder is accepted as their hand-over folder although it
1596
- sits in the git folder. Two workspaces of the store list may give the same full name (the same index,
1597
- repository folder name and branch tail): that name is then ambiguous (exit 2 listing both); give the lot
1598
- folder instead.
1599
- - The host loop: `lot start -> lot wait -> (lot answer -> lot wait)* -> lot result`. Every output names the exact
1600
- next command with the lot's full name, and the exit code says what the host does next (section below). Every
1601
- answer of `status`, `wait`, `answer`, `result` and `stop` goes to standard output, whatever its exit code; only
1602
- a usage error or a refusal (exit 2), and an answer hook that threw (exit 1 of `answer`), go to standard error.
1603
- `inbox` follows the same rule (its exit 1, nothing waits, is an answer). `lot start` stays outside it: a
1604
- refused start (exit 2) or a failed one (exit 1, the lot `failed`) is an error on standard error, naming the lot
1605
- and its next command. The answer line of a caller's question carries no `--by` (it defaults to `caller`); a person's names
1606
- `--by <who>`.
1607
- - `dialecte lot wait <id> [--timeout <seconds>] [--json]` returns the status as soon as the lot needs someone:
1608
- exit 0 `ready` or `committed`, 1 `failed` or `canceled`, 3 `input-required` (at once, every time, costing
1609
- nothing), 4 when the last transition is a limit (run again), 5 when `--timeout` is reached while the lot still
1610
- works. A real lot is looked at every second, by a stat of its folders and of the registry, and read again only
1611
- when one changed, nothing written; on a terminal a `waiting <name> (<state>,
1612
- <elapsed>)` line refreshes (never under `--json`). A simulated lot is played up to its next blocking point; one
1613
- with nothing left to play (no `scenario.json`, or every step played) never waits: it answers its state at once,
1614
- as `lot result` does (a working lot: exit 5), whatever `--timeout`. A damaged lot answers at once with exit 6,
1615
- as `lot status` prints it.
1616
- - `dialecte lot answer <id> <question> "<answer>" [--by <who>] [--json]` records the answer to an open question
1617
- once, then prints the status with `next: dialecte lot wait <name>`. The answer is one line; a question with
1618
- options takes one of them (compared trimmed, case-folded, recorded as the option is written); the same answer
1619
- again is `already`, another one is refused. A person's question needs `--by <who>` (not `caller`); a caller's
1620
- defaults to `caller`. `--by` is one line, not empty, checked before the lot is read (exit 2 naming `--by`).
1621
- A refusal's text form escapes the options, answer and `--by` it quotes (a line feed in them prints as
1622
- `\u{a}`, the refusal stays one line); `--json` carries them as stored. A damaged lot takes no answer (exit 2,
1623
- naming the lot, its damage and the stop to run; nothing written).
1624
- - `dialecte lot result <id> [--json]` never blocks and writes nothing. A `ready` or `committed` lot exits 0 with
1625
- `{ lot, state, handover: { name, folder, state, card, show, run }, worktree, branch, questions, simulated }`:
1626
- the card is the one `handover show --json` computes, `handover.state` the hand-over's own state read from git
1627
- (`committed` once its lots are committed, even before the registry says so), `questions` the answered ones
1628
- (`{ id, text, answer, by }`); a simulated lot's `handover` is `{ simulated: true }`, nothing to show or run.
1629
- `failed` and `canceled` exit 1 with `{ state, reason, at, position }` of the last transition, `input-required`
1630
- exits 3 with the open questions, `working` exits 5, a damaged lot exits 6 (as `lot status` prints it). The text
1631
- form prints agent text escaped.
1632
- - `dialecte lot stop <id> --reason <text> [--by <who>] [--json]` ends a lot. A `committed` lot is refused
1633
- (exit 2). A pending hand-over is abandoned first, as `handover abandon` does (`abandoned.json`, the registry
1634
- entry `abandoned`, the lock released when it names that hand-over); while its run is in progress, or once it is
1635
- committed, the stop is refused (exit 2) and publishes nothing. Then a `canceled` transition (cause `stop`, the
1636
- reason, `--by` or `caller`), and the registry is read once more: a hand-over registered meanwhile is abandoned
1637
- at once. A lot already `canceled` exits 0 writing nothing; one whose entry is still `pending` (a crash inside an
1638
- earlier stop) is repaired. It moves no worktree and deletes nothing; `lot close` and `worktree prune` let the
1639
- worktree go once the lot is canceled. The reason and `--by` are one line, not empty (exit 2). A damaged lot is
1640
- stopped by moving its folder aside, never deleted and nothing written into its broken records first: to
1641
- `<git common folder>/dialecte-lots-aside/<name>` (`-2`, `-3`, ... appended when the name is taken, an empty
1642
- folder included), with a `stopped.json` (`reason`, `by`, `at`, `damage`) inside the moved folder (a lot folder
1643
- that is a symbolic link: the link is moved, never its target, and the record is `<aside name>.stopped.json`
1644
- beside it). It prints `stopped <name>: damaged (<reason>); its folder is now <path>` (`{ lot, state:
1645
- "moved-aside", damage, folder }` with `--json`). Its index stays claimed, its worktree and branch stay; refused
1646
- (exit 2, nothing moved) while a live run marker holds the folder or a pending registry entry names it (first:
1647
- `handover abandon <entry>`); a stop that finds the folder gone (another
1648
- stop moved it) says `no lot <id>`. Until it is moved aside, a damaged lot holds its paths: the scope of its
1649
- `brief.json` when that reads as a list of texts, else every path, so `lot start` refuses an overlap with it
1650
- (`overlap with <name> (damaged: <reason>): ...`, or `its scope cannot be read: it holds every path`); one whose
1651
- identity reads simulated holds none.
1652
- - `dialecte lot start --simulate <scenario>` starts a simulated lot that plays one of the scenarios (`ready`,
1653
- `question`, `person`, `two-questions`, `limit`, `failure`, `slow`) under `lot wait`, publishing the records a
1654
- real run would: it writes only its lot folder, one line of the store list and one index claim, never a branch,
1655
- a worktree or a registry entry, and never blocks a real lot. A host proves its loop on it before a real run.
1656
- With `--dry-run` it is the dry run of that simulated start: exit 0, the findings a real start would refuse for
1657
- listed (`wouldRefuse` in JSON, `worktree: null`), no worktree named, and `next` the same start with
1658
- `--simulate <scenario>`; nothing claimed or written.
1659
- - `dialecte inbox [--repository <name>] [--simulated] [--json]` lists what waits on someone across every store of
1660
- the store list and the store of the current folder: one line per open question (person questions first, then
1661
- caller questions), then the ready lots, then the failed ones, by index within a group, each line
1662
- `<index> <repository> <branch> <what> <next command>`, where `<what>` is `question q<k> (person|caller)
1663
- <question text>`, `READY` or `FAILED <reason>` and the next command is the lot's own (the answer line of that
1664
- question, `handover show`, `lot result` or `lot stop`); then `working <n> · simulated <m> (listed with
1665
- --simulated)`. `--repository` keeps the lots whose repository folder has that name, `--simulated` lists the
1666
- simulated lots that wait. A lot folder whose `identity.json` does not read, or whose records do not hold, is a
1667
- `damaged <folder>: <reason>; next: dialecte lot stop <name> --reason <text>` line (a `.tmp-` folder being built,
1668
- or a folder whose name has no lot name's shape, is no lot). The records are checked once, on read: a question id is `q<k>` (k 1 or
1669
- more), an audience `caller` or `person`, a position's step, of and round non-negative integers, a transition's
1670
- `at` a time, an answer file's question its file's `q<k>`. Every lot verb names such a lot damaged (exit 6 for
1671
- `status`, `wait`, `result`; `answer` refuses, exit 2), so no forged field reaches a line or a `next`. It reads files only (each registry once per store), runs no process, writes nothing. `--json`:
1672
- `{ waiting: [<status of each waiting lot>], working, simulated, damaged }`. Exit 0 when something waits or is
1673
- damaged, 1 when nothing does, 2 for a usage error.
1674
- - `dialecte plan next <plan.md> [--json] [--all]` reads a plan's lot block (one fenced block with the info string
1675
- `json dialecte-lots` in the plan, or `<plan without .md>.lots.json` beside it; both or neither is refused) and proposes what can
1676
- start now; it starts, claims and writes nothing. Each entry declares an `id`, a `kind` (`lot`, `fix`, `spec`,
1677
- `person`), `dependsOn`, a `scope` per repository (`"."` is the whole repository), extra `heavy` steps
1678
- (`mutation`, `browser`, `release`), a `brief`, and a `match` (`branch`, `handover`, `feature`) by which its
1679
- records are found; the block's `shared` files (the changelog, the README, the command map) never hold a lot back.
1680
- An entry's state is read, never declared: done by a committed hand-over or store lot, open by a store lot, a
1681
- pending hand-over or a worktree on its branch, else ready, waiting, parked, or unknown with the reason when its
1682
- repository cannot be read (files only: the stores, the registries, `worktrees/*/HEAD`; no git process, except
1683
- one probe per lot whose hand-over was committed outside its folder and not closed yet: once its branch is past
1684
- the lot's base commit and on the base branch that lot reads `committed`, is no longer open nor holds anything,
1685
- and is listed under `landed` as `lot <full name> committed: hand-over committed in <folder>, branch on
1686
- <target>`; once `lot close` closes that hand-over every reader reads it `committed`, files only, with no
1687
- `landed` line; a lot with a live run or a transition later than that hand-over reads from its own records). The
1688
- text says the counts, the open lots (and open work no entry accounts for: its repository's proposals are
1689
- `unverified`), the lots that can start in critical-path order (`unblocks 7 (chain 4)`, `after <id>`, `merge:
1690
- <open lots>`, `next: dialecte lot start <brief>` or the brief to write), the ready lots held by an open one with
1691
- each scope pair met, person entries without a mark, the spec work (a spec missing or `DRAFT`), what each entry
1692
- waits for, the parked ones, then the machine: the live heavy steps with their worktree and age, the load against
1693
- twice the cores, the free and inactive memory against 2 GB (`vm_stat` on macOS, `/proc/meminfo` on Linux); a
1694
- proposal whose heavy steps would run beside a live one says `stacks:`, and on a short machine its heavy steps
1695
- would wait (advice only). `--all` lists the done entries; `--json` answers `{ plan, repositories, counts,
1696
- entries, proposals, held, landed, specWork, heavy, unknown }`, `landed` always a list (`[{ repository, lot,
1697
- folder, target }]`, `[]` when none). Exit 0 when a lot or fix can start, 1 when none can, 2
1698
- for a usage error, no block or an invalid one (every fault listed), or a repository that is not a git checkout.
1699
- `dialecte plan check <plan.md> [--json]` checks the block alone: one line when valid, else every fault (exit
1700
- 2). `dialecte plan mark <plan.md> <id> done --by <who> [--reason <text>]` records a person entry's mark once in
1701
- the machine's state folder (`<state>/dialecte/plans/`); a `lot` entry's state comes from its records and is
1702
- refused.
1703
- - `.dialecte/lot` reaches the lot folder, whose `round-<n>/` snapshots hold copies of the lot's files, tests
1704
- included. Leave `.dialecte/` out of every tool that walks the worktree: a test runner whose globs include dot
1705
- folders, a formatter, a linter. Git already leaves it out (`worktree add` excludes it).
1706
- - `dialecte lot exempt <reason>`, `lot accept <case> <reason>`, `lot revised <case|file|glob> <reason>`,
1707
- `lot gone <file|glob> <reason>` write the lot declaration `.dialecte/lot.json` at the package root (the
1708
- nearest package.json above the current folder) as tab-indented JSON, keeping what it holds; the same
1709
- case (or file) again replaces its reason. `accept` needs a case `<file>::<name>`; `gone` refuses one
1710
- (it writes `"gone": [{ "file": "<file or glob>", "reason": "..." }]`).
1711
- - `dialecte lot mutation <off|changed|audit|gate>` writes the lot's mutation switch (`"mutation"`, no
1712
- reason). Without it, `dialecte mutants run` mutates the changed lines when the lot's diff touches the
1713
- declared scope and nothing otherwise; `audit` mutates the whole scope; `gate` runs as `changed`.
1714
- - `dialecte lot standard <id|folder> consulted <note> | not-consulted <reason>` writes `<folder>/standard.json`
1715
- (`{ state, note, at }`, the note's words joined by single spaces) for the card's `standard` line; the line
1716
- references of what was read stay in the findings ledger. Another state, or no note, is a usage error
1717
- (exit 2); a folder inside a repository is refused as below.
1718
- - `dialecte lot finding`, `decide`, `snapshot`, `choice`, `delta` and `verify` keep a lot's review rounds in its
1719
- lot folder, or in a hand-over folder (`_commit-plan/<topic>-<date>/`) that stays outside every repository:
1720
- each refuses any other folder inside a git work tree or a git folder (`.git/`, a bare repository). `--` ends the options: the
1721
- words after it are taken as they are, so a finding or a reason may start with `--`. Each writes its file
1722
- whole (a temporary file renamed over it), so a reader never sees half a ledger.
1723
- - `lot finding <id|folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding>`
1724
- appends the row `| R<n>-<k> | <n> | <severity> | <file:line> | <finding> | open |` to
1725
- `<folder>/findings-ledger.md` (the folder, the file and its table made when absent; k one past the
1726
- highest of the round). A `|` is written `\|`; a line break is refused. A hand-written ledger keeps
1727
- every other byte.
1728
- - `lot decide <id|folder> <finding> <state>` rewrites that row's state cell: `open`, `fix-to-verify`,
1729
- `fixed <round> [note]` (a round after the one that raised it), `accepted <reason>`, `logged <where>`.
1730
- An id not in the ledger is refused, naming the ids it holds.
1731
- - `lot choice <id|folder> --by <who> <decision>` appends `| <decision> | <who> | <yyyy-mm-dd> |` to
1732
- `<folder>/decisions.md` (made with its title and table when absent): a decision made outside the
1733
- findings ledger, the user's above all. A `|` is written `\|`; an empty `--by`, a line break, or more
1734
- than one decision word (quote it) is refused.
1735
- - `lot snapshot <id|folder> --round <n>` copies every file `git status --porcelain -z
1736
- --untracked-files=all` lists at the worktree root (the old path of a rename included) to
1737
- `round-<n>/` at its repository-relative path - bytes, mode, a symlink as a symlink; a path gone from
1738
- disk (or now a folder) that HEAD holds goes in `round-<n>.deleted`, NUL-separated, sorted; HEAD in
1739
- `round-<n>.base`. An existing round, an untracked nested repository and a submodule (a gitlink in the
1740
- index or at HEAD) are refused; a run that
1741
- stops part-way leaves only `.partial` names, which the next run removes. `.dialecte/lot.json` is
1742
- never part of it. `round-<n>.state` (`{ "schema": 1, "at", "stateHash" }`, the worktree's state hash)
1743
- is written and renamed with the others. The risk class is derived again from the diff first, and appended
1744
- to `risk.jsonl` only when the snapshot goes ahead (a refused snapshot writes nothing); the cap is the
1745
- rounds of the higher of the effort's class and that class (low or light 1,
1746
- medium 2, high 3; the effort is the last `lot risk --effort` line, else the lot's), and a class above the
1747
- effort prints `! risk class now high (src/cleanup.ts:2: rmSync): cap 3`. With no effort recorded the cap
1748
- is 1 and a later round is refused, exit 2, naming `dialecte lot risk <folder> --effort low|medium|high --by
1749
- <who>`. A round above the cap of an effort is refused, exit 2, naming what set the cap (`(effort medium)`,
1750
- or `(effort medium, risk class high)` when a class raised it) and `dialecte lot snapshot <folder>
1751
- --round <n> --beyond-cap --by <who> --reason <text>`. With them the row `| round <n> beyond the cap of
1752
- <cap>: <reason> | <who> | <day> |` goes to `decisions.md` first, then the snapshot (a retry finds the
1753
- row of that round and adds none; once it stands, the plain `--round <n>` takes the round too). `--beyond-cap` within the cap, `--by` or `--reason` without it or
1754
- blank, and a `--by` or `--reason` holding a forbidden word (`lot snapshot: --by holds a forbidden word:
1755
- nothing written`, the word never printed) are refused, exit 2, nothing written; an existing round
1756
- stays exit 1.
1757
- - `lot verify <id|folder> --by <who> --note <text>`, run inside the lot's worktree, appends `{ schema: 1,
1758
- at, by, note, state }` to `<folder>/verify.jsonl` in one write, `state` the worktree's state hash: the
1759
- late fixes of that tree verified (the card's `late fixes` line, the `verify` guard). One later change
1760
- needs a new verify. Exit 0 recorded; 2 for `--by` or `--note` missing, blank or not one line, a
1761
- forbidden word in either, a run in another work tree than the lot identity's worktree (both named), or
1762
- no snapshot yet (nothing is late), nothing written; 1 outside a git work tree, or a line over the event
1763
- line limit.
1764
- - `lot delta <id|folder> --round <n> [--worktree] [--json]` (n ≥ 2) prints, for each file of
1765
- `round-<n-1>/`, of `round-<n-1>.deleted` or of the worktree's status, what changed since round n-1,
1766
- in the form that fits where the file is: the snapshot copy against the worktree file (or
1767
- `/dev/null` when it is gone), `/dev/null` against a file deleted then and back now or new and absent
1768
- from the base, `git diff HEAD` for a file round n-1 had at the base. Files unchanged since round n-1
1769
- are left out; colour, external diff and textconv settings never apply. It refuses when HEAD moved
1770
- since `round-<n-1>.base`, and refuses a nested repository or a submodule as `lot snapshot` does. `--worktree` adds a throwaway worktree on the branch
1771
- `<lot branch>-round-<n-1>` from the lot's branch tip, in `.worktrees/<index>-<repository>-<branch
1772
- tail>-round-<n-1>` with the lot's own index when its worktree is numbered (no new claim; else the
1773
- workspace's next): the deletions applied with `git rm
1774
- --pathspec-from-file`, then `round-<n-1>/` copied over, so a new test can run on the old code; it
1775
- prints its path and the removal command with its absolute `cd`. The lot's worktree is never
1776
- changed. Its `node_modules` comes from the pool, or a copy, as for `worktree add`.
1777
- - `lot close <hand-over name|index>... [--json]` closes finished lots: for each hand-over of the registry
1778
- named (by its name or its worktree's index) whose state is `committed` or `abandoned`, its worktree (the
1779
- path the registry entry holds) is closed: every decision first, for every argument with every rule, its
1780
- own state and branch included (one worktree reached by several names or indexes closes only when every
1781
- one of them may close, and then once, the other arguments answered "the same worktree as ..."; when one
1782
- keeps it, every one of them is kept, each line with the reason), its
1783
- `node_modules` read against the lockfile where it is; then the links of its `node_modules`
1784
- made absolute where they are, the worktree moved to the trash (`.worktrees/_trash/`, by
1785
- `git worktree move`), its `node_modules` parked in the pool (`.worktrees/_pool-<repository>-<n>`) from
1786
- there, its caches (`.vite`, `.cache`) sent to their own `_trash/` entries, and last the trashed worktree
1787
- removed in the background by `git worktree remove` without `--force`: git refuses a worktree written into
1788
- since the check, which then stays registered in `.worktrees/_trash/` for you to look at (one line says so
1789
- when something closed). Paths are compared by their real path as spelled on disk (a path typed in another
1790
- case on a case-insensitive volume matches). Before the move, the lot's final record is kept: the card line
1791
- of its `cards.log` (the one `handover run` wrote when it committed; else a recomputed one, marked
1792
- `recomputed`, built without the probe), read back and parsed, then a `removing` line naming the worktree,
1793
- its branch and the branch tip; after the move a `removed` line says `trashed` or `kept`. Kept also, with
1794
- why: `final record not kept: <reason>` when the record cannot be written or read back, and `the lot's
1795
- commit is not known` (with where to look and how to remove the worktree by hand) when a committed lot's
1796
- commit can be found neither among its lot commits nor in the worktree's hook record (read only when no
1797
- other committed hand-over shares the worktree). Every other hand-over of the worktree gets its card line
1798
- too, `head` its last lot commit or `null`. Kept,
1799
- with why and nothing done for that hand-over: first, a worktree a lot of the repository's store names
1800
- (by real path) while the lot is not `committed` nor `canceled`, reason `lot <full name> <state>` (the
1801
- store read once, no git process per lot but the one probe below). A lot whose hand-over was committed
1802
- outside its own folder (no registry entry for the lot folder, every entry naming its worktree and branch
1803
- `committed`) reads `committed` once its branch is past the lot's base commit (the base an ancestor of the
1804
- tip, the tip not the base) and on the base branch. Such a lot keeps nothing, and every outcome of its
1805
- worktree carries the line `lot <full name> committed: hand-over committed in <folder>, branch on <target>`
1806
- (under the outcome's line, indented; `landed` in `--json`); the other keep rules below still apply to it.
1807
- Once `lot close` has closed that hand-over, every reader (`lot status`, `lot wait`, the overlap at `lot
1808
- start`, `worktree prune`, `plan next` among them) reads the lot `committed`, files only and without the
1809
- probe, so a branch deleted afterwards never reopens it. A lot with a live run, or a transition later than
1810
- that hand-over (resumed after it), reads from its own records, never landed nor closed by it. A hand-over
1811
- still `pending`; its worktree is the main
1812
- checkout (never parked, moved or trashed); no registered worktree at that path (closed already, or one
1813
- in the trash or the pool: never a target again); a worktree on another branch than the hand-over's
1814
- (both branches named: it holds other work now); a `locked` worktree (`git worktree lock`); another
1815
- hand-over registered for the same worktree that is neither `committed` nor `abandoned` (named); a mutation
1816
- run started from it that still runs or died before reporting; `lot close` itself run from inside it
1817
- (run it from another folder); a process whose working folder is in it;
1818
- the processes not known (`lsof` failed or took longer than 20 s); a link from outside the worktree
1819
- pointing into it (`the link <path> points to it`: the links directly in the workspace, `.worktrees/`,
1820
- `_commit-plan/` and the scratch roots, and those in `node_modules/` and `node_modules/@*/` of every
1821
- worktree and main checkout of the workspace's repositories, read once per call; the worktree's own links
1822
- never count); a `dirty` worktree (anything
1823
- `git status --porcelain --untracked-files=normal` lists, untracked files included whatever
1824
- `status.showUntrackedFiles` says); a HEAD reflog reaching commits that neither the hand-over's branch, the
1825
- base branch nor a remote-tracking ref holds (a commit made on a detached HEAD: the reflog goes with the
1826
- worktree); ignored files its removal would delete that nothing else holds (`ignored files git worktree
1827
- remove would delete: .env`, the first three named past three): rebuilt folders (`node_modules/`, `dist/`,
1828
- the VitePress caches, the hooks folder, the `dialecte.rebuiltIgnored` folders), `.DS_Store`, the
1829
- `.dialecte/lot` link, a `.dialecte/lot.json` that is empty or byte-equal to the one archived by a
1830
- committed hand-over of this worktree, and files byte-equal, mode included, to the same path in the main
1831
- checkout go; anything else keeps it, `.dialecte/notes.md` included. The branch is never touched (`worktree prune` still lists the merged
1832
- ones). Each line names the folder it moved and where `node_modules` went (`closed <name>: 0007-cli-x;
1833
- node_modules pooled in _pool-cli-1`, or `trashed: <why it was not parked>`); a failure part-way keeps
1834
- that hand-over with the error and what was already moved, the others go on. A hand-over it closes gets
1835
- `closed` (the time) on its registry entry; closing it again prints `<name> already closed`, nothing
1836
- decided nor moved (an entry without it, a worktree removed by hand, is still kept: `nothing to close`).
1837
- Exit 0 when every named hand-over closed (or was already closed), 1 when one was kept, 2 for a name or
1838
- index the registry does not hold (then nothing is closed); `--json` prints
1839
- `[{ handover, closed: true, already?: true, landed? } | { handover, kept, landed? }]`.
1840
- - Recording a lot. Every record below is appended to a file, never rewritten; a reader skips a half line and a line
1841
- it cannot parse, and counts them.
1842
- - `dialecte lot station <id> start <station> [flags]` and `lot station <id> end <station> [--run <run>] [flags]`
1843
- append one station event to the lot's `events.jsonl` (`by: host`): the host says which station ran, with
1844
- which step, round, attempt, agent, vendor, model, tier, effort, session and skills (`--skill` seen,
1845
- `--skill-asked` asked by the brief), and, at its end, tokens (`--tokens-in`, `--tokens-out`,
1846
- `--tokens-cache-read`, `--tokens-cache-write`, `--tokens-total`), `--money <amount> <currency>`,
1847
- `--duration`, `--exit`, `--verdict` and `--suite <name>=<runs>` for suites the agent ran itself. Nothing but
1848
- the station is required; a field nobody gave stays unknown. `start` answers a `run` and the `end` command to
1849
- run; `end` pairs with `--run` (an end that gives no `--step`/`--round` then takes its start's), else with the one open start of its station whose step, round and attempt match
1850
- the ones it gives (several: refused), else is recorded alone. `--event <id>` makes a retry safe: the same id
1851
- with the same fields answers the first event (`already`) and writes nothing, other fields are refused.
1852
- `start` is refused on a committed, canceled or failed lot, `end` is accepted in every state. An `end`
1853
- records `stateHash`, the state hash of the lot's worktree (left out when it cannot be read; a retry does
1854
- not compare it): a check the station ran on that tree inside its run counts for its claim. The station
1855
- names `shared` and `outside` are the report's own labels and are refused. `lot station <id> --from
1856
- <file.json>` takes the same fields as one JSON object, plus `phase` (`start` or `end`); an unknown key
1857
- is refused, every fault at once. A line over 4,096 bytes is refused. Exit 1 when the event cannot be written, 2
1858
- for a usage error or a refusal.
1859
- - Step events: the cli writes `step.start` and `step.end` events (`by: cli`) into the lot's `events.jsonl` for
1860
- `gate --fast`, `--full`, `--release` and `--hook`, `contrib`, `tdd red`, `tdd green`, `mutants run`,
1861
- `handover run` (real and rehearsal), `lot delta --worktree` and `worktree add`: the step, whether it is heavy,
1862
- its exit, its time, whether a gate reused records, and per gate step its status, counts, time and selection. A
1863
- step in a worktree that links no lot, or none matching, writes nothing. The `step.end` of `tdd red` and
1864
- `tdd green` carries `stateHash`, the worktree's state hash after the run (computed only in a lot). A write that fails prints one
1865
- `events: not recorded: <reason>` line and never changes the step's exit; a step killed after its start writes
1866
- its end as interrupted where it can. Long lists are cut, failing parts first. A step run in a worktree whose
1867
- link names a lot that lives elsewhere (a copied or moved worktree) is written to that lot as `step.foreign`.
1868
- - `dialecte.stepEvents` in the cli's own `package.json` (`"stepEvents": 1`) tells a host that this cli writes step
1869
- events. Each event notes the capability of the cli installed in the lot's worktree; a cli without it (an
1870
- older release or source) writes none, so the report shows the step counts of such a lot as unknown rather
1871
- than 0.
1872
- - Heavy steps (`gate --full`, `--release`, `contrib`, `mutants run`, a rehearsal, a gate step the package
1873
- declares heavy, and for the last only while that part runs) write a live marker in
1874
- `<state folder>/dialecte/heavy/` (`$XDG_STATE_HOME`, else `~/.local/state`): the step, the lot, the
1875
- worktree, the process and its start time. The step removes it at its end; a marker whose process is gone, or
1876
- runs with another start time, is dead and ignored. A person's run outside any lot writes the marker too, and
1877
- no event. This is how a host sees which heavy step runs now, and since when.
1878
- - `dialecte lot report <id> [--json]` reads files only (no git, no process, nothing written) and prints one lot:
1879
- its state, feature, effort, steps and rounds; per station run the agent, tier, model, tokens, time, suites
1880
- and skills; totals for tokens (each field with how many stations did not report it, a lower bound when a
1881
- total is not exact), money per currency (with how many stations reported none), and time (the lot's elapsed time as agents, cli steps, waiting for
1882
- answers, waiting for the machine and the rest); the suites per step family with their counts, reuse and
1883
- reruns, attributed to the station whose time holds the step (`shared` when several, `outside stations`
1884
- when none, and always for the steps the orchestration runs; a step a person runs by hand during a
1885
- station lands on that station); the heavy steps, the folders (worktree add, throwaways, trash), the review
1886
- rounds from the findings ledger, the events counted (damaged, duplicates, unknown kinds) and the next
1887
- command. A number nobody reported is `unknown` in the text and `null` in `--json`, never 0. A step family
1888
- reads unknown, with the reason, when the worktree's cli writes no step events, when a record of a step has
1889
- no run in the events, or when nothing of the lot's steps left a trace. `dialecte lot report --feature <name>
1890
- [--simulated] [--json]` gives one line per lot of the feature, in every store of the store list and the
1891
- current folder, then the totals by station and by tier; simulated lots are counted apart and listed by
1892
- `--simulated`; a lot whose folder is gone is listed from its `cards.log` line. Exit 1 when the feature names
1893
- no lot, 2 for an unknown or ambiguous id.
1894
- - The hand-over card gains a `usage` row (tokens, agents, runs, agent time, and the report's command) when the
1895
- hand-over folder is a lot folder holding a station event; `handover show --json` carries `usage`. A folder
1896
- with no station event shows no row.
1897
- - `cards.log`, in `<git common folder>/dialecte-handover/`, one per repository: one JSON line per record,
1898
- appended in one write, never rewritten, never rotated. A `card` line is a lot's final record: its hand-over
1899
- card, usage and the times of its gate, tdd and hook records (a worktree's records go with it), written by
1900
- `handover run` once a commit is recorded, or by `lot close` when none exists. A `removing` line is written
1901
- before a worktree moves (its path, branch, branch tip and record times), a `removed` line after it (the same
1902
- id; `trashed` or `kept`). A `removing` without its `removed` reads as unknown. The report reads these lines
1903
- for lots whose worktree or folder is gone.
1904
- - `dialecte lot export <id> <dir> [--json]` copies a lot folder to `<dir>/<full name>/`, `asks/` left out, links
1905
- kept as links (one pointing outside the folder is named), with the lot's `cards.log` lines and registry
1906
- entry added as `cards.log` and `registry.json`. It is refused (exit 2, nothing written) for an unknown or
1907
- ambiguous id, for a `<dir>` inside a git work tree or a git folder, and when `<dir>/<full name>` exists.
1908
- The copy is made into a temporary folder beside it and each file's size and checksum compared with the
1909
- source's (`events.jsonl` as a prefix, since a running lot appends); a difference makes one more copy of
1910
- that file, a second one removes the temporary folder and exits 1 naming the file; a match renames it. The
1911
- source is never written; another run's temporary folder is named, never removed.
1912
- - `dialecte mutants run [--mode changed|audit] [--base <ref>]` runs StrykerJS (resolved from the package,
1913
- its devDependency) on the scope `package.json` declares:
1914
- `"dialecte": { "mutation": { "scope": [...], "exclude": [...], "errorFactories": [...], "fast": { "vitestConfig": "..." }, "full": { "command": "..." } } }`.
1915
- `changed` mutates the scope lines changed since the merge base with the base branch (found as
1916
- [the base branch](#the-base-branch) is; with none found, or a `dialecte.baseBranch` naming no branch, the run
1917
- is refused, exit 2, naming `dialecte.baseBranch` and `--base`) or `--base <ref>`, untracked scope files
1918
- whole; `audit` the whole scope (no base needed). Without `--mode` the lot's switch decides; with no switch,
1919
- `changed` when the change touches the scope, else `mutation off for this lot` and exit 0. A detached HEAD is
1920
- refused: a run is filed under its branch. Before Stryker starts, the run is written `running` with its
1921
- process id and that process's start time to `<git-common-dir>/dialecte-mutation/runs/<run id>.json` (every
1922
- worktree of the repository reads it); a run whose process is gone before it reports, or whose pid now
1923
- belongs to a process that started at another time, reads `died`. Every Stryker call names an empty config
1924
- file (`configFile`), so a `stryker.config.json` of the package is never merged in, and only the fast tier is
1925
- incremental. The fast tier runs first, then the timed-out mutants alone, then the declared full tier on the
1926
- survivors no committed record (`.dialecte/mutation-records.json`) lists; the entry is then replaced
1927
- `reported` with the counts, the survivors and the keys of the mutants it detected (killed or timed out), and
1928
- each survivor no record lists enters the ledger (`<git-common-dir>/dialecte-mutation/ledger.json`) as `new`,
1929
- keyed `<package>::<survivor key>`. A `new` or `scheduled` survivor becomes `killed` only when a later run
1930
- detected that exact mutant, and never by a run that started before the last run reporting it (that run tested
1931
- older code); a record with a reason and a family makes it `recorded` (a scheduled one keeps its follow-up
1932
- name). Any other run leaves it as it is: a survivor whose line changed or went away stays pending until the
1933
- lot tests it, records its reason or schedules it. The ledger's readers and writers hold a lock file beside it
1934
- (one whose owner process is gone, or that names no owner and is a few seconds old, is taken over) and first
1935
- take in every reported run the ledger has not taken in yet, in the order they started, so a run whose ledger
1936
- update was missed still reaches it, once. The last lines name the package, lot (the branch), tree (12
1937
- characters), mode, counts, each new survivor `file:line mutation` and each ledger item the run moved
1938
- (`<key> file:line killed|recorded`). Exit 1 only when Stryker fails (the run stays `running` until the
1939
- process ends); survivors never fail the command. Reports and sandboxes go under `.tmp/mutants/<run id>/`,
1940
- removed once the run reported. Stryker's incremental file lives in the run's work folder, seeded from and
1941
- written back to `<git-common-dir>/dialecte-mutation/incremental/<package hash>-<key>.json` after a reported
1942
- fast tier. The key holds the whole tree (`.dialecte/` left out), the package's path, the installed lock, the
1943
- linked `file:` dependencies, the fast tier's options, the cli version and the ignorer plugin's bytes, so the
1944
- file is reused on an identical tree only (a rerun, other targets, `changed` then `audit`, another worktree at
1945
- the same tree, a rerun after recording reasons) and never across edits. The store keeps the newest 4 files of
1946
- a package. A write-back that fails prints one warning on stderr and the run goes on.
1947
- - `dialecte mutants status [--json]`: the package's running runs with their age, died runs, `new`
1948
- survivors grouped by the lot that first saw them and `scheduled` ones by follow-up.
1949
- `dialecte mutants schedule <follow-up> <key>...` (or `--all-new`) moves `new` survivors to `scheduled`
1950
- under that follow-up (an unknown key refuses the whole call); `dialecte mutants abandon <run id>` marks a
1951
- died run `abandoned` and keeps it (a running or reported run is refused); `dialecte mutants migrate`
1952
- turns `scripts/mutants/equivalent-mutants.json` into `.dialecte/mutation-records.json` (same keys and
1953
- reasons, family `unclassified`, the line's hash), never overwriting an existing file. The store is
1954
- written by the cli only: never edit it by hand.
1955
- - `dialecte mutants judge [--file <file>]` prints, per file (sorted), the package's `new` survivors as a judge
1956
- packet: each survivor's key, line and mutation, a family guess with its reason (the first rule its code
1957
- matches: an `errors/` file or error wording, a `.constants.ts` file or a module-level declaration, an
1958
- exhaustive `default:`; `unclassified` when none does), the covering tests the last run that reported it named
1959
- (five, then `…and <n> more`), the code around it as the file is now (5 lines above and below, 21 at most, each
1960
- line cut at 160 characters, the mutated lines marked `>`, `line changed since the run` when its text differs
1961
- from the reported one) and the `record` and `schedule` commands that close it. A packet holds 10 survivors at
1962
- most and its JSON and its text stay within 12000 bytes each: the rest is counted (`…and <n> more survivors`);
1963
- a lone survivor over the cap loses window lines (context first), then test names, then the end of its mutation
1964
- text, each counted. A run entry stores at most five covering test names per survivor, and how many more.
1965
- `dialecte mutants record (--key <key>... | --file <file>) --family <family> --reason <text> [--removable]`
1966
- writes each survivor's record to `.dialecte/mutation-records.json` (family, trimmed reason of at most 200
1967
- characters, the hashes of its line and tests; `removable` for `invariant-guard` and `fallback-never-taken`
1968
- only; other records kept, files and records sorted), then moves each `new` or `scheduled` one to `recorded`
1969
- (a killed or recorded one stays as it is), both under the ledger lock, the records first: a crash between the
1970
- two leaves the survivor `new` until a later run or `record` takes the record in. `--key` repeats or takes
1971
- several keys; `--file` takes every `new` or `scheduled` survivor of the file. An unknown family, `unclassified`,
1972
- an empty or too long reason, `--removable` with another family, an unknown key, or a `--file` holding no `new`
1973
- or `scheduled` survivor refuses the whole call (exit 1, nothing written); both `--key` and `--file`, neither, no
1974
- `--family` or `--reason`, or an option given another of the verb's options as its value (`--reason --json`) is a
1975
- usage error (exit 2). `dialecte mutants drop <run id>` removes an abandoned run, or a reported run, from the
1976
- store; a running or died run (abandon it first) and the latest reported run of its branch (it is that branch's
1977
- evidence: drop it once a newer run of the branch reported) are refused. Every verb but `run` takes `--json` and
1978
- then prints exactly one JSON object on stdout, a refusal included: `{ "verb", "ok": true, ... }` or
1979
- `{ "verb", "ok": false, "reason" }` with the usual exit code (`status --json` prints the status itself).
1980
- - A `new` survivor or a died run blocks every hand-over of the package (the card's `mutation` line and
1981
- `handover run`'s guard) until it is killed, recorded, scheduled, rerun or abandoned; a running run blocks a
1982
- merge hand-over and a gate lot; `dialecte worktree prune` keeps the worktree of a running or died run.
1983
- - `dialecte worktree prune [--root <workspace>] [--yes] [--json]` lists, per repository of the workspace,
1984
- the worktrees and local branches whose commits are all in the base branch, the hand-over folders whose
1985
- lots are all committed (never `_commit-plan` itself, nor a folder holding other folders) and the
1986
- rehearsals whose process is gone - the rehearsal folders under `/tmp` (each goes whole) and the clones
1987
- earlier cli versions made in the system's temporary folder, each judged by its marker - with the
1988
- command that removes each (its absolute `cd` first).
1989
- `--yes` runs them after a confirmation on a terminal; without a terminal it refuses, so hand the
1990
- commands (or the `--yes` command) to a person. Kept, each with why: first, a worktree a lot of the
1991
- repository's store names (by real path) while the lot is not `committed` nor `canceled`
1992
- (`<branch>: lot <full name> <state>`; the store read once per repository, no git process per lot); an unmerged branch; the branch the
1993
- main checkout is on; a worktree a mutation run was started from while that run still runs
1994
- (`mutation run <id> still running (pid <pid>)`) or after it died before reporting
1995
- (`mutation run <id> died before reporting: rerun or dialecte mutants abandon <id>`; a reported or
1996
- abandoned run keeps nothing); a worktree a hand-over is pending in, or with uncommitted changes; a branch whose
1997
- reflog still reaches commits the base does not hold (reset onto a newer base after commits of its own:
1998
- its reflog is the only way back to them); a worktree or branch with no commit of its own in its reflog
1999
- (just made); a worktree holding ignored files that removing it would delete (anything but
2000
- `node_modules`, `dist`, `.vitepress/cache`, `.vitepress/dist`, `.DS_Store` and the hooks folder; a long
2001
- list is counted, the first three named); a rehearsal clone whose process still runs, or without a
2002
- marker. It never removes, nor offers to remove, a symbolic link or what a link reaches. A worktree
2003
- path, a hand-over folder or a rehearsal clone that is a link, or a hand-over folder reached through a
2004
- linked folder under the workspace at any depth, is kept with
2005
- `a link: prune never removes a link nor what it points to` (a dangling link included). A worktree,
2006
- hand-over folder or rehearsal clone that a link reaches (links looked for one level under the
2007
- workspace, its `.worktrees/`, its `_commit-plan/` and the scratch folder) is kept with
2008
- `the link <link> points to it`. `git worktree prune` unregisters every worktree whose folder holds no
2009
- checkout, a link's too: while a registered worktree of the repository is a link, a worktree deleted
2010
- from disk is kept, naming that link, and no `git worktree prune` is offered. The sibling links
2011
- `worktree add` makes (`.worktrees/core -> ../core`) are in no item. It reads each worktree with
2012
- `git --no-optional-locks`, so it never rewrites an index. Each hand-over's repository is read once for
2013
- the whole workspace, and its state once, never once per repository. `handover list` follows a link to a
2014
- hand-over folder and lists a folder reached by its path and through a link once. The pool entries and the
2015
- trash (a worktree in `_trash/` included) are never listed nor touched: one line each,
2016
- `pool: 2 entries (cli 1, core 1)` and `trash: 3 folders, being deleted or left over`.
2017
-
2018
- `gate --fast` starts with the hygiene of the worktree: nothing staged; no stash entry pushed on this
2019
- worktree's branch since `worktree add` made it (the baseline keeps every stash entry it saw, so another
2020
- session dropping one changes nothing; one stash is shared by every worktree and session: a new entry of
2021
- another branch is only noted, naming it; without a baseline the stash is not compared); and
2022
- every new file one the change declares (`--declare <path>`, repeatable; an undeclared one is a warning).
2023
- A failure says what changed and how to look at it with read-only commands.
2024
-
2025
- Steps run with the runner's defaults - no lock, no `nice`, no worker cap - whoever else shares the machine.
2026
- A step that counts tests and runs vitest (its command, or the npm script it runs, names `vitest`) and fails
2027
- on its exit code or its counts is run once more with `--no-file-parallelism`, on the failing files the first
2028
- run named (through `npm run <script>` after one `--`; the whole step when the output names no file). The
2029
- rerun passes when it exits 0, counts no failed test and at least one passed: the step then passes,
2030
- flagged - `serial rerun of <n> file(s): exit 0, <counts> flaky in parallel` on its line, one
2031
- `flaky <file>` line under it per file, the note kept in the gate record; the hand-over card's row of such a step,
2032
- or of a hook's test step `gate --hook` flagged so, reads `✓ <step> <passed> passed · <n> flaky, passed serially`
2033
- (n the flaky files), never a failed count. Otherwise the step fails as a
2034
- `real failure: <why>`, each file listed under it as `failed <file>` when it failed again or `flaky <file>`
2035
- when it passed serially, the rerun's last lines as the tail. While the rerun runs, the step's line still
2036
- shows its own command. A step that stalled, counts no tests, runs no vitest, or already runs one file at a time
2037
- (`--no-file-parallelism` in its command) is never rerun. `--json` carries the rerun of
2038
- each step (`rerun`: files, the files still failing, status, exit code, counts).
2039
-
2040
- `gate --fast` and `--full` run a `tdd` step after the hygiene (first in `--full`): every test-code file
2041
- changed since the base (test files, helpers, fixtures, snapshots) must be as the red run that last froze it
2042
- ("test code changed outside tdd red"), and every case of the change red then green, or unchanged; the
2043
- others fail the gate with the list. The flags of the receipts and the deleted cases are printed under the
2044
- step. The lot file may also accept cases without a red - a new test of behaviour that already exists, an honest
2045
- cut of an assertion: `"accept": [{ "case": "<file>::<name> [project]", "reason": "..." }]`. An accepted
2046
- case passes `tdd red` as accepted and does not block its file (a case already proven red then green keeps
2047
- its proof: an acceptance never overrides one, and an accepted receipt counts only while its entry stays in
2048
- the file); the gate lists each acceptance with its
2049
- reason, the hand-over card counts them by reason from the receipts (those of earlier lots, which the file
2050
- no longer names, counted on one line), and both report an acceptance or a `revised` entry no case used (the
2051
- gate's `unused accept` line adds `; the closest: <file>::<name>` when a case title of the change is close). An
2052
- entry names a title with its quotes folded: a straight `'` or `"` matches a curly one (`’`, `‘`, `“`, `”`) and
2053
- the reverse; nothing else (a backtick, a prime, the letter case) compares alike. The card
2054
- lists every `gone` entry with its reason; only the gate reports a `gone` entry that covers no finding. The file is strict: an unknown key, at the top or in
2055
- an `accept` entry, and an exemption without a reason are refused, naming what is wrong. A lot the orchestrator declares exempt - a wording, rename or doc-only lot - passes with its reason
2056
- and what the change touches: `{ "tdd": "exempt: <reason>" }` in `.dialecte/lot.json` at the package root
2057
- prints "exempt: <reason> (n production file(s), m test file(s) changed)". The hygiene and the hand-over
2058
- leave the file out (never committed); the hand-over card shows the exemption and the flags. A package that
2059
- does not test with vitest skips the step.
2060
-
2061
- A package tunes them in its package.json:
2062
-
2063
- ```json
2064
- "dialecte": {
2065
- "gate": {
2066
- "fast": [
2067
- {
2068
- "name": "tests",
2069
- "run": "npx vitest run --project unit --changed",
2070
- "counts": "tests",
2071
- "changedOnly": true
2072
- }
2073
- ]
2074
- },
2075
- "profile": "contributor",
2076
- "generatedDocs": [".vitepress/data/elements-catalog.json"],
2077
- "referencePatterns": ["SPEC-[0-9]+"],
2078
- "allowReferences": ["ticket number"],
2079
- "baseBranch": "main",
2080
- "rebuiltIgnored": ["coverage/"]
2081
- }
2082
- ```
2083
-
2084
- `gate.fast` / `gate.full` replace the default steps of that mode (`counts: "tests"` makes a step fail
2085
- when it counts no test; `changedOnly: true` marks a step that runs only the tests the change affects,
2086
- so "No test files found" passes with a note instead of failing; `restoresGeneratedDocs: true` restores the `generatedDocs` byte for byte after
2087
- it); `baseBranch` optionally names
2088
- [the base branch](#the-base-branch); `rebuiltIgnored` lists ignored
2089
- folders a build or a run rebuilds, which `lot close` may delete with a worktree: each a folder ending with `/`,
2090
- relative to the package root, read from the `package.json` of the main checkout nearest the ignored path (a
2091
- worktree's own declaration counts for nothing); an invalid entry (empty, absolute, holding `.` or `..`, without its
2092
- trailing `/`, not a string) is ignored, and an ignored folder nobody declares keeps the worktree; `referencePatterns` adds the package's own patterns (extended regular expressions) to the
2093
- citations (and, in a contributor, the tags) `rules` and `handover` refuse; `allowReferences` is the contributor's
2094
- opt-out: it lifts generic tags a contributor commits on purpose - `ticket number`, `acceptance criterion`,
2095
- `plan tag` - and refuses any other label in either profile: a citation of a standard is never allowed. A consumer
2096
- allows every tag already, so `allowReferences` changes nothing there (`dialecte doctor` says to remove it). A lot may hold a symbolic link, a link to a
2097
- folder included: it is hashed and scanned as its target text and committed as a link, the way git stores it (a
2098
- rehearsal copies it as the same relative link).
2099
-
2100
- **Scoped steps, heavy steps, the release list.** A step of `fast`, `full` or `release` may say `"scoped": true`
2101
- (never with `changedOnly`, never in `contrib.steps`): the gate resolves one base per run - `--base <ref>`, else the
2102
- merge-base of HEAD and [the base branch](#the-base-branch), else the empty tree (everything changed) - and hands the
2103
- step `DIALECTE_GATE_BASE`, `DIALECTE_GATE_TREE`, `DIALECTE_GATE_CHANGED` (a file of the changed paths byte for byte,
2104
- NUL-separated, both paths of a rename, relative to the repository top as `git diff --name-only` names them, while a
2105
- declared `failing` path is relative to the package root) and `DIALECTE_GATE_SELECTION` (a path to write). The step writes there
2106
- `{ "schema": 1, "base", "tree", "changed": <paths judged>, "selected": [{ "id", "reasons": [...] }], "skipped": [{ "id", "reason" }] }`:
2107
- `selected` and `skipped` are both required lists, each selected id has at least one reason, the file is at most 1 MiB
2108
- and an id matches `[A-Za-z0-9][A-Za-z0-9._-]{0,63}`. A missing or invalid selection, another base or tree, or another
2109
- count fails the step. An empty selection should exit 0 without starting vitest: it passes with
2110
- `nothing selected since <base> (<n> paths changed)` (`1 path changed` for one); a non-empty selection on a
2111
- `counts: "tests"` step that runs no test fails (`no test ran`). The step selects from the working files (never
2112
- `git show <tree>:`), so what it selects and what it runs are the same code. A failing step counting tests is rerun
2113
- once, serially, with its failing files appended as plain arguments (after one added `--` only when the step runs
2114
- through `npm run` and its command holds none), then `--no-file-parallelism`, with the same base, tree and changed file
2115
- and a new selection path: the rerun must select the same ids, and a script running vitest more than once passes
2116
- `--passWithNoTests` to each invocation (or runs one). A scoped step whose command (or the npm script it runs) does not
2117
- name vitest is rerun whatever runs it, when it exited non-zero on a test failure (a failed test counted, a `FAIL` line,
2118
- vitest's `Unhandled Errors` or `Errors <n> error` summary); for such a step a plain script error fails as itself. A
2119
- scoped step that names vitest keeps the rule of any vitest step: rerun on any failure. A first run whose selection is
2120
- not valid is never rerun.
2121
- The selection may declare `"failing": ["<path>", ...]` (relative to the package root, no `..`, no backslash; a leading
2122
- `./` and repeated `/` are normalised away): a failed step records those files with the ones its output names
2123
- (`failing` in the record and in `--json`; the card's row ends `· failing <n>: <first 3>`).
2124
- Run outside the gate (no `DIALECTE_GATE_SELECTION`), a scoped script selects everything. The base enters the record's
2125
- key, so a run at another base never reuses. `"heavy": true` marks a heavy suite (a browser suite); it is outside the
2126
- command hash. `gate.release` is the list `gate --release` runs (default: the `full` steps, derived ones included),
2127
- every scoped step against the empty tree (`--base` with `--release` feeds only the tdd step); it _covers full_ when
2128
- every `full` step is in it with the same `name`, `run`, `counts` and `changedOnly`, and only then does its green
2129
- record answer a commit hook, a rehearsal, contrib and the card. An environment switch that changes what runs belongs
2130
- in the step's `run`. A gate config the cli cannot run (a list that
2131
- is no list of steps, a step without `name` or `run`, a `scoped` or `heavy` that is no boolean, `scoped` with
2132
- `changedOnly`) is refused naming the list and the step: `gate`, `contrib` and `handover run` exit 2, `gate --hook`
2133
- exits 1, the card prints `✗ gate invalid gate config: <message>`.
2134
-
2135
- **Opting out of a default step.** A package that has no use for a default step (no skills folder, no type
2136
- benchmark yet) says so, with a reason, instead of wiring a script:
2137
-
2138
- ```json
2139
- "dialecte": {
2140
- "gate": { "skip": { "skills": "no skills folder in this package" } },
2141
- "contrib": { "skip": { "type-bench": "no type benchmark yet" } }
2142
- }
2143
- ```
2144
-
2145
- `dialecte.gate.skip` serves the default steps of `fast`, `full` and the release list that follows `full`;
2146
- `dialecte.contrib.skip` the default `contrib` steps (`docs`, `type-bench`) when `contrib.steps` is not declared.
2147
- A skip is only for a default step the package cannot run: an `npm run <x>` step whose script `x` is missing. A reason
2148
- is a non-empty string of one line and at most 200 characters. A name that is no default step of a mode with no
2149
- declared list, a step the package can run (its script is there, or it runs no npm script, as the default `tests`:
2150
- `"tests": skip is for a step the package cannot run; remove the skip`), an empty or too long reason, or a `skip`
2151
- that is no map is refused like any gate config (exit 2, naming the key and the name): an opt-out cannot go stale
2152
- unseen, and adding the script makes its skip refused until it is removed. An opted-out step runs in no mode (`skip skills
2153
- opted out: <reason>`; the card warns, never blocks), and a step the package declares has no opt-out: remove it or add its
2154
- script. Adding or removing an opt-out changes the gate record's key, so the gate runs again.
150
+ Each has its page: [`rules`](doc/commands/rules.md), [`gate`](doc/commands/gate.md), [`contrib`](doc/commands/contrib.md), [`tdd`](doc/commands/tdd.md), [`new`](doc/commands/new.md), [`handover`](doc/commands/handover.md), [`worktree`](doc/commands/worktree.md), [`lot`](doc/commands/lot.md), [`inbox`](doc/commands/inbox.md), [`health`](doc/commands/health.md), [`plan`](doc/commands/plan.md), [`mutants`](doc/commands/mutants.md), [`changelog`](doc/commands/changelog.md), [`text`](doc/commands/text.md).
2155
151
 
2156
152
  ### The base branch
2157
153
 
2158
154
  Every command that reads the base branch (the gate's base, `mutants`, `tdd`, `worktree add` and `worktree prune`,
2159
155
  `lot close`, the hand-over's target) finds it the same way, the first rule that answers winning:
2160
156
 
2161
- 1. `dialecte.baseBranch` when set (an optional override): the local branch, else origin's. Set to a branch that
157
+ 1. `dialecte.baseBranch` when set (an optional override). Set to a branch that
2162
158
  exists nowhere, it is refused, never replaced by another (a package without a `dialecte.gate` config too: its
2163
159
  default lists hold the scoped `rules` step): exit 2 for the gate's base, `mutants`, `handover write`
2164
160
  and `handover run`, exit 1 for `worktree add` of a new branch without `--from`; the commit hook fails, and the
2165
161
  tdd step of `gate --full` fails with the same text.
2166
- 2. The branch `origin/HEAD` names (recorded at clone), when that branch exists; the local one is preferred.
2167
- 3. `main`, local, else origin's.
2168
- 4. `master`, local, else origin's.
162
+ 2. The branch `origin/HEAD` names (recorded at clone), when that branch exists.
163
+ 3. `main`.
164
+ 4. `master`.
2169
165
  5. Nothing found: refused with `no base branch found (no dialecte.baseBranch, no origin/HEAD, no main, no master):
2170
166
  name it as dialecte.baseBranch in package.json`. The gate alone keeps selecting everything (with a note) in that
2171
167
  case; `worktree add` without `--from` refuses, `worktree prune` skips the repository with the text, `lot close`
2172
168
  holds nothing through the base, and `tdd` measures from HEAD.
2173
169
 
170
+ Each rule reads the branch where it is newest: the local branch or origin's, whichever is ahead of the other, and
171
+ origin's when they diverged. The remote is the truth: a merge queue lands on the host, so a local base branch goes
172
+ stale. `worktree add` (without `--from`) fetches origin before it cuts the branch, and `lot close` fetches it and
173
+ fast-forwards the local base branch (merged in the main checkout when it is checked out there and clean, its ref
174
+ moved otherwise; a line says when it does not move). A fetch that fails says so and the last known refs are read. A
175
+ lot's own branch is always read locally.
176
+
2174
177
  The repository field of `package.json` is a URL and is never read for this. `mutants` finds `origin/<b>` through
2175
178
  the same rule and no longer takes a tag named like the base branch.
2176
179
 
2177
- ### GitHub text: lot recap and text check
2178
-
2179
- Text written with an assistant tends to retell the diff and grow long. The pull request splits in two:
2180
- an expandable part made from records, and a short human part that is checked before it is posted. Both
2181
- commands only print; the user posts.
2182
-
2183
- - `dialecte lot recap <id|folder>` prints the expandable part (`<details>`) as GitHub markdown, from the
2184
- records only: the commits of the lots (or `not committed yet`), the test cases the newest gate record of the
2185
- current tree judged red then green, counted per test file, the gate and rules lines (and `mutation`), the
2186
- lot's mutation runs (`Mutation`: each run of the branch and of the branches it merges, oldest first, with
2187
- its mode, id and counts or its state; each survivor those runs killed or recorded; each survivor first seen
2188
- on those branches and scheduled, with its follow-up; `No mutation run.`, or `No mutation scope declared.`
2189
- for a package without one), the review rounds from
2190
- the findings ledger, the decisions (accepted findings, the lot declaration's `accept` and `revised` entries,
2191
- the rows of `decisions.md`, then, in a lot folder, one row per answer `answers/q<k>.json` in `k` order:
2192
- `q<k> <question text> -> <answer>`, by who answered, on the UTC day of the answer; an answer is never copied
2193
- into `decisions.md`), the logged findings as follow-ups, and who reviewed and posted it (`git config
2194
- user.name`; no name set is refused). Every section is always there, saying so in one line when empty; a
2195
- branch that does not hold the lots on top of the recorded base lists none as committed and says so. Each
2196
- finding is printed with its id, its text without one leading reviewer tag `[...]`. The ledger is read whole:
2197
- every row after its header with the header's cell count is a finding, whatever its id (`R<n>-<k>`, `TR3-1`,
2198
- `F-a`, printed as written), notes between rounds included; its round is the round cell's, else the one an
2199
- `R<n>-` id names, else the row is refused. A state is read as a history (`fix wrong 2 (...) - fixed 3
2200
- (reasoned)`): it starts with `fixed`, `accepted`, `logged`, `open`, `fix to verify`, `fix wrong` or
2201
- `reopened`, and a spaced dash starts a new part only before `fixed <n>`, `reopened <n> by <id>`, `fix wrong
2202
- <n>`, `fix to verify`, a closing `open`, or a later `accepted` or `logged` followed by ` (`, `: ` or a
2203
- spaced dash; any other spaced dash belongs to the text before it. The last part decides (`fix wrong`,
2204
- `reopened` and `fix to verify` leave the finding open), an accepted one's reason being the rest (in its
2205
- parentheses, or after `- ` / `: `); a state recap cannot read is refused with the row's id. A `file:line` is
2206
- printed relative to the repository, or to the workspace folder for a sibling repository (the parent of the
2207
- main checkout; of the `.worktrees` folder when the repository is gone), never absolute: an absolute path
2208
- outside both, or one the rewrite does not reach (a `/` starting a path segment after a backtick, a quote,
2209
- `=`, `[`, `-`; `~/`), is refused with the row's id; a `/` starting no segment (`a.ts / b.ts`, `+/- 2`) and
2210
- URLs stay. Where a finding was logged, the hand-over folder and the lots file's notes are left out. It writes
2211
- nothing.
2212
- - `dialecte text check <file> [--kind pr|issue|comment|commit]` checks every line before the first `<details`
2213
- line (the recap is not checked). A pull request or an issue holds the headings `What changes`, `Why`, `How
2214
- to check it` in this order, then `Watch out` only when it has something to say; each with text under it,
2215
- nothing before the first. A comment or a commit holds no heading; a commit's line 1 is its subject, not
2216
- empty and at most 72 characters (longer ones are cut in logs and in GitHub's list), with a blank line before
2217
- the body. The word cap: 150 for a pull request (the diff carries the rest), 200 for an issue (it stands
2218
- alone), 80 for a comment (it answers one point), 100 for a commit body (the why; the subject is not
2219
- counted). Words hold a letter or a digit; headings and fenced code blocks are not counted. Past the cap it
2220
- prints the count, the cap and every line from the one that passed it. Exit 0 when the text holds, 1 with one
2221
- line per problem.
2222
-
2223
- ## Run a script
2224
-
2225
- `dialecte run <script.ts>` runs a script against an in-memory project of the dialecte your project
2226
- installs (with `@dialecte/core` 0.8.0 or later) and answers one structured outcome. The script is a
2227
- module whose default export receives `{ project, doc, documentId, dialecte, helpers, utils }`; what it
2228
- returns is the outcome's `result`.
2229
-
2230
- ```ts
2231
- // add-part.ts
2232
- export default async function addPart({ doc }) {
2233
- const [assembly] = await doc.query.findByAttributes({
2234
- tagName: 'Assembly',
2235
- attributes: { name: 'A1' },
2236
- })
2237
- await doc.transaction(async (tx) =>
2238
- tx.addChild(assembly, { tagName: 'Part', attributes: { name: 'P2' } }),
2239
- )
2240
- }
2241
- ```
2242
-
2243
- ```
2244
- dialecte run add-part.ts --in assembly.xml --expect expected.json
2245
- failed: expectations not met
2246
- operations: Assembly +0 ~1 -0, Part +1 ~0 -0
2247
- diagnostics: none
2248
- expectations: 0 passed, 1 failed
2249
- ✗ expected 3 Part under Assembly[name="A1"], found 2
2250
- ```
2251
-
2252
- - `--in <file>` imports a file first (an empty document otherwise); its import diagnostics are in the
2253
- outcome. `--out <file>` writes the document once the script ran.
2254
- - `--prepare` stages the script's first transaction instead of committing it and stops the script
2255
- there: the records it would write, and what its callback returned (a lifecycle report), nothing
2256
- committed. Any other write is refused and fails the run, even when the script catches the refusal:
2257
- a second transaction, `commit()` on a prepared transaction, a transaction on a document opened
2258
- through `project.openDocument`, the project's own writes (`importFile`, `removeDocument`,
2259
- `undo`, ...) and its raw database (`getDatabaseInstance`). In every mode the runner alone commits:
2260
- `tx.commit`, `tx.finishStaging` and `tx.clearStagedOperations` are refused inside a callback, and a
2261
- transaction nested in another fails with `CONCURRENT_TRANSACTION`. The guarantee covers the API a
2262
- script is handed; a deliberate call around it (`Object.getPrototypeOf(doc).transaction.call(...)`, a
2263
- store reached by other means) is outside it.
2264
- - `--expect <file>`: a JSON array of expectations `{ "tag", "where"?, "under"?, "count"? }`, checked on
2265
- the result (on the staged transaction under `--prepare`); each one not met is named with the count
2266
- found. `count: 0` means none, no `count` at least one.
2267
- - Deterministic: ids come from a seeded generator (`--seed <n>`, 0 by default), `--now <iso>` freezes
2268
- the clock, both from the moment the script module loads (an id minted at its top level is seeded
2269
- too). The same script, input and seed give the same outcome.
2270
- - Operations are counted per record, as each commit merges them: an element created then updated in
2271
- one transaction is one creation.
2272
- - A thrown structured error is answered as code, key, detail, `meta` and the element's path from the
2273
- root (`/Root/A/AA_2[2]`); `dialecte explain <code>` says what it means.
2274
- - `--json` prints the outcome as data. `--package <name>` names the dialecte when the project depends
2275
- on none or several (`@dialecte/scl/v2019C1`, `@dialecte/core/test`). `--timeout <ms>` (120 s by
2276
- default): the run then answers a timeout and the command exits; called as a library, the script may
2277
- keep running in the caller's process. Exit 0 ok, 1 failed or an expectation not met, 2 usage. The
2278
- script's own console output goes to stderr. A value the script returns that is not JSON (a cycle, a
2279
- BigInt) is given as text with a note.
2280
- - Needs Node 22.18 or later: a `.ts` script runs through Node's built-in type stripping, no build step
2281
- (erasable TypeScript only: types, no enums or namespaces).
2282
-
2283
- `dialecte explain <code | key>` reads the error catalogue of the installed core and the error and
2284
- diagnostic catalogues the dialecte exports: the message, when it is raised, the usual fix, the docs
2285
- page. `--json` for the entries as data; exit 1 when no catalogue knows the code.
2286
-
2287
- ## A fixture from the engine
2288
-
2289
- `dialecte fixture <Tag>` answers the smallest XML document holding `<Tag>` that is valid against the
2290
- dialecte's full schema, built by the engine of the dialecte your project installs - never written by hand.
2291
- It is a `dialecte run` of a script the command writes from the definition, read through core's readers:
2292
-
2293
- - the chain of parents from the root down to the element: the shortest one (among chains as short, the
2294
- first in sequence order), or the one `--under A/B` names (the root may be named first or left out);
2295
- - every child an element on the way requires, as many times as it is required, and the first branch of
2296
- each choice it requires (unless a child already takes one), each with what it requires in turn; an
2297
- element declared with an abstract type names its first variant with `xsi:type`;
2298
- - a value for every required attribute, and text for an element whose type an empty text does not
2299
- satisfy: the fixed value, else the default, else the first value the type takes - an enumerated value,
2300
- a string its patterns match, a number counting up from the lowest its range allows, free text from the
2301
- tag name - checked against every facet (enumeration, pattern, length, range). Each sampled value is new
2302
- in the document, so unique and key fields never repeat one;
2303
- - every element a key selects holds its key fields, and every reference a keyref checks points at an
2304
- element of the key: one already planned when the values can meet (the element itself, for a reference to
2305
- its own key), else one planted along the key's selector, with what it requires in turn (its own
2306
- references included).
2307
-
2308
- ```
2309
- dialecte fixture AAA_1 --package @dialecte/core/test
2310
- <?xml version="1.0" encoding="UTF-8"?>
2311
- <Root xmlns="http://dialecte.dev/XML/DEFAULT">
2312
- <A aA="A">
2313
- <AA_1 aAA_1="AA_1">
2314
- <AAA_1 aAAA_1="aaa">
2315
- <AAAA_1 aAAAA_1="AAAA_1"/>
2316
- </AAA_1>
2317
- </AA_1>
2318
- </A>
2319
- </Root>
2320
- ```
2321
-
2322
- What is guaranteed, and how it is proven: the document is valid against the dialecte's full XSD -
2323
- structure, values, identity (unique and key) and references (keyref). The tests build the fixture of every
2324
- element of core's test dialecte and of scl and judge each with `xmllint --schema` on the real XSD.
2325
-
2326
- What is not:
2327
-
2328
- - The hooks have the last word on what they fill: an attribute a hook already set when the element was
2329
- added (an id, a derived name) keeps the hook's value. A dialecte whose hooks fill a key or reference
2330
- field differently from the plan could break a reference the plan made good; the tests catch it for the
2331
- dialectes they cover.
2332
- - Only the first branch of a required choice, and the first variant of an abstract type, are taken; the
2333
- fixture holds no optional content.
2334
- - A reference whose key is declared on another element than the keyref, a key reached only through `.//`
2335
- or through any element, and a field reaching past the selected element are not planted: the command
2336
- exits 1 naming the constraint, never with a document that breaks it.
2337
- - The document carries no record-id marks (`dev:db-id`): it is the plain export, as a user would get it.
2338
-
2339
- - Ids are seeded and the clock is frozen: the same command and the same installed versions give the same
2340
- bytes.
2341
- - `--out <file>` writes the document and prints one line (the path of the element, the bytes); `--json`
2342
- answers `{ ok, packageName, tag, path, bytes, xml }` (`out` in place of `xml` with `--out`).
2343
- - Exit 1 with the reason when there is no fixture: an unknown tag (the closest tags named), a `--under`
2344
- step its parent does not hold, an element only an endless chain of required children could hold, a
2345
- value the fixture cannot make (the attribute named: a pattern construct it does not read, facets no
2346
- value satisfies), a reference it cannot plant (the constraint named), or a write the engine refuses
2347
- (its outcome, as `dialecte run` prints it). Exit 2: usage.
2348
- - The command does not run a schema validator itself: no XSD ships with it.
2349
-
2350
180
  ## Developing the cli
2351
181
 
2352
182
  The `schema`, `run`, `fixture` and `explain` tests drive `@dialecte/core`'s own test dialecte: they resolve core from the
@@ -2363,9 +193,9 @@ lockfile). Build core there (`npm run build`) before running the tests. A releas
2363
193
  per dependency (its field, name and spec), and says how to pin it
2364
194
  (`npm install --save-exact <name>@<version>`).
2365
195
 
2366
- The cli has a commit hook: `.husky/pre-commit` runs `npm run check` (type-check, lint, format; no suite), then
2367
- `npm run test:hook` (`dialecte gate --hook` from the sources: the suite, unless a green `gate --full` of the
2368
- committed tree answers it), then `npm run build`. `npm install` in the
196
+ The cli has a commit hook: `.husky/pre-commit` runs `npm run test:hook` (`dialecte gate --hook` from the sources:
197
+ the tdd receipts of the lot, then `check` and `rules` on the touched files; no test suite: the lot's tests ran in
198
+ `tdd red` / `tdd green` on that tree, and CI runs the whole suite on every push). `npm install` in the
2369
199
  cli checkout activates it (`"prepare": "husky"` sets `core.hooksPath` to `.husky/_`), and `dialecte worktree add`
2370
200
  copies `.husky/_` into each new worktree, so `handover run` proves a cli lot again at its commit, running the
2371
201
  suite only for a tree no green `gate --full` checked. A hook
@@ -2373,10 +203,19 @@ runs with git's `GIT_DIR`, `GIT_INDEX_FILE` and the commit's identity set: the s
2373
203
  (`test/git-environment.setup.ts`, vitest `setupFiles`) clears them before any test, so a test's git acts on
2374
204
  its scratch repository only, and the cli clears git's repository variables at its start.
2375
205
 
206
+ The main checkout's `dist/` is rebuilt by the `post-merge` hook (and `post-rewrite` after a rebase) after
207
+ `git pull` or `lot close`'s fast-forward, when the checkout has one: the build goes to a folder of its own and
208
+ replaces `dist/` only when it succeeds; a failed build leaves `dist/` as it was, and a linked worktree builds
209
+ nothing. Run main's cli as `node src/cli.ts` in briefs.
210
+
2376
211
  The cli gates itself with its own `dialecte.gate` (package.json). `--fast`: `check`, a scoped `tests` step
2377
- (`node src/scoped-tests.ts`: `vitest related` over the paths changed between the gate base and the tree that a
2378
- test can import, and an empty selection exits 0 without starting vitest) and a scoped `rules` step on the same
2379
- changed list. `--full`: the default full steps (`check`, `skills`, `build`, the whole suite), then `rules` on the
212
+ (`node src/scoped-tests.ts`: the test files vitest's import graph has the changed paths a test can import reach, run
213
+ with `vitest run <files>` (the graph read once with the package's vitest, `src/lib/gate/test-graph.ts`), and an empty selection exits 0 without starting vitest; a changed path no test can import - the
214
+ manifest, the entry, the vitest config, a setup file, a file a test reads - is left to the full suite on CI, said in
215
+ one line; so is the far reach of a shared file, one more than a quarter of the package's test files and more than 50
216
+ reach (the command map, `src/lib/git.ts`, `test/scratch-repository.ts`), named with its count: its direct tests and
217
+ the other changed files' tests still run) and a scoped `rules` step on the same changed list. Its commit hook (`dialecte.gate.hook`) runs `check`
218
+ and the scoped `rules` after the tdd receipts of the lot; the full suite runs on CI for every push. `--full`: the default full steps (`check`, `skills`, `build`, the whole suite), then `rules` on the
2380
219
  changes since the gate base. The suite's setup file also points `XDG_CONFIG_HOME` at a folder that does not exist
2381
220
  (no person's forbidden words list is read) and sets `DIALECTE_KEEP_AWAKE=0` (no run of the suite holds the machine
2382
221
  awake); a case that wants either sets it itself.