@mmmnt/feature 0.3.2 → 0.4.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 (53) hide show
  1. package/LICENSE +16 -23
  2. package/README.md +887 -12
  3. package/dist/commands/audit.d.ts.map +1 -1
  4. package/dist/commands/audit.js +4 -3
  5. package/dist/commands/audit.js.map +1 -1
  6. package/dist/commands/diff.d.ts.map +1 -1
  7. package/dist/commands/diff.js +3 -0
  8. package/dist/commands/diff.js.map +1 -1
  9. package/dist/commands/fmt.d.ts.map +1 -1
  10. package/dist/commands/fmt.js +3 -2
  11. package/dist/commands/fmt.js.map +1 -1
  12. package/dist/commands/generate.d.ts.map +1 -1
  13. package/dist/commands/generate.js +3 -1
  14. package/dist/commands/generate.js.map +1 -1
  15. package/dist/commands/init.d.ts.map +1 -1
  16. package/dist/commands/init.js +7 -3
  17. package/dist/commands/init.js.map +1 -1
  18. package/dist/commands/lint.d.ts.map +1 -1
  19. package/dist/commands/lint.js +3 -3
  20. package/dist/commands/lint.js.map +1 -1
  21. package/dist/commands/report.d.ts.map +1 -1
  22. package/dist/commands/report.js +6 -5
  23. package/dist/commands/report.js.map +1 -1
  24. package/dist/commands/run.d.ts.map +1 -1
  25. package/dist/commands/run.js +43 -6
  26. package/dist/commands/run.js.map +1 -1
  27. package/dist/commands/verify.d.ts.map +1 -1
  28. package/dist/commands/verify.js +21 -17
  29. package/dist/commands/verify.js.map +1 -1
  30. package/dist/commands/watch.d.ts.map +1 -1
  31. package/dist/commands/watch.js +2 -1
  32. package/dist/commands/watch.js.map +1 -1
  33. package/dist/config.d.ts +19 -0
  34. package/dist/config.d.ts.map +1 -0
  35. package/dist/config.js +56 -0
  36. package/dist/config.js.map +1 -0
  37. package/dist/evidence.d.ts.map +1 -1
  38. package/dist/evidence.js +92 -3
  39. package/dist/evidence.js.map +1 -1
  40. package/dist/namespaces.d.ts +5 -0
  41. package/dist/namespaces.d.ts.map +1 -0
  42. package/dist/namespaces.js +12 -0
  43. package/dist/namespaces.js.map +1 -0
  44. package/dist/pipeline.d.ts +36 -2
  45. package/dist/pipeline.d.ts.map +1 -1
  46. package/dist/pipeline.js +136 -40
  47. package/dist/pipeline.js.map +1 -1
  48. package/dist/seed-fixtures.d.ts +27 -0
  49. package/dist/seed-fixtures.d.ts.map +1 -0
  50. package/dist/seed-fixtures.js +203 -0
  51. package/dist/seed-fixtures.js.map +1 -0
  52. package/package.json +9 -9
  53. package/schemas/evidence.schema.json +66 -0
package/README.md CHANGED
@@ -1,31 +1,906 @@
1
1
  # @mmmnt/feature
2
2
 
3
- The `feat` CLI — the toolchain for the `.feat` execution specification language. A `.feat` file
4
- instructs how a feature is built, predicts every observable effect it will produce, and compiles
5
- deterministically into complete test suites. Anything unpredicted is a failure.
3
+ **The `feat` CLI.** The toolchain for the `.feat` execution specification
4
+ language. A `.feat` file instructs how a feature is built, predicts every
5
+ observable effect it will produce, and compiles deterministically into complete
6
+ test suites. Anything unpredicted is a failure.
6
7
 
7
8
  ```sh
8
9
  npm install --save-dev @mmmnt/feature
9
- npx feat init # scaffolds config + a first spec, installs everything else
10
+ npx feat init # scaffolds config + a first spec, installs everything else
10
11
 
11
- npx feat generate # compile specs into test files
12
- npx feat run # execute them with the adapter lifecycle
12
+ npx feat generate # compile specs into test files
13
+ npx feat run # execute them with the adapter lifecycle
13
14
  ```
14
15
 
15
- `feat init` detects your package manager (npm/pnpm/yarn) and installs the
16
- runtime, starter adapters, and test runner; `--no-install` prints the command
17
- instead.
16
+ ## Where it sits
17
+
18
+ `feat` is the orchestrator. It owns the commands, the config, the evidence and
19
+ the exit codes, and delegates the work:
20
+
21
+ | Step | Package | What it does |
22
+ | --- | --- | --- |
23
+ | parse | [`@mmmnt/feat-core`](https://www.npmjs.com/package/@mmmnt/feat-core) | `.feat` source to the BuiltSpec IR, with the closed reference spaces checked |
24
+ | derive | `@mmmnt/feat-derive` | IR to a test topology: one case per scenario, one per outline row |
25
+ | emit | `@mmmnt/feat-emit-ts` | topology to a Vitest test file, byte-for-byte deterministic |
26
+ | run | `@mmmnt/feat-runner` | spawns `vitest run` on exactly the generated files |
27
+ | harness | `@mmmnt/feat-runtime` | loads the config, loads adapters, opens the capture window, diffs the prediction |
28
+ | analyze | [`@mmmnt/feat-analyze`](https://www.npmjs.com/package/@mmmnt/feat-analyze) | lint, audit, format |
29
+ | contracts | [`@mmmnt/feat-types`](https://www.npmjs.com/package/@mmmnt/feat-types) | the IR, the config and the adapter interfaces |
30
+
31
+ The package exposes one binary, `feat`. It is not a library: its `main` exports
32
+ only the oclif `Parse` command class, which is an implementation detail. To parse
33
+ in code, use `@mmmnt/feat-core`.
34
+
35
+ ## Install
36
+
37
+ ```sh
38
+ npm install --save-dev @mmmnt/feature
39
+ ```
40
+
41
+ Requirements:
42
+
43
+ - **Node 20 or later** (the repository's `engines` field).
44
+ - **Vitest** in the project. Generated suites are ordinary Vitest files and
45
+ `feat run` spawns `npx vitest run`. `feat init` installs it.
46
+ - **`@mmmnt/feat-runtime`** in the project. Every generated test imports it.
47
+ - **The adapters your config names**, installed in the project that owns
48
+ `feat.config.json`. An npm adapter resolves from the project's own
49
+ `package.json`, never from the toolchain's `node_modules`.
50
+ - **git**, only for `feat diff` and for the commit in an evidence bundle.
51
+
52
+ `feat init` installs the starter set: `@mmmnt/feat-runtime`,
53
+ `@mmmnt/feat-adapter-handler`, `@mmmnt/feat-adapter-fs`,
54
+ `@mmmnt/feat-schema-json` and `vitest`. It detects your package manager from a
55
+ lockfile (`pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`), then from
56
+ `npm_config_user_agent`, and falls back to npm. It installs only what
57
+ `package.json` does not already declare.
58
+
59
+ ## Quick start
60
+
61
+ ```sh
62
+ npx feat init --no-install # print the install command instead of running it
63
+ ```
64
+
65
+ `feat init` writes three files, plus `package.json` when there is none, and stops
66
+ with exit `2` if `feat.config.json`, `specs/greet.feat` or `specs/greet.contract.json`
67
+ already exists. It checks all three before it writes any, so a refused `init` has
68
+ written nothing and no file of yours is overwritten.
69
+
70
+ ```
71
+ created feat.config.json
72
+ created specs/greet.feat
73
+ created specs/greet.contract.json
74
+ created package.json # only when there was none
75
+ ```
76
+
77
+ The scaffold is a one-command project: a `Greet` handler at `src/greet.ts`, a
78
+ filesystem service, and a spec in `draft`. Write the handler, flip the spec to
79
+ `agreed` when it says what you mean, and run the chain:
80
+
81
+ ```ts
82
+ // src/greet.ts
83
+ export async function greet(input: { name: string }) {
84
+ if (input.name === "") return { status: "ERR", body: { code: "EMPTY_NAME", message: "blank" } };
85
+ return { status: "OK", body: { message: `Hello, ${input.name}` } };
86
+ }
87
+ ```
88
+
89
+ ```sh
90
+ npx feat parse specs/greet.feat # validate; prints the IR
91
+ npx feat generate # writes specs/greet.test.ts
92
+ npx feat run # 2 tests pass
93
+ ```
94
+
95
+ `feat run` needs an environment name, and the scaffolded config sets one:
96
+ `"environment": "spec"`, the in-process tier ([Tiers](#tiers-one-set-of-specs-an-overlay-per-environment)).
97
+ Change it, or override it with `FEAT_ENVIRONMENT` or `ENVIRONMENT`, when you
98
+ point the project at another tier (see [Environment](#environment)).
99
+
100
+ ## Project layout
101
+
102
+ | What | Where |
103
+ | --- | --- |
104
+ | Config | `feat.config.json` (any path via `--config`) |
105
+ | Specs | `**/*.feat` under `specs.dir` |
106
+ | Contracts | `<name>.contract.json`, beside the spec it pairs with |
107
+ | Generated tests | `specs.outputPattern` with `{name}` replaced, beside the spec: `specs/greet.feat` gives `specs/greet.test.ts`. Commit them. |
108
+ | Run artifacts | `.feature/` (evidence bundles, the variables sidecar), and the JUnit file wherever `report.junitOutput` points. Generated; gitignore them. |
109
+ | Runner scratch | `node_modules/.cache/feat/` (the runner's Vitest config and reporter) |
110
+
111
+ Discovery skips these directories wherever they appear: `node_modules`, `dist`,
112
+ `.turbo`, `.git`, `coverage`, `reports`, and `fixtures` (fixture `.feat` files
113
+ are test vectors, not project specs).
114
+
115
+ ## Configuration: `feat.config.json`
116
+
117
+ Every command reads the config through one loader, so a refused config is the
118
+ same refusal everywhere. The paths in the table below resolve like this:
119
+ `specs.dir` against **the directory you run `feat` from**, and adapter
120
+ `module` paths and relative adapter specifiers against **the directory holding
121
+ the config**.
122
+
123
+ A config that uses every field:
124
+
125
+ ```json
126
+ {
127
+ "featVersion": "1.0",
128
+ "environment": "spec",
129
+ "schemas": { "adapter": "@mmmnt/feat-schema-json" },
130
+ "response": {
131
+ "adapter": "@mmmnt/feat-adapter-handler",
132
+ "invoke": { "timeout": 10000 },
133
+ "commands": {
134
+ "CreateUser": { "module": "src/create-user.mjs", "export": "createUser", "namespace": true }
135
+ },
136
+ "actors": {
137
+ "default": "operator",
138
+ "operator": { "role": "operator" },
139
+ "auditor": { "role": "auditor" }
140
+ }
141
+ },
142
+ "services": {
143
+ "database": { "adapter": "@mmmnt/feat-adapter-memory", "consistency": "strong" },
144
+ "events": {
145
+ "adapter": "@mmmnt/feat-adapter-memory",
146
+ "consistency": "eventual",
147
+ "convergenceTimeout": 2000,
148
+ "absenceTimeout": 500,
149
+ "options": {}
150
+ }
151
+ },
152
+ "specs": {
153
+ "dir": "specs",
154
+ "pattern": "**/*.feat",
155
+ "contractPattern": "**/*.contract.json",
156
+ "outputPattern": "{name}.test.ts",
157
+ "exclude": ["drafts/**"]
158
+ },
159
+ "report": { "format": ["console", "junit"], "junitOutput": ".feature/reports/feat-junit.xml" }
160
+ }
161
+ ```
162
+
163
+ Unknown keys are refused: every object in the schema is closed except
164
+ `response.invoke`, `response.commands.<Name>`, `response.actors.<name>` and
165
+ `services.<key>.options`, which belong to the adapters.
166
+
167
+ ### Top level
168
+
169
+ | Field | Required | Meaning |
170
+ | --- | --- | --- |
171
+ | `featVersion` | no | Language version the project targets, `"<major>.<minor>"`. |
172
+ | `extends` | no | Makes this file a tier overlay of the named base. See [Tiers](#tiers-one-set-of-specs-an-overlay-per-environment). |
173
+ | `environment` | no | The environment this config verifies, `^[a-z][a-z0-9-]*$`. See [Environment](#environment). |
174
+ | `schemas` | yes | `{ adapter }`: the schema adapter, used when generating. |
175
+ | `response` | when specs use `when:` or `execute` | How a stimulus reaches the system. Deliver-only projects omit it. |
176
+ | `services` | yes | One entry per observable service. At least one. |
177
+ | `specs` | yes | Where specs are and where tests go. |
178
+ | `report` | no | Reporting. |
179
+
180
+ ### `schemas`
181
+
182
+ | Field | Meaning |
183
+ | --- | --- |
184
+ | `adapter` | An npm package name or a local path. The module must export `createAdapter`. The standard one is `@mmmnt/feat-schema-json`. It resolves contract `$ref`s, bundles cross-file and sibling references so the generated test is self-contained, and validates seed values. A project may supply its own. |
185
+
186
+ If the adapter cannot be resolved or loaded, `feat generate`, `verify` and `run` stop with exit `2`
187
+ and `Schema adapter '<name>' (feat.config.json › schemas.adapter) could not be loaded`, followed by
188
+ the reason and its code (`INVALID_CONFIG`). They never fall back to reading the referenced file
189
+ verbatim.
190
+
191
+ ### `response`
192
+
193
+ | Field | Required | Meaning |
194
+ | --- | --- | --- |
195
+ | `adapter` | yes | The response adapter, for example `@mmmnt/feat-adapter-handler` or `@mmmnt/feat-adapter-http`. |
196
+ | `commands` | yes, at least one | `CommandName` to the adapter's invocation shape (handler: `{ module, export }`, HTTP: `{ method, path }`). **A closed space:** a `when:` or `execute` that names a command not in this map is `UNKNOWN_COMMAND` at parse time. |
197
+ | `commands.<Name>.namespace` | no | `true` declares that a handler route reads `ctx.namespace`. The harness then refuses the route with `NAMESPACE_NOT_HONOURED` if it never does. Absent means never checked (SPEC-ADPHND-002). |
198
+ | `actors` | no | `name` to the adapter's auth material. **A closed space:** an `as <actor>` for a name not here is `UNKNOWN_ACTOR`. `default` is a string naming the actor used when a trigger has no `as`. `anonymous` is reserved, always allowed, and never declared. |
199
+ | `invoke` | no | Adapter-wide invocation config (base URL and headers, host and proto path, ...). A numeric `invoke.timeout` is also the per-invoke allowance in milliseconds that sizes the test timeout (default 30 000). |
200
+
201
+ ### `services`
202
+
203
+ Each key is a service name, and the **only valid prediction target** (a closed
204
+ space: a prediction, seed, delivery or fault that names another key is
205
+ `UNKNOWN_SERVICE_KEY`).
206
+
207
+ | Field | Required | Meaning |
208
+ | --- | --- | --- |
209
+ | `adapter` | yes | The service adapter module. |
210
+ | `consistency` | yes | `acid`, `strong` or `eventual`. `eventual` services are read after a wait, and their `has` lists compare unordered unless a spec writes `has ordered [...]`. The other two compare ordered. |
211
+ | `convergenceTimeout` | when `eventual` | Milliseconds. The ceiling of the wait before capture. Missing on an `eventual` service is `MISSING_CONVERGENCE_TIMEOUT`. |
212
+ | `absenceTimeout` | no | A shorter wait for absence proofs on `eventual` services. This release accepts and records it in the evidence bindings, but the harness does not read it. |
213
+ | `options` | no | Adapter-specific options. A `namespace` key here is refused (`NAMESPACE_CONFIGURED`). |
214
+
215
+ ### `specs`
216
+
217
+ | Field | Required | Meaning |
218
+ | --- | --- | --- |
219
+ | `dir` | yes | Directory searched recursively for `.feat` files, relative to the working directory. |
220
+ | `pattern` | yes | Required by the schema. The CLI in this release does not read it: it finds every `*.feat` under `dir`. |
221
+ | `contractPattern` | yes | Required by the schema. Not read either: a spec's contract is always `<name>.contract.json` beside it. |
222
+ | `outputPattern` | yes | Name of the generated file. `{name}` is the spec's file name without `.feat`. |
223
+ | `exclude` | no | Globs, relative to `dir`, that remove spec files from this config's run. `**` crosses directories, `*` and `?` do not. |
224
+
225
+ ### `report`
226
+
227
+ | Field | Meaning |
228
+ | --- | --- |
229
+ | `format` | A non-empty list of `console` and `junit`. |
230
+ | `junitOutput` | Where `feat run` writes JUnit XML. It is written only when `format` includes `junit` and this is set. `feat report` reads this path. |
231
+
232
+ ### Refusals
233
+
234
+ A config that cannot be used exits `2` with `ERROR [CODE] message`.
235
+
236
+ | Code | Meaning |
237
+ | --- | --- |
238
+ | `CONFIG_NOT_FOUND` | no file at the path |
239
+ | `INVALID_CONFIG` | not valid JSON, or violates the schema (the message names the first problem, for example `config root must have required property 'services'`); also an overlay that redeclares `featVersion` or `schemas`, or a base that is unreadable or invalid; also a module named as an adapter that cannot be resolved or loaded, or exports no `createAdapter` |
240
+ | `MISSING_CONVERGENCE_TIMEOUT` | an `eventual` service with no `convergenceTimeout` |
241
+ | `EXTENDS_NOT_FOUND` | the base named by `extends` does not exist |
242
+ | `EXTENDS_CHAIN` | the base itself has `extends` |
243
+ | `TIER_SPACE_MISMATCH` | the overlay adds a service, or adds or removes a command or an actor |
244
+
245
+ The schema is
246
+ [`schemas/feat.config.schema.json`](https://github.com/mmmnt/feature/blob/main/schemas/feat.config.schema.json).
18
247
 
19
248
  ## Commands
20
249
 
21
- `init` · `parse` · `generate` · `verify` (CI byte-lock) · `run` (`--spec`, `--coverage`) ·
22
- `report` (`--junit`) · `audit` · `lint` · `fmt` (`--check`) · `watch` · `diff`
250
+ Every command takes `-c, --config <path>` (default `feat.config.json`) except
251
+ `init`. Run `feat <command> --help` for the flags.
252
+
253
+ ### `feat init [--no-install]`
254
+
255
+ Scaffolds the project (see [Quick start](#quick-start)). `--no-install` skips
256
+ the install and prints it. Exit `2` with `ALREADY_INITIALIZED` when
257
+ `feat.config.json`, `specs/greet.feat` or `specs/greet.contract.json` exists; the
258
+ message names the file and nothing is written. If the install fails, `init` warns, prints the command
259
+ to run yourself, and still exits `0`.
260
+
261
+ ### `feat parse <file> [-c <config>]`
262
+
263
+ Validates one spec against the config and prints its IR as JSON on success.
264
+ Catches syntax errors and every closed-reference violation.
265
+
266
+ ```
267
+ $ feat parse specs/bad.feat
268
+ ERROR [MISSING_PRAGMA] specs/bad.feat:1
269
+ The first non-comment line must be a version pragma, e.g. 'feat 1.0'.
270
+ Hint: Add 'feat 1.0' as the first line.
271
+ ```
272
+
273
+ Exit `0`, `1` for a parse error (the codes are in
274
+ [`@mmmnt/feat-core`](https://www.npmjs.com/package/@mmmnt/feat-core)), `2` for a
275
+ refused config.
276
+
277
+ ### `feat generate [-c <config>]`
278
+
279
+ Compiles every spec under `specs.dir` into its test file: parse, derive,
280
+ resolve schemas and goldens, check seeds, emit. It writes nothing unless every
281
+ spec succeeded. A seed violation or a parse failure stops the run with exit `1`.
282
+ A refused config, or a schema adapter that cannot be resolved or loaded, is exit `2`.
283
+
284
+ ```
285
+ generated specs/greet.test.ts (from specs/greet.feat)
286
+ 1 test file(s) generated.
287
+ ```
288
+
289
+ The same spec, contract and closed spaces always give the same bytes, in every
290
+ tier. The file header carries an `Inputs-hash`.
291
+
292
+ ### `feat verify [-c <config>]`
293
+
294
+ The CI integrity gate. Regenerates in memory and byte-compares with the
295
+ committed files. A missing or different file fails the build.
296
+
297
+ ```
298
+ ERROR [VERIFY_FAILED] Committed tests do not match current specs:
299
+ specs/greet.test.ts (differs)
300
+ Run "feat generate" and commit the updated files.
301
+ ```
302
+
303
+ Exit `1` on drift, `2` on a refused config.
304
+
305
+ ### `feat run [-c <config>] [--spec <id>] [--coverage] [--shard <i/n>]`
306
+
307
+ Executes the generated tests with the full adapter lifecycle, through
308
+ `vitest run`.
309
+
310
+ | Flag | Meaning |
311
+ | --- | --- |
312
+ | `--spec <id>` | Run only the spec with this id (`SPEC-EX-001`). No match is exit `1`. |
313
+ | `--coverage` | Pass `--coverage` through to Vitest. Your coverage provider and thresholds apply. |
314
+ | `--shard <i/n>` | Run slice `i` of `n`. See [Shards](#shards). |
315
+
316
+ What it does, in order:
317
+
318
+ 1. Loads the config (exit `2` if refused) and resolves the
319
+ [environment](#environment) (none resolvable is exit `2`, `NO_ENVIRONMENT`, before any work).
320
+ 2. Deletes the previous variables sidecar, so a stale one cannot exist.
321
+ 3. Generates in memory to learn each spec's file and faults. **It does not
322
+ rewrite or compare the files on disk.** It runs what is committed, so run
323
+ `feat verify` first. A parse failure or a seed violation here is exit `1`; an
324
+ adapter that cannot be resolved or loaded is exit `2`.
325
+ 4. Filters by `--spec` and `--shard`.
326
+ 5. Derives every file's [namespace](#namespaces), from its path under the base
327
+ config's directory (the one the harness uses), and stops on a collision.
328
+ 6. Stops with `NOT_GENERATED` (exit `1`) if a generated file is missing.
329
+ 7. Computes timeouts from the active config and spawns Vitest. Files that arm an
330
+ exclusive fault run last, alone (see [Faults](#faults-and-the-serial-pass)).
331
+ 8. Prints `junit: <path>` when a JUnit file was written.
332
+
333
+ The run exits `0` when every test passes and `1` when any fails. It exits `2`
334
+ when the harness refused its configuration: a clock, fault or observation mode
335
+ an adapter cannot serve, an adapter that cannot `seed()` or `deliver()`, a namespace
336
+ problem, a bad adapter. The output carries
337
+ the refusal's code, for example
338
+ `Configuration error (exit 2): [FAULT_UNSUPPORTED] ...`.
339
+
340
+ A failed prediction names the spec, the scenario, the path, what was expected
341
+ and what was captured:
342
+
343
+ ```
344
+ Prediction violated:
345
+ SPEC-EX-001 › "greets by name" › response › message: expected string matching /Ada/, got "Hello, stranger"
346
+ ```
347
+
348
+ ### `feat report [-c <config>] [--junit] [--evidence] [--out <path>] [--force]`
349
+
350
+ Summarises the last run from its JUnit file: one line per suite with test,
351
+ failure and error counts, then a total. Exit `1` if anything failed.
352
+
353
+ | Flag | Meaning |
354
+ | --- | --- |
355
+ | `--junit` | Print the absolute path of the JUnit XML, for CI or Xray import. |
356
+ | `--evidence` | Write a `feat-evidence/2` bundle and exit. See [Evidence](#evidence-bundle). |
357
+ | `--out <path>` | With `--evidence`: the output path, replacing the convention. |
358
+ | `--force` | With `--evidence`: write even for the `local` environment. |
359
+
360
+ With no JUnit file (`report.junitOutput` unset, or `feat run` has not run) it
361
+ exits `2` with `NO_REPORT`.
362
+
363
+ ### `feat audit [-c <config>]`
364
+
365
+ The buildability gate (ADR-0008) over every spec. Per spec it runs
366
+ [`auditSpec`](https://www.npmjs.com/package/@mmmnt/feat-analyze): **B1** a
367
+ handler for code-producing types, **B3** a `touches` change boundary, **B2**
368
+ two-way traceability between `rejects X` lines and predicted `rejection X`
369
+ scenarios. It adds two warnings that need the filesystem: no paired
370
+ `.contract.json`, and no generated test file. A parse failure counts as an
371
+ error. Exit `1` if any spec has an error. Warnings never fail the run.
372
+
373
+ ```
374
+ ✗ specs/greet.feat (SPEC-EX-001, status built)
375
+ ERROR B2: predicted rejection 'EMPTY_NAME' has no `rejects EMPTY_NAME when …` line
376
+
377
+ audit: 1 spec(s), 1 with errors, 0 warning(s).
378
+ ```
379
+
380
+ ### `feat lint [-c <config>]`
381
+
382
+ Language-quality warnings: unused schema declarations, unused variables,
383
+ duplicate contract declarations, and a note for `draft` specs. Exit `1` only
384
+ when a spec does not parse. Warnings never fail the run.
385
+
386
+ ### `feat fmt [-c <config>] [--check]`
387
+
388
+ Conservative formatting: strips trailing whitespace, collapses blank-line runs,
389
+ ends the file with one newline. Content-preserving and idempotent. Without
390
+ `--check` it rewrites files. With `--check` it prints `would format <file>` and
391
+ changes nothing. Exit `1` with `--check` when any file would change, and exit
392
+ `1` when a file has a tab as its first character (it reports and does not touch
393
+ that file).
394
+
395
+ ### `feat watch [-c <config>] [--run] [--json] [--src <dir>...]`
396
+
397
+ Regenerates on change. It watches `specs.dir` for `.feat` and
398
+ `.contract.json` files. The first cycle writes every test file, and later cycles
399
+ rewrite only the files whose generated bytes changed. A config edit is not
400
+ watched; restart the command.
401
+
402
+ | Flag | Meaning |
403
+ | --- | --- |
404
+ | `--run` | Run the affected suites after each regeneration. The first cycle runs everything. |
405
+ | `--json` | Emit one NDJSON event per line on stdout. Implies `--run`. |
406
+ | `--src <dir>` | Also watch this directory. A change reruns **all** suites without regenerating. Repeatable. Changes to `*.test.ts` there are ignored. A missing directory is skipped. |
407
+
408
+ The `--json` events are the IDE surface. Each carries `ts` (an ISO timestamp):
409
+
410
+ | `event` | Fields |
411
+ | --- | --- |
412
+ | `generate` | `reason`, `files` (`[{ spec, output }]`), `changed` (output paths rewritten) |
413
+ | `source-change` | `reason`, for a `--src` change |
414
+ | `run` | `exitCode`, `suites` (`[{ spec, output }]`), `cases` (`[{ suite, name, state, message? }]`, `state` is `passed`, `failed` or `skipped`) |
415
+ | `error` | `reason`, `message`, when a cycle failed (parse failure, seed violation, ...) |
416
+
417
+ It writes a temporary report under `.feat-watch/`. Stop it with Ctrl-C.
23
418
 
24
- Exit codes everywhere: `0` success · `1` validation failure · `2` configuration error.
419
+ ### `feat diff <file> [-c <config>] [--ref <ref>]`
420
+
421
+ A spec-level change summary against a git ref (default `HEAD`), for PR review.
422
+ It compares IRs, so a comment or a reformat changes nothing. `<file>` is a path
423
+ from the directory you run in, which must be the repository root.
424
+
425
+ ```
426
+ status: agreed → built
427
+ + scenario "greets another"
428
+ - scenario "rejects a blank name"
429
+ ~ scenario "greets by name" changed
430
+ - contract error GreetError
431
+ ```
432
+
433
+ The lines are `status: a → b`, `+ scenario`, `- scenario`, `~ scenario ... changed`,
434
+ `+ contract <kind> <Schema>`, `- contract ...`, or `no IR-level changes`. If the
435
+ file does not exist at the ref it prints
436
+ `new spec (<id>) — not present at <ref>`. If the old version does not parse under
437
+ the current config it lists every scenario as new. Exit `1` when the current
438
+ spec does not parse. A config that cannot be loaded is exit `2`, with its code,
439
+ before any spec is read.
440
+
441
+ ## Environment
442
+
443
+ `feat run` and `feat report --evidence` need to know what they are verifying.
444
+ The name resolves in this order:
445
+
446
+ 1. `environment` in the config (an explicit override);
447
+ 2. the `FEAT_ENVIRONMENT` environment variable;
448
+ 3. the `ENVIRONMENT` environment variable.
449
+
450
+ If none names one, `feat run` and `feat report --evidence` stop before any work with
451
+ exit `2` and `NO_ENVIRONMENT`. The scaffold from `feat init` sets `"environment": "spec"`.
452
+
453
+ A name is lowercase letters, digits and hyphens. The environment is stamped into
454
+ the evidence bundle. The `local` environment records no evidence unless you pass
455
+ `--force`: compliance windows begin above local.
456
+
457
+ ## Tiers: one set of specs, an overlay per environment
458
+
459
+ The same specs run at two tiers: the **spec tier** (in-process, in-memory,
460
+ `strong`) and the **integration tier** (real products through product adapters,
461
+ real consistency, real timeouts). A tier is an overlay config that `extends` a
462
+ base (ADR-0024).
463
+
464
+ The base, `feat.config.json`, is the spec tier:
465
+
466
+ ```json
467
+ {
468
+ "featVersion": "1.0",
469
+ "environment": "spec",
470
+ "schemas": { "adapter": "@mmmnt/feat-schema-json" },
471
+ "response": {
472
+ "adapter": "@mmmnt/feat-adapter-handler",
473
+ "commands": { "Ping": { "module": "src/ping.mjs", "export": "ping" } }
474
+ },
475
+ "services": {
476
+ "events": { "adapter": "@mmmnt/feat-adapter-memory", "consistency": "strong" }
477
+ },
478
+ "specs": {
479
+ "dir": "specs",
480
+ "pattern": "**/*.feat",
481
+ "contractPattern": "**/*.contract.json",
482
+ "outputPattern": "{name}.test.ts"
483
+ }
484
+ }
485
+ ```
486
+
487
+ The overlay, `feat.integration.config.json`:
488
+
489
+ ```json
490
+ {
491
+ "extends": "./feat.config.json",
492
+ "environment": "integration",
493
+ "services": {
494
+ "events": {
495
+ "adapter": "@mmmnt/feat-adapter-kurrent",
496
+ "consistency": "eventual",
497
+ "convergenceTimeout": 5000,
498
+ "options": { "connectionStringEnv": "FEAT_KURRENT_URL" }
499
+ }
500
+ },
501
+ "specs": {
502
+ "dir": "specs",
503
+ "pattern": "**/*.feat",
504
+ "contractPattern": "**/*.contract.json",
505
+ "outputPattern": "{name}.test.ts",
506
+ "exclude": ["transport/**"]
507
+ }
508
+ }
509
+ ```
510
+
511
+ ```sh
512
+ npx feat run # the spec tier
513
+ npx feat run --config feat.integration.config.json # the integration tier
514
+ ```
515
+
516
+ The rules:
517
+
518
+ - **One level.** `extends` is a path relative to the overlay. A base that itself
519
+ extends is `EXTENDS_CHAIN`. A missing base is `EXTENDS_NOT_FOUND`.
520
+ - **Replace whole, per key.** The overlay replaces `environment`, `response`,
521
+ `specs` and `report` as a whole, and `services` key by key. There is no deep
522
+ merge: an overlay's adapter `options` never inherit the base's. A service key
523
+ the overlay does not name is inherited from the base, so an overlay cannot
524
+ remove a service.
525
+ - **Inherited.** `featVersion` and `schemas` come from the base and may not be
526
+ redeclared (`INVALID_CONFIG`). `environment` is **not** inherited: an overlay
527
+ without one resolves it from `FEAT_ENVIRONMENT` or `ENVIRONMENT`, so a bundle
528
+ is never stamped with the base's name by accident.
529
+ - **Validated after merging.** The overlay file alone need not carry `schemas`,
530
+ `services` or `specs`. The merged document is checked, including
531
+ `MISSING_CONVERGENCE_TIMEOUT`.
532
+ - **Parity.** An overlay may not add a service, and may not add or remove a
533
+ command or an actor. `TIER_SPACE_MISMATCH` at load, exit `2`, with the space
534
+ (`service`, `command`, `actor`), the change (`added`, `removed`) and the name:
535
+ `Overlay 'feat.integration.config.json' adds command 'Extra', which the base does not declare.`
536
+ Specs are parsed against the base, so a spec means the same thing in both tiers
537
+ by construction.
538
+ - **`specs.exclude`** removes spec files from a tier, for example transport-fault
539
+ specs from the spec tier. Because `specs` is replaced whole, an overlay that
540
+ sets `exclude` states the other four `specs` fields too.
541
+ - **Generated files are tier-independent.** The `Inputs-hash` covers the spec
542
+ text, the contract text, `featVersion`, and the **names** of the services,
543
+ commands and actors, nothing else. Adapters, consistency, timeouts and options
544
+ never enter it, so `feat generate` and `feat verify` give the same bytes
545
+ whichever tier's config you pass, and changing a timeout regenerates nothing.
546
+ The file embeds the base's path, and `feat run` hands the active config to the
547
+ suites as `FEAT_CONFIG`.
548
+ - **Ordering and timing follow the active tier.** The default `has` ordering is
549
+ resolved by the harness from the active config's `consistency`, and `feat run`
550
+ computes Vitest's `testTimeout` (the per-invoke allowance times the steps of
551
+ the worst case, plus the longest `convergenceTimeout`, plus 30 s) and
552
+ `hookTimeout` (120 s) from the active config.
553
+ - **Two unrelated config files are not an overlay.** Nothing then keeps their
554
+ spaces equal, and the generated files differ per tier.
555
+
556
+ This repository runs itself this way:
557
+ [`feat.config.json`](https://github.com/mmmnt/feature/blob/main/feat.config.json)
558
+ is the spec tier and
559
+ [`feat.integration.config.json`](https://github.com/mmmnt/feature/blob/main/feat.integration.config.json)
560
+ is the integration tier.
561
+
562
+ ## Seeds
563
+
564
+ A `seed` puts state into a service before the capture window opens, through the
565
+ adapter's `seed()`. Seed data is literal: no matchers, no `@when`.
566
+
567
+ **Inline**, a list of records, each optionally validated against a contract
568
+ schema with `with`:
569
+
570
+ ```feat
571
+ scenario "add an item":
572
+ given:
573
+ The store already holds seeded state.
574
+ seed store [ ItemAdded with ItemEvent { itemId: "11111111-0000-4000-8000-000000000001", name: "Item-1" } ]
575
+ when: AddItem { itemId: "22222222-0000-4000-8000-000000000009" }
576
+ predict rejection ITEM_EXISTS:
577
+ response 409 ItemError
578
+ store has []
579
+ ```
580
+
581
+ **Fixture**, bulk state from a JSON file, resolved against **the directory of
582
+ the spec that names it** (not the config directory or the working directory):
583
+
584
+ ```feat
585
+ scenario "add an item":
586
+ given:
587
+ The store already holds seeded state.
588
+ seed store from "data/items.json"
589
+ when: AddItem { itemId: "22222222-0000-4000-8000-000000000009" }
590
+ predict rejection ITEM_EXISTS:
591
+ response 409 ItemError
592
+ store has []
593
+ ```
594
+
595
+ A fixture is a JSON array of `{ type, schemaName?, values }` records, the shape
596
+ of an inline record. A record with a `schemaName` must name a schema in the
597
+ spec's contract and its `values` must validate against it. A record without one
598
+ is shape-checked only.
599
+
600
+ ```json
601
+ [
602
+ { "type": "ItemAdded", "schemaName": "ItemEvent", "values": { "itemId": "11111111-0000-4000-8000-000000000001", "name": "Item-1" } },
603
+ { "type": "ItemRenamed", "schemaName": "ItemEvent", "values": { "itemId": "11111111-0000-4000-8000-000000000002", "name": "Item-2" } }
604
+ ]
605
+ ```
606
+
607
+ **Checked at generate time (SPEC-GEN-001).** `feat generate`, and so `verify`,
608
+ `run` and `watch`, read every fixture, check its shape, check each `schemaName`
609
+ against the contract's closed space, validate values through the configured
610
+ schema adapter, and inline the checked records into the generated test. The test
611
+ reads no fixture at run time. Inline records get the same values check. Every
612
+ violation across every spec is collected and reported together, in spec,
613
+ scenario, row, seed, record order, and **nothing is written**.
614
+
615
+ ```
616
+ ERROR 1 seed violation(s); nothing was generated:
617
+ SEED_FIXTURE_SCHEMA_UNDECLARED: data/items.json record 1: schema 'NoSuchSchema' is not declared in the contract (declared: AddItemInput, ItemEvent, ItemRow, ItemError)
618
+ ```
619
+
620
+ | Code | When |
621
+ | --- | --- |
622
+ | `SEED_FIXTURE_NOT_FOUND` | the resolved path names no readable file |
623
+ | `SEED_FIXTURE_NOT_JSON` | the file is not valid JSON |
624
+ | `SEED_FIXTURE_NOT_RECORDS` | the JSON is not an array of `{ type, schemaName?, values }` records (the message names the record index and what is missing) |
625
+ | `SEED_FIXTURE_SCHEMA_UNDECLARED` | a record's `schemaName` is not in the contract |
626
+ | `SEED_FIXTURE_VALUES_INVALID` | a fixture record's `values` fail its schema |
627
+ | `SEED_VALUES_INVALID` | an inline record's values fail its schema, in a scenario that is not an outline |
628
+ | `SEED_ROW_VALUES_INVALID` | an inline record's values fail its schema in one row of a scenario outline |
629
+
630
+ An undeclared schema name on an **inline** record never reaches this step: the
631
+ parser refuses it as `UNDECLARED_SCHEMA`.
632
+
633
+ **Outlines and `SEED_ROW_VALUES_INVALID`.** In a `scenario outline`, each example
634
+ row gets its own copy of every inline seed record, with the row's values
635
+ substituted first (SPEC-DRV-001): a whole-value `<placeholder>` takes the row's
636
+ value, and a placeholder inside a string stays literal (`"Item-<n>"` is not
637
+ rewritten). Each row is then checked on its own, so one bad row is one violation
638
+ and the others raise nothing. The anchor ends in `› row[n]`, with `n` counting
639
+ from 1:
640
+
641
+ ```feat
642
+ scenario outline "seed per row":
643
+ given:
644
+ The store already holds seeded state.
645
+ seed store [ ItemAdded with ItemEvent { itemId: <id>, name: "Item-<n>" } ]
646
+ when: AddItem { itemId: "22222222-0000-4000-8000-000000000009" }
647
+ predict rejection ITEM_EXISTS:
648
+ response 409 ItemError
649
+ store has []
650
+ examples:
651
+ | id | n |
652
+ | "11111111-0000-4000-8000-000000000001" | 1 |
653
+ | 7 | 2 |
654
+ ```
655
+
656
+ Row 2 supplies `7` for `itemId`, which the contract says is a string, so
657
+ generation stops:
658
+
659
+ ```
660
+ ERROR 1 seed violation(s); nothing was generated:
661
+ SEED_ROW_VALUES_INVALID: scenario "seed per row" given › seed[0] record 0 › row[2]: values fail schema 'ItemEvent': /itemId must be string
662
+ ```
663
+
664
+ An inline seed with no placeholder is still checked in every row, so one bad
665
+ record is one violation per row. A **fixture** seed in an outline is never
666
+ substituted (a path written as a placeholder is looked up as written, and is
667
+ `SEED_FIXTURE_NOT_FOUND`). It is read, checked and counted once, and every row
668
+ carries its checked records.
669
+
670
+ ## Namespaces
671
+
672
+ Spec files run in parallel, often against one product. So that two files never
673
+ see each other's data, the runner gives **each spec file its own namespace**
674
+ (SPEC-RT-006), derived from the file's path alone: `s` plus the first 12 hex
675
+ characters of the SHA-256 of the spec's path relative to the base config's
676
+ directory, with `/` separators and no leading `./`. `specs/greet.feat` is
677
+ `sb0e796f7f361`. The pattern is `^s[0-9a-f]{12}$`.
678
+
679
+ The namespace reaches every adapter as `config.namespace` and as the
680
+ `FEAT_NAMESPACE` environment variable, and is delivered to a spec host (a
681
+ product adapter's out-of-process helper) too. Adapters isolate their data under
682
+ it. Namespaces isolate **data**, not availability: an exclusive fault still
683
+ affects a shared product.
684
+
685
+ Refusals, all exit `2` before any case has an effect:
686
+
687
+ | Code | When |
688
+ | --- | --- |
689
+ | `NAMESPACE_COLLISION` | two files in one run derive the same namespace; one must move (checked by `feat run` before it starts) |
690
+ | `NAMESPACE_CONFIGURED` | a `namespace` key is written in the config, in `response`, `response.invoke` or a service's `options`. A configured value would be shared by every file. |
691
+ | `NAMESPACE_NOT_HONOURED` | an adapter or host reports a namespace other than the one it was given, or a handler route with `namespace: true` never read it |
692
+
693
+ ## Faults and the serial pass
694
+
695
+ A `given:` block may arm logical faults (ADR-0023), as preconditions:
696
+
697
+ ```feat
698
+ given:
699
+ fault database Put TIMEOUT { "ms": 5 } times 2
700
+ fault broker Connection Partition until reset
701
+ ```
702
+
703
+ The form is `fault <service> <Operation> <Fault> [{ json }] [once | times <n> | until reset]`.
704
+ The harness arms them after the seeds and executes and before the capture
705
+ window, in written order. A fault is never an assertion: the scenario predicts
706
+ the system's reaction with the usual forms. Three refusals matter to a run:
707
+
708
+ | Code | Exit | When |
709
+ | --- | --- | --- |
710
+ | `FAULT_UNSUPPORTED` | `2` | the adapter has no `fault()`, offers no such operation or fault, does not declare that count, or cannot carry a detail. Before any effect. |
711
+ | `FAULT_REQUIRES_SERIAL` | `2` | an exclusive fault (`BrokerLoss`) armed outside the serial pass |
712
+ | `FAULT_NOT_CONSUMED` | `1` | an armed fault the system never consumed (a prediction violation). Skipped for an adapter that cannot observe consumption. |
713
+
714
+ **The serial pass (SPEC-RT-005).** A spec file that arms an exclusive fault
715
+ (`BrokerLoss`, which pauses a container every namespace shares) cannot run
716
+ beside other files. `feat run` finds those files from the IR, never by name (a `given` fault, or an
717
+ exclusive `<Operation>.<Fault>` in a string of a `when` input, as a probe's script), runs
718
+ every other file in the parallel pass, then runs the exclusive ones in a second
719
+ Vitest pass with one worker and `FEAT_SERIAL=1`. The two JUnit reports are
720
+ merged into one.
721
+
722
+ ## Shards
723
+
724
+ `--shard i/n` runs one disjoint slice of the generated files, so a suite whose
725
+ services share one store can run as `n` parallel jobs. The files are sorted by
726
+ path and dealt round-robin, so every job computes the same partition with no
727
+ coordination.
728
+
729
+ ```sh
730
+ npx feat run --shard 1/4 # in job 1
731
+ npx feat run --shard 2/4 # in job 2, with its OWN instruments
732
+ ```
733
+
734
+ - **Each shard needs its own instruments.** Shards that share a store are not
735
+ isolated.
736
+ - Each shard writes its own JUnit file: `feat-junit.xml` becomes
737
+ `feat-junit.shard-2-of-4.xml`. Collect them yourself. `feat report` reads the
738
+ unsuffixed path.
739
+ - More shards than files leaves some slices empty. An empty slice prints
740
+ `shard i/n: 0 file(s)`, writes no JUnit file, and exits `0`.
741
+ - `i/n` must satisfy `1 <= i <= n`, otherwise exit `1`.
742
+ - `--shard` combines with `--spec`.
743
+
744
+ ## JUnit and `feat report`
745
+
746
+ With `report.format` containing `junit` and `report.junitOutput` set, `feat run`
747
+ writes JUnit XML there. Each test case is a scenario, named
748
+ `SPEC-ID: Spec name > scenario name`, so a failure points at spec coordinates,
749
+ not a generated line. `feat report --junit` prints the absolute path for CI or
750
+ Xray import.
751
+
752
+ ```json
753
+ { "report": { "format": ["console", "junit"], "junitOutput": ".feature/reports/feat-junit.xml" } }
754
+ ```
755
+
756
+ ## Evidence bundle
757
+
758
+ `feat report --evidence` writes a self-contained, digest-anchored
759
+ `feat-evidence/2` record of the project's spec state and results. It is a record,
760
+ not a gate: it never fails the build by itself, and it needs no account.
761
+
762
+ ```sh
763
+ feat run # optional, populates the run block
764
+ feat report --evidence # writes .feature/evidence/<environment>/<commit>[-<config>][-dirty].json
765
+ ```
766
+
767
+ ```
768
+ evidence: .feature/evidence/ci/ae34f95486becc5b97d2acc3aaf176245cb71f94.json
769
+ evidence: specs 1, verify pass, run pass, environment ci
770
+ ```
771
+
772
+ The bundle holds:
773
+
774
+ | Block | Contents |
775
+ | --- | --- |
776
+ | `contract` | `feat-evidence/2` |
777
+ | `producer` | the tool, its version, and the exact `@mmmnt` toolchain versions |
778
+ | `project` | `feat_version`, `config_digest`, `environment`, the producing `commit`, `config` (see below) and `bindings` |
779
+ | `specs` | every spec: path, content digest, id, status, name, context, aggregate, type, handler, a zone-tagged `excerpt`, per-scenario digests, the contract `interface`, and the generated file's digest. A spec that does not parse is listed with `parse_error`. |
780
+ | `verify` | `pass`, or `fail` with the mismatched files (`feat verify` semantics) |
781
+ | `run` | the last run's test, failure and error counts and a digest of the JUnit file, when one exists |
782
+ | `runs` | one entry per scenario: spec id, pass or fail, duration, and parsed violation rows `{ path, expected, got }` |
783
+ | `variables` | each case's resolved spec variables, when a spec declares any |
784
+ | `signature` | `null` when produced locally |
785
+
786
+ Conventions:
787
+
788
+ - **Path.** `.feature/evidence/<environment>/<commit-sha>[-<config-slug>][-dirty].json`.
789
+ The default config keeps the bare `<sha>`. Any other config appends its slug
790
+ (`feat.integration.config.json` gives `-integration`), so a repo that reports
791
+ once per config never overwrites one file. A dirty tree appends `-dirty`, so it
792
+ cannot pass as a clean commit. `--out` replaces the whole path. The file name
793
+ uses `git rev-parse HEAD` (`nosha` outside a git repository). The `commit` field
794
+ inside prefers `GITHUB_SHA` when it is set.
795
+ - **Tier provenance (ADR-0024).** `project.config.resolved` is a digest of the
796
+ merged config. For an overlay, `project.config.overlay` and `.base` hold each
797
+ file's path and digest. `project.bindings` records the response adapter and,
798
+ per service, the adapter and its version (`adapterVersion`), the consistency and
799
+ timeouts, `observes` and whether fault consumption is observable
800
+ (`faultConsumptionObservable`) (ADR-0024), so an integration-tier
801
+ bundle is distinguishable from a spec-tier one.
802
+ - **Local records nothing.** With environment `local`, `--evidence` prints
803
+ `evidence: skipped` and writes nothing, unless `--force`.
804
+
805
+ The schema ships in this package as `schemas/evidence.schema.json`. The full
806
+ description is
807
+ [docs/evidence-bundle.md](https://github.com/mmmnt/feature/blob/main/docs/evidence-bundle.md).
808
+
809
+ ## Environment variables
810
+
811
+ | Variable | Used by | Meaning |
812
+ | --- | --- | --- |
813
+ | `ENVIRONMENT`, `FEAT_ENVIRONMENT` | `run`, `report --evidence` | The environment name (see [Environment](#environment)). |
814
+ | `FEAT_CONFIG` | generated tests | Set by `feat run` to the active config's absolute path. Set it yourself to run a generated file under another tier with plain Vitest. |
815
+ | `FEAT_NAMESPACE` | adapters | The spec file's namespace, set while its adapters are alive. |
816
+ | `FEAT_SERIAL` | the harness | `1` in the serial pass. Required to arm an exclusive fault. |
817
+ | `FEAT_FENCE_AUDIT` | the harness | Set to wait out the convergence ceiling anyway and fail if a capture grew after a fence vouched. |
818
+ | `GITHUB_SHA` | `report --evidence` | The commit recorded in the bundle. |
819
+ | `npm_config_user_agent` | `init` | Package manager detection, after lockfiles. |
820
+
821
+ ## Exit codes
822
+
823
+ | Code | Meaning |
824
+ | --- | --- |
825
+ | `0` | success |
826
+ | `1` | validation failure: a parse error, a seed violation, drift (`verify`), a failed prediction, a failed audit, a failed `fmt --check` |
827
+ | `2` | configuration error: a refused config (`CONFIG_NOT_FOUND`, `INVALID_CONFIG`, the `EXTENDS_*` codes, `TIER_SPACE_MISMATCH`, ...), a module named as an adapter that cannot be resolved or loaded (`INVALID_CONFIG`), no environment to name (`NO_ENVIRONMENT`), a harness refusal during `run` (`CLOCK_UNSUPPORTED`, `MODE_UNSUPPORTED`, `FAULT_*`, `NAMESPACE_*`, `SEED_UNSUPPORTED`, `DELIVER_UNSUPPORTED`), `NO_REPORT`, `ALREADY_INITIALIZED` |
828
+
829
+ Each exit `2` prints a `[CODE]`.
830
+
831
+ ## In CI
832
+
833
+ A typical pipeline is three lines:
834
+
835
+ ```sh
836
+ feat verify # committed tests match the specs
837
+ feat run # predictions hold against the real system
838
+ feat report --junit # print the JUnit path to import
839
+ ```
840
+
841
+ with the environment set (`ENVIRONMENT=ci`). Add `feat audit` to gate on
842
+ buildability, and `feat report --evidence` to archive the bundle as a build
843
+ artifact. For the integration tier add
844
+ `feat run --config feat.integration.config.json`.
845
+
846
+ ## What changed in 0.4.0
847
+
848
+ Release v0.1.48.
849
+
850
+ - **Tier overlays (ADR-0024).** `extends`, `specs.exclude`, `TIER_SPACE_MISMATCH`,
851
+ `EXTENDS_NOT_FOUND`, `EXTENDS_CHAIN`. Every command reads the config through
852
+ one loader. Generation is environment-agnostic: the `Inputs-hash` covers only
853
+ the closed spaces, ordering resolves in the harness, and the timing envelope and
854
+ `FEAT_CONFIG` come from `feat run`. This is a one-time change to every committed
855
+ generated file: run `feat generate` once and commit.
856
+ - **Seed checks (SPEC-GEN-001, SPEC-DRV-001).** Fixtures are validated and
857
+ inlined at generate time with all violations reported together. An outline
858
+ row's inline seeds are substituted and checked on their own, refused as
859
+ `SEED_ROW_VALUES_INVALID`.
860
+ - **Evidence.** The bundle records the overlay, its base and the tier's bindings
861
+ (ADR-0024).
862
+ - **Namespaces, faults and the serial pass (SPEC-RT-005, SPEC-RT-006, ADR-0023).**
863
+ One namespace per spec file, `feat run` stops on a collision, and exclusive
864
+ faults run in a serial pass after the parallel one.
865
+ - **Exit codes.** Exit `2` is a configuration error everywhere, with its code:
866
+ `generate` and `verify` on a refused config or schema adapter; `run` on a
867
+ harness configuration error, an adapter that cannot be loaded, or no
868
+ environment; `report --evidence` with no environment; `diff` with an
869
+ unloadable config. A parse failure or a seed violation stays exit `1`. The
870
+ generated suite tears down only a harness that was created.
871
+
872
+ Re-run `feat generate` after upgrading.
873
+
874
+ ## Specs and decisions
875
+
876
+ The toolchain is specified in `.feat` and built with itself.
877
+
878
+ - [SPEC-GEN-001](https://github.com/mmmnt/feature/blob/main/packages/feature/generate-seed-fixtures.feat):
879
+ check and inline seed fixtures at generate time
880
+ - [SPEC-DRV-001](https://github.com/mmmnt/feature/blob/main/packages/feat-derive/derive-seeds.feat):
881
+ derive substitutes each outline row into its own seeds
882
+ - [SPEC-RT-001](https://github.com/mmmnt/feature/blob/main/packages/feat-runtime/load-config.feat):
883
+ load and validate `feat.config.json`
884
+ - [SPEC-RT-004](https://github.com/mmmnt/feature/blob/main/packages/feat-runtime/load-config-extends.feat):
885
+ load a tier overlay
886
+ - [SPEC-RT-005](https://github.com/mmmnt/feature/blob/main/packages/feat-runner/serial-faults.feat):
887
+ exclusive faults run in a serial pass
888
+ - [SPEC-RT-006](https://github.com/mmmnt/feature/blob/main/packages/feat-runtime/harness-namespace.feat):
889
+ one namespace per spec file
890
+ - [ADR-0022](https://github.com/mmmnt/feature/blob/main/docs/adr/ADR-0022-uppercamel-rejection-ids.md):
891
+ rejection ids, `UPPER_SNAKE` or `UpperCamel`
892
+ - [ADR-0023](https://github.com/mmmnt/feature/blob/main/docs/adr/ADR-0023-adapter-interface-v2.md):
893
+ observation modes, the scenario clock, fault injection
894
+ - [ADR-0024](https://github.com/mmmnt/feature/blob/main/docs/adr/ADR-0024-tier-bindings.md):
895
+ tier bindings
896
+ - [Grammar reference](https://github.com/mmmnt/feature/blob/main/docs/grammar-reference.md)
897
+ - [Evidence bundle](https://github.com/mmmnt/feature/blob/main/docs/evidence-bundle.md)
25
898
 
26
899
  ## Documentation
27
900
 
28
901
  - Repository: https://github.com/mmmnt/feature
29
902
  - Getting started, language guide, CLI reference: https://github.com/mmmnt/feature/wiki
30
903
 
904
+ ## License
905
+
31
906
  MIT