import{_ as a,o as s,c as t,a2 as i}from"./chunks/framework.CJEbdX1t.js";const g=JSON.parse('{"title":"Spec Coverage","description":"","frontmatter":{},"headers":[],"relativePath":"concepts/coverage.md","filePath":"concepts/coverage.md"}'),n={name:"concepts/coverage.md"};function o(r,e,l,c,d,p){return s(),t("div",null,[...e[0]||(e[0]=[i(`<h1 id="spec-coverage" tabindex="-1">Spec Coverage <a class="header-anchor" href="#spec-coverage" aria-label="Permalink to &quot;Spec Coverage&quot;">​</a></h1><p>Spec coverage measures what percentage of spec acceptance criteria are verified against actual code. Unlike test coverage (which measures code execution), spec coverage measures <strong>intent realization</strong> — is the software doing what the spec says it should?</p><h2 id="coverage-model" tabindex="-1">Coverage Model <a class="header-anchor" href="#coverage-model" aria-label="Permalink to &quot;Coverage Model&quot;">​</a></h2><p>Coverage is calculated at three levels:</p><h3 id="acceptance-criteria-level" tabindex="-1">Acceptance Criteria Level <a class="header-anchor" href="#acceptance-criteria-level" aria-label="Permalink to &quot;Acceptance Criteria Level&quot;">​</a></h3><p>Each acceptance criterion is evaluated as:</p><table tabindex="0"><thead><tr><th>Status</th><th>Meaning</th></tr></thead><tbody><tr><td><strong>Realized</strong></td><td>Code fully implements this AC — evidence links to file and line</td></tr><tr><td><strong>Partially realized</strong></td><td>Partial implementation — explanation of what&#39;s missing</td></tr><tr><td><strong>Conflicting</strong></td><td>Code contradicts this AC — explanation of how</td></tr><tr><td><strong>Not addressed</strong></td><td>No code touches this area yet</td></tr></tbody></table><h3 id="section-level" tabindex="-1">Section Level <a class="header-anchor" href="#section-level" aria-label="Permalink to &quot;Section Level&quot;">​</a></h3><p>A section&#39;s coverage is the ratio of realized ACs to total ACs:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Section coverage = realized ACs / total ACs</span></span></code></pre></div><p>Section status auto-transitions based on coverage:</p><ul><li><strong>0%</strong> → stays at current status</li><li><strong>1-99%</strong> → <code>in_progress</code></li><li><strong>100%</strong> → <code>done</code></li></ul><h3 id="spec-level" tabindex="-1">Spec Level <a class="header-anchor" href="#spec-level" aria-label="Permalink to &quot;Spec Level&quot;">​</a></h3><p>A spec&#39;s coverage aggregates all its sections:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Spec coverage = realized ACs across all sections / total ACs</span></span></code></pre></div><h2 id="evidence-trail" tabindex="-1">Evidence Trail <a class="header-anchor" href="#evidence-trail" aria-label="Permalink to &quot;Evidence Trail&quot;">​</a></h2><p>Every realization includes evidence — the PR, file, and line numbers where the implementation lives:</p><div class="language-markdown vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">markdown</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">&lt;!-- specwright:realized-in:PR#412 src/payments/keys.ts:42-60 --&gt;</span></span></code></pre></div><p>This creates an audit trail connecting specs to code. If the code changes in a later PR, the agent can re-evaluate whether the realization still holds.</p><h2 id="coverage-dashboard" tabindex="-1">Coverage Dashboard <a class="header-anchor" href="#coverage-dashboard" aria-label="Permalink to &quot;Coverage Dashboard&quot;">​</a></h2><p>The <code>/sw:status</code> command (or the web dashboard) shows coverage at a glance:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Spec Coverage — payments-overhaul.md</span></span>
<span class="line"><span></span></span>
<span class="line"><span>  §1 Background                    ████████████ 100%  done</span></span>
<span class="line"><span>  §2 Stripe Migration              ██████░░░░░░  50%  in_progress</span></span>
<span class="line"><span>    §2.1 API Integration           ████░░░░░░░░  25%  in_progress</span></span>
<span class="line"><span>    §2.2 Webhook Handler           ████████████ 100%  done</span></span>
<span class="line"><span>  §3 Idempotency Layer             ░░░░░░░░░░░░   0%  blocked</span></span>
<span class="line"><span>  §4 Multi-Currency Support        ░░░░░░░░░░░░   0%  todo</span></span>
<span class="line"><span>  §5 Monitoring &amp; Alerts           ———————————— n/a   deprecated</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Overall: 8/18 ACs realized (44%)</span></span></code></pre></div><h2 id="staleness-detection" tabindex="-1">Staleness Detection <a class="header-anchor" href="#staleness-detection" aria-label="Permalink to &quot;Staleness Detection&quot;">​</a></h2><p>Coverage isn&#39;t static. When code changes but specs don&#39;t, sections become stale:</p><ul><li>A PR modifies <code>src/payments/retry.ts</code> which was evidence for §3.2</li><li>The agent re-evaluates: does the code still satisfy the acceptance criteria?</li><li>If not, the section is flagged as stale and the coverage drops</li></ul><p>Configure staleness detection in <a href="/docs/getting-started/configuration.html">SPECWRIGHT.yaml</a>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">agents</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  stale_detection</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;30d&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # flag sections not updated within 30 days</span></span></code></pre></div><h2 id="org-wide-coverage" tabindex="-1">Org-Wide Coverage <a class="header-anchor" href="#org-wide-coverage" aria-label="Permalink to &quot;Org-Wide Coverage&quot;">​</a></h2><p>At the org level (Tier 3), coverage aggregates across all repos:</p><ul><li><strong>Per-team coverage</strong> — Which team has the best spec-to-code alignment?</li><li><strong>Trend lines</strong> — Is coverage improving or degrading over time?</li><li><strong>Health score</strong> — Composite metric weighing coverage, staleness, and completeness</li></ul><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to &quot;Related&quot;">​</a></h2><ul><li><strong>Concept</strong>: <a href="/docs/concepts/living-specs.html">Living Specs</a> — the feedback loop that produces realization evidence</li><li><strong>Concept</strong>: <a href="/docs/concepts/delta-tracking.html">Delta Tracking</a> — how realization comments are stored in spec markdown</li><li><strong>Guide</strong>: <a href="/docs/guides/writing-specs.html">Writing Specs</a> — how to write testable acceptance criteria</li><li><strong>Reference</strong>: <a href="/docs/reference/cli.html">CLI</a> — <code>specwright status</code> for the coverage dashboard, <code>specwright verify</code> for AC verification</li><li><strong>Reference</strong>: <a href="/docs/reference/mcp.html">MCP Tools</a> — <code>get_coverage</code> for programmatic coverage queries</li><li><strong>Reference</strong>: <a href="/docs/reference/skills.html">Claude Code Skills</a> — <code>/sw:status</code> for interactive coverage views</li></ul>`,32)])])}const v=a(n,[["render",o]]);export{g as __pageData,v as default};
