Architectural Decision Records (ADRs) & Evolution Lineage Specification

This reference document specifies the directory topology, dual-format grammar (optional YAML frontmatter plus mandatory Markdown AST sections), lineage state machine (total supersession vs. non-destructive amendment), DAG acyclicity invariants, and registry contract for Architectural Decision Records (ADRs) in SpecOps (Research Area 4, governed by ADR-0001, ADR-0008, and ADR-0022).


1. Directory Topology & Lifecycle Folders

All Architectural Decision Records reside under docs/project/adrs/ and progress through two primary lifecycle stage directories alongside an authoritative registry index:


docs/project/adrs/
β”œβ”€β”€ REGISTRY.md                              # Pipe-delimited index of all ADRs
β”œβ”€β”€ proposed/                                # Draft decisions under architectural evaluation
β”‚   └── adr-XXXX-<slug>.md
└── accepted/                                # Active, ratified, or historical decisions
    └── adr-XXXX-<slug>.md

Path Resolution & Discovery

The ADR engines (ADRSupersessionEngine in src/spec_ops/adrs/supersession.py and ADRAmendmentEngine in src/spec_ops/adrs/amendment.py) resolve the ADR root directory in the following priority order:

  1. docs/project/adrs/ (canonical PMaC location)
  2. docs/adrs/ (legacy fallback)
  3. adrs/ (minimal repository fallback)

When resolving an individual ADR via find_adr_file(adrs_dir, target) (src/spec_ops/adrs/supersede.py):

  1. Direct file paths or paths relative to adrs_dir, adrs_dir.parent, or adrs_dir.parent.parent are checked first.
  2. Otherwise, the target string is normalized via normalize_adr_id(target) and matched against .md filenames (adr-XXXX stem match), frontmatter id fields, or the first H1 heading line across docs/project/adrs//.md (excluding REGISTRY.md and README.md).
  3. If no matching file exists, ADRNotFoundError (FileNotFoundError subclass) is raised.

Filename Convention & Canonical Identifier

Folder / File Lifecycle Role Allowed Statuses
docs/project/adrs/proposed/ Candidate architectural decisions awaiting review or empirical spike graduation (spec-ops spike graduate). Proposed
docs/project/adrs/accepted/ Ratified architectural invariants governing bounded contexts, plus historical records that were later superseded or amended. Accepted, Superseded
docs/project/adrs/REGISTRY.md Central index mapping every ADR-XXXX to its title, current status, and ratification date. N/A (Index file)

2. Dual-Format Grammar (Optional YAML Frontmatter + Markdown AST)

Unlike Backlog Tasks, User Stories, and PRDsβ€”which strictly require --- YAML frontmatter blocksβ€”ADRs intentionally support a Dual-Format Grammar:

  1. Pure Markdown Format: Foundational or hand-authored ADRs (such as ADR-0001 through ADR-0021) omit YAML frontmatter and encode their identifier, title, and status directly in Markdown headings.
  2. Hybrid YAML Frontmatter + Markdown Format: ADRs generated or mutated by CLI workflows (spec-ops spike graduate, spec-ops adr supersede, spec-ops adr amend, or ADR-0022) include a YAML frontmatter block above the Markdown body.

Schema Audit Exemption (`is_specification_file`)

In src/spec_ops/core/schema_validator.py, is_specification_file(path) applies special handling when "adrs" is in the path:

`ADRFrontmatter` Schema (`schema_validator.py`)

When YAML frontmatter is present on an ADR, it is validated against the ADRFrontmatter Pydantic model (SCHEMA_VERSION = "v2.0"):


class ADRFrontmatter(BaseModel):
    """Pydantic schema model for ADR frontmatter when present."""

    model_config = ConfigDict(extra="allow")

    id: Any
    title: str
    status: str = "Accepted"
    domain: Optional[str] = "Architecture"
    supersedes: Optional[Any] = None
    superseded_by: Optional[Any] = None
    amends: Optional[Any] = None
    amended_by: Optional[Any] = None
Field Type Required Default Semantics
id Any (`str \ int`) Yes (if frontmatter exists) β€” Canonical ID ("ADR-0022" or "0022"). Normalized to ADR-XXXX.
title str Yes (if frontmatter exists) β€” Human-readable decision title without the # ADR-XXXX: prefix.
status str No "Accepted" Lifecycle state ("Proposed", "Accepted", "Superseded").
domain Optional[str] No "Architecture" Architectural domain or bounded context classification.
supersedes Optional[Any] No None Canonical ID of the predecessor ADR retired by this decision (e.g., "ADR-0003").
superseded_by Optional[Any] No None Canonical ID of the newer ADR that replaced this decision (e.g., "ADR-0015").
amends Optional[Any] No None List of target ADR IDs (list[str] or str) incrementally refined by this ADR.
amended_by Optional[Any] No None List of amending ADR IDs (list[str] or str) that refine this ADR.
(extra keys) Any No Allowed extra="allow" permits metadata such as date: YYYY-MM-DD or spike_id: SPIKE-XXXX.

Reconciliation Between Frontmatter and Markdown (`parse_adr`)

parse_adr(file_path) in src/spec_ops/core/adr_parser.py constructs the ADR domain model (src/spec_ops/core/models.py) by reconciling YAML keys with Markdown regex extraction:

  1. id Resolution: Extracts adr-(\d+) from file_path.stem first (f"ADR-{num.zfill(4)}"), falling back to meta.get("id", file_path.stem.upper()). Note that parse_adr_info in supersede.py also overrides with normalize_adr_id(str(meta["id"])) when meta["id"] is present.
  2. title Resolution: Uses meta.get("title") if non-empty; otherwise inspects the first non-empty line of the Markdown body and strips the H1 prefix via re.sub(r"^#\s(ADR-\d+:\s)?", "", title_line).strip().
  3. status & domain: Defaults to meta.get("status", "Accepted") and meta.get("domain", "Architecture").
  4. Lineage Lists (amends, amended_by): Coerces scalar strings or YAML lists into uppercase list[str] (e.g., ["ADR-0002"]), while supersedes and superseded_by are normalized as strings.

Domain Model Representation (`ADR` Dataclass)

Parsed ADRs are materialized as ADR instances (src/spec_ops/core/models.py) with the following attributes:


3. Mandatory Markdown Body AST Sections

Every ADR document must contain an H1 header followed by four canonical H2 sections (## Status, ## Context, ## Decision, ## Consequences).

Canonical Examples: Pure Markdown vs. Hybrid YAML+Markdown

Example A β€” Pure Markdown ADR (docs/project/adrs/accepted/adr-0001-specification-as-code-architecture.md):


# ADR-0001: Specification as Code and Opinionated SDLC Guardrails

## Status
Accepted

## Context
Traditional agile tooling isolates user stories and backlog items in external web silos, leading to specification drift, context blindness for coding agents, and merge conflicts across parallel streams.

## Decision
We adopt **Project Management as Code**:
1. All project specifications (Personas, PRDs, User Stories, ADRs, Backlog Tasks) live inside `docs/project/` as Markdown documents with YAML frontmatter.
2. Specifications branch, review, and merge directly alongside production code.
3. Automated tools parse documentation into machine-readable relational graphs, ensuring zero specification drift.

## Consequences
- **Positive**: Full version-locking of requirements and code; conflict-free parallel worker execution; living interactive visualizer directly from git history.
- **Negative**: Requires discipline to maintain frontmatter metadata and lean JIT buffers.

Example B β€” Hybrid YAML Frontmatter + Markdown ADR (with Amendment Lineage):


---
id: ADR-0022
title: Declarative Markdown and YAML Specification Grammar and Document Metamodel
status: Accepted
domain: Architecture
date: 2026-10-15
amends:
  - ADR-0001
---

# ADR-0022: Declarative Markdown and YAML Specification Grammar and Document Metamodel

## Status
Accepted (amends [`ADR-0001`](file://adr-0001.md))

## Context
Exploratory architectural spike `SPIKE-0259` investigated the hypothesis...

## Decision
We adopt a formal **Declarative Markdown+YAML Specification Grammar & Metamodel**...

## Consequences
- **Positive**: Unifies frontmatter validation, markdown section linting, and directory topology rules.
- **Negative**: Requires keeping declarative grammar rules synchronized with reference documentation.

Section Grammar Rules

Section Heading Extraction Regex (adr_parser.py / supersede.py) Content Contract
# ADR-XXXX: </code></td> <td><code>^#\s<em>(ADR-\d+:\s</em>)?(?P<title>.+)$</code></td> <td>Top-level H1 heading declaring the canonical ADR ID and decision title.</td> </tr> <tr> <td><code>## Status</code></td> <td><code>## Status\s*\n([^\n]+)</code></td> <td>Declares current lifecycle state: <code>Proposed</code>, <code>Accepted</code>, <code>Superseded (by ADR-YYYY)</code>, <code>Superseded by ADR-YYYY</code>, or <code>Accepted (amends <a href="...">ADR-XXXX</a>)</code>.</td> </tr> <tr> <td><code>## Context</code></td> <td>`## Context\s<em>\n(.</em>?)(?=\n##\</td> <td>\Z)<code> (</code>re.DOTALL`)</td> <td>Problem forces, constraints, technical debt, or empirical benchmark findings graduated via `spec-ops spike graduate <SPIKE-ID> --result proven\</td> <td>disproven`.</td> </tr> <tr> <td><code>## Decision</code></td> <td>`## Decision\s<em>\n(.</em>?)(?=\n##\</td> <td>\Z)<code> (</code>re.DOTALL`)</td> <td>Normative, verifiable architectural rules and bounded context invariants ("We adopt...", numbered imperatives).</td> </tr> <tr> <td><code>## Consequences</code></td> <td>`## Consequences\s<em>\n(.</em>?)(?=\n##\</td> <td>\Z)<code> (</code>re.DOTALL`)</td> <td>Explicit trade-off analysis detailing <strong><code></strong>Positive<strong></code></strong> benefits and <strong><code></strong>Negative<strong></code></strong> costs or operational obligations.</td> </tr> </tbody></table></div> <hr /> <h2>4. Decision Evolution & Lineage State Machine</h2> <p>Architectural decisions evolve over time through two distinct mechanisms: <strong>Total Replacement (<code>supersede</code>)</strong> and <strong>Non-Destructive Refinement (<code>amend</code>)</strong>.</p> <pre class="mermaid"> stateDiagram-v2 [*] --> Proposed : Author in proposed/ or Spike Graduate Proposed --> Accepted : Ratify & Move to accepted/ Accepted --> Accepted : spec-ops adr amend (amends / amended_by) Accepted --> Superseded : spec-ops adr supersede (supersedes / superseded_by) Superseded --> [*] </pre> <h3>4.1 Total Replacement: `spec-ops adr supersede`</h3> <p>Implemented in <code>src/spec_ops/adrs/supersede.py</code> and <code>src/spec_ops/adrs/supersession.py</code> (<code>ADRSupersessionEngine.supersede</code>), supersession retires an obsolete decision in favor of a replacement ADR:</p> <ol> <li><strong>Cycle Detection (<code>detect_supersession_cycles</code>)</strong>:</li> </ol> <ul> <li>Discovers existing supersession edges across <code>REGISTRY.md</code>, YAML frontmatter (<code>superseded_by</code>), and Markdown body patterns (<code>r"Superseded\s+by\s+(?:\[</code>?)?(ADR-\d+)"`).</li> <li>Flattens transitive chains (<code>A -> B -> C</code> resolves <code>A -> C</code>) and verifies that adding <code>(old_id -> new_id)</code> does not introduce a self-loop (<code>old_id == new_id</code>) or cycle (<code>CircularSupersessionError</code>).</li> </ul> <ol> <li><strong>Predecessor ADR Mutation (<code>old_file</code>)</strong>:</li> </ol> <ul> <li>Sets YAML frontmatter <code>status: Superseded</code> and <code>superseded_by: ADR-YYYY</code>.</li> <li>Rewrites the Markdown <code>## Status</code> line to <code>Superseded (by ADR-YYYY)</code>.</li> </ul> <ol> <li><strong>Successor ADR Mutation (<code>new_file</code>)</strong>:</li> </ol> <ul> <li>Scaffolds a new ADR in <code>docs/project/adrs/accepted/</code> (if <code>--title</code> is provided) or moves an existing proposed ADR into <code>accepted/</code>.</li> <li>Sets YAML frontmatter <code>status: Accepted</code> and <code>supersedes: ADR-XXXX</code>.</li> </ul> <ol> <li><strong>Registry Synchronization (<code>update_registry_supersession</code>)</strong>:</li> </ol> <ul> <li>Updates <code>old_id</code> status column in <code>docs/project/adrs/REGISTRY.md</code> to <code>Superseded (by ADR-YYYY)</code> and ensures <code>new_id</code> is listed as <code>Accepted</code>.</li> </ul> <ol> <li><strong>Downstream Backlog Impact (<code>find_tasks_citing_adr</code> & <code>ArchitecturalReconciler</code>)</strong>:</li> </ol> <ul> <li>Scans <code>docs/project/backlog/{refined,proposed}/*.md</code> for tasks citing <code>old_id</code> in <code>governing_adrs</code> or body text, emitting warnings: <code>"Task TASK-XXXX cites superseded ADR-XXXX; requires architectural re-refinement"</code>.</li> <li>When <code>ArchitecturalReconciler.reconcile_task</code> (<code>src/spec_ops/backlog/reconciler.py</code>) runs, it automatically replaces superseded ADR references in <code>governing_adrs</code> and task body text with the transitive active successor (<code>change_type="superseded_adr"</code>).</li> </ul> <h3>4.2 Non-Destructive Refinement: `spec-ops adr amend`</h3> <p>Implemented in <code>src/spec_ops/adrs/amend.py</code> and <code>src/spec_ops/adrs/amendment.py</code> (<code>ADRAmendmentEngine.amend</code>), amendment layers incremental refinements onto a foundational decision <strong>without</strong> retiring the predecessor:</p> <ol> <li><strong>DAG Acyclicity & Cycle Detection (<code>detect_amendment_cycles</code>)</strong>:</li> </ol> <ul> <li><code>discover_amended_adrs</code> builds the directed graph <code>{amending_id: [target_ids]}</code> from <code>amends</code> frontmatter, reverse <code>amended_by</code> frontmatter, and Markdown body matches (<code>r"amends\s+(?:\[</code>?)?(ADR-\d+)"`).</li> <li>Runs Depth-First Search (DFS) with a recursion stack (<code>stack</code>) before modifying any files. Self-amendment (<code>ADR-X -> ADR-X</code>) or multi-hop cycles (<code>ADR-A -> ADR-B -> ADR-A</code>) raise <code>CircularAmendmentError</code>.</li> </ul> <ol> <li><strong>Bidirectional Frontmatter Linking</strong>:</li> </ol> <ul> <li><strong>Predecessor ADR (<code>old_file</code>)</strong>: Preserves <code>status: Accepted</code> and appends <code>new_id</code> to <code>amended_by: [ADR-YYYY]</code>.</li> <li><strong>Amending ADR (<code>new_file</code>)</strong>: Placed in <code>docs/project/adrs/accepted/</code> with <code>status: Accepted</code> and appends <code>old_id</code> to <code>amends: [ADR-XXXX]</code>.</li> </ul> <ol> <li><strong>Registry Synchronization (<code>update_registry_amendment</code>)</strong>:</li> </ol> <ul> <li>Keeps the predecessor ADR's status as <code>Accepted</code> in <code>REGISTRY.md</code> while adding or updating the amending ADR row as <code>Accepted</code>.</li> </ul> <ol> <li><strong>Downstream Hydration & DoR Gate Integration</strong>:</li> </ol> <ul> <li><strong>DoR Gate (<code>src/spec_ops/backlog/dor_gate.py</code>)</strong>: Tasks citing an accepted base ADR pass <code>RULE_GOVERNING_ADRS</code>; if <code>amended_by</code> is non-empty, <code>audit_task_health</code> appends an informational recommendation: <code>"ADR ADR-XXXX has active amendments [ADR-YYYY]."</code></li> <li><strong>Reconciler (<code>src/spec_ops/backlog/reconciler.py</code>)</strong>: Emits a non-destructive <code>active_amendment_notice</code> (<code>modified=False</code>) so the base ADR citation remains intact.</li> <li><strong>Worker Contract Hydration (<code>src/spec_ops/worker/claimer.py</code>)</strong>: <code>hydrate_task_prompt</code> calls <code>discover_amendments_by_target(adrs_dir)</code> and injects both inline annotations (<code>ADR-0002 (active amendments: ADR-0025)</code>) and a dedicated <code>- Active ADR Amendments:</code> bullet into <code>.task-prompt.md</code> so autonomous workers enforce both the foundational invariant and its amending deltas.</li> </ul> <h3>Comparison: Supersession vs. Amendment</h3> <div class="table-wrapper"><table><thead><tr> <th>Dimension</th> <th>Supersession (<code>spec-ops adr supersede</code>)</th> <th>Amendment (<code>spec-ops adr amend</code>)</th> </tr></thead><tbody> <tr> <td><strong>Predecessor <code>status</code></strong></td> <td>Transitions to <code>Superseded</code></td> <td>Remains <code>Accepted</code></td> </tr> <tr> <td><strong>Predecessor Frontmatter</strong></td> <td><code>superseded_by: ADR-YYYY</code> (scalar)</td> <td><code>amended_by: [ADR-YYYY, ...]</code> (list)</td> </tr> <tr> <td><strong>Successor Frontmatter</strong></td> <td><code>supersedes: ADR-XXXX</code> (scalar)</td> <td><code>amends: [ADR-XXXX, ...]</code> (list)</td> </tr> <tr> <td><strong><code>REGISTRY.md</code> Old Row</strong></td> <td><code>Superseded (by ADR-YYYY)</code></td> <td><code>Accepted</code></td> </tr> <tr> <td><strong>Cycle Exception</strong></td> <td><code>CircularSupersessionError</code></td> <td><code>CircularAmendmentError</code></td> </tr> <tr> <td><strong>DoR Gate (<code>dor_gate.py</code>)</strong></td> <td>Fails if task only cites <code>Superseded</code> ADR</td> <td>Passes; emits amendment recommendation</td> </tr> <tr> <td><strong>Task Reconciler</strong></td> <td>Rewrites <code>old_id -> new_id</code> (<code>modified=True</code>)</td> <td>Preserves <code>old_id</code>; logs <code>active_amendment_notice</code></td> </tr> <tr> <td><strong>Worker <code>.task-prompt.md</code></strong></td> <td>Cites replacement ADR</td> <td>Hydrates base ADR + <code>Active ADR Amendments</code> delta</td> </tr> </tbody></table></div> <hr /> <h2>5. ADR Registry Specification (`docs/project/adrs/REGISTRY.md`)</h2> <p><code>docs/project/adrs/REGISTRY.md</code> is the human- and machine-readable table indexing all Architectural Decision Records.</p> <h3>Format & Row Grammar</h3> <p>The file begins with <code># ADR Registry</code> followed by a 4-column Markdown pipe table:</p> <pre><code class="language-markdown"> # ADR Registry | ID | Title | Status | Date | |---|---|---|---| | ADR-0001 | Specification as Code and Opinionated SDLC Guardrails | Accepted | 2026-09-29 | | ADR-0003 | Blackbox Frontdoor Verification and Zero Backdoor Testing | Superseded (by ADR-0015) | 2026-09-29 | | ADR-0022 | Declarative Markdown and YAML Specification Grammar and Document Metamodel | Accepted | 2026-10-15 | </code></pre> <ul> <li><strong>Row Parsing Regex</strong>: <code>r"^\|\s<em>([^|]+?)\s</em>\|\s<em>([^|]+?)\s</em>\|\s<em>([^|]+?)\s</em>\|\s<em>([^|]+?)\s</em>\|$"</code></li> <li><strong>Columns</strong>:</li> </ul> <ol> <li><strong><code>ID</code></strong>: Canonical zero-padded identifier (<code>ADR-XXXX</code>).</li> <li><strong><code>Title</code></strong>: Concise decision title matching the ADR's H1 / frontmatter <code>title</code>.</li> <li><strong><code>Status</code></strong>: <code>Proposed</code>, <code>Accepted</code>, or <code>Superseded (by ADR-YYYY)</code>.</li> <li><strong><code>Date</code></strong>: ISO-8601 date (<code>YYYY-MM-DD</code>) when the decision was recorded or ratified.</li> </ol> <ul> <li><strong>Schema Validator Exemption</strong>: <code>REGISTRY.md</code> is listed in <code>ignored_names</code> within <code>is_specification_file()</code> (<code>src/spec_ops/core/schema_validator.py</code>) so it is never flagged for lacking YAML frontmatter.</li> <li><strong>Automated Maintenance</strong>: Both <code>update_registry_supersession</code> (<code>src/spec_ops/adrs/supersede.py</code>) and <code>update_registry_amendment</code> (<code>src/spec_ops/adrs/amend.py</code>) parse each pipe-delimited row in place, updating existing ADR rows or appending newly scaffolded ADR entries at the bottom of the table with <code>date.today().isoformat()</code>.</li> </ul> </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>