yadflow 3.18.1 → 4.0.0-next.1

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 (156) hide show
  1. package/CHANGELOG.md +355 -0
  2. package/README.md +79 -26
  3. package/bin/commands.mjs +41 -0
  4. package/bin/yad.mjs +437 -124
  5. package/cli/artifact-status.mjs +34 -15
  6. package/cli/checkpoint.mjs +69 -49
  7. package/cli/codeowners-command.mjs +170 -0
  8. package/cli/codeowners.mjs +397 -0
  9. package/cli/commit.mjs +13 -9
  10. package/cli/companion.mjs +2 -2
  11. package/cli/dial.mjs +183 -0
  12. package/cli/docs.mjs +88 -32
  13. package/cli/doctor.mjs +1472 -97
  14. package/cli/epic-state.mjs +3478 -232
  15. package/cli/epic.mjs +506 -0
  16. package/cli/errors.mjs +4 -1
  17. package/cli/gate.mjs +1002 -209
  18. package/cli/history.mjs +556 -0
  19. package/cli/hook.mjs +266 -55
  20. package/cli/hubcommit.mjs +6 -17
  21. package/cli/index-command.mjs +87 -0
  22. package/cli/ledger.mjs +57 -7
  23. package/cli/lib.mjs +184 -18
  24. package/cli/manifest.mjs +367 -56
  25. package/cli/migrate.mjs +726 -53
  26. package/cli/mode.mjs +170 -0
  27. package/cli/next.mjs +349 -90
  28. package/cli/openpr.mjs +191 -39
  29. package/cli/people.mjs +654 -0
  30. package/cli/plan.mjs +417 -132
  31. package/cli/platform.mjs +110 -129
  32. package/cli/product-index.mjs +287 -0
  33. package/cli/protection.mjs +706 -0
  34. package/cli/reconcile.mjs +38 -12
  35. package/cli/repo-publish.mjs +24 -26
  36. package/cli/repo.mjs +23 -14
  37. package/cli/report.mjs +21 -15
  38. package/cli/review.mjs +24 -27
  39. package/cli/riskmap-command.mjs +289 -0
  40. package/cli/riskmap.mjs +373 -0
  41. package/cli/setup.mjs +139 -287
  42. package/cli/ship.mjs +7 -6
  43. package/cli/skill.mjs +180 -0
  44. package/cli/skip.mjs +211 -30
  45. package/cli/thread.mjs +42 -17
  46. package/cli/tidy.mjs +20 -20
  47. package/cli/update-commit.mjs +22 -22
  48. package/cli/usage.mjs +115 -109
  49. package/package.json +3 -3
  50. package/skills/sdlc/config.yaml +166 -87
  51. package/skills/sdlc/module-help.csv +35 -35
  52. package/skills/yad-analysis/SKILL.md +125 -65
  53. package/skills/yad-architecture/SKILL.md +34 -23
  54. package/skills/yad-architecture/references/contract-format.md +10 -8
  55. package/skills/yad-backfill/SKILL.md +14 -8
  56. package/skills/yad-backfill/references/backfill.md +1 -1
  57. package/skills/yad-change/SKILL.md +127 -52
  58. package/skills/yad-change/references/triage.md +42 -28
  59. package/skills/yad-checks/SKILL.md +89 -45
  60. package/skills/yad-checks/references/check-gates.md +315 -92
  61. package/skills/yad-checks/templates/checks/build-test-lint.sh +25 -7
  62. package/skills/yad-checks/templates/checks/commit-message.sh +17 -3
  63. package/skills/yad-checks/templates/checks/contract-check.sh +58 -2
  64. package/skills/yad-checks/templates/checks/epic-open.sh +3 -3
  65. package/skills/yad-checks/templates/checks/install-deps.sh +46 -0
  66. package/skills/yad-checks/templates/checks/ledger-guard.sh +94 -18
  67. package/skills/yad-checks/templates/checks/lineage-check.sh +23 -9
  68. package/skills/yad-checks/templates/checks/package-manager.sh +140 -0
  69. package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +4 -4
  70. package/skills/yad-checks/templates/checks/risk-map-check.sh +438 -0
  71. package/skills/yad-checks/templates/checks/verified-commits.sh +20 -46
  72. package/skills/yad-checks/templates/github/yad-checks.yml +37 -5
  73. package/skills/yad-checks/templates/github/yad-hub-checks.yml +5 -5
  74. package/skills/yad-checks/templates/github/yad-update-guard.yml +3 -4
  75. package/skills/yad-checks/templates/github/yad-verified-commits.yml +4 -4
  76. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +7 -1
  77. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +22 -4
  78. package/skills/yad-checks/templates/gitlab/yad-hub-checks.gitlab-ci.yml +5 -5
  79. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +4 -4
  80. package/skills/yad-checks/templates/hooks/ledger-guard-cursor.sh +91 -0
  81. package/skills/yad-checks/templates/hooks/ledger-guard.sh +38 -7
  82. package/skills/yad-commit/SKILL.md +6 -6
  83. package/skills/yad-connect-design/SKILL.md +6 -6
  84. package/skills/yad-connect-design/references/design-context.md +1 -1
  85. package/skills/yad-connect-design/references/design-registry.md +2 -2
  86. package/skills/yad-connect-docs/SKILL.md +12 -12
  87. package/skills/yad-connect-docs/references/docs-registry.md +1 -1
  88. package/skills/yad-connect-learning/SKILL.md +5 -5
  89. package/skills/yad-connect-learning/references/learning-registry.md +2 -2
  90. package/skills/yad-connect-repos/SKILL.md +92 -54
  91. package/skills/yad-connect-repos/references/code-context.md +6 -6
  92. package/skills/yad-connect-repos/references/hub-config.md +68 -58
  93. package/skills/yad-connect-repos/references/repos-registry.md +10 -9
  94. package/skills/yad-connect-repos/references/risk-map.md +81 -0
  95. package/skills/yad-connect-testing/SKILL.md +6 -6
  96. package/skills/yad-connect-testing/references/testing-context.md +3 -4
  97. package/skills/yad-connect-testing/references/testing-registry.md +2 -2
  98. package/skills/yad-defects/SKILL.md +8 -8
  99. package/skills/yad-discovery/SKILL.md +130 -94
  100. package/skills/yad-discovery/references/discovery-schema.md +23 -7
  101. package/skills/yad-discovery/references/foundation-schema.md +374 -0
  102. package/skills/yad-docs/SKILL.md +16 -11
  103. package/skills/yad-docs/references/data-mapping.md +9 -7
  104. package/skills/yad-docs/templates/app/package-lock.json +3 -3
  105. package/skills/yad-docs-overview/SKILL.md +32 -17
  106. package/skills/yad-docs-overview/references/pipeline-model.md +47 -28
  107. package/skills/yad-docs-sync/SKILL.md +10 -5
  108. package/skills/yad-docs-sync/references/staleness.md +8 -7
  109. package/skills/yad-engineer-review/SKILL.md +88 -24
  110. package/skills/yad-engineer-review/references/ship-and-record.md +25 -16
  111. package/skills/yad-epic/SKILL.md +178 -100
  112. package/skills/yad-epic/references/state-schema.md +626 -117
  113. package/skills/yad-hub-bridge/SKILL.md +66 -48
  114. package/skills/yad-hub-bridge/references/bridge.md +110 -83
  115. package/skills/yad-hub-bridge/references/login-roster.md +163 -70
  116. package/skills/yad-hub-bridge/templates/checks/hub-route.sh +22 -19
  117. package/skills/yad-hub-bridge/templates/github/yad-gate-sync.yml +34 -14
  118. package/skills/yad-hub-bridge/templates/gitlab/gitlab-ci.include-root.yml +2 -2
  119. package/skills/yad-hub-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +22 -12
  120. package/skills/yad-implement/SKILL.md +29 -15
  121. package/skills/yad-implement/references/implement-conventions.md +2 -2
  122. package/skills/yad-learn/SKILL.md +9 -9
  123. package/skills/yad-learn/references/learning-state.md +2 -2
  124. package/skills/yad-open-pr/SKILL.md +64 -29
  125. package/skills/yad-pair-review/SKILL.md +18 -16
  126. package/skills/yad-pair-review/references/session-state.md +4 -4
  127. package/skills/yad-pr-template/SKILL.md +48 -27
  128. package/skills/yad-pr-template/references/risk-routing.md +97 -24
  129. package/skills/yad-pr-template/templates/checks/pr-template.sh +37 -15
  130. package/skills/yad-pr-template/templates/checks/pr-title.sh +27 -13
  131. package/skills/yad-pr-template/templates/checks/risk-route.sh +107 -14
  132. package/skills/yad-pr-template/templates/github/pull_request_template.md +7 -5
  133. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +7 -5
  134. package/skills/yad-pr-template/templates/hub/github/pull_request_template.md +15 -14
  135. package/skills/yad-pr-template/templates/hub/gitlab/merge_request_templates/Default.md +15 -13
  136. package/skills/yad-reconcile/SKILL.md +3 -3
  137. package/skills/yad-report/SKILL.md +5 -5
  138. package/skills/yad-review-companion/SKILL.md +12 -9
  139. package/skills/yad-review-gate/SKILL.md +198 -79
  140. package/skills/yad-review-gate/references/gating.md +230 -54
  141. package/skills/yad-run/SKILL.md +86 -56
  142. package/skills/yad-run/references/run-loop.md +67 -45
  143. package/skills/yad-ship/SKILL.md +18 -14
  144. package/skills/yad-spec/SKILL.md +31 -17
  145. package/skills/yad-spec/references/spec-handoff.md +17 -5
  146. package/skills/yad-status/SKILL.md +114 -56
  147. package/skills/yad-stories/SKILL.md +42 -27
  148. package/skills/yad-stories/references/story-schema.md +10 -9
  149. package/skills/yad-stub/SKILL.md +59 -48
  150. package/skills/yad-sync-repos/SKILL.md +3 -3
  151. package/skills/yad-test-cases/SKILL.md +37 -30
  152. package/skills/yad-test-cases/references/test-cases-schema.md +8 -5
  153. package/skills/yad-timeline/SKILL.md +8 -7
  154. package/skills/yad-ui/SKILL.md +46 -25
  155. package/cli/roster.mjs +0 -164
  156. package/skills/sdlc/install.sh +0 -68
@@ -1,134 +1,170 @@
1
1
  ---
2
2
  name: yad-discovery
3
- description: 'Optional front-zero of the gated SDLC — the once-per-project discovery phase. With the field-expert lenses (analyst + pm), run market research, a competitor study, a feasibility study, and (brownfield) a current-state study, then distil a functional + non-functional requirements list and a phased roadmap (MVP and beyond) into the reserved EP-discovery. Greenfield AND brownfield. Its roadmap.md becomes the menu of features each yad-epic reads. Seeds the EP-discovery state and hands off to the team review gate; never auto-advances. Use when the user says "start the project", "do discovery", "market research / feasibility / roadmap", or "what should we build first".'
3
+ description: 'The Foundation step of the gated SDLC — the Product level, run once per product before any feature epic. With the field-expert lenses (analyst + pm), frame the product and write the Foundation sections into foundation/ — purpose, market (optional), scope (what it is AND what it is not), MVP, roadmap, stack, repos, risks (optional). Greenfield AND brownfield (brownfield reads the connected code). The engine seeds the ledger with `yad foundation new`; this skill authors the sections, then hands off to the team review gate and never auto-advances. Its roadmap.md is the menu of features each yad-epic reads. Use when the user says "start the project", "write the Foundation", "do discovery", "market research / feasibility / roadmap", or "what should we build first".'
4
4
  ---
5
5
 
6
- # SDLC — Project Discovery (optional front-zero, "epic zero")
6
+ # SDLC — Foundation (the Product level)
7
7
 
8
- **Goal:** Produce a human-authored, AI-assisted **project-level discovery set** — the field expert's
9
- requirement-gathering for the whole product — under the reserved `EP-discovery` ("epic zero"), then
10
- hand off to `yad-review-gate`. The output `roadmap.md` is the menu of features; each feature is later
11
- taken into the normal `yad-epic` flow, which reads the roadmap for project context.
8
+ **Goal:** Produce a human-authored, AI-assisted **Foundation** for the whole product under
9
+ `{project-root}/foundation/`, then hand off to `yad-review-gate`. The Foundation says why the product
10
+ exists, what it is and is not, the smallest thing worth shipping, and the rough order after that. Its
11
+ `roadmap.md` is the menu of features; each feature is later taken into the normal `yad-epic` flow,
12
+ which reads it for project context.
12
13
 
13
- This is a **front state**: human-authored with AI assist and **never auto-advances**. It runs **once
14
- per project** and is **optional** — a team that already knows what to build can skip it and start at
15
- `yad-epic`. It supports **both greenfield and brownfield**, and produces a **competitor study in both**.
14
+ **What the Foundation is.** The roadmap (`docs/roadmap-idea-1.md`, Part 1) has two levels. The
15
+ **Product** level runs once per product and holds the Foundation. The **Feature** level runs once per
16
+ epic and walks the six phases. The Foundation has its own gate: one approval before feature work
17
+ begins. That approval is **reported, not enforced** in this release — `yad next` says when feature
18
+ epics are going ahead of an unapproved Foundation, and nothing is blocked.
16
19
 
17
- This skill enforces the build plan's core rules: all state lives in files; IDs are engine-assigned
18
- (the reserved `EP-discovery`, never a typed feature slug); front steps are locked to `human_approve`.
20
+ This is a **Shape step**: human-authored with AI assist and **never auto-advances**. It is
21
+ **optional** — a team that already knows what to build can start at `yad-epic`. It supports **both
22
+ greenfield and brownfield**.
23
+
24
+ The skill keeps its old name, `yad-discovery`. Before E75 it wrote a different set of files under the
25
+ reserved `EP-discovery` epic; that older spelling is still read (see Step 1).
19
26
 
20
27
  ## Conventions
21
28
 
22
29
  - `{project-root}` resolves from the project working directory.
23
- - Discovery artifacts live under `{project-root}/epics/EP-discovery/` (the reserved "epic zero").
24
- - Speak in the configured `communication_language`; write documents in `document_output_language`.
30
+ - The Foundation lives in `{project-root}/foundation/`: its sections directly inside it, its ledger in
31
+ `foundation/.sdlc/`, and its review summaries in `foundation/reviews/`. Its fixed id is
32
+ `EP-foundation` — every `yad` command takes that id.
33
+ - Speak in the `communication_language` set in `{project-root}/.sdlc/config.yaml`; write documents in `document_output_language`.
25
34
 
26
35
  ## On Activation
27
36
 
28
- ### Step 1 — Entry guard (runs once per project)
29
- The id is the reserved `EP-discovery` — never a feature slug. Discovery seeds its state exactly once:
30
- if `{project-root}/epics/EP-discovery/.sdlc/state.json` already exists, **STOP** and point the user at
31
- `yad next EP-discovery` (the phase is in review or done; edit the artifacts in place, don't re-seed).
32
- When no `state.json` exists yet, proceed and seed state in Step 5.
37
+ ### Step 1 — Entry guard (one Foundation per product)
38
+ - If `{project-root}/foundation/.sdlc/state.json` already exists, **STOP** and point the user at
39
+ `yad next EP-foundation`. The Foundation is already seeded; edit its sections in place.
40
+ - If `{project-root}/epics/EP-discovery/.sdlc/state.json` exists, this product already has its Product
41
+ level **in the old spelling**. A product has ONE Foundation, so do not seed a second. **STOP** and tell
42
+ the user:
43
+ - on a **local** ledger, `yad migrate` (preview) then `yad migrate --apply` converts it into
44
+ `foundation/`, keeping its files and approvals;
45
+ - on a **verified** ledger CI owns that ledger and it cannot be moved by hand — keep working in
46
+ `epics/EP-discovery/`, and review it with `yad gate open EP-discovery discovery/`.
33
47
 
34
48
  Detect the project mode from `{project-root}/.sdlc/hub.json` `profile.codebase`
35
49
  (`greenfield` | `brownfield`, set by `yad setup`). If absent, ask the user; default `greenfield`.
36
50
 
37
51
  ### Step 2 — Shape with the field-expert lenses (assist: analyst + pm)
38
- Adopt the **analyst** lens (`bmad-agent-analyst`, Mary) and the **pm** lens (`bmad-agent-pm`) to gather
39
- requirements as a domain expert would. Drive the existing BMAD research skills as the assist — they
40
- already exist in this project:
41
- - `bmad-market-research` — market size, segments, demand, trends, positioning.
42
- - `bmad-domain-research` — the problem domain, regulations, and constraints of the field.
43
- - `bmad-product-brief` — personas, value proposition, success metrics.
44
-
45
- Pressure-test: who are the users, what problem, what is the market, **who are the competitors and how
46
- do we differ** (required in BOTH modes), what is feasible, what is the smallest valuable slice (MVP),
47
- and what sequences after it.
48
-
49
- ### Step 2b — Brownfield current-state (make discovery code-aware)
52
+ Adopt the **analyst** lens and the **pm** lens to frame the product as a domain expert would. Research:
53
+ - **Market** — market size, segments, demand, trends, positioning.
54
+ - **Domain** — the problem domain, regulations, and constraints of the field.
55
+ - **Product brief** — the users it serves, the value proposition, success metrics.
56
+
57
+ Pressure-test: who is this for and why does it exist, what does success look like, who else does this
58
+ and why us, **what it is and explicitly what it is not**, what the smallest valuable slice is, what
59
+ sequences after it, what it is built with, and what could kill it.
60
+
61
+ ### Step 2a — Greenfield: write the Foundation with the user, one section at a time
62
+ On a **greenfield** product nothing is built yet, so every section comes from the user's answers. For
63
+ each section, `references/foundation-schema.md` gives the template, the questions to **Ask**, what **a
64
+ good answer** holds, what **the reviewer checks**, and a short example.
65
+
66
+ Work in this order, because each section is the input to the next:
67
+
68
+ 1. `purpose.md` — why it exists, who for, how success is measured.
69
+ 2. `scope.md` — what it is, and at least three things it is **not**.
70
+ 3. `mvp.md` — the smallest set of capabilities that reaches the first success signal.
71
+ 4. `roadmap.md` — Phase 1 is exactly the MVP, one row per feature; later phases in a stated order.
72
+ 5. `stack.md` — for each choice: the decision, the alternatives rejected, and why.
73
+ 6. `repos.md` — the layout and one row per intended repo; they need not exist yet.
74
+ 7. `market.md` and `risks.md` — only if the user wants them. Both are optional.
75
+
76
+ For each section:
77
+ - Ask the questions **one at a time**. Write down the user's answer, not your own guess. When an answer is
78
+ vague ("everyone", "fast", "not bloated"), ask again for something concrete.
79
+ - Draft the section's text, show it to the user, and change it until they agree. Then move to the next
80
+ one. The agreed text is written into `foundation/` in Step 5, once the authoring branch (Step 3) and the
81
+ ledger (Step 4) exist — never onto whatever branch happens to be checked out.
82
+ - Check it against the sections before it: the MVP must not contradict a non-goal in `scope.md`, and
83
+ Phase 1 of the roadmap must match `mvp.md`.
84
+
85
+ Keep examples inside `<!-- comments -->`. A section holding only its headings, comments and an empty table
86
+ is **not written**, and the gate warns about it (Step 5) — but a filled example row counts as content.
87
+
88
+ ### Step 2b — Brownfield: read what already exists
50
89
  Read the registry `{project-root}/.sdlc/repos.json` (`config.yaml` `code_context`). For **every
51
90
  connected repo**, load the lightweight code-map `{project-root}/.sdlc/code-context/<repo>/code-map.md`
52
- and base `current-state.md` on **what already exists** — modules, endpoints, data, gaps — so the
53
- roadmap extends the real system rather than re-proposing it.
91
+ and base `stack.md` and `repos.md` on **what already exists** — languages, frameworks, modules,
92
+ endpoints, data — so the Foundation describes the real system rather than re-proposing it.
54
93
 
55
- - **Greenfield-safe:** if `repos.json` is absent/empty (greenfield), `current-state.md` is a short
56
- "clean slate / assumptions & non-goals" note, and you proceed.
94
+ - **Greenfield-safe:** if `repos.json` is absent or empty, there is nothing to read — write every
95
+ section with the user as in Step 2a, where `stack.md` and `repos.md` record the intended choices, the
96
+ alternatives rejected, and why.
57
97
  - **Staleness:** if a repo's current HEAD (`git -C <path> rev-parse HEAD`) ≠ its registry `syncedHead`,
58
98
  warn and suggest `yad repo refresh <repo>` (a human decision — flag, never auto-refresh).
59
99
  - **Backfill pointer:** for an existing codebase, point the user at `yad-backfill` to capture specs for
60
- already-built features; discovery frames the *forward* roadmap, backfill captures the *current* one.
100
+ already-built features; the Foundation frames the *product*, backfill captures the *features*.
61
101
 
62
102
  ### Step 3 — Open the authoring branch
63
- Open the discovery authoring branch `discovery/EP-discovery` per the shared procedure
103
+ Open the Foundation authoring branch `foundation/EP-foundation` per the shared procedure
64
104
  (`../yad-epic/references/state-schema.md` → "Authoring branches"): git-safe (skip with a note if
65
105
  `{project-root}` is not a git work tree), check out the branch if it exists, else create it from the
66
- hub's default branch. Author and commit the discovery set on it. Distinct from the bridge's
67
- `review/EP-discovery/discovery` branch.
68
-
69
- ### Step 4 — Write the discovery set
70
- Write these files under `{project-root}/epics/EP-discovery/`. Each is a normal Markdown artifact; the
71
- gate binds to the **whole set** (editing any one revokes approvals). `roadmap.md` summarises and links
72
- the others and is the spine of the review.
73
-
74
- - `market-research.md` — market, segments, demand, trends (assist: `bmad-market-research`).
75
- - `competitor-analysis.md` — competitors, capabilities, gaps, our differentiation (**both modes**).
76
- - `current-state.md` — brownfield: what exists today (Step 2b); greenfield: clean-slate assumptions.
77
- - `feasibility.md` — technical/operational/economic feasibility, risks, viability, go/no-go.
78
- - `requirements.md` — the consolidated requirements list, **functional AND non-functional**, as a
79
- table (see `references/discovery-schema.md`). Functional rows are candidate features (registration,
80
- login, …); non-functional rows are cross-cutting (performance, security, accessibility, i18n …).
81
- - `roadmap.md` — the phased plan with an explicit **MVP** phase, then later phases. Each feature row
82
- carries a proposed `EP-<slug>` id, its target phase, and a `status:` of `planned`
83
- (see `references/discovery-schema.md` for the exact templates).
106
+ Product's default branch. Author and commit the Foundation on it. Distinct from the verified ledger's
107
+ `review/EP-foundation/foundation` branch.
84
108
 
85
- Leave `owner` for the user to set in each frontmatter. Fill the bodies with the user.
109
+ ### Step 4 — Seed the ledger with the engine
110
+ Run:
86
111
 
87
- ### Step 5 — Seed the state machine
88
- Create `{project-root}/epics/EP-discovery/.sdlc/state.json` describing the **2-step** front-zero
89
- sequence, both steps `automation: human_approve` and `locked`, with the `kind: "discovery"` marker the
90
- engine keys off. Use this exact shape (see `references/discovery-schema.md`):
91
-
92
- ```json
93
- {
94
- "epicId": "EP-discovery",
95
- "kind": "discovery",
96
- "createdAt": "<YYYY-MM-DD>",
97
- "currentStep": "discovery-review",
98
- "steps": [
99
- { "id": "discovery", "type": "author", "artifact": "discovery/", "assistance": "review", "automation": "human_approve", "locked": true, "status": "done", "risk_tags": [] },
100
- { "id": "discovery-review", "type": "review+approve", "artifact": "discovery/", "assistance": "review", "automation": "human_approve", "locked": true, "status": "in_review", "risk_tags": [] }
101
- ]
102
- }
112
+ ```
113
+ yad foundation new
103
114
  ```
104
115
 
105
- Notes:
106
- - The review step's artifact is the virtual base `discovery/` — the gate fingerprints the whole
107
- discovery file set (`market-research`, `competitor-analysis`, `current-state`, `feasibility`,
108
- `requirements`, `roadmap`), so editing any of them revokes prior approvals (mirrors `stories/`).
109
- **All six must exist to review:** if any is missing the set is incomplete and non-reviewable (the
110
- hash is `null`) and `yad gate open`/`sync` warn — so write all six (Step 4) before the gate.
111
- - `discovery-review` carries no `risk_tags` — it is the **base** rule (owner + 1 reviewer); discovery
112
- never escalates to domain owners (no contract surface is touched yet).
113
- - Also create an empty approvals ledger `.sdlc/approvals.json` and comments ledger
114
- `.sdlc/comments.json`, each containing `[]`, and the `reviews/` directory.
115
- - Commit the seed on the `discovery/EP-discovery` branch, and cut `review/EP-discovery/discovery` from
116
- it so the **first** review PR/MR carries the ledger to the default branch. In bridge mode
117
- `ledger-guard` exempts a new epic's ledger (creation, not mutation, #162); every later change to it
118
- is CI's. See `../yad-epic/references/state-schema.md`, "Authoring branches".
116
+ That writes `foundation/.sdlc/state.json` with the Foundation's two-step chain (`foundation` →
117
+ `foundation-review`), an empty `approvals.json` and `comments.json`, and the `foundation/reviews/`
118
+ folder. The engine owns that file: do not write or edit it by hand. The command refuses a second
119
+ Foundation and a product still on the old spelling (Step 1 already stopped for both).
120
+
121
+ ### Step 5 — Write the Foundation sections
122
+ Write these files directly in `{project-root}/foundation/`, one per section, using the templates in
123
+ `references/foundation-schema.md` for their headings. The bodies are the text already agreed with the
124
+ user — on greenfield, the sections drafted in Step 2a; on brownfield, what Step 2b read from the
125
+ code-maps. Do not start a section over from its blank template. The gate binds to the **whole set**: editing any section revokes
126
+ approvals. (The frontmatter `status:` line does not count — the gate rewrites it after the review.)
127
+
128
+ | File | Section | Required? |
129
+ |---|---|---|
130
+ | `purpose.md` | Why this exists, who it is for, what success looks like | required |
131
+ | `market.md` | Who else does this, and why us | optional |
132
+ | `scope.md` | What it is — **and explicitly what it is not** | required |
133
+ | `mvp.md` | The smallest thing worth shipping | required |
134
+ | `roadmap.md` | The rough order after the MVP — the menu of feature epics | required |
135
+ | `stack.md` | Languages, frameworks, hosting, databases | required |
136
+ | `repos.md` | How many repos, what each does, monorepo or separate | required |
137
+ | `risks.md` | What could kill this | optional |
138
+
139
+ **All six required sections must exist to review.** Until they do, the Foundation has no fingerprint to
140
+ bind an approval to, and `yad gate open` warns. An optional section counts once it exists — adding or
141
+ removing one after an approval revokes it, like any other edit.
142
+
143
+ **Every section that exists must also be written.** A section that still holds only its template — the
144
+ frontmatter, `#` and `##` headings, comments, `---` dividers and an empty table — makes `yad gate open` and `yad gate sync` warn
145
+ `Foundation not written yet`, and once the review has opened or passed `yad doctor` reports it as
146
+ `foundation:unwritten`. These are warnings, not refusals: finish the section before asking for review.
147
+
148
+ Leave `owner` for the user to set in each frontmatter. Fill the bodies with the user.
119
149
 
120
150
  ### Step 6 — Stop at the gate (do NOT advance)
121
- Report: the path to the discovery set, and that the next action is **review** via `yad-review-gate`
122
- (base rule: owner + 1 reviewer) on the virtual artifact `discovery/`. **Never mark discovery-review
123
- approved here** — only real reviewers do that through the gate. When the discovery gate passes, the
124
- state moves to the `discovery-done` sentinel (not `ready-for-build` — discovery has no build half); the
125
- roadmap is now the input that each `yad-epic` reads (its "Step 2c — read the roadmap"). When the hub
126
- has a platform, the gate opens a review PR on the hub (via `yad-hub-bridge`) and
127
- `yad-review-gate action: sync` pulls platform approvals/comments into the ledger; otherwise the review
128
- is recorded file-only.
151
+ Report the path to the Foundation, and that the next action is **review** via `yad-review-gate`:
152
+
153
+ ```
154
+ yad gate open EP-foundation foundation/
155
+ ```
156
+
157
+ **Never mark `foundation-review` approved here** — only real reviewers do that through the gate. When
158
+ the gate passes, the ledger moves to the `foundation-done` sentinel (not `ready-for-build` — the
159
+ Foundation has no Build). From then on `foundation/roadmap.md` and `foundation/scope.md` are the inputs
160
+ each `yad-epic` reads (its "Step 2c"). When the Product has a platform, the gate opens a review PR on the
161
+ Product (via `yad-hub-bridge`) and `yad-review-gate action: sync` pulls platform approvals and comments
162
+ into the ledger; otherwise the review is recorded locally.
129
163
 
130
164
  ## Reference
131
- - Discovery artifact templates + the 2-step state shape: `references/discovery-schema.md`.
165
+ - Foundation section templates: `references/foundation-schema.md`.
166
+ - The older spelling of the Product level (`EP-discovery`, its six files, and how it converts):
167
+ `references/discovery-schema.md`.
132
168
  - State schema, chain shapes, and the authoring-branch procedure:
133
169
  `../yad-epic/references/state-schema.md`.
134
170
  - The epic step that consumes `roadmap.md`: `../yad-epic/SKILL.md` (Step 2c).
@@ -1,4 +1,17 @@
1
- # Discovery schema — artifacts + the front-zero state shape
1
+ # Discovery schema — the OLD spelling of the Product level
2
+
3
+ > **Since E75 this is the older spelling.** New products get a Foundation in `{project-root}/foundation/`
4
+ > — see `foundation-schema.md`, seeded by `yad foundation new`. This page stays because a product that
5
+ > already has an `EP-discovery` keeps working exactly as described here: the engine still reads it, gates
6
+ > it, and ends its review at `discovery-done`.
7
+ >
8
+ > **Converting it.** On a **local** ledger, `yad migrate --apply` moves `epics/EP-discovery/` into
9
+ > `foundation/`: the six files keep their names (so their fingerprint, and every approval bound to it,
10
+ > is unchanged), the ledger is re-labelled to the Foundation's ids, and the step keeps `artifact:
11
+ > "discovery/"` so the gate still hashes those six files. On a **verified** ledger CI owns the files and
12
+ > the move cannot be made by a human commit, so the gate bot makes it: `yad gate ci` moves the folder at
13
+ > the next merged review it handles, once the product level's own review has passed and the checks
14
+ > committed in the repo know `foundation/`. A product has ONE product level: never seed a Foundation beside an `EP-discovery`.
2
15
 
3
16
  The project discovery phase ("epic zero") lives under `{project-root}/epics/EP-discovery/`. It reuses
4
17
  the per-epic ledger files (`.sdlc/state.json`, `approvals.json`, `comments.json`, `reviews/`,
@@ -15,21 +28,22 @@ object and the 2-step chain.
15
28
  "createdAt": "<YYYY-MM-DD>",
16
29
  "currentStep": "discovery-review",
17
30
  "steps": [
18
- { "id": "discovery", "type": "author", "artifact": "discovery/", "assistance": "review", "automation": "human_approve", "locked": true, "status": "done", "risk_tags": [] },
19
- { "id": "discovery-review", "type": "review+approve", "artifact": "discovery/", "assistance": "review", "automation": "human_approve", "locked": true, "status": "in_review", "risk_tags": [] }
31
+ { "id": "discovery", "type": "author", "artifact": "discovery/", "assistance": "review", "driver": "pair", "automation": "human_approve", "advance": "human", "locked": true, "status": "done", "risk_tags": [] },
32
+ { "id": "discovery-review", "type": "review+approve", "artifact": "discovery/", "assistance": "review", "driver": "pair", "automation": "human_approve", "advance": "human", "locked": true, "status": "in_review", "risk_tags": [] }
20
33
  ]
21
34
  }
22
35
  ```
23
36
 
24
37
  - `artifact: "discovery/"` is a **virtual** base: `artifactHash` fingerprints the whole discovery file
25
38
  set (`discoveryHash` in `cli/epic-state.mjs`), so an edit to any discovery file revokes prior
26
- approvals — exactly like `stories/` fingerprints the stories directory.
39
+ approvals — exactly like `stories/` fingerprints the stories directory. The frontmatter `status:` line
40
+ is left out of each file's fingerprint, so the gate flipping it to `approved` is not an edit.
27
41
  - The **full set is required to review**: if any of the six files is missing, `discoveryHash` returns
28
42
  `null` — the discovery is **incomplete and non-reviewable** (no hash to bind an approval to), and
29
43
  `yad gate open` / `yad gate sync` warn with the missing filenames. Write all six (in greenfield,
30
44
  `current-state.md` is a short clean-slate note) before handing off to the gate.
31
45
  - On approval the gate sets `currentStep: "discovery-done"` (a terminal sentinel — discovery has **no**
32
- build half, so it never becomes `ready-for-build`).
46
+ Build, so it never becomes `ready-for-build`).
33
47
  - The discovery files (relative to the epic dir) the gate commits on the review branch and re-hashes at
34
48
  merge are: `market-research.md`, `competitor-analysis.md`, `current-state.md`, `feasibility.md`,
35
49
  `requirements.md`, `roadmap.md` (the `DISCOVERY_FILES` list).
@@ -95,8 +109,10 @@ owner:
95
109
  <!-- explicitly deferred, with why -->
96
110
  ```
97
111
 
98
- Per-feature `status:` lifecycle (set by hand): `planned` → `epic-started` (a feature epic has been
99
- seeded with `yad-epic`) → `shipped`. The proposed `EP-<slug>` ids are suggestions for the eventual
112
+ **Do not update the `Status` column by hand.** Editing the roadmap after its review has passed makes the
113
+ approvals read as stale; `yad foundation status` reads each feature's status from the epic ledgers, for
114
+ this spelling too. (The column's old hand-set ladder was `planned` → `epic-started` → `shipped`; rows that
115
+ already say so can stay.) The proposed `EP-<slug>` ids are suggestions for the eventual
100
116
  `yad-epic` runs — `yad-epic` still assigns the id (and skips the reserved `EP-discovery`).
101
117
 
102
118
  The other four artifacts (`market-research.md`, `competitor-analysis.md`, `current-state.md`,