nukadoko 0.3.0 → 0.4.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 +27 -0
- data/README.ja.md +1 -0
- data/README.md +1 -0
- data/lib/nukadoko/check.rb +58 -1
- data/lib/nukadoko/claim_sides.rb +12 -0
- data/lib/nukadoko/cli.rb +8 -0
- data/lib/nukadoko/parameter_types.rb +54 -0
- data/lib/nukadoko/pattern.rb +52 -2
- data/lib/nukadoko/run.rb +16 -1
- data/lib/nukadoko/scaffold.rb +2 -2
- data/lib/nukadoko/trace_actions.rb +4 -2
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko.rb +2 -0
- data/llms.txt +8 -7
- data/sig/generated/nukadoko/check.rbs +10 -0
- data/sig/generated/nukadoko/claim_sides.rbs +13 -4
- data/sig/generated/nukadoko/parameter_types.rbs +27 -0
- data/sig/generated/nukadoko/pattern.rbs +25 -1
- data/sig/generated/nukadoko/run.rbs +7 -0
- data/sig/generated/nukadoko/trace_actions.rbs +3 -1
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: accd5db605b1ffc47adb646fdb20dee28405fa07bb75287852c76166f2694124
|
|
4
|
+
data.tar.gz: 5622bc6c03bc02029347541dd72dd48b80103b06a0bcd813a97f67957041be82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5466755c998989a39dfb454e070f2573059182afe20b56f4cb937fd015602c43d73025bce65385b7af08789b9775c512565035e6fd311d70a8689dbd9b8277a5
|
|
7
|
+
data.tar.gz: 63c90e50cc0341cd64db9af9df3ab953dc940dbfa0acade8b2892fe539cb08b1a9ea20409b2110e72d95c95bb4a0990bdbbb8fa9fc7e4d695e41d65098f92d71
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,33 @@ notes come from the section below whose heading starts with `## [<version>]`.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.0] - 2026-11-16
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- The gem accepts `playwright-ruby-client` 1.63.0 and later, in place of
|
|
14
|
+
exactly 1.61.0.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- A step record on a Playwright 1.63 driver had no `actions`: the driver
|
|
19
|
+
writes trace format version 9, which the engine now reads.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `Nukadoko.config(parameterTypes: [...])` registers custom parameter types, as
|
|
24
|
+
the TypeScript engine's `parameterTypes` does: each a `name`, a `regexp`
|
|
25
|
+
(a Ruby Regexp or a string), and an optional `transformer` lambda. A step
|
|
26
|
+
can read a value inside a sentence with no spaces around it, such as
|
|
27
|
+
`優先度{priority:priority}のタスクを足す`, without quotes in the feature
|
|
28
|
+
file. A shape the TypeScript schema refuses is `config-invalid` with its
|
|
29
|
+
words. `nuka check` reports `parameter-type-invalid` for a type that takes
|
|
30
|
+
a built-in name or repeats one, `parameter-type-unused` for one no
|
|
31
|
+
pattern names, and `claim-expected-transformed` for a claim that compares
|
|
32
|
+
with a capture a transformer rewrote, which a run under `--no-check`
|
|
33
|
+
leaves unjudged. A run under `--no-check` stops with
|
|
34
|
+
`parameter-type-collision` when the types do not register.
|
|
35
|
+
|
|
9
36
|
## [0.3.0] - 2026-11-16
|
|
10
37
|
|
|
11
38
|
### Changed
|
data/README.ja.md
CHANGED
|
@@ -99,6 +99,7 @@ gem が入れる実行ファイルには、`bundle binstubs <gem>` が `bin/<nam
|
|
|
99
99
|
- ブラウザの起動設定は `nukadoko.config.rb` に `Nukadoko.config(browser: { executablePath: "..." })` と書きます。`page` を使うステップは、シナリオごとに自分のブラウザコンテキストを持ちます。ステップの記録には、ページが送ったリクエストとステップのトレースが残ります。
|
|
100
100
|
- `scratch` を使うステップは `scratch.dir` で新しいディレクトリを得ます。シナリオが終わると消えます。`scratch.copy(source)` は、プロジェクトのファイルかディレクトリの写しを入れた新しいディレクトリを返します。`args:` キーワードを書かない本体は、args なしで呼ばれます。`Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` はプログラムを実行し、`{ exitCode:, signal:, stdout:, stderr: }` を返します。ステップの記録には実行したプロセスが残り、`redact:` に渡した値は `{{secret.NAME}}` になります。
|
|
101
101
|
- `Nukadoko.config(envFiles: [".env"])` は env ファイルを `env` フィクスチャに読み込みます。config の `program:` の環境は、その後ろに自分の `envFiles:` を足せます。git が追跡していないファイルと HEAD と違うファイルは秘密の出どころです。その 4 文字以上の値は、ステップの記録、`http.jsonl`、`nuka do` の出力で `{{secret.NAME}}` に置き換わります。ステップが表示したものは、秘密を伏せて stderr に出ます。`secrets: { public: [...], redact: [...] }` で、そのようなキーを平文のままにしたり、追跡しているファイルのキーを伏せたりできます。`nuka check` は、無いファイル、読み飛ばした行、どのファイルにもない `secrets` のキーを警告し、値は表示しません。
|
|
102
|
+
- `Nukadoko.config(parameterTypes: [{ name: "priority", regexp: /高|低/, transformer: ->(s) { s == "高" ? "high" : "low" } }])` は、TypeScript の config の `parameterTypes` と同じようにパラメータ型を登録します。前後に空白のない文の中の値も、`{p:priority}` で読めます。regexp は Ruby の Regexp か文字列です。transformer は省いてもよく、regexp が捕まえたグループを受け取ります。`nuka check` は、組み込みの名前を使う型、どのパターンも使わない型、transformer が書き換えた値と比べる主張を報告します。
|
|
102
103
|
- プロジェクトのフィクスチャは `nukadoko.config.rb` に書きます。ブロックは値を `use` に渡し、その後ろが後片付けです。例: `Nukadoko.fixture(:store) { |use| use.(Store.new) }`。`scope: :process` にすると、環境ごとの実行全体で 1 つの値を使います。
|
|
103
104
|
- `parts [CreateTodo, CompleteById]` で、ステップが呼べるステップを宣言します。`call.(CreateTodo, title: args.title)` で 1 つを実行し、args と返り値を確かめます。パターンのない part も書けます。呼び出しは、呼んだステップの記録の `calls` に残ります。`nuka check` は、`parts` の循環と、`mutates false` なのに `mutates true` の part を持つステップを報告します。
|
|
104
105
|
- `poll timeout_ms: 3000` は、すべての claim が 2 回続けて成り立つか時間切れになるまで、100 ミリ秒おきに `observe` を読み直します。`settled:` には、一度なったら変わらない状態を書きます。2 回続けてその状態なら、壊れた claim を待つのをやめます。読んだ結果はすべてステップの記録に残ります。
|
data/README.md
CHANGED
|
@@ -54,6 +54,7 @@ end
|
|
|
54
54
|
- Browser launch options go in `nukadoko.config.rb`, as `Nukadoko.config(browser: { executablePath: "..." })`. A step that names `page` gets a browser context of its own for each scenario; each step record holds the requests the page sent and a trace of the step.
|
|
55
55
|
- A step that names `scratch` gets `scratch.dir`, a fresh directory that is removed when the scenario ends, and `scratch.copy(source)`, one that holds a copy of a file or directory of the project. A body that names no `args:` keyword is called without them. `Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` runs a program and returns `{ exitCode:, signal:, stdout:, stderr: }`; the step record lists each run, with each `redact:` value the step holds written as `{{secret.NAME}}`.
|
|
56
56
|
- `Nukadoko.config(envFiles: [".env"])` loads env files into the `env` fixture, and an environment of the config's `program:` adds its own `envFiles:` after them. A file git does not track, or one that differs from HEAD, is a secret source: each of its values four characters or longer is written as `{{secret.NAME}}` in every step record, `http.jsonl`, and what `nuka do` prints, and what a step prints reaches stderr with them redacted. `secrets: { public: [...], redact: [...] }` keeps one such key plain, or redacts one key of a tracked file. `nuka check` warns about a missing file, a line it skipped, and a `secrets` key no file defines, and never prints a value.
|
|
57
|
+
- `Nukadoko.config(parameterTypes: [{ name: "priority", regexp: /高|低/, transformer: ->(s) { s == "高" ? "high" : "low" } }])` registers a parameter type, as `parameterTypes` does in the TypeScript config, so `{p:priority}` reads a value inside a sentence with no spaces around it. The regexp is a Ruby Regexp or a string, and the transformer, which may be left out, is given the groups the regexp captured. `nuka check` reports a type that takes a built-in name, one no pattern names, and a claim that compares with a capture a transformer rewrote.
|
|
57
58
|
- A project fixture goes in `nukadoko.config.rb`. The block calls `use` with the value, and what follows is the teardown: `Nukadoko.fixture(:store) { |use| use.(Store.new) }`. `scope: :process` keeps one value for the whole run of an environment.
|
|
58
59
|
- `parts [CreateTodo, CompleteById]` declares the steps a step may run, and `call.(CreateTodo, title: args.title)` runs one, with its args and returns checked. A part needs no pattern. Each call is kept under `calls` in the calling step's record. `nuka check` reports a cycle in `parts` and a `mutates false` step whose part declares `mutates true`.
|
|
59
60
|
- `poll timeout_ms: 3000` reads `observe` again, 100 ms apart, until every claim holds on two readings in a row or the time runs out. `settled:` names a state that cannot change once reached, so two settled readings in a row stop the wait for a claim that broke. Every reading is kept in the step record.
|
data/lib/nukadoko/check.rb
CHANGED
|
@@ -62,6 +62,11 @@ module Nukadoko
|
|
|
62
62
|
%(no .rb step file was found while scanning "features"; no step can ever be registered), Codes.fix("no-step-files-found"), nil)
|
|
63
63
|
end
|
|
64
64
|
@findings.concat(config)
|
|
65
|
+
# The config's parameterTypes did not register, so no pattern binds a
|
|
66
|
+
# line; that is said once, not once per pattern.
|
|
67
|
+
if (collision = Pattern.collision)
|
|
68
|
+
@findings << Finding.new("error", "parameter-type-invalid", nil, nil, nil, collision, Codes.fix("parameter-type-invalid"), nil)
|
|
69
|
+
end
|
|
65
70
|
@usable = steps.reject { definition_broken?(_1) }
|
|
66
71
|
@usable.each { check_contract(_1) }
|
|
67
72
|
check_duplicate_patterns
|
|
@@ -79,6 +84,7 @@ module Nukadoko
|
|
|
79
84
|
if full
|
|
80
85
|
check_unbound
|
|
81
86
|
check_from_unused
|
|
87
|
+
check_unused_parameter_types
|
|
82
88
|
end
|
|
83
89
|
# Errors, then warnings, then notes, each kind in the order found, as
|
|
84
90
|
# the TypeScript engine reports them.
|
|
@@ -137,7 +143,7 @@ module Nukadoko
|
|
|
137
143
|
Pattern.new(pattern)
|
|
138
144
|
nil
|
|
139
145
|
rescue Cucumber::CucumberExpressions::UndefinedParameterTypeError => e
|
|
140
|
-
types = Pattern
|
|
146
|
+
types = Pattern.registry.parameter_types.map(&:name).reject(&:empty?).sort
|
|
141
147
|
["unknown-parameter-type", "#{head}: #{e.message} This project's registered parameter types are: #{types.join(", ")}."]
|
|
142
148
|
rescue StandardError => e
|
|
143
149
|
["pattern-syntax-error", "#{head}: #{e.message}"]
|
|
@@ -224,6 +230,54 @@ module Nukadoko
|
|
|
224
230
|
end
|
|
225
231
|
end
|
|
226
232
|
|
|
233
|
+
# A config parameter type no pattern names.
|
|
234
|
+
#: () -> void
|
|
235
|
+
def check_unused_parameter_types
|
|
236
|
+
used = @steps.flat_map { (pattern = _1.pattern) ? pattern.scan(/\{(?:[^}:]*:)?([^}]*)\}/).flatten : [] }
|
|
237
|
+
(Nukadoko.config_options[:parameterTypes] || []).each do |type|
|
|
238
|
+
name = type[:name].to_s
|
|
239
|
+
next if used.include?(name)
|
|
240
|
+
|
|
241
|
+
findings << Finding.new("note", "parameter-type-unused", CONFIG, nil, nil,
|
|
242
|
+
%(Configured parameter type "#{name}" is not referenced by any typed or compat pattern.), Codes.fix("parameter-type-unused"), nil)
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# A claim whose expected value is an args key a type with a
|
|
247
|
+
# transformer fills compares with what code made of the line, while
|
|
248
|
+
# the record would name the sentence as its source.
|
|
249
|
+
#: (singleton(Step)) -> void
|
|
250
|
+
def check_transformed(step)
|
|
251
|
+
transformed = Pattern.transformed
|
|
252
|
+
claims = step.claims
|
|
253
|
+
pattern = step.pattern
|
|
254
|
+
return if transformed.empty? || claims.nil? || pattern.nil?
|
|
255
|
+
|
|
256
|
+
keys = {} #: Hash[String, String]
|
|
257
|
+
claims.each_with_index do |claim, index|
|
|
258
|
+
label = "claims[#{index}]"
|
|
259
|
+
each = claim[:each]
|
|
260
|
+
unless each
|
|
261
|
+
keys[claim[:expected].to_s] ||= label if claim[:expected].is_a?(String)
|
|
262
|
+
next
|
|
263
|
+
end
|
|
264
|
+
items = (Array(each[:where]).each_with_index.map { |item, i| ["#{label}.each.where[#{i}]", item] } +
|
|
265
|
+
Array(each[:claims]).each_with_index.map { |item, i| ["#{label}.each.claims[#{i}]", item] }) #: Array[[String, Hash[Symbol, untyped]]]
|
|
266
|
+
items.each { |item_label, item| keys[item[:expected].to_s] ||= item_label if item[:expected].is_a?(String) }
|
|
267
|
+
end
|
|
268
|
+
pattern.scan(Pattern::NAMED).each do |match|
|
|
269
|
+
key, type = Array(match).map(&:to_s)
|
|
270
|
+
label = keys[key.to_s]
|
|
271
|
+
next unless label && transformed.include?(type.to_s)
|
|
272
|
+
|
|
273
|
+
findings << Finding.about_step("error", "claim-expected-transformed", step,
|
|
274
|
+
%(Step "#{step.step_name}"'s #{label}.expected is args.#{key}, and its pattern "#{pattern}" fills it with the parameter type {#{type}}, ) +
|
|
275
|
+
"whose transformer rewrites the line's text before the claim reads it, so code would decide what the claim compares. " \
|
|
276
|
+
"Capture #{key} with a type that has no transformer, such as {#{key}:string}, and read it with expected_view if it needs one",
|
|
277
|
+
Codes.fix("claim-expected-transformed"))
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
227
281
|
# A from key every line fills with a capture never takes its value
|
|
228
282
|
# from the producer it names.
|
|
229
283
|
#: () -> void
|
|
@@ -551,6 +605,7 @@ module Nukadoko
|
|
|
551
605
|
#: () -> void
|
|
552
606
|
def check_lines
|
|
553
607
|
undefined = []
|
|
608
|
+
bound = [] #: Array[singleton(Step)]
|
|
554
609
|
@scenarios.each do |scenario|
|
|
555
610
|
scenario.steps.each do |line|
|
|
556
611
|
matches = Engine.matches(@usable, line.text)
|
|
@@ -558,6 +613,7 @@ module Nukadoko
|
|
|
558
613
|
when 0 then undefined << [scenario, line]
|
|
559
614
|
when 1
|
|
560
615
|
step, captures = matches.first
|
|
616
|
+
bound << step
|
|
561
617
|
check_fill(scenario, line, step, captures)
|
|
562
618
|
check_position(scenario, line, step)
|
|
563
619
|
check_kinds(scenario, line, step, captures)
|
|
@@ -569,6 +625,7 @@ module Nukadoko
|
|
|
569
625
|
end
|
|
570
626
|
end
|
|
571
627
|
end
|
|
628
|
+
bound.uniq.each { check_transformed(_1) }
|
|
572
629
|
@scenarios.each { check_from_order(_1) }
|
|
573
630
|
@scenarios.each { check_claim_sources(_1) }
|
|
574
631
|
suppress_undefined(undefined)
|
data/lib/nukadoko/claim_sides.rb
CHANGED
|
@@ -41,8 +41,18 @@ module Nukadoko
|
|
|
41
41
|
:from_keys, #: Array[String]
|
|
42
42
|
:labels, #: ^(String) -> String
|
|
43
43
|
:received, #: Array[String]
|
|
44
|
+
# Why a claim cannot compare with an args key, for each key the
|
|
45
|
+
# matched pattern fills with a parameter type that has a transformer.
|
|
46
|
+
:transformed, #: Hash[String, String]
|
|
44
47
|
)
|
|
45
48
|
|
|
49
|
+
# A Data block's methods are its own, but rbs-inline reads only a class
|
|
50
|
+
# body, so they are written in one.
|
|
51
|
+
class Inputs
|
|
52
|
+
#: (?transformed: Hash[String, String], **untyped) -> void
|
|
53
|
+
def initialize(transformed: {}, **rest) = super
|
|
54
|
+
end
|
|
55
|
+
|
|
46
56
|
#: (Place, String?) -> Place
|
|
47
57
|
def self.place_at(place, path)
|
|
48
58
|
return place if path.nil? || path.empty?
|
|
@@ -300,6 +310,8 @@ module Nukadoko
|
|
|
300
310
|
def self.expected_side(claim, inputs)
|
|
301
311
|
name = ->(place) { "the expected value #{place.label}" }
|
|
302
312
|
case claim[:expected]
|
|
313
|
+
in String => key if (reason = inputs.transformed[key])
|
|
314
|
+
[Side.new(place: arg_place(key, inputs), found: { unjudged: reason }), false]
|
|
303
315
|
in String => key then [shaped(arg_side([key], inputs, name), claim[:expected_view], nil), false]
|
|
304
316
|
in { from: String => key } then [arg_side(segments(key), inputs, name), false]
|
|
305
317
|
in { observe: String => path } then [side_of(read_at(inputs.observed, segments(path)), OBSERVE, segments(path), 0, name), true]
|
data/lib/nukadoko/cli.rb
CHANGED
|
@@ -270,6 +270,14 @@ module Nukadoko
|
|
|
270
270
|
stop = { severity: "refused", code: failed.code, message: "#{failed.file}: #{failed.message}", fix: failed.fix, do: "nuka check" }
|
|
271
271
|
return finish("run", false, findings: [stop], verdict: "refused", exit_code: 2)
|
|
272
272
|
end
|
|
273
|
+
# The TypeScript engine builds its bindings before any scenario starts,
|
|
274
|
+
# so parameter types that do not register stop a run under --no-check
|
|
275
|
+
# too.
|
|
276
|
+
if @no_check && (collision = Engine::Pattern.collision)
|
|
277
|
+
stop = { severity: "refused", code: "parameter-type-collision", message: collision,
|
|
278
|
+
fix: "Rename the parameter type, or remove one of the two registrations.", do: "nuka run --help" }
|
|
279
|
+
return finish("run", false, findings: [stop], verdict: "refused", exit_code: 2)
|
|
280
|
+
end
|
|
273
281
|
# Only the check's errors hold a run back, so only they are reported.
|
|
274
282
|
findings = @no_check ? [] : check.findings.map { relative(_1).to_h }.select { _1[:severity] == "error" }
|
|
275
283
|
unless @no_check || check.passed?
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
# The config's parameterTypes, read and handed to Pattern: each entry a
|
|
5
|
+
# name, a regexp, and an optional transformer. A shape the TypeScript
|
|
6
|
+
# engine's schema refuses is refused here with its words, so a project
|
|
7
|
+
# moves between the engines without a config that one of them takes and
|
|
8
|
+
# the other does not. Boundary: reading the entries; registering them and
|
|
9
|
+
# matching lines are Pattern's.
|
|
10
|
+
module Nukadoko
|
|
11
|
+
module Engine
|
|
12
|
+
module ParameterTypes
|
|
13
|
+
NAME = /\A[a-zA-Z0-9_-]+\z/
|
|
14
|
+
KEYS = %i[name regexp transformer].freeze
|
|
15
|
+
|
|
16
|
+
#: (untyped) -> void
|
|
17
|
+
def self.read(types)
|
|
18
|
+
types = [] if types.nil?
|
|
19
|
+
invalid("parameterTypes: Invalid input: expected array, received #{kind(types)}") unless types.is_a?(Array)
|
|
20
|
+
types.each_with_index do |type, index|
|
|
21
|
+
at = "parameterTypes.#{index}"
|
|
22
|
+
invalid("#{at}: Invalid input: expected object, received #{kind(type)}") unless type.is_a?(Hash)
|
|
23
|
+
extra = type.keys.map(&:to_sym) - KEYS
|
|
24
|
+
invalid("unknown key(s): #{extra.join(", ")}") if extra.any?
|
|
25
|
+
name = type[:name]
|
|
26
|
+
invalid("#{at}.name: Invalid input: expected string, received #{kind(name)}") unless name.is_a?(String)
|
|
27
|
+
invalid("#{at}.name: Invalid string: must match pattern /^[a-zA-Z0-9_-]+$/") unless name.match?(NAME)
|
|
28
|
+
invalid("#{at}.regexp: must be a Regexp or a string") unless type[:regexp].is_a?(Regexp) || type[:regexp].is_a?(String)
|
|
29
|
+
invalid("#{at}.transformer: must be a function") unless type[:transformer].nil? || type[:transformer].respond_to?(:call)
|
|
30
|
+
end
|
|
31
|
+
Pattern.configure(types)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# A value's kind in the words zod uses for it.
|
|
35
|
+
#: (untyped) -> String
|
|
36
|
+
def self.kind(value)
|
|
37
|
+
case value
|
|
38
|
+
when nil then "undefined"
|
|
39
|
+
when String then "string"
|
|
40
|
+
when Numeric then "number"
|
|
41
|
+
when true, false then "boolean"
|
|
42
|
+
when Array then "array"
|
|
43
|
+
when Hash then "object"
|
|
44
|
+
else value.class.name.to_s.downcase
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#: (String) -> bot
|
|
49
|
+
def self.invalid(detail)
|
|
50
|
+
raise Refusal.new("config-invalid", "Invalid config at #{CONFIG}: #{detail}", fix: "Correct the fields the message names in #{CONFIG}.")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/nukadoko/pattern.rb
CHANGED
|
@@ -71,7 +71,53 @@ module Nukadoko
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
NAMED = /\{([A-Za-z_][\w-]*):([\w-]+)\}/
|
|
74
|
-
|
|
74
|
+
BUILT_IN = Registry.new.parameter_types.map(&:name).freeze #: Array[String]
|
|
75
|
+
|
|
76
|
+
# The registry every pattern of the loaded project reads: the built-in
|
|
77
|
+
# types, and the config's parameterTypes on top of them.
|
|
78
|
+
#: () -> Registry
|
|
79
|
+
def self.registry = @registry ||= Registry.new
|
|
80
|
+
|
|
81
|
+
# Why the config's parameterTypes could not be registered, in the
|
|
82
|
+
# TypeScript engine's words, or nil. While it is set no pattern
|
|
83
|
+
# matches a line, as no pattern binds there: nuka check reports it
|
|
84
|
+
# once, as parameter-type-invalid, and a run under --no-check stops.
|
|
85
|
+
#: () -> String?
|
|
86
|
+
def self.collision = @collision
|
|
87
|
+
|
|
88
|
+
# The names of the config's parameter types that have a transformer,
|
|
89
|
+
# whose capture a claim cannot compare with.
|
|
90
|
+
#: () -> Array[String]
|
|
91
|
+
def self.transformed = @transformed || []
|
|
92
|
+
|
|
93
|
+
# Registers the config's parameterTypes: each a name, a regexp, and an
|
|
94
|
+
# optional transformer, given the groups the regexp captured. A type
|
|
95
|
+
# with no transformer gives the text the regexp matched, or its first
|
|
96
|
+
# group, as the JavaScript package does.
|
|
97
|
+
#: (Array[Hash[Symbol, untyped]]) -> void
|
|
98
|
+
def self.configure(types)
|
|
99
|
+
@registry = Registry.new
|
|
100
|
+
@collision = nil
|
|
101
|
+
@transformed = types.select { _1[:transformer] }.map { _1[:name].to_s }
|
|
102
|
+
seen = [] #: Array[String]
|
|
103
|
+
types.each do |type|
|
|
104
|
+
name = type[:name].to_s
|
|
105
|
+
if BUILT_IN.include?(name)
|
|
106
|
+
@collision = %(Custom parameter type "#{name}" collides with one of cucumber-expressions' own built-in parameter types; ) +
|
|
107
|
+
"redefining what {#{name}} means would quietly change the meaning of every pattern that already uses it"
|
|
108
|
+
elsif seen.include?(name)
|
|
109
|
+
@collision = %(Custom parameter type "#{name}" is registered more than once in parameterTypes)
|
|
110
|
+
end
|
|
111
|
+
if @collision
|
|
112
|
+
@registry = Registry.new
|
|
113
|
+
return
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
seen << name
|
|
117
|
+
transformer = type[:transformer] || ->(*groups) { groups.first }
|
|
118
|
+
@registry.define_parameter_type(CE::ParameterType.new(name, type[:regexp], Object, transformer, true, false))
|
|
119
|
+
end
|
|
120
|
+
end
|
|
75
121
|
|
|
76
122
|
attr_reader :source, :keys
|
|
77
123
|
|
|
@@ -79,11 +125,13 @@ module Nukadoko
|
|
|
79
125
|
def initialize(source)
|
|
80
126
|
@source = source
|
|
81
127
|
@keys = source.scan(NAMED).map { Array(_1).first.to_s }
|
|
82
|
-
@expression = CE::CucumberExpression.new(source.gsub(NAMED, '{\2}'),
|
|
128
|
+
@expression = CE::CucumberExpression.new(source.gsub(NAMED, '{\2}'), Pattern.registry)
|
|
83
129
|
end
|
|
84
130
|
|
|
85
131
|
#: (String) -> Hash[String, untyped]?
|
|
86
132
|
def match(text)
|
|
133
|
+
return nil if Pattern.collision
|
|
134
|
+
|
|
87
135
|
found = @expression.match(text)
|
|
88
136
|
found && keys.zip(found.map { _1.value(nil) }).to_h
|
|
89
137
|
end
|
|
@@ -91,6 +139,8 @@ module Nukadoko
|
|
|
91
139
|
# Each capture's text as the line wrote it, quotes included.
|
|
92
140
|
#: (String) -> Hash[String, String]?
|
|
93
141
|
def texts(text)
|
|
142
|
+
return nil if Pattern.collision
|
|
143
|
+
|
|
94
144
|
found = @expression.match(text)
|
|
95
145
|
found && keys.zip(found.map { _1.group.value }).to_h
|
|
96
146
|
end
|
data/lib/nukadoko/run.rb
CHANGED
|
@@ -768,6 +768,21 @@ module Nukadoko
|
|
|
768
768
|
record
|
|
769
769
|
end
|
|
770
770
|
|
|
771
|
+
# The args keys the line fills through a parameter type with a
|
|
772
|
+
# transformer, each with why a claim does not compare with it: code
|
|
773
|
+
# made the value, while the record would name the sentence. nuka check
|
|
774
|
+
# reports such a pattern; a run under --no-check agrees with it.
|
|
775
|
+
#: (untyped, Hash[String, String]) -> Hash[String, String]
|
|
776
|
+
def transformed_fills(step, origins)
|
|
777
|
+
pattern = step.pattern.to_s
|
|
778
|
+
pattern.scan(Pattern::NAMED).each_with_object({}) do |(key, type), found|
|
|
779
|
+
next unless Pattern.transformed.include?(type.to_s) && !origins.key?(key.to_s)
|
|
780
|
+
|
|
781
|
+
found[key.to_s] = %(the pattern "#{pattern}" fills args.#{key} with the parameter type {#{type}}, whose transformer rewrites the line's text before the claim reads it, ) +
|
|
782
|
+
"so code would decide what the claim compares, and the claim was not judged"
|
|
783
|
+
end
|
|
784
|
+
end
|
|
785
|
+
|
|
771
786
|
# A Then step's claims are judged on what it observed, or on its args
|
|
772
787
|
# when it reads nothing itself; any other step runs and returns.
|
|
773
788
|
# `step` is a step class whose observe or run its own file defines.
|
|
@@ -791,7 +806,7 @@ module Nukadoko
|
|
|
791
806
|
sides = lambda do |observed|
|
|
792
807
|
ClaimSides::Inputs.new(observed: observed, args: args, observes: observes, from_keys: step.from.keys.map(&:to_s),
|
|
793
808
|
labels: ->(key) { origins.fetch(key, "sentence:#{key}") },
|
|
794
|
-
received: observes ? step.inputs.fields.map { _1.name.to_s } : [])
|
|
809
|
+
received: observes ? step.inputs.fields.map { _1.name.to_s } : [], transformed: transformed_fills(step, origins))
|
|
795
810
|
end
|
|
796
811
|
# A reading with a page open is timed, so the record can say what the page had received by then.
|
|
797
812
|
read = (plain = read; -> { @browser.reading(&plain) }) if own[:page]
|
data/lib/nukadoko/scaffold.rb
CHANGED
|
@@ -73,7 +73,7 @@ module Nukadoko
|
|
|
73
73
|
repeated = captures.map(&:key).tally.select { _2 > 1 }.keys
|
|
74
74
|
return refusal("Refusing to scaffold: the pattern captures #{repeated.map { %("#{_1}") }.join(", ")} more than once, and one args field holds one value") if repeated.any?
|
|
75
75
|
|
|
76
|
-
types = Pattern
|
|
76
|
+
types = Pattern.registry.parameter_types.map(&:name).reject(&:empty?).sort
|
|
77
77
|
unknown = captures.map(&:type).uniq.find { !types.include?(_1) }
|
|
78
78
|
if unknown
|
|
79
79
|
return refusal(%(Refusing to scaffold: the pattern names type "#{unknown}", and this project registers none by that name; registered types: #{types.join(", ")}))
|
|
@@ -918,7 +918,7 @@ module Nukadoko
|
|
|
918
918
|
# itself, with the readings it could not choose between.
|
|
919
919
|
#: (String) -> Hash[Symbol, untyped]
|
|
920
920
|
def self.infer(text)
|
|
921
|
-
generated = generate(text, Pattern
|
|
921
|
+
generated = generate(text, Pattern.registry)
|
|
922
922
|
first = generated.first
|
|
923
923
|
same = generated.all? do |expression|
|
|
924
924
|
expression.parameter_types.size == first.parameter_types.size &&
|
|
@@ -16,10 +16,12 @@ require "zlib"
|
|
|
16
16
|
module Nukadoko
|
|
17
17
|
module Engine
|
|
18
18
|
module TraceActions
|
|
19
|
-
# Version 8 as the TypeScript engine measured it,
|
|
19
|
+
# Version 8 as the TypeScript engine measured it, version 9 as
|
|
20
|
+
# Playwright 1.63.0 writes it (the same fields and the same actions as
|
|
21
|
+
# version 8), and version 10 as
|
|
20
22
|
# Playwright 1.65.1 writes it for the Ruby client: the same `before`
|
|
21
23
|
# and `after` fields, with a number for `callId`.
|
|
22
|
-
KNOWN_VERSIONS = [8, 10].freeze
|
|
24
|
+
KNOWN_VERSIONS = [8, 9, 10].freeze
|
|
23
25
|
MAX_ACTIONS = 100
|
|
24
26
|
INTERNAL_WAIT = "__waitInfo__"
|
|
25
27
|
JUDGED_VIEW_GROUP = "nukadoko: view of the judged reading"
|
data/lib/nukadoko/version.rb
CHANGED
data/lib/nukadoko.rb
CHANGED
|
@@ -42,6 +42,7 @@ require_relative "nukadoko/definition"
|
|
|
42
42
|
require_relative "nukadoko/vocabulary"
|
|
43
43
|
require_relative "nukadoko/program"
|
|
44
44
|
require_relative "nukadoko/project_program"
|
|
45
|
+
require_relative "nukadoko/parameter_types"
|
|
45
46
|
require_relative "nukadoko/table"
|
|
46
47
|
require_relative "nukadoko/order"
|
|
47
48
|
require_relative "nukadoko/run_record"
|
|
@@ -76,6 +77,7 @@ module Nukadoko
|
|
|
76
77
|
config = File.join(root, Engine::CONFIG)
|
|
77
78
|
@legacy_program = nil
|
|
78
79
|
load config if File.exist?(config)
|
|
80
|
+
Engine::ParameterTypes.read(config_options[:parameterTypes])
|
|
79
81
|
@program_options = Engine::ProjectProgram.read(root)
|
|
80
82
|
end
|
|
81
83
|
|
data/llms.txt
CHANGED
|
@@ -11,16 +11,16 @@ A step either runs (`run`) or claims (`claims`). Only a Then claims, and a Then
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
- `npm install -D nukadoko` installs the `nuka` CLI. It installs no browser. Playwright is an optional peer, needed only by a step whose fixtures build `page`, `context`, `pageAs`, or `request`; `nuka check` reports `playwright-missing` for such a step when Playwright does not resolve. README.md "Install" names the Node and Playwright versions.
|
|
14
|
-
- `npx nuka init` writes `nukadoko.config.ts` (`nukadoko.config.mts` in a project whose `package.json` has no `"type": "module"`, and step files are then `.mts` too, which it says on stderr), creates `features/steps/`, adds a `test:scenarios` script, adds `.nukadoko/`, `.env`, `.env.*`, and `!.env.example` to `.gitignore`, and, when `tsconfig.json` exists, adds the steps and the config to its `include` and `rewriteRelativeImportExtensions` to its `compilerOptions`. stdout lists each path it wrote; a failed self-check exits 1. `nuka init --allure` writes `allurerc.mjs` and creates `.nukadoko/export/allure-results/` for `nuka report --format allure`. Set another `featuresDir` in the config afterwards when the features live elsewhere. `nuka init` writes no program
|
|
14
|
+
- `npx nuka init` writes `nukadoko.config.ts` (`nukadoko.config.mts` in a project whose `package.json` has no `"type": "module"`, and step files are then `.mts` too, which it says on stderr), creates `features/steps/`, adds a `test:scenarios` script, adds `.nukadoko/`, `.env`, `.env.*`, and `!.env.example` to `.gitignore`, and, when `tsconfig.json` exists, adds the steps and the config to its `include` and `rewriteRelativeImportExtensions` to its `compilerOptions`. stdout lists each path it wrote; a failed self-check exits 1. `nuka init --allure` writes `allurerc.mjs` and creates `.nukadoko/export/allure-results/` for `nuka report --format allure`. Set another `featuresDir` in the config afterwards when the features live elsewhere. `nuka init` writes no program; `--server` and `--server-url` are removed and name the config's `program`.
|
|
15
15
|
- Run `nuka` from the directory that holds the config. Elsewhere every command says on stderr that no config was found, names one in a parent directory if there is one, and runs on the defaults; `nuka scaffold` refuses there.
|
|
16
|
-
- `nukadoko.program.ts`, beside the config, describes the program under test: `export default defineProgram({ build, prepare, serve: { command, port, ready, timeout_ms }, url, env, setup, lists, environments })`, with `defineProgram` imported from `nukadoko`. `build` commands run once per run in the tree's root; `prepare` runs once per world with the world's env; `serve` starts the program on a free port (`port: "auto"`, the default) and waits until `ready` (default `/`) answers 2xx within `timeout_ms` (default 60000; every `timeout_ms` is a whole number of milliseconds from 1 to 2147483647, the longest delay a Node.js timer keeps); `url`, a string or a function of `{ name, root, dir, signal }`, names a program nukadoko does not start, and is exclusive with `serve`; `setup(world)` runs after `ready`, before the first scenario. `lists: { routes, flags, tables }` names one command per kind of place the program has, each printing one JSON object per line in the words the execution events use: `{ method, route, handler? }` (the method uppercase, the route's template, and what it runs in the program's own words) or `{ name, sides }`, or `{ table, holds? }`, what the table holds in the program's own declaration (`state`, the default, `bookkeeping`, such as telemetry or an audit trail, or `infrastructure`, such as applied migrations, a job queue, or a cache), plus keys of the program's own that start `x_`; an entry printed twice is one, and a table printed with two holdings is refused. In a world nukadoko serves with `{events}`, of the tree the run started in (the `tables` command of every tree, and of `nuka do`'s world when its step counts execution events), each runs once after `setup`, in the root with the world's env and placeholders, within 60000 ms (`{ command, timeout_ms }`), its stderr in `program.log`; a world at a `url` and one with no events file read none, the base and old worlds and `nuka do` read no `routes` or `flags`, and an environment's `lists` replaces the top level's whole. A list is read whole or not at all: a command that cannot start, exits non-zero, passes its limit, prints more than 16 MiB, or prints one line that is not one entry of its kind (a key that is neither the kind's nor `x_`, a lowercase method) leaves that list unread, fails no world and no row, and raises the `program-list-unread` warning naming the command and the line (a base or old world's names its tree, and `nuka do` raises it for its tables list). What the work of `setup` or a `url` function prints goes to stderr and `program.log`, redacted; one past its `timeout_ms` is abandoned, and the `signal` in its argument is aborted then and when a signal stops the start, so it stops only if it honours that signal. A command is an argv array or a string split on whitespace, never through a shell. `env` values and command words fill `{port}` (the port `serve` got, or the `url`'s, as written or the scheme's), `{url}`, `{dir}` (the world's directory, `.nukadoko/runs/<run_id>/worlds/<env>/`), `{root}`, `{world}`, `{token}` (random per world, redacted as `{{secret.WORLD_TOKEN}}`), `{events}` (in a world nukadoko serves, the absolute path of an empty file for the program's execution events, made with mode 0600 in a 0700 directory of its own outside the run directory and removed when the world stops), and `{condition.<name>}` (the value the world's environment declares under `conditions`, as text); a placeholder with no value in that world (`{port}` or `{url}` with neither `serve` nor `url`, `{events}` without `serve`, a `{condition.<name>}` its environment does not declare, anything but `{root}` in `build`) is refused by name, by `nuka check` for the worlds a `nuka run` with the same `--env` flags would start and by `nuka run` and `nuka do` for the worlds they start. The program's processes and the steps' process both get `env`, except that a variable whose value names `{events}` reaches only the program, so no step's code and no process a step starts can append to the events file. `nuka run` starts one world per environment before its BeforeAll hooks and stops it after the scenarios; the world's URL is the base URL of `page`, `context`, `pageAs`, `request`, and the `baseURL` fixture. `nuka do` starts one for its execution. `program.log` in the world's directory holds what every command printed, redacted. run.json's `worlds` lists each world (`name`, `tree`, `url`, `commands`, `timings`, `log`, `error`, `program_log: { stamped, lines, late, tagged }`, counted when the world stops, `null` for a world at a `url`, and `events: { file, lines, owned, late, unowned, unreadable, undefined_kinds }` when the program file names `{events}`, `null` for a world at a `url`, and `lists: { <kind>: { entries, error } }` for each list it read, `entries` counting its places once and `null` with the `error` that says why it was not read, absent when it read none; a `lists` command is a `commands` entry with `phase: "lists"`, timed in `lists_ms`), and each step record names its world in `world_name`. Every request a step sends to the world's origin (through `fetch`, `node:http`, `node:https`, a Playwright request context, or a Chromium page's documents, fetches, XHRs, and EventSources; for a `localhost` world, a name below `localhost` at its port too) carries a W3C `traceparent` with one trace id per step or hook (a Before, AfterStep, or After hook's requests carry the hook's own, recorded in the scenario's directory; a BeforeAll or AfterAll hook's, and the `fetch`, `node:http`, and `node:https` requests of a fixture's setup or teardown, go without one), all of a world's starting with the same eight hexadecimal characters, and a span id per request; a request that sets its own, or whose request context's `extraHTTPHeaders` set one, keeps it, and a `node:http` request is stamped as its headers are sent, so one the step sets after creating it is kept. A redirect to another origin takes no header: `fetch` is stamped on each hop to the world as undici sends it (the `undici:request:create` channel), with the step's arguments untouched; the exception is a Playwright request context, which sends a call's headers on with a redirect. An http.jsonl line names the `traceparent` the request went out with, nukadoko's or the step's own (a page's line, as the browser sent it), and then always `traceparent_sent_to`, the origins that received it (a request context's first hop and final response; an origin between them is not known); a step's `stamped` counts only the requests that went out with nukadoko's value. When nukadoko serves the program, a line of `program.log` belongs to the step whose trace id it carries (the first place in the line where the world's eight characters begin 32 hexadecimal ones), wherever and whenever it appears, and redaction never changes a trace id of the world or a `traceparent` value holding one; each step record gets its lines so far in `program-log.txt` beside it, redacted, and `observed.program_log: { trace_id, lines, file, stamped, truncated? }` (`file` is `null` when `lines` is 0); a step that stamped a request waits up to 300 ms for its lines, until none carrying its trace id has arrived for 30 ms after the step ended. A line that arrives later goes to the step's `program-log-late.txt` when the world stops, run.json's step gets `program_log_late: { lines, file, truncated? }`, the run summary names it on the step's line, and `nuka do` prints a `program-log-late` note; the record is not rewritten. The program must write the id into its lines: for Rails, `config.log_tags = [ ->(request) { request.headers["traceparent"] } ]` with the test log sent to stdout. The run summary says once per world, decided from the whole log, when no line carries a trace id of the world, how many lines arrived after their step ended (and only when none came in time, that output buffered on a pipe looks like that: `STDOUT.sync = true` in Ruby, `PYTHONUNBUFFERED=1` for Python), and when it was not read because the world runs at a `url`; there `observed.program_log` is `null`. A program that names `{events}` (`env: { EXECUTION_EVENTS: "{events}" }`) can append one JSON line per operation it ends to that file, in the format of docs/execution-events.md (`request`, `db`, `tx`, `job`, `http`, `flag`, `error`, and a writer's own `x_` kinds), each carrying the request's `traceparent` or, for a job, the one that enqueued it, at most 4095 bytes in one write call; a line belongs to the step whose trace id its parsed `trace` field holds, a line that does not read belongs to none and counts in `unreadable` for the step whose trace id its text carries, and each step record gets its lines, parsed, redacted (trace ids kept), and written again as JSON, in `events.jsonl` beside it, with `observed.events: { trace_id, lines, file, kinds, stamped, stamped_spans, unreadable, unowned, process_spans, process_requests, whole, open }`, with `mcp_spans` when the step sent an MCP call (`stamped_spans` are the span ids of the stamped requests, at most 1000; `process_requests` counts the request lines that carry a span a `runCommand` process got in its TRACEPARENT; `mcp_spans` are the spans of the step's MCP calls, below), read with the same wait as the program's log. `whole` is `true` when every request the step stamped has its `request` line (by span id), every job enqueued in the trace performed, every `runCommand` process it ran closed with no process of its group left, and every MCP call it sent went out in a stamped request; otherwise `open` names why, one gap word each in this order: `no-requests` (no stamped request, no `runCommand` process, and no MCP call), `processes-unbounded` (a `runCommand` process may still send: it still ran when the record was built, left a process of its group running, or ran on Windows; one that leaves its group, as a daemon does with `setsid`, is not seen), `mcp-unbounded` (`calls`: MCP calls that reached their server over stdio or another origin, whose end no line reports), `no-lines`, `request-unreported` (`requests`), `jobs-pending` (`job_ids`), `unreadable` (`lines`), `truncated`, `file-replaced`. A line that arrives later goes to the step's `events-late.jsonl`, run.json's step gets `events_late: { lines, file, truncated? }`, and `nuka do` prints an `events-late` note; the world's stop also gives each step of a world with an events file `path: { requests, entries, maybe, open }`, its trace counted by what each line did over every line, late ones included: `requests` each `request` line's `method`, `route`, `status` in the order the step sent them, `entries` with `count` by kind in this order, `error` (`class`, `handled`), `db` writes (`table`, `op`, and `holds` on a table the tables list marks as `bookkeeping` or `infrastructure`, whose writes stay in the path; reads are left out for now, as are `tx` lines, ids, and actors), `http` (`method`, `origin`, `path`, `status`), `job` (`name`, `phase`), `flag` (`name`, `side`, with `gates`), `maybe` the lines that may be any line, and `open` the gap words over every line; the world's redacted copy is `worlds/<env>/events.jsonl`, and the run summary gives the world one line when the file was not read, got no line, or holds lines no step record holds. A world at a `url` refuses `{events}`, and its steps' `observed.events` is `null`. A claim step's `events: { <key>: { of, count } }` counts lines of an earlier step's trace: `of` is that step or a list of candidates of which one ran earlier (the latest run of it counts; none leaves the claim `unjudged` with `producer-not-run`, two leave it `unjudged`), and `count` is `{ kind, ...fields }` with the format's kinds and fields, each field one value or a list, a value `{ sentence: "<capture>" }` taken from the line (the capture then counts as read), a `db` selection whose `op` may be a write stating `committed`, a `db` selection that names no `table` leaving out each line on a table the tables list says holds `bookkeeping` or `infrastructure` (one that names a table counts it whatever it holds), and a writer's own `x_` kind, an undefined kind or field, or a bad value refused at import. A claim names the key alone as its `actual` (no `view`, `at`, `count`, `each`, or path), compares with `equal`, `not-equal`, `greater-than`, `at-least`, `less-than`, or `at-most` against a number the line states (a `{n:int}` capture, digits, a number word, `once`, `twice`, or `never`, `no`, `none`, `nothing` as 0 under `equal`), and an events key shares no name with a `from` or args key and is read by a claim. When the claims are judged, the step reads the trace's lines from where that step's slice began and waits while its events may still become whole (`no-lines`, `request-unreported`, `jobs-pending`), up to its `timeout`, else 10 s, or a shorter `stepTimeout`, never until a claim holds. The count is a range, `[yes, yes + maybe]` when whole and unbounded above when not (`maybe`: lines that did not read, of an undefined kind or version, missing a field the selection reads, `holds_unknown`, a `db` line on a table the count may leave out because the tables list was not read or the writer named its table `unknown` while the list marks one, a write of unknown commit state, or owned by no step), and the claim holds or breaks only when every count in it agrees, else it is `unjudged` with the gap word in its reason (`kind-unreported` while the world has reported no line of the kind; `world-unread` at a `url`; `inlet-unnamed` without `{events}`). The record holds the count as `actual` when it is one number, else `actual_range`, then `counted`, `actual_from` `events:<step>@<line> count <selection>`, `measured` `{ step_record_id: <own>, channel: "events_read.<key>" }`, and the step's `events_read.<key>`, `{ of, trace_id, count, range, counted, whole, open, maybe, lines, unreadable, unowned, file, waited_ms }`, with the lines it counted in `events-read.jsonl`; run.json's step carries `events_read` too. `counted` groups the lines the count counted, most first, as `{ kind, fields, lines }` by the kind's fields (`request` method, route, status; `db` op, table; `tx` phase; `job` name, phase; `http` method, origin, status; `flag` name, side; `error` class, handled), every group listed, and the claim's line names the first three under every outcome (`...; counted 1 line: db insert into events`, `counted 3 lines: 2 db insert into scores, 1 db update rankings`, then `and 4 more lines in 2 groups`); `left_out`, present when the count left a line out, groups those lines the same way with each group's `holds`, on the claim and in `events_read`, and the line adds `; left out 1 line: db insert into events (bookkeeping)` after what it counted. When the world stops, each reading is counted again over every line of the trace, and a claim the whole count judges otherwise gets `after_world_stop: { lines, range, outcome, reason }` in run.json, the reason naming the lines the whole count counted that the claim's did not (`and the stop counted 1 more line: db insert into scores`), and its cell is `broke` (`a claim at line <n> was judged before every execution event it counts had arrived`). `nuka run` also raises the note `undeclared-write` for a head step that declares `mutates: false` whose trace holds a write the program committed to a table that holds state (late lines included; not a write that rolled back, one of unknown commit state, or any when the tables list was not read), once per step line of a scenario and environment, naming the step, the table, and the op: `the step at line 6, get, declares mutates: false, and its trace holds writes the program committed to tables that hold state, 1 line: db insert into scores`; it changes no status and no exit code, and never reads a request's method as a write. A world that does not start is `program-start-failed`, with the end of `program.log`; no scenario runs in it. `environments` entries override any of those fields (`env` merges by key) and add `policy: "read-only"`, `envFiles` (after the config's), a `version` probe, and `conditions`, the switches of the program that environment runs, each `true`, `false`, or a string with no whitespace and no `@` (`{ banner: true, locale: "ja" }`; the strings `"true"` and `"false"` are refused, since a string reads as on), which a scenario's `@with:` and `@without:` tags read (see `nuka run`); they set nothing, which `env` and the env files do, and nukadoko trusts them without checking the program, so derive the switch from them (`env: { BANNER: "{condition.banner}" }`). The top-level `defaultEnvironments: [<names>]` names the environments a run without `--env` starts, each an environment of the file or `default`. A tree with no program file starts no world, which suits a command-line tool. `baseURL` and `environments` in the config are refused, naming this file.
|
|
16
|
+
- `program` in `nukadoko.config.ts` describes the program under test: `program: () => ({ build, prepare, serve: { command, port, ready, timeout_ms }, url, env, setup, lists, environments })`, a function the config calls once; a change to it is not a change to the mapping `nuka run --base` compares, while its environments' `conditions` and `defaultEnvironments` are. A `nukadoko.program.ts` of an earlier release is refused with `program-file-moved`. `build` commands run once per run in the tree's root; `prepare` runs once per world with the world's env; `serve` starts the program on a free port (`port: "auto"`, the default) and waits until `ready` (default `/`) answers 2xx within `timeout_ms` (default 60000; every `timeout_ms` is a whole number of milliseconds from 1 to 2147483647, the longest delay a Node.js timer keeps); `url`, a string or a function of `{ name, root, dir, signal }`, names a program nukadoko does not start, and is exclusive with `serve`; `setup(world)` runs after `ready`, before the first scenario. `lists: { routes, flags, tables }` names one command per kind of place the program has, each printing one JSON object per line in the words the execution events use: `{ method, route, handler? }` (the method uppercase, the route's template, and what it runs in the program's own words) or `{ name, sides }`, or `{ table, holds? }`, what the table holds in the program's own declaration (`state`, the default, `bookkeeping`, such as telemetry or an audit trail, or `infrastructure`, such as applied migrations, a job queue, or a cache), plus keys of the program's own that start `x_`; an entry printed twice is one, and a table printed with two holdings is refused. In a world nukadoko serves with `{events}`, of the tree the run started in (the `tables` command of every tree, and of `nuka do`'s world when its step counts execution events), each runs once after `setup`, in the root with the world's env and placeholders, within 60000 ms (`{ command, timeout_ms }`), its stderr in `program.log`; a world at a `url` and one with no events file read none, the base and old worlds and `nuka do` read no `routes` or `flags`, and an environment's `lists` replaces the top level's whole. A list is read whole or not at all: a command that cannot start, exits non-zero, passes its limit, prints more than 16 MiB, or prints one line that is not one entry of its kind (a key that is neither the kind's nor `x_`, a lowercase method) leaves that list unread, fails no world and no row, and raises the `program-list-unread` warning naming the command and the line (a base or old world's names its tree, and `nuka do` raises it for its tables list). What the work of `setup` or a `url` function prints goes to stderr and `program.log`, redacted; one past its `timeout_ms` is abandoned, and the `signal` in its argument is aborted then and when a signal stops the start, so it stops only if it honours that signal. A command is an argv array or a string split on whitespace, never through a shell. `env` values and command words fill `{port}` (the port `serve` got, or the `url`'s, as written or the scheme's), `{url}`, `{dir}` (the world's directory, `.nukadoko/runs/<run_id>/worlds/<env>/`), `{root}`, `{world}`, `{token}` (random per world, redacted as `{{secret.WORLD_TOKEN}}`), `{events}` (in a world nukadoko serves, the absolute path of an empty file for the program's execution events, made with mode 0600 in a 0700 directory of its own outside the run directory and removed when the world stops), and `{condition.<name>}` (the value the world's environment declares under `conditions`, as text); a placeholder with no value in that world (`{port}` or `{url}` with neither `serve` nor `url`, `{events}` without `serve`, a `{condition.<name>}` its environment does not declare, anything but `{root}` in `build`) is refused by name, by `nuka check` for the worlds a `nuka run` with the same `--env` flags would start and by `nuka run` and `nuka do` for the worlds they start. The program's processes and the steps' process both get `env`, except that a variable whose value names `{events}` reaches only the program, so no step's code and no process a step starts can append to the events file. `nuka run` starts one world per environment before its BeforeAll hooks and stops it after the scenarios; the world's URL is the base URL of `page`, `context`, `pageAs`, `request`, and the `baseURL` fixture. `nuka do` starts one for its execution. `program.log` in the world's directory holds what every command printed, redacted. run.json's `worlds` lists each world (`name`, `tree`, `url`, `commands`, `timings`, `log`, `error`, `program_log: { stamped, lines, late, tagged }`, counted when the world stops, `null` for a world at a `url`, and `events: { file, lines, owned, late, unowned, unreadable, undefined_kinds }` when the program names `{events}`, `null` for a world at a `url`, and `lists: { <kind>: { entries, error } }` for each list it read, `entries` counting its places once and `null` with the `error` that says why it was not read, absent when it read none; a `lists` command is a `commands` entry with `phase: "lists"`, timed in `lists_ms`), and each step record names its world in `world_name`. Every request a step sends to the world's origin (through `fetch`, `node:http`, `node:https`, a Playwright request context, or a Chromium page's documents, fetches, XHRs, and EventSources; for a `localhost` world, a name below `localhost` at its port too) carries a W3C `traceparent` with one trace id per step or hook (a Before, AfterStep, or After hook's requests carry the hook's own, recorded in the scenario's directory; a BeforeAll or AfterAll hook's, and the `fetch`, `node:http`, and `node:https` requests of a fixture's setup or teardown, go without one), all of a world's starting with the same eight hexadecimal characters, and a span id per request; a request that sets its own, or whose request context's `extraHTTPHeaders` set one, keeps it, and a `node:http` request is stamped as its headers are sent, so one the step sets after creating it is kept. A redirect to another origin takes no header: `fetch` is stamped on each hop to the world as undici sends it (the `undici:request:create` channel), with the step's arguments untouched; the exception is a Playwright request context, which sends a call's headers on with a redirect. An http.jsonl line names the `traceparent` the request went out with, nukadoko's or the step's own (a page's line, as the browser sent it), and then always `traceparent_sent_to`, the origins that received it (a request context's first hop and final response; an origin between them is not known); a step's `stamped` counts only the requests that went out with nukadoko's value. When nukadoko serves the program, a line of `program.log` belongs to the step whose trace id it carries (the first place in the line where the world's eight characters begin 32 hexadecimal ones), wherever and whenever it appears, and redaction never changes a trace id of the world or a `traceparent` value holding one; each step record gets its lines so far in `program-log.txt` beside it, redacted, and `observed.program_log: { trace_id, lines, file, stamped, truncated? }` (`file` is `null` when `lines` is 0); a step that stamped a request waits up to 300 ms for its lines, until none carrying its trace id has arrived for 30 ms after the step ended. A line that arrives later goes to the step's `program-log-late.txt` when the world stops, run.json's step gets `program_log_late: { lines, file, truncated? }`, the run summary names it on the step's line, and `nuka do` prints a `program-log-late` note; the record is not rewritten. The program must write the id into its lines: for Rails, `config.log_tags = [ ->(request) { request.headers["traceparent"] } ]` with the test log sent to stdout. The run summary says once per world, decided from the whole log, when no line carries a trace id of the world, how many lines arrived after their step ended (and only when none came in time, that output buffered on a pipe looks like that: `STDOUT.sync = true` in Ruby, `PYTHONUNBUFFERED=1` for Python), and when it was not read because the world runs at a `url`; there `observed.program_log` is `null`. A program that names `{events}` (`env: { EXECUTION_EVENTS: "{events}" }`) can append one JSON line per operation it ends to that file, in the format of docs/execution-events.md (`request`, `db`, `tx`, `job`, `http`, `flag`, `error`, and a writer's own `x_` kinds), each carrying the request's `traceparent` or, for a job, the one that enqueued it, at most 4095 bytes in one write call; a line belongs to the step whose trace id its parsed `trace` field holds, a line that does not read belongs to none and counts in `unreadable` for the step whose trace id its text carries, and each step record gets its lines, parsed, redacted (trace ids kept), and written again as JSON, in `events.jsonl` beside it, with `observed.events: { trace_id, lines, file, kinds, stamped, stamped_spans, unreadable, unowned, process_spans, process_requests, whole, open }`, with `mcp_spans` when the step sent an MCP call (`stamped_spans` are the span ids of the stamped requests, at most 1000; `process_requests` counts the request lines that carry a span a `runCommand` process got in its TRACEPARENT; `mcp_spans` are the spans of the step's MCP calls, below), read with the same wait as the program's log. `whole` is `true` when every request the step stamped has its `request` line (by span id), every job enqueued in the trace performed, every `runCommand` process it ran closed with no process of its group left, and every MCP call it sent went out in a stamped request; otherwise `open` names why, one gap word each in this order: `no-requests` (no stamped request, no `runCommand` process, and no MCP call), `processes-unbounded` (a `runCommand` process may still send: it still ran when the record was built, left a process of its group running, or ran on Windows; one that leaves its group, as a daemon does with `setsid`, is not seen), `mcp-unbounded` (`calls`: MCP calls that reached their server over stdio or another origin, whose end no line reports), `no-lines`, `request-unreported` (`requests`), `jobs-pending` (`job_ids`), `unreadable` (`lines`), `truncated`, `file-replaced`. A line that arrives later goes to the step's `events-late.jsonl`, run.json's step gets `events_late: { lines, file, truncated? }`, and `nuka do` prints an `events-late` note; the world's stop also gives each step of a world with an events file `path: { requests, entries, maybe, open }`, its trace counted by what each line did over every line, late ones included: `requests` each `request` line's `method`, `route`, `status` in the order the step sent them, `entries` with `count` by kind in this order, `error` (`class`, `handled`), `db` writes (`table`, `op`, and `holds` on a table the tables list marks as `bookkeeping` or `infrastructure`, whose writes stay in the path; reads are left out for now, as are `tx` lines, ids, and actors), `http` (`method`, `origin`, `path`, `status`), `job` (`name`, `phase`), `flag` (`name`, `side`, with `gates`), `maybe` the lines that may be any line, and `open` the gap words over every line; the world's redacted copy is `worlds/<env>/events.jsonl`, and the run summary gives the world one line when the file was not read, got no line, or holds lines no step record holds. A world at a `url` refuses `{events}`, and its steps' `observed.events` is `null`. A claim step's `events: { <key>: { of, count } }` counts lines of an earlier step's trace: `of` is that step or a list of candidates of which one ran earlier (the latest run of it counts; none leaves the claim `unjudged` with `producer-not-run`, two leave it `unjudged`), and `count` is `{ kind, ...fields }` with the format's kinds and fields, each field one value or a list, a value `{ sentence: "<capture>" }` taken from the line (the capture then counts as read), a `db` selection whose `op` may be a write stating `committed`, a `db` selection that names no `table` leaving out each line on a table the tables list says holds `bookkeeping` or `infrastructure` (one that names a table counts it whatever it holds), and a writer's own `x_` kind, an undefined kind or field, or a bad value refused at import. A claim names the key alone as its `actual` (no `view`, `at`, `count`, `each`, or path), compares with `equal`, `not-equal`, `greater-than`, `at-least`, `less-than`, or `at-most` against a number the line states (a `{n:int}` capture, digits, a number word, `once`, `twice`, or `never`, `no`, `none`, `nothing` as 0 under `equal`), and an events key shares no name with a `from` or args key and is read by a claim. When the claims are judged, the step reads the trace's lines from where that step's slice began and waits while its events may still become whole (`no-lines`, `request-unreported`, `jobs-pending`), up to its `timeout`, else 10 s, or a shorter `stepTimeout`, never until a claim holds. The count is a range, `[yes, yes + maybe]` when whole and unbounded above when not (`maybe`: lines that did not read, of an undefined kind or version, missing a field the selection reads, `holds_unknown`, a `db` line on a table the count may leave out because the tables list was not read or the writer named its table `unknown` while the list marks one, a write of unknown commit state, or owned by no step), and the claim holds or breaks only when every count in it agrees, else it is `unjudged` with the gap word in its reason (`kind-unreported` while the world has reported no line of the kind; `world-unread` at a `url`; `inlet-unnamed` without `{events}`). The record holds the count as `actual` when it is one number, else `actual_range`, then `counted`, `actual_from` `events:<step>@<line> count <selection>`, `measured` `{ step_record_id: <own>, channel: "events_read.<key>" }`, and the step's `events_read.<key>`, `{ of, trace_id, count, range, counted, whole, open, maybe, lines, unreadable, unowned, file, waited_ms }`, with the lines it counted in `events-read.jsonl`; run.json's step carries `events_read` too. `counted` groups the lines the count counted, most first, as `{ kind, fields, lines }` by the kind's fields (`request` method, route, status; `db` op, table; `tx` phase; `job` name, phase; `http` method, origin, status; `flag` name, side; `error` class, handled), every group listed, and the claim's line names the first three under every outcome (`...; counted 1 line: db insert into events`, `counted 3 lines: 2 db insert into scores, 1 db update rankings`, then `and 4 more lines in 2 groups`); `left_out`, present when the count left a line out, groups those lines the same way with each group's `holds`, on the claim and in `events_read`, and the line adds `; left out 1 line: db insert into events (bookkeeping)` after what it counted. When the world stops, each reading is counted again over every line of the trace, and a claim the whole count judges otherwise gets `after_world_stop: { lines, range, outcome, reason }` in run.json, the reason naming the lines the whole count counted that the claim's did not (`and the stop counted 1 more line: db insert into scores`), and its cell is `broke` (`a claim at line <n> was judged before every execution event it counts had arrived`). `nuka run` also raises the note `undeclared-write` for a head step that declares `mutates: false` whose trace holds a write the program committed to a table that holds state (late lines included; not a write that rolled back, one of unknown commit state, or any when the tables list was not read), once per step line of a scenario and environment, naming the step, the table, and the op: `the step at line 6, get, declares mutates: false, and its trace holds writes the program committed to tables that hold state, 1 line: db insert into scores`; it changes no status and no exit code, and never reads a request's method as a write. A world that does not start is `program-start-failed`, with the end of `program.log`; no scenario runs in it. `environments` entries override any of those fields (`env` merges by key) and add `policy: "read-only"`, `envFiles` (after the config's), a `version` probe, and `conditions`, the switches of the program that environment runs, each `true`, `false`, or a string with no whitespace and no `@` (`{ banner: true, locale: "ja" }`; the strings `"true"` and `"false"` are refused, since a string reads as on), which a scenario's `@with:` and `@without:` tags read (see `nuka run`); they set nothing, which `env` and the env files do, and nukadoko trusts them without checking the program, so derive the switch from them (`env: { BANNER: "{condition.banner}" }`). The top-level `defaultEnvironments: [<names>]` names the environments a run without `--env` starts, each an environment of the program or `default`. A tree with no program starts no world, which suits a command-line tool. `baseURL` and `environments` at the top of the config are refused, naming `program`.
|
|
17
17
|
- Commit `features/`, the config, and the program file. `.nukadoko/` is the state directory and stays out of git: `runs/<run_id>/` holds everything one `nuka run` measured (`run.json`, `summary.md`, `steps/<id>/` step records, `scenarios/<id>/` scenario evidence), and `do/<id>/` holds `nuka do` step records. Never edit a record by hand, and never delete one to get a cleaner run.
|
|
18
18
|
- A step is a file under `features/steps/` that starts with `import { defineStep, z } from "nukadoko"`. An existing cucumber-js suite comes in through `nukadoko/compat`.
|
|
19
19
|
- `returns` can be left out, and `run` then returns nothing: a step whose `returns` is `z.object({})` may drop it and its final `return {}`, but an early `return {}` inside an `if` becomes `return;`, or the step falls through.
|
|
20
20
|
- `scratch` is a builtin fixture: `scratch.dir(prefix)` and `scratch.copy(source)` give temporary directories removed when the scenario ends. A `scratch` entry in `config.fixtures` replaces it.
|
|
21
21
|
- `await runCommand(command, args, { cwd, env, input, timeout, redact, files })`, imported from `nukadoko`, runs a program and records it in the step record's `observed.processes`, with the files it `added`, `changed`, and `removed` under its working directory (`files`), and `stdout` and `stderr`, the files in the step record's directory (`process-<n>.stdout.txt`, `process-<n>.stderr.txt`) that hold what it printed, redacted, `stdin`, the file that holds the `input` it was given, and `env`, its environment as a difference from the runner's, or `{ "inherited": true }`, with every name and a value only when it is an absolute path that exists when the process ends, a decimal integer, or `true` or `false` (any other value is `{ "hidden_bytes": <n> }`, its UTF-8 length), `group` inside a step on POSIX (`ended` when no process of its group still ran as it closed, `running` when one did), and `traceparent`, the `TRACEPARENT` (OpenTelemetry's environment carrier) nukadoko put in its environment when the run has a world: the step's trace id and a span id of the process's own, set unless the step's `env` holds a TRACEPARENT other than the runner's own, so a tool that copies it into the `traceparent` header of its requests makes the program's lines for them the step's; the result carries the same `files` (outside a step only with `files: true`), and a Then that claims what the command wrote reads it through a claim step's `files: { <key>: { of: <step>, change?, under? } }`, never through a list the step returns. `redact: { NAME: value }` writes a secret the step holds as `{{secret.NAME}}` in the recorded command. On Windows it finds a bare name such as `npm` through `PATH` and `PATHEXT` and runs a `.cmd` file through `cmd.exe`. Inside a step on POSIX the process runs in a process group and a session of its own, with no controlling terminal: the process that runs the steps passes each SIGINT, SIGTERM, or SIGHUP on to every such group still running, and `timeout` sends SIGTERM to the whole group. It returns a Promise, and its `exitCode` is `number | null` (`null` after a signal).
|
|
22
22
|
- `measureMcp(transport)`, imported from `nukadoko`, wraps an MCP client's transport (any object with `start`, `send`, `close`, `onmessage`, `onclose`: the SDK's `StdioClientTransport` or `StreamableHTTPClientTransport`; nukadoko imports no SDK) and returns it with every other member its own: `await client.connect(measureMcp(new StreamableHTTPClientTransport(new URL("/mcp", baseURL))))`, usually in a scenario fixture. Like `runCommand` it is an import, not a `ctx` member: each `send` finds the step that runs then, and a message sent outside every step (the client's `initialize`) passes untouched and is recorded nowhere. Each request and notification a step sends is a line of the step record's `mcp.jsonl` (`evidence.mcp`; `observed.mcp` counts them): `method`, `id` (or `notification: true`), the `tool`, `prompt`, or `uri` it names, `params` and `result` as JSON text redacted and cut at 16 KiB like a body, `traceparent`, `header_sent_to`, `duration_ms`, `is_error: true` for a result with `isError` (the tool ran and reported an error), `error: { code, message }` for a JSON-RPC error, `unanswered` (`step`, `run`, or `closed`), or `send_error`. Each call carries the step's trace context in `params._meta.traceparent` (a caller's own is kept); over HTTP to the world's origin the transport's request carries the same value as its header, so it counts as a stamped request and the program's `request` line closes the call, and a count claim on its work can be exact. Over stdio, or to another origin, the value is in `_meta` only: the server's work is the step's when it sends the world a request with that value as its header, the step's events stay open with `mcp-unbounded`, and an exact count is `unjudged` while `at-least` can hold. A stdio server gets no `{events}` path, so it writes no events itself. `measureMcp` decides no verdict: an error answer is a result the step reads. A call started after the record goes to that step's `mcp.jsonl` with `after_step_end: true`, counted in run.json's `after_step_end.mcp`. Server-to-client requests and notifications are not recorded. `nuka check` notes `mcp-transport-unmeasured` for `client.connect(new XClientTransport(...))`, where nothing can wrap the transport.
|
|
23
|
-
- A step record's `observed` keeps one key per channel nukadoko measures: `processes` (through `runCommand`), `mcp` (the MCP calls sent through `measureMcp`, above; absent when none), `websocket` (the opens, closes, and frames of each socket made with the global `WebSocket`, each a line of the step record's `websocket.jsonl` with `event`, `socket` (a number per socket), `url`, `at`, and a text frame's `data` redacted and cut at 16 KiB like a body; a frame sent belongs to the step that sent it, and the rest to the step running when it arrived; absent when none),`http` (a count of the requests the step's process sent through `fetch`, `node:http`, `node:https`, or a Playwright request context; each is a line in the step record's `http.jsonl` with its `request_body` and `response_body`, redacted and cut at 16 KiB, and never its headers, except `traceparent` when nukadoko added one, with `traceparent_sent_to` when a request context's redirect took it to another origin), `program_log` (when the run has a world URL: the step's slice of the program's log, above), `events` (when the program
|
|
23
|
+
- A step record's `observed` keeps one key per channel nukadoko measures: `processes` (through `runCommand`), `mcp` (the MCP calls sent through `measureMcp`, above; absent when none), `websocket` (the opens, closes, and frames of each socket made with the global `WebSocket`, each a line of the step record's `websocket.jsonl` with `event`, `socket` (a number per socket), `url`, `at`, and a text frame's `data` redacted and cut at 16 KiB like a body; a frame sent belongs to the step that sent it, and the rest to the step running when it arrived; absent when none),`http` (a count of the requests the step's process sent through `fetch`, `node:http`, `node:https`, or a Playwright request context; each is a line in the step record's `http.jsonl` with its `request_body` and `response_body`, redacted and cut at 16 KiB, and never its headers, except `traceparent` when nukadoko added one, with `traceparent_sent_to` when a request context's redirect took it to another origin), `program_log` (when the run has a world URL: the step's slice of the program's log, above), `events` (when the program names `{events}`, or `null` for a world at a `url`: the step's execution events, above), `files` (the paths changed in a scratch directory or written through `node:fs` by the step's process, each with up to 8 KiB of its content; a file the step asked Playwright to write, such as `page.screenshot({ path })`, is listed, and what Playwright's server writes on its own, such as trace chunks, a HAR, or a video, is not, whoever launched the browser), and `unmeasured` (each action nukadoko saw but cannot measure, as `{ kind, detail }`: a process started without `runCommand`, however it ended, named by its program and argument count and never its arguments or a `NAME=value` word, a `Worker`, a connection the step opened or wrote to that carries no recorded request, what a `node:http` upgrade (a WebSocket from the `ws` package) or a CONNECT tunnel carried after its handshake, a UDP datagram sent through `node:dgram` (once per address), a Chromium page's request to the world that went without a `traceparent` because the page's DevTools session failed (`page_request`, once per reason), or a path the step wrote whose identity nukadoko could not read). A channel the step never reached is `null`, not `0`, and `unmeasured` is `[]` when nukadoko saw nothing it could not measure; a child process's own traffic, a Worker's, and a native addon's are never seen. A body nukadoko stopped reading has `bytes_read` instead of `bytes` (with `incomplete: true` when it stopped waiting at the step's or the run's end), a body that failed on its own (an abort, a destroy) has `bytes_read` and an `error`, a `node:http` response the step never read has `response_body: { unread }`, a stream or FormData body a step passes to `fetch` in its `init` is `request_body: { unread }`, since `fetch` gets exactly the step's arguments, and a request with no response by the step's end has `status: 0` and an `error` that says how long it had. A request or a `runCommand` process a step starts after its record was written is written beside that record with `after_step_end: true`, run.json's step names `after_step_end: { requests, processes, http, mcp }`, the run summary names it and its file, and a request still open when the run ends gets its line then. A page's own requests (`page`, `context`, `pageAs`) are lines in `http.jsonl` too, without bodies. The run summary gives each step with an unmeasured action, or an action started after it ended, one line. `args_origin` names where each `args` key came from: `capture`, `docstring`, `table`, `{ from: { step_record_id, step, key } }`, `command_line`, or `schema`. nukadoko never infers a write from an HTTP method.
|
|
24
24
|
- Skills, for any Agent Skills host: `gh skill install meganemura/nukadoko --all`. The copy that matches the installed version is in `node_modules/nukadoko/skills/`, and `nuka skill path` prints that directory. This file is `node_modules/nukadoko/llms.txt`, and in the Ruby gem it sits beside the `skills/` directory `nuka skill path` prints.
|
|
25
25
|
|
|
26
26
|
## Ruby
|
|
@@ -32,8 +32,9 @@ The `nukadoko` gem is a second engine that reads the same feature files and judg
|
|
|
32
32
|
- A Then step has `claims [{ actual: "body", compare: "equal", expected: { from: "created" } }]` and `def observe(...)` in place of `run`, with `poll timeout_ms: 3000` when it waits.
|
|
33
33
|
- The keyword arguments of `run` or `observe` name the fixtures, with `args:` only when the body reads them: `request`, `page`, `scratch` (`dir` and `copy`), `call`, and each `Nukadoko.fixture(:name) { |use| use.(value) }` in `nukadoko.config.rb`.
|
|
34
34
|
- `Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` runs a program and returns `{ exitCode:, signal:, stdout:, stderr: }`, kept in the step record. Its `env` is added to the runner's environment, and `timeout` is in seconds.
|
|
35
|
-
- `
|
|
35
|
+
- `Nukadoko.config(program: -> { { serve: { command: "... {port}", ready: "/up" }, environments: { ... } } })` holds the program under test, an environment's own env files under `envFiles:`. A `nukadoko.program.rb` of an earlier release is refused with `program-file-moved`.
|
|
36
36
|
- `Nukadoko.config(envFiles: [".env"], secrets: { public: [...], redact: [...] })` loads env files and classifies their secrets as above.
|
|
37
|
+
- `Nukadoko.config(parameterTypes: [{ name: "priority", regexp: /高|低/, transformer: ->(s) { s == "高" ? "high" : "low" } }])` registers a parameter type as `parameterTypes` does in the TypeScript config: a Ruby Regexp or a string, and a lambda given the groups the regexp captured.
|
|
37
38
|
- The gem has one command the npm package does not, `sig`: it writes `sig/nukadoko/steps.rbs`, the RBS of each step's args and returns, so Steep checks the step bodies.
|
|
38
39
|
- Not in the gem yet: `requires`, `gives`, and `ends`, `measureMcp`, the `nukadoko/compat` door, and `nuka init --allure`.
|
|
39
40
|
|
|
@@ -46,15 +47,15 @@ Run them in this order. Exit 0 is the only pass.
|
|
|
46
47
|
- Both exit 1 when a step file did not import (`step-file-import-failed`) or when part of a step's contract could not be read: its `needs`, a `from` entry, or (for `describe`) an args or returns schema JSON Schema cannot represent. Each such part is a `contract-unreadable` finding naming the step in the `--json` envelope; the rest is printed either way.
|
|
47
48
|
- `nuka scaffold <name> --pattern <text> [--then | --command [<entry point>] [--cwd <key>] [--argv <key>] | --request "<METHOD> <path>" [--body <key>]] [--from <step>.<key>] [--description <text>] [--replace]`: a step file that fails until implemented. `--then` writes a claim step: `claims` in place of `run`, and no `returns` or `mutates`. With one value the line states (a capture, the docstring, or the table) and one `--from`, its claim compares the two with `equal`, and a chained `stdout` or `stderr` against a stated string gets `view: "text"`, which trims the newline a program prints last. When the two are of two different JSON types (a `{string}` capture against a `z.number()`), `--then` refuses: a claim across them never holds, and a claim on a word of the line instead would leave the stated value read by nothing, which a step with no `observe` may not do. With any other mix of stated values and `--from`, it writes an `observe` stub that throws `not implemented: <name>` and one claim on what `observe` returns against the first stated value. A line that states its value with a word alone (`no`, `none`, `nothing`, `neither`, `never`, `empty`) needs exactly one `--from` whose `returns` schema is a bare `z.string()`, `z.number()`, or `z.array()`: its claim compares that value with the word's literal of the same JSON type (`""`, `0`, or `[]`), with `equal`, or with `not-equal` right after the word `not`, `neither`, or `nor`. A number word from `zero` to `twelve`, `once`, or `twice` works the same way with a `z.number()` `--from`, and its claim is written with `equal`, which a number word lets the step change to the compare the line says. Without such a `--from`, and for a line that states no value, `--then` refuses. When every feature line the pattern matches carries a docstring, `args` gets `docstring: z.string()`, and for a table `table: z.array(z.array(z.string()))`; a Then claims it like a capture. `--command` writes a When step that runs a program and returns `exitCode`, `stdout`, and `stderr`; its value must be an existing file that plain `node` can start, and without one the step throws `fill in the entry point: <file>:<line>` until that line is filled in. It runs the program in an empty `scratch.dir()` with the pattern's captures as argv, one capture per element; `--argv <key>` splits that string capture into elements on whitespace only, with no quoting rule, so one line such as `When I run greet with "Ada --shout"` carries every argument and flag. `--cwd <key>` runs it in the directory that args key holds instead, such as the `dir` a Given returned. The step writes `mutates: true`, the default, under a comment that says to set it to false when the program changes nothing outside a scratch directory. A `--from` key is never argv: until it is placed (an environment variable, a flag, or `--cwd`), the step throws `pass <keys> where the program reads them: <file>:<line>`. `--request "<METHOD> <path>"` writes a When step that sends one request through Playwright's own `request` (`request.fetch(path, { method })`, resolved against the world's URL) and returns `status` and `body` (the response text); each `{key}` in the path is that args key's value, put in as it is, `--body <key>` sends an args key (a capture, a `--from` key, or the line's `docstring`) as `data`, and any other value throws `pass <keys> where the request reads them: <file>:<line>` until it is placed. It writes `mutates: true`, because the method is only a proxy for write semantics. `--request` is refused with `--then` or `--command`, and so is `--body` without `--request`. `--from` chains a key of an earlier step's `returns` into `args`, and repeats; the same key given for two steps lists both as candidate producers, which must declare the same schema for it. Without `--description`, `--command` and `--request` write a description of the step they generate, and any other form writes `TODO: describe <name>`, which `nuka check` reports as the note `step-description-todo`.
|
|
48
49
|
- `nuka scaffold --feature <path>`: one stub for each line `nuka check <path>` reports as `undefined-step`, the pattern read from the line (`{value:string}`, `{value:int}`, `{value:float}`) and a claim step for a Then line; a Then line that states no value, or states it with a word alone, gets a `note:` line on stderr and no stub. A line with a docstring gets a `docstring` key, and a line with a table a `table` key. A line that reads more than one way keeps its text as the pattern, with no capture, and gets a `note:` line on stderr. The stubs declare no `returns` and no `from`: for a When that runs a program and the Thens that read its result, use single `nuka scaffold` calls with `--command` and `--then --from <step>.<key>`. After the written paths, stderr gives a `next:` line and, for each stub, the single `nuka scaffold <name> --pattern <pattern> [--then] --replace` that writes it again byte for byte (left out for a stub whose single scaffold would write it differently), to add `--command`, `--from`, or `--description` to. A step file that already exists is refused; while it is still, byte for byte, what scaffold writes under some set of options (a `--feature` stub, or a `--command`, `--from`, or `--description` step nobody edited), the refusal's `do:` line is the same command with `--replace`, which overwrites that file and refuses any other.
|
|
49
|
-
- `nuka check [feature..] [--json] [--fail-on <code>] [--env <name>]...`: static checks for the files `nuka run` would select (a file, several, a directory, or every feature with no target), and the program
|
|
50
|
-
- `nuka run [feature..] [--no-check] [--env <name>]... [--tag <expression>]... [--concurrency <n>] [--repeat <n>] [--order file|shuffled[:<seed>]] [--proof-runs <n>] [--base <git ref>] [--step] [--records] [--json]`: runs `check` first for the selected scenarios and refuses on an error (`--no-check` runs anyway). `<file>:<line>` runs one scenario. Progress, failures, and the paths it wrote go to stderr (none of them under `--json`); each step's line says `passed`, `failed`, or `skipped`, the word its step record uses. stdout stays empty unless asked: `--records` writes each scenario's `run.json` entry there as one JSON line when it finishes (a step's `program_log_late` is only in `run.json`, written when the world stops), and `--json` prints `run.json` itself, which is the envelope: `run_dir` (the run directory, relative to the project root, the argument `nuka report` takes), `commit` (`sha`, `dirty`, and `working_tree`, the working tree as one git tree id: tracked files as on disk and untracked files `.gitignore` does not leave out, the state directory left out; absent when git gives none), `environments` (each `name`, `target_version`, `base_url`, its world's URL or `null`, and `conditions` when it declares them), `worlds` (each world the run started, with `name`, `tree`, `url`, `commands`, `timings`, `log`, and `error`; empty with no program file), `selection` (`partial` when a `:line` target left out a scenario of its file), `order` (`{ kind: "file" }`, or `{ kind: "shuffled", seed }` under `--order shuffled`), `counts` (`scenarios`, `passed`, `failed`, and `stopped` (a walk stopped them, `--step`) of the executions of required cells, `not_run` required cells, `controls` of the executions of controls, and `controls_not_run` control cells), `table` (the verdict table: `base` (`{ ref, commit }` under `--base`, else `null`), `mapping_changed` and `mapping_changes` (`files`, `config`, `conditions`, `default_environments`, `unseen`; `null` without `--base`), `worlds`, its columns `{ world, environment }` with `world` of `head`, `base`, or `old`, `left_out`, the selected criteria `--env` left out, `proof_runs`, the `--proof-runs` a control's `runs` is measured against, and `rows`, one per selected criterion and then one per removed one, with `feature`, `line`, `name`, `change` (`null`, or under `--base` `unchanged`, `changed`, `new`, or `removed`), `renamed_from` (`{ feature, name }` at the base), `retagged` (`true` for an unchanged row whose tags differ from the base's), `conditions` (its condition tags and `@held`), `cells` (each `world`, `environment`, `role` of `required` or `control`, `conditions` (each condition its row's tags name, with the value its environment declares, `null` where none), `outcome` of `pass`, `fail`, `broke`, `stopped`, `flaky`, or `not-run`, the `line` of every one but `pass` and `not-run`, `runs`, for `fail` the `claim` every run broke and `actuals`, each run's actual value, and a `reason` for `not-run`, for a `broke` a hook caused, and for a control `broke` whose proof round could not finish), `verdict` of `held`, `proven`, `removed`, `failed`, `unproven`, or `moved`, `reason`, one sentence, and for a removed row `lines`, its sentences at the base), `flags` (only when a head step's execution events name a flag or a head world's `lists.flags` list declares one: one row per `name` and `side`, a declared side no criterion evaluated included with no `criteria`, each with `listed_in` (each environment whose list declares the side, empty for one no list declares) whenever a flags list was read, and `only_side_evaluated: true` on a flag's one side when the criteria evaluated no other, the side as its lines name it and never as an environment's conditions declare it, with `criteria`, each criterion that evaluated it there with its row's `verdict` and its `cells` on that side (`environment`, `role`, `outcome`, `line`, and `gates`, each gate its lines named or `null`), and `counts` by verdict, where a criterion seen on the side only in controls counts as `controls`; evidence to join with the program's own record of the flag by `name` and `side`, not a verdict on the flag; the summary gives each row one line under "Flags"), `routes` (only when a head world read a `lists.routes` list: one entry per `method` and `route` a list or a head step's `request` line names, `null` for the requests the program matched to no route, ordered by route and then method, with `handlers`, `listed_in` (each environment whose list holds it; empty for a route no list names), `requests` (every `request` line of a head step naming it, a late one included, each line in exactly one entry; 0 for one no step requested), `statuses`, and `criteria` and `counts` by the rules of `flags`, each cell with its `requests` and `statuses`; a request counts the same in a Given as in a Then and says the program matched the route, never that a claim read its answer; the summary's "Routes" names the listed routes no step requested, apart from those whose handler a request reached through another route (PUT and PATCH of one resource), the requests no list names, and each world whose list was not read), `paths` (only when a pair of sides read execution events: under `--base` each environment's base world against its head world, `between: { kind: "base" }`, base pairs first, for the rows the base ran there, which, when both program files name `{events}`, is every row whose head cell there is required and ran (head's `{events}` alone builds the base world for this even when no criterion is new or changed, so a refactor is compared), and two environments whose `conditions` differ in exactly one, `between: { kind: "condition", name, a, b }`; one entry per pair, with the sides `a` and `b` (`world`, `environment`), side `a` being the base world, or the environment where the condition is `false` or not declared, `unread` naming why nothing was compared or `null`, `counts` of `changed`, `open`, `same_so_far` (open, with every open count one range on both sides under the same gap words), `marked_only` (the only differences are on tables marked as bookkeeping or infrastructure; a criterion's `result` reads every other difference), `same`, and `not_compared`, `criteria` with each criterion's `result`, under a base pair `explained_by` on a `changed` one (`criterion_change` when it is new or changed, `null` when it is unchanged and nothing in the feature files asked for the difference), its side executions `a` and `b` (`scenario_record_id`, the cell's `outcome` and `line`), and `steps`, the steps with a difference aligned by line: `ran: "both"` with `changed` and `open` entries, each carrying the range of its count on side `a` and side `b`, and `holds` on a marked table, and `gaps`, or `ran: "a"` or `"b"` for a step only that side ran; a count a side's missing lines could still reach is `open`, never `changed`, a flag's side is the premise of a pair of environments and never compared there, while against the base a flag whose side changed is a difference, and `not_compared` names each criterion left out with a `reason`, such as `did not run at the base`; `unread` says when the base's program file names no `{events}`; evidence, not a verdict; the summary lists up to 20 criteria per heading under "Changed paths", every base pair under one `base → head` heading that lists a criterion with the same lines in several environments once, counts the unchanged criteria compared (`Each of the 2 unchanged criteria compared did the same at the base and at head.` when each did), and lists the unchanged criteria that changed first, then the new or changed ones, then those that may differ, each group under a line of its own, and then, under `Bookkeeping and infrastructure writes that differ, which no sentence is about, though another reader of those tables may be:`, the differences with `holds`, which never rank a criterion), `limits` (what the run does not show, computed from the other fields of run.json: `left-out`, `check-skipped`, `control-not-proving` for a held row where no control failed at a Then, `no-claim`, `unmeasured`, `after-record`, `unrecorded-log`, and `unrecorded-events`, each with a `detail` and, where one exists, a `do` or `fix`; the summary renders it under `What this run does not show` right after the table, and stderr ends with one line of counts by kind, `limits: <n> <kind>, ... (run.json limits)`), and per scenario execution its `environment`, `role`, under `--base` the `world` and `row` of a base or old execution, and `for_paths` (`outcome`, and `line` when it did not pass) on a base execution run for `paths` alone, which is no cell, gets no proof runs, never changes the table, and whose stderr line ends `(for paths)`, and steps (each with `line`, `text`, `step`, `status`, `step_record_id`, `record`, `record_unreadable` with a `step-record-unreadable` warning when its step record could not be read back, a claim step's `claims`, `observation`, and `attempts`, and for a failure `error` with `kind` and `message` and the `used` results it read, a result over 4096 bytes of JSON cut to a preview with `truncated` and `result_bytes`), a failed scenario's `do` (a control has none), and every finding the run raised. `run.json` is written to `.nukadoko/runs/<run_id>/run.json` either way, and every path inside it (`record`, `evidence.dir`) is relative to that run directory; there is no scenario record file. The Markdown run summary, rendered from `run.json` alone, is always written beside it and appended to `$GITHUB_STEP_SUMMARY` when that is set; the run writes no Allure results or messages stream. Each failed scenario is a `scenario-failed` finding on stderr whose ` do:` line is the `nuka run <file>:<line>` that reruns it (under `--order shuffled`, which runs the feature files and then each file's scenarios in the order a seed names, with the seed on stderr before the first scenario, in `order`, and in the summary, the line names the scenarios that ran before it in its pass, then it, with `--order shuffled:<seed>`, or is the run itself under `--repeat` or `--concurrency` above 1), and a scenario a walk stopped is a `walk-stopped` one. `--step` walks one scenario with a person: see `nuka step` below. `--env` repeats: `--env a --env b` is one run with one `run_id` that runs every selected scenario in `a`, then in `b`; each environment gets its own env files, secrets, version probe, world, BeforeAll and AfterAll, and process-scope fixtures. A run without `--env` runs the environments the program file's `defaultEnvironments` names, or else every environment that declares `conditions`, in the order the file lists them, and `default` when none does; any other, such as a deployment target, runs when `--env` names it. Under `--env`, a scenario no named environment meets is not run: its row is left out of the table, counted in `table.left_out`, in one line on stderr (`<n> criteria not run: their conditions hold in no selected environment`), and as the `left-out` entry of `limits`, and `nuka check` reports `condition-unmet` for the default selection only. `--env default` names the top-level environment (as run.json names it), whether or not `nukadoko.program.ts` defines it, so it combines with named ones. The tags `@with:<condition>`, `@with:<condition>=<value>` (exact text; `=true` and `=false` are malformed, write `@with:` or `@without:`), and `@without:<condition>` (off: `false` or not declared) on a Feature, Rule, Scenario, or Examples line make a scenario's cell `required` in an environment that meets them all and a `control` elsewhere; a scenario with none is required everywhere, and `@held` says the base already has the behaviour. `@expects:status=<500-599>`, `@expects:page-error=<name>`, and `@expects:error=<class>` on the same lines accept one failure underneath the scenario: a passed execution whose step got a 5xx response, whose page threw an error nothing caught, or whose trace holds an `error` with `handled: false`, is `broke@<that step's line>` unless a tag names that failure (`unexpected-failure` names it and spells the tag; `expects-unseen` notes a tag that matched nothing); only a pass moves, and like condition tags they are content under `--base`. A cell is `pass`, `fail@<line>` (each execution broke a claim at that line in Then position), `broke@<line>` (each stopped there before a claim was judged: a Given or When error, an undefined line, an unjudged claim; or, at the scenario's line, a hook, which the cell's `reason` names with when it ran), `flaky@<line>` (its executions disagree), `stopped@<line>` (a walk was stopped after the step at that line with `nuka step stop`), or `·` (none ran, with the `reason`). A required cell runs once, or `--repeat` times; a control that failed at a Then line runs again in the same world until it has broken the same claim there `--proof-runs` times (default 2) or a run disagrees (runs agree on the claim, by its position in the step, not on its value, which may differ), each a `proof run <k>/<n>` line on stderr; under `--concurrency` a proof round runs in a worker of its own, which runs BeforeAll and AfterAll again, and a hook that fails there, or a worker that records nothing, makes the round's control cells `broke` with the reason and a `proof-run-incomplete` warning, and the row reads as one no control proves (under `--base`, the base world runs for a new or changed row). A row is `failed` when a required cell is not `pass` or it has no required cell (only under `--no-check` without `--env`, with a `criterion-without-required-cell` finding whose `do:` runs the scenario where it is met, or `nuka check` on its file), `proven` when every required cell passed and a control failed in `--proof-runs` runs, and `held` otherwise. The exit code is 1 when a row is `failed`, `unproven`, or `moved`, or when the run failed outside every scenario: a BeforeAll or AfterAll of a pass failed (at any `--concurrency`), a head world did not start (`program-start-failed`), or a `--concurrency` worker exited before each of its scenarios had a record (`run-incomplete`); a control never makes it red. A `held` row whose control passed says the Then does not see what the switch changes, or the switch does not reach it: read it before calling the criterion covered. The stderr count line counts required cells alone, and a run with a control adds a `<n> control runs, <k> not run` line and a `criteria: <held> held, <proven> proven, <failed> failed` line under it, which every run under `--base` has, with `<unproven> unproven, <moved> moved, <removed> removed` after them. The summary opens with the table, one row per criterion and one `head <environment>` column per environment, headed with the conditions it declares (and `base <environment>` and `old <environment>` under `--base`), then one line per red row with its reason and where it stopped; a failure's `do:` names its environment. Naming one environment twice is refused. `--base <git ref>` compares each criterion with the commit the ref names: its identity is its feature file and name, and its content its steps with their effective keyword, docstrings, and tables, its Examples row, and its condition tags and `@held`, so a rename, a move, or another tag leaves it `unchanged` (with `renamed_from` when its name or file differs, and `retagged` when its tags differ) and an edit makes it `changed`; the rest are `new` or `removed`. The mapping (files under the features directory other than `.feature` files, the whole config but `stateDir` and `retention`, by its value and by the config file's own bytes, so a constant a config function closes over counts and an edit to those two fields alone does too, and each environment's `conditions` and `defaultEnvironments`) is compared as one unit. A `new` or `changed` row that passed at head also runs in the `base` world (the base's code under head's criteria and mapping, built from the base's program file in `trees/base` under the run directory), where a base cell proves like a control after `--proof-runs` failures at one Then line; it is `proven` then, `unproven` (red) when nothing proves it (a compat Then never can, and the reason says so), and a row tagged `@held` is `held` when the base passes it. An `unchanged` row that passed at head runs in the `old` world (head's code under the base's feature files and mapping, in `trees/old`) when the mapping changed or the row is retagged or renamed, and is `moved` (red) when it does not pass there, or else `proven` when a control proves it, as without `--base`, and `held` when none does. Each `unproven` or `moved` row is a `criterion-unproven` or `criterion-moved` finding whose `do:` is `nuka run <file>:<line> --base <commit>`, naming the full hash the ref resolved to, which judges it again against the same commit after the ref moves. `--base` does not support yet a symbolic link at, above, or under the features directory or at the config file, a feature file outside the features directory, a submodule or a nested repository, or, for the base world alone, a workspace package linked into `node_modules` from inside the repository: the world such a shape reaches is not built, its cells are `·` with the reason, and a red row's finding has a `do:` that runs the row without `--base` and a `fix:` when an edit lets `--base` build the world; a shape that hides part of the mapping is named in `mapping_changes.unseen` and makes `mapping_changed` true. A criterion only the base holds is a `removed` row, quoted under the summary's "Removed criteria". The trees install nothing and resolve packages from head's project; a `url` function receives `tree` (`"base"` or `"head"`) and may return nothing for the base, and one that returns head's URL for the base leaves the base world not run, so it has to branch on `tree`. A tree whose cells do not run says why on stderr, `<world> <environment> not run: <reason>`. The summary opens with a line naming the base and what changed. A project outside git is refused with `base-outside-git`, a ref that names no commit with `base-ref-unknown`, a shallow clone without it with `base-shallow` (its `do` is the `git fetch`), a git failure with `base-git-failed`, and a `featuresDir` at the project root with `base-features-at-root`; `--since` is refused with `removed-flag`.
|
|
50
|
+
- `nuka check [feature..] [--json] [--fail-on <code>] [--env <name>]...`: static checks for the files `nuka run` would select (a file, several, a directory, or every feature with no target), and the program's placeholders for the worlds a `nuka run` with the same `--env` flags would start. Findings are errors, warnings, and notes; a note is rot rather than breakage (an unbound pattern, an unused `from` or fixture, a field with no `.describe()`), and only a check with no target reports notes, because they are facts about every feature the project scans. Exit 1 on any error, or on a code `--fail-on` names (one value per flag, repeatable, or comma-separated; the finding keeps its severity, and `--json` lists the hits in `fail_on_hits`; a note code with targets, which compute no notes, is refused with `fail-on-note-with-targets`); warnings and notes alone exit 0. `nuka check --codes` prints every code `check`, `run`, and a refusal can carry; the table under "Findings" is that list. Condition tags are read against the environments `--env` names, as `nuka run --env` does, or without it the ones a run without `--env` selects: `condition-tag-malformed`, `condition-unknown` (a condition no environment declares), and `condition-unmet` (a scenario no selected environment meets) are errors.
|
|
51
|
+
- `nuka run [feature..] [--no-check] [--env <name>]... [--tag <expression>]... [--concurrency <n>] [--repeat <n>] [--order file|shuffled[:<seed>]] [--proof-runs <n>] [--base <git ref>] [--step] [--records] [--json]`: runs `check` first for the selected scenarios and refuses on an error (`--no-check` runs anyway). `<file>:<line>` runs one scenario. Progress, failures, and the paths it wrote go to stderr (none of them under `--json`); each step's line says `passed`, `failed`, or `skipped`, the word its step record uses. stdout stays empty unless asked: `--records` writes each scenario's `run.json` entry there as one JSON line when it finishes (a step's `program_log_late` is only in `run.json`, written when the world stops), and `--json` prints `run.json` itself, which is the envelope: `run_dir` (the run directory, relative to the project root, the argument `nuka report` takes), `commit` (`sha`, `dirty`, and `working_tree`, the working tree as one git tree id: tracked files as on disk and untracked files `.gitignore` does not leave out, the state directory left out; absent when git gives none), `environments` (each `name`, `target_version`, `base_url`, its world's URL or `null`, and `conditions` when it declares them), `worlds` (each world the run started, with `name`, `tree`, `url`, `commands`, `timings`, `log`, and `error`; empty with no program), `selection` (`partial` when a `:line` target left out a scenario of its file), `order` (`{ kind: "file" }`, or `{ kind: "shuffled", seed }` under `--order shuffled`), `counts` (`scenarios`, `passed`, `failed`, and `stopped` (a walk stopped them, `--step`) of the executions of required cells, `not_run` required cells, `controls` of the executions of controls, and `controls_not_run` control cells), `table` (the verdict table: `base` (`{ ref, commit }` under `--base`, else `null`), `mapping_changed` and `mapping_changes` (`files`, `config`, `conditions`, `default_environments`, `unseen`; `null` without `--base`), `worlds`, its columns `{ world, environment }` with `world` of `head`, `base`, or `old`, `left_out`, the selected criteria `--env` left out, `proof_runs`, the `--proof-runs` a control's `runs` is measured against, and `rows`, one per selected criterion and then one per removed one, with `feature`, `line`, `name`, `change` (`null`, or under `--base` `unchanged`, `changed`, `new`, or `removed`), `renamed_from` (`{ feature, name }` at the base), `retagged` (`true` for an unchanged row whose tags differ from the base's), `conditions` (its condition tags and `@held`), `cells` (each `world`, `environment`, `role` of `required` or `control`, `conditions` (each condition its row's tags name, with the value its environment declares, `null` where none), `outcome` of `pass`, `fail`, `broke`, `stopped`, `flaky`, or `not-run`, the `line` of every one but `pass` and `not-run`, `runs`, for `fail` the `claim` every run broke and `actuals`, each run's actual value, and a `reason` for `not-run`, for a `broke` a hook caused, and for a control `broke` whose proof round could not finish), `verdict` of `held`, `proven`, `removed`, `failed`, `unproven`, or `moved`, `reason`, one sentence, and for a removed row `lines`, its sentences at the base), `flags` (only when a head step's execution events name a flag or a head world's `lists.flags` list declares one: one row per `name` and `side`, a declared side no criterion evaluated included with no `criteria`, each with `listed_in` (each environment whose list declares the side, empty for one no list declares) whenever a flags list was read, and `only_side_evaluated: true` on a flag's one side when the criteria evaluated no other, the side as its lines name it and never as an environment's conditions declare it, with `criteria`, each criterion that evaluated it there with its row's `verdict` and its `cells` on that side (`environment`, `role`, `outcome`, `line`, and `gates`, each gate its lines named or `null`), and `counts` by verdict, where a criterion seen on the side only in controls counts as `controls`; evidence to join with the program's own record of the flag by `name` and `side`, not a verdict on the flag; the summary gives each row one line under "Flags"), `routes` (only when a head world read a `lists.routes` list: one entry per `method` and `route` a list or a head step's `request` line names, `null` for the requests the program matched to no route, ordered by route and then method, with `handlers`, `listed_in` (each environment whose list holds it; empty for a route no list names), `requests` (every `request` line of a head step naming it, a late one included, each line in exactly one entry; 0 for one no step requested), `statuses`, and `criteria` and `counts` by the rules of `flags`, each cell with its `requests` and `statuses`; a request counts the same in a Given as in a Then and says the program matched the route, never that a claim read its answer; the summary's "Routes" names the listed routes no step requested, apart from those whose handler a request reached through another route (PUT and PATCH of one resource), the requests no list names, and each world whose list was not read), `paths` (only when a pair of sides read execution events: under `--base` each environment's base world against its head world, `between: { kind: "base" }`, base pairs first, for the rows the base ran there, which, when both programs name `{events}`, is every row whose head cell there is required and ran (head's `{events}` alone builds the base world for this even when no criterion is new or changed, so a refactor is compared), and two environments whose `conditions` differ in exactly one, `between: { kind: "condition", name, a, b }`; one entry per pair, with the sides `a` and `b` (`world`, `environment`), side `a` being the base world, or the environment where the condition is `false` or not declared, `unread` naming why nothing was compared or `null`, `counts` of `changed`, `open`, `same_so_far` (open, with every open count one range on both sides under the same gap words), `marked_only` (the only differences are on tables marked as bookkeeping or infrastructure; a criterion's `result` reads every other difference), `same`, and `not_compared`, `criteria` with each criterion's `result`, under a base pair `explained_by` on a `changed` one (`criterion_change` when it is new or changed, `null` when it is unchanged and nothing in the feature files asked for the difference), its side executions `a` and `b` (`scenario_record_id`, the cell's `outcome` and `line`), and `steps`, the steps with a difference aligned by line: `ran: "both"` with `changed` and `open` entries, each carrying the range of its count on side `a` and side `b`, and `holds` on a marked table, and `gaps`, or `ran: "a"` or `"b"` for a step only that side ran; a count a side's missing lines could still reach is `open`, never `changed`, a flag's side is the premise of a pair of environments and never compared there, while against the base a flag whose side changed is a difference, and `not_compared` names each criterion left out with a `reason`, such as `did not run at the base`; `unread` says when the base's program names no `{events}`; evidence, not a verdict; the summary lists up to 20 criteria per heading under "Changed paths", every base pair under one `base → head` heading that lists a criterion with the same lines in several environments once, counts the unchanged criteria compared (`Each of the 2 unchanged criteria compared did the same at the base and at head.` when each did), and lists the unchanged criteria that changed first, then the new or changed ones, then those that may differ, each group under a line of its own, and then, under `Bookkeeping and infrastructure writes that differ, which no sentence is about, though another reader of those tables may be:`, the differences with `holds`, which never rank a criterion), `limits` (what the run does not show, computed from the other fields of run.json: `left-out`, `check-skipped`, `control-not-proving` for a held row where no control failed at a Then, `no-claim`, `unmeasured`, `after-record`, `unrecorded-log`, and `unrecorded-events`, each with a `detail` and, where one exists, a `do` or `fix`; the summary renders it under `What this run does not show` right after the table, and stderr ends with one line of counts by kind, `limits: <n> <kind>, ... (run.json limits)`), and per scenario execution its `environment`, `role`, under `--base` the `world` and `row` of a base or old execution, and `for_paths` (`outcome`, and `line` when it did not pass) on a base execution run for `paths` alone, which is no cell, gets no proof runs, never changes the table, and whose stderr line ends `(for paths)`, and steps (each with `line`, `text`, `step`, `status`, `step_record_id`, `record`, `record_unreadable` with a `step-record-unreadable` warning when its step record could not be read back, a claim step's `claims`, `observation`, and `attempts`, and for a failure `error` with `kind` and `message` and the `used` results it read, a result over 4096 bytes of JSON cut to a preview with `truncated` and `result_bytes`), a failed scenario's `do` (a control has none), and every finding the run raised. `run.json` is written to `.nukadoko/runs/<run_id>/run.json` either way, and every path inside it (`record`, `evidence.dir`) is relative to that run directory; there is no scenario record file. The Markdown run summary, rendered from `run.json` alone, is always written beside it and appended to `$GITHUB_STEP_SUMMARY` when that is set; the run writes no Allure results or messages stream. Each failed scenario is a `scenario-failed` finding on stderr whose ` do:` line is the `nuka run <file>:<line>` that reruns it (under `--order shuffled`, which runs the feature files and then each file's scenarios in the order a seed names, with the seed on stderr before the first scenario, in `order`, and in the summary, the line names the scenarios that ran before it in its pass, then it, with `--order shuffled:<seed>`, or is the run itself under `--repeat` or `--concurrency` above 1), and a scenario a walk stopped is a `walk-stopped` one. `--step` walks one scenario with a person: see `nuka step` below. `--env` repeats: `--env a --env b` is one run with one `run_id` that runs every selected scenario in `a`, then in `b`; each environment gets its own env files, secrets, version probe, world, BeforeAll and AfterAll, and process-scope fixtures. A run without `--env` runs the environments the program's `defaultEnvironments` names, or else every environment that declares `conditions`, in the order the file lists them, and `default` when none does; any other, such as a deployment target, runs when `--env` names it. Under `--env`, a scenario no named environment meets is not run: its row is left out of the table, counted in `table.left_out`, in one line on stderr (`<n> criteria not run: their conditions hold in no selected environment`), and as the `left-out` entry of `limits`, and `nuka check` reports `condition-unmet` for the default selection only. `--env default` names the top-level environment (as run.json names it), whether or not the program defines it, so it combines with named ones. The tags `@with:<condition>`, `@with:<condition>=<value>` (exact text; `=true` and `=false` are malformed, write `@with:` or `@without:`), and `@without:<condition>` (off: `false` or not declared) on a Feature, Rule, Scenario, or Examples line make a scenario's cell `required` in an environment that meets them all and a `control` elsewhere; a scenario with none is required everywhere, and `@held` says the base already has the behaviour. `@expects:status=<500-599>`, `@expects:page-error=<name>`, and `@expects:error=<class>` on the same lines accept one failure underneath the scenario: a passed execution whose step got a 5xx response, whose page threw an error nothing caught, or whose trace holds an `error` with `handled: false`, is `broke@<that step's line>` unless a tag names that failure (`unexpected-failure` names it and spells the tag; `expects-unseen` notes a tag that matched nothing); only a pass moves, and like condition tags they are content under `--base`. A cell is `pass`, `fail@<line>` (each execution broke a claim at that line in Then position), `broke@<line>` (each stopped there before a claim was judged: a Given or When error, an undefined line, an unjudged claim; or, at the scenario's line, a hook, which the cell's `reason` names with when it ran), `flaky@<line>` (its executions disagree), `stopped@<line>` (a walk was stopped after the step at that line with `nuka step stop`), or `·` (none ran, with the `reason`). A required cell runs once, or `--repeat` times; a control that failed at a Then line runs again in the same world until it has broken the same claim there `--proof-runs` times (default 2) or a run disagrees (runs agree on the claim, by its position in the step, not on its value, which may differ), each a `proof run <k>/<n>` line on stderr; under `--concurrency` a proof round runs in a worker of its own, which runs BeforeAll and AfterAll again, and a hook that fails there, or a worker that records nothing, makes the round's control cells `broke` with the reason and a `proof-run-incomplete` warning, and the row reads as one no control proves (under `--base`, the base world runs for a new or changed row). A row is `failed` when a required cell is not `pass` or it has no required cell (only under `--no-check` without `--env`, with a `criterion-without-required-cell` finding whose `do:` runs the scenario where it is met, or `nuka check` on its file), `proven` when every required cell passed and a control failed in `--proof-runs` runs, and `held` otherwise. The exit code is 1 when a row is `failed`, `unproven`, or `moved`, or when the run failed outside every scenario: a BeforeAll or AfterAll of a pass failed (at any `--concurrency`), a head world did not start (`program-start-failed`), or a `--concurrency` worker exited before each of its scenarios had a record (`run-incomplete`); a control never makes it red. A `held` row whose control passed says the Then does not see what the switch changes, or the switch does not reach it: read it before calling the criterion covered. The stderr count line counts required cells alone, and a run with a control adds a `<n> control runs, <k> not run` line and a `criteria: <held> held, <proven> proven, <failed> failed` line under it, which every run under `--base` has, with `<unproven> unproven, <moved> moved, <removed> removed` after them. The summary opens with the table, one row per criterion and one `head <environment>` column per environment, headed with the conditions it declares (and `base <environment>` and `old <environment>` under `--base`), then one line per red row with its reason and where it stopped; a failure's `do:` names its environment. Naming one environment twice is refused. `--base <git ref>` compares each criterion with the commit the ref names: its identity is its feature file and name, and its content its steps with their effective keyword, docstrings, and tables, its Examples row, and its condition tags and `@held`, so a rename, a move, or another tag leaves it `unchanged` (with `renamed_from` when its name or file differs, and `retagged` when its tags differ) and an edit makes it `changed`; the rest are `new` or `removed`. The mapping (files under the features directory other than `.feature` files, the whole config but `stateDir` and `retention`, by its value and by the config file's own bytes, so a constant a config function closes over counts and an edit to those two fields alone does too, and each environment's `conditions` and `defaultEnvironments`) is compared as one unit. A `new` or `changed` row that passed at head also runs in the `base` world (the base's code under head's criteria and mapping, built from the base's program in `trees/base` under the run directory), where a base cell proves like a control after `--proof-runs` failures at one Then line; it is `proven` then, `unproven` (red) when nothing proves it (a compat Then never can, and the reason says so), and a row tagged `@held` is `held` when the base passes it. An `unchanged` row that passed at head runs in the `old` world (head's code under the base's feature files and mapping, in `trees/old`) when the mapping changed or the row is retagged or renamed, and is `moved` (red) when it does not pass there, or else `proven` when a control proves it, as without `--base`, and `held` when none does. Each `unproven` or `moved` row is a `criterion-unproven` or `criterion-moved` finding whose `do:` is `nuka run <file>:<line> --base <commit>`, naming the full hash the ref resolved to, which judges it again against the same commit after the ref moves. `--base` does not support yet a symbolic link at, above, or under the features directory or at the config file, a feature file outside the features directory, a submodule or a nested repository, or, for the base world alone, a workspace package linked into `node_modules` from inside the repository: the world such a shape reaches is not built, its cells are `·` with the reason, and a red row's finding has a `do:` that runs the row without `--base` and a `fix:` when an edit lets `--base` build the world; a shape that hides part of the mapping is named in `mapping_changes.unseen` and makes `mapping_changed` true. A criterion only the base holds is a `removed` row, quoted under the summary's "Removed criteria". The trees install nothing and resolve packages from head's project; a `url` function receives `tree` (`"base"` or `"head"`) and may return nothing for the base, and one that returns head's URL for the base leaves the base world not run, so it has to branch on `tree`. A tree whose cells do not run says why on stderr, `<world> <environment> not run: <reason>`. The summary opens with a line naming the base and what changed. A project outside git is refused with `base-outside-git`, a ref that names no commit with `base-ref-unknown`, a shallow clone without it with `base-shallow` (its `do` is the `git fetch`), a git failure with `base-git-failed`, and a `featuresDir` at the project root with `base-features-at-root`; `--since` is refused with `removed-flag`.
|
|
51
52
|
- `nuka report [<run dir>] --format markdown|allure|messages [--out <path>] [--json]`: renders one finished run from its run directory alone, so a run directory copied off a CI machine renders too: `markdown` reads `run.json` alone, and `allure` and `messages` read `run.json`, the step records, and `sources.json`, the feature text the run parsed. With no run dir it renders the newest run. `markdown` is the run summary, on stdout or to `--out` (the file a CI step posts as a pull request comment); `allure` writes Allure 2 format results to `.nukadoko/export/allure-results/` or the directory `--out` names; `messages` is a cucumber-messages NDJSON stream on stdout or to `--out`, where a run over several environments gives each environment its own pickle, named `<scenario> (<environment>)`, and every execution of a control is left out, so a JUnit report of a green run is green; Allure keeps each control with the status it ran to, named `<scenario> (control)` with a `role` label, so a control that failed is a failed result there by design, and a CI gates on `nuka run`'s exit code. A file written under `.nukadoko/export/` is noted in the run's exports manifest, so retention removes it with the run, and rendering the same run there again replaces it; a file written anywhere else is not noted, and stays unless it sits inside a run directory that is removed. `--json` prints the envelope with `run_id`, `format`, and `written`, and needs `--out` for `markdown` and `messages`. A directory with no `run.json` is refused with `run-not-found`, and one whose `run.json` this release does not read with `run-invalid`; for `allure` and `messages`, one with no `sources.json` (a run from an earlier release) is refused with `run-sources-missing`, and one whose `sources.json` is corrupt or of another version with `run-sources-invalid`. A missing directory on the way to `--out` is created; anything else in the way (a directory where a file goes, a file where the Allure directory goes, a FIFO, a dangling symbolic link, a path under a regular file, or `allure-history.jsonl` in the export directory in any letter case) is refused with `report-out-invalid` before the run is read, and so is a markdown or messages file the file system refuses to write, with its error code; an Allure directory the file system refuses to write into ends as `report-incomplete`. A render that left out part of the run (a scenario, a step record, or an attachment it could not read) writes the rest and exits 1 with `report-incomplete`; a step whose step record is gone is never shown passed.
|
|
52
53
|
- `nuka verdict [--json]`: before you say a change is done. It reads the newest run that ended and never starts one, and exits 1 when no run ended (`run-missing`), the newest run judged another working tree (`run-stale`: a file git counts changed after it started), it ran part of its files or was a walk (`run-partial`), or it left something red (its own failed findings, relayed as it printed them). A pass says that run judged exactly this tree and left nothing red; it does not say the change has a criterion of its own. Notes: `run-without-base`, `criteria-unchanged` (under `--base`, no criterion is new or changed), `working-tree-unknown` (outside git or before the first commit, where the verdict is the run's own). `--json` adds `judged` (`missing`, `stale`, `judged`, `unknown`), `working_tree`, `run_id`, `run_dir`, `run_working_tree`, and `base`. `skills/nukadoko/scripts/claude-code-verdict-hook.mjs` is an opt-in Claude Code hook that asks for it at the end of a turn that changed the tree.
|
|
53
54
|
- `nuka judge <feature:line> [--run <run-id>] [--meets|--misses --by <name> --because <sentence>] [--json]`: when a run leaves a judgment `pending` or `stale`. A Then with a `judged-as` claim asks for a judgment no compare can give (whether a text reads as friendly); the run reads the value and judges nothing. Without a verdict flag it shows each value, the quality the sentence names, its digest, its step record, and the judged view. With `--meets` or `--misses`, `--by`, and `--because` it records one judgment per value in `judgments/<feature path>.json`, which you commit. The judge is not the agent that wrote the change. A row whose judgment is not `judged` fails the run (`judgment-pending`, `judgment-stale`, `judgment-misses`, `judgment-uncitable`); the verdict column is never changed by a judgment.
|
|
54
55
|
|
|
55
56
|
Exploring one step at a time, when the path is not known yet:
|
|
56
57
|
|
|
57
|
-
- `nuka do <name> --args <json> [--use <step record id>] [--env <name>]`: one typed step under its contract; the step record goes to stdout with its id. `--use` fills the step's `from` keys from an earlier record and repeats; `--args` may be left out only when `--use` supplies every key. Each call builds a fresh browser and starts clean, and with
|
|
58
|
+
- `nuka do <name> --args <json> [--use <step record id>] [--env <name>]`: one typed step under its contract; the step record goes to stdout with its id. `--use` fills the step's `from` keys from an earlier record and repeats; `--args` may be left out only when `--use` supplies every key. Each call builds a fresh browser and starts clean, and with a program starts the environment's world for this one execution and stops it after; a step that needs login state gets it from a fixture.
|
|
58
59
|
- `nuka run <file>:<line> --step [--env <name>]`, started in the background, then `nuka step wait [--walk <n>]`, `nuka step next <pause> --walk <n>`, and `nuka step stop <pause> --walk <n>`, each `[--timeout <s>] [--json]`: a walk of one scenario with a person. The run pauses after each step with the world, the browser, and the fixtures still open, writes a screenshot (`page.png`) and an ARIA snapshot (`page.aria.yml`) of each open page under `runs/<run_id>/pauses/<n>/` (`page-2.*` for a second page, `page.<name>.*` for a `pageAs` context; the URL, the title, and the snapshot, which holds field values, passwords included, are redacted with the loaded secrets, and the screenshot covers each element, in every frame, whose text or field value holds one, as the final screenshot does; a capture that takes longer than the page's 5 seconds is `null`, the title too), and waits until `nuka step` answers that pause; what a page sends while it waits goes to `pauses/<n>/http.jsonl`, not to the step's own files. `wait` prints where the walk stands: the step and its line, its status, its record, the views, the world's URL, and `do` with the answers; at a pause it answers nothing. `next <n>` runs the next step and prints the next pause or the end. `stop <n>` skips the steps after it (After hooks, which see `SKIPPED`, and teardown still run): the scenario is `stopped` with `stopped: { after_step, line }`, its steps after the stop `skipped`, its cell `stopped@<line>`, its row failed, and its finding `walk-stopped`. The pause number is the step number, and an answer names its walk with `--walk` (required for `next` and `stop`, the number each pause prints), so an answer moves only the pause the person saw: one for a walk that is not the walk in the project is refused with `walk-not-current`, which names that walk, the same answer again prints what followed it and writes nothing, another answer to that pause is refused with `pause-answered`, and a pause the walk is not at, or that an ended walk never reached, with `pause-not-current`; each refusal's `do` is `nuka step wait --walk <n>`, which reports that walk, its end included. After the last step or a failed one nothing is left to stop, and `do` names only `next`. `--timeout` (default 90 seconds) bounds the wait; on expiry `nuka step` prints the walk as `starting` (its run has not begun the scenario) or `running`, with the same command as `do`, safe to repeat. Without `--walk`, a wait reports the newest walk until a `nuka step` call has printed how it ended (kept as `walks-reported/<n>` in the state directory), so a walk that ended before the wait started is still reported once; after that it waits for the next walk, and is refused with `walk-not-found`, naming the last walk and how it ended, when none starts. `wait --walk <n>` reports walk n whatever was reported. The run refuses more than one scenario, environment, or execution, and `--base` (`step-needs-one-scenario`), and a second walk in the project (`walk-in-progress`). A signal ends the walk as `interrupted`; a run that was killed leaves it gone, which `nuka step` reports as `walk-gone`. Without `--json` the run writes each pause's lines on stderr (the step, a `failure:` line where the scenario failed, and `do`); with it, nothing. `run.json`'s `walk` lists each pause with its step record, its answer, and its views, and the run summary says the run was walked, so it is not the run a reviewer approves. A pause where the scenario failed (a failed step, or an AfterStep hook that failed after a step that passed) carries `failure` (`by`: `step` or `hook`, and `message`) and prints as `walk-failed`. `nuka step` exits 0 for a walk paused, starting, running, or ended green, 1 for one paused where its scenario failed, ended red, interrupted, or gone, and 2 for a refusal.
|
|
59
60
|
- A browser app whose state cannot be repeated (an account that opens once, an order that must not be placed twice) is explored through the host's Playwright MCP server, not `nuka do`. It is connected when its `browser_*` tools are listed; a Claude Code host adds it with `claude mcp add playwright npx @playwright/mcp@latest`. Then write what was found as a scenario and run `nuka check` on it.
|
|
60
61
|
|
|
@@ -96,6 +96,16 @@ module Nukadoko
|
|
|
96
96
|
# : () -> void
|
|
97
97
|
def check_unbound: () -> void
|
|
98
98
|
|
|
99
|
+
# A config parameter type no pattern names.
|
|
100
|
+
# : () -> void
|
|
101
|
+
def check_unused_parameter_types: () -> void
|
|
102
|
+
|
|
103
|
+
# A claim whose expected value is an args key a type with a
|
|
104
|
+
# transformer fills compares with what code made of the line, while
|
|
105
|
+
# the record would name the sentence as its source.
|
|
106
|
+
# : (singleton(Step)) -> void
|
|
107
|
+
def check_transformed: (singleton(Step)) -> void
|
|
108
|
+
|
|
99
109
|
# A from key every line fills with a capture never takes its value
|
|
100
110
|
# from the producer it names.
|
|
101
111
|
# : () -> void
|
|
@@ -68,12 +68,21 @@ module Nukadoko
|
|
|
68
68
|
|
|
69
69
|
attr_reader received(): Array[String]
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
| (observed: untyped, args: untyped, observes: bool, from_keys: Array[String], labels: ^(String) -> String, received: Array[String]) -> instance
|
|
71
|
+
attr_reader transformed(): Hash[String, String]
|
|
73
72
|
|
|
74
|
-
def self.
|
|
73
|
+
def self.new: (untyped observed, untyped args, bool observes, Array[String] from_keys, ^(String) -> String labels, Array[String] received, Hash[String, String] transformed) -> instance
|
|
74
|
+
| (observed: untyped, args: untyped, observes: bool, from_keys: Array[String], labels: ^(String) -> String, received: Array[String], transformed: Hash[String, String]) -> instance
|
|
75
75
|
|
|
76
|
-
def members: () -> [ :observed, :args, :observes, :from_keys, :labels, :received ]
|
|
76
|
+
def self.members: () -> [ :observed, :args, :observes, :from_keys, :labels, :received, :transformed ]
|
|
77
|
+
|
|
78
|
+
def members: () -> [ :observed, :args, :observes, :from_keys, :labels, :received, :transformed ]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# A Data block's methods are its own, but rbs-inline reads only a class
|
|
82
|
+
# body, so they are written in one.
|
|
83
|
+
class Inputs
|
|
84
|
+
# : (?transformed: Hash[String, String], **untyped) -> void
|
|
85
|
+
def initialize: (?transformed: Hash[String, String], **untyped) -> void
|
|
77
86
|
end
|
|
78
87
|
|
|
79
88
|
# : (Place, String?) -> Place
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Generated from lib/nukadoko/parameter_types.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# The config's parameterTypes, read and handed to Pattern: each entry a
|
|
4
|
+
# name, a regexp, and an optional transformer. A shape the TypeScript
|
|
5
|
+
# engine's schema refuses is refused here with its words, so a project
|
|
6
|
+
# moves between the engines without a config that one of them takes and
|
|
7
|
+
# the other does not. Boundary: reading the entries; registering them and
|
|
8
|
+
# matching lines are Pattern's.
|
|
9
|
+
module Nukadoko
|
|
10
|
+
module Engine
|
|
11
|
+
module ParameterTypes
|
|
12
|
+
NAME: ::Regexp
|
|
13
|
+
|
|
14
|
+
KEYS: untyped
|
|
15
|
+
|
|
16
|
+
# : (untyped) -> void
|
|
17
|
+
def self.read: (untyped) -> void
|
|
18
|
+
|
|
19
|
+
# A value's kind in the words zod uses for it.
|
|
20
|
+
# : (untyped) -> String
|
|
21
|
+
def self.kind: (untyped) -> String
|
|
22
|
+
|
|
23
|
+
# : (String) -> bot
|
|
24
|
+
def self.invalid: (String) -> bot
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -42,7 +42,31 @@ module Nukadoko
|
|
|
42
42
|
|
|
43
43
|
NAMED: ::Regexp
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
BUILT_IN: Array[String]
|
|
46
|
+
|
|
47
|
+
# The registry every pattern of the loaded project reads: the built-in
|
|
48
|
+
# types, and the config's parameterTypes on top of them.
|
|
49
|
+
# : () -> Registry
|
|
50
|
+
def self.registry: () -> Registry
|
|
51
|
+
|
|
52
|
+
# Why the config's parameterTypes could not be registered, in the
|
|
53
|
+
# TypeScript engine's words, or nil. While it is set no pattern
|
|
54
|
+
# matches a line, as no pattern binds there: nuka check reports it
|
|
55
|
+
# once, as parameter-type-invalid, and a run under --no-check stops.
|
|
56
|
+
# : () -> String?
|
|
57
|
+
def self.collision: () -> String?
|
|
58
|
+
|
|
59
|
+
# The names of the config's parameter types that have a transformer,
|
|
60
|
+
# whose capture a claim cannot compare with.
|
|
61
|
+
# : () -> Array[String]
|
|
62
|
+
def self.transformed: () -> Array[String]
|
|
63
|
+
|
|
64
|
+
# Registers the config's parameterTypes: each a name, a regexp, and an
|
|
65
|
+
# optional transformer, given the groups the regexp captured. A type
|
|
66
|
+
# with no transformer gives the text the regexp matched, or its first
|
|
67
|
+
# group, as the JavaScript package does.
|
|
68
|
+
# : (Array[Hash[Symbol, untyped]]) -> void
|
|
69
|
+
def self.configure: (Array[Hash[Symbol, untyped]]) -> void
|
|
46
70
|
|
|
47
71
|
attr_reader source: untyped
|
|
48
72
|
|
|
@@ -200,6 +200,13 @@ module Nukadoko
|
|
|
200
200
|
# : (singleton(Step), Hash[Symbol, untyped], String, World, then_line: bool, at_line: Integer?, results: Array[untyped], origins: Hash[String, String]) { () -> [Hash[String, untyped], Hash[String, String]] } -> Hash[Symbol, untyped]
|
|
201
201
|
def execute: (singleton(Step), Hash[Symbol, untyped], String, World, then_line: bool, at_line: Integer?, results: Array[untyped], origins: Hash[String, String]) { () -> [ Hash[String, untyped], Hash[String, String] ] } -> Hash[Symbol, untyped]
|
|
202
202
|
|
|
203
|
+
# The args keys the line fills through a parameter type with a
|
|
204
|
+
# transformer, each with why a claim does not compare with it: code
|
|
205
|
+
# made the value, while the record would name the sentence. nuka check
|
|
206
|
+
# reports such a pattern; a run under --no-check agrees with it.
|
|
207
|
+
# : (untyped, Hash[String, String]) -> Hash[String, String]
|
|
208
|
+
def transformed_fills: (untyped, Hash[String, String]) -> Hash[String, String]
|
|
209
|
+
|
|
203
210
|
# A Then step's claims are judged on what it observed, or on its args
|
|
204
211
|
# when it reads nothing itself; any other step runs and returns.
|
|
205
212
|
# `step` is a step class whose observe or run its own file defines.
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
module Nukadoko
|
|
12
12
|
module Engine
|
|
13
13
|
module TraceActions
|
|
14
|
-
# Version 8 as the TypeScript engine measured it,
|
|
14
|
+
# Version 8 as the TypeScript engine measured it, version 9 as
|
|
15
|
+
# Playwright 1.63.0 writes it (the same fields and the same actions as
|
|
16
|
+
# version 8), and version 10 as
|
|
15
17
|
# Playwright 1.65.1 writes it for the Ruby client: the same `before`
|
|
16
18
|
# and `after` fields, with a number for `callId`.
|
|
17
19
|
KNOWN_VERSIONS: untyped
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nukadoko
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- meganemura
|
|
@@ -41,16 +41,16 @@ dependencies:
|
|
|
41
41
|
name: playwright-ruby-client
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
|
-
- -
|
|
44
|
+
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.
|
|
46
|
+
version: 1.63.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- -
|
|
51
|
+
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.
|
|
53
|
+
version: 1.63.0
|
|
54
54
|
executables:
|
|
55
55
|
- nuka
|
|
56
56
|
extensions: []
|
|
@@ -91,6 +91,7 @@ files:
|
|
|
91
91
|
- lib/nukadoko/literal.rb
|
|
92
92
|
- lib/nukadoko/measured.rb
|
|
93
93
|
- lib/nukadoko/order.rb
|
|
94
|
+
- lib/nukadoko/parameter_types.rb
|
|
94
95
|
- lib/nukadoko/parts.rb
|
|
95
96
|
- lib/nukadoko/pattern.rb
|
|
96
97
|
- lib/nukadoko/poll.rb
|
|
@@ -153,6 +154,7 @@ files:
|
|
|
153
154
|
- sig/generated/nukadoko/literal.rbs
|
|
154
155
|
- sig/generated/nukadoko/measured.rbs
|
|
155
156
|
- sig/generated/nukadoko/order.rbs
|
|
157
|
+
- sig/generated/nukadoko/parameter_types.rbs
|
|
156
158
|
- sig/generated/nukadoko/parts.rbs
|
|
157
159
|
- sig/generated/nukadoko/pattern.rbs
|
|
158
160
|
- sig/generated/nukadoko/poll.rbs
|