yadflow 3.19.0-next.2 → 4.0.0-next.3

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 (158) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/README.md +160 -22
  3. package/bin/commands.mjs +46 -0
  4. package/bin/yad.mjs +506 -117
  5. package/cli/artifact-status.mjs +30 -11
  6. package/cli/capture.mjs +417 -0
  7. package/cli/checkpoint.mjs +47 -27
  8. package/cli/claims.mjs +165 -0
  9. package/cli/codeowners-command.mjs +170 -0
  10. package/cli/codeowners.mjs +397 -0
  11. package/cli/commit.mjs +13 -9
  12. package/cli/dial.mjs +183 -0
  13. package/cli/docs.mjs +88 -32
  14. package/cli/doctor.mjs +1682 -90
  15. package/cli/epic-state.mjs +3460 -211
  16. package/cli/epic.mjs +506 -0
  17. package/cli/errors.mjs +3 -0
  18. package/cli/fold.mjs +247 -0
  19. package/cli/gate-local.mjs +296 -0
  20. package/cli/gate.mjs +977 -183
  21. package/cli/history.mjs +556 -0
  22. package/cli/hook.mjs +264 -53
  23. package/cli/hubcommit.mjs +9 -19
  24. package/cli/index-command.mjs +87 -0
  25. package/cli/ledger.mjs +54 -4
  26. package/cli/lib.mjs +161 -9
  27. package/cli/manifest.mjs +376 -38
  28. package/cli/migrate.mjs +683 -52
  29. package/cli/mode.mjs +170 -0
  30. package/cli/next.mjs +365 -86
  31. package/cli/openpr.mjs +193 -34
  32. package/cli/owners.mjs +266 -0
  33. package/cli/people.mjs +657 -0
  34. package/cli/plan.mjs +466 -125
  35. package/cli/platform.mjs +109 -128
  36. package/cli/product-index.mjs +287 -0
  37. package/cli/protection.mjs +706 -0
  38. package/cli/reconcile.mjs +40 -12
  39. package/cli/repo-publish.mjs +24 -26
  40. package/cli/repo.mjs +23 -14
  41. package/cli/report.mjs +24 -14
  42. package/cli/review.mjs +19 -22
  43. package/cli/riskmap-command.mjs +289 -0
  44. package/cli/riskmap.mjs +373 -0
  45. package/cli/setup.mjs +127 -279
  46. package/cli/ship.mjs +6 -5
  47. package/cli/skill.mjs +180 -0
  48. package/cli/skip.mjs +211 -30
  49. package/cli/thread.mjs +41 -16
  50. package/cli/tidy.mjs +18 -18
  51. package/cli/update-commit.mjs +21 -21
  52. package/cli/usage.mjs +115 -109
  53. package/package.json +3 -3
  54. package/skills/sdlc/config.yaml +149 -70
  55. package/skills/sdlc/module-help.csv +24 -24
  56. package/skills/yad-analysis/SKILL.md +121 -59
  57. package/skills/yad-architecture/SKILL.md +30 -18
  58. package/skills/yad-architecture/references/contract-format.md +8 -5
  59. package/skills/yad-backfill/SKILL.md +10 -4
  60. package/skills/yad-backfill/references/backfill.md +8 -1
  61. package/skills/yad-backfill/templates/checks/backfill-check.sh +10 -2
  62. package/skills/yad-change/SKILL.md +119 -42
  63. package/skills/yad-change/references/triage.md +42 -27
  64. package/skills/yad-checks/SKILL.md +68 -35
  65. package/skills/yad-checks/references/check-gates.md +310 -85
  66. package/skills/yad-checks/templates/checks/commit-message.sh +17 -3
  67. package/skills/yad-checks/templates/checks/contract-check.sh +130 -9
  68. package/skills/yad-checks/templates/checks/epic-open.sh +2 -2
  69. package/skills/yad-checks/templates/checks/ledger-guard.sh +55 -8
  70. package/skills/yad-checks/templates/checks/lineage-check.sh +23 -9
  71. package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +1 -1
  72. package/skills/yad-checks/templates/checks/risk-map-check.sh +438 -0
  73. package/skills/yad-checks/templates/checks/verified-commits.sh +20 -46
  74. package/skills/yad-checks/templates/github/yad-checks.yml +13 -2
  75. package/skills/yad-checks/templates/github/yad-hub-checks.yml +5 -5
  76. package/skills/yad-checks/templates/github/yad-update-guard.yml +7 -5
  77. package/skills/yad-checks/templates/github/yad-verified-commits.yml +4 -4
  78. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +10 -1
  79. package/skills/yad-checks/templates/gitlab/yad-hub-checks.gitlab-ci.yml +5 -5
  80. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +3 -3
  81. package/skills/yad-checks/templates/hooks/ledger-guard-cursor.sh +91 -0
  82. package/skills/yad-checks/templates/hooks/ledger-guard.sh +37 -6
  83. package/skills/yad-checks/templates/hooks/yad-capture.sh +53 -0
  84. package/skills/yad-commit/SKILL.md +4 -4
  85. package/skills/yad-connect-design/SKILL.md +5 -5
  86. package/skills/yad-connect-design/references/design-context.md +1 -1
  87. package/skills/yad-connect-design/references/design-registry.md +2 -2
  88. package/skills/yad-connect-docs/SKILL.md +11 -11
  89. package/skills/yad-connect-docs/references/docs-registry.md +1 -1
  90. package/skills/yad-connect-learning/SKILL.md +5 -5
  91. package/skills/yad-connect-learning/references/learning-registry.md +2 -2
  92. package/skills/yad-connect-repos/SKILL.md +66 -45
  93. package/skills/yad-connect-repos/references/code-context.md +4 -4
  94. package/skills/yad-connect-repos/references/hub-config.md +47 -51
  95. package/skills/yad-connect-repos/references/repos-registry.md +8 -7
  96. package/skills/yad-connect-repos/references/risk-map.md +81 -0
  97. package/skills/yad-connect-testing/SKILL.md +5 -5
  98. package/skills/yad-connect-testing/references/testing-context.md +3 -4
  99. package/skills/yad-connect-testing/references/testing-registry.md +2 -2
  100. package/skills/yad-defects/SKILL.md +7 -7
  101. package/skills/yad-discovery/SKILL.md +131 -94
  102. package/skills/yad-discovery/references/discovery-schema.md +22 -6
  103. package/skills/yad-discovery/references/foundation-schema.md +374 -0
  104. package/skills/yad-docs/SKILL.md +13 -8
  105. package/skills/yad-docs/references/data-mapping.md +9 -7
  106. package/skills/yad-docs/templates/app/package-lock.json +3 -3
  107. package/skills/yad-docs-overview/SKILL.md +30 -15
  108. package/skills/yad-docs-overview/references/pipeline-model.md +33 -20
  109. package/skills/yad-docs-sync/SKILL.md +10 -5
  110. package/skills/yad-docs-sync/references/staleness.md +8 -7
  111. package/skills/yad-engineer-review/SKILL.md +81 -17
  112. package/skills/yad-engineer-review/references/ship-and-record.md +17 -8
  113. package/skills/yad-epic/SKILL.md +173 -92
  114. package/skills/yad-epic/references/state-schema.md +610 -94
  115. package/skills/yad-hub-bridge/SKILL.md +57 -38
  116. package/skills/yad-hub-bridge/references/bridge.md +94 -67
  117. package/skills/yad-hub-bridge/references/login-roster.md +163 -70
  118. package/skills/yad-hub-bridge/templates/checks/hub-route.sh +22 -19
  119. package/skills/yad-hub-bridge/templates/github/yad-gate-sync.yml +34 -14
  120. package/skills/yad-hub-bridge/templates/gitlab/gitlab-ci.include-root.yml +2 -2
  121. package/skills/yad-hub-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +21 -11
  122. package/skills/yad-implement/SKILL.md +27 -13
  123. package/skills/yad-implement/references/implement-conventions.md +2 -2
  124. package/skills/yad-learn/SKILL.md +9 -9
  125. package/skills/yad-learn/references/learning-state.md +2 -2
  126. package/skills/yad-open-pr/SKILL.md +61 -26
  127. package/skills/yad-pair-review/SKILL.md +7 -5
  128. package/skills/yad-pair-review/references/session-state.md +1 -1
  129. package/skills/yad-pr-template/SKILL.md +47 -26
  130. package/skills/yad-pr-template/references/risk-routing.md +97 -24
  131. package/skills/yad-pr-template/templates/checks/pr-template.sh +34 -11
  132. package/skills/yad-pr-template/templates/checks/pr-title.sh +32 -9
  133. package/skills/yad-pr-template/templates/checks/risk-route.sh +107 -14
  134. package/skills/yad-pr-template/templates/github/pull_request_template.md +7 -5
  135. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +7 -5
  136. package/skills/yad-pr-template/templates/hub/github/pull_request_template.md +14 -13
  137. package/skills/yad-pr-template/templates/hub/gitlab/merge_request_templates/Default.md +14 -12
  138. package/skills/yad-reconcile/SKILL.md +3 -3
  139. package/skills/yad-report/SKILL.md +5 -5
  140. package/skills/yad-review-companion/SKILL.md +6 -3
  141. package/skills/yad-review-gate/SKILL.md +203 -93
  142. package/skills/yad-review-gate/references/gating.md +232 -54
  143. package/skills/yad-run/SKILL.md +81 -51
  144. package/skills/yad-run/references/run-loop.md +61 -39
  145. package/skills/yad-ship/SKILL.md +15 -11
  146. package/skills/yad-spec/SKILL.md +21 -6
  147. package/skills/yad-spec/references/spec-handoff.md +17 -5
  148. package/skills/yad-status/SKILL.md +115 -50
  149. package/skills/yad-stories/SKILL.md +37 -21
  150. package/skills/yad-stories/references/story-schema.md +7 -6
  151. package/skills/yad-stub/SKILL.md +58 -47
  152. package/skills/yad-sync-repos/SKILL.md +2 -2
  153. package/skills/yad-test-cases/SKILL.md +32 -23
  154. package/skills/yad-test-cases/references/test-cases-schema.md +7 -4
  155. package/skills/yad-timeline/SKILL.md +8 -7
  156. package/skills/yad-ui/SKILL.md +41 -18
  157. package/cli/roster.mjs +0 -164
  158. package/skills/sdlc/install.sh +0 -68
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: yad-checks
3
- description: 'Build Step C of the gated SDLC — the production-safety check gates. Wire and run the CI gates on a code repo: spec-link (every change links a real story/spec via its Task trailer), contract-check (a diff that changes the contract surface without a Contract-Change + an updated, re-locked contract FAILS and routes back to the architecture gate), build/test/lint, verified-commits (no unverified commits from unverified users — platform-Verified signature + roster-allowlisted author, on the hub and every repo), and the Phase 6 feature-thread gates lineage-check / epic-open / reconcile-debt (a change links a real threaded epic; a sealed epic refuses new behaviour; a thread with open hotfix debt is frozen until paid). The gates are CI-agnostic bash, invoked by GitHub Actions and GitLab CI. Use when the user says "wire the check gates", "run the gates", "require signed commits", or "set up CI checks" for a repo.'
3
+ description: 'Build Step C of the gated SDLC — the production-safety check gates. Wire and run the CI gates on a code repo: spec-link (every change links a real story/spec via its Task trailer), contract-check (a diff that changes the contract surface without a Contract-Change + an updated, re-locked contract FAILS and routes back to the architecture gate), build/test/lint, verified-commits (no unsigned commits — every commit carries a platform-Verified signature; write access to the repo decides who can author, on the Product and every repo), and the Phase 6 feature-thread gates lineage-check / epic-open / reconcile-debt (a change links a real threaded epic; a sealed epic refuses new behaviour; a thread with open hotfix debt is frozen until paid), plus an advisory risk-map check (warns when .sdlc/risk-map is stale). The gates are CI-agnostic bash, invoked by GitHub Actions and GitLab CI. Use when the user says "wire the check gates", "run the gates", "require signed commits", or "set up CI checks" for a repo.'
4
4
  ---
5
5
 
6
6
  # SDLC — Check Gates (Build Step C)
@@ -16,6 +16,10 @@ in CI on every PR/MR and must pass before merge (build plan §C). Each is a smal
16
16
  contract upstream, it **FAILS and routes back to the architecture gate**. The shared surface is
17
17
  never widened from inside a code repo (Phase 2 contract representation: delimited block + SHA-256 lock).
18
18
  Every story whose slice the diff touches is checked, not just the first — see `references/check-gates.md`.
19
+ A claimed `Contract-Change` against an epic that has **no lock at all** fails too: an epic on a short
20
+ lane (`chore`/`spike`) has no architecture step and never locks a surface, so it may consume the
21
+ contract but not change it, and the change belongs to a new epic on `classic`. That failure needs the
22
+ epic's ledger directory to resolve — a Product that is simply not checked out still defers, as before.
19
23
  3. **build/test/lint** — standard quality stage; tests must actually exercise new behavior, not just pass.
20
24
  CI installs and runs through the package manager declared by the repo's standard
21
25
  `package.json#packageManager` field (`npm` and `pnpm` are supported; any other manager stays on
@@ -25,15 +29,15 @@ in CI on every PR/MR and must pass before merge (build plan §C). Each is a smal
25
29
  The code-repo `yad-checks` workflow uses Node 22 by default (the build/test/lint job on GitHub; every
26
30
  `yad-*` gate job's image in the GitLab fragment) and reads `YAD_NODE_VERSION` (a GitHub repository
27
31
  variable or GitLab CI/CD variable) for repos whose declared runtime differs (a declared `packageManager` needs Corepack, so the override must be a line that
28
- bundles a current one: 20.19+, 22.14+ or 24; Node 25+ dropped it). The hub-side workflows (verified-commits, hub-checks, update-guard,
32
+ bundles a current one: 20.19+, 22.14+ or 24; Node 25+ dropped it). The Product-side workflows (verified-commits, hub-checks, update-guard,
29
33
  gate-sync) only run the `yad` CLI and keep their own pinned Node; the variable does not reach them.
30
34
  The CI job sets `YAD_TEST_MAX_WORKERS` (default `2`); the gate caps jest/vitest test concurrency at
31
35
  that and is a no-op for other runners (see `references/check-gates.md`).
32
- 4. **verified-commits** — no unverified commits from unverified users: every commit in the range must
33
- carry a signature the platform marks **Verified** AND be authored by a known identity
34
- (`.sdlc/verified-authors`, generated from the hub roster's `email` fields). Enforced on the
35
- **product hub and every connected repo**; runs on PRs/MRs only, so the gate-sync bot's direct
36
- ledger pushes are unaffected (never replace it with a default-branch push rule — see
36
+ 4. **verified-commits** — no unsigned commits: every commit in the range must carry a signature the
37
+ platform marks **Verified**. There is no author allowlist (E62): write access to the repo decides who
38
+ can author. An old `.sdlc/verified-authors` file is no longer read, and the gate prints a note when it
39
+ finds one. Enforced on the **Product and every connected repo**; runs on PRs/MRs only, so the
40
+ gate-sync bot's direct ledger pushes are unaffected (never replace it with a default-branch push rule — see
37
41
  `references/check-gates.md` §4).
38
42
  5. **lineage-check** (Phase 6) — the change's owning epic is a valid node in a **feature thread**: a
39
43
  `change`/`defect`/`hotfix` epic must thread to a real `parent`. Builds on spec-link's story→epic
@@ -43,14 +47,22 @@ in CI on every PR/MR and must pass before merge (build plan §C). Each is a smal
43
47
  change-epic (so the Shape artifacts can never go stale).
44
48
  7. **reconcile-debt** (Phase 6) — a hotfix that shipped first opens debt; the **next** change on its
45
49
  thread **FAILS** until the debt is paid (artifacts updated + a regression test added).
50
+ 8. **risk-map** (E65, **advisory — never fails**) — reads the code repo's `.sdlc/risk-map` (one line per
51
+ directory: `high` / `medium` / `low`, no names) and **warns** when this change adds a directory no line
52
+ covers, leaves a line whose directory is gone, touches a line still `unset` or `guessed`, or edits the
53
+ map itself. A repo with no map gets one note. It also prints the **approver count** (E66): a change
54
+ touching a directory the **base branch's** map marks `high` asks for one more approver — reported,
55
+ never enforced: branch protection holds the merge — and names who has **committed there in the last 30 days**
56
+ (E67), so the team knows who can meet that ask. The map is the team's file, never wired; the
57
+ `yad-connect-repos` skill drafts it. See `references/check-gates.md` §10.
46
58
 
47
- The Phase 6 gates read the owning epic in the **product hub** via `specs/<story>/link.md`'s
48
- `product-repo` path (like contract-check), and degrade to a PASS-with-note when the hub is not reachable
59
+ The Phase 6 gates read the owning epic in the **Product** via `specs/<story>/link.md`'s
60
+ `product-repo` path (like contract-check), and degrade to a PASS-with-note when the Product is not reachable
49
61
  from CI. See `references/check-gates.md` and `skills/yad-change`.
50
62
 
51
63
  The gates are **CI-agnostic bash** in `checks/`; thin pipeline configs invoke them on GitHub Actions
52
64
  and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the skill or let CI run them;
53
- **nothing auto-advances**. The gates are blocking in CI, but the human still owns the merge (Step E).
65
+ **nothing auto-advances**. The gates are blocking in CI (all but the advisory risk-map check), but the human still owns the merge (Step E).
54
66
 
55
67
  ## Conventions
56
68
 
@@ -60,8 +72,8 @@ and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the sk
60
72
  (`config.yaml` `build.code_repos_root`).
61
73
  - Canonical gate sources live in this skill's `templates/` (the source of truth that gets installed
62
74
  into each code repo):
63
- - `templates/checks/{spec-link,contract-check,package-manager,install-deps,build-test-lint,verified-commits}.sh`
64
- - `templates/checks/ledger-guard.sh` → **hub-only** gate, active **only in verified mode** — hub.json
75
+ - `templates/checks/{spec-link,contract-check,package-manager,install-deps,build-test-lint,verified-commits,risk-map-check}.sh`
76
+ - `templates/checks/ledger-guard.sh` → **Product-only** gate, active **only in verified mode** — hub.json
65
77
  carries BOTH a `platform` and `ledger: "verified"` — or, before `yad migrate`, `bridge_enabled`
66
78
  (or the legacy `bridge`) true. The same predicate
67
79
  `isVerifiedLedger` (`cli/manifest.mjs`) applies, so the gate and the CLI can never disagree about who owns the
@@ -73,16 +85,25 @@ and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the sk
73
85
  no CI path can create a ledger (`gate ci` only *advances* an existing chain, at merge, on the
74
86
  default branch), so an epic whose `.sdlc/state.json` is absent from the base ref may be created by
75
87
  a human on its first review PR/MR — **creation, not mutation** (#162). Once the ledger is on the
76
- default branch the guard is absolute again. Runs in `yad-hub-checks`
77
- alongside `verified-commits` (which waives the allowlist for the bot but still requires its
78
- signature). See `yad-hub-bridge`.
79
- - `templates/hooks/ledger-guard.sh` → **hub-only** agent guardrail, active **only in verified mode**
88
+ default branch the guard is absolute again. Runs in `yad-hub-checks`; `verified-commits` runs beside
89
+ it in its own `yad-verified-commits` workflow (and requires the bot's signature like any other
90
+ commit's). See `yad-hub-bridge`.
91
+ - `templates/hooks/ledger-guard.sh` → **Product-only** agent guardrail, active **only in verified mode**
80
92
  (the same `isVerifiedLedger` predicate). Not a CI gate: it is a **harness hook** that refuses an agent's
81
93
  edit to the CI-owned ledger at the moment it is attempted and names `yad gate open` instead — the
82
- local half of `checks/ledger-guard.sh` (#171). Installed to `<hub>/hooks/ledger-guard.sh` with the
83
- `PreToolUse` entry in `.claude/settings.json`. Fails OPEN; see "Step 2b" below.
94
+ local half of `checks/ledger-guard.sh` (#171). Installed to `<product>/hooks/ledger-guard.sh` with the
95
+ `PreToolUse` entry in `.claude/settings.json`; a `.cursor` project also gets
96
+ `templates/hooks/ledger-guard-cursor.sh` and a `preToolUse` entry in `.cursor/hooks.json`.
97
+ Fails OPEN; see "Step 2b" below.
98
+ - `templates/hooks/yad-capture.sh` → **Product-only**, in **both** ledger modes (E43): the post-edit
99
+ harness hook that runs `yad capture --hook`, which snapshots every changed Shape artifact onto the
100
+ person's private `yad/wip/<name>/<epic>` branches without touching the checkout. Wired as a
101
+ `PostToolUse` entry in `.claude/settings.json` and an `afterFileEdit` entry in `.cursor/hooks.json`;
102
+ always exits 0. It prints nothing, except under Claude Code when a file the edit changed is also
103
+ being edited by someone else (E46 claims): then one PostToolUse JSON note the agent reads.
104
+ `"capture": false` in the Product config unwires it.
84
105
  - `templates/github/yad-verified-commits.yml` + `templates/gitlab/yad-verified-commits.gitlab-ci.yml`
85
- → the standalone hub-side verified-commits CI (installed by `yad check --fix` with the hub wiring)
106
+ → the standalone Product-side verified-commits CI (installed by `yad check --fix` with the Product wiring)
86
107
  - `templates/github/yad-checks.yml` → installs to `.github/workflows/yad-checks.yml` (marked `# yad-managed: yad-checks`);
87
108
  its quality job uses `install-deps.sh`, reads the optional `YAD_NODE_VERSION` repository variable,
88
109
  exports the PR's exact `NX_BASE`/`NX_HEAD`, and filters unrelated history blobs while preserving
@@ -100,7 +121,7 @@ and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the sk
100
121
 
101
122
  ## Inputs
102
123
 
103
- - `repo` — the code repo to wire/run gates for (one of an epic's repos), or `hub` to wire the product hub itself.
124
+ - `repo` — the code repo to wire/run gates for (one of an epic's repos), or `hub` to wire the Product itself.
104
125
  - `action` — `wire` (install the gates into the repo) | `run` (run the three gates now). Default `run`.
105
126
  - `base` — for `run`: the base ref to diff against (the PR/MR target; default the repo's default branch).
106
127
 
@@ -109,7 +130,7 @@ and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the sk
109
130
  ### Step 1 — Resolve the code repo
110
131
  Map `repo` → `{project-root}/demo-repos/<repo>/` (or the registry `path` in `.sdlc/repos.json`); confirm
111
132
  it is its own git repo. Operate inside it with absolute paths. For `repo: hub`, the target is
112
- `{project-root}` itself and the platform comes from `.sdlc/hub.json` — see "Wiring the hub" in
133
+ `{project-root}` itself and the platform comes from `.sdlc/hub.json` — see "Wiring the Product" in
113
134
  `references/check-gates.md`.
114
135
 
115
136
  ### Step 2 — `wire` (install the gates, syncing with any existing CI)
@@ -162,12 +183,13 @@ Re-running `wire` is **idempotent** — markers (`# yad-managed: yad-checks`,
162
183
  `# yad-managed-include: yad-checks`) and the include-entry check make a second run a no-op.
163
184
  Commit the wiring on the repo's default branch (it is shared infrastructure, not a task diff).
164
185
 
165
- **The hub is wired the same way.** `repo: hub` wires the hub repo itself (platform from `.sdlc/hub.json`)
166
- with a hub-flavored gate set — see "Wiring the hub" in `references/check-gates.md`.
186
+ **The Product is wired the same way.** `repo: hub` wires the Product repo itself (platform from `.sdlc/hub.json`)
187
+ with a Product-flavored gate set — see "Wiring the Product" in `references/check-gates.md`.
167
188
 
168
- **The hub also gets the agent guardrail** (see below): `templates/hooks/ledger-guard.sh` →
169
- `<hub>/hooks/ledger-guard.sh`, plus the `PreToolUse` entry in `.claude/settings.json`. `yad setup`
170
- and `yad check --fix` install both; there is nothing to do by hand.
189
+ **The Product also gets the agent guardrail** (see below): `templates/hooks/ledger-guard.sh` →
190
+ `<product>/hooks/ledger-guard.sh`, plus the `PreToolUse` entry in `.claude/settings.json`. A project
191
+ whose targets include `.cursor` also gets `templates/hooks/ledger-guard-cursor.sh` and a `preToolUse`
192
+ entry in `.cursor/hooks.json`. `yad setup` and `yad check --fix` install them; nothing by hand.
171
193
 
172
194
  ### Step 2b — the agent guardrail (harness hooks, verified mode only)
173
195
  The CI gates speak at CI time. That is too late for one failure the field kept hitting (#171): in
@@ -182,8 +204,19 @@ file-editing tool call and refuses the write up front, naming the command that o
182
204
 
183
205
  - **Harness-agnostic by contract.** The script only locates `yad` and hands the tool payload to
184
206
  `yad hook ledger-guard`: **stdin** is a JSON tool-call payload, **exit 0** allows, **exit 2**
185
- denies with the reason on stderr. Claude Code's `PreToolUse` protocol is exactly that, so no
186
- adapter logic is needed; another harness needs only those two exit codes.
207
+ denies with the reason on stderr. Claude Code's `PreToolUse` reads exactly that, so its entry points
208
+ straight at the script. Cursor does NOT: its `preToolUse` is a **permission hook**, which wants a
209
+ JSON verdict on stdout and treats an empty or off-schema answer as a refusal — and this script
210
+ prints nothing when it allows, so wiring it there directly would block every file write in the
211
+ project. Cursor's entry points at `hooks/ledger-guard-cursor.sh` instead, which runs
212
+ `yad hook ledger-guard --format cursor` and always answers `{"permission":"allow"}` or
213
+ `{"permission":"deny","user_message":…,"agent_message":…}`. **Check which kind a harness is
214
+ before wiring it by hand.** A hook that fires only AFTER the write, such as Cursor's
215
+ `afterFileEdit`, is not used: it could report the edit but never refuse it, and reporting is what
216
+ the CI gate already does.
217
+ - **Targets with no such hook are named, not skipped.** `.agents`, `.gemini`, `.zencoder` and
218
+ `.opencode` get the script and no wiring, and `yad doctor` says which of a project's targets are
219
+ guarded by CI alone. Silence about an unguarded target reads as a guarded one.
187
220
  - **Same scope as the CI gate**, deliberately: guarded are `epics/*/.sdlc/{state,approvals,comments,hub-prs}.json`
188
221
  and `epics/*/reviews/*.md` (at the gate's own glob depth, which spans `/`); exempt are
189
222
  `contract-lock.json`, `change.json`, and every artifact. A **new** epic's ledger is exempt too —
@@ -191,15 +224,15 @@ file-editing tool call and refuses the write up front, naming the command that o
191
224
  `origin/` ref, case-folded slugs), never by looking at the working tree.
192
225
  - **A no-op with a local ledger.** There the ledger is locally owned and the hand-edit the authoring
193
226
  skills describe is *correct*, so nothing is wired and nothing is blocked.
194
- - **It fails OPEN** — no `yad`, no hub, an unreadable config, an unparseable payload all ALLOW, with
227
+ - **It fails OPEN** — no `yad`, no Product, an unreadable config, an unparseable payload all ALLOW, with
195
228
  a note on stderr. `ledger-guard` in CI fails *closed* and remains the authority. `YAD_HOOK_DISABLE=1`
196
229
  skips one command.
197
230
  - **Known gaps** (both caught by the CI gate instead): a `Bash` tool call (`sed -i epics/…`) is not
198
231
  intercepted — matching it would mean parsing shell; and the hook arms sessions **rooted at the
199
- hub**, since a harness reads hooks from its own project root — a session opened at the workspace
200
- above the hub never loads the hub's `.claude/settings.json`.
232
+ Product**, since a harness reads hooks from its own project root — a session opened at the workspace
233
+ above the Product never loads the Product's `.claude/settings.json`.
201
234
 
202
- `yad doctor` reports the guardrail as `agent ledger guard wired` / `not wired` on a verified hub.
235
+ `yad doctor` reports the guardrail as `agent ledger guard wired` / `not wired` on a verified Product.
203
236
  See `references/check-gates.md` §"The agent guardrail".
204
237
 
205
238
  ### Step 3 — `run` (run the gates now)
@@ -224,8 +257,8 @@ human engineer review (Step E) still own the merge. This skill never edits the e
224
257
  - **Run standalone** (the Phase 3 default): **stop** here. A clean pass does not advance anything; a
225
258
  human takes the next step.
226
259
  - **Run by the orchestrator** (`yad-run`, Phase 4): this skill still just reports PASS/FAIL — the
227
- *advance decision* is the orchestrator's, read from the `checks` step's `automation` dial. On a clean
228
- pass with `checks` earned to `machine_advance`, `yad-run` advances to `engineer-review` on its own;
260
+ *advance decision* is the orchestrator's, read from the `checks` step's advance dial. On a clean
261
+ pass with `checks` set to `advance: auto`, `yad-run` advances to `engineer-review` on its own;
229
262
  on any FAIL it halts and pulls in a human (build plan §B). **What the gates check is unchanged** —
230
263
  only who decides to proceed after a clean pass.
231
264
 
@@ -236,7 +269,7 @@ human engineer review (Step E) still own the merge. This skill never edits the e
236
269
  to the architecture gate; only an updated, re-locked contract + `Contract-Change: yes` may pass.
237
270
  - **Tests must exercise behavior.** build/test/lint is not satisfied by empty or trivial tests.
238
271
  - **The gate never advances itself.** A FAIL always halts. A clean PASS advances only when the
239
- orchestrator's `checks` dial is `machine_advance` (earned) — and only as far as the engineer review,
272
+ orchestrator's `checks` dial is `advance: auto` (`yad dial`) — and only as far as the engineer review,
240
273
  which is always human. Standalone, the gate still stops and the human owns the merge.
241
274
 
242
275
  ## Reference