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
@@ -2,199 +2,198 @@
2
2
 
3
3
  ## The program
4
4
 
5
- The config holds the criteria, and its `program` holds how a run gets the
6
- program the scenarios talk to: how to build it, prepare its state, start it,
7
- and the env its processes get. `nuka init` does not write it: write it from
8
- what the README or CI script already runs.
9
-
10
- ```ts
11
- import { defineConfig } from "nukadoko";
12
-
13
- export default defineConfig({
14
- program: () => ({
15
- build: ["npm run build"], // once per run, in the tree's root
16
- prepare: ["node dist/migrate.js"], // once per world, with env below
17
- serve: { command: "node dist/server.js", ready: "/health" },
18
- env: { PORT: "{port}", DATABASE_PATH: "{dir}/app.sqlite3" },
19
- }),
20
- });
21
- ```
22
-
23
- `nuka run` starts one world per environment: it runs `build` and
24
- `prepare`, starts `serve` on a free port, waits until `ready` answers
25
- 2xx, runs the scenarios against that URL (the base URL of `page`,
26
- `request`, and the `baseURL` fixture), and stops the program after the
27
- AfterAll hooks. `nuka do` does the same for its one execution. No
28
- terminal has to keep a server running, and no fixture starts one.
29
-
30
- A command is an argv array, or a string split on whitespace. Neither goes
31
- through a shell; write `["sh", "-c", "a && b"]` when one is needed. The program
32
- learns its port only from `{port}`, in the command or in `env`. `ready` is a
33
- path on the program's own server, and only a 2xx answer counts: a redirect is
34
- not followed, so name a path that answers 200 with no login (`/up`, `/health`).
35
- `url` is an `http:` or `https:` URL with no user or password in it.
5
+ The config holds the criteria, and its `program` holds how a run gets the program the
6
+ scenarios talk to: how to build it, prepare its state, start it, and the env its processes
7
+ get. `nuka init` does not write it: write it from what the README or CI script already
8
+ runs. How the config writes it is `typescript/program.md` or `ruby/program.md`; the gem
9
+ reads `serve`, `env`, `environments`, and `defaultEnvironments`, and the rest of this page
10
+ is the TypeScript engine's.
11
+
12
+ `nuka run` starts one system per environment: it runs `build` and `prepare`, starts
13
+ `serve` on a free port, waits until `ready` answers 2xx, runs the scenarios against that
14
+ URL (the base URL of `page`, `request`, and the `baseURL` fixture), and stops the program
15
+ after the AfterAll hooks. `nuka do` does the same for its one execution. No terminal has
16
+ to keep a server running, and no fixture starts one.
17
+
18
+ A command is an argv array, or a string split on whitespace. Neither goes through a shell;
19
+ write `["sh", "-c", "a && b"]` when one is needed. The program learns its port only from
20
+ `{port}`, in the command or in `env`. `ready` is a path on the program's own server, and
21
+ only a 2xx answer counts: a redirect is not followed, so name a path that answers 200 with
22
+ no login (`/up`, `/health`). `url` is an `http:` or `https:` URL with no user or password
23
+ in it.
36
24
 
37
25
  | Placeholder | Its value |
38
26
  | --- | --- |
39
- | `{port}`, `{url}` | the world's port (the one `serve` got, or the `url`'s, 443 or 80 when it names none) and URL |
40
- | `{dir}` | the world's own directory under the run: its database, its pid file |
41
- | `{root}` | the tree's root, the one placeholder `build` may name |
42
- | `{world}` | the environment's name |
43
- | `{token}` | random per world, redacted as `{{secret.WORLD_TOKEN}}` in every record |
44
- | `{events}` | a private empty file a world nukadoko serves gets for its program's execution events |
27
+ | `{port}`, `{url}` | the service's port (the one `serve` got, or the `url`'s, 443 or 80 when it names none) and URL |
28
+ | `{service.<name>.url}`, `{service.<name>.port}` | another service's URL and port in the same system |
29
+ | `{dir}` | the service's own directory under the run, `systems/<environment>/<service>/`: its database, its pid file |
30
+ | `{root}` | the directory the service's commands run in, the one placeholder `build` may name |
31
+ | `{system}` | the environment's name |
32
+ | `{token}` | random per system, redacted as `{{secret.SYSTEM_TOKEN}}` in every record |
33
+ | `{events}` | a private empty file a system nukadoko serves gets for its program's execution events |
45
34
  | `{condition.<name>}` | the value the environment declares for that condition: `true`, `false`, or the string |
46
- A placeholder a world has no value for (`{port}` or `{url}` with neither `serve`
47
- nor `url`, `{events}` without `serve`, `{condition.<name>}` where the
48
- environment does not declare it, anything but `{root}` in `build`) is
49
- `program-placeholder-unfilled`: `nuka check` reports it for the worlds a `nuka
50
- run` with the same `--env` flags would start, and `nuka run` and `nuka do`
51
- refuse it before any command runs.
52
-
53
- One world serves every scenario of an environment, so what one scenario
54
- writes is there for the next: a scenario creates what it reads and claims
55
- only on that (`scenario-rules.md`, S8, and `examples/http-api.md`).
56
-
57
- A step reads the same `env`: in `process.env` during the run and in the
58
- `env` fixture, after the config's env files. `setup(world)` runs once per
59
- world before the first scenario, to seed data; what it prints reaches
60
- stderr and `program.log` redacted. A `setup` or `url` function past its
61
- limit is abandoned and its `signal` aborted: it stops only if it honours it.
62
-
63
- Every phase has a limit: 600 s for each `build` or `prepare` command, 60 s for
64
- `serve` to answer `ready`, `setup`, and a `url` function. Write `{ command,
65
- timeout_ms }` for a command, `serve.timeout_ms`, `setup: { run, timeout_ms }`,
66
- or `url: { resolve, timeout_ms }` for another, in whole milliseconds up to
67
- 2147483647, the longest delay a Node.js timer keeps. Each phase prints `world
68
- <name>: <phase> started` on stderr, so a long wait names what it waits on. A
69
- `build` or `prepare` command's process group is killed when the command exits:
70
- a service that has to outlive `prepare`, such as a database, starts with
71
- `setsid`, as a daemon does. `serve.command` stays in the foreground: one that
72
- daemonizes, as `rails server -d` does, exits before `ready` answers and fails
73
- the world, and the daemon keeps running, out of nukadoko's reach.
35
+ A placeholder a system has no value for (`{port}` or `{url}` with neither `serve` nor
36
+ `url`, `{events}` without `serve`, `{condition.<name>}` the environment does not declare,
37
+ anything but `{root}` in `build`) is `program-placeholder-unfilled`, and `{world}`, the
38
+ old name of `{system}` that nothing fills, is `program-placeholder-renamed`: `nuka check`
39
+ reports them for the systems a `nuka run` with the same `--env` flags starts, and `nuka
40
+ run` and `nuka do` refuse them before any command runs.
41
+
42
+ One system serves every scenario of an environment, so what one scenario writes is there
43
+ for the next: a scenario creates what it reads and claims only on that
44
+ (`scenario-rules.md`, S8, and `typescript/examples/http-api.md`).
45
+
46
+ A step reads the same `env`: in `process.env` during the run and in the `env` fixture,
47
+ after the config's env files. `setup(system)` runs once per system before the first
48
+ scenario, to make its test tenant and seed data, and every step reads what it returns, a
49
+ JSON value, as the `setupResult` fixture; reading it where no `setup` makes one is
50
+ `setup-result-missing`. `stepsReach: "url"` makes a service URL the only way in, so
51
+ `runCommand` is refused there (`command-refused`, a `broke` cell, and the `check` note
52
+ `steps-reach-command`), and a system a team starts itself declares `stepsReach: "any"`,
53
+ the default. What `setup` prints reaches stderr and `program.log` redacted. A `setup` or
54
+ `url` function past its limit is abandoned and its `signal` aborted: it stops only if it
55
+ honours it.
56
+
57
+ Every phase has a limit: 600 s for each `build` or `prepare` command, 60 s for `serve` to
58
+ answer `ready`, `setup`, and a `url` function. Write `{ command, timeout_ms }` for a
59
+ command, `serve.timeout_ms`, `setup: { run, timeout_ms }`, or `url: { resolve, timeout_ms
60
+ }` for another, in whole milliseconds up to 2147483647, the longest delay a Node.js timer
61
+ keeps. Each phase prints `system <name>: <phase> started` on stderr, so a long wait names
62
+ what it waits on. A `build` or `prepare` command's process group is killed when the
63
+ command exits: a service that has to outlive `prepare`, such as a database, starts with
64
+ `setsid`, as a daemon does. `serve.command` stays in the foreground: one that daemonizes,
65
+ as `rails server -d` does, exits before `ready` answers and fails the system, and the
66
+ daemon keeps running, out of nukadoko's reach.
67
+
68
+ ## Several services
69
+
70
+ `services` names each server of a program, with its own fields and `root`, where its code
71
+ is (`../billing`, a clone beside the repository); `primary` names the one the steps reach,
72
+ and `external: true` one only reached at its `url`. With no `services`, the program is one
73
+ service, `main`. `{service.<name>.url}` names another service's address, and a step
74
+ reaches one through the `services` fixture (`services.billing.url`), never a URL of its
75
+ own, so the same scenarios run where an environment moves every service to a `url`. A
76
+ `root` that is no directory is `program-service-root-missing`. Under `--base`, a `root`
77
+ outside the repository builds once, and the summary names its commit. docs/spec.md
78
+ "Services" has every rule.
74
79
 
75
80
  ## When it does not start
76
81
 
77
- A world that does not start fails the run with `program-start-failed`,
78
- which names the command, how it ended (a phase past its limit included),
79
- and the end of the world's `program.log`: read that file first, at
80
- `.nukadoko/runs/<run_id>/worlds/<environment>/program.log`. No scenario
81
- runs in that environment. A fixed `port` something else already answers
82
- on is refused the same way, since every request would reach a server
83
- nukadoko did not start. `program-exited` (a warning) says the program
84
- died during the run, which the failed steps alone would not.
82
+ A system that does not start fails the run with `program-start-failed`, which names the
83
+ command, how it ended (a phase past its limit included), and the end of the failing
84
+ service's `program.log`: read that file first, at
85
+ `.nukadoko/runs/<run_id>/systems/<environment>/<service>/program.log` (`main` for one
86
+ service). No scenario runs in that environment. A fixed `port` something else already
87
+ answers on is refused the same way, since every request would reach a server nukadoko did
88
+ not start. `program-exited` (a warning) says the program died during the run, which the
89
+ failed steps alone would not.
85
90
 
86
- `run.json`'s `worlds` names what each world ran, its URL, its timings,
87
- and its log; each step record names its world in `world_name`.
91
+ `run.json`'s `systems` names what each service ran (`services`), its URL, timings, log,
92
+ and the system's own `setup_result`; each step record names its system in `system_name`.
88
93
 
89
94
  ## Each step's lines of the program's log
90
95
 
91
- Every request a step sends to the world's origin (through `fetch`, `node:http`,
92
- `request`, and a Chromium page) carries a W3C `traceparent` with the step's own
93
- trace id. A request that sets its own keeps it. When the program writes the
94
- trace id into its log lines, each step record gets the lines that carry its
95
- trace id in `program-log.txt` beside it, counted in `observed.program_log`
96
- (`{ trace_id, lines, file, stamped }`). Read that file first when a step against
97
- the program fails: it holds what the server did for that step. A line that
98
- arrived after the step ended is still that step's, in `program-log-late.txt`
99
- beside the record; the run summary names it on the step's `after-record` entry.
100
-
101
- `lines: 0` with `stamped` above 0 says only that no line carried the
102
- step's trace id by the time its record was written. Read the world's
103
- `unrecorded-log` entry in the summary, decided from the whole log once the
104
- world stopped: "carries no trace ids" means the program does not tag its
105
- lines; a late line is on its step's `after-record` entry. When the world's
106
- entry says none came in time, output buffered on a pipe is a possible cause:
107
- `STDOUT.sync = true` fixes it in Ruby and `PYTHONUNBUFFERED=1` in Python.
108
- For Rails, send the test log to stdout and tag it, in `config/environments/test.rb`:
109
-
96
+ Every request a step sends to a service's origin, an external one aside (through `fetch`,
97
+ `node:http`, `request`, and a Chromium page), carries a W3C `traceparent` with the step's
98
+ own trace id. A request that sets its own keeps it. When the program writes the trace id
99
+ into its log lines, each step record gets each service's lines that carry it in
100
+ `program-log.<service>.txt`, counted in `observed.program_log.services`. Read that file
101
+ first when a step against the program fails: it holds what the server did for that step. A
102
+ line that arrived after the step ended is still that step's, in
103
+ `program-log-late.<service>.txt`; the summary names it on `after-record`.
104
+
105
+ `lines: 0` with `stamped` above 0 says only that no line carried the step's trace id by
106
+ the time its record was written. Read the system's `unrecorded-log` entry in the summary,
107
+ decided from the whole log once the system stopped: "carries no trace ids" means the
108
+ program does not tag its lines; a late line is on its step's `after-record` entry. When
109
+ the system's entry says none came in time, output buffered on a pipe is a possible cause:
110
+ `STDOUT.sync = true` fixes it in Ruby and `PYTHONUNBUFFERED=1` in Python. For Rails, send
111
+ the test log to stdout and tag it, in `config/environments/test.rb`:
112
+ <!-- engine: neither -->
110
113
  ```ruby
111
114
  config.logger = ActiveSupport::TaggedLogging.logger($stdout) if ENV["RAILS_LOG_TO_STDOUT"].present?
112
115
  config.log_tags = [ ->(request) { request.headers["traceparent"] } ]
113
116
  ```
114
117
 
115
- with `RAILS_LOG_TO_STDOUT: "1"` in the program's `env`. A Node
116
- server prints `req.headers.traceparent` at the start of each line it
117
- writes for a request. A world at a `url` has no log nukadoko reads:
118
- `observed.program_log` is `null`, and the server's own log finds a
119
- step's requests by the `traceparent` on its `http.jsonl` lines, each
120
- with `traceparent_sent_to`, the origins that received it.
118
+ with `RAILS_LOG_TO_STDOUT: "1"` in the program's `env`. A Node server prints
119
+ `req.headers.traceparent` at the start of each line it writes for a request. A service at
120
+ a `url` has no log nukadoko reads: its entry in `observed.program_log.services` is `null`,
121
+ and the server's own log finds a step's requests by the `traceparent` on its `http.jsonl`
122
+ lines, each with `traceparent_sent_to`, the origins that received it.
121
123
 
122
124
  ## Each step's execution events
123
125
 
124
- A program can also write one JSON line per operation it ends (a request, a
125
- statement, a transaction, a job, an outgoing call, a flag, an error) to the file
126
- `{events}` names, in the format of docs/execution-events.md:
127
- `env: { EXECUTION_EVENTS: "{events}" }`. Each line carries the request's
128
- `traceparent`, a job's the one that enqueued it, so the lines of every process
129
- the program runs reach the step that caused them. Each step record gets its
130
- lines, redacted, in `events.jsonl` beside it, counted in `observed.events`
131
- (`{ trace_id, lines, file, kinds, stamped, stamped_spans, unreadable, unowned,
132
- process_spans, process_requests, whole, open }`, and `mcp_spans` after an MCP
133
- call). A `runCommand` process gets the step's trace context as `TRACEPARENT`,
134
- an MCP call through `measureMcp` in `params._meta.traceparent`
135
- (`references/evidence.md`); a tool or a stdio server that copies it into its
136
- requests' `traceparent` header makes their lines the step's (`process_requests`
137
- counts a tool's). Only the program gets the variable that names `{events}`,
138
- never a step or a process it starts, so no line a step writes reads as the
139
- program's. Read it to see what the program did inside a step: which tables it
140
- read and wrote, which jobs it enqueued and ran.
141
-
142
- `whole: true` says every request the step stamped has its `request` line, every
143
- job it enqueued performed, each `runCommand` process it ran ended with its
144
- process group, and each MCP call went to the world over HTTP. `whole: false`
145
- never says nothing more happened: `open` names why, one word each: `no-requests`
146
- (no stamped request, `runCommand` process, or MCP call, such as a Then that only
147
- reads the page), `processes-unbounded` (a process it ran still runs, left its
148
- group running, or ran on Windows), `mcp-unbounded` (an MCP call went over stdio
149
- or to another origin), `no-lines` (no writer, or a wrong variable),
150
- `request-unreported`, `jobs-pending` (with `job_ids`), `unreadable` (a line
151
- spliced or cut), `truncated`, `file-replaced`. A line that arrived later is in
152
- `events-late.jsonl`, and the run summary names it. The whole file, redacted, is
153
- in `worlds/<environment>/events.jsonl`; a world at a `url` has none, and
154
- `observed.events` is `null` there. run.json's step gets `path`, what its trace
155
- did, late lines included (writes, jobs, requests, flags; no reads); its flags
156
- and requests make run.json's `flags` and `routes`, and `lists` (docs/spec.md
157
- "Lists") names those no step reached (`references/verdicts.md`).
126
+ A program can also write one JSON line per operation it ends (a request, a statement, a
127
+ transaction, a job, an outgoing call, a flag, an error) to the file `{events}` names, in
128
+ the format of docs/execution-events.md: `env: { EXECUTION_EVENTS: "{events}" }`. Each line
129
+ carries the request's `traceparent`, a job's the one that enqueued it, so the lines of
130
+ every process the program runs reach the step that caused them. Each service that names
131
+ `{events}` gets a file of its own, and each step record gets each service's lines,
132
+ redacted, in `events.<service>.jsonl` beside it, counted in `observed.events` (`{
133
+ trace_id, stamped, services, process_spans, whole, open }`, and `mcp_spans` after an MCP
134
+ call), whose `services` holds one entry per service (`{ lines, file, kinds, stamped,
135
+ stamped_spans, unreadable, unowned, process_requests }`, `null` for one whose events are
136
+ not read). A `runCommand` process gets the step's trace context as `TRACEPARENT`, an MCP
137
+ call through `measureMcp` in `params._meta.traceparent` (`references/evidence.md`); a tool
138
+ or a stdio server that copies it into its requests' `traceparent` header makes their lines
139
+ the step's (`process_requests` counts a tool's). Only the program gets the variable that
140
+ names `{events}`, never a step or a process it starts, so no line a step writes reads as
141
+ the program's. Read it to see what the program did inside a step: which tables it read and
142
+ wrote, which jobs it enqueued and ran.
143
+
144
+ `whole` and `open` are one answer for the step, over every service's lines: the trace is
145
+ one, and only the files are several. `whole: true` says every request the step stamped has
146
+ its `request` line, every job it enqueued performed, each `runCommand` process it ran
147
+ ended with its process group, each MCP call went to the system over HTTP, and nukadoko
148
+ reads the events of every service it sent a request to. `whole: false` never says nothing
149
+ more happened: `open` names why, one word each, a gap about one service naming it in
150
+ `service`: `no-requests` (no stamped request, `runCommand` process, or MCP call, such as a
151
+ Then that only reads the page), `processes-unbounded` (a process it ran still runs, left
152
+ its group running, or ran on Windows), `mcp-unbounded` (an MCP call went over stdio or to
153
+ another origin), `service-unrecorded` (a service it sent a request to names no `{events}`
154
+ or runs at a `url`), `no-lines` (no writer, or a wrong variable), `request-unreported`,
155
+ `jobs-pending` (with `job_ids`, matched per service), `unreadable` (a line spliced or
156
+ cut), `truncated`, `file-replaced`. A line that arrived later is in
157
+ `events-late.<service>.jsonl`, and the run summary names it. Each service's whole file,
158
+ redacted, is in `systems/<environment>/<service>/events.jsonl`; a system at a `url` has
159
+ none, and `observed.events` is `null` there. run.json's step gets `path`, what its trace
160
+ did, late lines included (writes, jobs, requests, flags; no reads), each entry naming the
161
+ `service` whose file held it; its flags and requests make run.json's `flags` (one row per
162
+ service, flag, and side) and `routes`, and `lists` (docs/spec.md "Lists") names those no
163
+ step reached (`references/verdicts.md`).
158
164
 
159
165
  ## Claiming what the program did
160
166
 
161
- A Then counts an earlier step's events: `events: { writes: { of: placeScore,
162
- count: { kind: "db", op: ["insert", "update", "delete", "other"], committed:
163
- true } } }` beside a claim on `actual: "writes"` and a number. It waits while
164
- they may still be `whole` (the step's `timeout`, else 10 s), and is `unjudged`,
165
- naming the gap, while the count is a range: an absence holds on a whole reading
166
- only. Its line and `events_read` name what it `counted`, and what a `db` count
167
- with no `table` left out on tables `lists.tables` marks (`left_out`,
168
- `references/diagnosing.md`); a line after the claim makes the cell `broke`.
169
- `events-inlet-missing` and `events-unread` name a world that reads none (a
170
- `--base` ref without `{events}` still runs).
167
+ A Then counts an earlier step's events: `events: { writes: { of: placeScore, count: {
168
+ kind: "db", op: ["insert", "update", "delete", "other"], committed: true } } }` beside a
169
+ claim on `actual: "writes"` and a number. The key counts every service's lines of that
170
+ step's trace, or one service's with `service: "billing"` beside its `count`; `nuka check`
171
+ reports `events-service-unknown` for a name no service of the system has. It waits while
172
+ they may still be `whole` (the step's `timeout`, else 10 s), and is `unjudged`, naming the
173
+ gap, while the count is a range: an absence holds on a whole reading only. Its line and
174
+ `events_read` name what it `counted`, and what a `db` count with no `table` left out on
175
+ tables `lists.tables` marks (`left_out`, `references/diagnosing.md`); a line after the
176
+ claim makes the cell `broke`. `events-inlet-missing` and `events-unread` name a system
177
+ that reads none (a `--base` ref without `{events}` still runs).
171
178
 
172
179
  ## Environments and programs nukadoko does not start
173
180
 
174
- An entry of `environments` overrides any field above (`env` merges by
175
- key). A feature behind a switch gets one environment per side, each
176
- naming its side in `conditions`:
177
-
178
- ```ts
179
- env: { CHECKOUT_V2: "{condition.checkout_v2}" },
180
- environments: {
181
- "checkout-v1": { conditions: { checkout_v2: false } },
182
- "checkout-v2": { conditions: { checkout_v2: true } },
183
- },
184
- ```
181
+ An entry of `environments` overrides any field above (`env` merges by key). A feature
182
+ behind a switch gets one environment per side, each naming its side in `conditions`
183
+ ("Environments" on your engine's page).
185
184
 
186
185
  `conditions` sets nothing, and nukadoko does not check it against the program;
187
- `{condition.checkout_v2}` hands the program the declared side, so the two
188
- cannot disagree. It says which side the environment is on for a scenario's
189
- `@with:checkout_v2` or `@without:checkout_v2` tag (`references/verdicts.md`).
190
- `nuka run` without `--env` runs every environment that declares `conditions`,
191
- or the ones a top-level `defaultEnvironments` names, so a deployment target can
192
- declare its switches and stay out. `url` in place of `serve` names a program
193
- that runs elsewhere, such as a staging server, and starts nothing: give it
194
- `build: []` and `prepare: []` when the top level has them, and
195
- `policy: "read-only"` when the data there belongs to someone else. Under
196
- `nuka run --base`, a `url` function receives `tree` and branches on it: one
197
- that answers the base world with head's URL leaves that world not run.
198
-
199
- A tree with no program starts no world, which suits a command-line tool whose
200
- steps run commands with `runCommand`. "Program" in docs/spec.md has every field.
186
+ `{condition.checkout_v2}` hands the program the declared side, so the two cannot disagree.
187
+ It says which side the environment is on for a scenario's `@with:checkout_v2` or
188
+ `@without:checkout_v2` tag (`references/verdicts.md`). `nuka run` without `--env` runs
189
+ every environment that declares `conditions`, or the ones a top-level
190
+ `defaultEnvironments` names, so a deployment target can declare its switches and stay out.
191
+ `url` in place of `serve` names a program that runs elsewhere, such as a staging server,
192
+ and starts nothing: it takes none of the top level's `build`, `prepare`, or `root`, so it
193
+ writes its own only to run one there, and it wants `policy: "read-only"` when the data
194
+ there belongs to someone else. Under `nuka run --base`, a `url` function receives `tree`
195
+ and branches on it: one that answers the base system with head's URL leaves that system
196
+ not run.
197
+
198
+ A tree with no program starts no system, which suits a command-line tool whose steps run
199
+ commands with `runCommand`. "Program" in docs/spec.md has every field.
@@ -15,7 +15,7 @@ npx nuka step wait
15
15
  ```
16
16
 
17
17
  `--step` runs one scenario in one environment, and after each step it
18
- pauses with the world, the browser, and the fixtures still open until a
18
+ pauses with the system, the browser, and the fixtures still open until a
19
19
  `nuka step` call answers. Start it in the host's background mode (in
20
20
  Claude Code, `run_in_background`), since it does not return until the
21
21
  walk ends. `nuka step wait` waits up to `--timeout` seconds (default 90)
@@ -26,14 +26,14 @@ walk 1 paused after step 1/4 (passed): the shopper opens the cart
26
26
  scenario: features/checkout.feature:12 Pay for a cart (default)
27
27
  record: .nukadoko/runs/<run_id>/steps/<id>/record.json
28
28
  view: page 1 http://127.0.0.1:41233/cart "Cart": <run_dir>/pauses/1/page.png <run_dir>/pauses/1/page.aria.yml
29
- world: http://127.0.0.1:41233
29
+ system: http://127.0.0.1:41233
30
30
  do: nuka step next 1 --walk 1 (or: nuka step stop 1 --walk 1)
31
31
  ```
32
32
 
33
33
  `--json` gives the same as fields: `walk`, `pause` (`pause`, `of`,
34
34
  `line`, `text`, `step`, `status`, `record`, `failure` when the scenario
35
35
  failed there, `remaining`, `paused_at`, `views`), `run_id`, `run_dir`,
36
- `scenario`, `world`, and `do`. A wait that prints `starting` or
36
+ `scenario`, `system`, and `do`. A wait that prints `starting` or
37
37
  `running` ran out before the walk paused: run it again. A run that
38
38
  refused (more than one scenario, say) never pauses, and a wait shows it
39
39
  ended before its scenario ran. A wait reports each end once, then waits
@@ -54,20 +54,19 @@ For each pause, before you say anything about the step:
54
54
  (`page-2.*`, `page.<name>.*` for a second page or a `pageAs` context),
55
55
  taken after the step's record. What a page sent while the walk waited
56
56
  is in `pauses/<n>/http.jsonl`, not in the step's.
57
- - The world, when there is one: its URL is live, so you can read it, but
57
+ - The system, when there is one: its URL is live, so you can read it, but
58
58
  anything you change there is what the next step finds.
59
59
 
60
60
  What each part of `observed` says (a `null` channel means nothing was
61
61
  measured there, not that nothing happened):
62
62
 
63
- - `processes` lists each `runCommand`, with its command, `cwd`, `exit_code`,
64
- `group` (`running` if a process it started still ran in its group), `files`
65
- (what it added, changed, or removed under its working directory), `stdout` and
66
- `stderr` (the files in the record's directory that hold what it printed),
67
- `stdin` (the file that holds what it was given), and `env` (how its
68
- environment differed from the runner's: each name, with a value only when it
69
- is an existing absolute path, a decimal integer, or a boolean, else its
70
- `hidden_bytes`).
63
+ - `processes` lists each `runCommand`, with its command, `cwd`, `exit_code`, `group`
64
+ (`running` if a process it started still ran in its group), `files` (what it added,
65
+ changed, or removed under its working directory), `stdout` and `stderr` (the files
66
+ in the record's directory that hold what it printed), `stdin` (the file that holds
67
+ what it was given), and `env` (how its environment differed from the runner's: each
68
+ name, with a value only when it is an existing absolute path, a decimal integer, or
69
+ a boolean, else its `hidden_bytes`).
71
70
  - `http` counts the requests the step sent. Each is a line in `http.jsonl` with
72
71
  its method, URL, status, request body, and response body. A line marked
73
72
  `after_step_end` started after the record was written, so the record does not
@@ -76,12 +75,13 @@ measured there, not that nothing happened):
76
75
  on its own. A line's `traceparent` is the value the request went out with,
77
76
  nukadoko's or the step's own, and `traceparent_sent_to` the origins that
78
77
  received it; nukadoko's value names the id the program's log lines carry.
79
- - `program_log` counts the step's lines of the program's log, in
80
- `program-log.txt` (late ones in `program-log-late.txt`): what the server
81
- did for this step. `lines: 0` with `stamped` above 0 is explained by the
82
- run summary's line for the world (`program.md`); `null`: a `url` world.
83
- - `events` counts the step's execution events by kind, in `events.jsonl`
84
- (late ones in `events-late.jsonl`); `open` names why `whole` is false.
78
+ - `program_log.services` counts each service's lines, in `program-log.<service>.txt`
79
+ (late ones in `program-log-late.<service>.txt`): what it did for this step.
80
+ `lines: 0` with `stamped` above 0 is explained by the run summary's line
81
+ for the system (`program.md`); a service's `null`: it runs at a `url`.
82
+ - `events.services` counts each service's execution events by kind, in
83
+ `events.<service>.jsonl` (late ones in `events-late.<service>.jsonl`); `whole` and
84
+ `open` are the step's one answer over them all, a gap about one service naming it.
85
85
  - `mcp` and `websocket` count the lines of `mcp.jsonl` and `websocket.jsonl` (`evidence.md`).
86
86
  - `files` lists the paths the step changed in a scratch directory or wrote
87
87
  through `node:fs`, each with its content after the step. A file the step asked
@@ -162,7 +162,7 @@ Tell the person, in their language and in plain words:
162
162
 
163
163
  Then stop and wait for the person. Never answer a pause they have not
164
164
  answered: the run waits exactly so that they judge each step while its
165
- world is still there. Answer with the pause number they saw and the walk
165
+ system is still there. Answer with the pause number they saw and the walk
166
166
  number it printed (`walk 1 paused ...`), as the `do` line spells it:
167
167
 
168
168
  - To go on: `npx nuka step next <n> --walk <w>`. It runs the next step
@@ -183,7 +183,7 @@ views, answer `next` once the person has seen them, and go to `diagnosing.md`. A
183
183
  walk a signal ended (the host's background limit, Ctrl-C) prints `interrupted`;
184
184
  one whose run was killed prints `walk-gone`, and its `do:` starts it again.
185
185
 
186
- A walked run is not the run a reviewer approves (the world and the browser
186
+ A walked run is not the run a reviewer approves (the system and the browser
187
187
  stayed open between steps, and its summary says so): after the walk, run the
188
188
  scenario once more without `--step`.
189
189
 
@@ -0,0 +1,106 @@
1
+ # Claim steps in Ruby
2
+
3
+ What a claim means, where its values come from, and every compare are in
4
+ `../checking-steps.md`. This page is how a Ruby step file writes one.
5
+
6
+ ## A claim step
7
+
8
+ A Then declares `claims [...]` in place of `def run`, as a list of hashes
9
+ with the same keys as in TypeScript (`actual`, `view`, `at`, `count`,
10
+ `compare`, `expected`, `expected_view`). A key the line states is a field
11
+ of `args` with no `default:`.
12
+
13
+ ```ruby
14
+ # conformance/cases/cli/steps-rb/exits_with.rb
15
+ class ExitsWith < Nukadoko::Step
16
+ description "The process exit code is exactly this"
17
+ pattern "it exits with {code:int}"
18
+ args do
19
+ number :code, "The expected exit code"
20
+ field :exitCode, RunTally.returns[:exitCode]
21
+ end
22
+ from exitCode: [RunTally, :exitCode]
23
+ claims [{ actual: "exitCode", compare: "equal", expected: "code" }]
24
+ end
25
+ ```
26
+
27
+ ## An expected value an earlier step returned
28
+
29
+ `from` names the step class and its key as a symbol, and
30
+ `field :<key>, <Step>.returns[:<key>]` reuses the producer's field.
31
+
32
+ ```ruby
33
+ # conformance/cases/http-api/steps-rb/list_has_created_item.rb
34
+ class ListHasCreatedItem < Nukadoko::Step
35
+ description "The item list holds the item an earlier step created, id and name"
36
+ pattern "the list has the item that was created"
37
+ args do
38
+ unknown :body, "The list the request got"
39
+ field :created, AnItemExists.returns[:body]
40
+ end
41
+ from body: [ListItems, :body], created: [AnItemExists, :body]
42
+ claims [{ actual: "body", compare: "has-item", expected: { from: "created" } }]
43
+ end
44
+ ```
45
+
46
+ ## Observe and poll
47
+
48
+ `def observe(...)` takes the fixtures as keyword arguments, as `run`
49
+ does, and reads the args through `args:`. Give every field a description,
50
+ so `nuka describe` connects a criterion's wording to the field that
51
+ answers it. `poll` takes `timeout_ms:` and `settled:`, or `false`.
52
+
53
+ ```ruby
54
+ # conformance/cases/poll/steps-rb/job_ends.rb
55
+ class JobEnds < Nukadoko::Step
56
+ pattern "the job ends {wanted:string}"
57
+ description "The job an earlier step started reaches this status in GET /jobs/:id"
58
+ args do
59
+ string :wanted, "The status the job is expected to reach"
60
+ field :id, StartJob.returns[:id]
61
+ end
62
+ from id: [StartJob, :id]
63
+ poll timeout_ms: 3000, settled: [{ actual: "status", compare: "not-equal", expected: { literal: "running" } }]
64
+ claims [{ actual: "status", compare: "equal", expected: "wanted" }]
65
+
66
+ def observe(request:, args:)
67
+ { status: request.get("/jobs/#{args.id}").json["status"] }
68
+ end
69
+ end
70
+ ```
71
+
72
+ ## A page by role and name
73
+
74
+ `observe` returns the page or a locator, and nukadoko takes its ARIA
75
+ snapshot. playwright-ruby-client's methods are snake_case
76
+ (`page.get_by_role("form", name: "Scores")`).
77
+
78
+ ```ruby
79
+ # conformance/engine/projects/claim-aria/steps-rb/scores_form_shows.rb
80
+ class ScoresFormShows < Nukadoko::Step
81
+ pattern "the scores form shows"
82
+ description "The scores form's accessibility tree against the tree the docstring states"
83
+ args { string :tree, "Part of the ARIA snapshot the form shows" }
84
+ poll timeout_ms: 2000
85
+ claims [{ actual: "form", compare: "fits-aria-snapshot", expected: "tree" }]
86
+
87
+ def observe(page:, args:) = { form: page.get_by_role("form", name: "Scores") }
88
+ end
89
+ ```
90
+
91
+ ## The files an earlier step changed
92
+
93
+ `files` names the paths the `Nukadoko.run_command` processes of an
94
+ earlier step changed, read from that step's record, and a claim reads the
95
+ key as its actual. `of` is the step class, or a list of them.
96
+
97
+ ```ruby
98
+ # conformance/engine/projects/changed-files/steps-rb/notes_include.rb
99
+ class NotesInclude < Nukadoko::Step
100
+ pattern "the notes include {path:string}"
101
+ description "The notes the program added include one path"
102
+ args { string :path, "A path under notes/" }
103
+ files written: { of: WriteNotes, change: "added", under: "notes" }
104
+ claims [{ actual: "written", compare: "has-item", expected: "path" }]
105
+ end
106
+ ```