@lovrozagar/oat 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +26 -1936
  2. package/dist/cli.js +326 -60
  3. package/dist/config/define-config.d.ts +15 -1
  4. package/dist/config/define-config.d.ts.map +1 -1
  5. package/dist/config/define-config.js.map +1 -1
  6. package/dist/config/validate.d.ts +12 -0
  7. package/dist/config/validate.d.ts.map +1 -0
  8. package/dist/config/validate.js +86 -0
  9. package/dist/config/validate.js.map +1 -0
  10. package/dist/conformance/effects.d.ts +9 -0
  11. package/dist/conformance/effects.d.ts.map +1 -0
  12. package/dist/conformance/effects.js +276 -0
  13. package/dist/conformance/effects.js.map +1 -0
  14. package/dist/conformance/expected-failures.d.ts +18 -0
  15. package/dist/conformance/expected-failures.d.ts.map +1 -0
  16. package/dist/conformance/expected-failures.js +48 -0
  17. package/dist/conformance/expected-failures.js.map +1 -0
  18. package/dist/conformance/feature-gate.d.ts +7 -0
  19. package/dist/conformance/feature-gate.d.ts.map +1 -0
  20. package/dist/conformance/feature-gate.js +428 -0
  21. package/dist/conformance/feature-gate.js.map +1 -0
  22. package/dist/conformance/fuzz.d.ts +108 -0
  23. package/dist/conformance/fuzz.d.ts.map +1 -0
  24. package/dist/conformance/fuzz.js +246 -0
  25. package/dist/conformance/fuzz.js.map +1 -0
  26. package/dist/conformance/leaks.d.ts +10 -0
  27. package/dist/conformance/leaks.d.ts.map +1 -0
  28. package/dist/conformance/leaks.js +23 -0
  29. package/dist/conformance/leaks.js.map +1 -0
  30. package/dist/conformance/pool.d.ts +49 -0
  31. package/dist/conformance/pool.d.ts.map +1 -0
  32. package/dist/conformance/pool.js +75 -0
  33. package/dist/conformance/pool.js.map +1 -0
  34. package/dist/conformance/rate-limit.d.ts +7 -0
  35. package/dist/conformance/rate-limit.d.ts.map +1 -0
  36. package/dist/conformance/rate-limit.js +372 -0
  37. package/dist/conformance/rate-limit.js.map +1 -0
  38. package/dist/conformance/scope.d.ts +15 -0
  39. package/dist/conformance/scope.d.ts.map +1 -0
  40. package/dist/conformance/scope.js +78 -0
  41. package/dist/conformance/scope.js.map +1 -0
  42. package/dist/conformance/seed-contract.d.ts +11 -0
  43. package/dist/conformance/seed-contract.d.ts.map +1 -0
  44. package/dist/conformance/seed-contract.js +680 -0
  45. package/dist/conformance/seed-contract.js.map +1 -0
  46. package/dist/conformance/shapes.d.ts +35 -0
  47. package/dist/conformance/shapes.d.ts.map +1 -0
  48. package/dist/conformance/shapes.js +162 -0
  49. package/dist/conformance/shapes.js.map +1 -0
  50. package/dist/conformance/specs.d.ts +21 -0
  51. package/dist/conformance/specs.d.ts.map +1 -0
  52. package/dist/conformance/specs.js +306 -0
  53. package/dist/conformance/specs.js.map +1 -0
  54. package/dist/conformance/suite.d.ts +209 -0
  55. package/dist/conformance/suite.d.ts.map +1 -0
  56. package/dist/conformance/suite.js +1538 -0
  57. package/dist/conformance/suite.js.map +1 -0
  58. package/dist/conformance/unique.d.ts +7 -0
  59. package/dist/conformance/unique.d.ts.map +1 -0
  60. package/dist/conformance/unique.js +586 -0
  61. package/dist/conformance/unique.js.map +1 -0
  62. package/dist/conformance/worker.d.ts +3 -0
  63. package/dist/conformance/worker.d.ts.map +1 -0
  64. package/dist/conformance/worker.js +27 -0
  65. package/dist/conformance/worker.js.map +1 -0
  66. package/dist/index.d.ts +10 -3
  67. package/dist/index.js +6 -2
  68. package/dist/reference/defects.d.ts +71 -1
  69. package/dist/reference/defects.d.ts.map +1 -1
  70. package/dist/reference/defects.js +74 -8
  71. package/dist/reference/defects.js.map +1 -1
  72. package/dist/reference/dialect.d.ts +6 -4
  73. package/dist/reference/dialect.d.ts.map +1 -1
  74. package/dist/reference/dialect.js +1 -0
  75. package/dist/reference/dialect.js.map +1 -1
  76. package/dist/reference/http.d.ts +17 -25
  77. package/dist/reference/http.d.ts.map +1 -1
  78. package/dist/reference/http.js +574 -224
  79. package/dist/reference/http.js.map +1 -1
  80. package/dist/reference/listing.d.ts +51 -0
  81. package/dist/reference/listing.d.ts.map +1 -0
  82. package/dist/reference/listing.js +256 -0
  83. package/dist/reference/listing.js.map +1 -0
  84. package/dist/reference/model.d.ts +35 -1
  85. package/dist/reference/model.d.ts.map +1 -1
  86. package/dist/reference/model.js +42 -0
  87. package/dist/reference/model.js.map +1 -1
  88. package/dist/reference/query.d.ts +132 -43
  89. package/dist/reference/query.d.ts.map +1 -1
  90. package/dist/reference/query.js +397 -315
  91. package/dist/reference/query.js.map +1 -1
  92. package/dist/reference/shapes.d.ts +60 -0
  93. package/dist/reference/shapes.d.ts.map +1 -0
  94. package/dist/reference/shapes.js +142 -0
  95. package/dist/reference/shapes.js.map +1 -0
  96. package/dist/reference/spec.d.ts +9 -2
  97. package/dist/reference/spec.d.ts.map +1 -1
  98. package/dist/reference/spec.js +291 -71
  99. package/dist/reference/spec.js.map +1 -1
  100. package/dist/reference/store-api.d.ts +14 -43
  101. package/dist/reference/store-api.d.ts.map +1 -1
  102. package/dist/reference/store-api.js +8 -58
  103. package/dist/reference/store-api.js.map +1 -1
  104. package/dist/reference/stores/memory.d.ts +12 -15
  105. package/dist/reference/stores/memory.d.ts.map +1 -1
  106. package/dist/reference/stores/memory.js +22 -70
  107. package/dist/reference/stores/memory.js.map +1 -1
  108. package/dist/reference/stores/postgres.d.ts +11 -23
  109. package/dist/reference/stores/postgres.d.ts.map +1 -1
  110. package/dist/reference/stores/postgres.js +53 -334
  111. package/dist/reference/stores/postgres.js.map +1 -1
  112. package/dist/reference/stores/sql-compile.d.ts +36 -0
  113. package/dist/reference/stores/sql-compile.d.ts.map +1 -0
  114. package/dist/reference/stores/sql-compile.js +95 -0
  115. package/dist/reference/stores/sql-compile.js.map +1 -0
  116. package/dist/reference/stores/sqlite.d.ts +12 -27
  117. package/dist/reference/stores/sqlite.d.ts.map +1 -1
  118. package/dist/reference/stores/sqlite.js +54 -355
  119. package/dist/reference/stores/sqlite.js.map +1 -1
  120. package/dist/report/console.d.ts +2 -1
  121. package/dist/report/console.d.ts.map +1 -1
  122. package/dist/report/console.js +56 -10
  123. package/dist/report/console.js.map +1 -1
  124. package/dist/report/matrix.d.ts +10 -13
  125. package/dist/report/matrix.d.ts.map +1 -1
  126. package/dist/report/matrix.js +82 -18
  127. package/dist/report/matrix.js.map +1 -1
  128. package/dist/report/render.d.ts +18 -1
  129. package/dist/report/render.d.ts.map +1 -1
  130. package/dist/report/render.js +169 -14
  131. package/dist/report/render.js.map +1 -1
  132. package/dist/runtime/async.d.ts +16 -3
  133. package/dist/runtime/async.d.ts.map +1 -1
  134. package/dist/runtime/async.js +24 -19
  135. package/dist/runtime/async.js.map +1 -1
  136. package/dist/runtime/auth.d.ts +2 -9
  137. package/dist/runtime/auth.d.ts.map +1 -1
  138. package/dist/runtime/auth.js +38 -62
  139. package/dist/runtime/auth.js.map +1 -1
  140. package/dist/runtime/body.d.ts +15 -3
  141. package/dist/runtime/body.d.ts.map +1 -1
  142. package/dist/runtime/body.js +61 -12
  143. package/dist/runtime/body.js.map +1 -1
  144. package/dist/runtime/check-costs.d.ts +15 -0
  145. package/dist/runtime/check-costs.d.ts.map +1 -0
  146. package/dist/runtime/check-costs.js +114 -0
  147. package/dist/runtime/check-costs.js.map +1 -0
  148. package/dist/runtime/check-ids.d.ts +15 -0
  149. package/dist/runtime/check-ids.d.ts.map +1 -0
  150. package/dist/runtime/check-ids.js +140 -0
  151. package/dist/runtime/check-ids.js.map +1 -0
  152. package/dist/runtime/checks.d.ts +122 -18
  153. package/dist/runtime/checks.d.ts.map +1 -1
  154. package/dist/runtime/checks.js +3437 -1933
  155. package/dist/runtime/checks.js.map +1 -1
  156. package/dist/runtime/client.d.ts +112 -0
  157. package/dist/runtime/client.d.ts.map +1 -1
  158. package/dist/runtime/client.js +271 -39
  159. package/dist/runtime/client.js.map +1 -1
  160. package/dist/runtime/cookies.d.ts +16 -2
  161. package/dist/runtime/cookies.d.ts.map +1 -1
  162. package/dist/runtime/cookies.js +83 -22
  163. package/dist/runtime/cookies.js.map +1 -1
  164. package/dist/runtime/exchanges.d.ts +4 -5
  165. package/dist/runtime/exchanges.d.ts.map +1 -1
  166. package/dist/runtime/exchanges.js +33 -55
  167. package/dist/runtime/exchanges.js.map +1 -1
  168. package/dist/runtime/exit.d.ts +40 -0
  169. package/dist/runtime/exit.d.ts.map +1 -0
  170. package/dist/runtime/exit.js +48 -0
  171. package/dist/runtime/exit.js.map +1 -0
  172. package/dist/runtime/feature-gate.d.ts +0 -9
  173. package/dist/runtime/feature-gate.d.ts.map +1 -1
  174. package/dist/runtime/feature-gate.js +0 -21
  175. package/dist/runtime/feature-gate.js.map +1 -1
  176. package/dist/runtime/finding.d.ts +61 -7
  177. package/dist/runtime/finding.d.ts.map +1 -1
  178. package/dist/runtime/finding.js +74 -12
  179. package/dist/runtime/finding.js.map +1 -1
  180. package/dist/runtime/fixture.d.ts +35 -28
  181. package/dist/runtime/fixture.d.ts.map +1 -1
  182. package/dist/runtime/fixture.js +92 -731
  183. package/dist/runtime/fixture.js.map +1 -1
  184. package/dist/runtime/generate.d.ts +63 -0
  185. package/dist/runtime/generate.d.ts.map +1 -0
  186. package/dist/runtime/generate.js +635 -0
  187. package/dist/runtime/generate.js.map +1 -0
  188. package/dist/runtime/headers.d.ts +6 -0
  189. package/dist/runtime/headers.d.ts.map +1 -0
  190. package/dist/runtime/headers.js +16 -0
  191. package/dist/runtime/headers.js.map +1 -0
  192. package/dist/runtime/path.d.ts +7 -0
  193. package/dist/runtime/path.d.ts.map +1 -0
  194. package/dist/runtime/path.js +44 -0
  195. package/dist/runtime/path.js.map +1 -0
  196. package/dist/runtime/payloads.d.ts +2 -0
  197. package/dist/runtime/payloads.d.ts.map +1 -1
  198. package/dist/runtime/payloads.js +2 -1
  199. package/dist/runtime/payloads.js.map +1 -1
  200. package/dist/runtime/rate-limit.d.ts +6 -4
  201. package/dist/runtime/rate-limit.d.ts.map +1 -1
  202. package/dist/runtime/rate-limit.js +22 -33
  203. package/dist/runtime/rate-limit.js.map +1 -1
  204. package/dist/runtime/redact.d.ts +24 -0
  205. package/dist/runtime/redact.d.ts.map +1 -0
  206. package/dist/runtime/redact.js +98 -0
  207. package/dist/runtime/redact.js.map +1 -0
  208. package/dist/runtime/run.d.ts +51 -2
  209. package/dist/runtime/run.d.ts.map +1 -1
  210. package/dist/runtime/run.js +463 -195
  211. package/dist/runtime/run.js.map +1 -1
  212. package/dist/runtime/runs.d.ts +5 -0
  213. package/dist/runtime/runs.d.ts.map +1 -1
  214. package/dist/runtime/runs.js +7 -1
  215. package/dist/runtime/runs.js.map +1 -1
  216. package/dist/runtime/scope.d.ts +163 -0
  217. package/dist/runtime/scope.d.ts.map +1 -0
  218. package/dist/runtime/scope.js +423 -0
  219. package/dist/runtime/scope.js.map +1 -0
  220. package/dist/runtime/teardown.d.ts +17 -4
  221. package/dist/runtime/teardown.d.ts.map +1 -1
  222. package/dist/runtime/teardown.js +49 -16
  223. package/dist/runtime/teardown.js.map +1 -1
  224. package/dist/runtime/transcript.d.ts +34 -2
  225. package/dist/runtime/transcript.d.ts.map +1 -1
  226. package/dist/runtime/transcript.js +119 -24
  227. package/dist/runtime/transcript.js.map +1 -1
  228. package/dist/runtime/unique.d.ts +2 -11
  229. package/dist/runtime/unique.d.ts.map +1 -1
  230. package/dist/runtime/unique.js +27 -53
  231. package/dist/runtime/unique.js.map +1 -1
  232. package/dist/runtime/validate.d.ts +13 -2
  233. package/dist/runtime/validate.d.ts.map +1 -1
  234. package/dist/runtime/validate.js +51 -31
  235. package/dist/runtime/validate.js.map +1 -1
  236. package/dist/runtime/wait.d.ts +2 -1
  237. package/dist/runtime/wait.d.ts.map +1 -1
  238. package/dist/runtime/wait.js +2 -36
  239. package/dist/runtime/wait.js.map +1 -1
  240. package/dist/runtime/world.d.ts +31 -3
  241. package/dist/runtime/world.d.ts.map +1 -1
  242. package/dist/runtime/world.js +113 -32
  243. package/dist/runtime/world.js.map +1 -1
  244. package/dist/spec/collection.d.ts +8 -2
  245. package/dist/spec/collection.d.ts.map +1 -1
  246. package/dist/spec/collection.js +47 -7
  247. package/dist/spec/collection.js.map +1 -1
  248. package/dist/spec/extensions.d.ts +5 -1
  249. package/dist/spec/extensions.d.ts.map +1 -1
  250. package/dist/spec/extensions.js +9 -2
  251. package/dist/spec/extensions.js.map +1 -1
  252. package/dist/spec/graph.d.ts +46 -0
  253. package/dist/spec/graph.d.ts.map +1 -1
  254. package/dist/spec/graph.js +175 -11
  255. package/dist/spec/graph.js.map +1 -1
  256. package/dist/spec/load.d.ts +25 -5
  257. package/dist/spec/load.d.ts.map +1 -1
  258. package/dist/spec/load.js +160 -59
  259. package/dist/spec/load.js.map +1 -1
  260. package/dist/spec/query-capabilities.d.ts +4 -0
  261. package/dist/spec/query-capabilities.d.ts.map +1 -1
  262. package/dist/spec/query-capabilities.js +6 -0
  263. package/dist/spec/query-capabilities.js.map +1 -1
  264. package/dist/spec/schema.d.ts +20 -0
  265. package/dist/spec/schema.d.ts.map +1 -0
  266. package/dist/spec/schema.js +118 -0
  267. package/dist/spec/schema.js.map +1 -0
  268. package/dist/spec/tag-schema.d.ts +12 -0
  269. package/dist/spec/tag-schema.d.ts.map +1 -0
  270. package/dist/spec/tag-schema.js +143 -0
  271. package/dist/spec/tag-schema.js.map +1 -0
  272. package/dist/spec/types.js +17 -1
  273. package/dist/spec/types.js.map +1 -1
  274. package/docs/api.md +59 -0
  275. package/docs/assumptions.md +99 -0
  276. package/docs/checks.md +183 -0
  277. package/docs/commands.md +214 -0
  278. package/docs/configuration.md +650 -0
  279. package/docs/model.md +184 -0
  280. package/docs/reference-defects.md +94 -0
  281. package/docs/reports.md +211 -0
  282. package/docs/tags.md +400 -0
  283. package/package.json +3 -1
package/README.md CHANGED
@@ -30,46 +30,17 @@ Those are disagreements between **projections of the same fact**. That is the ma
30
30
 
31
31
  There is no ground-truth database. A filter and its negation must partition the set. A page walk must cover the collection without gaps or dupes. List, item, and `id.eq.` must show the same field. One root cause is one finding; checks that depend on a broken primitive are `BLOCKED`, not a page of copies.
32
32
 
33
- This file is the operator manual. An agent that has read it can install oat, write every kind of config, run every command, tag a document, interpret every outcome, and know what each check needs and asserts.
34
-
35
- ## Table of contents
36
-
37
- - [Install](#install)
38
- - [How a run works](#how-a-run-works)
39
- - [Quick start](#quick-start)
40
- - [Complete configs](#complete-configs)
41
- - [Commands](#commands)
42
- - [oat run](#oat-run)
43
- - [oat doctor](#oat-doctor)
44
- - [oat plan](#oat-plan)
45
- - [oat serve](#oat-serve)
46
- - [oat conformance](#oat-conformance)
47
- - [Configuration](#configuration)
48
- - [Top-level fields](#top-level-fields)
49
- - [Principals](#principals)
50
- - [Auth flows](#auth-flows)
51
- - [Harvested principal](#harvested-principal)
52
- - [Secondary origins](#secondary-origins)
53
- - [Hooks](#hooks)
54
- - [Uploads](#uploads)
55
- - [Environment interpolation](#environment-interpolation)
56
- - [Loading TypeScript configs](#loading-typescript-configs)
57
- - [How the model is derived](#how-the-model-is-derived)
58
- - [Seeding](#seeding)
59
- - [Query roles and grammars](#query-roles-and-grammars)
60
- - [Pagination and envelopes](#pagination-and-envelopes)
61
- - [OpenAPI meta tags](#openapi-meta-tags)
62
- - [Checks](#checks)
63
- - [Verdicts, skips, and exit codes](#verdicts-skips-and-exit-codes)
64
- - [Reports](#reports)
65
- - [Progress logs](#progress-logs)
66
- - [Programmatic API](#programmatic-api)
67
- - [CI](#ci)
68
- - [Reference defects (`oat serve --defects`)](#reference-defects-oat-serve---defects)
69
- - [Limits and non-features](#limits-and-non-features)
70
- - [Compared to schema fuzzers](#compared-to-schema-fuzzers)
71
- - [Labs](#labs)
72
- - [License](#license)
33
+ ## Reference
34
+
35
+ - [Commands](docs/commands.md) — `run`, `--ops`, `doctor`, `plan`, `serve`, `conformance`
36
+ - [Configuration](docs/configuration.md) — complete configs, every field, principals, auth flows, hooks, uploads
37
+ - [How oat reads a document](docs/model.md) — entities, identity, seeding, query grammars, pagination
38
+ - [OpenAPI meta tags](docs/tags.md) — every `x-*` tag and what it unlocks
39
+ - [Checks and verdicts](docs/checks.md) — what each check needs and asserts, verdicts, exit codes
40
+ - [Reports](docs/reports.md) — `oat-report.json`, `matrix.json`, repro scripts, progress logs
41
+ - [Programmatic API](docs/api.md)
42
+ - [Assumptions](docs/assumptions.md) — every assumption oat makes about an API, and how to declare an exception
43
+ - [Reference defects](docs/reference-defects.md) — the named lies `oat serve --defects` can tell
73
44
 
74
45
  ## Install
75
46
 
@@ -96,7 +67,7 @@ Unknown commands, unknown flags, and missing required flags exit `2`.
96
67
  2. **Model** entities by inverting `x-invalidate` (or path heuristics) into a read surface per entity.
97
68
  3. **Authenticate** every configured principal (static headers and/or an auth flow). Credentials refresh on a countdown from `exp` (default 30s buffer) before every dispatch and each async poll.
98
69
  4. **Seed** a cohort of records per entity, in parent-before-child order, using each entity's create operation.
99
- 5. **Test** the matrix, one entity at a time: foundations first, then composition, writes, isolation, declared effects. Entities run in series. Checks inside an entity stay ordered.
70
+ 5. **Test** the matrix entity by entity: foundations first, then composition, writes, isolation, declared effects. Entities that can see each other's writes — a parent and its children, a route one invalidates, an effect one lands on another — run in series; entities that share nothing run side by side. Checks inside an entity stay ordered.
100
71
  6. **Teardown** everything the run created, unless `--keep-fixtures` / `keepFixtures: true`.
101
72
 
102
73
  The first principal is the writer. Isolation needs a second principal with different `roots`. A rank lattice needs two or more principals that share `roots` and differ in `rank`. Invite checks need `x-invite` plus a peer with `inviteAs`.
@@ -136,1910 +107,28 @@ oat run --config oat.config.ts
136
107
 
137
108
  `doctor` is the adoption command. It runs offline against the spec alone and reports every coverage gap, naming the tag that would close it.
138
109
 
139
- ## Complete configs
140
-
141
- These are copy-paste starting points. Real configs import `defineConfig` from `@lovrozagar/oat`. Files inside this repository import from `../dist/index.js` because they live in the source tree.
142
-
143
- ### Static API keys, two tenants (smallest useful)
144
-
145
- ```ts
146
- // oat.config.ts
147
- import { defineConfig } from "@lovrozagar/oat"
148
-
149
- export default defineConfig({
150
- spec: "https://api.example.com/openapi.json",
151
- baseUrl: "https://api.example.com",
152
- principals: [
153
- {
154
- id: "alpha",
155
- headers: { authorization: "Bearer ${API_TOKEN}" },
156
- roots: { project_id: "${PROJECT_A}" },
157
- },
158
- {
159
- id: "beta",
160
- headers: { authorization: "Bearer ${API_TOKEN_B}" },
161
- roots: { project_id: "${PROJECT_B}" },
162
- },
163
- ],
164
- })
165
- ```
166
-
167
- ```bash
168
- export API_TOKEN=… API_TOKEN_B=… PROJECT_A=proj_a PROJECT_B=proj_b
169
- oat run --config oat.config.ts
170
- ```
171
-
172
- One principal is enough to seed and run CRUD / query / schema checks. The second principal, with different `roots`, is what makes `tenant.*` run. Without it those checks are **did not apply**, not a pass.
173
-
174
- Shipped as `labs/minimal.config.ts` (and in the npm package).
175
-
176
- ### JSON config
177
-
178
- Same object. `${NAME}` is interpolated after load. There is no `defineConfig` wrapper.
179
-
180
- ```json
181
- {
182
- "spec": "https://api.example.com/openapi.json",
183
- "baseUrl": "https://api.example.com",
184
- "principals": [
185
- {
186
- "id": "alpha",
187
- "headers": { "authorization": "Bearer ${API_TOKEN}" },
188
- "roots": { "project_id": "${PROJECT_A}" }
189
- }
190
- ],
191
- "seed": 42,
192
- "cohortSize": 7,
193
- "outDir": "./.oat/runs"
194
- }
195
- ```
196
-
197
- ```bash
198
- oat run --config oat.config.json
199
- ```
200
-
201
- ### Demo server (operation-id login)
202
-
203
- Shipped as `labs/local.config.ts`. Points at `oat serve`.
204
-
205
- ```ts
206
- import { defineConfig } from "@lovrozagar/oat"
207
-
208
- export default defineConfig({
209
- spec: "/v1/openapi/spec",
210
- baseUrl: "http://127.0.0.1:8787",
211
- seed: 42,
212
- principals: [
213
- {
214
- id: "alpha",
215
- roots: { project_id: "proj_alpha" },
216
- auth: {
217
- credentialFrom: "$.access_token",
218
- steps: [{ operationId: "auth.token", body: { key: "key_alpha" } }],
219
- },
220
- },
221
- {
222
- id: "beta",
223
- roots: { project_id: "proj_beta" },
224
- auth: {
225
- credentialFrom: "$.access_token",
226
- steps: [{ operationId: "auth.token", body: { key: "key_beta" } }],
227
- },
228
- },
229
- ],
230
- })
231
- ```
232
-
233
- `spec: "/v1/openapi/spec"` is resolved against `baseUrl`. `--base-url` on the CLI overrides the origin without editing the file.
234
-
235
- ### Two tenants plus a same-tenant rank lattice
236
-
237
- See [Principals](#principals). Isolation keys off `roots`. Rank keys off `rank` with shared `roots`.
238
-
239
- ## Commands
240
-
241
- ```
242
- oat run --config <file> test a live backend and write a report
243
- oat doctor --spec <url|file> what oat can and cannot test, and why
244
- oat plan --spec <url|file> print the derived model (offline)
245
- oat serve [--defects A,B] run the demo API
246
- oat conformance self-test: injected defects vs detection
247
- oat help
248
- ```
249
-
250
- `--spec` for `doctor` / `plan` can be replaced by `--config` (the spec is read from the config). `--json` makes those two commands emit machine-readable output. `--base-url` on `doctor` / `plan` is only used to resolve a relative spec path.
251
-
252
- `--untagged` is a **serve** flag (and a conformance concern). It is not a `run` flag.
253
-
254
- ### `oat run`
255
-
256
- Requires `--config`. CLI flags override the same field in the config when both are set.
257
-
258
- | flag | default | meaning |
259
- | ------------------------------------------ | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
260
- | `--config` | required | module or JSON file, default export |
261
- | `--base-url` | `config.baseUrl` | backend origin |
262
- | `--only` | `config.only` or all entities | comma-separated entity names as `oat plan` prints them (singularised) |
263
- | `--seed` | `config.seed` or `1` | fixture generation seed (reproducible) |
264
- | `--out` | `config.outDir` or `./.oat/runs` | history root; each run writes `<out>/<datetime>/` and updates `latest` |
265
- | `--max-in-flight` | `config.maxInFlight` or `4` | HTTP requests allowed at once |
266
- | `--keep-fixtures` | `config.keepFixtures` or false | do not DELETE what the run created |
267
- | `--quiet` | false | no stderr progress; files under `--out` still update |
268
- | `--save-exchanges` / `--no-save-exchanges` | on unless `--profile cheap` | persist every HTTP exchange under the run dir (`exchanges.jsonl`, `exchanges/`, `blobs/`). Does **not** change in-memory transcript RAM |
269
-
270
- **Exit codes:** `0` no defects, `1` at least one root-cause finding (`BACKEND_BUG`, `SPEC_BUG`, `SECURITY`, `AMBIGUITY`) **or** the run stopped because the network never came back, `2` usage error (missing `--config`, no principals, unknown flag). `COVERAGE_GAP` and `BLOCKED` do not fail the process.
271
-
272
- Example:
273
-
274
- ```bash
275
- oat run --config oat.config.ts --only store,product --out .oat/runs/prod
276
- ```
277
-
278
- `--only store,product` matches the **entity names** from `oat plan`, not path segments. `/v1/stores` is usually the entity `store`. If a name is unknown, that entity is simply not tested (the others still run).
279
-
280
- A run with no principals exits `2`. Isolation checks then need a second principal; they are skipped, not failed, when only one is present.
281
-
282
- ### `oat doctor`
283
-
284
- Offline. Loads the document, builds the model, prints coverage.
285
-
286
- ```bash
287
- oat doctor --spec https://api.example.com/openapi.json
288
- oat doctor --config oat.config.ts --json
289
- oat doctor --spec ./openapi.yaml --base-url https://api.example.com
290
- ```
291
-
292
- Human output:
293
-
294
- - `trackable` — entities with an identity and a read surface
295
- - `listable` — those that also have a list (query checks need this)
296
- - tags that are absent, and the checks each tag would unlock
297
- - tags that would **sharpen** checks that already run (`x-query`, `x-tenant`)
298
- - per-operation gaps (`x-entity` could not be inferred, assumed tenant param, …)
299
- - external `$ref`s that were not fetched
300
-
301
- `--json` shape:
302
-
303
- ```json
304
- {
305
- "blocking": 1,
306
- "entities": 12,
307
- "trackableEntities": 10,
308
- "testableEntities": 10,
309
- "listableEntities": 8,
310
- "roots": ["organization_id"],
311
- "externalRefs": ["https://example.com/shared.yaml"],
312
- "gaps": [{ "operationId": "table.list", "tag": "x-query", "detail": "…" }]
313
- }
314
- ```
315
-
316
- Exit `1` if there are **blocking** gaps: entities that are not trackable (no identity / no read), or the document has roots oat cannot create. Advisory gaps (missing `x-query`, no `x-async`) print and still exit `0`.
317
-
318
- ### `oat plan`
319
-
320
- Offline. Prints the derived entity graph, operations, and query capability.
321
-
322
- ```bash
323
- oat plan --spec ./openapi.yaml
324
- oat plan --config oat.config.ts --json
325
- ```
326
-
327
- Human columns:
328
-
329
- ```
330
- entity CLRUD ident read surface
331
- store CLRU· id 2 route(s) (inferred)
332
- GET /v1/stores
333
- GET /v1/stores/{store_id}
334
- ```
335
-
336
- `CLRUD` is Create / List / Read / Update / Delete. `·` means that slot is missing. `ident` is the identity property. Read surface is declared (`x-invalidate`) or inferred (sibling collection/item routes).
337
-
338
- `--json` is `{ entities, operations, roots }` — the full `SpecModel` maps, including conventions, query capability, async, invite, and path params. Use this when you need to know what oat will call something.
339
-
340
- ### `oat serve`
341
-
342
- In-process demo API. Same fixture as conformance.
343
-
344
- ```bash
345
- oat serve
346
- oat serve --defects STALE_LIST,PATCH_REPLACES
347
- oat serve --backend sqlite --dialect classic
348
- oat serve --untagged
349
- ```
350
-
351
- | flag | default | meaning |
352
- | ------------ | ----------- | -------------------------------------------------------------------------------------- |
353
- | `--backend` | `memory` | `memory` \| `sqlite` \| `postgres` |
354
- | `--dialect` | `postgrest` | `postgrest` \| `classic` \| `linked` \| `jsonapi` \| `plain` |
355
- | `--defects` | none | comma-separated names from [Reference defects](#reference-defects-oat-serve---defects) |
356
- | `--untagged` | false | serve the same API behind a spec with every `x-*` tag stripped |
357
-
358
- Printed keys: `key_alpha` (tenant `proj_alpha`), `key_beta` (tenant `proj_beta`). Spec: `{url}/v1/openapi/spec`. Stop with ctrl-c.
359
-
360
- `labs/local.config.ts` is written for this server.
361
-
362
- Dialects are **reference-backend shapes**, not something you configure against your API. They exist so conformance proves checks read the document rather than one fixture's spelling:
363
-
364
- | dialect | filter | sort | select | page model | envelope |
365
- | ----------- | --------------------------- | ---------- | ---------------- | ------------------- | --------------------------------- |
366
- | `postgrest` | `filter=status.eq.active` | `name.asc` | `select=id,name` | `page` + `cursor` | entity-named + `count`/`hasMore` |
367
- | `classic` | `filter=status=eq:active` | `sort=` | `fields=` | `page` + `per_page` | `{ data, total_count, has_more }` |
368
- | `linked` | postgrest | dotted | `fields=` | `offset` + `limit` | raw array + `Link: rel=next` |
369
- | `jsonapi` | postgrest | `-name` | `fields[table]=` | `page` + `size` | `{ data, total, has_more }` |
370
- | `plain` | `?status=active` (equality) | `name:asc` | `fields=` | `page` + `limit` | `{ items, total, has_more }` |
371
-
372
- `postgres` needs a server on the default `postgres` database (local, default `postgres` driver connection). `sqlite` needs Node's `node:sqlite` (`--experimental-sqlite` on Node 22). Missing backends fail at serve time rather than falling back.
373
-
374
- ### `oat conformance`
375
-
376
- Self-test. Not for your API. Injects named defects into the reference backend and asserts oat reports the matching check.
377
-
378
- ```bash
379
- # this repo
380
- npm test
381
-
382
- # after install, from a checkout with --experimental-sqlite if you want sqlite
383
- oat conformance
384
- oat conformance --backend memory --dialect plain
385
- oat conformance --fuzz 300 --max-defects 12 --seed 7
386
- oat conformance --precision 60 --backend memory
387
- oat conformance --parser
388
- oat conformance --backend d1
389
- oat conformance --only STALE_LIST,PATCH_REPLACES
390
- ```
391
-
392
- | flag | meaning |
393
- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
394
- | `--backend` | `memory` \| `sqlite` \| `postgres` \| `d1`. Default: every _local_ backend that is available. `d1` is never default — it is remote |
395
- | `--dialect` | pin one shape; default runs postgrest on each backend plus classic/linked/jsonapi/plain on memory |
396
- | `--fuzz [n]` | random _sets_ of defects (default 25 if flag is bare) |
397
- | `--max-defects` | cap per fuzz combination (default 4) |
398
- | `--precision [n]` | vary _data_ against a correct backend; any finding is a false positive (default 50 if flag is bare) |
399
- | `--seed` | replay a fuzz/precision run |
400
- | `--parser` | only the hostile-document + example-spec + tag-unlock suites |
401
- | `--only` | restrict injected defects (comma-separated `STALE_LIST,…`) |
402
-
403
- A default `oat conformance` (no `--fuzz` / `--precision` / `--parser`) also runs a 40-case combination smoke on memory after the one-at-a-time matrix.
404
-
405
- D1 needs `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_D1_DATABASE_ID`, `CLOUDFLARE_API_TOKEN`. Postgres needs a reachable server on the default connection (`database: "postgres"`). Missing backends are skipped with a printed reason, not treated as a pass.
406
-
407
- `--parser` still always runs first (hostile documents, `labs/annotated-openapi.yaml` model lock, tag-unlock map). Exit `1` if any parser, matrix, fuzz, or precision case fails.
408
-
409
- ## Configuration
410
-
411
- Two inputs, always: **the spec** and **a config file**. Backend-specific knowledge lives in `x-*` tags and this file. A backend adopts oat by adding tags, not by adapting to oat.
412
-
413
- A config is:
414
-
415
- - `.ts` / `.js` / `.mjs` with `export default defineConfig({ ... })`, or
416
- - `.json` with the same object.
417
-
418
- Named export without `default` is also accepted (`module.default ?? module`).
419
-
420
- ### Top-level fields
421
-
422
- ```ts
423
- import { defineConfig } from "@lovrozagar/oat"
424
-
425
- export default defineConfig({
426
- spec: "https://api.example.com/openapi.json", // URL or filesystem path; JSON or YAML
427
- baseUrl: "https://api.example.com",
428
- principals: [/* at least one; see below */],
429
- hooks: {/* optional */},
430
- uploads: { pool: ["./fixtures/**/*"], eachMax: 24 },
431
- globalHeaders: { "x-request-id": "oat" }, // sent on every request; oat does not inspect them
432
- roots: { org_id: "org_shared" }, // path params oat cannot create; also declarable via x-root
433
- seed: 42, // fixture generation; a failing run with the same seed is identical
434
- cohortSize: 12, // records created per entity (default 7)
435
- maxInFlight: 4, // HTTP in flight
436
- only: ["store", "product"], // restrict entities
437
- keepFixtures: false,
438
- outDir: "./.oat/runs",
439
- saveExchanges: true, // default on unless --profile cheap; --quiet does not turn this off
440
- network: { retries: 4, waitMs: 60_000 }, // fetch-threw: retry, then wait for the link
441
- outOfBand: { attempts: 20, initialMs: 1000, maxMs: 8000 },
442
- origins: [{ id: "cdn", baseUrl: "https://cdn.example.com", spec: "https://cdn.example.com/openapi.json" }],
443
- query: {
444
- operators: ["eq", "neq", "gt", "gte", "lt", "lte", "in", "nin", "like", "ilike", "is"],
445
- emptyIn: "match-none",
446
- maxInValues: 100,
447
- searchEmpty: "match-all",
448
- sort: { nulls: ["first", "last"], maxKeys: 3 },
449
- select: { unknown: "reject" },
450
- },
451
- entities: {
452
- row: {
453
- query: {
454
- identityFilter: "_id",
455
- filterable: [{ field: "_id", type: "string", ops: ["eq", "neq", "in"] }],
456
- },
457
- },
458
- },
459
- })
460
- ```
461
-
462
- | field | required | default | notes |
463
- | --------------- | -------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
464
- | `spec` | yes | | See [Spec loading](#spec-loading) |
465
- | `baseUrl` | yes | | Primary origin. OpenAPI `servers[]` is ignored |
466
- | `principals` | yes | | Non-empty. First is the writer |
467
- | `hooks` | no | | See [Hooks](#hooks) |
468
- | `uploads` | no | | `pool` globs; optional `each` (operationId → globs) and `eachMax`. JSON configs may set all three |
469
- | `globalHeaders` | no | `{}` | Merged first. `resolveHeaders` then caller headers then auth |
470
- | `origins` | no | `[]` | Extra `{ id, baseUrl, spec }` hosts. Auth JWT is reused. Do not merge those routes into `spec` |
471
- | `outOfBand` | no | `{ attempts: 6, initialMs: 200, maxMs: 3000 }` | Backoff for `resolveOutOfBand` and `resolvePrincipalAuth`. See [Hooks](#hooks) |
472
- | `roots` | no | `{}` | Shared path params (merged with each principal's `roots`) |
473
- | `seed` | no | `1` | Integer. Same seed → same fixture bodies |
474
- | `cohortSize` | no | `7` | Sliced from the 7 built-in variants. Larger repeats the pattern |
475
- | `maxInFlight` | no | `4` | Across the whole run |
476
- | `only` | no | all | Entity names from `oat plan` |
477
- | `keepFixtures` | no | `false` | Skip DELETE at the end |
478
- | `outDir` | no | `./.oat/runs` | History root. Each run writes `<outDir>/<datetime>/` and updates `latest`. Also writes `principals.json` after acquire |
479
- | `saveExchanges` | no | on unless `profile` is `cheap` | Persist every HTTP exchange under the run dir. `--save-exchanges` / `--no-save-exchanges` override. `--quiet` does not |
480
- | `network` | no | `{ retries: 4, waitMs: 60000, requestTimeoutMs: 180000 }` | When `fetch` throws (offline / DNS / reset / timeout): retry, then wait once for the link. Not a 5xx policy. `requestTimeoutMs: 0` disables the per-attempt cap |
481
- | `query` | no | | Global query-catalog defaults. Overlay after `x-query`. Does not invent operators |
482
- | `entities` | no | | Per-entity overlays. This release only reads `query`. Unknown names are ignored; `doctor` warns |
483
-
484
- `spec` may be a path relative to `baseUrl` (`/v1/openapi/spec`) or an absolute URL or a file.
485
-
486
- CLI `--base-url`, `--only`, `--seed`, `--out`, `--max-in-flight`, `--keep-fixtures`, `--save-exchanges` / `--no-save-exchanges` override these when passed.
487
-
488
- ### Spec loading
489
-
490
- Resolved in this order, never by guessing the string's "look":
491
-
492
- 1. Absolute `http(s)://` or `file://` — used as given.
493
- 2. A path that exists on disk, relative to the working directory.
494
- 3. Anything else, when `baseUrl` is known — resolved against it (`/v1/openapi/spec`, `openapi.json`).
495
-
496
- JSON if the first non-space character is `{` or `[`, otherwise YAML. Empty files error. A JSON document with more opening than closing brackets is diagnosed as truncated (proxy / download limit), not as a syntax error.
497
-
498
- OpenAPI 3.0 and 3.1 both work. oat reads `paths`, operations, parameters, request/response JSON schemas, and `x-*` extensions. It does not require a particular `openapi:` version string.
499
-
500
- Internal `$ref`s are dereferenced. External `$ref`s stay unresolved and show up in `oat doctor` / the JSON `externalRefs` list.
501
-
502
- ### Principals
503
-
504
- ```ts
505
- {
506
- id: "alpha", // required, stable name in reports
507
- headers: { authorization: "Bearer …" }, // static; enough for a long-lived key
508
- auth: { /* AuthFlow — see below */ },
509
- roots: { org_id: "org_alpha" }, // this principal's tenant / path params
510
- rootsFromFlow: { org_id: "orgId" }, // take path params from values the auth flow bound
511
- role: "owner", // free-form label in reports
512
- rank: 2, // higher can do everything a lower rank can; default 0
513
- inviteAs: "key_beta", // how an owner names this principal in an invite body
514
- }
515
- ```
516
-
517
- Rules that matter:
518
-
519
- - **Isolation** (`tenant.*`) needs two principals whose `roots` differ.
520
- - **Rank** (`auth.rank-is-monotonic`) needs two principals with the _same_ `roots` and different `rank`.
521
- - **Invite** (`auth.invite-grants-then-revokes`) needs `x-invite` on the spec and a _different-tenant_ principal with `inviteAs` set.
522
- - Extra principals are not ignored. Isolation picks the first different-`roots` peer. Rank uses the same-tenant pair.
523
- - `headers` and `auth` compose: static headers are sent, then the flow's credential header is merged on top.
524
- - A principal with only `headers` (no `auth`) never hits a login route.
525
- - `auth` may be a harvested credential instead of a step chain: `{ fromHook: "oauth-google" }`. See [Harvested principal](#harvested-principal).
526
-
527
- Example — two tenants plus a same-tenant lattice:
528
-
529
- ```ts
530
- principals: [
531
- {
532
- id: "alpha",
533
- role: "owner",
534
- rank: 2,
535
- auth: {
536
- credentialFrom: "$.access_token",
537
- steps: [{ operationId: "auth.token", body: { key: "key_alpha" } }],
538
- },
539
- roots: { org_id: "org_alpha" },
540
- },
541
- {
542
- id: "alpha_member",
543
- role: "member",
544
- rank: 1,
545
- auth: {
546
- credentialFrom: "$.access_token",
547
- steps: [{ operationId: "auth.token", body: { key: "key_alpha_member" } }],
548
- },
549
- roots: { org_id: "org_alpha" },
550
- },
551
- {
552
- id: "beta",
553
- role: "owner",
554
- rank: 2,
555
- inviteAs: "key_beta",
556
- auth: {
557
- credentialFrom: "$.access_token",
558
- steps: [{ operationId: "auth.token", body: { key: "key_beta" } }],
559
- },
560
- roots: { org_id: "org_beta" },
561
- },
562
- ]
563
- ```
564
-
565
- ### Auth flows
566
-
567
- ```ts
568
- auth: {
569
- steps: [ /* register / verify — first acquire only */ ],
570
- credentialFrom: "$.access_token", // JSON path in the last (or saved) response
571
- expiresInFrom: "$.expires_in", // lifetime in seconds
572
- header: "authorization", // default
573
- template: "Bearer {credential}", // default
574
- assumeTtlMs: 3600000, // used only if neither expiresInFrom nor JWT exp is present
575
- refreshBufferMs: 30_000, // optional; default 30s. Proactive when expiresAt - now <= this
576
- refresh: { // signup flows must set this — re-running steps is not a refresh
577
- steps: [
578
- {
579
- operationId: "auth.refreshToken",
580
- body: { refresh_token: "{refreshToken}" },
581
- saveAs: {
582
- credential: "$.access_token",
583
- refreshToken: "$.refresh_token",
584
- },
585
- },
586
- ],
587
- },
588
- }
589
- ```
590
-
591
- Expiry is `expiresInFrom` (seconds) → JWT `exp` claim → `assumeTtlMs`. `assumeTtlMs` is only the fallback lifetime when nothing else revealed expiry — it is not used for the refresh threshold when `expiresAt` is known.
592
-
593
- Refresh is countdown-based (`expiresAt - refreshBufferMs`, default 30s) before every dispatch and before each async poll. Signup flows declare `auth.refresh` (refresh-token operation). Re-running `steps` is only the fallback when `refresh` is omitted (API-key / token-exchange principals). A register-like first hop without `refresh` fails closed (`AUTH_REFRESH_REQUIRED`) rather than signing up again.
594
-
595
- One 401 → force refresh + single retry with live headers. A second 401 is evidence. 5xx / 429 are never a refresh trigger. `expiresAt === null` (static-header principal) never proactive-refreshes.
596
-
597
- Each step is one of:
598
-
599
- **Operation step** (prefer this — survives the path moving):
600
-
601
- ```ts
602
- {
603
- operationId: "auth.token",
604
- body: { key: "${API_KEY}" },
605
- headers: { "x-extra": "1" },
606
- query: { realm: "test" },
607
- saveAs: { credential: "$.access_token", refreshToken: "$.refresh_token" },
608
- saveClaimsFrom: { token: "$.access_token", bind: { orgId: "orgs.0.oid" } },
609
- bind: { address: "user@example.test" }, // literals, with {name} interpolation
610
- expect: [200], // default: any 2xx
611
- }
612
- ```
613
-
614
- **Request step** (when the document has no auth operations, or the hop is not in the spec):
615
-
616
- ```ts
617
- {
618
- method: "POST",
619
- path: "/v1/auth/register/email",
620
- body: { email: "{address}", password: "…" },
621
- bind: { address: "oat-alpha@example.test" },
622
- }
623
- ```
624
-
625
- `path` is joined to this origin's `baseUrl`, unless it is an absolute `http://` or `https://` URL — then oat dispatches to that URL as a recorded exchange (method, URL, status, redirects, response headers). That is how a consume page on the app origin is an auth step when `baseUrl` is the API. Unknown host is allowed. `redirect` defaults to `"follow"` with a per-request cookie jar, so a 303 that sets `Set-Cookie` still leaves that cookie visible to `saveAs`. `redirect: "manual"` stops at the first 3xx (`expect: [303]` then bind from that response).
626
-
627
- **Out-of-band step** (email link, OTP — oat cannot collect this itself):
628
-
629
- ```ts
630
- { outOfBand: { address: "{address}", kind: "email-verify", as: "verifyLink" } }
631
- ```
632
-
633
- The hook returns a string. If that string is a URL, a later RequestStep must GET it — a hook-side `fetch` is not a recorded exchange.
634
-
635
- Later steps interpolate `{name}` from the flow scope, `saveAs` addresses included (`cookie:rt.{userId}` reads a per-user cookie). `saveAs` addresses:
636
-
637
- - `$.foo.bar` / `$.orgs.0.id` — JSON body (dot + numeric index only; no JSON Pointer, no filters)
638
- - `cookie:<name>` — that cookie on `Set-Cookie` for this hop, including followed hops
639
- - `header:<name>` — a non-set-cookie response header, case-insensitive
640
-
641
- Missing cookie / header / JSON path fails the auth step closed. Bind `saveAs.refreshToken` from `$.refresh_token` or `cookie:refresh` so `{refreshToken}` interpolates in `auth.refresh`. `saveClaimsFrom.token` is a JSON path into the response body (`$.access_token`) or a scope key already bound by `saveAs` (`credential`). Signature is not verified — oat is reading its own credential. `rootsFromFlow` maps path parameter names to those bound keys.
642
-
643
- `bind` on a step runs **before** the request. `saveAs` then `saveClaimsFrom` run **after**. `credentialFrom` is read from the last HTTP response unless a step already saved `credential`. `outOfBand.as = "credential"` still wins over `credentialFrom`.
644
-
645
- If a step's status is not acceptable, auth fails the run (not a finding): `oat: principal "alpha" failed at auth step 2 (POST /v1/…)`.
646
-
647
- A complete register → mailed GET → cookie session example:
648
-
649
- ```ts
650
- function signUp(email: string): AuthFlow {
651
- return {
652
- credentialFrom: "$.access_token",
653
- expiresInFrom: "$.access_token_expires_in",
654
- header: "cookie",
655
- template: "session={credential}",
656
- refresh: {
657
- steps: [
658
- {
659
- body: { refresh_token: "{refreshToken}" },
660
- method: "POST",
661
- path: "/v1/auth/refresh",
662
- saveAs: { credential: "$.access_token", refreshToken: "$.refresh_token" },
663
- },
664
- ],
665
- },
666
- steps: [
667
- {
668
- bind: { address: email },
669
- body: { email, password: "…" },
670
- method: "POST",
671
- path: "/v1/auth/register/email",
672
- saveAs: { credential: "$.access_token", refreshToken: "$.refresh_token" },
673
- },
674
- { outOfBand: { address: email, as: "verifyLink", kind: "email-verify" } },
675
- {
676
- method: "GET",
677
- path: "{verifyLink}", // absolute URL; not joined to baseUrl
678
- expect: [200, 303],
679
- saveAs: {
680
- credential: "cookie:session",
681
- refreshToken: "cookie:refresh",
682
- },
683
- saveClaimsFrom: {
684
- token: "credential",
685
- bind: { orgId: "orgs.0.oid", projectId: "orgs.0.pids.0" },
686
- },
687
- },
688
- ],
689
- }
690
- }
691
- ```
692
-
693
- When the user path **is** POST-token, keep that chain — it is still valid:
694
-
695
- ```ts
696
- { outOfBand: { address: email, as: "verifyToken", kind: "email-verify" } },
697
- {
698
- body: { token: "{verifyToken}" },
699
- method: "POST",
700
- path: "/v1/auth/email/verify",
701
- saveAs: { credential: "$.access_token", refreshToken: "$.refresh_token" },
702
- saveClaimsFrom: { token: "$.access_token", bind: { orgId: "orgs.0.oid" } },
703
- }
704
- ```
705
-
706
- ```ts
707
- principals: [
708
- {
709
- id: "alpha",
710
- auth: signUp("oat-alpha@example.test"),
711
- rootsFromFlow: { organization_id: "orgId", project_id: "projectId" },
712
- },
713
- ]
714
- ```
715
-
716
- The address used for `teardownPrincipal` is `scope.address` or `scope.email` (set via `bind: { address }` or `bind: { email }`).
717
-
718
- ### Harvested principal
719
-
720
- When the credential is produced outside oat (a human finishes Google OAuth on a harvest page, a pair lands in KV), do not make oat drive `authorize` / `callback`:
721
-
722
- ```ts
723
- {
724
- id: "google-user",
725
- auth: { fromHook: "oauth-google" },
726
- }
727
- ```
728
-
729
- oat polls `hooks.resolvePrincipalAuth("oauth-google")` with the same `outOfBand` backoff as mail. Return `{ credential, refreshToken?, expiresIn? }` or `null` to retry. Refresh re-calls the hook (401 and countdown). oat does not speak OAuth.
730
-
731
- ### Secondary origins
732
-
733
- One run, one primary `baseUrl`. A CDN (or any second host) keeps its own OpenAPI.
734
-
735
- ```ts
736
- export default defineConfig({
737
- spec: "https://api.example.com/openapi.json",
738
- baseUrl: "https://api.example.com",
739
- principals: [/* acquire JWT on the API */],
740
- origins: [{ id: "cdn", baseUrl: "https://cdn.example.com", spec: "https://cdn.example.com/openapi.json" }],
741
- })
742
- ```
743
-
744
- After primary auth, oat snapshots the principals, binds those credentials to the other host, and runs the matrix against that document. Auth steps may set `origin: "cdn"` to send one hop to a named origin during acquire.
745
-
746
- Do not merge CDN routes into the API gateway document.
747
-
748
- A second `defineConfig` can reuse the first run's snapshot instead:
749
-
750
- ```ts
751
- import { defineConfig, loadPersistedPrincipals } from "@lovrozagar/oat"
752
-
753
- export default defineConfig({
754
- spec: "https://cdn.example.com/openapi.json",
755
- baseUrl: "https://cdn.example.com",
756
- principals: loadPersistedPrincipals("./.oat/runs/latest/principals.json"),
757
- })
758
- ```
759
-
760
- The CLI writes `principals.json` into each run folder (and `.oat/runs/latest/principals.json` via the `latest` symlink).
761
-
762
- ### Hooks
763
-
764
- ```ts
765
- hooks: {
766
- // Return null to retry (attempt is 1-based). oat backs off until a value arrives.
767
- // `scope` is the flow at this step; `headers` are the live principal credential headers.
768
- resolveOutOfBand: async ({ address, kind, attempt, scope, headers }) => {
769
- const link = await readMailCatcher(address, kind)
770
- return link // URL or token string, or null
771
- },
772
- // Remove a principal this run provisioned. `ctx` is the last live credential.
773
- teardownPrincipal: async (address, { credential, headers }) => {
774
- await fetch(`https://api.example.com/v1/auth/account`, { method: "DELETE", headers })
775
- },
776
- // Return a file to send, `{ fields }` to replace the whole request, or null to fall through.
777
- resolveUpload: async ({ operationId, field, contentMediaType }) => {
778
- if (operationId === "extract.once" && field === "file") {
779
- const bytes = await Deno.readFile("./invoices/known.pdf")
780
- return { bytes, filename: "known.pdf", mediaType: "application/pdf" }
781
- }
782
- return null
783
- },
784
- // After globalHeaders, before auth. Return null to add nothing.
785
- resolveHeaders: async ({ operationId, method, url }) => {
786
- if (operationId === "auth.register" || operationId === "auth.login") {
787
- return { "cf-turnstile-response": await harvestTurnstile() }
788
- }
789
- return null
790
- },
791
- // Replace a generated JSON field. Null keeps the generator.
792
- resolveInput: async ({ operationId, field }) => {
793
- if (operationId === "billing.subscribe" && field === "payment_method_id") {
794
- return process.env.STRIPE_TEST_PM
795
- }
796
- return null
797
- },
798
- // Harvested OAuth pair. Null retries with the outOfBand backoff.
799
- resolvePrincipalAuth: async (fromHook) => {
800
- if (fromHook !== "oauth-google") return null
801
- const pair = await readHarvestedGoogle()
802
- return pair === null ? null : { credential: pair.access_token, refreshToken: pair.refresh_token, expiresIn: pair.expires_in }
803
- },
804
- // After seed: add or replace any axis of the query catalog. Null keeps the merge.
805
- resolveQueryCapabilities: async ({ entity, get }) => {
806
- if (entity !== "row") return null
807
- const body = await get("table.get")
808
- return { filterable: /* harvest from body */ [] }
809
- },
810
- // Optional extra stop condition while x-wait polls.
811
- awaitSideEffect: async ({ operationId, record }) => {
812
- if (operationId !== "webhook.deliver") return null
813
- return Array.isArray((record as { items?: unknown }).items) && (record as { items: unknown[] }).items.length > 0
814
- ? true
815
- : null
816
- },
817
- }
818
- ```
819
-
820
- Without `resolveOutOfBand`, an `outOfBand` step cannot complete. oat polls the hook; the hook must not sleep. Returning `""` is treated like `null`. The hook is not a recorded hop: if the human GETs a mailed URL, a later RequestStep must GET that URL so it appears in `exchanges.jsonl` and can `expect` / `saveAs`.
821
-
822
- Default schedule (0.6.2, unchanged unless `outOfBand` is set): **6** attempts, first sleep **200** ms, doubling, cap **3000** ms. oat sleeps after every miss, including the last, so the worst-case wait is
823
-
824
- `200 + 400 + 800 + 1600 + 3000 + 3000 = 9000` ms.
825
-
826
- That is too short for real mail (often 10–60 s) and for a human finishing Google OAuth or a Turnstile harvest. Configure it:
827
-
828
- ```ts
829
- outOfBand: { attempts: 20, initialMs: 1000, maxMs: 8000 }
830
- // worst case: 1000 + 2000 + 4000 + 8000×17 = 143000 ms
831
- ```
832
-
833
- Worst-case wait is `sum_{i=0}^{attempts-1} min(initialMs × 2^i, maxMs)`. `worstCaseWaitMs()` from the package computes it. Existing configs that omit `outOfBand` do not slow down.
834
-
835
- Without `teardownPrincipal`, provisioned accounts are reported as leftover rather than cascade-deleted. Per-record DELETE still runs for seeded rows when a delete (or `x-cleanup`) exists. The hook is called with the last live credential (`ctx.credential` / `ctx.headers`), not an already-cleared one, so authenticated delete-account is expressible without a tester-key god route. One-argument JavaScript callbacks still run.
836
-
837
- `resolveHeaders` is called on every dispatch (including the 401 retry). Merge order: `globalHeaders` → hook → per-request headers → principal credential. Use `ctx.operationId` / `ctx.method` / `ctx.url` to attach a one-shot captcha only on captcha ops. oat does not speak Turnstile.
838
-
839
- `resolveInput` is the JSON twin of `resolveUpload`. Return a value to replace that field (`payment_method_id` on `billing.subscribe`); `null` keeps the generator.
840
-
841
- `resolveQueryCapabilities` runs once per entity after seed. `get(operationId)` (or `"GET /path"`) uses the seeded parent scope so a follow-up read can harvest dynamic columns. A provided `filterable` / `sortable` / `searchable` / `selectable` list **replaces** that axis; omitted axes stay. JSON configs have no hook.
842
-
843
- `resolvePrincipalAuth` and `awaitSideEffect` are documented below.
844
-
845
- Worked `query` overlay for a generic PostgREST-shaped API (not a named product):
846
-
847
- ```ts
848
- export default defineConfig({
849
- spec: "https://api.example.com/openapi.json",
850
- baseUrl: "https://api.example.com",
851
- principals: [{ id: "alpha", headers: { authorization: `Bearer ${process.env.TOKEN}` } }],
852
- query: {
853
- operators: ["eq", "neq", "gt", "gte", "lt", "lte", "in", "nin", "like", "ilike", "is"],
854
- operatorsByType: {
855
- string: ["eq", "neq", "like", "ilike", "in", "nin", "is"],
856
- number: ["eq", "neq", "gt", "gte", "lt", "lte", "in", "nin", "is"],
857
- date: ["eq", "neq", "gt", "gte", "lt", "lte", "is"],
858
- boolean: ["eq", "neq", "is"],
859
- },
860
- aliases: { ne: "neq" },
861
- emptyIn: "match-none",
862
- maxInValues: 100,
863
- maxFilterConditions: 20,
864
- searchEmpty: "match-all",
865
- sort: { nulls: ["first", "last"], maxKeys: 3 },
866
- select: { nested: false, unknown: "reject" },
867
- },
868
- })
869
- ```
870
-
871
- New surface still has to be listed. oat will not silently enable `in` / `ilike` / `is` / `contains` / search modes / `nullsfirst` on every PostgREST-shaped document.
872
-
873
- ### Uploads
874
-
875
- Multipart and binary parts are filled in this order:
876
-
877
- 1. `hooks.resolveUpload` — a non-null `UploadFile` wins. `{ fields }` that includes a file part replaces the whole request. `{ fields }` that omits the file part overlays scalars and keeps the each / pool / dummy bytes.
878
- 2. `uploads.each` fixture for this invocation, when that operation is listed.
879
- 3. `uploads.pool` — first file whose extension / sniffed type matches the part's `contentMediaType`. Same `seed` + field + index → same pick. Ops not in `each` stay pick-one.
880
- 4. A tiny dummy with sniffable magic (`%PDF-1.1`, 1×1 PNG, empty zip, …). Unknown types become 16 octet-stream bytes, not a skip.
881
-
882
- `uploads.each` is a matrix, not a source. `operationId → globs` means that operation is invoked once per matched file (after `eachMax`). Same seed does **not** collapse `each`. A hook that ignores `request.fixture` and always returns the same file will send that file N times.
883
-
884
- Each invocation is still a citeable hop (method, URL, status, fixture name, content-addressed body). Live `FormData` / `Blob` payloads are **not** kept on `Client.transcript` for the rest of the run — they are replaced with `{ sha256, bytes, mediaType }` (and multipart `{ parts }`) after the hop is journaled, or immediately when the journal is off. Fan-out therefore multiplies requests, not retained fixture bytes.
885
-
886
- ```ts
887
- export default defineConfig({
888
- spec: "openapi.json",
889
- baseUrl: "https://api.example.com",
890
- principals: [/* … */],
891
- uploads: {
892
- pool: ["./fixtures/**/*"],
893
- each: {
894
- "extract.once": ["./fixtures/**/*"],
895
- "extract.stream": ["./fixtures/**/*"],
896
- },
897
- eachMax: 24,
898
- },
899
- hooks: {
900
- resolveUpload: async ({ operationId, field, fixture }) => {
901
- if (operationId === "extract.once" && field === "file") {
902
- return { fields: { columns: "vendor,date,amount" } }
903
- }
904
- return null
905
- },
906
- },
907
- })
908
- ```
909
-
910
- | case | outcome |
911
- | ------------------------------- | ----------------------------------------------------------- |
912
- | `each` omitted | pick-one (today) |
913
- | glob matches 0 files | warn once, no extra invocations, fall through to pool/dummy |
914
- | one path in the list is missing | drop that slot, warn once, never `BACKEND_BUG` |
915
- | `eachMax` < match count | first `eachMax` after sort, warn that it capped |
916
- | fixture unreadable | drop that slot, warn once, not `BACKEND_BUG` |
917
-
918
- A missing pool path warns once and falls through. An empty pool match uses a dummy. The run does not fail. JSON configs may set `pool`, `each`, and `eachMax`. `resolveUpload` is TypeScript.
919
-
920
- `--profile cheap` (or any profile that excludes the op) still drops the whole family. `each` does not punch through a profile.
921
-
922
- Findings from an `each` invocation carry `fixture: "invoice.pdf"` and render as `extract.once · invoice.pdf`. One 5xx is one finding on that file.
923
-
924
- oat does not OCR. It sends bytes and checks HTTP / JSON. A 200 with empty extract rows is not automatically a backend defect. A 4xx because the dummy is “not a real invoice” is not automatically a backend defect if the dummy matched the declared `contentMediaType`.
925
-
926
- Prefer `multipart/form-data` when the operation documents it, even if JSON is also listed. Text form fields still use the string generator (`format` / `pattern` / `maxLength`). A part that is either text or file is sent as a file when the schema is binary.
927
-
928
- ### Environment interpolation
929
-
930
- After the module loads, every string in the config is scanned for `${NAME}`:
931
-
932
- ```ts
933
- headers: {
934
- authorization: "Bearer ${API_TOKEN}"
935
- }
936
- ```
937
-
938
- If `API_TOKEN` is unset, oat exits with an error. Do not commit secrets; put them in the environment.
939
-
940
- Template literals in a `.ts` config (`Bearer ${process.env.API_TOKEN}`) are evaluated by Node _before_ oat sees the object. Either style works; `${NAME}` is what a `.json` config can use.
941
-
942
- Names match `[A-Z0-9_]+` case-insensitively.
110
+ ## CI
943
111
 
944
- ### Loading TypeScript configs
112
+ This repository runs [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) on every push and pull request to `main`: format, lint, typecheck, then `npm test` (conformance on memory, sqlite and a Postgres service, the built-in combination smoke with a fresh fuzz seed per run, and a precision pass). D1 and the live labs Workers are not in that job — D1 needs Cloudflare credentials.
945
113
 
946
- `.js` / `.mjs` / `.json` load everywhere.
114
+ The package is [`@lovrozagar/oat` on npm](https://www.npmjs.com/package/@lovrozagar/oat). That URL is the repository website. GitHub Releases match npm versions. Pushing a tag `vX.Y.Z` (same as `package.json` `version`) runs [`.github/workflows/release.yml`](./.github/workflows/release.yml): test, `npm publish` via trusted publishing, then a GitHub Release. Configure the trusted publisher once on npm (package Settings → Trusted Publisher → GitHub Actions, workflow `release.yml`, no environment). Do not publish to GitHub Packages — people install from the public npm registry.
947
115
 
948
- `.ts` configs require a runtime that can import TypeScript: Node 22.6+ with `--experimental-strip-types`, or Node 23+. The published `oat` binary is itself JS; it still has to `import()` your config. If that fails, the error says so. Workaround: compile the config, or write `.mjs`.
116
+ Against **your** API:
949
117
 
950
- ```bash
951
- node --experimental-strip-types ./node_modules/@lovrozagar/oat/dist/cli.js run --config oat.config.ts
118
+ ```yaml
119
+ # GitHub Actions sketch
120
+ - run: npm i -D @lovrozagar/oat
121
+ - run: oat doctor --spec "$SPEC_URL"
122
+ - run: oat run --config oat.config.ts
123
+ env:
124
+ API_TOKEN: ${{ secrets.API_TOKEN }}
125
+ API_TOKEN_B: ${{ secrets.API_TOKEN_B }}
952
126
  ```
953
127
 
954
- ## How the model is derived
955
-
956
- `oat plan` is this model. Checks never see raw paths; they see entities, actions, and query **roles**.
957
-
958
- ### Entity name and action
959
-
960
- **Explicit:** `x-entity: { name, action, identity? }` on the operation.
961
-
962
- **Heuristic** (when the tag is absent):
963
-
964
- 1. Split the path on `/`. Ignore `{param}` segments.
965
- 2. The last non-parameter segment is the noun. `v1` / `v2` / `vN` is never a noun.
966
- 3. Singularise that noun (`stores` → `store`, `batches` → `batch`). Irregulars include `people→person`, `categories→category`, `campuses→campus`, `statuses→status`, `children→child`, `companies→company`, `addresses→address`, `indices→index`, `queries→query`, `properties→property`, `entities→entity`, `inboxes→inbox`. Endings `us|ss|is|os|as|ics|ews|ess|ous|sis` are left alone (`status` stays `status`).
967
- 4. If a non-parameter segment follows the noun (`/rows/aggregate`, `/tables/{id}/restore`), action is `action`.
968
- 5. Otherwise: `GET` collection → `list`, `GET` item → `read`, `POST` collection → `create`, `POST` item → `action`, `PUT`/`PATCH` → `update`, `DELETE` → `delete`.
969
-
970
- If no noun can be found, the operation is untracked and `doctor` records an `x-entity` gap.
971
-
972
- `--only` and report entity names are these singular names.
973
-
974
- ### Identity
975
-
976
- `x-entity.identity` wins. Else the first of `id`, `uuid`, `slug`, `key`, `name` that is **required** on the item schema, else the first of those that exists, else the trailing path-param suffix (`{table_id}` → `id`). Without an identity the entity is not trackable.
977
-
978
- ### Read surface
979
-
980
- The set of `GET` routes through which an instance is visible.
981
-
982
- - Declared: every `"METHOD /path"` in any `x-invalidate` that refers to this entity.
983
- - Inferred: sibling collection and item routes on the same path prefix as a mutator.
984
-
985
- `invalidation.declared-route-changes` only runs when a mutator's `x-invalidate` names **another** entity's route.
986
-
987
- ### Generated / immutable / soft-delete / tenant
988
-
989
- See [OpenAPI meta tags](#openapi-meta-tags). Fallbacks:
990
-
991
- - `readOnly: true` counts as generated (omitted from create bodies).
992
- - No immutability testing without `x-immutable`.
993
- - Tenant param: `x-tenant` or a path param matching `org|organization|tenant|workspace|account|project|app` + optional `_id`/`_slug`. Inferred tenants make a cross-tenant read `AMBIGUITY`, not `SECURITY`. With neither a tag nor an inferred name, the check does not apply.
994
-
995
- ### Idempotency
996
-
997
- No meta tag. If create declares a header matching `Idempotency-Key` / `Idempotence-Key` / `X-Idempotency-Key` (spaces ignored, case-insensitive), `idempotency.replay-does-not-duplicate` runs.
998
-
999
- ## Seeding
1000
-
1001
- Per entity, oat POSTs the create body built from the request schema (JSON, multipart, or urlencoded).
1002
-
1003
- Default cohort is **7** records, one of each variant, sliced by `cohortSize`:
1004
-
1005
- | variant | what it is for |
1006
- | --------------- | -------------------------------------------------- |
1007
- | `baseline` | `"Quarterly Report N"` |
1008
- | `lexical-first` | sorts first (`"aaa first alphabetically"`) |
1009
- | `lexical-last` | sorts last (`"zzz last alphabetically"`) |
1010
- | `null-heavy` | `null` on every nullable field |
1011
- | `unicode` | `"äöüß čćžšđ 日本語 中文 한글 привет مرحبا 🙂"` |
1012
- | `metacharacter` | `"100% _off_ *everything*"` — LIKE / escape probes |
1013
- | `boundary` | empty / maxLength / numeric `maximum` |
1014
-
1015
- Numbers use the ladder `1, 2, 5, 10, 20, 50, 100` so **lexical order ≠ numeric order** (otherwise a TEXT compare looks correct). Enums walk `index % enum.length`. `readOnly` / `x-generated` fields are omitted. Required fields that cannot be generated get a type fallback (`0`, `false`, `[]`, `{}`, `"value"`). Arrays honour `minItems` (never send `[]` when `minItems ≥ 1`). Nested objects stop at depth 4.
1016
-
1017
- Empty schemas (`{}`, `true`, `additionalProperties: {}`) and cyclic `$ref`s after inlining stop the walk — they become a scalar or `{}`, never another object descent. A `RangeError` during generation is a `COVERAGE_GAP` on that entity naming the operationId and JSON pointer (`fixture generation overflow on table.create (/)`), not `blocked by unknown`.
1018
-
1019
- String fields honour `format`, `pattern`, and `minLength` together: `email` → `oat-{variant}-{index}@example.test`, `uri` / `url` → `https://example.test/...`, `uuid` → a fixed-shape UUID, `pattern` → a string that matches (or the field is omitted / the entity is a gap). A generated string is padded to `minLength` (repeat the last character) without breaking `pattern`. `"Quarterly Report N"` is only used when the document does not constrain the string. `minLength` greater than `maxLength` omits an optional field and records `missingRequired` on a required one.
1020
-
1021
- An operation with `x-invite` is not `entity.create`. oat does not POST a generated invitee. The invite check sends `granteeField` = the peer's `inviteAs`. Missing `inviteAs` is a coverage gap naming the tag.
1022
-
1023
- A create whose `operationId` appears in any principal `auth.steps`, or that declares `x-fresh-principal`, is not seeded. Those rows were provisioned by the auth flow.
1024
-
1025
- Parent path parameters are created first (depth-first through the owning entity's create). Config / principal `roots` fill parameters oat cannot create.
1026
-
1027
- A create that returns `>= 300` on the first variant fails the entity (downstream checks `BLOCKED`). Later variants that fail just shorten the cohort — a partial cohort is still used.
1028
-
1029
- HTTP 429 is retried first — `Retry-After` or exponential backoff, up to five times — on seed, checks, and teardown, whether or not the operation declared `x-rate-limit`. The first 429 is never a seed failure. A leftover 429 after those retries is a gap, not a backend defect.
1030
-
1031
- A 402 / plan-limit (`payment_required`, `*_plan_limit`) on create is not a backend defect when the same-tenant list already has a row — typically an earlier `x-effects` create that filled a free-plan quota. oat reuses that id so children (a `row` after extract created a `table`) can still seed. It does not invent records. Write-path checks on the adopted entity stand down.
1032
-
1033
- A documented feature-gate 403 is the exception: if create declares `x-feature-gate` and the body is `vars.type: feature_gate` (and `vars.feature` matches the tag when present), oat records a `COVERAGE_GAP` naming the tag rather than a seed defect. See [`x-feature-gate`](#x-feature-gate).
1034
-
1035
- When create is tagged `x-unique`, a first-variant seed **409** with a nonempty same-tenant list **adopts** that row (`world.seed` `COVERAGE_GAP` naming `x-unique` — the create could not insert). Unique-conflict checks still run against that row. Write-path oracles that need a body oat submitted stay skipped. 409 with an empty list stays `BLOCKED` (`could not seed`). A 409 without the tag is still today's seed failure. The seed 409 itself is not `create.unique-conflict-rejected` passing — that check is the explicit second POST. See [`x-unique`](#x-unique). Later variants that 409 only shorten the cohort. Generated values for unique body columns differ across variants (a suffix) without weakening `maxLength` / `pattern`; if the document cannot express two distinct values, oat records a gap and skips extra variants.
1036
-
1037
- `--seed` / `seed` makes the bodies identical across runs. It does not make server-assigned ids identical.
1038
-
1039
- Teardown DELETEs created rows (or the `x-cleanup` route) newest-first. Failures and missing delete routes are printed as leftovers, not as check findings. `keepFixtures: true` skips this.
1040
-
1041
- ## Query roles and grammars
1042
-
1043
- Checks do not look for a parameter _named_ `filter`. They resolve **roles** from aliases, then write values in the grammar the document demonstrates.
1044
-
1045
- | role | aliases (normalised: case, `_` / `-`, `perPage` → `per_page`) |
1046
- | ----------------- | ----------------------------------------------------------------------------------- |
1047
- | filter | `filter`, `where`, `query`, `conditions` |
1048
- | order | `order`, `order_by`, `sort`, `sort_by`, `ordering` |
1049
- | select | `select`, `fields`, `field`, `include_fields`, `projection`, `only` |
1050
- | search | `q`, `search`, `query_text`, `term`, `keyword`, `text` |
1051
- | search mode | `search_mode`, `searchmode`, `search_type`, `mode` (only if a search role exists) |
1052
- | limit (page size) | `limit`, `per_page`, `page_size`, `pagesize`, `count`, `max_results`, `top`, `size` |
1053
- | page | `page`, `page_number`, `pagenum`, `p` |
1054
- | offset | `offset`, `skip`, `start`, `from` |
1055
- | cursor | `cursor`, `after`, `starting_after`, `next`, `page_token`, `continuation` |
1056
-
1057
- A bracketed suffix is a _value_ in the name (`fields[articles]`, `filter[status]`), not part of the role. `count` is a page size only when it looks like one (has `maximum` or a default); otherwise it is treated as a total.
1058
-
1059
- A bounded integer with a default that matches no alias is still taken as page size. A 1-based integer with no maximum is taken as page number.
1060
-
1061
- **Filter grammars** — how oat **writes** a term:
1062
-
1063
- | name | example | `and` / `or` |
1064
- | ----------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------- |
1065
- | `postgrest` | `status.eq.active`, `name.neq.x`, `id.in.(a,b)`, `name.ilike.FOO`, `note.is.null`, `tags.contains.x` | `and(a.eq.1,b.eq.2)`, `or(...)` |
1066
- | `colon` | `filter=status=eq:active` (comma-joined terms; no grouping) | not expressible; those checks skip |
1067
- | `equality` | `?status=active` (one query param per field). Only `eq` is expressible | not expressible |
1068
-
1069
- Operators the **postgrest** writer can emit: `eq`, `ne`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`, `like`, `ilike`, `is`, `contains`. Colon stays on `eq` / `neq` / `gt` / `gte` / `lt` / `lte` / `like`. Equality is `eq` only. Anything a grammar cannot write becomes **did not apply**, not a failed request.
1070
-
1071
- A check that needs `in`, `ilike`, `is`, `contains`, a search mode, or `nullsfirst` / `nullslast` also needs that capability **declared**. oat does not infer new operators, modes, or nulls tokens onto an API that never listed them.
1072
-
1073
- **Sort grammars:** `name.asc` (dotted), `-name` (prefixed / JSON:API; ascending is the bare name), `name:asc` (colon), `name asc` (spaced). Dotted (PostgREST-shaped) can also emit `name.asc.nullsfirst` / `name.desc.nullslast` when the capability map allows that token. Colon / prefixed / spaced stay as they are.
1074
-
1075
- **Select grammars:** `id,name` (csv) or `fields[table]=id,name` (bracketed). If the parameter is already named `fields[articles]`, that name is used verbatim.
1076
-
1077
- ### How a grammar is inferred
1078
-
1079
- `x-query.grammar` wins when it is `postgrest` | `colon` | `equality`.
1080
-
1081
- Otherwise oat concatenates the filter/order/select parameter's `example`, `examples`, and `description`:
1082
-
1083
- - Filter: `/postgrest/i` or `field.op.value` / `status.eq.active` → `postgrest`; `status=eq:` → `colon`; else `equality`. A free-text `filter` string that still looks like equality produces an `x-query` gap telling you to declare the grammar.
1084
- - Sort: `name.asc` → dotted; `name:desc` → colon; `name desc` → spaced; leading `-field` → prefixed; else dotted.
1085
- - Select: parameter name or description contains `fields[…]` → bracketed; else csv.
1086
-
1087
- Without `x-query`, if a filter/order/select/search role resolves, oat assumes **every scalar** is filterable/sortable/selectable (`string` / `number` / `integer` / `boolean`, including nullable unions). Searchable-without-tag is further narrowed to names matching `name|title|slug|label|description|email`. `doctor` warns. Pagination-only lists stay uncovered.
1088
-
1089
- That heuristic runs **only** for an axis that was not tagged and not set in config. An explicit empty claim — `filterable: []`, `searchable: null`, `selectable: []`, `sortable: []` — is a claim of none. oat will not infer scalars over it.
1090
-
1091
- Searchable / filterable / sortable / selectable from the tag are used as given. `maxLimit` is also taken from a page-size parameter's `schema.maximum` when the tag omits it.
1092
-
1093
- ### Declared or skip
1094
-
1095
- Every list check consults one **effective capability map** per entity. Precedence, unchanged in spirit:
1096
-
1097
- | order | source | what it contributes |
1098
- | ----- | ------------------------------- | ---------------------------------------------------------------------------------------------------- |
1099
- | 1 | `x-query` on the list operation | fields, structured rows, operators, modes, caps, harvest |
1100
- | 2 | `config.entities[name].query` | union of fields; overlay of ops / modes / caps |
1101
- | 3 | `config.query` | global defaults for the same keys |
1102
- | 4 | heuristic | today's scalars / name-regex searchable — **only if that axis was not tagged and not set in config** |
1103
- | 5 | skip | the check does not apply |
1104
-
1105
- `hooks.resolveQueryCapabilities` runs after 1–3 (and after any `*From` harvest) and may add or replace any axis. Return `null` to keep the merge. Called once per entity after seed, with the seeded parent scope so a follow-up GET can run.
1106
-
1107
- Missing capability → the check does not apply / unresolved. Never `BACKEND_BUG` for an undeclared op, mode, or nulls option.
1108
-
1109
- ## Pagination and envelopes
1110
-
1111
- Three page models, all first-class:
1112
-
1113
- - **Page number** (`page` + `limit` roles).
1114
- - **Offset** (`offset` + `limit`). Checks that say "page 3" translate to `offset = (page - 1) * size` (size defaults to 20 only for that translation).
1115
- - **Cursor** (`cursor` role + envelope `nextCursor` or a `Link: rel=next` header).
1116
-
1117
- `hasMore` is taken from the body (`hasMore`, `has_more`, `hasNextPage`, `more`) **or** from a documented `Link` response header. Under Link pagination, **absence** of `rel="next"` means no more pages.
1118
-
1119
- Collection shape is derived from the success JSON schema, not from hardcoded wrapper names:
1120
-
1121
- - Response `type: array` → the body is the list (`key: null`).
1122
- - Otherwise the array property whose items are objects, skipping sidecar names `error(s)`, `warning(s)`, `message(s)`, `meta`, `links`. Resource-named envelopes (`{ tables: [...] }`) work.
1123
- - Sibling keys become envelope fields:
1124
-
1125
- | role | accepted property names |
1126
- | ---------- | ----------------------------------------------------------- |
1127
- | total | `count`, `total`, `totalCount`, `total_count`, `totalItems` |
1128
- | hasMore | `hasMore`, `has_more`, `hasNextPage`, `more` |
1129
- | nextCursor | `nextCursor`, `next_cursor`, `cursor`, `next`, `endCursor` |
1130
- | page | `page`, `pageNumber`, `page_number`, `offset` |
1131
- | limit | `limit`, `perPage`, `per_page`, `pageSize`, `page_size` |
1132
-
1133
- Success schema is the first JSON media type on responses `200`, `201`, `202`, `2XX`, or `default`. Request schema is taken from `requestBody` preferring `multipart/form-data`, then `application/x-www-form-urlencoded`, then JSON. A success response that lists `text/event-stream` is a stream: oat consumes it to the end and does not treat the raw body as a JSON schema defect. Media type is the stream tag — there is no `x-stream`.
1134
-
1135
- ## OpenAPI meta tags
1136
-
1137
- Vendor-neutral `x-*` extensions. Every one is optional. Precedence: **explicit tag → heuristic → skip with a coverage gap**.
1138
-
1139
- A complete document with every tag in place is shipped as `labs/annotated-openapi.yaml` (also in the npm package). `oat conformance` asserts the derived model matches that file.
1140
-
1141
- ```bash
1142
- oat plan --spec node_modules/@lovrozagar/oat/labs/annotated-openapi.yaml
1143
- oat doctor --spec node_modules/@lovrozagar/oat/labs/annotated-openapi.yaml
1144
- ```
1145
-
1146
- What each tag **unlocks** (otherwise the check cannot run):
1147
-
1148
- | tag | checks unlocked |
1149
- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1150
- | `x-async` | `async.reaches-terminal-state`, `async.receipt-identifies-the-job` |
1151
- | `x-effects` | `effects.declared-effect-occurs` |
1152
- | `x-immutable` | `patch.immutable-field-rejected` |
1153
- | `x-invalidate` | `invalidation.declared-route-changes` (when the list names another entity) |
1154
- | `x-query` | `spec.declared-filterable-is-filterable`, `spec.declared-sortable-is-sortable`, `spec.declared-selectable-is-selectable`, plus the declared-or-skip catalog checks (`in` / `ilike` / `is` / nulls / caps / …) |
1155
- | `x-soft-delete` | `softdelete.absent-from-default-list` |
1156
- | `x-invite` | `auth.invite-grants-then-revokes` |
1157
- | `x-wait` | `effects.side-effect-arrives` |
1158
- | `x-unique` | `create.unique-conflict-rejected`, `update.unique-conflict-rejected` |
1159
-
1160
- What each tag **sharpens** (the check already runs, but the verdict changes):
1161
-
1162
- | tag | without it |
1163
- | ---------- | --------------------------------------------------------------------------------------------------------------------------- |
1164
- | `x-query` | every scalar is probed, including columns you never indexed — expect findings you will dismiss |
1165
- | `x-tenant` | inferred tenant: a cross-tenant read is `AMBIGUITY`, not `SECURITY`. No tenant tagged or inferred: the check does not apply |
1166
-
1167
- ### `x-invalidate`
1168
-
1169
- ```yaml
1170
- x-invalidate:
1171
- - GET /v1/projects/{project_id}/tables
1172
- - GET /v1/projects/{project_id}/tables/{table_id}
1173
- ```
1174
-
1175
- `string[]` of `"METHOD /path"`. Colon or brace path params; oat normalises to brace. Method is uppercased.
1176
-
1177
- This is the entity graph. Inverted, it is each entity's read surface. Highest-value tag.
1178
-
1179
- **Fallback:** pair a mutator with sibling collection/item routes on the same path prefix. Misses cross-entity effects.
1180
-
1181
- **Unlocks:** `invalidation.declared-route-changes` (when the list names _another_ entity's route).
1182
-
1183
- ### `x-entity`
1184
-
1185
- ```yaml
1186
- x-entity:
1187
- name: table
1188
- action: create # create | list | read | update | delete | action
1189
- identity: id
1190
- ```
1191
-
1192
- Overrides path-segment inference. `identity` is required when the item schema has no `id` (or `uuid` / `slug` / `key` / `name`).
1193
-
1194
- **Fallback:** deepest plural segment + HTTP verb. See [How the model is derived](#how-the-model-is-derived).
1195
-
1196
- ### `x-invite`
1197
-
1198
- ```yaml
1199
- x-invite:
1200
- invite: table.invite
1201
- accept: invite.accept
1202
- revoke: table.revoke
1203
- granteeField: key
1204
- tokenPointer: $.token
1205
- grantPointer: $.grant_id
1206
- tokenFrom: response # or outOfBand
1207
- tokenKind: org-invite # only when tokenFrom is outOfBand; default `${entity}-invite`
1208
- acceptFrom: token # default. `link` = GET the OOB URL instead of POSTing accept JSON
1209
- ```
1210
-
1211
- Put this on the invite operation. Config must give the invitee `inviteAs`. Defaults if omitted: `granteeField: key`, `tokenPointer: $.token`, `grantPointer: $.grant_id`, `tokenFrom: response`, `acceptFrom: token`. All three of `invite` / `accept` / `revoke` (operationIds) are required or the tag is ignored. `oat doctor` / `oat plan` print the accept mode.
1212
-
1213
- `tokenFrom: response` (default) reads the accept token from the invite HTTP body at `tokenPointer`. Keep this for backends that still put the token in JSON.
1214
-
1215
- `tokenFrom: outOfBand` ignores the response token and calls `resolveOutOfBand({ address: inviteAs, kind, scope, headers })` after the invite POST. `kind` is `tokenKind` or `${entity}-invite` (`org` → `org-invite`, `project` → `project-invite`). Use this when the live profile must accept only the mailed token.
1216
-
1217
- `acceptFrom: token` (default) stuffs that string into the documented accept JSON / path as today. `acceptFrom: link` requires the string to be an absolute `http(s)` URL: oat GETs it (recorded, cookie-jar follow). The `accept` operationId is unused for that hop; `revoke` still uses the documented revoke operation. 2xx/3xx that leaves the grant readable continues the timeline; 4xx, 404, or an unreadable grant is a finding. A config that still POSTs `{ token }` with `tokenFrom: outOfBand` and no `acceptFrom` does not change meaning.
1218
-
1219
- An invite operation is **not** the entity's fixture create, even when it is `POST` on the collection. oat will not seed it with a generated email. The invite check (and only that check) creates the grant, using `inviteAs` as `granteeField`. The check still runs when there is no non-invite create, as long as an item or list route exists.
1220
-
1221
- Timeline asserted: cannot read → invite → still cannot → accept → can → revoke → cannot.
1222
-
1223
- Accept and revoke send the documented JSON request body when the operation declares one, filled from the invite token / grant id (and other known scope values). A path-only accept (`POST /invites/{token}` with no body) stays path-only — oat does not invent a body.
1224
-
1225
- **Fallback:** the check does not run.
1226
-
1227
- ### `x-query`
1228
-
1229
- String arrays still work. Structured rows are optional. Either, not both required.
1230
-
1231
- ```yaml
1232
- x-query:
1233
- grammar: postgrest # postgrest | colon | equality
1234
- filterable: [id, name, created_at]
1235
- sortable: [name, created_at]
1236
- searchable: [name, slug]
1237
- selectable: [id, name, created_at]
1238
- maxLimit: 100
1239
- defaultOrder: created_at.desc
1240
- stableTiebreak: id
1241
-
1242
- # structured (optional) — unlocks per-field ops / types / nulls
1243
- filterable:
1244
- - { field: id, type: string, ops: [eq, neq, in, nin] }
1245
- - { field: name, type: string, ops: [eq, neq, like, ilike, in] }
1246
- - { field: created_at, type: date, ops: [eq, gt, gte, lt, lte, is] }
1247
- - { field: tags, type: array, ops: [contains, eq, is] }
1248
- sortable:
1249
- - { field: name, type: string }
1250
- - { field: created_at, type: date, nulls: [first, last] }
1251
-
1252
- operators: [eq, ne, neq, gt, gte, lt, lte, in, nin, like, ilike, is, contains]
1253
- operatorsByType:
1254
- string: [eq, ne, neq, like, ilike, in, nin, is]
1255
- number: [eq, ne, neq, gt, gte, lt, lte, in, nin, is]
1256
- date: [eq, ne, neq, gt, gte, lt, lte, is]
1257
- enum: [eq, ne, neq, in, nin, is]
1258
- boolean: [eq, ne, neq, is]
1259
- array: [contains, eq, is]
1260
- aliases: { ne: neq }
1261
- identityFilter: _id # filter field when it differs from the JSON identity
1262
- emptyIn: match-none # reject | match-none; undeclared → empty-in check skips
1263
- maxInValues: 100
1264
- maxFilterConditions: 20
1265
- searchModes: [keyword] # free-form; undeclared → mode checks skip
1266
- searchEmpty: match-all # ignore | match-all | reject
1267
- sortNulls: [first, last]
1268
- maxSortKeys: 3
1269
- selectNested: true # `rel(col)` grammar; undeclared → nested check skips
1270
- selectUnknown: reject # reject | ignore; undeclared → unknown-select check skips
1271
-
1272
- # harvest any axis from another GET — no baked path
1273
- filterableFrom: { operationId: table.get, path: $.columns[*].name, typePath: $.columns[*].type, typeMap: { text: string, int: number } }
1274
- sortableFrom: { operationId: table.get, path: $.columns[*].name }
1275
- searchableFrom: { operationId: table.get, path: $.columns[?(@.searchable==true)].name }
1276
- selectableFrom: { operationId: table.get, path: $.columns[*].name }
1277
- ```
1278
-
1279
- `defaultOrder` / `stableTiebreak` / `maxLimit` stay. Harvest keys are generic JSON paths (`$`, dots, `[n]`, `[*]`, `[?(@.key==value)]`). Absent → no harvest.
1280
-
1281
- String arrays + `operatorsByType` is enough for most APIs. Per-field `ops` / `nulls` close the list that field actually accepts.
1282
-
1283
- **Fallback:** if those roles resolve and the axis was not tagged and not set in config, treat every scalar as capable and warn. Empty tagged `filterable: []` / `searchable: null` / `selectable: []` is an explicit claim of none.
1284
-
1285
- **Unlocks:** `spec.declared-filterable-is-filterable`, `spec.declared-sortable-is-sortable`, `spec.declared-selectable-is-selectable`. Structured extras unlock the matching catalog checks (`in` = union of `eq`, `ilike` vs `like`, `is.null`, illegal op, empty `in`, caps, nulls, search empty/modes, unknown select, nested `rel(col)`). Sharpens every other query check (without the tag they probe columns you may not have indexed).
1286
-
1287
- `oat doctor` prints, per entity, the effective map (all four axes, ops, modes, caps, harvest/hook) and which new checks will apply. Unknown `config.entities` names are ignored and warned.
1288
-
1289
- ### `x-async`
1290
-
1291
- ```yaml
1292
- x-async:
1293
- poll: "GET /v1/projects/{project_id}/batches/{batch_id}"
1294
- idFrom: batch_id # or $.id
1295
- until: "status.in.complete,partial,failed"
1296
- successWhen: "status.eq.complete"
1297
- timeoutMs: 120000
1298
- pollIntervalMs: 2000
1299
- ```
1300
-
1301
- `x-async` means **POST is a receipt, then poll**. It is not how you mark a stream. A stream is a success response that lists `text/event-stream`.
1302
-
1303
- When the start response is JSON, oat polls `poll` until `until` matches, then treats that payload as the result. `poll` may be an operationId or `"GET /path/{id}"`. Defaults: `timeoutMs: 120000`, `pollIntervalMs: 2000`.
1304
-
1305
- When the start response is `text/event-stream`, oat parses `event:` / `data:` frames. `data` is JSON when it starts with `{` / `[`. `idFrom` is resolved against **each event's JSON `data`**, first hit wins — `$.batch_id` on `event: batch` data `{ "batch_id": "…" }` works. A frame named `complete` / `error`, or one whose `data` matches `until`, is the terminal record; `successWhen` is applied to it and oat does **not** GET the poll route. Poll only if the stream ended without a terminal frame **and** `idFrom` resolved.
1306
-
1307
- A spec may leave both `x-async` and `text/event-stream` on the same operation. The stream is still the result; `x-async` only supplies `idFrom` / `until` / the poll fallback.
1308
-
1309
- `until` / `successWhen` use the same `field.op.value` predicates as filters (`eq`, `in`, …).
1310
-
1311
- **Fallback:** treated as synchronous; async checks are `COVERAGE_GAP`. A 2xx stream without `x-async` is consumed and recorded; async checks do not run.
1312
-
1313
- ### `x-effects`
1314
-
1315
- ```yaml
1316
- x-effects:
1317
- - { entity: table, op: create }
1318
- - { entity: row, op: append, min: 1 }
1319
- ```
1320
-
1321
- `op`: `create` | `append` | `update` | `delete` | `replace`. Each item is `{ entity, op, count?, min? }`.
1322
-
1323
- - `count` is an **exact** cardinality delta on that entity's list.
1324
- - `min` is **at-least** (`delta >= min` and `added.length >= min`). Use this when the child count is data-dependent (an extract that appends 1 / 2 / 5 rows).
1325
- - Omit both → `count: 1` (invite / create).
1326
- - Set both on one item → rejected at load / `oat doctor` (`x-effects` gap). The item is not checked.
1327
-
1328
- After a write that declares `create` on A, oat binds the new A id from the write response (`table_id`, or the entity identity) or from A's list delta — the same adopt idea as a 402 plan-limit reuse. Later items in **that same** `x-effects` array whose child list is under A (`GET .../tables/{table_id}/rows`) fill the path with that id. `x-wait` after the same write uses the same bound id. No tester hook.
1329
-
1330
- An extract-shaped write (create table + append ≥1 row) fails when the new table's row list is empty, and passes when it has 5.
1331
-
1332
- **Fallback:** derived from `x-entity.action` for this entity only.
1333
-
1334
- ### `x-wait`
1335
-
1336
- ```yaml
1337
- x-wait:
1338
- operationId: inbox.list
1339
- until: $.items.0
1340
- timeoutMs: 30000
1341
- pollIntervalMs: 1000
1342
- ```
1343
-
1344
- Put this on the **write**. After that write succeeds, oat polls `operationId` until `until` (JSON path `$.items.0` or JSON pointer `/items/0`) is non-empty, or `hooks.awaitSideEffect` returns `true`. Default `timeoutMs` is **30s**. Timeout is a **finding** (`effects.side-effect-arrives`), not a coverage gap.
1345
-
1346
- Use this for queue consumers and webhook inboxes (1–30 s), not for the same request. `x-effects` still asserts cardinality; `x-wait` asserts “this other GET eventually has a body”. If the poll path needs a parent id the write created, oat binds it the same way `x-effects` does.
1347
-
1348
- **Fallback:** the check does not run.
1349
-
1350
- ### `x-soft-delete`
1351
-
1352
- ```yaml
1353
- x-soft-delete: deleted_at
1354
- ```
1355
-
1356
- On any operation of the entity (commonly DELETE). Tombstone, not remove. Without it, a correct soft-delete looks like a bug (the row is still GET-able).
1357
-
1358
- ### `x-immutable` / `x-generated`
1359
-
1360
- ```yaml
1361
- x-immutable: [id, project_id, created_at]
1362
- x-generated: [id, created_at, updated_at]
1363
- ```
1364
-
1365
- Generated fields are omitted from create bodies and expected in responses. Immutable fields must reject or ignore PATCH.
1366
-
1367
- **Fallback:** `readOnly: true` counts as generated. No immutability testing without the tag.
1368
-
1369
- ### `x-tenant`
1370
-
1371
- ```yaml
1372
- x-tenant: project_id
1373
- ```
1374
-
1375
- Path parameter that scopes the operation.
1376
-
1377
- **Fallback:** regex over `{organization_id}`, `{project_id}`, `{tenant_id}`, `{workspace_id}`, `{app_slug}`, `{org_id}`, `{account_id}`, … (`org|organization|tenant|workspace|account|project|app` + optional `_id`/`_slug`). Without the tag, a matching path parameter still infers a tenant and a cross-tenant read is `AMBIGUITY`, not `SECURITY`. Omitting `x-tenant` and not naming a tenant path parameter means the check does not apply.
1378
-
1379
- ### `x-root`
1380
-
1381
- ```yaml
1382
- # on a path parameter, not an operation
1383
- x-root: true
1384
- ```
1385
-
1386
- This resource has no create endpoint; supply it in config `roots` / principal `roots`.
1387
-
1388
- **Fallback:** inferred when a path param has no create op; everything beneath is `UNSEEDABLE`.
1389
-
1390
- ### `x-cleanup`
1391
-
1392
- ```yaml
1393
- x-cleanup: "DELETE /v1/projects/{project_id}/tables/{table_id}"
1394
- ```
1395
-
1396
- Teardown route when the entity has no discoverable delete. Without it, leftover records are reported at end of run.
1397
-
1398
- ### `x-cost` / `x-destructive` / `x-idempotent` / `x-fresh-principal`
1399
-
1400
- ```yaml
1401
- x-cost: high # low | medium | high
1402
- x-destructive: true
1403
- x-idempotent: true
1404
- x-fresh-principal: true
1405
- ```
1406
-
1407
- `x-cost` and `x-destructive` are consulted by `--profile` (below). `x-idempotent` and `x-fresh-principal` are parsed onto the operation model for the `plan`/`doctor` output but not yet consulted anywhere else. Replay safety is tested from a documented `Idempotency-Key` header (`idempotency.replay-does-not-duplicate`), not from `x-idempotent`.
1408
-
1409
- ### `x-feature-gate`
1410
-
1411
- ```yaml
1412
- x-feature-gate: webhooks # or custom_domain, audit_log, …
1413
- ```
1414
-
1415
- Plan key this operation is sold behind. Honey/apps emit it as route meta → OpenAPI. `doctor` / `plan` show it. A non-string or missing tag is ignored (`null`).
1416
-
1417
- This is not cost. `--profile cheap` skips expensive operations; a free principal hitting `webhook.create` is the real product. Skipping the op in a profile would hide the gate.
1418
-
1419
- A 403 is a **documented feature-gate denial** only when all of:
1420
-
1421
- 1. The operation has `x-feature-gate: <string>`.
1422
- 2. HTTP status is 403.
1423
- 3. JSON body `vars.type === "feature_gate"`.
1424
- 4. `vars.feature` equals the tag **when `vars.feature` is a string**. Absent `vars.feature` is enough together with (3). A string that disagrees with the tag is backend/tag drift — still a seed failure.
1425
-
1426
- `error_key` / `feature_name` / `required_plan` are i18n/product and are not required. A typical body:
1427
-
1428
- ```json
1429
- {
1430
- "success": false,
1431
- "status": 403,
1432
- "status_key": "forbidden",
1433
- "error_key": "forbidden",
1434
- "vars": {
1435
- "type": "feature_gate",
1436
- "feature": "webhooks",
1437
- "feature_name": "Webhooks",
1438
- "current_plan": "free",
1439
- "required_plan": "pro"
1440
- }
1441
- }
1442
- ```
1443
-
1444
- A gated create is a **coverage gap, not a fail**. oat degrades the entity the same way `--profile` excluding `create` does: `COVERAGE_GAP` on `world.seed` naming `x-feature-gate: <key>` (and the plan vars if present); remaining checks that needed a seeded row `did not apply` / `BLOCKED` because of that gap, not a page of "returned 403" copies. If the list route already has rows, read-only checks still run.
1445
-
1446
- A later write (`create` after seed, `update`, action) that returns a documented gate 403 is the same: the check that needed a 2xx is `COVERAGE_GAP` / did not apply, citing the tag — not `SECURITY`, not a schema defect. `validation.*` and `schema.error-response-matches-document` still apply: the 403 body must match the documented 403 schema. A gate 403 with an undeclared shape is still drift.
1447
-
1448
- Every 403 is not a feature gate. No tag, or a tag that disagrees with `vars.feature`, stays a `SeedError`.
1449
-
1450
- **Fallback:** none. Without the tag, a 403 is a failed create.
1451
-
1452
- ### `x-unique`
1453
-
1454
- ```yaml
1455
- x-unique:
1456
- - [email]
1457
- - [workspace_id, slug]
1458
- # or: { columns: [email] }
1459
- # or a single string[] meaning one set: [email]
1460
- ```
1461
-
1462
- Column sets that must stay unique. Honey/apps emit this as route meta → OpenAPI. `doctor` / `plan` show the effective sets per entity the way they show `x-feature-gate`.
1463
-
1464
- Accepted shapes: a list of column sets, `{ columns: [...] }` objects, and a single `string[]` meaning one set. Each set is a non-empty list of column names; empty sets are dropped. Malformed / non-array → treat as absent (`null`), unique checks do not run, `doctor` records an `x-unique` gap. `[]` after filtering → explicit none, checks do not run. No tag → unique checks do not run, `doctor` says so.
1465
-
1466
- Do not infer uniqueness from 409s, unique-looking names, or JSON Schema `uniqueItems`. Index names and product `error_key` / `vars.type` are not required; HTTP **409** is the unique-conflict class.
1467
-
1468
- `create.unique-conflict-rejected` — after a known row (seeded or adopted), a second create with the same unique-set values is 409, list cardinality does not grow, and a documented 409 body still matches the 409 schema. **2xx is `BACKEND_BUG`** (evidence: both exchanges, unique columns, list before/after when list resolved; tear down a returned id). Probe each probeable set separately (one 2xx fails the check; do not collide every set in one request). Probeable = at least one column on the create JSON or form body; path/tenant/`x-generated` columns may fill set identity from scope, but a set with no body columns is skipped, not failed. Do not reuse `Idempotency-Key` / `Idempotence-Key` / `X-Idempotency-Key` (omit, or send a fresh key if the document requires it). 402 / documented feature-gate 403 on the probe is `COVERAGE_GAP`, not a unique pass. Other 4xx / 5xx is not a unique pass. Verdict is never `SECURITY`. Leftover/extra rows do not skip the check.
1469
-
1470
- `update.unique-conflict-rejected` — PATCH a **different** row onto another row's unique-set values is 409 (same scoring). PATCH of a row's own unique values unchanged is not this check. Skip update sets whose columns are all `x-immutable`.
1471
-
1472
- **Fallback:** none. Without the tag, unique checks do not run, and a seed 409 is a failed create.
1473
-
1474
- ### `--profile` — cost gating
1475
-
1476
- ```bash
1477
- oat run --config oat.config.ts --profile cheap
1478
- ```
1479
-
1480
- A profile restricts which operations a run is allowed to touch, filtering on `x-cost` and `x-destructive`. Two exist without being declared anywhere: `full` (no gating — the default, today's behaviour if you never mention a profile) and `cheap` (`{ maxCost: "low" }`). Reach for a profile when some operations are expensive to call every run — an extraction endpoint billed per request, a bulk job, anything you don't want fired on every `oat run`.
1481
-
1482
- Anything more specific than a cost band is a named entry in config:
1483
-
1484
- ```ts
1485
- export default defineConfig({
1486
- // ...
1487
- profiles: {
1488
- // skip everything above "low" cost, same as the built-in "cheap"
1489
- cheap: { maxCost: "low" },
1490
- // skip destructive operations and two specific extraction endpoints
1491
- safe: { excludeDestructive: true, exclude: ["report.extract", "report.summarize"] },
1492
- },
1493
- profile: "safe", // --profile on the CLI overrides this
1494
- })
1495
- ```
1496
-
1497
- An excluded operation never silently narrows what gets reported. Excluding an entity's `create` degrades that entity the same way a real seeding failure does — a `COVERAGE_GAP` naming the reason, then read-only checks run against whatever the list route already returns; `BLOCKED` if nothing exists to fall back on. Excluding `read`/`update`/`delete` individually stands down just the checks that need that one operation.
1498
-
1499
- Exclusion applies to every invocation, not only create/read/update/delete. `effects.declared-effect-occurs` and `async.reaches-terminal-state` drop ops the profile forbids and record `profile.skip` — they do not POST `extract.once` under `--profile cheap`. A check whose only targets were excluded did not apply / names the profile; it never looks like the backend returned 500.
1500
-
1501
- The run summary states what a profile skipped: `skipped 12 operation(s) under --profile cheap (12 high-cost)` — the same principle as `did not apply` for a coverage gap: a report that only shows what ran invites the reader to assume the rest was verified.
1502
-
1503
- `--profile cheap` also defaults the exchange journal **off**. `--save-exchanges` turns it back on; `--quiet` does not change it.
1504
-
1505
- ### `x-rate-limit` — pacing oat's own traffic
1506
-
1507
- ```yaml
1508
- x-rate-limit: { category: ai, rps: 3 }
1509
- ```
1510
-
1511
- Groups operations sharing one throughput budget (`category`) and optionally the rate itself (`rps`). Without this, oat's matrix can hammer a `login` or paid-inference route past its real limit, collect 429s, and report them as backend defects — exactly the false-positive class that erodes trust fastest. With it, requests to that category are paced through a token bucket before they fire.
1512
-
1513
- Tags are the **proactive** path. HTTP 429 is the **reactive** path and is honoured even when the operation has no `x-rate-limit` at all (untagged JWT writes, teardown DELETEs). oat reads `Retry-After` (delta-seconds or HTTP-date), otherwise backs off 1s, 2s, 4s… capped at 30s, and retries the same request up to five times. The wait is fed into the matching bucket, or into an implicit `untagged-write` bucket so the next call does not immediately re-trip.
1514
-
1515
- A 429 is only ever reported when the request that drew it was demonstrably under the _declared_ rate — oat's own bucket had a free token, so it did not have to wait for one. A 429 that arrived only after oat's bucket made the request wait means oat's own rate model was too generous, which is paced around, never reported. A 429 against a config-supplied or implicit rate is never a finding.
1516
-
1517
- `config.rateLimits` is checked first and needs no tag at all — it is what keeps oat usable against a backend that has not adopted `x-rate-limit` yet, or against an environment (staging, usually) whose real limit differs from what the document claims for production. A 429 against a config-supplied rate is never a finding: it is the operator's own belief about the environment, not a claim the API made.
1518
-
1519
- ```ts
1520
- export default defineConfig({
1521
- // ...
1522
- rateLimits: [
1523
- { match: "POST /v1/auth/login", rps: 2 },
1524
- { match: "auth.login", rps: 2 }, // operationId works too
1525
- { match: "category:ai", rps: 1 }, // overrides every x-rate-limit-tagged "ai" operation at once
1526
- ],
1527
- })
1528
- ```
1529
-
1530
- ## Checks
1531
-
1532
- 96 checks. A check that cannot run says so (`did not apply` + `needs`). A check that depends on a broken primitive is `BLOCKED`. A check that ran and stopped is inconclusive, not a pass.
1533
-
1534
- Order is fixed (foundations first) so cascade suppression has a cause to point at. Mutating checks run alone; read-only checks may share in-flight requests under `maxInFlight`.
1535
-
1536
- `depends` is the `dependsOn` list: if any of those already failed **for this entity**, this check is `BLOCKED` rather than reported as a second defect. Suppression is transitive.
1537
-
1538
- | id | asserts | needs | depends |
1539
- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- | --------------------------------------- |
1540
- | `list.read-after-write` | a just-created record appears on the list | create + a seeded record | — |
1541
- | `create.persists-submitted-fields` | every writable field sent on create is echoed | create that echoes the record | `list.read-after-write` |
1542
- | `payload.string-survives` | a documented-valid string is stored exactly; 4xx after an ASCII control is a fail | update or create+delete, item GET, unconstrained string | `list.read-after-write` |
1543
- | `create.status-matches-document` | create status is one the document declared | create | — |
1544
- | `response.status-is-documented` | every non-create exchange returns a status that operation names (`default` ≠ 201) | a modeled non-create operation oat invoked | — |
1545
- | `schema.success-response-matches-document` | create body validates against the success schema | success schema on create | `create.status-matches-document` |
1546
- | `schema.error-response-matches-document` | an error body validates against the documented error schema | error schema on the item route | — |
1547
- | `pagination.limit-bounds-page-size` | page size ≤ the requested limit | page-size _role_ (aliases include `limit`, `per_page`, …) | `list.read-after-write` |
1548
- | `pagination.limit-respects-documented-max` | requesting more than `maxLimit` does not return more | declared `maxLimit` and a larger cohort | `pagination.limit-bounds-page-size` |
1549
- | `pagination.has-more-is-accurate` | `hasMore` / `Link rel=next` matches whether another page exists | page-forward + `hasMore` or `Link rel=next` | `pagination.limit-bounds-page-size` |
1550
- | `pagination.page-walk-covers-set` | walking pages covers the collection with no gaps or dupes | page or offset + ≥3 records | `pagination.limit-bounds-page-size` |
1551
- | `pagination.cursor-agrees-with-page` | cursor walk and page walk yield the same set | both cursor and page | `pagination.limit-bounds-page-size` |
1552
- | `filter.unknown-field-rejected` | a filter on a field that does not exist is not silently ignored | a filter expression | — |
1553
- | `filter.equality-selects-exactly-one` | `id.eq.<one>` returns that one record | equality on the identity | `list.read-after-write` |
1554
- | `filter.zero-match-returns-none` | a filter that matches nothing returns an empty page, not the whole set | same | `list.read-after-write` |
1555
- | `filter.negation-partitions-the-set` | `eq` ∪ `neq` = whole set, intersection empty | eq and neq | `list.read-after-write`, equality |
1556
- | `filter.and-composes-as-intersection` | `and(A,B)` = A ∩ B | two filterable fields + AND | equality / list |
1557
- | `filter.or-composes-as-union` | `or(A,B)` = A ∪ B | `or()` — **postgrest grammar only** | equality / list |
1558
- | `filter.like-metacharacters-escaped` | `%` `_` `*` in a value are literals, not wildcards | like operator | `list.read-after-write` |
1559
- | `filter.numeric-comparison-is-numeric` | `gt`/`lt` on a number uses numeric order, not TEXT (`1,10,2`) | numeric field + a filter param | `list.read-after-write`, unknown-field |
1560
- | `filter.in-is-union-of-eq` | `in.(a,b)` = `eq.a` ∪ `eq.b` | field allows `in`; ≥2 distinct values | equality |
1561
- | `filter.nin-complements-in` | `in` ∩ `nin` empty; union = set minus nulls | field allows `in` and `nin` | `in` |
1562
- | `filter.gte-is-gt-or-eq` | `gte.x` = `gt.x` ∪ `eq.x` | field allows `gte` and `gt`; ordered type | numeric comparison |
1563
- | `filter.lte-is-lt-or-eq` | `lte.x` = `lt.x` ∪ `eq.x` | field allows `lte` and `lt` | numeric comparison |
1564
- | `filter.ordered-triple-partitions` | `lt` ∪ `eq` ∪ `gt` = set minus nulls; pairwise disjoint | field allows all three | numeric comparison |
1565
- | `filter.ilike-is-case-insensitive` | case-flipped value: `ilike` matches; `like` does not (unresolved if both match) | field allows both | like |
1566
- | `filter.is-null-selects-nulls` | `is.null` = nulls; `is.notnull` = complement | field allows `is`; cohort has a null | foundations |
1567
- | `filter.contains-membership` | `contains.<el>` = records whose array value includes `el` | array field or ops include `contains` | foundations |
1568
- | `filter.nested-and-or-distributes` | `and(A,or(B,C))` = (A∩B) ∪ (A∩C) | postgrest grammar; ≥2 filterable fields | `and` / `or` |
1569
- | `filter.alias-matches-canonical` | each declared alias token selects the same id-set as its target | `aliases` non-empty | equality |
1570
- | `filter.illegal-op-rejected` | one op **not** in that field's `ops` is 4xx | closed `ops` list | unknown-field |
1571
- | `filter.empty-in` | `in.()` is 4xx (`reject`) or zero rows (`match-none`) | `emptyIn` set; field allows `in` | `in` |
1572
- | `filter.in-over-limit-rejected` | `in` list of `maxInValues+1` is 4xx | `maxInValues` set | foundations |
1573
- | `filter.condition-cap-rejected` | `maxFilterConditions+1` `eq` terms is 4xx | `maxFilterConditions` set | foundations |
1574
- | `spec.declared-filterable-ops-accepted` | every declared field × every op in that field's `ops` returns <400 | closed `ops` | declared-filterable |
1575
- | `spec.declared-filterable-illegal-op-rejected` | one illegal op per declared field is 4xx | closed `ops` | illegal-op |
1576
- | `error.malformed-filter-not-5xx` | garbage filter text is 4xx, never 5xx | a filter expression | — |
1577
- | `query.filter-selects-from-whole-set` | a filter is applied to the collection, not to the current page | filterable + ≥3 records | list / walk |
1578
- | `sort.order-is-applied` | requesting a sort actually rearranges the page | order + a sortable field | `pagination.limit-bounds-page-size` |
1579
- | `sort.reverse-symmetry` | desc is the reverse of asc (nulls included) | order + asc/desc | order-is-applied |
1580
- | `sort.unknown-field-rejected` | `order` on an undeclared field is 4xx, not silent ignore | order param | — |
1581
- | `sort.numeric-order-is-numeric` | `1,10,2` sorts as numbers, not text | numeric sortable field whose lexical order disagrees | order-is-applied |
1582
- | `sort.nulls-first-last` | `nullsfirst` / `nullslast` put nulls at the start / end of asc | declared nulls token; dotted grammar; cohort has a null | order + reverse |
1583
- | `sort.multi-key-tiebreak` | ties on the first key are ordered by the second | ≥2 sortable fields; `maxKeys` absent or ≥2 | order + reverse |
1584
- | `sort.default-order-applied` | omitting `order` matches `defaultOrder` | `defaultOrder` set; walk complete | order + walk |
1585
- | `sort.stable-tiebreak` | the same `order` twice yields the same sequence | `stableTiebreak` set | order-is-applied |
1586
- | `spec.declared-sortable-nulls-accepted` | each declared nulls token returns <400 | some field/global declares `nulls` | order-is-applied |
1587
- | `search.q-narrows-result` | a search term that matches one record does not return the whole set | search param + searchable fields | `list.read-after-write` |
1588
- | `search.tokens-and` | `q=a b` = intersection (AND). Sameness of AND and OR passes | searchable fields; two tokens that split the cohort | `q-narrows` |
1589
- | `search.case-insensitive` | case-flipped token matches the same set (unresolved if the backend is case-sensitive) | searchable field with a letter | `q-narrows` |
1590
- | `search.empty-q` | `q=` is ignore / match-all / reject as declared | `searchEmpty` set | `q-narrows` |
1591
- | `search.undeclared-field-not-required` | extra recall on a non-searchable field is not `SEARCH_IGNORED` | ≥1 searchable and ≥1 non-searchable string | `q-narrows` |
1592
- | `search.mode-accepted` | each declared `searchModes` value is <400 on the mode param | `searchModes` set and a mode role | — |
1593
- | `search.modes-differ` | two modes may differ; exact sameness is unresolved, not a fail | ≥2 `searchModes`; a mode param | `mode-accepted` |
1594
- | `select.projection-honoured` | `select=id,name` does not return undeclared fields | select param | — |
1595
- | `select.requested-fields-present` | every name in `select=` appears on each returned item | select param; ≥1 selectable field | projection |
1596
- | `select.unknown-field-rejected` | unknown select name is 4xx (`reject`) or dropped (`ignore`) | `select.unknown` set | projection |
1597
- | `select.nested-honoured` | `rel(col)` returns `rel` as an object/array carrying only `col` | `select.nested` and a named relation | projection |
1598
- | `count.consistent-with-returned-page` | envelope total ≥ rows on this page, and is not zero when the page is not | envelope total | `list.read-after-write` |
1599
- | `count.matches-filtered-set` | filtered total equals the size of the filtered walk | total + a filter | list, equality |
1600
- | `query.axes-compose` | filter + sort together: filter still holds on the sorted page | filterable + sortable | filter + sort foundations |
1601
- | `query.filter-and-select-compose` | filter + select together | filterable + select | same |
1602
- | `query.search-and-filter-compose` | search + filter together | filterable + search | same |
1603
- | `query.filter-sort-select-compose` | filter + sort + select | filter + sort + select | same |
1604
- | `query.filter-search-sort-compose` | filter + search + sort | filter + search + sort | same |
1605
- | `query.filter-search-select-compose` | filter + search + select | filter + search + select | same |
1606
- | `query.sort-and-select-compose` | sort + select: order holds; extras dropped; requested fields present | sortable + selectable | sort + select |
1607
- | `query.search-and-select-compose` | search + select: search membership holds; extras dropped | searchable + selectable | search + select |
1608
- | `query.search-and-sort-compose` | search + sort: search membership holds; remaining rows ordered | searchable + sortable | search + sort |
1609
- | `query.filter-search-sort-select-compose` | all four: filter ∩ search; order holds; extras dropped | all four axes declared | the triples |
1610
- | `spec.declared-filterable-is-filterable` | every `x-query.filterable` field actually accepts a filter | `x-query` naming filterable fields | filter foundations |
1611
- | `spec.declared-sortable-is-sortable` | every `x-query.sortable` field actually accepts a sort | `x-query` naming sortable fields | sort foundations |
1612
- | `spec.declared-selectable-is-selectable` | every `x-query.selectable` field actually accepts a select | `x-query` naming selectable fields | select |
1613
- | `tenant.item-not-readable-cross-tenant` | principal B cannot GET principal A's item | second principal, different `roots`, and a tagged or inferred tenant | — |
1614
- | `tenant.denial-does-not-reveal-existence` | 404 vs 403 (or equivalent) does not distinguish "exists other tenant" from "missing" | second principal, and a tagged or inferred tenant | `tenant.item-not-readable-cross-tenant` |
1615
- | `tenant.filter-does-not-bypass-scope` | `filter=id.eq.<other tenant>` does not return that row | second principal, a filter, and a tagged or inferred tenant | `query.filter-selects-from-whole-set` |
1616
- | `auth.rank-is-monotonic` | a lower rank cannot do what a higher rank is denied | two same-tenant principals at different `rank` | `list.read-after-write` |
1617
- | `auth.invite-grants-then-revokes` | invite → accept grants; revoke takes it back | `x-invite` + peer with `inviteAs` | list, cross-tenant |
1618
- | `create.unique-conflict-rejected` | a second create colliding a documented unique set is 409, not 2xx; the list does not grow | `x-unique` with a probeable create body column and a known row | — |
1619
- | `update.unique-conflict-rejected` | PATCHing a **different** row onto another row's unique-set values is 409, not 2xx | `x-unique`, update, two known rows; skip all-`x-immutable` sets | — |
1620
- | `patch.immutable-field-rejected` | PATCHing an `x-immutable` field is rejected or ignored | `x-immutable` | — |
1621
- | `softdelete.absent-from-default-list` | a soft-deleted row is gone from the default list | `x-soft-delete` | `list.read-after-write` |
1622
- | `invalidation.declared-route-changes` | after a write, the other entity's listed route actually changes | `x-invalidate` naming another entity | list, persist |
1623
- | `effects.declared-effect-occurs` | `x-effects` cardinality delta is observed on the named list (`count` exact, `min` at-least; nested child lists bind the created parent id) | `x-effects` | `list.read-after-write` |
1624
- | `effects.side-effect-arrives` | after the write, the named GET’s JSON path is occupied before `timeoutMs` | `x-wait` | `list.read-after-write` |
1625
- | `async.reaches-terminal-state` | `x-async` reaches `until` (poll, or a terminal SSE frame) before `timeoutMs` | `x-async` | — |
1626
- | `async.receipt-identifies-the-job` | `idFrom` on the receipt (JSON object or SSE event JSON) resolves to a pollable job | `x-async` + `idFrom` | — |
1627
- | `patch.minimality` | PATCH `{ name }` does not clear other writable fields | update + item route | — |
1628
- | `idempotency.replay-does-not-duplicate` | same Idempotency-Key + same body does not create a second row | create + documented Idempotency-Key header | list, persist |
1629
- | `delete.absent-record-returns-404` | DELETE of a missing id is 404, not 200 | delete | — |
1630
- | `concurrency.no-lost-update` | two PATCHes to different fields do not clobber each other | update + two writable strings | persist + patch |
1631
- | `validation.enum-enforced` | a value outside the enum is rejected | enum in the request schema | — |
1632
- | `validation.max-length-enforced` | a string over `maxLength` is rejected | maxLength | — |
1633
- | `validation.required-enforced` | omitting a required field is rejected | required field | — |
1634
- | `validation.content-type-enforced` | a wrong Content-Type is 415 when 415 is documented | documented 415 | — |
1635
- | `consistency.projections-agree` | list, item, and filtered views of the same field agree | item route + a comparable field | list + persist + filter |
1636
-
1637
- On a typical untagged CRUD document (create, list, item, `page`/`limit`, maybe `sort`):
1638
-
1639
- - Foundations, PATCH/delete, and schema checks usually run.
1640
- - The query matrix runs when filter/order/select/search roles resolve.
1641
- - Isolation runs only if you configured two principals.
1642
- - Spec-as-adversary and tagged behaviour never run — `doctor` says so.
1643
-
1644
- Worked examples of what a finding looks like:
1645
-
1646
- ```text
1647
- BACKEND_BUG table created row missing from GET /tables
1648
- list.read-after-write
1649
-
1650
- BACKEND_BUG product PATCH { name } cleared description
1651
- patch.minimality
1652
-
1653
- SECURITY table GET /tables/{id} readable with the other tenant's key
1654
- tenant.item-not-readable-cross-tenant
1655
-
1656
- SPEC_BUG table x-query.filterable lists "ghost"; filter=ghost.eq.x is 400
1657
- spec.declared-filterable-is-filterable
1658
-
1659
- BACKEND_BUG table in() is not the union of the equalities it lists
1660
- filter.in-is-union-of-eq
1661
-
1662
- BACKEND_BUG table an illegal filter operator is accepted
1663
- filter.illegal-op-rejected
1664
-
1665
- COVERAGE_GAP batch no x-async; receipt treated as the result
1666
- async.reaches-terminal-state
1667
- ```
1668
-
1669
- ## Verdicts, skips, and exit codes
1670
-
1671
- | verdict | meaning | fails `oat run`? |
1672
- | -------------- | -------------------------------------------------------------------- | ---------------- |
1673
- | `BACKEND_BUG` | the handler is wrong | yes |
1674
- | `SPEC_BUG` | the document is wrong (or disagrees with the handler) | yes |
1675
- | `SECURITY` | isolation/authz failure and `x-tenant` (or equivalent) was declared | yes |
1676
- | `AMBIGUITY` | same evidence, but the tenant boundary was only inferred | yes |
1677
- | `COVERAGE_GAP` | the check could not run; the report names the missing tag or surface | no |
1678
- | `BLOCKED` | a check this one depends on already failed | no |
1679
-
1680
- Separate from findings:
1681
-
1682
- - **did not apply** — entity never had what `needs` lists (printed in the report, not a pass). Example: no `select` parameter → `select.projection-honoured` did not apply.
1683
- - **inconclusive** — the check ran and stopped (empty listing, probe 4xx, no shared filterable field, …). Not a pass. The report prints the reason.
1684
-
1685
- Coverage is split **never** (zero entities could run it) vs **partial** (ran on some entities, skipped on others). A clean run still prints both. "Nothing found" and "nothing was looked for" are different.
1686
-
1687
- Cascade suppression is transitive: one root cause is one finding, not a page of consequences. A blocked check has **not** been verified; re-run after the cause is fixed.
1688
-
1689
- `oat run` exit `1` if any finding has a failing verdict. Gaps and blocked entries do not fail CI.
1690
-
1691
- Console (stdout) after a run:
1692
-
1693
- ```
1694
- 50 checks · 5 entities · 842 requests · 41.2s · p95 90ms · 4 checks did not apply
1695
-
1696
- BACKEND DEFECTS (1)
1697
- product PATCH { name } also cleared description
1698
- patch.minimality
1699
-
1700
- DID NOT APPLY — no entity had what these need
1701
- async.reaches-terminal-state needs an operation declaring x-async
1702
-
1703
- leftover teardown printed next
1704
- report / matrix / graph / progress paths
1705
- ```
1706
-
1707
- ## Reports
1708
-
1709
- Written under `--out` (default `./.oat/runs`). Each invocation creates a UTC timestamp folder and points `latest` at it:
1710
-
1711
- ```
1712
- .oat/runs/2026-08-18T12-00-00Z/
1713
- .oat/runs/latest -> 2026-08-18T12-00-00Z
1714
- ```
1715
-
1716
- `--out` / `outDir` replace the root, not the leaf — `--out .oat/runs/prod` writes `.oat/runs/prod/<datetime>/`.
1717
-
1718
- | file | |
1719
- | ---------------------------- | ------------------------------------------------------------------------------------------------------ |
1720
- | `oat-report.md` | human report: summary, findings with request/response excerpts, coverage, latency p50/p95/max |
1721
- | `oat-report.json` | same data for CI. Summary only — full exchanges are not inlined here |
1722
- | `matrix.html` | visual matrix of entities × checks |
1723
- | `matrix.json` | the same graph (AI-friendly), including a mermaid string |
1724
- | `issue-repro/*.sh` | one executable `curl` script per finding that has evidence. Directory is omitted when the run is clean |
1725
- | `progress.log` | logfmt, one event per line, never truncated |
1726
- | `progress.jsonl` | same events as JSON |
1727
- | `progress.tsv` | same columns, tab-separated. `req_id` is the join key to the exchange journal |
1728
- | `progress.json` | latest snapshot only (overwritten ~1s) |
1729
- | `exchanges.jsonl` | one line per request (`seq`, `requestId`, method, url, status, bytes, …). Greppable |
1730
- | `exchanges/<requestId>.json` | full exchange: status, headers, described bodies. Missing id → `seq-<n>.json`. Duplicate id → `-<seq>` |
1731
- | `blobs/<sha256>` | content-addressed file parts and oversized / binary bodies |
1732
-
1733
- The journal is oat `Exchange` JSON, not HAR (HAR export is out of scope). Default **on** unless `--profile cheap`. `--no-save-exchanges` skips `exchanges/` entirely. `--quiet` does not. **`--no-save-exchanges` does not reduce transcript RAM** — it only skips the disk journal. The in-memory transcript always drops live `FormData` / `Blob` / `ArrayBuffer` / multi-MiB strings after each hop, keeping citeable metadata and content-addressed body descriptors. Reconstruct bytes from `blobs/<sha256>` when a check genuinely needs them.
1734
-
1735
- Bodies are described, never base64 multipart. JSON / text inline up to 256 KiB, then `blobs/<sha256>`. `FormData` file parts and binary downloads (`application/pdf`, spreadsheet, image, `octet-stream`) are always blobs; the same fixture bytes POSTed N times share one file. SSE is parsed incrementally into `{ event, data }[]` frames — the raw `text/event-stream` concatenation is not retained on the transcript.
1736
-
1737
- Redaction is on by default (not opt-in), applied on write:
1738
-
1739
- - Headers: `authorization`, `cookie`, `set-cookie`, `proxy-authorization`, and any `x-*-key` / `x-*-secret` / `x-ia-tester-key` (case-insensitive).
1740
- - JSON bodies, any depth: `access_token`, `refresh_token`, `id_token`, `password`, `token`, `secret`, `api_key` → `"<redacted>"`.
1741
-
1742
- Join `progress.tsv` `req_id` to `exchanges.jsonl` `requestId` (response `x-request-id` / `request-id` / `x-correlation-id` / `correlation-id` wins; else what oat sent). `oat-report.md` includes one line such as `1841 exchanges → exchanges/`.
1743
-
1744
- ### `oat-report.json`
1745
-
1746
- ```json
1747
- {
1748
- "backend": "https://api.example.com",
1749
- "generatedAt": "2026-08-15T12:00:00.000Z",
1750
- "durationMs": 41200,
1751
- "requests": 842,
1752
- "entitiesTested": ["store", "product"],
1753
- "checksRun": ["list.read-after-write", "patch.minimality"],
1754
- "checksSkipped": [{ "check": "async.reaches-terminal-state", "entity": "store", "needs": "…" }],
1755
- "checksSuppressed": [{ "check": "query.axes-compose", "entity": "store", "because": "list.read-after-write" }],
1756
- "inconclusive": [{ "check": "filter.and-composes-as-intersection", "entity": "store", "reason": "…" }],
1757
- "summary": { "BACKEND_BUG": 1 },
1758
- "coverage": {
1759
- "neverApplied": ["async.reaches-terminal-state"],
1760
- "partial": [{ "check": "select.projection-honoured", "ran": 1, "skipped": 1 }]
1761
- },
1762
- "latency": {
1763
- "p50": 12,
1764
- "p95": 90,
1765
- "max": 400,
1766
- "slowest": { "method": "GET", "path": "/v1/products" }
1767
- },
1768
- "findings": [
1769
- {
1770
- "check": "patch.minimality",
1771
- "verdict": "BACKEND_BUG",
1772
- "entity": "product",
1773
- "summary": "PATCH { name } also cleared description",
1774
- "detail": "…",
1775
- "evidence": [
1776
- {
1777
- "method": "PATCH",
1778
- "url": "https://api.example.com/v1/products/p1",
1779
- "status": 200,
1780
- "requestBody": { "name": "x" },
1781
- "responseBody": { "name": "x", "description": null }
1782
- }
1783
- ]
1784
- }
1785
- ]
1786
- }
1787
- ```
1788
-
1789
- Latency is reported, never asserted. oat has no baseline for "too slow".
1790
-
1791
- Gate in CI on process exit code, or on `findings` whose `verdict` is not `COVERAGE_GAP` / `BLOCKED`.
1792
-
1793
- ### `matrix.json`
1794
-
1795
- ```json
1796
- {
1797
- "kind": "oat.matrix",
1798
- "version": 2,
1799
- "baseUrl": "…",
1800
- "generatedAt": "…",
1801
- "thesis": "…",
1802
- "summary": "…",
1803
- "index": { "entityCount": 5, "failed": ["product"], "parents": ["store"], "crossClaims": 1, "inbound": {} },
1804
- "counts": { "failed": 1, "blocked": 0, "held": 40, "skipped": 14 },
1805
- "entities": [
1806
- {
1807
- "name": "product",
1808
- "identity": "id",
1809
- "readSurface": ["GET /v1/products", "GET /v1/products/{id}"],
1810
- "counts": { "failed": 1, "blocked": 0, "held": 20, "skipped": 5 },
1811
- "roots": ["store_id"],
1812
- "nodes": [
1813
- {
1814
- "id": "product/patch.minimality",
1815
- "group": "product",
1816
- "layer": "axis",
1817
- "status": "failed",
1818
- "verdict": "BACKEND_BUG",
1819
- "summary": "…"
1820
- }
1821
- ]
1822
- }
1823
- ],
1824
- "invalidate": [
1825
- {
1826
- "fromEntity": "product",
1827
- "fromOp": "product.create",
1828
- "toEntity": "store",
1829
- "toRoute": "GET /v1/stores/{id}",
1830
- "cross": true
1831
- }
1832
- ],
1833
- "edges": [{ "from": "product/list.read-after-write", "to": "product/patch.minimality", "kind": "dependsOn" }],
1834
- "mermaid": "flowchart LR\n…"
1835
- }
1836
- ```
1837
-
1838
- Cell `status`: `held` (passed), `failed`, `blocked`, `skipped`. Edge `kind`: `dependsOn` (cascade) or `uses` (a composition check built from a single-axis check).
1839
-
1840
- ### `issue-repro/<entity>-<check>.sh`
1841
-
1842
- Created only when a finding has HTTP evidence. Not created on a clean run.
1843
-
1844
- ```bash
1845
- #!/usr/bin/env bash
1846
- # Generated by oat. Set TOKEN to a valid credential before running.
1847
- # product — PATCH { name } also cleared description
1848
- set -u
1849
- BASE="${BASE:-https://api.example.com}"
1850
- TOKEN="${TOKEN:?set TOKEN to a valid credential}"
1851
-
1852
- # step 1 — observed 200
1853
- curl -sS -X PATCH "$BASE/v1/products/p1" \
1854
- -H "authorization: Bearer $TOKEN" \
1855
- -H "content-type: application/json" \
1856
- -d '{"name":"x"}'
1857
- ```
1858
-
1859
- `authorization`, `cookie`, and `x-api-key` are redacted to `$TOKEN`. Replay needs a live credential; ids in the script are whatever the failing run created (gone if teardown ran). Use `--keep-fixtures` when you want to replay against the same rows.
1860
-
1861
- ## Progress logs
1862
-
1863
- `progress.log` starts with a glossary. Fields:
1864
-
1865
- | key | |
1866
- | -------------------------- | -------------------------------------------------------------------------------- |
1867
- | `ts` | ISO-8601 UTC when the line was written |
1868
- | `status` | `ok`, `stall` (`idle_ms` ≥ 15000 after the last call returned), or `in_flight` |
1869
- | `done` / `total` | entity index / how many entities |
1870
- | `phase` | `load` \| `auth` \| `seed` \| `test` \| `teardown` \| `done` |
1871
- | `entity` / `check` | current entity and check id |
1872
- | `msg` | phase note. In-flight is `status`, not `msg` |
1873
- | `req` / `find` | request count, finding count |
1874
- | `method` / `path` / `http` | last completed call, or the in-flight call when `status=in_flight` (`http=-`) |
1875
- | `last_ms` | duration of the last completed call. `-` while `in_flight` |
1876
- | `idle_ms` | while `in_flight`: ms since this request started. otherwise ms since it returned |
1877
- | `elapsed_ms` | wall clock since start |
1878
-
1879
- `--quiet` keeps the files and drops stderr.
1880
-
1881
- Every HTTP call emits a **start** line (`status=in_flight`, `http=-`, `last_ms=-`) when `fetch` is issued, then a **completed** line when it returns (`http=200`, `last_ms` ≈ wall time, `idle_ms=0`). The 5 s heartbeat keeps the in-flight path and climbs `idle_ms` until the call returns; after return it climbs on the completed call (and becomes `stall` at 15 s). A 300 s `POST /extract` therefore stays `/extract` in the log, not the previous refresh or GET.
1882
-
1883
- Lines are also written when the phase/entity/check/message changes, or every 2 s, or on `load`/`done`. `progress.json` is rewritten about once a second.
1884
-
1885
- If `idle_ms` climbs through a long poll (`x-async`) that is expected. If it climbs on a simple GET while `status` is not `in_flight`, the process or the network is stuck. Live `run` aborts a single `fetch` after `network.requestTimeoutMs` (default **180s**). A hung `text/event-stream` becomes `net.unreachable` (`kind=timeout`), not an unbounded buffer on the transcript. Set `requestTimeoutMs: 0` only if you intend to wait for the socket.
1886
-
1887
- Bun and Node both honour that timeout. If oat still runs away with RAM (a bug, or a caller holding the process open), treat the process like any other prefer-kill target for `earlyoom` / systemd — Bun is often **not** in a default `--prefer` list.
1888
-
1889
- ## Programmatic API
1890
-
1891
- ```ts
1892
- import {
1893
- defineConfig,
1894
- loadConfig,
1895
- run,
1896
- loadSpec,
1897
- dereference,
1898
- buildModel,
1899
- renderJson,
1900
- renderMarkdown,
1901
- } from "@lovrozagar/oat"
1902
-
1903
- const config = defineConfig({
1904
- spec: "./openapi.yaml",
1905
- baseUrl: "https://api.example.com",
1906
- principals: [{ id: "alpha", headers: { authorization: `Bearer ${process.env.API_TOKEN}` } }],
1907
- })
1908
-
1909
- const result = await run({
1910
- spec: config.spec,
1911
- baseUrl: config.baseUrl,
1912
- principals: config.principals,
1913
- seed: 1,
1914
- maxInFlight: 4,
1915
- onProgress: (snap) => {
1916
- // snap.phase, snap.entity, snap.check, snap.inflight, snap.last, snap.message, …
1917
- },
1918
- })
1919
-
1920
- // result.findings, result.checksSkipped, result.checksSuppressed,
1921
- // result.inconclusive, result.entitiesTested, result.teardown, result.created
1922
- ```
1923
-
1924
- `loadConfig(path)` loads `.ts` / `.js` / `.mjs` / `.json` the same way the CLI does. The CLI then expands `${NAME}` in every string. `defineConfig` is an identity function for typing; it does not interpolate. If you call `run()` with an in-process object, resolve secrets yourself (template literals, `process.env`) before passing it.
1925
-
1926
- `run(options)` does not write files. The CLI writes reports after `run` returns. To produce the same artifacts, call `renderMarkdown` / `renderJson` / `renderMatrixHtml` / `renderMatrixGraph` / `renderRepros` with a `ReportInput` (`findings`, `model`, `client`, `baseUrl`, `entitiesTested`, `checksRun`, `startedAt`, `durationMs`, plus optional skip/suppress/inconclusive lists).
1927
-
1928
- Offline:
1929
-
1930
- ```ts
1931
- const doc = await loadSpec("./openapi.yaml")
1932
- const { doc: resolved, externalRefs } = dereference(doc)
1933
- const model = buildModel(resolved)
1934
- ```
1935
-
1936
- Types exported: `OatConfig`, `Principal`, `AuthFlow`, `AuthRefresh`, `AuthStep`, `HookAuth`, `Hooks`, `Uploads`, `UploadRequest`, `UploadFile`, `HeaderRequest`, `InputRequest`, `OriginSpec`, `OutOfBandConfig`, `OutOfBandRequest`, `TeardownPrincipalContext`, `RunOptions`, `RunResult`, `Finding`, `Verdict`, `Actor`, `SpecModel`, `EntityModel`, `OperationModel`, `OpenApiDocument`, `AuthRefreshRequiredError`, `loadPersistedPrincipals`, `worstCaseWaitMs`, `allocateRunDir`, `DEFAULT_RUNS_ROOT`, matrix types.
1937
-
1938
- ## CI
1939
-
1940
- This repository runs [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) on every push and pull request to `main`: format, lint, typecheck, then `npm test` (conformance on memory + sqlite, plus the built-in combination smoke). D1, live labs Workers, and postgres are not in that job — D1 needs Cloudflare credentials, and the postgres reference backend is not yet a green CI gate.
1941
-
1942
- The package is [`@lovrozagar/oat` on npm](https://www.npmjs.com/package/@lovrozagar/oat). That URL is the repository website. GitHub Releases match npm versions. Pushing a tag `vX.Y.Z` (same as `package.json` `version`) runs [`.github/workflows/release.yml`](./.github/workflows/release.yml): test, `npm publish` via trusted publishing, then a GitHub Release. Configure the trusted publisher once on npm (package Settings → Trusted Publisher → GitHub Actions, workflow `release.yml`, no environment). Do not publish to GitHub Packages — people install from the public npm registry.
1943
-
1944
- Against **your** API:
1945
-
1946
- ```yaml
1947
- # GitHub Actions sketch
1948
- - run: npm i -D @lovrozagar/oat
1949
- - run: oat doctor --spec "$SPEC_URL"
1950
- - run: oat run --config oat.config.ts
1951
- env:
1952
- API_TOKEN: ${{ secrets.API_TOKEN }}
1953
- API_TOKEN_B: ${{ secrets.API_TOKEN_B }}
1954
- ```
1955
-
1956
- Gate on exit code 1 (defects). Read `.oat/runs/latest/oat-report.json` if you need to classify verdicts.
128
+ Gate on exit code 1 (defects); treat 3 as "the run itself failed", not as a pass or a defect. Read `.oat/runs/latest/oat-report.json` if you need to classify verdicts.
1957
129
 
1958
130
  Wipe leftover rows on a shared database between runs if a previous `--keep-fixtures` or a crashed teardown left data. Leftover rows make numeric/filter checks look like type bugs (`1, 10, 2` from old TEXT-sorted leftovers mixed with a fresh numeric cohort).
1959
131
 
1960
- ## Reference defects (`oat serve --defects`)
1961
-
1962
- Comma-separated. Each is one named lie the demo API can tell. Primary check is what conformance asserts; extras in parentheses are accepted additional symptoms of the same lie.
1963
-
1964
- | defect | primary check | the lie |
1965
- | ------------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |
1966
- | `STALE_LIST` | `list.read-after-write` | create succeeds, list does not show the row |
1967
- | `CREATE_DROPS_FIELD` | `create.persists-submitted-fields` | a submitted field is dropped |
1968
- | `STRING_PAYLOAD_MANGLED` | `payload.string-survives` | non-ASCII / surrounding whitespace stripped on write |
1969
- | `RESPONSE_STATUS_UNDECLARED` | `response.status-is-documented` | PATCH returns 201 when the document names 200 |
1970
- | `CREATED_201_AS_200` | `create.status-matches-document` | create returns 200 when the spec says 201 |
1971
- | `RESPONSE_SCHEMA_DRIFT` | `schema.success-response-matches-document` | success body does not match the schema |
1972
- | `ERROR_SCHEMA_DRIFT` | `schema.error-response-matches-document` | error body does not match the schema |
1973
- | `LIMIT_IGNORED` | `pagination.limit-bounds-page-size` | `limit` is accepted and ignored |
1974
- | `LIMIT_EXCEEDS_MAX` | `pagination.limit-respects-documented-max` | documented max is not capped |
1975
- | `HASMORE_ALWAYS_FALSE` | `pagination.has-more-is-accurate` | `hasMore` is always false |
1976
- | `OFF_BY_ONE_PAGE` | `pagination.page-walk-covers-set` | page walk skips or repeats |
1977
- | `UNSTABLE_SORT` | `pagination.page-walk-covers-set` | default order is not a total order |
1978
- | `CURSOR_DRIFT` | `pagination.cursor-agrees-with-page` | cursor and page disagree |
1979
- | `FILTER_IGNORED` | `filter.unknown-field-rejected` | unknown filter field is ignored |
1980
- | `FILTER_EQ_NOT_APPLIED` | `filter.equality-selects-exactly-one` | equality filter is ignored |
1981
- | `EMPTY_RESULT_RETURNS_ALL` | `filter.zero-match-returns-none` | empty match returns the whole set |
1982
- | `NEQ_DROPS_NULLS` | `filter.negation-partitions-the-set` | `neq` drops nulls so the partition leaks |
1983
- | `FILTER_GROUP_COMBINATOR_SWAPPED` | `filter.and-composes-as-intersection` | `and`/`or` are swapped |
1984
- | `LIKE_UNESCAPED` | `filter.like-metacharacters-escaped` | `%`/`_` are wildcards in values |
1985
- | `NUMERIC_COMPARED_AS_TEXT` | `filter.numeric-comparison-is-numeric` | numbers compared as strings |
1986
- | `ERROR_500_ON_BAD_FILTER` | `error.malformed-filter-not-5xx` | bad filter is 500 |
1987
- | `FILTER_AFTER_PAGINATION` | `query.filter-selects-from-whole-set` | filter applied after the page is cut |
1988
- | `ORDER_IGNORED` | `sort.order-is-applied` | sort param is ignored |
1989
- | `SORT_DESC_DROPS_NULLS` | `sort.reverse-symmetry` | desc drops nulls |
1990
- | `SEARCH_IGNORED` | `search.q-narrows-result` | search param is ignored |
1991
- | `SELECT_IGNORED` | `select.projection-honoured` | select param is ignored |
1992
- | `COUNT_ALWAYS_ZERO` | `count.consistent-with-returned-page` | total is always 0 |
1993
- | `COUNT_IGNORES_FILTER` | `count.matches-filtered-set` | total ignores the filter |
1994
- | `FILTER_DROPPED_WHEN_SORTED` | `query.axes-compose` | sort drops the filter |
1995
- | `FILTER_DROPPED_WHEN_SELECTED` | `query.filter-and-select-compose` | select drops the filter |
1996
- | `FILTER_DROPPED_WHEN_SEARCHED` | `query.search-and-filter-compose` | search drops the filter |
1997
- | `FILTER_DROPPED_WHEN_SORTED_AND_SELECTED` | `query.filter-sort-select-compose` | the triple drops the filter |
1998
- | `FILTER_DROPPED_WHEN_SORTED_AND_SEARCHED` | `query.filter-search-sort-compose` | the triple drops the filter |
1999
- | `FILTER_DROPPED_WHEN_SEARCHED_AND_SELECTED` | `query.filter-search-select-compose` | the triple drops the filter |
2000
- | `SPEC_OVERCLAIMS_FILTERABLE` | `spec.declared-filterable-is-filterable` | `x-query` lists a field that 400s |
2001
- | `SPEC_OVERCLAIMS_SORTABLE` | `spec.declared-sortable-is-sortable` | same for sort |
2002
- | `SPEC_OVERCLAIMS_SELECTABLE` | `spec.declared-selectable-is-selectable` | same for select |
2003
- | `FILTER_IN_FIRST_ONLY` | `filter.in-is-union-of-eq` | `in.(a,b)` matches only the first value |
2004
- | `FILTER_GTE_IS_GT` | `filter.gte-is-gt-or-eq` | `gte` is compiled as `gt` |
2005
- | `FILTER_ILIKE_IS_LIKE` | `filter.ilike-is-case-insensitive` | `ilike` is compiled as `like` |
2006
- | `FILTER_IS_NULL_MATCHES_ALL` | `filter.is-null-selects-nulls` | `is.null` matches every row |
2007
- | `FILTER_ILLEGAL_OP_IGNORED` | `filter.illegal-op-rejected` | an operator outside the allowlist is ignored |
2008
- | `SORT_NUMERIC_AS_TEXT` | `sort.numeric-order-is-numeric` | a numeric field is ordered lexicographically |
2009
- | `SORT_MULTI_KEY_IGNORED` | `sort.multi-key-tiebreak` | the second sort key is ignored |
2010
- | `SELECT_FIELD_MISSING` | `select.requested-fields-present` | a requested select field is dropped |
2011
- | `CROSS_TENANT_READ` | `tenant.item-not-readable-cross-tenant` | item GET is global by id |
2012
- | `EXISTENCE_LEAK_VIA_STATUS` | `tenant.denial-does-not-reveal-existence` | 403 vs 404 reveals the other tenant's row |
2013
- | `TENANT_LEAK_VIA_FILTER` | `tenant.filter-does-not-bypass-scope` | filter drops the tenant predicate |
2014
- | `ROLE_MONOTONICITY_BROKEN` | `auth.rank-is-monotonic` | a lower rank can do more |
2015
- | `INVITE_NEVER_GRANTS` | `auth.invite-grants-then-revokes` | accept does not grant |
2016
- | `REVOKE_IGNORED` | `auth.invite-grants-then-revokes` | revoke leaves the grant |
2017
- | `IMMUTABLE_WRITABLE` | `patch.immutable-field-rejected` | immutable fields accept writes |
2018
- | `SOFT_DELETE_LEAK` | `softdelete.absent-from-default-list` | tombstone stays on the default list |
2019
- | `PARENT_PROJECTION_STALE` | `invalidation.declared-route-changes` | child write does not bump the parent |
2020
- | `EFFECT_NOT_APPLIED` | `effects.declared-effect-occurs` | declared cardinality delta does not happen |
2021
- | `ASYNC_NEVER_COMPLETES` | `async.reaches-terminal-state` | job stays pending |
2022
- | `ASYNC_RECEIPT_MISSING_ID` | `async.receipt-identifies-the-job` | receipt has no id |
2023
- | `PATCH_REPLACES` | `patch.minimality` | PATCH is implemented as replace |
2024
- | `IDEMPOTENCY_IGNORED` | `idempotency.replay-does-not-duplicate` | Idempotency-Key is ignored |
2025
- | `UNIQUE_NOT_ENFORCED` | `create.unique-conflict-rejected` | a duplicate unique-set write is 2xx instead of 409 |
2026
- | `DELETE_MISSING_OK` | `delete.absent-record-returns-404` | DELETE missing returns 200 |
2027
- | `CONCURRENT_WRITE_LOST` | `concurrency.no-lost-update` | full-row write clobbers a parallel PATCH |
2028
- | `ENUM_NOT_VALIDATED` | `validation.enum-enforced` | enum is not enforced |
2029
- | `MAXLENGTH_NOT_VALIDATED` | `validation.max-length-enforced` | maxLength is not enforced |
2030
- | `REQUIRED_NOT_VALIDATED` | `validation.required-enforced` | required is not enforced |
2031
- | `CONTENT_TYPE_NOT_ENFORCED` | `validation.content-type-enforced` | wrong Content-Type is accepted |
2032
- | `LIST_DETAIL_DISAGREE` | `consistency.projections-agree` | list and item show different values |
2033
- | `COLUMN_NAME_MISMATCH` | `create.persists-submitted-fields` | SQL identifier does not match the field (SQL backends) |
2034
- | `COLLATION_INCONSISTENT` | `pagination.cursor-agrees-with-page` | cursor order ≠ page order (SQL) |
2035
-
2036
- ```bash
2037
- oat serve --defects STALE_LIST,PATCH_REPLACES
2038
- oat run --config labs/local.config.ts --base-url <url>
2039
- ```
2040
-
2041
- `COLUMN_NAME_MISMATCH`, `NUMERIC_COMPARED_AS_TEXT`, `COLLATION_INCONSISTENT`, and `CONCURRENT_WRITE_LOST` are SQL-only in conformance (the in-memory store cannot exhibit them).
2042
-
2043
132
  ## Limits and non-features
2044
133
 
2045
134
  These are deliberate. An agent should not invent a flag for them.
@@ -2058,6 +147,7 @@ These are deliberate. An agent should not invent a flag for them.
2058
147
  - **`or()` is postgrest-only.**
2059
148
  - **Leftover rows on a shared DB** poison numeric and filter checks. Wipe between runs.
2060
149
  - **`--only` uses plan names** (`store`, not `stores` or `/v1/stores`).
150
+ - **`--ops` trusts support operations.** A targeted green means the targets held, given that what they needed worked. A defect in an untargeted operation is out of scope, even when a target called it.
2061
151
  - **Default cohort is 7.** `pagination.limit-respects-documented-max` needs `cohortSize > maxLimit`.
2062
152
  - **First principal is the writer.** Extra principals are peers / lattice, not a pool of writers.
2063
153