nukadoko 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +553 -3
  3. data/README.ja.md +22 -6
  4. data/README.md +13 -7
  5. data/docs/ci.ja.md +542 -0
  6. data/docs/ci.md +635 -0
  7. data/docs/commands.ja.md +1524 -0
  8. data/docs/commands.md +1281 -0
  9. data/docs/engines.json +19 -0
  10. data/docs/execution-events.ja.md +336 -0
  11. data/docs/execution-events.md +423 -0
  12. data/docs/glossary.json +1348 -0
  13. data/docs/guide.ja.md +733 -0
  14. data/docs/guide.md +815 -0
  15. data/docs/intent.ja.md +133 -0
  16. data/docs/intent.md +156 -0
  17. data/docs/layout.ja.md +442 -0
  18. data/docs/layout.md +399 -0
  19. data/docs/releasing.ja.md +186 -0
  20. data/docs/releasing.md +237 -0
  21. data/docs/ruby/reference.ja.md +302 -0
  22. data/docs/ruby/reference.md +368 -0
  23. data/docs/spec.ja.md +8916 -0
  24. data/docs/spec.md +11250 -0
  25. data/docs/tutorial.ja.md +451 -0
  26. data/docs/tutorial.md +458 -0
  27. data/docs/typescript/adopting.ja.md +231 -0
  28. data/docs/typescript/adopting.md +251 -0
  29. data/docs/typescript/doors.ja.md +301 -0
  30. data/docs/typescript/doors.md +329 -0
  31. data/docs/typescript/migration-playwright-test.ja.md +189 -0
  32. data/docs/typescript/migration-playwright-test.md +212 -0
  33. data/docs/typescript/migration.ja.md +391 -0
  34. data/docs/typescript/migration.md +505 -0
  35. data/docs/typescript/reference.ja.md +176 -0
  36. data/docs/typescript/reference.md +197 -0
  37. data/docs/typescript/upgrading.ja.md +1774 -0
  38. data/docs/typescript/upgrading.md +2224 -0
  39. data/docs/web-app.ja.md +627 -0
  40. data/docs/web-app.md +659 -0
  41. data/docs/writing-scenarios.ja.md +544 -0
  42. data/docs/writing-scenarios.md +563 -0
  43. data/lib/nukadoko/base.rb +12 -5
  44. data/lib/nukadoko/changed_files.rb +95 -0
  45. data/lib/nukadoko/check.rb +459 -51
  46. data/lib/nukadoko/claim_drops.rb +271 -0
  47. data/lib/nukadoko/claim_line.rb +24 -4
  48. data/lib/nukadoko/claim_rules.rb +143 -1
  49. data/lib/nukadoko/claim_sides.rb +157 -9
  50. data/lib/nukadoko/cli.rb +403 -50
  51. data/lib/nukadoko/codes.json +246 -21
  52. data/lib/nukadoko/codes.rb +21 -4
  53. data/lib/nukadoko/command.rb +120 -13
  54. data/lib/nukadoko/command_help.rb +128 -0
  55. data/lib/nukadoko/compat.rb +469 -0
  56. data/lib/nukadoko/criteria.rb +1 -1
  57. data/lib/nukadoko/definition.rb +157 -7
  58. data/lib/nukadoko/error_frames.rb +6 -3
  59. data/lib/nukadoko/events/count.rb +146 -0
  60. data/lib/nukadoko/events/counted.rb +114 -0
  61. data/lib/nukadoko/events/format.rb +257 -0
  62. data/lib/nukadoko/events/lists.rb +154 -0
  63. data/lib/nukadoko/events/path.rb +285 -0
  64. data/lib/nukadoko/events/read.rb +284 -0
  65. data/lib/nukadoko/events/reader.rb +490 -0
  66. data/lib/nukadoko/events/selection.rb +252 -0
  67. data/lib/nukadoko/events/tally.rb +438 -0
  68. data/lib/nukadoko/features.rb +2 -2
  69. data/lib/nukadoko/fixtures.rb +160 -35
  70. data/lib/nukadoko/http_recording.rb +6 -2
  71. data/lib/nukadoko/intent.rb +364 -0
  72. data/lib/nukadoko/intent_file.rb +81 -0
  73. data/lib/nukadoko/intent_view.rb +190 -0
  74. data/lib/nukadoko/js_json.rb +2 -1
  75. data/lib/nukadoko/judge.rb +2 -2
  76. data/lib/nukadoko/judgment_file.rb +22 -1
  77. data/lib/nukadoko/judgments.rb +33 -3
  78. data/lib/nukadoko/measure_mcp.rb +202 -0
  79. data/lib/nukadoko/parts.rb +8 -2
  80. data/lib/nukadoko/path_view.rb +252 -0
  81. data/lib/nukadoko/place_rows.rb +161 -0
  82. data/lib/nukadoko/program.rb +1265 -51
  83. data/lib/nukadoko/program_log.rb +122 -0
  84. data/lib/nukadoko/program_shape.rb +385 -0
  85. data/lib/nukadoko/project_fixtures.rb +43 -10
  86. data/lib/nukadoko/project_program.rb +5 -4
  87. data/lib/nukadoko/repeated_prefix.rb +310 -0
  88. data/lib/nukadoko/report_run.rb +3 -3
  89. data/lib/nukadoko/run.rb +1156 -159
  90. data/lib/nukadoko/run_record.rb +70 -46
  91. data/lib/nukadoko/scaffold.rb +24 -6
  92. data/lib/nukadoko/schema.rb +15 -2
  93. data/lib/nukadoko/secrets.rb +55 -5
  94. data/lib/nukadoko/states.rb +478 -0
  95. data/lib/nukadoko/step.rb +71 -2
  96. data/lib/nukadoko/step_fixtures.rb +52 -3
  97. data/lib/nukadoko/summary.rb +803 -30
  98. data/lib/nukadoko/table.rb +4 -2
  99. data/lib/nukadoko/text_fit.rb +20 -7
  100. data/lib/nukadoko/trace.rb +152 -45
  101. data/lib/nukadoko/tree_passes.rb +95 -33
  102. data/lib/nukadoko/underneath.rb +311 -0
  103. data/lib/nukadoko/verdict.rb +18 -1
  104. data/lib/nukadoko/version.rb +1 -1
  105. data/lib/nukadoko/vocabulary.rb +166 -23
  106. data/lib/nukadoko/walk.rb +2 -2
  107. data/lib/nukadoko/walk_step.rb +1 -1
  108. data/lib/nukadoko.rb +23 -0
  109. data/llms.txt +42 -35
  110. data/sig/generated/nukadoko/base.rbs +4 -4
  111. data/sig/generated/nukadoko/changed_files.rbs +42 -0
  112. data/sig/generated/nukadoko/check.rbs +147 -10
  113. data/sig/generated/nukadoko/claim_drops.rbs +135 -0
  114. data/sig/generated/nukadoko/claim_line.rbs +11 -0
  115. data/sig/generated/nukadoko/claim_rules.rbs +49 -4
  116. data/sig/generated/nukadoko/claim_sides.rbs +63 -12
  117. data/sig/generated/nukadoko/cli.rbs +80 -7
  118. data/sig/generated/nukadoko/codes.rbs +19 -4
  119. data/sig/generated/nukadoko/command.rbs +68 -1
  120. data/sig/generated/nukadoko/command_help.rbs +18 -0
  121. data/sig/generated/nukadoko/compat.rbs +392 -0
  122. data/sig/generated/nukadoko/criteria.rbs +1 -1
  123. data/sig/generated/nukadoko/definition.rbs +50 -0
  124. data/sig/generated/nukadoko/error_frames.rbs +1 -1
  125. data/sig/generated/nukadoko/events/count.rbs +69 -0
  126. data/sig/generated/nukadoko/events/counted.rbs +70 -0
  127. data/sig/generated/nukadoko/events/format.rbs +163 -0
  128. data/sig/generated/nukadoko/events/lists.rbs +47 -0
  129. data/sig/generated/nukadoko/events/path.rbs +161 -0
  130. data/sig/generated/nukadoko/events/read.rbs +109 -0
  131. data/sig/generated/nukadoko/events/reader.rbs +226 -0
  132. data/sig/generated/nukadoko/events/selection.rbs +100 -0
  133. data/sig/generated/nukadoko/events/tally.rbs +227 -0
  134. data/sig/generated/nukadoko/features.rbs +6 -4
  135. data/sig/generated/nukadoko/fixtures.rbs +67 -11
  136. data/sig/generated/nukadoko/http_recording.rbs +1 -1
  137. data/sig/generated/nukadoko/intent.rbs +132 -0
  138. data/sig/generated/nukadoko/intent_file.rbs +46 -0
  139. data/sig/generated/nukadoko/intent_view.rbs +69 -0
  140. data/sig/generated/nukadoko/judgment_file.rbs +7 -1
  141. data/sig/generated/nukadoko/judgments.rbs +10 -0
  142. data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
  143. data/sig/generated/nukadoko/parts.rbs +2 -2
  144. data/sig/generated/nukadoko/path_view.rbs +105 -0
  145. data/sig/generated/nukadoko/place_rows.rbs +43 -0
  146. data/sig/generated/nukadoko/program.rbs +627 -23
  147. data/sig/generated/nukadoko/program_log.rbs +67 -0
  148. data/sig/generated/nukadoko/program_shape.rbs +147 -0
  149. data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
  150. data/sig/generated/nukadoko/project_program.rbs +2 -1
  151. data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
  152. data/sig/generated/nukadoko/report_run.rbs +1 -1
  153. data/sig/generated/nukadoko/run.rbs +286 -41
  154. data/sig/generated/nukadoko/run_record.rbs +20 -12
  155. data/sig/generated/nukadoko/scaffold.rbs +3 -0
  156. data/sig/generated/nukadoko/schema.rbs +5 -0
  157. data/sig/generated/nukadoko/secrets.rbs +26 -3
  158. data/sig/generated/nukadoko/states.rbs +214 -0
  159. data/sig/generated/nukadoko/step.rbs +58 -1
  160. data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
  161. data/sig/generated/nukadoko/summary.rbs +256 -2
  162. data/sig/generated/nukadoko/table.rbs +3 -2
  163. data/sig/generated/nukadoko/trace.rbs +108 -33
  164. data/sig/generated/nukadoko/tree_passes.rbs +36 -8
  165. data/sig/generated/nukadoko/underneath.rbs +141 -0
  166. data/sig/generated/nukadoko/verdict.rbs +8 -0
  167. data/sig/generated/nukadoko/vocabulary.rbs +45 -6
  168. data/skills/nukadoko/SKILL.md +18 -18
  169. data/skills/nukadoko/references/checking-steps.md +16 -83
  170. data/skills/nukadoko/references/diagnosing.md +6 -6
  171. data/skills/nukadoko/references/done.md +22 -0
  172. data/skills/nukadoko/references/evidence.md +19 -6
  173. data/skills/nukadoko/references/exploring.md +22 -7
  174. data/skills/nukadoko/references/fixtures.md +12 -32
  175. data/skills/nukadoko/references/judgments.md +18 -0
  176. data/skills/nukadoko/references/maintenance.md +1 -1
  177. data/skills/nukadoko/references/merge-risk.md +1 -1
  178. data/skills/nukadoko/references/parts.md +46 -23
  179. data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
  180. data/skills/nukadoko/references/program.md +168 -169
  181. data/skills/nukadoko/references/reviewing.md +20 -20
  182. data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
  183. data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
  184. data/skills/nukadoko/references/ruby/fixtures.md +34 -0
  185. data/skills/nukadoko/references/ruby/program.md +112 -0
  186. data/skills/nukadoko/references/ruby/step-files.md +115 -0
  187. data/skills/nukadoko/references/running.md +34 -34
  188. data/skills/nukadoko/references/scenario-rules.md +7 -6
  189. data/skills/nukadoko/references/states.md +7 -1
  190. data/skills/nukadoko/references/step-files.md +41 -120
  191. data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
  192. data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
  193. data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
  194. data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
  195. data/skills/nukadoko/references/typescript/fixtures.md +56 -0
  196. data/skills/nukadoko/references/typescript/program.md +111 -0
  197. data/skills/nukadoko/references/typescript/step-files.md +104 -0
  198. data/skills/nukadoko/references/verdicts.md +10 -10
  199. data/skills/nukadoko/references/writing-steps.md +67 -67
  200. data/skills/nukadoko/references/writing-the-feature.md +1 -1
  201. data/skills/nukadoko-verification/SKILL.md +13 -8
  202. metadata +103 -7
  203. data/skills/nukadoko/references/ruby.md +0 -80
@@ -0,0 +1,109 @@
1
+ # Generated from lib/nukadoko/events/read.rb with RBS::Inline
2
+
3
+ # A claim step's reading of an earlier step's execution events, at the
4
+ # moment its claims are judged: the lines of that step's trace counted
5
+ # against each selection, as a range, written to READ_FILE beside the
6
+ # reading step's record. Boundary: what a line says and what a count says
7
+ # of a claim are Events'; which step produced the events, and the
8
+ # deadline, are the caller's; this module reads and waits.
9
+ #
10
+ # A reading starts at the byte the producer's slice began reading at, so
11
+ # it holds every line of the producer's trace, and the lines no step owns
12
+ # from then on: such a line may be the producer's, so it widens every
13
+ # count it could match. Lines another step owns do not.
14
+ #
15
+ # The reading waits while the producer's events may still become whole (a
16
+ # request with no line yet, a job not yet performed, no line at all). It
17
+ # stops once they are whole, once a gap no more lines can close is open,
18
+ # or when the deadline is near. It never waits until a claim would hold:
19
+ # waiting for "one row was written" would make "nothing was written" hold
20
+ # before the write arrived.
21
+ #
22
+ # A recorded producer (`nuka do --use`) is read from its record's
23
+ # directory: each service's slice and its late lines, read again with the
24
+ # same tally. Its lines no step owns were counted in its slice and not
25
+ # kept, so each one widens every count by one.
26
+ #
27
+ # A count may name one service, and then reads that service's lines alone;
28
+ # one that names none reads every service's, so "nothing was written"
29
+ # means nothing anywhere, and a kind none of them reported keeps it from
30
+ # being whole.
31
+ module Nukadoko
32
+ module Engine
33
+ module Events
34
+ READ_FILE: ::String
35
+
36
+ # Gaps more lines can close: the reading waits only while every open
37
+ # gap is one of these.
38
+ CLOSABLE: untyped
39
+
40
+ NO_MAYBE: untyped
41
+
42
+ # One producer's lines, folded for every key that reads it.
43
+ class Group
44
+ attr_reader producer: Hash[Symbol, untyped]
45
+
46
+ attr_reader requests: Array[Hash[Symbol, untyped]]
47
+
48
+ attr_reader tally: Tally
49
+
50
+ attr_accessor unowned_not_kept: Integer
51
+
52
+ # What each service's file holds, as this reading knows it.
53
+ attr_reader files: Hash[String, Hash[Symbol, bool]]
54
+
55
+ # : (Hash[Symbol, untyped], Array[Hash[Symbol, untyped]], Tally, Array[String]) -> void
56
+ def initialize: (Hash[Symbol, untyped], Array[Hash[Symbol, untyped]], Tally, Array[String]) -> void
57
+
58
+ # : () -> String
59
+ def trace_id: () -> String
60
+
61
+ # The services this group reads, in order.
62
+ # : () -> Array[String]
63
+ def services: () -> Array[String]
64
+
65
+ # `files` with `service`'s state changed.
66
+ # : (String, Hash[Symbol, bool]) -> void
67
+ def mark: (String, Hash[Symbol, bool]) -> void
68
+
69
+ # Whether more lines can no longer change whether the group is whole.
70
+ # : () -> bool
71
+ def settled?: () -> bool
72
+ end
73
+
74
+ # : () -> Float
75
+ def self.clock: () -> Float
76
+
77
+ # Reads each request's producer (`{ key:, producer:, selection:,
78
+ # service: }`), waiting until every live producer's events are whole,
79
+ # can no longer become whole, or `until_at` (monotonic seconds) is
80
+ # near, and writes the lines it counted to READ_FILE in `dir`. Returns
81
+ # each key's reading, as a step record's `events_read` holds it.
82
+ # `tables` is what each service of the claim step's system says in its
83
+ # tables list, which decides the lines a count leaves out.
84
+ # : (Array[Hash[Symbol, untyped]], Float, String, Secrets, ?Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
85
+ def self.read: (Array[Hash[Symbol, untyped]], Float, String, Secrets, ?Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
86
+
87
+ # Reads each service's file forward, feeding each group's tally, until
88
+ # every group is settled or `until_at` is near. One loop over every
89
+ # file: a line a service wrote for a request another service passed on
90
+ # closes work the first service's file leaves open. The block keeps a
91
+ # line some group counted, by its service and byte.
92
+ # : (Array[Group], Array[ServiceFile], Float) { (String, Integer, String, Line) -> void } -> void
93
+ def self.read_live: (Array[Group], Array[ServiceFile], Float) { (String, Integer, String, Line) -> void } -> void
94
+
95
+ # Waits until the step that `start` began is whole, can no longer
96
+ # become whole, or `until_at` is near, and keeps nothing: `nuka do`
97
+ # waits so before it stops its system. A system no service of which
98
+ # has written a line yet is not waited for: a program that writes none
99
+ # would cost every call the whole wait.
100
+ # : (Reader, Hash[Symbol, untyped]?, Float) -> void
101
+ def self.settle: (Reader, Hash[Symbol, untyped]?, Float) -> void
102
+
103
+ # Folds a recorded producer's lines, one service's files at a time,
104
+ # into its group's tally.
105
+ # : (Group, KindsSeen) { (String, Line) -> void } -> void
106
+ def self.read_recorded: (Group, KindsSeen) { (String, Line) -> void } -> void
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,226 @@
1
+ # Generated from lib/nukadoko/events/reader.rb with RBS::Inline
2
+
3
+ # The execution events each service of a served system appends to the file
4
+ # `{events}` names (docs/execution-events.md, docs/spec.md "Execution
5
+ # events"): each step's slice of them, written beside its record when the
6
+ # step ends, and, once the system has stopped, each service's redacted copy
7
+ # and each step's lines that arrived after its record. Boundary: owns no
8
+ # file (the program writes it, Program makes and removes it), and decides
9
+ # nothing a line says (Events, Selection, Tally do).
10
+ #
11
+ # One reader over every service: a step's trace runs across them, and one
12
+ # wait reads them all, so a line one service wrote for a request another
13
+ # service passed on closes work the first service's file leaves open. A
14
+ # service whose events nukadoko does not read (one that names no
15
+ # `{events}`, or one at a `url`) has no file here, and the steps that sent
16
+ # it a request say so (`service-unrecorded`).
17
+ #
18
+ # A line belongs to the step whose trace id its parsed `trace` field
19
+ # holds, never to one whose id merely appears in its text: a value inside
20
+ # an event can hold an id too. An unreadable line has no owner, so no
21
+ # step's events take data from it; when its text carries a step's trace
22
+ # id by the program log's rule, the step's slice counts it as damage to
23
+ # its trace, and the line is kept only in the system's copy.
24
+ #
25
+ # The program writes the file directly, not through a pipe nukadoko
26
+ # redacts, so only redacted copies reach the run directory: each line is
27
+ # parsed, redacted with the step's secrets, and written again as JSON, so
28
+ # a copy is JSON wherever a secret was, and a record shows exactly what
29
+ # was read. An unreadable line has no object to redact, so its text is
30
+ # redacted as the program log's is.
31
+ #
32
+ # The file nukadoko made is the one read. A file that is replaced, or made
33
+ # shorter, while the scenarios run is no longer read, and every step from
34
+ # then on says so (`file-replaced`), since what it read may be incomplete.
35
+ #
36
+ # A step that stamped a request, or gave a process its trace, reads the
37
+ # file as it waits, as the program log's slice does (Trace::Log): until no
38
+ # line of its own has arrived for QUIET seconds after the later of its
39
+ # last such line and the moment it ended, and no longer than SETTLE.
40
+ module Nukadoko
41
+ module Engine
42
+ module Events
43
+ SYSTEM_FILE: ::String
44
+
45
+ # The most one of a step's files holds; a step whose lines come to
46
+ # more keeps the first of them, marked `truncated`.
47
+ SLICE_CAP: untyped
48
+
49
+ QUIET: ::Float
50
+
51
+ SETTLE: ::Float
52
+
53
+ POLL: ::Float
54
+
55
+ READ_CHUNK: untyped
56
+
57
+ # The file beside the step record that holds a service's lines of the
58
+ # step.
59
+ # : (String) -> String
60
+ def self.slice_file: (String) -> String
61
+
62
+ # The file beside the step record for a service's lines of the step
63
+ # that arrived after its record was written.
64
+ # : (String) -> String
65
+ def self.late_file: (String) -> String
66
+
67
+ # Whether `name` is a file a service's slice or late lines take beside
68
+ # a step record, whatever the service's name, in any case: a step may
69
+ # not attach one.
70
+ # : (String) -> bool
71
+ def self.events_file?: (String) -> bool
72
+
73
+ # The line as a copy keeps it: the parsed object redacted and written
74
+ # again, or the text redacted when there is no object.
75
+ # : (String, Line, Secrets) -> String
76
+ def self.kept_line: (String, Line, Secrets) -> String
77
+
78
+ # Hands each complete line of `path` from byte `from` to the block,
79
+ # with the byte it starts at, a chunk at a time, and returns the byte
80
+ # after the last complete line: a line still being written is read by
81
+ # the next call. A file that does not exist yet has no lines.
82
+ # : (String, Integer) { (String, Integer) -> void } -> Integer
83
+ def self.each_line: (String, Integer) { (String, Integer) -> void } -> Integer
84
+
85
+ # A step's process count as a tally reads it: none, all ended, or one
86
+ # that may still send.
87
+ # : (Array[Hash[Symbol, untyped]]?) -> String
88
+ def self.processes_state: (Array[Hash[Symbol, untyped]]?) -> String
89
+
90
+ # What a tally needs of a step's trace. `unread` names the services
91
+ # whose events nukadoko does not read, of which the ones the step sent
92
+ # a request to leave the trace open under their name.
93
+ # : (Trace::Boundary, Array[Hash[Symbol, untyped]]?, ?Array[String]) -> Hash[Symbol, untyped]
94
+ def self.inputs_of: (Trace::Boundary, Array[Hash[Symbol, untyped]]?, ?Array[String]) -> Hash[Symbol, untyped]
95
+
96
+ # The tally inputs of a recorded slice: each service's stamped spans
97
+ # as its entry holds them. The slice's own gaps say what its processes
98
+ # left open: `processes-unbounded` names one that may still send, and
99
+ # `no-requests` a step that ran none and stamped nothing. A step with
100
+ # no gap of either kind that stamped nothing ran processes that all
101
+ # ended. A service whose events the run did not read is named by the
102
+ # slice's own `service-unrecorded`, since its entry is nil.
103
+ # : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
104
+ def self.inputs_of_slice: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
105
+
106
+ # Every service of a slice whose lines the run read, in its order.
107
+ # : (Hash[Symbol, untyped]) -> Array[String]
108
+ def self.services_of: (Hash[Symbol, untyped]) -> Array[String]
109
+
110
+ # What one of a step's files may still hold, out of SLICE_CAP.
111
+ class Kept
112
+ attr_reader lines: Array[String]
113
+
114
+ attr_reader truncated: bool
115
+
116
+ # : () -> void
117
+ def initialize: () -> void
118
+
119
+ # : (String) -> void
120
+ def keep: (String) -> void
121
+
122
+ # Writes the kept lines to `name` in `dir` and returns `name`, or
123
+ # nil when none were kept or the file could not be written.
124
+ # : (String, String) -> String?
125
+ def write: (String, String) -> String?
126
+ end
127
+
128
+ # One service's events file, as a claim step's reading reads it
129
+ # (Events.read).
130
+ class ServiceFile
131
+ attr_reader service: String
132
+
133
+ attr_reader path: String
134
+
135
+ attr_reader prefix: String
136
+
137
+ # : (String, String, String) -> void
138
+ def initialize: (String, String, String) -> void
139
+
140
+ attr_accessor offset: Integer
141
+
142
+ # Whether the file is still the one nukadoko made, asked before each
143
+ # read from `offset`: once it answers false, it always does.
144
+ # : (Integer) -> bool
145
+ def readable?: (Integer) -> bool
146
+
147
+ # : () -> bool
148
+ def replaced?: () -> bool
149
+
150
+ # The kinds this service's program has reported, through the end of
151
+ # the file as it stands now.
152
+ # : () -> KindsSeen
153
+ def kinds_seen: () -> KindsSeen
154
+
155
+ private
156
+
157
+ # : () -> [Integer, Integer, Integer]?
158
+ def identity: () -> [ Integer, Integer, Integer ]?
159
+ end
160
+
161
+ # Every service's events file of one system, read forward as its steps
162
+ # end.
163
+ class Reader
164
+ attr_reader prefix: String
165
+
166
+ # One per service whose file this reader reads, in the program's
167
+ # order.
168
+ attr_reader systems: Array[ServiceFile]
169
+
170
+ # `services` is each service of the system with a URL: `service` and
171
+ # `path`, the file it appends its events to, or nil for a service
172
+ # whose events nukadoko does not read.
173
+ # : (Array[Hash[Symbol, untyped]], String, ^() -> Secrets) -> void
174
+ def initialize: (Array[Hash[Symbol, untyped]], String, ^() -> Secrets) -> void
175
+
176
+ # Where the step whose trace is `trace_id` began, nil when this
177
+ # reader sliced no such step.
178
+ # : (String) -> Hash[Symbol, untyped]?
179
+ def producer: (String) -> Hash[Symbol, untyped]?
180
+
181
+ # Reads what every service's file gained since the last call and
182
+ # writes the slice of `boundary`'s trace into `dir`.
183
+ # : (String, Trace::Boundary, Array[Hash[Symbol, untyped]]?) -> Hash[Symbol, untyped]
184
+ def slice: (String, Trace::Boundary, Array[Hash[Symbol, untyped]]?) -> Hash[Symbol, untyped]
185
+
186
+ # Once the system stopped: each service's redacted copy at
187
+ # `copies[service]`, each step's lines past its slice in its
188
+ # `Events.late_file(service)`, and what each file holds. `steps`
189
+ # maps a trace id to [lines its slice read per service, its record's
190
+ # directory, its tally inputs]. With inputs, a step's path and its
191
+ # writes that persisted to a table that holds state are folded from
192
+ # every line of its trace, across every service, and each of
193
+ # `recounts` (`{ trace_id:, inputs:, selection:, service:,
194
+ # replaced: }`) is counted again over every line of its trace,
195
+ # leaving out what `tables`, each service's tables list, leaves out.
196
+ # A writer's own kind counts in a path by `own_fields`, the fields
197
+ # the change's intent reads on it.
198
+ # : (Hash[String, String], Hash[String, Array[untyped]], ?recounts: Array[Hash[Symbol, untyped]], ?tables: Hash[String, Hash[Symbol, untyped]], ?own_fields: Hash[String, Array[String]]) -> Hash[Symbol, untyped]
199
+ def collect: (Hash[String, String], Hash[String, Array[untyped]], ?recounts: Array[Hash[Symbol, untyped]], ?tables: Hash[String, Hash[Symbol, untyped]], ?own_fields: Hash[String, Array[String]]) -> Hash[Symbol, untyped]
200
+
201
+ private
202
+
203
+ # Reads one service's whole file into the folds and tallies the stop
204
+ # shares across its services, and writes its copy and its steps'
205
+ # late lines.
206
+ # : (ServiceFile, String?, Hash[String, Array[untyped]], folds: Hash[String, PathFold], writes: Hash[String, Tally], kinds: KindsSeen, tallies_of: Hash[String, Array[Tally]]) -> Hash[Symbol, untyped]
207
+ def collect_service: (ServiceFile, String?, Hash[String, Array[untyped]], folds: Hash[String, PathFold], writes: Hash[String, Tally], kinds: KindsSeen, tallies_of: Hash[String, Array[Tally]]) -> Hash[Symbol, untyped]
208
+
209
+ # : (String, Array[String], String) -> String?
210
+ def append: (String, Array[String], String) -> String?
211
+
212
+ # : () -> Float
213
+ def now: () -> Float
214
+
215
+ # Reads what every service's file gained and hands each line to
216
+ # `own`, which answers whether it is the ending step's; then, when
217
+ # the step stamped anything, keeps reading as it waits for the
218
+ # step's lines still on their way (module header). One wait over
219
+ # every file: a line a service wrote for a request another service
220
+ # passed on closes work the first service's file leaves open.
221
+ # : (Float?, ^(String, String) -> bool) -> void
222
+ def read_step: (Float?, ^(String, String) -> bool) -> void
223
+ end
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,100 @@
1
+ # Generated from lib/nukadoko/events/selection.rb with RBS::Inline
2
+
3
+ # What a count over execution events selects (one kind, and for each field
4
+ # it names, the values a line must hold), the refusal of a selection the
5
+ # format cannot judge, and what one line says about one selection. Pure.
6
+ # Which lines are a trace's, and whether a line's change persisted, are
7
+ # the caller's (Tally, CommitIndex).
8
+ #
9
+ # A field a selection names is one whose value is one string, one number,
10
+ # or true or false: lists (`ids`, `calls`) are not what a count selects by.
11
+ # `committed` is not a field of the line to compare but the commit state
12
+ # the format defines, so it has a rule of its own: a db selection whose
13
+ # `op` may be a write states it, since a write that was rolled back would
14
+ # otherwise count as written, and one that selects reads alone leaves it
15
+ # out, since a read persists nothing.
16
+ #
17
+ # A line answers a selection with `yes`, `no`, or why it may match: a kind
18
+ # the format does not define, a later version, a selected field that is
19
+ # missing or invalid, or a commit state still to be decided. A definite
20
+ # `no` on any field wins over an unknown one. A writer's own kind (`x_`)
21
+ # is never one of the kinds a selection names.
22
+ #
23
+ # A selection here is a Hash with String keys, as a line's object is: the
24
+ # step's declaration is read into one with Selection.normalize.
25
+ module Nukadoko
26
+ module Engine
27
+ module Events
28
+ module Selection
29
+ # Every write whose change persisted, as "nothing was written"
30
+ # selects them.
31
+ PERSISTED_WRITES: untyped
32
+
33
+ VALUE_WORDS: untyped
34
+
35
+ # A declaration with its keys as strings, a value from the sentence
36
+ # (`{ sentence: "table" }`) kept as `{ "sentence" => "table" }`.
37
+ # : (untyped) -> untyped
38
+ def self?.normalize: (untyped) -> untyped
39
+
40
+ # : (String, Field) -> bool
41
+ def self?.selectable?: (String, Field) -> bool
42
+
43
+ # : (untyped, Field) -> bool
44
+ def self?.fits?: (untyped, Field) -> bool
45
+
46
+ # : (Field) -> String
47
+ def self?.value_words: (Field) -> String
48
+
49
+ # : (untyped) -> bool
50
+ def self?.sentence_value?: (untyped) -> bool
51
+
52
+ # : (untyped) -> Array[untyped]
53
+ def self?.values_of: (untyped) -> Array[untyped]
54
+
55
+ # : (untyped) -> bool
56
+ def self?.reads_alone?: (untyped) -> bool
57
+
58
+ # : (untyped) -> String
59
+ def self?.shown: (untyped) -> String
60
+
61
+ # Why `value` is not a selection the format can judge, one message
62
+ # per problem, each starting with `where`. Empty when it is one.
63
+ # : (untyped, String) -> Array[String]
64
+ def self?.problems: (untyped, String) -> Array[String]
65
+
66
+ # Each value a declared selection takes from the sentence: the field
67
+ # that names it and the capture's name.
68
+ # : (untyped) -> Array[Hash[Symbol, String]]
69
+ def self?.sentence_values: (untyped) -> Array[Hash[Symbol, String]]
70
+
71
+ # The selection with each value from the sentence filled in by
72
+ # `capture`, or why it is not one the format can judge.
73
+ # : (Hash[String, untyped], ^(String) -> untyped, String) -> Hash[Symbol, untyped]
74
+ def self?.resolve: (Hash[String, untyped], ^(String) -> untyped, String) -> Hash[Symbol, untyped]
75
+
76
+ # Whether a line's value may be one of the wanted values although
77
+ # it equals none: `table: "unknown"` names a table the writer could
78
+ # not tell, and `op: "other"` may be an upsert.
79
+ # : (String, String, untyped, Array[untyped]) -> bool
80
+ def self?.undecided?: (String, String, untyped, Array[untyped]) -> bool
81
+
82
+ # What `line` says about `selection`: "yes", "no", "commit-state",
83
+ # or a cause a count's `maybe` counts by.
84
+ # : (Hash[String, untyped], Line) -> String
85
+ def self?.match: (Hash[String, untyped], Line) -> String
86
+
87
+ # A value as a label names it: a word of letters, digits, and
88
+ # `_:/.@-` as it is, any other value as JSON, and a value from the
89
+ # sentence as `sentence:<capture>`.
90
+ # : (untyped) -> String
91
+ def self?.value_text: (untyped) -> String
92
+
93
+ # The selection in the words a record's label and a summary use:
94
+ # `db where op in [insert, update, delete, other], committed true`.
95
+ # : (Hash[String, untyped]) -> String
96
+ def self?.describe: (Hash[String, untyped]) -> String
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,227 @@
1
+ # Generated from lib/nukadoko/events/tally.rb with RBS::Inline
2
+
3
+ # What the lines of one trace say about the work they report, folded in
4
+ # the order each service's file holds them: how many there are of each
5
+ # kind, whether every request the step sent and every job it enqueued has
6
+ # reported its end, and, for each selection a count names, how many lines
7
+ # match, what they were (Counted), and how many may. Pure. Which lines are
8
+ # the trace's, and reading and redacting them, are the caller's.
9
+ #
10
+ # A step's trace is one across the services of its system, and each
11
+ # service nukadoko serves writes its own file, so every line the tally
12
+ # folds names the service whose file holds it. What the step did is one
13
+ # count; what a service reported is counted under its name, and so is
14
+ # every gap that one service's lines leave open. A count may name one
15
+ # service, and then counts that service's lines alone; one that names none
16
+ # counts every service's, so "nothing was written" means nothing anywhere.
17
+ #
18
+ # The format writes an operation's line when the operation ends, after the
19
+ # lines of everything inside it. So a request's line closes what the
20
+ # request did, and a job's `perform` line closes that run of the job: the
21
+ # work a trace reports is whole once every request the step stamped has
22
+ # its line and every job enqueued in the trace has performed. A request's
23
+ # line names the span the step put in its `traceparent`, so each one is
24
+ # matched to the request that sent it, whichever service's file holds the
25
+ # line; a line with a bare trace id stands for one request to the service
26
+ # whose file holds it. A job is matched under the service that reported
27
+ # it, since a job id is the program's own and two programs can write the
28
+ # same one. Lines of several processes are in write order, so the counts
29
+ # per job are compared, never their order. A run_command process is work
30
+ # no count bounds while it may still run, so a trace whose step ran one is
31
+ # not whole until it closed with no process of its group left.
32
+ #
33
+ # A service the step sent a request to whose events nukadoko does not read
34
+ # (one that names no `{events}`, or one at a `url`) leaves the trace open
35
+ # under its name: no line says where that service's work ended.
36
+ #
37
+ # A count never drops a line it cannot read as a match or a miss: a line
38
+ # that may be any line is counted as one that may match, by its cause, and
39
+ # so is a readable line no step owns in the step's window, when it could
40
+ # match. A db line whose match depends on its commit state is kept until
41
+ # the reading, since a later `tx` line of the trace decides it.
42
+ #
43
+ # Whether a db line's change persisted is decided from the lines of the
44
+ # service that wrote it alone, as the format states it: a `tx` of one
45
+ # program holds no statement of another, and two programs can write the
46
+ # same id. A line with `committed` is in that state unless a `tx` on its
47
+ # parent chain rolled back, which makes it unknown; otherwise the change
48
+ # persisted when every `tx` on its parent chain committed and did not when
49
+ # one rolled back; anything else is unknown.
50
+ #
51
+ # Each service reads its own tables list, so a line a db selection leaves
52
+ # out is placed by the list of the service that wrote it.
53
+ module Nukadoko
54
+ module Engine
55
+ module Events
56
+ # Why a reading of a step's events may not hold everything its work
57
+ # did, in the order a record lists them.
58
+ GAP_WORDS: untyped
59
+
60
+ # Why a line may match a selection, as a count's `maybe` names it.
61
+ MAYBE_CAUSES: untyped
62
+
63
+ TABLE_HOLDS: untyped
64
+
65
+ # The tables of a system whose program names no tables list.
66
+ NO_MARKED_TABLES: Hash[Symbol, untyped]
67
+
68
+ # What `table` holds by `tables`, when it is marked; nil for a table
69
+ # that holds state, or when the list was not read.
70
+ # : (Hash[Symbol, untyped], untyped) -> String?
71
+ def self.mark_of: (Hash[Symbol, untyped], untyped) -> String?
72
+
73
+ # What `tables` says of a line a count of `selection` would count:
74
+ # "counted", a holding the count leaves out, or "unknown". Only a db
75
+ # selection that names no table leaves a line out.
76
+ # : (Hash[String, untyped], Line, Hash[Symbol, untyped]) -> String
77
+ def self.table_rule: (Hash[String, untyped], Line, Hash[Symbol, untyped]) -> String
78
+
79
+ # The order a record lists gaps in: GAP_WORDS, then the service a gap
80
+ # names.
81
+ # : (Hash[Symbol, untyped]) -> [Integer, String]
82
+ def self.gap_order: (Hash[Symbol, untyped]) -> [ Integer, String ]
83
+
84
+ # The gaps of a reading of a selection of `kind`: the trace's, and
85
+ # `kind-unreported` when the system's program reported no line of it.
86
+ # : (Array[Hash[Symbol, untyped]], String, (KindsSeen | AnyKindsSeen)) -> Array[Hash[Symbol, untyped]]
87
+ def self.reading_gaps: (Array[Hash[Symbol, untyped]], String, KindsSeen | AnyKindsSeen) -> Array[Hash[Symbol, untyped]]
88
+
89
+ # Each service whose file a reading found replaced or made shorter, as
90
+ # its gaps say: the file a later pass reads is not the one it read.
91
+ # : (Array[Hash[Symbol, untyped]]) -> Hash[String, bool]
92
+ def self.replaced_services: (Array[Hash[Symbol, untyped]]) -> Hash[String, bool]
93
+
94
+ # The kinds a system's program has reported so far.
95
+ class KindsSeen
96
+ # : () -> void
97
+ def initialize: () -> void
98
+
99
+ # : (Line) -> void
100
+ def note: (Line) -> void
101
+
102
+ # : (String) -> bool
103
+ def has?: (String) -> bool
104
+ end
105
+
106
+ # The kinds any of several services' programs has reported: what a
107
+ # count that names no service reads, since one service reporting a
108
+ # kind is enough for its absence elsewhere to mean something. `note`
109
+ # goes to none of them: each is noted where its own lines are read.
110
+ class AnyKindsSeen
111
+ # : (Array[KindsSeen]) -> void
112
+ def initialize: (Array[KindsSeen]) -> void
113
+
114
+ # : (Line) -> void
115
+ def note: (Line) -> void
116
+
117
+ # : (String) -> bool
118
+ def has?: (String) -> bool
119
+ end
120
+
121
+ # Whether a db line's change persisted, from the lines noted so far.
122
+ class CommitIndex
123
+ # : () -> void
124
+ def initialize: () -> void
125
+
126
+ # : (Line) -> void
127
+ def note: (Line) -> void
128
+
129
+ # "persisted", "not-persisted", or "unknown".
130
+ # : (Hash[String, untyped]) -> String
131
+ def state_of: (Hash[String, untyped]) -> String
132
+ end
133
+
134
+ # Every span id the step stamped, in no particular service's order.
135
+ # : (Hash[Symbol, untyped]) -> Array[String]
136
+ def self.spans_of: (Hash[Symbol, untyped]) -> Array[String]
137
+
138
+ # How many requests the step stamped, the ones whose span id was not
139
+ # kept included.
140
+ # : (Hash[Symbol, untyped]) -> Integer
141
+ def self.stamped_count: (Hash[Symbol, untyped]) -> Integer
142
+
143
+ # What one service's lines said, as the fold counts them. A service
144
+ # holds the commit chains of its own lines, since a `tx` of one
145
+ # process holds no statement of another.
146
+ class ServiceState
147
+ attr_accessor lines: untyped
148
+
149
+ attr_accessor unreadable: untyped
150
+
151
+ attr_accessor unowned: untyped
152
+
153
+ attr_accessor process_requests: untyped
154
+
155
+ attr_accessor bare: untyped
156
+
157
+ attr_reader kinds: untyped
158
+
159
+ attr_reader jobs: untyped
160
+
161
+ attr_reader commits: untyped
162
+
163
+ # : () -> void
164
+ def initialize: () -> void
165
+ end
166
+
167
+ # One trace's lines, folded in each service's file order.
168
+ class Tally
169
+ # `inputs`: `spans` (the span ids of the requests the step stamped,
170
+ # by the service each went to), `spans_not_kept` (by service),
171
+ # `processes` ("none", "ended", or "unbounded"), `process_spans`,
172
+ # `mcp_spans`, `selections` (each `selection` with the one `service`
173
+ # it counts, if it names one), `tables` (by service), and
174
+ # `unrecorded` (each service whose events nukadoko does not read).
175
+ # : (Hash[Symbol, untyped]) -> void
176
+ def initialize: (Hash[Symbol, untyped]) -> void
177
+
178
+ # A readable line of `service`'s file whose trace is the tally's, in
179
+ # file order.
180
+ # : (Line, String) -> void
181
+ def owned: (Line, String) -> void
182
+
183
+ # An unreadable line of `service`'s file whose text carries the
184
+ # tally's trace id.
185
+ # : (String) -> void
186
+ def damaged: (String) -> void
187
+
188
+ # A readable line of `service`'s file that no step owns, written in
189
+ # the step's window.
190
+ # : (Line, String) -> void
191
+ def unowned: (Line, String) -> void
192
+
193
+ # What the lines folded so far say, with what each service's reader
194
+ # knows of its file: `files` is `truncated` and `replaced` by
195
+ # service. A service with no entry in `files` has none in the
196
+ # reading.
197
+ # : (Hash[String, Hash[Symbol, bool]]) -> Hash[Symbol, untyped]
198
+ def reading: (Hash[String, Hash[Symbol, bool]]) -> Hash[Symbol, untyped]
199
+
200
+ private
201
+
202
+ # : (String) -> ServiceState
203
+ def state_of: (String) -> ServiceState
204
+
205
+ # : (String) -> Hash[Symbol, untyped]
206
+ def tables_of: (String) -> Hash[Symbol, untyped]
207
+
208
+ # Whether the count at `index` counts what `service`'s file holds:
209
+ # every service's, unless the count names one.
210
+ # : (Integer, String) -> bool
211
+ def counting?: (Integer, String) -> bool
212
+
213
+ # What one service's lines leave open.
214
+ # : (String, ServiceState, Hash[Symbol, bool]) -> Array[Hash[Symbol, untyped]]
215
+ def service_gaps: (String, ServiceState, Hash[Symbol, bool]) -> Array[Hash[Symbol, untyped]]
216
+
217
+ # : (Hash[String, untyped], Integer, Array[untyped]) -> Hash[Symbol, untyped]
218
+ def decided: (Hash[String, untyped], Integer, Array[untyped]) -> Hash[Symbol, untyped]
219
+
220
+ # The tables list that marks `table`, among the services read: a
221
+ # table one service's list marks is that service's.
222
+ # : (Array[untyped], untyped) -> Hash[Symbol, untyped]
223
+ def marking_tables: (Array[untyped], untyped) -> Hash[Symbol, untyped]
224
+ end
225
+ end
226
+ end
227
+ end