@turri-dev/cli 0.1.3-next.f74e98a → 0.1.4-next.073df25

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 (49) hide show
  1. package/README.md +22 -1
  2. package/dist/ask.js +34 -15
  3. package/dist/cli-options.js +12 -6
  4. package/dist/config-edit.js +1 -0
  5. package/dist/config.js +5 -2
  6. package/dist/extension.js +86 -25
  7. package/dist/genome.js +1 -1
  8. package/dist/init-config.js +5 -0
  9. package/dist/loop-cli.js +13 -1
  10. package/dist/loop-tools.js +31 -12
  11. package/dist/pi-launch.js +5 -0
  12. package/dist/pi.js +76 -19
  13. package/dist/question-dialog.js +9 -3
  14. package/dist/questioning.js +1 -1
  15. package/dist/regenerate/activity.js +23 -0
  16. package/dist/regenerate/conform.js +5 -5
  17. package/dist/regenerate/conformance-agents.js +28 -8
  18. package/dist/regenerate/conformance.js +24 -10
  19. package/dist/regenerate/list-arguments.js +121 -0
  20. package/dist/regenerate/loop.js +137 -18
  21. package/dist/regenerate/notes.js +66 -17
  22. package/dist/regenerate/prompt.js +3 -1
  23. package/dist/regenerate/regenerate.js +16 -10
  24. package/dist/regenerate/regression.js +2 -1
  25. package/dist/regenerate/requires.js +55 -2
  26. package/dist/regenerate/self-check.js +13 -6
  27. package/dist/regenerate/test-scripts.js +54 -10
  28. package/dist/regenerate/unit-review.js +12 -1
  29. package/dist/regenerate-cli.js +11 -5
  30. package/dist/release-tools.js +1 -1
  31. package/dist/resume-line.js +4 -0
  32. package/dist/review/live.js +2 -1
  33. package/dist/run-report.js +39 -1
  34. package/dist/spec-tools.js +10 -45
  35. package/docs/authoring-plain.md +12 -7
  36. package/docs/config.md +3 -2
  37. package/docs/headless.md +33 -3
  38. package/docs/installation.md +3 -0
  39. package/docs/regenerating.md +70 -20
  40. package/docs/skills-and-gates.md +5 -3
  41. package/docs/using.md +24 -9
  42. package/genome/rules/func-specs.md +1 -0
  43. package/genome/rules/project-model.md +5 -3
  44. package/genome/rules/turri-regeneration.md +76 -0
  45. package/genome/skills/bud/SKILL.md +67 -36
  46. package/genome/skills/bud/references/intent.md +4 -0
  47. package/genome/skills/refactor-module/SKILL.md +24 -2
  48. package/package.json +3 -3
  49. package/genome/skills/bud/references/checklist.md +0 -44
@@ -22,6 +22,9 @@ const emptyTotals = () => ({
22
22
  llm_calls: 0,
23
23
  agent_turns: 0,
24
24
  compactions: 0,
25
+ provider_retries: 0,
26
+ provider_stalls: 0,
27
+ turns_stopped: 0,
25
28
  model_seconds: 0,
26
29
  });
27
30
  function addUsage(totals, usage) {
@@ -43,8 +46,14 @@ function addEvent(totals, event, tokens) {
43
46
  }
44
47
  else if (event.kind === "turn")
45
48
  totals.agent_turns += 1;
46
- else
49
+ else if (event.kind === "compaction")
47
50
  totals.compactions += 1;
51
+ else if (event.kind === "provider_retry")
52
+ totals.provider_retries += 1;
53
+ else if (event.kind === "provider_stall")
54
+ totals.provider_stalls += 1;
55
+ else
56
+ totals.turns_stopped += 1;
48
57
  }
49
58
  function sumTotals(a, b) {
50
59
  const sum = emptyTotals();
@@ -181,6 +190,32 @@ export function startRunReport(options) {
181
190
  list,
182
191
  };
183
192
  };
193
+ /** The spec gaps the pulses' agents met, in the order the pulses started: questions a person would want to decide. */
194
+ const specGapsOf = (jobs) => jobs.flatMap((job) => {
195
+ const details = job.details;
196
+ return (details?.specGaps ?? []).map((gap) => ({
197
+ module: job.module ?? null,
198
+ pulse: job.pulse ?? null,
199
+ pulse_id: job.id,
200
+ landed: job.status === "succeeded" && details?.landed === true,
201
+ question: gap.question,
202
+ assumption: gap.assumption,
203
+ }));
204
+ });
205
+ /** Each request the provider failed and was waited out or stalled on, and each turn turri ended itself: why, and where. */
206
+ const turnIncidentsOf = () => events
207
+ .filter((event) => event.kind === "provider_retry" || event.kind === "provider_stall" || event.kind === "stopped")
208
+ .map((event) => ({
209
+ kind: event.kind,
210
+ pulse_id: event.job ?? null,
211
+ role: event.role ?? null,
212
+ model: event.model ?? null,
213
+ ...(event.kind === "stopped"
214
+ ? { reason: event.reason ?? null }
215
+ : event.kind === "provider_stall"
216
+ ? { silent_seconds: Math.round((event.waitMs ?? 0) / 1000) }
217
+ : { error: event.error ?? null, attempt: event.attempt ?? null, of: event.of ?? null, wait_seconds: Math.round((event.waitMs ?? 0) / 100) / 10 }),
218
+ }));
184
219
  const functionalitiesOf = (counts) => {
185
220
  if (counts === undefined)
186
221
  return null;
@@ -228,6 +263,7 @@ export function startRunReport(options) {
228
263
  build_dir: options.buildDir !== undefined ? resolve(options.buildDir) : null,
229
264
  conformance_tests: options.conformanceTests,
230
265
  review: options.review ?? null,
266
+ mutation_testing: options.mutationTesting ?? null,
231
267
  models: {
232
268
  ...Object.fromEntries(Object.entries(options.models).map(([role, choice]) => [role, { model: choice.model ?? null, thinking: choice.thinking ?? null }])),
233
269
  observed: Object.fromEntries([...new Set(events.map((event) => event.role ?? "unknown"))].sort().map((role) => [role, [...new Set(events.filter((event) => (event.role ?? "unknown") === role).map((event) => event.model ?? "unknown"))].sort()])),
@@ -245,6 +281,8 @@ export function startRunReport(options) {
245
281
  usage: usageOf(jobs),
246
282
  pulses: pulsesOf(jobs, now),
247
283
  functionalities: functionalitiesOf(attempt(sources.completion)),
284
+ spec_gaps: specGapsOf(jobs),
285
+ turn_incidents: turnIncidentsOf(),
248
286
  ...(exitParts ?? {}),
249
287
  logs: {
250
288
  jobs_dir: fromProject(join(projectRoot, ".turri", "jobs")),
@@ -1,8 +1,8 @@
1
- import { readdirSync, readFileSync } from "node:fs";
2
- import { basename, dirname, join, relative, resolve } from "node:path";
1
+ import { basename, relative, resolve } from "node:path";
3
2
  import { defineTool } from "@earendil-works/pi-coding-agent";
4
3
  import { Type } from "typebox";
5
- import { IMPORT_DIRECTIVE, PLAIN_SOURCE_FILE_EXTENSION, plainFileParser, readPlainSourceMetadata } from "./plain/parser.js";
4
+ import { plainFileParser } from "./plain/parser.js";
5
+ import { importingModules, isImportModule } from "./regenerate/requires.js";
6
6
  import { resolveTemplateDirs } from "./regenerate/paths.js";
7
7
  import { applySpecDiff, plainFilesOf, revertSpecDiff } from "./regenerate/regenerate.js";
8
8
  import { MissingFunctionalitiesError } from "./plain/errors.js";
@@ -62,24 +62,12 @@ export function createSpecDiffTools(options) {
62
62
  // file that cannot be parsed. A module with no functional specs yet is not broken. An import
63
63
  // module - definitions only, say - is not a module of its own: it is parsed as the modules
64
64
  // that import it read it, the one the change is built for among them.
65
- const importers = (file) => {
66
- const name = basename(file, ".plain");
67
- const dir = dirname(resolve(cwd, file));
68
- return readdirSync(dir)
69
- .filter((entry) => entry.endsWith(".plain"))
70
- .map((entry) => join(dir, entry))
71
- .filter((path) => {
72
- try {
73
- return (readPlainSourceMetadata(readFileSync(path, "utf8")).metadata[IMPORT_DIRECTIVE] ?? []).includes(name);
74
- }
75
- catch {
76
- return false;
77
- }
78
- });
79
- };
80
- const imported = importedNames(resolveTemplateDirs(resolve(cwd, params.plain_file)));
81
65
  const toParse = [
82
- ...new Set([params.plain_file, ...touched].flatMap((file) => imported.has(basename(file, ".plain")) ? importers(file).filter((path) => !imported.has(basename(path, ".plain"))) : [resolve(cwd, file)])),
66
+ ...new Set([params.plain_file, ...touched].flatMap((file) => {
67
+ const path = resolve(cwd, file);
68
+ const importing = isImportModule(path) ? importingModules(path) : [];
69
+ return importing.length > 0 ? importing : [path];
70
+ })),
83
71
  ];
84
72
  for (const path of toParse) {
85
73
  const file = relative(cwd, path);
@@ -100,7 +88,8 @@ export function createSpecDiffTools(options) {
100
88
  owed = false;
101
89
  liveReview?.notice(`${params.plain_file}, after the change to ${touched.join(", ")}`);
102
90
  // In the files, the change is work: the loop works out what is left to build and plans it.
103
- const statuses = await loop.bringUp(params.plain_file, params.guidance !== undefined ? { guidance: params.guidance } : {});
91
+ // A spec change, not a request: a module the person halted stays halted.
92
+ const statuses = await loop.bringUp(params.plain_file, { specChange: true, ...(params.guidance !== undefined ? { guidance: params.guidance } : {}) });
104
93
  const lines = [
105
94
  result === "applied" ? `Applied the change to ${touched.join(", ")}.` : `The change to ${touched.join(", ")} was already applied.`,
106
95
  `Building in the background:\n${describeModules(statuses)}\n`,
@@ -129,27 +118,3 @@ export function createSpecDiffTools(options) {
129
118
  },
130
119
  };
131
120
  }
132
- /** The module names some .plain file in these folders imports: import modules, not codebases. */
133
- export function importedNames(dirs) {
134
- const names = new Set();
135
- for (const dir of dirs) {
136
- let entries;
137
- try {
138
- entries = readdirSync(dir).filter((name) => name.endsWith(PLAIN_SOURCE_FILE_EXTENSION));
139
- }
140
- catch {
141
- continue;
142
- }
143
- for (const entry of entries) {
144
- try {
145
- const imports = readPlainSourceMetadata(readFileSync(join(dir, entry), "utf8")).metadata[IMPORT_DIRECTIVE];
146
- for (const name of imports ?? [])
147
- names.add(name);
148
- }
149
- catch {
150
- // A file that does not read imports nothing.
151
- }
152
- }
153
- }
154
- return names;
155
- }
@@ -158,13 +158,15 @@ an agent has to decide to go and read.
158
158
  | `import-modules.md`, `requires-modules.md` | the two ways modules build on each other |
159
159
  | `exported-concepts.md`, `required-concepts.md` | which concepts cross module boundaries |
160
160
  | `integrations.md` (+ standalone, embedded, embedded testing) | specs for REST API integrations, deployed standalone or embedded in an existing codebase |
161
+ | `turri-regeneration.md` | turri's model of itself: a spec change regenerated as a spec diff, wherever it sits, in the chain's tip; what each kind of change sets off; what a coding agent sees; how bad code is fixed; where the cost is - so a spec is placed by what it means, never to spare regeneration |
161
162
  | `stdlib.md` | the standard library: when to import which template, and every template with what it is and where it is, read from `stdlib/` |
162
163
 
163
164
  The ones that shape a spec most:
164
165
 
165
166
  - **One functionality is at most ~200 lines of code.** A bigger one is split before it is written
166
167
  (`analyze-if-func-spec-too-complex`, `break-down-func-spec`).
167
- - **Functional specs are in build order.** Each is rendered on top of the ones before it.
168
+ - **Functional specs are in build order.** Each is rendered on top of the ones before it - which is
169
+ what a spec may assume, not what a change costs: a spec inserted anywhere is regenerated alone.
168
170
  - **They state facts, with a concrete subject.** "A :User: can add a :Task:" - not "Implement
169
171
  adding tasks", not "The system should…".
170
172
  - **Nothing a test cannot check.** No `robust`, `seamless`, `as appropriate`; state the checkable
@@ -196,18 +198,21 @@ the reading that fits the rest of the spec, and marks each such decision in its
196
198
  code, environment and turri problems to the builds, and stops when a functionality keeps
197
199
  struggling after the spec was clarified, when two cycles change nothing, or after twenty.
198
200
 
199
- For an existing project, `bud` works the same way, scoped to one feature: intent → scope →
200
- product → review. After a short feature-intent interview it asks product questions one at a time -
201
- a trigger and its outcome, an edge case, a rule - and every answer is one spec change, a git diff
202
- written with `write_spec_diff` and built the moment it is written. A change to something already
201
+ For an existing project, `bud` works the same way, scoped to one feature: intent → scope → product.
202
+ It first asks how many questions the product phase may ask - light, medium, thorough or best
203
+ judgement, as `brood` does - then a short feature-intent interview, then product questions - a
204
+ trigger and its outcome, an edge case, a rule - and every answer is a spec change, a git diff
205
+ written with `write_spec_diff` and built the moment it is written, before the next question. What
206
+ the questions leave open it decides itself, a spec change each. A change to something already
203
207
  specified, built or still to build, is put to the user first and is a spec diff too: what is left to
204
- build is worked out again from the spec.
208
+ build is worked out again from the spec. It ends on the person's confirmation of a short summary of
209
+ the feature's changes.
205
210
 
206
211
  What keeps the interview honest is the harness, not the interviewer:
207
212
 
208
213
  - **Every question offers choices** (`ask_user` refuses a question without them), and each
209
214
  answer maps to one spec change.
210
- - **Every answer is written before the next question.** In `brood`'s product phase `ask_user` refuses
215
+ - **Every answer is written before the next question.** In the product phase of `brood` and `bud`, `ask_user` refuses
211
216
  a new question until the last answer is a spec change - see [skills and gates](skills-and-gates.md).
212
217
  - **Each phase ends on the person's confirmation** of a short summary, not on the interviewer's word.
213
218
 
package/docs/config.md CHANGED
@@ -84,7 +84,7 @@ runs:
84
84
  | --- | --- |
85
85
  | now | `harness-model` and `models.chat` - the conversation switches to it; `parallel-jobs` - a pulse waiting for a slot starts if there is one now; `allow-to-stop-jobs` |
86
86
  | your next message | `rules-off` - for the conversation; a skill's agents from the next skill run |
87
- | the next pulse - one running keeps what it started with | `coding-model`, `judge-model`, every other `models.<role>`, `review`, `turn-limit`, `compact-at`, `agent-env`, `toolchains` |
87
+ | the next pulse - one running keeps what it started with | `coding-model`, `judge-model`, every other `models.<role>`, `review`, `mutation-testing`, `turn-limit`, `compact-at`, `agent-env`, `toolchains` |
88
88
  | the next time the work is planned | `conformance-tests`, `conformance-budget`, `max-specs-per-pulse`, `max-lines-per-pulse` |
89
89
  | the next test run - the running pulse's too | the testing scripts, `testing-scripts-run-on` |
90
90
  | the next pulse that lands - the running one too | `release-after-pulse` |
@@ -128,6 +128,7 @@ models: # each agent role's model, thinking and tur
128
128
  | `conformance-tests` | `all` (or `true`): conformance tests for every functional spec of every module with test reqs, written once each module's code is built, before anything is built on it. `chosen`: for the functional specs chosen - every one with acceptance tests, and those the chooser picks as each code pulse ends, from what that pulse regenerated. `module`: the same, but the chooser is asked once, when the whole module is regenerated, and plans the conformance pulses too. Under both, the choice is made inside the pulse, before anything is built on the module, and the pulse's report says what was chosen and why; those the person asks for with `conform` are written too; once chosen, a functional spec keeps them, and they are rewritten when it changes - see [who chooses, and when](regenerating.md#conformance-tests-in-the-work-loop). `false`: none written, and none of the existing ones run - until the conversation asks with `conform` | `false` |
129
129
  | `conformance-budget` | under `conformance-tests: chosen` or `module`: how many of a module's functional specs may be chosen for conformance tests, beside those with acceptance tests - a count (`2`) or a share of its functional specs (`30%`, rounded up, at least one). Every choice for the module counts, whenever it was made; the chooser is told what is left, and can choose no more. Your own `conform` is not limited. A stack's `config.turri.<stack>.yaml` can set its own | no limit |
130
130
  | `review` | `true` or `false`: whether the code and its unit tests - and the conformance tests - are reviewed once they pass: two reviews at most, the second weighed by the arbiter; off, a job lands once its tests pass - see [regenerating the code](regenerating.md#the-code-and-its-unit-tests-are-reviewed) | `false` |
131
+ | `mutation-testing` | `true` or `false`: whether the coding agent and the reviewer have `can_it_fail` - one change put in the code for one run of the unit testing script, to see that a test catches it; on a copy of the code, or in place and put back after the run (see [regenerating the code](regenerating.md#checking-its-own-work)). `turri regenerate --mutation-testing false` for one run | `true` |
131
132
  | `rules-off` | a list of rule names - `integrations`, `concise-specs`, the files of `genome/rules/` without `.md` - left out of the conversation's prompt and every spec-writing agent's: a rule this project's own skills or AGENTS.md replace, such as one that says to probe a live API before any spec is written. The project's alone | none |
132
133
  | `allow-to-stop-jobs` | `true` or `false`: whether turri stops a running job the spec has moved on from - a functional spec it regenerates changed, or a file one links was edited - rolls it back and regenerates the spec as it now is. `false`: the job runs to its end and lands, and what changed since is regenerated on top of it by the next job - see [regenerating the code](regenerating.md). Your own `halt` stops a job either way | `true` |
133
134
  | `release-after-pulse` | `true` or `false`: whether every pulse that lands code releases it, in the chat, as its last stage - before the module's next pulse starts, whatever the chat is doing: an agent on the coding model looks for the project's release guidance as the chat does (what was passed to `release` this conversation, AGENTS.md, the project's skills) and, when it says to release after a build, does what it says - see [deploy](deploy.md#after-every-pulse). One release a pulse that lands; a release that fails is said in the pulse's report, and what it landed stays | `false` |
@@ -142,7 +143,7 @@ models: # each agent role's model, thinking and tur
142
143
  | `toolchains` | folders of this machine an agent's commands may read beside the system's, the `PATH`'s and those the toolchain variables point at - a toolchain installed somewhere unusual (`[/srv/zig]`). A stack's add to the project's. See [the OS sandbox](sandbox.md#the-os-sandbox) | none |
143
144
  | `turn-limit` | seconds each turn of an agent a job starts has, for every role without its own (`models:`); `0` for none. The config is the only place it is set. A turn past it ends at its next request to the model - see [regenerating the code](regenerating.md) | 120 |
144
145
  | `models` | each agent role's own model, thinking and turn limit - see [models per role](#models-per-role) | every role on `coding-model`, the conversation's side on `harness-model` |
145
- | `testing-scripts-run-on` | what the testing scripts run on - always on this machine, in your environment. `in-place`: the real build and tests folders, the script at its own path, from the project - so a script that finds a host codebase from its own path finds it. `copy`: a fresh copy of the code, staged in `plain_modules/.turri/scripts/`, with the script copied beside it; it gives the coding agent `can_it_fail` (see [the testing scripts](regenerating.md#the-testing-scripts)) | `in-place` |
146
+ | `testing-scripts-run-on` | what the testing scripts run on - always on this machine, in your environment. `in-place`: the real build and tests folders, the script at its own path, from the project - so a script that finds a host codebase from its own path finds it. `copy`: a fresh copy of the code, staged in `plain_modules/.turri/scripts/`, with the script copied beside it. `can_it_fail` works on either: on a copy it changes the copy, in place the code itself for the one run, put back after it (see [the testing scripts](regenerating.md#the-testing-scripts)) | `in-place` |
146
147
 
147
148
  Keys are written with dashes; underscores are read the same (`conformance_tests`). A key turri
148
149
  does not know is ignored - another tool's `config.yaml`, read while it is the old file, may carry several - and so is a value of the
package/docs/headless.md CHANGED
@@ -86,7 +86,10 @@ Useful options - `turri regenerate --help` lists all of them:
86
86
  | `--judge-model <provider/id>` | `judge-model`: the judge and the test review; not given, the coding model |
87
87
  | `--conformance-tests <all\|chosen\|module\|false>` | `conformance-tests`, with its values (`true` is `all`) |
88
88
  | `--review <true\|false>` | `review`: whether the code and its tests are reviewed once they pass |
89
+ | `--mutation-testing <true\|false>` | `mutation-testing`: whether the coding agent and the reviewer have `can_it_fail` |
89
90
  | `--stack <name>` | build with the stack's `config.turri.<name>.yaml` over `config.turri.yaml`; default, `TURRI_STACK`, else none |
91
+ | `--from-scratch` | delete the module's code and conformance tests (its lineage keeps them) and regenerate all of it |
92
+ | `--from-scratch-chain` | the same for every module of its requires chain, the base's included, built again from the bottom |
90
93
  | `--start-over` | start over, unasked, a codebase built without a module it now requires - without a terminal, a run that needs it and lacks it stops |
91
94
  | `--build-dir <dir>` | as the run ends, export the code there - see below |
92
95
  | `--report <file.json>` | write [the run report](#the-run-report) there |
@@ -104,7 +107,8 @@ Conformance tests follow `conformance-tests:` in `config.turri.yaml`, or `--conf
104
107
  The command exits `0` only when every module is complete: its code regenerated from the spec as it is
105
108
  now, and its conformance tests written for what is built when they are on - no pulse failed, nothing
106
109
  halted, nothing waiting for a start over. Anything else exits `1`, and the last lines say which
107
- module is not complete, and why. The log says, per functionality, what was built and whether its
110
+ module is not complete, and why. A behaviour the spec leaves open that an agent had to decide is printed
111
+ as a `spec gap` under its pulse, with what was decided meanwhile. The log says, per functionality, what was built and whether its
108
112
  tests passed.
109
113
 
110
114
  | | |
@@ -150,6 +154,7 @@ changes meaning or goes; new fields may appear in the same version. Paths in `pu
150
154
  "spec_file": "/work/app.plain", "project_dir": "/work", "build_dir": "/work/out", // build_dir: null without one
151
155
  "conformance_tests": "all", // all | chosen | module | false
152
156
  "review": false,
157
+ "mutation_testing": true,
153
158
  "models": {
154
159
  "harness": { "model": "…", "thinking": "medium" }, // the planner, the chooser
155
160
  "coding": { "model": "…", "thinking": "low" },
@@ -165,7 +170,7 @@ changes meaning or goes; new fields may appear in the same version. Paths in `pu
165
170
  "usage": {
166
171
  "total": {
167
172
  "input_tokens": 0, "output_tokens": 0, "cache_read_tokens": 0, "cache_write_tokens": 0, "cost_usd": 0,
168
- "llm_calls": 0, "agent_turns": 0, "compactions": 0, "model_seconds": 0
173
+ "llm_calls": 0, "agent_turns": 0, "compactions": 0, "provider_retries": 0, "provider_stalls": 0, "turns_stopped": 0, "model_seconds": 0
169
174
  },
170
175
  "in_pulses": { }, // the pulses' usage added up - the same fields
171
176
  "outside_pulses": { }, // the planner, the conformance chooser, a failed pulse's diagnosis
@@ -191,6 +196,16 @@ changes meaning or goes; new fields may appear in the same version. Paths in `pu
191
196
  ],
192
197
  "codebases": ["plain_modules/app/code"]
193
198
  },
199
+ "spec_gaps": [{ // [] when no agent met one
200
+ "module": "app", "pulse": 3, "pulse_id": "2a058729", "landed": true,
201
+ "question": "What happens to a contact archived in HubSpot after it was synced?",
202
+ "assumption": "An archived contact is left as synced - asserted in sync.test.ts, archived contacts"
203
+ }],
204
+ "turn_incidents": [ // [] when none
205
+ { "kind": "provider_retry", "pulse_id": "2a058729", "role": "coding", "model": "…", "error": "…: 529 overloaded", "attempt": 1, "of": 6, "wait_seconds": 15.3 },
206
+ { "kind": "provider_stall", "pulse_id": "2a058729", "role": "coding", "model": "…", "silent_seconds": 120 },
207
+ { "kind": "stopped", "pulse_id": "5c1e0b2f", "role": "conformance explorer", "model": "…", "reason": "10 submit_exploration calls failed in a row" }
208
+ ],
194
209
  "build_dir_export": { "exported": true, "dir": "/work/out", "module": "app", "commit": "8036b3b", "files": 23 },
195
210
  "logs": { "jobs_dir": ".turri/jobs", "debug_dir": ".turri/debug", "sessions_dir": ".turri/sessions" }
196
211
  }
@@ -209,6 +224,21 @@ calls; a role or model turri could not tell is `unknown`.
209
224
  stopped, or did not pass - and everything it wrote was undone. A pulse that failed is tried once more
210
225
  before it counts as failed; both tries are the one pulse.
211
226
 
227
+ **Spec gaps.** A behaviour the spec leaves open that an agent met and decided on its own - reported with
228
+ `report_spec_gap` (see [regenerating](regenerating.md)). In the chat they are put to you as the pulse ends; a
229
+ headless run has no one to ask, so they are listed here, in the order the pulses started, and printed under the
230
+ pulse that met them. `assumption` is what the agent decided meanwhile, also in the codebase's notes'
231
+ assumptions while its pulse is `landed`; a pulse rolled back takes it out of the notes, but the question still
232
+ stands. Settle the ones you care about in the spec and run again.
233
+
234
+ **Turn incidents.** Each time the model provider failed for a moment and pi or turri waited it out before trying
235
+ the request again, each time the provider sent nothing back on a request for two minutes, and each turn turri
236
+ stopped itself - an agent going round in a circle, its calls failing again and again, its time up - after which the
237
+ run carried on. The provider failing or stalling is printed as it happens, in yellow, under the pulse; a stop is
238
+ the work's normal course and is only listed. They are counted in the usage as `provider_retries`,
239
+ `provider_stalls` and `turns_stopped`. Many of any point at the model, not the spec: a provider at its limits, or a
240
+ model too small for the role it was given.
241
+
212
242
  **Completed functional specs** - the pass rate, the figure to compare runs by.
213
243
  A functional spec is completed when the code record of the codebase the run delivers - the
214
244
  furthest-built of the chain, the one `--build-dir` exports - as last committed, holds it as the spec has
@@ -227,7 +257,7 @@ and modules that are complete are skipped, so it picks up where it stopped - aft
227
257
  provider outage, or a machine that went to sleep anyway. Whatever the stopped run left
228
258
  half-written is undone first: each step starts from the module's last commit. A functionality whose spec has changed
229
259
  since counts as not built, so editing the spec and re-running rebuilds what changed. `--from-scratch`
230
- rebuilds everything.
260
+ rebuilds the module; `--from-scratch-chain` rebuilds every module of its chain.
231
261
 
232
262
  ## Rebuilding one functionality
233
263
 
@@ -40,6 +40,9 @@ on npm runs JavaScript compiled from them instead (`npm run build`, into `dist/`
40
40
  before they pack), as Node runs no `.ts` file inside a `node_modules`. `bin/turri.mjs` runs `src/` where there is one,
41
41
  and `dist/` otherwise.
42
42
 
43
+ To update, `git pull` and `npm install` - the second picks up a dependency that changed, pi's say. `npm link` needs
44
+ running only once. A **turri** already running keeps the code it started with: start it again to run what you pulled.
45
+
43
46
  ## In Docker
44
47
 
45
48
  `docker/Dockerfile` builds an image with Node, git, bash, bubblewrap and **turri** linked; the agents' commands and the
@@ -112,6 +112,10 @@ the planner's, the spec-steps agent's, the conformance agents' - is laid out in
112
112
  A module that `requires` another inherits its functional specs; one that `import`s another
113
113
  inherits its definitions, implementation reqs and test reqs.
114
114
 
115
+ An import module - one a `.plain` file imports, or one kept in a `template/` folder - is no codebase of its own. A
116
+ change to it is built in the modules that import it, through any import modules between, whose code is started; when
117
+ none is, nothing is built, and the change goes in with the first of them built.
118
+
115
119
  Template search order: the plain file's own directory, then a sibling `template/`, then
116
120
  `--template-dir`, then `PLAIN_TEMPLATE_DIRS`.
117
121
 
@@ -119,7 +123,22 @@ An agent that goes round in a circle - the same tool called with the same argume
119
123
  nothing in between, or a look (read, grep, find, ls) made again with nothing changed since, however
120
124
  many other looks came between, so the same answer comes back - is let through three times; the next
121
125
  such call is refused with what is happening, and past six its turn is stopped, and the harness goes on
122
- from there as after any turn. The arguments are compared whatever order they come in.
126
+ from there as after any turn. The arguments are compared whatever order they come in. So too an agent whose
127
+ calls to one tool fail ten times in a row, nothing going through - a call its arguments do not fit never reaches
128
+ any guard on the tools.
129
+
130
+ A turn turri stops itself - for any of these, or for its time, below - ends as any turn ends: what the agent said
131
+ stands, `[the turn was stopped: ...]` after it, and the caller does what it does when the agent handed nothing over
132
+ (the explorer's fallback, a nudge, a failed round). The abort that ended it is never taken for the provider
133
+ failing; an abort turri did not make still is. A stop is the work's normal course: it is in the pulse's activity
134
+ and log and the run report's `turn_incidents`, but not said in the chat or a headless run's console - those say
135
+ only the model provider failing or stalling.
136
+
137
+ A tool argument that is a list of objects - the explorer's `interfaces` and `plan`, a reviewer's `problems` - is
138
+ what small models get wrong most. Before a call's arguments are checked, a list sent as JSON text, entries sent as
139
+ JSON text, one object for the list, or a list written inside another argument's text
140
+ (`...</tests_reach_it><plan>[...]</plan>`) are taken as the list; what still is not one is refused saying which
141
+ argument, what was sent, each entry's fields and an example (`list-arguments.ts`).
123
142
 
124
143
  The agents with one thing to decide have a budget of tool calls: the judge 30, the test review and the
125
144
  explorer 40. Past it every tool but the one that hands the decision over refuses, telling it to decide
@@ -241,12 +260,18 @@ use each:
241
260
  - **`my_diff`**: the diff of the code folder from the commit the job started from, new files whole - exactly
242
261
  what the reviewer is shown. Read before handing the work in: every part of the change in it, and nothing else.
243
262
  - **`can_it_fail`**: whether the unit tests catch a bug. The agent gives one change to a code file - a
244
- condition turned round, a value changed - and the unit testing script runs on a fresh copy of the code with
245
- it; the code itself is never touched. If every test still passes, no test catches that bug. Six
263
+ condition turned round, a value changed - and the unit testing script runs with it. Where the testing scripts
264
+ run on a copy (`testing-scripts-run-on: copy`), the change is made to a fresh copy and the code itself is never
265
+ touched. In place, the default, it is made to the code itself, so a script that finds the code from its own path
266
+ sees it; the file is put back as it was once the run ends - passed, failed, hung, the script failing to start, the
267
+ script rewriting the file, turri exiting. Killed outright, the next unit of work starts from the last commit anyway.
268
+ It never runs beside another call of the agent's, so no edit lands while the bug is in. What the script does
269
+ beyond the code - a package copied into a host codebase - it does with the bug in, until the next test run puts the
270
+ real code there. If every test still passes, no test catches that bug. Six
246
271
  runs a job. A bug often makes the code hang instead - a loop that never ends - so a run may take three times
247
272
  as long as the last passing run of the unit tests, within 15 and 60 seconds, and one that does not finish is
248
- reported as a hang, not as a test that caught it. Only where the testing scripts run on a copy
249
- (`testing-scripts-run-on: copy`): in place, the default, there is no copy to change.
273
+ reported as a hang, not as a test that caught it. `mutation-testing: false` in the [config](config.md) - or
274
+ `turri regenerate --mutation-testing false` - takes it away, from the reviewer too.
250
275
  - **`start_service`**, **`service_logs`**, **`stop_service`**: a server or a worker it built, started in the
251
276
  background on this machine, behind the same walls as its shell - the command check, the module's environment, the
252
277
  OS sandbox, the audit while it comes up - to try from outside with `curl` as a client would. Whatever the stack: the
@@ -266,7 +291,8 @@ Passing unit tests prove only what they check, and a coding agent is quick to wr
266
291
  next to nothing - that a function exists, that a result is not empty, that a status is 200 - or code
267
292
  that no test reaches. So, with `review: true` in the [config](config.md), once the unit testing script
268
293
  passes a reviewer on the judge model reads what the work wrote, beside the spec, and changes nothing. It
269
- reviews both halves. The review is off by default - `review: false`, or the key left out - and so is the
294
+ reviews both halves, with the unit testing script word for word in its prompt: a test the script never reaches is
295
+ not run, and checks nothing. The review is off by default - `review: false`, or the key left out - and so is the
270
296
  conformance tests' review: the work goes on once its tests pass.
271
297
 
272
298
  - **The code.** Every behaviour, edge case, validation rule and error the spec states for this work
@@ -375,6 +401,18 @@ halts its codebase: nothing more runs there until the spec changes or the module
375
401
  the command line, `turri regenerate` runs until nothing more can start, one line as each job starts and
376
402
  ends, and exits 1 when any failed.
377
403
 
404
+ The person halts a module's planned work too: `halt` (and `/halt`) given a planned row - `planned-<module>-2`,
405
+ `planned-<module>-waiting` - or the module's name. A module's pulses are planned again from its spec at every look, so
406
+ one planned pulse cannot be taken out alone: the module is halted - its running pulse stopped and rolled back, none of
407
+ its planned pulses started, the modules built on it waiting for it - and what landed stays. A halt the person asked for
408
+ holds through spec changes - `write_spec_diff` brings the spec in without starting the module - until the module is
409
+ asked for again (`regenerate`, `conform`). To build some of it later, or cut it differently, there is `steer`; to drop
410
+ work, the spec.
411
+
412
+ A module the loop looked after whose `.plain` file is gone is forgotten - no rows, nothing waited for - and a codebase
413
+ left behind, or whose spec no longer parses, shows nothing planned: its plan, and what it waited for, were the spec's
414
+ before.
415
+
378
416
  ### How the work is cut into jobs
379
417
 
380
418
  A job that renders the whole of a new spec is too big to build well, and a render per functional spec,
@@ -503,8 +541,9 @@ testing script, stops before it starts and says which skill adds it.
503
541
  `prepare-environment-script:` in the config, else the one `prepare_environment*.sh` at the root, else in
504
542
  `test_scripts/` - on the build, before every run of the conformance testing script: the harness's own, and the agents'
505
543
  `run_conformance_tests`. Both get the same build folder - the code in place, or the same fresh copy - so what it sets up
506
- for that build, the conformance testing script finds. With conformance off it is not run. The conformance agents are
507
- shown it, before the conformance testing script.
544
+ for that build, the conformance testing script finds. With conformance off it is not run. Every agent shown the
545
+ conformance testing script - the explorer, the conformance agent, the judge, the code fixer and the repair agent - is
546
+ shown it too, before the conformance testing script.
508
547
 
509
548
  **Where they run.** On this machine, as you would run them: unfenced - no sandbox, no command check, no audit - in
510
549
  your own environment with this machine's toolchains, turri's model providers' API keys alone left out. They are yours,
@@ -543,7 +582,8 @@ does not find them:
543
582
  testing-scripts-run-on: copy
544
583
  ```
545
584
 
546
- `can_it_fail` needs a copy to change, so an agent has it only where the scripts run on one.
585
+ `can_it_fail` works either way: on a copy it changes the copy; in place it changes the code for the one run and puts
586
+ it back.
547
587
 
548
588
  ### When the environment lacks something
549
589
 
@@ -700,7 +740,7 @@ with no agent and no testing script. Moving specs into a module the code was not
700
740
  change to the code brings that module's code in, so the codebase stops: it has to be started over - its code
701
741
  and conformance tests taken out, committed so its history keeps them, and the chain built again from the
702
742
  bottom. That is never done unasked. In the chat the model asks the person, saying why, and calls
703
- `regenerate` with `from_scratch` once they agree; `turri regenerate` and `spec-diff` ask at the terminal, and
743
+ `regenerate` with `from_scratch: "module"` once they agree; `turri regenerate` and `spec-diff` ask at the terminal, and
704
744
  `--start-over` agrees in advance - with no terminal and no flag, the run stops there, exit 1, saying so.
705
745
 
706
746
  ## Conformance tests
@@ -836,7 +876,8 @@ coding agent that fixes the code is told the same of the tests: it can read them
836
876
  Before the test author starts, an explorer - an agent in
837
877
  the code's folder with the file tools alone: it reads the code, runs nothing and changes nothing - hands over everything
838
878
  the author needs, in parts: how to build and run it; how the conformance tests reach it as the project's
839
- conformance testing script runs them - the explorer is given the script, and says what it builds or
879
+ conformance testing script runs them - the explorer is given the script, and the prepare script before it where there
880
+ is one, and says what they build or
840
881
  installs and what the tests depend on or start (a package, a module, an entry point, by its exact name);
841
882
  how each functionality is reached from outside
842
883
  (the command, or the route, method and the request and response fields); what it needs around it; and
@@ -919,7 +960,8 @@ culprit: what it does with the tests, the tests fit; what it needs of the build,
919
960
  - **the code:** the coding agent - in the code's folder, reading the tests but never changing them - fixes it,
920
961
  and keeps its unit tests passing. The judge quotes the spec's own words the code does not meet, or the testing
921
962
  script's for what it needs of the build (`script_needs`: a build output, an entry point, a module) - each checked
922
- by the harness against the text it quotes;
963
+ by the harness against the text it quotes. The acceptance tests are in that text, labelled as their tests are:
964
+ for a spec change, those of every functional spec it touches, not only the last one's;
923
965
  - **the tests:** the conformance agent corrects them to what the spec says;
924
966
  - **the spec:** two functional specs cannot both hold, whatever the code does;
925
967
  - **the environment:** neither the code nor the tests can fix it - only the person can, in what the run is given:
@@ -961,7 +1003,9 @@ spending the rest of its 20 attempts on it. Two failures are the same once what
961
1003
  taken out of their lines - numbers, times, paths, colour codes, and the ids a service makes up for each
962
1004
  response, a UUID or a correlation id. Nothing changes either when the agent sent to fix the code or the tests
963
1005
  changes no file: two such fixes in a row, and the run stops. The conformance agent has the testing script in its prompt,
964
- and is told to fit the tests' own build to it.
1006
+ and is told to fit the tests' own build to it. The code fixer has the testing scripts its fixes are run by - the
1007
+ conformance testing script, the prepare script before it, and the unit testing script - word for word in its task:
1008
+ what the conformance testing script needs of the build, it reads there, not only in the judge's quote of it.
965
1009
 
966
1010
  **Escalation.** A failure judged the tests' goes to the conformance agent first: it owns the tests. When the run then
967
1011
  fails the same way - the fix changed nothing, or nothing that mattered - the judge is asked again, now whether the
@@ -1067,8 +1111,7 @@ both. Each set goes where its folder goes - copied up the chain, committed, roll
1067
1111
  | --- | --- |
1068
1112
  | Where things are | entry points, layout, where each functionality lives |
1069
1113
  | How to build, run and test | the commands that work, what had to be installed |
1070
- | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open |
1071
- | Spec gaps | what the spec should say and does not - a behaviour the person would want to decide, as the question it leaves |
1114
+ | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open - and the tests that assert it, when any do; one no test asserts is written down all the same |
1072
1115
  | Pitfalls | what went wrong and what fixed it - and what the debugger found, filed by turri itself |
1073
1116
  | Pulses | written by turri alone, as each pulse ends: the last ten, a line each |
1074
1117
 
@@ -1085,9 +1128,16 @@ it landed, a commit of its own (`pulse 3 rolled back: …`) when it did not - so
1085
1128
  commit, keeps it. `update_notes` refuses the section. What the debugger finds is filed in the pitfalls the moment it
1086
1129
  finds it, not left to the coding agent to write down.
1087
1130
 
1088
- The spec gaps a pulse's agents add are said in its report - "Spec gaps its agents met ... Put each to the user" - so
1089
- the conversation asks you, and writes the ones you decide into the spec; the gaps stay in the notes, for the agents
1090
- after, until then.
1131
+ A spec gap - what the spec should say and does not, a behaviour you would want to decide - is not a note: the notes
1132
+ are the next agent's, and a gap is yours. An agent reports one with `report_spec_gap`, giving the question it leaves
1133
+ and the assumption it made meanwhile; turri writes that assumption into the notes' assumptions, so the code built on
1134
+ it is known for what it is. The gaps a pulse's agents report are said in its report - "Spec gaps its agents met ... Put
1135
+ each to the user", each with its assumption - so the conversation asks you, and writes the ones you decide into the
1136
+ spec; the pulse that builds the answer finds the assumption it replaces in the notes, and the tests it names.
1137
+ A headless run has no one to ask: it prints each gap under its pulse, and lists them in its run report's
1138
+ `spec_gaps` ([running unattended](headless.md#the-run-report)). However many gaps a pulse's agents report, they
1139
+ are put to you - never a reason to stop the pulse; the tool is guarded like any other. A notes
1140
+ file from before keeps no spec gaps section: its lines are dropped as it is read.
1091
1141
 
1092
1142
  Stubborn on the specs, flexible on the assumptions: the spec is never an assumption and never
1093
1143
  copied into the notes, and where the two disagree the spec wins. An agent builds on the assumptions
@@ -1110,8 +1160,8 @@ Leaving notes is required, and only through the `update_notes` tool. The file to
1110
1160
  notes file, and a change made to it any other way - from the shell, by a script - is undone. An agent
1111
1161
  that finishes without calling `update_notes` is asked again, up to three times; if it still has not,
1112
1162
  the activity log says so. The turn that asks is for the notes alone: the work is done - its testing script's run
1113
- passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` is
1114
- refused, and an agent that keeps calling them has its turn stopped. What
1163
+ passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` and
1164
+ `report_spec_gap` is refused, and an agent that keeps calling the refused ones has its turn stopped. What
1115
1165
  landed is what the harness checked; nothing changes after it. Only work that lands is asked: a job whose code or tests do not pass - or whose
1116
1166
  testing script cannot run - is rolled back, notes and all, so its agent is not asked to leave any.
1117
1167
 
@@ -52,7 +52,7 @@ last one - one answer, one change, as an interview writes them. `spawn` is unpac
52
52
  each change to write the next at once, not to carry on with an interview it does not have.
53
53
 
54
54
  `questioning:` under `metadata:` names the steps the questioning level caps (`src/questioning.ts`) - `brood`'s
55
- `[stack, product]`. When there are any and someone to ask, the harness itself asks the first question of the first
55
+ `[stack, product]`, `bud`'s `[product]`. When there are any and someone to ask, the harness itself asks the first question of the first
56
56
  step: how many questions those steps may ask - light (3), medium (5), thorough (10) or best judgement - and tells the
57
57
  agent the answer beside each step's instructions, with how broad each question is to be: broad at light, a whole area
58
58
  at once, narrow at thorough, an edge case at a time. Every level covers the same ground, in less or more depth. In a
@@ -63,7 +63,7 @@ questions each step has asked, are kept in the run's `run.json`, so a resumed ru
63
63
  or a run with nobody to ask, is not capped.
64
64
 
65
65
  `spec-diff-per-answer:` under `metadata:` names the steps where every answer is a spec change - `brood`'s
66
- `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
66
+ and `bud`'s `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
67
67
  with `write_spec_diff` (a confirmation, or a question dismissed, owes nothing), and `write_spec_diff` no longer waits
68
68
  for an answer before a change: the agent writes as many as the step needs, those it decides itself included. The
69
69
  level limits the questions, never the spec changes.
@@ -133,7 +133,9 @@ change the step makes and puts its findings on the executor's next tool result.
133
133
  - **Interview the user.** `ask_user` puts one question to the person. In the TUI it is a dialog;
134
134
  from the CLI the options are numbered. Offering choices is required, not optional - a call with
135
135
  neither `options` nor `free_form: true` is refused - and every list carries "Something else…".
136
- `multi_select: true` keeps offering what is left until they are done. The skill's agent talks in a
136
+ `multi_select: true` gives every option a box, ticked and unticked as it is chosen - a pick made by mistake is
137
+ undone by choosing it again - until they choose Done; what they type is one more box, ticked. "Something
138
+ else…", "Chat about this" and Done are no boxes. The skill's agent talks in a
137
139
  session of its own that the person never sees, so what the person must read to answer - the brief
138
140
  to confirm, the plan to approve - it passes as `ask_user`'s `context`, shown above the question in
139
141
  the dialog; `brood`, `spawn` and `bud` pass their briefs so. The agents are told to keep it to what can be taken in at