nukadoko 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +417 -0
  3. data/README.ja.md +62 -7
  4. data/README.md +19 -5
  5. data/exe/nuka +8 -0
  6. data/lib/nukadoko/aria_snapshot.rb +1008 -0
  7. data/lib/nukadoko/aria_tree.rb +150 -0
  8. data/lib/nukadoko/base.rb +294 -0
  9. data/lib/nukadoko/check.rb +669 -22
  10. data/lib/nukadoko/claim_check.rb +177 -0
  11. data/lib/nukadoko/claim_check_run.rb +293 -0
  12. data/lib/nukadoko/claim_line.rb +381 -0
  13. data/lib/nukadoko/claim_rules.rb +519 -0
  14. data/lib/nukadoko/claim_sides.rb +469 -0
  15. data/lib/nukadoko/claims.rb +576 -37
  16. data/lib/nukadoko/cli.rb +814 -22
  17. data/lib/nukadoko/codes.json +947 -0
  18. data/lib/nukadoko/codes.rb +19 -0
  19. data/lib/nukadoko/command.rb +214 -12
  20. data/lib/nukadoko/criteria.rb +172 -0
  21. data/lib/nukadoko/definition.rb +33 -41
  22. data/lib/nukadoko/env_check.rb +88 -0
  23. data/lib/nukadoko/features.rb +80 -10
  24. data/lib/nukadoko/fixtures.rb +329 -11
  25. data/lib/nukadoko/http_recording.rb +68 -0
  26. data/lib/nukadoko/init.rb +129 -0
  27. data/lib/nukadoko/js_json.rb +274 -0
  28. data/lib/nukadoko/js_pattern.rb +531 -0
  29. data/lib/nukadoko/judge.rb +221 -0
  30. data/lib/nukadoko/judgment_file.rb +78 -0
  31. data/lib/nukadoko/judgments.rb +256 -0
  32. data/lib/nukadoko/literal.rb +129 -0
  33. data/lib/nukadoko/measured.rb +105 -0
  34. data/lib/nukadoko/order.rb +84 -0
  35. data/lib/nukadoko/parts.rb +43 -22
  36. data/lib/nukadoko/pattern.rb +73 -3
  37. data/lib/nukadoko/poll.rb +21 -8
  38. data/lib/nukadoko/program.rb +105 -17
  39. data/lib/nukadoko/project_files.rb +17 -0
  40. data/lib/nukadoko/project_fixtures.rb +17 -2
  41. data/lib/nukadoko/project_program.rb +119 -0
  42. data/lib/nukadoko/report_allure.rb +751 -0
  43. data/lib/nukadoko/report_messages.rb +167 -0
  44. data/lib/nukadoko/report_run.rb +169 -0
  45. data/lib/nukadoko/run.rb +898 -91
  46. data/lib/nukadoko/run_record.rb +535 -0
  47. data/lib/nukadoko/scaffold.rb +1015 -0
  48. data/lib/nukadoko/schema.rb +120 -21
  49. data/lib/nukadoko/secrets.rb +375 -0
  50. data/lib/nukadoko/selection.rb +163 -0
  51. data/lib/nukadoko/signature.rb +4 -1
  52. data/lib/nukadoko/skill.rb +36 -0
  53. data/lib/nukadoko/spaces.rb +28 -0
  54. data/lib/nukadoko/step.rb +68 -21
  55. data/lib/nukadoko/summary.rb +662 -0
  56. data/lib/nukadoko/table.rb +34 -2
  57. data/lib/nukadoko/text_fit.rb +179 -0
  58. data/lib/nukadoko/trace.rb +244 -0
  59. data/lib/nukadoko/trace_actions.rb +116 -0
  60. data/lib/nukadoko/tree_passes.rb +122 -0
  61. data/lib/nukadoko/verdict.rb +128 -0
  62. data/lib/nukadoko/version.rb +2 -1
  63. data/lib/nukadoko/vocabulary.rb +6 -0
  64. data/lib/nukadoko/walk.rb +305 -0
  65. data/lib/nukadoko/walk_files.rb +473 -0
  66. data/lib/nukadoko/walk_step.rb +149 -0
  67. data/lib/nukadoko.rb +60 -2
  68. data/llms.txt +297 -0
  69. data/sig/generated/nukadoko/aria_snapshot.rbs +331 -0
  70. data/sig/generated/nukadoko/aria_tree.rbs +142 -0
  71. data/sig/generated/nukadoko/base.rbs +142 -0
  72. data/sig/generated/nukadoko/check.rbs +255 -0
  73. data/sig/generated/nukadoko/claim_check.rbs +118 -0
  74. data/sig/generated/nukadoko/claim_check_run.rbs +88 -0
  75. data/sig/generated/nukadoko/claim_line.rbs +158 -0
  76. data/sig/generated/nukadoko/claim_rules.rbs +172 -0
  77. data/sig/generated/nukadoko/claim_sides.rbs +207 -0
  78. data/sig/generated/nukadoko/claims.rbs +208 -0
  79. data/sig/generated/nukadoko/cli.rbs +182 -0
  80. data/sig/generated/nukadoko/codes.rbs +16 -0
  81. data/sig/generated/nukadoko/command.rbs +109 -0
  82. data/sig/generated/nukadoko/criteria.rbs +83 -0
  83. data/sig/generated/nukadoko/definition.rbs +30 -0
  84. data/sig/generated/nukadoko/env_check.rbs +34 -0
  85. data/sig/generated/nukadoko/features.rbs +101 -0
  86. data/sig/generated/nukadoko/fixtures.rbs +175 -0
  87. data/sig/generated/nukadoko/http_recording.rbs +29 -0
  88. data/sig/generated/nukadoko/init.rbs +64 -0
  89. data/sig/generated/nukadoko/js_json.rbs +109 -0
  90. data/sig/generated/nukadoko/js_pattern.rbs +194 -0
  91. data/sig/generated/nukadoko/judge.rbs +64 -0
  92. data/sig/generated/nukadoko/judgment_file.rbs +39 -0
  93. data/sig/generated/nukadoko/judgments.rbs +120 -0
  94. data/sig/generated/nukadoko/literal.rbs +71 -0
  95. data/sig/generated/nukadoko/measured.rbs +42 -0
  96. data/sig/generated/nukadoko/order.rbs +54 -0
  97. data/sig/generated/nukadoko/parts.rbs +35 -0
  98. data/sig/generated/nukadoko/pattern.rbs +62 -0
  99. data/sig/generated/nukadoko/poll.rbs +41 -0
  100. data/sig/generated/nukadoko/program.rbs +101 -0
  101. data/sig/generated/nukadoko/project_files.rbs +19 -0
  102. data/sig/generated/nukadoko/project_fixtures.rbs +57 -0
  103. data/sig/generated/nukadoko/project_program.rbs +55 -0
  104. data/sig/generated/nukadoko/report_allure.rbs +268 -0
  105. data/sig/generated/nukadoko/report_messages.rbs +68 -0
  106. data/sig/generated/nukadoko/report_run.rbs +102 -0
  107. data/sig/generated/nukadoko/run.rbs +264 -0
  108. data/sig/generated/nukadoko/run_record.rbs +175 -0
  109. data/sig/generated/nukadoko/scaffold.rbs +328 -0
  110. data/sig/generated/nukadoko/schema.rbs +155 -0
  111. data/sig/generated/nukadoko/secrets.rbs +172 -0
  112. data/sig/generated/nukadoko/selection.rbs +73 -0
  113. data/sig/generated/nukadoko/signature.rbs +17 -0
  114. data/sig/generated/nukadoko/skill.rbs +20 -0
  115. data/sig/generated/nukadoko/spaces.rbs +31 -0
  116. data/sig/generated/nukadoko/step.rbs +115 -0
  117. data/sig/generated/nukadoko/summary.rbs +204 -0
  118. data/sig/generated/nukadoko/table.rbs +43 -0
  119. data/sig/generated/nukadoko/text_fit.rbs +70 -0
  120. data/sig/generated/nukadoko/trace.rbs +127 -0
  121. data/sig/generated/nukadoko/trace_actions.rbs +40 -0
  122. data/sig/generated/nukadoko/tree_passes.rbs +48 -0
  123. data/sig/generated/nukadoko/verdict.rbs +56 -0
  124. data/sig/generated/nukadoko/version.rbs +5 -0
  125. data/sig/generated/nukadoko/vocabulary.rbs +25 -0
  126. data/sig/generated/nukadoko/walk.rbs +139 -0
  127. data/sig/generated/nukadoko/walk_files.rbs +189 -0
  128. data/sig/generated/nukadoko/walk_step.rbs +50 -0
  129. data/sig/generated/nukadoko.rbs +26 -0
  130. data/sig/nukadoko.rbs +5 -48
  131. data/skills/nukadoko/SKILL.md +120 -0
  132. data/skills/nukadoko/references/checking-steps.md +200 -0
  133. data/skills/nukadoko/references/diagnosing.md +200 -0
  134. data/skills/nukadoko/references/done.md +99 -0
  135. data/skills/nukadoko/references/evidence.md +124 -0
  136. data/skills/nukadoko/references/examples/cli.md +230 -0
  137. data/skills/nukadoko/references/examples/http-api.md +342 -0
  138. data/skills/nukadoko/references/examples/workflow.md +173 -0
  139. data/skills/nukadoko/references/exploring.md +184 -0
  140. data/skills/nukadoko/references/fixtures.md +198 -0
  141. data/skills/nukadoko/references/from-prose.md +51 -0
  142. data/skills/nukadoko/references/judgments.md +95 -0
  143. data/skills/nukadoko/references/maintenance.md +97 -0
  144. data/skills/nukadoko/references/merge-risk.md +74 -0
  145. data/skills/nukadoko/references/parts.md +152 -0
  146. data/skills/nukadoko/references/perturbed-worlds.md +109 -0
  147. data/skills/nukadoko/references/program.md +200 -0
  148. data/skills/nukadoko/references/reviewing.md +200 -0
  149. data/skills/nukadoko/references/running.md +200 -0
  150. data/skills/nukadoko/references/scenario-rules.md +188 -0
  151. data/skills/nukadoko/references/states.md +66 -0
  152. data/skills/nukadoko/references/step-files.md +200 -0
  153. data/skills/nukadoko/references/verdicts.md +200 -0
  154. data/skills/nukadoko/references/writing-steps.md +200 -0
  155. data/skills/nukadoko/references/writing-the-feature.md +165 -0
  156. data/skills/nukadoko/scripts/claude-code-verdict-hook.mjs +99 -0
  157. data/skills/nukadoko/scripts/merge-risk.jq +56 -0
  158. data/skills/nukadoko-verification/SKILL.md +263 -0
  159. metadata +133 -1
@@ -0,0 +1,127 @@
1
+ # Generated from lib/nukadoko/trace.rb with RBS::Inline
2
+
3
+ # The W3C trace context the engine puts on what a step sends to the world,
4
+ # and the program's log read back by it, as the TypeScript engine does it.
5
+ # Each step gets one trace id; each request to the world's origin, and
6
+ # each process run_command starts, gets a span id of its own under it. A
7
+ # line of program.log belongs to the step whose trace id it carries,
8
+ # wherever it appears: every trace id of one world starts with the same
9
+ # eight characters, so the id a line carries is the first place where
10
+ # those begin 32 hexadecimal ones, and no list of ids is needed to read it.
11
+ module Nukadoko
12
+ module Engine
13
+ module Trace
14
+ PREFIX_LENGTH: ::Integer
15
+
16
+ ID_LENGTH: ::Integer
17
+
18
+ MAX_SPANS: ::Integer
19
+
20
+ # : () -> String
21
+ def self.new_prefix: () -> String
22
+
23
+ # W3C reserves an id of all zeros as invalid, so one is drawn again.
24
+ # : (String) -> String
25
+ def self.new_id: (String) -> String
26
+
27
+ # : () -> String
28
+ def self.new_span: () -> String
29
+
30
+ # : (String, String) -> String
31
+ def self.traceparent: (String, String) -> String
32
+
33
+ # The trace id of the world `prefix` names that `line` carries, or nil.
34
+ # : (String, String) -> String?
35
+ def self.id_in: (String, String) -> String?
36
+
37
+ # : (URI::Generic) -> String
38
+ def self.origin: (URI::Generic) -> String
39
+
40
+ # Only the world's origin gets the header: a third party's server may
41
+ # answer a header it did not expect differently. A world at localhost
42
+ # also answers at each name below localhost on the same port.
43
+ # : (untyped, untyped) -> bool
44
+ def self.stamps?: (untyped, untyped) -> bool
45
+
46
+ # The step that runs now, kept per thread as the processes are.
47
+ # : () -> Boundary?
48
+ def self.current: () -> Boundary?
49
+
50
+ # : [T] (Boundary) { () -> T } -> T
51
+ def self.within: [T] (Boundary) { () -> T } -> T
52
+
53
+ # One step's trace: what it stamped, and when it last did.
54
+ class Boundary
55
+ attr_reader trace_id: String
56
+
57
+ attr_reader origin: String
58
+
59
+ attr_reader stamped: Integer
60
+
61
+ attr_reader spans: Array[String]
62
+
63
+ attr_reader process_spans: Array[String]
64
+
65
+ attr_reader last_stamp_at: Float?
66
+
67
+ # : (String, String) -> void
68
+ def initialize: (String, String) -> void
69
+
70
+ # The traceparent a request to `url` goes out with, or nil when it
71
+ # is not the world's.
72
+ # : (untyped) -> String?
73
+ def stamp: (untyped) -> String?
74
+
75
+ # A process's TRACEPARENT is not a stamped request: nothing waits
76
+ # for the request it may send, but the log is read a little longer.
77
+ # : () -> String
78
+ def process_traceparent: () -> String
79
+ end
80
+
81
+ # program.log read forward as the steps run: each step takes the
82
+ # complete lines written since the last step read, keeps those that
83
+ # carry its trace id, and, when it stamped anything, waits until the
84
+ # log has been quiet for 30 ms (at most 300 ms) for lines still on
85
+ # their way.
86
+ class Log
87
+ SLICE_FILE: ::String
88
+
89
+ LATE_FILE: ::String
90
+
91
+ QUIET: ::Float
92
+
93
+ SETTLE: ::Float
94
+
95
+ POLL: ::Float
96
+
97
+ KEPT: untyped
98
+
99
+ attr_reader path: String
100
+
101
+ attr_reader prefix: String
102
+
103
+ # : (String, String) -> void
104
+ def initialize: (String, String) -> void
105
+
106
+ # : (String, Boundary) -> Hash[Symbol, untyped]
107
+ def slice: (String, Boundary) -> Hash[Symbol, untyped]
108
+
109
+ # Once the world stopped: how many lines carry a trace id of the
110
+ # world, and each step's lines that its slice did not read, written
111
+ # beside its record. `steps` maps a trace id to [lines read, dir].
112
+ # : (Hash[String, Array[untyped]]) -> Hash[Symbol, untyped]
113
+ def late: (Hash[String, Array[untyped]]) -> Hash[Symbol, untyped]
114
+
115
+ private
116
+
117
+ # : () -> Float
118
+ def now: () -> Float
119
+
120
+ # A line still being written, after the last newline, is left for
121
+ # the next read.
122
+ # : () { (String) -> void } -> void
123
+ def each_new_line: () { (String) -> void } -> void
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,40 @@
1
+ # Generated from lib/nukadoko/trace_actions.rb with RBS::Inline
2
+
3
+ # A step's trace.zip read back into the step record's `actions`: every
4
+ # Playwright call the step made through its page, as the TypeScript engine
5
+ # lists them. Only `trace.trace` inside the zip is read, by walking the
6
+ # zip's central directory, so no zip library is needed. A trace that cannot
7
+ # be read gives no actions rather than failing the step: measuring never
8
+ # breaks the execution. A trace format version this build has not measured
9
+ # gives none either, since guessing at its shape would turn an unread
10
+ # format into a record.
11
+ module Nukadoko
12
+ module Engine
13
+ module TraceActions
14
+ # Version 8 as the TypeScript engine measured it, and version 10 as
15
+ # Playwright 1.65.1 writes it for the Ruby client: the same `before`
16
+ # and `after` fields, with a number for `callId`.
17
+ KNOWN_VERSIONS: untyped
18
+
19
+ MAX_ACTIONS: ::Integer
20
+
21
+ INTERNAL_WAIT: ::String
22
+
23
+ JUDGED_VIEW_GROUP: ::String
24
+
25
+ # { actions:, truncated: } for the trace at `path`, or nil when there
26
+ # is none.
27
+ # : (String) -> Hash[Symbol, untyped]?
28
+ def self?.read: (String) -> Hash[Symbol, untyped]?
29
+
30
+ # : (String) -> Hash[Symbol, untyped]
31
+ def self?.parse: (String) -> Hash[Symbol, untyped]
32
+
33
+ # : (Hash[String, untyped], Hash[String, untyped], Hash[String, untyped]) -> Hash[Symbol, untyped]
34
+ def self?.action: (Hash[String, untyped], Hash[String, untyped], Hash[String, untyped]) -> Hash[Symbol, untyped]
35
+
36
+ # : (String, String) -> String?
37
+ def self?.zip_entry: (String, String) -> String?
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ # Generated from lib/nukadoko/tree_passes.rb with RBS::Inline
2
+
3
+ # The base and the old world's passes of a `--base` run. Each row plans the
4
+ # cells its verdict needs from its head cells (RunRecord.planned_world_cells),
5
+ # and each tree runs its planned rows one environment at a time, in a
6
+ # process of its own started in the tree: a step file is loaded into the
7
+ # process that runs it, and head's steps are already loaded in this one.
8
+ # The pass writes its step records into the head run's directory, and its
9
+ # executions and cells come back as JSON. A cell whose pass did not run
10
+ # says why.
11
+ module Nukadoko
12
+ module Engine
13
+ class TreePasses
14
+ EXE: untyped
15
+
16
+ LIB: untyped
17
+
18
+ # `judged_by` says why head's passing executions of a row judged no
19
+ # claim in Then position (Run.then_judged_by).
20
+ # : (Base, Array[Scenario], Hash[Scenario, Array[Hash[Symbol, untyped]]], Array[Environment], String, IO, ?^(Scenario) -> untyped, ?head_root: String) -> void
21
+ def initialize: (Base, Array[Scenario], Hash[Scenario, Array[Hash[Symbol, untyped]]], Array[Environment], String, IO, ?^(Scenario) -> untyped, ?head_root: String) -> void
22
+
23
+ # The worlds each tree's passes started, as run.json names them.
24
+ attr_reader worlds: untyped
25
+
26
+ # Appends each tree execution to `executions`, and returns each row's
27
+ # base and old cells by its scenario.
28
+ # : (Array[Hash[Symbol, untyped]]) -> Hash[Scenario, Array[Hash[Symbol, untyped]]]
29
+ def call: (Array[Hash[Symbol, untyped]]) -> Hash[Scenario, Array[Hash[Symbol, untyped]]]
30
+
31
+ private
32
+
33
+ # : (Scenario) -> Hash[Symbol, Array[String]]
34
+ def plan: (Scenario) -> Hash[Symbol, Array[String]]
35
+
36
+ # Where a tree runs a head row: at its own place in the base tree,
37
+ # which holds head's features, and at the ref's place in the old one.
38
+ # : (String, Scenario) -> Array[untyped]
39
+ def place: (String, Scenario) -> Array[untyped]
40
+
41
+ # : (Scenario, String, Environment, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
42
+ def cell: (Scenario, String, Environment, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
43
+
44
+ # : (String, String, Environment, Array[Scenario]) -> Hash[Symbol, untyped]
45
+ def run_tree: (String, String, Environment, Array[Scenario]) -> Hash[Symbol, untyped]
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,56 @@
1
+ # Generated from lib/nukadoko/verdict.rb with RBS::Inline
2
+
3
+ # `nuka verdict`: whether the newest run that ended judged the working tree
4
+ # as it is now and left nothing red. It reads run.json files and one git
5
+ # tree id, and never starts a run. A run's red findings are relayed only
6
+ # when it judged this tree: a red row of an earlier tree may be fixed
7
+ # already, and a green one may not hold now.
8
+ module Nukadoko
9
+ module Engine
10
+ class Verdict
11
+ FIXES: untyped
12
+
13
+ attr_reader judged: String
14
+
15
+ attr_reader findings: Array[Hash[Symbol, untyped]]
16
+
17
+ attr_reader newest: Hash[Symbol, untyped]?
18
+
19
+ attr_reader working_tree: String?
20
+
21
+ # : (String) -> void
22
+ def initialize: (String) -> void
23
+
24
+ # The run with the latest start; a run.json whose run_id is not its
25
+ # directory's name, or that does not parse, is no run.
26
+ # : (String) -> Hash[Symbol, untyped]?
27
+ def self.newest_run: (String) -> Hash[Symbol, untyped]?
28
+
29
+ # : () -> bool
30
+ def open?: () -> bool
31
+
32
+ # : () -> Hash[Symbol, untyped]
33
+ def envelope_fields: () -> Hash[Symbol, untyped]
34
+
35
+ # : () -> String
36
+ def headline: () -> String
37
+
38
+ private
39
+
40
+ # : () -> String?
41
+ def recorded: () -> String?
42
+
43
+ # : () -> String
44
+ def again: () -> String
45
+
46
+ # : () -> [String, Array[Hash[Symbol, untyped]]]
47
+ def judge: () -> [ String, Array[Hash[Symbol, untyped]] ]
48
+
49
+ # : (String, String) -> Hash[Symbol, untyped]
50
+ def note: (String, String) -> Hash[Symbol, untyped]
51
+
52
+ # : () -> String
53
+ def stale_message: () -> String
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/nukadoko/version.rb with RBS::Inline
2
+
3
+ module Nukadoko
4
+ VERSION: ::String
5
+ end
@@ -0,0 +1,25 @@
1
+ # Generated from lib/nukadoko/vocabulary.rb with RBS::Inline
2
+
3
+ # What `nuka steps` and `nuka describe` print: each step as data, in the
4
+ # fields the TypeScript engine prints, so an agent picks a step from either
5
+ # engine's vocabulary without opening a file.
6
+ module Nukadoko
7
+ module Vocabulary
8
+ BROWSER: untyped
9
+
10
+ # : (singleton(Step), String) -> Hash[Symbol, untyped]
11
+ def self.entry: (singleton(Step), String) -> Hash[Symbol, untyped]
12
+
13
+ # : (singleton(Step), String) -> Hash[Symbol, untyped]
14
+ def self.describe: (singleton(Step), String) -> Hash[Symbol, untyped]
15
+
16
+ # : (singleton(Step)) -> Hash[untyped, untyped]?
17
+ def self.from: (singleton(Step)) -> Hash[untyped, untyped]?
18
+
19
+ # : (singleton(Step)) -> String
20
+ def self.text: (singleton(Step)) -> String
21
+
22
+ # : (Hash[Symbol, untyped]) -> String
23
+ def self.claim_text: (Hash[Symbol, untyped]) -> String
24
+ end
25
+ end
@@ -0,0 +1,139 @@
1
+ # Generated from lib/nukadoko/walk.rb with RBS::Inline
2
+
3
+ # A walk of `nuka run --step` as data: the states one walk passes through,
4
+ # the one transition the run applies to move it, and what one `nuka step`
5
+ # call does next and prints, in the TypeScript engine's shape
6
+ # (src/run/walk.ts). Pure: no file system, no clock, no process. WalkFiles
7
+ # reads and writes the files both sides share, and Run holds the step that
8
+ # pauses.
9
+ #
10
+ # One walk is one execution of one scenario. Pause k comes after step k, so
11
+ # a pause number names the step a person was shown, and an answer names the
12
+ # walk and the pause it answers: an answer to a pause nobody was shown, or
13
+ # to an earlier walk the same command once answered, is refused, never
14
+ # applied to whichever pause is open. Pause numbers only increase, and
15
+ # `ended` absorbs every later event, so a replayed answer or a late signal
16
+ # cannot move a walk backwards.
17
+ #
18
+ # A state is a hash with symbol keys, as walk.json holds it once parsed:
19
+ # `state` is starting, running (with `after`), paused (with `pause`), or
20
+ # ended (with `end`, `ended_at`, and `reached`).
21
+ module Nukadoko
22
+ module Engine
23
+ module Walk
24
+ # A transition the walk's table does not have: a bug in the run that
25
+ # applies events, never something a reader of walk.json can cause.
26
+ class TransitionError < StandardError
27
+ end
28
+
29
+ START_KEYS: untyped
30
+
31
+ RUN_KEYS: untyped
32
+
33
+ # One line on what failed the scenario at a pause. The Ruby engine has
34
+ # no AfterStep hooks, but a pause read from a TypeScript walk can
35
+ # name one.
36
+ # : (Hash[Symbol, untyped]) -> String
37
+ def self?.failure_text: (Hash[Symbol, untyped]) -> String
38
+
39
+ # The walk's first state, before the run knows its scenario.
40
+ # : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
41
+ def self?.start: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
42
+
43
+ # One transition:
44
+ #
45
+ # starting --begun--> running(after 0) --paused(k > after)--> paused(k)
46
+ # paused(k) --answered(k)--> running(after k)
47
+ # any live state --ended--> ended, which absorbs every later event
48
+ #
49
+ # Raises TransitionError for any other pair.
50
+ # : (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
51
+ def self?.advance: (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
52
+
53
+ # The one spelling of an answer, for the do lines and the refusals.
54
+ # : (Integer, Integer, String) -> String
55
+ def self?.answer_command: (Integer, Integer, String) -> String
56
+
57
+ # The one spelling of a wait for one walk.
58
+ # : (Integer) -> String
59
+ def self?.wait_command: (Integer) -> String
60
+
61
+ # The command a walk that ended has to be started with again.
62
+ # : (String) -> String
63
+ def self?.restart_command: (String) -> String
64
+
65
+ # walk.json as `nuka step` reads it. A walk whose process is gone
66
+ # without recording its end is `gone`: killed, or crashed. `none`: no
67
+ # walk was ever recorded in the project.
68
+ # : (Hash[Symbol, untyped]?, ^(Integer) -> bool) -> Hash[Symbol, untyped]
69
+ def self?.see: (Hash[Symbol, untyped]?, ^(Integer) -> bool) -> Hash[Symbol, untyped]
70
+
71
+ # : (Hash[Symbol, untyped]) -> Integer
72
+ def self?.number_of: (Hash[Symbol, untyped]) -> Integer
73
+
74
+ # The walk one `nuka step` call is about, fixed when the call starts.
75
+ # A call is { kind: "wait", walk: Integer? } or { kind: "answer",
76
+ # walk:, pause:, answer: }. A wait that names no walk is about the
77
+ # newest walk until some `nuka step` call has reported how that walk
78
+ # ended, and about the next walk after that, which a `nuka run
79
+ # --step` started just before the wait may not have recorded yet. So
80
+ # a walk that ended before anyone looked is still reported, and an
81
+ # end is not reported in place of the walk that follows it.
82
+ # : (Hash[Symbol, untyped], Hash[Symbol, untyped], ^(Integer) -> bool) -> Integer
83
+ def self?.call_target: (Hash[Symbol, untyped], Hash[Symbol, untyped], ^(Integer) -> bool) -> Integer
84
+
85
+ # How a walk stands, after its number: "ended: interrupted by SIGTERM,
86
+ # exit 143", "is at pause 2".
87
+ # : (Hash[Symbol, untyped]) -> String
88
+ def self?.standing: (Hash[Symbol, untyped]) -> String
89
+
90
+ # What follows "ended" in a walk's standing.
91
+ # : (Hash[Symbol, untyped]) -> String
92
+ def self?.how_ended: (Hash[Symbol, untyped]) -> String
93
+
94
+ # The message of a wait that found no walk to report before its time
95
+ # ran out: which walk it waited for, and the last walk there is and
96
+ # how it stands, so the caller is not told that nothing ran.
97
+ # : (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped]) -> String
98
+ def self?.nothing_started_message: (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped]) -> String
99
+
100
+ # : (Hash[Symbol, untyped]) -> String
101
+ def self?.where_text: (Hash[Symbol, untyped]) -> String
102
+
103
+ # Where the walk walk.json holds stands, for a refusal that names it.
104
+ # : (Hash[Symbol, untyped]) -> String
105
+ def self?.current_text: (Hash[Symbol, untyped]) -> String
106
+
107
+ # A call that names a walk walk.json no longer holds, or does not hold
108
+ # yet. The do is a wait for the walk there is, which answers nothing.
109
+ # : (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
110
+ def self?.not_current: (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
111
+
112
+ # What one `nuka step` call does next, from walk.json as it stands now
113
+ # (`seen`), the walk the call is about (`target`), and the answers
114
+ # that walk's run directory holds, by pause. Pure, so that repeating a
115
+ # call is a property test: an answer already given the same way
116
+ # reports where the walk went from it, and writes nothing again.
117
+ # : (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped], Hash[Integer, String]) -> Hash[Symbol, untyped]
118
+ def self?.decide: (Hash[Symbol, untyped], Integer, Hash[Symbol, untyped], Hash[Integer, String]) -> Hash[Symbol, untyped]
119
+
120
+ # : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
121
+ def self?.run_fields: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
122
+
123
+ # What `nuka step` prints beside the envelope's head: its exit code,
124
+ # its findings, and its fields. 0 for a walk paused, starting,
125
+ # running, or ended green; 1 for one paused where its scenario
126
+ # failed, ended red, interrupted, or gone. A walk starting or running
127
+ # is one the call's wait ran out on: the call itself is then the
128
+ # `do`, since repeating it is safe.
129
+ # : (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
130
+ def self?.report: (Hash[Symbol, untyped], Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
131
+
132
+ # The lines `nuka run --step` writes on stderr at a pause of walk
133
+ # `walk`, outside `--json`: the step, what failed when the scenario
134
+ # failed there, and the answers.
135
+ # : (Integer, Hash[Symbol, untyped]) -> String
136
+ def self?.pause_lines: (Integer, Hash[Symbol, untyped]) -> String
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,189 @@
1
+ # Generated from lib/nukadoko/walk_files.rb with RBS::Inline
2
+
3
+ # The files a walk of `nuka run --step` and `nuka step` share, read and
4
+ # written from both sides, in the TypeScript engine's layout
5
+ # (src/run/walk-files.ts), so either engine's `nuka step` answers either
6
+ # engine's walk. Nothing else names these files, and nothing here decides
7
+ # anything: Walk says what a state becomes and what a call does next, Run
8
+ # says when a step is done, and the CLI prints.
9
+ #
10
+ # Each file has one writer, so no write needs a lock of its own:
11
+ #
12
+ # .nukadoko/walk.lock/<n> the run of walk n, created exclusively, holding its pid, then `released`
13
+ # .nukadoko/walk.json the run, replaced whole (written aside, then renamed)
14
+ # <run_dir>/answers/<n>.json nuka step, created exclusively, never rewritten
15
+ # <run_dir>/pauses/<n>/ the run: the views, and the open page's requests
16
+ # .nukadoko/walks-reported/<n> nuka step, created exclusively once it printed how walk n ended
17
+ #
18
+ # A process that holds the lock and is gone (a crash, a SIGKILL) leaves a
19
+ # walk.json that is not ended and a pid that is not alive: a reader sees the
20
+ # walk as gone, and the next `nuka run --step` takes the lock over. A pid
21
+ # check, not a lease a process renews: it needs no clock of its own.
22
+ module Nukadoko
23
+ module Engine
24
+ module WalkFiles
25
+ LOCK_DIR: ::String
26
+
27
+ RELEASED: ::String
28
+
29
+ STATE_FILE: ::String
30
+
31
+ REPORTED_DIR: ::String
32
+
33
+ POLL: ::Float
34
+
35
+ STATES: untyped
36
+
37
+ # The run's side of one walk.
38
+ class Handle
39
+ attr_reader number: untyped
40
+
41
+ # : (String, String, Integer, Hash[Symbol, untyped], (^(String) -> void)?) -> void
42
+ def initialize: (String, String, Integer, Hash[Symbol, untyped], (^(String) -> void)?) -> void
43
+
44
+ # The run has its directory and its one scenario.
45
+ # : (Hash[Symbol, untyped]) -> void
46
+ def begin: (Hash[Symbol, untyped]) -> void
47
+
48
+ # Writes the pause and waits for its answer. `hold` takes the pause's
49
+ # directory and the path the run records it as, and returns the
50
+ # views of the open page.
51
+ # : (Hash[Symbol, untyped]) { (String, String) -> Array[Hash[Symbol, untyped]] } -> String
52
+ def pause_after: (Hash[Symbol, untyped]) { (String, String) -> Array[Hash[Symbol, untyped]] } -> String
53
+
54
+ # run.json's `walk`: each pause so far, and its answer. It names only
55
+ # files that are there when it is written.
56
+ # : () -> Hash[Symbol, untyped]
57
+ def record: () -> Hash[Symbol, untyped]
58
+
59
+ # Records how the walk ended and releases the lock. The first call
60
+ # wins: a signal's cleanup and the run's own end can both reach it.
61
+ # : (Hash[Symbol, untyped]) -> void
62
+ def end: (Hash[Symbol, untyped]) -> void
63
+
64
+ private
65
+
66
+ # : (Hash[Symbol, untyped]) -> void
67
+ def apply: (Hash[Symbol, untyped]) -> void
68
+ end
69
+
70
+ # : () -> String
71
+ def self?.now: () -> String
72
+
73
+ # Whether `pid` is a live process. EPERM is a process this one may
74
+ # not signal, which is alive.
75
+ # : (Integer) -> bool
76
+ def self?.alive?: (Integer) -> bool
77
+
78
+ # : (String) -> String
79
+ def self?.state_dir: (String) -> String
80
+
81
+ # : (String, String) -> String
82
+ def self?.answers_dir: (String, String) -> String
83
+
84
+ # : (String, String) -> void
85
+ def self?.replace_file: (String, String) -> void
86
+
87
+ # walk.json as one read found it: { state: } (nil for no file), or
88
+ # { unreadable: } with why. walk.json has one writer, so a reader
89
+ # checks only the fields every state carries and trusts the rest.
90
+ # : (String) -> Hash[Symbol, untyped]
91
+ def self?.read_state: (String) -> Hash[Symbol, untyped]
92
+
93
+ # The whole-number names in a directory, and none when it is missing.
94
+ # : (String) -> Array[Integer]
95
+ def self?.numbered: (String) -> Array[Integer]
96
+
97
+ # One past every walk this project recorded, in walk.json or as a
98
+ # reported end, so a walk.json lost cannot give a new walk the number
99
+ # of one whose end a `nuka step` call already printed.
100
+ # : (String) -> Integer
101
+ def self?.highest_recorded: (String) -> Integer
102
+
103
+ # The highest lock file and its holder: a pid, "released", or nil for
104
+ # a file that holds neither. Only a number below the highest is ever
105
+ # removed, so a file gone between the listing and the read means a
106
+ # higher one exists: list again.
107
+ # : (String) -> Hash[Symbol, untyped]?
108
+ def self?.lock_top: (String) -> Hash[Symbol, untyped]?
109
+
110
+ # Creates `target` with `text` only when it does not exist. A link is
111
+ # exclusive, and the file appears with its whole text: a process
112
+ # killed between an exclusive create and its write would leave an
113
+ # empty lock no reader could tell from one being written.
114
+ # : (String, String) -> bool
115
+ def self?.link_whole: (String, String) -> bool
116
+
117
+ # : (String) -> void
118
+ def self?.remove_quietly: (String) -> void
119
+
120
+ # The pid of a live process, not this one, that holds a lock file
121
+ # below `walk`, or nil.
122
+ # : (String, Integer) -> Integer?
123
+ def self?.live_holder_below: (String, Integer) -> Integer?
124
+
125
+ # The lock is a directory with one file per walk that took it, named
126
+ # by the walk's number; the highest number holds it. A run takes the
127
+ # lock by creating the next number, so it never removes a file
128
+ # another process may hold: of two runs that find the same holder
129
+ # dead or released, only one creates the next number. A file is
130
+ # removed only once a higher one exists, and only by the process that
131
+ # created that higher one, or by its own creator giving way.
132
+ # : (String) -> Hash[Symbol, untyped]
133
+ def self?.take_lock: (String) -> Hash[Symbol, untyped]
134
+
135
+ # The file stays, so the highest number never goes back down; it says
136
+ # `released`, which the next run takes over like a dead pid.
137
+ # : (String, Integer) -> void
138
+ def self?.release_lock: (String, Integer) -> void
139
+
140
+ # An answer file is created exclusively and written in one call, so a
141
+ # reader can catch it empty for a moment: that reads as not answered
142
+ # yet, and the next poll reads it whole.
143
+ # : (String) -> Hash[Symbol, String]?
144
+ def self?.read_answer: (String) -> Hash[Symbol, String]?
145
+
146
+ # The answer at `path`, once `nuka step` has written it.
147
+ # : (String) -> Hash[Symbol, String]
148
+ def self?.wait_answer: (String) -> Hash[Symbol, String]
149
+
150
+ # Starts the run's side of a walk: takes the lock, which numbers the
151
+ # walk one past every walk recorded, and writes it as starting. A
152
+ # Handle, or { refused: } with why. `announce` gets the lines of each
153
+ # pause, outside --json.
154
+ # : (String, String, ?announce: (^(String) -> void)?) -> (Handle | Hash[Symbol, untyped])
155
+ def self?.open: (String, String, ?announce: (^(String) -> void)?) -> (Handle | Hash[Symbol, untyped])
156
+
157
+ # The run directory of the walk that is live now, relative to the
158
+ # project root: a walk running or paused whose pid is alive, nil for
159
+ # none. A walk still starting has no run directory yet, so for it
160
+ # "starting" is returned. `nuka clean` keeps what this names.
161
+ # : (String) -> Hash[Symbol, untyped]?
162
+ def self?.live_run: (String) -> Hash[Symbol, untyped]?
163
+
164
+ # : (String, Hash[Symbol, untyped], Integer) -> Hash[Integer, String]
165
+ def self?.answers_of: (String, Hash[Symbol, untyped], Integer) -> Hash[Integer, String]
166
+
167
+ # One empty file per walk whose end a `nuka step` call printed.
168
+ # Created exclusively, so two calls that print the same end leave one
169
+ # file.
170
+ # : (String, Integer) -> bool
171
+ def self?.end_reported?: (String, Integer) -> bool
172
+
173
+ # : (String, Integer) -> void
174
+ def self?.mark_end_reported: (String, Integer) -> void
175
+
176
+ # : (String, String, Integer, String) -> void
177
+ def self?.write_answer: (String, String, Integer, String) -> void
178
+
179
+ # One `nuka step` call: reads walk.json until the walk reaches a state
180
+ # the call can report, writing the call's answer once when the walk
181
+ # waits at its pause. Repeating a call is safe. `timeout` (seconds)
182
+ # bounds the wait: a walk still running then is reported as running,
183
+ # with the call itself as its `do`, and a wait that never found its
184
+ # walk is refused as walk-not-found.
185
+ # : (String, Hash[Symbol, untyped], Numeric, ?alive: ^(Integer) -> bool) -> Hash[Symbol, untyped]
186
+ def self?.step_call: (String, Hash[Symbol, untyped], Numeric, ?alive: ^(Integer) -> bool) -> Hash[Symbol, untyped]
187
+ end
188
+ end
189
+ end