nukadoko 0.1.0 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +417 -0
- data/README.ja.md +62 -7
- data/README.md +19 -5
- data/exe/nuka +8 -0
- data/lib/nukadoko/aria_snapshot.rb +1008 -0
- data/lib/nukadoko/aria_tree.rb +150 -0
- data/lib/nukadoko/base.rb +294 -0
- data/lib/nukadoko/check.rb +669 -22
- data/lib/nukadoko/claim_check.rb +177 -0
- data/lib/nukadoko/claim_check_run.rb +293 -0
- data/lib/nukadoko/claim_line.rb +381 -0
- data/lib/nukadoko/claim_rules.rb +519 -0
- data/lib/nukadoko/claim_sides.rb +469 -0
- data/lib/nukadoko/claims.rb +576 -37
- data/lib/nukadoko/cli.rb +814 -22
- data/lib/nukadoko/codes.json +947 -0
- data/lib/nukadoko/codes.rb +19 -0
- data/lib/nukadoko/command.rb +214 -12
- data/lib/nukadoko/criteria.rb +172 -0
- data/lib/nukadoko/definition.rb +33 -41
- data/lib/nukadoko/env_check.rb +88 -0
- data/lib/nukadoko/features.rb +80 -10
- data/lib/nukadoko/fixtures.rb +329 -11
- data/lib/nukadoko/http_recording.rb +68 -0
- data/lib/nukadoko/init.rb +129 -0
- data/lib/nukadoko/js_json.rb +274 -0
- data/lib/nukadoko/js_pattern.rb +531 -0
- data/lib/nukadoko/judge.rb +221 -0
- data/lib/nukadoko/judgment_file.rb +78 -0
- data/lib/nukadoko/judgments.rb +256 -0
- data/lib/nukadoko/literal.rb +129 -0
- data/lib/nukadoko/measured.rb +105 -0
- data/lib/nukadoko/order.rb +84 -0
- data/lib/nukadoko/parts.rb +43 -22
- data/lib/nukadoko/pattern.rb +73 -3
- data/lib/nukadoko/poll.rb +21 -8
- data/lib/nukadoko/program.rb +105 -17
- data/lib/nukadoko/project_files.rb +17 -0
- data/lib/nukadoko/project_fixtures.rb +17 -2
- data/lib/nukadoko/project_program.rb +119 -0
- data/lib/nukadoko/report_allure.rb +751 -0
- data/lib/nukadoko/report_messages.rb +167 -0
- data/lib/nukadoko/report_run.rb +169 -0
- data/lib/nukadoko/run.rb +898 -91
- data/lib/nukadoko/run_record.rb +535 -0
- data/lib/nukadoko/scaffold.rb +1015 -0
- data/lib/nukadoko/schema.rb +120 -21
- data/lib/nukadoko/secrets.rb +375 -0
- data/lib/nukadoko/selection.rb +163 -0
- data/lib/nukadoko/signature.rb +4 -1
- data/lib/nukadoko/skill.rb +36 -0
- data/lib/nukadoko/spaces.rb +28 -0
- data/lib/nukadoko/step.rb +68 -21
- data/lib/nukadoko/summary.rb +662 -0
- data/lib/nukadoko/table.rb +34 -2
- data/lib/nukadoko/text_fit.rb +179 -0
- data/lib/nukadoko/trace.rb +244 -0
- data/lib/nukadoko/trace_actions.rb +116 -0
- data/lib/nukadoko/tree_passes.rb +122 -0
- data/lib/nukadoko/verdict.rb +128 -0
- data/lib/nukadoko/version.rb +2 -1
- data/lib/nukadoko/vocabulary.rb +6 -0
- data/lib/nukadoko/walk.rb +305 -0
- data/lib/nukadoko/walk_files.rb +473 -0
- data/lib/nukadoko/walk_step.rb +149 -0
- data/lib/nukadoko.rb +60 -2
- data/llms.txt +297 -0
- data/sig/generated/nukadoko/aria_snapshot.rbs +331 -0
- data/sig/generated/nukadoko/aria_tree.rbs +142 -0
- data/sig/generated/nukadoko/base.rbs +142 -0
- data/sig/generated/nukadoko/check.rbs +255 -0
- data/sig/generated/nukadoko/claim_check.rbs +118 -0
- data/sig/generated/nukadoko/claim_check_run.rbs +88 -0
- data/sig/generated/nukadoko/claim_line.rbs +158 -0
- data/sig/generated/nukadoko/claim_rules.rbs +172 -0
- data/sig/generated/nukadoko/claim_sides.rbs +207 -0
- data/sig/generated/nukadoko/claims.rbs +208 -0
- data/sig/generated/nukadoko/cli.rbs +182 -0
- data/sig/generated/nukadoko/codes.rbs +16 -0
- data/sig/generated/nukadoko/command.rbs +109 -0
- data/sig/generated/nukadoko/criteria.rbs +83 -0
- data/sig/generated/nukadoko/definition.rbs +30 -0
- data/sig/generated/nukadoko/env_check.rbs +34 -0
- data/sig/generated/nukadoko/features.rbs +101 -0
- data/sig/generated/nukadoko/fixtures.rbs +175 -0
- data/sig/generated/nukadoko/http_recording.rbs +29 -0
- data/sig/generated/nukadoko/init.rbs +64 -0
- data/sig/generated/nukadoko/js_json.rbs +109 -0
- data/sig/generated/nukadoko/js_pattern.rbs +194 -0
- data/sig/generated/nukadoko/judge.rbs +64 -0
- data/sig/generated/nukadoko/judgment_file.rbs +39 -0
- data/sig/generated/nukadoko/judgments.rbs +120 -0
- data/sig/generated/nukadoko/literal.rbs +71 -0
- data/sig/generated/nukadoko/measured.rbs +42 -0
- data/sig/generated/nukadoko/order.rbs +54 -0
- data/sig/generated/nukadoko/parts.rbs +35 -0
- data/sig/generated/nukadoko/pattern.rbs +62 -0
- data/sig/generated/nukadoko/poll.rbs +41 -0
- data/sig/generated/nukadoko/program.rbs +101 -0
- data/sig/generated/nukadoko/project_files.rbs +19 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +57 -0
- data/sig/generated/nukadoko/project_program.rbs +55 -0
- data/sig/generated/nukadoko/report_allure.rbs +268 -0
- data/sig/generated/nukadoko/report_messages.rbs +68 -0
- data/sig/generated/nukadoko/report_run.rbs +102 -0
- data/sig/generated/nukadoko/run.rbs +264 -0
- data/sig/generated/nukadoko/run_record.rbs +175 -0
- data/sig/generated/nukadoko/scaffold.rbs +328 -0
- data/sig/generated/nukadoko/schema.rbs +155 -0
- data/sig/generated/nukadoko/secrets.rbs +172 -0
- data/sig/generated/nukadoko/selection.rbs +73 -0
- data/sig/generated/nukadoko/signature.rbs +17 -0
- data/sig/generated/nukadoko/skill.rbs +20 -0
- data/sig/generated/nukadoko/spaces.rbs +31 -0
- data/sig/generated/nukadoko/step.rbs +115 -0
- data/sig/generated/nukadoko/summary.rbs +204 -0
- data/sig/generated/nukadoko/table.rbs +43 -0
- data/sig/generated/nukadoko/text_fit.rbs +70 -0
- data/sig/generated/nukadoko/trace.rbs +127 -0
- data/sig/generated/nukadoko/trace_actions.rbs +40 -0
- data/sig/generated/nukadoko/tree_passes.rbs +48 -0
- data/sig/generated/nukadoko/verdict.rbs +56 -0
- data/sig/generated/nukadoko/version.rbs +5 -0
- data/sig/generated/nukadoko/vocabulary.rbs +25 -0
- data/sig/generated/nukadoko/walk.rbs +139 -0
- data/sig/generated/nukadoko/walk_files.rbs +189 -0
- data/sig/generated/nukadoko/walk_step.rbs +50 -0
- data/sig/generated/nukadoko.rbs +26 -0
- data/sig/nukadoko.rbs +5 -48
- data/skills/nukadoko/SKILL.md +120 -0
- data/skills/nukadoko/references/checking-steps.md +200 -0
- data/skills/nukadoko/references/diagnosing.md +200 -0
- data/skills/nukadoko/references/done.md +99 -0
- data/skills/nukadoko/references/evidence.md +124 -0
- data/skills/nukadoko/references/examples/cli.md +230 -0
- data/skills/nukadoko/references/examples/http-api.md +342 -0
- data/skills/nukadoko/references/examples/workflow.md +173 -0
- data/skills/nukadoko/references/exploring.md +184 -0
- data/skills/nukadoko/references/fixtures.md +198 -0
- data/skills/nukadoko/references/from-prose.md +51 -0
- data/skills/nukadoko/references/judgments.md +95 -0
- data/skills/nukadoko/references/maintenance.md +97 -0
- data/skills/nukadoko/references/merge-risk.md +74 -0
- data/skills/nukadoko/references/parts.md +152 -0
- data/skills/nukadoko/references/perturbed-worlds.md +109 -0
- data/skills/nukadoko/references/program.md +200 -0
- data/skills/nukadoko/references/reviewing.md +200 -0
- data/skills/nukadoko/references/running.md +200 -0
- data/skills/nukadoko/references/scenario-rules.md +188 -0
- data/skills/nukadoko/references/states.md +66 -0
- data/skills/nukadoko/references/step-files.md +200 -0
- data/skills/nukadoko/references/verdicts.md +200 -0
- data/skills/nukadoko/references/writing-steps.md +200 -0
- data/skills/nukadoko/references/writing-the-feature.md +165 -0
- data/skills/nukadoko/scripts/claude-code-verdict-hook.mjs +99 -0
- data/skills/nukadoko/scripts/merge-risk.jq +56 -0
- data/skills/nukadoko-verification/SKILL.md +263 -0
- metadata +133 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Generated from lib/nukadoko/walk_step.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# `nuka step wait`, `nuka step next <pause> --walk <n>`, and `nuka step stop
|
|
4
|
+
# <pause> --walk <n>`, the side of a walk that answers it, in the
|
|
5
|
+
# TypeScript engine's shape (src/cli/step.ts). This class reads its
|
|
6
|
+
# arguments and prints; WalkFiles reads and writes the walk's files, and
|
|
7
|
+
# Walk decides what a call does. Findings go to stderr outside --json, as
|
|
8
|
+
# the TypeScript engine prints them, so stdout holds only where the walk
|
|
9
|
+
# stands.
|
|
10
|
+
module Nukadoko
|
|
11
|
+
class CLI
|
|
12
|
+
class Walked
|
|
13
|
+
ACTIONS: untyped
|
|
14
|
+
|
|
15
|
+
DEFAULT_TIMEOUT: ::Integer
|
|
16
|
+
|
|
17
|
+
# : (String, Array[String], Hash[String, Array[String]], json: bool, out: IO, ?err: IO) -> void
|
|
18
|
+
def initialize: (String, Array[String], Hash[String, Array[String]], json: bool, out: IO, ?err: IO) -> void
|
|
19
|
+
|
|
20
|
+
# : () -> Integer
|
|
21
|
+
def call: () -> Integer
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# A whole number of 1 or more, as the command line gave it, or nil.
|
|
26
|
+
# : (String?) -> Integer?
|
|
27
|
+
def whole: (String?) -> Integer?
|
|
28
|
+
|
|
29
|
+
# : () -> Hash[Symbol, untyped]
|
|
30
|
+
def call_of: () -> Hash[Symbol, untyped]
|
|
31
|
+
|
|
32
|
+
# : (String, String) -> String
|
|
33
|
+
def joined: (String, String) -> String
|
|
34
|
+
|
|
35
|
+
# What a person reads at a pause: where the step is, what it
|
|
36
|
+
# recorded, the views of the page it left open, and the two answers.
|
|
37
|
+
# : (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> String
|
|
38
|
+
def text: (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> String
|
|
39
|
+
|
|
40
|
+
# : (String, Integer, Array[Hash[Symbol, untyped]], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
41
|
+
def envelope: (String, Integer, Array[Hash[Symbol, untyped]], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
42
|
+
|
|
43
|
+
# : (String, String, String, ?run: String?, ?fields: Hash[Symbol, untyped]) -> Integer
|
|
44
|
+
def refuse: (String, String, String, ?run: String?, ?fields: Hash[Symbol, untyped]) -> Integer
|
|
45
|
+
|
|
46
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
47
|
+
def print_finding: (Hash[Symbol, untyped]) -> void
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Generated from lib/nukadoko.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Nukadoko
|
|
4
|
+
# What a program file of a release before the program moved into the
|
|
5
|
+
# config calls. Only a `--base` ref still holds one, and the run reads it
|
|
6
|
+
# in a process of its own (Engine::ProjectProgram.elsewhere).
|
|
7
|
+
# : (**untyped) -> Hash[Symbol, untyped]
|
|
8
|
+
def self.program: (**untyped) -> Hash[Symbol, untyped]
|
|
9
|
+
|
|
10
|
+
# : () -> Hash[Symbol, untyped]?
|
|
11
|
+
def self.legacy_program: () -> Hash[Symbol, untyped]?
|
|
12
|
+
|
|
13
|
+
# The program under test of the project whose config load_project read.
|
|
14
|
+
# : () -> Hash[Symbol, untyped]
|
|
15
|
+
def self.program_options: () -> Hash[Symbol, untyped]
|
|
16
|
+
|
|
17
|
+
# Loads the config of the project at `root`, and reads its program.
|
|
18
|
+
# : (String) -> void
|
|
19
|
+
def self.load_project: (String) -> void
|
|
20
|
+
|
|
21
|
+
# : (**untyped) -> Hash[Symbol, untyped]
|
|
22
|
+
def self.config: (**untyped) -> Hash[Symbol, untyped]
|
|
23
|
+
|
|
24
|
+
# : () -> Hash[Symbol, untyped]
|
|
25
|
+
def self.config_options: () -> Hash[Symbol, untyped]
|
|
26
|
+
end
|
data/sig/nukadoko.rbs
CHANGED
|
@@ -1,54 +1,11 @@
|
|
|
1
|
+
# What rbs-inline cannot write from lib/'s comments: the methods
|
|
2
|
+
# define_method defines, and the type of a command's result a step author
|
|
3
|
+
# reads. The rest is in sig/generated.
|
|
1
4
|
module Nukadoko
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def boolean: (Symbol, ?String, ?null: bool) -> void
|
|
5
|
-
def integer: (Symbol, ?String, ?null: bool) -> void
|
|
6
|
-
def number: (Symbol, ?String, ?null: bool) -> void
|
|
7
|
-
def strings: (Symbol, ?String, ?null: bool) -> void
|
|
8
|
-
def table: (Symbol, ?String, ?null: bool) -> void
|
|
9
|
-
def unknown: (Symbol, ?String) -> void
|
|
10
|
-
def enum: (Symbol, Array[String | Symbol], ?String, ?null: bool) -> void
|
|
11
|
-
def object: (Symbol, ?String, ?null: bool) { () [self: Schema] -> void } -> void
|
|
12
|
-
def field: (Symbol, Field, ?String) -> void
|
|
13
|
-
def []: (Symbol) -> Field
|
|
14
|
-
|
|
15
|
-
class Field
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
type command_result = { exitCode: Integer?, stdout: String, stderr: String }
|
|
20
|
-
|
|
21
|
-
def self.run_command: (String, ?Array[String], ?cwd: String, ?env: Hash[String | Symbol, String], ?stdin: String?) -> command_result
|
|
22
|
-
def self.fixture: (Symbol, ?scope: :scenario | :process) { (^(untyped) -> void, **untyped) -> void } -> untyped
|
|
23
|
-
|
|
24
|
-
class Step
|
|
25
|
-
def self.pattern: (String) -> String
|
|
26
|
-
def self.description: (String) -> String
|
|
27
|
-
def self.mutates: (bool) -> bool
|
|
28
|
-
def self.claims: (Array[Hash[Symbol, untyped]]) -> untyped
|
|
29
|
-
def self.poll: (untyped) -> untyped
|
|
30
|
-
def self.args: () { () [self: Schema] -> void } -> Schema
|
|
31
|
-
def self.returns: () { () [self: Schema] -> void } -> Schema
|
|
32
|
-
| () -> Schema
|
|
33
|
-
def self.from: (Hash[Symbol, untyped]) -> untyped
|
|
34
|
-
def self.parts: (Array[singleton(Step)]) -> Array[singleton(Step)]
|
|
35
|
-
end
|
|
5
|
+
# `files` is there when the run measured what changed under its cwd.
|
|
6
|
+
type command_result = { exitCode: Integer?, signal: String?, stdout: String, stderr: String, ?files: untyped }
|
|
36
7
|
|
|
37
8
|
module Engine
|
|
38
|
-
class Response
|
|
39
|
-
attr_reader status: Integer
|
|
40
|
-
def json: () -> untyped
|
|
41
|
-
def ok?: () -> bool
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
class Caller
|
|
45
|
-
def call: (singleton(Nukadoko::Step), ?Hash[String | Symbol, untyped], **untyped) -> untyped
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class Scratch
|
|
49
|
-
def dir: (?String) -> String
|
|
50
|
-
end
|
|
51
|
-
|
|
52
9
|
class Request
|
|
53
10
|
def get: (String, ?data: untyped, ?body: String?, ?headers: Hash[String, String]) -> Response
|
|
54
11
|
def post: (String, ?data: untyped, ?body: String?, ?headers: Hash[String, String]) -> Response
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nukadoko
|
|
3
|
+
description: Use when turning a requirement into a Gherkin scenario and the run that is its evidence, for a person to review, starting from whatever is on hand, whether that is raw prose with no stated acceptance criteria yet (a ticket, a request, a conversation), acceptance criteria that still need concrete scenarios, a scenario ready to write, a path already explored one `nuka do` call at a time and now worth fixing in a scenario, a browser app whose state cannot be repeated and has to be explored through a Playwright MCP server first, or a scenario a person wants to walk one step at a time, the run paused after each step while the agent explains its record and waits for the person's answer.
|
|
4
|
+
compatibility: Requires the nukadoko npm package installed in the project (a devDependency), whose nuka CLI is run as `npx nuka`; the loop below shells out to it (nuka init, nuka steps, nuka describe, nuka scaffold, nuka do, nuka check, nuka run, nuka step, nuka verdict, nuka judge).
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# nukadoko acceptance loop
|
|
9
|
+
|
|
10
|
+
A person approves a change by reading the feature file and the run
|
|
11
|
+
summary: the run is the evidence, and where the approval is recorded is
|
|
12
|
+
the team's process. The feature is written before the implementation it judges,
|
|
13
|
+
from the criteria and never from the program's output, which is what
|
|
14
|
+
makes a green run evidence rather than agreement. This file is the order
|
|
15
|
+
of work: open the reference a step names when you reach it.
|
|
16
|
+
`node_modules/nukadoko/llms.txt` names every command, flag, and code.
|
|
17
|
+
|
|
18
|
+
## Before the first command
|
|
19
|
+
|
|
20
|
+
Say in two or three sentences what the loop is for and what it will
|
|
21
|
+
touch, then one line for each of these that applies:
|
|
22
|
+
|
|
23
|
+
- A `mutates: true` step that reaches past the project (a real service, a
|
|
24
|
+
shared database, a file outside `scratch`) gets a go-ahead before its first
|
|
25
|
+
`nuka do`, once, not on every retry. A step that writes only under `scratch`,
|
|
26
|
+
or only to a server a fixture or the program in `nukadoko.config.ts` started, needs none
|
|
27
|
+
(`references/writing-steps.md`, "Asking before a step changes something").
|
|
28
|
+
- A step that needs `page`, `context`, `pageAs`, or `request` needs the project's
|
|
29
|
+
own `playwright`; `nuka check` reports `playwright-missing` with the
|
|
30
|
+
install line. Adding it is a dependency change: ask first. A `page` step
|
|
31
|
+
makes `nuka run` open a browser and take minutes. A project on e2e
|
|
32
|
+
drives it through e2e instead (`references/fixtures.md`, last section).
|
|
33
|
+
- A Playwright MCP server, when the loop explores a browser app whose
|
|
34
|
+
state cannot be repeated, drives the real application with whatever
|
|
35
|
+
login it holds. A click that submits something there needs the same
|
|
36
|
+
go-ahead (`references/exploring.md`).
|
|
37
|
+
|
|
38
|
+
Run-time output lands under `.nukadoko/`, gitignored, and can hold
|
|
39
|
+
credentials in plaintext. nukadoko makes no outbound calls of its own and
|
|
40
|
+
never commits, pushes, or publishes. Keep the narration short.
|
|
41
|
+
|
|
42
|
+
## Where to start
|
|
43
|
+
|
|
44
|
+
Run `nuka` from the directory that holds the config, and `nuka init` first
|
|
45
|
+
when there is none (`references/running.md`, "Setting up"); an app to start
|
|
46
|
+
needs the program in `nukadoko.config.ts` (`references/program.md`). A Ruby project
|
|
47
|
+
writes steps as the "Ruby" section of `llms.txt` says. Pick one line:
|
|
48
|
+
|
|
49
|
+
1. **Prose only** (a ticket, a request, a conversation):
|
|
50
|
+
`references/from-prose.md`, then line 2.
|
|
51
|
+
2. **Criteria sentences, no scenario yet**: `references/scenario-rules.md`
|
|
52
|
+
and `references/writing-the-feature.md`, then the loop.
|
|
53
|
+
3. **A concrete scenario, or one you can write directly**: the loop.
|
|
54
|
+
4. **A path already run** with `nuka do` or a Playwright MCP server:
|
|
55
|
+
write the scenario from what you ran (`references/exploring.md`, "Then
|
|
56
|
+
fix what you found"), then the loop at step 3.
|
|
57
|
+
5. **A browser app whose state cannot be repeated** (an account that
|
|
58
|
+
opens once): drive it through the host's Playwright MCP server,
|
|
59
|
+
connected when its `browser_*` tools are listed; a Claude Code host
|
|
60
|
+
adds it with `claude mcp add playwright npx @playwright/mcp@latest`
|
|
61
|
+
once the person agrees. Then line 4 (`references/exploring.md`,
|
|
62
|
+
"Exploring state that cannot be repeated").
|
|
63
|
+
6. **A scenario the person wants to check step by step with you**: walk
|
|
64
|
+
it with `nuka run <file>:<line> --step` (`references/reviewing.md`).
|
|
65
|
+
|
|
66
|
+
If none is true, ask what this is supposed to do before writing anything.
|
|
67
|
+
|
|
68
|
+
## The loop
|
|
69
|
+
|
|
70
|
+
1. **Feature first.** Write the `.feature` from the criteria, by
|
|
71
|
+
`references/scenario-rules.md`, and copy the criteria verbatim under
|
|
72
|
+
`Feature:` (`references/writing-the-feature.md`). Every expected value
|
|
73
|
+
is one the criteria state; a value they do not state is a question for
|
|
74
|
+
a person, not a guess and not a value read off the program.
|
|
75
|
+
2. **Steps.** `nuka steps` lists the vocabulary, `nuka describe <step>` one
|
|
76
|
+
contract; reuse before scaffolding. `nuka scaffold --feature <file>` stubs
|
|
77
|
+
each undefined line and prints each stub's own `nuka scaffold ...
|
|
78
|
+
--replace` line. Redo the When that runs a program or sends a request, and
|
|
79
|
+
the Thens that read it, from those lines with `--description`, `--command
|
|
80
|
+
<entry point>` (`--cwd`, `--argv`) or `--request "<METHOD> <path>"`, and
|
|
81
|
+
`--from <step>.<key>` per value an earlier step returns (its producer has
|
|
82
|
+
to return that key already). A step that needs only what an earlier line
|
|
83
|
+
did `requires` the state that line's step `gives` (`references/states.md`).
|
|
84
|
+
A Then declares `claims`, never `run` (`references/checking-steps.md`). Run
|
|
85
|
+
each alone with `nuka do <step> --args '<json>'`
|
|
86
|
+
(`references/writing-steps.md`). Finished projects: `references/examples/`.
|
|
87
|
+
3. **`nuka check <feature>`.** Fix every error and read every warning: a
|
|
88
|
+
warning is a question about intent, not noise. Each finding names its
|
|
89
|
+
file, a `fix:` (an edit) or `do:` (a command) line; apply or run it.
|
|
90
|
+
4. **`nuka run <feature>`** until no table row is `failed`, reading the step
|
|
91
|
+
record a failure names first (`references/diagnosing.md`), then once more
|
|
92
|
+
with `--order shuffled` (`references/running.md`). A red Then, an
|
|
93
|
+
`unexpected-failure`, or a `held` row whose control passed
|
|
94
|
+
(`references/verdicts.md`) is fixed in the code or by asking the person,
|
|
95
|
+
never by weakening it or tagging it away. Read "What this run does not show",
|
|
96
|
+
`measured: none` (`references/reviewing.md`), `undeclared-write`, and each `judgment-` finding (`references/judgments.md`).
|
|
97
|
+
5. **Commit before the run you report**, push, and open the pull request;
|
|
98
|
+
CI posts the summary of `nuka run --base <the base>` (`docs/ci.md`). Run
|
|
99
|
+
it first: `unproven`, `moved`, and `intent-` findings are red
|
|
100
|
+
(`references/verdicts.md`, and `INTENT.md` in `references/done.md`).
|
|
101
|
+
6. **Decide where the feature lives**, in the same pull request: the
|
|
102
|
+
product's core path moves into `featuresDir`, which `nuka run` runs on
|
|
103
|
+
every commit; a feature for one change stays outside it, named in
|
|
104
|
+
`additionalFeatureDirs` (`references/maintenance.md`).
|
|
105
|
+
|
|
106
|
+
A lesson from a run becomes an example row, then a rule, then a finding
|
|
107
|
+
code (`references/scenario-rules.md`, "How this file grows").
|
|
108
|
+
|
|
109
|
+
## What not to do
|
|
110
|
+
|
|
111
|
+
- Don't write a Then from what the program printed, or edit one after a red
|
|
112
|
+
run without the person's word: either is the implementation grading itself.
|
|
113
|
+
- Don't fill in a requirement the source never stated (`references/from-prose.md`).
|
|
114
|
+
- Don't run a step that reaches past the project without a go-ahead, and
|
|
115
|
+
don't keep fixing one step past three cycles: report where it stands. A
|
|
116
|
+
prompt that gives a different budget overrides the three.
|
|
117
|
+
- Don't hand-edit a step record or a run summary: it was measured, and
|
|
118
|
+
editing it turns it back into an unmeasured account.
|
|
119
|
+
- Don't act unasked on a note about a step you are not writing:
|
|
120
|
+
report it (`references/maintenance.md`).
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# A Then that claims
|
|
2
|
+
|
|
3
|
+
## The shape
|
|
4
|
+
|
|
5
|
+
A Then judges, never in code: its step declares `claims` in place of `run`,
|
|
6
|
+
naming the value it reads, how it compares it, and where its expected value
|
|
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
|
|
11
|
+
(`then-without-claims`) and a claim step in a Given or a When
|
|
12
|
+
(`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
|
+
```
|
|
28
|
+
|
|
29
|
+
A claim is `{ actual, view?, at?, count?, compare, expected, expected_view? }`.
|
|
30
|
+
`nuka scaffold --then --from <step>.<key>` writes this shape when the
|
|
31
|
+
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.
|
|
37
|
+
|
|
38
|
+
## Where the expected value comes from
|
|
39
|
+
|
|
40
|
+
Pick the source from the sentence; the record names it in `expected_from`.
|
|
41
|
+
|
|
42
|
+
- **The sentence states it** (a capture, the docstring, or the table):
|
|
43
|
+
`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
|
|
49
|
+
claim reads each value the line states: an unread capture is refused, an
|
|
50
|
+
unread docstring or table `claim-sentence-unread`.
|
|
51
|
+
- **An earlier step returned it** ("the item count is unchanged"): `expected:
|
|
52
|
+
{ from: "<from key>.<path>" }`, recorded as `from:<step>@<line>.<key>`.
|
|
53
|
+
- **The pattern's fixed words state it** ("is refused", "exits 0"):
|
|
54
|
+
`expected: { literal: "refused" }`, or `compare: "is-a", expected: {
|
|
55
|
+
literal: "UUID" }` for "the order id is a UUID". The literal is exactly the
|
|
56
|
+
pattern's own words, `zero` to `twelve` as a number word, `once`, or `twice`
|
|
57
|
+
(any compare), or `0`, `""`, or `[]` for `no`, `none`, `nothing`, or
|
|
58
|
+
`neither` (`0` for `never`, `""` or `[]` for `empty`) with `compare: "equal"`
|
|
59
|
+
only, or `"not-equal"` only right after the fixed word `not`, `neither`, or
|
|
60
|
+
`nor` ("is not empty"). A `neither` that a `nor` follows states nothing. Any
|
|
61
|
+
other literal is refused: `Then the command succeeds` cannot claim `0`.
|
|
62
|
+
- **A second reading** ("A is listed before B"): `expected: { observe:
|
|
63
|
+
"<path>" }`, a value `observe` returned beside the actual one.
|
|
64
|
+
|
|
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
|
+
## The actual value
|
|
101
|
+
|
|
102
|
+
`actual` is a path whose first segment is a `from` key or a key `observe`
|
|
103
|
+
returns, or an `events` key (`program.md`) or a `files` key (`parts.md`) alone,
|
|
104
|
+
never a key the sentence fills (a `from` key hides an `observe` key of its name,
|
|
105
|
+
so a step whose claims read no `observe` key is refused); a path reads own
|
|
106
|
+
properties only (not `constructor`, not a getter). `view: "text"` trims the end
|
|
107
|
+
(a program's last newline), `"lines"` also splits it into lines, `"json"` parses
|
|
108
|
+
it, and `"comma-list"` splits it at commas; `at` then takes a path inside the
|
|
109
|
+
viewed value, so parsing is data: `{ actual: "stdout", view: "json", at:
|
|
110
|
+
"sections.git.0.dirty_count", compare: "equal", expected: "count" }`. `count:
|
|
111
|
+
true` then compares the number of items of the array there, with a number
|
|
112
|
+
compare only (`at-least` the literal `1` for "at least one row"), and breaks on
|
|
113
|
+
a value that is not an array. `{ actual, each: { where?, claims } }` applies
|
|
114
|
+
item claims to every item of an array (paths inside are relative to the item),
|
|
115
|
+
and breaks when the array, or what `where` selects, is empty. A `where` claim
|
|
116
|
+
whose path starts an item claim's, or the reverse, is refused with `equal`,
|
|
117
|
+
`has-same-items`, `has-fields`, `lacks-field`, `fits-text`, `is-a`, `has-item`,
|
|
118
|
+
`matches`, `contains-text`, `starts-with-text`, or `ends-with-text`, and breaks
|
|
119
|
+
the claim where it implies it.
|
|
120
|
+
|
|
121
|
+
The compares: `equal` (structural), `not-equal`, `contains-text`,
|
|
122
|
+
`starts-with-text`, `ends-with-text`, `has-item`, `has-same-items` (in any
|
|
123
|
+
order), `has-fields` (the expected fields at any depth, each array whole),
|
|
124
|
+
`lacks-field` (no key of the expected name: "has no password field" is
|
|
125
|
+
`expected: { literal: "password" }`, and a field set to `null` is a key),
|
|
126
|
+
`fits-text` (line by line; a line `...` is any lines, `[..]` any text in its
|
|
127
|
+
line, `[..:id]` too, one text per name, no two alike), `is-a` (a kind: a JSON type, `integer`, `uuid`, `date`, `timestamp`,
|
|
128
|
+
`url`), `fits-aria-snapshot` (a page by role and name, below), `matches`,
|
|
129
|
+
`greater-than`, `at-least`, `less-than`, `at-most`, and `judged-as` for a
|
|
130
|
+
quality only a reader can judge (`judgments.md`). A JSON docstring (`expected_view: "json"`)
|
|
131
|
+
claims a whole response with `equal` (a field it leaves out breaks it, a `null` one too) or some of its fields with
|
|
132
|
+
`has-fields`; output that changes each run takes `fits-text`, never `{ from }`
|
|
133
|
+
or `{ observe }`. Two values of different JSON types break the claim (`is-a` and
|
|
134
|
+
`lacks-field` aside), and so does an expected value nearly every value holds (a
|
|
135
|
+
blank text or field name, a pattern matching `""`, an object with no field, only
|
|
136
|
+
stand-ins). Each side is a plain JSON copy, and `observe` gets a clone of
|
|
137
|
+
its inputs; a `Date`, a bigint, `NaN`, an `undefined` item, a `Proxy`, or
|
|
138
|
+
nesting past 256 levels leaves the claim `unjudged` (return an ISO string or a
|
|
139
|
+
number). Each claim or item the step's deadline cuts off, a running `matches`
|
|
140
|
+
included, is `unjudged`, with how many. So is a claim that a key `returns`
|
|
141
|
+
dropped could break. `nuka check` reports a `from` path `returns` lacks or
|
|
142
|
+
`args` drops (`claim-path-unknown`, `claim-args-dropped`), a `lacks-field`
|
|
143
|
+
on a field `returns` drops (`claim-field-stripped`), a count or `each` on a
|
|
144
|
+
non-array (`claim-not-an-array`), sides at one place (`claim-compares-itself`),
|
|
145
|
+
an `is-a` capture naming no kind (`claim-kind-unknown`), and a transformer on
|
|
146
|
+
an expected key (`claim-expected-transformed`).
|
|
147
|
+
|
|
148
|
+
## Observe, poll, and a boolean
|
|
149
|
+
|
|
150
|
+
`observe(fixtures, args)` reads the world when no earlier step returned the
|
|
151
|
+
value. It gets every args key but the ones a claim compares with, or the `from`
|
|
152
|
+
key of an actual compared with `{ observe }`, and reading one, or calling
|
|
153
|
+
`resultOf`, throws: an earlier step's value reaches a claim through `from`
|
|
154
|
+
alone. A throw records `unobserved`. Return what you measured, never a verdict:
|
|
155
|
+
a text, a number, a list (a claim with `count: true` counts it, so return the
|
|
156
|
+
list, not its length). A boolean literal is refused when the actual value comes
|
|
157
|
+
from `observe`, since `{ visible: true }` is the judgment made in code. For a
|
|
158
|
+
yes or no in the sentence, return the word it uses
|
|
159
|
+
(`outcome: "accepted" | "refused"`, `examples/workflow.md`), or the measurement
|
|
160
|
+
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
|
|
162
|
+
that answers it; a note on a step you are not changing is a report.
|
|
163
|
+
|
|
164
|
+
`poll: { timeout_ms }` runs `observe` every 100 ms until every claim holds on
|
|
165
|
+
two readings in a row, then judges the last; `readings` keep what each read. A
|
|
166
|
+
Then whose `observe` reaches `page`, `context`, or `pageAs` states `poll` or
|
|
167
|
+
`poll: false` (`claim-poll-unstated`). A broken poll waits out its timeout,
|
|
168
|
+
unless `settled: [{ actual, compare, expected: { literal } }]` names a state the
|
|
169
|
+
page cannot leave once reached (no busy element): two readings in a row in it
|
|
170
|
+
with a claim broken stop the poll, and it never makes a claim hold.
|
|
171
|
+
|
|
172
|
+
**One step per claim, or the expected value in the line?** Let the sentence a
|
|
173
|
+
non-engineer agreed to decide: "the total is {expected:int}" carries its value,
|
|
174
|
+
so it is one step; "is in trial" and "is not in trial" are two steps.
|
|
175
|
+
|
|
176
|
+
## A page by role and name
|
|
177
|
+
|
|
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
|
|
182
|
+
returns the page or a locator from `observe` and claims `fits-aria-snapshot`
|
|
183
|
+
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
|
+
```
|
|
197
|
+
|
|
198
|
+
The docstring states part of the tree (`writing-the-feature.md`). A name between
|
|
199
|
+
slashes, `[active]`, and a tree that names nothing are refused
|
|
200
|
+
(`claim-aria-snapshot-unreadable`, `claim-aria-snapshot-names-nothing`).
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Diagnosing a failed run
|
|
2
|
+
|
|
3
|
+
## A command that refused
|
|
4
|
+
|
|
5
|
+
A command that stopped before it ran anything exits 2, not 1, and prints one
|
|
6
|
+
`refused` finding with a code, such as
|
|
7
|
+
`refused\ttarget-not-found\t-\t<message>`; under `--json` it is in the
|
|
8
|
+
envelope's `findings`, and `verdict` is `refused`. Make the edit its `fix:` line
|
|
9
|
+
names, or run its `do:` line, before you guess at a fix: the `do:` is the step
|
|
10
|
+
list for an unknown step name, the install line for a missing package, or the
|
|
11
|
+
command's own `--help` for a flag it does not accept.
|
|
12
|
+
|
|
13
|
+
## Work through the failed step first
|
|
14
|
+
|
|
15
|
+
`nuka run`'s stderr already names where to start: under the failed step's
|
|
16
|
+
`failed` line, the first line of its error and the path of its step record
|
|
17
|
+
(`record <stateDir>/runs/<run_id>/steps/<id>`), and after the summary, a
|
|
18
|
+
`failed\tscenario-failed\t<file>:<line>\t<name>: <error>` finding per
|
|
19
|
+
failed scenario, whose ` do:` line runs that scenario alone.
|
|
20
|
+
The same list is in the run's `run.json` (`nuka run --json` prints it):
|
|
21
|
+
each entry of `scenarios` with `status: "failed"` names its `do` command,
|
|
22
|
+
and its failed step names its `line`, its `error` (`kind`, `message`),
|
|
23
|
+
its step `record`, and the `used` results it read (a large one cut to a
|
|
24
|
+
preview marked `truncated`; the producer's `record` holds it whole).
|
|
25
|
+
When the failed step read from a step whose program exited nonzero, a
|
|
26
|
+
`used <step> exit <code> <first stderr line>` line sits between the
|
|
27
|
+
two: a Then that claimed against an empty stdout usually broke there, because
|
|
28
|
+
the program did not start (a missing build, a missing dependency, a `.js`
|
|
29
|
+
import of a `.ts` file under `node`), and the step that ran it passed.
|
|
30
|
+
When that program was Node and it crashed, the line shows the `Error:`
|
|
31
|
+
line, not the location Node printed above it. A program that wrote its
|
|
32
|
+
refusal on stdout and nothing on stderr (as under `--json`) shows
|
|
33
|
+
`stdout: ` and what it printed there.
|
|
34
|
+
A Then that failed with `claim_broken` prints its claim line: both
|
|
35
|
+
values and where each came from. Check that the actual value's source is
|
|
36
|
+
the thing the criterion means before you suspect the implementation; the
|
|
37
|
+
step record's `claims` give each claim's `measured`, the channel that
|
|
38
|
+
holds the raw value. `unobserved` means `observe` threw, so no claim was
|
|
39
|
+
judged. A claim step's `timeout` leaves each claim `unjudged`, beside the
|
|
40
|
+
readings read before the deadline. `claim_unjudged` means nukadoko itself failed while judging (its
|
|
41
|
+
reason names the failure): nothing is known about that criterion yet. Open that path's `record.json` rather than
|
|
42
|
+
searching the records directory.
|
|
43
|
+
|
|
44
|
+
Before repeating `nuka run <feature>`, read the failed step's own step
|
|
45
|
+
record in this order. The sections below are how to read the items that
|
|
46
|
+
need more than a glance.
|
|
47
|
+
|
|
48
|
+
1. Its `used` entries: each carries the full validated `result` of the upstream
|
|
49
|
+
step it read from, sitting right on the step record that failed.
|
|
50
|
+
2. `actions`, then the rest of the timeline ("Reading a step record as a
|
|
51
|
+
timeline"): every Playwright call this step made through the `page` fixture,
|
|
52
|
+
`expect` waits included, each with its own duration and outcome.
|
|
53
|
+
3. `page_events`, if the step opened a browser: a console error, an
|
|
54
|
+
uncaught page error, or a failed request recorded there can explain a
|
|
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`).
|
|
61
|
+
5. `nuka do <step> --use <upstream-step-record-id>` when the record
|
|
62
|
+
sharpens a hypothesis rather than confirming it ("Testing a hypothesis
|
|
63
|
+
without a full re-run").
|
|
64
|
+
6. Re-run the scenario last, with the `do:` line `nuka run` printed, once the
|
|
65
|
+
step itself passes under `do`, not as the first thing tried after a failure.
|
|
66
|
+
|
|
67
|
+
## Reading a broken claim
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
claim broken: "food: 5.5\nrent: 100" (from:run-tally@16.stdout as text) equal "food: 5.5\nrent: 101" (sentence:expected); first difference at line 2: actual "rent: 100", expected "rent: 101"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The actual value and its source, the compare, the expected value and its source,
|
|
74
|
+
then where the two part. A broken `has-same-items`, or `equal` on two lists with
|
|
75
|
+
an item inserted or removed, names the expected items that are missing and the
|
|
76
|
+
actual items that are extra, each with its index on its own side
|
|
77
|
+
(`; 1 actual item is extra: ["4","chair","2"] (item 3)`), so an inserted row is
|
|
78
|
+
one extra item, not a difference at every row after it. The step fails with
|
|
79
|
+
`claim_broken`, and the run summary lists every claim under "Claims" with its
|
|
80
|
+
outcome. A broken claim is fixed in the implementation or by asking the person,
|
|
81
|
+
never by a weaker compare.
|
|
82
|
+
|
|
83
|
+
A polled claim that broke says why its poll stopped. `; the poll stopped on
|
|
84
|
+
reading 4, before its 5000 ms timeout, since readings 3 and 4 settled (screen
|
|
85
|
+
equal "scoring")` means the page reached the state the step declares final;
|
|
86
|
+
`the poll read until its 5000 ms timeout, and no two consecutive readings
|
|
87
|
+
settled` means it never did. Each reading's `settled` in the record says which.
|
|
88
|
+
|
|
89
|
+
A claim on a count of execution events ends with what the count counted,
|
|
90
|
+
grouped by what each line reports, whatever the outcome:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
claim broken: 1 (events:open-room@4 count db where op in [insert, update, delete, other], committed true) equal 0 (literal:nothing); counted 1 line: db insert into events
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`events_read.<key>.counted` in the step record lists every group, and
|
|
97
|
+
`events-read.jsonl` holds each line. A group the sentence does not mean is
|
|
98
|
+
a question for the person. A table the program writes for its own
|
|
99
|
+
bookkeeping (a telemetry row) or to run (a cache entry, a migration row) is
|
|
100
|
+
the program's to declare: a `lists.tables` command prints
|
|
101
|
+
`{"table":"events","holds":"bookkeeping"}` (or `"infrastructure"`) from
|
|
102
|
+
where the program already says it, never from a list in the config,
|
|
103
|
+
and a `db` count that names no `table` then leaves those lines out. The
|
|
104
|
+
line ends `left out 1 line: db insert into events (bookkeeping)`, and
|
|
105
|
+
`events_read.<key>.left_out` names each group. Otherwise the implementation
|
|
106
|
+
stops the write, or the step's `count` names the tables the sentence means.
|
|
107
|
+
A held count is read the same way, since it may have counted the wrong
|
|
108
|
+
table or left out the one the sentence means. A tables list that was not
|
|
109
|
+
read (`program-list-unread`) leaves such a count `unjudged`
|
|
110
|
+
(`holds_unknown`): fix the command first.
|
|
111
|
+
|
|
112
|
+
The note `undeclared-write` (`nuka run`) names a step that declares
|
|
113
|
+
`mutates: false` whose trace holds a write the program committed to a
|
|
114
|
+
table that holds state, with the table and the op. The declaration or the
|
|
115
|
+
program is wrong; ask the person which before changing either.
|
|
116
|
+
|
|
117
|
+
## Reading a step record as a timeline
|
|
118
|
+
|
|
119
|
+
Read the failed step's own step record as one timeline rather than a bag of
|
|
120
|
+
separate fields: `started_at`, `finished_at`, `sections[].at`, `polls[].at`,
|
|
121
|
+
`actions[].at`, and `evidence.screenshots[].at` all share one clock, so sorted
|
|
122
|
+
together they are an ordered account of what happened when.
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
jq -r '([{at: .started_at, event: "started"}, {at: .finished_at, event: "finished"}]
|
|
126
|
+
+ (.sections // [] | map({at, event: "section:\(.label)"}))
|
|
127
|
+
+ (.polls // [] | map({at, event: "poll:\(.description // "poll")"}))
|
|
128
|
+
+ (.actions // [] | map({at, event: "action:\(.method) (\(.ms)ms, \(.outcome))"}))
|
|
129
|
+
+ (.evidence.screenshots // [] | map({at, event: "screenshot:\(.file)"})))
|
|
130
|
+
| sort_by(.at)[] | "\(.at) \(.event)"' record.json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`actions` is every Playwright call this step made through the `page`
|
|
134
|
+
fixture, `expect` waits included, each with its own duration and outcome,
|
|
135
|
+
read straight off the step's own trace: an `expect` that timed out shows up
|
|
136
|
+
here with `outcome: "failed"` and a real `ms`, often enough to explain a
|
|
137
|
+
failure without opening the trace viewer at all.
|
|
138
|
+
|
|
139
|
+
If the step opened a browser (destructured `page`), also check `page_events` on
|
|
140
|
+
that step record: a console error, an uncaught page error, or a failed request
|
|
141
|
+
recorded there can explain a failure nothing else on the step record mentions,
|
|
142
|
+
since it comes from the page itself rather than anything the step declared.
|
|
143
|
+
|
|
144
|
+
## The `final.png` and absence claims
|
|
145
|
+
|
|
146
|
+
If an absence claim turns up on that timeline, check whether its own moment
|
|
147
|
+
sits before whatever readiness evidence the step returned alongside it.
|
|
148
|
+
Earlier means the read landed before the page was ready to be read,
|
|
149
|
+
premature, not a state problem to go chase in the app. Don't trust
|
|
150
|
+
`final.png` to show the moment of failure either: it is taken at teardown,
|
|
151
|
+
the scenario's end (the step's under `nuka do`). A Then that read a page has
|
|
152
|
+
`judged_view` (`judged/page.png`, `judged/page.aria.yml`), taken right after
|
|
153
|
+
the reading its claims were judged on, each file with `after_reading_ms`
|
|
154
|
+
(the summary's `seen` links it): open that first. Reach for the
|
|
155
|
+
trace only when the DOM itself is what's in question: `npx playwright
|
|
156
|
+
show-trace <evidence.dir>/trace.zip`. That trace is this one step's own
|
|
157
|
+
window now, not the whole scenario's recording, so what it shows is exactly
|
|
158
|
+
this failure, nothing earlier in the scenario to scrub past first.
|
|
159
|
+
A `pageAs(name)` context records apart from the default one: its trace is
|
|
160
|
+
the `evidence.named_traces[]` entry whose `as` is that name, with `file`
|
|
161
|
+
naming `trace.<name>.zip`, and its screenshot is `final.<name>.png`.
|
|
162
|
+
A step that only called an API has no page to show. With `showRequests:
|
|
163
|
+
true` in `nukadoko.config.ts`, `evidence.requests_trace` names a trace
|
|
164
|
+
(`requests.zip`) whose screen shows each request the step sent and the
|
|
165
|
+
body that came back, redacted as http.jsonl is. http.jsonl holds the same
|
|
166
|
+
facts as text, and is quicker to read.
|
|
167
|
+
|
|
168
|
+
A Then that read a page while a request to the world was in flight says so on
|
|
169
|
+
its summary line (`read with a request in flight`, each request with the step
|
|
170
|
+
that sent it), and its record's `pages` name each page's `last_response` and
|
|
171
|
+
`in_flight` in `page_requests`, whose `span_id` finds the page's `http.jsonl`
|
|
172
|
+
line and the program's request line. A claim that broke there may have read the
|
|
173
|
+
page before the answer it needed: poll the Then (`checking-steps.md`), or have
|
|
174
|
+
the When wait for what it started. This is an order, never what the page drew.
|
|
175
|
+
|
|
176
|
+
## A step that timed out
|
|
177
|
+
|
|
178
|
+
`error.kind: "timeout"` on a typed step means its `run` passed its
|
|
179
|
+
deadline: `stepTimeout` in `nukadoko.config.ts` (twenty minutes unless the
|
|
180
|
+
project sets it), or the step's own `defineStep({ timeout })`, which
|
|
181
|
+
`nuka describe <step>` shows when it is declared. The error message names
|
|
182
|
+
which one fired. Before raising either, read the timeline: the last
|
|
183
|
+
`sections` label says which stage the step was in when the deadline
|
|
184
|
+
passed. A wait on something that will never happen only fails slower
|
|
185
|
+
under a longer deadline. Raise the step's own `timeout` only when the step
|
|
186
|
+
is slow by design, and `stepTimeout` only when most steps are.
|
|
187
|
+
|
|
188
|
+
## Testing a hypothesis without a full re-run
|
|
189
|
+
|
|
190
|
+
If a step record only sharpens a hypothesis rather than confirming it, test
|
|
191
|
+
the hypothesis with `nuka do <step> --use <upstream-step-record-id>`
|
|
192
|
+
instead of re-running the scenario. It executes the one step in question,
|
|
193
|
+
seconds, where a full `nuka run` costs minutes, and it still counts toward
|
|
194
|
+
the same three-fix-and-retry-cycles rule in `references/writing-steps.md`
|
|
195
|
+
("When the vocabulary has no step for it").
|
|
196
|
+
|
|
197
|
+
Re-run the whole feature last, once the step itself passes under `do`, not
|
|
198
|
+
as the first thing tried after a failure. Repeating `nuka run` end to end
|
|
199
|
+
is the expensive way to learn what a single step record, or a single `do`
|
|
200
|
+
call, would already have told you.
|