design-process-playbook / design-doc-example.html
michaelassraf's picture
Add Q&A/product clarifications and per-function feedback sign-off
808f30e verified
Raw History Blame Contribute Delete
21.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lean Spec — Device Alert Rules v1 (worked example)</title>
<style>
:root {
color-scheme: light;
--page: #f9f9f7; --surface-1: #fcfcfb;
--ink-1: #0b0b0b; --ink-2: #52514e; --ink-muted: #898781;
--hairline: #e1e0d9; --baseline: #c3c2b7;
--c-product: #2a78d6; --c-be: #eb6834; --c-fe: #1baf7a;
--c-devops: #eda100; --c-ux: #e87ba4; --c-tl: #4a3aa7;
--good: #0ca30c; --good-text: #006300;
--wash: rgba(42,120,214,0.06);
}
@media (prefers-color-scheme: dark) {
:root:where(:not([data-theme="light"])) {
color-scheme: dark;
--page: #0d0d0d; --surface-1: #1a1a19;
--ink-1: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
--hairline: #2c2c2a; --baseline: #383835;
--c-product: #3987e5; --c-be: #d95926; --c-fe: #199e70;
--c-devops: #c98500; --c-ux: #d55181; --c-tl: #9085e9;
--good: #0ca30c; --good-text: #0ca30c;
--wash: rgba(57,135,229,0.12);
}
}
* { margin:0; padding:0; box-sizing:border-box; }
body { background: var(--page); color: var(--ink-1);
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.5; font-size: 14.5px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 30px 24px 60px; }
a { color: var(--c-product); }
.backlink { font-size: 12.5px; text-decoration: none; color: var(--ink-muted); }
h1 { font-size: 23px; letter-spacing: -0.02em; margin-top: 12px; }
.docid { color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.card { background: var(--surface-1); border: 1px solid var(--hairline);
border-radius: 14px; padding: 16px 18px; margin-top: 14px; }
section { margin-top: 26px; }
section > h2 { font-size: 16px; margin-bottom: 6px; }
b, strong { color: var(--ink-1); }
.header-card table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.header-card td { padding: 4px 8px; vertical-align: top; color: var(--ink-2); }
.header-card td.k { width: 90px; color: var(--ink-muted); font-weight: 600; font-size: 11px;
text-transform: uppercase; letter-spacing: .04em; }
.status { display:inline-block; font-weight:700; font-size:12px; border-radius:999px;
padding: 1px 11px; color:#fff; background: var(--good); }
.tier { display:inline-block; font-weight:700; color:#fff; border-radius:6px;
padding: 0 8px; font-size: 12px; background: #3987e5; }
.dot { width:9px; height:9px; border-radius:50%; display:inline-block; vertical-align:-1px; }
.tiles { display:grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; padding: 12px 14px; }
.tile .lbl { font-size: 10.5px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.tile .val { font-size: 20px; font-weight: 700; color: var(--ink-1); margin-top: 2px; line-height: 1.15; }
.tile .ctx { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
table.data { width:100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align:left; color: var(--ink-muted); font-weight:600; font-size:10.5px;
text-transform: uppercase; letter-spacing: .04em; padding: 5px 8px;
border-bottom: 1px solid var(--baseline); }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--hairline); vertical-align: top; color: var(--ink-2); }
table.data td:first-child { color: var(--ink-1); white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em;
background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 5px; padding: 0 4px; }
figure { margin: 8px 0 0; }
figcaption { color: var(--ink-muted); font-size: 11.5px; margin-top: 6px; }
svg { width: 100%; height: auto; display: block; }
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.type { display:inline-block; font-weight:600; font-size:10.5px; border-radius:999px;
padding: 1px 9px; margin-left: 8px; vertical-align: 2px;
color: var(--ink-muted); border: 1px dashed var(--baseline); background: var(--surface-1);
text-transform: uppercase; letter-spacing: .04em; }
.tag { display:inline-block; font-weight:700; font-size:10.5px; border-radius:5px; padding:0 6px; }
.tag.blocking { background: rgba(227,73,72,0.14); color:#c22a29; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .tag.blocking { color:#e66767; } }
.tag.suggestion { background: var(--wash); color: var(--c-product); }
.tag.question { background: rgba(237,161,0,0.12); color: var(--c-devops); }
.ok { color: var(--good-text); }
footer { margin-top: 40px; color: var(--ink-muted); font-size: 11.5px;
border-top: 1px solid var(--hairline); padding-top: 12px; line-height: 1.7; }
</style>
</head>
<body>
<div class="wrap">
<a class="backlink" href="./">← System Design Process Playbook</a>
<h1>Device Alert Rules — Lean Spec</h1>
<div class="docid">DD-2026-041 · worked example · format per 2026 SDD practice (Spec Kit · Kiro · Linear): one page, tables over prose, agent-readable</div>
<div class="card header-card">
<table>
<tr><td class="k">Status</td><td><span class="status">Approved-with-changes</span> · <span class="tier">M</span> · DRI <span class="dot" style="background:var(--c-be)"></span> Dana (BE) · 48h review · 1 blocking → resolved</td></tr>
<tr><td class="k">Sign-offs</td><td>PM ✓ · BE TL ✓ · FE TL ✓ · UX ✓ · DevOps TL ✓ · Platform TL ✓</td></tr>
<tr><td class="k">Links</td><td><a href="#">Brief</a> · <a href="#">Figma</a> · <a href="#">Prototype</a> · <a href="#">Tasks</a> <span style="font-size:11px">(placeholders)</span></td></tr>
</table>
</div>
<!-- WHY -->
<section>
<h2>Why <span class="type">numbers</span></h2>
<div class="tiles">
<div class="tile"><div class="lbl">Problem</div><div class="val">No alerting</div><div class="ctx">issues found by looking</div></div>
<div class="tile"><div class="lbl">Success</div><div class="val">≥60%</div><div class="ctx">pilots create a rule, week 1</div></div>
<div class="tile"><div class="lbl">Time-to-ack</div><div class="val">&lt;30 min</div><div class="ctx">baseline ~4h</div></div>
<div class="tile"><div class="lbl">NFR</div><div class="val">&lt;90s</div><div class="ctx">p95 · &lt;$400/mo</div></div>
</div>
</section>
<!-- WHAT -->
<section>
<h2>What it does <span class="type">table</span></h2>
<div class="card">
<table class="data">
<thead><tr><th>Trigger</th><th>Behavior</th></tr></thead>
<tbody>
<tr><td>Threshold crossed</td><td>notify rule's channels (email · Slack · webhook) &lt;90s p95</td></tr>
<tr><td>Heartbeat missed</td><td>"agent offline" alert</td></tr>
<tr><td>Data missing</td><td>no fire — never a false "CPU 0%"</td></tr>
<tr><td>Repeat / storm</td><td>cooldown per device+rule · 500/h tenant cap → one summary</td></tr>
<tr><td>Delivery fails</td><td>3× retry → in-app banner + digest</td></tr>
</tbody>
</table>
</div>
</section>
<!-- HOW -->
<section>
<h2>How <span class="type">diagram + 1 line of text</span></h2>
<div class="card">
<figure>
<svg viewBox="0 0 860 200" role="img" aria-label="Architecture: agents send metrics through the ingest API into Kafka; the new Rules Evaluator consumes metrics, writes alert events to ClickHouse and calls the Notification service. The web app manages rules via the Rules API backed by Postgres.">
<defs>
<marker id="a" markerWidth="9" markerHeight="9" refX="7" refY="4.5" orient="auto">
<path d="M1,1 L8,4.5 L1,8" fill="none" stroke="var(--ink-muted)" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
</marker>
</defs>
<rect x="10" y="30" width="110" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="65" y="50" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Agents</text>
<text x="65" y="66" font-size="10" fill="var(--ink-muted)" text-anchor="middle">metrics / 60s</text>
<line x1="120" y1="53" x2="152" y2="53" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="156" y="30" width="110" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="211" y="50" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Ingest API</text>
<text x="211" y="66" font-size="10" fill="var(--ink-muted)" text-anchor="middle">existing</text>
<line x1="266" y1="53" x2="298" y2="53" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="302" y="30" width="130" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="367" y="50" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Kafka</text>
<text x="367" y="66" font-size="10" fill="var(--ink-muted)" text-anchor="middle">device.metrics</text>
<line x1="432" y1="53" x2="464" y2="53" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="468" y="24" width="150" height="58" rx="10" fill="var(--wash)" stroke="var(--c-be)"/>
<text x="543" y="47" font-size="12" font-weight="700" fill="var(--ink-1)" text-anchor="middle">Rules Evaluator</text>
<text x="543" y="64" font-size="10" fill="var(--ink-2)" text-anchor="middle">NEW · own consumer group</text>
<line x1="618" y1="42" x2="672" y2="42" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<line x1="618" y1="66" x2="672" y2="120" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="676" y="20" width="172" height="44" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="762" y="38" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Notification service</text>
<text x="762" y="54" font-size="10" fill="var(--ink-muted)" text-anchor="middle">email · Slack · webhook</text>
<rect x="676" y="106" width="172" height="44" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="762" y="124" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">ClickHouse</text>
<text x="762" y="140" font-size="10" fill="var(--ink-muted)" text-anchor="middle">alert_events · 90d</text>
<rect x="10" y="130" width="110" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="65" y="150" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Web app</text>
<text x="65" y="166" font-size="10" fill="var(--ink-muted)" text-anchor="middle">rule builder UI</text>
<line x1="120" y1="153" x2="152" y2="153" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="156" y="130" width="110" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="211" y="150" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Rules API</text>
<text x="211" y="166" font-size="10" fill="var(--ink-muted)" text-anchor="middle">CRUD + validate</text>
<line x1="266" y1="153" x2="298" y2="153" stroke="var(--ink-muted)" stroke-width="1.3" marker-end="url(#a)"/>
<rect x="302" y="130" width="130" height="46" rx="10" fill="var(--surface-1)" stroke="var(--hairline)"/>
<text x="367" y="150" font-size="12" font-weight="600" fill="var(--ink-1)" text-anchor="middle">Postgres</text>
<text x="367" y="166" font-size="10" fill="var(--ink-muted)" text-anchor="middle">alert_rules</text>
<path d="M 432 153 C 460 153, 470 100, 490 86" fill="none" stroke="var(--ink-muted)" stroke-width="1.3" stroke-dasharray="4 4" marker-end="url(#a)"/>
<text x="470" y="130" font-size="10" fill="var(--ink-muted)">rules.changed</text>
</svg>
<figcaption>One decision: server-side streaming eval, own consumer group — can't slow ingest, agents untouched (Client: N/A v1). Spike-proven at 55k msg/s/pod.</figcaption>
</figure>
</div>
</section>
<!-- PLAN -->
<section>
<h2>Build plan <span class="type">table</span></h2>
<div class="card">
<table class="data">
<thead><tr><th></th><th>One line each — details live in the linked tasks</th></tr></thead>
<tbody>
<tr><td><span class="dot" style="background:var(--c-be)"></span> API</td><td>CRUD <code>/v1/alert-rules</code> + <code>/v1/alert-events</code> history · additive-only until v2</td></tr>
<tr><td><span class="dot" style="background:var(--c-be)"></span> Data</td><td><code>alert_rules</code> (Postgres) · <code>alert_events</code> (ClickHouse, 90d) · additive migration</td></tr>
<tr><td><span class="dot" style="background:var(--c-fe)"></span> FE</td><td>rule builder stepper + history views per Figma · empty/error states designed</td></tr>
<tr><td><span class="dot" style="background:var(--c-be)"></span> Security</td><td>tenant-scoped · <code>alerts:manage</code> role · secrets in vault · no PII in payloads</td></tr>
<tr><td><span class="dot" style="background:var(--c-devops)"></span> Rollout</td><td>flag <code>alert_rules_v1</code> · 5-tenant pilot, 2 cycles → GA · lag+failure dashboard day 1</td></tr>
<tr><td><span class="dot" style="background:var(--c-devops)"></span> Rollback</td><td>flag off + scale to 0 — offsets retained, nothing lost</td></tr>
<tr><td><span class="dot" style="background:var(--c-tl)"></span> Verify</td><td>edge table = unit cases · load 50k msg/s, p95 &lt; 90s · success metric wired day 1</td></tr>
</tbody>
</table>
</div>
</section>
<!-- Q&A -->
<section>
<h2>Q&amp;A — product &amp; technical clarifications <span class="type">table</span></h2>
<div class="sub" style="color:var(--ink-muted);font-size:12px;margin-bottom:2px">Anyone asks by commenting on the doc (shaping → discussion). The answer is written <b>into the spec</b> — the "folded into" column proves it. This table is the log, so the same question is never asked twice.</div>
<div class="card">
<table class="data">
<thead><tr><th>Question</th><th style="width:70px">From → To</th><th>Answer</th><th style="width:110px">Folded into</th></tr></thead>
<tbody>
<tr><td style="white-space:normal">Threshold per device or per tenant?</td><td><span class="dot" style="background:var(--c-be)"></span> BE → PM</td><td>per-rule, applies to all matched devices; per-device overrides = v2</td><td class="ok">✓ What it does</td></tr>
<tr><td style="white-space:normal">Who can create rules?</td><td><span class="dot" style="background:var(--c-fe)"></span> FE → PM</td><td>Admin + Technician roles only (<code>alerts:manage</code>)</td><td class="ok">✓ Build plan</td></tr>
<tr><td style="white-space:normal">Does "agent offline" need agent-side changes?</td><td><span class="dot" style="background:var(--c-fe)"></span> Client → PM</td><td>no — server-side heartbeat detection is enough for v1</td><td class="ok">✓ How</td></tr>
<tr><td style="white-space:normal">Notification cost ceiling per tenant?</td><td><span class="dot" style="background:var(--c-devops)"></span> DevOps → PM</td><td>inside the $400/mo total; no per-tenant billing in v1</td><td class="ok">✓ Why (NFR)</td></tr>
<tr><td style="white-space:normal">Ship default starter rules enabled?</td><td><span class="dot" style="background:var(--c-ux)"></span> UX → PM</td><td><b>open</b> — PM decides from pilot data, due end of pilot</td><td>◌ backlog</td></tr>
</tbody>
</table>
</div>
</section>
<!-- FEEDBACK -->
<section>
<h2>Function feedback &amp; sign-off <span class="type">table</span></h2>
<div class="sub" style="color:var(--ink-muted);font-size:12px;margin-bottom:2px">Every function leaves a row — even "no concerns". Comment types per the playbook: [blocking] must be resolved · [suggestion] author's call · [question] answered in the doc.</div>
<div class="card">
<table class="data">
<thead><tr><th style="width:100px">Function</th><th>Feedback</th><th style="width:230px">Outcome</th></tr></thead>
<tbody>
<tr><td><span class="dot" style="background:var(--c-product)"></span> PM</td><td>scope creep risk — cap v1 to 4 metric types</td><td class="ok">✓ taken — What it does trimmed</td></tr>
<tr><td><span class="dot" style="background:var(--c-be)"></span> BE TL</td><td><span class="tag suggestion">[suggestion]</span> <code>conditions[]</code> array now for future compound rules</td><td>declined — additive in v2, logged in backlog</td></tr>
<tr><td><span class="dot" style="background:var(--c-fe)"></span> FE TL</td><td>events list needs cursor pagination for 90d history</td><td class="ok">✓ taken — Build plan (API row)</td></tr>
<tr><td><span class="dot" style="background:var(--c-fe)"></span> Client TL</td><td>no concerns — confirms agents untouched in v1</td><td class="ok">✓ signed off (N/A is a reviewed claim)</td></tr>
<tr><td><span class="dot" style="background:var(--c-devops)"></span> DevOps TL</td><td><span class="tag blocking">[blocking]</span> no consumer-lag alert; downtime behavior undefined</td><td class="ok">✓ resolved — Rollout rows added, §-only re-review same day</td></tr>
<tr><td><span class="dot" style="background:var(--c-ux)"></span> UX</td><td><span class="tag question">[question]</span> what does the user see when all channels fail?</td><td class="ok">✓ answered in doc — banner behavior + Figma updated</td></tr>
</tbody>
</table>
</div>
</section>
<!-- DECISIONS -->
<section>
<h2>Decisions <span class="type">table</span></h2>
<div class="card">
<table class="data">
<thead><tr><th>Record</th><th></th></tr></thead>
<tbody>
<tr><td>Rejected</td><td>polling (too slow) · agent-side eval (v2) · buy PagerDuty (core value; webhooks bridge instead)</td></tr>
<tr><td>v2 backlog</td><td>escalation policies · quiet hours · compound rules · per-site grouping · default starter rules (open Q&amp;A)</td></tr>
</tbody>
</table>
</div>
</section>
<!-- FORMAT REFERENCE -->
<section>
<h2>Format reference — each component's type &amp; purpose</h2>
<div class="card">
<table class="data">
<thead><tr><th>Component</th><th>Type</th><th>Purpose</th><th>Rule</th></tr></thead>
<tbody>
<tr><td>Header</td><td>metadata table</td><td>the decision record: status, tier, DRI, sign-offs — and links to where the depth lives (brief, Figma, prototype, tasks)</td><td>pointers only, never content · 3–4 rows</td></tr>
<tr><td>Why</td><td>stat tiles</td><td>the problem and the measurable targets everyone must remember</td><td>numbers only — if it needs a sentence, it's not a target yet</td></tr>
<tr><td>What it does</td><td>trigger → behavior table</td><td>the testable behavior contract; each row becomes a test an agent can verify</td><td>one behavior per row · no paragraphs</td></tr>
<tr><td>How</td><td>diagram + 1 line</td><td><b>both on purpose:</b> the diagram carries structure (what talks to what, where the new piece sits) — text can't; the one line carries the decision (why this shape, what it trades) — boxes can't</td><td>text budget = 1 line; more than that belongs in Decisions, or the design is too big → split the doc</td></tr>
<tr><td>Build plan</td><td>per-function table</td><td>who builds what — the entry point for the decomposition workshop</td><td>one row per function · details live in the tasks, not here</td></tr>
<tr><td>Q&amp;A</td><td>question log table</td><td><b>how engineers ask product (and each other) anything:</b> comment on the doc during shaping/discussion; PM or the owning function answers; the answer is folded into the spec section it affects</td><td>every answered row names where it was folded in · open rows have an owner + due · the thread is the log, the spec is the truth</td></tr>
<tr><td>Function feedback</td><td>sign-off table</td><td>where BE / FE / Client / DevOps / UX / PM feedback lands, with its disposition — visible proof every function reviewed</td><td>one row per function, even "no concerns" · [blocking] resolved before approval · silence ≠ sign-off</td></tr>
<tr><td>Decisions</td><td>table</td><td>the doc's memory: rejected alternatives (with reasons) and the v2 backlog</td><td>one line per decision · abandoned ideas are kept, never deleted</td></tr>
</tbody>
</table>
</div>
</section>
<footer>
Part of the <a href="./">System Design Process Playbook</a> · format:
<a href="https://github.com/github/spec-kit">GitHub Spec Kit</a> ·
<a href="https://kiro.dev">AWS Kiro</a> ·
<a href="https://linear.app/method">Linear Method</a> ·
<a href="https://claude.com/blog/how-anthropic-teams-use-claude-code">Anthropic workflows</a>
</footer>
</div>
</body>
</html>