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
data/docs/intent.ja.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# 意図のファイル
|
|
2
|
+
|
|
3
|
+
変更は、判定される作業より前に、何を違うようにするつもりかを、リポジトリの最上位の `INTENT.md` で宣言します。
|
|
4
|
+
レビューする人は、書かれた意図を承認します。
|
|
5
|
+
そのあと機械が、実際の振る舞いの変化を意図と比べます。
|
|
6
|
+
nukadoko はそうした機械の 1 つです。
|
|
7
|
+
`nuka run --base <ref>` は、シナリオの実行イベントに対してこのファイルを読みます([docs/spec.ja.md](spec.ja.md) の「変更の意図」を参照)。
|
|
8
|
+
このページは書式だけを書きます。
|
|
9
|
+
アプリケーション自身がすべての契約の決定を比べるツールのような、ほかのツールが、nukadoko なしで同じファイルを読めるようにするためです。
|
|
10
|
+
|
|
11
|
+
## ファイルの場所と、どのファイルが数えられるか
|
|
12
|
+
|
|
13
|
+
- ファイルは、リポジトリの最上位の `INTENT.md` です。
|
|
14
|
+
- ファイルは、それを書いた変更のものです。
|
|
15
|
+
基点が同じテキストで持つファイルは前の変更の意図で、読み手はそれを無視します。
|
|
16
|
+
- 変更の最初のコミットで書きます。
|
|
17
|
+
そのあとファイルを変えるコミットは意図の変化で、レビューする人はそれをそのように読みます。
|
|
18
|
+
nukadoko は、意図を宣言したコミット、それが最初のコミットだったか、そのあと意図を変えた各コミットを名指します。
|
|
19
|
+
|
|
20
|
+
## 表
|
|
21
|
+
|
|
22
|
+
ファイルは Markdown です。
|
|
23
|
+
読み手が読む表は 1 つです。
|
|
24
|
+
見出しの行がちょうど次のとおりである最初の表を、表の行でない最初の行の前まで読みます。
|
|
25
|
+
その前後の文は人のためのものです。
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
| Target | Observation | Before | After |
|
|
29
|
+
| --- | --- | --- | --- |
|
|
30
|
+
| x_result.reason=plan:team x_result.seats>=10 | x_decision x_result.features | ["projects","sso"] | ["projects","sso","audit_log"] |
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
セルは 2 つの `|` のあいだのテキストを、前後の空白を除いたものです。
|
|
34
|
+
セルの中の `|` は `\|` と書きます。
|
|
35
|
+
見出しがあって行の無い表は、何も変わらないことを宣言します。
|
|
36
|
+
|
|
37
|
+
各行は 1 つの主張です。
|
|
38
|
+
対象が名指す行について、観測するものが前から後へ動く、という主張です。
|
|
39
|
+
|
|
40
|
+
## 項
|
|
41
|
+
|
|
42
|
+
対象と観測は、空白で区切った項です。
|
|
43
|
+
|
|
44
|
+
- `field<op>value` は、行のフィールドがその値のとき成り立ちます。
|
|
45
|
+
`op` は `=`、`!=`、`<`、`<=`、`>`、`>=` のどれかです。
|
|
46
|
+
大小は、2 つの数か 2 つの文字列のあいだでだけ比べます。
|
|
47
|
+
そのフィールドを持たない行では、どの項も成り立ちません。
|
|
48
|
+
- フィールドは行の中へのドット区切りの道筋です。
|
|
49
|
+
`x_result.seats` は、行の `x_result` オブジェクトの `seats` です。
|
|
50
|
+
- 値は、JSON として読めるときは JSON で、そうでなければ書いたとおりのテキストです。
|
|
51
|
+
`plan:team` と `"plan:team"` は同じ値で、`10` は数、`"10"` は文字列です。
|
|
52
|
+
空白を含む値は `"two words"` のように JSON で書きます。
|
|
53
|
+
項は、JSON の文字列の外かつ括弧の外にある空白で終わるので、`["a", "b"]` は 1 つの値です。
|
|
54
|
+
|
|
55
|
+
## 列
|
|
56
|
+
|
|
57
|
+
| 列 | 持つもの |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| Target | 行が扱う受け入れ基準か行。`@tag` の項と `field<op>value` の項で、すべてが成り立つ必要があります。空ならすべてです。 |
|
|
60
|
+
| Observation | [docs/execution-events.ja.md](execution-events.ja.md) の行の種類、観測する行を絞る `field<op>value` の項、そして多くとも 1 つの値の無いフィールド(その値を観測するフィールド)です。 |
|
|
61
|
+
| Before | 基点で観測するものです。 |
|
|
62
|
+
| After | 変更のあとで観測するものです。 |
|
|
63
|
+
|
|
64
|
+
- 対象の `field<op>value` の項は、観測する行の上で読みます。
|
|
65
|
+
そのため、決定の対象についての条件は、決定の行そのものに書きます。
|
|
66
|
+
行が対象を `x_subject` に持つなら `x_subject.plan=team` のようにです。
|
|
67
|
+
- `@tag` の項はシナリオの tag を名指し、行が扱うシナリオを絞るだけです。
|
|
68
|
+
行が扱う振る舞いは、tag ではなく、観測する行の上の `field<op>value` の項で書きます。
|
|
69
|
+
シナリオを持たないツールは `@tag` の項を評価できず、それを持つ行を `not_reached` と報告します。
|
|
70
|
+
- 種類は `request`、`db`、`http`、`job`、`flag`、`error` か、`x_` で始まる書き手自身の種類です。
|
|
71
|
+
書式の種類のフィールドは、粗い実行経路が保つものです。
|
|
72
|
+
`request` は `method`、`route`、`status`、`db` は `table`、`op`、`http` は `method`、`origin`、`path`、`status`、`job` は `name`、`phase`、`flag` は `name`、`side`、`error` は `class`、`handled` です。
|
|
73
|
+
データベースの読み取りはどの実行経路にも入らないので、`db op=read` は何にも当てはまりません。
|
|
74
|
+
ループバックのホスト(`localhost`、`127.0.0.1`、`[::1]`)の `http` の行の `origin` は、ポートを除いて比べます。
|
|
75
|
+
テストの run は走りながらポートを選ぶからです。
|
|
76
|
+
`origin` の項も同じように読みます。
|
|
77
|
+
`origin=http://localhost` も `origin=http://localhost:3000` も、どのポートの `localhost` への呼び出しにも当てはまります。
|
|
78
|
+
ほかのホストのオリジンはポートを保ちます。
|
|
79
|
+
書き手自身の種類のフィールドは `x_` で始まります。
|
|
80
|
+
- 観測するフィールドが無いとき、前と後は整数です。
|
|
81
|
+
1 つの step が作る、観測する行の数です。
|
|
82
|
+
新しい呼び出しなら `0` と `1` です。
|
|
83
|
+
- 観測するフィールドがあるとき、前と後はそのフィールドの値です。
|
|
84
|
+
その行は、前を持っていた行が、同じ数だけ後を持つようになると言います。
|
|
85
|
+
値が変わり、行の数も変わるときは、2 つの行で書きます。
|
|
86
|
+
数のための、観測するフィールドの無い行と、値のための、フィールドのある行です。
|
|
87
|
+
- 前と後がどちらも空のとき、その行は、観測するものが何であれ変わらないと言います。
|
|
88
|
+
リファクタは、どの決定も変わらないと言うために `| | x_decision x_result | | |` と書きます。
|
|
89
|
+
前と後は、どちらも埋めるか、どちらも空にします。
|
|
90
|
+
|
|
91
|
+
## 決定の入力
|
|
92
|
+
|
|
93
|
+
決定のイベントは、その入力を持つべきです。
|
|
94
|
+
対象が名指すフィールドを、`x_input` オブジェクトのように持ちます。
|
|
95
|
+
対象は観測する行の上で読むので、入力を持つ決定なら、どのツールも同じ対象を同じフィールドで評価できます。
|
|
96
|
+
シナリオを走らせるツールでも、すべての契約の決定を比べるツールでも同じです。
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
| Target | Observation | Before | After |
|
|
100
|
+
| --- | --- | --- | --- |
|
|
101
|
+
| x_input.plan=team x_input.status=active x_input.seats>=10 | x_decision x_result.features | ["projects","sso"] | ["projects","sso","audit_log"] |
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 行の結果
|
|
105
|
+
|
|
106
|
+
ツールは各行を次のどれかとして報告します:
|
|
107
|
+
|
|
108
|
+
| 結果 | 意味 |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| `as_intended` | 行が扱うものはどれも、行が言うとおりにしました。 |
|
|
111
|
+
| `not_happening` | 行が扱うもののどれかが、行が言うとおりにしませんでした。動かなかった数や値、または変わらないと言う行で動いたものです。 |
|
|
112
|
+
| `not_reached` | 比較は、行が扱うものを見つけませんでした。ほかの比較が届くかもしれません。 |
|
|
113
|
+
|
|
114
|
+
ツールが見つける各違いは、どれかの行が宣言しているか、意図していないものです。
|
|
115
|
+
ツールは、意図していない違いと、`not_happening` の行で失敗します。
|
|
116
|
+
`not_reached` の行は、それだけでは何も失敗させません。
|
|
117
|
+
どの比較がそれを扱うべきかを言います。
|
|
118
|
+
|
|
119
|
+
## 数行で書ける読み手
|
|
120
|
+
|
|
121
|
+
ほかの言語の読み手は、表の各行を `\` が前に無い `|` で分け、各セルの前後の空白を除き、セルを JSON の文字列と括弧の外にある空白で項に分けます。
|
|
122
|
+
次の JavaScript が行を読みます:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
const lines = text.split(/\r?\n/);
|
|
126
|
+
const at = lines.findIndex((line) => /^\|\s*Target\s*\|\s*Observation\s*\|\s*Before\s*\|\s*After\s*\|\s*$/.test(line));
|
|
127
|
+
const rows = [];
|
|
128
|
+
for (const line of lines.slice(at + 2)) {
|
|
129
|
+
if (!line.trim().startsWith("|")) break;
|
|
130
|
+
const cells = line.trim().slice(1, -1).split(/(?<!\\)\|/).map((cell) => cell.replaceAll("\\|", "|").trim());
|
|
131
|
+
rows.push({ target: cells[0], observation: cells[1], before: cells[2], after: cells[3] });
|
|
132
|
+
}
|
|
133
|
+
```
|
data/docs/intent.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# The intent file
|
|
2
|
+
|
|
3
|
+
A change declares what it means to do differently in `INTENT.md` at the
|
|
4
|
+
repository's top, before the work it judges.
|
|
5
|
+
A reviewer approves the intent as written.
|
|
6
|
+
A machine then compares the real behavior change with it.
|
|
7
|
+
nukadoko is one such machine: `nuka run --base <ref>` reads the file
|
|
8
|
+
against the scenarios' execution events (see "The change's intent" in
|
|
9
|
+
[docs/spec.md](spec.md)).
|
|
10
|
+
This page is the format alone, so another tool, such as an
|
|
11
|
+
application's own comparison of every contract's decision, reads the
|
|
12
|
+
same file without nukadoko.
|
|
13
|
+
|
|
14
|
+
## Where the file is, and which one counts
|
|
15
|
+
|
|
16
|
+
- The file is `INTENT.md` at the top of the repository.
|
|
17
|
+
- It belongs to the change that wrote it.
|
|
18
|
+
A file the base holds with the same text is an earlier change's intent,
|
|
19
|
+
and a reader ignores it.
|
|
20
|
+
- Write it in the change's first commit.
|
|
21
|
+
A later commit that changes it is a change of intent, which the
|
|
22
|
+
reviewer reads as such: nukadoko names the commit that declared it,
|
|
23
|
+
whether that was the first, and each later commit that changed it.
|
|
24
|
+
|
|
25
|
+
## The table
|
|
26
|
+
|
|
27
|
+
The file is Markdown.
|
|
28
|
+
A reader reads one table: the first one whose header row is exactly
|
|
29
|
+
this, and its rows up to the first line that is not a table row.
|
|
30
|
+
Prose before and after it is for people.
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
| Target | Observation | Before | After |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| x_result.reason=plan:team x_result.seats>=10 | x_decision x_result.features | ["projects","sso"] | ["projects","sso","audit_log"] |
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
A cell is the text between two `|`, trimmed.
|
|
39
|
+
A `|` inside a cell is written `\|`.
|
|
40
|
+
A table with a header and no row declares that nothing changes.
|
|
41
|
+
|
|
42
|
+
Each row is one claim: for the lines the target names, the observation
|
|
43
|
+
goes from before to after.
|
|
44
|
+
|
|
45
|
+
## Terms
|
|
46
|
+
|
|
47
|
+
A target and an observation are terms separated by spaces.
|
|
48
|
+
|
|
49
|
+
- `field<op>value` holds when a line's field has that value.
|
|
50
|
+
`op` is one of `=`, `!=`, `<`, `<=`, `>`, `>=`.
|
|
51
|
+
An order compares two numbers or two strings, and nothing else.
|
|
52
|
+
A line that does not have the field meets no term on it.
|
|
53
|
+
- A field is a dotted path into a line: `x_result.seats` is the `seats`
|
|
54
|
+
of the line's `x_result` object.
|
|
55
|
+
- A value is JSON when it parses as JSON, and is otherwise the text as
|
|
56
|
+
written: `plan:team` and `"plan:team"` are the same value, `10` is a
|
|
57
|
+
number, and `"10"` is a string.
|
|
58
|
+
A value with a space in it is written as JSON: `"two words"`.
|
|
59
|
+
A term ends at a space that is outside a JSON string and outside
|
|
60
|
+
brackets, so `["a", "b"]` is one value.
|
|
61
|
+
|
|
62
|
+
## Columns
|
|
63
|
+
|
|
64
|
+
| Column | Holds |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Target | Which criteria or lines the row is about: `@tag` terms and `field<op>value` terms, all of which must hold. Empty means every one. |
|
|
67
|
+
| Observation | A kind of line from [docs/execution-events.md](execution-events.md), then `field<op>value` terms that narrow which lines are observed, then at most one field with no value, the field whose value is observed. |
|
|
68
|
+
| Before | What the observation is at the base. |
|
|
69
|
+
| After | What it is after the change. |
|
|
70
|
+
|
|
71
|
+
- A `field<op>value` term of the target is read on the observed line.
|
|
72
|
+
So a condition on a decision's subject is written on the decision's
|
|
73
|
+
own line, such as `x_subject.plan=team` when the line carries its
|
|
74
|
+
subject in `x_subject`.
|
|
75
|
+
- A `@tag` term names a scenario tag, and only narrows which scenarios
|
|
76
|
+
the row covers.
|
|
77
|
+
The behavior the row is about is written as `field<op>value` terms
|
|
78
|
+
on the observed line, never as a tag.
|
|
79
|
+
A tool that has no scenarios cannot evaluate a `@tag` term, and
|
|
80
|
+
reports a row that has one as `not_reached`.
|
|
81
|
+
- The kind is one of `request`, `db`, `http`, `job`, `flag`, `error`, or
|
|
82
|
+
a writer's own kind that starts with `x_`.
|
|
83
|
+
A field of the format's kind is one a coarse path keeps: `request`
|
|
84
|
+
`method`, `route`, `status`; `db` `table`, `op`; `http` `method`,
|
|
85
|
+
`origin`, `path`, `status`; `job` `name`, `phase`; `flag` `name`,
|
|
86
|
+
`side`; `error` `class`, `handled`.
|
|
87
|
+
A database read is in no path, so `db op=read` matches nothing.
|
|
88
|
+
An `http` line's `origin` on a loopback host (`localhost`,
|
|
89
|
+
`127.0.0.1`, `[::1]`) is compared without its port, since a test run
|
|
90
|
+
picks its ports as it runs, and an `origin` term is read the same
|
|
91
|
+
way: `origin=http://localhost` and `origin=http://localhost:3000`
|
|
92
|
+
both aim at a call to `localhost` on any port.
|
|
93
|
+
An origin on any other host keeps its port.
|
|
94
|
+
A field of a writer's own kind starts with `x_`.
|
|
95
|
+
- With no field to observe, before and after are whole numbers: how many
|
|
96
|
+
observed lines one step makes, such as `0` and `1` for a new call.
|
|
97
|
+
- With a field to observe, before and after are values of that field.
|
|
98
|
+
The row says that the lines that held before now hold after, as many
|
|
99
|
+
as there were.
|
|
100
|
+
A change of value that also changes how many lines there are is two
|
|
101
|
+
rows: a row with no field to observe for the count, and a row with
|
|
102
|
+
the field for the value.
|
|
103
|
+
- When before and after are both empty, the row says that the
|
|
104
|
+
observation does not change, whatever it is.
|
|
105
|
+
A refactor writes `| | x_decision x_result | | |` to say that no
|
|
106
|
+
decision changes.
|
|
107
|
+
Before and after are both filled, or both empty.
|
|
108
|
+
|
|
109
|
+
## A decision's inputs
|
|
110
|
+
|
|
111
|
+
A decision event should carry its inputs: the fields a target names,
|
|
112
|
+
such as an `x_input` object.
|
|
113
|
+
A target is read on the observed line, so a decision that carries its
|
|
114
|
+
inputs lets every tool evaluate the same target on the same fields,
|
|
115
|
+
whether the tool runs scenarios or compares every contract's decision.
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
| Target | Observation | Before | After |
|
|
119
|
+
| --- | --- | --- | --- |
|
|
120
|
+
| x_input.plan=team x_input.status=active x_input.seats>=10 | x_decision x_result.features | ["projects","sso"] | ["projects","sso","audit_log"] |
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## What a row comes to
|
|
124
|
+
|
|
125
|
+
A tool reports each row as one of these:
|
|
126
|
+
|
|
127
|
+
| Result | Meaning |
|
|
128
|
+
| --- | --- |
|
|
129
|
+
| `as_intended` | Each thing the row is about did what it says. |
|
|
130
|
+
| `not_happening` | Something the row is about did not do what it says: a count or a value that did not move, or a row of no change that moved. |
|
|
131
|
+
| `not_reached` | The comparison found nothing the row is about. Another comparison may reach it. |
|
|
132
|
+
|
|
133
|
+
And each difference the tool finds is declared by a row, or it is
|
|
134
|
+
unintended.
|
|
135
|
+
A tool fails on an unintended difference and on a row that is
|
|
136
|
+
`not_happening`.
|
|
137
|
+
A row that is `not_reached` fails nothing by itself: it says which
|
|
138
|
+
comparison has to cover it.
|
|
139
|
+
|
|
140
|
+
## A reader in a few lines
|
|
141
|
+
|
|
142
|
+
A reader of another language splits each line of the table at the `|`
|
|
143
|
+
that `\` does not escape, trims each cell, and splits a cell into terms
|
|
144
|
+
at the spaces outside JSON strings and brackets.
|
|
145
|
+
This JavaScript reads the rows:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
const lines = text.split(/\r?\n/);
|
|
149
|
+
const at = lines.findIndex((line) => /^\|\s*Target\s*\|\s*Observation\s*\|\s*Before\s*\|\s*After\s*\|\s*$/.test(line));
|
|
150
|
+
const rows = [];
|
|
151
|
+
for (const line of lines.slice(at + 2)) {
|
|
152
|
+
if (!line.trim().startsWith("|")) break;
|
|
153
|
+
const cells = line.trim().slice(1, -1).split(/(?<!\\)\|/).map((cell) => cell.replaceAll("\\|", "|").trim());
|
|
154
|
+
rows.push({ target: cells[0], observation: cells[1], before: cells[2], after: cells[3] });
|
|
155
|
+
}
|
|
156
|
+
```
|