nukadoko 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 (200) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +541 -3
  3. data/README.ja.md +20 -5
  4. data/README.md +12 -6
  5. data/docs/ci.ja.md +542 -0
  6. data/docs/ci.md +635 -0
  7. data/docs/commands.ja.md +1524 -0
  8. data/docs/commands.md +1281 -0
  9. data/docs/engines.json +19 -0
  10. data/docs/execution-events.ja.md +336 -0
  11. data/docs/execution-events.md +423 -0
  12. data/docs/glossary.json +1348 -0
  13. data/docs/guide.ja.md +733 -0
  14. data/docs/guide.md +815 -0
  15. data/docs/intent.ja.md +133 -0
  16. data/docs/intent.md +156 -0
  17. data/docs/layout.ja.md +442 -0
  18. data/docs/layout.md +399 -0
  19. data/docs/releasing.ja.md +186 -0
  20. data/docs/releasing.md +237 -0
  21. data/docs/ruby/reference.ja.md +302 -0
  22. data/docs/ruby/reference.md +368 -0
  23. data/docs/spec.ja.md +8916 -0
  24. data/docs/spec.md +11250 -0
  25. data/docs/tutorial.ja.md +451 -0
  26. data/docs/tutorial.md +458 -0
  27. data/docs/typescript/adopting.ja.md +231 -0
  28. data/docs/typescript/adopting.md +251 -0
  29. data/docs/typescript/doors.ja.md +301 -0
  30. data/docs/typescript/doors.md +329 -0
  31. data/docs/typescript/migration-playwright-test.ja.md +189 -0
  32. data/docs/typescript/migration-playwright-test.md +212 -0
  33. data/docs/typescript/migration.ja.md +391 -0
  34. data/docs/typescript/migration.md +505 -0
  35. data/docs/typescript/reference.ja.md +176 -0
  36. data/docs/typescript/reference.md +197 -0
  37. data/docs/typescript/upgrading.ja.md +1774 -0
  38. data/docs/typescript/upgrading.md +2224 -0
  39. data/docs/web-app.ja.md +627 -0
  40. data/docs/web-app.md +659 -0
  41. data/docs/writing-scenarios.ja.md +544 -0
  42. data/docs/writing-scenarios.md +563 -0
  43. data/lib/nukadoko/base.rb +12 -5
  44. data/lib/nukadoko/changed_files.rb +95 -0
  45. data/lib/nukadoko/check.rb +459 -51
  46. data/lib/nukadoko/claim_drops.rb +271 -0
  47. data/lib/nukadoko/claim_line.rb +24 -4
  48. data/lib/nukadoko/claim_rules.rb +143 -1
  49. data/lib/nukadoko/claim_sides.rb +157 -9
  50. data/lib/nukadoko/cli.rb +395 -48
  51. data/lib/nukadoko/codes.json +246 -21
  52. data/lib/nukadoko/codes.rb +21 -4
  53. data/lib/nukadoko/command.rb +120 -13
  54. data/lib/nukadoko/command_help.rb +128 -0
  55. data/lib/nukadoko/compat.rb +469 -0
  56. data/lib/nukadoko/criteria.rb +1 -1
  57. data/lib/nukadoko/definition.rb +157 -7
  58. data/lib/nukadoko/error_frames.rb +6 -3
  59. data/lib/nukadoko/events/count.rb +146 -0
  60. data/lib/nukadoko/events/counted.rb +114 -0
  61. data/lib/nukadoko/events/format.rb +257 -0
  62. data/lib/nukadoko/events/lists.rb +154 -0
  63. data/lib/nukadoko/events/path.rb +285 -0
  64. data/lib/nukadoko/events/read.rb +284 -0
  65. data/lib/nukadoko/events/reader.rb +490 -0
  66. data/lib/nukadoko/events/selection.rb +252 -0
  67. data/lib/nukadoko/events/tally.rb +438 -0
  68. data/lib/nukadoko/features.rb +2 -2
  69. data/lib/nukadoko/fixtures.rb +160 -35
  70. data/lib/nukadoko/http_recording.rb +6 -2
  71. data/lib/nukadoko/intent.rb +364 -0
  72. data/lib/nukadoko/intent_file.rb +81 -0
  73. data/lib/nukadoko/intent_view.rb +190 -0
  74. data/lib/nukadoko/js_json.rb +2 -1
  75. data/lib/nukadoko/judge.rb +2 -2
  76. data/lib/nukadoko/judgment_file.rb +1 -1
  77. data/lib/nukadoko/judgments.rb +4 -4
  78. data/lib/nukadoko/measure_mcp.rb +202 -0
  79. data/lib/nukadoko/parts.rb +8 -2
  80. data/lib/nukadoko/path_view.rb +252 -0
  81. data/lib/nukadoko/place_rows.rb +161 -0
  82. data/lib/nukadoko/program.rb +1265 -51
  83. data/lib/nukadoko/program_log.rb +122 -0
  84. data/lib/nukadoko/program_shape.rb +385 -0
  85. data/lib/nukadoko/project_fixtures.rb +43 -10
  86. data/lib/nukadoko/project_program.rb +5 -4
  87. data/lib/nukadoko/repeated_prefix.rb +310 -0
  88. data/lib/nukadoko/report_run.rb +3 -3
  89. data/lib/nukadoko/run.rb +1148 -159
  90. data/lib/nukadoko/run_record.rb +70 -46
  91. data/lib/nukadoko/scaffold.rb +24 -6
  92. data/lib/nukadoko/schema.rb +15 -2
  93. data/lib/nukadoko/secrets.rb +55 -5
  94. data/lib/nukadoko/states.rb +478 -0
  95. data/lib/nukadoko/step.rb +71 -2
  96. data/lib/nukadoko/step_fixtures.rb +52 -3
  97. data/lib/nukadoko/summary.rb +799 -29
  98. data/lib/nukadoko/table.rb +4 -2
  99. data/lib/nukadoko/text_fit.rb +20 -7
  100. data/lib/nukadoko/trace.rb +152 -45
  101. data/lib/nukadoko/tree_passes.rb +95 -33
  102. data/lib/nukadoko/underneath.rb +311 -0
  103. data/lib/nukadoko/version.rb +1 -1
  104. data/lib/nukadoko/vocabulary.rb +166 -23
  105. data/lib/nukadoko/walk.rb +2 -2
  106. data/lib/nukadoko/walk_step.rb +1 -1
  107. data/lib/nukadoko.rb +23 -0
  108. data/llms.txt +41 -34
  109. data/sig/generated/nukadoko/base.rbs +4 -4
  110. data/sig/generated/nukadoko/changed_files.rbs +42 -0
  111. data/sig/generated/nukadoko/check.rbs +147 -10
  112. data/sig/generated/nukadoko/claim_drops.rbs +135 -0
  113. data/sig/generated/nukadoko/claim_line.rbs +11 -0
  114. data/sig/generated/nukadoko/claim_rules.rbs +49 -4
  115. data/sig/generated/nukadoko/claim_sides.rbs +63 -12
  116. data/sig/generated/nukadoko/cli.rbs +80 -7
  117. data/sig/generated/nukadoko/codes.rbs +19 -4
  118. data/sig/generated/nukadoko/command.rbs +68 -1
  119. data/sig/generated/nukadoko/command_help.rbs +18 -0
  120. data/sig/generated/nukadoko/compat.rbs +392 -0
  121. data/sig/generated/nukadoko/criteria.rbs +1 -1
  122. data/sig/generated/nukadoko/definition.rbs +50 -0
  123. data/sig/generated/nukadoko/error_frames.rbs +1 -1
  124. data/sig/generated/nukadoko/events/count.rbs +69 -0
  125. data/sig/generated/nukadoko/events/counted.rbs +70 -0
  126. data/sig/generated/nukadoko/events/format.rbs +163 -0
  127. data/sig/generated/nukadoko/events/lists.rbs +47 -0
  128. data/sig/generated/nukadoko/events/path.rbs +161 -0
  129. data/sig/generated/nukadoko/events/read.rbs +109 -0
  130. data/sig/generated/nukadoko/events/reader.rbs +226 -0
  131. data/sig/generated/nukadoko/events/selection.rbs +100 -0
  132. data/sig/generated/nukadoko/events/tally.rbs +227 -0
  133. data/sig/generated/nukadoko/features.rbs +6 -4
  134. data/sig/generated/nukadoko/fixtures.rbs +67 -11
  135. data/sig/generated/nukadoko/http_recording.rbs +1 -1
  136. data/sig/generated/nukadoko/intent.rbs +132 -0
  137. data/sig/generated/nukadoko/intent_file.rbs +46 -0
  138. data/sig/generated/nukadoko/intent_view.rbs +69 -0
  139. data/sig/generated/nukadoko/judgment_file.rbs +1 -1
  140. data/sig/generated/nukadoko/judgments.rbs +1 -1
  141. data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
  142. data/sig/generated/nukadoko/parts.rbs +2 -2
  143. data/sig/generated/nukadoko/path_view.rbs +105 -0
  144. data/sig/generated/nukadoko/place_rows.rbs +43 -0
  145. data/sig/generated/nukadoko/program.rbs +627 -23
  146. data/sig/generated/nukadoko/program_log.rbs +67 -0
  147. data/sig/generated/nukadoko/program_shape.rbs +147 -0
  148. data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
  149. data/sig/generated/nukadoko/project_program.rbs +2 -1
  150. data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
  151. data/sig/generated/nukadoko/report_run.rbs +1 -1
  152. data/sig/generated/nukadoko/run.rbs +286 -41
  153. data/sig/generated/nukadoko/run_record.rbs +20 -12
  154. data/sig/generated/nukadoko/scaffold.rbs +3 -0
  155. data/sig/generated/nukadoko/schema.rbs +5 -0
  156. data/sig/generated/nukadoko/secrets.rbs +26 -3
  157. data/sig/generated/nukadoko/states.rbs +214 -0
  158. data/sig/generated/nukadoko/step.rbs +58 -1
  159. data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
  160. data/sig/generated/nukadoko/summary.rbs +256 -2
  161. data/sig/generated/nukadoko/table.rbs +3 -2
  162. data/sig/generated/nukadoko/trace.rbs +108 -33
  163. data/sig/generated/nukadoko/tree_passes.rbs +36 -8
  164. data/sig/generated/nukadoko/underneath.rbs +141 -0
  165. data/sig/generated/nukadoko/vocabulary.rbs +45 -6
  166. data/skills/nukadoko/SKILL.md +18 -18
  167. data/skills/nukadoko/references/checking-steps.md +16 -83
  168. data/skills/nukadoko/references/diagnosing.md +6 -6
  169. data/skills/nukadoko/references/evidence.md +19 -6
  170. data/skills/nukadoko/references/exploring.md +22 -7
  171. data/skills/nukadoko/references/fixtures.md +12 -32
  172. data/skills/nukadoko/references/judgments.md +12 -0
  173. data/skills/nukadoko/references/maintenance.md +1 -1
  174. data/skills/nukadoko/references/merge-risk.md +1 -1
  175. data/skills/nukadoko/references/parts.md +46 -23
  176. data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
  177. data/skills/nukadoko/references/program.md +168 -169
  178. data/skills/nukadoko/references/reviewing.md +20 -20
  179. data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
  180. data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
  181. data/skills/nukadoko/references/ruby/fixtures.md +34 -0
  182. data/skills/nukadoko/references/ruby/program.md +112 -0
  183. data/skills/nukadoko/references/ruby/step-files.md +115 -0
  184. data/skills/nukadoko/references/running.md +34 -34
  185. data/skills/nukadoko/references/scenario-rules.md +7 -6
  186. data/skills/nukadoko/references/states.md +7 -1
  187. data/skills/nukadoko/references/step-files.md +41 -120
  188. data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
  189. data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
  190. data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
  191. data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
  192. data/skills/nukadoko/references/typescript/fixtures.md +56 -0
  193. data/skills/nukadoko/references/typescript/program.md +111 -0
  194. data/skills/nukadoko/references/typescript/step-files.md +104 -0
  195. data/skills/nukadoko/references/verdicts.md +10 -10
  196. data/skills/nukadoko/references/writing-steps.md +67 -67
  197. data/skills/nukadoko/references/writing-the-feature.md +1 -1
  198. data/skills/nukadoko-verification/SKILL.md +13 -8
  199. metadata +103 -7
  200. data/skills/nukadoko/references/ruby.md +0 -80
@@ -5,35 +5,19 @@
5
5
  A Then judges, never in code: its step declares `claims` in place of `run`,
6
6
  naming the value it reads, how it compares it, and where its expected value
7
7
  comes from. nukadoko compares, and the step record keeps each claim with both
8
- values and their sources. A typed Then never calls `expect` or `node:assert`.
9
- `defineStep` refuses a claim step that also declares `run`, `returns`,
10
- `mutates`, or `parts`. `nuka check` refuses a Then bound to a step that runs
8
+ values and their sources; a Then never asserts in code. `nuka check` refuses
9
+ a Then bound to a step that runs
11
10
  (`then-without-claims`) and a claim step in a Given or a When
12
11
  (`claims-outside-then`): a step that reads a value for a later Then is a When.
13
-
14
- ```ts
15
- import { defineStep, z } from "nukadoko";
16
- import runTally from "./run-tally.ts";
17
-
18
- export default defineStep({
19
- pattern: "it exits with {code:int}",
20
- args: z.object({
21
- code: z.number().describe("The expected exit code"),
22
- exitCode: runTally.returns.shape.exitCode,
23
- }),
24
- from: { exitCode: [runTally, "exitCode"] },
25
- claims: [{ actual: "exitCode", compare: "equal", expected: "code" }],
26
- });
27
- ```
12
+ How a step file writes one, with an example for each section here, is
13
+ `typescript/checking-steps.md` or `ruby/checking-steps.md`.
28
14
 
29
15
  A claim is `{ actual, view?, at?, count?, compare, expected, expected_view? }`.
30
16
  `nuka scaffold --then --from <step>.<key>` writes this shape when the
31
17
  line states one value (for a word such as `empty`, the literal of the
32
- chained key's type); `examples/` has a finished Then for a CLI, an API,
33
- and a workflow (`examples/workflow.md` claims a literal and a sentence
34
- value in one step). Write claims as plain data (no getter, Proxy, class
35
- instance, hole, or unknown key) and export what `defineStep` returned: it
36
- validates one frozen copy, and a copy of the step (`{ ...step }`) fails.
18
+ chained key's type); `typescript/examples/` has a finished Then for a CLI, an API,
19
+ and a workflow (`typescript/examples/workflow.md` claims a literal and a sentence
20
+ value in one step), and `ruby/examples/cli.md` has the CLI's Thens in Ruby.
37
21
 
38
22
  ## Where the expected value comes from
39
23
 
@@ -41,11 +25,10 @@ Pick the source from the sentence; the record names it in `expected_from`.
41
25
 
42
26
  - **The sentence states it** (a capture, the docstring, or the table):
43
27
  `expected: "code"`, recorded as `sentence:code`. The key is required in
44
- `args`, with no default, and its schema must not rewrite the value
45
- (`z.coerce`, a transform, a pipe, `trim`, `catch`, a default inside, or a
46
- refine on an object, an array, or the args object is refused; a schema that
47
- still changes it leaves the claim `unjudged`). Read it as JSON, lines, or a
48
- comma list with `expected_view` on a `z.string()` key. With no `observe`, a
28
+ `args`, with no default, and its schema must not rewrite the value (a
29
+ coercion, a transform, or a default is refused; a schema that still changes
30
+ it leaves the claim `unjudged`). Read it as JSON, lines, or a comma list with
31
+ `expected_view` on a string key. With no `observe`, a
49
32
  claim reads each value the line states: an unread capture is refused, an
50
33
  unread docstring or table `claim-sentence-unread`.
51
34
  - **An earlier step returned it** ("the item count is unchanged"): `expected:
@@ -62,41 +45,6 @@ Pick the source from the sentence; the record names it in `expected_from`.
62
45
  - **A second reading** ("A is listed before B"): `expected: { observe:
63
46
  "<path>" }`, a value `observe` returned beside the actual one.
64
47
 
65
- ```ts
66
- import { defineStep, z } from "nukadoko";
67
- import countItems from "./count-items.ts";
68
-
69
- export default defineStep({
70
- pattern: "the item count is unchanged",
71
- args: z.object({ before: countItems.returns.shape.count }),
72
- from: { before: [countItems, "count"] },
73
- async observe({ request }) {
74
- return { items: await (await request.get("/items")).json() };
75
- },
76
- claims: [{ actual: "items", count: true, compare: "equal", expected: { from: "before" } }],
77
- });
78
- ```
79
-
80
- ```ts
81
- import { defineStep, z } from "nukadoko";
82
-
83
- export default defineStep({
84
- pattern: "{first:string} is listed before {second:string}",
85
- args: z.object({
86
- first: z.string().describe("The title expected first"),
87
- second: z.string().describe("The title expected after it"),
88
- }),
89
- async observe({ page }, { first, second }) {
90
- const titles = await page.locator(".result h2").allTextContents();
91
- // A title that is not there is undefined, and an undefined value breaks the claim.
92
- const at = (title: string) => (titles.includes(title) ? titles.indexOf(title) : undefined);
93
- return { firstAt: at(first), secondAt: at(second) };
94
- },
95
- poll: { timeout_ms: 5000 },
96
- claims: [{ actual: "firstAt", compare: "less-than", expected: { observe: "secondAt" } }],
97
- });
98
- ```
99
-
100
48
  ## The actual value
101
49
 
102
50
  `actual` is a path whose first segment is a `from` key or a key `observe`
@@ -147,7 +95,7 @@ an expected key (`claim-expected-transformed`).
147
95
 
148
96
  ## Observe, poll, and a boolean
149
97
 
150
- `observe(fixtures, args)` reads the world when no earlier step returned the
98
+ `observe(fixtures, args)` reads the system when no earlier step returned the
151
99
  value. It gets every args key but the ones a claim compares with, or the `from`
152
100
  key of an actual compared with `{ observe }`, and reading one, or calling
153
101
  `resultOf`, throws: an earlier step's value reaches a claim through `from`
@@ -156,9 +104,9 @@ a text, a number, a list (a claim with `count: true` counts it, so return the
156
104
  list, not its length). A boolean literal is refused when the actual value comes
157
105
  from `observe`, since `{ visible: true }` is the judgment made in code. For a
158
106
  yes or no in the sentence, return the word it uses
159
- (`outcome: "accepted" | "refused"`, `examples/workflow.md`), or the measurement
107
+ (`outcome: "accepted" | "refused"`, `typescript/examples/workflow.md`), or the measurement
160
108
  behind it. Give every `args` and `returns` field of a step you write or rewrite
161
- a `.describe()`, so `nuka describe` connects a criterion's wording to the field
109
+ a description, so `nuka describe` connects a criterion's wording to the field
162
110
  that answers it; a note on a step you are not changing is a report.
163
111
 
164
112
  `poll: { timeout_ms }` runs `observe` every 100 ms until every claim holds on
@@ -175,25 +123,10 @@ so it is one step; "is in trial" and "is not in trial" are two steps.
175
123
 
176
124
  ## A page by role and name
177
125
 
178
- A When may still wait with Playwright's `expect` before it acts (outside
179
- `playwright test`, on Playwright 1.61.1, a failing `expect.soft` throws at once,
180
- and `toMatchAriaSnapshot`, `toHaveScreenshot`, and `toMatchSnapshot` throw
181
- `"<name>() must be called during the test"`). For what a page shows, a Then
126
+ A When may still wait on the page before it acts. For what a page shows, a Then
182
127
  returns the page or a locator from `observe` and claims `fits-aria-snapshot`
183
128
  against the docstring (the one required `args` key no capture or `from` fills);
184
- nukadoko takes the ARIA snapshot, and the record keeps it whole:
185
-
186
- ```ts
187
- import { defineStep, z } from "nukadoko";
188
-
189
- export default defineStep({
190
- pattern: "the scores form shows",
191
- args: z.object({ tree: z.string().describe("Part of the form's ARIA snapshot") }),
192
- observe: ({ page }) => ({ form: page.getByRole("form", { name: "Scores" }) }),
193
- poll: { timeout_ms: 5000 },
194
- claims: [{ actual: "form", compare: "fits-aria-snapshot", expected: "tree" }],
195
- });
196
- ```
129
+ nukadoko takes the ARIA snapshot, and the record keeps it whole.
197
130
 
198
131
  The docstring states part of the tree (`writing-the-feature.md`). A name between
199
132
  slashes, `[active]`, and a tree that names nothing are refused
@@ -53,11 +53,11 @@ need more than a glance.
53
53
  3. `page_events`, if the step opened a browser: a console error, an
54
54
  uncaught page error, or a failed request recorded there can explain a
55
55
  failure nothing else on the step record mentions.
56
- 4. `program-log.txt` beside the record, when `observed.program_log` names it,
57
- and `program-log-late.txt` when the run summary names one: the lines the
58
- program under test wrote for this step's own requests, such as the error
59
- behind a 500, and `events.jsonl` when `observed.events` names it: each
60
- statement, job, and call it made (`program.md`).
56
+ 4. `program-log.<service>.txt` beside the record, when `observed.program_log`
57
+ names it, and `program-log-late.<service>.txt` when the summary names one:
58
+ the lines each service wrote for this step's own requests, such as the error
59
+ behind a 500, and `events.<service>.jsonl` when `observed.events.services`
60
+ names it: each statement, job, and call that service made (`program.md`).
61
61
  5. `nuka do <step> --use <upstream-step-record-id>` when the record
62
62
  sharpens a hypothesis rather than confirming it ("Testing a hypothesis
63
63
  without a full re-run").
@@ -165,7 +165,7 @@ true` in `nukadoko.config.ts`, `evidence.requests_trace` names a trace
165
165
  body that came back, redacted as http.jsonl is. http.jsonl holds the same
166
166
  facts as text, and is quicker to read.
167
167
 
168
- A Then that read a page while a request to the world was in flight says so on
168
+ A Then that read a page while a request to the system was in flight says so on
169
169
  its summary line (`read with a request in flight`, each request with the step
170
170
  that sent it), and its record's `pages` name each page's `last_response` and
171
171
  `in_flight` in `page_requests`, whose `span_id` finds the page's `http.jsonl`
@@ -7,6 +7,13 @@ response body past the 16 KiB `http.jsonl` keeps. Reach for the `evidence` fixtu
7
7
  of `console.log`-ing it away or writing it to disk with no place on the
8
8
  step record to point back at:
9
9
 
10
+ ```ruby
11
+ def run(evidence:, request:)
12
+ res = request.get("/orders")
13
+ evidence.attach("orders.json", res.body)
14
+ end
15
+ ```
16
+
10
17
  ```ts
11
18
  async run({ evidence, request }, args) {
12
19
  const res = await request.get("/orders");
@@ -38,7 +45,12 @@ answers itself never reaches nukadoko, so it has no line; a mocked
38
45
 
39
46
  A step that calls a program's MCP server uses the SDK's own `Client`,
40
47
  connected in a fixture, with its transport passed through `measureMcp`
41
- (from `nukadoko`); nukadoko adds no client:
48
+ (from `nukadoko`, `Nukadoko.measure_mcp` in the gem); nukadoko adds no
49
+ client:
50
+
51
+ ```ruby
52
+ client = MCP::Client.new(transport: Nukadoko.measure_mcp(MCP::Client::HTTP.new(url: "#{base_url}/mcp")))
53
+ ```
42
54
 
43
55
  ```ts
44
56
  await client.connect(measureMcp(new StreamableHTTPClientTransport(new URL("/mcp", baseURL))));
@@ -49,7 +61,7 @@ step's `mcp.jsonl` (`evidence.mcp`, counted by `observed.mcp`): the
49
61
  method, the tool, prompt, or resource, `params` and `result` kept like
50
62
  a body, `is_error` (the tool reported an error), `error` (a JSON-RPC
51
63
  error), `duration_ms`, or `unanswered`. The call carries the step's
52
- trace context in `params._meta.traceparent`, and over HTTP to the world
64
+ trace context in `params._meta.traceparent`, and over HTTP to the system
53
65
  in its header too, so the server's events for it are the step's
54
66
  (`references/program.md`). An error answer is a result the step reads,
55
67
  never a failure nukadoko decides. `nuka check` notes
@@ -84,7 +96,7 @@ process started through `node:child_process` instead of `runCommand`
84
96
  recorded request (a database client, a pool opened before the step),
85
97
  what a WebSocket from a library over `node:http` (the `ws` package) or a
86
98
  CONNECT tunnel carried after its handshake, a UDP
87
- datagram sent through `node:dgram`, a Chromium page's request to the world that went without a `traceparent` because the page's DevTools session failed, or a path the step wrote whose identity nukadoko could not read. Such an
99
+ datagram sent through `node:dgram`, a Chromium page's request to the system that went without a `traceparent` because the page's DevTools session failed, or a path the step wrote whose identity nukadoko could not read. Such an
88
100
  entry says the record holds no evidence of what that action did. Start
89
101
  the program with `runCommand`, or attach the evidence the action
90
102
  produced. An empty list means nukadoko saw nothing it could not measure,
@@ -102,9 +114,10 @@ the first. A name that differs only by case counts as the same name, so
102
114
  the second call is suffixed the same way (`Report.txt`, then
103
115
  `report-2.txt`) and the two do not share one path. A harness file name is
104
116
  refused with `ReservedEvidenceNameError`: `record.json`, `final.png`,
105
- `trace.zip`, `http.jsonl`, `program-log.txt`, `program-log-late.txt`,
106
- `events.jsonl`, `events-late.jsonl`, `events-read.jsonl`, `mcp.jsonl`, `judged` (a
107
- claim step's `judged_view`), `world` under `nuka do`, and `process-<n>.stdout.txt`,
117
+ `trace.zip`, `http.jsonl`, `program-log.<service>.txt`, `program-log-late.<service>.txt`,
118
+ `events.<service>.jsonl`, `events-late.<service>.jsonl`,
119
+ `events-read.jsonl`, `mcp.jsonl`, `judged` (a claim step's
120
+ `judged_view`), `system` under `nuka do`, and `process-<n>.stdout.txt`,
108
121
  `process-<n>.stderr.txt`, `process-<n>.stdin.txt`, and
109
122
  `process-<n>.json` (what a `runCommand` process printed and was given,
110
123
  and the entry of one that started after the step ended), in any case.
@@ -12,8 +12,25 @@ not name is not recorded. That is right for a step a scenario relies on,
12
12
  and wrong for the first look at a system nobody has described yet.
13
13
 
14
14
  Write one probe step for the looking. Give it no `pattern`, so it can
15
- never become a line in a feature, and a `returns` of `z.unknown()`, so
16
- nothing is filtered out:
15
+ never become a line in a feature, and a `returns` that keeps the body
16
+ whole, so nothing is filtered out:
17
+
18
+ ```ruby
19
+ class Probe < Nukadoko::Step
20
+ description "Send one request and return the whole response, for looking at"
21
+ args { string :path, "Path under the program's URL" }
22
+ returns do
23
+ number :status
24
+ unknown :body
25
+ end
26
+ mutates false
27
+
28
+ def run(request:, args:)
29
+ res = request.get(args.path)
30
+ { status: res.status, body: res.body }
31
+ end
32
+ end
33
+ ```
17
34
 
18
35
  ```ts
19
36
  import { defineStep, z } from "nukadoko";
@@ -34,9 +51,7 @@ export default defineStep({
34
51
 
35
52
  `nuka do probe --args '{"path":"/accounts/1"}'` then prints the whole
36
53
  thing, because `do` writes the step record to stdout. One probe lasts a
37
- project; write it once and stop guessing at shapes.
38
-
39
- A permissive `returns` is deliberate here and stays confined to the probe.
54
+ project; write it once and stop guessing at shapes. A permissive `returns` is deliberate here and stays confined to the probe.
40
55
  The moment you know the shape, the step that a scenario will name declares
41
56
  it properly. A probe that drifts into being relied on is a contract that
42
57
  stopped saying anything.
@@ -82,7 +97,7 @@ fills the `from` keys of the next step from a record you already have.
82
97
  A claim step's `events` keys take a record the same way:
83
98
  `nuka do nothing-was-written --use <place-score's record id>` counts the
84
99
  execution events that record kept (`references/program.md`). Before
85
- `nuka do` stops its world, it waits up to 10 s for the step's own events
100
+ `nuka do` stops its system, it waits up to 10 s for the step's own events
86
101
  to be whole, so the lines of a job that performs after the response are
87
102
  there for that count.
88
103
  A `files` key takes one the same way, and reads the files that record's
@@ -121,7 +136,7 @@ Say before the first call that the browser acts on the real application
121
136
  with whatever login it holds. A click that submits a form there is the
122
137
  same as a `mutates: true` step: it needs a go-ahead first.
123
138
 
124
- A world many calls deep is not reproducible, by anyone, and nothing the
139
+ A system many calls deep is not reproducible, by anyone, and nothing the
125
140
  MCP server did is a step record. What you found counts once it is a
126
141
  scenario: write the steps it needs, write the scenario from what you did
127
142
  ("Then fix what you found" below), and run `nuka check` on it, then
@@ -3,38 +3,15 @@
3
3
  When a scenario needs a project resource a step merely borrows (a tenant, a
4
4
  seeded database row, an uploaded file), don't write its teardown inside the
5
5
  step: that puts something in the feature file that is not itself an
6
- acceptance condition. Declare it as a fixture instead, under
7
- `nukadoko.config.ts`'s own `fixtures`, using `defineFixtures` (from the
8
- `nukadoko` package).
6
+ acceptance condition. Declare it as a fixture instead, in the config.
9
7
 
10
8
  ## Declaring a fixture
11
9
 
12
- ```ts
13
- export default defineConfig({
14
- fixtures: {
15
- tenant: async ({ request }, use) => {
16
- const t = await createTenant(request);
17
- await use(t);
18
- await destroyTenant(request, t);
19
- },
20
- },
21
- });
22
-
23
- declare module "nukadoko" {
24
- interface StepFixtures {
25
- tenant: Tenant;
26
- }
27
- }
28
- ```
29
-
30
- `tsc` needs the `declare module` block: without it, a step that
31
- destructures `tenant` fails with `Property 'tenant' does not exist on type
32
- 'FixtureBag'`. `nuka check` does not need it, because it reads fixture
33
- names from the source text. Write the block in `nukadoko.config.ts`, next
34
- to the fixture, with the type the fixture passes to `use()`.
10
+ How the config declares one is `typescript/fixtures.md` or
11
+ `ruby/fixtures.md`.
35
12
 
36
- A step reaches it the same way it reaches `page` or `request`, by
37
- destructuring the name: `async ({ tenant }, args) => {...}`. Setup runs the
13
+ A step reaches it the same way it reaches `page` or `request`, by naming
14
+ it among its fixtures. Setup runs the
38
15
  first time a step names it; teardown runs after that step's scenario
39
16
  finishes, in reverse build order, whether the scenario passed or failed.
40
17
  What a fixture leaves (a signed-in context) belongs to the `gives` of the
@@ -55,7 +32,7 @@ itself whether to keep what it built (for inspection) or tear it down;
55
32
  `{ scope: "process" }` in a second, options element of the tuple form
56
33
  builds it once for the whole `nuka run` invocation instead of once per
57
34
  scenario, for something genuinely shared across scenarios rather than owned
58
- by one (not for something that must happen exactly once in the world
35
+ by one (not for something that must happen exactly once in the system
59
36
  regardless of process count, like seeding a database: `process` is one
60
37
  address space, not one invocation). A fixture that never calls `use()`
61
38
  fails its step by name rather than hanging the run. A second `use()` call
@@ -69,10 +46,11 @@ fixture's own destructuring cannot be read, or names a fixture nukadoko
69
46
  does not know. The finding names the fixture.
70
47
 
71
48
  The program under test is not a fixture: the program in `nukadoko.config.ts` builds it,
72
- starts it once per world on a port of its own, and stops it after the
49
+ starts it once per system on a port of its own, and stops it after the
73
50
  scenarios (`program.md`). A fixture that starts a server in-process
74
51
  gives a run no record of which program answered. A fixture that connects
75
- an MCP client to the program passes the transport through `measureMcp`,
52
+ an MCP client to the program passes the transport through `measureMcp`
53
+ (`Nukadoko.measure_mcp`),
76
54
  so each call a step sends is in its record (`evidence.md`).
77
55
 
78
56
 
@@ -166,8 +144,10 @@ or a binding is `env-file-skipped-line` from `nuka check`.
166
144
  A project already on e2e (`tester-army/e2e`) keeps its engines: its
167
145
  `e2e/runner` exports `openHost`, which opens e2e sessions inside another
168
146
  runner. Open the host in a process fixture and one session per scenario;
169
- nukadoko gains no dependency, since the project already has `e2e`.
147
+ nukadoko gains no dependency, since the project already has `e2e`. It is a
148
+ JavaScript library, so this is the TypeScript engine's:
170
149
 
150
+ <!-- engine: typescript -->
171
151
  ```ts
172
152
  e2eHost: [async ({ baseURL }, use) => {
173
153
  const host = await openHost({ config: { targets: [
@@ -17,6 +17,18 @@ change to that value asks for a new one.
17
17
  The claim is `judged-as`. Its actual is the value to judge, its expected
18
18
  the quality the sentence names, from a capture or the pattern's own words:
19
19
 
20
+ ```ruby
21
+ class GreetingReadsAs < Nukadoko::Step
22
+ pattern "the greeting reads as {quality:string}"
23
+ args do
24
+ string :quality
25
+ field :stdout, RunGreet.returns[:stdout]
26
+ end
27
+ from stdout: [RunGreet, :stdout]
28
+ claims [{ actual: "stdout", view: "text", compare: "judged-as", expected: "quality" }]
29
+ end
30
+ ```
31
+
20
32
  ```ts
21
33
  export default defineStep({
22
34
  pattern: "the greeting reads as {quality:string}",
@@ -67,7 +67,7 @@ the one that covers the most step executions, not the slowest. It names a
67
67
  process-scope fixture only when every shared step declares
68
68
  `mutates: false`. Otherwise it names the first step that may write: an
69
69
  opening that creates the record each scenario then reads by id stays in
70
- each scenario (`scenario-rules.md`, S8, and `examples/http-api.md`). A
70
+ each scenario (`scenario-rules.md`, S8, and `typescript/examples/http-api.md`). A
71
71
  step that keeps the default `mutates: true` but writes nothing a later
72
72
  scenario reads is the one case to judge yourself.
73
73
 
@@ -18,7 +18,7 @@ jq -r --argjson sensitive '["payments", "/admin/:id"]' \
18
18
  ```
19
19
 
20
20
  Every answer below except Verification is a difference between the base
21
- world and head, so a run without `--base` gives no answer. The script says
21
+ system and head, so a run without `--base` gives no answer. The script says
22
22
  so and stops.
23
23
 
24
24
  `sensitive` lists the tables and routes this project treats as sensitive:
@@ -20,9 +20,9 @@ person reading the scenario, not to the code moving data between steps?
20
20
  After a failure, what should be knowable about it?
21
21
 
22
22
  - Its inputs and its result, under a contract worth stating: make it a
23
- **part**. Define it with `defineStep` and no `pattern`, list it in the
24
- calling step's `parts`, and run it with `await call(thePart, {...})`.
25
- Destructure `call` in that step's `run`, not in a fixture: `nuka check`
23
+ **part**. Define it as a step with no `pattern`, list it in the calling
24
+ step's `parts`, and run it through the `call` fixture. Name `call` in that
25
+ step's `run`, not in a fixture: `nuka check`
26
26
  reports a fixture that names it.
27
27
  Its args and its result are validated exactly as a step's are, and the
28
28
  call is recorded under `calls` on the calling step's own step record.
@@ -67,11 +67,11 @@ line that requires it after this one (`states.md`).
67
67
  The original step keeps its pattern, its `args`, and its `returns`. Only
68
68
  its body moves.
69
69
 
70
- 1. Move each half into its own file under `features/steps/`, defined with
71
- `defineStep`, with no `pattern`. Give each one the `args` and `returns`
70
+ 1. Move each half into its own step file under `features/steps/`, with no
71
+ `pattern`. Give each one the `args` and `returns`
72
72
  it actually demands, not the ones its current caller happens to have.
73
73
  2. List them in the original step's `parts`, and replace the moved code
74
- with `await call(thatPart, {...})`.
74
+ with a call through `call`.
75
75
  3. Run `nuka check`. A part the caller did not list is refused at the
76
76
  call, and a step declaring `mutates: false` while listing a part that
77
77
  declares `mutates: true` is an error: the composite's own flag has to
@@ -79,34 +79,57 @@ its body moves.
79
79
  4. Run the original scenario. Its feature file did not change, so a
80
80
  reviewer who approved that sentence has nothing new to read.
81
81
 
82
- `parts` takes the imported step objects themselves, never their names,
83
- the same way `from` names its producer:
82
+ `parts` takes the steps themselves (imported in TypeScript, the classes in
83
+ Ruby), never their names, the same way `from` names its producer:
84
+
85
+ ```ruby
86
+ # conformance/cases/parts/steps-rb/a_done_todo.rb
87
+ class ADoneTodo < Nukadoko::Step
88
+ pattern "a done todo titled {title:string} exists"
89
+ description "Create a todo and complete it, through two parts"
90
+ args { string :title, "The title of the todo" }
91
+ returns do
92
+ string :id, "The id of the todo"
93
+ boolean :done, "true once completed"
94
+ end
95
+ mutates true
96
+ parts [CreateTodo, CompleteById]
97
+
98
+ def run(call:, args:)
99
+ created = call.(CreateTodo, title: args.title)
100
+ completed = call.(CompleteById, id: created.id)
101
+ { id: completed.id, done: completed.done }
102
+ end
103
+ end
104
+ ```
84
105
 
85
106
  ```ts
86
- import openAccount from "./open-account.ts";
87
- import sendWelcomeMail from "./send-welcome-mail.ts";
107
+ // conformance/cases/parts/steps-ts/a-done-todo.ts
108
+ import { defineStep, z } from "nukadoko";
109
+ import createTodo from "./parts/create-todo.ts";
110
+ import completeById from "./parts/complete-by-id.ts";
88
111
 
89
112
  export default defineStep({
90
- // pattern, description, args and returns are exactly what they were
91
- pattern: "a customer {email:string} is onboarded on the {plan:string} plan",
92
- args: z.object({ email: z.string(), plan: z.string() }),
93
- returns: z.object({ accountId: z.string(), mailId: z.string() }),
94
- parts: [openAccount, sendWelcomeMail],
113
+ pattern: "a done todo titled {title:string} exists",
114
+ description: "Create a todo and complete it, through two parts",
115
+ args: z.object({ title: z.string().describe("The title of the todo") }),
116
+ returns: z.object({
117
+ id: z.string().describe("The id of the todo"),
118
+ done: z.boolean().describe("true once completed"),
119
+ }),
120
+ mutates: true,
121
+ parts: [createTodo, completeById],
95
122
  async run({ call }, args) {
96
- const { accountId } = await call(openAccount, {
97
- email: args.email,
98
- plan: args.plan,
99
- });
100
- const { mailId } = await call(sendWelcomeMail, { email: args.email });
101
- return { accountId, mailId };
123
+ const created = await call(createTodo, { title: args.title });
124
+ const completed = await call(completeById, { id: created.id });
125
+ return { id: completed.id, done: completed.done };
102
126
  },
103
127
  });
104
128
  ```
105
129
 
106
130
  Get each part right on its own before wiring the composite back together.
107
131
  A part with no `pattern` is still vocabulary, so it runs alone like any
108
- other step: `nuka do open-account --args '{"email":"ada@example.com",
109
- "plan":"team"}'`.
132
+ other step: `nuka do create-todo --args '{"title":"x"}'`.
110
133
 
111
134
  When the second scenario wants to name one half as a line of its own,
112
135
  give that part a `pattern`. It stays callable from the composite at the
@@ -1,17 +1,17 @@
1
- # Worlds that differ in what no criterion may depend on
1
+ # Systems that differ in what no criterion may depend on
2
2
 
3
3
  A criterion such as "an order placed late in the UTC day keeps that day"
4
4
  should hold whatever time zone the server runs in and whatever day the
5
5
  run happens on. One run shows it in one zone on one day, so a defect of
6
6
  the zone or the clock is missing from the run and from its summary
7
- (docs/spec.md, "Out of scope"). Declare the worlds that would show it,
7
+ (docs/spec.md, "Out of scope"). Declare the systems that would show it,
8
8
  and the verdict table turns the defect red.
9
9
 
10
10
  Four axes, and where each one lives:
11
11
 
12
12
  - **Order**: `nuka run <feature> --order shuffled`; a red rerun of the
13
13
  `do:` line is an order dependence (`references/running.md`).
14
- - **The same world again**: `nuka run <feature>:<line> --repeat <n>`;
14
+ - **The same system again**: `nuka run <feature>:<line> --repeat <n>`;
15
15
  runs that disagree are `flaky@<line>`, which is red.
16
16
  - **Time zone and clock** (and a random seed): one environment per value,
17
17
  below. The program reads each value from its environment variables, so
@@ -23,6 +23,24 @@ Each environment declares its zone and its clock as `conditions`, and
23
23
  `env` hands the same values to the program through `{condition.<name>}`,
24
24
  so the column heading and the program cannot disagree:
25
25
 
26
+ ```ruby
27
+ # Two zones by two pinned clocks. A combination left out is not run, and
28
+ # nothing reports it, so the cross product is written once, here.
29
+ zones = { utc: "UTC", tokyo: "Asia/Tokyo" }
30
+ clocks = { midmonth: "2026-03-10T12:00:00Z", monthend: "2026-01-31T12:00:00Z" }
31
+ environments = zones.flat_map { |zone, tz| clocks.map { |clock, now| ["#{zone}-#{clock}", { conditions: { tz: tz, now: now } }] } }.to_h
32
+
33
+ Nukadoko.config(
34
+ program: -> {
35
+ {
36
+ serve: { command: "ruby src/server.rb", ready: "/health" },
37
+ env: { PORT: "{port}", TZ: "{condition.tz}", NOW: "{condition.now}" },
38
+ environments: environments,
39
+ }
40
+ },
41
+ )
42
+ ```
43
+
26
44
  ```ts
27
45
  import { defineConfig } from "nukadoko";
28
46
 
@@ -58,7 +76,7 @@ export default defineConfig({
58
76
  tag would end. libfaketime's absolute form, `@2026-03-10 23:30:00`,
59
77
  cannot be one: use its relative form (`+14h`) or a seam that reads an
60
78
  ISO time.
61
- - **The world's `env` reaches the step's process too** (`process.env`
79
+ - **The system's `env` reaches the step's process too** (`process.env`
62
80
  during the run), and Node switches zones when `process.env.TZ` changes.
63
81
  A step that computes its expected date from its own clock or zone moves
64
82
  the same way the program does, and hides the defect. Write the input
@@ -78,27 +96,27 @@ broke and where it held:
78
96
  ```
79
97
 
80
98
  The reason names no cause: the environments can differ in more than their
81
- conditions. Rerun one world with the finding's `do:` line, which names it
99
+ conditions. Rerun one system with the finding's `do:` line, which names it
82
100
  with `--env`.
83
101
 
84
102
  ## Under `--base`
85
103
 
86
- A fix for a zone defect proves itself only in a world that shows the
87
- defect. A new criterion for a business-day fix, run with UTC worlds alone,
88
- was `unproven` (`base utc: pass`); with a Tokyo world beside it, the base
104
+ A fix for a zone defect proves itself only in a system that shows the
105
+ defect. A new criterion for a business-day fix, run with UTC systems alone,
106
+ was `unproven` (`base utc: pass`); with a Tokyo system beside it, the base
89
107
  cell there was `fail@13 (2 runs)` and the row was `proven`. Keep these
90
108
  environments in the run CI posts with `--base`.
91
109
 
92
110
  ## The cost
93
111
 
94
- Every environment is a world: two zones by two clocks runs each scenario
95
- four times, and so does the base world under `--base`. With switch
112
+ Every environment is a system: two zones by two clocks runs each scenario
113
+ four times, and so does the base system under `--base`. With switch
96
114
  environments already there (`checkout-v1`, `checkout-v2`), write the
97
115
  cross product by hand, each entry declaring the switch and the zone; the
98
116
  switch's tags keep working, since each entry still declares its side.
99
117
  `defaultEnvironments` keeps a run without `--env` on a few of them; then
100
- say in the pull request which worlds CI runs, since a local green and a
101
- CI red can disagree, and the column headings say which world was which.
118
+ say in the pull request which systems CI runs, since a local green and a
119
+ CI red can disagree, and the column headings say which system was which.
102
120
 
103
121
  ## What stays out of reach
104
122