From 1112e2b313f4cfd69fbe82b1b24cb8b25a842d93 Mon Sep 17 00:00:00 2001 From: John Lianoglou Date: Sun, 29 Nov 2026 16:50:54 -0500 Subject: [PATCH 01/15] feat(product-development): add idea and shaping stages and the glossary (#49) Adds the ideas/, shaping/ and features/ stages with per-stage AGENTS.md and authority rules, scopes the Foundation Gate to PRD drafting, adds the Promotion step (merge ratifies), idea discovery and spikes with the decision ledger, the CONTEXT.md glossary and root CONTEXT-MAP.md, renames the phase-* references to workflow names, ADR 0001 (stage directories carry authority), generic shared-calendar examples, and atomic no-overwrite scaffolding in init.sh. Refs #36, #35 --- CONTEXT-MAP.md | 11 + .../0001-stage-directories-carry-authority.md | 16 + docs/development.md | 16 +- ...-25-product-vision-resource-integration.md | 8 +- ...oduct-constitution-workflow-integration.md | 14 +- ...26-05-25-product-vision-resource-design.md | 2 +- ...26-product-constitution-workflow-design.md | 6 +- plugins/product-development/README.md | 46 +- .../skills/product-development/CONTEXT.md | 173 +++++++ .../skills/product-development/SKILL.md | 138 ++++-- .../product-development/docs/METHODOLOGY.md | 42 +- ...{phase-4-scenarios.md => bdd-scenarios.md} | 79 +-- .../references/idea-discovery-and-spikes.md | 81 +++ .../references/initialization.md | 22 +- .../references/product-constitution.md | 2 +- .../references/product-vision.md | 2 +- ...hase-2-requirements.md => requirements.md} | 22 +- ...hase-3-user-stories.md => user-stories.md} | 22 +- .../product-development/scripts/init.sh | 68 ++- .../templates/AGENTS.md.tmpl | 29 +- .../templates/README.md.tmpl | 37 +- .../templates/features/AGENTS.md.tmpl | 22 + .../templates/ideas/AGENTS.md.tmpl | 22 + .../templates/shaping/AGENTS.md.tmpl | 24 + .../product-development/tests/init.bats | 463 +++++++++++++++++- 25 files changed, 1153 insertions(+), 214 deletions(-) create mode 100644 CONTEXT-MAP.md create mode 100644 docs/adr/0001-stage-directories-carry-authority.md create mode 100644 plugins/product-development/skills/product-development/CONTEXT.md rename plugins/product-development/skills/product-development/references/{phase-4-scenarios.md => bdd-scenarios.md} (59%) create mode 100644 plugins/product-development/skills/product-development/references/idea-discovery-and-spikes.md rename plugins/product-development/skills/product-development/references/{phase-2-requirements.md => requirements.md} (81%) rename plugins/product-development/skills/product-development/references/{phase-3-user-stories.md => user-stories.md} (72%) create mode 100644 plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/ideas/AGENTS.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl diff --git a/CONTEXT-MAP.md b/CONTEXT-MAP.md new file mode 100644 index 0000000..3d40786 --- /dev/null +++ b/CONTEXT-MAP.md @@ -0,0 +1,11 @@ +# Context Map + +Each plugin that defines its own domain language keeps a `CONTEXT.md` beside its skill. This map lists them. + +## Contexts + +- [Product Development](./plugins/product-development/skills/product-development/CONTEXT.md): how a product's intent is written down, approved, changed and kept true, from foundation documents through feature specs + +## Relationships + +None yet. Add a relationship when one context's terms depend on another's. diff --git a/docs/adr/0001-stage-directories-carry-authority.md b/docs/adr/0001-stage-directories-carry-authority.md new file mode 100644 index 0000000..1f8f6e3 --- /dev/null +++ b/docs/adr/0001-stage-directories-carry-authority.md @@ -0,0 +1,16 @@ +# Stage directories carry authority + +The product-development skill files product documents into three stages, `ideas/`, `shaping/` and `features/`, and a document's stage, the authority it carries, comes from the directory it sits in, not from a status field. A status field drifts once code ships unless someone remembers to update it; a path moves in the same pull request as the work, so an agent reading the tree always sees the authority a document has. + +The path settles authority, not every lifecycle state. Some change states also depend on recorded events. Merging the promotion PR marks a change Ratified. The project's ship signal, recorded in the feature log, marks it Shipped. Ratified and Shipped share a path, so a reader tells them apart by those records, not by the directory. + +## Considered options + +- **A `status:` field in front matter.** Rejected: nothing forces it to change when the work moves on, and agents trust whatever it says. A spec marked approved, or a draft never marked approved, misleads every later reader. +- **One directory with a tag per maturity level.** Rejected for the same drift risk, and because agents would have to read every document to learn which ones carry requirements. With stage directories, an `AGENTS.md` per stage tells agents when to read it and when to stay out. + +## Consequences + +- Promotion is a move. Merging a change's promotion PR ratifies it and moves it into `features/`; the merge is the approval record. +- Code alone never admits a spec to `features/`. Behavior found only in code enters through `shaping/` or `ideas/` and is ratified like any other change. +- The Foundation Gate blocks drafting a PRD, not ideas or shaping, so early intent has a home before the foundation documents exist. diff --git a/docs/development.md b/docs/development.md index 7414e4a..d30ac60 100644 --- a/docs/development.md +++ b/docs/development.md @@ -91,9 +91,15 @@ The init script scaffolds `docs/product/` from templates: | --- | --- | | `docs/product/README.md` | Three-tier documentation hierarchy, artifact flow diagram, boundary rule for scenario placement, directory structure reference | | `docs/product/AGENTS.md` | Agent guidance for organizing product docs, feature workflow checklist, specification evolution conventions | -| `docs/product/features/` | Empty directory ready for the first feature | +| `docs/product/ideas/AGENTS.md` | `ideas/` stage guidance: no requirements authority, read only when named or through idea discovery | +| `docs/product/shaping/AGENTS.md` | `shaping/` stage guidance: tentative context for the change being shaped, promotion rule | +| `docs/product/features/AGENTS.md` | `features/` stage guidance: requirements, admitted only by a merged promotion PR | -Files that already exist are never overwritten. +Files that already exist are never overwritten. Each file renders to a temp +file beside it and is published with a hard link, so a concurrent run or a file +created meanwhile is never replaced, and a failed render leaves nothing behind. +An existing stage directory keeps +its content and gains an `AGENTS.md` only if it has none. The script inspects the target project before prompting: @@ -141,10 +147,12 @@ git diff --check ```text agent-plugins/ ├── README.md +├── CONTEXT-MAP.md ← points to each plugin's glossary (CONTEXT.md) ├── .agents/plugins/marketplace.json ├── .claude-plugin/marketplace.json ├── .github/plugin/marketplace.json ├── docs/ +│ └── adr/ ← architecture decision records ├── tests/marketplace-package.bats └── plugins/ ├── product-development/ @@ -178,5 +186,5 @@ agent-plugins/ ``` Reference files are loaded by the agent only when it enters the corresponding -workflow, keeping context focused. The `phase-*` reference filenames remain for -compatibility. +workflow, keeping context focused. Each reference file is named for its +workflow. diff --git a/docs/superpowers/plans/2026-05-25-product-vision-resource-integration.md b/docs/superpowers/plans/2026-05-25-product-vision-resource-integration.md index 545ac75..f0b3269 100644 --- a/docs/superpowers/plans/2026-05-25-product-vision-resource-integration.md +++ b/docs/superpowers/plans/2026-05-25-product-vision-resource-integration.md @@ -22,7 +22,7 @@ This is a docs and skill-resource change. No runtime feature code is expected. T - Point to `references/product-vision.md`. - Modify `skills/product-development/references/initialization.md` - Explain post-init Foundation Gate requirement. -- Modify `skills/product-development/references/phase-2-requirements.md` +- Modify `skills/product-development/references/requirements.md` - Legacy compatibility path for the Requirements workflow. - Make approved `docs/product/constitution.md` and approved, versioned `docs/product/vision.md` required before the first PRD. - Add PRD vision alignment checks. @@ -125,7 +125,7 @@ This is a docs and skill-resource change. No runtime feature code is expected. T - Modify: `skills/product-development/SKILL.md` - Modify: `skills/product-development/references/initialization.md` -- Modify: `skills/product-development/references/phase-2-requirements.md` +- Modify: `skills/product-development/references/requirements.md` **Steps:** @@ -191,7 +191,7 @@ This is a docs and skill-resource change. No runtime feature code is expected. T Clarify that vision is not scaffolded because it requires project-specific interrogation. -- [ ] **Step 7: Update `references/phase-2-requirements.md`** +- [ ] **Step 7: Update `references/requirements.md`** Required input list must include: @@ -210,7 +210,7 @@ This is a docs and skill-resource change. No runtime feature code is expected. T - [ ] **Step 8: Commit** ```bash - git add skills/product-development/SKILL.md skills/product-development/references/initialization.md skills/product-development/references/phase-2-requirements.md + git add skills/product-development/SKILL.md skills/product-development/references/initialization.md skills/product-development/references/requirements.md git commit -m "docs: require foundation stage before first PRD" ``` diff --git a/docs/superpowers/plans/2026-05-26-product-constitution-workflow-integration.md b/docs/superpowers/plans/2026-05-26-product-constitution-workflow-integration.md index 51a9a5d..90e2be9 100644 --- a/docs/superpowers/plans/2026-05-26-product-constitution-workflow-integration.md +++ b/docs/superpowers/plans/2026-05-26-product-constitution-workflow-integration.md @@ -552,7 +552,7 @@ git commit -m "docs: update initialization foundation guidance" **Files:** -- Modify: `skills/product-development/references/phase-2-requirements.md` +- Modify: `skills/product-development/references/requirements.md` **Goal:** @@ -618,8 +618,8 @@ If this is the first PRD and either foundation document is missing, unapproved, Run: ```bash -rg -n "five constitutional principles|Safety Is Non-Negotiable|Privacy By Default|Local-First Core" skills/product-development/references/phase-2-requirements.md -rg -n "PASS/RISK/FAIL/N/A|FAIL against the constitution|version metadata" skills/product-development/references/phase-2-requirements.md +rg -n "five constitutional principles|Safety Is Non-Negotiable|Privacy By Default|Local-First Core" skills/product-development/references/requirements.md +rg -n "PASS/RISK/FAIL/N/A|FAIL against the constitution|version metadata" skills/product-development/references/requirements.md ``` Expected output: @@ -630,7 +630,7 @@ Expected output: **Commit:** ```bash -git add skills/product-development/references/phase-2-requirements.md +git add skills/product-development/references/requirements.md git commit -m "docs: make constitution alignment dynamic" ``` @@ -643,7 +643,7 @@ git commit -m "docs: make constitution alignment dynamic" - `skills/product-development/references/product-constitution.md` - `skills/product-development/references/product-vision.md` - `skills/product-development/references/initialization.md` - - `skills/product-development/references/phase-2-requirements.md` + - `skills/product-development/references/requirements.md` - `skills/product-development/templates/README.md.tmpl` - `skills/product-development/templates/AGENTS.md.tmpl` - `skills/product-development/scripts/init.sh` @@ -675,7 +675,7 @@ Expected output: both hashes are `cc34e8b2794ade47bb516394755561e60683150124ad21 ```bash rg -n "references/product-constitution.md|source/product-constitution-guide.md|product-constitution-guide.md" skills/product-development/SKILL.md skills/product-development/references/product-constitution.md -rg -n "constitution-grill|future work|five constitutional principles|Safety Is Non-Negotiable" skills/product-development/SKILL.md skills/product-development/references/phase-2-requirements.md +rg -n "constitution-grill|future work|five constitutional principles|Safety Is Non-Negotiable" skills/product-development/SKILL.md skills/product-development/references/requirements.md ``` Expected output: @@ -715,7 +715,7 @@ git add \ skills/product-development/references/source/product-constitution-guide.md \ skills/product-development/references/product-vision.md \ skills/product-development/references/initialization.md \ - skills/product-development/references/phase-2-requirements.md \ + skills/product-development/references/requirements.md \ skills/product-development/templates/README.md.tmpl \ skills/product-development/templates/AGENTS.md.tmpl \ skills/product-development/scripts/init.sh \ diff --git a/docs/superpowers/specs/2026-05-25-product-vision-resource-design.md b/docs/superpowers/specs/2026-05-25-product-vision-resource-design.md index e09fb08..083e80e 100644 --- a/docs/superpowers/specs/2026-05-25-product-vision-resource-design.md +++ b/docs/superpowers/specs/2026-05-25-product-vision-resource-design.md @@ -206,7 +206,7 @@ Update `skills/product-development/references/initialization.md`: - Clarify that vision is produced by grilling, not scaffolding. - Include the `grill-with-docs` recommendation behavior. -Update `skills/product-development/references/phase-2-requirements.md`: +Update `skills/product-development/references/requirements.md`: - Treat this filename as a legacy compatibility path for the Requirements workflow. - Make approved `docs/product/constitution.md` and approved, versioned `docs/product/vision.md` required inputs for the first PRD. diff --git a/docs/superpowers/specs/2026-05-26-product-constitution-workflow-design.md b/docs/superpowers/specs/2026-05-26-product-constitution-workflow-design.md index 2b77d0b..c243df8 100644 --- a/docs/superpowers/specs/2026-05-26-product-constitution-workflow-design.md +++ b/docs/superpowers/specs/2026-05-26-product-constitution-workflow-design.md @@ -182,7 +182,7 @@ Later PRDs must: ## Requirements Guidance -`references/phase-2-requirements.md` currently includes a hard-coded five-principle constitution table. This should become dynamic. +`references/requirements.md` currently includes a hard-coded five-principle constitution table. This should become dynamic. Every PRD should validate against the actual approved `docs/product/constitution.md`: @@ -216,7 +216,7 @@ Before presenting a constitution for approval, reconcile terminology and decisio - `skills/product-development/references/source/product-constitution-guide.md` - `skills/product-development/references/product-vision.md` - `skills/product-development/references/initialization.md` -- `skills/product-development/references/phase-2-requirements.md` +- `skills/product-development/references/requirements.md` - `skills/product-development/templates/README.md.tmpl` - `skills/product-development/templates/AGENTS.md.tmpl` - `skills/product-development/tests/init.bats` @@ -245,7 +245,7 @@ Static checks: - `references/source/product-constitution-guide.md` exists. - `references/source/product-constitution-guide.md` preserves the attached guide substantially as-is; headings and major sections from the source are still present and not condensed into a summary. - No stale language says the Constitution Grill remains future work. -- `references/phase-2-requirements.md` no longer presents hard-coded five principles as normative. +- `references/requirements.md` no longer presents hard-coded five principles as normative. - Foundation Gate wording stays consistent across `SKILL.md`, initialization reference, generated README, generated AGENTS, and requirements reference. - Source archive remains separate from operational reference. diff --git a/plugins/product-development/README.md b/plugins/product-development/README.md index dfc687c..95b350d 100644 --- a/plugins/product-development/README.md +++ b/plugins/product-development/README.md @@ -17,16 +17,25 @@ This plugin guides agents through product artifacts in a deliberate sequence, with human review gates between each workflow: ```text -Project Setup -> Foundation Stage -> Discovery and Design -> Requirements -> User Stories -> BDD Scenarios -> Implementation Planning - | | | | | - Foundation Gate Design Approval PRD/TRD Approval Story Approval Scenario Approval +Project Setup -> Foundation workflow -> Discovery and Design -> Requirements -> User Stories -> BDD Scenarios -> Promotion -> Implementation Planning + | | | | | + Design Approval PRD/TRD Approval Story Approval Scenario Approval Ratification + + Foundation Gate ``` -Foundation Stage contains Product Constitution approval and the Product Vision -workflow. Foundation Gate blocks the first PRD until constitution is approved -and versioned, and vision is approved and versioned. Discovery and Design can -still happen before the gate passes. Each approval point pauses for review -before the agent proceeds. +The Foundation workflow contains Product Constitution approval and the Product +Vision workflow. Foundation Gate blocks drafting the first PRD until +constitution is approved and versioned, and vision is approved and versioned. +It does not block ideas or shaping: Discovery and Design can still happen +before the gate passes. Each approval point pauses for review before the agent +proceeds. + +Feature content moves through three stage directories under `docs/product/`. +`ideas/` holds early sketches with no requirements authority. `shaping/` holds +changes being worked out, including draft PRDs and TRDs. `features/` holds +ratified changes and shipped feature specs, which are the requirements. +Merging a change's promotion PR ratifies it and moves it into `features/`. +Code alone never admits a spec. ## Start A Product Workflow @@ -63,14 +72,15 @@ At each gate, you can: | Workflow | Artifact | Location | | --- | --- | --- | | Project Setup | Documentation structure | `docs/product/README.md`, `docs/product/AGENTS.md` | -| Foundation Stage | Constitution | `docs/product/constitution.md`, `docs/product/constitutions/constitution-vX.Y.Z.md` | -| Foundation Stage | Product vision | `docs/product/vision.md`, `docs/product/visions/vision-vX.Y.Z.md` | -| Discovery and Design | Design document | `docs/plans/YYYY-MM-DD--design.md` | -| Requirements | PRD | `docs/product/features/{feature}/PRD.md` | -| Requirements | TRD | `docs/product/features/{feature}/TRD.md` | -| User Stories | User stories | `docs/product/features/{feature}/stories/*.md` | -| BDD Scenarios | Platform scenarios | `docs/product/features/{feature}/scenarios/*.feature` | +| Foundation workflow | Constitution | `docs/product/constitution.md`, `docs/product/constitutions/constitution-vX.Y.Z.md` | +| Foundation workflow | Product vision | `docs/product/vision.md`, `docs/product/visions/vision-vX.Y.Z.md` | +| Discovery and Design | Shaping document | `docs/product/shaping/{feature}/` | +| Requirements | PRD | `docs/product/shaping/{feature}/PRD.md` | +| Requirements | TRD | `docs/product/shaping/{feature}/TRD.md` | +| User Stories | User stories | `docs/product/shaping/{feature}/stories/*.md` | +| BDD Scenarios | Platform scenarios | `docs/product/shaping/{feature}/scenarios/*.feature` | | BDD Scenarios | Surface scenarios | `apps/{surface}/docs/features/{feature}/scenarios/*.feature` | +| Promotion | Ratified change | `docs/product/features/{feature}/` | | Implementation Planning | Implementation plan | `docs/plans/YYYY-MM-DD-.md` | Platform-level artifacts describe what the product does regardless of which app @@ -131,8 +141,10 @@ All TRDs must follow the vendor-agnostic facade pattern. Product specs are living artifacts: -- PRDs and TRDs are updated in place with a changelog recording date, change, - and rationale. +- PRDs and TRDs keep a changelog recording date, change, and rationale. +- A change to requirements, stories or scenarios is drafted in `shaping/` and + ratified by a promotion PR, like a new feature. Only edits that don't change + meaning (typos, links, clarifications) go directly into ratified documents. - User stories progress through a lifecycle from Draft to Ready to In Progress to Done to Archived. - BDD scenarios are living and self-verifying; when behavior changes, scenarios diff --git a/plugins/product-development/skills/product-development/CONTEXT.md b/plugins/product-development/skills/product-development/CONTEXT.md new file mode 100644 index 0000000..833facd --- /dev/null +++ b/plugins/product-development/skills/product-development/CONTEXT.md @@ -0,0 +1,173 @@ +# Product Development + +How a product's intent is written down, approved, changed and kept true as the product evolves, from foundation documents through feature specs. + +## Language + +### Foundation + +**Foundation documents**: +The approved, versioned constitution and vision that every feature must align with. +_Avoid_: Anchor docs + +**Foundation Gate**: +The check that approved, versioned foundation documents exist before a PRD is drafted. +_Avoid_: Foundation Stage + +**Alignment check**: +A PRD's assessment against the constitution's principles and the approved vision. + +**Amendment**: +A versioned change to a foundation document. + +### Stages and early work + +**Stage**: +A category of authority for product documents, shown by the directory a document sits in: `ideas/`, `shaping/` or `features/`. +_Avoid_: Phase, maturity + +**Idea**: +An early sketch that nobody is shaping yet. It has no requirements authority. +_Avoid_: Seedling, backlog item + +**Idea discovery**: +A scoped subagent search of ideas for any that bear on an upcoming design or plan. + +**Shaping document**: +The tentative design of a change while it is worked out. ADRs and contracts it links keep their own authority. +_Avoid_: Shaping spec, draft spec + +**Spike**: +A disposable prototype that answers a shaping question. Its code never admits a spec. + +**Decision ledger**: +An append-only record of the decisions an agent makes during an unattended spike, kept for the maintainer's review. When the spike ends, every entry is absorbed into a lasting document before the ledger is deleted. + +**Open question**: +An unchecked assumption or an undecided choice, recorded in the one document it concerns, together with what it blocks and how it will be resolved. +_Avoid_: TBD, unknown + +**Blocking level**: +What an open question holds back: `design` (ratification), `implementation` (handoff), `release` (shipping or a delivery-plan step) or `none yet`. + +**Delivery plan**: +The product's intended order of what ships, with the conditions each step must meet. It holds no tasks or owners. +_Avoid_: Implementation plan, release plan + +### Features + +**Feature**: +A product capability with a stable ID. +_Avoid_: Direction, epic + +**Feature bundle**: +The directory, inside the product's OKF bundle at `docs/product/`, that holds everything about one feature: its spec, changes, stories, scenarios and log. +_Avoid_: Feature folder + +**Feature spec**: +The current-state documents of a feature bundle, describing the feature's shipped behavior. +_Avoid_: Living spec, PRD + +**Feature overview**: +The document that opens a feature spec, summarizes the feature and links to its facet specs. +_Avoid_: Entry document, main spec + +**Facet spec**: +A current-state document that covers one face of a feature, such as one user type, workflow or contract. +_Avoid_: Seam document, spec fragment, spec slice + +**Spec unit**: +An independently changeable section of a feature spec with its own stable ID. Examples: `FR-12` invitation expiry, `NFR-03` invite acceptance latency, `MEM-02` membership status transitions, and a whole scenario file such as `accept-invitation.feature`. +_Avoid_: Requirement block + +**Feature tag**: +A code comment that names the feature a file or declaration implements, by stable ID. + +**Feature path convention**: +Placing files that cannot carry comments under a path segment named for their feature's ID. + +### Changes + +**Change**: +A bounded addition to or revision of a feature, including its first version, described by a PRD, a TRD and deltas. +_Avoid_: Amendment, change proposal, evolution + +**Change state**: +A change's position in its lifecycle: Idea, Shaping, In review, Ratified, Shipped, Canonized or Dropped. +_Avoid_: Status (that is OKF's readiness field) + +**Ratification**: +The maintainer's approval of a change, recorded by merging its promotion PR. +_Avoid_: Sign-off + +**Promotion PR**: +The pull request whose merge ratifies a change and admits it to its feature bundle. + +**Delta**: +An explicit set of spec units that a change adds, modifies or removes. +_Avoid_: Patch, diff + +**Base text**: +The content of a spec unit recorded when a delta modifies or removes it. + +**Overlap check**: +A check that finds concurrent changes targeting the same spec units, so the maintainer can sequence or combine them. + +**Base check**: +A check that finds drift between a delta's base text and the current feature spec, so the delta can be rebased before canonization. + +**Shipped**: +The change state reached when a change meets the project's definition of live. The change still sits in `changes//`; the project's ship signal, not the path, marks this state. It triggers canonization. +_Avoid_: Reconciled, delivered, implemented + +**Ship signal**: +The event a project names as making a change live, such as the implementation PR merging, a release, or a feature flag reaching everyone. It marks a change Shipped and triggers canonization. +_Avoid_: Release, launch, go-live (each project's word for the event varies; this names its role) + +**Canonization**: +Making a shipped change part of the feature spec: accounting for each requirement and scenario as shipped, changed or deferred, applying its deltas, archiving the change and logging the outcome. +_Avoid_: Fold, reconcile, assimilate, apply + +**Canonized**: +The change state of a change whose deltas are in the feature spec. The change sits in the change archive. + +**Dropped**: +The change state of a change withdrawn before it shipped, removed and logged in the lineage log with a reason. + +**Change archive**: +The record of a feature's canonized changes, kept as history. + +### Logs + +**Feature log**: +One feature's dated history and the reasons behind each change. +_Avoid_: Changelog, history section + +**Lineage log**: +The product-wide record of feature splits, merges and drops, dropped changes, and promotion PRs closed without merging, with reasons. + +### Delivery boundary + +**Handoff**: +What a ratified change gives the implementation workflow: the change, its stories and scenarios, the affected feature spec, the foundation documents, the project's ship signal and any open release-level questions. It is drafted at ratification and sent once no implementation-level question remains open. + +### Adoption + +**Modernization**: +Converting specs written with an earlier version of this skill into feature bundles, separating shipped behavior, approved unbuilt work and drafts. +_Avoid_: Migration, upgrade + +**Retrofit**: +Discovering a codebase's features from the maintainer's account and repo evidence, then seeding ideas and shaping documents. +_Avoid_: Onboarding, backfill + +**Feature inventory**: +The maintainer-approved list of features a retrofit produces, routing each one to modernization, shaping or ideas. It is discarded once its features are seeded. +_Avoid_: Feature map + +**Feature lens**: +One strategy for finding feature evidence in a codebase, such as the domain model, screens and flows, or commit history. +_Avoid_: Survey angle + +**Artifact retirement**: +Removing a legacy spec artifact, with the maintainer's approval, once its durable content lives elsewhere: in a feature spec for specs of shipped behavior, or in a shaping document, ADR or log for plans and design docs. diff --git a/plugins/product-development/skills/product-development/SKILL.md b/plugins/product-development/skills/product-development/SKILL.md index 278dbb5..681734b 100644 --- a/plugins/product-development/skills/product-development/SKILL.md +++ b/plugins/product-development/skills/product-development/SKILL.md @@ -1,56 +1,85 @@ --- name: product-development -description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, plan implementation, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." +description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, capture an idea, shape a change, run a spike, promote a change, plan implementation, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." --- # Product Development Lifecycle Guide features through the product development lifecycle from idea to implementation plan. Each workflow produces specific artifacts that feed into the next. Workflow transitions are gated by human review, with optional automated review passes. +The skill's glossary is [CONTEXT.md](CONTEXT.md). Use its terms exactly, in conversation and in the documents you write. A word listed under _Avoid_ must not be used as a name for that entry's concept; it stays correct when it names something else, such as the PRD or an implementation plan. + ## Lifecycle Map ``` [Project Setup] ← one-time setup (scripts/init.sh) ↓ -Foundation Stage +Foundation workflow ├─ Product Constitution approval ├─ Product Vision workflow (Vision Grill) ├─ additional product-anchor workflows (planned extension point) └─ Foundation Gate: approved, versioned constitution + approved, versioned vision before first PRD ↓ -Discovery and Design +Discovery and Design ← idea discovery first; design saved in shaping/ ↓ [human approves design] -Requirements +Requirements ← drafted in shaping/, after the Foundation Gate ├─ PRD [human approves before TRD] └─ TRD [human approves PRD + TRD] → optional review pass ↓ -User Stories +User Stories ← drafted in shaping/ ↓ [human approves stories] → optional review pass -BDD Scenarios +BDD Scenarios ← drafted in shaping/ ↓ [human approves scenarios] → optional review pass -Implementation Planning +Promotion ← promotion PR moves the change into features/ + ↓ [maintainer merges = ratification] +Implementation Planning ← idea discovery first; plans from features/ ``` -Foundation Stage does not block brainstorming or design exploration. Foundation Gate blocks creation of the first PRD. Later PRDs must check constitution and vision alignment before proceeding. +The Foundation Gate blocks drafting a PRD, not ideas or shaping. The default order is still to establish the foundation documents first. Later PRDs must check constitution and vision alignment before proceeding. + +## Stages + +A stage is a category of authority for product documents, shown by the directory a document sits in. Read a document's authority from its path, never from a status field. + +| Stage | Holds | Agents treat it as | +|-------|-------|--------------------| +| `docs/product/ideas/` | Early sketches nobody is shaping yet | No requirements authority. Read an idea only when the task names it, or through idea discovery. | +| `docs/product/shaping/` | Changes being worked out: shaping documents and draft PRDs, TRDs, stories and scenarios | Tentative context for work on that feature. ADRs and contracts that a shaping document links keep their own authority. | +| `docs/product/features/` | Ratified changes and shipped feature specs | Requirements | + +Rules: + +- The maintainer moves an idea to `shaping/` when they start shaping it. +- The Foundation Gate blocks drafting a PRD, not ideas or shaping. +- A PRD is drafted in `shaping/`. Merging the change's promotion PR ratifies the change and moves it into `features/`. +- Code alone never admits a spec to `features/`. Behavior that exists only in code enters through `shaping/` or `ideas/`. +- Each stage directory has an `AGENTS.md` that says when agents read it and when they stay out. + +Before a design or plan, run idea discovery: a subagent reads `ideas/` and reports any idea that enables, conflicts with or overlaps the work. Spikes answer shaping questions and keep a decision ledger when run unattended. Consult `references/idea-discovery-and-spikes.md` for both. ## Workflows ### Project Setup -**Trigger:** The project does not yet have a `docs/product/` directory, or the user asks to "initialize product docs" or "set up product documentation." +**Trigger:** The project does not yet have a `docs/product/` directory or is missing one of the scaffold files listed under Output, or the user asks to "initialize product docs" or "set up product documentation." -**Process:** Run the initialization script (`scripts/init.sh`) to scaffold the documentation structure. The script uses templates with placeholders, auto-detects project context (name, surfaces), and prompts the user for domain-specific values. Consult `references/initialization.md` for the full workflow. +**Process:** Run the initialization script (`scripts/init.sh`) to scaffold the documentation structure, including the three stage directories. The script uses templates with placeholders, auto-detects project context (name, surfaces), and prompts the user for domain-specific values. Consult `references/initialization.md` for the full workflow. **Output:** - `docs/product/README.md` — documentation hierarchy and boundary rules - `docs/product/AGENTS.md` — agent guidance for organizing product docs -- `docs/product/features/` — empty directory ready for the first feature +- `docs/product/ideas/AGENTS.md`, `docs/product/shaping/AGENTS.md`, `docs/product/features/AGENTS.md` — the three stage directories, each with its agent guidance + +**This workflow runs once per project.** Skip only when every scaffold file exists: `docs/product/README.md`, `docs/product/AGENTS.md`, `docs/product/ideas/AGENTS.md`, `docs/product/shaping/AGENTS.md` and `docs/product/features/AGENTS.md`. If any is missing, for example after an interrupted run, re-run `scripts/init.sh`. It never overwrites, so it fills only the gaps. -**This workflow runs once per project.** Skip if `docs/product/README.md` already exists. +### Foundation workflow -### Foundation Stage +**Trigger:** Either of two entry points: -**Trigger:** `docs/product/constitution.md` or `docs/product/vision.md` is missing, the user asks to create or update product-anchor docs, or the agent is preparing to start the first feature PRD and must verify Foundation Gate before drafting. +- The user asks to create, update or approve product-anchor docs, such as the constitution or the vision. +- The agent is about to draft a PRD and the Foundation Gate has not passed: `docs/product/constitution.md` or `docs/product/vision.md` is missing, unapproved or unversioned. + +A missing foundation document does not trigger this workflow during ideas, discovery, design or other shaping work. Raise it when PRD drafting is next. **Process:** Establish product-anchor docs in this hierarchy: @@ -61,15 +90,19 @@ Foundation Stage does not block brainstorming or design exploration. Foundation **Output:** Approved, versioned `docs/product/constitution.md`; approved, versioned `docs/product/vision.md`; optional `CONTEXT-MAP.md`, `docs/product/CONTEXT.md`, and ADRs when approved and used. -**Foundation Gate:** Do not create the first PRD until the user approves `docs/product/constitution.md`, it has version metadata, and approved, versioned `docs/product/vision.md` exists. +**Foundation Gate:** Do not draft the first PRD until the user approves `docs/product/constitution.md`, it has version metadata, and approved, versioned `docs/product/vision.md` exists. The gate blocks PRD drafting only: ideas, discovery, design and other shaping work may proceed before it passes. ### Discovery and Design -**Trigger:** An idea, feature request, or problem statement arrives. +**Trigger:** An idea, feature request, or problem statement arrives, or the maintainer moves an idea to `shaping/`. + +**Process:** Run idea discovery first (`references/idea-discovery-and-spikes.md`) and bring its questions to the brainstorming session. Then invoke the `brainstorming` skill. It handles collaborative exploration, approach proposals, and design approval. When a shaping question needs a prototype, run a spike. -**Process:** Invoke the `brainstorming` skill. It handles collaborative exploration, approach proposals, and design approval. +Override the brainstorming skill's own hand-off. It saves its design under `docs/superpowers/specs/` and then invokes `writing-plans`. Here, save the approved design as the change's shaping document in `docs/product/shaping/{feature}/`, then return control to this skill. Do not invoke `writing-plans` or plan implementation before the change is ratified. -**Output:** Approved design document at `docs/plans/YYYY-MM-DD--design.md`. +An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, with no gate. + +**Output:** Approved design, saved as the change's shaping document in `docs/product/shaping/{feature}/`. **Gate:** Do not proceed to Requirements until the design is approved. @@ -79,13 +112,13 @@ Foundation Stage does not block brainstorming or design exploration. Foundation **Required inputs:** Approved design document, approved, versioned `docs/product/constitution.md`, and approved, versioned `docs/product/vision.md`. Missing, unapproved, or unversioned foundation documents block first-PRD requirements work. -**Process:** Create product and technical requirements documents. Consult `references/phase-2-requirements.md` for structure, conventions, constitution alignment, and vision alignment. +**Process:** Create product and technical requirements documents. Consult `references/requirements.md` for structure, conventions, constitution alignment, and vision alignment. **Gate:** The PRD defines *what*; the TRD defines *how*. Present the PRD for human approval before writing the TRD. This prevents wasted architectural work if the requirements shift. **Output:** -- `docs/product/features/{feature}/PRD.md` -- `docs/product/features/{feature}/TRD.md` +- `docs/product/shaping/{feature}/PRD.md` +- `docs/product/shaping/{feature}/TRD.md` **Gate:** Both documents reviewed and approved before proceeding. Run configured review passes (see Configuration). @@ -95,9 +128,9 @@ Foundation Stage does not block brainstorming or design exploration. Foundation **Trigger:** PRD and TRD are reviewed and stable. -**Process:** Decompose PRD requirements into user-facing narratives. Consult `references/phase-3-user-stories.md` for format, sizing guidance, and acceptance criteria conventions. +**Process:** Decompose PRD requirements into user-facing narratives. Consult `references/user-stories.md` for format, sizing guidance, and acceptance criteria conventions. -**Output:** Story files at `docs/product/features/{feature}/stories/`. +**Output:** Story files at `docs/product/shaping/{feature}/stories/`. **Gate:** Stories reviewed and approved. Run configured review passes. @@ -107,21 +140,35 @@ Foundation Stage does not block brainstorming or design exploration. Foundation **Trigger:** User stories have acceptance criteria defined. -**Process:** Express acceptance criteria as Gherkin scenarios. Consult `references/phase-4-scenarios.md` for the boundary rule, file placement, and writing conventions. +**Process:** Express acceptance criteria as Gherkin scenarios. Consult `references/bdd-scenarios.md` for the boundary rule, file placement, and writing conventions. **Output:** -- Platform-level scenarios: `docs/product/features/{feature}/scenarios/*.feature` -- Surface-specific scenarios: `apps/{surface}/docs/features/{feature}/scenarios/*.feature` +- Platform-level scenarios: `docs/product/shaping/{feature}/scenarios/*.feature` +- Surface-specific scenarios: `apps/{surface}/docs/features/{feature}/scenarios/*.feature`, written now, before promotion **Gate:** Scenarios reviewed and approved. Run configured review passes. **Boundary rule:** If the Given/When/Then language is surface-neutral, the scenario is platform-level. If it references a specific interaction model (swipe, D-pad, gaze), it is surface-specific. -### Implementation Planning +### Promotion **Trigger:** Scenarios are reviewed and cover the acceptance criteria. -**Process:** Load the approved constitution and approved vision with the reviewed scenarios, then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. +**Process:** Open a promotion PR that moves the change's approved documents from `docs/product/shaping/{feature}/` into `docs/product/features/{feature}/`. The maintainer reviews it. Merging the promotion PR ratifies the change; the merge is the approval record. Code alone never admits a spec, so a change whose code has already shipped still goes through promotion. + +The promotion PR also lists each app-local scenario file under `apps/{surface}/docs/features/{feature}/scenarios/` that it adds or changes, so the maintainer ratifies surface-specific scenarios with the rest of the change. + +The feature-root destination is provisional. It holds until the feature-evolution pathway (issue #23) gives each change its own directory. Until then, check for collisions before moving anything: if the destination already holds a PRD, TRD, story or scenario with the same name as one being promoted, stop and ask the maintainer. Never overwrite a ratified document during promotion. + +**Output:** The ratified change in `docs/product/features/{feature}/`. + +**Gate:** Do not plan implementation until the promotion PR has merged. + +### Implementation Planning + +**Trigger:** The change's promotion PR has merged. + +**Process:** Run idea discovery first. Load the approved constitution and approved vision with the ratified platform scenarios from `docs/product/features/{feature}/scenarios/` and the ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed. Read each app-local scenario as it stood at that PR's merge commit (`git show :`), because a later change may already be editing the working copy. Then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. **Output:** Implementation plan at `docs/plans/YYYY-MM-DD-.md`. @@ -203,10 +250,11 @@ For each writing workflow, dispatch a sub-agent with only the inputs it needs: | Workflow | Sub-agent receives | Sub-agent returns | |----------|-------------------|-------------------| -| Requirements PRD | Design doc, constitution, vision, `references/phase-2-requirements.md`, example features | PRD written to disk | -| Requirements TRD | Approved PRD, constitution, vision, `references/phase-2-requirements.md`, example features | TRD written to disk | -| User Stories | Approved PRD, TRD, constitution, vision, `references/phase-3-user-stories.md` | Story files written to disk | -| BDD Scenarios | User stories, TRD, constitution, vision, `references/phase-4-scenarios.md` | `.feature` files written to disk | +| Requirements PRD | Shaping document, constitution, vision, `references/requirements.md`, ratified features in `features/` as examples, if any | PRD written to disk | +| Requirements TRD | Approved PRD, constitution, vision, `references/requirements.md`, ratified features in `features/` as examples, if any | TRD written to disk | +| Idea discovery | Summary of the work, `docs/product/ideas/`, report format from `references/idea-discovery-and-spikes.md` | Report of relevant ideas, nothing else | +| User Stories | Approved PRD, TRD, constitution, vision, `references/user-stories.md` | Story files written to disk | +| BDD Scenarios | User stories, TRD, constitution, vision, `references/bdd-scenarios.md` | `.feature` files written to disk | The main context reviews sub-agent output with the human and iterates if needed. @@ -223,7 +271,7 @@ All product documentation follows a three-tier hierarchy. See `docs/product/READ | Tier | Location | Contains | |------|----------|----------| -| Platform | `docs/product/` | PRDs, TRDs, user stories, platform-level scenarios | +| Platform | `docs/product/` | Foundation documents and the `ideas/`, `shaping/` and `features/` stages: PRDs, TRDs, user stories, platform-level scenarios | | App | `apps/{surface}/docs/` | Surface-specific scenarios | | Code | `apps/{surface}/tests/` | Step definitions (test automation) | @@ -233,15 +281,18 @@ Not every feature starts at the beginning. Match the entry point to the current | Starting point | Enter at | |---------------|----------| -| No `docs/product/` directory | Project Setup | -| Missing, unapproved, or unversioned constitution or vision before first PRD | Foundation Stage | +| No `docs/product/` directory, or any scaffold file missing (`README.md`, `AGENTS.md`, or a stage `AGENTS.md`) | Project Setup | +| Missing, unapproved, or unversioned constitution or vision before first PRD | Foundation workflow | +| Early idea nobody is shaping yet | Record it in `ideas/` | | Vague idea, no clarity on approach | Discovery and Design | | Clear requirements, needs documentation | Requirements after Foundation Gate | | PRD exists, needs decomposition | User Stories | | Stories exist, needs testable criteria | BDD Scenarios | -| Scenarios exist, needs implementation | Implementation Planning | +| Approved change in `shaping/`, not yet ratified | Promotion | +| Ratified change in `features/`, needs implementation | Implementation Planning | +| Code exists with no spec | Discovery and Design (code alone never admits a spec) | -Clear requirements may skip brainstorming only after Foundation Gate passes. If this is the first PRD and `docs/product/constitution.md` or `docs/product/vision.md` is missing, unapproved, or unversioned, run Foundation Stage before Requirements. +Clear requirements may skip brainstorming only after Foundation Gate passes. If this is the first PRD and `docs/product/constitution.md` or `docs/product/vision.md` is missing, unapproved, or unversioned, run the Foundation workflow before Requirements. ## Skill Delegation @@ -258,23 +309,25 @@ Product specifications are living artifacts. Different artifact types evolve at | Artifact | Strategy | |----------|----------| | Constitution, Vision | Immutable + supersede (semver) | +| Idea, shaping document | Draft; authority comes from the stage directory | | PRD, TRD | Living document with changelog | | User Stories | Living — add, complete, archive | | Platform Scenarios | Living + self-verifying | | Surface Scenarios | Living + self-verifying | -When updating an existing spec, append to its changelog with date, change, and rationale. When changes are so extensive the document is unrecognizable from its original form, supersede with a new document instead. +A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. When updating an existing spec, append to its changelog with date, change, and rationale. When changes are so extensive the document is unrecognizable from its original form, supersede with a new document instead. ## Reference Files -Detailed guidance for each workflow lives in reference files to keep context targeted. The `phase-*` filenames are legacy compatibility paths; load them by the workflow names below: +Detailed guidance for each workflow lives in reference files to keep context targeted. Each file is named for its workflow: - **`references/initialization.md`** — Project initialization workflow, placeholders, post-init steps - **`references/product-constitution.md`** — Product Constitution workflow, Foundation Gate, Constitution Grill, versioning, amendment behavior, and alignment checks - **`references/product-vision.md`** — Product Vision workflow, Foundation Gate, Vision Grill, versioning, and context/ADR coordination -- **`references/phase-2-requirements.md`** — PRD and TRD structure, conventions, constitution and vision checks -- **`references/phase-3-user-stories.md`** — Story format, acceptance criteria, sizing -- **`references/phase-4-scenarios.md`** — Gherkin conventions, boundary rule, file placement +- **`references/idea-discovery-and-spikes.md`** — Idea discovery before a design or plan, spikes, and the decision ledger +- **`references/requirements.md`** — PRD and TRD structure, conventions, constitution and vision checks +- **`references/user-stories.md`** — Story format, acceptance criteria, sizing +- **`references/bdd-scenarios.md`** — Gherkin conventions, boundary rule, file placement - **`docs/METHODOLOGY.md`** — Specification evolution strategies, changelog conventions, supersession rules Load `references/source/product-constitution-guide.md` only through `references/product-constitution.md` when exact source detail is needed. Load `references/source/vision-document-guide.md` only through `references/product-vision.md` when exact source detail is needed. @@ -287,3 +340,4 @@ Load `references/source/product-constitution-guide.md` only through `references/ - **`templates/README.md.tmpl`** — Documentation hierarchy template - **`templates/AGENTS.md.tmpl`** — Agent guidance template +- **`templates/ideas/AGENTS.md.tmpl`**, **`templates/shaping/AGENTS.md.tmpl`**, **`templates/features/AGENTS.md.tmpl`** — Stage guidance: each stage's authority, and when agents read it or stay out diff --git a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md index 9a0998c..3609828 100644 --- a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md +++ b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md @@ -6,6 +6,26 @@ Product specifications are living artifacts that evolve alongside the product. D **Traceability over format.** Whether a specification is updated in place or superseded by a new document, the requirement is that any current specification can be traced back to the decision that created it. Git history provides this for living documents. Explicit supersession headers provide this for immutable documents. +## Stages Carry Authority + +A product document's authority comes from the stage directory it sits in, not from a status field. A status field drifts once code ships unless someone remembers to update it; a path moves in the same pull request as the work. The decision is recorded in ADR 0001 (stage directories carry authority). + +| Stage | Holds | Authority | +|-------|-------|-----------| +| `docs/product/ideas/` | Early sketches nobody is shaping yet | None. Agents read an idea only when the task names it, or through idea discovery. | +| `docs/product/shaping/` | Changes being worked out: shaping documents and draft PRDs, TRDs, stories and scenarios | Tentative context for work on that feature. ADRs and contracts that a shaping document links keep their own authority. | +| `docs/product/features/` | Ratified changes and shipped feature specs | Requirements | + +### Promotion rule + +- The maintainer moves an idea to `shaping/` when they start shaping it. +- The Foundation Gate blocks drafting a PRD, not ideas or shaping. +- A PRD is drafted in `shaping/`. Merging the change's promotion PR ratifies the change and moves it into `features/`. The merge is the approval record. +- Code alone never admits a spec to `features/`. Behavior found only in code enters through `ideas/` or `shaping/` and is promoted like any other change. +- A spike's code never admits a spec either. Its decision ledger lives with the spike, never in `docs/product/`, and its entries move into lasting documents when the spike ends. + +The evolution strategies below apply once a document has the authority of its stage: foundation documents once approved, PRDs, TRDs, stories and scenarios once ratified into `features/`. Ideas and shaping documents are drafts and change freely. + ## Evolution Strategies ### Immutable + Supersede @@ -27,16 +47,16 @@ The document is never modified after approval. When the specification must chang ### Living Document -The document is updated in place. A changelog section at the bottom records significant changes with date, description, and rationale. +The document keeps one current version. A changelog section at the bottom records significant changes with date, description, and rationale. -**Mechanism:** Edit the document directly. Append to the changelog. Git history provides the full diff. +**Mechanism:** Once the document is ratified, a change to its meaning is drafted in `shaping/{feature}/` and ratified by a promotion PR (see [When to Supersede vs. Update](#when-to-supersede-vs-update)). Append to the changelog. Git history provides the full diff. ```markdown ## Changelog | Date | Change | Rationale | |------|--------|-----------| -| 2026-03-15 | Added `session_paused` event | User research showed pause frequency is a key engagement signal | +| 2026-03-15 | Added accepting a recurring series in one step | Invitees declined weekly events rather than accept each occurrence | | 2026-03-01 | Initial version | — | ``` @@ -58,10 +78,12 @@ The specification is tied to automated tests. When behavior changes, the specifi |----------|----------|----------|-----------| | Constitution | Immutable + supersede (semver) | `docs/product/` | Governance changes are rare and consequential | | Vision | Immutable + supersede (semver) | `docs/product/` | Strategic direction changes are deliberate | -| PRD | Living document with changelog | `docs/product/features/{feature}/` | Requirements evolve incrementally | -| TRD | Living document with changelog | `docs/product/features/{feature}/` | Architecture tracks requirements | -| User Stories | Living — add, complete, archive | `docs/product/features/{feature}/stories/` | Stories are transient work items | -| Platform Scenarios | Living + self-verifying | `docs/product/features/{feature}/scenarios/` | Executable behavioral contracts | +| Idea | Draft, no changelog | `docs/product/ideas/` | No requirements authority; moves to `shaping/` when shaping starts | +| Shaping document | Draft, no changelog | `docs/product/shaping/{feature}/` | Tentative design; moves with its change on promotion | +| PRD | Living document with changelog | `docs/product/shaping/{feature}/` while shaped, `docs/product/features/{feature}/` once ratified | Requirements evolve incrementally | +| TRD | Living document with changelog | `docs/product/shaping/{feature}/` while shaped, `docs/product/features/{feature}/` once ratified | Architecture tracks requirements | +| User Stories | Living — add, complete, archive | `stories/` under the change's stage directory | Stories are transient work items | +| Platform Scenarios | Living + self-verifying | `scenarios/` under the change's stage directory | Executable behavioral contracts | | Surface Scenarios | Living + self-verifying | `apps/{surface}/docs/features/{feature}/scenarios/` | Surface-specific executable contracts | ## User Story Lifecycle @@ -88,7 +110,11 @@ For living documents (PRDs, TRDs), the changelog section is the last section in ## When to Supersede vs. Update -Update in place when: +A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. + +The feature-evolution pathway (issue #23) will replace these strategies with a full change model. Until then, promotion's collision rule holds: if an amended document would replace a ratified one with the same name, the promotion stops and the maintainer decides. + +Amend through shaping and promotion when: - Adding a new requirement or event to an existing feature - Refining acceptance criteria based on implementation learnings - Updating dependency versions or technical details diff --git a/plugins/product-development/skills/product-development/references/phase-4-scenarios.md b/plugins/product-development/skills/product-development/references/bdd-scenarios.md similarity index 59% rename from plugins/product-development/skills/product-development/references/phase-4-scenarios.md rename to plugins/product-development/skills/product-development/references/bdd-scenarios.md index 8952c03..6dca07c 100644 --- a/plugins/product-development/skills/product-development/references/phase-4-scenarios.md +++ b/plugins/product-development/skills/product-development/references/bdd-scenarios.md @@ -1,21 +1,22 @@ # BDD Scenarios -This file keeps its `phase-4-scenarios.md` name as a legacy compatibility path. The public workflow name is BDD Scenarios. - Scenarios are **living + self-verifying** artifacts (see `docs/METHODOLOGY.md`). They are tied to automated tests via step definitions. When behavior changes, the scenario is updated and the test suite validates that the specification matches reality. A failing scenario means the spec and the implementation have diverged. ## Inputs -- User stories at `docs/product/features/{feature}/stories/` -- TRD at `docs/product/features/{feature}/TRD.md` (for technical context on what is feasible) +- User stories at `docs/product/shaping/{feature}/stories/` while the change is drafted +- TRD at `docs/product/shaping/{feature}/TRD.md` (for technical context on what is feasible) +- For a feature that already has ratified documents, also read the baseline in `docs/product/features/{feature}/`: its stories, TRD and existing scenarios - Approved, versioned product constitution at `docs/product/constitution.md` - Approved, versioned product vision at `docs/product/vision.md` ## Output Locations **Platform-level scenarios** (surface-neutral behavioral contracts): +Platform-level scenarios are drafted with their change in `shaping/` and move into `docs/product/features/{feature}/scenarios/` when the promotion PR merges. + ``` -docs/product/features/{feature}/scenarios/ +docs/product/shaping/{feature}/scenarios/ ├── {story-or-behavior-name}.feature └── ... ``` @@ -27,6 +28,8 @@ apps/{surface}/docs/features/{feature}/scenarios/ └── ... ``` +Write surface-specific scenarios with the change, before promotion. The promotion PR lists each app-local scenario file it adds or changes. + **Step definitions** (test automation, always app-local): ``` apps/{surface}/tests/features/{feature}/steps/ @@ -38,11 +41,11 @@ apps/{surface}/tests/features/{feature}/steps/ A scenario belongs at **platform level** if its Given/When/Then language holds true regardless of surface. The words should not reference any specific input mechanism, UI widget, or device capability. -> "Given the user has not consented to analytics, When an unhandled error occurs, Then the error report contains no persistent identifier" +> "Given an invitee has accepted an invitation, When the organizer moves the event, Then the event shows the new time in the invitee's calendar" A scenario belongs at **app level** if its language references a surface-specific interaction model. -> "Given I am on the BreathWork session screen, When I swipe down during an active round, Then haptic feedback fires and the session pauses" +> "Given I am on the day view for Monday, When I swipe left, Then the day view shows Tuesday" **When in doubt:** Write it at platform level. Move to app level only when the scenario cannot be expressed without surface-specific language. @@ -51,9 +54,9 @@ A scenario belongs at **app level** if its language references a surface-specifi ### File naming Use lowercase kebab-case matching the behavior being tested: -- `consent-opted-out-error-reporting.feature` -- `session-completion-tracking.feature` -- `swipe-pause-haptics.feature` (surface-specific) +- `invitation-acceptance.feature` +- `event-reschedule-sync.feature` +- `day-view-swipe-navigation.feature` (surface-specific) ### Feature block @@ -73,8 +76,8 @@ Feature: {Feature name from PRD} ### Writing guidelines - **One behavior per scenario.** A scenario tests one thing. If there are multiple Then clauses, consider whether they are really separate behaviors. -- **Use domain language, not implementation language.** "the user consents to analytics" not "setAnalyticsConsent(true) is called." -- **Avoid UI details in platform scenarios.** "the user enables analytics" not "the user taps the Enable button." UI details belong in surface-specific scenarios. +- **Use domain language, not implementation language.** "the invitee accepts the invitation" not "acceptInvitation(eventId) is called." +- **Avoid UI details in platform scenarios.** "the invitee accepts the invitation" not "the invitee taps the Accept button." UI details belong in surface-specific scenarios. - **Acceptance criteria map to scenarios.** Each acceptance criterion from a user story should have at least one corresponding scenario. - **Tag surface-specific scenarios.** Use `@mobile`, `@tv`, `@web` tags at the Feature or Scenario level for surface-specific files. - **Preserve foundation constraints.** Add scenario coverage for constitutional behaviors when relevant, and do not weaken `MUST` or `MUST NOT` language. @@ -83,37 +86,35 @@ Feature: {Feature name from PRD} ### Example: Platform-level scenario ```gherkin -Feature: Consent-tiered error reporting - Error reports are always sent but detail varies by consent state. - - Scenario: Error report for opted-out user contains no identifier - Given the user has not consented to analytics - When an unhandled error occurs - Then an error report is sent to the error tracking service - And the report contains a stack trace - And the report contains no persistent user identifier - - Scenario: Error report for opted-in user includes anonymous ID - Given the user has consented to analytics - When an unhandled error occurs - Then an error report is sent to the error tracking service - And the report contains a stack trace - And the report contains the user's anonymous identifier +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined ``` ### Example: Surface-specific scenario ```gherkin @mobile -Feature: Session pause via gesture - Mobile users can pause an active session with a swipe gesture. - - Scenario: Swipe down pauses active breathing round - Given I am on the BreathWork session screen - And a breathing round is active - When I swipe down - Then the session pauses - And haptic feedback fires +Feature: Day view swipe navigation + Phone users move between days with a swipe gesture. + + Scenario: Swipe left shows the next day + Given I am on the day view for Monday + And Tuesday has two events + When I swipe left + Then the day view shows Tuesday + And Tuesday's two events are listed ``` ## Traceability @@ -129,7 +130,9 @@ This makes it possible to audit which stories have scenario coverage and which d ## Quality Criteria -Scenarios are ready for Implementation Planning when: +Scenarios are ready for Promotion when the criteria below hold. Implementation Planning starts only after the promotion PR merges. + +Criteria: - Every user story acceptance criterion has at least one corresponding scenario - Platform-level and surface-specific scenarios are filed in the correct locations - Scenarios use domain language, not implementation language diff --git a/plugins/product-development/skills/product-development/references/idea-discovery-and-spikes.md b/plugins/product-development/skills/product-development/references/idea-discovery-and-spikes.md new file mode 100644 index 0000000..049c602 --- /dev/null +++ b/plugins/product-development/skills/product-development/references/idea-discovery-and-spikes.md @@ -0,0 +1,81 @@ +# Idea Discovery and Spikes + +Load this reference before a design or plan (idea discovery) or when a shaping question needs a prototype to answer it (spikes). Terms follow the skill's glossary, [CONTEXT.md](../CONTEXT.md). + +## Idea discovery + +Ideas have no requirements authority, and agents do not read `docs/product/ideas/` for general context. Idea discovery is the exception: a scoped subagent search for ideas that bear on upcoming work. The main context pays for idea content only when an idea is relevant. + +### When to run + +- Before Discovery and Design produces a design. +- Before Implementation Planning writes a plan. + +Skip it when `docs/product/ideas/` holds no ideas. + +### How to run + +Dispatch one subagent. Give it: + +- a short summary of the work: the feature, the problem, and the scope of the design or plan +- the path `docs/product/ideas/` +- the report format below + +The subagent reads every idea and reports only the ones that bear on the work. The main context does not open idea files itself unless the report names one and the maintainer wants to discuss it. + +### Report format + +```markdown +| Idea | Relation | Why it matters | Ask the maintainer | +|------|----------|----------------|--------------------| +| `ideas/shared-calendar-reminders.md` | enables | Reminders reuse the invitation's event time | Ship reminders with invitations, or later? | +| `ideas/public-calendars.md` | conflicts | Public calendars assume no invitation step | Do public calendars skip invitations? | +``` + +Relation is one of `enables`, `conflicts` or `overlaps`. When no idea bears on the work, the report says so in one line. + +### Using the report + +- Put each question to the maintainer before the design or plan is approved. +- An idea that enables or overlaps the work stays an idea. Only the maintainer moves an idea to `shaping/`; do not fold it into the design on your own. +- The maintainer settles each conflict: change the design, revise or drop the idea, or note the conflict in the shaping document for later. + +## Spikes + +A spike is a disposable prototype that answers a shaping question. + +- Name the question before you start. The spike answers that question and nothing more. +- Keep spike code out of the product's main line: use a throwaway branch or a scratch directory, and delete the code once the question is answered. +- Spike code never admits a spec. Working code is evidence for the shaping document, not a requirement, and nothing reaches `features/` because a spike ran. +- Record the answer in the shaping document that asked the question. + +### Decision ledger + +When an agent runs a spike unattended, it keeps a decision ledger: an append-only record of the decisions it made, for the maintainer to review. + +- The ledger lives with the spike, for example `DECISIONS.md` at the spike's root, never in `docs/product/`. +- Append only. Never edit or delete an entry while the spike runs. To correct an entry, add a new one that names it. +- Record every decision the maintainer would have been asked about if present. + +Entry format: + +```markdown +## D-003 2026-11-29: Store invitations per calendar, not per user + +- Question: How does an invitee see pending invitations across calendars? +- Decision: Keep pending invitations on the calendar and query them by invitee. +- Alternatives: A per-user inbox copied on send. +- Reason: One source of truth; revoking an invitation needs no fan-out. +- Reversible: Yes. An inbox can be added later as a projection. +``` + +When the spike ends, the maintainer reviews the ledger and every recorded decision moves to one of four destinations: + +| The entry is | It moves to | +|--------------|-------------| +| Part of the change's tentative design | The shaping document | +| Hard to reverse, surprising, and the result of a real trade-off | An ADR | +| History or reasoning about a ratified feature | That feature's log | +| A new possibility outside the spike's question | An idea in `ideas/` | + +No entry is dropped. A decision the maintainer rejects or reverses still lands, recorded with its reason, usually in the shaping document. Delete the ledger only after every entry has landed in one of these destinations. diff --git a/plugins/product-development/skills/product-development/references/initialization.md b/plugins/product-development/skills/product-development/references/initialization.md index 8819506..24102d1 100644 --- a/plugins/product-development/skills/product-development/references/initialization.md +++ b/plugins/product-development/skills/product-development/references/initialization.md @@ -2,7 +2,7 @@ ## Purpose -Set up the `docs/product/` directory structure for a project that will use the product development lifecycle. This is a one-time step that creates the documentation hierarchy, agent guidance, and feature directory. +Set up the `docs/product/` directory structure for a project that will use the product development lifecycle. This is a one-time step that creates the documentation hierarchy, agent guidance, and the three stage directories. ## What gets created @@ -10,9 +10,11 @@ Set up the `docs/product/` directory structure for a project that will use the p |------|---------| | `docs/product/README.md` | Documentation hierarchy, artifact flow, boundary rule, directory structure | | `docs/product/AGENTS.md` | Agent guidance for organizing product documentation | -| `docs/product/features/` | Empty directory, ready for the first feature | +| `docs/product/ideas/AGENTS.md` | `ideas/` stage: early sketches with no requirements authority | +| `docs/product/shaping/AGENTS.md` | `shaping/` stage: changes being worked out, including draft PRDs and TRDs | +| `docs/product/features/AGENTS.md` | `features/` stage: ratified changes and shipped feature specs | -Files that already exist are skipped — the script never overwrites. +Each stage directory gets its own `AGENTS.md` that says when agents read the stage and when they stay out. Files that already exist are skipped — the script never overwrites. If any scaffold file is missing, for example after an interrupted run, run the script again: it creates only the missing files. A stage directory that already exists keeps its content and gains an `AGENTS.md` only if it has none. ## Running the script @@ -29,8 +31,8 @@ The initialization script lives at `scripts/init.sh` relative to this skill's ro scripts/init.sh /path/to/project \ --project-name "MyProject" \ --surfaces "mobile,web" \ - --platform-scenario-example "Error reports contain no PII." \ - --surface-scenario-example "Swiping down pauses the session." + --platform-scenario-example "Every invitee sees the event's current time." \ + --surface-scenario-example "Swiping left shows the next day." ``` ### Via standalone execution @@ -56,10 +58,10 @@ Uses auto-detected and default values without prompting. | `{{PROJECT_NAME}}` | `package.json` name field, then directory name | Directory name | | `{{SURFACES}}` | Subdirectories under `apps/` | `mobile` | | `{{SURFACE_LIST_PROSE}}` | Derived from surfaces (e.g., "mobile, web, or tv") | — | -| `{{PLATFORM_SCENARIO_EXAMPLE}}` | Ask user | "Error reports for non-consented users contain no persistent identifier." | -| `{{SURFACE_SCENARIO_EXAMPLE}}` | Ask user | "Swiping down during a breathing round triggers haptic feedback." | +| `{{PLATFORM_SCENARIO_EXAMPLE}}` | Ask user | "An accepted invitation adds the event to the invitee's calendar." | +| `{{SURFACE_SCENARIO_EXAMPLE}}` | Ask user | "Swiping left on the day view shows the next day." | | `{{SURFACE_SCENARIO_EXAMPLE_FULL}}` | Same as above (full sentence) | — | -| `{{EXAMPLE_FEATURES_LINE}}` | Auto-detected from existing `docs/product/features/` subdirs | Empty (omitted) | +| `{{EXAMPLE_FEATURES_LINE}}` | Auto-detected from existing `docs/product/features/` subdirectories | Empty (omitted) | ### What to ask the user @@ -79,10 +81,10 @@ After running the script: 3. Create and approve versioned `docs/product/constitution.md` through the Constitution Grill (use the immutable + supersede evolution strategy) 4. Run the Product Vision workflow before the first PRD 5. Create approved, versioned `docs/product/vision.md` through the Vision Grill (use the immutable + supersede evolution strategy) -6. Proceed to the first PRD only after the Foundation Gate passes +6. Draft the first PRD, in `docs/product/shaping/`, only after the Foundation Gate passes When running the Constitution Grill or Vision Grill, prefer `grill-with-docs` if it is installed. If it is missing, notify the user up front, recommend installing it for doc-aware interrogation, and continue with the built-in fallback only if the user declines installation or asks to proceed. The constitution is not generated by the initialization script because governance principles require human approval. The vision is not scaffolded because it requires project-specific interrogation through the Vision Grill. These documents are the foundation that all PRDs reference, so they should be written deliberately rather than scaffolded. -Discovery and design exploration may happen before the Foundation Gate, but the first Requirements PRD cannot start until `docs/product/constitution.md` is approved with version metadata and approved, versioned `docs/product/vision.md` exists. +The Foundation Gate blocks drafting a PRD, not ideas or shaping. Ideas, discovery and design exploration may happen before it passes, but the first Requirements PRD cannot start until `docs/product/constitution.md` is approved with version metadata and approved, versioned `docs/product/vision.md` exists. diff --git a/plugins/product-development/skills/product-development/references/product-constitution.md b/plugins/product-development/skills/product-development/references/product-constitution.md index 9d1dca0..61a2d5a 100644 --- a/plugins/product-development/skills/product-development/references/product-constitution.md +++ b/plugins/product-development/skills/product-development/references/product-constitution.md @@ -21,7 +21,7 @@ First feature PRD work is blocked until both foundation documents exist and are - `docs/product/constitution.md` - approved product constitution with version metadata. - `docs/product/vision.md` - approved, versioned product north star. -Do not create the first feature PRD while either document is missing, unapproved, or unversioned. Brainstorming and design exploration may continue before Foundation Gate passes. +Do not draft the first feature PRD while either document is missing, unapproved, or unversioned. The Foundation Gate blocks drafting a PRD, not ideas or shaping: ideas, brainstorming and design exploration may continue before it passes. ## Preferred dependency: grill-with-docs diff --git a/plugins/product-development/skills/product-development/references/product-vision.md b/plugins/product-development/skills/product-development/references/product-vision.md index 7e623c0..ef77168 100644 --- a/plugins/product-development/skills/product-development/references/product-vision.md +++ b/plugins/product-development/skills/product-development/references/product-vision.md @@ -23,7 +23,7 @@ First feature PRD work is blocked until both foundation documents exist and are - `docs/product/constitution.md` — approved product governance principles with version metadata. - `docs/product/vision.md` — approved, versioned product north star. -Do not create the first feature PRD while either document is missing, unapproved, or unversioned. Clear requirements may skip brainstorming only after Foundation Gate passes. +Do not draft the first feature PRD while either document is missing, unapproved, or unversioned. The Foundation Gate blocks drafting a PRD, not ideas or shaping. Clear requirements may skip brainstorming only after Foundation Gate passes. Run the Vision workflow after Product Constitution approval. The vision must reconcile against the approved constitution and cannot weaken constitutional principles. diff --git a/plugins/product-development/skills/product-development/references/phase-2-requirements.md b/plugins/product-development/skills/product-development/references/requirements.md similarity index 81% rename from plugins/product-development/skills/product-development/references/phase-2-requirements.md rename to plugins/product-development/skills/product-development/references/requirements.md index 956cf0f..4003de8 100644 --- a/plugins/product-development/skills/product-development/references/phase-2-requirements.md +++ b/plugins/product-development/skills/product-development/references/requirements.md @@ -1,14 +1,12 @@ # Requirements (PRD + TRD) -This file keeps its `phase-2-requirements.md` name as a legacy compatibility path. The public workflow name is Requirements. - ## Inputs -- Approved design document from Discovery and Design +- Approved shaping document from Discovery and Design, in `docs/product/shaping/{feature}/` - `docs/product/constitution.md` - approved governance principles with version metadata. Required before the first PRD. - `docs/product/vision.md` - approved, versioned product north star. Required before the first PRD. -If this is the first PRD and either foundation document is missing, unapproved, or unversioned, stop and run Foundation Stage before drafting requirements. +If this is the first PRD and either foundation document is missing, unapproved, or unversioned, stop and run the Foundation workflow before drafting requirements. The Foundation Gate blocks drafting a PRD, not ideas or shaping. Later PRDs must still load the approved, versioned constitution and approved, versioned vision for alignment checks. @@ -17,11 +15,13 @@ If the PRD would change strategic direction, stop and supersede the vision befor ## Output Location ``` -docs/product/features/{feature}/ +docs/product/shaping/{feature}/ ├── PRD.md └── TRD.md ``` +Draft both documents in `shaping/`. They are tentative until the change's promotion PR merges, which ratifies the change and moves it into `docs/product/features/{feature}/`. Code alone never admits a spec: a PRD written for behavior that already exists in code is still drafted here and promoted. + ## PRD Structure The Product Requirements Document describes **what** and **why**. @@ -90,6 +90,7 @@ The Technical Requirements Document describes **how**, architecturally. A PRD is ready for User Stories when: - Every current constitutional principle or standard is PASS or N/A with justification; RISK has resolved mitigation or an approved amendment path; FAIL is not present - Vision alignment is explicit: target users, value proposition, platform principles, and relevant surface vision are consistent with approved `docs/product/vision.md` +- User stories name their personas, and each persona is defined in the PRD - User stories have clear acceptance criteria - Functional requirements are prioritized - Privacy model is explicit about what is and isn't collected @@ -102,7 +103,7 @@ A TRD is ready for User Stories when: ## Evolution Strategy -PRDs and TRDs are **living documents**. When requirements evolve, update the document in place and append to the changelog. See `docs/METHODOLOGY.md` for full conventions. +PRDs and TRDs are **living documents**. A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Record it in the changelog. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. See `docs/METHODOLOGY.md` for full conventions. ### Changelog section @@ -113,7 +114,7 @@ Every PRD and TRD ends with a changelog: | Date | Change | Rationale | |------|--------|-----------| -| 2026-03-15 | Added `session_paused` event | User research showed pause frequency is a key engagement signal | +| 2026-03-15 | Added accepting a recurring series in one step | Invitees declined weekly events rather than accept each occurrence | | 2026-03-01 | Initial version | — | ``` @@ -131,9 +132,6 @@ Supersede with a new document (rather than editing) when: The threshold is judgment-based: if the volume of changes would confuse someone reading the document relative to its original intent, create a new version. -## Existing Examples +## Templates -Reference these existing PRD/TRD pairs as templates: -- `docs/product/features/analytics/` -- `docs/product/features/error-tracking/` -- `docs/product/features/feature-flags/` +The PRD Structure and TRD Structure sections above are the templates: use their required sections, in order. Once the project has ratified features in `docs/product/features/`, follow their local conventions as well, but the required sections still apply. diff --git a/plugins/product-development/skills/product-development/references/phase-3-user-stories.md b/plugins/product-development/skills/product-development/references/user-stories.md similarity index 72% rename from plugins/product-development/skills/product-development/references/phase-3-user-stories.md rename to plugins/product-development/skills/product-development/references/user-stories.md index 94db0ae..6b52bd1 100644 --- a/plugins/product-development/skills/product-development/references/phase-3-user-stories.md +++ b/plugins/product-development/skills/product-development/references/user-stories.md @@ -1,18 +1,19 @@ # User Stories -This file keeps its `phase-3-user-stories.md` name as a legacy compatibility path. The public workflow name is User Stories. - ## Inputs -- Approved PRD at `docs/product/features/{feature}/PRD.md` -- TRD at `docs/product/features/{feature}/TRD.md` (for technical feasibility context) +- Approved PRD at `docs/product/shaping/{feature}/PRD.md` while the change is drafted +- TRD at `docs/product/shaping/{feature}/TRD.md` (for technical feasibility context) +- For a feature that already has ratified documents, also read the baseline in `docs/product/features/{feature}/`: its PRD, TRD and existing stories - Approved, versioned product constitution at `docs/product/constitution.md` - Approved, versioned product vision at `docs/product/vision.md` ## Output Location +Stories are drafted with their change in `shaping/` and move into `docs/product/features/{feature}/stories/` when the promotion PR merges. + ``` -docs/product/features/{feature}/stories/ +docs/product/shaping/{feature}/stories/ ├── US-001-.md ├── US-002-.md └── ... @@ -49,10 +50,7 @@ so that {benefit}. ### Personas -Use personas from the PRD's user stories section. Common Eirene personas: - -- **Practitioner** — the person using the app for breathwork -- **Developer** — the team building and maintaining the app +Take personas from the PRD. The PRD names the people the feature serves; reuse those names exactly so every story traces to a persona the PRD defines. If a story needs a persona the PRD does not name, stop and add it to the PRD first. ### Acceptance criteria @@ -63,8 +61,8 @@ Each criterion must be: Write criteria in plain language, not Gherkin. Gherkin comes in BDD Scenarios. -**Good:** "Error reports for opted-out users contain no persistent identifier" -**Bad:** "Error reports work correctly" (not testable — what does "correctly" mean?) +**Good:** "An accepted invitation appears in the invitee's calendar" +**Bad:** "Invitations work correctly" (not testable — what does "correctly" mean?) ### Story sizing @@ -82,7 +80,7 @@ Stories also preserve foundation alignment: ## Platform-Level Artifacts -User stories describe **user intent**, not surface-specific interactions. A story like "As a practitioner, I want my breathwork errors reported automatically" applies to every surface. The surface-specific details (how errors manifest on mobile vs TV) are captured in BDD Scenarios. +User stories describe **user intent**, not surface-specific interactions. A story like "As an invitee, I want to accept a calendar invitation, so that the event appears in my calendar" applies to every surface. The surface-specific details (tapping a notification on a phone or clicking a link in a browser) are captured in BDD Scenarios. If a story can only apply to one surface, note the surface in the story's metadata but keep the file at platform level. This makes it visible in cross-surface planning. diff --git a/plugins/product-development/skills/product-development/scripts/init.sh b/plugins/product-development/skills/product-development/scripts/init.sh index f73501d..f1c81e2 100755 --- a/plugins/product-development/skills/product-development/scripts/init.sh +++ b/plugins/product-development/skills/product-development/scripts/init.sh @@ -112,10 +112,10 @@ prompt PROJECT_NAME "Project name" "$PROJECT_NAME" prompt SURFACES "App surfaces (comma-separated)" "${SURFACES:-mobile}" prompt PLATFORM_SCENARIO_EXAMPLE \ "Example platform-level scenario (surface-neutral)" \ - "Error reports for non-consented users contain no persistent identifier." + "An accepted invitation adds the event to the invitee's calendar." prompt SURFACE_SCENARIO_EXAMPLE \ "Example surface-specific scenario (bound to interaction model)" \ - "Swiping down during a breathing round triggers haptic feedback." + "Swiping left on the day view shows the next day." # --- Derived values --- # Map surface directory names to human-friendly prose @@ -148,7 +148,7 @@ else done fi -# Short form for scenario hint (e.g., "haptic feedback on swipe, D-pad navigation") +# Short form for scenario hint (e.g., "Swiping left on the day view shows the next day") SURFACE_SCENARIO_SHORT="${SURFACE_SCENARIO_EXAMPLE%%.*}" SURFACE_SCENARIO_SHORT="${SURFACE_SCENARIO_SHORT%%—*}" SURFACE_SCENARIO_SHORT="$(echo "$SURFACE_SCENARIO_SHORT" | sed 's/[[:space:]]*$//')" @@ -156,7 +156,7 @@ SURFACE_SCENARIO_SHORT="$(echo "$SURFACE_SCENARIO_SHORT" | sed 's/[[:space:]]*$/ # Example features line (blank if no features directory exists) EXAMPLE_FEATURES_LINE="" if [[ -d "$PROJECT_ROOT/docs/product/features" ]]; then - features=$(ls -1 "$PROJECT_ROOT/docs/product/features" 2>/dev/null | head -5 | sed 's/^/`/' | sed 's/$/\/`/' | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') + features=$(find "$PROJECT_ROOT/docs/product/features" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; 2>/dev/null | sort | head -5 | sed 's/^/`/' | sed 's/$/\/`/' | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') if [[ -n "$features" ]]; then EXAMPLE_FEATURES_LINE="- Use the existing feature directories as examples: ${features}." fi @@ -191,10 +191,14 @@ substitute() { } # --- File generation --- +# Temp file of the render in progress, removed on any exit. +PENDING_TMP="" +trap 'if [[ -n "$PENDING_TMP" ]]; then rm -f "$PENDING_TMP"; fi' EXIT + generate() { local template="$1" target="$2" - if [[ -f "$target" ]]; then + if [[ -e "$target" || -L "$target" ]]; then echo " SKIP $target (already exists)" return fi @@ -204,9 +208,35 @@ generate() { return fi - mkdir -p "$(dirname "$target")" - substitute "$template" > "$target" - echo " CREATE $target" + # Render to a temp file beside the target, then publish it with link(1), + # which makes a hard link at exactly the target path and fails if anything + # exists there. Unlike ln, it never links into a directory (or a symlink to + # one) that appeared at the target. A concurrent run or a file created + # meanwhile is never replaced, and a failed render leaves no target behind. + local dir + dir="$(dirname "$target")" + mkdir -p "$dir" + PENDING_TMP="$(mktemp "$dir/.$(basename "$target").tmp.XXXXXX")" + if ! substitute "$template" > "$PENDING_TMP"; then + rm -f "$PENDING_TMP" + PENDING_TMP="" + echo " ERROR $target (could not render $template)" >&2 + exit 1 + fi + # mktemp creates the file 0600; give it the mode a plain redirect would. + chmod "$(printf '%o' $(( 0666 & ~0$(umask) )))" "$PENDING_TMP" + if link "$PENDING_TMP" "$target" 2>/dev/null; then + echo " CREATE $target" + elif [[ -e "$target" || -L "$target" ]]; then + echo " SKIP $target (already exists)" + else + rm -f "$PENDING_TMP" + PENDING_TMP="" + echo " ERROR $target (could not publish)" >&2 + exit 1 + fi + rm -f "$PENDING_TMP" + PENDING_TMP="" } echo "" @@ -218,21 +248,23 @@ echo "" generate "$TEMPLATE_DIR/README.md.tmpl" "$PROJECT_ROOT/docs/product/README.md" generate "$TEMPLATE_DIR/AGENTS.md.tmpl" "$PROJECT_ROOT/docs/product/AGENTS.md" -# Create features directory -if [[ ! -d "$PROJECT_ROOT/docs/product/features" ]]; then - if $DRY_RUN; then - echo " WOULD CREATE $PROJECT_ROOT/docs/product/features/" +# Create stage directories, each with its own agent guidance +for stage in ideas shaping features; do + stage_dir="$PROJECT_ROOT/docs/product/$stage" + if [[ -d "$stage_dir" ]]; then + echo " SKIP $stage_dir/ (already exists)" + elif $DRY_RUN; then + echo " WOULD CREATE $stage_dir/" else - mkdir -p "$PROJECT_ROOT/docs/product/features" - echo " CREATE $PROJECT_ROOT/docs/product/features/" + mkdir -p "$stage_dir" + echo " CREATE $stage_dir/" fi -else - echo " SKIP $PROJECT_ROOT/docs/product/features/ (already exists)" -fi + generate "$TEMPLATE_DIR/$stage/AGENTS.md.tmpl" "$stage_dir/AGENTS.md" +done echo "" echo "Done. Next steps:" echo " 1. Review docs/product/README.md and docs/product/AGENTS.md" echo " 2. Run the Product Constitution workflow to create approved, versioned docs/product/constitution.md" echo " 3. Run the Product Vision workflow to create approved, versioned docs/product/vision.md" -echo " 4. Start the first PRD only after the Foundation Gate passes" +echo " 4. Draft the first PRD in docs/product/shaping/ only after the Foundation Gate passes" diff --git a/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl index f5a667c..10901a8 100644 --- a/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl @@ -2,14 +2,25 @@ When creating or organizing product documentation in this directory, refer to [README.md](./README.md) for the documentation hierarchy, artifact types, directory structure, and boundary rules. +## Stages + +Feature content lives in three stage directories, and a document's authority comes from its directory. Each has its own `AGENTS.md`; follow it. + +- `ideas/` — early sketches with no requirements authority. Read an idea only when the task names it, or through idea discovery. +- `shaping/` — changes being worked out, including draft PRDs and TRDs. Tentative context for work on that feature; ADRs and contracts it links keep their own authority. +- `features/` — ratified changes and shipped feature specs. These are the requirements. + +The maintainer moves an idea to `shaping/` when they start shaping it. A PRD is drafted in `shaping/`; merging the change's promotion PR ratifies it and moves it into `features/`. Code alone never admits a spec to `features/`. + ## Key rules -- **PRDs, TRDs, user stories, and platform-level scenarios** belong under `docs/product/features/{feature}/`. +- **PRDs, TRDs, user stories, and platform-level scenarios** are drafted under `docs/product/shaping/{feature}/` and live under `docs/product/features/{feature}/` once ratified. - **Surface-specific scenarios** (those whose Given/When/Then language references a specific interaction model) belong under `apps/{surface}/docs/features/{feature}/scenarios/`. - **Step definitions** (test automation) always belong under each app's test directory, never in `docs/`. - Before creating the first feature PRD, confirm `docs/product/constitution.md` exists, is approved, and has version metadata. - Before creating the first feature PRD, confirm `docs/product/vision.md` exists, is approved, and has version metadata. - If either foundation document is missing, unapproved, or unversioned, complete the Foundation Gate before Requirements. +- The Foundation Gate blocks drafting a PRD, not ideas or shaping. - Use the Constitution Grill before the Vision Grill when creating foundation documents. - If product context lives at `docs/product/CONTEXT.md`, ensure root `CONTEXT-MAP.md` points to it so Matt-style `grill-with-docs` agents can discover it. - Keep `docs/product/CONTEXT.md` limited to glossary and domain language. Put assumptions in vision/research synthesis and decisions in ADRs. @@ -20,13 +31,15 @@ When creating or organizing product documentation in this directory, refer to [R ## When adding a new feature -1. Confirm the Foundation Gate has passed before Requirements. -2. Create `docs/product/features/{feature}/PRD.md`. -3. Create `docs/product/features/{feature}/TRD.md`. -4. Add user stories under `docs/product/features/{feature}/stories/` as work progresses. -5. Add platform-level behavioral scenarios under `docs/product/features/{feature}/scenarios/` as acceptance criteria are defined. -6. Surface-specific scenarios and step definitions are created during implementation under the relevant app. +1. Run idea discovery: a subagent reads `docs/product/ideas/` and reports ideas that bear on the work. +2. Save the approved design as the shaping document in `docs/product/shaping/{feature}/`. +3. Confirm the Foundation Gate has passed before Requirements. +4. Draft `PRD.md`, then `TRD.md`, in `docs/product/shaping/{feature}/`. +5. Add user stories under `docs/product/shaping/{feature}/stories/` and platform-level scenarios under `docs/product/shaping/{feature}/scenarios/`. +6. Write surface-specific scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` before promotion. +7. Open a promotion PR that moves the approved change into `docs/product/features/{feature}/` and lists each app-local scenario file it adds or changes. Its merge ratifies the change. If the destination already holds a document with the same name, stop and ask instead of overwriting. +8. Step definitions are created during implementation under the relevant app. ## Specification evolution -PRDs and TRDs are living documents — update in place and append to the changelog section (date, change, rationale). For evolution strategies per artifact type, consult the product-development methodology documentation (installed at `.agents/local-skills/product-development/docs/METHODOLOGY.md` or `.agents/skills/product-development/docs/METHODOLOGY.md`). +Once ratified, PRDs and TRDs are living documents with a changelog section (date, change, rationale). A change to requirements, stories or scenarios is drafted in `docs/product/shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. For evolution strategies per artifact type, consult the product-development methodology documentation (installed at `.agents/local-skills/product-development/docs/METHODOLOGY.md` or `.agents/skills/product-development/docs/METHODOLOGY.md`). diff --git a/plugins/product-development/skills/product-development/templates/README.md.tmpl b/plugins/product-development/skills/product-development/templates/README.md.tmpl index 8944ecb..6ace385 100644 --- a/plugins/product-development/skills/product-development/templates/README.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/README.md.tmpl @@ -10,6 +10,8 @@ Product governance and cross-surface specifications. Artifacts here describe wha - `constitution.md` — approved, versioned product constitution required before the first PRD - `vision.md` — approved, versioned north-star product vision required before the first PRD +- `ideas/` — early sketches nobody is shaping yet (see [Stages](#stages)) +- `shaping/{feature}/` — a change being worked out: its shaping document and draft PRD, TRD, stories and scenarios - `features/{feature}/PRD.md` — product requirements (what and why) - `features/{feature}/TRD.md` — technical requirements (how, architecturally) - `features/{feature}/stories/` — user stories decomposing the PRD's requirements @@ -19,7 +21,7 @@ Product governance and cross-surface specifications. Artifacts here describe wha Surface-specific specifications. Artifacts here describe behaviors and interactions that are bound to a specific surface's interaction model. -- `features/{feature}/scenarios/` — surface-specific `.feature` files (e.g., {{SURFACE_SCENARIO_EXAMPLE}}) +- `features/{feature}/scenarios/` — surface-specific `.feature` files (e.g., {{SURFACE_SCENARIO_EXAMPLE}}), written before the change's promotion PR, which lists them so the maintainer ratifies them with the rest of the change Step definitions (automation code that implements both platform and surface scenarios) live in each app's test directory, not in `docs/`. @@ -27,6 +29,21 @@ Step definitions (automation code that implements both platform and surface scen Shared types, schemas, hooks, and domain models. Documentation at this level is code-level: READMEs, JSDoc/TSDoc, and inline documentation. Packages carry the "one domain model, many surfaces" principle into code. +## Stages + +Feature content moves through three stage directories. A document's stage, and so its authority, comes from the directory it sits in, not from a status field. + +| Stage | Holds | Agents treat it as | +|-------|-------|--------------------| +| `ideas/` | Early sketches nobody is shaping yet | No requirements authority. Read an idea only when the task names it, or through idea discovery. | +| `shaping/` | Changes being worked out, including draft PRDs and TRDs | Tentative context for work on that feature. ADRs and contracts that a shaping document links keep their own authority. | +| `features/` | Ratified changes and shipped feature specs | Requirements | + +- The maintainer moves an idea to `shaping/` when they start shaping it. +- A PRD is drafted in `shaping/`. Merging the change's promotion PR ratifies the change and moves it into `features/`. +- Code alone never admits a spec to `features/`. +- Each stage directory has an `AGENTS.md` that says when agents read it and when they stay out. + ## Artifact flow Each artifact type references the one above it: @@ -36,6 +53,10 @@ Constitution ↓ Vision (approved, versioned north star) ↓ +Idea (ideas/, optional) + ↓ +Shaping document (shaping/, the tentative design) + ↓ PRD (checks constitution and vision alignment) ↓ TRD (references PRD requirements) @@ -44,7 +65,9 @@ User Stories (decompose PRD requirements into user-facing narratives) ↓ Platform Scenarios (verify stories' acceptance criteria as behavioral contracts) ↓ -Surface Scenarios (extend with interaction-specific behaviors) +Surface Scenarios (extend with interaction-specific behaviors, written before promotion) + ↓ +Promotion PR (merge ratifies the change, moves it into features/ and lists its app-local scenarios) ↓ Step Definitions (automate scenarios as executable tests) ``` @@ -53,6 +76,8 @@ Step Definitions (automate scenarios as executable tests) Before the first feature PRD, `docs/product/constitution.md` and `docs/product/vision.md` must exist, be approved, and carry explicit version metadata. If either foundation document is missing, unapproved, or unversioned, complete the Foundation Gate before starting feature requirements. +The Foundation Gate blocks drafting a PRD, not ideas or shaping. Ideas and shaping documents may be written before the foundation documents exist, though the default order is still to establish them first. + When `grill-with-docs` is used, product-domain context may live in `docs/product/CONTEXT.md`; if so, root `CONTEXT-MAP.md` should point to it. `CONTEXT.md` is for glossary and domain language, not requirements. ADRs default to `docs/adr/` unless this repository already uses another ADR convention. ## Boundary rule @@ -76,7 +101,13 @@ docs/product/ ├── constitution.md ← approved, versioned product constitution ├── vision.md ← approved, versioned product vision ├── CONTEXT.md ← optional product-domain context for grill-with-docs -└── features/ +├── ideas/ ← early sketches, no requirements authority +│ └── AGENTS.md +├── shaping/ ← changes being worked out +│ ├── AGENTS.md +│ └── {feature}/ ← shaping document, draft PRD, TRD, stories, scenarios +└── features/ ← ratified changes and shipped specs: requirements + ├── AGENTS.md └── {feature}/ ├── PRD.md ← product requirements ├── TRD.md ← technical requirements diff --git a/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl new file mode 100644 index 0000000..2a8dd1d --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl @@ -0,0 +1,22 @@ +# Agent Guidance: Features + +This directory is the `features/` stage. It holds ratified changes and shipped feature specs. + +## Authority + +Documents here are requirements. Plan, implement, test and review against them. + +## When to read + +- Planning, implementing, testing, reviewing or auditing a feature: read that feature's directory. +- Shaping a change to an existing feature: read the affected feature for its current requirements. + +## When to stay out + +- Features the task does not touch. + +## Rules + +- Content enters only through a merged promotion PR from `../shaping/`. Do not draft here. +- Code alone never admits a spec. Behavior that exists in code but not here goes to `../shaping/` or `../ideas/` first. +- Update ratified documents only as the "Specification evolution" section of `../AGENTS.md` describes. diff --git a/plugins/product-development/skills/product-development/templates/ideas/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/ideas/AGENTS.md.tmpl new file mode 100644 index 0000000..50bea99 --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/ideas/AGENTS.md.tmpl @@ -0,0 +1,22 @@ +# Agent Guidance: Ideas + +This directory is the `ideas/` stage. It holds early sketches of features and changes that nobody is shaping yet. + +## Authority + +Ideas have no requirements authority. An idea is not a requirement, a decision or a commitment. Never plan or implement from an idea. + +## When to read + +- The task names an idea in this directory. +- The task is idea discovery: before a design or plan, a subagent reads this directory and reports any idea that enables, conflicts with or overlaps the work, and what to ask the maintainer. + +## When to stay out + +- Every other task. Do not load ideas for general context. Idea discovery keeps idea content out of the main context unless an idea is relevant. + +## Writing here + +- Add an idea when the maintainer asks, or when a spike ends with a finding worth keeping as an idea. +- Use one file per idea, named in lowercase kebab-case. +- The maintainer moves an idea to `../shaping/` when they start shaping it. Do not move an idea unless the maintainer asks. diff --git a/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl new file mode 100644 index 0000000..3594a25 --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl @@ -0,0 +1,24 @@ +# Agent Guidance: Shaping + +This directory is the `shaping/` stage. It holds changes being worked out: shaping documents and draft PRDs, TRDs, user stories and scenarios. + +## Authority + +Shaping documents are tentative context for work on the feature they concern. They are not requirements until the change is ratified. ADRs and contracts that a shaping document links keep their own authority. + +## When to read + +- Design, requirements, story or scenario work on the change a shaping document concerns. +- A spike that answers one of the change's shaping questions. +- Review of the change's promotion PR. + +## When to stay out + +- Implementation. Implement from `../features/`, never from a shaping document. +- Work on other features. A shaping document for one feature does not constrain another. + +## Rules + +- Draft a PRD here, and only after the Foundation Gate passes. Ideas and shaping documents do not need the gate. +- Merging the change's promotion PR ratifies the change and moves it into `../features/`. +- Code alone never admits a spec. Spike findings land here as shaping content, never in `../features/`. diff --git a/plugins/product-development/skills/product-development/tests/init.bats b/plugins/product-development/skills/product-development/tests/init.bats index 06d8fa6..f8b6ca9 100644 --- a/plugins/product-development/skills/product-development/tests/init.bats +++ b/plugins/product-development/skills/product-development/tests/init.bats @@ -4,6 +4,7 @@ SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)" INIT_SCRIPT="$SCRIPT_DIR/scripts/init.sh" +REPO_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)" setup() { TEST_PROJECT="$(mktemp -d)" @@ -13,6 +14,14 @@ teardown() { rm -rf "$TEST_PROJECT" } +# Fails unless grep runs and finds no match. A bare `! grep` mid-test never +# fails a bats test, and a missing file must not pass as "no match". +refute_grep() { + local rc=0 + grep "$@" >/dev/null || rc=$? + [ "$rc" -eq 1 ] || { echo "refute_grep $* exited $rc" >&2; return 1; } +} + # --- Scaffolding --- @test "creates docs/product/README.md" { @@ -62,14 +71,14 @@ teardown() { @test "substitutes platform scenario example in quotes" { run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" \ - --platform-scenario-example "All sessions have a pause button." - grep -q '"All sessions have a pause button."' "$TEST_PROJECT/docs/product/README.md" + --platform-scenario-example "Every event has an organizer." + grep -q '"Every event has an organizer."' "$TEST_PROJECT/docs/product/README.md" } @test "substitutes surface scenario example in quotes" { run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" \ - --surface-scenario-example "Double-tap pauses the session." - grep -q '"Double-tap pauses the session."' "$TEST_PROJECT/docs/product/README.md" + --surface-scenario-example "Double-tap a day to create an event." + grep -q '"Double-tap a day to create an event."' "$TEST_PROJECT/docs/product/README.md" } # --- Skip existing files --- @@ -84,7 +93,7 @@ teardown() { # Original content preserved grep -q "existing content" "$TEST_PROJECT/docs/product/README.md" # New content not written - ! grep -q "NewName" "$TEST_PROJECT/docs/product/README.md" + refute_grep -q "NewName" "$TEST_PROJECT/docs/product/README.md" } @test "skips AGENTS.md if it already exists" { @@ -98,13 +107,164 @@ teardown() { } @test "skips features directory if it already exists" { - mkdir -p "$TEST_PROJECT/docs/product/features/analytics" + mkdir -p "$TEST_PROJECT/docs/product/features/shared-calendars" run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" [ "$status" -eq 0 ] # Existing subdirectory preserved - [ -d "$TEST_PROJECT/docs/product/features/analytics" ] + [ -d "$TEST_PROJECT/docs/product/features/shared-calendars" ] +} + +@test "created files take their mode from the umask" { + umask 022 + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + [[ "$(ls -l "$TEST_PROJECT/docs/product/README.md")" == "-rw-r--r--"* ]] +} + +# Copies the script and its templates so a test can alter a template. +copy_skill() { + SKILL_COPY="$(mktemp -d)" + cp -R "$SCRIPT_DIR/scripts" "$SCRIPT_DIR/templates" "$SKILL_COPY/" +} + +@test "a failed render leaves no file behind, so a retry creates it" { + copy_skill + mv "$SKILL_COPY/templates/AGENTS.md.tmpl" "$SKILL_COPY/AGENTS.md.tmpl.bak" + + run "$SKILL_COPY/scripts/init.sh" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -ne 0 ] + [ ! -e "$TEST_PROJECT/docs/product/AGENTS.md" ] + [ -z "$(find "$TEST_PROJECT/docs/product" -name '.*.tmp.*')" ] + + mv "$SKILL_COPY/AGENTS.md.tmpl.bak" "$SKILL_COPY/templates/AGENTS.md.tmpl" + run "$SKILL_COPY/scripts/init.sh" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + grep -q "README.md" "$TEST_PROJECT/docs/product/AGENTS.md" + rm -rf "$SKILL_COPY" +} + +# Waits up to 5 seconds for a background job and returns its status. On +# timeout it kills the job and the job's children, reaps it, and returns 124. +wait_bounded() { + local pid="$1" tries=0 + while kill -0 "$pid" 2>/dev/null; do + tries=$((tries + 1)) + if [ "$tries" -ge 100 ]; then + pkill -P "$pid" 2>/dev/null || true + kill "$pid" 2>/dev/null || true + sleep 0.5 + pkill -KILL -P "$pid" 2>/dev/null || true + kill -KILL "$pid" 2>/dev/null || true + wait "$pid" 2>/dev/null || true + return 124 + fi + sleep 0.05 + done + wait "$pid" +} + +# Runs init in the background with README.md.tmpl replaced by a FIFO, so the +# script stops mid-render after its existence check. Once the temp file exists, +# runs the command in "$@" to put something at the target, then releases the +# render. Uses SKILL_COPY if the test already made one. Sets RACE_STATUS and +# RACE_OUT. Every wait is bounded, so a regression fails the test instead of +# hanging it. +race_readme() { + [ -n "${SKILL_COPY:-}" ] || copy_skill + local template="$SKILL_COPY/templates/README.md.tmpl" + local real="$SKILL_COPY/README.md.tmpl.real" + mv "$template" "$real" + mkfifo "$template" + RACE_OUT="$SKILL_COPY/out" + + "$SKILL_COPY/scripts/init.sh" "$TEST_PROJECT" --non-interactive --project-name "X" \ + > "$RACE_OUT" 2>&1 3>&- & + local pid=$! + + local tries=0 + until [ -n "$(find "$TEST_PROJECT/docs/product" -maxdepth 1 -name '.README.md.tmp.*' 2>/dev/null)" ]; do + tries=$((tries + 1)) + if [ "$tries" -ge 100 ]; then + wait_bounded "$pid" || true + echo "no temp file appeared before rendering" >&2 + return 1 + fi + sleep 0.05 + done + + "$@" + + # The writer blocks until the script opens the FIFO. If the script never + # does, the writer is killed rather than left blocking. + ( exec cat "$real" > "$template" ) 3>&- & + local writer=$! + RACE_STATUS=0 + wait_bounded "$pid" || RACE_STATUS=$? + kill "$writer" 2>/dev/null || true + wait "$writer" 2>/dev/null || true + [ "$RACE_STATUS" -ne 124 ] || { echo "init did not finish" >&2; return 1; } +} + +@test "never replaces a file that appears while it renders" { + race_readme sh -c 'echo "written by another run" > "$1"' _ "$TEST_PROJECT/docs/product/README.md" + + [ "$RACE_STATUS" -eq 0 ] + [ "$(cat "$TEST_PROJECT/docs/product/README.md")" = "written by another run" ] + grep -q "SKIP $TEST_PROJECT/docs/product/README.md" "$RACE_OUT" + [ -z "$(find "$TEST_PROJECT/docs/product" -name '.*.tmp.*')" ] + rm -rf "$SKILL_COPY" +} + +@test "never links into a directory that appears at the target while it renders" { + race_readme mkdir "$TEST_PROJECT/docs/product/README.md" + + [ -d "$TEST_PROJECT/docs/product/README.md" ] + [ -z "$(ls -A "$TEST_PROJECT/docs/product/README.md")" ] + refute_grep -q "CREATE $TEST_PROJECT/docs/product/README.md" "$RACE_OUT" + grep -qE "(SKIP|ERROR) $TEST_PROJECT/docs/product/README.md" "$RACE_OUT" + [ -z "$(find "$TEST_PROJECT/docs/product" -name '.*.tmp.*')" ] + rm -rf "$SKILL_COPY" +} + +@test "never links through a symlink to a directory that appears at the target" { + local elsewhere="$TEST_PROJECT/elsewhere" + mkdir "$elsewhere" + race_readme ln -s "$elsewhere" "$TEST_PROJECT/docs/product/README.md" + + [ -L "$TEST_PROJECT/docs/product/README.md" ] + [ -z "$(ls -A "$elsewhere")" ] + refute_grep -q "CREATE $TEST_PROJECT/docs/product/README.md" "$RACE_OUT" + grep -qE "(SKIP|ERROR) $TEST_PROJECT/docs/product/README.md" "$RACE_OUT" + rm -rf "$SKILL_COPY" +} + +@test "the race harness fails fast when init exits before creating its temp file" { + copy_skill + printf '#!/usr/bin/env bash\nexit 0\n' > "$SKILL_COPY/scripts/init.sh" + local start=$SECONDS + run race_readme true + [ "$status" -ne 0 ] + [ $((SECONDS - start)) -lt 15 ] + rm -rf "$SKILL_COPY" +} + +@test "the race harness never blocks on the FIFO when init exits without reading it" { + copy_skill + # Creates the temp file the harness waits for, then exits without opening the FIFO. + cat > "$SKILL_COPY/scripts/init.sh" <<'EOF' +#!/usr/bin/env bash +mkdir -p "$1/docs/product" +touch "$1/docs/product/.README.md.tmp.stub" +sleep 0.2 +exit 3 +EOF + local start=$SECONDS + race_readme true + [ "$RACE_STATUS" -eq 3 ] + [ $((SECONDS - start)) -lt 15 ] + rm -rf "$SKILL_COPY" } @test "reports SKIP for existing files" { @@ -130,7 +290,7 @@ teardown() { [ "$status" -eq 0 ] # Should use the temp directory basename (varies per run, just check it was substituted) - ! grep -q "{{PROJECT_NAME}}" "$TEST_PROJECT/docs/product/README.md" + refute_grep -q "{{PROJECT_NAME}}" "$TEST_PROJECT/docs/product/README.md" } @test "detects surfaces from apps/ subdirectories" { @@ -144,14 +304,14 @@ teardown() { } @test "detects existing feature directories with trailing slash for AGENTS.md" { - mkdir -p "$TEST_PROJECT/docs/product/features/analytics" - mkdir -p "$TEST_PROJECT/docs/product/features/error-tracking" + mkdir -p "$TEST_PROJECT/docs/product/features/shared-calendars" + mkdir -p "$TEST_PROJECT/docs/product/features/event-invitations" # Only README and features/ exist, not AGENTS.md — so AGENTS.md gets created run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" [ "$status" -eq 0 ] - grep -q '`analytics/`' "$TEST_PROJECT/docs/product/AGENTS.md" - grep -q '`error-tracking/`' "$TEST_PROJECT/docs/product/AGENTS.md" + grep -q '`shared-calendars/`' "$TEST_PROJECT/docs/product/AGENTS.md" + grep -q '`event-invitations/`' "$TEST_PROJECT/docs/product/AGENTS.md" } # --- Dry run --- @@ -185,13 +345,13 @@ teardown() { @test "no unsubstituted placeholders in README" { run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" --surfaces "mobile" [ "$status" -eq 0 ] - ! grep -q '{{' "$TEST_PROJECT/docs/product/README.md" + refute_grep -q '{{' "$TEST_PROJECT/docs/product/README.md" } @test "no unsubstituted placeholders in AGENTS.md" { run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" [ "$status" -eq 0 ] - ! grep -q '{{' "$TEST_PROJECT/docs/product/AGENTS.md" + refute_grep -q '{{' "$TEST_PROJECT/docs/product/AGENTS.md" } # --- Output structure --- @@ -253,7 +413,7 @@ teardown() { [ "$status" -eq 0 ] grep -q "Foundation Gate" <<< "$output" [[ "$output" == *"2. Run the Product Constitution workflow to create approved, versioned docs/product/constitution.md"*"3. Run the Product Vision workflow to create approved, versioned docs/product/vision.md"* ]] - ! grep -q "Start your first feature with: docs/product/features/{feature}/PRD.md" <<< "$output" + refute_grep -q "Start your first feature with: docs/product/features/{feature}/PRD.md" <<< "$output" } @test "skill references constitution resources and versioned foundation gate" { @@ -264,10 +424,10 @@ teardown() { } @test "requirements reference uses dynamic constitution alignment" { - grep -q "PASS/RISK/FAIL/N/A" "$SCRIPT_DIR/references/phase-2-requirements.md" - grep -q "FAIL against the constitution blocks the PRD" "$SCRIPT_DIR/references/phase-2-requirements.md" - grep -q "vision.md.*ratify or migrate" "$SCRIPT_DIR/references/phase-2-requirements.md" - ! grep -q "five constitutional principles" "$SCRIPT_DIR/references/phase-2-requirements.md" + grep -q "PASS/RISK/FAIL/N/A" "$SCRIPT_DIR/references/requirements.md" + grep -q "FAIL against the constitution blocks the PRD" "$SCRIPT_DIR/references/requirements.md" + grep -q "vision.md.*ratify or migrate" "$SCRIPT_DIR/references/requirements.md" + refute_grep -q "five constitutional principles" "$SCRIPT_DIR/references/requirements.md" } @test "constitution reference routes through source archive and overrides source paths" { @@ -278,12 +438,265 @@ teardown() { } @test "downstream workflows preserve constitution and vision alignment" { - grep -q "docs/product/constitution.md" "$SCRIPT_DIR/references/phase-3-user-stories.md" - grep -q "docs/product/vision.md" "$SCRIPT_DIR/references/phase-3-user-stories.md" - grep -q "Constitutional constraints and approved vision intent are preserved" "$SCRIPT_DIR/references/phase-3-user-stories.md" - grep -q "docs/product/constitution.md" "$SCRIPT_DIR/references/phase-4-scenarios.md" - grep -q "docs/product/vision.md" "$SCRIPT_DIR/references/phase-4-scenarios.md" - grep -q "Constitutional behaviors have coverage" "$SCRIPT_DIR/references/phase-4-scenarios.md" + grep -q "docs/product/constitution.md" "$SCRIPT_DIR/references/user-stories.md" + grep -q "docs/product/vision.md" "$SCRIPT_DIR/references/user-stories.md" + grep -q "Constitutional constraints and approved vision intent are preserved" "$SCRIPT_DIR/references/user-stories.md" + grep -q "docs/product/constitution.md" "$SCRIPT_DIR/references/bdd-scenarios.md" + grep -q "docs/product/vision.md" "$SCRIPT_DIR/references/bdd-scenarios.md" + grep -q "Constitutional behaviors have coverage" "$SCRIPT_DIR/references/bdd-scenarios.md" grep -q "Load the approved constitution and approved vision" "$SCRIPT_DIR/SKILL.md" grep -q "| Requirements TRD | Approved PRD, constitution, vision" "$SCRIPT_DIR/SKILL.md" } + +# --- Stage directories --- + +@test "scaffolds ideas, shaping and features stages with an AGENTS.md in each" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + for stage in ideas shaping features; do + [ -d "$TEST_PROJECT/docs/product/$stage" ] + [ -f "$TEST_PROJECT/docs/product/$stage/AGENTS.md" ] + done +} + +@test "each stage AGENTS.md states its authority and when agents read it or stay out" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + for stage in ideas shaping features; do + grep -q "^## Authority" "$TEST_PROJECT/docs/product/$stage/AGENTS.md" + grep -q "^## When to read" "$TEST_PROJECT/docs/product/$stage/AGENTS.md" + grep -q "^## When to stay out" "$TEST_PROJECT/docs/product/$stage/AGENTS.md" + refute_grep -q '{{' "$TEST_PROJECT/docs/product/$stage/AGENTS.md" + done + grep -q "no requirements authority" "$TEST_PROJECT/docs/product/ideas/AGENTS.md" + grep -q "idea discovery" "$TEST_PROJECT/docs/product/ideas/AGENTS.md" + grep -q "ADRs and contracts" "$TEST_PROJECT/docs/product/shaping/AGENTS.md" + grep -q "promotion PR" "$TEST_PROJECT/docs/product/shaping/AGENTS.md" + grep -q "Code alone never admits a spec" "$TEST_PROJECT/docs/product/features/AGENTS.md" +} + +@test "never overwrites an existing stage AGENTS.md" { + for stage in ideas shaping features; do + mkdir -p "$TEST_PROJECT/docs/product/$stage" + echo "existing $stage guidance" > "$TEST_PROJECT/docs/product/$stage/AGENTS.md" + done + + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + for stage in ideas shaping features; do + [ "$(cat "$TEST_PROJECT/docs/product/$stage/AGENTS.md")" = "existing $stage guidance" ] + [[ "$output" == *"SKIP $TEST_PROJECT/docs/product/$stage/AGENTS.md"* ]] + done +} + +@test "adds a stage AGENTS.md to an existing stage directory without touching its content" { + mkdir -p "$TEST_PROJECT/docs/product/ideas" + echo "an early sketch" > "$TEST_PROJECT/docs/product/ideas/shared-calendars.md" + + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + [ "$(cat "$TEST_PROJECT/docs/product/ideas/shared-calendars.md")" = "an early sketch" ] + [ -f "$TEST_PROJECT/docs/product/ideas/AGENTS.md" ] +} + +@test "dry run creates no stage directories" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" --dry-run + [ "$status" -eq 0 ] + for stage in ideas shaping features; do + [ ! -e "$TEST_PROJECT/docs/product/$stage" ] + [[ "$output" == *"WOULD CREATE $TEST_PROJECT/docs/product/$stage/AGENTS.md"* ]] + done +} + +@test "example features line lists feature directories only" { + mkdir -p "$TEST_PROJECT/docs/product/features/shared-calendars" + echo "existing" > "$TEST_PROJECT/docs/product/features/AGENTS.md" + + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + grep -q '`shared-calendars/`' "$TEST_PROJECT/docs/product/AGENTS.md" + refute_grep -q '`AGENTS.md/`' "$TEST_PROJECT/docs/product/AGENTS.md" +} + +# --- Workflow names --- + +@test "Foundation Stage is renamed to the Foundation workflow" { + grep -q "### Foundation workflow" "$SCRIPT_DIR/SKILL.md" + refute_grep -rq "Foundation Stage" "$SCRIPT_DIR/SKILL.md" "$SCRIPT_DIR/references" "$SCRIPT_DIR/templates" "$SCRIPT_DIR/docs" "$SCRIPT_DIR/scripts" "$REPO_ROOT/plugins/product-development/README.md" +} + +@test "workflow references use workflow names and nothing links the old phase names" { + [ -f "$SCRIPT_DIR/references/requirements.md" ] + [ -f "$SCRIPT_DIR/references/user-stories.md" ] + [ -f "$SCRIPT_DIR/references/bdd-scenarios.md" ] + [ ! -e "$SCRIPT_DIR/references/phase-2-requirements.md" ] + [ ! -e "$SCRIPT_DIR/references/phase-3-user-stories.md" ] + [ ! -e "$SCRIPT_DIR/references/phase-4-scenarios.md" ] + run grep -rnE 'phase-[234]-(requirements|user-stories|scenarios)' "$REPO_ROOT" --exclude-dir=.git --exclude=init.bats + [ "$status" -eq 1 ] +} + +# --- Glossary and ADR --- + +@test "glossary exists, SKILL.md links it, and the root context map points to it" { + [ -f "$SCRIPT_DIR/CONTEXT.md" ] + grep -q "^## Language" "$SCRIPT_DIR/CONTEXT.md" + grep -q "^\*\*Foundation Gate\*\*:" "$SCRIPT_DIR/CONTEXT.md" + grep -q "^\*\*Stage\*\*:" "$SCRIPT_DIR/CONTEXT.md" + grep -q "(CONTEXT.md)" "$SCRIPT_DIR/SKILL.md" + [ -f "$REPO_ROOT/CONTEXT-MAP.md" ] + grep -q "plugins/product-development/skills/product-development/CONTEXT.md" "$REPO_ROOT/CONTEXT-MAP.md" +} + +@test "ADR records that stage directories carry authority" { + [ -f "$REPO_ROOT/docs/adr/0001-stage-directories-carry-authority.md" ] + grep -q "The path settles authority, not every lifecycle state" "$REPO_ROOT/docs/adr/0001-stage-directories-carry-authority.md" + grep -q "Ratified and Shipped share a path" "$REPO_ROOT/docs/adr/0001-stage-directories-carry-authority.md" + refute_grep -q "a change's state will come from its path" "$REPO_ROOT/docs/adr/0001-stage-directories-carry-authority.md" +} + +# --- Stage guidance --- + +@test "README and AGENTS.md describe the three stages and the promotion rule" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + for file in README.md AGENTS.md; do + grep -q '`ideas/`' "$TEST_PROJECT/docs/product/$file" + grep -q '`shaping/`' "$TEST_PROJECT/docs/product/$file" + grep -q '`features/`' "$TEST_PROJECT/docs/product/$file" + grep -q "promotion PR" "$TEST_PROJECT/docs/product/$file" + grep -q "Code alone never admits a spec" "$TEST_PROJECT/docs/product/$file" + done + grep -q "## Stages" "$TEST_PROJECT/docs/product/README.md" +} + +@test "skill and methodology describe the three stages and the promotion rule" { + for file in "$SCRIPT_DIR/SKILL.md" "$SCRIPT_DIR/docs/METHODOLOGY.md"; do + grep -q '`ideas/`' "$file" + grep -q '`shaping/`' "$file" + grep -q '`features/`' "$file" + grep -q "promotion PR" "$file" + grep -q "Code alone never admits a spec" "$file" + done +} + +@test "Foundation Gate blocks PRD drafting, not ideas or shaping" { + grep -q "The Foundation Gate blocks drafting a PRD, not ideas or shaping" "$SCRIPT_DIR/SKILL.md" + grep -q "blocks drafting a PRD, not ideas or shaping" "$SCRIPT_DIR/templates/README.md.tmpl" + grep -q "blocks drafting a PRD, not ideas or shaping" "$SCRIPT_DIR/templates/AGENTS.md.tmpl" +} + +@test "skill links the idea discovery and spike reference" { + grep -q "references/idea-discovery-and-spikes.md" "$SCRIPT_DIR/SKILL.md" + grep -q "## Idea discovery" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" + grep -q "## Spikes" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" + grep -q "## Decision ledger" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" + grep -q "never in \`docs/product/\`" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" +} + +# --- Generic examples --- + +@test "user stories reference takes personas from the PRD" { + grep -q "Take personas from the PRD" "$SCRIPT_DIR/references/user-stories.md" + refute_grep -q "Common .* personas" "$SCRIPT_DIR/references/user-stories.md" +} + +@test "requirements reference points to the skill's structure instead of a project's feature folders" { + refute_grep -q "## Existing Examples" "$SCRIPT_DIR/references/requirements.md" + refute_grep -qE 'docs/product/features/[a-z]' "$SCRIPT_DIR/references/requirements.md" +} + +# --- Workflow hand-offs --- + +@test "brainstorming saves the design to shaping and returns control before ratification" { + grep -q 'save the approved design as the change.s shaping document in `docs/product/shaping/{feature}/`, then return control to this skill' "$SCRIPT_DIR/SKILL.md" + grep -q 'Do not invoke `writing-plans` or plan implementation before the change is ratified' "$SCRIPT_DIR/SKILL.md" +} + +@test "a missing foundation document triggers the Foundation workflow only at PRD drafting" { + grep -q "A missing foundation document does not trigger this workflow during ideas, discovery, design or other shaping work" "$SCRIPT_DIR/SKILL.md" + grep -q "The user asks to create, update or approve product-anchor docs" "$SCRIPT_DIR/SKILL.md" +} + +@test "promotion marks its layout provisional and stops on a name collision" { + grep -q "The feature-root destination is provisional" "$SCRIPT_DIR/SKILL.md" + grep -q "issue #23" "$SCRIPT_DIR/SKILL.md" + grep -q "stop and ask the maintainer. Never overwrite a ratified document during promotion" "$SCRIPT_DIR/SKILL.md" +} + +@test "surface-specific scenarios are written before promotion and listed in the promotion PR" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + grep -q 'surface-specific scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` before promotion' "$TEST_PROJECT/docs/product/AGENTS.md" + grep -q "lists each app-local scenario file it adds or changes" "$TEST_PROJECT/docs/product/AGENTS.md" + refute_grep -q "Surface-specific scenarios and step definitions are created during implementation" "$TEST_PROJECT/docs/product/AGENTS.md" + grep -q "lists each app-local scenario file" "$SCRIPT_DIR/SKILL.md" + grep -q "before promotion" "$SCRIPT_DIR/references/bdd-scenarios.md" + + # In the generated README's artifact flow, platform and surface scenarios + # come together, before the promotion PR. + local readme="$TEST_PROJECT/docs/product/README.md" platform surface promotion + platform=$(grep -n "^Platform Scenarios" "$readme" | cut -d: -f1) + surface=$(grep -n "^Surface Scenarios" "$readme" | cut -d: -f1) + promotion=$(grep -n "^Promotion PR" "$readme" | cut -d: -f1) + [ -n "$platform" ] && [ -n "$surface" ] && [ -n "$promotion" ] + [ "$surface" -eq $((platform + 2)) ] + [ "$surface" -lt "$promotion" ] +} + +@test "re-running after a partial run fills the missing scaffold files and keeps the rest" { + mkdir -p "$TEST_PROJECT/docs/product" + echo "kept README" > "$TEST_PROJECT/docs/product/README.md" + + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + [ "$(cat "$TEST_PROJECT/docs/product/README.md")" = "kept README" ] + [ -f "$TEST_PROJECT/docs/product/AGENTS.md" ] + for stage in ideas shaping features; do + [ -f "$TEST_PROJECT/docs/product/$stage/AGENTS.md" ] + done +} + +@test "Project Setup skips only when every scaffold file exists" { + local setup + setup=$(sed -n '/^### Project Setup/,/^### Foundation workflow/p' "$SCRIPT_DIR/SKILL.md") + grep -q "Skip only when every scaffold file exists" <<< "$setup" + grep -q 're-run `scripts/init.sh`' <<< "$setup" + refute_grep -q 'Skip if `docs/product/README.md` already exists' <<< "$setup" + grep -qE '^\| No `docs/product/` directory, or any scaffold file missing .*\| Project Setup \|$' "$SCRIPT_DIR/SKILL.md" + for file in README.md AGENTS.md ideas/AGENTS.md shaping/AGENTS.md features/AGENTS.md; do + grep -qF "docs/product/$file" <<< "$setup" + done +} + +@test "changes to ratified specs go through shaping and promotion, not in-place edits" { + run "$INIT_SCRIPT" "$TEST_PROJECT" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + for file in "$TEST_PROJECT/docs/product/AGENTS.md" "$SCRIPT_DIR/docs/METHODOLOGY.md" "$SCRIPT_DIR/SKILL.md" \ + "$SCRIPT_DIR/references/requirements.md" "$REPO_ROOT/plugins/product-development/README.md"; do + # Join wrapped lines so a sentence matches wherever it breaks. + local text + text=$(tr -s '\n ' ' ' < "$file") + grep -q "A change to requirements, stories or scenarios is drafted in [^ ]*shaping/[^ ]* and ratified by a promotion PR" <<< "$text" + grep -q "edits that don't change meaning (typos, links, clarifications) go directly into ratified documents" <<< "$text" + done + refute_grep -q "update in place and append" "$TEST_PROJECT/docs/product/AGENTS.md" + refute_grep -q "update the document in place" "$SCRIPT_DIR/references/requirements.md" + refute_grep -q "updated in place with a changelog" "$REPO_ROOT/plugins/product-development/README.md" + refute_grep -q "^Update in place when" "$SCRIPT_DIR/docs/METHODOLOGY.md" + refute_grep -q "Edit the document directly" "$SCRIPT_DIR/docs/METHODOLOGY.md" + grep -q "issue #23" "$SCRIPT_DIR/docs/METHODOLOGY.md" +} + +@test "implementation planning loads ratified platform and app-local scenarios" { + local planning + planning=$(sed -n '/^### Implementation Planning/,/^## /p' "$SCRIPT_DIR/SKILL.md") + grep -q 'ratified platform scenarios from `docs/product/features/{feature}/scenarios/`' <<< "$planning" + grep -q 'ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed' <<< "$planning" +} + +@test "every spike ledger decision lands in one of four destinations before the ledger is deleted" { + grep -q "every recorded decision moves to one of four destinations" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" + grep -q "Delete the ledger only after every entry has landed" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" + refute_grep -q "Dropped, with the maintainer" "$SCRIPT_DIR/references/idea-discovery-and-spikes.md" +} From b2ee9256b052f0df12a80d3d9e144cb51d3d97cb Mon Sep 17 00:00:00 2001 From: John Lianoglou Date: Sun, 29 Nov 2026 18:37:53 -0500 Subject: [PATCH 02/15] feat(product-development): add feature directories, changes and deltas (#50) Every PRD and TRD now describes a change. docs/product/ is one OKF v0.3 bundle; each feature directory holds a feature spec (overview plus facet specs), log.md, changes// with deltas against stable spec units (base text for MODIFIED and REMOVED), the change's own stories and scenarios, and changes/archive/. Shaping moves to shaping/--/. Adds the overlap and base checks with worked examples and fixtures (two canonizations, first version, feature merge and split), the states and OKF status mapping, the feature and lineage logs without stub bundles, durable-tense rules for specs and deltas (#24), ADRs 0002 and 0003, and bumps the plugin to 0.2.0. Refs #23, #24, #35 --- ...deltas-with-base-text-canonized-at-ship.md | 22 + ...3-product-documents-form-one-okf-bundle.md | 21 + docs/development.md | 1 + .../.claude-plugin/plugin.json | 2 +- .../.codex-plugin/plugin.json | 2 +- plugins/product-development/README.md | 45 +- .../product-development/gemini-extension.json | 2 +- plugins/product-development/package.json | 2 +- plugins/product-development/plugin.json | 2 +- .../skills/product-development/CONTEXT.md | 2 +- .../skills/product-development/SKILL.md | 83 +- .../product-development/docs/METHODOLOGY.md | 120 +- .../references/bdd-scenarios.md | 14 +- .../references/changes-and-deltas.md | 318 ++++ .../references/feature-bundles.md | 175 ++ .../references/requirements.md | 87 +- .../references/user-stories.md | 32 +- .../templates/AGENTS.md.tmpl | 21 +- .../templates/README.md.tmpl | 37 +- .../templates/documents/delta.md.tmpl | 100 ++ .../templates/documents/feature-log.md.tmpl | 23 + .../documents/feature-spec-facet.md.tmpl | 21 + .../documents/feature-spec-overview.md.tmpl | 31 + .../templates/documents/lineage-log.md.tmpl | 33 + .../templates/features/AGENTS.md.tmpl | 18 +- .../templates/shaping/AGENTS.md.tmpl | 6 +- .../tests/feature-evolution.bats | 1427 +++++++++++++++++ .../tests/fixtures/feature-merge/README.md | 11 + .../deltas/sharing.delta.md | 28 + .../deltas/calendar-links/sharing.delta.md | 28 + .../deltas/sharing.delta.md | 28 + .../2027-01-20-absorb-calendar-links/PRD.md | 27 + .../deltas/calendar-links/sharing.delta.md | 60 + .../deltas/sharing.delta.md | 48 + .../expected/shared-calendars/log.md | 20 + .../scenarios/calendar-links.feature | 13 + .../shared-calendars/shared-calendars-spec.md | 26 + .../expected/shared-calendars/sharing.md | 33 + .../calendar-links/calendar-links-spec.md | 21 + .../feature-merge/start/calendar-links/log.md | 8 + .../scenarios/calendar-links.feature | 13 + .../start/calendar-links/sharing.md | 25 + .../changes/absorb-calendar-links/PRD.md | 27 + .../deltas/calendar-links/sharing.delta.md | 60 + .../deltas/sharing.delta.md | 48 + .../scenarios/calendar-links.feature | 13 + .../start/shared-calendars/log.md | 15 + .../shared-calendars/shared-calendars-spec.md | 26 + .../start/shared-calendars/sharing.md | 21 + .../tests/fixtures/feature-split/README.md | 11 + .../calendar-links/calendar-links-spec.md | 21 + .../expected/calendar-links/log.md | 14 + .../expected/calendar-links/sharing.md | 21 + .../2027-03-10-split-calendar-links/PRD.md | 26 + .../calendar-links-spec.delta.md | 54 + .../deltas/calendar-links/sharing.delta.md | 52 + .../deltas/sharing.delta.md | 30 + .../expected/shared-calendars/log.md | 20 + .../shared-calendars/shared-calendars-spec.md | 21 + .../expected/shared-calendars/sharing.md | 21 + .../calendar-links/calendar-links-spec.md | 13 + .../feature-split/start/calendar-links/log.md | 9 + .../changes/split-calendar-links/PRD.md | 26 + .../calendar-links-spec.delta.md | 54 + .../deltas/calendar-links/sharing.delta.md | 52 + .../deltas/sharing.delta.md | 30 + .../start/shared-calendars/log.md | 15 + .../shared-calendars/shared-calendars-spec.md | 21 + .../start/shared-calendars/sharing.md | 29 + .../tests/fixtures/first-version/README.md | 11 + .../2026-09-14-event-invitations/PRD.md | 27 + .../deltas/invitations.delta.md | 56 + .../deltas/reminders.delta.md | 42 + .../deltas/shared-calendars-spec.delta.md | 60 + .../expected/shared-calendars/invitations.md | 21 + .../expected/shared-calendars/log.md | 20 + .../expected/shared-calendars/reminders.md | 17 + .../scenarios/event-reminders.feature | 8 + .../scenarios/invitation-responses.feature | 8 + .../shared-calendars/shared-calendars-spec.md | 27 + .../stories/US-001-respond-to-invitation.md | 22 + .../deltas/invitations.delta.md | 56 + .../deltas/shared-calendars-spec.delta.md | 59 + .../changes/event-invitations/PRD.md | 27 + .../deltas/invitations.delta.md | 56 + .../deltas/reminders.delta.md | 42 + .../deltas/shared-calendars-spec.delta.md | 60 + .../scenarios/event-reminders.feature | 8 + .../scenarios/invitation-responses.feature | 8 + .../stories/US-001-respond-to-invitation.md | 22 + .../start/shared-calendars/log.md | 15 + .../shared-calendars/shared-calendars-spec.md | 13 + .../fixtures/two-canonizations/README.md | 12 + .../deltas/invitations.delta.md | 84 + .../archive/2026-12-01-invite-expiry/PRD.md | 26 + .../archive/2026-12-01-invite-expiry/TRD.md | 25 + .../deltas/invitations.delta.md | 46 + .../2026-12-15-decline-with-note/PRD.md | 27 + .../2026-12-15-decline-with-note/TRD.md | 25 + .../deltas/invitations.delta.md | 84 + .../expected/shared-calendars/invitations.md | 33 + .../expected/shared-calendars/log.md | 43 + .../scenarios/invitation-expiry.feature | 14 + .../scenarios/invitation-responses.feature | 21 + .../shared-calendars/shared-calendars-spec.md | 26 + .../stories/US-001-respond-to-invitation.md | 22 + .../stories/US-007-invitation-expiry.md | 22 + .../stories/US-008-decline-with-note.md | 22 + .../deltas/invitations.delta.md | 84 + .../changes/decline-with-note/PRD.md | 27 + .../changes/decline-with-note/TRD.md | 25 + .../deltas/invitations.delta.md | 84 + .../scenarios/invitation-responses.feature | 21 + .../stories/US-008-decline-with-note.md | 22 + .../changes/invite-expiry/PRD.md | 26 + .../changes/invite-expiry/TRD.md | 25 + .../invite-expiry/deltas/invitations.delta.md | 46 + .../scenarios/invitation-expiry.feature | 14 + .../stories/US-007-invitation-expiry.md | 22 + .../start/shared-calendars/invitations.md | 25 + .../start/shared-calendars/log.md | 32 + .../scenarios/invitation-responses.feature | 15 + .../shared-calendars/shared-calendars-spec.md | 26 + .../stories/US-001-respond-to-invitation.md | 22 + .../tests/helpers/deltas.py | 876 ++++++++++ .../product-development/tests/init.bats | 17 +- .../tests/plugin-package.bats | 10 +- 127 files changed, 6227 insertions(+), 195 deletions(-) create mode 100644 docs/adr/0002-deltas-with-base-text-canonized-at-ship.md create mode 100644 docs/adr/0003-product-documents-form-one-okf-bundle.md create mode 100644 plugins/product-development/skills/product-development/references/changes-and-deltas.md create mode 100644 plugins/product-development/skills/product-development/references/feature-bundles.md create mode 100644 plugins/product-development/skills/product-development/templates/documents/delta.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/documents/feature-log.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/documents/feature-spec-facet.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/documents/feature-spec-overview.md.tmpl create mode 100644 plugins/product-development/skills/product-development/templates/documents/lineage-log.md.tmpl create mode 100644 plugins/product-development/skills/product-development/tests/feature-evolution.bats create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/README.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/calendar-links--link-expiry/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--link-expiry/deltas/calendar-links/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--share-roles/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/calendar-links/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/scenarios/calendar-links.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/calendar-links-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/scenarios/calendar-links.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/calendar-links/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/scenarios/calendar-links.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/README.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/calendar-links-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/calendar-links-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/sharing.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/sharing.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/README.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/reminders.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/shared-calendars-spec.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/invitations.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/reminders.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/event-reminders.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/invitation-responses.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/stories/US-001-respond-to-invitation.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/shared-calendars-spec.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/reminders.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/shared-calendars-spec.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/event-reminders.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/invitation-responses.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/stories/US-001-respond-to-invitation.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/README.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/drafts/shared-calendars--decline-with-note/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/TRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/TRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/invitations.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-expiry.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-responses.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-001-respond-to-invitation.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-007-invitation-expiry.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-008-decline-with-note.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/rebased/decline-with-note/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/TRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/scenarios/invitation-responses.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/stories/US-008-decline-with-note.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/TRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/deltas/invitations.delta.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/scenarios/invitation-expiry.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/stories/US-007-invitation-expiry.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/invitations.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/log.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/scenarios/invitation-responses.feature create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/shared-calendars-spec.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/stories/US-001-respond-to-invitation.md create mode 100755 plugins/product-development/skills/product-development/tests/helpers/deltas.py diff --git a/docs/adr/0002-deltas-with-base-text-canonized-at-ship.md b/docs/adr/0002-deltas-with-base-text-canonized-at-ship.md new file mode 100644 index 0000000..31619f3 --- /dev/null +++ b/docs/adr/0002-deltas-with-base-text-canonized-at-ship.md @@ -0,0 +1,22 @@ +# Deltas with base text, canonized at ship + +The product-development skill describes each feature twice over. The feature spec says what the feature does now and holds shipped behavior only. A change says what one bounded addition or revision will do, including the feature's first version. A change carries deltas: each delta lists the spec units it adds, modifies or removes, named by stable ID (`FR-12`) or as a whole scenario file. A modified or removed unit records its base text, the content the change was written against. The deltas reach the feature spec at canonization, after the change ships, not when it is ratified. + +Base text is what makes parallel changes safe. Without it, two changes that edit one requirement can't tell that the other exists, and whichever is applied second overwrites the first. OpenSpec, which uses a similar delta model, documents exactly this failure: the second archive silently drops the first change's edits. Here two checks prevent it. The overlap check, when a promotion PR is prepared and again just before it merges, finds other in-flight changes that touch the same spec units or add a unit with the same ID, so the maintainer can order or combine them. The base check, at canonization and again just before the canonization PR merges, compares each recorded base text with the latest feature spec; if the spec has drifted, the delta is rebased first and the maintainer confirms any change in meaning. + +Canonizing at ship keeps the feature spec true. A ratified change that never ships, ships late or ships differently never puts unshipped behavior into the spec. + +## Considered options + +- **Edit the PRD and TRD in place, with a changelog table.** Rejected: the document can't hold an approved change that hasn't shipped without mixing it into shipped behavior, and history ends up in tables nobody reads. +- **Apply deltas when the change is ratified.** Rejected: the spec would describe behavior that hasn't shipped, and a dropped or deferred requirement would have to be backed out of it. +- **Deltas without base text, as a list of new versions.** Rejected: nothing detects that the spec changed under a delta, so parallel changes overwrite each other silently. +- **Line diffs against the spec.** Rejected: diffs break on unrelated edits and give no unit to reason about. Units with stable IDs survive moves and reformatting. + +## Consequences + +- Every PRD and TRD describes a change, including the first version. A change record is dated history, so planning tense is correct in it. The feature spec and delta text use durable tense, since canonization applies delta text word for word. +- Spec units need stable IDs, unique within their feature and never reused. Scenario files are units as whole files. +- A change keeps its own stories and scenarios until canonization, so an expectation that hasn't shipped never sits beside shipped ones. +- The archive keeps each change's ratified deltas, so the reason for every spec unit stays traceable to the change that wrote it. +- Each feature's log records ratification, the ship signal and canonization, replacing changelog tables. diff --git a/docs/adr/0003-product-documents-form-one-okf-bundle.md b/docs/adr/0003-product-documents-form-one-okf-bundle.md new file mode 100644 index 0000000..478bda1 --- /dev/null +++ b/docs/adr/0003-product-documents-form-one-okf-bundle.md @@ -0,0 +1,21 @@ +# Product documents form one OKF bundle + +The product-development skill treats `docs/product/` as one Open Knowledge Format (OKF) v0.3 bundle. `docs/product/index.md` is the bundle root and declares `okf_version: "0.3"`. Every directory gets a generated `index.md`; below the root these are plain listings without front matter. Each feature directory is a self-contained subtree with its own `log.md`, and a feature's metadata lives in the front matter of its feature spec overview, `-spec.md`. + +A document's `type` comes from a closed list: `constitution`, `vision`, `research-note`, `idea`, `shaping`, `feature-spec-overview`, `feature-spec-facet`, `prd`, `trd`, `delta`, `story`, `delivery-plan`, `open-questions`. Values are lowercase kebab-case. What a facet spec covers, such as a workflow, a contract or a user type, goes in open `tags`. A closed type list lets checks and agents rely on a fixed set of document kinds; open tags let each product describe its facets in its own words. + +OKF `status` follows from the document's path: `draft` in `ideas/` and `shaping/`, `stable` for ratified changes and feature specs, and `deprecated` for archived changes. The path is the authority, as ADR 0001 (stage directories carry authority) records; `status` mirrors it for OKF consumers, and a check fails when the two disagree. + +## Considered options + +- **No OKF profile.** Rejected: agents would keep navigating by directory listings alone, and nothing would check that a document's kind and readiness match where it sits. +- **One bundle per feature.** Rejected: foundation documents, ideas and shaping would sit outside every bundle, and links between features would cross bundle boundaries. +- **An open `type` vocabulary.** Rejected: checks and agents can't rely on a kind they don't know, and near-duplicate types drift apart. +- **Front matter on every Markdown file.** Rejected: OKF v0.3 does not require it. A file without a `type` is not a concept, so `README.md` and `AGENTS.md` keep their roles, and `.feature` files stay assets. + +## Consequences + +- ADRs, engineering references and test code stay outside `docs/product/`; links to them are external links, which OKF consumers accept even when broken. +- `index.md` and `log.md` are reserved names at every level. Only the bundle-root `index.md` carries front matter. +- Moving a document between stages changes its `status` in the same pull request. +- The profile reference, the index generator and the profile checks are delivered separately, under the OKF profile work. diff --git a/docs/development.md b/docs/development.md index d30ac60..726b953 100644 --- a/docs/development.md +++ b/docs/development.md @@ -136,6 +136,7 @@ should reflect the target project's domain. nix develop -c bats tests/marketplace-package.bats nix develop -c bats plugins/product-development/tests/plugin-package.bats nix develop -c bats plugins/product-development/skills/product-development/tests/init.bats +nix develop -c bats plugins/product-development/skills/product-development/tests/feature-evolution.bats nix develop -c bats plugins/delivery-engineering/tests/plugin-package.bats nix develop -c bats plugins/okf-bundle/tests/plugin-package.bats nix develop -c bats plugins/branch-guard/tests diff --git a/plugins/product-development/.claude-plugin/plugin.json b/plugins/product-development/.claude-plugin/plugin.json index 745fc3d..c78cbf6 100644 --- a/plugins/product-development/.claude-plugin/plugin.json +++ b/plugins/product-development/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "product-development", - "version": "0.1.0", + "version": "0.2.0", "description": "Product development lifecycle workflows as portable agent skills.", "author": { "name": "Prometheas Labs" diff --git a/plugins/product-development/.codex-plugin/plugin.json b/plugins/product-development/.codex-plugin/plugin.json index 7ca80ad..1679c5d 100644 --- a/plugins/product-development/.codex-plugin/plugin.json +++ b/plugins/product-development/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "product-development", - "version": "0.1.0", + "version": "0.2.0", "description": "Product development lifecycle workflows as portable agent skills.", "author": { "name": "Prometheas Labs" diff --git a/plugins/product-development/README.md b/plugins/product-development/README.md index 95b350d..3fa0336 100644 --- a/plugins/product-development/README.md +++ b/plugins/product-development/README.md @@ -2,7 +2,8 @@ The Product Development methodology as a portable agent plugin. It guides features through the product development lifecycle from idea to implementation -plan, producing artifacts that feed the next workflow. +plan, producing artifacts that feed the next workflow, and keeps each feature's +spec true as its changes ship. The canonical methodology lives in `skills/product-development/`. Marketplace manifests and adapter wrappers expose @@ -17,7 +18,7 @@ This plugin guides agents through product artifacts in a deliberate sequence, with human review gates between each workflow: ```text -Project Setup -> Foundation workflow -> Discovery and Design -> Requirements -> User Stories -> BDD Scenarios -> Promotion -> Implementation Planning +Project Setup -> Foundation workflow -> Discovery and Design -> Requirements -> User Stories -> BDD Scenarios -> Promotion -> Implementation Planning -> Canonization | | | | | Design Approval PRD/TRD Approval Story Approval Scenario Approval Ratification + Foundation Gate @@ -37,6 +38,14 @@ ratified changes and shipped feature specs, which are the requirements. Merging a change's promotion PR ratifies it and moves it into `features/`. Code alone never admits a spec. +Each feature has a feature bundle in `features/{feature}/`. Its feature spec +describes shipped behavior only. Every PRD and TRD describes a change, including +a feature's first version, and each change carries deltas: the spec units it +adds, modifies or removes, with base text for each one it modifies or removes. +When a change ships, canonization applies its deltas to the feature spec and +archives the change. An overlap check and a base check stop two changes to one +feature from silently overwriting each other. + ## Start A Product Workflow After installing the plugin, ask your agent to initialize product docs in the @@ -74,14 +83,16 @@ At each gate, you can: | Project Setup | Documentation structure | `docs/product/README.md`, `docs/product/AGENTS.md` | | Foundation workflow | Constitution | `docs/product/constitution.md`, `docs/product/constitutions/constitution-vX.Y.Z.md` | | Foundation workflow | Product vision | `docs/product/vision.md`, `docs/product/visions/vision-vX.Y.Z.md` | -| Discovery and Design | Shaping document | `docs/product/shaping/{feature}/` | -| Requirements | PRD | `docs/product/shaping/{feature}/PRD.md` | -| Requirements | TRD | `docs/product/shaping/{feature}/TRD.md` | -| User Stories | User stories | `docs/product/shaping/{feature}/stories/*.md` | -| BDD Scenarios | Platform scenarios | `docs/product/shaping/{feature}/scenarios/*.feature` | +| Discovery and Design | Shaping document | `docs/product/shaping/{feature}--{change}/` | +| Requirements | PRD | `docs/product/shaping/{feature}--{change}/PRD.md` | +| Requirements | TRD | `docs/product/shaping/{feature}--{change}/TRD.md` | +| Requirements | Deltas | `docs/product/shaping/{feature}--{change}/deltas/{facet}.delta.md` | +| User Stories | User stories | `docs/product/shaping/{feature}--{change}/stories/*.md` | +| BDD Scenarios | Platform scenarios | `docs/product/shaping/{feature}--{change}/scenarios/*.feature` | | BDD Scenarios | Surface scenarios | `apps/{surface}/docs/features/{feature}/scenarios/*.feature` | -| Promotion | Ratified change | `docs/product/features/{feature}/` | +| Promotion | Ratified change | `docs/product/features/{feature}/changes/{change}/` | | Implementation Planning | Implementation plan | `docs/plans/YYYY-MM-DD-.md` | +| Ship Signal and Canonization | Feature spec, feature log, archived change | `docs/product/features/{feature}/` | Platform-level artifacts describe what the product does regardless of which app surface delivers it. Surface-specific artifacts capture behavior tied to a @@ -139,18 +150,24 @@ All TRDs must follow the vendor-agnostic facade pattern. ## Specification Evolution -Product specs are living artifacts: +Product specs evolve through ratified changes: -- PRDs and TRDs keep a changelog recording date, change, and rationale. +- The feature spec describes shipped behavior in durable tense and changes only + when a shipped change is canonized into it. - A change to requirements, stories or scenarios is drafted in `shaping/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. -- User stories progress through a lifecycle from Draft to Ready to In Progress - to Done to Archived. +- A change's PRD and TRD are its dated record, so planning tense is fine in + them. They have no changelog: each feature's `log.md` records its history and + reasons, and `features/log.md` records feature splits, merges and drops. +- A change keeps its own stories and scenarios until canonization moves them to + the feature root. Each file is a unit in the change's deltas, so a deferred + one stays with the archived change. - BDD scenarios are living and self-verifying; when behavior changes, scenarios update and the test suite validates the spec. - Governance docs such as constitution and vision are never edited after approval; a new version supersedes the old one. -When incremental updates are insufficient, supersede with a new document instead -of editing beyond recognition. +A change that would replace most of a feature's spec units is a fundamental +change: its deltas replace them, or it is a feature split, merge or drop +recorded in the lineage log. diff --git a/plugins/product-development/gemini-extension.json b/plugins/product-development/gemini-extension.json index 643b234..6132a9c 100644 --- a/plugins/product-development/gemini-extension.json +++ b/plugins/product-development/gemini-extension.json @@ -1,5 +1,5 @@ { "name": "product-development", - "version": "0.1.0", + "version": "0.2.0", "description": "Product development lifecycle workflows as portable agent skills." } diff --git a/plugins/product-development/package.json b/plugins/product-development/package.json index 6e3b7e6..c206aaa 100644 --- a/plugins/product-development/package.json +++ b/plugins/product-development/package.json @@ -1,6 +1,6 @@ { "name": "product-development", - "version": "0.1.0", + "version": "0.2.0", "description": "Product development lifecycle workflows as portable agent skills.", "private": false, "keywords": [ diff --git a/plugins/product-development/plugin.json b/plugins/product-development/plugin.json index c4b045a..14705a0 100644 --- a/plugins/product-development/plugin.json +++ b/plugins/product-development/plugin.json @@ -1,6 +1,6 @@ { "name": "product-development", - "version": "0.1.0", + "version": "0.2.0", "description": "Product development lifecycle workflows as portable agent skills.", "author": { "name": "Prometheas Labs" diff --git a/plugins/product-development/skills/product-development/CONTEXT.md b/plugins/product-development/skills/product-development/CONTEXT.md index 833facd..8023517 100644 --- a/plugins/product-development/skills/product-development/CONTEXT.md +++ b/plugins/product-development/skills/product-development/CONTEXT.md @@ -69,7 +69,7 @@ The current-state documents of a feature bundle, describing the feature's shippe _Avoid_: Living spec, PRD **Feature overview**: -The document that opens a feature spec, summarizes the feature and links to its facet specs. +The document that opens a feature spec, summarizes the feature and links to its facet specs. Until the feature's first change is canonized, it is metadata-only: front matter, title and History, with no behavior claims, even after that change has shipped. _Avoid_: Entry document, main spec **Facet spec**: diff --git a/plugins/product-development/skills/product-development/SKILL.md b/plugins/product-development/skills/product-development/SKILL.md index 681734b..0863d16 100644 --- a/plugins/product-development/skills/product-development/SKILL.md +++ b/plugins/product-development/skills/product-development/SKILL.md @@ -1,11 +1,11 @@ --- name: product-development -description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, capture an idea, shape a change, run a spike, promote a change, plan implementation, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." +description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, capture an idea, shape a change, run a spike, promote a change, plan implementation, record a ship signal, canonize a shipped change, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." --- # Product Development Lifecycle -Guide features through the product development lifecycle from idea to implementation plan. Each workflow produces specific artifacts that feed into the next. Workflow transitions are gated by human review, with optional automated review passes. +Guide features through the product development lifecycle from idea to implementation plan, and keep each feature spec true once its changes ship. Each workflow produces specific artifacts that feed into the next. Workflow transitions are gated by human review, with optional automated review passes. The skill's glossary is [CONTEXT.md](CONTEXT.md). Use its terms exactly, in conversation and in the documents you write. A word listed under _Avoid_ must not be used as a name for that entry's concept; it stays correct when it names something else, such as the PRD or an implementation plan. @@ -30,9 +30,11 @@ User Stories ← drafted in shaping/ ↓ [human approves stories] → optional review pass BDD Scenarios ← drafted in shaping/ ↓ [human approves scenarios] → optional review pass -Promotion ← promotion PR moves the change into features/ +Promotion ← overlap check; promotion PR moves the change to features/{feature}/changes/{change}/ ↓ [maintainer merges = ratification] -Implementation Planning ← idea discovery first; plans from features/ +Implementation Planning ← idea discovery first; plans from the ratified change + ↓ [project's ship signal fires] → Shipped entry in the feature log +Canonization ← base check; deltas applied to the feature spec; change archived ``` The Foundation Gate blocks drafting a PRD, not ideas or shaping. The default order is still to establish the foundation documents first. Later PRDs must check constitution and vision alignment before proceeding. @@ -57,6 +59,18 @@ Rules: Before a design or plan, run idea discovery: a subagent reads `ideas/` and reports any idea that enables, conflicts with or overlaps the work. Spikes answer shaping questions and keep a decision ledger when run unattended. Consult `references/idea-discovery-and-spikes.md` for both. +## Feature Bundles and Changes + +Each feature has a feature bundle, `docs/product/features/{feature}/`, inside the product's OKF bundle at `docs/product/`. It separates what the feature does now from the changes that got it there: + +- The **feature spec**, `{feature}-spec.md` (the feature overview) plus one facet spec per user type, workflow or contract, describes shipped behavior only, in durable tense. Only canonization changes its meaning. +- A **change** is one bounded addition to or revision of the feature, including its first version. Every PRD and TRD describes a change. The change's **deltas** list the spec units it adds, modifies or removes, with base text for each modified or removed unit. The change keeps its own stories and scenarios until it is canonized. +- The **feature log**, `log.md`, records the feature's history and reasons. The **lineage log**, `features/log.md`, records feature splits, merges and drops, dropped changes, and promotion PRs closed without merging. + +A change's state comes from its path plus two recorded signals: Idea, Shaping, In review (promotion PR open), Ratified (in `changes/{change}/`), Shipped (still in `changes/{change}/`, with a Shipped entry in the feature log), Canonized (in `changes/archive/`) or Dropped (deleted, with a lineage-log entry). + +Consult `references/feature-bundles.md` for the bundle layout, spec units, the OKF `status` mapping and both logs, and `references/changes-and-deltas.md` for the change and delta contract, the overlap and base checks, and worked examples. + ## Workflows ### Project Setup @@ -96,13 +110,13 @@ A missing foundation document does not trigger this workflow during ideas, disco **Trigger:** An idea, feature request, or problem statement arrives, or the maintainer moves an idea to `shaping/`. -**Process:** Run idea discovery first (`references/idea-discovery-and-spikes.md`) and bring its questions to the brainstorming session. Then invoke the `brainstorming` skill. It handles collaborative exploration, approach proposals, and design approval. When a shaping question needs a prototype, run a spike. +**Process:** Run idea discovery first (`references/idea-discovery-and-spikes.md`) and bring its questions to the brainstorming session. Classify the work as a new feature, an incremental amendment, an evolution or migration, or a fundamental change (`references/changes-and-deltas.md`); work on an existing feature is a change to that feature, never a competing feature directory. Then invoke the `brainstorming` skill. It handles collaborative exploration, approach proposals, and design approval. When a shaping question needs a prototype, run a spike. -Override the brainstorming skill's own hand-off. It saves its design under `docs/superpowers/specs/` and then invokes `writing-plans`. Here, save the approved design as the change's shaping document in `docs/product/shaping/{feature}/`, then return control to this skill. Do not invoke `writing-plans` or plan implementation before the change is ratified. +Override the brainstorming skill's own hand-off. It saves its design under `docs/superpowers/specs/` and then invokes `writing-plans`. Here, save the approved design as the change's shaping document in `docs/product/shaping/{feature}--{change}/`, then return control to this skill. The shaping document includes the change's provenance record (`references/changes-and-deltas.md`, Provenance). A change to an existing feature names it in the shaping document's front matter: `x-amends: {feature}`. Do not invoke `writing-plans` or plan implementation before the change is ratified. An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, with no gate. -**Output:** Approved design, saved as the change's shaping document in `docs/product/shaping/{feature}/`. +**Output:** Approved design, saved as the change's shaping document in `docs/product/shaping/{feature}--{change}/`. **Gate:** Do not proceed to Requirements until the design is approved. @@ -112,13 +126,14 @@ An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, **Required inputs:** Approved design document, approved, versioned `docs/product/constitution.md`, and approved, versioned `docs/product/vision.md`. Missing, unapproved, or unversioned foundation documents block first-PRD requirements work. -**Process:** Create product and technical requirements documents. Consult `references/requirements.md` for structure, conventions, constitution alignment, and vision alignment. +**Process:** Create the change's product and technical requirements documents and its deltas. The PRD and TRD describe this change, even when it is the feature's first version; for a feature that already exists, read its feature spec first. Consult `references/requirements.md` for structure, conventions, constitution alignment, and vision alignment, and `references/changes-and-deltas.md` for the delta format. **Gate:** The PRD defines *what*; the TRD defines *how*. Present the PRD for human approval before writing the TRD. This prevents wasted architectural work if the requirements shift. **Output:** -- `docs/product/shaping/{feature}/PRD.md` -- `docs/product/shaping/{feature}/TRD.md` +- `docs/product/shaping/{feature}--{change}/PRD.md` +- `docs/product/shaping/{feature}--{change}/TRD.md` +- `docs/product/shaping/{feature}--{change}/deltas/{facet}.delta.md`, one per feature spec document the change touches **Gate:** Both documents reviewed and approved before proceeding. Run configured review passes (see Configuration). @@ -130,7 +145,7 @@ An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, **Process:** Decompose PRD requirements into user-facing narratives. Consult `references/user-stories.md` for format, sizing guidance, and acceptance criteria conventions. -**Output:** Story files at `docs/product/shaping/{feature}/stories/`. +**Output:** Story files at `docs/product/shaping/{feature}--{change}/stories/`. A revised story is listed in the change's deltas as a whole-file unit. **Gate:** Stories reviewed and approved. Run configured review passes. @@ -143,7 +158,7 @@ An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, **Process:** Express acceptance criteria as Gherkin scenarios. Consult `references/bdd-scenarios.md` for the boundary rule, file placement, and writing conventions. **Output:** -- Platform-level scenarios: `docs/product/shaping/{feature}/scenarios/*.feature` +- Platform-level scenarios: `docs/product/shaping/{feature}--{change}/scenarios/*.feature`, each revised scenario file listed in the change's deltas as a whole-file unit - Surface-specific scenarios: `apps/{surface}/docs/features/{feature}/scenarios/*.feature`, written now, before promotion **Gate:** Scenarios reviewed and approved. Run configured review passes. @@ -154,13 +169,13 @@ An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, **Trigger:** Scenarios are reviewed and cover the acceptance criteria. -**Process:** Open a promotion PR that moves the change's approved documents from `docs/product/shaping/{feature}/` into `docs/product/features/{feature}/`. The maintainer reviews it. Merging the promotion PR ratifies the change; the merge is the approval record. Code alone never admits a spec, so a change whose code has already shipped still goes through promotion. +**Process:** Run the overlap check (`references/changes-and-deltas.md`) and put its report in the promotion PR. Open a promotion PR that moves the change's approved documents from `docs/product/shaping/{feature}--{change}/` into `docs/product/features/{feature}/changes/{change}/`, sets their OKF `status` to `stable`, and adds a Ratified entry to the feature log. For a new feature, the PR also creates the feature bundle: a metadata-only feature overview that claims no behavior, `log.md` and `changes/`. The first canonization writes the complete overview and the facet specs (`references/feature-bundles.md`). The maintainer reviews it and orders or combines any overlapping changes. Run the overlap check again just before the PR merges. Merging the promotion PR ratifies the change; the merge is the approval record. Code alone never admits a spec, so a change whose code has already shipped still goes through promotion. The promotion PR also lists each app-local scenario file under `apps/{surface}/docs/features/{feature}/scenarios/` that it adds or changes, so the maintainer ratifies surface-specific scenarios with the rest of the change. -The feature-root destination is provisional. It holds until the feature-evolution pathway (issue #23) gives each change its own directory. Until then, check for collisions before moving anything: if the destination already holds a PRD, TRD, story or scenario with the same name as one being promoted, stop and ask the maintainer. Never overwrite a ratified document during promotion. +Check for collisions before moving anything: if `features/{feature}/changes/{change}/` already exists, the change name is already used in the change archive, or a new feature's bundle already exists, stop and ask the maintainer. Never overwrite a ratified document during promotion. -**Output:** The ratified change in `docs/product/features/{feature}/`. +**Output:** The ratified change in `docs/product/features/{feature}/changes/{change}/`. **Gate:** Do not plan implementation until the promotion PR has merged. @@ -168,10 +183,20 @@ The feature-root destination is provisional. It holds until the feature-evolutio **Trigger:** The change's promotion PR has merged. -**Process:** Run idea discovery first. Load the approved constitution and approved vision with the ratified platform scenarios from `docs/product/features/{feature}/scenarios/` and the ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed. Read each app-local scenario as it stood at that PR's merge commit (`git show :`), because a later change may already be editing the working copy. Then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. +**Process:** Run idea discovery first. Load the approved constitution and approved vision, the ratified change in `docs/product/features/{feature}/changes/{change}/` with its platform scenarios from `docs/product/features/{feature}/changes/{change}/scenarios/`, the feature spec and shipped scenarios at the feature root, and the ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed. Read each app-local scenario as it stood at that PR's merge commit, resolved from the PR (`git show :`), because a later change may already be editing the working copy. Then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. **Output:** Implementation plan at `docs/plans/YYYY-MM-DD-.md`. +### Ship Signal and Canonization + +**Trigger:** The project's ship signal fires for a ratified change: the event the project names as making a change live, such as the implementation PR merging, a release, or a feature flag reaching everyone. + +**Process:** Record a Shipped entry in the feature log with the evidence. The change stays in `docs/product/features/{feature}/changes/{change}/`; it is now Shipped. Canonization follows: account for each requirement and scenario as shipped, changed or deferred, run the base check, apply the deltas as reconciled with that accounting, move the story and scenario files the reconciled deltas list to the feature root (a deferred file stays with the archived change), archive the change to `changes/archive/YYYY-MM-DD-{change}/`, and write a Canonized entry in the feature log. Consult `references/changes-and-deltas.md` for the contract and the base check. The step-by-step canonization workflow comes with #21 (canonize shipped changes into the feature spec). + +**Output:** The updated feature spec, stories and scenarios at the feature root; the archived change; feature-log entries for Shipped and Canonized. + +**Gate:** The maintainer confirms any change in meaning, any deferred unit and any rebased delta before the canonization PR merges. Run the base check again just before it merges. + ## Gates and Review Passes ### Gate behavior @@ -250,8 +275,9 @@ For each writing workflow, dispatch a sub-agent with only the inputs it needs: | Workflow | Sub-agent receives | Sub-agent returns | |----------|-------------------|-------------------| -| Requirements PRD | Shaping document, constitution, vision, `references/requirements.md`, ratified features in `features/` as examples, if any | PRD written to disk | -| Requirements TRD | Approved PRD, constitution, vision, `references/requirements.md`, ratified features in `features/` as examples, if any | TRD written to disk | +| Requirements PRD | Shaping document, constitution, vision, `references/requirements.md`, the feature spec of the feature it amends, if any | PRD written to disk | +| Requirements TRD | Approved PRD, constitution, vision, `references/requirements.md`, the feature spec of the feature it amends, if any | TRD written to disk | +| Deltas | Approved PRD and TRD, the feature spec, `references/changes-and-deltas.md` | Delta files written to disk | | Idea discovery | Summary of the work, `docs/product/ideas/`, report format from `references/idea-discovery-and-spikes.md` | Report of relevant ideas, nothing else | | User Stories | Approved PRD, TRD, constitution, vision, `references/user-stories.md` | Story files written to disk | | BDD Scenarios | User stories, TRD, constitution, vision, `references/bdd-scenarios.md` | `.feature` files written to disk | @@ -288,8 +314,10 @@ Not every feature starts at the beginning. Match the entry point to the current | Clear requirements, needs documentation | Requirements after Foundation Gate | | PRD exists, needs decomposition | User Stories | | Stories exist, needs testable criteria | BDD Scenarios | +| Discovery suggests the work may evolve an existing feature | Discovery and Design: classify the work first | | Approved change in `shaping/`, not yet ratified | Promotion | -| Ratified change in `features/`, needs implementation | Implementation Planning | +| Ratified change in `features/{feature}/changes/`, needs implementation | Implementation Planning | +| Ship signal fired for a ratified change | Ship Signal and Canonization | | Code exists with no spec | Discovery and Design (code alone never admits a spec) | Clear requirements may skip brainstorming only after Foundation Gate passes. If this is the first PRD and `docs/product/constitution.md` or `docs/product/vision.md` is missing, unapproved, or unversioned, run the Foundation workflow before Requirements. @@ -304,18 +332,18 @@ This skill orchestrates the lifecycle but delegates to specialized skills for bo ## Specification Evolution -Product specifications are living artifacts. Different artifact types evolve at different rates. Consult `docs/METHODOLOGY.md` for the full methodology. Summary: +Product specifications are living artifacts, and each kind changes in its own way. Consult `docs/METHODOLOGY.md` for the full methodology. Summary: | Artifact | Strategy | |----------|----------| | Constitution, Vision | Immutable + supersede (semver) | | Idea, shaping document | Draft; authority comes from the stage directory | -| PRD, TRD | Living document with changelog | -| User Stories | Living — add, complete, archive | -| Platform Scenarios | Living + self-verifying | -| Surface Scenarios | Living + self-verifying | +| Change: PRD, TRD, deltas, its stories and scenarios | Dated record of one change; archived at canonization | +| Feature spec, feature-root stories and scenarios | Current state; changed only by canonization | +| Platform and surface scenarios | Self-verifying | +| Feature log, lineage log | Append-only history | -A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. When updating an existing spec, append to its changelog with date, change, and rationale. When changes are so extensive the document is unrecognizable from its original form, supersede with a new document instead. +A change to requirements, stories or scenarios is drafted in `shaping/{feature}--{change}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. Change events and their reasons go in the feature log, never in spec prose. A fundamental change replaces most of a feature's spec units through its deltas, or is a lineage event recorded in the lineage log. ## Reference Files @@ -325,10 +353,12 @@ Detailed guidance for each workflow lives in reference files to keep context tar - **`references/product-constitution.md`** — Product Constitution workflow, Foundation Gate, Constitution Grill, versioning, amendment behavior, and alignment checks - **`references/product-vision.md`** — Product Vision workflow, Foundation Gate, Vision Grill, versioning, and context/ADR coordination - **`references/idea-discovery-and-spikes.md`** — Idea discovery before a design or plan, spikes, and the decision ledger +- **`references/feature-bundles.md`** — Feature bundle layout, feature spec and spec units, OKF `status` mapping, feature log and lineage log +- **`references/changes-and-deltas.md`** — The change and delta contract, change states, overlap and base checks, worked examples - **`references/requirements.md`** — PRD and TRD structure, conventions, constitution and vision checks - **`references/user-stories.md`** — Story format, acceptance criteria, sizing - **`references/bdd-scenarios.md`** — Gherkin conventions, boundary rule, file placement -- **`docs/METHODOLOGY.md`** — Specification evolution strategies, changelog conventions, supersession rules +- **`docs/METHODOLOGY.md`** — Specification evolution strategies, the change model, feature log conventions Load `references/source/product-constitution-guide.md` only through `references/product-constitution.md` when exact source detail is needed. Load `references/source/vision-document-guide.md` only through `references/product-vision.md` when exact source detail is needed. @@ -341,3 +371,4 @@ Load `references/source/product-constitution-guide.md` only through `references/ - **`templates/README.md.tmpl`** — Documentation hierarchy template - **`templates/AGENTS.md.tmpl`** — Agent guidance template - **`templates/ideas/AGENTS.md.tmpl`**, **`templates/shaping/AGENTS.md.tmpl`**, **`templates/features/AGENTS.md.tmpl`** — Stage guidance: each stage's authority, and when agents read it or stay out +- **`templates/documents/`** — Document templates the agent copies: feature spec overview and facet, delta, feature log and lineage log diff --git a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md index 3609828..9e39319 100644 --- a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md +++ b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md @@ -4,7 +4,7 @@ Product specifications are living artifacts that evolve alongside the product. D ## Core Principle -**Traceability over format.** Whether a specification is updated in place or superseded by a new document, the requirement is that any current specification can be traced back to the decision that created it. Git history provides this for living documents. Explicit supersession headers provide this for immutable documents. +**Traceability over format.** Whether a specification is updated in place or superseded by a new document, the requirement is that any current specification can be traced back to the decision that created it. Git history and the change archive provide this for feature specs and changes. Explicit supersession headers provide this for immutable documents. ## Stages Carry Authority @@ -24,7 +24,35 @@ A product document's authority comes from the stage directory it sits in, not fr - Code alone never admits a spec to `features/`. Behavior found only in code enters through `ideas/` or `shaping/` and is promoted like any other change. - A spike's code never admits a spec either. Its decision ledger lives with the spike, never in `docs/product/`, and its entries move into lasting documents when the spike ends. -The evolution strategies below apply once a document has the authority of its stage: foundation documents once approved, PRDs, TRDs, stories and scenarios once ratified into `features/`. Ideas and shaping documents are drafts and change freely. +The evolution strategies below apply once a document has the authority of its stage: foundation documents once approved, changes once ratified into `features/`, and feature specs always. Ideas and shaping documents are drafts and change freely. + +## The Change Model + +A feature lives in its own feature bundle, `docs/product/features/{feature}/`, inside the product's OKF bundle at `docs/product/`. The bundle separates what the feature does now from the changes that got it there. ADR 0002 (deltas with base text, canonized at ship) and ADR 0003 (product documents form one OKF bundle) record the decisions. `references/feature-bundles.md` and `references/changes-and-deltas.md` hold the details. + +- The **feature spec**, a feature overview plus facet specs, describes shipped behavior only, in durable tense. +- A **change** is one bounded addition to or revision of a feature, including its first version. Every PRD and TRD describes a change. Its **deltas** list the spec units it adds, modifies or removes; each modified or removed unit records its base text. +- A **spec unit** is an independently changeable section of the feature spec with a stable ID, such as `FR-12` invitation expiry or `MEM-02` membership status transitions, or a whole scenario file. +- **Canonization** makes a shipped change part of the feature spec: it accounts for each requirement and scenario as shipped, changed or deferred, applies the deltas as reconciled with that accounting, moves the story and scenario files the reconciled deltas list to the feature root, archives the change, and logs the outcome. Every story and scenario file a change adds or revises is a whole-file unit in its deltas, so a deferred one never reaches the feature root. +- The **feature log** records each feature's dated history and reasons. The **lineage log** records feature splits, merges and drops, dropped changes, and promotion PRs closed without merging. + +### Lifecycle of a change + +1. **Shaping.** The change is drafted in `shaping/{feature}--{change}/`. The shaping document and the PRD hold the change's provenance: affected consumers, compatibility constraints, who decided what and when, evidence with the claim each source supports, rejected alternatives, and non-goals and boundaries for the delivery team (`references/changes-and-deltas.md`, Provenance). A change to an existing feature names it with `x-amends: {feature}`; the ratified feature spec stays in force while the change is worked out. +2. **Ratification.** The maintainer merges the promotion PR, after the overlap check. The change moves to `features/{feature}/changes/{change}/`. The merge is the approval record. +3. **Shipped.** Each project names its ship signal, the event that makes a change live. When it fires, a feature-log entry records the evidence. The change stays in `changes/{change}/`. +4. **Canonization.** After the base check, the deltas are applied to the feature spec, the story and scenario files the reconciled deltas list move to the feature root, the change moves to `changes/archive/YYYY-MM-DD-{change}/` with its ratified deltas' content intact and its documents' `status` set to `deprecated`, and a feature-log entry records the outcome. Deferred requirements become shaping items. The change is now Canonized. The step-by-step workflow comes with #21 (canonize shipped changes into the feature spec). + +A change withdrawn before it ships is Dropped: its directory is deleted and the lineage log records why. + +### Parallel changes + +Two changes to one feature can be in flight together. Two checks keep the second from silently overwriting the first: + +- The **overlap check**, when a promotion PR is prepared and again just before it merges, finds other in-flight changes that touch the same spec units or add a unit with the same ID. The maintainer orders or combines them. +- The **base check**, at canonization and again just before the canonization PR merges, compares each recorded base text with the latest feature spec. If the spec has drifted, the delta is rebased first, and the maintainer confirms any change in meaning. + +`references/changes-and-deltas.md` walks through two parallel changes, and the skill's test fixture runs them. ## Evolution Strategies @@ -45,24 +73,21 @@ The document is never modified after approval. When the specification must chang **Use for:** Governance documents where changes are rare, consequential, and require deliberate review. A quiet edit to the constitution undermines its authority. -### Living Document +### Change Record -The document keeps one current version. A changelog section at the bottom records significant changes with date, description, and rationale. +A change's PRD, TRD, deltas, stories and scenarios are the dated record of one bounded change. They are written before the change ships, so planning tense is correct in the PRD and TRD. They are not re-tensed after it ships: canonization moves the change to the change archive, where the same text reads as history. -**Mechanism:** Once the document is ratified, a change to its meaning is drafted in `shaping/{feature}/` and ratified by a promotion PR (see [When to Supersede vs. Update](#when-to-supersede-vs-update)). Append to the changelog. Git history provides the full diff. +**Mechanism:** Draft in `shaping/{feature}--{change}/`, ratify by a promotion PR, canonize at ship, archive. A later revision of the feature is a new change, not an edit to an earlier one. -```markdown -## Changelog +**Use for:** PRDs, TRDs, deltas, and the stories and scenarios a change adds or revises. -| Date | Change | Rationale | -|------|--------|-----------| -| 2026-03-15 | Added accepting a recurring series in one step | Invitees declined weekly events rather than accept each occurrence | -| 2026-03-01 | Initial version | — | -``` +### Current State, Canonized at Ship -**Use for:** Specifications that evolve incrementally. Adding a new analytics event, refining acceptance criteria, updating a dependency version. +The document describes what the product does now, in durable tense, and changes only when a shipped change is canonized into it. -**When to supersede instead:** If the changes are so extensive that the document is no longer recognizable from its original form — a major pivot, a complete rearchitecture, or a fundamental change in approach — create a new document and supersede the old one rather than editing it beyond recognition. +**Mechanism:** Canonization applies a change's deltas unit by unit, after the base check. Change events go in the feature log, never in the document. Edits that don't change meaning (typos, links, clarifications) may go in directly. + +**Use for:** The feature spec, and the stories and scenarios at the feature root. ### Living + Self-Verifying @@ -78,52 +103,49 @@ The specification is tied to automated tests. When behavior changes, the specifi |----------|----------|----------|-----------| | Constitution | Immutable + supersede (semver) | `docs/product/` | Governance changes are rare and consequential | | Vision | Immutable + supersede (semver) | `docs/product/` | Strategic direction changes are deliberate | -| Idea | Draft, no changelog | `docs/product/ideas/` | No requirements authority; moves to `shaping/` when shaping starts | -| Shaping document | Draft, no changelog | `docs/product/shaping/{feature}/` | Tentative design; moves with its change on promotion | -| PRD | Living document with changelog | `docs/product/shaping/{feature}/` while shaped, `docs/product/features/{feature}/` once ratified | Requirements evolve incrementally | -| TRD | Living document with changelog | `docs/product/shaping/{feature}/` while shaped, `docs/product/features/{feature}/` once ratified | Architecture tracks requirements | -| User Stories | Living — add, complete, archive | `stories/` under the change's stage directory | Stories are transient work items | -| Platform Scenarios | Living + self-verifying | `scenarios/` under the change's stage directory | Executable behavioral contracts | +| Idea | Draft | `docs/product/ideas/` | No requirements authority; moves to `shaping/` when shaping starts | +| Shaping document | Draft | `docs/product/shaping/{feature}--{change}/` | Tentative design; moves with its change on promotion, or is absorbed into the PRD | +| PRD, TRD, deltas | Change record | `shaping/{feature}--{change}/`, then `features/{feature}/changes/{change}/`, then `changes/archive/` | One change, written before it ships | +| Feature spec | Current state, canonized at ship | `docs/product/features/{feature}/` | Shipped behavior only | +| User Stories | Change record, then current state | The change's `stories/`, then the feature root's `stories/` at canonization | Unshipped stories never sit beside shipped ones | +| Platform Scenarios | Living + self-verifying | The change's `scenarios/`, then the feature root's `scenarios/` at canonization | Executable behavioral contracts | | Surface Scenarios | Living + self-verifying | `apps/{surface}/docs/features/{feature}/scenarios/` | Surface-specific executable contracts | +| Feature log, lineage log | Append-only | `features/{feature}/log.md`, `features/log.md` | History and reasons | -## User Story Lifecycle - -Stories have a status field that tracks their progress: +## Feature Log Conventions -- **Draft** — story is being written, acceptance criteria may be incomplete -- **Ready** — story is approved and ready for scenario writing or implementation -- **In Progress** — story is being implemented -- **Done** — story is implemented, scenarios pass -- **Archived** — story has been superseded or is no longer relevant +The feature log replaces the changelog tables PRDs and TRDs used to end with. Each feature's `log.md` holds dated entries, oldest first, for each change's ratification, ship signal and canonization, and for decisions no change record holds. -Done and archived stories remain in the `stories/` directory for traceability. If the directory becomes noisy, completed stories may be moved to `stories/archive/`. +- Record the date, the change, the reason and links +- Link records that outlive canonization: the promotion PR for Ratified, the ship evidence for Shipped, the archive path for Canonized. `changes/{change}/` is deleted when the change is archived +- The reason matters more than the description: git diff shows *what* changed, but not *why* +- Change events ("replaces X", "added Y") go here, never in spec prose +- Consequential decisions also get an ADR, linked from the entry +- Minor corrections (typos, formatting) do not need entries -## Changelog Conventions +The lineage log, `features/log.md`, records events that span features: splits, merges and drops, dropped changes, and promotion PRs closed without merging. A bundle or change that is removed is deleted, not left as a stub; its lineage entry links the last commit that had it. -For living documents (PRDs, TRDs), the changelog section is the last section in the document. +## Classifying a Change -- Record the date, a brief description of the change, and the rationale -- The rationale matters more than the description — git diff shows *what* changed, but not *why* -- The initial version entry has no rationale (it's self-evident) -- Minor corrections (typos, formatting) do not need changelog entries -- Changes to requirements, architecture, or acceptance criteria always get entries +A change to requirements, stories or scenarios is drafted in `shaping/{feature}--{change}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. -## When to Supersede vs. Update +When discovery finds that proposed work may touch an existing feature, classify it before shaping: -A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. +| Classification | Path | +|----------------|------| +| Independent new feature | A change in `shaping/` that creates a new feature bundle when ratified | +| Incremental amendment | A small change, with deltas against the existing feature spec | +| Evolution or migration | A change in `shaping/` that names its target feature with `x-amends: {feature}`. The ratified feature spec stays in force while the change is worked out. | +| Fundamental change | A change whose deltas replace most spec units, or a lineage event (split, merge or drop) recorded in the lineage log | -The feature-evolution pathway (issue #23) will replace these strategies with a full change model. Until then, promotion's collision rule holds: if an amended document would replace a ratified one with the same name, the promotion stops and the maintainer decides. +Work on an existing feature is a change to that feature's bundle, so the feature keeps one lineage. Discovery is not approval: nothing changes the feature spec until a change is ratified and ships. -Amend through shaping and promotion when: -- Adding a new requirement or event to an existing feature -- Refining acceptance criteria based on implementation learnings -- Updating dependency versions or technical details -- Correcting errors discovered during implementation - -Supersede with a new document when: +A fundamental change is the right path when: - Replacing the underlying technology (e.g., migrating from PostHog to another vendor) - Fundamentally changing the privacy or consent model -- Rearchitecting a feature to the point where the original PRD/TRD is unrecognizable -- Changing governance principles (constitution, vision) +- Rearchitecting a feature to the point where most of its spec units would be rewritten +- Splitting one feature into several, or merging several into one + +The threshold is judgment-based: if someone reading the deltas would be confused by the volume of changes relative to the feature's current spec, treat it as a fundamental change and say so in the PRD. -The threshold is judgment-based: if someone reading the document would be confused by the volume of changes relative to the original intent, it's time for a new version. +Constitution and vision changes follow Immutable + Supersede instead. diff --git a/plugins/product-development/skills/product-development/references/bdd-scenarios.md b/plugins/product-development/skills/product-development/references/bdd-scenarios.md index 6dca07c..bdf3332 100644 --- a/plugins/product-development/skills/product-development/references/bdd-scenarios.md +++ b/plugins/product-development/skills/product-development/references/bdd-scenarios.md @@ -4,19 +4,21 @@ Scenarios are **living + self-verifying** artifacts (see `docs/METHODOLOGY.md`). ## Inputs -- User stories at `docs/product/shaping/{feature}/stories/` while the change is drafted -- TRD at `docs/product/shaping/{feature}/TRD.md` (for technical context on what is feasible) -- For a feature that already has ratified documents, also read the baseline in `docs/product/features/{feature}/`: its stories, TRD and existing scenarios +- User stories at `docs/product/shaping/{feature}--{change}/stories/` while the change is drafted +- TRD at `docs/product/shaping/{feature}--{change}/TRD.md` (for technical context on what is feasible) +- For an existing feature, also read its feature spec and the scenarios of shipped behavior in `docs/product/features/{feature}/scenarios/` - Approved, versioned product constitution at `docs/product/constitution.md` - Approved, versioned product vision at `docs/product/vision.md` ## Output Locations **Platform-level scenarios** (surface-neutral behavioral contracts): -Platform-level scenarios are drafted with their change in `shaping/` and move into `docs/product/features/{feature}/scenarios/` when the promotion PR merges. +Platform-level scenarios are drafted with their change in `shaping/` and move with it into `docs/product/features/{feature}/changes/{change}/scenarios/` when the promotion PR merges. They stay in the change until it is canonized, which moves them to `docs/product/features/{feature}/scenarios/` at the feature root. The feature root holds only scenarios of shipped behavior. + +To revise a shipped scenario file, put the new version in the change's `scenarios/` under the same name and list the file in the change's deltas as a modified whole-file unit, with the shipped file as base text. A scenario file is one spec unit, so the overlap and base checks catch two changes that revise it at once. See `references/changes-and-deltas.md`. ``` -docs/product/shaping/{feature}/scenarios/ +docs/product/shaping/{feature}--{change}/scenarios/ ├── {story-or-behavior-name}.feature └── ... ``` @@ -28,7 +30,7 @@ apps/{surface}/docs/features/{feature}/scenarios/ └── ... ``` -Write surface-specific scenarios with the change, before promotion. The promotion PR lists each app-local scenario file it adds or changes. +Write surface-specific scenarios with the change, before promotion. The change lists each app-local scenario file it adds or changes in its deltas, with the file's base text when it existed before the change, and the promotion PR lists them too. If canonization defers one, the canonization PR restores it from that base text, or deletes it when the change added it and there is no base to restore. **Step definitions** (test automation, always app-local): ``` diff --git a/plugins/product-development/skills/product-development/references/changes-and-deltas.md b/plugins/product-development/skills/product-development/references/changes-and-deltas.md new file mode 100644 index 0000000..ae7ff3a --- /dev/null +++ b/plugins/product-development/skills/product-development/references/changes-and-deltas.md @@ -0,0 +1,318 @@ +# Changes and Deltas + +Load this reference when you shape, promote, check or canonize a change to a feature. It defines the change and delta contract: what a change holds, the delta format, spec-unit IDs and base text, the change states, and the overlap and base checks. Where a feature's documents live is in [feature-bundles.md](feature-bundles.md). Terms follow the skill's glossary, [CONTEXT.md](../CONTEXT.md). + +## What a change is + +A change is one bounded addition to or revision of a feature, including the feature's first version. Every PRD and TRD describes a change: + +- The **PRD** says what the change does and why. +- The **TRD** says how the change will be built. +- The **deltas** list the spec units the change adds, modifies or removes in the feature spec. +- The change's own **stories** and **scenarios** describe the behavior it adds or revises. + +A change record is dated history: it describes work that has not shipped when it is written, and reads as the record of that work afterwards. Planning tense is correct in its PRD and TRD. Delta text is the exception: canonization applies it to the feature spec word for word, so it is written in the feature spec's durable tense (see [feature-bundles.md](feature-bundles.md#durable-tense)). + +### Classifying the work + +Before shaping, classify what discovery found. Each class is a change, or a lineage event carried by a change: + +| Classification | Path | +|----------------|------| +| Independent new feature | A change in `shaping/` that creates a new feature bundle when ratified | +| Incremental amendment | A small change, with deltas against the existing feature spec | +| Evolution or migration | A change in `shaping/` whose shaping document names its target feature with `x-amends: {feature}`. The ratified feature spec stays in force while the change is worked out. | +| Fundamental change | A change whose deltas replace most of the feature's spec units, or a lineage event (split, merge or drop) recorded in the lineage log `features/log.md` | + +There is no competing feature directory for work on an existing feature. Work that evolves a feature is a change to that feature's bundle, so the feature keeps one lineage. Creating a new feature beside an existing one, or splitting one, is a decision the maintainer makes through the promotion PR. + +### Provenance + +The shaping document records why the change is being made and on what evidence, and the PRD carries that record forward, so the reasons outlive canonization. Fill in each row; write "none" rather than leave one out. + +| Record | What it holds | +|--------|---------------| +| Current artifacts | The feature spec units, contracts and package or API surfaces the change touches, and the implementation constraints it works within | +| Affected consumers | Upstream and downstream owners, surfaces and integrations the change affects, and the follow-up each one needs | +| Compatibility constraints | Public, package, API and data compatibility the change must keep, its migration effect, and who owns any migration work | +| Decisions | Each stakeholder decision: who decided what, and when, the reason, and the assumptions still unresolved | +| Evidence | Internal evidence (issues, reviews, tests, incidents, consumer requirements) and external sources, each with a direct link and the claim each source supports | +| Rejected alternatives | Each alternative considered and why it lost, including keeping the current boundary and creating an independent feature | +| Non-goals and boundaries | For the active delivery team: the scope, refactors and adjacent clean-up the change excludes, and the boundaries its implementation must not cross | + +Discovery is not approval: the record informs the maintainer's decision, and the promotion PR is where it is made. + +## Change states + +A change's state comes from its path, plus two recorded signals: + +| State | Where the change sits | Signal | OKF `status` | +|-------|----------------------|--------|--------------| +| Idea | `ideas/` | — | `draft` | +| Shaping | `shaping/{feature}--{change}/` | — | `draft` | +| In review | `shaping/{feature}--{change}/` | Its promotion PR is open | `draft` | +| Ratified | `features/{feature}/changes/{change}/` | Its promotion PR merged | `stable` | +| Shipped | `features/{feature}/changes/{change}/` | A feature-log entry records the ship signal | `stable` | +| Canonized | `features/{feature}/changes/archive/YYYY-MM-DD-{change}/` | — | `deprecated` | +| Dropped | Deleted | A lineage-log entry records the drop and its reason | — | + +Ratified and Shipped share a path. Read the feature log to tell them apart: a Shipped change has a Shipped entry. In review is read from the forge, not the tree. + +A Shipped change cannot be dropped. Its behavior is live, so withdrawing it is a new change whose deltas remove that behavior, canonized like any other. + +## Naming + +- `{change}` is lowercase kebab-case and names what the change does: `invite-expiry`, `decline-with-note`. A feature's first version is a change like any other; name it for what it delivers. +- A change name is unique within its feature, including the change archive. Two features may each have a change of the same name, so a change is identified by its feature and name, written `{feature}/{change}`, such as `calendar-links/link-expiry`. Checks, reports and logs that span more than one feature name changes this way. +- While shaped, a change lives in `shaping/{feature}--{change}/`, one directory per change. `{feature}` is the feature it creates or amends. A shaping directory never holds more than one change. +- A change to an existing feature names it in its shaping document's front matter, `x-amends: {feature}`. A change that creates a feature has no `x-amends`. + +## Change directory + +``` +shaping/{feature}--{change}/ while shaped and in review + {change}.md shaping document (type: shaping) + PRD.md type: prd + TRD.md type: trd + deltas/{facet}.delta.md type: delta + deltas/{feature-id}/{facet}.delta.md type: delta, against another feature + stories/US--.md type: story + scenarios/*.feature + {feature-id}/stories/, {feature-id}/scenarios/ + files the change adds to another feature + +features/{feature}/changes/{change}/ once ratified, until canonized + (the same files) +``` + +The promotion PR moves the PRD, TRD, deltas, stories and scenarios from the shaping directory to `features/{feature}/changes/{change}/`, sets their `status` to `stable`, adds a Ratified entry to the feature log, and deletes the shaping directory. The shaping document either moves with the change or is absorbed into the PRD; the PRD keeps the provenance record either way. For a new feature, the promotion PR also creates the feature bundle: a metadata-only feature overview that claims no behavior (see [feature-bundles.md](feature-bundles.md#feature-bundle-layout)), `log.md` and `changes/`. A split into a new feature initializes the receiving bundle the same way (see [feature-bundles.md](feature-bundles.md#no-stub-bundles)). + +## Deltas + +A delta lists the spec units a change adds, modifies or removes in one feature spec document. Write one delta per document the change touches: + +- `deltas/{facet}.delta.md` targets the facet spec `{facet}.md`. +- `deltas/{feature}-spec.delta.md` targets the feature overview. A change that alters the overview outside its units, such as completing a metadata-only overview or adding a Facets row for a new facet, rewrites the whole document with a `DOCUMENT` entry holding `Base text:` and `New text:`. +- A delta that writes a new facet spec targets a document that does not exist yet. It opens with a `DOCUMENT` entry whose `Text:` holds the facet's front matter (`type`, `title`, `description`, `status`, `tags`), title and summary; canonization writes the facet from that entry and the delta's added units. Units for a missing document without a `DOCUMENT` entry are refused. +- `deltas/{feature-id}/{facet}.delta.md` targets `features/{feature-id}/{facet}.md`, a document in another feature. Every delta that touches a feature other than the change's own uses this feature-qualified target, as a merge or split does. Without the qualifier, `deltas/sharing.delta.md` could not tell the change's own `sharing.md` from another feature's. A qualified delta's heading is `# Delta: {feature-id}/{facet}.md`, and its whole-file unit paths are relative to that feature's root. A story or scenario file it adds sits in the change under `{feature-id}/stories/` or `{feature-id}/scenarios/`. + +Checks and reports name a unit in another feature with its feature, such as `calendar-links/FR-01`, and a change in another feature the same way, such as `calendar-links/link-expiry`. + +List each story and scenario file the change adds or revises in the delta of the facet whose behavior it covers. Template: `templates/documents/delta.md.tmpl`. + +### Format + +A delta has up to three unit sections, `## ADDED`, `## MODIFIED` and `## REMOVED`, with one `###` entry per spec unit, and may open with a `## DOCUMENT` section for the whole document and end with a `## App-local scenario files` section. An entry's heading is the unit's ID, or the path of a whole-file unit relative to the feature root. Unit text sits in a fenced block (`~~~markdown`, or `~~~gherkin` for a scenario file) exactly as it reads, or will read, in the feature spec, heading included. + +Fences follow CommonMark. The outer fence is a run of three or more tildes (or backticks), and the payload ends at the first line that holds only a run of the same character at least as long. When the unit itself contains a fenced block, make the outer fence longer than every fence inside it: wrap a unit that contains `~~~` in `~~~~markdown` and `~~~~`. A line of text after a payload's closing fence means an inner fence closed it early; the delta is refused. + +`Section:` names the heading of the section an added unit joins, and it must name exactly one heading in the target document. When two sections share a title, such as a `Requirements` section under both `Members` and `Guests`, give the heading path instead: `Section: Guests > Requirements`. An anchor that matches more than one heading is refused at the base check, and nothing is applied. A plain title that matches no heading starts a new `##` section at the end of the document. + +| Section | Entry holds | +|---------|-------------| +| `ADDED` | `Section:` the heading, or heading path, of the feature spec section the unit joins, then `Text:` and the unit. A whole-file unit holds nothing more: its content is the file in the change's `stories/` or `scenarios/`. A reconciled entry for a split file carries `Text:` with the shipped part (see [Deferred stories and scenarios](#deferred-stories-and-scenarios)). | +| `MODIFIED` | `Base text:` and the unit as it stood when the delta was written, then `New text:` and the unit as the change leaves it. A whole-file unit holds only the base text; the new version is the file in the change. A reconciled entry for a split file adds `New text:` with the shipped part. | +| `REMOVED` | `Base text:` and the unit as it stood when the delta was written. | +| `App-local scenario files` | One entry per app-local scenario file, headed by its path from the repository root: `Base text:` with the file before the change for a revised file, nothing for an added one (see [App-local scenario files](#app-local-scenario-files)). | +| `DOCUMENT` | No `###` entry. `Text:` and the front matter, title and summary of a document the delta writes; or `Base text:` and `New text:` with the whole document, before and after, for a rewrite. A rewrite holds no other entries. | + +```markdown +--- +type: delta +title: Invitations delta for invite-expiry +description: Spec units the invite-expiry change adds and modifies in the invitations facet. +status: stable +--- + +# Delta: invitations.md + +## ADDED + +### FR-12 + +Section: Requirements + +Text: + +~~~markdown +### FR-12 Invitation expiry + +An invitation that has no response 14 days after it was sent expires. The organizer is told when an invitation expires. +~~~ + +### scenarios/invitation-expiry.feature + +### stories/US-007-invitation-expiry.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +~~~ +``` + +Rules: + +- Name every unit the change touches. A unit missing from the deltas is not changed by canonization. +- Copy base text from the current feature spec when the delta is written, without editing it. Base text is the record the base check compares against. +- A new unit takes the next free number for its prefix (see [feature-bundles.md](feature-bundles.md#spec-units)). The PRD uses the same IDs for the requirements it adds or revises, so each PRD requirement traces to the unit it becomes. +- Write `Text:` and `New text:` in durable tense. Words such as "will", "now", "no longer" or "new" do not belong in delta text, because they would land in the feature spec. +- Every story and scenario file the change adds or revises is a whole-file unit with its own entry: `ADDED` for a file new to the feature root, `MODIFIED` for a revised one. The overlap and base checks cover it, and canonization moves only the files the reconciled deltas list, so each file follows the coverage accounting. A change that holds a file its deltas don't list cannot be canonized. + +### Moving a unit + +A unit that moves to another facet, or to another feature, is a `REMOVED` entry, with base text, in the delta of the document it leaves, and an `ADDED` entry in the delta of the document it joins. + +- **Between facets of one feature**, the unit keeps its ID: the base check accepts an `ADDED` ID that the same change removes from the same feature. +- **Into another feature**, the unit keeps its ID when the receiving feature has not used it, checked against its feature spec, its change archive and its changes in flight. Otherwise it takes the next free ID there; the PRD maps the old ID to the new one, and the lineage-log entry records the mapping. + +The overlap check reads the pair as the change's own move. It reports the unit only when another change touches it too, and then says the change `moves` it. + +### App-local scenario files + +Surface-specific scenarios stay with their app, under `apps/{surface}/docs/features/{feature}/scenarios/`, and are written before promotion. The change lists each app-local scenario file it adds or changes in a `## App-local scenario files` section of the relevant delta, one `###` entry per file, headed by its path from the repository root. An entry for a file the change revises holds `Base text:` with the file as it stood before the change; an entry for a file the change adds holds nothing more. At promotion, the recorded base text equals the file as it stood immediately before the promotion PR merged, at the merge commit's first parent (`git show ^1:`), and a file the change adds is absent there. When another change revised the file after the base text was recorded, the promotion PR rebases the base text before it merges. These entries are not whole-file units: the promotion PR edits the files in place, so canonization does not move them. Read an app-local scenario as it stood at the promotion PR's merge commit, resolved from the PR (`git show :`), because a later change may already be editing the working copy. The overlap check compares these paths too. + +Canonization accounts for each app-local file as it does for the change's other scenario files: + +- **Shipped:** the reconciled delta keeps the file's entry as listed, and the file stays as the promotion PR left it. +- **Deferred:** the reconciled delta drops the entry, and the canonization PR restores it from the recorded base text, or deletes a file the change added. +- **Partly shipped:** the reconciled entry carries `New text:` with the base text plus the shipped scenarios, and the canonization PR writes that text. + +Before it restores or rewrites a file, canonization compares it with the file at the promotion PR's merge commit; if another change has edited it since, canonization refuses and the maintainer reconciles the file. Likewise, canonization refuses a deferral whose recorded base text differs from the file at the merge commit's first parent, or that deletes a file present there: putting back a stale base would undo another change's revision. The shaping item a deferral creates starts from the file at the promotion PR's merge commit. + +## A change's stories and scenarios + +A change carries its own stories and scenarios until it is canonized. The feature root keeps only stories and scenarios of shipped behavior, so an expectation that has not shipped never sits beside shipped ones, and anyone reading `scenarios/` at the feature root reads only what the product does. + +Worked example. The `shared-calendars` feature root has `stories/US-001-respond-to-invitation.md` and `scenarios/invitation-responses.feature`. The change `invite-expiry` adds a story and a scenario, and the change `decline-with-note` adds a story and revises the existing scenario file: + +``` +features/shared-calendars/ + stories/US-001-respond-to-invitation.md shipped + scenarios/invitation-responses.feature shipped + changes/invite-expiry/ + stories/US-007-invitation-expiry.md added by the change + scenarios/invitation-expiry.feature added by the change + changes/decline-with-note/ + stories/US-008-decline-with-note.md added by the change + scenarios/invitation-responses.feature the change's revised version +``` + +`decline-with-note`'s delta lists `scenarios/invitation-responses.feature` under `MODIFIED`, with the shipped file as its base text. Until `decline-with-note` is canonized, the shipped version stays at the feature root. At canonization the revised file replaces the shipped one and the added story moves to the feature root, because the reconciled deltas list each of them. The archived change keeps its PRD, TRD and deltas, and any story or scenario file the accounting deferred. + +### Deferred stories and scenarios + +Canonization's accounting decides each story and scenario file, as it decides each requirement: + +- **Shipped or changed:** the reconciled delta keeps the file's entry, and canonization moves the file to the feature root. +- **Deferred:** the reconciled delta drops the file's entry. The file stays in the archived change, and the shaping item the deferral creates starts from a copy of it. A deferred file never reaches the feature root. +- **Partly shipped:** a file that holds both shipped and deferred scenarios is split. The reconciled entry carries the shipped scenarios as its text, `Text:` for an added file or `New text:` for a revised one, and canonization writes that text at the feature root. The change's own file, with the deferred scenarios, stays in the archived change for the shaping item. A story whose acceptance criteria shipped only in part is split the same way. +- **App-local scenario files:** the promotion PR edited them in place, so a deferral restores the file from its recorded base text (see [App-local scenario files](#app-local-scenario-files)). +- **`DOCUMENT` entries:** their text is reconciled like a changed unit, with the maintainer's approval. A description, summary or Facets row that describes deferred behavior is rewritten to describe only what shipped, and links to deferred facet specs, stories or scenarios are removed. A facet spec whose units are all deferred is not written: its delta is left out of the reconciled deltas and stays in the archived change. Canonization resolves every relative link in `DOCUMENT` text, including `./` forms, against the bundle as it will be after canonization, and refuses a link that does not resolve. The rule covers reference-style links: each link reference definition's target resolves the same way. A link to an existing document the change leaves alone resolves; a link to a deferred facet spec, story or scenario, to a file the change removes, or to an app-local scenario file the deferral deletes, does not. The first-version fixture, `tests/fixtures/first-version/`, defers a whole facet this way. + +## Overlap check + +The overlap check finds concurrent changes that target the same spec units, so the maintainer can sequence or combine them before either is ratified. + +**When:** when a change's promotion PR is prepared, and again just before it merges. + +**Compare** the change's deltas against every other change that has not been canonized and touches a feature the deltas touch. For each such feature, that is its ratified and shipped changes in `features/{feature}/changes/`, its changes in `shaping/{feature}--*/`, its open promotion PRs, and any change to another feature whose feature-qualified deltas target it. Compare units by feature and ID: `FR-01` in `shared-calendars` and `FR-01` in `calendar-links` are two units. Compare changes by feature and name: `calendar-links/link-expiry` and `shared-calendars/link-expiry` are two changes. Report every unit that: + +- another change also modifies or removes; +- another change adds with the same ID, even when the two units mean different things; +- is added with an ID the receiving feature's spec or change archive already uses; +- is a whole-file unit, or an app-local scenario path, that another change also touches. + +**Report** to the maintainer in the promotion PR: + +```markdown +| Unit | This change | Other change | Other change's state | +|------|-------------|--------------|----------------------| +| FR-03 | modifies | invite-expiry modifies | Ratified | +| FR-12 | adds "Decline notes" | invite-expiry adds "Invitation expiry" | Ratified | +``` + +**Resolve:** the maintainer either orders the changes, so the later one is rebased at its canonization, or combines them into one change. Two changes adding the same ID always end with one of them renumbered before its promotion PR merges. When no overlap is found, the promotion PR says so in one line. + +## Base check + +The base check finds drift between a delta's base text and the current feature spec, so the delta can be rebased before canonization overwrites anything. + +**When:** at canonization, before the deltas are applied, and again just before the canonization PR merges, against the latest feature spec on the default branch. + +**Check** each delta entry against the feature it targets: the change's own feature, or the feature a feature-qualified delta names. + +- `MODIFIED` and `REMOVED` unit: the recorded base text matches the unit in the feature spec, ignoring trailing whitespace. +- `MODIFIED` and `REMOVED` whole-file unit: the base text matches the file at the feature root. +- `DOCUMENT` entry: a document the delta writes does not exist yet; a rewritten document matches its base text. +- `ADDED` unit: no unit in the target feature's spec has its ID, unless the same change removes that ID from that feature ([a move](#moving-a-unit)), and its `Section:` anchor names at most one heading in the target document. `ADDED` whole-file unit: no file exists at its path at the feature root. +- Unit IDs are unique per feature after the change: with every delta applied, each ID appears once across the feature's spec documents. Two entries that add the same free ID, in different facets or the same one, are refused; a move leaves exactly one copy. + +**Rebase** when a unit has drifted: write the change's edit again on top of the unit as it now stands, so the result keeps both the other change's edits and this one's. The maintainer confirms any change in meaning. The canonization applies the rebased text; the archive keeps the deltas as they were ratified, and the Canonized log entry records the rebase. An `ADDED` ID that is now taken is renumbered, with the PRD's references to it. + +## Worked example: two parallel changes + +The `shared-calendars` feature has an `invitations.md` facet spec with three units: + +```markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. + +### FR-04 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. + +### FR-05 Response visibility + +The organizer sees each invitee's response. +``` + +Two changes are shaped at the same time: + +- **`invite-expiry`** adds `FR-12 Invitation expiry` and modifies `FR-03` to add "An expired invitation cannot be accepted." +- **`decline-with-note`** adds `FR-12 Decline notes`, modifies `FR-03` to let an invitee add a note when declining, and modifies `FR-05` so the organizer sees any decline note. + +**1. Overlap check, `invite-expiry`'s promotion PR.** `decline-with-note` is still in `shaping/`. The check reports `FR-03` (both modify) and `FR-12` (both add). The maintainer rules: `invite-expiry` goes first, and `decline-with-note` renumbers its unit. `invite-expiry`'s promotion PR merges; it is Ratified. + +**2. Overlap check, `decline-with-note`'s promotion PR.** Its delta now adds `FR-13 Decline notes`. The check still reports `FR-03`, already ordered by the maintainer; the PR records the ordering and merges. Both changes are Ratified, and both deltas record the same base text for `FR-03`: the sentence pair above. + +**3. Canonize `invite-expiry`.** It ships first. Its base check passes: `FR-03` still matches its base text and `FR-12` is free. Canonization adds `FR-12`, rewrites `FR-03`, moves its story and scenario to the feature root and archives the change as `changes/archive/2026-12-01-invite-expiry/`. + +**4. Canonize `decline-with-note`.** Its base check fails on `FR-03`: the feature spec now ends with "An expired invitation cannot be accepted.", which the recorded base text lacks. Applying the delta as ratified would silently drop `invite-expiry`'s sentence. The delta is rebased instead: + +```markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +``` + +The maintainer confirms the meaning is unchanged: both edits stand. The base check passes on the rebased delta, canonization applies it, and `FR-03` keeps the first change's edit along with the second's. The archive `changes/archive/2026-12-15-decline-with-note/` keeps the delta as ratified, and the Canonized log entry records the rebase. + +The skill's test fixture, `tests/fixtures/two-canonizations/`, runs exactly these two canonizations. + +## Shipping and canonization + +Each project names its **ship signal**, the event that makes a change live: a merge to the default branch, a release, a feature flag reaching everyone. When it fires, a Shipped entry in the feature log records the evidence. The change stays in `changes/{change}/`; it is now Shipped, and canonization is due. + +**Canonization** makes the shipped change part of the feature spec. It accounts for each requirement, scenario and `DOCUMENT` entry in the change as shipped, changed or deferred, runs the base check, applies the deltas as reconciled with that accounting, moves the story and scenario files the reconciled deltas list to the feature root, archives the change to `changes/archive/YYYY-MM-DD-{change}/` dated the day of canonization, and writes a Canonized entry in the feature log. Deferred units, including deferred story and scenario files, are left out of the spec and become shaping items; changed units carry the text the maintainer approved. The archive keeps the content of the ratified deltas as approved; canonization changes only their OKF `status`, from `stable` to `deprecated`, as it does for every document in the archived change. + +The step-by-step canonization workflow comes with #21 (canonize shipped changes into the feature spec). This reference defines the contract it consumes. + +## Changing a ratified change + +A ratified change records an approval, so a change in its meaning needs one too. Draft the revision in `shaping/{feature}--{change}/` and open a promotion PR for it. Its destination, `changes/{change}/`, already exists, so promotion stops and the maintainer decides how the revision lands. Edits that don't change meaning (typos, links, clarifications) may go in directly. diff --git a/plugins/product-development/skills/product-development/references/feature-bundles.md b/plugins/product-development/skills/product-development/references/feature-bundles.md new file mode 100644 index 0000000..d97b646 --- /dev/null +++ b/plugins/product-development/skills/product-development/references/feature-bundles.md @@ -0,0 +1,175 @@ +# Feature Bundles + +Load this reference when you create, read or change anything under `docs/product/features/`: a feature spec, a change waiting to ship, the feature log or the lineage log. How changes are drafted, checked and canonized is in [changes-and-deltas.md](changes-and-deltas.md). Terms follow the skill's glossary, [CONTEXT.md](../CONTEXT.md). + +## The product bundle + +`docs/product/` is one Open Knowledge Format (OKF) v0.3 bundle. `docs/product/index.md` is the bundle root and declares `okf_version: "0.3"`. Every directory has a generated `index.md`; below the root these are plain listings without front matter. `index.md` and `log.md` are reserved names at every level, and neither carries front matter below the root. ADR 0003 (product documents form one OKF bundle) records the decision. The OKF profile reference, the index generator and the profile checks come with #25 (the OKF profile). + +Every product document carries front matter with `type`, `title`, `description` and `status`, and may carry `tags`. `README.md` and `AGENTS.md` have no `type`, so they are not OKF concepts and keep their roles. `.feature` files are assets. + +`type` comes from a closed list: `constitution`, `vision`, `research-note`, `idea`, `shaping`, `feature-spec-overview`, `feature-spec-facet`, `prd`, `trd`, `delta`, `story`, `delivery-plan`, `open-questions`. What a facet spec covers goes in open `tags`, for example `workflow`, `contract`, `policy`, `data`, `integration`, `permissions`, `entitlement`, `notification`, `screen`, `quality` or `user-type`. + +`status` follows from the path. The path is the authority (ADR 0001, stage directories carry authority); `status` mirrors it for OKF consumers, and the two must agree. + +| Path | OKF `status` | +|------|--------------| +| `ideas/`, `shaping/` | `draft` | +| `features/{feature}/changes/{change}/` (ratified or shipped change) | `stable` | +| Feature spec, and stories at the feature root | `stable` | +| `features/{feature}/changes/archive/` | `deprecated` | + +Moving a document between these paths changes its `status` in the same pull request. + +## Feature bundle layout + +Each feature has one feature bundle, named for the feature's ID in lowercase kebab-case: + +``` +docs/product/features/ + index.md OKF listing, generated + log.md lineage log: splits, merges, drops, dropped changes, closed promotion PRs + {feature}/ + index.md OKF listing, generated + log.md feature log: dated history and reasons + {feature}-spec.md feature overview + {facet}.md facet specs: one user type, workflow or contract each + stories/ stories for shipped behavior + scenarios/*.feature scenarios for shipped behavior + changes/{change}/ a ratified change waiting to ship, or shipped and waiting for canonization + PRD.md + TRD.md + deltas/{facet}.delta.md + stories/ stories the change adds or revises + scenarios/*.feature scenarios the change adds or revises + changes/archive/YYYY-MM-DD-{change}/ + a canonized change, kept as history +``` + +The feature root holds shipped behavior only. Everything about a change that has not been canonized stays in its `changes/{change}/` directory, including its stories and scenarios, so an expectation that hasn't shipped never sits beside shipped ones. + +A feature bundle exists from the day its first change is ratified. Until that change is canonized, the bundle holds a metadata-only feature overview, the log and the change, and no facet specs. That holds while the change is Ratified and after it ships: behavior reaches the feature spec only through canonization, so between the ship signal and canonization a shipped first version is read from its change directory and its Shipped log entry. + +- **At ratification**, the promotion PR writes a metadata-only feature overview: front matter with `type: feature-spec-overview`, a `title`, a `description` that names the feature's subject without claiming any behavior, and the `status` the path mapping gives the feature spec, `stable`; then the title and the History section. It has no summary, no facet table and no links to facets, stories or scenarios, which don't exist yet. +- **At the first canonization**, canonization writes the complete shipped overview and each new facet spec from the reconciled deltas. A delta that writes a facet spec opens with a `## DOCUMENT` entry holding the facet's front matter, title and summary, and its added units follow. The overview's delta rewrites the metadata-only overview with the complete one: its summary, a Facets row linking each facet with its spec-unit prefixes, and the stories and scenarios links. When part of the first version is deferred, the `DOCUMENT` text is reconciled too, so the overview and facet summaries describe only what shipped and link nothing deferred. See [changes-and-deltas.md](changes-and-deltas.md#deferred-stories-and-scenarios). + +A later change that adds a facet does the same: its facet delta writes the facet, and its overview delta adds the facet's row. + +## Feature spec + +The feature spec is the feature overview plus its facet specs. It describes the feature's shipped behavior and nothing else. + +- **Feature overview**, `{feature}-spec.md`, type `feature-spec-overview`. It summarizes what the feature is for, lists its facet specs with the spec-unit prefixes each one uses, and holds the feature's metadata in its front matter. Template: `templates/documents/feature-spec-overview.md.tmpl`. +- **Facet spec**, `{facet}.md`, type `feature-spec-facet`. It covers one face of the feature, such as one user type, one workflow or one contract. Its subject goes in `tags`. Template: `templates/documents/feature-spec-facet.md.tmpl`. + +### Durable tense + +Write the feature spec so that it stays true for as long as the behavior it describes: + +- Present tense, describing what the feature does. "An invitation expires 14 days after it was sent", not "Invitations will expire". +- No change events. Words like "now", "no longer", "replaces", "new" or "formerly" describe a change; put the change in the feature log. +- No plans. No file lists, no dependencies to add or remove, no "to be built", no conditions on a future approval. A dependency or footprint map, where a project wants one, belongs in engineering documentation outside `docs/product/`. + +Only canonization changes the meaning of a feature spec. Edits that don't change meaning (typos, links, clarifications) may go in directly. + +### Spec units + +A spec unit is an independently changeable section of a feature spec with a stable ID. Deltas add, modify and remove whole units, so the unit is the smallest thing two changes can collide on. + +- A unit is a heading whose text starts with the unit's ID, then a space and a short name: `### FR-12 Invitation expiry`. The unit runs to the next heading at the same level or higher. Headings inside a unit sit at a deeper level. A heading inside a fenced code block is text: it neither starts nor ends a unit, and a `Section:` anchor never names it. +- An ID is an uppercase prefix, a hyphen and a number: `FR-12`, `NFR-03`, `MEM-02`. `FR` and `NFR` are for functional and non-functional requirements. A facet may declare its own prefix, such as `MEM` for membership rules; the feature overview lists each facet's prefixes. +- IDs are unique within the feature and never reused, even after the unit is removed. A new unit takes the next free number for its prefix, checked against the feature spec, the change archive and the changes in flight. +- A unit keeps its ID when it moves between facet specs of the same feature. A unit that moves to another feature keeps its ID when the receiving feature has not used it, and otherwise takes the next free ID there. See [Moving a unit](changes-and-deltas.md#moving-a-unit). +- A scenario file at the feature root is a spec unit as a whole file, named by its path, such as `scenarios/invitation-responses.feature`. A story file a change revises is treated the same way, as a whole-file unit named by its path. + +### Stories and scenarios at the feature root + +`stories/` and `scenarios/` at the feature root hold the stories and platform-level scenarios of shipped behavior. Canonization moves here the story and scenario files a change's reconciled deltas list; a deferred file stays with the archived change. Scenarios at the feature root describe shipped behavior, so a failing one means the implementation and the spec have diverged. + +Surface-specific scenarios stay with their app, under `apps/{surface}/docs/features/{feature}/scenarios/`. A change lists the app-local scenario files it adds or changes (see [changes-and-deltas.md](changes-and-deltas.md#app-local-scenario-files)). + +## Feature log + +Each feature bundle has a `log.md`, the feature log: the feature's dated history and the reasons behind each change. It replaces the changelog tables that PRDs and TRDs used to end with. As an OKF reserved file it has no front matter. Template: `templates/documents/feature-log.md.tmpl`. + +Entries are append-only and in date order, oldest first. Each entry has a heading with the date and the event, then the change, the reason and links: + +```markdown +## 2026-12-01 Canonized: invite-expiry + +- Change: [invite-expiry](changes/archive/2026-12-01-invite-expiry/) +- Reason: Invitees left invitations unanswered for weeks, so organizers could not plan. +- Outcome: Added FR-12 and `scenarios/invitation-expiry.feature`; modified FR-03. Nothing deferred. +- Links: canonization PR #123 +``` + +Write an entry for each of these events: + +| Event | Written by | Records | +|-------|-----------|---------| +| Ratified | The promotion PR | The change, why it is being made, and a link to the promotion PR | +| Shipped | The commit or PR that records the ship signal | The ship signal and a link to its evidence, such as a release, a merged implementation PR or a flag reaching everyone | +| Canonized | The canonization PR | A link to the archived change, what was applied, what changed in meaning with the maintainer's approval, what was deferred and where it went, any rebased delta | +| Decision | Whoever records it | A decision about the feature that no change record holds, such as a spike finding | + +Link each entry to something that outlives canonization. `changes/{change}/` is deleted when the change is archived, so a Ratified entry links the promotion PR, a Shipped entry links its evidence, and the Canonized entry links the archive path. A Ratified entry links the promotion PR only: the PR writes the entry, so it can't hold its own merge commit. Resolve the merge commit from the PR when you need it. + +A Shipped entry is how a reader tells a Shipped change from a Ratified one: both sit in `changes/{change}/` (ADR 0001). A decision that is hard to reverse, surprising and the result of a real trade-off also gets an ADR; the log entry links it. + +Change events go in the log, never in the feature spec. + +## Lineage log + +`docs/product/features/log.md` is the lineage log: the product-wide record of events that a single feature log can't hold. Template: `templates/documents/lineage-log.md.tmpl`. Write an entry, with a reason, for each: + +- **Feature split**: one feature becomes two or more. +- **Feature merge**: two or more features become one. +- **Feature drop**: a feature is withdrawn. +- **Dropped change**: a change is withdrawn before it ships, from `shaping/` or from `changes/`. A Shipped change cannot be dropped: withdrawing shipped behavior is a new change that removes it, shaped, ratified and canonized like any other. +- **Promotion PR closed without merging**: the change returns to `shaping/` or is dropped; say which. + +A closed PR can't carry its own entry, so add it in the next commit to the default branch that touches `docs/product/`. + +### No stub bundles + +A bundle that no longer describes a feature is deleted, not left behind as a stub that points elsewhere. The same holds for a dropped change's directory. The lineage-log entry keeps the history: it names what was removed, why, where its spec units went, and links the last commit that had it, so `git show :` recovers the content. + +A split or merge is shaped and ratified like any other change. The change belongs to one feature, usually the receiving one. Its deltas remove the moving units from the source feature and add them to the receiving one; each delta against a feature other than the change's own uses a feature-qualified target, `deltas/{feature-id}/{facet}.delta.md` (see [changes-and-deltas.md](changes-and-deltas.md#deltas)). The overlap and base checks run against every feature the deltas touch. If a moved unit's ID is already taken in the receiving feature, the unit takes the next free ID there, and the lineage entry maps each old ID to its new one. When canonization leaves a source bundle with no spec units and no stories or scenarios, delete the bundle in the same PR. Canonization that would delete a bundle is refused while that bundle holds any other change in `changes/`, Ratified or Shipped: deleting the bundle would delete that change too. It is refused as well while an uncanonized change in any other feature has feature-qualified deltas that target the bundle: those deltas would have no bundle to apply to. Each such change is first canonized, moved to the receiving feature (or, for a change in another feature, its deltas retargeted there), or dropped with a lineage-log entry; then the lineage change is canonized. A Shipped change in that bundle is canonized or moved, never dropped. + +When a change's feature-qualified deltas target a feature that does not exist yet, its promotion PR initializes that bundle like a first version, as a split into a new feature does: a metadata-only feature overview, and a log with a Ratified entry naming the owning change, such as `Ratified: shared-calendars/split-calendar-links`. The change itself belongs to the source feature, and the source's own Ratified entry records the split. The promotion PR also adds a Feature split entry to the lineage log, linking the promotion PR, because the new bundle appears with it. The change's deltas for the new feature write its facet specs and complete its overview, as a first version's deltas do. Canonization refuses a feature-qualified delta whose receiving bundle has no overview or log. The skill's test fixture, `tests/fixtures/feature-split/`, runs a split like this one. + +Withdrawing a ratified split follows the no-stub rule. Dropping the owning change also deletes a receiving bundle its promotion PR created, when that bundle holds no other change and no shipped content (spec units, stories or scenarios). The Dropped change entry names the deleted bundle under Removed, with the last commit that had it. A receiving bundle that holds another change stays. + +### Worked example: a merge + +The product has two features, `shared-calendars` and `calendar-links`. Calendar links turn out to be one more way to share a calendar, so the maintainer merges them. The change `absorb-calendar-links`, shaped in `shaping/shared-calendars--absorb-calendar-links/`, carries two deltas: + +- `deltas/sharing.delta.md` adds the units from `calendar-links` to the `sharing.md` facet of `shared-calendars`. `calendar-links` used `FR-01` and `FR-02`, which `shared-calendars` already has, so they arrive as `FR-14` and `FR-15`, the next free numbers once `decline-with-note` has taken `FR-13`. +- `deltas/calendar-links/sharing.delta.md`, a feature-qualified delta, removes every unit `calendar-links/sharing.md` had, with base text. Both features have a `sharing.md` facet, so the qualifier is what says which one each delta targets. + +The overlap check for the promotion PR compares these deltas with the changes in flight for both features. A `calendar-links` change that modifies its own `FR-01` overlaps with the merge, which removes it; a `shared-calendars` change that modifies `FR-01` there does not. + +When the change is canonized, the canonization PR deletes `features/calendar-links/` and adds to the lineage log: + +```markdown +## 2027-01-20 Feature merge: calendar-links into shared-calendars + +- Reason: A calendar link is one way to share a calendar; two features split one concept. +- Change: [absorb-calendar-links](shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/) +- Units: calendar-links FR-01 → shared-calendars FR-14; FR-02 → FR-15 +- Removed: `features/calendar-links/`, last present in commit 4f2a9c1 +``` + +No `calendar-links` directory remains. Its history is in this entry, in the archived change and in Git. The skill's test fixture, `tests/fixtures/feature-merge/`, runs a merge like this one. + +### Worked example: a dropped change + +The change `recurring-invitations` was ratified, then the maintainer withdrew it before it shipped. The PR that drops it deletes `features/shared-calendars/changes/recurring-invitations/` and adds: + +```markdown +## 2027-02-03 Dropped change: shared-calendars/recurring-invitations + +- Reason: Usage showed organizers re-invite per event; the series model added cost without demand. +- State when dropped: Ratified +- Removed: `features/shared-calendars/changes/recurring-invitations/`, last present in commit 9b07e3d +``` diff --git a/plugins/product-development/skills/product-development/references/requirements.md b/plugins/product-development/skills/product-development/references/requirements.md index 4003de8..08e05aa 100644 --- a/plugins/product-development/skills/product-development/references/requirements.md +++ b/plugins/product-development/skills/product-development/references/requirements.md @@ -2,7 +2,8 @@ ## Inputs -- Approved shaping document from Discovery and Design, in `docs/product/shaping/{feature}/` +- Approved shaping document from Discovery and Design, in `docs/product/shaping/{feature}--{change}/` +- For a change to an existing feature, its feature spec in `docs/product/features/{feature}/`: the feature overview `{feature}-spec.md` and the facet specs the change touches - `docs/product/constitution.md` - approved governance principles with version metadata. Required before the first PRD. - `docs/product/vision.md` - approved, versioned product north star. Required before the first PRD. @@ -15,12 +16,22 @@ If the PRD would change strategic direction, stop and supersede the vision befor ## Output Location ``` -docs/product/shaping/{feature}/ +docs/product/shaping/{feature}--{change}/ ├── PRD.md -└── TRD.md +├── TRD.md +└── deltas/ + └── {facet}.delta.md ``` -Draft both documents in `shaping/`. They are tentative until the change's promotion PR merges, which ratifies the change and moves it into `docs/product/features/{feature}/`. Code alone never admits a spec: a PRD written for behavior that already exists in code is still drafted here and promoted. +Draft the PRD, the TRD and the deltas in `shaping/`. They are tentative until the change's promotion PR merges, which ratifies the change and moves it into `docs/product/features/{feature}/changes/{change}/`. Code alone never admits a spec: a PRD written for behavior that already exists in code is still drafted here and promoted. + +Every PRD and TRD describes a change, including a feature's first version. They describe that change only, never the whole feature: the feature spec holds what the feature does. See `references/changes-and-deltas.md`. + +## Tense + +A PRD and a TRD are the dated record of one change. They describe work that has not shipped when they are written, so planning tense is correct in them: "Invitations will expire after 14 days", "Create `src/invitations/expire-invitations.ts`". They are not re-tensed after the change ships. Canonization moves the change to the change archive, where the same text reads as history. + +The feature spec and the delta text that canonization applies to it use durable tense instead (`references/feature-bundles.md`). Change events, such as "replaces X" or "added Y", go in the feature log, never in spec prose. ## PRD Structure @@ -28,16 +39,17 @@ The Product Requirements Document describes **what** and **why**. ### Required sections -1. **Header** — feature name, status, created date, implementation service +1. **Header** — front matter (`type: prd`, `title`, `description`, and the OKF `status` that follows from the path), then the feature ID, the change name, created date, implementation service 2. **Problem** — what problem this solves, why it matters now 3. **Goal** — one-sentence summary of the desired outcome -4. **User Stories** — numbered (US-1, US-2, ...) with acceptance criteria per story -5. **Requirements** — functional (FR-*) and non-functional (NFR-*) in table format with priority (Must/Should/Could) -6. **Privacy Model** — what data is collected, what is never collected, consent model -7. **Success Metrics** — measurable criteria with pass/fail or target values -8. **Constitution Alignment** — table checking every current constitutional principle or standard with PASS/RISK/FAIL/N/A -9. **Vision Alignment** — explicit check that target users, value proposition, platform principles, and relevant surface vision match approved `docs/product/vision.md` -10. **Open Questions** — unresolved decisions to address during implementation +4. **Provenance** — the shaping document's provenance record, carried forward: current artifacts, affected consumers, compatibility constraints, decisions (who decided what, and when), evidence with the claim each source supports, rejected alternatives, and non-goals and boundaries (the scope and refactors the delivery team must leave out). See `references/changes-and-deltas.md` +5. **User Stories** — numbered (US-1, US-2, ...) with acceptance criteria per story +6. **Requirements** — functional (FR-*) and non-functional (NFR-*) in table format with priority (Must/Should/Could). These are the requirements this change adds or revises. Their IDs are the feature's spec-unit IDs: a revised requirement keeps its ID, and a new one takes the next free number for its prefix, so each requirement traces to the unit its delta writes +7. **Privacy Model** — what data is collected, what is never collected, consent model +8. **Success Metrics** — measurable criteria with pass/fail or target values +9. **Constitution Alignment** — table checking every current constitutional principle or standard with PASS/RISK/FAIL/N/A +10. **Vision Alignment** — explicit check that target users, value proposition, platform principles, and relevant surface vision match approved `docs/product/vision.md` +11. **Open Questions** — unresolved decisions to address during implementation ### Constitution alignment check @@ -66,18 +78,20 @@ The Technical Requirements Document describes **how**, architecturally. ### Required sections -1. **Header** — feature name, status, created date, implementation service/library +1. **Header** — front matter (`type: trd`, `title`, `description`, and the OKF `status` that follows from the path), then the feature ID, the change name, a link to the change's PRD, created date, implementation service/library 2. **Architecture Overview** — ASCII diagram showing component relationships and data flow -3. **Directory Structure** — exact file tree showing where new code lives +3. **Directory Structure** — exact file tree showing where this change's code lives 4. **Design Rationale** — why this architecture (vendor-agnostic facades, shared instances, etc.) -5. **Dependencies** — packages to add and remove, with versions and purpose -6. **Files** — tables for Create, Modify, and Remove with file paths and purpose/change description +5. **Dependencies** (change-scoped plan) — packages this change adds and removes, with versions and purpose, and dependencies it deliberately leaves out +6. **Files** (change-scoped plan) — tables for Create, Modify, and Remove with file paths and purpose/change description for this change 7. **Public API** — TypeScript signatures for the feature's public interface, with usage examples 8. **Data Storage** — database keys, schemas, defaults (if applicable) 9. **Vendor Configuration** — SDK configuration, API keys, options (if applicable) 10. **Testing Strategy** — unit tests (with specific test cases) and manual verification steps 11. **Risks and Mitigations** — table with likelihood, impact, and mitigation per risk +Dependencies and Files are change-scoped plans. They say what this change will add, remove, create and modify, and they stay in the change's TRD as that change's plan. Once the change ships, the manifest and the code are the source of truth, and the archived TRD reads as the record of what the change planned. The feature spec holds no file lists and no add-and-remove dependency tables. A current dependency or footprint map, where a project wants one, belongs in engineering documentation outside `docs/product/`. + ### Design principles - **Vendor-agnostic facades** — app code imports from `lib/services/{feature}/`, never from vendor modules directly @@ -94,6 +108,14 @@ A PRD is ready for User Stories when: - User stories have clear acceptance criteria - Functional requirements are prioritized - Privacy model is explicit about what is and isn't collected +- Provenance names the affected consumers, compatibility constraints, decisions with who made them and when, evidence with the claim each source supports, rejected alternatives, and non-goals and boundaries for the delivery team + +Deltas are ready when: +- Every requirement the PRD adds, revises or removes has a delta entry with the same ID +- Every story and scenario file the change adds or revises in the feature bundle has a whole-file entry +- Every app-local scenario file the change adds or changes is listed by path under `## App-local scenario files`, with its base text when the file existed before the change, matching the file as it will stand just before the promotion PR merges +- Every modified or removed unit records base text copied from the current feature spec +- Added and new text is in durable tense A TRD is ready for User Stories when: - Architecture diagram is clear and matches the file structure @@ -101,36 +123,17 @@ A TRD is ready for User Stories when: - Dependencies are listed - Testing strategy covers the acceptance criteria -## Evolution Strategy - -PRDs and TRDs are **living documents**. A change to requirements, stories or scenarios is drafted in `shaping/{feature}/` and ratified by a promotion PR, like a new feature. Record it in the changelog. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. See `docs/METHODOLOGY.md` for full conventions. - -### Changelog section +## Deltas -Every PRD and TRD ends with a changelog: +Draft the change's deltas once the PRD and TRD are approved, and present them for approval with the TRD or right after it. Write one delta per feature spec document the change touches, listing each spec unit it adds, modifies or removes. For a feature's first version, every unit is added. Consult `references/changes-and-deltas.md` for the format and `templates/documents/delta.md.tmpl` for the template. -```markdown -## Changelog - -| Date | Change | Rationale | -|------|--------|-----------| -| 2026-03-15 | Added accepting a recurring series in one step | Invitees declined weekly events rather than accept each occurrence | -| 2026-03-01 | Initial version | — | -``` - -- Record date, brief description, and **rationale** (git diff shows *what* changed, the changelog captures *why*) -- The initial version entry has no rationale (self-evident) -- Minor corrections (typos, formatting) do not need changelog entries -- Changes to requirements, architecture, or acceptance criteria always get entries - -### When to supersede instead +## Evolution Strategy -Supersede with a new document (rather than editing) when: -- Replacing the underlying technology (e.g., migrating analytics vendors) -- Fundamentally changing the privacy or consent model -- Rearchitecting a feature to the point where the original PRD/TRD is unrecognizable +A PRD and a TRD are the record of one change, not living documents. A change to requirements, stories or scenarios is drafted in `shaping/{feature}--{change}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. See `docs/METHODOLOGY.md` for full conventions. -The threshold is judgment-based: if the volume of changes would confuse someone reading the document relative to its original intent, create a new version. +- A later revision of the feature is a new change with its own PRD, TRD and deltas, not an edit to an earlier change's documents. +- PRDs and TRDs have no changelog section. The reason for each change is in the PRD, and the feature log (`references/feature-bundles.md`) records when it was ratified, shipped and canonized. +- When a change would replace most of a feature's spec units, it is a fundamental change: its deltas replace them, or it is a lineage event (split, merge or drop) recorded in the lineage log. Fundamentally changing the privacy or consent model, or replacing the underlying technology, usually lands here. ## Templates diff --git a/plugins/product-development/skills/product-development/references/user-stories.md b/plugins/product-development/skills/product-development/references/user-stories.md index 6b52bd1..d9a9c0a 100644 --- a/plugins/product-development/skills/product-development/references/user-stories.md +++ b/plugins/product-development/skills/product-development/references/user-stories.md @@ -2,18 +2,18 @@ ## Inputs -- Approved PRD at `docs/product/shaping/{feature}/PRD.md` while the change is drafted -- TRD at `docs/product/shaping/{feature}/TRD.md` (for technical feasibility context) -- For a feature that already has ratified documents, also read the baseline in `docs/product/features/{feature}/`: its PRD, TRD and existing stories +- Approved PRD at `docs/product/shaping/{feature}--{change}/PRD.md` while the change is drafted +- TRD at `docs/product/shaping/{feature}--{change}/TRD.md` (for technical feasibility context) +- For an existing feature, also read its feature spec and the stories of shipped behavior in `docs/product/features/{feature}/stories/` - Approved, versioned product constitution at `docs/product/constitution.md` - Approved, versioned product vision at `docs/product/vision.md` ## Output Location -Stories are drafted with their change in `shaping/` and move into `docs/product/features/{feature}/stories/` when the promotion PR merges. +Stories are drafted with their change in `shaping/` and move with it into `docs/product/features/{feature}/changes/{change}/stories/` when the promotion PR merges. They stay in the change until it is canonized, which moves them to `docs/product/features/{feature}/stories/` at the feature root, beside the stories of other shipped behavior. ``` -docs/product/shaping/{feature}/stories/ +docs/product/shaping/{feature}--{change}/stories/ ├── US-001-.md ├── US-002-.md └── ... @@ -21,12 +21,18 @@ docs/product/shaping/{feature}/stories/ ## Story Format -Each story is a separate markdown file. Stories are **living artifacts** that progress through a lifecycle (see `docs/METHODOLOGY.md`). +Each story is a separate markdown file. Story numbers are unique within the feature, like spec-unit IDs: a new story takes the next free number. ```markdown +--- +type: story +title: "US-{NNN}: {Short title}" +description: {One sentence: who wants what.} +status: draft +--- + # US-{NNN}: {Short title} -**Status:** Draft | Ready | In Progress | Done | Archived **PRD Requirement:** FR-{N}, NFR-{N} ## Story @@ -86,15 +92,13 @@ If a story can only apply to one surface, note the surface in the story's metada ## Story Lifecycle -Stories progress through statuses: +A story has no status field of its own. Its OKF `status` follows from its path, and its place follows its change's state: -- **Draft** — story is being written, acceptance criteria may be incomplete -- **Ready** — story is approved and ready for scenario writing or implementation -- **In Progress** — story is being implemented -- **Done** — story is implemented, scenarios pass -- **Archived** — story has been superseded or is no longer relevant +- In `shaping/{feature}--{change}/stories/` while the change is Shaping or In review +- In `features/{feature}/changes/{change}/stories/` while the change is Ratified or Shipped +- In `features/{feature}/stories/` at the feature root once the change is Canonized -Done and archived stories remain in `stories/` for traceability. If the directory becomes noisy, completed stories may be moved to `stories/archive/`. +To revise a shipped story, a change carries the new version in its own `stories/` and lists the story in its deltas as a modified whole-file unit, with the shipped file as base text. To withdraw one, the change lists it as a removed whole-file unit. See `references/changes-and-deltas.md`. ## Quality Criteria diff --git a/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl index 10901a8..0daae8b 100644 --- a/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/AGENTS.md.tmpl @@ -14,7 +14,8 @@ The maintainer moves an idea to `shaping/` when they start shaping it. A PRD is ## Key rules -- **PRDs, TRDs, user stories, and platform-level scenarios** are drafted under `docs/product/shaping/{feature}/` and live under `docs/product/features/{feature}/` once ratified. +- **Every PRD and TRD describes a change**, including a feature's first version. A change's PRD, TRD, deltas, user stories and platform-level scenarios are drafted under `docs/product/shaping/{feature}--{change}/` and live under `docs/product/features/{feature}/changes/{change}/` once ratified. +- **The feature spec** (`docs/product/features/{feature}/{feature}-spec.md` plus its facet specs) and the stories and scenarios at the feature root describe shipped behavior only, in durable tense. Only canonization of a shipped change changes their meaning. - **Surface-specific scenarios** (those whose Given/When/Then language references a specific interaction model) belong under `apps/{surface}/docs/features/{feature}/scenarios/`. - **Step definitions** (test automation) always belong under each app's test directory, never in `docs/`. - Before creating the first feature PRD, confirm `docs/product/constitution.md` exists, is approved, and has version metadata. @@ -32,14 +33,16 @@ The maintainer moves an idea to `shaping/` when they start shaping it. A PRD is ## When adding a new feature 1. Run idea discovery: a subagent reads `docs/product/ideas/` and reports ideas that bear on the work. -2. Save the approved design as the shaping document in `docs/product/shaping/{feature}/`. -3. Confirm the Foundation Gate has passed before Requirements. -4. Draft `PRD.md`, then `TRD.md`, in `docs/product/shaping/{feature}/`. -5. Add user stories under `docs/product/shaping/{feature}/stories/` and platform-level scenarios under `docs/product/shaping/{feature}/scenarios/`. -6. Write surface-specific scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` before promotion. -7. Open a promotion PR that moves the approved change into `docs/product/features/{feature}/` and lists each app-local scenario file it adds or changes. Its merge ratifies the change. If the destination already holds a document with the same name, stop and ask instead of overwriting. -8. Step definitions are created during implementation under the relevant app. +2. Classify the work: a new feature, an incremental amendment, an evolution or migration of an existing feature, or a fundamental change. Work on an existing feature is a change to that feature, never a competing feature directory. +3. Save the approved design as the shaping document in `docs/product/shaping/{feature}--{change}/`. +4. Confirm the Foundation Gate has passed before Requirements. +5. Draft `PRD.md`, then `TRD.md`, then the deltas under `deltas/`, in `docs/product/shaping/{feature}--{change}/`. +6. Add user stories under `docs/product/shaping/{feature}--{change}/stories/` and platform-level scenarios under `docs/product/shaping/{feature}--{change}/scenarios/`. +7. Write surface-specific scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` before promotion. +8. Run the overlap check, then open a promotion PR that moves the approved change into `docs/product/features/{feature}/changes/{change}/` and lists each app-local scenario file it adds or changes. Run the overlap check again just before it merges. Its merge ratifies the change. If the destination already exists, stop and ask instead of overwriting. +9. Step definitions are created during implementation under the relevant app. +10. When the project's ship signal fires, record it in the feature log, then canonize the change: run the base check, apply its deltas to the feature spec, move the story and scenario files its reconciled deltas list to the feature root and archive it under `changes/archive/`. ## Specification evolution -Once ratified, PRDs and TRDs are living documents with a changelog section (date, change, rationale). A change to requirements, stories or scenarios is drafted in `docs/product/shaping/{feature}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. For evolution strategies per artifact type, consult the product-development methodology documentation (installed at `.agents/local-skills/product-development/docs/METHODOLOGY.md` or `.agents/skills/product-development/docs/METHODOLOGY.md`). +A change to requirements, stories or scenarios is drafted in `docs/product/shaping/{feature}--{change}/` and ratified by a promotion PR, like a new feature. Only edits that don't change meaning (typos, links, clarifications) go directly into ratified documents. PRDs and TRDs have no changelog: each feature's `log.md` records its history and reasons, and `features/log.md` records feature splits, merges and drops, dropped changes, and promotion PRs closed without merging. For evolution strategies per artifact type, consult the product-development methodology documentation (installed at `.agents/local-skills/product-development/docs/METHODOLOGY.md` or `.agents/skills/product-development/docs/METHODOLOGY.md`). diff --git a/plugins/product-development/skills/product-development/templates/README.md.tmpl b/plugins/product-development/skills/product-development/templates/README.md.tmpl index 6ace385..4826cde 100644 --- a/plugins/product-development/skills/product-development/templates/README.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/README.md.tmpl @@ -11,11 +11,14 @@ Product governance and cross-surface specifications. Artifacts here describe wha - `constitution.md` — approved, versioned product constitution required before the first PRD - `vision.md` — approved, versioned north-star product vision required before the first PRD - `ideas/` — early sketches nobody is shaping yet (see [Stages](#stages)) -- `shaping/{feature}/` — a change being worked out: its shaping document and draft PRD, TRD, stories and scenarios -- `features/{feature}/PRD.md` — product requirements (what and why) -- `features/{feature}/TRD.md` — technical requirements (how, architecturally) -- `features/{feature}/stories/` — user stories decomposing the PRD's requirements -- `features/{feature}/scenarios/` — platform-level behavioral contracts (`.feature` files in Gherkin) +- `shaping/{feature}--{change}/` — one change being worked out: its shaping document and draft PRD, TRD, deltas, stories and scenarios +- `features/{feature}/` — the feature bundle: + - `{feature}-spec.md` and facet specs — the feature spec: shipped behavior only + - `stories/`, `scenarios/` — stories and platform-level scenarios (`.feature` files in Gherkin) for shipped behavior + - `changes/{change}/` — a ratified change waiting to ship or to be canonized: its PRD (what and why), TRD (how), deltas, stories and scenarios + - `changes/archive/` — canonized changes, kept as history + - `log.md` — the feature log: dated history and reasons +- `features/log.md` — the lineage log: feature splits, merges and drops, dropped changes, and promotion PRs closed without merging ### App level (`/apps/{surface}/docs/`) @@ -40,7 +43,8 @@ Feature content moves through three stage directories. A document's stage, and s | `features/` | Ratified changes and shipped feature specs | Requirements | - The maintainer moves an idea to `shaping/` when they start shaping it. -- A PRD is drafted in `shaping/`. Merging the change's promotion PR ratifies the change and moves it into `features/`. +- A PRD is drafted in `shaping/`. Merging the change's promotion PR ratifies the change and moves it into `features/{feature}/changes/{change}/`. +- When the change ships, canonization applies its deltas to the feature spec and archives it. - Code alone never admits a spec to `features/`. - Each stage directory has an `AGENTS.md` that says when agents read it and when they stay out. @@ -67,9 +71,13 @@ Platform Scenarios (verify stories' acceptance criteria as behavioral contracts) ↓ Surface Scenarios (extend with interaction-specific behaviors, written before promotion) ↓ -Promotion PR (merge ratifies the change, moves it into features/ and lists its app-local scenarios) +Promotion PR (merge ratifies the change, moves it into features/{feature}/changes/{change}/ and lists its app-local scenarios) ↓ Step Definitions (automate scenarios as executable tests) + ↓ +Ship signal (recorded in the feature log) + ↓ +Canonization (deltas applied to the feature spec; change archived) ``` ## Foundation gate @@ -105,14 +113,19 @@ docs/product/ │ └── AGENTS.md ├── shaping/ ← changes being worked out │ ├── AGENTS.md -│ └── {feature}/ ← shaping document, draft PRD, TRD, stories, scenarios +│ └── {feature}--{change}/ ← shaping document, draft PRD, TRD, deltas, stories, scenarios └── features/ ← ratified changes and shipped specs: requirements ├── AGENTS.md + ├── log.md ← lineage log └── {feature}/ - ├── PRD.md ← product requirements - ├── TRD.md ← technical requirements - ├── stories/ ← user stories (.md) - └── scenarios/ ← platform-level .feature files + ├── log.md ← feature log + ├── {feature}-spec.md ← feature overview + ├── {facet}.md ← facet specs + ├── stories/ ← stories for shipped behavior + ├── scenarios/ ← platform-level .feature files for shipped behavior + └── changes/ + ├── {change}/ ← ratified change: PRD, TRD, deltas/, stories/, scenarios/ + └── archive/ ← canonized changes apps/{surface}/ ├── docs/ diff --git a/plugins/product-development/skills/product-development/templates/documents/delta.md.tmpl b/plugins/product-development/skills/product-development/templates/documents/delta.md.tmpl new file mode 100644 index 0000000..3bad584 --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/documents/delta.md.tmpl @@ -0,0 +1,100 @@ +--- +type: delta +title: delta for +description: Spec units the change adds, modifies or removes in .md. +status: draft +--- + +# Delta: .md + + + +## DOCUMENT + + + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: +description: +status: stable +tags: [] +--- + +# + + +~~~ + +## ADDED + +### + +Section: Requirements, when the title is not unique> + +Text: + +~~~markdown +### + + +~~~ + +### scenarios/.feature + +### stories/US--.md + +## MODIFIED + +### + +Base text: + +~~~markdown +### + + +~~~ + +New text: + +~~~markdown +### + + +~~~ + +### scenarios/.feature + +Base text: + +~~~gherkin + +~~~ + +## REMOVED + +### + +Base text: + +~~~markdown +### + + +~~~ + +## App-local scenario files + + + +### apps//docs/features//scenarios/.feature + +Base text: + +~~~gherkin + +~~~ diff --git a/plugins/product-development/skills/product-development/templates/documents/feature-log.md.tmpl b/plugins/product-development/skills/product-development/templates/documents/feature-log.md.tmpl new file mode 100644 index 0000000..6556a6c --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/documents/feature-log.md.tmpl @@ -0,0 +1,23 @@ +# Feature log: + +Dated history of the feature and the reasons behind each change, oldest first. Append new entries at the end. + +Link each entry to a record that outlives canonization: `changes//` is deleted when the change is archived. + +## Ratified: + +- Change: +- Reason: +- Links: Promotion PR # + +## Shipped: + +- Change: +- Ship signal: +- Evidence: + +## Canonized: + +- Change: [](changes/archive/-/) +- Outcome: +- Links: canonization PR # diff --git a/plugins/product-development/skills/product-development/templates/documents/feature-spec-facet.md.tmpl b/plugins/product-development/skills/product-development/templates/documents/feature-spec-facet.md.tmpl new file mode 100644 index 0000000..2ee3ea3 --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/documents/feature-spec-facet.md.tmpl @@ -0,0 +1,21 @@ +--- +type: feature-spec-facet +title: +description: +status: stable +tags: [] +--- + +# + + + +## Requirements + +### FR- + + + +### NFR- + + diff --git a/plugins/product-development/skills/product-development/templates/documents/feature-spec-overview.md.tmpl b/plugins/product-development/skills/product-development/templates/documents/feature-spec-overview.md.tmpl new file mode 100644 index 0000000..97b6067 --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/documents/feature-spec-overview.md.tmpl @@ -0,0 +1,31 @@ +--- +type: feature-spec-overview +title: +description: +status: stable +tags: [] +--- + + + +# + + + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [](.md) | | FR, NFR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) +- Surface-specific scenarios: `apps/{surface}/docs/features//scenarios/` + +## History + + + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/templates/documents/lineage-log.md.tmpl b/plugins/product-development/skills/product-development/templates/documents/lineage-log.md.tmpl new file mode 100644 index 0000000..6f2787b --- /dev/null +++ b/plugins/product-development/skills/product-development/templates/documents/lineage-log.md.tmpl @@ -0,0 +1,33 @@ +# Lineage log + +Product-wide record of feature splits, merges and drops, dropped changes, and promotion PRs closed without merging, with reasons, oldest first. Append new entries at the end. + +## Feature split: into + +- Reason: +- Change: /, promotion PR # +- Units: → + +## : + +- Reason: +- Change: [](/changes/archive/-/) +- Units: → +- Removed: `features//`, last present in commit + +## Dropped change: / + + + +- Reason: +- State when dropped: +- Removed: ``, last present in commit +- Removed: `features//`, the receiving bundle the change's promotion PR created, last present in commit + + + +## Promotion PR closed without merging: / + +- Reason: +- PR: # +- Outcome: diff --git a/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl index 2a8dd1d..b3df921 100644 --- a/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/features/AGENTS.md.tmpl @@ -1,6 +1,13 @@ # Agent Guidance: Features -This directory is the `features/` stage. It holds ratified changes and shipped feature specs. +This directory is the `features/` stage. It holds one feature bundle per feature, `{feature}/`, and the lineage log, `log.md`. + +Inside a feature bundle: + +- `{feature}-spec.md` and the facet specs, with `stories/` and `scenarios/`, describe shipped behavior only. +- `changes/{change}/` holds a ratified change waiting to ship, or shipped and waiting for canonization. Its stories and scenarios stay there until canonization. +- `changes/archive/` holds canonized changes as history. +- `log.md` is the feature log. ## Authority @@ -8,15 +15,20 @@ Documents here are requirements. Plan, implement, test and review against them. ## When to read -- Planning, implementing, testing, reviewing or auditing a feature: read that feature's directory. -- Shaping a change to an existing feature: read the affected feature for its current requirements. +- Planning or implementing a change: read the change in `changes/{change}/` and the feature spec it amends. +- Testing, reviewing or auditing shipped behavior: read the feature spec and the feature-root stories and scenarios. +- Shaping a change to an existing feature: read the feature spec for its current requirements. ## When to stay out - Features the task does not touch. +- `changes/archive/`, unless the task needs a past change's reasons. ## Rules - Content enters only through a merged promotion PR from `../shaping/`. Do not draft here. - Code alone never admits a spec. Behavior that exists in code but not here goes to `../shaping/` or `../ideas/` first. +- Only canonization of a shipped change changes the meaning of a feature spec. Write the feature spec in durable tense, with change events in the feature log. - Update ratified documents only as the "Specification evolution" section of `../AGENTS.md` describes. +- A removed feature bundle or change is deleted, not left as a stub. Record it in the lineage log, `log.md`. +- Don't canonize a merge that deletes a bundle while that bundle holds another change in `changes/`. Canonize or move that change first, or drop it only if it has not shipped. diff --git a/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl b/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl index 3594a25..bb46b40 100644 --- a/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl +++ b/plugins/product-development/skills/product-development/templates/shaping/AGENTS.md.tmpl @@ -1,6 +1,6 @@ # Agent Guidance: Shaping -This directory is the `shaping/` stage. It holds changes being worked out: shaping documents and draft PRDs, TRDs, user stories and scenarios. +This directory is the `shaping/` stage. It holds changes being worked out, one directory per change, named `{feature}--{change}/`: the shaping document and the draft PRD, TRD, deltas, user stories and scenarios. ## Authority @@ -20,5 +20,7 @@ Shaping documents are tentative context for work on the feature they concern. Th ## Rules - Draft a PRD here, and only after the Foundation Gate passes. Ideas and shaping documents do not need the gate. -- Merging the change's promotion PR ratifies the change and moves it into `../features/`. +- The shaping document records the change's provenance: current artifacts, affected consumers, compatibility constraints, who decided what and when, evidence with the claim each source supports, rejected alternatives, and non-goals and boundaries for the delivery team. The PRD carries it forward. Discovery is not approval; the promotion PR is the decision gate. +- One change per directory. A change to an existing feature names it in the shaping document's front matter: `x-amends: {feature}`. +- Merging the change's promotion PR ratifies the change and moves it into `../features/{feature}/changes/{change}/`. - Code alone never admits a spec. Spike findings land here as shaping content, never in `../features/`. diff --git a/plugins/product-development/skills/product-development/tests/feature-evolution.bats b/plugins/product-development/skills/product-development/tests/feature-evolution.bats new file mode 100644 index 0000000..9e1719a --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/feature-evolution.bats @@ -0,0 +1,1427 @@ +#!/usr/bin/env bats + +# Tests for the 0.2.0 change model: feature bundles, changes, deltas, +# the overlap and base checks, logs, and the durable-tense rules. + +SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)" +ADR_DIR="$REPO_ROOT/docs/adr" + +# Fails unless grep runs and finds no match. A bare `! grep` mid-test never +# fails a bats test, and a missing file must not pass as "no match". +refute_grep() { + local rc=0 + grep "$@" >/dev/null || rc=$? + [ "$rc" -eq 1 ] || { echo "refute_grep $* exited $rc" >&2; return 1; } +} + +# Prints a file with wrapped lines joined, so a sentence matches wherever +# it breaks. +joined() { + tr -s '\n ' ' ' < "$1" +} + +# --- ADRs --- + +@test "ADR 0002 records deltas with base text, canonized at ship" { + local adr="$ADR_DIR/0002-deltas-with-base-text-canonized-at-ship.md" + [ -f "$adr" ] + grep -q "^## Considered options" "$adr" + grep -q "^## Consequences" "$adr" + grep -q "base text" "$adr" + grep -q "overlap check" "$adr" + grep -q "base check" "$adr" + grep -qi "canoniz" "$adr" + grep -q "OpenSpec" "$adr" +} + +@test "ADR 0003 records product documents as one OKF bundle with closed types and open tags" { + local adr="$ADR_DIR/0003-product-documents-form-one-okf-bundle.md" + [ -f "$adr" ] + grep -q "^## Considered options" "$adr" + grep -q "^## Consequences" "$adr" + grep -q '`docs/product/`' "$adr" + grep -q 'okf_version: "0.3"' "$adr" + grep -q "closed" "$adr" + grep -q '`tags`' "$adr" + for type in constitution vision research-note idea shaping feature-spec-overview \ + feature-spec-facet prd trd delta story delivery-plan open-questions; do + grep -q "\`$type\`" "$adr" || { echo "ADR 0003 misses type $type" >&2; return 1; } + done + grep -q "draft" "$adr" + grep -q "stable" "$adr" + grep -q "deprecated" "$adr" +} + +# --- Feature bundles --- + +@test "feature bundle reference lays out the bundle, its changes and its archive" { + local ref="$SCRIPT_DIR/references/feature-bundles.md" + [ -f "$ref" ] + for entry in 'log.md' '{feature}-spec.md' '{facet}.md' 'changes/{change}/' \ + 'deltas/{facet}.delta.md' 'changes/archive/YYYY-MM-DD-{change}/' 'stories/' 'scenarios/\*.feature'; do + grep -q "^ *$entry" "$ref" || { echo "layout misses $entry" >&2; return 1; } + done + grep -q "The feature root holds shipped behavior only" "$ref" + grep -q 'okf_version: "0.3"' "$ref" +} + +@test "feature bundle reference maps OKF status from the path" { + local ref="$SCRIPT_DIR/references/feature-bundles.md" + grep -qE '^\| `ideas/`, `shaping/` \| `draft` \|$' "$ref" + grep -qE '^\| `features/{feature}/changes/{change}/` .*\| `stable` \|$' "$ref" + grep -qE '^\| Feature spec, .*\| `stable` \|$' "$ref" + grep -qE '^\| `features/{feature}/changes/archive/` \| `deprecated` \|$' "$ref" +} + +@test "spec units are headings that start with a stable ID, and scenario files are whole-file units" { + local text + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "A unit is a heading whose text starts with the unit's ID" <<< "$text" + grep -q "IDs are unique within the feature and never reused" <<< "$text" + grep -q "A scenario file at the feature root is a spec unit as a whole file" <<< "$text" + grep -q "A heading inside a fenced code block is text: it neither starts nor ends a unit" <<< "$text" +} + +@test "feature spec is written in durable tense and changes only by canonization" { + local text + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "### Durable tense" "$SCRIPT_DIR/references/feature-bundles.md" + grep -q "Only canonization changes the meaning of a feature spec" <<< "$text" + grep -q "No file lists, no dependencies to add or remove" <<< "$text" +} + +@test "feature log replaces changelog tables and records ratification, ship signal and canonization" { + local ref="$SCRIPT_DIR/references/feature-bundles.md" + grep -q "## Feature log" "$ref" + grep -q "It replaces the changelog tables" "$ref" + for event in Ratified Shipped Canonized; do + grep -qE "^\| $event \|" "$ref" || { echo "feature log misses $event" >&2; return 1; } + done +} + +@test "feature-log links outlive canonization: promotion PR, ship evidence, archive" { + local tmpl="$SCRIPT_DIR/templates/documents/feature-log.md.tmpl" entry + # changes// is gone once the change is canonized, so no entry links it. + refute_grep -qE '\]\(changes/[^/)]+/\)' "$tmpl" "$SCRIPT_DIR/references/feature-bundles.md" \ + "$FIXTURE"/*/shared-calendars/log.md + entry=$(sed -n '/^## Ratified/,/^## /p' "$tmpl") + grep -q '^- Links: Promotion PR #$' <<< "$entry" + # The promotion PR writes the Ratified entry, so it can't hold its own merge commit. + refute_grep -q 'merge commit' "$tmpl" "$SCRIPT_DIR/docs/METHODOLOGY.md" + refute_grep -rq 'Promotion PR.*merge commit' "$SCRIPT_DIR/tests/fixtures" + grep -q "A Ratified entry links the promotion PR only" <<< "$(joined "$SCRIPT_DIR/references/feature-bundles.md")" + entry=$(sed -n '/^## Shipped/,/^## /p' "$tmpl") + grep -q '^- Evidence: ' <<< "$entry" + entry=$(sed -n '/^## Canonized/,$p' "$tmpl") + grep -q '](changes/archive/-/)' <<< "$entry" + grep -qE '^\| Ratified \| .*a link to the promotion PR \|$' "$SCRIPT_DIR/references/feature-bundles.md" +} + +@test "lineage log records splits, merges, drops, dropped changes and closed promotion PRs without stubs" { + local ref="$SCRIPT_DIR/references/feature-bundles.md" + grep -q '`docs/product/features/log.md` is the lineage log' "$ref" + for event in "Feature split" "Feature merge" "Feature drop" "Dropped change" "Promotion PR closed without merging"; do + grep -q "\*\*$event\*\*" "$ref" || { echo "lineage log misses $event" >&2; return 1; } + done + grep -q "### No stub bundles" "$ref" + grep -q "Canonization that would delete a bundle is refused while that bundle holds any other change in \`changes/\`, Ratified or Shipped" <<< "$(joined "$ref")" + grep -q "It is refused as well while an uncanonized change in any other feature has feature-qualified deltas that target the bundle" <<< "$(joined "$ref")" + grep -q "links the last commit that had it" "$ref" + grep -q "### Worked example: a merge" "$ref" + grep -q "No \`calendar-links\` directory remains" "$ref" +} + +@test "a Shipped change cannot be dropped; withdrawing shipped behavior is a new change" { + local tmpl="$SCRIPT_DIR/templates/documents/lineage-log.md.tmpl" text + grep -qx -- "- State when dropped: " "$tmpl" + grep -q "A Shipped change cannot be dropped" "$tmpl" + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "A Shipped change cannot be dropped: withdrawing shipped behavior is a new change that removes it, shaped, ratified and canonized like any other" <<< "$text" + grep -q "A Shipped change in that bundle is canonized or moved, never dropped" <<< "$text" + grep -q "A Shipped change cannot be dropped" <<< "$(joined "$SCRIPT_DIR/references/changes-and-deltas.md")" + grep -q "drop it only if it has not shipped" "$SCRIPT_DIR/templates/features/AGENTS.md.tmpl" +} + +# --- Changes and deltas --- + +@test "every PRD and TRD describes a change, including the first version" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q "including the feature's first version. Every PRD and TRD describes a change" <<< "$text" + grep -q "Planning tense is correct in its PRD and TRD" <<< "$text" + grep -q "delta text .* durable tense" <<< "$(tr 'A-Z' 'a-z' <<< "$text")" +} + +@test "shaping and the PRD carry the change's provenance" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" req="$SCRIPT_DIR/references/requirements.md" table + grep -q "^### Provenance" "$ref" + table=$(sed -n '/^### Provenance/,/^## /p' "$ref") + for row in "Current artifacts" "Affected consumers" "Compatibility constraints" "Decisions" "Evidence" "Rejected alternatives" "Non-goals and boundaries"; do + grep -qE "^\| $row \|" <<< "$table" || { echo "provenance misses $row" >&2; return 1; } + done + grep -q "who decided what, and when" <<< "$table" + grep -q "the claim each source supports" <<< "$table" + grep -qE '^[0-9]+\. \*\*Provenance\*\*' "$req" + grep -q "^- Provenance names the affected consumers" "$req" + grep -qE '^\| Non-goals and boundaries \| .*active delivery team.*refactors' <<< "$table" + grep -qE '^[0-9]+\. \*\*Provenance\*\* .*non-goals and boundaries' "$req" + grep -qE '^- Provenance names .*non-goals and boundaries' "$req" + grep -q "non-goals and boundaries" "$SCRIPT_DIR/docs/METHODOLOGY.md" + grep -q "non-goals and boundaries" "$SCRIPT_DIR/templates/shaping/AGENTS.md.tmpl" + grep -q "provenance: affected consumers, compatibility constraints, who decided what and when" "$SCRIPT_DIR/docs/METHODOLOGY.md" + grep -q "provenance" "$SCRIPT_DIR/templates/shaping/AGENTS.md.tmpl" +} + +@test "the four classifications each map to a path" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" + for class in "Independent new feature" "Incremental amendment" "Evolution or migration" "Fundamental change"; do + grep -qE "^\| $class \|" "$ref" || { echo "missing classification $class" >&2; return 1; } + done + grep -q 'x-amends: {feature}' "$ref" +} + +@test "change states come from the path and two signals, with the OKF status mapping" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" + grep -qE '^\| Idea \| `ideas/` \| — \| `draft` \|$' "$ref" + grep -qE '^\| Shaping \| `shaping/{feature}--{change}/` \| — \| `draft` \|$' "$ref" + grep -qE '^\| In review \| `shaping/{feature}--{change}/` \| Its promotion PR is open \| `draft` \|$' "$ref" + grep -qE '^\| Ratified \| `features/{feature}/changes/{change}/` \| Its promotion PR merged \| `stable` \|$' "$ref" + grep -qE '^\| Shipped \| `features/{feature}/changes/{change}/` \| A feature-log entry records the ship signal \| `stable` \|$' "$ref" + grep -qE '^\| Canonized \| `features/{feature}/changes/archive/YYYY-MM-DD-{change}/` \| — \| `deprecated` \|$' "$ref" + grep -qE '^\| Dropped \| Deleted \| A lineage-log entry records the drop and its reason \| — \|$' "$ref" +} + +@test "a shaping directory holds one change and is named for its feature and change" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q 'While shaped, a change lives in `shaping/{feature}--{change}/`, one directory per change' <<< "$text" + grep -q "A change name is unique within its feature, including the change archive" <<< "$text" +} + +@test "deltas list added, modified and removed units, and modified and removed units record base text" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" + grep -qE '^\| `ADDED` \|' "$ref" + grep -qE '^\| `MODIFIED` \| `Base text:` .* `New text:`' "$ref" + grep -qE '^\| `REMOVED` \| `Base text:`' "$ref" + grep -q "Copy base text from the current feature spec" "$ref" + grep -q "make the outer fence longer than every fence inside it" "$ref" + grep -q 'Section: Guests > Requirements' "$ref" +} + +@test "deltas that touch another feature use feature-qualified targets, and moved units keep their IDs" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" text merge + text=$(joined "$ref") + grep -q '`deltas/{feature-id}/{facet}.delta.md` targets `features/{feature-id}/{facet}.md`' <<< "$text" + grep -q "^### Moving a unit" "$ref" + grep -q "the base check accepts an \`ADDED\` ID that the same change removes from the same feature" <<< "$text" + grep -q "Compare units by feature and ID" <<< "$text" + grep -q "Compare changes by feature and name" <<< "$text" + grep -q 'a change is identified by its feature and name, written `{feature}/{change}`' <<< "$text" + merge=$(sed -n '/^### Worked example: a merge/,/^### Worked example: a dropped change/p' "$SCRIPT_DIR/references/feature-bundles.md") + grep -q 'deltas/calendar-links/sharing.delta.md' <<< "$merge" + grep -q 'tests/fixtures/feature-merge/' <<< "$merge" +} + +@test "overlap check runs at promotion and before merge, and catches two changes adding the same ID" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q "## Overlap check" "$SCRIPT_DIR/references/changes-and-deltas.md" + grep -q "\*\*When:\*\* when a change's promotion PR is prepared, and again just before it merges" <<< "$text" + grep -q "another change adds with the same ID" <<< "$text" + grep -q "Two changes adding the same ID always end with one of them renumbered" <<< "$text" +} + +@test "base check runs at canonization and before the canonization PR merges, and rebases drift" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q "## Base check" "$SCRIPT_DIR/references/changes-and-deltas.md" + grep -q "\*\*When:\*\* at canonization, before the deltas are applied, and again just before the canonization PR merges" <<< "$text" + grep -q "The maintainer confirms any change in meaning" <<< "$text" + grep -q "the archive keeps the deltas as they were ratified" <<< "$text" +} + +@test "worked example runs two parallel changes, including a same-ID addition and a rebase" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" example + example=$(sed -n '/^## Worked example: two parallel changes/,/^## Shipping and canonization/p' "$ref") + grep -q "invite-expiry" <<< "$example" + grep -q "decline-with-note" <<< "$example" + grep -q 'reports `FR-03` (both modify) and `FR-12` (both add)' <<< "$example" + grep -q "Its base check fails on \`FR-03\`" <<< "$example" + grep -q "tests/fixtures/two-canonizations/" <<< "$example" +} + +@test "a change's stories and scenarios stay in the change until canonization, with a worked example" { + local ref="$SCRIPT_DIR/references/changes-and-deltas.md" + grep -q "## A change's stories and scenarios" "$ref" + grep -q "A change carries its own stories and scenarios until it is canonized" "$ref" + grep -q "changes/decline-with-note/" "$ref" + grep -q "scenarios/invitation-responses.feature the change's revised version" "$ref" + grep -q "### Deferred stories and scenarios" "$ref" + grep -q "Every story and scenario file the change adds or revises is a whole-file unit with its own entry" "$ref" + refute_grep -q "An added story needs no entry" "$ref" +} + +@test "canonization is summarized and its workflow reference is left to issue #21" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q "## Shipping and canonization" "$SCRIPT_DIR/references/changes-and-deltas.md" + grep -q "#21 (canonize shipped changes into the feature spec)" <<< "$text" + grep -q "The archive keeps the content of the ratified deltas as approved; canonization changes only their OKF \`status\`, from \`stable\` to \`deprecated\`" <<< "$text" + refute_grep -q "The archive keeps the ratified deltas unchanged" <<< "$text" +} + +# --- Document templates --- + +@test "document templates carry the closed OKF types" { + local dir="$SCRIPT_DIR/templates/documents" + grep -q "^type: feature-spec-overview$" "$dir/feature-spec-overview.md.tmpl" + grep -q "^type: feature-spec-facet$" "$dir/feature-spec-facet.md.tmpl" + grep -q "^type: delta$" "$dir/delta.md.tmpl" + grep -q "^status: stable$" "$dir/feature-spec-overview.md.tmpl" + grep -q "^status: stable$" "$dir/feature-spec-facet.md.tmpl" + grep -q "^status: draft$" "$dir/delta.md.tmpl" + for section in ADDED MODIFIED REMOVED; do + grep -q "^## $section$" "$dir/delta.md.tmpl" + done +} + +@test "log templates have no front matter" { + for log in feature-log lineage-log; do + local first + first=$(head -1 "$SCRIPT_DIR/templates/documents/$log.md.tmpl") + [ "$first" != "---" ] + done +} + +@test "feature spec templates contain no planning-tense prompts" { + for tmpl in feature-spec-overview feature-spec-facet; do + local file="$SCRIPT_DIR/templates/documents/$tmpl.md.tmpl" + refute_grep -qiE '\bwill\b|to be (created|built|added)|\bplanned\b|\bproposed\b|add and remove|\b(Create|Modify|Remove)\b|\bDependencies\b|\bif .* is approved\b|changelog' "$file" + done +} + +# --- Fixture: two canonizations against one feature --- + +FIXTURE="$SCRIPT_DIR/tests/fixtures/two-canonizations" +DELTAS="$SCRIPT_DIR/tests/helpers/deltas.py" + +# Prints a checksum line per file under a directory, to prove a refused +# canonization changed nothing. +snapshot() { + (cd "$1" && find . -type f | LC_ALL=C sort | xargs shasum) +} + +# Copies the start state into a temp features/ directory. +stage_fixture() { + WORK="$(mktemp -d)" + cp -R "$FIXTURE/start/shared-calendars" "$WORK/shared-calendars" + FEATURE="$WORK/shared-calendars" +} + +@test "fixture: overlap check flags a same-ID addition and a shared modified unit" { + run python3 "$DELTAS" overlap "$FIXTURE/start/shared-calendars/changes/invite-expiry" "$FIXTURE/drafts/shared-calendars--decline-with-note" + [ "$status" -eq 1 ] + grep -qx "FR-03: invite-expiry modifies; decline-with-note modifies" <<< "$output" + grep -qx "FR-12: invite-expiry adds; decline-with-note adds" <<< "$output" +} + +@test "fixture: after renumbering, the overlap check reports only the ordered FR-03" { + run python3 "$DELTAS" overlap "$FIXTURE/start/shared-calendars/changes/invite-expiry" "$FIXTURE/start/shared-calendars/changes/decline-with-note" + [ "$status" -eq 1 ] + grep -qx "FR-03: invite-expiry modifies; decline-with-note modifies" <<< "$output" + refute_grep -q "FR-12\|FR-13" <<< "$output" +} + +@test "fixture: a change's stories and scenarios stay in the change until canonization" { + local root="$FIXTURE/start/shared-calendars" + [ ! -e "$root/stories/US-007-invitation-expiry.md" ] + [ ! -e "$root/scenarios/invitation-expiry.feature" ] + [ -f "$root/changes/invite-expiry/stories/US-007-invitation-expiry.md" ] + [ -f "$root/changes/invite-expiry/scenarios/invitation-expiry.feature" ] + # The revised scenario file differs from the shipped one until canonization. + refute_grep -q "decline note" "$root/scenarios/invitation-responses.feature" + grep -q "decline note" "$root/changes/decline-with-note/scenarios/invitation-responses.feature" +} + +@test "fixture: the second canonization preserves the first one's edits" { + stage_fixture + + run python3 "$DELTAS" canonize "$FEATURE" invite-expiry --date 2026-12-01 + [ "$status" -eq 0 ] + grep -q "An expired invitation cannot be accepted." "$FEATURE/invitations.md" + [ -f "$FEATURE/scenarios/invitation-expiry.feature" ] + # Canonizing one change leaves the other change's files in the change. + [ ! -e "$FEATURE/stories/US-008-decline-with-note.md" ] + refute_grep -q "decline note" "$FEATURE/scenarios/invitation-responses.feature" + + # decline-with-note was written against FR-03 before invite-expiry + # changed it. The base check catches the drift. + run python3 "$DELTAS" base-check "$FEATURE" "$FEATURE/changes/decline-with-note" + [ "$status" -eq 1 ] + grep -qx "FR-03: base text differs from invitations.md" <<< "$output" + refute_grep -q "FR-05\|FR-13\|invitation-responses" <<< "$output" + + # Canonizing with the stale delta is refused and changes nothing, so the + # first change's sentence can't be silently dropped. + local before + before="$(cat "$FEATURE/invitations.md")" + run python3 "$DELTAS" canonize "$FEATURE" decline-with-note --date 2026-12-15 + [ "$status" -eq 1 ] + [ "$(cat "$FEATURE/invitations.md")" = "$before" ] + [ -d "$FEATURE/changes/decline-with-note" ] + + # With the rebased delta, canonization runs and keeps both edits. + run python3 "$DELTAS" canonize "$FEATURE" decline-with-note --date 2026-12-15 \ + --deltas "$FIXTURE/rebased/decline-with-note/deltas" + [ "$status" -eq 0 ] + grep -q "and can add a note when declining" "$FEATURE/invitations.md" + grep -q "An expired invitation cannot be accepted." "$FEATURE/invitations.md" + + run diff -r -x log.md "$FIXTURE/expected/shared-calendars" "$FEATURE" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + rm -rf "$WORK" +} + +@test "fixture: the archive keeps the ratified deltas, not the rebased one" { + local start="$FIXTURE/start/shared-calendars/changes/decline-with-note/deltas/invitations.delta.md" + local archived="$FIXTURE/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/deltas/invitations.delta.md" + [ "$(sed 's/^status: stable$/status: deprecated/' "$start")" = "$(cat "$archived")" ] + grep -q "^status: deprecated$" "$archived" +} + +@test "fixture: feature logs run in date order and only append" { + local log dates + for log in "$FIXTURE"/*/shared-calendars/log.md; do + dates=$(sed -n 's/^## \([0-9-]\{10\}\) .*/\1/p' "$log") + [ -n "$dates" ] + [ "$dates" = "$(sort <<< "$dates")" ] || { echo "$log: entries out of date order" >&2; return 1; } + done + # Canonization appends its entries: the expected log starts with the start log. + local start="$FIXTURE/start/shared-calendars/log.md" + [ "$(head -n "$(wc -l < "$start")" "$FIXTURE/expected/shared-calendars/log.md")" = "$(cat "$start")" ] +} + +@test "fixture: expected spec holds shipped behavior in durable tense" { + local spec="$FIXTURE/expected/shared-calendars/invitations.md" + refute_grep -qiE '\bwill\b|\bnow\b|no longer|\bnew\b|replaces|formerly' "$spec" +} + +@test "examples keep delta text in durable tense and give merged units free IDs" { + refute_grep -rqi "can no longer be accepted" "$SCRIPT_DIR/references" "$FIXTURE"/*/*/invitations.md "$FIXTURE"/*/*/deltas "$FIXTURE"/start/shared-calendars/changes/*/deltas "$FIXTURE"/expected/shared-calendars/changes/archive/*/deltas + grep -q 'An expired invitation cannot be accepted.' "$SCRIPT_DIR/references/changes-and-deltas.md" + # decline-with-note took FR-13, so the merge example's units take FR-14 and FR-15. + local merge + merge=$(sed -n '/^### Worked example: a merge/,/^### Worked example: a dropped change/p' "$SCRIPT_DIR/references/feature-bundles.md") + refute_grep -q 'arrive as `FR-13`\|shared-calendars FR-13' <<< "$merge" + grep -q 'arrive as `FR-14` and `FR-15`' <<< "$merge" + grep -q 'calendar-links FR-01 → shared-calendars FR-14; FR-02 → FR-15' <<< "$merge" +} + +# --- Fixture: a feature merge --- + +MERGE="$SCRIPT_DIR/tests/fixtures/feature-merge" + +# Copies both features of the merge's start state into a temp features/ directory. +stage_merge() { + WORK="$(mktemp -d)" + cp -R "$MERGE/start/shared-calendars" "$MERGE/start/calendar-links" "$WORK/" + FEATURE="$WORK/shared-calendars" +} + +@test "merge fixture: the overlap check keys units by feature" { + run python3 "$DELTAS" overlap "$MERGE/start/shared-calendars/changes/absorb-calendar-links" \ + "$MERGE/drafts/calendar-links--link-expiry" "$MERGE/drafts/shared-calendars--share-roles" + [ "$status" -eq 1 ] + # The merge removes calendar-links FR-01, which link-expiry modifies. + # share-roles modifies shared-calendars FR-01, a different unit. + [ "$output" = "calendar-links/FR-01: shared-calendars/absorb-calendar-links removes; calendar-links/link-expiry modifies" ] +} + +@test "merge fixture: the overlap check keys changes by feature and name" { + # Two features each have a change named link-expiry, and both modify + # calendar-links FR-01. A change name is unique only within its feature. + run python3 "$DELTAS" overlap "$MERGE/drafts/calendar-links--link-expiry" "$MERGE/drafts/shared-calendars--link-expiry" + [ "$status" -eq 1 ] + [ "$output" = "calendar-links/FR-01: calendar-links/link-expiry modifies; shared-calendars/link-expiry modifies" ] +} + +@test "merge fixture: canonization applies a feature-qualified delta and deletes the emptied bundle" { + stage_merge + run python3 "$DELTAS" canonize "$FEATURE" absorb-calendar-links --date 2027-01-20 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + grep -qx "deleted calendar-links: no spec units remain" <<< "$output" + [ ! -e "$WORK/calendar-links" ] + run diff -r -x log.md "$MERGE/expected/shared-calendars" "$FEATURE" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + rm -rf "$WORK" +} + +@test "merge fixture: a bundle with another live change is not deleted" { + stage_merge + # A ratified calendar-links change that only adds a unit overlaps with + # nothing the merge touches, but deleting the bundle would delete it. + mkdir -p "$WORK/calendar-links/changes/link-qr-codes/deltas" + printf '%s\n' '# Delta: sharing.md' '' '## ADDED' '' '### FR-10' '' 'Section: Requirements' '' 'Text:' '' \ + '~~~markdown' '### FR-10 Link QR codes' '' 'An owner shows a calendar link as a QR code.' '~~~' \ + > "$WORK/calendar-links/changes/link-qr-codes/deltas/sharing.delta.md" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" absorb-calendar-links --date 2027-01-20 + [ "$status" -eq 1 ] + [ "$output" = "calendar-links: canonizing would delete this bundle, but it holds other changes: link-qr-codes; canonize them or move them to shared-calendars first, or drop those that have not shipped" ] + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "merge fixture: a bundle another feature's live change targets is not deleted" { + stage_merge + # A ratified change in a third feature adds a unit to calendar-links + # through a feature-qualified delta. calendar-links holds no change of + # its own, but deleting it would leave that delta with no bundle. + mkdir -p "$WORK/event-search/changes/link-search/deltas/calendar-links" + printf '%s\n' '# Delta: calendar-links/sharing.md' '' '## ADDED' '' '### FR-10' '' 'Section: Requirements' '' 'Text:' '' \ + '~~~markdown' '### FR-10 Link search' '' 'An owner finds a calendar link by its label.' '~~~' \ + > "$WORK/event-search/changes/link-search/deltas/calendar-links/sharing.delta.md" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" absorb-calendar-links --date 2027-01-20 + [ "$status" -eq 1 ] + [ "$output" = "calendar-links: canonizing would delete this bundle, but changes in other features target it: event-search/link-search; canonize them or retarget their deltas to shared-calendars first, or drop those that have not shipped" ] + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "merge fixture: the base check covers the other feature's units" { + stage_merge + sed -i.bak 's/the link stops working at once\./the link stops working within a minute./' "$WORK/calendar-links/sharing.md" + rm "$WORK/calendar-links/sharing.md.bak" + run python3 "$DELTAS" base-check "$FEATURE" "$FEATURE/changes/absorb-calendar-links" + [ "$status" -eq 1 ] + [ "$output" = "calendar-links/FR-02: base text differs from calendar-links/sharing.md" ] + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" absorb-calendar-links --date 2027-01-20 + [ "$status" -eq 1 ] + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "merge fixture: an ID taken in the receiving feature is refused" { + stage_merge + # FR-09 is free in shared-calendars until another change takes it. + printf '%s\n' '' '### FR-09 Share notifications' '' 'A person is told when a calendar is shared with them.' >> "$FEATURE/sharing.md" + run python3 "$DELTAS" base-check "$FEATURE" "$FEATURE/changes/absorb-calendar-links" + [ "$status" -eq 1 ] + [ "$output" = "FR-09: added, but sharing.md already has FR-09" ] + rm -rf "$WORK" +} + +@test "helper: a unit that moves between facets keeps its ID" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' '' '### FR-02 Two' '' 'Two.' > "$feature/a.md" + printf '%s\n' '# B' '' '## Requirements' '' '### FR-05 Five' '' 'Five.' > "$feature/b.md" + printf '%s\n' '# Delta: a.md' '' '## REMOVED' '' '### FR-02' '' 'Base text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' > "$feature/changes/c/deltas/a.delta.md" + printf '%s\n' '# Delta: b.md' '' '## ADDED' '' '### FR-02' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' > "$feature/changes/c/deltas/b.delta.md" + # A change's own move is not an overlap. + run python3 "$DELTAS" overlap "$feature/changes/c" + [ "$status" -eq 0 ] + [ "$output" = "no overlap" ] + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + refute_grep -q "FR-02" "$feature/a.md" + grep -qx "### FR-02 Two" "$feature/b.md" + [ "$(cat "$feature/a.md" "$feature/b.md" | grep -c '^### FR-02 ')" -eq 1 ] + rm -rf "$work" +} + +@test "helper: two facets adding the same free ID are refused after all deltas apply" { + local work feature before + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + printf '%s\n' '# B' '' '## Requirements' '' '### FR-05 Five' '' 'Five.' > "$feature/b.md" + printf '%s\n' '# Delta: a.md' '' '## ADDED' '' '### FR-02' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' > "$feature/changes/c/deltas/a.delta.md" + printf '%s\n' '# Delta: b.md' '' '## ADDED' '' '### FR-02' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-02 Deux' '' 'Deux.' '~~~' > "$feature/changes/c/deltas/b.delta.md" + # Each entry alone finds FR-02 free in the current spec. + run python3 "$DELTAS" base-check "$feature" "$feature/changes/c" + [ "$status" -eq 0 ] + before="$(snapshot "$work")" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 1 ] + [ "$output" = "FR-02: 2 units have this ID after canonization, in a.md, b.md; IDs are unique per feature" ] + [ "$(snapshot "$work")" = "$before" ] + rm -rf "$work" +} + +@test "changes and deltas reference requires unique unit IDs per feature after the change" { + grep -q "Unit IDs are unique per feature after the change: with every delta applied, each ID appears once across the feature's spec documents" \ + <<< "$(joined "$SCRIPT_DIR/references/changes-and-deltas.md")" +} + +@test "helper: a unit moved within a sibling bundle keeps that bundle" { + local work q + work="$(mktemp -d)" + mkdir -p "$work/f/changes/c/deltas/g" "$work/g" + q="$work/f/changes/c/deltas/g" + printf '%s\n' '---' 'type: feature-spec-overview' '---' '' '# G' > "$work/g/g-spec.md" + printf '%s\n' '# G log' > "$work/g/log.md" + printf '%s\n' '# A' '' '## Requirements' > "$work/g/a.md" + printf '%s\n' '# Z' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$work/g/z.md" + # The addition to a.md sorts before the removal from z.md; FR-01 is the + # bundle's only unit before and after. + printf '%s\n' '# Delta: g/a.md' '' '## ADDED' '' '### FR-01' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-01 One' '' 'One.' '~~~' > "$q/a.delta.md" + printf '%s\n' '# Delta: g/z.md' '' '## REMOVED' '' '### FR-01' '' 'Base text:' '' '~~~markdown' '### FR-01 One' '' 'One.' '~~~' > "$q/z.delta.md" + run python3 "$DELTAS" canonize "$work/f" c --date 2026-12-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + refute_grep -q "deleted g" <<< "$output" + grep -qx "### FR-01 One" "$work/g/a.md" + refute_grep -q "FR-01" "$work/g/z.md" + rm -rf "$work" +} + +# --- Fixture: a feature split --- + +SPLIT="$SCRIPT_DIR/tests/fixtures/feature-split" + +@test "split fixture: the promotion PR initializes the receiving bundle like a first version" { + local overview="$SPLIT/start/calendar-links/calendar-links-spec.md" + grep -q '^type: feature-spec-overview$' "$overview" + refute_grep -q '^## Facets\|sharing.md' "$overview" + [ "$(ls "$SPLIT/start/calendar-links")" = "$(printf '%s\n' calendar-links-spec.md log.md)" ] + grep -qx "## 2027-03-01 Ratified: shared-calendars/split-calendar-links" "$SPLIT/start/calendar-links/log.md" + grep -qx "## 2027-03-01 Ratified: split-calendar-links" "$SPLIT/start/shared-calendars/log.md" + grep -q "the split moves FR-03 and FR-04 to a new feature, calendar-links" "$SPLIT/start/shared-calendars/log.md" +} + +@test "split fixture: canonization completes the receiving bundle" { + WORK="$(mktemp -d)" + cp -R "$SPLIT/start/shared-calendars" "$SPLIT/start/calendar-links" "$WORK/" + run python3 "$DELTAS" canonize "$WORK/shared-calendars" split-calendar-links --date 2027-03-10 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + for f in shared-calendars calendar-links; do + run diff -r -x log.md "$SPLIT/expected/$f" "$WORK/$f" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + done + rm -rf "$WORK" +} + +@test "a split's receiving overview links the owning feature's archived change, not its own archive" { + local tmpl="$SCRIPT_DIR/templates/documents/feature-spec-overview.md.tmpl" + grep -q 'Link `changes/archive/` only when this bundle has one' <<< "$(joined "$tmpl")" + grep -q "a split's receiving bundle links the owning feature's archived change instead" <<< "$(joined "$tmpl")" + refute_grep -qF '(changes/archive/)' "$SPLIT/start/calendar-links/calendar-links-spec.md" "$SPLIT/expected/calendar-links/calendar-links-spec.md" + grep -q '(../shared-calendars/changes/archive/2027-03-10-split-calendar-links/)' "$SPLIT/expected/calendar-links/calendar-links-spec.md" +} + +@test "split fixture: a split into a feature its promotion PR did not initialize is refused" { + WORK="$(mktemp -d)" + cp -R "$SPLIT/start/shared-calendars" "$WORK/" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$WORK/shared-calendars" split-calendar-links --date 2027-03-10 + [ "$status" -eq 1 ] + grep -qx "calendar-links: the receiving bundle is missing its overview or log; the promotion PR initializes it like a first version" <<< "$output" + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "dropping a split's owning change deletes the receiving bundle it created" { + local text tmpl="$SCRIPT_DIR/templates/documents/lineage-log.md.tmpl" + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "Dropping the owning change also deletes a receiving bundle its promotion PR created, when that bundle holds no other change and no shipped content" <<< "$text" + grep -q "The Dropped change entry names the deleted bundle under Removed" <<< "$text" + grep -q -- "- Removed: \`features//\`, the receiving bundle the change's promotion PR created, last present in commit " "$tmpl" +} + +@test "a split's promotion PR initializes the receiving bundle and both logs record the split" { + local text + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "When a change's feature-qualified deltas target a feature that does not exist yet, its promotion PR initializes that bundle like a first version" <<< "$text" + grep -q "a Ratified entry naming the owning change" <<< "$text" + grep -q "The promotion PR also adds a Feature split entry to the lineage log" <<< "$text" + grep -q "tests/fixtures/feature-split/" <<< "$text" +} + +# --- Fixture: a feature's first version --- + +FIRST="$SCRIPT_DIR/tests/fixtures/first-version" + +@test "first-version fixture: ratification leaves a metadata-only overview" { + local overview="$FIRST/start/shared-calendars/shared-calendars-spec.md" + grep -q '^type: feature-spec-overview$' "$overview" + grep -q '^status: stable$' "$overview" + # No behavior claims and no links to facets, stories or scenarios that don't exist yet. + refute_grep -q '^## Facets\|^## Stories and scenarios\|invitations.md\|stories/\|scenarios/' "$overview" + [ "$(grep -v '^$' "$overview" | sed -n '/^# /,$p' | sed -n 2p)" = "## History" ] +} + +@test "first-version fixture: canonization writes the facet's front matter and the complete overview" { + WORK="$(mktemp -d)" + cp -R "$FIRST/start/shared-calendars" "$WORK/" + run python3 "$DELTAS" canonize "$WORK/shared-calendars" event-invitations --date 2026-09-14 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + run diff -r -x log.md "$FIRST/expected/shared-calendars" "$WORK/shared-calendars" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + rm -rf "$WORK" +} + +# Copies the first version's start state and writes reconciled deltas that +# defer the reminders facet but keep the overview's DOCUMENT text as ratified. +stage_partial_first_version() { + WORK="$(mktemp -d)" + cp -R "$FIRST/start/shared-calendars" "$WORK/" + FEATURE="$WORK/shared-calendars" + mkdir -p "$WORK/unreconciled" + cp "$FEATURE/changes/event-invitations/deltas/invitations.delta.md" \ + "$FEATURE/changes/event-invitations/deltas/shared-calendars-spec.delta.md" "$WORK/unreconciled/" +} + +@test "first-version fixture: a deferred facet's DOCUMENT text is not published" { + stage_partial_first_version + local before + before="$(snapshot "$WORK")" + # The overview's DOCUMENT text still describes the deferred reminders. + run python3 "$DELTAS" canonize "$FEATURE" event-invitations --date 2026-09-14 --deltas "$WORK/unreconciled" + [ "$status" -eq 1 ] + grep -qx "shared-calendars-spec.md: DOCUMENT links reminders.md, which does not resolve after canonization; reconcile the DOCUMENT text with what shipped" <<< "$output" + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "first-version fixture: a partly shipped first version publishes only what shipped" { + stage_partial_first_version + run python3 "$DELTAS" canonize "$FEATURE" event-invitations --date 2026-09-14 --deltas "$FIRST/reconciled-partial/deltas" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + grep -qx "deferred: scenarios/event-reminders.feature stays in changes/archive/2026-09-14-event-invitations" <<< "$output" + [ ! -e "$FEATURE/reminders.md" ] + [ ! -e "$FEATURE/scenarios/event-reminders.feature" ] + refute_grep -rqi "remind" "$FEATURE/shared-calendars-spec.md" "$FEATURE/invitations.md" "$FEATURE/scenarios" "$FEATURE/stories" + [ -f "$FEATURE/changes/archive/2026-09-14-event-invitations/scenarios/event-reminders.feature" ] + [ -f "$FEATURE/changes/archive/2026-09-14-event-invitations/deltas/reminders.delta.md" ] + grep -q "^| \[Invitations\](./invitations.md) |" "$FEATURE/shared-calendars-spec.md" + rm -rf "$WORK" +} + +@test "first-version fixture: a ./ link to a deferred facet is refused" { + stage_partial_first_version + mkdir -p "$WORK/dot-link" + cp "$FIRST/reconciled-partial/deltas/"*.delta.md "$WORK/dot-link/" + # Put the deferred Reminders row back, written with a ./ prefix. + sed -i.bak '/^| \[Invitations\]/a\ +| [Reminders](./reminders.md) | How invitees who accepted are reminded of the event | FR | +' "$WORK/dot-link/shared-calendars-spec.delta.md" + rm "$WORK/dot-link/shared-calendars-spec.delta.md.bak" + grep -q '(./reminders.md)' "$WORK/dot-link/shared-calendars-spec.delta.md" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" event-invitations --date 2026-09-14 --deltas "$WORK/dot-link" + [ "$status" -eq 1 ] + [ "$output" = "shared-calendars-spec.md: DOCUMENT links ./reminders.md, which does not resolve after canonization; reconcile the DOCUMENT text with what shipped" ] + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "first-version fixture: a reference-style link to a deferred facet is refused" { + stage_partial_first_version + mkdir -p "$WORK/ref-link" + cp "$FIRST/reconciled-partial/deltas/invitations.delta.md" "$WORK/ref-link/" + # Put the deferred Reminders row back as a reference-style link. + awk '{ print } + /^\| \[Invitations\]/ { print "| [Reminders][facet] | How invitees who accepted are reminded of the event | FR |" } + /^- Platform-level scenarios:/ { print ""; print "[facet]: ./reminders.md" }' \ + "$FIRST/reconciled-partial/deltas/shared-calendars-spec.delta.md" > "$WORK/ref-link/shared-calendars-spec.delta.md" + grep -qx '\[facet\]: ./reminders.md' "$WORK/ref-link/shared-calendars-spec.delta.md" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" event-invitations --date 2026-09-14 --deltas "$WORK/ref-link" + [ "$status" -eq 1 ] + [ "$output" = "shared-calendars-spec.md: DOCUMENT links ./reminders.md, which does not resolve after canonization; reconcile the DOCUMENT text with what shipped" ] + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +# Prints an overview delta that rewrites the document in $1 as the text in $2. +overview_rewrite() { + printf '%s\n' '---' 'type: delta' 'title: Overview delta' 'description: The overview rewritten.' 'status: stable' '---' '' \ + '# Delta: shared-calendars-spec.md' '' '## DOCUMENT' '' 'Base text:' '' '~~~markdown' + cat "$1" + printf '%s\n' '~~~' '' 'New text:' '' '~~~markdown' + cat "$2" + printf '%s\n' '~~~' +} + +@test "first-version fixture: DOCUMENT text may link an existing facet the change does not write" { + stage_partial_first_version + run python3 "$DELTAS" canonize "$FEATURE" event-invitations --date 2026-09-14 --deltas "$FIRST/reconciled-partial/deltas" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + # The deferred reminders ship later as their own change. Its overview + # rewrite links invitations.md, which exists and which it leaves alone. + local archived="$FEATURE/changes/archive/2026-09-14-event-invitations" change="$FEATURE/changes/event-reminders" + mkdir -p "$change/deltas" "$change/scenarios" + cp "$archived/scenarios/event-reminders.feature" "$change/scenarios/" + sed 's/^status: deprecated$/status: stable/' "$archived/deltas/reminders.delta.md" > "$change/deltas/reminders.delta.md" + sed 's#(reminders.md)#(./notifications.md)#' "$FIRST/expected/shared-calendars/shared-calendars-spec.md" > "$WORK/broken.md" + overview_rewrite "$FEATURE/shared-calendars-spec.md" "$WORK/broken.md" > "$change/deltas/shared-calendars-spec.delta.md" + run python3 "$DELTAS" canonize "$FEATURE" event-reminders --date 2026-10-01 + [ "$status" -eq 1 ] + [ "$output" = "shared-calendars-spec.md: DOCUMENT links ./notifications.md, which does not resolve after canonization; reconcile the DOCUMENT text with what shipped" ] + sed 's#(reminders.md)#(./reminders.md)#' "$FIRST/expected/shared-calendars/shared-calendars-spec.md" > "$WORK/fixed.md" + overview_rewrite "$FEATURE/shared-calendars-spec.md" "$WORK/fixed.md" > "$change/deltas/shared-calendars-spec.delta.md" + run python3 "$DELTAS" canonize "$FEATURE" event-reminders --date 2026-10-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + grep -q "^| \[Invitations\](invitations.md) |" "$FEATURE/shared-calendars-spec.md" + [ -f "$FEATURE/reminders.md" ] + [ -f "$FEATURE/scenarios/event-reminders.feature" ] + rm -rf "$WORK" +} + +@test "DOCUMENT links resolve against the bundle as it will be after canonization" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q 'Canonization resolves every relative link in `DOCUMENT` text, including `./` forms, against the bundle as it will be after canonization, and refuses a link that does not resolve' <<< "$text" + grep -q "A link to an existing document the change leaves alone resolves" <<< "$text" + grep -q "The rule covers reference-style links: each link reference definition's target resolves the same way" <<< "$text" + grep -q "or to an app-local scenario file the deferral deletes, does not" <<< "$text" + refute_grep -q "it does not write" <<< "$text" +} + +@test "helper: units for a missing document without a DOCUMENT entry are refused" { + WORK="$(mktemp -d)" + cp -R "$FIRST/start/shared-calendars" "$WORK/" + local delta="$WORK/shared-calendars/changes/event-invitations/deltas/invitations.delta.md" + # Drop the DOCUMENT section: the facet would be written without front matter. + sed -i.bak '/^## DOCUMENT$/,/^## ADDED$/{/^## ADDED$/!d;}' "$delta" + rm "$delta.bak" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$WORK/shared-calendars" event-invitations --date 2026-09-14 + [ "$status" -eq 1 ] + grep -qx "invitations.md: the document does not exist, and the delta has no DOCUMENT entry to write it" <<< "$output" + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "first versions: ratification writes a metadata-only overview and canonization completes the bundle" { + local text tmpl="$SCRIPT_DIR/templates/documents/feature-spec-overview.md.tmpl" + text=$(joined "$SCRIPT_DIR/references/feature-bundles.md") + grep -q "the promotion PR writes a metadata-only feature overview" <<< "$text" + grep -q "canonization writes the complete shipped overview" <<< "$text" + # A first change can be Shipped while the overview is still metadata-only. + refute_grep -q "because none of the feature's behavior has shipped" <<< "$text" + grep -q "That holds while the change is Ratified and after it ships" <<< "$text" + grep -q "Until the feature's first change is canonized, it is metadata-only" <<< "$(joined "$SCRIPT_DIR/CONTEXT.md")" + grep -q '^## DOCUMENT$' "$SCRIPT_DIR/templates/documents/delta.md.tmpl" + grep -qE '^\| `DOCUMENT` \|' "$SCRIPT_DIR/references/changes-and-deltas.md" + grep -q "metadata-only" "$tmpl" +} + +@test "canonization reconciles DOCUMENT text with what shipped" { + local text + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q "their text is reconciled like a changed unit, with the maintainer's approval" <<< "$text" + grep -q "links to deferred facet specs, stories or scenarios are removed" <<< "$text" + grep -q 'accounts for each requirement, scenario and `DOCUMENT` entry' <<< "$text" + grep -q "the \`DOCUMENT\` text is reconciled too" <<< "$(joined "$SCRIPT_DIR/references/feature-bundles.md")" +} + +# --- App-local scenario files --- + +# Builds a repository whose feature f has a shipped change c. Before c, the +# app had one scenario file, quick-reply.feature; c revised it in place and +# added drag-reschedule.feature. PROMOTED is the promotion PR's merge commit; +# its first parent holds the files as they stood before promotion. +# $1 lists the app-local entries the reconciled deltas keep: "all" or "none". +# With $2 "stale", another change revised quick-reply.feature after c recorded +# its base text and merged before c's promotion PR. +stage_app_local() { + WORK="$(mktemp -d)" + FEATURE="$WORK/docs/product/features/f" + APP="apps/web/docs/features/f/scenarios" + mkdir -p "$FEATURE" "$WORK/$APP" + printf '%s\n' '# F' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$FEATURE/a.md" + BASE="$(printf '%s\n' 'Feature: Quick reply' '' ' Scenario: Reply from a notification' ' When I reply from a notification' ' Then the reply is sent')" + if [ "${2:-}" = stale ]; then + printf '%s\n' "$BASE" '' ' Scenario: Reply with a sticker' ' When I reply with a sticker' ' Then the sticker is sent' > "$WORK/$APP/quick-reply.feature" + else + printf '%s\n' "$BASE" > "$WORK/$APP/quick-reply.feature" + fi + git -C "$WORK" init -q + git -C "$WORK" add -A + git -C "$WORK" -c user.name=t -c user.email=t@example.invalid commit --no-gpg-sign -qm "before promotion" + mkdir -p "$FEATURE/changes/c/deltas" "$WORK/reconciled" + printf '%s\n' "$BASE" '' ' Scenario: Reply with an emoji' ' When I reply with an emoji' ' Then the emoji is sent' > "$WORK/$APP/quick-reply.feature" + printf '%s\n' 'Feature: Drag to reschedule' '' ' Scenario: Drag an event' ' When I drag an event to another day' ' Then it moves to that day' > "$WORK/$APP/drag-reschedule.feature" + local added + added="$(printf '%s\n' '# Delta: a.md' '' '## ADDED' '' '### FR-02' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~')" + local entries + entries="$(printf '%s\n' '' '## App-local scenario files' '' "### $APP/quick-reply.feature" '' 'Base text:' '' '~~~gherkin' "$BASE" '~~~' '' "### $APP/drag-reschedule.feature")" + printf '%s\n%s\n' "$added" "$entries" > "$FEATURE/changes/c/deltas/a.delta.md" + if [ "$1" = all ]; then + printf '%s\n%s\n' "$added" "$entries" > "$WORK/reconciled/a.delta.md" + else + printf '%s\n' "$added" > "$WORK/reconciled/a.delta.md" + fi + git -C "$WORK" add -A + git -C "$WORK" -c user.name=t -c user.email=t@example.invalid commit --no-gpg-sign -qm promote + PROMOTED="$(git -C "$WORK" rev-parse HEAD)" +} + +@test "helper: shipped app-local scenario files stay as the promotion PR left them" { + stage_app_local all + local before + before="$(cat "$WORK/$APP/quick-reply.feature" "$WORK/$APP/drag-reschedule.feature")" + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + [ "$(cat "$WORK/$APP/quick-reply.feature" "$WORK/$APP/drag-reschedule.feature")" = "$before" ] + rm -rf "$WORK" +} + +@test "helper: deferred app-local scenario files are restored from their base text" { + stage_app_local none + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" --repo "$WORK" --promoted "$PROMOTED" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + grep -qx "deferred: $APP/quick-reply.feature restored to its base text" <<< "$output" + grep -qx "deferred: $APP/drag-reschedule.feature removed; the change added it" <<< "$output" + [ "$(cat "$WORK/$APP/quick-reply.feature")" = "$BASE" ] + [ ! -e "$WORK/$APP/drag-reschedule.feature" ] + grep -qx "### FR-02 Two" "$FEATURE/a.md" + rm -rf "$WORK" +} + +@test "helper: a deferred app-local scenario file another change has edited is refused" { + stage_app_local none + printf '%s\n' '' ' Scenario: Reply offline' ' When I reply while offline' ' Then the reply is sent when I reconnect' >> "$WORK/$APP/quick-reply.feature" + git -C "$WORK" -c user.name=t -c user.email=t@example.invalid commit --no-gpg-sign -qam "another change" + local before + before="$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" --repo "$WORK" --promoted "$PROMOTED" + [ "$status" -eq 1 ] + [ "$output" = "$APP/quick-reply.feature: changed since the promotion PR merged; the maintainer reconciles the deferral" ] + [ "$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" = "$before" ] + rm -rf "$WORK" +} + +@test "helper: a deferral whose base text predates the file before promotion is refused" { + stage_app_local none stale + local before + before="$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" --repo "$WORK" --promoted "$PROMOTED" + [ "$status" -eq 1 ] + [ "$output" = "$APP/quick-reply.feature: the recorded base text differs from the file before the promotion PR merged; the maintainer reconciles the deferral" ] + [ "$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" = "$before" ] + rm -rf "$WORK" +} + +# Prints a delta that writes feature f's overview, linking the path in $1. +overview_linking() { + printf '%s\n' '# Delta: f-spec.md' '' '## DOCUMENT' '' 'Text:' '' '~~~markdown' '---' 'type: feature-spec-overview' \ + 'title: F' 'description: F.' 'status: stable' '---' '' '# F' '' "Web scenarios: [scenario]($1)" '~~~' +} + +@test "helper: a DOCUMENT link to an app-local scenario file the deferral deletes is refused" { + stage_app_local none + local link="../../../../apps/web/docs/features/f/scenarios" + overview_linking "$link/drag-reschedule.feature" > "$WORK/reconciled/f-spec.delta.md" + local before + before="$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" --repo "$WORK" --promoted "$PROMOTED" + [ "$status" -eq 1 ] + [ "$output" = "f-spec.md: DOCUMENT links $link/drag-reschedule.feature, which does not resolve after canonization; reconcile the DOCUMENT text with what shipped" ] + [ "$(snapshot "$WORK/docs"; snapshot "$WORK/apps")" = "$before" ] + # A file the deferral restores still resolves. + overview_linking "$link/quick-reply.feature" > "$WORK/reconciled/f-spec.delta.md" + run python3 "$DELTAS" canonize "$FEATURE" c --date 2026-12-01 --deltas "$WORK/reconciled" --repo "$WORK" --promoted "$PROMOTED" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + [ -f "$FEATURE/f-spec.md" ] + rm -rf "$WORK" +} + +@test "app-local scenario files are listed by path with base text in the delta and in the readiness checklist" { + local text req + text=$(joined "$SCRIPT_DIR/references/changes-and-deltas.md") + grep -q 'An entry for a file the change revises holds `Base text:` with the file as it stood before the change' <<< "$text" + grep -q "the canonization PR restores it from the recorded base text, or deletes a file the change added" <<< "$text" + grep -q "if another change has edited it since, canonization refuses and the maintainer reconciles the file" <<< "$text" + grep -q "At promotion, the recorded base text equals the file as it stood immediately before the promotion PR merged, at the merge commit's first parent" <<< "$text" + grep -q "canonization refuses a deferral whose recorded base text differs from the file at the merge commit's first parent" <<< "$text" + req=$(joined "$SCRIPT_DIR/references/requirements.md") + grep -q 'Every story and scenario file the change adds or revises in the feature bundle has a whole-file entry' <<< "$req" + grep -q 'Every app-local scenario file the change adds or changes is listed by path under `## App-local scenario files`, with its base text when the file existed before the change' <<< "$req" + grep -q '^Base text:$' <<< "$(sed -n '/^## App-local scenario files$/,$p' "$SCRIPT_DIR/templates/documents/delta.md.tmpl")" + grep -q "the canonization PR restores it from that base text, or deletes it when the change added it and there is no base to restore" <<< "$(joined "$SCRIPT_DIR/references/bdd-scenarios.md")" +} + +# --- Delta helper edge cases --- + +@test "helper: removing a unit needs matching base text, and an added ID must be free" { + local work feature change + work="$(mktemp -d)" + feature="$work/f" + change="$feature/changes/c" + mkdir -p "$change/deltas" + printf '%s\n' '---' 'type: feature-spec-facet' 'title: A' 'description: A.' 'status: stable' '---' '' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' '' '### FR-02 Two' '' 'Two.' > "$feature/a.md" + printf '%s\n' '---' 'type: delta' 'title: d' 'description: d.' 'status: stable' '---' '' '# Delta: a.md' '' '## REMOVED' '' '### FR-02' '' 'Base text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' > "$change/deltas/a.delta.md" + + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] + refute_grep -q "FR-02" "$feature/a.md" + grep -q "^### FR-01 One$" "$feature/a.md" + [ -d "$feature/changes/archive/2026-12-01-c" ] + + mkdir -p "$feature/changes/d/deltas" + printf '%s\n' '# Delta: a.md' '' '## ADDED' '' '### FR-01' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '### FR-01 Clash' '' 'Clash.' '~~~' > "$feature/changes/d/deltas/a.delta.md" + run python3 "$DELTAS" base-check "$feature" "$feature/changes/d" + [ "$status" -eq 1 ] + grep -qx "FR-01: added, but a.md already has FR-01" <<< "$output" + rm -rf "$work" +} + +@test "helper: unterminated front matter is bad input, not a crash" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + printf '%s\n' '---' 'type: delta' 'title: d' '' '# Delta: a.md' '' '## REMOVED' '' '### FR-01' '' 'Base text:' '' '~~~markdown' '### FR-01 One' '' 'One.' '~~~' > "$feature/changes/c/deltas/a.delta.md" + run python3 "$DELTAS" base-check "$feature" "$feature/changes/c" + [ "$status" -eq 2 ] + grep -q "a.delta.md: front matter opens with '---' but has no closing '---' line" <<< "$output" + refute_grep -q "Traceback" <<< "$output" + rm -rf "$work" +} + +@test "helper: an empty ADDED text is refused by the heading check" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + printf '%s\n' '# Delta: a.md' '' '## ADDED' '' '### FR-02' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '~~~' > "$feature/changes/c/deltas/a.delta.md" + run python3 "$DELTAS" base-check "$feature" "$feature/changes/c" + [ "$status" -eq 2 ] + grep -q "a.delta.md: text for FR-02 does not start with its heading" <<< "$output" + refute_grep -q "Traceback" <<< "$output" + rm -rf "$work" +} + +@test "helper: a delta with only whole-file units writes no facet" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" "$feature/changes/c/scenarios" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + printf '%s\n' 'Feature: Extra' '' ' Scenario: Extra' ' Given one' ' Then two' > "$feature/changes/c/scenarios/extra.feature" + printf '%s\n' '# Delta: extra.md' '' '## ADDED' '' '### scenarios/extra.feature' > "$feature/changes/c/deltas/extra.delta.md" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + [ -f "$feature/scenarios/extra.feature" ] + [ ! -e "$feature/extra.md" ] + rm -rf "$work" +} + +@test "helper: editing one unit keeps blank lines inside another" { + local work feature before + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + # FR-01's fenced example holds two blank lines in a row, which are part + # of its literal text and of any base text recorded for it. + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' '~~~text' 'first' '' '' 'second' '~~~' '' '### FR-02 Two' '' 'Two.' '' '### FR-03 Three' '' 'Three.' > "$feature/a.md" + before="$(sed -n '/^### FR-01/,/^### FR-02/p' "$feature/a.md")" + printf '%s\n' '# Delta: a.md' '' '## MODIFIED' '' '### FR-02' '' 'Base text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' '' \ + 'New text:' '' '~~~markdown' '### FR-02 Two' '' 'Two, revised.' '~~~' '' '## REMOVED' '' '### FR-03' '' 'Base text:' '' '~~~markdown' '### FR-03 Three' '' 'Three.' '~~~' \ + > "$feature/changes/c/deltas/a.delta.md" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + [ "$(sed -n '/^### FR-01/,/^### FR-02/p' "$feature/a.md")" = "$before" ] + [ "$(cat "$feature/a.md")" = "$(printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' '~~~text' 'first' '' '' 'second' '~~~' '' '### FR-02 Two' '' 'Two, revised.')" ] + rm -rf "$work" +} + +@test "helper: a stale whole-file base text is refused and changes nothing" { + stage_fixture + # The shipped scenario file drifts after decline-with-note recorded it as base text. + printf '%s\n' '' ' Scenario: An organizer can resend an invitation' ' Given I invited someone to an event' ' When I resend the invitation' ' Then they receive it again' \ + >> "$FEATURE/scenarios/invitation-responses.feature" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" decline-with-note --date 2026-12-15 + [ "$status" -eq 1 ] + grep -qx "scenarios/invitation-responses.feature: base text differs from the feature root" <<< "$output" + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "helper: a stale removal is refused and changes nothing" { + local work feature before + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '---' 'type: feature-spec-facet' 'title: A' 'description: A.' 'status: stable' '---' '' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' '' '### FR-02 Two' '' 'Two, revised after the delta was written.' > "$feature/a.md" + printf '%s\n' '# Delta: a.md' '' '## REMOVED' '' '### FR-02' '' 'Base text:' '' '~~~markdown' '### FR-02 Two' '' 'Two.' '~~~' > "$feature/changes/c/deltas/a.delta.md" + before="$(snapshot "$work")" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 1 ] + grep -qx "FR-02: base text differs from a.md" <<< "$output" + [ "$(snapshot "$work")" = "$before" ] + rm -rf "$work" +} + +# Writes invite-expiry's deltas as reconciled at canonization, through a +# sed script, to $WORK/reconciled. +reconcile_invite_expiry() { + mkdir -p "$WORK/reconciled" + sed "$1" "$FEATURE/changes/invite-expiry/deltas/invitations.delta.md" > "$WORK/reconciled/invitations.delta.md" +} + +@test "helper: a deferred scenario file stays out of the feature root" { + stage_fixture + # The accounting defers the expiry scenarios: the reconciled delta drops the file. + reconcile_invite_expiry '/^### scenarios\/invitation-expiry.feature$/d' + run python3 "$DELTAS" canonize "$FEATURE" invite-expiry --date 2026-12-01 --deltas "$WORK/reconciled" + [ "$status" -eq 0 ] + grep -qx "deferred: scenarios/invitation-expiry.feature stays in changes/archive/2026-12-01-invite-expiry" <<< "$output" + [ ! -e "$FEATURE/scenarios/invitation-expiry.feature" ] + [ -f "$FEATURE/changes/archive/2026-12-01-invite-expiry/scenarios/invitation-expiry.feature" ] + [ -f "$FEATURE/stories/US-007-invitation-expiry.md" ] + rm -rf "$WORK" +} + +@test "helper: a file with shipped and deferred scenarios is split at canonization" { + stage_fixture + # Only the first scenario shipped. The reconciled entry carries the shipped part. + reconcile_invite_expiry '/^### scenarios\/invitation-expiry.feature$/a\ +\ +Text:\ +\ +~~~gherkin\ +# Traces: US-007\ +Feature: Invitation expiry\ + An unanswered invitation expires after 14 days.\ +\ + Scenario: An unanswered invitation expires after 14 days\ + Given an organizer invited me to an event 14 days ago\ + And I have not responded\ + When the invitation expires\ + Then the organizer is told that my invitation expired\ +~~~ +' + run python3 "$DELTAS" canonize "$FEATURE" invite-expiry --date 2026-12-01 --deltas "$WORK/reconciled" + [ "$status" -eq 0 ] + grep -qx " Scenario: An unanswered invitation expires after 14 days" "$FEATURE/scenarios/invitation-expiry.feature" + grep -qx " Then the organizer is told that my invitation expired" "$FEATURE/scenarios/invitation-expiry.feature" + refute_grep -q "An expired invitation can't be accepted" "$FEATURE/scenarios/invitation-expiry.feature" + # The change's file, with the deferred scenario, stays in the archive. + grep -q "An expired invitation can't be accepted" "$FEATURE/changes/archive/2026-12-01-invite-expiry/scenarios/invitation-expiry.feature" + rm -rf "$WORK" +} + +@test "helper: an added story its deltas don't list is refused" { + stage_fixture + printf '%s\n' '---' 'type: story' 'title: "US-009: Extra"' 'description: Extra.' 'status: stable' '---' '' '# US-009: Extra' \ + > "$FEATURE/changes/invite-expiry/stories/US-009-extra.md" + local before + before="$(snapshot "$WORK")" + run python3 "$DELTAS" canonize "$FEATURE" invite-expiry --date 2026-12-01 + [ "$status" -eq 1 ] + grep -qx "stories/US-009-extra.md: the change holds this file, but its deltas do not list it" <<< "$output" + [ "$(snapshot "$WORK")" = "$before" ] + rm -rf "$WORK" +} + +@test "helper: a change that revises a feature-root story its deltas don't list is refused" { + stage_fixture + cp "$FEATURE/stories/US-001-respond-to-invitation.md" "$FEATURE/changes/invite-expiry/stories/" + echo "- [ ] An extra criterion" >> "$FEATURE/changes/invite-expiry/stories/US-001-respond-to-invitation.md" + run python3 "$DELTAS" canonize "$FEATURE" invite-expiry --date 2026-12-01 + [ "$status" -eq 1 ] + grep -qx "stories/US-001-respond-to-invitation.md: the change holds this file, but its deltas do not list it" <<< "$output" + [ -d "$FEATURE/changes/invite-expiry" ] + rm -rf "$WORK" +} + +@test "helper: an outer fence longer than any inner fence keeps the whole unit" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '---' 'type: feature-spec-facet' 'title: A' 'description: A.' 'status: stable' '---' '' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + cat > "$feature/changes/c/deltas/a.delta.md" <<'DELTA' +# Delta: a.md + +## ADDED + +### FR-02 + +Section: Requirements + +Text: + +~~~~markdown +### FR-02 Invitation email + +The invitation email has this subject line: + +~~~text +You're invited: +~~~ + +The email links to the event. +~~~~ +DELTA + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] + grep -qx "You're invited: " "$feature/a.md" + [ "$(grep -cx '~~~text\|~~~' "$feature/a.md")" -eq 2 ] + grep -qx "The email links to the event." "$feature/a.md" + rm -rf "$work" +} + +@test "helper: text after a payload's closing fence is refused" { + local work feature before + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# A' '' '## Requirements' '' '### FR-01 One' '' 'One.' > "$feature/a.md" + # The outer fence is no longer than the inner one, so the payload ends early. + cat > "$feature/changes/c/deltas/a.delta.md" <<'DELTA' +# Delta: a.md + +## ADDED + +### FR-02 + +Section: Requirements + +Text: + +~~~markdown +### FR-02 Invitation email + +~~~text +You're invited: +~~~ + +The email links to the event. +~~~ +DELTA + before="$(snapshot "$work")" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 2 ] + grep -q "text after the closing fence of ADDED FR-02 'Text'" <<< "$output" + [ "$(snapshot "$work")" = "$before" ] + rm -rf "$work" +} + +@test "helper: an ambiguous insertion section is refused, and a heading path picks one" { + local work feature before + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + printf '%s\n' '# Roles' '' '## Members' '' '### Requirements' '' '#### MEM-01 Join' '' 'A member joins.' '' \ + '## Guests' '' '### Requirements' '' '#### MEM-02 Visit' '' 'A guest visits.' '' '## Glossary' '' 'Terms.' > "$feature/roles.md" + printf '%s\n' '# Delta: roles.md' '' '## ADDED' '' '### MEM-03' '' 'Section: Requirements' '' 'Text:' '' '~~~markdown' '#### MEM-03 Leave' '' 'A guest leaves.' '~~~' \ + > "$feature/changes/c/deltas/roles.delta.md" + before="$(snapshot "$work")" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 1 ] + grep -qx "MEM-03: section 'Requirements' matches 2 headings in roles.md; name it by its heading path, such as 'Members > Requirements'" <<< "$output" + [ "$(snapshot "$work")" = "$before" ] + + sed -i.bak 's/^Section: Requirements$/Section: Guests > Requirements/' "$feature/changes/c/deltas/roles.delta.md" + rm "$feature/changes/c/deltas/roles.delta.md.bak" + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] + # MEM-03 lands in the Guests section, after MEM-02 and before the glossary. + [ "$(grep -n '^#### MEM-02\|^#### MEM-03\|^## Glossary' "$feature/roles.md" | cut -d' ' -f2 | tr '\n' ' ')" = "MEM-02 MEM-03 Glossary " ] + rm -rf "$work" +} + +@test "helper: headings inside a fenced code example are not sections or unit boundaries" { + local work feature + work="$(mktemp -d)" + feature="$work/f" + mkdir -p "$feature/changes/c/deltas" + cat > "$feature/export.md" <<'DOC' +# Export + +## Requirements + +### FR-01 Export header + +An exported calendar file starts with this header: + +~~~markdown +## Requirements +# Calendar export +~~~ + +The events follow the header. + +### FR-02 Export format + +An export is a Markdown file. +DOC + cat > "$feature/changes/c/deltas/export.delta.md" <<'DELTA' +# Delta: export.md + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Export name + +An export is named for its calendar. +~~~ + +## MODIFIED + +### FR-01 + +Base text: + +~~~~markdown +### FR-01 Export header + +An exported calendar file starts with this header: + +~~~markdown +## Requirements +# Calendar export +~~~ + +The events follow the header. +~~~~ + +New text: + +~~~~markdown +### FR-01 Export header + +An exported calendar file starts with this header: + +~~~markdown +## Requirements +# Calendar export +~~~ + +The events follow the header, oldest first. +~~~~ +DELTA + run python3 "$DELTAS" base-check "$feature" "$feature/changes/c" + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + run python3 "$DELTAS" canonize "$feature" c --date 2026-12-01 + [ "$status" -eq 0 ] || { echo "$output" >&2; return 1; } + grep -qx "The events follow the header, oldest first." "$feature/export.md" + [ "$(grep -cx '## Requirements' "$feature/export.md")" -eq 2 ] + # FR-03 joins the real Requirements section, after FR-02. + [ "$(grep -o '^### FR-0[0-9]' "$feature/export.md" | tr '\n' ' ')" = "### FR-01 ### FR-02 ### FR-03 " ] + rm -rf "$work" +} + +# --- The skill uses the change model --- + +@test "skill links the feature bundle and change references and summarizes the model" { + grep -q "references/feature-bundles.md" "$SCRIPT_DIR/SKILL.md" + grep -q "references/changes-and-deltas.md" "$SCRIPT_DIR/SKILL.md" + grep -q "^## Feature Bundles and Changes" "$SCRIPT_DIR/SKILL.md" + grep -q "^### Ship Signal and Canonization" "$SCRIPT_DIR/SKILL.md" + grep -q "#21 (canonize shipped changes into the feature spec)" "$SCRIPT_DIR/SKILL.md" +} + +@test "lifecycle map ends with the ship signal and canonization" { + local map + map=$(sed -n '/^## Lifecycle Map/,/^## Stages/p' "$SCRIPT_DIR/SKILL.md") + grep -q "overlap check; promotion PR moves the change to features/{feature}/changes/{change}/" <<< "$map" + grep -q "ship signal fires" <<< "$map" + grep -q "^Canonization .*base check" <<< "$map" +} + +@test "discovery classifies the work and never creates a competing feature directory" { + local text + text=$(joined "$SCRIPT_DIR/SKILL.md") + grep -q "Classify the work as a new feature, an incremental amendment, an evolution or migration, or a fundamental change" <<< "$text" + grep -q "never a competing feature directory" <<< "$text" + grep -q 'x-amends: {feature}' <<< "$text" +} + +@test "requirements produce the change's PRD, TRD and deltas" { + grep -q 'docs/product/shaping/{feature}--{change}/deltas/{facet}.delta.md' "$SCRIPT_DIR/SKILL.md" + grep -q "^## Deltas" "$SCRIPT_DIR/references/requirements.md" + grep -q "Every PRD and TRD describes a change, including a feature's first version" "$SCRIPT_DIR/references/requirements.md" +} + +@test "no workflow file still uses the one-directory-per-feature shaping layout" { + for file in SKILL.md docs/METHODOLOGY.md references/requirements.md references/user-stories.md \ + references/bdd-scenarios.md templates/AGENTS.md.tmpl templates/README.md.tmpl \ + templates/shaping/AGENTS.md.tmpl templates/features/AGENTS.md.tmpl; do + refute_grep -q 'shaping/{feature}/' "$SCRIPT_DIR/$file" + done + refute_grep -q 'shaping/{feature}/' "$REPO_ROOT/plugins/product-development/README.md" +} + +@test "PRDs and TRDs carry no changelog; the feature log records history" { + refute_grep -q "^## Changelog" "$SCRIPT_DIR/references/requirements.md" + refute_grep -q "Every PRD and TRD ends with a changelog" "$SCRIPT_DIR/references/requirements.md" + refute_grep -q "^## Changelog" "$SCRIPT_DIR/docs/METHODOLOGY.md" + refute_grep -q "Living document with changelog" "$SCRIPT_DIR/docs/METHODOLOGY.md" "$SCRIPT_DIR/SKILL.md" + grep -q "^## Feature Log Conventions" "$SCRIPT_DIR/docs/METHODOLOGY.md" + grep -q "PRDs and TRDs have no changelog section" "$SCRIPT_DIR/references/requirements.md" + refute_grep -q "PRDs and TRDs keep a changelog" "$REPO_ROOT/plugins/product-development/README.md" +} + +@test "change records may use planning tense; TRD Dependencies and Files are change-scoped plans" { + local req="$SCRIPT_DIR/references/requirements.md" + grep -q "^## Tense" "$req" + grep -q "planning tense is correct in them" "$req" + grep -q "They are not re-tensed after the change ships" "$req" + grep -qE '^5\. \*\*Dependencies\*\* \(change-scoped plan\)' "$req" + grep -qE '^6\. \*\*Files\*\* \(change-scoped plan\)' "$req" + grep -q "Dependencies and Files are change-scoped plans" "$req" + grep -q "The feature spec holds no file lists and no add-and-remove dependency tables" "$req" +} + +@test "methodology defines the change model, both checks, both logs and the classifications" { + local m="$SCRIPT_DIR/docs/METHODOLOGY.md" + grep -q "^## The Change Model" "$m" + for term in "feature spec" "change" "spec unit" "Canonization" "feature log" "lineage log" "overlap check" "base check"; do + grep -q "\*\*$term\*\*" "$m" || { echo "methodology misses $term" >&2; return 1; } + done + grep -q "^## Classifying a Change" "$m" + grep -q "ADR 0002" "$m" + grep -q "ADR 0003" "$m" +} + +@test "stories follow their change instead of carrying a status field" { + local us="$SCRIPT_DIR/references/user-stories.md" + refute_grep -q '^\*\*Status:\*\*' "$us" + grep -q "A story has no status field of its own" "$us" + grep -q '^type: story$' "$us" +} + +@test "scaffolded docs describe feature bundles, changes and canonization" { + local work + work="$(mktemp -d)" + run "$SCRIPT_DIR/scripts/init.sh" "$work" --non-interactive --project-name "X" + [ "$status" -eq 0 ] + grep -q 'changes/{change}/' "$work/docs/product/README.md" + grep -q 'features/log.md' "$work/docs/product/README.md" + grep -q '^Canonization' "$work/docs/product/README.md" + grep -q 'Every PRD and TRD describes a change' "$work/docs/product/AGENTS.md" + grep -q 'Run the overlap check' "$work/docs/product/AGENTS.md" + grep -q 'canonize the change' "$work/docs/product/AGENTS.md" + grep -q '{feature}--{change}/' "$work/docs/product/shaping/AGENTS.md" + grep -q 'changes/{change}/' "$work/docs/product/features/AGENTS.md" + grep -q 'not left as a stub' "$work/docs/product/features/AGENTS.md" + rm -rf "$work" +} diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/README.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/README.md new file mode 100644 index 0000000..cfc7284 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/README.md @@ -0,0 +1,11 @@ +# Fixture: a feature merge + +The merge in `references/feature-bundles.md` ("Worked example: a merge"), reduced to one facet per feature. `tests/feature-evolution.bats` runs it with `tests/helpers/deltas.py`. + +| Directory | What it holds | +|-----------|---------------| +| `start/` | Two features that both have a `sharing.md` facet. The shipped change `absorb-calendar-links` in `shared-calendars` adds the calendar-links units to `shared-calendars/sharing.md` and, through the feature-qualified delta `deltas/calendar-links/sharing.delta.md`, removes them from `calendar-links/sharing.md`. `FR-01` and `FR-02` are taken in `shared-calendars`, so they arrive as `FR-03` and `FR-04`; `FR-09` is free there and keeps its ID. | +| `drafts/` | Three changes in shaping: `calendar-links--link-expiry` modifies `calendar-links` `FR-01`, which the merge removes; `shared-calendars--share-roles` modifies `shared-calendars` `FR-01`, a different unit with the same ID; and `shared-calendars--link-expiry`, a change with the same name as one in `calendar-links`, modifies `calendar-links` `FR-01` through a feature-qualified delta. | +| `expected/shared-calendars/` | The bundle after canonization. The `calendar-links` bundle is deleted because no spec units remain in it. | + +The test compares everything except `log.md`. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/calendar-links--link-expiry/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/calendar-links--link-expiry/deltas/sharing.delta.md new file mode 100644 index 0000000..a37e570 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/calendar-links--link-expiry/deltas/sharing.delta.md @@ -0,0 +1,28 @@ +--- +type: delta +title: Sharing delta for link-expiry +description: Spec units the link-expiry change modifies in calendar-links/sharing.md. +status: draft +--- + +# Delta: sharing.md + +## MODIFIED + +### FR-01 + +Base text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +New text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. The owner chooses whether the link shows event details or only busy times. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--link-expiry/deltas/calendar-links/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--link-expiry/deltas/calendar-links/sharing.delta.md new file mode 100644 index 0000000..c9e7c61 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--link-expiry/deltas/calendar-links/sharing.delta.md @@ -0,0 +1,28 @@ +--- +type: delta +title: calendar-links sharing delta for link-expiry +description: Spec units the shared-calendars link-expiry change modifies in calendar-links/sharing.md. +status: draft +--- + +# Delta: calendar-links/sharing.md + +## MODIFIED + +### FR-01 + +Base text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +New text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. A link stops working when its owner stops sharing the calendar. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--share-roles/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--share-roles/deltas/sharing.delta.md new file mode 100644 index 0000000..c3bbae2 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/drafts/shared-calendars--share-roles/deltas/sharing.delta.md @@ -0,0 +1,28 @@ +--- +type: delta +title: Sharing delta for share-roles +description: Spec units the share-roles change modifies in shared-calendars/sharing.md. +status: draft +--- + +# Delta: sharing.md + +## MODIFIED + +### FR-01 + +Base text: + +~~~markdown +### FR-01 Calendar sharing + +An owner shares a calendar with a person by email address. +~~~ + +New text: + +~~~markdown +### FR-01 Calendar sharing + +An owner shares a calendar with a person or a group by email address. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/PRD.md new file mode 100644 index 0000000..189784b --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: absorb-calendar-links" +description: Calendar links become part of shared calendars. +status: deprecated +--- + +# PRD: absorb-calendar-links + +**Feature:** shared-calendars +**Created:** 2026-12-28 + +## Problem + +Calendar links and shared calendars are two features for one concept: showing a calendar to other people. Owners look for links in the sharing settings and don't find them. + +## Goal + +An owner manages every way of sharing a calendar in one place. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | calendar-links FR-01, renumbered: FR-01 is taken in shared-calendars. | Must | +| FR-04 | calendar-links FR-02, renumbered: FR-02 is taken in shared-calendars. | Must | +| FR-09 | calendar-links FR-09, which keeps its ID: shared-calendars does not use FR-09. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/calendar-links/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/calendar-links/sharing.delta.md new file mode 100644 index 0000000..1e86f29 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/calendar-links/sharing.delta.md @@ -0,0 +1,60 @@ +--- +type: delta +title: calendar-links sharing delta for absorb-calendar-links +description: Spec units the absorb-calendar-links change removes from calendar-links/sharing.md. +status: deprecated +--- + +# Delta: calendar-links/sharing.md + +## REMOVED + +### FR-01 + +Base text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-02 + +Base text: + +~~~markdown +### FR-02 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ + +### FR-09 + +Base text: + +~~~markdown +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. +~~~ + +### scenarios/calendar-links.feature + +Base text: + +~~~gherkin +# Traces: US-004 +Feature: Calendar links + A calendar link shows a calendar to anyone who opens it. + + Scenario: Opening a calendar link shows the calendar + Given an owner has created a link to their calendar + When I open the link + Then I see the calendar's events + + Scenario: A revoked link stops working + Given an owner has revoked a link to their calendar + When I open the link + Then I do not see the calendar's events +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/sharing.delta.md new file mode 100644 index 0000000..78f0bc1 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/changes/archive/2027-01-20-absorb-calendar-links/deltas/sharing.delta.md @@ -0,0 +1,48 @@ +--- +type: delta +title: Sharing delta for absorb-calendar-links +description: Spec units the absorb-calendar-links change adds to sharing.md, moved from calendar-links. +status: deprecated +--- + +# Delta: sharing.md + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Section: Requirements + +Text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ + +### FR-09 + +Section: Requirements + +Text: + +~~~markdown +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. +~~~ + +### scenarios/calendar-links.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/log.md new file mode 100644 index 0000000..72fc038 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/log.md @@ -0,0 +1,20 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-01-06 Ratified: absorb-calendar-links + +- Change: absorb-calendar-links +- Reason: A calendar link is one way to share a calendar; two features split one concept. +- Links: Promotion PR #131 + +## 2027-01-15 Shipped: absorb-calendar-links + +- Change: absorb-calendar-links +- Ship signal: release 4.0 reached all users. +- Evidence: [release 4.0](https://example.com/releases/4.0) + +## 2027-01-20 Canonized: absorb-calendar-links + +- Change: [absorb-calendar-links](changes/archive/2027-01-20-absorb-calendar-links/) +- Outcome: Added FR-03, FR-04 and FR-09 and `scenarios/calendar-links.feature`, moved from calendar-links. Deleted the calendar-links bundle. Nothing deferred. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/scenarios/calendar-links.feature b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/scenarios/calendar-links.feature new file mode 100644 index 0000000..6aee0ef --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/scenarios/calendar-links.feature @@ -0,0 +1,13 @@ +# Traces: US-004 +Feature: Calendar links + A calendar link shows a calendar to anyone who opens it. + + Scenario: Opening a calendar link shows the calendar + Given an owner has created a link to their calendar + When I open the link + Then I see the calendar's events + + Scenario: A revoked link stops working + Given an owner has revoked a link to their calendar + When I open the link + Then I do not see the calendar's events diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..3fbadfb --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,26 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar and decide what each person can do with it. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. Its owner decides who can see it and who can change it. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How a calendar's owner shares it and sets what others can do | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/sharing.md new file mode 100644 index 0000000..04dea38 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/expected/shared-calendars/sharing.md @@ -0,0 +1,33 @@ +--- +type: feature-spec-facet +title: Sharing +description: How a calendar's owner shares it and sets what others can do. +status: stable +tags: [workflow, permissions] +--- + +# Sharing + +A calendar's owner shares the calendar with people and sets what each of them can do. + +## Requirements + +### FR-01 Calendar sharing + +An owner shares a calendar with a person by email address. + +### FR-02 Share permissions + +An owner sets each person's access to view only, or to view and edit. + +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. + +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. + +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/calendar-links-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/calendar-links-spec.md new file mode 100644 index 0000000..4ca9fc7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/calendar-links-spec.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-overview +title: Calendar links +description: Anyone with a calendar's link can see the calendar. +status: stable +tags: [] +--- + +# Calendar links + +A calendar link shows a calendar to anyone who opens it, without an account. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How an owner creates and revokes calendar links | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/log.md new file mode 100644 index 0000000..8db15e0 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/log.md @@ -0,0 +1,8 @@ +# Feature log: calendar-links + +Dated history of the calendar-links feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2026-06-02 Canonized: link-sharing + +- Change: [link-sharing](changes/archive/2026-06-02-link-sharing/) +- Outcome: Added FR-01, FR-02 and FR-09 and `scenarios/calendar-links.feature`. Nothing deferred. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/scenarios/calendar-links.feature b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/scenarios/calendar-links.feature new file mode 100644 index 0000000..6aee0ef --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/scenarios/calendar-links.feature @@ -0,0 +1,13 @@ +# Traces: US-004 +Feature: Calendar links + A calendar link shows a calendar to anyone who opens it. + + Scenario: Opening a calendar link shows the calendar + Given an owner has created a link to their calendar + When I open the link + Then I see the calendar's events + + Scenario: A revoked link stops working + Given an owner has revoked a link to their calendar + When I open the link + Then I do not see the calendar's events diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/sharing.md new file mode 100644 index 0000000..23f7f98 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/calendar-links/sharing.md @@ -0,0 +1,25 @@ +--- +type: feature-spec-facet +title: Sharing +description: How an owner creates and revokes calendar links. +status: stable +tags: [workflow] +--- + +# Sharing + +An owner creates links to a calendar and revokes them. + +## Requirements + +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. + +### FR-02 Link revocation + +An owner revokes a calendar link, and the link stops working at once. + +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/PRD.md new file mode 100644 index 0000000..df08ccb --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: absorb-calendar-links" +description: Calendar links become part of shared calendars. +status: stable +--- + +# PRD: absorb-calendar-links + +**Feature:** shared-calendars +**Created:** 2026-12-28 + +## Problem + +Calendar links and shared calendars are two features for one concept: showing a calendar to other people. Owners look for links in the sharing settings and don't find them. + +## Goal + +An owner manages every way of sharing a calendar in one place. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | calendar-links FR-01, renumbered: FR-01 is taken in shared-calendars. | Must | +| FR-04 | calendar-links FR-02, renumbered: FR-02 is taken in shared-calendars. | Must | +| FR-09 | calendar-links FR-09, which keeps its ID: shared-calendars does not use FR-09. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/calendar-links/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/calendar-links/sharing.delta.md new file mode 100644 index 0000000..df970d7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/calendar-links/sharing.delta.md @@ -0,0 +1,60 @@ +--- +type: delta +title: calendar-links sharing delta for absorb-calendar-links +description: Spec units the absorb-calendar-links change removes from calendar-links/sharing.md. +status: stable +--- + +# Delta: calendar-links/sharing.md + +## REMOVED + +### FR-01 + +Base text: + +~~~markdown +### FR-01 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-02 + +Base text: + +~~~markdown +### FR-02 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ + +### FR-09 + +Base text: + +~~~markdown +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. +~~~ + +### scenarios/calendar-links.feature + +Base text: + +~~~gherkin +# Traces: US-004 +Feature: Calendar links + A calendar link shows a calendar to anyone who opens it. + + Scenario: Opening a calendar link shows the calendar + Given an owner has created a link to their calendar + When I open the link + Then I see the calendar's events + + Scenario: A revoked link stops working + Given an owner has revoked a link to their calendar + When I open the link + Then I do not see the calendar's events +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/sharing.delta.md new file mode 100644 index 0000000..eb6e8c7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/deltas/sharing.delta.md @@ -0,0 +1,48 @@ +--- +type: delta +title: Sharing delta for absorb-calendar-links +description: Spec units the absorb-calendar-links change adds to sharing.md, moved from calendar-links. +status: stable +--- + +# Delta: sharing.md + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Section: Requirements + +Text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ + +### FR-09 + +Section: Requirements + +Text: + +~~~markdown +### FR-09 Link expiry + +A calendar link stops working 30 days after it was created unless its owner renews it. +~~~ + +### scenarios/calendar-links.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/scenarios/calendar-links.feature b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/scenarios/calendar-links.feature new file mode 100644 index 0000000..6aee0ef --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/changes/absorb-calendar-links/scenarios/calendar-links.feature @@ -0,0 +1,13 @@ +# Traces: US-004 +Feature: Calendar links + A calendar link shows a calendar to anyone who opens it. + + Scenario: Opening a calendar link shows the calendar + Given an owner has created a link to their calendar + When I open the link + Then I see the calendar's events + + Scenario: A revoked link stops working + Given an owner has revoked a link to their calendar + When I open the link + Then I do not see the calendar's events diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/log.md new file mode 100644 index 0000000..9148ceb --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/log.md @@ -0,0 +1,15 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-01-06 Ratified: absorb-calendar-links + +- Change: absorb-calendar-links +- Reason: A calendar link is one way to share a calendar; two features split one concept. +- Links: Promotion PR #131 + +## 2027-01-15 Shipped: absorb-calendar-links + +- Change: absorb-calendar-links +- Ship signal: release 4.0 reached all users. +- Evidence: [release 4.0](https://example.com/releases/4.0) diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..3fbadfb --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,26 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar and decide what each person can do with it. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. Its owner decides who can see it and who can change it. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How a calendar's owner shares it and sets what others can do | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/sharing.md new file mode 100644 index 0000000..a6989b2 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-merge/start/shared-calendars/sharing.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-facet +title: Sharing +description: How a calendar's owner shares it and sets what others can do. +status: stable +tags: [workflow, permissions] +--- + +# Sharing + +A calendar's owner shares the calendar with people and sets what each of them can do. + +## Requirements + +### FR-01 Calendar sharing + +An owner shares a calendar with a person by email address. + +### FR-02 Share permissions + +An owner sets each person's access to view only, or to view and edit. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/README.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/README.md new file mode 100644 index 0000000..e5f534b --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/README.md @@ -0,0 +1,11 @@ +# Fixture: a feature split + +A split that moves calendar links out of `shared-calendars` into a new feature, `calendar-links`. `tests/feature-evolution.bats` runs it with `tests/helpers/deltas.py`. + +| Directory | What it holds | +|-----------|---------------| +| `start/shared-calendars/` | The source feature after the split's promotion PR merged and the ship signal fired. It owns the change `split-calendar-links`, whose deltas remove `FR-03` and `FR-04` from `sharing.md` and, through feature-qualified deltas under `deltas/calendar-links/`, write the new feature's `sharing.md` facet and complete its overview. Its log records the split. | +| `start/calendar-links/` | The receiving bundle as the promotion PR initialized it, like a first version: a metadata-only overview and a log whose Ratified entry names the owning change. | +| `expected/` | Both bundles after canonization. `FR-03` and `FR-04` keep their IDs, which `calendar-links` has not used. | + +The test compares everything except `log.md`. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/calendar-links-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/calendar-links-spec.md new file mode 100644 index 0000000..b405ecf --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/calendar-links-spec.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +A calendar link shows a calendar to anyone who opens it, without an account. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How an owner creates and revokes calendar links | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. The split's change is archived with the feature it left: [shared-calendars/split-calendar-links](../shared-calendars/changes/archive/2027-03-10-split-calendar-links/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/log.md new file mode 100644 index 0000000..ff0ab2b --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/log.md @@ -0,0 +1,14 @@ +# Feature log: calendar-links + +Dated history of the calendar-links feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-03-01 Ratified: shared-calendars/split-calendar-links + +- Change: split-calendar-links, owned by shared-calendars. It splits calendar links out of shared-calendars into this feature. +- Reason: Calendar links serve people without an account, a different audience from sharing. +- Links: Promotion PR #142 + +## 2027-03-10 Canonized: shared-calendars/split-calendar-links + +- Change: [split-calendar-links](../shared-calendars/changes/archive/2027-03-10-split-calendar-links/) +- Outcome: Wrote the overview and the sharing facet spec. Added FR-03 and FR-04, moved from shared-calendars with their IDs. Nothing deferred. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/sharing.md new file mode 100644 index 0000000..9f8610c --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/calendar-links/sharing.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-facet +title: Sharing +description: How an owner creates and revokes calendar links. +status: stable +tags: [workflow] +--- + +# Sharing + +An owner creates links to a calendar and revokes them. + +## Requirements + +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. + +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/PRD.md new file mode 100644 index 0000000..f16f888 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/PRD.md @@ -0,0 +1,26 @@ +--- +type: prd +title: "PRD: split-calendar-links" +description: Calendar links become a feature of their own. +status: deprecated +--- + +# PRD: split-calendar-links + +**Feature:** shared-calendars +**Created:** 2027-02-15 + +## Problem + +Calendar links serve people without an account, while sharing serves people the owner names. One feature holds two audiences, and changes to one keep reaching the other. + +## Goal + +Calendar links have their own feature, `calendar-links`, with its own spec and history. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | Moves to calendar-links and keeps its ID, which calendar-links has not used. | Must | +| FR-04 | Moves to calendar-links and keeps its ID, which calendar-links has not used. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md new file mode 100644 index 0000000..be877a0 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md @@ -0,0 +1,54 @@ +--- +type: delta +title: Overview delta for split-calendar-links +description: The calendar-links overview as the split-calendar-links change completes it. +status: deprecated +--- + +# Delta: calendar-links/calendar-links-spec.md + +## DOCUMENT + +Base text: + +~~~markdown +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. +~~~ + +New text: + +~~~markdown +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +A calendar link shows a calendar to anyone who opens it, without an account. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How an owner creates and revokes calendar links | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. The split's change is archived with the feature it left: [shared-calendars/split-calendar-links](../shared-calendars/changes/archive/2027-03-10-split-calendar-links/). +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/sharing.delta.md new file mode 100644 index 0000000..82cc28a --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/calendar-links/sharing.delta.md @@ -0,0 +1,52 @@ +--- +type: delta +title: calendar-links sharing delta for split-calendar-links +description: The calendar-links sharing facet the split-calendar-links change writes, and the units it moves there. +status: deprecated +--- + +# Delta: calendar-links/sharing.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Sharing +description: How an owner creates and revokes calendar links. +status: stable +tags: [workflow] +--- + +# Sharing + +An owner creates links to a calendar and revokes them. +~~~ + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Section: Requirements + +Text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/sharing.delta.md new file mode 100644 index 0000000..bb7d48f --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/changes/archive/2027-03-10-split-calendar-links/deltas/sharing.delta.md @@ -0,0 +1,30 @@ +--- +type: delta +title: Sharing delta for split-calendar-links +description: Spec units the split-calendar-links change moves out of sharing.md. +status: deprecated +--- + +# Delta: sharing.md + +## REMOVED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Base text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/log.md new file mode 100644 index 0000000..be1193e --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/log.md @@ -0,0 +1,20 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-03-01 Ratified: split-calendar-links + +- Change: split-calendar-links +- Reason: Calendar links serve people without an account, a different audience from sharing; the split moves FR-03 and FR-04 to a new feature, calendar-links. +- Links: Promotion PR #142 + +## 2027-03-08 Shipped: split-calendar-links + +- Change: split-calendar-links +- Ship signal: release 4.2 reached all users, with calendar links on their own settings page. +- Evidence: [release 4.2](https://example.com/releases/4.2) + +## 2027-03-10 Canonized: split-calendar-links + +- Change: [split-calendar-links](changes/archive/2027-03-10-split-calendar-links/) +- Outcome: Removed FR-03 and FR-04, moved to calendar-links with their IDs. Wrote the calendar-links sharing facet and completed its overview. Nothing deferred. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..b65d0a9 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar and decide what each person can do with it. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. Its owner decides who can see it and who can change it. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How a calendar's owner shares it and sets what others can do | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/sharing.md new file mode 100644 index 0000000..a6989b2 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/expected/shared-calendars/sharing.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-facet +title: Sharing +description: How a calendar's owner shares it and sets what others can do. +status: stable +tags: [workflow, permissions] +--- + +# Sharing + +A calendar's owner shares the calendar with people and sets what each of them can do. + +## Requirements + +### FR-01 Calendar sharing + +An owner shares a calendar with a person by email address. + +### FR-02 Share permissions + +An owner sets each person's access to view only, or to view and edit. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/calendar-links-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/calendar-links-spec.md new file mode 100644 index 0000000..7508440 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/calendar-links-spec.md @@ -0,0 +1,13 @@ +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/log.md new file mode 100644 index 0000000..7446bfa --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/calendar-links/log.md @@ -0,0 +1,9 @@ +# Feature log: calendar-links + +Dated history of the calendar-links feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-03-01 Ratified: shared-calendars/split-calendar-links + +- Change: split-calendar-links, owned by shared-calendars. It splits calendar links out of shared-calendars into this feature. +- Reason: Calendar links serve people without an account, a different audience from sharing. +- Links: Promotion PR #142 diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/PRD.md new file mode 100644 index 0000000..21a3dc8 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/PRD.md @@ -0,0 +1,26 @@ +--- +type: prd +title: "PRD: split-calendar-links" +description: Calendar links become a feature of their own. +status: stable +--- + +# PRD: split-calendar-links + +**Feature:** shared-calendars +**Created:** 2027-02-15 + +## Problem + +Calendar links serve people without an account, while sharing serves people the owner names. One feature holds two audiences, and changes to one keep reaching the other. + +## Goal + +Calendar links have their own feature, `calendar-links`, with its own spec and history. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | Moves to calendar-links and keeps its ID, which calendar-links has not used. | Must | +| FR-04 | Moves to calendar-links and keeps its ID, which calendar-links has not used. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md new file mode 100644 index 0000000..82da7ea --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/calendar-links-spec.delta.md @@ -0,0 +1,54 @@ +--- +type: delta +title: Overview delta for split-calendar-links +description: The calendar-links overview as the split-calendar-links change completes it. +status: stable +--- + +# Delta: calendar-links/calendar-links-spec.md + +## DOCUMENT + +Base text: + +~~~markdown +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. +~~~ + +New text: + +~~~markdown +--- +type: feature-spec-overview +title: Calendar links +description: Calendar links and the people who open them. +status: stable +tags: [] +--- + +# Calendar links + +A calendar link shows a calendar to anyone who opens it, without an account. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How an owner creates and revokes calendar links | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons, starting with the split that created it. The split's change is archived with the feature it left: [shared-calendars/split-calendar-links](../shared-calendars/changes/archive/2027-03-10-split-calendar-links/). +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/sharing.delta.md new file mode 100644 index 0000000..8d31876 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/calendar-links/sharing.delta.md @@ -0,0 +1,52 @@ +--- +type: delta +title: calendar-links sharing delta for split-calendar-links +description: The calendar-links sharing facet the split-calendar-links change writes, and the units it moves there. +status: stable +--- + +# Delta: calendar-links/sharing.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Sharing +description: How an owner creates and revokes calendar links. +status: stable +tags: [workflow] +--- + +# Sharing + +An owner creates links to a calendar and revokes them. +~~~ + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Section: Requirements + +Text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/sharing.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/sharing.delta.md new file mode 100644 index 0000000..33c0fab --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/changes/split-calendar-links/deltas/sharing.delta.md @@ -0,0 +1,30 @@ +--- +type: delta +title: Sharing delta for split-calendar-links +description: Spec units the split-calendar-links change moves out of sharing.md. +status: stable +--- + +# Delta: sharing.md + +## REMOVED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. +~~~ + +### FR-04 + +Base text: + +~~~markdown +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/log.md new file mode 100644 index 0000000..5b2321d --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/log.md @@ -0,0 +1,15 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2027-03-01 Ratified: split-calendar-links + +- Change: split-calendar-links +- Reason: Calendar links serve people without an account, a different audience from sharing; the split moves FR-03 and FR-04 to a new feature, calendar-links. +- Links: Promotion PR #142 + +## 2027-03-08 Shipped: split-calendar-links + +- Change: split-calendar-links +- Ship signal: release 4.2 reached all users, with calendar links on their own settings page. +- Evidence: [release 4.2](https://example.com/releases/4.2) diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..b65d0a9 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar and decide what each person can do with it. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. Its owner decides who can see it and who can change it. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Sharing](sharing.md) | How a calendar's owner shares it and sets what others can do | FR | + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/sharing.md b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/sharing.md new file mode 100644 index 0000000..a062e06 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/feature-split/start/shared-calendars/sharing.md @@ -0,0 +1,29 @@ +--- +type: feature-spec-facet +title: Sharing +description: How a calendar's owner shares it and sets what others can do. +status: stable +tags: [workflow, permissions] +--- + +# Sharing + +A calendar's owner shares the calendar with people and sets what each of them can do. + +## Requirements + +### FR-01 Calendar sharing + +An owner shares a calendar with a person by email address. + +### FR-02 Share permissions + +An owner sets each person's access to view only, or to view and edit. + +### FR-03 Calendar links + +An owner creates a link that shows the calendar to anyone who opens it. + +### FR-04 Link revocation + +An owner revokes a calendar link, and the link stops working at once. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/README.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/README.md new file mode 100644 index 0000000..0acb849 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/README.md @@ -0,0 +1,11 @@ +# Fixture: a feature's first version + +A feature bundle from the ratification of its first change, `event-invitations`, to its first canonization. `tests/feature-evolution.bats` runs it with `tests/helpers/deltas.py`. + +| Directory | What it holds | +|-----------|---------------| +| `start/shared-calendars/` | The bundle after ratification and the ship signal: a metadata-only overview (front matter, title and History, with no behavior claims and no links to facets that don't exist yet), the log and the change. | +| `expected/shared-calendars/` | The bundle after canonization. The overview delta's `DOCUMENT` entry completes the overview; each facet delta's `DOCUMENT` entry writes the invitations or reminders facet spec's front matter, title and summary, and its added units follow. | +| `reconciled-partial/deltas/` | The deltas as reconciled when the reminders shipped later than the rest: the reminders delta is left out, and the overview's `New text:` drops the reminders sentence and the Reminders row, with the maintainer's approval. | + +The test compares everything except `log.md`. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/PRD.md new file mode 100644 index 0000000..1c9fbf0 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: event-invitations" +description: The first version of shared calendars: invitations to events and responses to them. +status: deprecated +--- + +# PRD: event-invitations + +**Feature:** shared-calendars +**Created:** 2026-08-03 + +## Problem + +A group that plans events together has no shared place to invite people and see who is coming. + +## Goal + +An organizer invites people to an event and sees each response. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-01 | An invitee will be able to accept or decline an invitation. | Must | +| FR-02 | Invitations will be delivered by email and in the app. | Must | +| FR-03 | Invitees who accepted will be reminded an hour before the event. | Should | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/invitations.delta.md new file mode 100644 index 0000000..47fb390 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/invitations.delta.md @@ -0,0 +1,56 @@ +--- +type: delta +title: Invitations delta for event-invitations +description: The invitations facet spec the event-invitations change writes, and its units. +status: deprecated +--- + +# Delta: invitations.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. +~~~ + +## ADDED + +### FR-01 + +Section: Requirements + +Text: + +~~~markdown +### FR-01 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-02 + +Section: Requirements + +Text: + +~~~markdown +### FR-02 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. +~~~ + +### stories/US-001-respond-to-invitation.md + +### scenarios/invitation-responses.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/reminders.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/reminders.delta.md new file mode 100644 index 0000000..54b01b9 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/reminders.delta.md @@ -0,0 +1,42 @@ +--- +type: delta +title: Reminders delta for event-invitations +description: The reminders facet spec the event-invitations change writes, and its units. +status: deprecated +--- + +# Delta: reminders.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Reminders +description: How invitees who accepted an invitation are reminded of the event. +status: stable +tags: [notification] +--- + +# Reminders + +An invitee who accepted an invitation is reminded before the event starts. +~~~ + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Event reminders + +An invitee who accepted an invitation is reminded one hour before the event starts. +~~~ + +### scenarios/event-reminders.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/shared-calendars-spec.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/shared-calendars-spec.delta.md new file mode 100644 index 0000000..59346a5 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/changes/archive/2026-09-14-event-invitations/deltas/shared-calendars-spec.delta.md @@ -0,0 +1,60 @@ +--- +type: delta +title: Overview delta for event-invitations +description: The shared-calendars overview as the event-invitations change completes it. +status: deprecated +--- + +# Delta: shared-calendars-spec.md + +## DOCUMENT + +Base text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ + +New text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, each invitee's response decides whether the event joins their calendar, and invitees who accept are reminded before it starts. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](invitations.md) | How an organizer invites people and how invitees respond | FR | +| [Reminders](reminders.md) | How invitees who accepted are reminded of the event | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/invitations.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/invitations.md new file mode 100644 index 0000000..f70b7b4 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/invitations.md @@ -0,0 +1,21 @@ +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. + +## Requirements + +### FR-01 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. + +### FR-02 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/log.md new file mode 100644 index 0000000..169021f --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/log.md @@ -0,0 +1,20 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2026-08-17 Ratified: event-invitations + +- Change: event-invitations +- Reason: Groups planning events together had no shared place to invite people and track responses. +- Links: Promotion PR #87 + +## 2026-09-08 Shipped: event-invitations + +- Change: event-invitations +- Ship signal: release 3.0 reached all users. +- Evidence: [release 3.0](https://example.com/releases/3.0) + +## 2026-09-14 Canonized: event-invitations + +- Change: [event-invitations](changes/archive/2026-09-14-event-invitations/) +- Outcome: Wrote the overview and the invitations and reminders facet specs. Added FR-01, FR-02, FR-03, `stories/US-001-respond-to-invitation.md`, `scenarios/invitation-responses.feature` and `scenarios/event-reminders.feature`. Nothing deferred. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/reminders.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/reminders.md new file mode 100644 index 0000000..1735e12 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/reminders.md @@ -0,0 +1,17 @@ +--- +type: feature-spec-facet +title: Reminders +description: How invitees who accepted an invitation are reminded of the event. +status: stable +tags: [notification] +--- + +# Reminders + +An invitee who accepted an invitation is reminded before the event starts. + +## Requirements + +### FR-03 Event reminders + +An invitee who accepted an invitation is reminded one hour before the event starts. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/event-reminders.feature b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/event-reminders.feature new file mode 100644 index 0000000..2e41dcc --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/event-reminders.feature @@ -0,0 +1,8 @@ +# Traces: US-001 +Feature: Event reminders + An invitee who accepted an invitation is reminded before the event. + + Scenario: An accepted invitation brings a reminder an hour before the event + Given I accepted an invitation to an event + When the event is one hour away + Then I receive a reminder diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/invitation-responses.feature b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/invitation-responses.feature new file mode 100644 index 0000000..8dd97af --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/scenarios/invitation-responses.feature @@ -0,0 +1,8 @@ +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..ece3f55 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,27 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, each invitee's response decides whether the event joins their calendar, and invitees who accept are reminded before it starts. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](invitations.md) | How an organizer invites people and how invitees respond | FR | +| [Reminders](reminders.md) | How invitees who accepted are reminded of the event | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/stories/US-001-respond-to-invitation.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/stories/US-001-respond-to-invitation.md new file mode 100644 index 0000000..0f61004 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/expected/shared-calendars/stories/US-001-respond-to-invitation.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-001: Respond to an invitation" +description: An invitee accepts or declines an invitation to an event. +status: stable +--- + +# US-001: Respond to an invitation + +**PRD Requirement:** FR-01, FR-02 + +## Story + +As an invitee, +I want to accept or decline an invitation, +so that the organizer knows whether I am coming. + +## Acceptance Criteria + +- [ ] An invitation reaches me by email and in the app +- [ ] Accepting adds the event to my calendar +- [ ] Declining leaves my calendar unchanged diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/invitations.delta.md new file mode 100644 index 0000000..873cc73 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/invitations.delta.md @@ -0,0 +1,56 @@ +--- +type: delta +title: Invitations delta for event-invitations +description: The invitations facet spec the event-invitations change writes, and its units. +status: stable +--- + +# Delta: invitations.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. +~~~ + +## ADDED + +### FR-01 + +Section: Requirements + +Text: + +~~~markdown +### FR-01 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-02 + +Section: Requirements + +Text: + +~~~markdown +### FR-02 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. +~~~ + +### stories/US-001-respond-to-invitation.md + +### scenarios/invitation-responses.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/shared-calendars-spec.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/shared-calendars-spec.delta.md new file mode 100644 index 0000000..473e837 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/reconciled-partial/deltas/shared-calendars-spec.delta.md @@ -0,0 +1,59 @@ +--- +type: delta +title: Overview delta for event-invitations +description: The shared-calendars overview as the event-invitations change completes it. +status: stable +--- + +# Delta: shared-calendars-spec.md + +## DOCUMENT + +Base text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ + +New text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, and each invitee's response decides whether the event joins their calendar. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](./invitations.md) | How an organizer invites people and how invitees respond | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/PRD.md new file mode 100644 index 0000000..741743a --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: event-invitations" +description: The first version of shared calendars: invitations to events and responses to them. +status: stable +--- + +# PRD: event-invitations + +**Feature:** shared-calendars +**Created:** 2026-08-03 + +## Problem + +A group that plans events together has no shared place to invite people and see who is coming. + +## Goal + +An organizer invites people to an event and sees each response. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-01 | An invitee will be able to accept or decline an invitation. | Must | +| FR-02 | Invitations will be delivered by email and in the app. | Must | +| FR-03 | Invitees who accepted will be reminded an hour before the event. | Should | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/invitations.delta.md new file mode 100644 index 0000000..873cc73 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/invitations.delta.md @@ -0,0 +1,56 @@ +--- +type: delta +title: Invitations delta for event-invitations +description: The invitations facet spec the event-invitations change writes, and its units. +status: stable +--- + +# Delta: invitations.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. +~~~ + +## ADDED + +### FR-01 + +Section: Requirements + +Text: + +~~~markdown +### FR-01 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-02 + +Section: Requirements + +Text: + +~~~markdown +### FR-02 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. +~~~ + +### stories/US-001-respond-to-invitation.md + +### scenarios/invitation-responses.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/reminders.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/reminders.delta.md new file mode 100644 index 0000000..719cfa0 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/reminders.delta.md @@ -0,0 +1,42 @@ +--- +type: delta +title: Reminders delta for event-invitations +description: The reminders facet spec the event-invitations change writes, and its units. +status: stable +--- + +# Delta: reminders.md + +## DOCUMENT + +Text: + +~~~markdown +--- +type: feature-spec-facet +title: Reminders +description: How invitees who accepted an invitation are reminded of the event. +status: stable +tags: [notification] +--- + +# Reminders + +An invitee who accepted an invitation is reminded before the event starts. +~~~ + +## ADDED + +### FR-03 + +Section: Requirements + +Text: + +~~~markdown +### FR-03 Event reminders + +An invitee who accepted an invitation is reminded one hour before the event starts. +~~~ + +### scenarios/event-reminders.feature diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/shared-calendars-spec.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/shared-calendars-spec.delta.md new file mode 100644 index 0000000..32bb15c --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/deltas/shared-calendars-spec.delta.md @@ -0,0 +1,60 @@ +--- +type: delta +title: Overview delta for event-invitations +description: The shared-calendars overview as the event-invitations change completes it. +status: stable +--- + +# Delta: shared-calendars-spec.md + +## DOCUMENT + +Base text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ + +New text: + +~~~markdown +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, each invitee's response decides whether the event joins their calendar, and invitees who accept are reminded before it starts. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](invitations.md) | How an organizer invites people and how invitees respond | FR | +| [Reminders](reminders.md) | How invitees who accepted are reminded of the event | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/event-reminders.feature b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/event-reminders.feature new file mode 100644 index 0000000..2e41dcc --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/event-reminders.feature @@ -0,0 +1,8 @@ +# Traces: US-001 +Feature: Event reminders + An invitee who accepted an invitation is reminded before the event. + + Scenario: An accepted invitation brings a reminder an hour before the event + Given I accepted an invitation to an event + When the event is one hour away + Then I receive a reminder diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/invitation-responses.feature b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/invitation-responses.feature new file mode 100644 index 0000000..8dd97af --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/scenarios/invitation-responses.feature @@ -0,0 +1,8 @@ +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/stories/US-001-respond-to-invitation.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/stories/US-001-respond-to-invitation.md new file mode 100644 index 0000000..0f61004 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/changes/event-invitations/stories/US-001-respond-to-invitation.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-001: Respond to an invitation" +description: An invitee accepts or declines an invitation to an event. +status: stable +--- + +# US-001: Respond to an invitation + +**PRD Requirement:** FR-01, FR-02 + +## Story + +As an invitee, +I want to accept or decline an invitation, +so that the organizer knows whether I am coming. + +## Acceptance Criteria + +- [ ] An invitation reaches me by email and in the app +- [ ] Accepting adds the event to my calendar +- [ ] Declining leaves my calendar unchanged diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/log.md new file mode 100644 index 0000000..402d478 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/log.md @@ -0,0 +1,15 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2026-08-17 Ratified: event-invitations + +- Change: event-invitations +- Reason: Groups planning events together had no shared place to invite people and track responses. +- Links: Promotion PR #87 + +## 2026-09-08 Shipped: event-invitations + +- Change: event-invitations +- Ship signal: release 3.0 reached all users. +- Evidence: [release 3.0](https://example.com/releases/3.0) diff --git a/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..81869b7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/first-version/start/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,13 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: Shared calendars and invitations to their events. +status: stable +tags: [] +--- + +# Shared calendars + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/README.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/README.md new file mode 100644 index 0000000..c6f8e21 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/README.md @@ -0,0 +1,12 @@ +# Fixture: two canonizations against one feature + +The worked example in `references/changes-and-deltas.md` ("Worked example: two parallel changes"), as files. `tests/feature-evolution.bats` runs it with `tests/helpers/deltas.py`. + +| Directory | What it holds | +|-----------|---------------| +| `start/shared-calendars/` | The feature bundle with two ratified, shipped changes, `invite-expiry` and `decline-with-note`. Both modify `FR-03` against the same base text. Each change holds its own stories and scenarios. | +| `drafts/shared-calendars--decline-with-note/` | `decline-with-note`'s delta as first drafted, in its shaping directory, adding `FR-12` like `invite-expiry` does. The overlap check flags it; the ratified delta uses `FR-13`. | +| `rebased/decline-with-note/` | `decline-with-note`'s delta rebased onto `FR-03` as `invite-expiry` left it, as confirmed by the maintainer at canonization. | +| `expected/shared-calendars/` | The bundle after both canonizations. `FR-03` keeps both changes' edits, the stories and scenarios sit at the feature root, and the archive holds both changes with their deltas as ratified. | + +The test compares everything except `log.md`, whose entries the canonization workflow writes. A separate test checks that each log runs in date order and that the expected log only appends to the start log. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/drafts/shared-calendars--decline-with-note/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/drafts/shared-calendars--decline-with-note/deltas/invitations.delta.md new file mode 100644 index 0000000..72402f3 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/drafts/shared-calendars--decline-with-note/deltas/invitations.delta.md @@ -0,0 +1,84 @@ +--- +type: delta +title: Invitations delta for decline-with-note +description: Spec units the decline-with-note change adds and modifies in invitations.md. +status: draft +--- + +# Delta: invitations.md + +## ADDED + +### FR-12 + +Section: Requirements + +Text: + +~~~markdown +### FR-12 Decline notes + +Only the organizer sees a decline note. +~~~ + +### stories/US-008-decline-with-note.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-05 + +Base text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response. +~~~ + +New text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response, with any decline note. +~~~ + +### scenarios/invitation-responses.feature + +Base text: + +~~~gherkin +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/PRD.md new file mode 100644 index 0000000..6b9c9c9 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/PRD.md @@ -0,0 +1,26 @@ +--- +type: prd +title: "PRD: invite-expiry" +description: Invitations expire when an invitee does not respond within 14 days. +status: deprecated +--- + +# PRD: invite-expiry + +**Feature:** shared-calendars +**Created:** 2026-10-20 + +## Problem + +Invitees leave invitations unanswered for weeks. Organizers can't tell who is coming, so they can't plan. + +## Goal + +An organizer knows within 14 days whether each invitee is coming. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-12 | An invitation with no response 14 days after it was sent will expire, and the organizer will be told. | Must | +| FR-03 | An expired invitation can no longer be accepted. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/TRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/TRD.md new file mode 100644 index 0000000..6aacc9c --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/TRD.md @@ -0,0 +1,25 @@ +--- +type: trd +title: "TRD: invite-expiry" +description: How invitation expiry will be built. +status: deprecated +--- + +# TRD: invite-expiry + +**PRD:** [PRD.md](PRD.md) + +## Architecture Overview + +A daily job will mark invitations older than 14 days with no response as expired and queue a notice to the organizer. + +## Dependencies + +This change adds no packages. + +## Files + +| Action | Path | Purpose | +|--------|------|---------| +| Create | `src/invitations/expire-invitations.ts` | Daily expiry job | +| Modify | `src/invitations/respond.ts` | Reject responses to expired invitations | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/deltas/invitations.delta.md new file mode 100644 index 0000000..fd8a803 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-01-invite-expiry/deltas/invitations.delta.md @@ -0,0 +1,46 @@ +--- +type: delta +title: Invitations delta for invite-expiry +description: Spec units the invite-expiry change adds and modifies in invitations.md. +status: deprecated +--- + +# Delta: invitations.md + +## ADDED + +### FR-12 + +Section: Requirements + +Text: + +~~~markdown +### FR-12 Invitation expiry + +An invitation that has no response 14 days after it was sent expires. The organizer is told when an invitation expires. +~~~ + +### scenarios/invitation-expiry.feature + +### stories/US-007-invitation-expiry.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/PRD.md new file mode 100644 index 0000000..2bd55bf --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: decline-with-note" +description: An invitee can add a note when declining, and only the organizer sees it. +status: deprecated +--- + +# PRD: decline-with-note + +**Feature:** shared-calendars +**Created:** 2026-10-27 + +## Problem + +Organizers follow up with every invitee who declines to ask why. A short note at decline time would save the message. + +## Goal + +An invitee who declines can tell the organizer why, in the same step. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | An invitee will be able to add a note when declining. | Must | +| FR-13 | Only the organizer will see a decline note. | Must | +| FR-05 | The organizer will see any decline note with the response. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/TRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/TRD.md new file mode 100644 index 0000000..1454489 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/TRD.md @@ -0,0 +1,25 @@ +--- +type: trd +title: "TRD: decline-with-note" +description: How decline notes will be built. +status: deprecated +--- + +# TRD: decline-with-note + +**PRD:** [PRD.md](PRD.md) + +## Architecture Overview + +The decline response will carry an optional note, stored with the response and returned only to the organizer. + +## Dependencies + +This change adds no packages. + +## Files + +| Action | Path | Purpose | +|--------|------|---------| +| Modify | `src/invitations/respond.ts` | Accept an optional note on decline | +| Modify | `src/invitations/responses-view.ts` | Show the note to the organizer only | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/deltas/invitations.delta.md new file mode 100644 index 0000000..38a2a66 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/changes/archive/2026-12-15-decline-with-note/deltas/invitations.delta.md @@ -0,0 +1,84 @@ +--- +type: delta +title: Invitations delta for decline-with-note +description: Spec units the decline-with-note change adds and modifies in invitations.md. +status: deprecated +--- + +# Delta: invitations.md + +## ADDED + +### FR-13 + +Section: Requirements + +Text: + +~~~markdown +### FR-13 Decline notes + +Only the organizer sees a decline note. +~~~ + +### stories/US-008-decline-with-note.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-05 + +Base text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response. +~~~ + +New text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response, with any decline note. +~~~ + +### scenarios/invitation-responses.feature + +Base text: + +~~~gherkin +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/invitations.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/invitations.md new file mode 100644 index 0000000..06ef56c --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/invitations.md @@ -0,0 +1,33 @@ +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. + +## Requirements + +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. + +### FR-04 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. + +### FR-05 Response visibility + +The organizer sees each invitee's response, with any decline note. + +### FR-12 Invitation expiry + +An invitation that has no response 14 days after it was sent expires. The organizer is told when an invitation expires. + +### FR-13 Decline notes + +Only the organizer sees a decline note. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/log.md new file mode 100644 index 0000000..9798c59 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/log.md @@ -0,0 +1,43 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2026-09-14 Canonized: first-version + +- Outcome: Added FR-03, FR-04 and FR-05, `stories/US-001-respond-to-invitation.md` and `scenarios/invitation-responses.feature`. Nothing deferred. + +## 2026-11-02 Ratified: invite-expiry + +- Change: invite-expiry +- Reason: Invitees left invitations unanswered for weeks, so organizers could not plan. +- Links: Promotion PR #101 + +## 2026-11-09 Ratified: decline-with-note + +- Change: decline-with-note +- Reason: Organizers asked why people declined; a note saves a follow-up message. +- Overlap: FR-03 is also modified by invite-expiry. The maintainer ordered invite-expiry first. FR-12 was renumbered to FR-13. +- Links: Promotion PR #104 + +## 2026-11-24 Shipped: invite-expiry + +- Change: invite-expiry +- Ship signal: release 3.4 reached all users. +- Evidence: [release 3.4](https://example.com/releases/3.4) + +## 2026-11-28 Shipped: decline-with-note + +- Change: decline-with-note +- Ship signal: release 3.5 reached all users. +- Evidence: [release 3.5](https://example.com/releases/3.5) + +## 2026-12-01 Canonized: invite-expiry + +- Change: [invite-expiry](changes/archive/2026-12-01-invite-expiry/) +- Outcome: Added FR-12, `stories/US-007-invitation-expiry.md` and `scenarios/invitation-expiry.feature`; modified FR-03. Nothing deferred. + +## 2026-12-15 Canonized: decline-with-note + +- Change: [decline-with-note](changes/archive/2026-12-15-decline-with-note/) +- Outcome: Added FR-13 and `stories/US-008-decline-with-note.md`; modified FR-05 and `scenarios/invitation-responses.feature`. Nothing deferred. +- Rebased: FR-03 had drifted since ratification, when invite-expiry added "An expired invitation cannot be accepted." The rebased FR-03 keeps that sentence and adds the decline note. The maintainer confirmed the meaning is unchanged. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-expiry.feature b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-expiry.feature new file mode 100644 index 0000000..6f0c98e --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-expiry.feature @@ -0,0 +1,14 @@ +# Traces: US-007 +Feature: Invitation expiry + An unanswered invitation expires after 14 days. + + Scenario: An unanswered invitation expires after 14 days + Given an organizer invited me to an event 14 days ago + And I have not responded + When the invitation expires + Then the organizer is told that my invitation expired + + Scenario: An expired invitation can't be accepted + Given my invitation to an event has expired + When I try to accept the invitation + Then the event does not appear in my calendar diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-responses.feature b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-responses.feature new file mode 100644 index 0000000..1a65171 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/scenarios/invitation-responses.feature @@ -0,0 +1,21 @@ +# Traces: US-001, US-008 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined + + Scenario: Only the organizer sees a decline note + Given an organizer has invited me and another invitee to an event + When I decline the invitation with the note "Away that week" + Then the organizer sees my note with my response + And the other invitee does not see my note diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..0f05965 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,26 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar, invite each other to events and respond to invitations. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, and each invitee's response decides whether the event joins their calendar. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](invitations.md) | How an organizer invites people and how invitees respond | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-001-respond-to-invitation.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-001-respond-to-invitation.md new file mode 100644 index 0000000..00a4ccd --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-001-respond-to-invitation.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-001: Respond to an invitation" +description: An invitee accepts or declines an invitation. +status: stable +--- + +# US-001: Respond to an invitation + +**PRD Requirement:** FR-03, FR-05 + +## Story + +As an invitee, +I want to accept or decline an invitation, +so that my calendar shows the events I will attend. + +## Acceptance Criteria + +- [x] An accepted invitation adds the event to the invitee's calendar +- [x] A declined invitation leaves the invitee's calendar unchanged +- [x] The organizer sees the response diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-007-invitation-expiry.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-007-invitation-expiry.md new file mode 100644 index 0000000..b5c0f49 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-007-invitation-expiry.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-007: Invitation expiry" +description: An unanswered invitation expires and the organizer is told. +status: stable +--- + +# US-007: Invitation expiry + +**PRD Requirement:** FR-12, FR-03 + +## Story + +As an organizer, +I want unanswered invitations to expire, +so that I know who is coming in time to plan. + +## Acceptance Criteria + +- [ ] An invitation with no response 14 days after it was sent expires +- [ ] The organizer is told when an invitation expires +- [ ] An expired invitation can't be accepted diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-008-decline-with-note.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-008-decline-with-note.md new file mode 100644 index 0000000..82718ce --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/expected/shared-calendars/stories/US-008-decline-with-note.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-008: Decline with a note" +description: An invitee adds a note when declining, and only the organizer sees it. +status: stable +--- + +# US-008: Decline with a note + +**PRD Requirement:** FR-03, FR-05, FR-13 + +## Story + +As an invitee, +I want to add a note when I decline an invitation, +so that the organizer knows why without asking. + +## Acceptance Criteria + +- [ ] An invitee can add a note when declining +- [ ] The organizer sees the note with the response +- [ ] Other invitees don't see the note diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/rebased/decline-with-note/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/rebased/decline-with-note/deltas/invitations.delta.md new file mode 100644 index 0000000..fe967d7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/rebased/decline-with-note/deltas/invitations.delta.md @@ -0,0 +1,84 @@ +--- +type: delta +title: Invitations delta for decline-with-note, rebased +description: The decline-with-note delta rebased onto FR-03 as invite-expiry left it, confirmed by the maintainer. +status: stable +--- + +# Delta: invitations.md + +## ADDED + +### FR-13 + +Section: Requirements + +Text: + +~~~markdown +### FR-13 Decline notes + +Only the organizer sees a decline note. +~~~ + +### stories/US-008-decline-with-note.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +~~~ + +### FR-05 + +Base text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response. +~~~ + +New text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response, with any decline note. +~~~ + +### scenarios/invitation-responses.feature + +Base text: + +~~~gherkin +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/PRD.md new file mode 100644 index 0000000..8e1f619 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/PRD.md @@ -0,0 +1,27 @@ +--- +type: prd +title: "PRD: decline-with-note" +description: An invitee can add a note when declining, and only the organizer sees it. +status: stable +--- + +# PRD: decline-with-note + +**Feature:** shared-calendars +**Created:** 2026-10-27 + +## Problem + +Organizers follow up with every invitee who declines to ask why. A short note at decline time would save the message. + +## Goal + +An invitee who declines can tell the organizer why, in the same step. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-03 | An invitee will be able to add a note when declining. | Must | +| FR-13 | Only the organizer will see a decline note. | Must | +| FR-05 | The organizer will see any decline note with the response. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/TRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/TRD.md new file mode 100644 index 0000000..6c706f7 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/TRD.md @@ -0,0 +1,25 @@ +--- +type: trd +title: "TRD: decline-with-note" +description: How decline notes will be built. +status: stable +--- + +# TRD: decline-with-note + +**PRD:** [PRD.md](PRD.md) + +## Architecture Overview + +The decline response will carry an optional note, stored with the response and returned only to the organizer. + +## Dependencies + +This change adds no packages. + +## Files + +| Action | Path | Purpose | +|--------|------|---------| +| Modify | `src/invitations/respond.ts` | Accept an optional note on decline | +| Modify | `src/invitations/responses-view.ts` | Show the note to the organizer only | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/deltas/invitations.delta.md new file mode 100644 index 0000000..1cf7e37 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/deltas/invitations.delta.md @@ -0,0 +1,84 @@ +--- +type: delta +title: Invitations delta for decline-with-note +description: Spec units the decline-with-note change adds and modifies in invitations.md. +status: stable +--- + +# Delta: invitations.md + +## ADDED + +### FR-13 + +Section: Requirements + +Text: + +~~~markdown +### FR-13 Decline notes + +Only the organizer sees a decline note. +~~~ + +### stories/US-008-decline-with-note.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation, and can add a note when declining. An accepted invitation adds the event to the invitee's calendar. +~~~ + +### FR-05 + +Base text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response. +~~~ + +New text: + +~~~markdown +### FR-05 Response visibility + +The organizer sees each invitee's response, with any decline note. +~~~ + +### scenarios/invitation-responses.feature + +Base text: + +~~~gherkin +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/scenarios/invitation-responses.feature b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/scenarios/invitation-responses.feature new file mode 100644 index 0000000..1a65171 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/scenarios/invitation-responses.feature @@ -0,0 +1,21 @@ +# Traces: US-001, US-008 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined + + Scenario: Only the organizer sees a decline note + Given an organizer has invited me and another invitee to an event + When I decline the invitation with the note "Away that week" + Then the organizer sees my note with my response + And the other invitee does not see my note diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/stories/US-008-decline-with-note.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/stories/US-008-decline-with-note.md new file mode 100644 index 0000000..82718ce --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/decline-with-note/stories/US-008-decline-with-note.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-008: Decline with a note" +description: An invitee adds a note when declining, and only the organizer sees it. +status: stable +--- + +# US-008: Decline with a note + +**PRD Requirement:** FR-03, FR-05, FR-13 + +## Story + +As an invitee, +I want to add a note when I decline an invitation, +so that the organizer knows why without asking. + +## Acceptance Criteria + +- [ ] An invitee can add a note when declining +- [ ] The organizer sees the note with the response +- [ ] Other invitees don't see the note diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/PRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/PRD.md new file mode 100644 index 0000000..c62f76b --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/PRD.md @@ -0,0 +1,26 @@ +--- +type: prd +title: "PRD: invite-expiry" +description: Invitations expire when an invitee does not respond within 14 days. +status: stable +--- + +# PRD: invite-expiry + +**Feature:** shared-calendars +**Created:** 2026-10-20 + +## Problem + +Invitees leave invitations unanswered for weeks. Organizers can't tell who is coming, so they can't plan. + +## Goal + +An organizer knows within 14 days whether each invitee is coming. + +## Requirements + +| ID | Requirement | Priority | +|----|-------------|----------| +| FR-12 | An invitation with no response 14 days after it was sent will expire, and the organizer will be told. | Must | +| FR-03 | An expired invitation can no longer be accepted. | Must | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/TRD.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/TRD.md new file mode 100644 index 0000000..44e440e --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/TRD.md @@ -0,0 +1,25 @@ +--- +type: trd +title: "TRD: invite-expiry" +description: How invitation expiry will be built. +status: stable +--- + +# TRD: invite-expiry + +**PRD:** [PRD.md](PRD.md) + +## Architecture Overview + +A daily job will mark invitations older than 14 days with no response as expired and queue a notice to the organizer. + +## Dependencies + +This change adds no packages. + +## Files + +| Action | Path | Purpose | +|--------|------|---------| +| Create | `src/invitations/expire-invitations.ts` | Daily expiry job | +| Modify | `src/invitations/respond.ts` | Reject responses to expired invitations | diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/deltas/invitations.delta.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/deltas/invitations.delta.md new file mode 100644 index 0000000..51153fd --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/deltas/invitations.delta.md @@ -0,0 +1,46 @@ +--- +type: delta +title: Invitations delta for invite-expiry +description: Spec units the invite-expiry change adds and modifies in invitations.md. +status: stable +--- + +# Delta: invitations.md + +## ADDED + +### FR-12 + +Section: Requirements + +Text: + +~~~markdown +### FR-12 Invitation expiry + +An invitation that has no response 14 days after it was sent expires. The organizer is told when an invitation expires. +~~~ + +### scenarios/invitation-expiry.feature + +### stories/US-007-invitation-expiry.md + +## MODIFIED + +### FR-03 + +Base text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. +~~~ + +New text: + +~~~markdown +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. An expired invitation cannot be accepted. +~~~ diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/scenarios/invitation-expiry.feature b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/scenarios/invitation-expiry.feature new file mode 100644 index 0000000..6f0c98e --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/scenarios/invitation-expiry.feature @@ -0,0 +1,14 @@ +# Traces: US-007 +Feature: Invitation expiry + An unanswered invitation expires after 14 days. + + Scenario: An unanswered invitation expires after 14 days + Given an organizer invited me to an event 14 days ago + And I have not responded + When the invitation expires + Then the organizer is told that my invitation expired + + Scenario: An expired invitation can't be accepted + Given my invitation to an event has expired + When I try to accept the invitation + Then the event does not appear in my calendar diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/stories/US-007-invitation-expiry.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/stories/US-007-invitation-expiry.md new file mode 100644 index 0000000..b5c0f49 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/changes/invite-expiry/stories/US-007-invitation-expiry.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-007: Invitation expiry" +description: An unanswered invitation expires and the organizer is told. +status: stable +--- + +# US-007: Invitation expiry + +**PRD Requirement:** FR-12, FR-03 + +## Story + +As an organizer, +I want unanswered invitations to expire, +so that I know who is coming in time to plan. + +## Acceptance Criteria + +- [ ] An invitation with no response 14 days after it was sent expires +- [ ] The organizer is told when an invitation expires +- [ ] An expired invitation can't be accepted diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/invitations.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/invitations.md new file mode 100644 index 0000000..3a022b5 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/invitations.md @@ -0,0 +1,25 @@ +--- +type: feature-spec-facet +title: Invitations +description: How an organizer invites people to an event and how invitees respond. +status: stable +tags: [workflow] +--- + +# Invitations + +An organizer invites people to an event on a shared calendar. Each invitee responds, and the organizer sees the responses. + +## Requirements + +### FR-03 Invitation responses + +An invitee can accept or decline an invitation. An accepted invitation adds the event to the invitee's calendar. + +### FR-04 Invitation delivery + +An invitation is delivered to the invitee by email and in the app. + +### FR-05 Response visibility + +The organizer sees each invitee's response. diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/log.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/log.md new file mode 100644 index 0000000..a0dd095 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/log.md @@ -0,0 +1,32 @@ +# Feature log: shared-calendars + +Dated history of the shared-calendars feature and the reasons behind each change, oldest first. Append new entries at the end. + +## 2026-09-14 Canonized: first-version + +- Outcome: Added FR-03, FR-04 and FR-05, `stories/US-001-respond-to-invitation.md` and `scenarios/invitation-responses.feature`. Nothing deferred. + +## 2026-11-02 Ratified: invite-expiry + +- Change: invite-expiry +- Reason: Invitees left invitations unanswered for weeks, so organizers could not plan. +- Links: Promotion PR #101 + +## 2026-11-09 Ratified: decline-with-note + +- Change: decline-with-note +- Reason: Organizers asked why people declined; a note saves a follow-up message. +- Overlap: FR-03 is also modified by invite-expiry. The maintainer ordered invite-expiry first. FR-12 was renumbered to FR-13. +- Links: Promotion PR #104 + +## 2026-11-24 Shipped: invite-expiry + +- Change: invite-expiry +- Ship signal: release 3.4 reached all users. +- Evidence: [release 3.4](https://example.com/releases/3.4) + +## 2026-11-28 Shipped: decline-with-note + +- Change: decline-with-note +- Ship signal: release 3.5 reached all users. +- Evidence: [release 3.5](https://example.com/releases/3.5) diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/scenarios/invitation-responses.feature b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/scenarios/invitation-responses.feature new file mode 100644 index 0000000..4cee75b --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/scenarios/invitation-responses.feature @@ -0,0 +1,15 @@ +# Traces: US-001 +Feature: Invitation responses + An invitee's response decides whether the event joins their calendar. + + Scenario: Accepting an invitation adds the event to the invitee's calendar + Given an organizer has invited me to an event + When I accept the invitation + Then the event appears in my calendar + And the organizer sees my response as accepted + + Scenario: Declining an invitation leaves the invitee's calendar unchanged + Given an organizer has invited me to an event + When I decline the invitation + Then the event does not appear in my calendar + And the organizer sees my response as declined diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/shared-calendars-spec.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/shared-calendars-spec.md new file mode 100644 index 0000000..0f05965 --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/shared-calendars-spec.md @@ -0,0 +1,26 @@ +--- +type: feature-spec-overview +title: Shared calendars +description: People share a calendar, invite each other to events and respond to invitations. +status: stable +tags: [] +--- + +# Shared calendars + +A shared calendar lets a group plan events together. An organizer invites people to an event, and each invitee's response decides whether the event joins their calendar. + +## Facets + +| Facet spec | Covers | Spec-unit prefixes | +|------------|--------|--------------------| +| [Invitations](invitations.md) | How an organizer invites people and how invitees respond | FR | + +## Stories and scenarios + +- Stories: [stories/](stories/) +- Platform-level scenarios: [scenarios/](scenarios/) + +## History + +The feature log, [log.md](log.md), records each change to this feature and its reasons. Canonized changes are kept in [changes/archive/](changes/archive/). diff --git a/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/stories/US-001-respond-to-invitation.md b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/stories/US-001-respond-to-invitation.md new file mode 100644 index 0000000..00a4ccd --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/fixtures/two-canonizations/start/shared-calendars/stories/US-001-respond-to-invitation.md @@ -0,0 +1,22 @@ +--- +type: story +title: "US-001: Respond to an invitation" +description: An invitee accepts or declines an invitation. +status: stable +--- + +# US-001: Respond to an invitation + +**PRD Requirement:** FR-03, FR-05 + +## Story + +As an invitee, +I want to accept or decline an invitation, +so that my calendar shows the events I will attend. + +## Acceptance Criteria + +- [x] An accepted invitation adds the event to the invitee's calendar +- [x] A declined invitation leaves the invitee's calendar unchanged +- [x] The organizer sees the response diff --git a/plugins/product-development/skills/product-development/tests/helpers/deltas.py b/plugins/product-development/skills/product-development/tests/helpers/deltas.py new file mode 100755 index 0000000..7d206bc --- /dev/null +++ b/plugins/product-development/skills/product-development/tests/helpers/deltas.py @@ -0,0 +1,876 @@ +#!/usr/bin/env python3 +"""Test helper: apply the change and delta contract to a feature bundle. + +This is test support for the feature-evolution suite, not a skill script. +It follows references/changes-and-deltas.md mechanically so the fixture can +prove the contract holds: the overlap check, the base check, and the parts +of canonization that touch files (apply deltas, move stories and scenarios, +archive the change). The canonization workflow itself is an agent workflow. + +A change directory is features/{feature}/changes/{change}/ or +shaping/{feature}--{change}/; its path names the feature that owns it. A +change is identified by its feature and name. +A delta in deltas/{feature-id}/ targets another feature, a sibling of +FEATURE_DIR. + +App-local scenario files sit outside the bundle, at paths from the +repository root. Deferring one needs --repo, the repository root, and +--promoted, the promotion PR's merge commit. + +Usage: + deltas.py overlap CHANGE_DIR [CHANGE_DIR ...] + deltas.py base-check FEATURE_DIR CHANGE_DIR [--deltas DIR] + deltas.py canonize FEATURE_DIR CHANGE --date YYYY-MM-DD [--deltas DIR] + [--repo DIR --promoted REV] + +Exit status: 0 on success, 1 when a check finds a problem (nothing is +changed), 2 on bad input. +""" + +import argparse +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +UNIT_ID = r"[A-Z][A-Z0-9]*-[0-9]+" +HEADING = re.compile(r"^(#{1,6}) (.*?)\s*$") +UNIT_HEADING = re.compile(r"^(#{1,6}) (" + UNIT_ID + r")(?: .*)?$") +FILE_UNIT = re.compile(r"^(scenarios|stories)/[^/]+$") +APP_LOCAL = re.compile(r"^apps/[^/\s]+/docs/features/[^/\s]+/scenarios/[^/\s]+\.feature$") +APP_SECTION = "App-local scenario files" +FENCE_OPEN = re.compile(r"^(~{3,}|`{3,})[^`~]*$") +SECTIONS = ("ADDED", "MODIFIED", "REMOVED") +NOT_SPEC = {"log.md", "index.md", "README.md", "AGENTS.md"} + + +class InputError(Exception): + pass + + +def normalize(text): + """Unit text compared ignoring trailing whitespace and blank edges.""" + lines = [line.rstrip() for line in text.strip("\n").split("\n")] + while lines and not lines[-1]: + lines.pop() + while lines and not lines[0]: + lines.pop(0) + return "\n".join(lines) + + +def split_front_matter(text, where="document"): + if text.startswith("---\n"): + end = text.find("\n---\n", 3) + if end < 0: + raise InputError(f"{where}: front matter opens with '---' but has no closing '---' line") + return text[: end + 5], text[end + 5 :] + return "", text + + +# --- Deltas --- + + +def parse_delta(path): + """Return the entries of one delta file. + + Each entry: {"section", "unit", "kind" ("id" or "file"), "fields"}, where + fields maps a label ("Text", "Base text", "New text", "Section") to its + value. Fenced values keep their exact content. + """ + _, body = split_front_matter(path.read_text(), path) + entries = [] + section = None + entry = None + label = None + fence = None + closed = None + buf = [] + for line in body.split("\n"): + if fence is not None: + # CommonMark: the payload closes at a run of the fence character + # at least as long as the opening run, and nothing else. + if re.fullmatch(re.escape(fence[0]) + "{" + str(len(fence)) + r",}\s*", line): + entry["fields"][label] = "\n".join(buf) + closed = f"{entry['section']} {entry['unit']} '{label}'" + fence, label, buf = None, None, [] + else: + buf.append(line) + continue + if closed and line.strip(): + if not (line.startswith("#") or re.match(r"^(Section: |Text:$|Base text:$|New text:$)", line)): + raise InputError( + f"{path}: text after the closing fence of {closed}; " + "make the outer fence longer than any fence inside the unit" + ) + closed = None + if line.startswith("## "): + name = line[3:].strip() + section = name if name in SECTIONS + ("DOCUMENT", APP_SECTION) else None + entry = None + if section == "DOCUMENT": + # The whole document: its front matter, title and summary for + # a document the delta writes, or all of it for a rewrite. + entry = {"section": section, "unit": "DOCUMENT", "kind": "doc", "fields": {}} + entries.append(entry) + continue + if section is None: + continue + if line.startswith("### ") and section != "DOCUMENT": + unit = line[4:].strip() + if section == APP_SECTION: + if not APP_LOCAL.match(unit): + raise InputError(f"{path}: app-local entry '{unit}' is not an apps/{{surface}}/docs/features/{{feature}}/scenarios/ path") + kind = "app" + elif re.fullmatch(UNIT_ID, unit): + kind = "id" + elif FILE_UNIT.match(unit): + kind = "file" + else: + raise InputError(f"{path}: entry '{unit}' is neither a unit ID nor a file unit") + entry = {"section": section, "unit": unit, "kind": kind, "fields": {}} + entries.append(entry) + continue + if entry is None: + continue + m = re.match(r"^Section: (.+)$", line) + if m: + entry["fields"]["Section"] = m.group(1).strip() + continue + m = re.match(r"^(Text|Base text|New text):$", line) + if m: + label = m.group(1) + continue + m = FENCE_OPEN.match(line) + if m and label: + fence, buf = m.group(1), [] + continue + if fence is not None: + raise InputError(f"{path}: unterminated fence") + docs = [e for e in entries if e["kind"] == "doc"] + if len(docs) > 1: + raise InputError(f"{path}: more than one DOCUMENT section") + for e in docs: + fields = set(e["fields"]) + if fields == {"Base text", "New text"}: + if len(entries) > 1: + raise InputError(f"{path}: a delta that rewrites its whole document holds no other entries") + elif fields != {"Text"}: + raise InputError(f"{path}: DOCUMENT holds Text, or Base text and New text") + text = e["fields"].get("Text", e["fields"].get("New text")) + front, _ = split_front_matter(text + "\n", f"{path}: DOCUMENT text") + missing = [k for k in ("type", "title", "description", "status") if not re.search(rf"^{k}: ", front, re.M)] + if missing: + raise InputError(f"{path}: DOCUMENT text lacks front matter: {', '.join(missing)}") + for e in entries: + if e["kind"] == "app": + if "Base text" in e["fields"] and "Text" in e["fields"]: + raise InputError(f"{path}: app-local {e['unit']} holds New text, not Text, with its base text") + continue + if e["kind"] == "doc": + continue + need = { + ("ADDED", "id"): ("Section", "Text"), + ("MODIFIED", "id"): ("Base text", "New text"), + ("REMOVED", "id"): ("Base text",), + ("ADDED", "file"): (), + ("MODIFIED", "file"): ("Base text",), + ("REMOVED", "file"): ("Base text",), + }[(e["section"], e["kind"])] + for field in need: + if field not in e["fields"]: + raise InputError(f"{path}: {e['section']} {e['unit']} lacks '{field}'") + if e["kind"] == "id" and ("Text" in e["fields"] or "New text" in e["fields"]): + text = e["fields"]["Text"] if "Text" in e["fields"] else e["fields"]["New text"] + m = UNIT_HEADING.match(text.split("\n", 1)[0]) + if not m or m.group(2) != e["unit"]: + raise InputError(f"{path}: text for {e['unit']} does not start with its heading") + return entries + + +def delta_files(change_dir, deltas_dir=None): + """Return (delta path, qualifier) pairs. A delta directly in deltas/ + targets the change's own feature (qualifier None); a delta in + deltas/{feature-id}/ targets that feature.""" + d = Path(deltas_dir) if deltas_dir else Path(change_dir) / "deltas" + files = [(p, None) for p in sorted(d.glob("*.delta.md"))] + files += [(p, p.parent.name) for p in sorted(d.glob("*/*.delta.md"))] + if not files: + raise InputError(f"no deltas in {d}") + return files + + +def target_name(delta_path): + return delta_path.name[: -len(".delta.md")] + ".md" + + +def prefix(qualifier): + return f"{qualifier}/" if qualifier else "" + + +def feature_of(feature, qualifier): + """The feature directory a delta with this qualifier targets.""" + return feature.parent / qualifier if qualifier else feature + + +def change_feature(change_dir): + """The feature that owns a change: features/{feature}/changes/{change}/ + or shaping/{feature}--{change}/.""" + p = Path(change_dir).resolve() + if p.parent.name == "changes": + return p.parent.parent.name + if "--" in p.name: + return p.name.split("--", 1)[0] + raise InputError(f"{change_dir}: cannot tell which feature owns this change") + + +def change_name(change_dir): + return Path(change_dir).resolve().name.split("--", 1)[-1] + + +def file_units(deltas): + """Map each whole-file unit, as (qualifier, path), to (section, text), + where text is the Text or New text a reconciled entry carries for a + split file, or None.""" + units = {} + for delta, q in deltas: + for e in parse_delta(delta): + if e["kind"] == "file": + text = e["fields"].get("Text", e["fields"].get("New text")) + units[(q, e["unit"])] = (e["section"], text) + return units + + +# --- Feature spec --- + + +def spec_docs(feature_dir): + return sorted(p for p in Path(feature_dir).glob("*.md") if p.name not in NOT_SPEC) + + +def headings(lines): + """Map line index -> (level, title) for each ATX heading outside fenced + code blocks. A heading inside a code example is text, not structure.""" + found, fence = {}, None + for i, line in enumerate(lines): + if fence is not None: + if re.fullmatch(r" {0,3}" + re.escape(fence[0]) + "{" + str(len(fence)) + r",}\s*", line): + fence = None + continue + m = re.match(r" {0,3}(~{3,}|`{3,})", line) + if m and not (m.group(1)[0] == "`" and "`" in line[m.end() :]): + fence = m.group(1) + continue + h = HEADING.match(line) + if h: + found[i] = (len(h.group(1)), h.group(2)) + return found + + +def section_end(lines, heads, at): + """Index of the first heading after `at` at its level or higher.""" + level = heads[at][0] + return next((j for j in sorted(heads) if j > at and heads[j][0] <= level), len(lines)) + + +def find_units(lines): + """Map unit ID -> (start, end) line indexes, end exclusive.""" + heads = headings(lines) + units = {} + for i in heads: + m = UNIT_HEADING.match(lines[i]) + if m: + units[m.group(2)] = (i, section_end(lines, heads, i)) + return units + + +def unit_id_list(lines): + """Unit IDs in heading order, repeats kept.""" + heads = headings(lines) + return [m.group(2) for i in sorted(heads) if (m := UNIT_HEADING.match(lines[i]))] + + +def duplicate_ids(feature, features): + """Unit IDs that appear more than once in a feature's spec documents. + `feature` is the change's feature in a trial canonization, so the + documents read as they will after every delta is applied.""" + out = [] + for q in features: + fdir = feature_of(feature, q) + if not fdir.is_dir(): + continue + where = {} + for doc in spec_docs(fdir): + for uid in unit_id_list(doc.read_text().split("\n")): + where.setdefault(uid, []).append(doc.name) + for uid, docs in sorted(where.items()): + if len(docs) > 1: + out.append( + f"{prefix(q)}{uid}: {len(docs)} units have this ID after canonization, in " + f"{', '.join(prefix(q) + d for d in docs)}; IDs are unique per feature" + ) + return out + + +def all_unit_ids(feature_dir): + ids = {} + for doc in spec_docs(feature_dir): + for uid in find_units(doc.read_text().split("\n")): + ids[uid] = doc.name + return ids + + +def section_matches(lines, anchor): + """Line indexes of the headings an ADDED entry's Section names. + + The anchor is a heading title, or a heading path such as + "Guests > Requirements" that ends at the heading. + """ + want = [part.strip() for part in anchor.split(">")] + stack, matches = [], [] + for i, (level, title) in sorted(headings(lines).items()): + while stack and stack[-1][0] >= level: + stack.pop() + stack.append((level, title)) + if [title for _, title in stack][-len(want):] == want: + matches.append(i) + return matches + + +def section_parents(lines, at): + """Indexes of the heading at `at` and its parent headings, outermost + first, without the document title.""" + heads = headings(lines) + chain = [at] + level = heads[at][0] + for i in sorted((i for i in heads if i < at), reverse=True): + if 1 < heads[i][0] < level: + chain.insert(0, i) + level = heads[i][0] + return chain + + +def unit_text(lines, span): + return normalize("\n".join(lines[span[0] : span[1]])) + + +# --- Checks --- + + +def overlap(change_dirs): + # Units are keyed by the feature that holds them, so a delta against + # another feature is compared with that feature's changes. Changes are + # keyed by their feature and name: a name is unique only within its + # feature. + touched = {} + owners = set() + for change in change_dirs: + owner = change_feature(change) + owners.add(owner) + name = (owner, change_name(change)) + for delta, q in delta_files(change): + for e in parse_delta(delta): + if e["kind"] == "doc": + unit = target_name(delta) + verb = "writes" if "Text" in e["fields"] else "rewrites" + elif e["kind"] == "app": + unit, verb = e["unit"], "changes" + else: + unit = e["unit"] + verb = {"ADDED": "adds", "MODIFIED": "modifies", "REMOVED": "removes"}[e["section"]] + touched.setdefault((q or owner, unit), {}).setdefault(name, set()).add(verb) + # Name units and changes with their feature whenever more than one + # feature is involved. + qualify = len(owners | {f for f, _ in touched}) > 1 + found = {} + for (feat, unit), who in touched.items(): + if len(who) > 1: + label = f"{feat}/{unit}" if qualify else unit + found[label] = [ + f"{owner + '/' if qualify else ''}{name} " + f"{'moves' if {'adds', 'removes'} <= verbs else ', '.join(sorted(verbs))}" + for (owner, name), verbs in who.items() + ] + for label in sorted(found): + print(f"{label}: {'; '.join(found[label])}") + if not found: + print("no overlap") + return 1 if found else 0 + + +def base_check(feature_dir, change_dir, deltas_dir=None): + feature = Path(feature_dir) + problems = [] + deltas = delta_files(change_dir, deltas_dir) + # An ADDED ID the same change removes from the same feature is a unit + # moving between facets: it keeps its ID. + removed = {} + for delta, q in deltas: + for e in parse_delta(delta): + if e["section"] == "REMOVED" and e["kind"] == "id": + removed.setdefault(q, set()).add(e["unit"]) + # A split into a new feature: its promotion PR initialized the receiving + # bundle like a first version, with a metadata-only overview and a log. + for q in sorted({q for _, q in deltas if q and q != feature.name}): + fdir = feature_of(feature, q) + if not (fdir / f"{q}-spec.md").is_file() or not (fdir / "log.md").is_file(): + problems.append( + f"{q}: the receiving bundle is missing its overview or log; " + "the promotion PR initializes it like a first version" + ) + if problems: + for p in problems: + print(p) + return 1 + ids = {} + for delta, q in deltas: + fdir, pre = feature_of(feature, q), prefix(q) + if q not in ids: + ids[q] = all_unit_ids(fdir) if fdir.is_dir() else {} + target = fdir / target_name(delta) + name = pre + target.name + entries = parse_delta(delta) + doc = next((e for e in entries if e["kind"] == "doc"), None) + if doc and "Text" in doc["fields"]: + if target.exists(): + problems.append(f"{name}: the delta writes this document, but it already exists") + lines = doc["fields"]["Text"].split("\n") + elif doc: + if not target.exists(): + problems.append(f"{name}: the delta rewrites this document, but it does not exist") + elif normalize(target.read_text()) != normalize(doc["fields"]["Base text"]): + problems.append(f"{name}: base text differs from the document") + continue + elif target.exists(): + lines = target.read_text().split("\n") + else: + lines = [] + if any(e["kind"] == "id" for e in entries): + problems.append(f"{name}: the document does not exist, and the delta has no DOCUMENT entry to write it") + units = find_units(lines) + for e in entries: + if e["kind"] in ("doc", "app"): + continue + unit, section = e["unit"], e["section"] + label = pre + unit + if e["kind"] == "file": + current = fdir / unit + if section == "ADDED": + if current.exists(): + problems.append(f"{label}: added, but the file already exists at the feature root") + elif not current.exists(): + problems.append(f"{label}: {section.lower()}, but the file is missing at the feature root") + elif normalize(current.read_text()) != normalize(e["fields"]["Base text"]): + problems.append(f"{label}: base text differs from the feature root") + continue + if section == "ADDED": + if unit in ids[q] and unit not in removed.get(q, set()): + problems.append(f"{label}: added, but {pre}{ids[q][unit]} already has {unit}") + anchor = e["fields"]["Section"] + found = section_matches(lines, anchor) + if not found and ">" in anchor: + problems.append(f"{label}: section '{anchor}' names no heading in {name}") + if len(found) > 1: + heads = headings(lines) + example = " > ".join(heads[j][1] for j in section_parents(lines, found[0])) + problems.append( + f"{label}: section '{anchor}' matches {len(found)} headings in {name}; " + f"name it by its heading path, such as '{example}'" + ) + elif unit not in units: + problems.append(f"{label}: {section.lower()}, but {name} has no {unit}") + elif unit_text(lines, units[unit]) != normalize(e["fields"]["Base text"]): + problems.append(f"{label}: base text differs from {name}") + for p in problems: + print(p) + return 1 if problems else 0 + + +# --- Canonization --- + + +def apply_delta(target, entries): + if not any(e["kind"] in ("doc", "id") for e in entries): + # Only whole-file units: the story and scenario moves carry them, + # and the facet is left alone. + return + lines = target.read_text().split("\n") if target.exists() else [] + for e in sorted(entries, key=lambda e: e["kind"] != "doc"): + if e["kind"] == "doc": + if "New text" in e["fields"]: + target.write_text(e["fields"]["New text"].rstrip("\n") + "\n") + return + lines = e["fields"]["Text"].split("\n") + continue + if e["kind"] != "id": + continue + units = find_units(lines) + if e["section"] == "MODIFIED": + s, t = units[e["unit"]] + new = payload(e["fields"]["New text"]) + lines[s:t] = new + [""] + squeeze(lines, s + len(new)) + squeeze(lines, s) + elif e["section"] == "REMOVED": + s, t = units[e["unit"]] + del lines[s:t] + squeeze(lines, s) + else: + new = payload(e["fields"]["Text"]) + title = e["fields"]["Section"] + found = section_matches(lines, title) + if len(found) > 1: + raise InputError(f"section '{title}' is ambiguous in {target.name}") + at = section_end(lines, headings(lines), found[0]) if found else None + if at is None: + while lines and not lines[-1].strip(): + lines.pop() + lines += ["", "## " + title, ""] if lines else ["## " + title, ""] + at = len(lines) + while at > 0 and not lines[at - 1].strip(): + at -= 1 + lines[at:at] = [""] + new + [""] + squeeze(lines, at + 1 + len(new)) + squeeze(lines, at) + target.write_text("\n".join(lines).rstrip("\n") + "\n") + + +def payload(text): + """A unit's lines from its delta text, without trailing blank lines.""" + lines = text.split("\n") + while lines and not lines[-1].strip(): + lines.pop() + return lines + + +def squeeze(lines, at): + """Collapse the run of blank lines at an edit boundary, index `at`, to + one. Blank lines elsewhere, such as inside an untouched unit's fenced + example, are left as they are.""" + s, e = at, at + while s > 0 and not lines[s - 1].strip(): + s -= 1 + while e < len(lines) and not lines[e].strip(): + e += 1 + if e - s > 1: + lines[s:e] = [""] + + +def held_files(change_dir): + """The story and scenario files a change holds, as (qualifier, path). + Files for another feature sit under {feature-id}/ in the change.""" + held = [] + roots = [(change_dir, None)] + [ + (d, d.name) + for d in sorted(change_dir.iterdir()) + if d.is_dir() and d.name not in ("deltas", "stories", "scenarios") + ] + for root, q in roots: + for sub in ("stories", "scenarios"): + d = root / sub + held += [(q, f"{sub}/{f.name}") for f in sorted(d.iterdir())] if d.is_dir() else [] + return held + + +INLINE_LINK = re.compile(r"\]\(\s*#?]+)") +LINK_DEFINITION = re.compile(r"^ {0,3}\[[^\]]+\]:\s*#?]+)", re.M) + + +def link_targets(text): + """The targets of inline links and of reference-style link definitions.""" + return INLINE_LINK.findall(text) + LINK_DEFINITION.findall(text) + + +def dangling_links(feature, trial, deltas, deleted=()): + """Links in DOCUMENT text that do not resolve in the bundle as it will be + after canonization. `trial` is the feature in a copy of the features + directory with the canonization applied. Every relative link counts, + inline or reference-style, `./` forms included; a link to an existing + document the change leaves alone resolves. `deleted` holds the real + paths of app-local files the canonization PR deletes.""" + out = [] + gone = {os.path.realpath(p) for p in deleted} + for delta, q in deltas: + for e in parse_delta(delta): + if e["kind"] != "doc": + continue + text = e["fields"].get("Text", e["fields"].get("New text")) + doc_dir = feature_of(trial, q) + for link in link_targets(text): + if re.match(r"^[A-Za-z][A-Za-z0-9+.-]*:|^/", link): + continue + resolved = Path(os.path.normpath(doc_dir / link)) + # A link that leaves the features directory resolves against + # the real tree, which canonization changes only by its + # app-local deferrals. + rel = os.path.relpath(resolved, trial.parent) + where = resolved if not rel.startswith("..") else Path(os.path.normpath(feature.parent / rel)) + if not where.exists() or os.path.realpath(where) in gone: + out.append( + f"{prefix(q)}{target_name(delta)}: DOCUMENT links {link}, which does not resolve after canonization; " + "reconcile the DOCUMENT text with what shipped" + ) + return out + + +def emptied_bundles(trial, deltas): + """The other features whose bundles canonization leaves with no spec + units and no stories or scenarios. `trial` is the change's feature in a + trial canonization, so the bundles are read as the applied deltas left + them: a unit moved within a bundle stays, and a rewrite that drops the + last unit empties it.""" + out = [] + for q in sorted({q for _, q in deltas if q and q != trial.name}): + fdir = feature_of(trial, q) + if not fdir.is_dir(): + continue + files = [f for sub in ("stories", "scenarios") for f in (fdir / sub).glob("*") if f.is_file()] + if not all_unit_ids(fdir) and not files: + out.append(q) + return out + + +def refuse_deletion(feature, change_dir, emptied): + """Report each bundle canonization would delete while another + uncanonized change depends on it: a change the bundle holds, or a change + in any other feature whose feature-qualified deltas target it. Returns + True when any is found.""" + found = False + live = [ + d + for fdir in sorted(p for p in feature.parent.iterdir() if p.is_dir()) + for d in sorted((fdir / "changes").glob("*")) + if d.is_dir() and d.name != "archive" and d.resolve() != change_dir.resolve() + ] + for q in emptied: + held = [d.name for d in live if d.parent.parent.name == q] + targeting = [f"{d.parent.parent.name}/{d.name}" for d in live if d.parent.parent.name != q and any((d / "deltas" / q).glob("*.delta.md"))] + if held: + print( + f"{q}: canonizing would delete this bundle, but it holds other changes: {', '.join(held)}; " + f"canonize them or move them to {feature.name} first, or drop those that have not shipped" + ) + if targeting: + print( + f"{q}: canonizing would delete this bundle, but changes in other features target it: {', '.join(targeting)}; " + f"canonize them or retarget their deltas to {feature.name} first, or drop those that have not shipped" + ) + found = found or bool(held or targeting) + return found + + +def app_local(deltas): + """Map each app-local scenario path the deltas list to its entry fields.""" + return {e["unit"]: e["fields"] for delta, _ in deltas for e in parse_delta(delta) if e["kind"] == "app"} + + +def app_local_plan(change_dir, deltas_dir, repo, promoted): + """Decide each app-local scenario file the ratified deltas list. + + The promotion PR edited these files in place. A file whose entry the + reconciled deltas keep without new text shipped as it is. A dropped + entry defers the file: it goes back to its recorded base text, or is + deleted when the change added it. An entry with New text (or Text) is a + partly shipped file, written with that text. Either way the file must + still read as the promotion PR's merge commit left it; otherwise another + change has edited it, and the maintainer reconciles it. + + A deferral puts back the recorded base, so that base must be the file as + it stood just before the promotion PR merged, at the merge commit's first + parent: absent for an added file. A base recorded before another change + revised the file would restore a stale version. + + Returns (actions, problems); an action is (path, text or None, note). + """ + ratified = app_local(delta_files(change_dir)) + reconciled = app_local(delta_files(change_dir, deltas_dir)) + actions, problems = [], [] + for path, fields in ratified.items(): + kept = reconciled.get(path) + shipped = kept.get("New text", kept.get("Text")) if kept is not None else None + if kept is not None and shipped is None: + continue + if kept is not None: + actions.append((path, shipped, "keeps only its shipped scenarios")) + elif "Base text" in fields: + actions.append((path, fields["Base text"], "restored to its base text")) + else: + actions.append((path, None, "removed; the change added it")) + if actions and not (repo and promoted): + raise InputError("deferring app-local scenario files needs --repo and --promoted") + def show(rev, path): + out = subprocess.run(["git", "-C", str(repo), "show", f"{rev}:{path}"], capture_output=True, text=True) + return out.stdout if out.returncode == 0 else None + + for path, _, _ in actions: + current = Path(repo) / path + merged = show(promoted, path) + if merged is None or not current.is_file() or normalize(current.read_text()) != normalize(merged): + problems.append(f"{path}: changed since the promotion PR merged; the maintainer reconciles the deferral") + continue + if path in reconciled: + continue + before = show(f"{promoted}^1", path) + base = ratified[path].get("Base text") + if (before is None) != (base is None) or (base is not None and normalize(before) != normalize(base)): + problems.append( + f"{path}: the recorded base text differs from the file before the promotion PR merged; " + "the maintainer reconciles the deferral" + ) + return actions, problems + + +def canonize(feature_dir, change, date, deltas_dir=None, repo=None, promoted=None): + feature = Path(feature_dir) + change_dir = feature / "changes" / change + if not change_dir.is_dir(): + raise InputError(f"no change {change_dir}") + archive = feature / "changes" / "archive" / f"{date}-{change}" + if archive.exists(): + raise InputError(f"{archive} already exists") + + if base_check(feature, change_dir, deltas_dir): + print(f"base check failed: rebase the deltas of {change} before canonizing") + return 1 + + # Every story and scenario file the change holds is a whole-file unit + # of its ratified deltas. Canonization moves only the files its + # reconciled deltas list; a file the accounting deferred stays with the + # archived change. + ratified = file_units(delta_files(change_dir)) + reconciled = file_units(delta_files(change_dir, deltas_dir)) + held = held_files(change_dir) + for key in held: + if ratified.get(key, ("",))[0] not in ("ADDED", "MODIFIED"): + print(f"{prefix(key[0])}{key[1]}: the change holds this file, but its deltas do not list it") + return 1 + writes, deferred = [], [] + for key, (section, text) in reconciled.items(): + if section == "REMOVED": + continue + if text is None and key not in held: + print(f"{prefix(key[0])}{key[1]}: the deltas list this file, but the change does not hold it") + return 1 + writes.append((key, text)) + deferred = [key for key in held if key not in reconciled] + + # App-local scenario files: the promotion PR edited them in place, so a + # deferral puts back what was there before the change. + app_actions, app_problems = app_local_plan(change_dir, deltas_dir, repo, promoted) + if app_problems: + print("\n".join(app_problems)) + return 1 + + # The rest is checked against a trial canonization in a copy of the + # features directory, so it reads the bundles as they will be: written + # documents present, removed and deferred ones gone, emptied bundles + # deleted, app-local files the deferral deletes included. + deltas = delta_files(change_dir, deltas_dir) + with tempfile.TemporaryDirectory() as tmp: + trial = Path(tmp) / feature.parent.name + shutil.copytree(feature.parent, trial, symlinks=True) + apply_canonization(trial / feature.name, change, date, deltas, reconciled, writes, []) + emptied = emptied_bundles(trial / feature.name, deltas) + duplicates = duplicate_ids(trial / feature.name, [None] + sorted({q for _, q in deltas if q and q != feature.name})) + for q in emptied: + shutil.rmtree(feature_of(trial / feature.name, q)) + deleted = [Path(repo) / path for path, text, _ in app_actions if text is None] + dangling = dangling_links(feature, trial / feature.name, deltas, deleted) + + # A lineage change that empties another feature's bundle deletes it, so + # it waits until that bundle holds no other change and no other + # feature's change targets it. + if refuse_deletion(feature, change_dir, emptied): + return 1 + if duplicates or dangling: + print("\n".join(duplicates + dangling)) + return 1 + + archive = apply_canonization(feature, change, date, deltas, reconciled, writes, emptied) + for path, text, note in app_actions: + target = Path(repo) / path + if text is None: + target.unlink() + else: + target.write_text(text.rstrip("\n") + "\n") + print(f"deferred: {path} {note}") + for key in deferred: + print(f"deferred: {prefix(key[0])}{key[1]} stays in {archive.relative_to(feature)}") + for q in emptied: + print(f"deleted {q}: no spec units remain") + print(f"canonized {change} into {feature.name}; archived as {archive.relative_to(feature)}") + return 0 + + +def apply_canonization(feature, change, date, deltas, reconciled, writes, emptied): + """Apply checked deltas to FEATURE and archive the change. Returns the + archive path.""" + change_dir = feature / "changes" / change + archive = feature / "changes" / "archive" / f"{date}-{change}" + for delta, q in deltas: + fdir = feature_of(feature, q) + apply_delta(fdir / target_name(delta), parse_delta(delta)) + for (q, rel), (section, _) in reconciled.items(): + if section == "REMOVED": + (feature_of(feature, q) / rel).unlink() + for (q, rel), text in writes: + dest = feature_of(feature, q) / rel + dest.parent.mkdir(parents=True, exist_ok=True) + if text is None: + shutil.move(str(change_dir / prefix(q) / rel), str(dest)) + else: + # A split file: the reconciled entry carries the shipped part, and + # the change's file, with the deferred part, is archived. + dest.write_text(text.rstrip("\n") + "\n") + for d in sorted(change_dir.rglob("*"), reverse=True): + if d.is_dir() and not any(d.iterdir()): + d.rmdir() + + archive.parent.mkdir(parents=True, exist_ok=True) + shutil.move(str(change_dir), str(archive)) + for doc in archive.rglob("*.md"): + front, body = split_front_matter(doc.read_text(), doc) + if front: + doc.write_text(front.replace("\nstatus: stable\n", "\nstatus: deprecated\n") + body) + + # A source bundle left with no spec units and no stories or scenarios is + # deleted, not left as a stub. + for q in emptied: + shutil.rmtree(feature_of(feature, q)) + return archive + + +def main(argv): + parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + sub = parser.add_subparsers(dest="cmd", required=True) + p = sub.add_parser("overlap") + p.add_argument("changes", nargs="+") + p = sub.add_parser("base-check") + p.add_argument("feature") + p.add_argument("change") + p.add_argument("--deltas") + p = sub.add_parser("canonize") + p.add_argument("feature") + p.add_argument("change") + p.add_argument("--date", required=True) + p.add_argument("--deltas") + p.add_argument("--repo") + p.add_argument("--promoted") + args = parser.parse_args(argv) + try: + if args.cmd == "overlap": + return overlap(args.changes) + if args.cmd == "base-check": + return base_check(args.feature, args.change, args.deltas) + if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", args.date): + raise InputError("--date must be YYYY-MM-DD") + return canonize(args.feature, args.change, args.date, args.deltas, args.repo, args.promoted) + except InputError as err: + print(f"error: {err}", file=sys.stderr) + return 2 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/plugins/product-development/skills/product-development/tests/init.bats b/plugins/product-development/skills/product-development/tests/init.bats index f8b6ca9..539e359 100644 --- a/plugins/product-development/skills/product-development/tests/init.bats +++ b/plugins/product-development/skills/product-development/tests/init.bats @@ -609,7 +609,7 @@ EOF # --- Workflow hand-offs --- @test "brainstorming saves the design to shaping and returns control before ratification" { - grep -q 'save the approved design as the change.s shaping document in `docs/product/shaping/{feature}/`, then return control to this skill' "$SCRIPT_DIR/SKILL.md" + grep -q 'save the approved design as the change.s shaping document in `docs/product/shaping/{feature}--{change}/`, then return control to this skill' "$SCRIPT_DIR/SKILL.md" grep -q 'Do not invoke `writing-plans` or plan implementation before the change is ratified' "$SCRIPT_DIR/SKILL.md" } @@ -618,10 +618,13 @@ EOF grep -q "The user asks to create, update or approve product-anchor docs" "$SCRIPT_DIR/SKILL.md" } -@test "promotion marks its layout provisional and stops on a name collision" { - grep -q "The feature-root destination is provisional" "$SCRIPT_DIR/SKILL.md" - grep -q "issue #23" "$SCRIPT_DIR/SKILL.md" - grep -q "stop and ask the maintainer. Never overwrite a ratified document during promotion" "$SCRIPT_DIR/SKILL.md" +@test "promotion moves each change into its own directory and stops on a collision" { + local promotion + promotion=$(sed -n '/^### Promotion/,/^### Implementation Planning/p' "$SCRIPT_DIR/SKILL.md") + grep -q 'moves the change.s approved documents from `docs/product/shaping/{feature}--{change}/` into `docs/product/features/{feature}/changes/{change}/`' <<< "$promotion" + grep -q 'if `features/{feature}/changes/{change}/` already exists' <<< "$promotion" + grep -q "stop and ask the maintainer. Never overwrite a ratified document during promotion" <<< "$promotion" + refute_grep -q "provisional" <<< "$promotion" } @test "surface-specific scenarios are written before promotion and listed in the promotion PR" { @@ -685,13 +688,13 @@ EOF refute_grep -q "updated in place with a changelog" "$REPO_ROOT/plugins/product-development/README.md" refute_grep -q "^Update in place when" "$SCRIPT_DIR/docs/METHODOLOGY.md" refute_grep -q "Edit the document directly" "$SCRIPT_DIR/docs/METHODOLOGY.md" - grep -q "issue #23" "$SCRIPT_DIR/docs/METHODOLOGY.md" } @test "implementation planning loads ratified platform and app-local scenarios" { local planning planning=$(sed -n '/^### Implementation Planning/,/^## /p' "$SCRIPT_DIR/SKILL.md") - grep -q 'ratified platform scenarios from `docs/product/features/{feature}/scenarios/`' <<< "$planning" + grep -q 'its platform scenarios from `docs/product/features/{feature}/changes/{change}/scenarios/`' <<< "$planning" + grep -q 'the feature spec and shipped scenarios at the feature root' <<< "$planning" grep -q 'ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed' <<< "$planning" } diff --git a/plugins/product-development/tests/plugin-package.bats b/plugins/product-development/tests/plugin-package.bats index 8121c95..ba7e443 100644 --- a/plugins/product-development/tests/plugin-package.bats +++ b/plugins/product-development/tests/plugin-package.bats @@ -405,7 +405,7 @@ assert_adapter_files_are_thin() { assert_json_object_keys_equals "$PLUGIN_ROOT/plugin.json" "." "name" "version" "description" "author" "keywords" "skills" assert_json_object_keys_equals "$PLUGIN_ROOT/plugin.json" "author" "name" assert_json_field_equals "$PLUGIN_ROOT/plugin.json" "name" "product-development" - assert_json_field_equals "$PLUGIN_ROOT/plugin.json" "version" "0.1.0" + assert_json_field_equals "$PLUGIN_ROOT/plugin.json" "version" "0.2.0" assert_json_field_equals "$PLUGIN_ROOT/plugin.json" "description" "$EXPECTED_DESCRIPTION" assert_json_field_equals "$PLUGIN_ROOT/plugin.json" "author.name" "$EXPECTED_AUTHOR_NAME" assert_json_array_equals "$PLUGIN_ROOT/plugin.json" "keywords" "agent-skill" "product-development" "copilot-cli-plugin" @@ -414,7 +414,7 @@ assert_adapter_files_are_thin() { assert_json_object_keys_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "." "name" "version" "description" "author" "skills" assert_json_object_keys_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "author" "name" assert_json_field_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "name" "product-development" - assert_json_field_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "version" "0.1.0" + assert_json_field_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "version" "0.2.0" assert_json_field_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "description" "$EXPECTED_DESCRIPTION" assert_json_field_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "author.name" "$EXPECTED_AUTHOR_NAME" assert_json_array_equals "$PLUGIN_ROOT/.claude-plugin/plugin.json" "skills" "./skills/product-development" @@ -423,7 +423,7 @@ assert_adapter_files_are_thin() { assert_json_object_keys_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "author" "name" assert_json_object_keys_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "interface" "displayName" "shortDescription" "longDescription" "developerName" "category" "capabilities" "defaultPrompt" assert_json_field_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "name" "product-development" - assert_json_field_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "version" "0.1.0" + assert_json_field_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "version" "0.2.0" assert_json_field_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "description" "$EXPECTED_DESCRIPTION" assert_json_field_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "author.name" "$EXPECTED_AUTHOR_NAME" assert_json_array_equals "$PLUGIN_ROOT/.codex-plugin/plugin.json" "keywords" "agent-skill" "product-development" "codex-plugin" @@ -438,13 +438,13 @@ assert_adapter_files_are_thin() { assert_json_object_keys_equals "$PLUGIN_ROOT/gemini-extension.json" "." "name" "version" "description" assert_json_field_equals "$PLUGIN_ROOT/gemini-extension.json" "name" "product-development" - assert_json_field_equals "$PLUGIN_ROOT/gemini-extension.json" "version" "0.1.0" + assert_json_field_equals "$PLUGIN_ROOT/gemini-extension.json" "version" "0.2.0" assert_json_field_equals "$PLUGIN_ROOT/gemini-extension.json" "description" "$EXPECTED_DESCRIPTION" assert_json_object_keys_equals "$PLUGIN_ROOT/package.json" "." "name" "version" "description" "private" "keywords" "pi" assert_json_object_keys_equals "$PLUGIN_ROOT/package.json" "pi" "skills" assert_json_field_equals "$PLUGIN_ROOT/package.json" "name" "product-development" - assert_json_field_equals "$PLUGIN_ROOT/package.json" "version" "0.1.0" + assert_json_field_equals "$PLUGIN_ROOT/package.json" "version" "0.2.0" assert_json_field_equals "$PLUGIN_ROOT/package.json" "description" "$EXPECTED_DESCRIPTION" assert_json_boolean_equals "$PLUGIN_ROOT/package.json" "private" "false" assert_json_array_equals "$PLUGIN_ROOT/package.json" "keywords" "agent-plugin" "agent-skill" "product-development" "pi-package" From 3cb9ae53304b92209282427575748d1022f52095 Mon Sep 17 00:00:00 2001 From: John Lianoglou Date: Sun, 29 Nov 2026 19:36:22 -0500 Subject: [PATCH 03/15] feat(product-development): track open questions by what they block (#53) Adds the open-questions register: blocking levels (design, implementation, release, none yet) with their check points, resolution methods, OQ-N IDs with HTML anchors, what each question blocks, the deferral rule with approval record and cycle-safe chains, homes and the one-home rule, docs/product/open-questions.md scaffolded by init.sh, scripts/open-questions.py (index, check, blocking) with tests, a pre-ship Release Check workflow, and a worked example. Refs #37, #35 --- docs/development.md | 2 + .../skills/product-development/SKILL.md | 28 +- .../product-development/docs/METHODOLOGY.md | 1 + .../references/changes-and-deltas.md | 4 +- .../references/initialization.md | 1 + .../references/open-questions.md | 144 ++++ .../references/requirements.md | 14 +- .../product-development/scripts/init.sh | 1 + .../scripts/open-questions.py | 567 +++++++++++++ .../templates/AGENTS.md.tmpl | 5 +- .../templates/README.md.tmpl | 2 + .../templates/open-questions.md.tmpl | 25 + .../tests/fixtures/open-questions/README.md | 11 + .../2026-10-01-event-invitations/PRD.md | 14 + .../open-questions/bundle/open-questions.md | 22 + .../PRD.md | 16 + .../shaping.md | 15 + .../shared-calendars--invite-expiry/PRD.md | 22 + .../product-development/tests/init.bats | 43 + .../tests/open-questions.bats | 781 ++++++++++++++++++ 20 files changed, 1709 insertions(+), 9 deletions(-) create mode 100644 plugins/product-development/skills/product-development/references/open-questions.md create mode 100755 plugins/product-development/skills/product-development/scripts/open-questions.py create mode 100644 plugins/product-development/skills/product-development/templates/open-questions.md.tmpl create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/README.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/bundle/features/shared-calendars/changes/archive/2026-10-01-event-invitations/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/bundle/open-questions.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/bundle/shaping/shared-calendars--decline-with-note/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/bundle/shaping/shared-calendars--extend-invitations/shaping.md create mode 100644 plugins/product-development/skills/product-development/tests/fixtures/open-questions/bundle/shaping/shared-calendars--invite-expiry/PRD.md create mode 100644 plugins/product-development/skills/product-development/tests/open-questions.bats diff --git a/docs/development.md b/docs/development.md index 726b953..939d0cd 100644 --- a/docs/development.md +++ b/docs/development.md @@ -94,6 +94,7 @@ The init script scaffolds `docs/product/` from templates: | `docs/product/ideas/AGENTS.md` | `ideas/` stage guidance: no requirements authority, read only when named or through idea discovery | | `docs/product/shaping/AGENTS.md` | `shaping/` stage guidance: tentative context for the change being shaped, promotion rule | | `docs/product/features/AGENTS.md` | `features/` stage guidance: requirements, admitted only by a merged promotion PR | +| `docs/product/open-questions.md` | Product-wide open questions and the generated open-questions index (`scripts/open-questions.py`) | Files that already exist are never overwritten. Each file renders to a temp file beside it and is published with a hard link, so a concurrent run or a file @@ -137,6 +138,7 @@ nix develop -c bats tests/marketplace-package.bats nix develop -c bats plugins/product-development/tests/plugin-package.bats nix develop -c bats plugins/product-development/skills/product-development/tests/init.bats nix develop -c bats plugins/product-development/skills/product-development/tests/feature-evolution.bats +nix develop -c bats plugins/product-development/skills/product-development/tests/open-questions.bats nix develop -c bats plugins/delivery-engineering/tests/plugin-package.bats nix develop -c bats plugins/okf-bundle/tests/plugin-package.bats nix develop -c bats plugins/branch-guard/tests diff --git a/plugins/product-development/skills/product-development/SKILL.md b/plugins/product-development/skills/product-development/SKILL.md index 0863d16..e4077f3 100644 --- a/plugins/product-development/skills/product-development/SKILL.md +++ b/plugins/product-development/skills/product-development/SKILL.md @@ -1,6 +1,6 @@ --- name: product-development -description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, capture an idea, shape a change, run a spike, promote a change, plan implementation, record a ship signal, canonize a shipped change, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." +description: "Use when the user asks to create a feature, write a PRD or TRD, add user stories, write scenarios, create acceptance criteria, capture an idea, shape a change, run a spike, promote a change, plan implementation, run the pre-ship Release Check, execute a delivery-plan step (for example a rollout), record a ship signal, canonize a shipped change, initialize product docs, set up product documentation, create, approve, amend, or validate a Product Constitution, run the Constitution Grill, create or maintain Product Vision, run a Vision Grill, or work anywhere in the product development lifecycle from project setup through implementation planning." --- # Product Development Lifecycle @@ -33,6 +33,8 @@ BDD Scenarios ← drafted in shaping/ Promotion ← overlap check; promotion PR moves the change to features/{feature}/changes/{change}/ ↓ [maintainer merges = ratification] Implementation Planning ← idea discovery first; plans from the ratified change + ↓ +Release Check ← release-level open-questions check, before the ship signal ↓ [project's ship signal fires] → Shipped entry in the feature log Canonization ← base check; deltas applied to the feature spec; change archived ``` @@ -83,8 +85,9 @@ Consult `references/feature-bundles.md` for the bundle layout, spec units, the O - `docs/product/README.md` — documentation hierarchy and boundary rules - `docs/product/AGENTS.md` — agent guidance for organizing product docs - `docs/product/ideas/AGENTS.md`, `docs/product/shaping/AGENTS.md`, `docs/product/features/AGENTS.md` — the three stage directories, each with its agent guidance +- `docs/product/open-questions.md` — the register of product-wide open questions and the generated open-questions index -**This workflow runs once per project.** Skip only when every scaffold file exists: `docs/product/README.md`, `docs/product/AGENTS.md`, `docs/product/ideas/AGENTS.md`, `docs/product/shaping/AGENTS.md` and `docs/product/features/AGENTS.md`. If any is missing, for example after an interrupted run, re-run `scripts/init.sh`. It never overwrites, so it fills only the gaps. +**This workflow runs once per project.** Skip only when every scaffold file exists: `docs/product/README.md`, `docs/product/AGENTS.md`, `docs/product/ideas/AGENTS.md`, `docs/product/shaping/AGENTS.md`, `docs/product/features/AGENTS.md` and `docs/product/open-questions.md`. If any is missing, for example after an interrupted run, re-run `scripts/init.sh`. It never overwrites, so it fills only the gaps. ### Foundation workflow @@ -169,7 +172,7 @@ An early idea that nobody is shaping yet goes to `docs/product/ideas/` instead, **Trigger:** Scenarios are reviewed and cover the acceptance criteria. -**Process:** Run the overlap check (`references/changes-and-deltas.md`) and put its report in the promotion PR. Open a promotion PR that moves the change's approved documents from `docs/product/shaping/{feature}--{change}/` into `docs/product/features/{feature}/changes/{change}/`, sets their OKF `status` to `stable`, and adds a Ratified entry to the feature log. For a new feature, the PR also creates the feature bundle: a metadata-only feature overview that claims no behavior, `log.md` and `changes/`. The first canonization writes the complete overview and the facet specs (`references/feature-bundles.md`). The maintainer reviews it and orders or combines any overlapping changes. Run the overlap check again just before the PR merges. Merging the promotion PR ratifies the change; the merge is the approval record. Code alone never admits a spec, so a change whose code has already shipped still goes through promotion. +**Process:** Run the overlap check (`references/changes-and-deltas.md`) and put its report in the promotion PR. Open a promotion PR that moves the change's approved documents from `docs/product/shaping/{feature}--{change}/` into `docs/product/features/{feature}/changes/{change}/`, sets their OKF `status` to `stable`, and adds a Ratified entry to the feature log. For a new feature, the PR also creates the feature bundle: a metadata-only feature overview that claims no behavior, `log.md` and `changes/`. The first canonization writes the complete overview and the facet specs (`references/feature-bundles.md`). The maintainer reviews it and orders or combines any overlapping changes. Run the overlap check again just before the PR merges. At both points, also run the design-level open-questions check (`references/open-questions.md`): no open `design` or `none yet` question may name the change unless the maintainer approved its deferral. Merging the promotion PR ratifies the change; the merge is the approval record. Code alone never admits a spec, so a change whose code has already shipped still goes through promotion. The promotion PR also lists each app-local scenario file under `apps/{surface}/docs/features/{feature}/scenarios/` that it adds or changes, so the maintainer ratifies surface-specific scenarios with the rest of the change. @@ -183,10 +186,20 @@ Check for collisions before moving anything: if `features/{feature}/changes/{cha **Trigger:** The change's promotion PR has merged. -**Process:** Run idea discovery first. Load the approved constitution and approved vision, the ratified change in `docs/product/features/{feature}/changes/{change}/` with its platform scenarios from `docs/product/features/{feature}/changes/{change}/scenarios/`, the feature spec and shipped scenarios at the feature root, and the ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed. Read each app-local scenario as it stood at that PR's merge commit, resolved from the PR (`git show :`), because a later change may already be editing the working copy. Then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. +**Process:** Run idea discovery first. Load the approved constitution and approved vision, the ratified change in `docs/product/features/{feature}/changes/{change}/` with its platform scenarios from `docs/product/features/{feature}/changes/{change}/scenarios/`, the feature spec and shipped scenarios at the feature root, and the ratified app-local scenarios under `apps/{surface}/docs/features/{feature}/scenarios/` that the merged promotion PR listed. Read each app-local scenario as it stood at that PR's merge commit, resolved from the PR (`git show :`), because a later change may already be editing the working copy. Then invoke the `writing-plans` skill. It creates a detailed, task-by-task implementation plan with TDD steps, file paths, and verification criteria. Before the handoff is sent to implementation, run the implementation-level open-questions check (`references/open-questions.md`): no open `design`, `implementation` or `none yet` question may name the change unless its deferral is approved. Stop before planning if the plan would violate `MUST NOT` language, weaken a constitutional principle, conflict with the approved vision, or exceed clear authority. **Output:** Implementation plan at `docs/plans/YYYY-MM-DD-.md`. +### Release Check + +**Trigger:** Someone is about to fire the ship signal for a ratified change (merge the implementation PR, cut the release, or widen the feature flag to everyone, whichever the project names), or to execute a step in the delivery plan. + +**Process:** Whoever will fire the ship signal runs the release-level open-questions check (`references/open-questions.md`), `scripts/open-questions.py blocking docs/product {feature}/{change} --level release`: no open `design`, `implementation`, `release` or `none yet` question may name the change unless its deferral is approved. When merging the implementation PR is the ship signal, the implementation workflow runs this check before that merge. + +Release questions can also name a delivery-plan step, by path and anchor. Before executing a delivery-plan step, run the same check on the step: `scripts/open-questions.py blocking docs/product roadmap.md#broader-rollout --level release`. When that step fires a change's ship signal, run both checks, the change's and the step's. + +**Gate:** Do not fire the ship signal until its checks pass, and do not execute a delivery-plan step until its check passes. + ### Ship Signal and Canonization **Trigger:** The project's ship signal fires for a ratified change: the event the project names as making a change live, such as the implementation PR merging, a release, or a feature flag reaching everyone. @@ -307,7 +320,7 @@ Not every feature starts at the beginning. Match the entry point to the current | Starting point | Enter at | |---------------|----------| -| No `docs/product/` directory, or any scaffold file missing (`README.md`, `AGENTS.md`, or a stage `AGENTS.md`) | Project Setup | +| No `docs/product/` directory, or any scaffold file missing (`README.md`, `AGENTS.md`, a stage `AGENTS.md`, or `open-questions.md`) | Project Setup | | Missing, unapproved, or unversioned constitution or vision before first PRD | Foundation workflow | | Early idea nobody is shaping yet | Record it in `ideas/` | | Vague idea, no clarity on approach | Discovery and Design | @@ -317,6 +330,8 @@ Not every feature starts at the beginning. Match the entry point to the current | Discovery suggests the work may evolve an existing feature | Discovery and Design: classify the work first | | Approved change in `shaping/`, not yet ratified | Promotion | | Ratified change in `features/{feature}/changes/`, needs implementation | Implementation Planning | +| About to fire the ship signal for a ratified change | Release Check | +| About to execute a step in the delivery plan | Release Check | | Ship signal fired for a ratified change | Ship Signal and Canonization | | Code exists with no spec | Discovery and Design (code alone never admits a spec) | @@ -356,6 +371,7 @@ Detailed guidance for each workflow lives in reference files to keep context tar - **`references/feature-bundles.md`** — Feature bundle layout, feature spec and spec units, OKF `status` mapping, feature log and lineage log - **`references/changes-and-deltas.md`** — The change and delta contract, change states, overlap and base checks, worked examples - **`references/requirements.md`** — PRD and TRD structure, conventions, constitution and vision checks +- **`references/open-questions.md`** — Open questions: blocking levels and their check points, resolution methods, IDs and anchors, deferral, homes and the generated index - **`references/user-stories.md`** — Story format, acceptance criteria, sizing - **`references/bdd-scenarios.md`** — Gherkin conventions, boundary rule, file placement - **`docs/METHODOLOGY.md`** — Specification evolution strategies, the change model, feature log conventions @@ -365,10 +381,12 @@ Load `references/source/product-constitution-guide.md` only through `references/ ## Scripts - **`scripts/init.sh`** — Project initialization script. Scaffolds `docs/product/` from templates with placeholder substitution. Supports interactive prompts, CLI arguments, and `--dry-run`. +- **`scripts/open-questions.py`** — Generates the open-questions index in `docs/product/open-questions.md`, checks it in CI, and lists the open questions that hold a change at a check point. See `references/open-questions.md`. ## Templates - **`templates/README.md.tmpl`** — Documentation hierarchy template - **`templates/AGENTS.md.tmpl`** — Agent guidance template - **`templates/ideas/AGENTS.md.tmpl`**, **`templates/shaping/AGENTS.md.tmpl`**, **`templates/features/AGENTS.md.tmpl`** — Stage guidance: each stage's authority, and when agents read it or stay out +- **`templates/open-questions.md.tmpl`** — The product-wide open-questions register with its index markers - **`templates/documents/`** — Document templates the agent copies: feature spec overview and facet, delta, feature log and lineage log diff --git a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md index 9e39319..35452c8 100644 --- a/plugins/product-development/skills/product-development/docs/METHODOLOGY.md +++ b/plugins/product-development/skills/product-development/docs/METHODOLOGY.md @@ -110,6 +110,7 @@ The specification is tied to automated tests. When behavior changes, the specifi | User Stories | Change record, then current state | The change's `stories/`, then the feature root's `stories/` at canonization | Unshipped stories never sit beside shipped ones | | Platform Scenarios | Living + self-verifying | The change's `scenarios/`, then the feature root's `scenarios/` at canonization | Executable behavioral contracts | | Surface Scenarios | Living + self-verifying | `apps/{surface}/docs/features/{feature}/scenarios/` | Surface-specific executable contracts | +| Open questions | Removed when answered; index generated | Each document's Open Questions table; product-wide ones in `docs/product/open-questions.md` | The answer moves into the spec, an ADR or the feature log, so it has one home | | Feature log, lineage log | Append-only | `features/{feature}/log.md`, `features/log.md` | History and reasons | ## Feature Log Conventions diff --git a/plugins/product-development/skills/product-development/references/changes-and-deltas.md b/plugins/product-development/skills/product-development/references/changes-and-deltas.md index ae7ff3a..4f93d97 100644 --- a/plugins/product-development/skills/product-development/references/changes-and-deltas.md +++ b/plugins/product-development/skills/product-development/references/changes-and-deltas.md @@ -246,6 +246,8 @@ The overlap check finds concurrent changes that target the same spec units, so t | FR-12 | adds "Decline notes" | invite-expiry adds "Invitation expiry" | Ratified | ``` +The design-level open-questions check runs at the same two points: no open `design` or `none yet` question may name the change unless its deferral is approved ([open-questions.md](open-questions.md)). + **Resolve:** the maintainer either orders the changes, so the later one is rebased at its canonization, or combines them into one change. Two changes adding the same ID always end with one of them renumbered before its promotion PR merges. When no overlap is found, the promotion PR says so in one line. ## Base check @@ -307,7 +309,7 @@ The skill's test fixture, `tests/fixtures/two-canonizations/`, runs exactly thes ## Shipping and canonization -Each project names its **ship signal**, the event that makes a change live: a merge to the default branch, a release, a feature flag reaching everyone. When it fires, a Shipped entry in the feature log records the evidence. The change stays in `changes/{change}/`; it is now Shipped, and canonization is due. +Each project names its **ship signal**, the event that makes a change live: a merge to the default branch, a release, a feature flag reaching everyone. Before it fires, whoever fires it runs the release-level open-questions check ([open-questions.md](open-questions.md)); when merging the implementation PR is the ship signal, the implementation workflow runs it before that merge. When it fires, a Shipped entry in the feature log records the evidence. The change stays in `changes/{change}/`; it is now Shipped, and canonization is due. **Canonization** makes the shipped change part of the feature spec. It accounts for each requirement, scenario and `DOCUMENT` entry in the change as shipped, changed or deferred, runs the base check, applies the deltas as reconciled with that accounting, moves the story and scenario files the reconciled deltas list to the feature root, archives the change to `changes/archive/YYYY-MM-DD-{change}/` dated the day of canonization, and writes a Canonized entry in the feature log. Deferred units, including deferred story and scenario files, are left out of the spec and become shaping items; changed units carry the text the maintainer approved. The archive keeps the content of the ratified deltas as approved; canonization changes only their OKF `status`, from `stable` to `deprecated`, as it does for every document in the archived change. diff --git a/plugins/product-development/skills/product-development/references/initialization.md b/plugins/product-development/skills/product-development/references/initialization.md index 24102d1..c004c97 100644 --- a/plugins/product-development/skills/product-development/references/initialization.md +++ b/plugins/product-development/skills/product-development/references/initialization.md @@ -13,6 +13,7 @@ Set up the `docs/product/` directory structure for a project that will use the p | `docs/product/ideas/AGENTS.md` | `ideas/` stage: early sketches with no requirements authority | | `docs/product/shaping/AGENTS.md` | `shaping/` stage: changes being worked out, including draft PRDs and TRDs | | `docs/product/features/AGENTS.md` | `features/` stage: ratified changes and shipped feature specs | +| `docs/product/open-questions.md` | Product-wide open questions and the generated index of every open or deferred question (`references/open-questions.md`) | Each stage directory gets its own `AGENTS.md` that says when agents read the stage and when they stay out. Files that already exist are skipped — the script never overwrites. If any scaffold file is missing, for example after an interrupted run, run the script again: it creates only the missing files. A stage directory that already exists keeps its content and gains an `AGENTS.md` only if it has none. diff --git a/plugins/product-development/skills/product-development/references/open-questions.md b/plugins/product-development/skills/product-development/references/open-questions.md new file mode 100644 index 0000000..fe1677a --- /dev/null +++ b/plugins/product-development/skills/product-development/references/open-questions.md @@ -0,0 +1,144 @@ +# Open Questions + +Load this reference when you record, defer, answer or check an open question in any product document, or regenerate the open-questions index. Terms follow the skill's glossary, [CONTEXT.md](../CONTEXT.md). + +An open question is an unchecked assumption or an undecided choice. It is recorded in the one document it concerns, together with what it blocks and how it will be answered. A question that should stop ratification must look different from one that can wait until after launch, so every question carries a blocking level. + +## What each question records + +### Blocking level + +What the question holds back, and when that is checked: + +| Blocking level | Blocks | Checked | +|----------------|--------|---------| +| `design` | Ratification of the change | When the promotion PR is prepared, and again just before it merges | +| `implementation` | Sending the handoff | Before the handoff is sent | +| `release` | The ship decision, or a step in the delivery plan | Before the ship signal fires, by whoever fires it. When merging the implementation PR is the ship signal, the implementation workflow checks before that merge. A step in the delivery plan is checked before the step is executed. | +| `none yet` | Nothing yet | Must be classified before the change's next check | + +A check passes when no open question that names its target sits at the checked level or an earlier one, and none is `none yet`. A design-level question that is still open at the handoff fails that check too: the change was ratified with it settled or deferred, so an open one means it was added later and needs a decision before work goes on. An approved deferral satisfies the check. + +The checks themselves, and how the maintainer works through the questions they find, belong to the ratification and handoff workflows. This reference defines what they check. + +### Resolution method + +How the question gets answered: + +- `research`: reading, interviews or analysis. +- `spike`: a disposable prototype (`references/idea-discovery-and-spikes.md`). +- `maintainer decision`: the maintainer chooses. +- `measurement after shipping`: data gathered once the change is live. + +A question answered by measurement after shipping can't block that same ship decision. It is classified as `none yet`, or as `release` for a later step in the delivery plan. As a `release` question it names only delivery-plan steps, by path and anchor outside any change's documents, never a change, so a product-wide one can't hold the ship it measures. + +### What it applies to + +Each question names what it blocks, in its Blocks cell: + +- `this change`, for a question in a change's own documents (its shaping document, PRD or TRD). It means the change the document belongs to, `{feature}/{change}`, so the meaning survives the move from `shaping/` to `features/` at promotion. +- `this document`, for a document's own questions, such as a question in the vision. A question scoped to one of a change's documents, by `this document` or by the document's path, also holds that change's checks. +- A change by name, `{feature}/{change}`, or a step in the delivery plan by path and anchor, such as `roadmap.md#invitation-extension`. Separate several targets with commas. + +A product-wide release question blocks only the targets it names. A question about regional sender rules for expiry notices that names `shared-calendars/invite-expiry` holds that change's ship decision and no other. + +## Identity + +Each question has an ID that is unique within its document, for example `OQ-3`, and its table row starts with an HTML anchor, ``, because a table row creates no link target on its own. Elsewhere it is referred to as `#oq-3`, as a link. A new question takes the next never-issued number in its document. Answered questions leave the table, so check the document's Git history for the highest number ever issued (`git log --follow -p -- `, which follows it across committed moves), not just the rows that remain. If the document was moved but the move is not yet committed, also check the history of its prior path. Numbers are not reused, so an old link never points at a different question. + +When a document moves, links to its questions are updated like any other link in the bundle. The index generator refuses to run while any link to a question anchor does not resolve, which catches the ones that weren't. + +## The table + +Every document with open questions holds them in one table under an `## Open Questions` heading, with exactly these columns: + +```markdown +## Open Questions + +| ID | Question | Blocking level | Blocks | Resolution | Deferred to | Approval | +|----|----------|----------------|--------|------------|-------------|----------| +| OQ-1 | Is 14 days the right expiry period for every calendar? | design | this change | maintainer decision | — | — | +``` + +- **Blocking level** and **Resolution** take the values above. +- **Deferred to** and **Approval** stay `—` until the question is deferred. +- A document with no open questions keeps the heading and the header row, or drops the section. +- A table under an `## Open Questions` heading, a table whose first columns are `ID` and `Question`, or a table with a row carrying a question ID is an open-questions table, and its header must match these columns exactly, so a typo such as `Blocking Level` is refused instead of hiding the table's questions. +- A table counts with or without its outer pipes, as GitHub renders it either way. It ends where GitHub ends it: at a blank line, or at a line that starts a blockquote, heading, list item or code fence. + +The PRD and TRD templates in `references/requirements.md` use this table. + +## Deferral + +Deferring a question means recording it, getting maintainer approval, and naming the target: a shaping item, a later change, or a step in the delivery plan. The question's row records the target in **Deferred to**, as a link to the target's row (`[