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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +553 -3
- data/README.ja.md +22 -6
- data/README.md +13 -7
- data/docs/ci.ja.md +542 -0
- data/docs/ci.md +635 -0
- data/docs/commands.ja.md +1524 -0
- data/docs/commands.md +1281 -0
- data/docs/engines.json +19 -0
- data/docs/execution-events.ja.md +336 -0
- data/docs/execution-events.md +423 -0
- data/docs/glossary.json +1348 -0
- data/docs/guide.ja.md +733 -0
- data/docs/guide.md +815 -0
- data/docs/intent.ja.md +133 -0
- data/docs/intent.md +156 -0
- data/docs/layout.ja.md +442 -0
- data/docs/layout.md +399 -0
- data/docs/releasing.ja.md +186 -0
- data/docs/releasing.md +237 -0
- data/docs/ruby/reference.ja.md +302 -0
- data/docs/ruby/reference.md +368 -0
- data/docs/spec.ja.md +8916 -0
- data/docs/spec.md +11250 -0
- data/docs/tutorial.ja.md +451 -0
- data/docs/tutorial.md +458 -0
- data/docs/typescript/adopting.ja.md +231 -0
- data/docs/typescript/adopting.md +251 -0
- data/docs/typescript/doors.ja.md +301 -0
- data/docs/typescript/doors.md +329 -0
- data/docs/typescript/migration-playwright-test.ja.md +189 -0
- data/docs/typescript/migration-playwright-test.md +212 -0
- data/docs/typescript/migration.ja.md +391 -0
- data/docs/typescript/migration.md +505 -0
- data/docs/typescript/reference.ja.md +176 -0
- data/docs/typescript/reference.md +197 -0
- data/docs/typescript/upgrading.ja.md +1774 -0
- data/docs/typescript/upgrading.md +2224 -0
- data/docs/web-app.ja.md +627 -0
- data/docs/web-app.md +659 -0
- data/docs/writing-scenarios.ja.md +544 -0
- data/docs/writing-scenarios.md +563 -0
- data/lib/nukadoko/base.rb +12 -5
- data/lib/nukadoko/changed_files.rb +95 -0
- data/lib/nukadoko/check.rb +459 -51
- data/lib/nukadoko/claim_drops.rb +271 -0
- data/lib/nukadoko/claim_line.rb +24 -4
- data/lib/nukadoko/claim_rules.rb +143 -1
- data/lib/nukadoko/claim_sides.rb +157 -9
- data/lib/nukadoko/cli.rb +403 -50
- data/lib/nukadoko/codes.json +246 -21
- data/lib/nukadoko/codes.rb +21 -4
- data/lib/nukadoko/command.rb +120 -13
- data/lib/nukadoko/command_help.rb +128 -0
- data/lib/nukadoko/compat.rb +469 -0
- data/lib/nukadoko/criteria.rb +1 -1
- data/lib/nukadoko/definition.rb +157 -7
- data/lib/nukadoko/error_frames.rb +6 -3
- data/lib/nukadoko/events/count.rb +146 -0
- data/lib/nukadoko/events/counted.rb +114 -0
- data/lib/nukadoko/events/format.rb +257 -0
- data/lib/nukadoko/events/lists.rb +154 -0
- data/lib/nukadoko/events/path.rb +285 -0
- data/lib/nukadoko/events/read.rb +284 -0
- data/lib/nukadoko/events/reader.rb +490 -0
- data/lib/nukadoko/events/selection.rb +252 -0
- data/lib/nukadoko/events/tally.rb +438 -0
- data/lib/nukadoko/features.rb +2 -2
- data/lib/nukadoko/fixtures.rb +160 -35
- data/lib/nukadoko/http_recording.rb +6 -2
- data/lib/nukadoko/intent.rb +364 -0
- data/lib/nukadoko/intent_file.rb +81 -0
- data/lib/nukadoko/intent_view.rb +190 -0
- data/lib/nukadoko/js_json.rb +2 -1
- data/lib/nukadoko/judge.rb +2 -2
- data/lib/nukadoko/judgment_file.rb +22 -1
- data/lib/nukadoko/judgments.rb +33 -3
- data/lib/nukadoko/measure_mcp.rb +202 -0
- data/lib/nukadoko/parts.rb +8 -2
- data/lib/nukadoko/path_view.rb +252 -0
- data/lib/nukadoko/place_rows.rb +161 -0
- data/lib/nukadoko/program.rb +1265 -51
- data/lib/nukadoko/program_log.rb +122 -0
- data/lib/nukadoko/program_shape.rb +385 -0
- data/lib/nukadoko/project_fixtures.rb +43 -10
- data/lib/nukadoko/project_program.rb +5 -4
- data/lib/nukadoko/repeated_prefix.rb +310 -0
- data/lib/nukadoko/report_run.rb +3 -3
- data/lib/nukadoko/run.rb +1156 -159
- data/lib/nukadoko/run_record.rb +70 -46
- data/lib/nukadoko/scaffold.rb +24 -6
- data/lib/nukadoko/schema.rb +15 -2
- data/lib/nukadoko/secrets.rb +55 -5
- data/lib/nukadoko/states.rb +478 -0
- data/lib/nukadoko/step.rb +71 -2
- data/lib/nukadoko/step_fixtures.rb +52 -3
- data/lib/nukadoko/summary.rb +803 -30
- data/lib/nukadoko/table.rb +4 -2
- data/lib/nukadoko/text_fit.rb +20 -7
- data/lib/nukadoko/trace.rb +152 -45
- data/lib/nukadoko/tree_passes.rb +95 -33
- data/lib/nukadoko/underneath.rb +311 -0
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +166 -23
- data/lib/nukadoko/walk.rb +2 -2
- data/lib/nukadoko/walk_step.rb +1 -1
- data/lib/nukadoko.rb +23 -0
- data/llms.txt +42 -35
- data/sig/generated/nukadoko/base.rbs +4 -4
- data/sig/generated/nukadoko/changed_files.rbs +42 -0
- data/sig/generated/nukadoko/check.rbs +147 -10
- data/sig/generated/nukadoko/claim_drops.rbs +135 -0
- data/sig/generated/nukadoko/claim_line.rbs +11 -0
- data/sig/generated/nukadoko/claim_rules.rbs +49 -4
- data/sig/generated/nukadoko/claim_sides.rbs +63 -12
- data/sig/generated/nukadoko/cli.rbs +80 -7
- data/sig/generated/nukadoko/codes.rbs +19 -4
- data/sig/generated/nukadoko/command.rbs +68 -1
- data/sig/generated/nukadoko/command_help.rbs +18 -0
- data/sig/generated/nukadoko/compat.rbs +392 -0
- data/sig/generated/nukadoko/criteria.rbs +1 -1
- data/sig/generated/nukadoko/definition.rbs +50 -0
- data/sig/generated/nukadoko/error_frames.rbs +1 -1
- data/sig/generated/nukadoko/events/count.rbs +69 -0
- data/sig/generated/nukadoko/events/counted.rbs +70 -0
- data/sig/generated/nukadoko/events/format.rbs +163 -0
- data/sig/generated/nukadoko/events/lists.rbs +47 -0
- data/sig/generated/nukadoko/events/path.rbs +161 -0
- data/sig/generated/nukadoko/events/read.rbs +109 -0
- data/sig/generated/nukadoko/events/reader.rbs +226 -0
- data/sig/generated/nukadoko/events/selection.rbs +100 -0
- data/sig/generated/nukadoko/events/tally.rbs +227 -0
- data/sig/generated/nukadoko/features.rbs +6 -4
- data/sig/generated/nukadoko/fixtures.rbs +67 -11
- data/sig/generated/nukadoko/http_recording.rbs +1 -1
- data/sig/generated/nukadoko/intent.rbs +132 -0
- data/sig/generated/nukadoko/intent_file.rbs +46 -0
- data/sig/generated/nukadoko/intent_view.rbs +69 -0
- data/sig/generated/nukadoko/judgment_file.rbs +7 -1
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
- data/sig/generated/nukadoko/parts.rbs +2 -2
- data/sig/generated/nukadoko/path_view.rbs +105 -0
- data/sig/generated/nukadoko/place_rows.rbs +43 -0
- data/sig/generated/nukadoko/program.rbs +627 -23
- data/sig/generated/nukadoko/program_log.rbs +67 -0
- data/sig/generated/nukadoko/program_shape.rbs +147 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
- data/sig/generated/nukadoko/project_program.rbs +2 -1
- data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
- data/sig/generated/nukadoko/report_run.rbs +1 -1
- data/sig/generated/nukadoko/run.rbs +286 -41
- data/sig/generated/nukadoko/run_record.rbs +20 -12
- data/sig/generated/nukadoko/scaffold.rbs +3 -0
- data/sig/generated/nukadoko/schema.rbs +5 -0
- data/sig/generated/nukadoko/secrets.rbs +26 -3
- data/sig/generated/nukadoko/states.rbs +214 -0
- data/sig/generated/nukadoko/step.rbs +58 -1
- data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
- data/sig/generated/nukadoko/summary.rbs +256 -2
- data/sig/generated/nukadoko/table.rbs +3 -2
- data/sig/generated/nukadoko/trace.rbs +108 -33
- data/sig/generated/nukadoko/tree_passes.rbs +36 -8
- data/sig/generated/nukadoko/underneath.rbs +141 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/sig/generated/nukadoko/vocabulary.rbs +45 -6
- data/skills/nukadoko/SKILL.md +18 -18
- data/skills/nukadoko/references/checking-steps.md +16 -83
- data/skills/nukadoko/references/diagnosing.md +6 -6
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/evidence.md +19 -6
- data/skills/nukadoko/references/exploring.md +22 -7
- data/skills/nukadoko/references/fixtures.md +12 -32
- data/skills/nukadoko/references/judgments.md +18 -0
- data/skills/nukadoko/references/maintenance.md +1 -1
- data/skills/nukadoko/references/merge-risk.md +1 -1
- data/skills/nukadoko/references/parts.md +46 -23
- data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
- data/skills/nukadoko/references/program.md +168 -169
- data/skills/nukadoko/references/reviewing.md +20 -20
- data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
- data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
- data/skills/nukadoko/references/ruby/fixtures.md +34 -0
- data/skills/nukadoko/references/ruby/program.md +112 -0
- data/skills/nukadoko/references/ruby/step-files.md +115 -0
- data/skills/nukadoko/references/running.md +34 -34
- data/skills/nukadoko/references/scenario-rules.md +7 -6
- data/skills/nukadoko/references/states.md +7 -1
- data/skills/nukadoko/references/step-files.md +41 -120
- data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
- data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
- data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
- data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
- data/skills/nukadoko/references/typescript/fixtures.md +56 -0
- data/skills/nukadoko/references/typescript/program.md +111 -0
- data/skills/nukadoko/references/typescript/step-files.md +104 -0
- data/skills/nukadoko/references/verdicts.md +10 -10
- data/skills/nukadoko/references/writing-steps.md +67 -67
- data/skills/nukadoko/references/writing-the-feature.md +1 -1
- data/skills/nukadoko-verification/SKILL.md +13 -8
- metadata +103 -7
- data/skills/nukadoko/references/ruby.md +0 -80
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
# What the lines of one trace say about the work they report, folded in
|
|
5
|
+
# the order each service's file holds them: how many there are of each
|
|
6
|
+
# kind, whether every request the step sent and every job it enqueued has
|
|
7
|
+
# reported its end, and, for each selection a count names, how many lines
|
|
8
|
+
# match, what they were (Counted), and how many may. Pure. Which lines are
|
|
9
|
+
# the trace's, and reading and redacting them, are the caller's.
|
|
10
|
+
#
|
|
11
|
+
# A step's trace is one across the services of its system, and each
|
|
12
|
+
# service nukadoko serves writes its own file, so every line the tally
|
|
13
|
+
# folds names the service whose file holds it. What the step did is one
|
|
14
|
+
# count; what a service reported is counted under its name, and so is
|
|
15
|
+
# every gap that one service's lines leave open. A count may name one
|
|
16
|
+
# service, and then counts that service's lines alone; one that names none
|
|
17
|
+
# counts every service's, so "nothing was written" means nothing anywhere.
|
|
18
|
+
#
|
|
19
|
+
# The format writes an operation's line when the operation ends, after the
|
|
20
|
+
# lines of everything inside it. So a request's line closes what the
|
|
21
|
+
# request did, and a job's `perform` line closes that run of the job: the
|
|
22
|
+
# work a trace reports is whole once every request the step stamped has
|
|
23
|
+
# its line and every job enqueued in the trace has performed. A request's
|
|
24
|
+
# line names the span the step put in its `traceparent`, so each one is
|
|
25
|
+
# matched to the request that sent it, whichever service's file holds the
|
|
26
|
+
# line; a line with a bare trace id stands for one request to the service
|
|
27
|
+
# whose file holds it. A job is matched under the service that reported
|
|
28
|
+
# it, since a job id is the program's own and two programs can write the
|
|
29
|
+
# same one. Lines of several processes are in write order, so the counts
|
|
30
|
+
# per job are compared, never their order. A run_command process is work
|
|
31
|
+
# no count bounds while it may still run, so a trace whose step ran one is
|
|
32
|
+
# not whole until it closed with no process of its group left.
|
|
33
|
+
#
|
|
34
|
+
# A service the step sent a request to whose events nukadoko does not read
|
|
35
|
+
# (one that names no `{events}`, or one at a `url`) leaves the trace open
|
|
36
|
+
# under its name: no line says where that service's work ended.
|
|
37
|
+
#
|
|
38
|
+
# A count never drops a line it cannot read as a match or a miss: a line
|
|
39
|
+
# that may be any line is counted as one that may match, by its cause, and
|
|
40
|
+
# so is a readable line no step owns in the step's window, when it could
|
|
41
|
+
# match. A db line whose match depends on its commit state is kept until
|
|
42
|
+
# the reading, since a later `tx` line of the trace decides it.
|
|
43
|
+
#
|
|
44
|
+
# Whether a db line's change persisted is decided from the lines of the
|
|
45
|
+
# service that wrote it alone, as the format states it: a `tx` of one
|
|
46
|
+
# program holds no statement of another, and two programs can write the
|
|
47
|
+
# same id. A line with `committed` is in that state unless a `tx` on its
|
|
48
|
+
# parent chain rolled back, which makes it unknown; otherwise the change
|
|
49
|
+
# persisted when every `tx` on its parent chain committed and did not when
|
|
50
|
+
# one rolled back; anything else is unknown.
|
|
51
|
+
#
|
|
52
|
+
# Each service reads its own tables list, so a line a db selection leaves
|
|
53
|
+
# out is placed by the list of the service that wrote it.
|
|
54
|
+
module Nukadoko
|
|
55
|
+
module Engine
|
|
56
|
+
module Events
|
|
57
|
+
# Why a reading of a step's events may not hold everything its work
|
|
58
|
+
# did, in the order a record lists them.
|
|
59
|
+
GAP_WORDS = %w[inlet-unnamed system-unread producer-not-run no-requests processes-unbounded mcp-unbounded service-unrecorded no-lines
|
|
60
|
+
request-unreported jobs-pending kind-unreported unreadable truncated file-replaced].freeze
|
|
61
|
+
|
|
62
|
+
# Why a line may match a selection, as a count's `maybe` names it.
|
|
63
|
+
MAYBE_CAUSES = %w[unreadable undefined_kind unknown_version field_unknown holds_unknown commit_unknown unowned].freeze
|
|
64
|
+
|
|
65
|
+
TABLE_HOLDS = %w[state bookkeeping infrastructure].freeze
|
|
66
|
+
|
|
67
|
+
# The tables of a system whose program names no tables list.
|
|
68
|
+
NO_MARKED_TABLES = { marked: {} }.freeze #: Hash[Symbol, untyped]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# What `table` holds by `tables`, when it is marked; nil for a table
|
|
72
|
+
# that holds state, or when the list was not read.
|
|
73
|
+
#: (Hash[Symbol, untyped], untyped) -> String?
|
|
74
|
+
def self.mark_of(tables, table)
|
|
75
|
+
return nil if tables[:unread] || !table.is_a?(String)
|
|
76
|
+
|
|
77
|
+
tables[:marked][table]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# What `tables` says of a line a count of `selection` would count:
|
|
81
|
+
# "counted", a holding the count leaves out, or "unknown". Only a db
|
|
82
|
+
# selection that names no table leaves a line out.
|
|
83
|
+
#: (Hash[String, untyped], Line, Hash[Symbol, untyped]) -> String
|
|
84
|
+
def self.table_rule(selection, line, tables)
|
|
85
|
+
return "counted" if selection["kind"] != "db" || selection.key?("table")
|
|
86
|
+
return "counted" unless line.event? && line.kind == "db"
|
|
87
|
+
return "unknown" if tables[:unread]
|
|
88
|
+
|
|
89
|
+
table = (line.object || {})["table"]
|
|
90
|
+
return tables[:marked].any? ? "unknown" : "counted" if table == "unknown"
|
|
91
|
+
|
|
92
|
+
mark_of(tables, table) || "counted"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# The order a record lists gaps in: GAP_WORDS, then the service a gap
|
|
96
|
+
# names.
|
|
97
|
+
#: (Hash[Symbol, untyped]) -> [Integer, String]
|
|
98
|
+
def self.gap_order(gap) = [GAP_WORDS.index(gap[:gap]) || GAP_WORDS.size, gap[:service].to_s]
|
|
99
|
+
|
|
100
|
+
# The gaps of a reading of a selection of `kind`: the trace's, and
|
|
101
|
+
# `kind-unreported` when the system's program reported no line of it.
|
|
102
|
+
#: (Array[Hash[Symbol, untyped]], String, (KindsSeen | AnyKindsSeen)) -> Array[Hash[Symbol, untyped]]
|
|
103
|
+
def self.reading_gaps(open, kind, kinds)
|
|
104
|
+
gaps = kinds.has?(kind) ? open.dup : [*open, { gap: "kind-unreported", kind: kind }]
|
|
105
|
+
gaps.sort_by { gap_order(_1) }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Each service whose file a reading found replaced or made shorter, as
|
|
109
|
+
# its gaps say: the file a later pass reads is not the one it read.
|
|
110
|
+
#: (Array[Hash[Symbol, untyped]]) -> Hash[String, bool]
|
|
111
|
+
def self.replaced_services(open)
|
|
112
|
+
open.filter_map { [_1[:service].to_s, true] if _1[:gap] == "file-replaced" && _1[:service] }.to_h
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# The kinds a system's program has reported so far.
|
|
116
|
+
class KindsSeen
|
|
117
|
+
#: () -> void
|
|
118
|
+
def initialize
|
|
119
|
+
@seen = {} #: Hash[String, bool]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#: (Line) -> void
|
|
123
|
+
def note(line) = (@seen[line.kind.to_s] = true if line.event?)
|
|
124
|
+
|
|
125
|
+
#: (String) -> bool
|
|
126
|
+
def has?(kind) = @seen.key?(kind)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# The kinds any of several services' programs has reported: what a
|
|
130
|
+
# count that names no service reads, since one service reporting a
|
|
131
|
+
# kind is enough for its absence elsewhere to mean something. `note`
|
|
132
|
+
# goes to none of them: each is noted where its own lines are read.
|
|
133
|
+
class AnyKindsSeen
|
|
134
|
+
#: (Array[KindsSeen]) -> void
|
|
135
|
+
def initialize(seen)
|
|
136
|
+
@seen = seen
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
#: (Line) -> void
|
|
140
|
+
def note(line) = nil
|
|
141
|
+
|
|
142
|
+
#: (String) -> bool
|
|
143
|
+
def has?(kind) = @seen.any? { _1.has?(kind) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Whether a db line's change persisted, from the lines noted so far.
|
|
147
|
+
class CommitIndex
|
|
148
|
+
#: () -> void
|
|
149
|
+
def initialize
|
|
150
|
+
@by_id = {} #: Hash[String, Symbol]
|
|
151
|
+
@parents = {} #: Hash[String, [bool, untyped]]
|
|
152
|
+
@repeated = {} #: Hash[String, bool]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
#: (Line) -> void
|
|
156
|
+
def note(line)
|
|
157
|
+
id = (line.object || {})["id"]
|
|
158
|
+
return unless id.is_a?(String)
|
|
159
|
+
return @repeated[id] = true if @by_id.key?(id)
|
|
160
|
+
|
|
161
|
+
@by_id[id] = if %w[undefined-kind unknown-version].include?(line.state) then :unknown
|
|
162
|
+
elsif line.event? && line.kind == "tx" then (line.object || {})["phase"] == "rollback" ? :rolled_back : :committed
|
|
163
|
+
else :other
|
|
164
|
+
end
|
|
165
|
+
object = line.object || {}
|
|
166
|
+
@parents[id] = [object.key?("parent"), object["parent"]]
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# "persisted", "not-persisted", or "unknown".
|
|
170
|
+
#: (Hash[String, untyped]) -> String
|
|
171
|
+
def state_of(object)
|
|
172
|
+
own = object["committed"]
|
|
173
|
+
return "unknown" if object.key?("committed") && ![true, false].include?(own)
|
|
174
|
+
|
|
175
|
+
ends = :no_tx
|
|
176
|
+
seen = {} #: Hash[String, bool]
|
|
177
|
+
has_next = object.key?("parent")
|
|
178
|
+
after = object["parent"]
|
|
179
|
+
txs = 0
|
|
180
|
+
loop do
|
|
181
|
+
unless has_next
|
|
182
|
+
ends = txs.positive? ? :committed : :no_tx
|
|
183
|
+
break
|
|
184
|
+
end
|
|
185
|
+
if !after.is_a?(String) || seen[after] || @repeated[after]
|
|
186
|
+
ends = :ambiguous
|
|
187
|
+
break
|
|
188
|
+
end
|
|
189
|
+
seen[after] = true
|
|
190
|
+
found = @by_id[after]
|
|
191
|
+
if found.nil?
|
|
192
|
+
ends = :dangling
|
|
193
|
+
break
|
|
194
|
+
end
|
|
195
|
+
if found == :unknown
|
|
196
|
+
ends = :ambiguous
|
|
197
|
+
break
|
|
198
|
+
end
|
|
199
|
+
if found == :other
|
|
200
|
+
ends = txs.positive? ? :committed : :no_tx
|
|
201
|
+
break
|
|
202
|
+
end
|
|
203
|
+
if found == :rolled_back
|
|
204
|
+
ends = :rolled_back
|
|
205
|
+
break
|
|
206
|
+
end
|
|
207
|
+
txs += 1
|
|
208
|
+
has_next, after = @parents.fetch(after, [false, nil])
|
|
209
|
+
end
|
|
210
|
+
if object.key?("committed")
|
|
211
|
+
return "unknown" if %i[rolled_back ambiguous].include?(ends)
|
|
212
|
+
|
|
213
|
+
return own ? "persisted" : "not-persisted"
|
|
214
|
+
end
|
|
215
|
+
return "not-persisted" if ends == :rolled_back
|
|
216
|
+
return "persisted" if ends == :committed
|
|
217
|
+
|
|
218
|
+
"unknown"
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Every span id the step stamped, in no particular service's order.
|
|
223
|
+
#: (Hash[Symbol, untyped]) -> Array[String]
|
|
224
|
+
def self.spans_of(inputs) = inputs[:spans].values.flatten
|
|
225
|
+
|
|
226
|
+
# How many requests the step stamped, the ones whose span id was not
|
|
227
|
+
# kept included.
|
|
228
|
+
#: (Hash[Symbol, untyped]) -> Integer
|
|
229
|
+
def self.stamped_count(inputs) = spans_of(inputs).size + (inputs[:spans_not_kept] || {}).values.sum
|
|
230
|
+
|
|
231
|
+
# What one service's lines said, as the fold counts them. A service
|
|
232
|
+
# holds the commit chains of its own lines, since a `tx` of one
|
|
233
|
+
# process holds no statement of another.
|
|
234
|
+
class ServiceState
|
|
235
|
+
attr_accessor :lines, :unreadable, :unowned, :process_requests, :bare
|
|
236
|
+
attr_reader :kinds, :jobs, :commits
|
|
237
|
+
|
|
238
|
+
#: () -> void
|
|
239
|
+
def initialize
|
|
240
|
+
@lines = 0
|
|
241
|
+
@unreadable = 0
|
|
242
|
+
@unowned = 0
|
|
243
|
+
@process_requests = 0
|
|
244
|
+
@bare = 0
|
|
245
|
+
@kinds = Hash.new(0) #: Hash[String, Integer]
|
|
246
|
+
@jobs = {} #: Hash[String, [Integer, Integer]]
|
|
247
|
+
@commits = CommitIndex.new
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# One trace's lines, folded in each service's file order.
|
|
252
|
+
class Tally
|
|
253
|
+
# `inputs`: `spans` (the span ids of the requests the step stamped,
|
|
254
|
+
# by the service each went to), `spans_not_kept` (by service),
|
|
255
|
+
# `processes` ("none", "ended", or "unbounded"), `process_spans`,
|
|
256
|
+
# `mcp_spans`, `selections` (each `selection` with the one `service`
|
|
257
|
+
# it counts, if it names one), `tables` (by service), and
|
|
258
|
+
# `unrecorded` (each service whose events nukadoko does not read).
|
|
259
|
+
#: (Hash[Symbol, untyped]) -> void
|
|
260
|
+
def initialize(inputs)
|
|
261
|
+
@inputs = inputs
|
|
262
|
+
@stamped = Events.spans_of(inputs).to_h { [_1, true] } #: Hash[String, bool]
|
|
263
|
+
@reported = {} #: Hash[String, bool]
|
|
264
|
+
@process_spans = (inputs[:process_spans] || []).to_h { [_1, true] } #: Hash[String, bool]
|
|
265
|
+
@mcp_spans = (inputs[:mcp_spans] || []).uniq #: Array[String]
|
|
266
|
+
@selections = inputs[:selections] || [] #: Array[Hash[Symbol, untyped]]
|
|
267
|
+
@tables = inputs[:tables] || {} #: Hash[String, Hash[Symbol, untyped]]
|
|
268
|
+
@states = {} #: Hash[String, ServiceState]
|
|
269
|
+
@counts = @selections.map { { yes: 0, maybe: MAYBE_CAUSES.to_h { [_1, 0] } } }
|
|
270
|
+
@grouped = @selections.map { Counted::Groups.new(_1[:selection]["kind"]) }
|
|
271
|
+
@left_out = @selections.map { Counted::Groups.new(_1[:selection]["kind"]) }
|
|
272
|
+
@awaiting = @selections.map { [] } #: Array[Array[[Hash[String, untyped], String, String]]]
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# A readable line of `service`'s file whose trace is the tally's, in
|
|
276
|
+
# file order.
|
|
277
|
+
#: (Line, String) -> void
|
|
278
|
+
def owned(line, service)
|
|
279
|
+
state = state_of(service)
|
|
280
|
+
tables = tables_of(service)
|
|
281
|
+
state.lines += 1
|
|
282
|
+
state.kinds[line.kind.to_s] += 1
|
|
283
|
+
state.commits.note(line)
|
|
284
|
+
object = line.object || {}
|
|
285
|
+
@selections.each_with_index do |counted, index|
|
|
286
|
+
next unless counting?(index, service)
|
|
287
|
+
|
|
288
|
+
selection = counted[:selection]
|
|
289
|
+
match = Selection.match(selection, line)
|
|
290
|
+
next if match == "no"
|
|
291
|
+
|
|
292
|
+
rule = Events.table_rule(selection, line, tables)
|
|
293
|
+
count = @counts[index]
|
|
294
|
+
if match == "commit-state"
|
|
295
|
+
@awaiting[index] << [object, %w[counted unknown].include?(rule) ? rule : "left-out", service]
|
|
296
|
+
elsif rule == "counted"
|
|
297
|
+
if match == "yes"
|
|
298
|
+
count[:yes] += 1
|
|
299
|
+
@grouped[index].add(object)
|
|
300
|
+
else count[:maybe][match] += 1
|
|
301
|
+
end
|
|
302
|
+
elsif rule == "unknown" then count[:maybe][match == "yes" ? "holds_unknown" : match] += 1
|
|
303
|
+
elsif match == "yes" then @left_out[index].add(object)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
return unless line.event?
|
|
307
|
+
|
|
308
|
+
span = line.trace&.span
|
|
309
|
+
if line.kind == "request"
|
|
310
|
+
if span.nil? then state.bare += 1
|
|
311
|
+
elsif @stamped.key?(span) then @reported[span] = true
|
|
312
|
+
elsif @process_spans.key?(span) then state.process_requests += 1
|
|
313
|
+
end
|
|
314
|
+
elsif line.kind == "job"
|
|
315
|
+
enqueues, performs = state.jobs.fetch(object["job_id"], [0, 0])
|
|
316
|
+
state.jobs[object["job_id"]] = object["phase"] == "enqueue" ? [enqueues + 1, performs] : [enqueues, performs + 1]
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
# An unreadable line of `service`'s file whose text carries the
|
|
321
|
+
# tally's trace id.
|
|
322
|
+
#: (String) -> void
|
|
323
|
+
def damaged(service)
|
|
324
|
+
state_of(service).unreadable += 1
|
|
325
|
+
@counts.each_with_index { |count, index| count[:maybe]["unreadable"] += 1 if counting?(index, service) }
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# A readable line of `service`'s file that no step owns, written in
|
|
329
|
+
# the step's window.
|
|
330
|
+
#: (Line, String) -> void
|
|
331
|
+
def unowned(line, service)
|
|
332
|
+
state_of(service).unowned += 1
|
|
333
|
+
@selections.each_with_index do |counted, index|
|
|
334
|
+
next unless counting?(index, service)
|
|
335
|
+
next if Selection.match(counted[:selection], line) == "no"
|
|
336
|
+
|
|
337
|
+
@counts[index][:maybe]["unowned"] += 1 if %w[counted unknown].include?(Events.table_rule(counted[:selection], line, tables_of(service)))
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# What the lines folded so far say, with what each service's reader
|
|
342
|
+
# knows of its file: `files` is `truncated` and `replaced` by
|
|
343
|
+
# service. A service with no entry in `files` has none in the
|
|
344
|
+
# reading.
|
|
345
|
+
#: (Hash[String, Hash[Symbol, bool]]) -> Hash[Symbol, untyped]
|
|
346
|
+
def reading(files)
|
|
347
|
+
read = files.map { |service, file| [service, state_of(service), file] } #: Array[[String, ServiceState, Hash[Symbol, bool]]]
|
|
348
|
+
requests = Events.stamped_count(@inputs)
|
|
349
|
+
mcp_unbounded = @mcp_spans.count { !@stamped.key?(_1) }
|
|
350
|
+
processes = @inputs[:processes]
|
|
351
|
+
open = [] #: Array[Hash[Symbol, untyped]]
|
|
352
|
+
open << { gap: "no-requests" } if requests.zero? && processes == "none" && @mcp_spans.empty?
|
|
353
|
+
open << { gap: "processes-unbounded" } if processes == "unbounded"
|
|
354
|
+
open << { gap: "mcp-unbounded", calls: mcp_unbounded } if mcp_unbounded.positive?
|
|
355
|
+
(@inputs[:unrecorded] || []).each { open << { gap: "service-unrecorded", service: _1 } }
|
|
356
|
+
read.each { |service, state, file| open.concat(service_gaps(service, state, file)) }
|
|
357
|
+
open = open.sort_by { Events.gap_order(_1) }
|
|
358
|
+
counts = @selections.each_with_index.map { |counted, index| decided(counted[:selection], index, read) }
|
|
359
|
+
{ lines: read.sum { _2.lines }, unreadable: read.sum { _2.unreadable }, unowned: read.sum { _2.unowned },
|
|
360
|
+
services: read.to_h { |service, state, _file|
|
|
361
|
+
[service, { lines: state.lines, kinds: state.kinds.dup, unreadable: state.unreadable,
|
|
362
|
+
unowned: state.unowned, process_requests: state.process_requests }]
|
|
363
|
+
},
|
|
364
|
+
whole: open.empty?, open: open, counts: counts }
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
private
|
|
368
|
+
|
|
369
|
+
#: (String) -> ServiceState
|
|
370
|
+
def state_of(service) = @states[service] ||= ServiceState.new
|
|
371
|
+
|
|
372
|
+
#: (String) -> Hash[Symbol, untyped]
|
|
373
|
+
def tables_of(service) = @tables[service] || NO_MARKED_TABLES
|
|
374
|
+
|
|
375
|
+
# Whether the count at `index` counts what `service`'s file holds:
|
|
376
|
+
# every service's, unless the count names one.
|
|
377
|
+
#: (Integer, String) -> bool
|
|
378
|
+
def counting?(index, service)
|
|
379
|
+
named = @selections[index][:service]
|
|
380
|
+
named.nil? || named == service
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
# What one service's lines leave open.
|
|
384
|
+
#: (String, ServiceState, Hash[Symbol, bool]) -> Array[Hash[Symbol, untyped]]
|
|
385
|
+
def service_gaps(service, state, file)
|
|
386
|
+
sent = (@inputs[:spans][service] || []).size + ((@inputs[:spans_not_kept] || {})[service] || 0)
|
|
387
|
+
matched = (@inputs[:spans][service] || []).count { @reported.key?(_1) }
|
|
388
|
+
unmatched = [0, sent - matched - state.bare].max
|
|
389
|
+
silent = sent.positive? && state.lines.zero? && state.unreadable.zero? && !file[:replaced]
|
|
390
|
+
pending = state.jobs.select { |_, (enqueues, performs)| performs < enqueues }.keys
|
|
391
|
+
gaps = [] #: Array[Hash[Symbol, untyped]]
|
|
392
|
+
gaps << { gap: "no-lines", service: service } if silent
|
|
393
|
+
gaps << { gap: "request-unreported", service: service, requests: unmatched } if !silent && unmatched.positive?
|
|
394
|
+
gaps << { gap: "jobs-pending", service: service, job_ids: pending } if pending.any?
|
|
395
|
+
gaps << { gap: "unreadable", service: service, lines: state.unreadable } if state.unreadable.positive?
|
|
396
|
+
gaps << { gap: "truncated", service: service } if file[:truncated]
|
|
397
|
+
gaps << { gap: "file-replaced", service: service } if file[:replaced]
|
|
398
|
+
gaps
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
#: (Hash[String, untyped], Integer, Array[untyped]) -> Hash[Symbol, untyped]
|
|
402
|
+
def decided(selection, index, read)
|
|
403
|
+
count = @counts[index]
|
|
404
|
+
wanted = selection["committed"] == true ? "persisted" : "not-persisted"
|
|
405
|
+
matched = [] #: Array[Hash[String, untyped]]
|
|
406
|
+
out = [] #: Array[Hash[String, untyped]]
|
|
407
|
+
unknown = 0
|
|
408
|
+
holds_unknown = 0
|
|
409
|
+
@awaiting[index].each do |object, as, service|
|
|
410
|
+
state = state_of(service).commits.state_of(object)
|
|
411
|
+
if state == "unknown"
|
|
412
|
+
unknown += 1 unless as == "left-out"
|
|
413
|
+
elsif state == wanted
|
|
414
|
+
case as
|
|
415
|
+
when "counted" then matched << object
|
|
416
|
+
when "unknown" then holds_unknown += 1
|
|
417
|
+
else out << object
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
maybe = count[:maybe].merge("holds_unknown" => count[:maybe]["holds_unknown"] + holds_unknown, "commit_unknown" => count[:maybe]["commit_unknown"] + unknown)
|
|
422
|
+
{ yes: count[:yes] + matched.size, maybe: maybe, counted: @grouped[index].groups(matched),
|
|
423
|
+
left_out: @left_out[index].groups(out).map { _1.merge(holds: Events.mark_of(marking_tables(read, _1[:fields]["table"]), _1[:fields]["table"])) } }
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# The tables list that marks `table`, among the services read: a
|
|
427
|
+
# table one service's list marks is that service's.
|
|
428
|
+
#: (Array[untyped], untyped) -> Hash[Symbol, untyped]
|
|
429
|
+
def marking_tables(read, table)
|
|
430
|
+
return NO_MARKED_TABLES unless table.is_a?(String)
|
|
431
|
+
|
|
432
|
+
found = read.find { |service, _state, _file| Events.mark_of(tables_of(service), table) }
|
|
433
|
+
found.nil? ? NO_MARKED_TABLES : tables_of(found.first)
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
end
|
data/lib/nukadoko/features.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Nukadoko
|
|
|
12
12
|
# row of an outline, and `outline_name` the name as written, before a
|
|
13
13
|
# row fills it. A step from a Background has `background` set.
|
|
14
14
|
Scenario = Data.define(:uri, :line, :keyword_line, :name, :tags, :steps, :tag_lines, :columns, :outline_name, :serial)
|
|
15
|
-
PickleStep = Data.define(:text, :line, :kind, :table, :doc_string, :background)
|
|
15
|
+
PickleStep = Data.define(:text, :line, :kind, :table, :doc_string, :doc_string_media_type, :background)
|
|
16
16
|
# What makes a file, or a part of one, run nothing: a file that does
|
|
17
17
|
# not parse, or an outline with no row to run. `line` is nil for a file.
|
|
18
18
|
FeatureProblem = Data.define(:code, :uri, :line, :message)
|
|
@@ -45,7 +45,7 @@ module Nukadoko
|
|
|
45
45
|
steps = pickle.steps.map do |step|
|
|
46
46
|
table = step.argument&.data_table&.rows&.map { |row| row.cells.map(&:value) }
|
|
47
47
|
PickleStep.new(step.text, lines.fetch(step.ast_node_ids.first), step.type, table, step.argument&.doc_string&.content,
|
|
48
|
-
background.key?(step.ast_node_ids.first))
|
|
48
|
+
step.argument&.doc_string&.media_type, background.key?(step.ast_node_ids.first))
|
|
49
49
|
end
|
|
50
50
|
scenarios << Scenario.new(pickle.uri, lines.fetch(pickle.ast_node_ids.last), lines.fetch(pickle.ast_node_ids.first),
|
|
51
51
|
pickle.name, pickle.tags.map(&:name), steps,
|