@gate-forge/cli 0.13.10 → 0.14.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 (63) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/dist/adopted-baseline.d.ts +2 -0
  3. package/dist/adopted-baseline.d.ts.map +1 -1
  4. package/dist/adopted-baseline.js +1 -0
  5. package/dist/adopted-baseline.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +3 -0
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/adapters.d.ts.map +1 -1
  10. package/dist/commands/adapters.js +17 -12
  11. package/dist/commands/adapters.js.map +1 -1
  12. package/dist/commands/adopt.d.ts.map +1 -1
  13. package/dist/commands/adopt.js +162 -12
  14. package/dist/commands/adopt.js.map +1 -1
  15. package/dist/commands/baseline.d.ts.map +1 -1
  16. package/dist/commands/baseline.js +23 -5
  17. package/dist/commands/baseline.js.map +1 -1
  18. package/dist/commands/check.d.ts.map +1 -1
  19. package/dist/commands/check.js +48 -69
  20. package/dist/commands/check.js.map +1 -1
  21. package/dist/commands/config.d.ts +3 -0
  22. package/dist/commands/config.d.ts.map +1 -0
  23. package/dist/commands/config.js +106 -0
  24. package/dist/commands/config.js.map +1 -0
  25. package/dist/commands/init-presets.d.ts +11 -0
  26. package/dist/commands/init-presets.d.ts.map +1 -1
  27. package/dist/commands/init-presets.js +6 -0
  28. package/dist/commands/init-presets.js.map +1 -1
  29. package/dist/commands/init.d.ts.map +1 -1
  30. package/dist/commands/init.js +13 -1
  31. package/dist/commands/init.js.map +1 -1
  32. package/dist/commands/next.d.ts.map +1 -1
  33. package/dist/commands/next.js +33 -4
  34. package/dist/commands/next.js.map +1 -1
  35. package/dist/commands/test-gates.d.ts +7 -0
  36. package/dist/commands/test-gates.d.ts.map +1 -1
  37. package/dist/commands/test-gates.js +38 -2
  38. package/dist/commands/test-gates.js.map +1 -1
  39. package/dist/endpoint-compiler.d.ts.map +1 -1
  40. package/dist/endpoint-compiler.js +73 -6
  41. package/dist/endpoint-compiler.js.map +1 -1
  42. package/dist/evaluate.d.ts +31 -1
  43. package/dist/evaluate.d.ts.map +1 -1
  44. package/dist/evaluate.js +62 -4
  45. package/dist/evaluate.js.map +1 -1
  46. package/dist/evidence-authority.d.ts +68 -0
  47. package/dist/evidence-authority.d.ts.map +1 -0
  48. package/dist/evidence-authority.js +114 -0
  49. package/dist/evidence-authority.js.map +1 -0
  50. package/dist/pipeline.d.ts.map +1 -1
  51. package/dist/pipeline.js +1 -0
  52. package/dist/pipeline.js.map +1 -1
  53. package/dist/run-evidence.d.ts +1 -1
  54. package/dist/run-evidence.d.ts.map +1 -1
  55. package/dist/run-evidence.js +7 -3
  56. package/dist/run-evidence.js.map +1 -1
  57. package/dist/state.d.ts +19 -1
  58. package/dist/state.d.ts.map +1 -1
  59. package/dist/state.js +39 -1
  60. package/dist/state.js.map +1 -1
  61. package/guides/QUICKSTART.md +7 -7
  62. package/guides/REFERENCE.md +256 -0
  63. package/package.json +11 -11
@@ -24,11 +24,11 @@ Example for a React frontend, FastAPI backend, and SQLAlchemy data layer:
24
24
 
25
25
  ```sh
26
26
  npm i -D \
27
- @gate-forge/cli@0.13.10 \
28
- @gate-forge/pack-playwright@0.13.10 \
29
- @gate-forge/pack-http@0.13.10 \
30
- @gate-forge/pack-fastapi@0.13.10 \
31
- @gate-forge/pack-sqlalchemy@0.13.10
27
+ @gate-forge/cli@0.14.0 \
28
+ @gate-forge/pack-playwright@0.14.0 \
29
+ @gate-forge/pack-http@0.14.0 \
30
+ @gate-forge/pack-fastapi@0.14.0 \
31
+ @gate-forge/pack-sqlalchemy@0.14.0
32
32
  ```
33
33
 
34
34
  Use the project-local `gateforge` binary from your npm script or add `node_modules/.bin` to your shell `PATH`. If the scan recommends other packs, add only the ones your code uses, at the same version. A mismatched Gateforge package contract can stop the CLI with exit code 2 and `GATEFORGE_PACKAGE_INCOMPATIBLE`.
@@ -49,7 +49,7 @@ This installs every pack of the release; the scan still recommends the ones your
49
49
 
50
50
  **You should see:** npm installs the packages without a Gateforge compatibility error.
51
51
 
52
- **If not:** align every direct `@gate-forge/*` package to `0.13.10`, then install again. Do not work around the compatibility error.
52
+ **If not:** align every direct `@gate-forge/*` package to `0.14.0`, then install again. Do not work around the compatibility error.
53
53
 
54
54
  ## 2. Pick a goal
55
55
 
@@ -501,7 +501,7 @@ the registry. To gate a release that is not on the registry yet (a local
501
501
  regenerate:
502
502
 
503
503
  ```sh
504
- GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.13.10.tgz \
504
+ GATEFORGE_CI_ENGINE_SOURCE=vendor/gate-forge-cli-0.14.0.tgz \
505
505
  gateforge enforce --ci github
506
506
  ```
507
507
 
@@ -1,5 +1,6 @@
1
1
  # Gateforge CLI reference
2
2
 
3
+
3
4
  The reference for the `gateforge` CLI: every command, flag, exit
4
5
  code, and protocol, plus the usage documentation that lived in the
5
6
  repository README before the 0.9.0 documentation split. Both halves
@@ -1274,8 +1275,57 @@ repo-root-relative. `changed.provider: auto` (the default) picks
1274
1275
  instant for deterministic reports; `system` (default) freezes it at run
1275
1276
  start.
1276
1277
 
1278
+ ### HTTP route source (`http.routeSource`)
1279
+
1280
+ `.gateforge.yml` accepts:
1281
+
1282
+ ```yaml
1283
+ http:
1284
+ routeSource: both
1285
+ ```
1286
+
1287
+ `routeSource` is `both` by default. `both` unions detector routes with the
1288
+ operations published in the app's OpenAPI document; `detectors` and
1289
+ `openapi` select only that source. In `both` mode, a route present in only
1290
+ one source produces a report-only `ROUTE_SOURCE_MISMATCH` finding. The union
1291
+ matters because OpenAPI may omit routes hidden from its schema, while
1292
+ detectors can also report routes not exposed by the running app.
1293
+
1294
+ OpenAPI path insertion order is not dispatch precedence. When multiple
1295
+ routes match a concrete request, the matcher uses proven detector
1296
+ `registration` order (same serving scope, distinct positions) and selects
1297
+ the first registered match. Without enough order evidence it returns an
1298
+ ambiguous result rather than guessing. A single full match resolves; no
1299
+ matching method and path is unmatched. Matching ignores query strings and
1300
+ accepts trailing-slash variants; positional parameters match one segment,
1301
+ and a trailing catch-all matches one or more segments.
1302
+
1277
1303
  Enforcement-relevant sections:
1278
1304
 
1305
+ - `http.routeSource:` — the served-route inventory source: `both`
1306
+ (default), `detectors`, or `openapi`. `both` unions both inventories and
1307
+ reports source-only routes as report-only `ROUTE_SOURCE_MISMATCH` findings.
1308
+ - `http.callFindings:` — the channel the HTTP call findings (unmatched,
1309
+ ambiguous, unresolvable) use: `block` (default) or `report`. `block` fails
1310
+ the check on NEW findings; findings already recorded as debt by adoption are
1311
+ counted, not blocked. `report` prints and serializes new findings on the
1312
+ advisory channel and leaves the exit code alone. See "Adopting call findings"
1313
+ and "The HTTP call rules and the coverage summary" below.
1314
+ - `http.responseShape:` — `off` (default), `report`, or `block`: whether the
1315
+ witness checks each proxied JSON response body against the app's OpenAPI
1316
+ response schema. The document is read from `http.openapiPath:` (default
1317
+ `/openapi.json`) at run bind. `report` prints mismatches as advisories;
1318
+ `block` makes every consumed endpoint owe `http:response-matches-model`,
1319
+ so a wrong field type fails with `HTTP_RESPONSE_SHAPE_MISMATCH`. A route
1320
+ with no schema, or a run with no reachable document, is `unchecked` and
1321
+ never fails. A body over 1 MiB is refused as `HTTP_BODY_TOO_LARGE` for
1322
+ that obligation only. The light and normal presets write `report`, the
1323
+ strict preset writes `block`.
1324
+ - Read and write these settings with `gateforge config get <key>`,
1325
+ `gateforge config set <key> <value>`, and `gateforge config list`.
1326
+ `set` refuses a key the schema does not know or a value it rejects, and
1327
+ leaves `.gateforge.yml` untouched.
1328
+
1279
1329
  - `enforcement:` — `mode: standard | managed` (default `standard`),
1280
1330
  `strictE2E: boolean` (default `false`), and optional
1281
1331
  `receiptStage: pre-push | pre-commit | ci`. New configs choose `pre-push`;
@@ -1307,6 +1357,212 @@ Enforcement-relevant sections:
1307
1357
  changing the list moves the approved revision. See "Developer and CI
1308
1358
  tooling is owner-declared" above.
1309
1359
 
1360
+ ### The exchange ledger (`http.exchanges`, `httpLedger`)
1361
+
1362
+ Every witnessed test session now leaves its HTTP exchanges as evidence,
1363
+ not only the sessions that carry claims. When a session that PASSED
1364
+ closes (and when a page sweep completes), the witness issues ONE
1365
+ claim-free record of kind `http.exchanges` carrying the same transport
1366
+ snapshot the per-claim `http.observed` records carry: the deduplicated,
1367
+ capped exchange list (`method`, `url`, `status`, `fetchDest`, `resourceType`),
1368
+ its watermark, and `truncated` when the cap cut the list. `fetchDest` is
1369
+ the lowercased `Sec-Fetch-Dest` value when present; otherwise the
1370
+ Playwright fixture derives it from the request resource type (`fetch`/`xhr`
1371
+ become `empty`, `document` becomes `document`, and assets retain their
1372
+ destination class). The fixture's `x-gateforge-resource-type` header is
1373
+ test-process supplied, not proof. When browser `Sec-Fetch-Dest` is absent, it
1374
+ supplies the fallback used to classify API traffic; that classification
1375
+ affects API call and response-shape findings, but never satisfies a transport
1376
+ obligation. A disagreement records `resourceTypeConflict: true` while
1377
+ preserving the browser destination.
1378
+ Missing both facts yields `null`. A session whose test did not pass drops its record, and
1379
+ `http.exchanges` cannot satisfy an obligation or serve as proof. Its rows
1380
+ supply the report and the R1-R5 evaluation.
1381
+
1382
+ At verdict time the report JSON carries `httpLedger` for a run that
1383
+ witnessed at least one such record:
1384
+
1385
+ ```json
1386
+ {
1387
+ "httpLedger": {
1388
+ "rows": [
1389
+ {
1390
+ "testId": "tests/checkout#apples",
1391
+ "method": "GET",
1392
+ "path": "/items/apples",
1393
+ "status": 200,
1394
+ "fetchDest": "empty",
1395
+ "kind": "api",
1396
+ "route": "http.endpoint:GET /items/{}",
1397
+ "resolution": "match"
1398
+ }
1399
+ ],
1400
+ "summary": { "exchanges": 1, "matched": 1, "unmatched": 0, "ambiguous": 0, "incomplete": 0 }
1401
+ }
1402
+ }
1403
+ ```
1404
+
1405
+ One row per witnessed exchange, sorted by test id, method, path, and
1406
+ status. `path` is the query-stripped observed path; `fetchDest` is the
1407
+ effective lowercased destination (browser `Sec-Fetch-Dest` preferred,
1408
+ otherwise derived from Playwright's `resourceType`); `resourceType` retains
1409
+ that raw fixture value or is `null`; `resourceTypeConflict` is present when
1410
+ the two facts disagree. `route` is the resource id
1411
+ the ONE route matcher attributed it to, or `null`. `kind` is `api` only
1412
+ when `fetchDest` is exactly `empty`; `document` and `iframe` are `page`,
1413
+ other non-empty destinations (for example `script`, `style`, `image`, or
1414
+ `font`) are `asset`, and an absent/null destination is `unknown`.
1415
+ `resolution` is that matcher's answer — `match`, `nomatch`,
1416
+ `ambiguous` (with the equal candidates in `candidates`), or
1417
+ `incomplete` (an inventory entry cannot be attributed). If the route
1418
+ inventory is empty or unavailable, resolution is `incomplete` rather
1419
+ than `nomatch` and the summary reports `inventory: "unavailable"`; an
1420
+ unattributable route candidate reports `inventory: "incomplete"`.
1421
+ The `httpLedger` report field is report-only by itself; the exchange evidence
1422
+ is also consumed by the R1-R5 rules below, whose findings can affect the
1423
+ verdict and exit code through `http.callFindings`. The key is absent from runs
1424
+ that witnessed no session exchanges.
1425
+ `fetchDest: "empty"` alone identifies API traffic for R2/R3 findings.
1426
+
1427
+ ### The HTTP call rules and the coverage summary (`http.callFindings`)
1428
+
1429
+ The ledger is not decoration: five rules run over it at verdict time.
1430
+
1431
+ - **R1 — API use means API use.** A route is USED when an API exchange
1432
+ (`fetchDest: "empty"`) matched it (a ledger row with `kind: "api"` and
1433
+ `resolution: "match"`) OR the static join consumed it (the endpoint
1434
+ carries `frontendConsumed: true`). Page, asset, and unknown traffic do
1435
+ not count as API calls or used API routes. A used route already owes
1436
+ `http:request-observed` + `http:response-status-ok`: those obligations
1437
+ are generated BEFORE the run by the `consumed: true` policy against the
1438
+ same join (or by every endpoint under
1439
+ `http.endpoint.requireObservation: all`), so no rule here invents an
1440
+ obligation.
1441
+ - **R2 — an unmatched API call is a defect only with a complete inventory.**
1442
+ Only `kind: "api"` rows with `resolution: "nomatch"` and status 404 or
1443
+ 405 report `HTTP_CALL_UNMATCHED`, naming the test, method, path and
1444
+ missing-route statuses. Repeats are one finding. A nomatch with every
1445
+ other status reports `HTTP_ROUTE_NOT_INVENTORIED` as a report-only
1446
+ advisory: the app answered, so the detector inventory may be incomplete.
1447
+ This advisory is never blocking or adoptable debt. An empty route
1448
+ inventory or `incomplete` matcher result cannot prove a call unmatched.
1449
+ - **R3 — an ambiguous API call is a defect.** Only API rows matching
1450
+ several routes at equal specificity report `HTTP_CALL_AMBIGUOUS` with
1451
+ the candidates. Incomplete inventory placements and page/asset/unknown
1452
+ rows never produce R2/R3 findings.
1453
+ - **R4 — an unresolvable call site is never dropped.** A static call
1454
+ whose target the join cannot compute reports `HTTP_CALL_UNRESOLVED`
1455
+ with its `file:line`. It reads the unresolved call-site facts the graph
1456
+ already carries; the pre-existing `unresolved` blocking entries for the
1457
+ same sites stay exactly as they were.
1458
+ - **R5 — served but never used is a count.** It appears in the summary
1459
+ and is never a finding.
1460
+
1461
+ Which channel these findings use is the owner's:
1462
+
1463
+ - `http.callFindings: report | block` (default `block`) — in `report`
1464
+ mode every NEW finding is printed and serialized on the report's existing
1465
+ `advisories` channel and the exit code is untouched; in `block` mode the
1466
+ new findings join the run's blocking set and fail the check exactly like
1467
+ any other blocking finding. Findings already recorded as debt are counted,
1468
+ not blocked, in either mode (see "Adopting call findings" below).
1469
+
1470
+ Every run also carries the summary line — in the human report as
1471
+
1472
+ ```
1473
+ HTTP: 782 served, 367 used, 340 proven, 27 missing, 12 unmatched, 0 ambiguous (complete route inventory)
1474
+ ```
1475
+
1476
+ and in the json report under `httpCoverage` (absent from reports that do
1477
+ not compute it). When the route inventory is unavailable or incomplete,
1478
+ the summary names that status instead of treating unmatched traffic as a
1479
+ proven defect. `served` is the route table minus routes the detector
1480
+ PROVES unmounted: until a detector emits mount provenance, nothing is
1481
+ subtracted, because an absent proof is unknown served-ness rather than
1482
+ proof of dead code. `used` counts served routes with a caller, `proven`
1483
+ counts used routes whose BOTH transport obligations are `satisfied` (a
1484
+ waived or baselined obligation is a recorded forgiveness, never proof),
1485
+ and `missing` is `used` minus `proven`.
1486
+
1487
+
1488
+ ### Adopting call findings (`http.callFindings`, debt, then new blocks)
1489
+
1490
+ Only blocking-eligible `HTTP_CALL_UNMATCHED` (404/405), `HTTP_CALL_AMBIGUOUS`
1491
+ and `HTTP_CALL_UNRESOLVED` findings are recorded as debt. `HTTP_ROUTE_NOT_INVENTORIED`
1492
+ is always advisory: it is never adopted and can never block. A NEW eligible finding
1493
+ blocks in `block` mode.
1494
+
1495
+ - **Identity.** Each finding has a fingerprint: a sha256 over a canonical
1496
+ description of the call. For UNMATCHED and AMBIGUOUS the description is the
1497
+ finding code, the HTTP method, the path shape, and the test id. The path shape
1498
+ drops the query and fragment and collapses any segment that is all digits, a
1499
+ UUID, or 16+ hex characters to `:id`. For UNRESOLVED it is the code, the file,
1500
+ and the scanner detail without its trailing `file:line`. The HTTP status and
1501
+ line numbers are NOT part of the identity, so a harmless edit does not churn
1502
+ the debt.
1503
+ - **Storage.** Recorded in the adoption receipt as the family marker
1504
+ `families['http-calls']`, never in the baseline document. The marker maps each
1505
+ finding's key to its fingerprint and lists the fingerprints as forgiven. It is
1506
+ written only when there are findings to record, so a repository with none keeps
1507
+ the 0.13 receipt shape.
1508
+ - **Migrating an adopted repository.** `gateforge adopt --family http-calls`
1509
+ previews what would be recorded (nothing is written); `--confirm` writes the
1510
+ marker. The marker is permanent, so a repeat is a loud no-op. Until it is
1511
+ recorded, `check` names the migration in one line. A repository with no
1512
+ receipt at all is pointed at the plain `gateforge adopt` instead.
1513
+ - **Debt count.** Adopted findings are counted as known debt in the report
1514
+ summary as `baselinedHttpCallFindings`. A FIXED finding leaves that count on
1515
+ the next run with no edit. Its fingerprint stays in the receipt until
1516
+ `gateforge baseline update --family-http-calls <fingerprint>...` shrinks it;
1517
+ `--family-http-calls=` keeps none.
1518
+ - **Known limitation.** A call that was fixed, then re-introduced identically,
1519
+ and not yet shrunk out of the receipt is forgiven again. Run
1520
+ `gateforge baseline update --family-http-calls` after a fix to close that
1521
+ window.
1522
+ - **Preset defaults.** `light` writes `callFindings: report` (advisory only);
1523
+ `normal` and `strict` write `callFindings: block`. A config with no
1524
+ `callFindings` key takes the schema default, `block`.
1525
+
1526
+ ### Mount proofs (`mountProvenances`, `HTTP_ENDPOINT_UNMOUNTED`)
1527
+
1528
+ What "the detector PROVES unmounted" means in practice. The FastAPI pack
1529
+ walks each app's `include_router` graph ONCE and stamps every route it
1530
+ reaches with the chain it crossed, in the same `<module>:<var>` identity a
1531
+ route's `registration.scope` uses:
1532
+
1533
+ ```
1534
+ include-chain:app.main:app → app.api:api_router → app.items:items_router
1535
+ ```
1536
+
1537
+ The compiled `http.endpoint` carries those strings in `mountProvenances`
1538
+ (deduplicated, sorted; one entry per mount, so a router included by two
1539
+ apps yields two). A route declared by a router NO `include_router` targets
1540
+ carries none — it is still reported, because a declaration is a claim, but
1541
+ nothing proves an app serves it, and it therefore leaves `served`.
1542
+
1543
+ - **`HTTP_ENDPOINT_UNMOUNTED` (report-only).** Names each endpoint whose
1544
+ router nothing mounts, so the reader can mount the router or delete the
1545
+ dead code. It is deliberately not a blocking code, and it is minted only
1546
+ in a run that carries proofs at all: with no proof anywhere, the detector
1547
+ could not follow the mount graph, and an empty proof means "unknown",
1548
+ never "dead code".
1549
+ - **`conditional: true`.** A route declared inside a module-level
1550
+ `if`/`try`/`with`/`for`/`while` registers only when that branch runs, so
1551
+ its served-ness is unknown statically. Such an endpoint is MARKED, never
1552
+ dropped, and the flag is never a served-ness input: its router is mounted
1553
+ either way, so the route keeps its `mountProvenances` and its
1554
+ `registration` (which holds whenever the route does register).
1555
+ - **`adapters scaffold`** skips exactly these paths. With no mount proof
1556
+ anywhere in the graph it scaffolds nothing unmounted, for the same reason.
1557
+
1558
+ `gateforge next` names the caller of a used-but-unproven route: when the
1559
+ top item is one of its two transport contracts, the `why` line ends with
1560
+ `— this route is used by <testId | file:line:col>, …`, where the names
1561
+ are the witnessing tests whose exchange matched it (a page-sweep session
1562
+ prints as `page-sweep`) and the static call sites joined onto it. A
1563
+ non-HTTP obligation never gets an HTTP caller, and a proven route never
1564
+ names one.
1565
+
1310
1566
  ## Pages
1311
1567
 
1312
1568
  Each detected frontend route creates two page promises: `page:loads` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gate-forge/cli",
3
- "version": "0.13.10",
3
+ "version": "0.14.0",
4
4
  "gateforgeCompatibility": {
5
5
  "supervisedFixtureProtocol": "gateforge.supervised-playwright.v1"
6
6
  },
@@ -33,16 +33,16 @@
33
33
  "test": "vitest run"
34
34
  },
35
35
  "dependencies": {
36
- "@gate-forge/core": "^0.13.10",
37
- "@gate-forge/http-contract": "^0.13.10",
38
- "@gate-forge/pack-fastapi": "^0.13.10",
39
- "@gate-forge/pack-alembic": "^0.13.10",
40
- "@gate-forge/pack-http": "^0.13.10",
41
- "@gate-forge/pack-react-router": "^0.13.10",
42
- "@gate-forge/pack-playwright": "^0.13.10",
43
- "@gate-forge/pack-sqlalchemy": "^0.13.10",
44
- "@gate-forge/pack-task": "^0.13.10",
45
- "@gate-forge/plugin-protocol": "^0.13.10",
36
+ "@gate-forge/core": "^0.14.0",
37
+ "@gate-forge/http-contract": "^0.14.0",
38
+ "@gate-forge/pack-fastapi": "^0.14.0",
39
+ "@gate-forge/pack-alembic": "^0.14.0",
40
+ "@gate-forge/pack-http": "^0.14.0",
41
+ "@gate-forge/pack-react-router": "^0.14.0",
42
+ "@gate-forge/pack-playwright": "^0.14.0",
43
+ "@gate-forge/pack-sqlalchemy": "^0.14.0",
44
+ "@gate-forge/pack-task": "^0.14.0",
45
+ "@gate-forge/plugin-protocol": "^0.14.0",
46
46
  "picomatch": "^4.0.7",
47
47
  "yaml": "^2.8.1"
48
48
  },