@hexagen-monaco/sync 0.13.0 → 0.15.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 (55) hide show
  1. package/README.md +379 -16
  2. package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts +12 -0
  3. package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts.map +1 -0
  4. package/dist/cli.js +4500 -1814
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/arch/validate-outcome.d.ts +30 -0
  7. package/dist/commands/arch/validate-outcome.d.ts.map +1 -0
  8. package/dist/commands/arch/validate.d.ts +3 -1
  9. package/dist/commands/arch/validate.d.ts.map +1 -1
  10. package/dist/commands/bootstrap/index.d.ts.map +1 -1
  11. package/dist/commands/contract/evaluate.d.ts +54 -0
  12. package/dist/commands/contract/evaluate.d.ts.map +1 -1
  13. package/dist/commands/contract/growth.d.ts +22 -0
  14. package/dist/commands/contract/growth.d.ts.map +1 -0
  15. package/dist/commands/contract/index.d.ts +11 -3
  16. package/dist/commands/contract/index.d.ts.map +1 -1
  17. package/dist/commands/evidence/check.d.ts +2 -0
  18. package/dist/commands/evidence/check.d.ts.map +1 -1
  19. package/dist/commands/evidence/index.d.ts.map +1 -1
  20. package/dist/commands/evidence/pack.d.ts.map +1 -1
  21. package/dist/commands/evidence/verify.d.ts +83 -0
  22. package/dist/commands/evidence/verify.d.ts.map +1 -0
  23. package/dist/commands/grant/issue.d.ts.map +1 -1
  24. package/dist/commands/grant/list.d.ts +72 -0
  25. package/dist/commands/grant/list.d.ts.map +1 -0
  26. package/dist/commands/grant/verify.d.ts +7 -1
  27. package/dist/commands/grant/verify.d.ts.map +1 -1
  28. package/dist/commands/manifest/migrate.d.ts +8 -0
  29. package/dist/commands/manifest/migrate.d.ts.map +1 -1
  30. package/dist/commands/remove/index.d.ts +41 -0
  31. package/dist/commands/remove/index.d.ts.map +1 -0
  32. package/dist/commands/report/exec-git.d.ts.map +1 -1
  33. package/dist/commands/shared/brownfield-sidecar.d.ts +30 -0
  34. package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -1
  35. package/dist/commands/shared/confirm.d.ts.map +1 -1
  36. package/dist/commands/shared/grant-enumerator.d.ts +32 -0
  37. package/dist/commands/shared/grant-enumerator.d.ts.map +1 -0
  38. package/dist/commands/sync/check-json.d.ts +47 -0
  39. package/dist/commands/sync/check-json.d.ts.map +1 -0
  40. package/dist/commands/workbook/export.d.ts.map +1 -1
  41. package/dist/generators/architecture-files.d.ts.map +1 -1
  42. package/dist/generators/root-file-templates.d.ts +2 -2
  43. package/dist/generators/root-file-templates.d.ts.map +1 -1
  44. package/dist/generators/root-files.d.ts.map +1 -1
  45. package/dist/index.js +450 -421
  46. package/dist/index.js.map +1 -1
  47. package/dist/infrastructure/config/index.d.ts +3 -0
  48. package/dist/infrastructure/config/index.d.ts.map +1 -0
  49. package/dist/infrastructure/index.d.ts +1 -0
  50. package/dist/infrastructure/index.d.ts.map +1 -1
  51. package/dist/types/manifest/generator.d.ts +2 -0
  52. package/dist/types/manifest/generator.d.ts.map +1 -1
  53. package/dist/types/manifest/monorepo.d.ts +1 -0
  54. package/dist/types/manifest/monorepo.d.ts.map +1 -1
  55. package/package.json +1 -1
package/README.md CHANGED
@@ -52,6 +52,69 @@ npx hexagen sync
52
52
 
53
53
  Consult `npx hexagen arch --help` for the full list of manifest operations.
54
54
 
55
+ ### Machine-readable output
56
+
57
+ `hexagen arch validate --json` prints exactly one JSON line on stdout, with the
58
+ linter's own logs relayed to stderr:
59
+
60
+ ```json
61
+ {
62
+ "schemaVersion": 1,
63
+ "command": "arch validate",
64
+ "status": "compliant",
65
+ "exitCode": 0,
66
+ "fresh": 0,
67
+ "expired": 0,
68
+ "baselineGrowth": 0,
69
+ "filesScanned": 12,
70
+ "reason": null
71
+ }
72
+ ```
73
+
74
+ Exit codes: `0` compliant, `1` violations, `2` could not run (a broken manifest,
75
+ a missing linter, a timeout, or an unreadable `--json` line). `status` is one of
76
+ `"compliant" | "violations" | "could-not-run"`, and `reason` is `null` unless the
77
+ status is `"could-not-run"`.
78
+
79
+ `hexagen sync --check --json` prints exactly one JSON line on stdout, with every
80
+ sync engine log relayed to stderr:
81
+
82
+ ```json
83
+ {
84
+ "schemaVersion": 1,
85
+ "command": "sync --check",
86
+ "status": "drift",
87
+ "exitCode": 1,
88
+ "pending": { "created": 1, "updated": 0, "deleted": 0, "total": 1 },
89
+ "errors": 0,
90
+ "manifestMissing": false,
91
+ "reason": null
92
+ }
93
+ ```
94
+
95
+ `status` is one of `"converged" | "drift" | "could-not-run"`, decided in this
96
+ order: a thrown fatal error is `could-not-run` (with `pending`, `errors` and
97
+ `manifestMissing` all `null` and `reason` set to the error message); a missing
98
+ manifest is `could-not-run` with `reason` `"manifest not found"`; any generator
99
+ failure is `could-not-run` with `reason` `"<n> generator failure(s)"`; any
100
+ pending change is `"drift"`; otherwise `"converged"`. `exitCode` is `0` only
101
+ for `converged`, and `1` otherwise — the exit codes are unchanged. `--json`
102
+ without `--check` is a usage error: exit 2, nothing on stdout.
103
+
104
+ ### Generator identity
105
+
106
+ Hexagen-written manifests carry an identity marker: `generator.name: "@hexagen-monaco/sync"`
107
+ (the **published** package name). `hexagen sync` stamps it when it creates a new
108
+ manifest (external mode, fresh target) and so does `hexagen bootstrap`; `hexagen
109
+ manifest migrate` adds it to an existing project — in the side-car named by
110
+ `workspace_config` for a split manifest, otherwise at the root. Absence stays
111
+ valid (legacy). A consumer reads `.architecture/manifest.yaml`, then the file
112
+ `workspace_config` names, whose `generator` wins:
113
+
114
+ ```bash
115
+ npx hexagen manifest migrate --dry-run
116
+ ```
117
+
55
118
  ### `hexagen grant issue`
56
119
 
57
120
  Mints a signed Grant — the file `hexagen_accept_transaction` trusts as its
@@ -142,9 +205,11 @@ manifest exists: a grant that names no context at all (no manifest to
142
205
  derive contexts from, and no `--contexts` given) is paths-only in the
143
206
  literal sense, but since every manifest-mutation tool's enforcement
144
207
  requires a context match, such a grant cannot authorize any of those seven
145
- tools — it is scoped only for a future, generic Field Kit adapter that
146
- doesn't check `contexts`, not for `hexagen_accept_transaction` as it exists
147
- today. Prints the grant JSON to stdout, or to `--out <file>` if given.
208
+ tools. It is scoped for `hexagen_propose_patch`, the Field Kit adapter that
209
+ exists today: that tool is propose-only, and its enforcement checks `tools`,
210
+ `paths`, `max_files` and the slice, never `contexts`. It is not scoped for
211
+ `hexagen_accept_transaction`, which requires a context match on every
212
+ mutation. Prints the grant JSON to stdout, or to `--out <file>` if given.
148
213
 
149
214
  ### `hexagen grant show` and `hexagen grant check`
150
215
 
@@ -196,6 +261,66 @@ print the workspace root, the key path and its fingerprint, never the key.
196
261
  auto-broken), and `--key-file`/`--engagement` pointing at a key other than the
197
262
  server default produces a warning naming both keys.
198
263
 
264
+ ### `hexagen grant list`
265
+
266
+ ```bash
267
+ npx hexagen grant list # every grant under .hexagen/grants/, as a table
268
+ npx hexagen grant list --status live # only the live rows
269
+ npx hexagen grant list --json # the same rows as a JSON array on stdout
270
+ ```
271
+
272
+ A read-only listing of every `*.json` under `.hexagen/grants/` — there is no
273
+ `--dir` and no other directory — so you can see what is live, expired or revoked
274
+ without opening JSON by hand. Two lines come first, the directory it read and the
275
+ time the window was judged at, then the resolved key by path and fingerprint
276
+ (never the key), then the table and its summary:
277
+
278
+ ```text
279
+ file status id principal agent mode expires_at revoked_at signature
280
+ grants/g-live.json live g-live martin lane-1 propose 2026-10-01T18:00:00Z - verified
281
+ grants/g-revoked.json revoked g-revoked martin lane-1 propose 2026-10-01T18:00:00Z 2026-10-01T10:00:00Z verified
282
+ grants/g-expired.json expired g-expired martin lane-1 propose 2026-10-01T11:00:00Z - verified
283
+ 3 entries: 1 live, 1 expired, 1 revoked, 0 invalid
284
+ ```
285
+
286
+ The columns are file, status, id, principal, agent, mode, `expires_at`,
287
+ `revoked_at` and the signature verdict; rows are sorted by `expires_at`
288
+ descending, then id. The status is the shared `checkGrantWindow` answer, never a
289
+ second implementation of the window, and it is computed at call time and printed
290
+ with that time. The verification key is resolved once for the whole listing and
291
+ named exactly as `grant issue`, `show` and `check` resolve it. It works in a repo
292
+ with a manifest too, reading the in-repo key.
293
+
294
+ - Every entry in the directory becomes a row, including every refusal and every
295
+ error one raises: a symlink is `invalid: symlink` and is never read, and so are
296
+ an off-allow-list name, a name the key/env pattern forbids, unparseable JSON, a
297
+ JSON value that is not a grant, a file over the 32 MiB per-file cap, and an
298
+ entry that vanishes mid-read (`invalid: vanished before it could be read`). One
299
+ unreadable grant never hides the others — the deliberate difference from
300
+ `workbook export`, which fails the whole call instead. The reads go through the
301
+ same sidecar guards the export uses, so `.hexagen/grants/` has one enumerator,
302
+ not three.
303
+ - Exit 0 only if at least one grant was read, every grant read verifies and no
304
+ row is invalid. Exit 1 if no grant was read, any row is invalid, or any grant
305
+ read fails its signature — including one `--status` filtered out of the printed
306
+ rows. Exit 2 for bad input (an unknown `--status`, an unresolvable workspace
307
+ root, an unreadable directory) or a missing `.hexagen/` or `.hexagen/grants/`.
308
+ A fresh checkout has no `grants/` directory at all, so stage the grant files
309
+ first with `hexagen workbook export --stage .hexagen/grants/<id>.json --yes`.
310
+ - `--status live|expired|revoked|invalid|all` (default `all`) filters the printed
311
+ rows and nothing else. The summary always totals the whole directory, so an
312
+ invalid entry, or a signature failure the filter dropped, is still on screen
313
+ next to the exit code it caused — with `--status live` over a directory that
314
+ also holds one invalid entry, one row is printed and the summary reads:
315
+ `1 shown (--status live); all 4 entries: 1 live, 1 expired, 1 revoked, 1 invalid`.
316
+ `--json` prints the array of rows on stdout, with the key line, the summary and
317
+ the note on stderr.
318
+ - A `revoked_at` edited by hand breaks the signature, so the row reads `revoked`
319
+ and `not verified` — the same split `grant check` reports. `live` is the window
320
+ alone, at the timestamp printed beside it: read the signature column before
321
+ trusting a row. A listing is a snapshot, and a grant can be revoked a second
322
+ later.
323
+
199
324
  ### `hexagen observe`
200
325
 
201
326
  A read-only scan of a repo you do not control. It reports what is already
@@ -344,9 +469,13 @@ npx hexagen observe --out .hexagen/observed.json --yes
344
469
  npx hexagen slice init --path src/billing/ --exclude src/billing/generated/ --yes
345
470
  npx hexagen slice check # drift report
346
471
  npx hexagen contract propose # candidate rules; writes nothing
472
+ npx hexagen contract propose --closed # one candidate `closed` rule instead
347
473
  npx hexagen contract add-rule --kind forbid --from src/billing/ --to src/auth/ --yes
474
+ npx hexagen contract add-rule --kind closed --except src/auth/ --yes # close the slice, except one crossing
348
475
  npx hexagen contract check # gate; exit 1 on a new violation
349
476
  npx hexagen contract check --baseline --yes # record today's violations
477
+ npx hexagen contract check --base <base-sha> # pinned PR base; exit 1 on growth
478
+ npx hexagen contract check --base <base-sha> --allow-growth --reason "<why>"
350
479
  ```
351
480
 
352
481
  **`slice`** writes `.hexagen/slice.json`.
@@ -371,15 +500,56 @@ npx hexagen contract check --baseline --yes # record today's violations
371
500
  **`contract`** writes `.hexagen/contract.json`, whose `sliceId` comes from
372
501
  `slice.json`.
373
502
 
374
- - `contract propose` prints each pair of slice `paths` entries joined by an
375
- in-slice edge (both ends inside the slice, different entries) as a candidate
376
- `forbid` rule. It writes nothing.
503
+ - `contract propose [--closed]` prints each pair of slice `paths` entries joined by
504
+ an in-slice edge (both ends inside the slice, different entries) as a candidate
505
+ `forbid` rule. With `--closed` it prints one candidate `closed` rule instead,
506
+ whose `except` list names every crossing `observed.json` already makes, each
507
+ target emitted exactly as `slice check` prints it: the file path for a file
508
+ target, the package root for a package root, deduplicated, never widened to a
509
+ bare directory name (an `except` entry without a trailing `/` is an exact file,
510
+ so `lib` excepts nothing). Delete the entries you do not accept, and widen a
511
+ file to its directory by hand. A crossing no `except` can accept — a
512
+ root-package target (`.`), a target an `excludes` entry denies, or a target
513
+ spelled as a directory — is reported as `not proposed:` with the advice that
514
+ would accept it, because a rule naming one would still fail, or would accept
515
+ far more than the crossing observed. Both printed `add-rule` lines — the
516
+ cross-prefix one and the `--closed` one — are quoted for a POSIX shell, so
517
+ `sh`, `bash` or `zsh` can run either as it stands; `cmd.exe` does not read
518
+ those quotes, so do not paste one there. The cross-prefix line names the
519
+ slice's own prefixes in `--from`/`--to`, and a prefix is a repo path, so a
520
+ space or a `;` in one would otherwise split the command or run what follows.
521
+ With `--closed`, an
522
+ `observed.json` whose edges were not collected refuses (exit 2) and prints no
523
+ command at all: nothing is known about the crossings, so "no edge leaves the
524
+ slice" would be a claim the report cannot make. An incomplete edge list is a
525
+ `note:` line, not a refusal. It writes nothing and takes no write flag.
377
526
  - `contract add-rule --kind forbid|allow-only --from <prefix> --to <prefix>
378
- [--severity error|warn] [--id <id>]` appends a rule (`error` by default). The
379
- built-in id `unresolved-import` and duplicate ids are refused.
380
- - `contract show` prints the contract.
381
- - `contract check [--baseline]` evaluates the rules against the observed edges
382
- whose `from` is inside the slice. A `forbid` rule fails on an edge from its
527
+ [--severity error|warn] [--id <id>]` appends a rule (`error` by default). A
528
+ `closed` rule takes `--except <prefix>…` and neither `--from` nor `--to`: the
529
+ slice is the `from` side and `except[]` is the only escape hatch, so several
530
+ accepted crossings out of one source are one rule. `--except` may be given with
531
+ no prefixes at all, which accepts no crossing. Each kind refuses the other
532
+ kinds' flags by name, and every `--from`, `--to` and `--except` entry must
533
+ pass the slice-path rules, so a bare directory name (`libs/shared`) is an exact
534
+ path and excepts nothing — write `libs/shared/`. The built-in id
535
+ `unresolved-import`, an id outside `A-Za-z0-9._-` (1-64 chars, no `..`), a
536
+ duplicate id, and a missing `--kind` are refused, the last as exit 2 like every
537
+ other usage error.
538
+ - `contract show` prints the contract, and warns when **one** `closed` rule's
539
+ `except` list covers every observed package root outside the slice: that rule
540
+ then accepts every crossing it could have refused, so the slice is not closed.
541
+ Rules are not pooled — two rules that between them cover the whole repo leave
542
+ each edge one rule still to fail, which is what a closed slice wants. Coverage
543
+ is asked per package root, so `--except apps/` covers `apps/web` and
544
+ `apps/admin`, while `--except apps/web/ui/` covers neither the rest of its own
545
+ package nor any sibling; a bare `apps` covers nothing. A package the slice
546
+ occupies and one an `excludes` entry denies are not units to cover, and the
547
+ root package (`.`) never is. A contract with no `closed` rule reads no scan at
548
+ all, and a missing `slice.json`/`observed.json` is a `note:` line, not a
549
+ refusal.
550
+ - `contract check [--baseline] [--base <ref>] [--allow-growth --reason <text>]`
551
+ evaluates the rules against the observed edges whose `from` is inside the slice.
552
+ A `forbid` rule fails on an edge from its
383
553
  `from` prefix to its `to` prefix. An `allow-only` rule fails on an edge from
384
554
  its `from` prefix to anywhere that is neither its `to` prefix nor its own
385
555
  `from` prefix. A `warn` rule is printed but does not fail the check. The
@@ -397,6 +567,67 @@ npx hexagen contract check --baseline --yes # record today's violations
397
567
  of that UTC day) no longer hides its violation. A root-package target (`.`)
398
568
  is never inside a `to` prefix, so it always violates an `allow-only` rule.
399
569
 
570
+ A `closed` rule fails on any edge from inside the slice to a target that is
571
+ neither inside the slice nor under one of its `except` prefixes, so one rule
572
+ holds every accepted crossing out of the slice: the prefix kinds admit exactly
573
+ one. A package root is judged under both spellings, so
574
+ `--except libs/shared/` covers `libs/shared` and `libs/shared/x.ts`, and an
575
+ entry with no trailing `/` is an exact path. A root-package target (`.`) is
576
+ never inside an `except` prefix, so it always violates a `closed` rule, exactly
577
+ as it always violates an `allow-only` one. An edge whose source is inside an
578
+ `excludes` entry is not judged at all, and under a `closed` rule an `excludes`
579
+ entry creates violations instead of suppressing them: an except cannot re-open
580
+ an excluded target, so an edge into one still fails even under an `except` that
581
+ covers it. `--except src/` accepts every crossing out of `src/`, so read the
582
+ list before you commit it.
583
+
584
+ **The `--base` ratchet.** `contract check --base <ref>` also reads
585
+ `.hexagen/contract.json` and `.hexagen/slice.json` **at** `<ref>` with `git show`,
586
+ and fails when the working tree has made the slice's gate weaker than the
587
+ contract there. It is a detection, not a write-time refusal: the change is already
588
+ committed, and each finding is printed as `growth: …` with the hash the base was
589
+ read at. Growth is:
590
+
591
+ - a `knownViolations` entry the base never had for that rule + file + specifier;
592
+ an edit to the `file` or `specifier` of an entry the base did have;
593
+ - an `expires` pushed later from another `expires`, or dropped;
594
+ - a rule gone from the tree; a rule's `kind`, `from` or `to` changed, in either
595
+ direction; a `closed` rule's `except` prefix added or widened; a rule's
596
+ `severity` moved `error` → `warn`;
597
+ - a `slice.json` `excludes` entry the base did not have; a `paths` entry removed;
598
+ a `paths` entry replaced by a strictly longer prefix.
599
+
600
+ **Not** growth: an entry removed, an `expires` shortened, an `expires` added where
601
+ the base had none, a `reason` added, a rule added, an exclude removed, a `paths`
602
+ entry added or widened, a duplicate baseline entry, two rules that share an id
603
+ swapped, an `except` prefix removed or narrowed, and a `severity` raised from
604
+ `warn` to `error`. Rules are matched by value, so two rules sharing an id are
605
+ compared as a multiset, and entries are matched on rule + file + specifier,
606
+ strongest cover first, so a duplicate that already carries no `expires` is not
607
+ reported as a dropped date.
608
+
609
+ `--allow-growth --reason <text>` accepts the growth, prints the reason beside the
610
+ finding and into the log, and the check then continues — so its exit code is
611
+ still the plain check's, not automatically 0. `--reason` on its own does nothing.
612
+
613
+ Both files must be staged for a base to exist: every writer of `.hexagen/` adds
614
+ it to the exclude file, so `git show` cannot tell "never staged" from "the commit
615
+ that first added it", and the command reports the absence instead of passing.
616
+ Stage them with `hexagen workbook export --stage` on
617
+ `.hexagen/slice.json` and `.hexagen/contract.json`, plus `--yes` (or plain
618
+ `git add -f`). Pass the pinned PR base, never a
619
+ PR-supplied ref: `--base` is client-supplied, so a workflow that lets a PR pick
620
+ its own base compares the head with itself and passes. The one PR that first
621
+ stages the sidecars has a base that predates them — that is the bootstrap case,
622
+ judged on violations alone, and the
623
+ [CI recipe](../../docs/ci/brownfield-gate-recipe.md) runs the plain check for it.
624
+ The guard runs after the slice-id and contract parse and **before**
625
+ `observed.json` is loaded, so growth is still reported when `observed.json` is
626
+ missing or stale. One gap it cannot close: `contract check --baseline --yes`
627
+ rewrites `knownViolations` with no base in sight, so it can drop an `expires` the
628
+ guard would otherwise have reported — `--base` and `--baseline` are refused
629
+ together.
630
+
400
631
  **Concurrent edits.** `add-rule` and `check --baseline` (with `--yes`) hold
401
632
  `.hexagen/contract.json.lock`, created exclusively with the process id inside,
402
633
  while they read and rewrite `contract.json`, and remove it when they finish. If
@@ -419,11 +650,11 @@ than `HEAD` the commands warn, and with `--strict` fail.
419
650
 
420
651
  **Exit codes** (`slice check`, `contract check`, `contract propose`):
421
652
 
422
- | Code | Meaning |
423
- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
424
- | 0 | Clean (`slice check`, `contract check`), or the command succeeded |
425
- | 1 | Drift (`slice check`) or a violation not in the baseline, or incomplete edges (`contract check`) |
426
- | 2 | Bad input or refused: a missing or invalid file, a bad path or id, a refused overwrite, no `--yes`, a slice commit not in the repository, a stale `observed.json`, `--strict` and a different HEAD |
653
+ | Code | Meaning |
654
+ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
655
+ | 0 | Clean (`slice check`, `contract check`), or growth accepted with `--allow-growth` **and** the plain check clean, or the command succeeded |
656
+ | 1 | Drift (`slice check`), or a violation not in the baseline, or incomplete edges, or growth against `--base` (`contract check`) |
657
+ | 2 | Bad input or refused: a missing or invalid file, a bad path or id, a refused overwrite, no `--yes`, a slice commit not in the repository, a stale `observed.json`, `--strict` and a different HEAD, an unresolvable `--base` (a shallow clone that never fetched it), a `.hexagen/` file absent at `--base` because it was never staged, a `.hexagen/` file at `--base` that exists but cannot be read, a base file that is not valid JSON or does not match its schema, an inconsistent base (the contract at `--base` names another slice than the slice there), `--allow-growth` without `--reason`, `--allow-growth` without `--base`, `--base` with `--baseline` |
427
658
 
428
659
  `init`, `add-rule`, `show` and `--baseline` return 0 on success and 2 otherwise.
429
660
 
@@ -483,6 +714,137 @@ path outside `.hexagen/`, a symlink) refuses the whole call and stages nothing.
483
714
 
484
715
  ---
485
716
 
717
+ ### `hexagen evidence verify`
718
+
719
+ ```text
720
+ hexagen evidence verify --since <git-ref> [--until <git-ref>]
721
+ --grant <file>... [--root <dir>]
722
+ [--key-file <path>] [--engagement <id>]
723
+ [--allow-empty]
724
+ ```
725
+
726
+ A synopsis, not a runnable line: `[…]` marks an optional flag and `<…>` a value you
727
+ supply.
728
+
729
+ Names every changed file the kit governs — inside the slice (minus its excludes)
730
+ or inside any `--grant`'s `paths` — that no trace line appended after `--since`
731
+ covers. It is found after the fact, not refused: it reads only, never writes
732
+ `.hexagen/`, and never stops a write.
733
+
734
+ It reads the range `<since>..<until>` (default `HEAD`) with `git diff`, taking
735
+ the slice at **`<since>`** and the trace, the tip and the proposals at
736
+ **`<until>`**, so a range cannot widen its own scope or its own evidence.
737
+ `<since>` must be an ancestor of `<until>`. It then verifies the trace exactly as
738
+ `evidence pack` does — chain, line shape, the four Rules of
739
+ `docs/kernel/TRACE.md`, and the anchored tip — and joins each changed file to the
740
+ line that claims it. `tip.json` is **required** here, and only a line at or below
741
+ `tip.seq` covers anything: the chain binds each line to the one above it, but only
742
+ a key-holder's `pack` binds the head to the engagement key. A change that a line
743
+ would have covered on paper alone is still reported unaccounted, naming the seq to
744
+ pack. Every grant the trace cites must be supplied as a `--grant`, and the
745
+ engagement key comes from `--key-file`, then `HEXAGEN_GRANT_KEY_FILE`, then the
746
+ engagement — in CI that is a secret written outside the checkout, never a key in
747
+ the tree.
748
+
749
+ No Trace field carries the paths: the join reads them back from
750
+ `.hexagen/proposals/<id>.json` by its `traceSeq` and `grantId`, and recomputes
751
+ `result_digest` over `JSON.stringify({halt_reason, proposal_id, paths})`, so a
752
+ `paths` entry edited after the line was written breaks the digest instead of being
753
+ believed. Only a line whose `seq` is above the last `seq` in the trace as of
754
+ `<since>` can cover anything, read with `git show`; a checkout where the trace was
755
+ not tracked at `<since>`, or where that line is not the one the trace held there,
756
+ exits 2 rather than trusting a clock.
757
+
758
+ It prints the unaccounted paths on stdout and, on stderr, each one with the
759
+ nearest candidate line plus how many changes it skipped as outside the slice and
760
+ every grant. Exit 0 when nothing is unaccounted, 1 when something is, 2 for bad
761
+ input or bad state: an unresolvable `--since` or `--until` (a shallow clone that
762
+ never fetched it says so), a `--since` that is not an ancestor of `--until`, a
763
+ missing or unreadable slice at `<since>`, a missing or empty trace at `<until>`, a
764
+ missing or unverified `tip.json`, an unsound trace, a proposal that does not
765
+ reproduce its line's `result_digest`, a grant that does not verify, a trace not
766
+ tracked at `<since>`, a `--root` that is not the repo top level, and an empty
767
+ diff without `--allow-empty`.
768
+
769
+ Two limits worth stating: it proves an authorized line covering a path exists, not
770
+ that the line is true; and until Trace carries paths itself, a change applied
771
+ through `hexagen_accept_transaction` is unaccounted here, because that writer
772
+ leaves no path list behind. Coverage needs the `.hexagen/` evidence committed, so
773
+ stage it first — and in CI, pack before verify:
774
+
775
+ ```bash
776
+ hexagen workbook export --stage .hexagen/slice.json \
777
+ .hexagen/evidence/trace.jsonl \
778
+ .hexagen/evidence/tip.json \
779
+ .hexagen/grants/<id>.json \
780
+ .hexagen/proposals/<id>.json \
781
+ --yes
782
+ ```
783
+
784
+ ---
785
+
786
+ ### The brownfield CI gate
787
+
788
+ A client repo holds only `.hexagen/` and no manifest, so the generated
789
+ conformance gate has nothing to run there. Copy
790
+ [`docs/ci/brownfield-gate.yml`](../../docs/ci/brownfield-gate.yml) into the client
791
+ repo's `.github/workflows/` and edit its one `EDIT SPOT`: the
792
+ `HEXAGEN_VERSION` pin. `contract check --base` (step 3) and `evidence verify`
793
+ (step 4b) first ship in 0.14.0, so that is the **minimum** the gate needs rather
794
+ than a published release — release tags are the owner's to cut. Set it to a
795
+ version you can install and bump it deliberately; `hexagen --help` is the check
796
+ that the pin exists, because an older CLI's command parser refuses those two
797
+ flags and the job then fails at step 3 for a reason that has nothing to do with
798
+ the change under review.
799
+
800
+ `evidence pack` and `evidence verify` are the two halves of the gate, and the
801
+ recipe is a document rather than a template:
802
+ [`docs/ci/brownfield-gate-recipe.md`](../../docs/ci/brownfield-gate-recipe.md).
803
+ Every step's `run:` script is read out of that workflow and executed against the
804
+ built CLI on a fixture client repo by
805
+ `__tests__/contract/brownfield-gate.contract.test.ts`, so the recipe cannot drift
806
+ from what the job does. The one exception is `Install the hexagen CLI`: the
807
+ fixture already holds the artifact that install fetches — the built dist, copied
808
+ into the consumer's `node_modules/@hexagen-monaco/sync` — so the install is the
809
+ only step the suite does not run. Every kit command, and every step that can
810
+ decide the job, does run.
811
+
812
+ - `evidence pack <trace> --grant <file>... --out <zip>` checks the whole trace and
813
+ writes an HMAC'd bundle: 0 packed, 1 the evidence is invalid and nothing was
814
+ written, 2 usage or a failed precondition (no key, `--out` outside `.hexagen/`,
815
+ an `--out` that already exists). It is step 4, and it is also the only command
816
+ that anchors a line — so it runs even where nothing needs the bundle, because
817
+ step 4b counts only what a `pack` anchored.
818
+ - `evidence verify --since <ref> --grant <file>...` is step 4b and writes
819
+ nothing. It is documented under
820
+ [`hexagen evidence verify`](#hexagen-evidence-verify) above.
821
+
822
+ Fail-fast and in order, every step printing `step <n> exit <code>` — 1 is a
823
+ violation, 2 is bad input or stale state — and step 2 the one non-blocking
824
+ drift report. The steps are: the staged `.hexagen/` paths are tracked
825
+ (`git ls-files --error-unmatch`, exit 2 otherwise), `observe --out … --yes`,
826
+ `slice check --strict`, `contract check --base` against the pinned PR base SHA,
827
+ `evidence pack` into a disposable path under `.hexagen/`, then `evidence verify`
828
+ against the same base. Step 3 asks what the base holds and there are three
829
+ answers, not two: both sidecar files (compare, and let violations and growth
830
+ fail), neither (the PR that first stages them, judged on violations alone), or
831
+ exactly one — which it refuses with exit 2 rather than compare half a baseline.
832
+ Step 4b is skipped on exactly one PR, the bootstrap whose base carries no slice;
833
+ a base with a slice but no trace runs it and lets it exit 2.
834
+
835
+ The gate needs no manifest, no `apps/web` and no workbench package: the published
836
+ CLI is the only dependency. The engagement key is injected from a CI secret into
837
+ `$RUNNER_TEMP` at mode 0600 and read through `HEXAGEN_GRANT_KEY_FILE`, never
838
+ from the checkout. A missing or weak key is a denial, never a skip — and
839
+ because the job is fail-fast, only the first step that reads the key reports
840
+ it: the injection step exits 2 on an empty secret, while a non-empty but weak
841
+ key is caught by `evidence pack` in step 4, which exits 2 too.
842
+ `evidence verify` never runs in either case, because the job stopped first. The
843
+ bundle's HMAC is symmetric, so the CI secret can forge it and the FDE and CI
844
+ cannot be told apart.
845
+
846
+ ---
847
+
486
848
  ## Programmatic Usage
487
849
 
488
850
  > **The supported contract of this package is the `hexagen` binary.** The root
@@ -647,6 +1009,7 @@ The source `packages/sync/package.json` is never mutated by this process.
647
1009
  - **HexaGen Monaco repository:** https://github.com/martinkrakowski/hexagen-monaco
648
1010
  - **Architecture Decision Record:** [`ADR-0068`](../../.architecture/decisions/ADR-0068-published-cli-bundling.md) — CLI Bundling Strategy
649
1011
  - **Manifest schema:** `@hexagen/project-configuration`
1012
+ - **Brownfield CI gate recipe:** [`docs/ci/brownfield-gate-recipe.md`](../../docs/ci/brownfield-gate-recipe.md) — the gate a client repo runs when the workbench is gone
650
1013
  - **Issue tracker:** https://github.com/martinkrakowski/hexagen-monaco/issues
651
1014
 
652
1015
  ---
@@ -0,0 +1,12 @@
1
+ import type { DeepEqual } from "./migrate-manifest.use-case.js";
2
+ export interface StampGeneratorIdentityResult {
3
+ content: string;
4
+ changed: boolean;
5
+ }
6
+ export declare class StampGeneratorIdentityUseCase {
7
+ private readonly deepEqual;
8
+ constructor(deepEqual: DeepEqual);
9
+ execute(content: string): StampGeneratorIdentityResult;
10
+ private assertStampedOnlyAdded;
11
+ }
12
+ //# sourceMappingURL=stamp-generator-identity.use-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stamp-generator-identity.use-case.d.ts","sourceRoot":"","sources":["../../../src/application/use-cases/stamp-generator-identity.use-case.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,6BAA6B;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,4BAA4B;IAwEtD,OAAO,CAAC,sBAAsB;CAyB/B"}