@dialecte/cli 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/README.md +212 -19
  2. package/dist/cli.js +54477 -48362
  3. package/dist/lookups.d.ts +357 -13
  4. package/dist/lookups.js +2246 -26
  5. package/package.json +20 -1
package/README.md CHANGED
@@ -25,7 +25,7 @@ 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
27
  ```
28
- Discover api members schema explain standard facts
28
+ Discover api members schema explain standard facts ask
29
29
  Use run fixture new
30
30
  Grow lot
31
31
  Plan plan
@@ -42,11 +42,13 @@ dialecte schema <Tag> # what an element may hold and where
42
42
  dialecte explain <code> # what an error or diagnostic code means, when it is raised, the usual fix
43
43
  dialecte standard index|find|show|eval # index and search the standards kept on this machine, outside every repository
44
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
45
46
  dialecte run <script.ts> # run a script on an in-memory project of the installed dialecte: one structured outcome
46
47
  dialecte fixture <Tag> # the smallest valid XML document holding an element, built by the dialecte's engine
47
48
  dialecte new verb <namespace> <query|transaction> <name>
48
49
  dialecte lot start <brief.json> # a lot from its brief: the lot folder in the store, the numbered worktree, .dialecte/lot
49
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
50
52
  dialecte lot wait <id> [--timeout <seconds>] # until the lot needs someone: ready, a question, failed, a limit
51
53
  dialecte lot answer <id> <question> "<answer>" [--by <who>] # answer an open question of the lot, once
52
54
  dialecte lot result <id> # the hand-over (card, show and run lines) of a ready lot, or why it stopped; writes nothing
@@ -349,6 +351,12 @@ characters, never split nor stemmed; its plural (the acronym and one lowercase `
349
351
  closest quote and why (`ranked <r>`, `not found by find`, `not in the text`, `unknown file <id>`). Items with
350
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
351
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).
352
360
 
353
361
  `show`, `find` and `eval` build the index first when it is missing. Every verb answers exit 2 with how to set
354
362
  `DIALECTE_STANDARD` when no standard is configured.
@@ -412,6 +420,77 @@ previous fact of a question gets its `supersededBy`, with a `superseded` line ma
412
420
  `show` and `forget` answer exit 1 for an id with no fact (the closest ids named) or a fact file that is not
413
421
  readable JSON (its path named).
414
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
+
415
494
  ## MCP server
416
495
 
417
496
  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`.
@@ -509,9 +588,53 @@ the answer.
509
588
  gate's selection (the files it checked); outside a gate, the files changed against HEAD and the new ones,
510
589
  that result recorded in the worktree's git folder (`dialecte-rules.json`: when, HEAD, the state hash, the
511
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
+
512
631
  - `dialecte gate [--fast | --full] [--base <ref>] [--no-reuse] [--declare <path>]... [--json]` runs the Definition of Done: `--fast` (default) `check`,
513
632
  `skills:check` and the tests of the changed files; `--full` adds `build` and the whole suite (the
514
- runner's defaults: every file in parallel), then the steps derived from the package's scripts after its
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
515
638
  own (declared or default): `type-narrowing` (`npm run type-narrowing`, a check a publish workflow runs)
516
639
  when the package has that script and no step runs it; without the script, one line
517
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:
@@ -530,7 +653,13 @@ the answer.
530
653
  hand-over card shows `✗ <step> not wired (no npm script; or dialecte.gate.skip)` for a full or release record
531
654
  (`dialecte.contrib.skip` for a contrib one) and `! <step> not
532
655
  wired (no npm script)` for a fast one, and `! <step> opted out: <reason>` for an opt-out (a warning). The
533
- `type-narrowing` step is derived from the package's scripts and is never unwired. A gate record written
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
534
663
  before this check is not reused for a package with an unwired or opted-out step (the key changes). While a hand-over
535
664
  holds the repository (`dialecte handover <lots.json>` wrote its lock), the gate runs only under the
536
665
  hand-over written for this repository - the script the lock names exists and the `lots.json` beside it
@@ -632,8 +761,13 @@ the answer.
632
761
  stops (state `T`) and is reported as stalled.
633
762
  - `dialecte contrib [--no-reuse] [--json]` runs the contributor checks of a package whose profile is
634
763
  `contributor`, after `gate --full` and before `dialecte handover`, one line per row: `rules` on the files
635
- changed against HEAD (recorded as `dialecte rules` records it), the package's `dialecte.contrib.steps`
636
- (default: `docs`, `npm run doc:build` with the `generatedDocs` restored, and `type-bench`,
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`,
637
771
  `npm run type-bench:check`; `[]` keeps the built-in rows only) run as the gate runs its steps (a default
638
772
  step whose npm script is missing fails the run before any row, the built-in `rules` and `release` rows
639
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
@@ -946,14 +1080,14 @@ the answer.
946
1080
  merge hand-over the tdd verdict is judged on the worktree's own lot tree (the tree its first merge lot
947
1081
  merged onto), current while the hook record of the merged tree stands, so no `gates ran on another tree`
948
1082
  for it), then, in a consumer, `mutation` when the package declares a mutation scope (below), then
949
- `review` from the hand-over folder's findings ledger and `round-<n>/` snapshots (below), then `late
950
- fixes` on a card still to run (below), then `standard`. `✓`
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`. `✓`
951
1085
  passed; `!` to look at (a step not run here, with its reason, or not run after a failure; no
952
1086
  findings ledger, or one holding no row yet: `no findings recorded`; only nits open); `✗` failed (a
953
1087
  failed step, a blocking or should-fix finding open, no independent review after the last round, `gate
954
1088
  never run on this tree` when there is no record).
955
- - `review`: the review rounds are the `round-<n>/` snapshots only, against the cap of the lot's effort
956
- (low 1, medium 2, high 3; the identity's effort, else the folder's `brief.json`), then the independent
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
957
1091
  review, then the open findings: `✓ review 2 review rounds of 2 · independent review approve · approved`.
958
1092
  The independent review must come after the last snapshot: an `independent-reviewer` station end with a
959
1093
  verdict strictly after the snapshot's time (`round-<n>.state`'s `at`, else `round-<n>.base`'s mtime; a
@@ -968,6 +1102,11 @@ the answer.
968
1102
  no snapshot, no ledger row and no independent end, a folder without step events and with no snapshot
969
1103
  (its ledger rows claim no independent review), and a release hand-over keep the ledger-only line
970
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.
971
1110
  - `late fixes`: a change of the tree after the last snapshot (the worktree's state hash against
972
1111
  `round-<n>.state`'s) reads `! late fixes unverified since round <n> (<k> files): dialecte lot verify
973
1112
  <lot> --by <who> --note <text>`, a `lot verify` of the current state `✓ late fixes verified by <who>:
@@ -1079,7 +1218,16 @@ the answer.
1079
1218
  `✓ verify no late fixes`, or `verified by <who>: <note>`), come after the merges guard. Each refusal
1080
1219
  exits 2 with nothing committed, where every other guard exits 1; `--rehearse` prints `!` for each and goes
1081
1220
  on. The merges guard's note for a merge lot of the target that moved reads `lot <n>: merges main at <sha>; main
1082
- is now <sha> (see target)`. Each guard prints one line with its result
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
1083
1231
  and its time (`✓ snapshot 110 file(s) 0.4 s`): repository, the lots file as reviewed, hooks
1084
1232
  folder, branch, HEAD, empty index, the files against the snapshot, deleted files, files outside the
1085
1233
  lots, references (citations, declared patterns, and the tags of a contributor), `contrib` in a contributor
@@ -1155,7 +1303,10 @@ the answer.
1155
1303
  lot is reused and no contrib run is needed, no clone is made: the guards, a reused merge's `tree <sha>`,
1156
1304
  then `rehearsal skipped: every lot's tree has a green record` and the card. Otherwise the clone is made
1157
1305
  (`▶ rehearsal contrib` then runs `dialecte contrib` in it at the lots file's HEAD on the tree the lots
1158
- leave, before any commit, its record going to the repository's store as a rehearsal's; the clone is put
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
1159
1310
  back after it, the files the run left removed) and
1160
1311
  the reused lots are committed in it with `--no-verify` (their hook skipped, in the clone only), the
1161
1312
  others with their hook. A real run (no `--rehearse`) runs every commit's hook, whatever the store holds.
@@ -1217,8 +1368,9 @@ the answer.
1217
1368
  the note after the sync names each installed package of the staged lock that has one,
1218
1369
  `install scripts not run: <names>`: each package once by its name, a nested copy too, five named then
1219
1370
  `and <n> more`), the working copies put back byte for byte;
1220
- refused when the install changed the staged files or the versions still differ (dev, peer and optional
1221
- packages an install leaves out aside). A real run that leaves every lot committed then moves the worktree's `.dialecte/lot.json`
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`
1222
1374
  into the hand-over folder as `lot.json`, after the card is built, and leaves an empty declaration
1223
1375
  (`{}`) in its place, saying so in one line (`lot file archived: <folder>/lot.json`): the next lot on
1224
1376
  the branch does not inherit its entries. No lot file, an empty one, a rehearsal, a stopped run, or a
@@ -1346,7 +1498,7 @@ the answer.
1346
1498
  (`lockfile`, `notChecked`, `problems`: `package`, `problem`; `command` when there are problems). The
1347
1499
  exit code stays 0 whatever the links and the lockfile say: the worktree exists, and its card says what
1348
1500
  to run.
1349
- - `dialecte lot start <brief.json> [--effort low|medium|high] [--dry-run] [--simulate <scenario>] [--json]` starts a lot from its brief
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
1350
1502
  (`schema`, `feature`, `repository`, `branch`, `base`, `goal`, `plan`, `scope`, `steps`, `lots`, `effort`).
1351
1503
  Every check runs first and every refusal is printed at once (`<field>: <rule> - <detail>`, `{ refused }` with
1352
1504
  `--json`, exit 2), before anything is created: the fields, the repository's main checkout, a new valid branch,
@@ -1367,6 +1519,38 @@ the answer.
1367
1519
  `{ dryRun: true, lot, worktree, next }` dry run, `{ lot, folder, state, reason, next }` failed,
1368
1520
  `{ refused, next: null }` a refused brief, `{ error, usage, next: null }` a usage error (exit 2),
1369
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.
1370
1554
  - `dialecte lot status <id> [--json]` derives the lot's state from its records (`working`, `input-required`,
1371
1555
  `ready`, `committed`, `canceled`, `failed`), with the worktree and link checks and the exact next command (the
1372
1556
  text form adds an `also:` line when there is one, five lines at most); it
@@ -1396,7 +1580,10 @@ the answer.
1396
1580
  (<station> ended with <word>)`. `--json` adds `station` (`{ kind, station, check, step, round, why,
1397
1581
  unplaced, noEnd }`, `null` for a simulated lot) and `rounds` (`{ review, cap, effort, steps, beyondCap:
1398
1582
  [{ round, by, reason }], independent }`, `effort` the level the cap is taken from or `null`, `steps` the
1399
- brief's count; the text form prints from them). Other states, a
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
1400
1587
  simulated lot and `lot start` keep their next. A damaged lot (a folder of the store whose name has a lot
1401
1588
  name's shape and whose records do not hold: no readable `identity.json`, one naming another folder, or a record
1402
1589
  that fails its check) answers `<name> damaged: <reason>` then `next: dialecte lot stop <name> --reason <text>`
@@ -1553,9 +1740,14 @@ the answer.
1553
1740
  index or at HEAD) are refused; a run that
1554
1741
  stops part-way leaves only `.partial` names, which the next run removes. `.dialecte/lot.json` is
1555
1742
  never part of it. `round-<n>.state` (`{ "schema": 1, "at", "stateHash" }`, the worktree's state hash)
1556
- is written and renamed with the others. A round above the cap of the lot's effort (low 1, medium 2,
1557
- high 3; the identity's effort, else the folder's `brief.json`, else none recorded and a cap of 1; an
1558
- interim read until the risk class lands) is refused, exit 2, naming `dialecte lot snapshot <folder>
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>
1559
1751
  --round <n> --beyond-cap --by <who> --reason <text>`. With them the row `| round <n> beyond the cap of
1560
1752
  <cap>: <reason> | <who> | <day> |` goes to `decisions.md` first, then the snapshot (a retry finds the
1561
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
@@ -1967,7 +2159,8 @@ Every command that reads the base branch (the gate's base, `mutants`, `tdd`, `wo
1967
2159
  `lot close`, the hand-over's target) finds it the same way, the first rule that answers winning:
1968
2160
 
1969
2161
  1. `dialecte.baseBranch` when set (an optional override): the local branch, else origin's. Set to a branch that
1970
- exists nowhere, it is refused, never replaced by another: exit 2 for the gate's base, `mutants`, `handover write`
2162
+ exists nowhere, it is refused, never replaced by another (a package without a `dialecte.gate` config too: its
2163
+ default lists hold the scoped `rules` step): exit 2 for the gate's base, `mutants`, `handover write`
1971
2164
  and `handover run`, exit 1 for `worktree add` of a new branch without `--from`; the commit hook fails, and the
1972
2165
  tdd step of `gate --full` fails with the same text.
1973
2166
  2. The branch `origin/HEAD` names (recorded at clone), when that branch exists; the local one is preferred.