nukadoko 0.6.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 +541 -3
- data/README.ja.md +20 -5
- data/README.md +12 -6
- 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 +395 -48
- 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 +1 -1
- data/lib/nukadoko/judgments.rb +4 -4
- 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 +1148 -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 +799 -29
- 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/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 +41 -34
- 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 +1 -1
- data/sig/generated/nukadoko/judgments.rbs +1 -1
- 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/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/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 +12 -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,423 @@
|
|
|
1
|
+
# Execution events, version 1
|
|
2
|
+
|
|
3
|
+
An execution event is one line that a program writes when one operation
|
|
4
|
+
ends: a request it served, a database statement, a transaction, a job,
|
|
5
|
+
an outgoing HTTP call, a feature flag it evaluated, an error.
|
|
6
|
+
The lines of one request, and of the jobs it enqueued, share one trace
|
|
7
|
+
id, so a reader can collect what the program did inside that request, in
|
|
8
|
+
the same shape on a laptop, in a test run, in staging, and in
|
|
9
|
+
production.
|
|
10
|
+
|
|
11
|
+
The format assumes no reader.
|
|
12
|
+
A test harness, a log pipeline, a database table, and a person with
|
|
13
|
+
`grep` and `jq` read the same lines.
|
|
14
|
+
Nothing in a line names the tool that reads it.
|
|
15
|
+
How nukadoko reads these lines is in [docs/spec.md](spec.md),
|
|
16
|
+
"Execution events".
|
|
17
|
+
|
|
18
|
+
The words "must", "must not", "should", and "may" have their RFC 2119
|
|
19
|
+
meanings.
|
|
20
|
+
|
|
21
|
+
## Where lines go
|
|
22
|
+
|
|
23
|
+
- A file holds UTF-8 text, one JSON object per line.
|
|
24
|
+
Each line ends with one line feed (0x0A).
|
|
25
|
+
The file has no byte order mark and no blank lines.
|
|
26
|
+
- The deployment names the file.
|
|
27
|
+
An environment variable is the usual way; the examples here use
|
|
28
|
+
`EXECUTION_EVENTS`.
|
|
29
|
+
When no path is set, the writer writes nothing and the program runs as
|
|
30
|
+
usual.
|
|
31
|
+
- The writer opens the file for appending (`O_APPEND`) and writes each
|
|
32
|
+
line, its line feed included, in one write call.
|
|
33
|
+
Several threads and several processes (a web server and a job worker,
|
|
34
|
+
two server processes) may append to one file this way.
|
|
35
|
+
A writer must not write part of a line, hold lines across operations
|
|
36
|
+
without writing them at each operation's end, or write through a stream
|
|
37
|
+
that splits large writes.
|
|
38
|
+
- A line should be at most 4095 bytes before its line feed.
|
|
39
|
+
Appends of one write call up to that size from several processes stay
|
|
40
|
+
whole on the platforms in common use; a longer one can be spliced with
|
|
41
|
+
another process's line.
|
|
42
|
+
A writer leaves out optional fields, `calls` first, rather than write
|
|
43
|
+
a longer line.
|
|
44
|
+
The caps under "Kinds" keep a usual line far below that size.
|
|
45
|
+
- A writer should check that the call wrote the whole line.
|
|
46
|
+
A short write leaves a damaged line, which a reader treats as
|
|
47
|
+
unreadable (see "Knowing that a trace is complete"), never as absent.
|
|
48
|
+
- Append to a local file.
|
|
49
|
+
A network file system may not keep appends from two hosts whole.
|
|
50
|
+
- A writer must not rewrite, truncate, or rotate the file while a reader
|
|
51
|
+
reads it.
|
|
52
|
+
Rotation in production renames the file and starts a new one between
|
|
53
|
+
reads.
|
|
54
|
+
A reader that sees the file get shorter, or a new file at the path,
|
|
55
|
+
knows that what it read may be incomplete.
|
|
56
|
+
- A failure to write must not fail the operation.
|
|
57
|
+
The writer should say so once on its standard error.
|
|
58
|
+
The rules under "Knowing that a trace is complete" make a missing line
|
|
59
|
+
visible to a reader.
|
|
60
|
+
- Other carriers hold the same record: a row per line in a table, one
|
|
61
|
+
message per line on a stream.
|
|
62
|
+
One JSON object is one event wherever it is kept.
|
|
63
|
+
|
|
64
|
+
## Inside first
|
|
65
|
+
|
|
66
|
+
An operation's line is written when the operation ends, after the lines
|
|
67
|
+
of every operation inside it.
|
|
68
|
+
|
|
69
|
+
- A request's line comes after every line that the request's own work
|
|
70
|
+
wrote in that process.
|
|
71
|
+
For a response whose body streams, the line is written when the body
|
|
72
|
+
ends or the client goes away, not when the headers are sent.
|
|
73
|
+
- A transaction's line is written when it commits or rolls back.
|
|
74
|
+
- A job's `perform` line comes after every line of that run of the job.
|
|
75
|
+
- Work that an operation starts and does not wait for (a thread, a
|
|
76
|
+
timer, a deferred callback) is a job: write an `enqueue` line when it
|
|
77
|
+
starts and a `perform` line when it ends.
|
|
78
|
+
Otherwise its lines can come after the request's line, and a reader
|
|
79
|
+
cannot tell that the request's work was still going on.
|
|
80
|
+
|
|
81
|
+
This rule is what lets a reader treat a request's line and a job's
|
|
82
|
+
`perform` line as "everything inside is written".
|
|
83
|
+
|
|
84
|
+
## Common fields
|
|
85
|
+
|
|
86
|
+
Every kind may carry these fields.
|
|
87
|
+
|
|
88
|
+
| Field | Type | Required | Meaning |
|
|
89
|
+
| --- | --- | --- | --- |
|
|
90
|
+
| `trace` | string | yes | The trace the line belongs to (below). |
|
|
91
|
+
| `kind` | string | yes | One of the kinds under "Kinds", or a name that starts with `x_`. |
|
|
92
|
+
| `id` | string | see below | This operation's id: 1 to 64 characters, unique within its trace. 16 random lowercase hexadecimal characters are recommended. |
|
|
93
|
+
| `parent` | string | no | The `id` of the operation this one happened inside, in the same trace. |
|
|
94
|
+
| `actor` | string | no | An opaque id of who acted (a user id, a session id, a hash of either). Never a name or an email address. |
|
|
95
|
+
| `at` | string | no | `path:line` of the code that performed the operation, with the path relative to the repository root. |
|
|
96
|
+
| `dur_ms` | number | no | How long the operation took, in milliseconds, 0 or more. |
|
|
97
|
+
| `time` | string | no | When the line was written, RFC 3339 in UTC with `Z`. |
|
|
98
|
+
| `v` | integer | no | The format version. Absent means 1. |
|
|
99
|
+
|
|
100
|
+
### `trace`
|
|
101
|
+
|
|
102
|
+
`trace` is a W3C Trace Context `traceparent` value
|
|
103
|
+
(`00-<32 hex trace id>-<16 hex parent id>-<2 hex flags>`), or a bare
|
|
104
|
+
trace id of 32 hexadecimal characters.
|
|
105
|
+
|
|
106
|
+
- A request's line carries the `traceparent` header the request arrived
|
|
107
|
+
with, unchanged.
|
|
108
|
+
The caller put its own span id in that header, so the caller can find
|
|
109
|
+
the line for each call it made.
|
|
110
|
+
A header that is not a valid `traceparent` counts as absent.
|
|
111
|
+
- When no valid header arrived, the program makes one with a new random
|
|
112
|
+
trace id and a new random parent id, and uses it as if it had arrived.
|
|
113
|
+
- Every line written inside a request carries the same `trace` value as
|
|
114
|
+
the request's line.
|
|
115
|
+
- A job carries the `trace` of the operation that enqueued it, in the
|
|
116
|
+
job's own payload.
|
|
117
|
+
Its `enqueue` line, its `perform` line, and every line inside the run
|
|
118
|
+
carry that value.
|
|
119
|
+
A job that no traced operation enqueued (a schedule, a console) makes
|
|
120
|
+
a new trace.
|
|
121
|
+
- An outgoing HTTP call should send a `traceparent` with the same trace
|
|
122
|
+
id and the `http` line's `id` as the parent id, so the service it calls
|
|
123
|
+
can write lines in the same trace.
|
|
124
|
+
- A command-line tool that calls the program should send the value of a
|
|
125
|
+
non-empty `TRACEPARENT` environment variable, the OpenTelemetry
|
|
126
|
+
convention for trace context carried through the environment, as the
|
|
127
|
+
`traceparent` header of its requests.
|
|
128
|
+
The program's lines for those requests then belong to the trace of
|
|
129
|
+
whatever ran the tool.
|
|
130
|
+
- Writers should write lowercase.
|
|
131
|
+
Readers compare trace ids without regard to case.
|
|
132
|
+
A trace id of all zeros, a parent id of all zeros, and the version
|
|
133
|
+
`ff` are invalid.
|
|
134
|
+
|
|
135
|
+
### `id` and `parent`
|
|
136
|
+
|
|
137
|
+
`id` must be present on every line that another line names as `parent`:
|
|
138
|
+
a `request`, a `tx`, a job's `perform` line.
|
|
139
|
+
It should be present on every line.
|
|
140
|
+
|
|
141
|
+
`parent` names the nearest enclosing operation.
|
|
142
|
+
A statement inside a transaction names the transaction; a savepoint
|
|
143
|
+
names the transaction around it; a transaction, a flag, or a job's
|
|
144
|
+
`enqueue` line inside a request names the request; a line inside a
|
|
145
|
+
job's run names that `perform` line's `id`.
|
|
146
|
+
A request's line and a job's `perform` line have no `parent` in the
|
|
147
|
+
trace.
|
|
148
|
+
|
|
149
|
+
## Value rules
|
|
150
|
+
|
|
151
|
+
- A line is one JSON object (RFC 8259).
|
|
152
|
+
No key appears twice in one object.
|
|
153
|
+
- An integer is between -(2^53 - 1) and 2^53 - 1.
|
|
154
|
+
Write a larger integer, such as a 64-bit id, as a string.
|
|
155
|
+
- Strings are valid UTF-8, with no unpaired surrogate.
|
|
156
|
+
- Write `null` only where "Kinds" allows it.
|
|
157
|
+
Leave an optional field out when there is nothing to say.
|
|
158
|
+
- A writer's own fields start with `x_`.
|
|
159
|
+
A reader keeps them and decides nothing on them, except a field a
|
|
160
|
+
project names in its intent ([docs/intent.md](intent.md)), which
|
|
161
|
+
`nuka run --base` compares between the base and the change.
|
|
162
|
+
A field that is neither defined here nor starts with `x_` is a
|
|
163
|
+
mistake; a reader may report it.
|
|
164
|
+
- A writer's own kinds start with `x_` too, with the same rule.
|
|
165
|
+
A kind that is neither defined here nor starts with `x_` is a mistake
|
|
166
|
+
or a later version's kind.
|
|
167
|
+
A reader that counts lines must treat such a line as possibly any
|
|
168
|
+
kind.
|
|
169
|
+
|
|
170
|
+
## Kinds
|
|
171
|
+
|
|
172
|
+
### `request`: a request the program served
|
|
173
|
+
|
|
174
|
+
| Field | Type | Required | Meaning |
|
|
175
|
+
| --- | --- | --- | --- |
|
|
176
|
+
| `method` | string | yes | The HTTP method, uppercase. |
|
|
177
|
+
| `route` | string or `null` | yes | The template of the route that matched (`/rooms/:room_id/scores`), never the path with its values. `null` when no route matched. |
|
|
178
|
+
| `status` | integer | yes | The status code sent. |
|
|
179
|
+
| `calls` | array of strings | no | The application functions the request ran through, as `path:line` of each definition, in the order of first call, each once, at most 200. |
|
|
180
|
+
|
|
181
|
+
A program that also prints every route it has, in these same words
|
|
182
|
+
(`method` and `route`), lets a reader find the routes no step
|
|
183
|
+
requested: see "Lists" in [docs/spec.md](spec.md).
|
|
184
|
+
|
|
185
|
+
### `db`: one database statement
|
|
186
|
+
|
|
187
|
+
| Field | Type | Required | Meaning |
|
|
188
|
+
| --- | --- | --- | --- |
|
|
189
|
+
| `table` | string | yes | The table the statement read or changed. `unknown` when the writer cannot tell. |
|
|
190
|
+
| `op` | string | yes | `read`, `insert`, `update`, `delete`, or `other`. `other` is any statement that can change data and is none of the three: an upsert whose branch the writer does not know, a schema change, a procedure call. |
|
|
191
|
+
| `rows` | integer or `null` | no | Rows the statement changed or returned. `null` when the driver does not say. |
|
|
192
|
+
| `ids` | array of strings or integers | no | The primary keys of the rows the statement changed. Present only when it is complete and has at most 100 entries; leave it out when there are more or the writer cannot tell. |
|
|
193
|
+
| `committed` | boolean | no | `true` when the change persisted with no transaction left to decide it (the statement ran outside a transaction). `false` when the writer knows it did not persist. Leave it out inside a transaction, and name the transaction in `parent`. |
|
|
194
|
+
|
|
195
|
+
A program that also prints what each of its tables holds, in these same
|
|
196
|
+
words (`table`), lets a reader tell a write to the program's state from
|
|
197
|
+
one to its own bookkeeping or infrastructure: see "What a table holds"
|
|
198
|
+
in [docs/spec.md](spec.md).
|
|
199
|
+
|
|
200
|
+
### `tx`: a transaction or a savepoint ended
|
|
201
|
+
|
|
202
|
+
| Field | Type | Required | Meaning |
|
|
203
|
+
| --- | --- | --- | --- |
|
|
204
|
+
| `id` | string | yes | The transaction's id, which the statements inside it name as `parent`. |
|
|
205
|
+
| `phase` | string | yes | `commit` or `rollback`. |
|
|
206
|
+
|
|
207
|
+
A savepoint is a `tx` line whose `parent` is the transaction around it.
|
|
208
|
+
A transaction that never ends (the process died) has no line, so the
|
|
209
|
+
state of its statements stays unknown (see "Whether a statement's change
|
|
210
|
+
persisted").
|
|
211
|
+
|
|
212
|
+
### `job`: a job enqueued, or a run of it ended
|
|
213
|
+
|
|
214
|
+
| Field | Type | Required | Meaning |
|
|
215
|
+
| --- | --- | --- | --- |
|
|
216
|
+
| `name` | string | yes | The job's type or class name. |
|
|
217
|
+
| `queue` | string | no | The queue it went to. |
|
|
218
|
+
| `phase` | string | yes | `enqueue` or `perform`. |
|
|
219
|
+
| `job_id` | string | yes | The job system's id of the job: the same value on its `enqueue` line and on its `perform` line. |
|
|
220
|
+
| `calls` | array of strings | no | As on `request`, for the run. |
|
|
221
|
+
|
|
222
|
+
- The `perform` line is written when the job system is done with that
|
|
223
|
+
enqueue: the job ran to the end, raised, or was dropped without
|
|
224
|
+
running.
|
|
225
|
+
A dropped job's `perform` line has no lines inside it.
|
|
226
|
+
- A run that will be tried again writes the retry's `enqueue` line
|
|
227
|
+
before its own `perform` line, since the retry was decided inside the
|
|
228
|
+
run.
|
|
229
|
+
A reader then never sees the job as done between a failed run and its
|
|
230
|
+
retry.
|
|
231
|
+
- A job that is enqueued with a delay writes its `enqueue` line when it
|
|
232
|
+
is enqueued, and its `perform` line when it runs.
|
|
233
|
+
|
|
234
|
+
### `http`: an outgoing HTTP call
|
|
235
|
+
|
|
236
|
+
| Field | Type | Required | Meaning |
|
|
237
|
+
| --- | --- | --- | --- |
|
|
238
|
+
| `method` | string | yes | The HTTP method, uppercase. |
|
|
239
|
+
| `origin` | string | yes | `scheme://host` with the port when it is not the default. Never user information. |
|
|
240
|
+
| `path` | string | yes | The path, with no query and no fragment. A template when the client knows one. |
|
|
241
|
+
| `status` | integer or `null` | yes | The status code received. `null` when no response came. |
|
|
242
|
+
|
|
243
|
+
A reader that compares two runs compares an `origin` on a loopback host
|
|
244
|
+
(`localhost`, `127.0.0.1`, `[::1]`) without its port.
|
|
245
|
+
A test run starts the services it calls on ports it picks as it runs,
|
|
246
|
+
so the same call reaches another port on every run.
|
|
247
|
+
A writer still writes the port.
|
|
248
|
+
An origin on any other host keeps its port, since there a port names a
|
|
249
|
+
different service.
|
|
250
|
+
|
|
251
|
+
### `flag`: a feature flag evaluated
|
|
252
|
+
|
|
253
|
+
| Field | Type | Required | Meaning |
|
|
254
|
+
| --- | --- | --- | --- |
|
|
255
|
+
| `name` | string | yes | The flag's name. |
|
|
256
|
+
| `side` | string | yes | What the program got: `on`, `off`, or a variant's name. |
|
|
257
|
+
| `gate` | string | no | What decided it: `boolean`, `actor`, or `percentage`. |
|
|
258
|
+
|
|
259
|
+
Write one line for each evaluation, the `off` side too.
|
|
260
|
+
A difference between two sides' paths needs both.
|
|
261
|
+
|
|
262
|
+
### `error`: an error raised
|
|
263
|
+
|
|
264
|
+
| Field | Type | Required | Meaning |
|
|
265
|
+
| --- | --- | --- | --- |
|
|
266
|
+
| `class` | string | yes | The error's class or code. |
|
|
267
|
+
| `handled` | boolean | yes | `true` when the program caught it and went on, `false` when it ended the operation. |
|
|
268
|
+
|
|
269
|
+
There is no message field: messages carry values.
|
|
270
|
+
`at` should name where the error was raised.
|
|
271
|
+
|
|
272
|
+
Write `handled: false` only for an error that ended the operation.
|
|
273
|
+
nukadoko reads such a line in a step's trace as a failure of the program.
|
|
274
|
+
A scenario that passed over one is `broke` in its cell, unless its tag `@expects:error=<class>` names the line's `class`.
|
|
275
|
+
|
|
276
|
+
## Whether a statement's change persisted
|
|
277
|
+
|
|
278
|
+
A reader decides the commit state of a `db` line from the lines of its
|
|
279
|
+
trace only:
|
|
280
|
+
|
|
281
|
+
1. When the line has `committed`, that is its state, unless a `tx` on
|
|
282
|
+
its parent chain rolled back, which makes the state unknown.
|
|
283
|
+
2. Otherwise, follow `parent` while it names a `tx` line of the trace.
|
|
284
|
+
The change persisted when every `tx` on that chain committed.
|
|
285
|
+
It did not persist when any of them rolled back.
|
|
286
|
+
The state is unknown when the chain names an id that no line of the
|
|
287
|
+
trace has (yet), or when an id appears on two lines.
|
|
288
|
+
3. A line with neither `committed` nor a `tx` parent has an unknown
|
|
289
|
+
state.
|
|
290
|
+
|
|
291
|
+
A reader must never read an unknown state as either answer.
|
|
292
|
+
A writer that cannot name the transaction a statement ran in leaves both
|
|
293
|
+
out, and the statement's state is honestly unknown.
|
|
294
|
+
|
|
295
|
+
Two cases a writer gets wrong easily:
|
|
296
|
+
|
|
297
|
+
- Rails 8.1, when it rolls back to a savepoint, sends
|
|
298
|
+
`ROLLBACK TO SAVEPOINT x` and then, at once, `RELEASE SAVEPOINT x`.
|
|
299
|
+
A writer that reads `RELEASE` as a commit reports a write that was
|
|
300
|
+
rolled back as persisted.
|
|
301
|
+
Pair the two statements by the savepoint's name, and write a `tx` line
|
|
302
|
+
for the first outcome only.
|
|
303
|
+
- A write inside a transaction that began before the request has no
|
|
304
|
+
transaction line in the trace: the test's own transaction around each
|
|
305
|
+
test, which a test framework opens so that the test leaves no rows
|
|
306
|
+
behind, is the usual case.
|
|
307
|
+
`committed: true` is false there, since the test's transaction rolls
|
|
308
|
+
back when the test ends.
|
|
309
|
+
Give such a statement a `parent` that no line of the trace carries, so
|
|
310
|
+
that a reader resolves its state as unknown.
|
|
311
|
+
In Rails, `connection.transaction_open?` tells the two cases apart for
|
|
312
|
+
a statement outside every transaction the request began: it is true
|
|
313
|
+
inside the test's transaction, and false when the statement commits on
|
|
314
|
+
its own.
|
|
315
|
+
|
|
316
|
+
## Knowing that a trace is complete
|
|
317
|
+
|
|
318
|
+
A count of lines ("no row was written", "one score was inserted") means
|
|
319
|
+
something only when the reader knows that every line it counts has been
|
|
320
|
+
written.
|
|
321
|
+
The format gives the reader these facts:
|
|
322
|
+
|
|
323
|
+
1. **Every request it sent has its line.**
|
|
324
|
+
The caller knows the parent id it put in each `traceparent` it sent,
|
|
325
|
+
and each request's line carries that header back.
|
|
326
|
+
When the line for each of those ids is in the file, the inside-first
|
|
327
|
+
rule says the requests' own work is written.
|
|
328
|
+
A line whose `trace` is a bare trace id stands for one request, which
|
|
329
|
+
one unknown.
|
|
330
|
+
2. **Every job is done.**
|
|
331
|
+
For each `job_id` in the trace, the file holds at least as many
|
|
332
|
+
`perform` lines as `enqueue` lines.
|
|
333
|
+
The order does not matter: a fast job can write its `perform` line
|
|
334
|
+
before the request writes its own.
|
|
335
|
+
3. **Nothing was lost on the way.**
|
|
336
|
+
The file was not replaced, truncated, or made shorter while the
|
|
337
|
+
reader read it.
|
|
338
|
+
|
|
339
|
+
Until all three hold, a count is a lower bound only.
|
|
340
|
+
And:
|
|
341
|
+
|
|
342
|
+
- No line at all for a trace is never evidence that nothing happened: a
|
|
343
|
+
program without a writer, or with the wrong path, writes nothing too.
|
|
344
|
+
Fact 1 needs at least one request line.
|
|
345
|
+
- A line the reader cannot parse, of a kind or a version it does not
|
|
346
|
+
know, or whose field a count reads is missing or invalid, may be any
|
|
347
|
+
line.
|
|
348
|
+
It raises the upper bound of a count by one; it never disappears.
|
|
349
|
+
- A line of the trace that arrives after the reader decided means the
|
|
350
|
+
decision was made on less than the whole trace.
|
|
351
|
+
The reader should keep that line apart, as late, and say that the
|
|
352
|
+
decision was not final.
|
|
353
|
+
- Lines from several processes are in write order, not in time order.
|
|
354
|
+
A reader must not assume that one process's line came before another's
|
|
355
|
+
because it is earlier in the file.
|
|
356
|
+
|
|
357
|
+
## What a line must not hold
|
|
358
|
+
|
|
359
|
+
- No values from rows, no statement text with values, no request or
|
|
360
|
+
response bodies, no headers, no cookies, no tokens, no error messages.
|
|
361
|
+
- Primary keys only, at most 100 of them on one line.
|
|
362
|
+
- Route templates, not paths with ids.
|
|
363
|
+
Outgoing paths without the query.
|
|
364
|
+
- `actor` is opaque.
|
|
365
|
+
|
|
366
|
+
Trace ids and span ids are not secrets.
|
|
367
|
+
A pipeline that redacts lines should keep 32-character and 16-character
|
|
368
|
+
hexadecimal ids whole, because they are what ties the lines of a trace
|
|
369
|
+
together.
|
|
370
|
+
|
|
371
|
+
## Versions
|
|
372
|
+
|
|
373
|
+
This is version 1.
|
|
374
|
+
A writer of version 1 leaves `v` out or writes `1`.
|
|
375
|
+
Any change to the kinds, the fields, or the rules above is a new
|
|
376
|
+
version, and its lines carry `v`.
|
|
377
|
+
A reader that does not know a line's version treats the line as
|
|
378
|
+
unreadable: it may be any line.
|
|
379
|
+
|
|
380
|
+
## Example
|
|
381
|
+
|
|
382
|
+
A request places a score.
|
|
383
|
+
It reads the room, evaluates a flag, inserts the score inside a
|
|
384
|
+
transaction, enqueues a job that recalculates the ranking, and commits.
|
|
385
|
+
A separate worker process runs the job, which updates the ranking
|
|
386
|
+
outside a transaction.
|
|
387
|
+
Both processes append to one file.
|
|
388
|
+
The caller sent
|
|
389
|
+
`traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01`.
|
|
390
|
+
|
|
391
|
+
```jsonl
|
|
392
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"db","id":"9c1e0b7a4d2f8e63","parent":"5a0f3c9e1b7d2486","table":"rooms","op":"read","rows":1,"dur_ms":0.3}
|
|
393
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"flag","id":"e47b2d90c3a15f68","parent":"5a0f3c9e1b7d2486","name":"score_input_slider","side":"off","gate":"boolean"}
|
|
394
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"db","id":"2b8d6f0e9a3c1745","parent":"c7e2a1f04b9d3866","table":"scores","op":"insert","rows":1,"ids":[42],"at":"app/models/room.rb:88","dur_ms":0.6}
|
|
395
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"job","id":"0d5c8a2e7f1b3946","parent":"5a0f3c9e1b7d2486","name":"ScoreRecalcJob","queue":"default","phase":"enqueue","job_id":"3f2a9c41"}
|
|
396
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"tx","id":"c7e2a1f04b9d3866","parent":"5a0f3c9e1b7d2486","phase":"commit","dur_ms":1.4}
|
|
397
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"request","id":"5a0f3c9e1b7d2486","method":"POST","route":"/rooms/:room_id/scores","status":303,"dur_ms":12.5}
|
|
398
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"db","id":"8f3a0c6d2e9b1574","parent":"b1d94e7a0c3f5862","table":"rankings","op":"update","rows":3,"committed":true,"dur_ms":0.9}
|
|
399
|
+
{"trace":"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01","kind":"job","id":"b1d94e7a0c3f5862","name":"ScoreRecalcJob","queue":"default","phase":"perform","job_id":"3f2a9c41","dur_ms":4.1}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
What a reader can say, line by line:
|
|
403
|
+
|
|
404
|
+
- After line 6, the caller's request (parent id `00f067aa0ba902b7`) has
|
|
405
|
+
its line, so the request's own work is written.
|
|
406
|
+
Job `3f2a9c41` has one `enqueue` and no `perform`, so the trace is not
|
|
407
|
+
complete yet: "the ranking was not changed" cannot be known.
|
|
408
|
+
- After line 8, the job has one `perform` for its one `enqueue`, and the
|
|
409
|
+
trace is complete.
|
|
410
|
+
- The insert on line 3 names transaction `c7e2a1f04b9d3866`, which line
|
|
411
|
+
5 says committed, so the score persisted.
|
|
412
|
+
Line 7 states `committed: true` itself.
|
|
413
|
+
- Inserts into `scores` that persisted: exactly 1.
|
|
414
|
+
Writes that persisted: exactly 2 (lines 3 and 7).
|
|
415
|
+
Flags evaluated: `score_input_slider`, side `off`.
|
|
416
|
+
|
|
417
|
+
The same request, refused because the score is out of range, writes one
|
|
418
|
+
line, and a reader that sent it can say "nothing was written" once that
|
|
419
|
+
line is there and no job is open:
|
|
420
|
+
|
|
421
|
+
```jsonl
|
|
422
|
+
{"trace":"00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01","kind":"request","id":"71e0c4a9d3b28f56","method":"POST","route":"/rooms/:room_id/scores","status":422,"dur_ms":3.2}
|
|
423
|
+
```
|