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
  # Testing registry — schema + freshness rule
2
2
 
3
- The registry is the product hub's record of which testing tool is connected and how to reach it. It is
3
+ The registry is the Product's record of which testing tool is connected and how to reach it. It is
4
4
  **project-wide** (one testing tool per project, shared across every epic), so it lives at the product
5
5
  root, not under any `epics/EP-<slug>/.sdlc/`.
6
6
 
@@ -50,6 +50,6 @@ only). This mirrors how `repos.json`, `hub.json`, and `design.json` are committe
50
50
 
51
51
  ## Greenfield
52
52
 
53
- A brand-new product hub has no `testing.json`. That is valid — `yad-test-cases` treats "no testing tool
53
+ A brand-new Product has no `testing.json`. That is valid — `yad-test-cases` treats "no testing tool
54
54
  connected" the same as `tool: "none"` and produces the Markdown test-case artifact only. The registry
55
55
  appears the first time `connect` runs.
@@ -1,21 +1,21 @@
1
1
  ---
2
2
  name: yad-defects
3
- description: 'Phase 6 output enrichment (never a gate) — the quality-gap report. Generates a per-epic AND per-thread defect/bug report (the vendored React/Vite/Tailwind shell HTML + a DEFECTS.md) that aggregates every kind:defect change-epic + each change.json defect block + shipped regressions in the build ledger (the folded build-log.json unioned with every build-log/ shard) BY escape_stage (the SDLC gate that should have caught the defect) and root_cause, and visualizes WHERE quality gaps systematically come from — e.g. "% of this feature''s defects that escaped at the test-cases gate" — so the team hardens the originating stage instead of just fixing symptoms. Degrades to markdown-only when no docs target is connected. Use when the user says "show the defect report", "where are our quality gaps", "generate the bug report for this epic", or "which gate is leaking defects".'
3
+ description: 'Phase 6 output enrichment (never a gate) — the quality-gap report. Generates a per-epic AND per-thread defect/bug report (the vendored React/Vite/Tailwind shell HTML + a DEFECTS.md) that aggregates every defect-type change-epic + each change.json defect block + shipped regressions in the build ledger (the folded build-log.json unioned with every build-log/ shard) BY escape_stage (the SDLC gate that should have caught the defect) and root_cause, and visualizes WHERE quality gaps systematically come from — e.g. "% of this feature''s defects that escaped at the test-cases gate" — so the team hardens the originating stage instead of just fixing symptoms. Degrades to markdown-only when no docs target is connected. Use when the user says "show the defect report", "where are our quality gaps", "generate the bug report for this epic", or "which gate is leaking defects".'
4
4
  ---
5
5
 
6
6
  # SDLC — Quality-Gap Report (Phase 6, output enrichment)
7
7
 
8
8
  **Goal:** Turn the thread's defects into a **systemic quality signal**. Because every defect is a
9
- first-class `kind: defect` change-epic carrying an `escape_stage` (the gate that *should* have caught it)
9
+ first-class `defect`-type change-epic carrying an `escape_stage` (the gate that *should* have caught it)
10
10
  and a `root_cause`, this report can show not just *what* broke but *where the SDLC let it through* — so
11
11
  the team fixes the originating stage (weak test design, an under-specified story, a missed architecture
12
12
  risk), not just the symptom. It is an **output enrichment**, exactly like `yad-docs` — **never a gate**.
13
13
 
14
14
  ## Conventions
15
15
 
16
- - `{project-root}` resolves from the product hub.
16
+ - `{project-root}` resolves from the Product.
17
17
  - Reuses the **`yad-docs` shell** verbatim (`../yad-docs/templates/app/`) — generated `src/data/*.ts`,
18
- themed, deployed via `yad docs deploy`; build-only / markdown-only when no docs target.
18
+ themed; build-only / markdown-only (`yad docs deploy` does not build `defects-site/` yet).
19
19
  - Per **epic** (one epic's defects) and per **thread** (the whole feature; the thread report lives under
20
20
  the genesis epic, since `thread == genesis id`). The thread is derived from `parent:` frontmatter.
21
21
  - Deterministic generation, like `yad-docs` (stable sort, fixed key order, no timestamps in data).
@@ -30,7 +30,7 @@ risk), not just the symptom. It is an **output enrichment**, exactly like `yad-d
30
30
 
31
31
  ### Step 1 — Collect the defects
32
32
  Resolve the scope (`yad thread <id> --json` for a thread). Collect, across the scoped epic(s):
33
- - every `kind: defect` (and `kind: hotfix`) change-epic + its `.sdlc/change.json` `defect` block
33
+ - every `defect` (and `hotfix`) type change-epic + its `.sdlc/change.json` `defect` block
34
34
  (`origin`, `severity`, `escape_stage`, `root_cause`);
35
35
  - the shipped regression fixes from each epic's build ledger (the fix that closed the defect, linking
36
36
  the change-epic → its regression story/test);
@@ -66,8 +66,8 @@ Generate the site into `epics/<scope>/defects-site/` with sections:
66
66
  5. **Severity & age.**
67
67
  6. **Recommendations** — which originating stage to harden, derived from the top escape-stages.
68
68
 
69
- Also write a plain `epics/<scope>/DEFECTS.md` mirror. On `action: deploy`, `yad docs deploy` the site
70
- (build-only when no target).
69
+ Also write a plain `epics/<scope>/DEFECTS.md` mirror. On `action: deploy`, note that
70
+ `yad docs deploy` does not build this folder yet (it builds only the epic `docs-site/` and the overview) — build it with `npm ci` (or `npm install` when it has no lockfile) and `npm run build` inside the folder, and report it as build-only; a failed npm build is reported as a failure, never as a deploy.
71
71
 
72
72
  ## Hard rules
73
73
 
@@ -1,134 +1,171 @@
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 **Shape step**: 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); Shape 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 verified ledger'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 the Foundation on it, and end the step with `yad fold EP-foundation foundation` — the one commit the
107
+ step keeps (E44). Distinct from the verified ledger's
108
+ `review/EP-foundation/foundation` branch.
84
109
 
85
- Leave `owner` for the user to set in each frontmatter. Fill the bodies with the user.
110
+ ### Step 4 — Seed the ledger with the engine
111
+ Run:
86
112
 
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
- }
113
+ ```
114
+ yad foundation new
103
115
  ```
104
116
 
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 verified 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".
117
+ That writes `foundation/.sdlc/state.json` with the Foundation's two-step chain (`foundation` →
118
+ `foundation-review`), an empty `approvals.json` and `comments.json`, and the `foundation/reviews/`
119
+ folder. The engine owns that file: do not write or edit it by hand. The command refuses a second
120
+ Foundation and a product still on the old spelling (Step 1 already stopped for both).
121
+
122
+ ### Step 5 — Write the Foundation sections
123
+ Write these files directly in `{project-root}/foundation/`, one per section, using the templates in
124
+ `references/foundation-schema.md` for their headings. The bodies are the text already agreed with the
125
+ user — on greenfield, the sections drafted in Step 2a; on brownfield, what Step 2b read from the
126
+ code-maps. Do not start a section over from its blank template. The gate binds to the **whole set**: editing any section revokes
127
+ approvals. (The frontmatter `status:` line does not count — the gate rewrites it after the review.)
128
+
129
+ | File | Section | Required? |
130
+ |---|---|---|
131
+ | `purpose.md` | Why this exists, who it is for, what success looks like | required |
132
+ | `market.md` | Who else does this, and why us | optional |
133
+ | `scope.md` | What it is — **and explicitly what it is not** | required |
134
+ | `mvp.md` | The smallest thing worth shipping | required |
135
+ | `roadmap.md` | The rough order after the MVP — the menu of feature epics | required |
136
+ | `stack.md` | Languages, frameworks, hosting, databases | required |
137
+ | `repos.md` | How many repos, what each does, monorepo or separate | required |
138
+ | `risks.md` | What could kill this | optional |
139
+
140
+ **All six required sections must exist to review.** Until they do, the Foundation has no fingerprint to
141
+ bind an approval to, and `yad gate open` warns. An optional section counts once it exists — adding or
142
+ removing one after an approval revokes it, like any other edit.
143
+
144
+ **Every section that exists must also be written.** A section that still holds only its template — the
145
+ frontmatter, `#` and `##` headings, comments, `---` dividers and an empty table — makes `yad gate open` and `yad gate sync` warn
146
+ `Foundation not written yet`, and once the review has opened or passed `yad doctor` reports it as
147
+ `foundation:unwritten`. These are warnings, not refusals: finish the section before asking for review.
148
+
149
+ Leave `owner` for the user to set in each frontmatter. Fill the bodies with the user.
119
150
 
120
151
  ### 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); 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 local.
152
+ Report the path to the Foundation, and that the next action is **review** via `yad-review-gate`:
153
+
154
+ ```
155
+ yad gate open EP-foundation foundation/
156
+ ```
157
+
158
+ **Never mark `foundation-review` approved here** — only real reviewers do that through the gate. When
159
+ the gate passes, the ledger moves to the `foundation-done` sentinel (not `ready-for-build` — the
160
+ Foundation has no Build). From then on `foundation/roadmap.md` and `foundation/scope.md` are the inputs
161
+ each `yad-epic` reads (its "Step 2c"). When the Product has a platform, the gate opens a review PR on the
162
+ Product (via `yad-hub-bridge`) and `yad-review-gate action: sync` pulls platform approvals and comments
163
+ into the ledger; otherwise the review is recorded locally.
129
164
 
130
165
  ## Reference
131
- - Discovery artifact templates + the 2-step state shape: `references/discovery-schema.md`.
166
+ - Foundation section templates: `references/foundation-schema.md`.
167
+ - The older spelling of the Product level (`EP-discovery`, its six files, and how it converts):
168
+ `references/discovery-schema.md`.
132
169
  - State schema, chain shapes, and the authoring-branch procedure:
133
170
  `../yad-epic/references/state-schema.md`.
134
171
  - 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,15 +28,16 @@ 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,
@@ -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`,