Product Discovery & PRD Document Structure Specification

This reference specification defines the canonical directory topology, file naming conventions, YAML frontmatter schema (PRDFrontmatter), Markdown Abstract Syntax Tree (AST) section grammar, falsifiability linting rules (PRDLinter), stage-gate promotion workflows, and REGISTRY.md table schema for Product Requirements Documents (PRDs) in SpecOps (Research Area 2, governed by ADR-0001, ADR-0008, and ADR-0022).


1. Directory Topology & Lifecycle Stages

All Product Requirements Documents and product-level discovery indices reside under docs/project/product/:


docs/project/product/
β”œβ”€β”€ REGISTRY.md                      # Canonical index of all PRDs across stages
β”œβ”€β”€ uat-signoff.json                 # Customer UAT acceptance sign-off ledger (optional)
β”œβ”€β”€ idea/                            # Stage 1: Raw discovery drafts & problem framing
β”‚   └── prd-XXXX-<slug>.md
β”œβ”€β”€ shaped/                          # Stage 2: Shaped scope, anti-goals & outcomes
β”‚   └── prd-XXXX-<slug>.md
β”œβ”€β”€ accepted/                        # Stage 3: Active engineering & BDD decomposition
β”‚   └── prd-XXXX-<slug>.md
└── shipped/                         # Stage 4: 100% delivered & verified capabilities
    └── prd-XXXX-<slug>.md

Lifecycle Stages & Promotion Gates

PRDs progress monotonically through four directory-backed lifecycle stages managed by PRDLifecycleManager (src/spec_ops/prd/lifecycle.py) and ship_prd (src/spec_ops/prd/shipping.py):

Stage Directory Frontmatter status Entry / Promotion Gate Criteria CLI Transition Command
idea/ Idea Initial discovery draft scaffolded with target persona and initial problem context. spec-ops prd new / spec-ops prd discover
shaped/ Shaped Document must contain a user pain-point heading matching `^##\s+(Who this is for\ Problem Statement\ What the person cannot do today)`. spec-ops prd promote PRD-XXXX --stage shaped
accepted/ Accepted 1. target_persona is mapped (not empty, unmapped, none, or unknown).
2. ## Checkable Outcomes exists and defines at least one outcome.
3. All checkable outcomes pass PRDLinter falsifiability checks with zero subjective terms.
spec-ops prd promote PRD-XXXX --stage accepted
shipped/ Shipped 1. 100% of linked/governing backlog tasks (TASK-XXXX) have status Complete.
2. Linked BDD user stories (US-XXXX) pass frontdoor test verification.
3. Updates REGISTRY.md, closes active horizon in ROADMAP.md, and emits dist/releases/PRD-XXXX-release-manifest.json.
spec-ops prd ship PRD-XXXX

When a PRD is promoted across stages, PRDLifecycleManager.promote() atomically:

  1. Rewrites the status: field in YAML frontmatter to the capitalized stage name (Idea, Shaped, Accepted, or Shipped).
  2. Moves the Markdown file from its previous stage directory to docs/project/product// and unlinks the old path.
  3. Synchronizes the corresponding row in docs/project/product/REGISTRY.md.

2. File Naming & Numbering Conventions

PRD files must adhere to strict naming and numbering invariants enforced by src/spec_ops/core/numbering.py:

  1. Filename stem: regex ^(?:prd-)?(\d+) (case-insensitive).
  2. YAML frontmatter id field: regex (?m)^\sid:\s['"]?(?:PRD-)?(\d+)['"]?\s*$.
  3. Markdown H1 heading: regex #\s*PRD-(\d+).

3. YAML Frontmatter Schema (`PRDFrontmatter`)

Every PRD file must begin on line 1 with a YAML frontmatter block delimited by --- lines. Frontmatter is validated against PRDFrontmatter in src/spec_ops/core/schema_validator.py (Schema v2.0).


---
id: '0008'
title: Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine
status: Accepted
created: 2026-10-15
target_persona: Alex (The Agentic Systems Architect) & Morgan (The Autonomous Coding Agent)
component: core
---

Field Reference

Field Type Required Default Description & Validation Rules
id `str \ int (Any`) Yes β€” 4-digit identifier string ('0008') or canonical ID ('PRD-0008'). Normalized by parse_prd() to PRD-XXXX.
title str Yes β€” Human-readable title of the product capability or initiative.
status str Optional "Accepted" Lifecycle state (Idea, Shaped, Accepted, or Shipped). Should match the parent stage directory.
created `date \ str \ None (Any`) Optional None ISO-8601 creation date (YYYY-MM-DD).
target_persona str Yes β€” Target user archetype(s) mapped from docs/project/user_stories/PERSONAS.md. Must not be empty, unmapped, none, or unknown.
component str Yes β€” Primary target bounded context or architectural component (e.g., core, prd, security, worker, adopt).

Strict `extra="forbid"` Policy (What Can and Cannot Be Tracked)

PRDFrontmatter configures model_config = ConfigDict(extra="forbid"). Any unrecognized YAML key triggers a SchemaDiagnosticError (extra_forbidden) with exact line and column pointers during uv run spec-ops schema check.


4. Markdown Body AST Grammar

Following the closing --- frontmatter delimiter, the Markdown body must conform to the structural AST grammar enforced by PRDLinter (src/spec_ops/prd/linter.py) and extracted by parse_prd() (src/spec_ops/core/parser.py).

Canonical Document Template


# PRD-0008 β€” Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine

## Who this is for

- **Alex (The Agentic Systems Architect)**: Needs a formal, self-describing grammar for project documents.

## What the person cannot do today

- Document contracts are implicitly scattered across regexes in multiple modules.

## What good looks like

1. **Declarative Grammar Engine**:
   - Unified validation of YAML frontmatter and Markdown AST sections.

## What this does not do

- Does not replace standard Markdown or YAML syntax with a proprietary binary format.

## Checkable Outcomes

1. Five comprehensive reference specification documents exist under `docs/reference/specs/` and `uv run spec-ops docs build` compiles them with zero warnings.
2. Running `uv run spec-ops schema check` validates YAML frontmatter across `docs/project/` and exits with code 0.

## Linked User Stories

- `US-0133`
- `US-0134`

## Implementing Backlog Tasks

- `TASK-0259`
- `TASK-0261`

Section Grammar Rules

Section Heading Requirement Linter / Parser Regex AST Content Contract
# PRD-XXXX β€” </code></td> <td>Required H1</td> <td><code>#\s*PRD-(\d+)</code></td> <td>Top-level title matching the frontmatter <code>id</code> and <code>title</code>.</td> </tr> <tr> <td><code>## Who this is for</code> <em>(or <code>## Problem Statement</code>)</em></td> <td><strong>Mandatory H2</strong> (<code>PRDLinter</code>)</td> <td>`^##\s+(Who this is for\</td> <td>Problem Statement)\b`</td> <td>Identifies the target persona(s) from <code>PERSONAS.md</code> and their operational context.</td> </tr> <tr> <td><code>## What the person cannot do today</code></td> <td><strong>Mandatory H2</strong> (<code>parse_prd</code> & <code>shaped</code> gate)</td> <td>`^##\s+What the person cannot do today\s<em>\n(.</em>?)(?=\n##\</td> <td>\Z)`</td> <td>Extracted verbatim into <code>PRD.problem_statement</code> by <code>parse_prd()</code>. Describes concrete user friction and pain points.</td> </tr> <tr> <td><code>## What good looks like</code></td> <td><strong>Mandatory H2</strong> (<code>PRDLinter</code>)</td> <td><code>^##\s+What good looks like\b</code></td> <td>Enumerates the core capabilities and desired end-state architecture.</td> </tr> <tr> <td><code>## What this does not do</code></td> <td><strong>Mandatory H2</strong> (<code>PRDLinter</code>)</td> <td><code>^##\s+What this does not do\b</code></td> <td>Explicit anti-goals, non-goals, and scope boundaries preventing multi-agent scope creep.</td> </tr> <tr> <td><code>## Checkable Outcomes</code></td> <td><strong>Mandatory H2</strong> (<code>PRDLinter</code> & <code>parse_prd</code>)</td> <td><code>^##\s+Checkable Outcomes\b</code></td> <td>Contains 1 or more numbered (<code>1. </code>) or bulleted (<code>- </code> or <code>* </code>) list items. Extracted into <code>PRD.outcomes</code>. HTML comments (<code><!-- ... --></code>) are stripped prior to validation.</td> </tr> <tr> <td><code>## Linked User Stories</code></td> <td>Standard H2 (<code>parse_prd</code>)</td> <td><code>US-(\d+)</code> (global document scan)</td> <td>Bullet list of <code>US-XXXX</code> identifiers normalized and deduplicated into <code>PRD.linked_stories</code>.</td> </tr> <tr> <td><code>## Implementing Backlog Tasks</code></td> <td>Standard H2 (<code>parse_prd</code>)</td> <td><code>TASK-(\d+)</code> (global document scan)</td> <td>Bullet list of <code>TASK-XXXX</code> identifiers normalized and deduplicated into <code>PRD.implementing_tasks</code>.</td> </tr> </tbody></table></div> <hr /> <h2>5. Falsifiability Linter Grammar (`spec-ops prd lint`)</h2> <p>To prevent vague, untestable requirements from entering engineering decomposition, <code>PRDLinter</code> (<code>src/spec_ops/prd/linter.py</code>) inspects every list item under <code>## Checkable Outcomes</code>.</p> <h3>Outcome Extraction Grammar</h3> <ol> <li>The linter locates the line matching <code>^##\s+Checkable Outcomes\b</code> (case-insensitive).</li> <li>It scans subsequent lines until the next <code>^##\s+</code> H2 heading or end-of-file.</li> <li>Blank lines and standalone HTML comment lines (<code><!-- ... --></code>) are skipped.</li> <li>Every list item matching <code>^(\d+\.|\-|\*)\s+(.+)$</code> has inline HTML comments removed and is evaluated by <code>PRDLinter.check_subjective_terms()</code>.</li> <li>If zero list items are found under <code>## Checkable Outcomes</code>, the linter emits a violation: <code>"No checkable outcomes defined"</code>.</li> </ol> <h3>Forbidden Compound Phrases (`COMPOUND_PHRASES`)</h3> <p>Checked first via case-insensitive regular expressions:</p> <div class="table-wrapper"><table><thead><tr> <th>Regex Pattern</th> <th>Matched Phrase</th> </tr></thead><tbody> <tr> <td><code>\bclean\s+and\s+modern\b</code></td> <td><code>"clean and modern"</code></td> </tr> <tr> <td><code>\bfast\s+and\s+responsive\b</code></td> <td><code>"fast and responsive"</code></td> </tr> <tr> <td><code>\bsimple\s+and\s+intuitive\b</code></td> <td><code>"simple and intuitive"</code></td> </tr> <tr> <td><code>\bintuitive\s+and\s+easy\b</code></td> <td><code>"intuitive and easy"</code></td> </tr> <tr> <td><code>\beasy\s+to\s+use\b</code></td> <td><code>"easy to use"</code></td> </tr> <tr> <td><code>\bnoticeably\s+faster\b</code></td> <td><code>"noticeably faster"</code></td> </tr> </tbody></table></div> <h3>Forbidden Subjective Words (`SUBJECTIVE_WORDS`)</h3> <p>Checked second via whole-word boundary regex <code>\b(<word>)\b</code> (case-insensitive):</p> <ul> <li><code>clean</code>, <code>modern</code>, <code>intuitive</code>, <code>fast</code>, <code>faster</code>, <code>responsive</code></li> <li><code>simple</code>, <code>easy</code>, <code>seamless</code>, <code>user-friendly</code>, <code>user friendly</code>, <code>robust</code></li> <li><code>beautiful</code>, <code>elegant</code>, <code>smooth</code>, <code>frictionless</code>, <code>delightful</code></li> </ul> <p>When any forbidden phrase or word is detected in a checkable outcome, <code>PRDLinter</code> marks <code>is_falsifiable=False</code> and emits a line-accurate <code>LintViolation</code>:</p> <ul> <li><strong>Message</strong>: <code>Subjective adjective '<term>' is unfalsifiable</code></li> <li><strong>Guidance</strong>: <code>Replace subjective adjectives with measurable frontdoor criteria or observable CLI/API assertions</code></li> </ul> <hr /> <h2>6. Product Registry Specification (`docs/project/product/REGISTRY.md`)</h2> <p><code>docs/project/product/REGISTRY.md</code> maintains the single-table index of all PRDs across <code>idea/</code>, <code>shaped/</code>, <code>accepted/</code>, and <code>shipped/</code>. It is updated atomically whenever <code>PRDLifecycleManager.update_registry()</code> or <code>update_registry_shipped()</code> executes.</p> <h3>Table Structure & Column Grammar</h3> <pre><code class="language-markdown"> # PRD Registry | ID | Title | Status | Target Persona | Component | |---|---|---|---|---| | `PRD-0001` | SpecOps Autonomous Project Management Engine | Shipped | Alex | core | | `PRD-0003` | Product Discovery, Web PRD Studio & Living UAT Verification | Accepted | Taylor | prd | | `PRD-0008` | Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine | Accepted | Alex, Morgan, Riley | core | </code></pre> <div class="table-wrapper"><table><thead><tr> <th>Column Index</th> <th>Column Header</th> <th>Format Contract</th> <th>Source Field</th> </tr></thead><tbody> <tr> <td><code>1</code></td> <td><code>ID</code></td> <td>Backtick-wrapped canonical ID: `<code> </code>PRD-XXXX<code> </code>`</td> <td>Normalized <code>PRDFrontmatter.id</code></td> </tr> <tr> <td><code>2</code></td> <td><code>Title</code></td> <td>Plain text title</td> <td><code>PRDFrontmatter.title</code></td> </tr> <tr> <td><code>3</code></td> <td><code>Status</code></td> <td>Title-case lifecycle stage (<code>Idea</code>, <code>Shaped</code>, <code>Accepted</code>, <code>Shipped</code>)</td> <td><code>PRDFrontmatter.status</code> / directory stage</td> </tr> <tr> <td><code>4</code></td> <td><code>Target Persona</code></td> <td>Persona name(s)</td> <td><code>PRDFrontmatter.target_persona</code></td> </tr> <tr> <td><code>5</code></td> <td><code>Component</code></td> <td>Bounded context / component slug</td> <td><code>PRDFrontmatter.component</code></td> </tr> </tbody></table></div> <p>When parsing or updating <code>REGISTRY.md</code>, rows are split on <code>|</code> (<code>len(parts) == 7</code> including leading and trailing empty cells) and matched case-insensitively by stripping backticks from Column 1 (<code>parts[1].replace("</code>", "").upper() == clean_id`).</p> <hr /> <h2>7. Customer UAT Ledger & Release Manifest Artifacts</h2> <p>During the <code>accepted</code> and <code>shipped</code> lifecycle stages, SpecOps tracks outcome-level business acceptance and cryptographic release provenance through two companion JSON artifacts:</p> <h3>Customer UAT Sign-Off Ledger (`docs/project/product/uat-signoff.json`)</h3> <p>Recorded via <code>uv run spec-ops prd uat sign --prd PRD-XXXX --outcome <N> --reviewer "<Name>" --status Approved</code>:</p> <pre><code class="language-json"> { "signoffs": { "PRD-0008:1": { "prd_id": "PRD-0008", "outcome_id": "1", "status": "Approved", "reviewer": "Taylor (The Product Manager)", "notes": "Verified via frontdoor tests", "signed_at": "2026-10-15T12:00:00Z" } } } </code></pre> <p><code>reconcile_shipping_uat_status()</code> (<code>src/spec_ops/prd/shipping.py</code>) matches each 1-indexed outcome extracted from <code>## Checkable Outcomes</code> against keys formatted as <code><PRD-ID>:<OUTCOME-INDEX></code>.</p> <h3>Shipped Release Manifest (`dist/releases/PRD-XXXX-release-manifest.json`)</h3> <p>Synthesized automatically when <code>uv run spec-ops prd ship PRD-XXXX</code> succeeds:</p> <ul> <li><code>$schema</code>: <code>"spec-ops/release-manifest-v1"</code></li> <li><code>prd</code>: <code>{ "id": "PRD-XXXX", "title": "...", "persona": "..." }</code></li> <li><code>completed_tasks</code>: Array of <code>{ "id": "TASK-XXXX", "commit_sha": "<40-hex-sha>" }</code></li> <li><code>test_verification</code>: <code>{ "status": "Passed (CI)", "total_scenarios": <int>, "failed_scenarios": 0 }</code></li> <li><code>uat_verification</code>: <code>{ "status": "Approved" | "Pending PM", "total_outcomes": <int>, "approved_outcomes": <int> }</code></li> </ul> <hr /> <h2>8. CLI & Programmatic Frontdoors</h2> <h3>Command-Line Interface</h3> <p>Use the following public CLI commands to scaffold, lint, validate, and promote PRD specifications:</p> <pre><code class="language-bash"> # Scaffold a new PRD in docs/project/product/idea/ uv run spec-ops prd new --title "Capability Title" --persona "Alex" --component "core" --non-interactive # Lint all PRDs or a specific PRD file for required sections and falsifiable outcomes uv run spec-ops prd lint uv run spec-ops prd lint docs/project/product/accepted/prd-0008-formal-specification-grammar--document-metamo.md # Validate PRD YAML frontmatter against PRDFrontmatter schema v2.0 uv run spec-ops schema check docs/project/product/ # Promote a PRD across lifecycle gates and ship upon completion uv run spec-ops prd promote PRD-0008 --stage shaped uv run spec-ops prd promote PRD-0008 --stage accepted uv run spec-ops prd ship PRD-0008 </code></pre> <h3>Python Domain & Linter Frontdoors</h3> <pre><code class="language-python"> from pathlib import Path from spec_ops.core.parser import parse_prd from spec_ops.core.schema_validator import validate_document from spec_ops.prd.linter import PRDLinter prd_path = Path("docs/project/product/accepted/prd-0008-formal-specification-grammar--document-metamo.md") # 1. Parse PRD into domain model (PRD.id, PRD.problem_statement, PRD.outcomes, PRD.linked_stories) prd = parse_prd(prd_path) # 2. Validate YAML frontmatter against PRDFrontmatter (Schema v2.0, extra="forbid") schema_errors = validate_document(prd_path.read_text(encoding="utf-8"), file_path=prd_path) # 3. Run structural section and falsifiability outcome linting lint_result = PRDLinter().lint_file(prd_path) assert lint_result.is_valid </code></pre> </main> <script type="module"> const mermaidNodes = document.querySelectorAll('.mermaid, pre code.language-mermaid'); if (mermaidNodes.length > 0) { document.querySelectorAll('pre code.language-mermaid').forEach(code => { const pre = code.parentElement; if (pre && pre.tagName.toLowerCase() === 'pre') { pre.className = 'mermaid'; pre.textContent = code.textContent; } }); try { const { default: mermaid } = await import('https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'); mermaid.initialize({ startOnLoad: false, theme: 'dark', securityLevel: 'loose', }); await mermaid.run(); } catch (err) { console.error('Failed to load or render Mermaid diagrams:', err); } } </script> </body> </html>