{"name":"release-ledger","title":"Release ledger","description":"Build a what's-new feature into a product: capture merged work, categorise it nightly, and show each signed-in user only what shipped since they last looked, plus a digest and hand-written announcements. Symptoms: what's-new popup, in-app changelog for users, since-you-were-away digest, tell logged-in users what changed, product updates feed. This writes tables, jobs and UI into an app; it does not write the notes for one version — that is release-notes.","compatibility":"Any product with a version-controlled source of merged work, a durable store, a scheduler that can run once a day, and an authenticated user identity to hang a per-user watermark on. Automatic capture assumes a forge that emits webhooks; manual capture needs none. Analysis assumes a language model reachable from the job runner, and the digest assumes one chat or mail surface. No specific framework, database, or job runner is required.","allowedTools":"Read Write Edit Grep Glob Bash","license":"MIT","kind":"signals","useWhen":"recording what shipped to which signed-in users, across a release","group":"workflow","lifecycle":"release","version":"1.0.0","author":"crissmoldovan","install":["npx skills add crissmoldovan/agent-skills --skill release-ledger"],"asks":["Onboard a release ledger into this app. Run the stack investigation first and\nshow me the answers before you write anything, then produce\ndocs/release-ledger/implementation.md mapping every stage onto what is actually\nhere. Do not create tables yet.","We already capture merged pull requests into a queue table but nothing reads it.\nAdd the nightly analysis stage only: batch the queue, classify and describe each\nrow with describe-changes, and write one ledger entry per change. Print a cost\nestimate for the backlog before the first model call.","Manual ledger, no webhook. Set up the entries, dismissals, and announcements\ntables plus the per-user popup with a 30-day watermark cap, and give me an admin\nform to write an announcement with a start date and an audience."],"commands":[],"documents":[{"path":"references/data-model.md","slug":"data-model","title":"Release ledger — reference data model","body":"# Release ledger — reference data model\n\nPortable SQL, written against ANSI types with PostgreSQL spellings where a choice\nwas needed. Rename freely; the constraints are the part that matters, and each one\nis annotated with the failure it prevents.\n\n## Overview\n\n| Table | Holds | Written by |\n|---|---|---|\n| `release_capture_queue` | Raw merge payloads, unanalysed | The capture endpoint |\n| `release_entries` | Analysed, user-facing entries | The analysis job |\n| `release_announcements` | Hand-written, scheduled entries | Admins |\n| `release_dismissals` | One watermark per user | The dismiss endpoint |\n| `release_sends` | One row per digest attempt | The digest job |\n\n## 1. Capture queue\n\n```sql\ncreate table release_capture_queue (\n  id              bigserial primary key,\n  source          text        not null,          -- 'github', 'gitlab', 'manual'\n  repository      text        not null,\n  change_number   integer     not null,          -- PR / MR number\n  merged_at       timestamptz not null,\n  payload         jsonb       not null,          -- the whole event, unmodified\n  analysed_at     timestamptz,\n  attempt_count   integer     not null default 0,\n  last_error      text,\n  created_at      timestamptz not null default now(),\n\n  constraint release_capture_queue_natural_key\n    unique (source, repository, change_number)\n);\n\ncreate index release_capture_queue_pending\n  on release_capture_queue (merged_at)\n  where analysed_at is null;\n```\n\n- **`unique (source, repository, change_number)`** is the idempotency key. Forges\n  replay deliveries after a timeout or a manual redelivery; insert with\n  `on conflict do nothing` and a replay costs one wasted statement.\n- **`payload` stores the event unmodified.** Do not extract fields at capture\n  time. Every field you decide not to keep is a field the analysis prompt cannot\n  use six months from now, and re-fetching from the forge needs a credential the\n  capture path deliberately does not have.\n- **`attempt_count` and `last_error`** exist so a permanently unanalysable row\n  can be excluded from the batch instead of blocking it every night.\n- **The partial index** is what makes \"select the unanalysed batch\" cheap once\n  the table has a year in it.\n\n## 2. Entries\n\n```sql\ncreate table release_entries (\n  id              uuid        primary key default gen_random_uuid(),\n  queue_id        bigint      references release_capture_queue (id),\n  kind            text        not null\n                    check (kind in ('feature','bug_fix','improvement',\n                                    'security','ops','docs','breaking')),\n  title           text        not null,\n  short_md        text        not null,\n  medium_md       text,\n  detail_md       text,\n  refs            jsonb       not null default '[]'::jsonb,\n  ticket_ref      text,\n  reporter_user_id uuid       references users (id),\n  published_at    timestamptz not null,\n  created_at      timestamptz not null default now(),\n\n  constraint release_entries_queue_unique unique (queue_id)\n);\n\ncreate index release_entries_published on release_entries (published_at desc);\n```\n\n- **`kind`'s check constraint** is the `describe-changes` classification, exactly.\n  Keep the two in step; a ledger that invents an eighth kind and a describer that\n  emits seven produce rows nothing renders.\n- **`unique (queue_id)`** stops a re-run of the analysis job from producing a\n  second entry for the same change. A nullable `queue_id` leaves room for entries\n  an agent wrote by hand in a manual-only ledger.\n- **`published_at` is the merge date, not the analysis date.** Backfill depends on\n  this; so does the \"since you were away\" arithmetic.\n- **`refs`** is the `describe-changes` reference array — path, line range, and an\n  optional commit. Store it as given; render it on the detail page only.\n- **`reporter_user_id` will be null for most rows** in any real product, because\n  most merged changes have no linked request. Render its absence as absence.\n\n## 3. Announcements\n\n```sql\ncreate table release_announcements (\n  id           uuid        primary key default gen_random_uuid(),\n  title        text        not null,\n  body_md      text        not null,\n  starts_on    date        not null,\n  ends_on      date,\n  audience     text        not null default 'everyone',\n  audience_ids text[]      not null default '{}',\n  pinned       boolean     not null default false,\n  author_id    uuid        not null references users (id),\n  created_at   timestamptz not null default now(),\n\n  constraint release_announcements_window\n    check (ends_on is null or ends_on >= starts_on)\n);\n```\n\n- **Separate from `release_entries`** because the lifecycles differ: an\n  announcement has a schedule and an audience, an entry has a diff and a\n  classification, and a merged table is half-null in both directions.\n- **`audience` plus `audience_ids`** keeps the common case (`everyone`) cheap and\n  the targeted case explicit. Resolve it server-side, always.\n- **`starts_on` is a date, not a timestamp**, because \"goes live on Monday\" is how\n  people write announcements and a timezone-bearing instant invites a 00:00 UTC\n  surprise.\n\n## 4. Dismissals\n\n```sql\ncreate table release_dismissals (\n  user_id       uuid        primary key references users (id) on delete cascade,\n  watermark_at  timestamptz not null,\n  updated_at    timestamptz not null default now()\n);\n```\n\n- **One row per user**, so `primary key (user_id)`. A per-event dismissal table\n  grows without bound and answers the same question more slowly.\n- **The watermark is a timestamp, not an entry id**, so entries inserted out of\n  order (a backfill, a late analysis) are still covered by a single comparison.\n- **Where access policies exist**, this is the one ledger table an end user writes:\n  allow insert and update where the row's `user_id` equals the caller, and nothing\n  else.\n\n## 5. Sends\n\n```sql\ncreate table release_sends (\n  id            uuid        primary key default gen_random_uuid(),\n  channel       text        not null,\n  recipient     text,\n  provider      text        not null,          -- 'slack', 'email', ...\n  status        text        not null\n                  check (status in ('sent','failed','skipped')),\n  reason        text,\n  entry_count   integer     not null default 0,\n  cutoff_at     timestamptz not null,          -- entries after this were included\n  external_id   text,\n  external_url  text,\n  error         text,\n  sent_at       timestamptz not null default now(),\n  triggered_by  text\n);\n\ncreate index release_sends_channel_time on release_sends (channel, sent_at desc);\n```\n\n- **A row per attempt, including the ones that sent nothing.** `skipped` always\n  carries a `reason`. This is the difference between \"quiet day\" and \"the job has\n  been throwing for a week\" — without it, both look like silence.\n- **`cutoff_at`** is what the next run reads to find its range. Reading it from\n  the last *successful* send means a failed night is covered by the next one\n  instead of becoming a hole.\n- **`external_id` and `external_url`** make a send auditable from the ledger side\n  without querying the chat provider.\n\n## The popup query\n\n```sql\nselect e.id, e.kind, e.title, e.short_md, e.published_at\n  from release_entries e\n where e.published_at > greatest(\n         coalesce((select watermark_at from release_dismissals\n                    where user_id = :user_id), 'epoch'::timestamptz),\n         now() - interval '30 days')\n   and e.published_at <= now()\n order by e.published_at desc\n limit 50;\n```\n\n`greatest(watermark, now - window)` is the cap. It is one expression and it covers\nboth the new user and the long-absent one; a code path that special-cases \"no\nwatermark row\" is a second place for the window to be wrong.\n\nAnnouncements are a second query against `release_announcements` filtered by\n`starts_on <= current_date`, `ends_on is null or ends_on >= current_date`, and the\ncaller's audience — unioned in the application, sorted with `pinned` first.\n\n## Grants and policies\n\nWhere the database enforces per-row access:\n\n1. **Revoke first, then grant what is needed.** A default that grants insert,\n   update, and delete on every new table is how a browser-writable ledger happens\n   without anything failing.\n2. `release_dismissals` — the only table an end user writes. Insert and update\n   where `user_id` equals the caller.\n3. `release_entries` and `release_announcements` — read-only for end users if the\n   popup queries the database directly; no end-user access at all if the popup\n   goes through a server endpoint that filters by audience. Prefer the second: it\n   keeps audience enforcement in one place.\n4. `release_capture_queue` and `release_sends` — no end-user access in either\n   direction. They are written by privileged server code only.\n","bodyHtml":"<h2 id=\"release-ledger-reference-data-model\">Release ledger — reference data model</h2>\n<p>Portable SQL, written against ANSI types with PostgreSQL spellings where a choice\nwas needed. Rename freely; the constraints are the part that matters, and each one\nis annotated with the failure it prevents.</p>\n<h3 id=\"overview\">Overview</h3>\n<table>\n<thead>\n<tr>\n<th>Table</th>\n<th>Holds</th>\n<th>Written by</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>release_capture_queue</code></td>\n<td>Raw merge payloads, unanalysed</td>\n<td>The capture endpoint</td>\n</tr>\n<tr>\n<td><code>release_entries</code></td>\n<td>Analysed, user-facing entries</td>\n<td>The analysis job</td>\n</tr>\n<tr>\n<td><code>release_announcements</code></td>\n<td>Hand-written, scheduled entries</td>\n<td>Admins</td>\n</tr>\n<tr>\n<td><code>release_dismissals</code></td>\n<td>One watermark per user</td>\n<td>The dismiss endpoint</td>\n</tr>\n<tr>\n<td><code>release_sends</code></td>\n<td>One row per digest attempt</td>\n<td>The digest job</td>\n</tr>\n</tbody></table>\n<h3 id=\"1-capture-queue\">1. Capture queue</h3>\n<pre><code class=\"language-sql\">create table release_capture_queue (\n  id              bigserial primary key,\n  source          text        not null,          -- &#39;github&#39;, &#39;gitlab&#39;, &#39;manual&#39;\n  repository      text        not null,\n  change_number   integer     not null,          -- PR / MR number\n  merged_at       timestamptz not null,\n  payload         jsonb       not null,          -- the whole event, unmodified\n  analysed_at     timestamptz,\n  attempt_count   integer     not null default 0,\n  last_error      text,\n  created_at      timestamptz not null default now(),\n\n  constraint release_capture_queue_natural_key\n    unique (source, repository, change_number)\n);\n\ncreate index release_capture_queue_pending\n  on release_capture_queue (merged_at)\n  where analysed_at is null;\n</code></pre>\n<ul>\n<li><strong><code>unique (source, repository, change_number)</code></strong> is the idempotency key. Forges\nreplay deliveries after a timeout or a manual redelivery; insert with\n<code>on conflict do nothing</code> and a replay costs one wasted statement.</li>\n<li><strong><code>payload</code> stores the event unmodified.</strong> Do not extract fields at capture\ntime. Every field you decide not to keep is a field the analysis prompt cannot\nuse six months from now, and re-fetching from the forge needs a credential the\ncapture path deliberately does not have.</li>\n<li><strong><code>attempt_count</code> and <code>last_error</code></strong> exist so a permanently unanalysable row\ncan be excluded from the batch instead of blocking it every night.</li>\n<li><strong>The partial index</strong> is what makes &quot;select the unanalysed batch&quot; cheap once\nthe table has a year in it.</li>\n</ul>\n<h3 id=\"2-entries\">2. Entries</h3>\n<pre><code class=\"language-sql\">create table release_entries (\n  id              uuid        primary key default gen_random_uuid(),\n  queue_id        bigint      references release_capture_queue (id),\n  kind            text        not null\n                    check (kind in (&#39;feature&#39;,&#39;bug_fix&#39;,&#39;improvement&#39;,\n                                    &#39;security&#39;,&#39;ops&#39;,&#39;docs&#39;,&#39;breaking&#39;)),\n  title           text        not null,\n  short_md        text        not null,\n  medium_md       text,\n  detail_md       text,\n  refs            jsonb       not null default &#39;[]&#39;::jsonb,\n  ticket_ref      text,\n  reporter_user_id uuid       references users (id),\n  published_at    timestamptz not null,\n  created_at      timestamptz not null default now(),\n\n  constraint release_entries_queue_unique unique (queue_id)\n);\n\ncreate index release_entries_published on release_entries (published_at desc);\n</code></pre>\n<ul>\n<li><strong><code>kind</code>&#39;s check constraint</strong> is the <code>describe-changes</code> classification, exactly.\nKeep the two in step; a ledger that invents an eighth kind and a describer that\nemits seven produce rows nothing renders.</li>\n<li><strong><code>unique (queue_id)</code></strong> stops a re-run of the analysis job from producing a\nsecond entry for the same change. A nullable <code>queue_id</code> leaves room for entries\nan agent wrote by hand in a manual-only ledger.</li>\n<li><strong><code>published_at</code> is the merge date, not the analysis date.</strong> Backfill depends on\nthis; so does the &quot;since you were away&quot; arithmetic.</li>\n<li><strong><code>refs</code></strong> is the <code>describe-changes</code> reference array — path, line range, and an\noptional commit. Store it as given; render it on the detail page only.</li>\n<li><strong><code>reporter_user_id</code> will be null for most rows</strong> in any real product, because\nmost merged changes have no linked request. Render its absence as absence.</li>\n</ul>\n<h3 id=\"3-announcements\">3. Announcements</h3>\n<pre><code class=\"language-sql\">create table release_announcements (\n  id           uuid        primary key default gen_random_uuid(),\n  title        text        not null,\n  body_md      text        not null,\n  starts_on    date        not null,\n  ends_on      date,\n  audience     text        not null default &#39;everyone&#39;,\n  audience_ids text[]      not null default &#39;{}&#39;,\n  pinned       boolean     not null default false,\n  author_id    uuid        not null references users (id),\n  created_at   timestamptz not null default now(),\n\n  constraint release_announcements_window\n    check (ends_on is null or ends_on &gt;= starts_on)\n);\n</code></pre>\n<ul>\n<li><strong>Separate from <code>release_entries</code></strong> because the lifecycles differ: an\nannouncement has a schedule and an audience, an entry has a diff and a\nclassification, and a merged table is half-null in both directions.</li>\n<li><strong><code>audience</code> plus <code>audience_ids</code></strong> keeps the common case (<code>everyone</code>) cheap and\nthe targeted case explicit. Resolve it server-side, always.</li>\n<li><strong><code>starts_on</code> is a date, not a timestamp</strong>, because &quot;goes live on Monday&quot; is how\npeople write announcements and a timezone-bearing instant invites a 00:00 UTC\nsurprise.</li>\n</ul>\n<h3 id=\"4-dismissals\">4. Dismissals</h3>\n<pre><code class=\"language-sql\">create table release_dismissals (\n  user_id       uuid        primary key references users (id) on delete cascade,\n  watermark_at  timestamptz not null,\n  updated_at    timestamptz not null default now()\n);\n</code></pre>\n<ul>\n<li><strong>One row per user</strong>, so <code>primary key (user_id)</code>. A per-event dismissal table\ngrows without bound and answers the same question more slowly.</li>\n<li><strong>The watermark is a timestamp, not an entry id</strong>, so entries inserted out of\norder (a backfill, a late analysis) are still covered by a single comparison.</li>\n<li><strong>Where access policies exist</strong>, this is the one ledger table an end user writes:\nallow insert and update where the row&#39;s <code>user_id</code> equals the caller, and nothing\nelse.</li>\n</ul>\n<h3 id=\"5-sends\">5. Sends</h3>\n<pre><code class=\"language-sql\">create table release_sends (\n  id            uuid        primary key default gen_random_uuid(),\n  channel       text        not null,\n  recipient     text,\n  provider      text        not null,          -- &#39;slack&#39;, &#39;email&#39;, ...\n  status        text        not null\n                  check (status in (&#39;sent&#39;,&#39;failed&#39;,&#39;skipped&#39;)),\n  reason        text,\n  entry_count   integer     not null default 0,\n  cutoff_at     timestamptz not null,          -- entries after this were included\n  external_id   text,\n  external_url  text,\n  error         text,\n  sent_at       timestamptz not null default now(),\n  triggered_by  text\n);\n\ncreate index release_sends_channel_time on release_sends (channel, sent_at desc);\n</code></pre>\n<ul>\n<li><strong>A row per attempt, including the ones that sent nothing.</strong> <code>skipped</code> always\ncarries a <code>reason</code>. This is the difference between &quot;quiet day&quot; and &quot;the job has\nbeen throwing for a week&quot; — without it, both look like silence.</li>\n<li><strong><code>cutoff_at</code></strong> is what the next run reads to find its range. Reading it from\nthe last <em>successful</em> send means a failed night is covered by the next one\ninstead of becoming a hole.</li>\n<li><strong><code>external_id</code> and <code>external_url</code></strong> make a send auditable from the ledger side\nwithout querying the chat provider.</li>\n</ul>\n<h3 id=\"the-popup-query\">The popup query</h3>\n<pre><code class=\"language-sql\">select e.id, e.kind, e.title, e.short_md, e.published_at\n  from release_entries e\n where e.published_at &gt; greatest(\n         coalesce((select watermark_at from release_dismissals\n                    where user_id = :user_id), &#39;epoch&#39;::timestamptz),\n         now() - interval &#39;30 days&#39;)\n   and e.published_at &lt;= now()\n order by e.published_at desc\n limit 50;\n</code></pre>\n<p><code>greatest(watermark, now - window)</code> is the cap. It is one expression and it covers\nboth the new user and the long-absent one; a code path that special-cases &quot;no\nwatermark row&quot; is a second place for the window to be wrong.</p>\n<p>Announcements are a second query against <code>release_announcements</code> filtered by\n<code>starts_on &lt;= current_date</code>, <code>ends_on is null or ends_on &gt;= current_date</code>, and the\ncaller&#39;s audience — unioned in the application, sorted with <code>pinned</code> first.</p>\n<h3 id=\"grants-and-policies\">Grants and policies</h3>\n<p>Where the database enforces per-row access:</p>\n<ol>\n<li><strong>Revoke first, then grant what is needed.</strong> A default that grants insert,\nupdate, and delete on every new table is how a browser-writable ledger happens\nwithout anything failing.</li>\n<li><code>release_dismissals</code> — the only table an end user writes. Insert and update\nwhere <code>user_id</code> equals the caller.</li>\n<li><code>release_entries</code> and <code>release_announcements</code> — read-only for end users if the\npopup queries the database directly; no end-user access at all if the popup\ngoes through a server endpoint that filters by audience. Prefer the second: it\nkeeps audience enforcement in one place.</li>\n<li><code>release_capture_queue</code> and <code>release_sends</code> — no end-user access in either\ndirection. They are written by privileged server code only.</li>\n</ol>\n","words":1187},{"path":"references/onboarding-checklist.md","slug":"onboarding-checklist","title":"Release ledger — stack investigation checklist","body":"# Release ledger — stack investigation checklist\n\nA bounded investigation. Answer every line, write the answers into\n`docs/release-ledger/implementation.md`, and stop. This is not an invitation to\nread the codebase; each question exists because a specific later decision depends\non it.\n\nMark anything you cannot answer as an open question with a named owner. An honest\ngap is cheaper than a guess that a migration is written against.\n\n## 1. Shape of the application\n\n| Question | What the answer decides |\n|---|---|\n| Which framework and major version serves HTTP? | Where the capture endpoint and the popup endpoints live, and what the route signature looks like. |\n| Is there a server/client component split? | Whether audience filtering can happen in the same file as rendering. |\n| Where do shared server utilities live? | Where the ledger's query helpers go so both the popup and the digest use one copy. |\n| Is there an existing docs directory? | Where `implementation.md` belongs. |\n\n## 2. Data\n\n| Question | What the answer decides |\n|---|---|\n| Which database, and which client is used from server code? | The schema dialect and the connection idiom for every ledger query. |\n| Where do migrations live, and what is the file naming rule? | Where the ledger migration is written and how its version is stamped. |\n| Is there a review or staging step before a migration applies? | Whether you may create the tables yourself or must hand the file over. |\n| Does the database enforce row-level access, and is it on by default for new tables? | Whether the ledger tables need policies, grants, or neither. |\n| Which client does *privileged* server code use, and does it bypass row-level access? | Whether the digest job can read every entry while the popup endpoint cannot. |\n| Is there a helper for reading a large result set in pages? | Whether the analysis and backfill jobs can select the whole queue at once. |\n\n## 3. Scheduling and background work\n\n| Question | What the answer decides |\n|---|---|\n| What runs background jobs, and how is a job registered? | Where the analysis and digest jobs live and how they are discovered. |\n| How is a recurring schedule declared, and does it support a timezone? | Whether \"nightly at 09:30 local\" is expressible or must be computed in UTC. |\n| Is there a batch-trigger primitive, or only one-at-a-time dispatch? | Whether analysis fans out or must chunk manually. |\n| How does a job report failure, and what does the runner do with it? | Whether a failed digest is visible or silently swallowed. |\n| Is there a registry of job identifiers that new jobs must join? | Whether registration is a second step people forget. |\n\n## 4. Identity and permissions\n\n| Question | What the answer decides |\n|---|---|\n| What is the user table, and what is its primary key type? | The foreign key on the dismissal watermark. |\n| How does a server route learn the current user? | The popup and dismiss endpoints' first line. |\n| How are roles or groups represented, and can they be read server-side? | How announcement audiences are expressed and enforced. |\n| Is there an admin area with its own access rule? | Where the announcement composer goes. |\n| Does the project have a test that asserts every route checks authorization? | Whether new endpoints must follow a specific shape to pass it. |\n\n## 5. Delivery surfaces\n\n| Question | What the answer decides |\n|---|---|\n| Is there a chat integration, and what helper posts a message? | Whether the digest reuses an existing poster or needs one. |\n| Does that helper take markdown, or a block format? | Whether the digest converts, and where the converter comes from. |\n| Is there a per-message size or block-count limit? | Where the \"and N more\" truncation tail is applied. |\n| How are recipients addressed — channel, or per-user? | Whether the digest is one post or a fan-out, and how many users a fan-out would miss. |\n| Is there an existing table recording outbound sends, and can it accept a row that is not tied to something else? | Whether the ledger needs its own send table. |\n\n## 6. Existing inbound events\n\n| Question | What the answer decides |\n|---|---|\n| Is there already an endpoint receiving forge webhooks? | Whether capture extends an endpoint or adds one. |\n| Does it verify signatures, and how? | Whether the `github-webhooks` skill is an adoption or an audit. |\n| Which events are already subscribed? | Whether the hook configuration needs changing at all. |\n| Does the existing handler filter events before doing work, and how many does it discard? | Where capture hooks in. Measure this; do not assume. |\n| Is that endpoint exempt from the project's authorization rules? | Whether capture inherits the exemption and the new popup routes do not. |\n\n## 7. Rendering\n\n| Question | What the answer decides |\n|---|---|\n| Is there an existing markdown renderer in the UI? | Whether entry rendering reuses it. |\n| Does it allow raw HTML? | Whether it is safe for text derived from change bodies. |\n| Is there a typography or prose stylesheet, and is it actually installed? | Whether markdown needs an explicit component map to look right. |\n| What dialog or sheet primitive exists? | What the popup is built from. |\n| Where is the application chrome mounted? | Where the popup attaches so it appears on every authenticated page. |\n\n## 8. Model access\n\n| Question | What the answer decides |\n|---|---|\n| How does existing code call a language model from a background job? | The analysis job's call site and its error contract. |\n| Is there a prompt or template registry? | Whether the analysis prompt is code or data. |\n| Is structured output supported, and with what schema mechanism? | Whether the `describe-changes` contract can be enforced by the model or must be validated after. |\n| Is there cost logging? | Whether the backfill estimate can be checked against reality afterwards. |\n\n## Completion gate\n\nThe investigation is complete when every row above has an answer or a named open\nquestion, and `docs/release-ledger/implementation.md` contains a section per\nsystem-model stage naming the concrete file, table, schedule, or helper that will\ncarry it. Nothing is built before that document exists.\n","bodyHtml":"<h2 id=\"release-ledger-stack-investigation-checklist\">Release ledger — stack investigation checklist</h2>\n<p>A bounded investigation. Answer every line, write the answers into\n<code>docs/release-ledger/implementation.md</code>, and stop. This is not an invitation to\nread the codebase; each question exists because a specific later decision depends\non it.</p>\n<p>Mark anything you cannot answer as an open question with a named owner. An honest\ngap is cheaper than a guess that a migration is written against.</p>\n<h3 id=\"1-shape-of-the-application\">1. Shape of the application</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Which framework and major version serves HTTP?</td>\n<td>Where the capture endpoint and the popup endpoints live, and what the route signature looks like.</td>\n</tr>\n<tr>\n<td>Is there a server/client component split?</td>\n<td>Whether audience filtering can happen in the same file as rendering.</td>\n</tr>\n<tr>\n<td>Where do shared server utilities live?</td>\n<td>Where the ledger&#39;s query helpers go so both the popup and the digest use one copy.</td>\n</tr>\n<tr>\n<td>Is there an existing docs directory?</td>\n<td>Where <code>implementation.md</code> belongs.</td>\n</tr>\n</tbody></table>\n<h3 id=\"2-data\">2. Data</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Which database, and which client is used from server code?</td>\n<td>The schema dialect and the connection idiom for every ledger query.</td>\n</tr>\n<tr>\n<td>Where do migrations live, and what is the file naming rule?</td>\n<td>Where the ledger migration is written and how its version is stamped.</td>\n</tr>\n<tr>\n<td>Is there a review or staging step before a migration applies?</td>\n<td>Whether you may create the tables yourself or must hand the file over.</td>\n</tr>\n<tr>\n<td>Does the database enforce row-level access, and is it on by default for new tables?</td>\n<td>Whether the ledger tables need policies, grants, or neither.</td>\n</tr>\n<tr>\n<td>Which client does <em>privileged</em> server code use, and does it bypass row-level access?</td>\n<td>Whether the digest job can read every entry while the popup endpoint cannot.</td>\n</tr>\n<tr>\n<td>Is there a helper for reading a large result set in pages?</td>\n<td>Whether the analysis and backfill jobs can select the whole queue at once.</td>\n</tr>\n</tbody></table>\n<h3 id=\"3-scheduling-and-background-work\">3. Scheduling and background work</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>What runs background jobs, and how is a job registered?</td>\n<td>Where the analysis and digest jobs live and how they are discovered.</td>\n</tr>\n<tr>\n<td>How is a recurring schedule declared, and does it support a timezone?</td>\n<td>Whether &quot;nightly at 09:30 local&quot; is expressible or must be computed in UTC.</td>\n</tr>\n<tr>\n<td>Is there a batch-trigger primitive, or only one-at-a-time dispatch?</td>\n<td>Whether analysis fans out or must chunk manually.</td>\n</tr>\n<tr>\n<td>How does a job report failure, and what does the runner do with it?</td>\n<td>Whether a failed digest is visible or silently swallowed.</td>\n</tr>\n<tr>\n<td>Is there a registry of job identifiers that new jobs must join?</td>\n<td>Whether registration is a second step people forget.</td>\n</tr>\n</tbody></table>\n<h3 id=\"4-identity-and-permissions\">4. Identity and permissions</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>What is the user table, and what is its primary key type?</td>\n<td>The foreign key on the dismissal watermark.</td>\n</tr>\n<tr>\n<td>How does a server route learn the current user?</td>\n<td>The popup and dismiss endpoints&#39; first line.</td>\n</tr>\n<tr>\n<td>How are roles or groups represented, and can they be read server-side?</td>\n<td>How announcement audiences are expressed and enforced.</td>\n</tr>\n<tr>\n<td>Is there an admin area with its own access rule?</td>\n<td>Where the announcement composer goes.</td>\n</tr>\n<tr>\n<td>Does the project have a test that asserts every route checks authorization?</td>\n<td>Whether new endpoints must follow a specific shape to pass it.</td>\n</tr>\n</tbody></table>\n<h3 id=\"5-delivery-surfaces\">5. Delivery surfaces</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Is there a chat integration, and what helper posts a message?</td>\n<td>Whether the digest reuses an existing poster or needs one.</td>\n</tr>\n<tr>\n<td>Does that helper take markdown, or a block format?</td>\n<td>Whether the digest converts, and where the converter comes from.</td>\n</tr>\n<tr>\n<td>Is there a per-message size or block-count limit?</td>\n<td>Where the &quot;and N more&quot; truncation tail is applied.</td>\n</tr>\n<tr>\n<td>How are recipients addressed — channel, or per-user?</td>\n<td>Whether the digest is one post or a fan-out, and how many users a fan-out would miss.</td>\n</tr>\n<tr>\n<td>Is there an existing table recording outbound sends, and can it accept a row that is not tied to something else?</td>\n<td>Whether the ledger needs its own send table.</td>\n</tr>\n</tbody></table>\n<h3 id=\"6-existing-inbound-events\">6. Existing inbound events</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Is there already an endpoint receiving forge webhooks?</td>\n<td>Whether capture extends an endpoint or adds one.</td>\n</tr>\n<tr>\n<td>Does it verify signatures, and how?</td>\n<td>Whether the <code>github-webhooks</code> skill is an adoption or an audit.</td>\n</tr>\n<tr>\n<td>Which events are already subscribed?</td>\n<td>Whether the hook configuration needs changing at all.</td>\n</tr>\n<tr>\n<td>Does the existing handler filter events before doing work, and how many does it discard?</td>\n<td>Where capture hooks in. Measure this; do not assume.</td>\n</tr>\n<tr>\n<td>Is that endpoint exempt from the project&#39;s authorization rules?</td>\n<td>Whether capture inherits the exemption and the new popup routes do not.</td>\n</tr>\n</tbody></table>\n<h3 id=\"7-rendering\">7. Rendering</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Is there an existing markdown renderer in the UI?</td>\n<td>Whether entry rendering reuses it.</td>\n</tr>\n<tr>\n<td>Does it allow raw HTML?</td>\n<td>Whether it is safe for text derived from change bodies.</td>\n</tr>\n<tr>\n<td>Is there a typography or prose stylesheet, and is it actually installed?</td>\n<td>Whether markdown needs an explicit component map to look right.</td>\n</tr>\n<tr>\n<td>What dialog or sheet primitive exists?</td>\n<td>What the popup is built from.</td>\n</tr>\n<tr>\n<td>Where is the application chrome mounted?</td>\n<td>Where the popup attaches so it appears on every authenticated page.</td>\n</tr>\n</tbody></table>\n<h3 id=\"8-model-access\">8. Model access</h3>\n<table>\n<thead>\n<tr>\n<th>Question</th>\n<th>What the answer decides</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>How does existing code call a language model from a background job?</td>\n<td>The analysis job&#39;s call site and its error contract.</td>\n</tr>\n<tr>\n<td>Is there a prompt or template registry?</td>\n<td>Whether the analysis prompt is code or data.</td>\n</tr>\n<tr>\n<td>Is structured output supported, and with what schema mechanism?</td>\n<td>Whether the <code>describe-changes</code> contract can be enforced by the model or must be validated after.</td>\n</tr>\n<tr>\n<td>Is there cost logging?</td>\n<td>Whether the backfill estimate can be checked against reality afterwards.</td>\n</tr>\n</tbody></table>\n<h3 id=\"completion-gate\">Completion gate</h3>\n<p>The investigation is complete when every row above has an answer or a named open\nquestion, and <code>docs/release-ledger/implementation.md</code> contains a section per\nsystem-model stage naming the concrete file, table, schedule, or helper that will\ncarry it. Nothing is built before that document exists.</p>\n","words":1106},{"path":"references/system-model.md","slug":"system-model","title":"Release ledger — system model","body":"# Release ledger — system model\n\nThe six stages, their contracts, and what each is allowed to do when the next one\nis unavailable. Names here are roles, not table names; map them onto the host's\nvocabulary in the implementation document.\n\n## Stage contracts\n\n| Stage | Input | Output | Must not |\n|---|---|---|---|\n| Capture | One merge event | One queue row, or none if the key already exists | Call a model, enrich, filter on business rules, block the caller |\n| Analysis | A batch of unanalysed queue rows | One ledger entry per row; the row marked analysed | Reorder, drop silently, run unbounded |\n| Popup | A user identity | Entries newer than the user's watermark, within the window | Return entries the user's audience excludes |\n| Dismiss | A user identity and a timestamp | The watermark advanced | Advance past the newest entry the user was shown |\n| Digest | A time range and a channel | One post and one send row | Report success when it posted nothing |\n| Announcements | A human author | A scheduled, audience-targeted entry | Enter the analysis queue |\n\n## Sequence: automatic capture through to the popup\n\n```text\nforge            endpoint          queue          analysis job        entries      user\n  │                 │                │                 │                 │           │\n  ├─ merge event ──►│                │                 │                 │           │\n  │                 ├─ verify sig    │                 │                 │           │\n  │                 ├─ insert ──────►│  (on conflict   │                 │           │\n  │                 │                │   do nothing)   │                 │           │\n  │◄── 200 ─────────┤                │                 │                 │           │\n  │                 │                │                 │                 │           │\n  │              nightly ────────────┼────────────────►│                 │           │\n  │                 │                │  select where   │                 │           │\n  │                 │                │  analysed_at is  │                │           │\n  │                 │                │  null, limit N  │                 │           │\n  │                 │                │                 ├─ describe ─────►│           │\n  │                 │                │◄── mark analysed┤                 │           │\n  │                 │                │                 │                 │           │\n  │                 │                │                 │                 │◄─ open ───┤\n  │                 │                │                 │      entries after watermark│\n  │                 │                │                 │      ──────────────────────►│\n  │                 │                │                 │                 │◄─ dismiss ┤\n  │                 │                │                 │       watermark := now      │\n```\n\nThe 200 is returned before analysis exists. That is the point of the queue: the\nforge's retry policy and the model's availability are decoupled.\n\n## Sequence: the daily digest\n\n```text\nscheduler ──► digest job\n                 ├─ read the previous send row for this channel\n                 ├─ select entries created after that send's cutoff\n                 ├─ select announcements whose start date is today\n                 ├─ if both sets are empty:\n                 │      write send row {status: skipped, reason: \"no entries\"}  ── stop\n                 ├─ render markdown to the channel's block format\n                 ├─ truncate to the channel's block limit with an \"and N more\" tail\n                 ├─ post\n                 └─ write send row {status: sent | failed, external_id, error}\n```\n\nThe cutoff comes from the previous **send row**, not from \"now minus 24 hours\". A\njob that failed yesterday must not create a hole; reading the last successful\ncutoff makes the next run cover both days.\n\n## Failure behaviour at each boundary\n\n- **Forge unreachable at capture.** Nothing to do — the forge retries. Do not\n  poll as a fallback unless capture has been missing events long enough to\n  measure; a poller and a webhook both writing the same natural key is fine, and\n  a poller replacing the webhook is a different design.\n- **Store unreachable at capture.** Return a non-2xx so the forge retries. This\n  is the one case where failing the request is correct.\n- **Model unavailable during analysis.** The queue rows stay unanalysed. The next\n  night picks them up. Cap the retry count per row and record the last error, so\n  a permanently poisonous payload does not occupy the batch forever.\n- **A single row fails analysis.** Record the failure on that row, continue with\n  the batch. One bad payload must not stop the other twelve.\n- **The popup cannot reach entries.** Render nothing. A what's-new popup that\n  shows an error dialog on login is worse than a popup that does not appear.\n- **The channel rejects the digest post.** Write the send row with `failed` and\n  the error, and leave the cutoff unadvanced so the next run retries the same\n  range.\n\n## The watermark, precisely\n\nThe watermark is a per-user timestamp. The set a user sees is:\n\n```text\nentries where published_at > max(user.watermark, now - window)\n                          and published_at <= now\n                          and audience matches the user\norder by published_at desc\n```\n\nTwo consequences worth stating explicitly:\n\n- **A new user sees the window, not the history.** Their watermark is null, so\n  `max(null, now - window)` is the window floor. That is the desired behaviour:\n  a first login is not a changelog archive.\n- **Dismissal sets the watermark to the newest entry the user was shown**, not to\n  `now`. If an entry is published while the popup is open, setting the watermark\n  to `now` would swallow it unseen.\n\n## Announcements\n\nAn announcement is authored, not derived. It carries:\n\n- `starts_on` — the date it becomes visible. A pinned announcement posts to the\n  digest channel on this date, once.\n- `ends_on` — optional. After it, the announcement stops appearing in the popup\n  even for users whose watermark predates it.\n- `audience` — roles, groups, or \"everyone\". Resolved server-side.\n- `pinned` — whether it sorts above analysed entries in the popup.\n\nAnnouncements and analysed entries share a rendering path and nothing else. Keep\nthem in separate tables: they have different lifecycles, different authorship, and\ndifferent permissions, and merging them produces a table where half the columns\nare always null.\n\n## Backfill\n\nBackfill runs through the same analysis path as the nightly job, with three\nadditions:\n\n1. **Count the input first** and print an estimate of the model cost before\n   anything is called. A month of merged work on a busy repository is a large\n   number of tokens.\n2. **Cap the batch size** and run batches under an explicit total limit, so a\n   miscounted estimate cannot become an unbounded bill.\n3. **Set `published_at` from the merge date**, not from the backfill run time.\n   Otherwise every historical change appears to have shipped today and every\n   user's popup shows the entire history at once.\n","bodyHtml":"<h2 id=\"release-ledger-system-model\">Release ledger — system model</h2>\n<p>The six stages, their contracts, and what each is allowed to do when the next one\nis unavailable. Names here are roles, not table names; map them onto the host&#39;s\nvocabulary in the implementation document.</p>\n<h3 id=\"stage-contracts\">Stage contracts</h3>\n<table>\n<thead>\n<tr>\n<th>Stage</th>\n<th>Input</th>\n<th>Output</th>\n<th>Must not</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Capture</td>\n<td>One merge event</td>\n<td>One queue row, or none if the key already exists</td>\n<td>Call a model, enrich, filter on business rules, block the caller</td>\n</tr>\n<tr>\n<td>Analysis</td>\n<td>A batch of unanalysed queue rows</td>\n<td>One ledger entry per row; the row marked analysed</td>\n<td>Reorder, drop silently, run unbounded</td>\n</tr>\n<tr>\n<td>Popup</td>\n<td>A user identity</td>\n<td>Entries newer than the user&#39;s watermark, within the window</td>\n<td>Return entries the user&#39;s audience excludes</td>\n</tr>\n<tr>\n<td>Dismiss</td>\n<td>A user identity and a timestamp</td>\n<td>The watermark advanced</td>\n<td>Advance past the newest entry the user was shown</td>\n</tr>\n<tr>\n<td>Digest</td>\n<td>A time range and a channel</td>\n<td>One post and one send row</td>\n<td>Report success when it posted nothing</td>\n</tr>\n<tr>\n<td>Announcements</td>\n<td>A human author</td>\n<td>A scheduled, audience-targeted entry</td>\n<td>Enter the analysis queue</td>\n</tr>\n</tbody></table>\n<h3 id=\"sequence-automatic-capture-through-to-the-popup\">Sequence: automatic capture through to the popup</h3>\n<pre><code class=\"language-text\">forge            endpoint          queue          analysis job        entries      user\n  │                 │                │                 │                 │           │\n  ├─ merge event ──►│                │                 │                 │           │\n  │                 ├─ verify sig    │                 │                 │           │\n  │                 ├─ insert ──────►│  (on conflict   │                 │           │\n  │                 │                │   do nothing)   │                 │           │\n  │◄── 200 ─────────┤                │                 │                 │           │\n  │                 │                │                 │                 │           │\n  │              nightly ────────────┼────────────────►│                 │           │\n  │                 │                │  select where   │                 │           │\n  │                 │                │  analysed_at is  │                │           │\n  │                 │                │  null, limit N  │                 │           │\n  │                 │                │                 ├─ describe ─────►│           │\n  │                 │                │◄── mark analysed┤                 │           │\n  │                 │                │                 │                 │           │\n  │                 │                │                 │                 │◄─ open ───┤\n  │                 │                │                 │      entries after watermark│\n  │                 │                │                 │      ──────────────────────►│\n  │                 │                │                 │                 │◄─ dismiss ┤\n  │                 │                │                 │       watermark := now      │\n</code></pre>\n<p>The 200 is returned before analysis exists. That is the point of the queue: the\nforge&#39;s retry policy and the model&#39;s availability are decoupled.</p>\n<h3 id=\"sequence-the-daily-digest\">Sequence: the daily digest</h3>\n<pre><code class=\"language-text\">scheduler ──► digest job\n                 ├─ read the previous send row for this channel\n                 ├─ select entries created after that send&#39;s cutoff\n                 ├─ select announcements whose start date is today\n                 ├─ if both sets are empty:\n                 │      write send row {status: skipped, reason: &quot;no entries&quot;}  ── stop\n                 ├─ render markdown to the channel&#39;s block format\n                 ├─ truncate to the channel&#39;s block limit with an &quot;and N more&quot; tail\n                 ├─ post\n                 └─ write send row {status: sent | failed, external_id, error}\n</code></pre>\n<p>The cutoff comes from the previous <strong>send row</strong>, not from &quot;now minus 24 hours&quot;. A\njob that failed yesterday must not create a hole; reading the last successful\ncutoff makes the next run cover both days.</p>\n<h3 id=\"failure-behaviour-at-each-boundary\">Failure behaviour at each boundary</h3>\n<ul>\n<li><strong>Forge unreachable at capture.</strong> Nothing to do — the forge retries. Do not\npoll as a fallback unless capture has been missing events long enough to\nmeasure; a poller and a webhook both writing the same natural key is fine, and\na poller replacing the webhook is a different design.</li>\n<li><strong>Store unreachable at capture.</strong> Return a non-2xx so the forge retries. This\nis the one case where failing the request is correct.</li>\n<li><strong>Model unavailable during analysis.</strong> The queue rows stay unanalysed. The next\nnight picks them up. Cap the retry count per row and record the last error, so\na permanently poisonous payload does not occupy the batch forever.</li>\n<li><strong>A single row fails analysis.</strong> Record the failure on that row, continue with\nthe batch. One bad payload must not stop the other twelve.</li>\n<li><strong>The popup cannot reach entries.</strong> Render nothing. A what&#39;s-new popup that\nshows an error dialog on login is worse than a popup that does not appear.</li>\n<li><strong>The channel rejects the digest post.</strong> Write the send row with <code>failed</code> and\nthe error, and leave the cutoff unadvanced so the next run retries the same\nrange.</li>\n</ul>\n<h3 id=\"the-watermark-precisely\">The watermark, precisely</h3>\n<p>The watermark is a per-user timestamp. The set a user sees is:</p>\n<pre><code class=\"language-text\">entries where published_at &gt; max(user.watermark, now - window)\n                          and published_at &lt;= now\n                          and audience matches the user\norder by published_at desc\n</code></pre>\n<p>Two consequences worth stating explicitly:</p>\n<ul>\n<li><strong>A new user sees the window, not the history.</strong> Their watermark is null, so\n<code>max(null, now - window)</code> is the window floor. That is the desired behaviour:\na first login is not a changelog archive.</li>\n<li><strong>Dismissal sets the watermark to the newest entry the user was shown</strong>, not to\n<code>now</code>. If an entry is published while the popup is open, setting the watermark\nto <code>now</code> would swallow it unseen.</li>\n</ul>\n<h3 id=\"announcements\">Announcements</h3>\n<p>An announcement is authored, not derived. It carries:</p>\n<ul>\n<li><code>starts_on</code> — the date it becomes visible. A pinned announcement posts to the\ndigest channel on this date, once.</li>\n<li><code>ends_on</code> — optional. After it, the announcement stops appearing in the popup\neven for users whose watermark predates it.</li>\n<li><code>audience</code> — roles, groups, or &quot;everyone&quot;. Resolved server-side.</li>\n<li><code>pinned</code> — whether it sorts above analysed entries in the popup.</li>\n</ul>\n<p>Announcements and analysed entries share a rendering path and nothing else. Keep\nthem in separate tables: they have different lifecycles, different authorship, and\ndifferent permissions, and merging them produces a table where half the columns\nare always null.</p>\n<h3 id=\"backfill\">Backfill</h3>\n<p>Backfill runs through the same analysis path as the nightly job, with three\nadditions:</p>\n<ol>\n<li><strong>Count the input first</strong> and print an estimate of the model cost before\nanything is called. A month of merged work on a busy repository is a large\nnumber of tokens.</li>\n<li><strong>Cap the batch size</strong> and run batches under an explicit total limit, so a\nmiscounted estimate cannot become an unbounded bill.</li>\n<li><strong>Set <code>published_at</code> from the merge date</strong>, not from the backfill run time.\nOtherwise every historical change appears to have shipped today and every\nuser&#39;s popup shows the entire history at once.</li>\n</ol>\n","words":1024}],"body":"# Release ledger\n\nA user who was away for two weeks comes back and cannot tell what shipped. The\nchangelog is written for the team, the commit log is unreadable, and the release\nnotes stopped in March. A release ledger fixes that one thing: it records every\nmerged change, describes it in plain language, and shows each user only what\nlanded since *they* last looked.\n\nThis skill is the onboarding procedure. It does not ship a library. Its output is\na written implementation map, in the host repository, saying where each part of\nthe system lands on the stack that is actually there.\n\nThree skills divide the work: **`release-ledger`** orchestrates, **`github-webhooks`**\ncaptures, **`describe-changes`** writes the entries. Install the companions from\nthe same pack with `npx skills add crissmoldovan/agent-skills`, and name them in\nthe implementation map rather than reimplementing what they cover.\n\n## The system model\n\nSix stages. Each is a boundary you can build and verify alone.\n\n```text\n  merge event ──► capture ──► queue row (raw payload, unanalysed)\n                                  │\n                        nightly   ▼\n                       analysis ──► ledger entry {kind, title, short, medium, detail}\n                                  │\n                announcements ────┤\n              (hand-written,      │\n               scheduled,         ▼\n               audience-targeted) ├──► per-user popup   (entries newer than the user's watermark)\n                                  └──► daily digest     (entries since the previous digest)\n```\n\n1. **Capture** writes the raw merge payload and nothing else. It never calls a\n   model, never blocks, and never drops a row because a later stage might not\n   like it.\n2. **The queue** is the unanalysed set. It exists so capture and analysis fail\n   independently: a model outage costs a delayed entry, not a lost one.\n3. **Nightly analysis** turns each queued payload into one ledger entry with a\n   classification and three registers of description. This is where\n   `describe-changes` is invoked.\n4. **The popup** is per user. Each user carries a watermark — the timestamp they\n   last acknowledged — and sees entries newer than it, capped at a window.\n5. **The digest** is per channel. It posts entries created since the previous\n   digest to one chat or mail surface, and records the send.\n6. **Announcements** are hand-written entries that bypass capture and analysis.\n   They carry a schedule and an audience, and render in the same surfaces.\n\nRead [the system model reference](references/system-model.md) for the stage\ncontracts, the failure modes at each boundary, and the sequences in text form.\n\n## When to Use\n\n- A product has users who log in intermittently and no reliable way to tell them\n  what changed while they were away.\n- A team ships continuously and the release notes have fallen behind, or were\n  never written for the people who use the product.\n- Someone asks for \"a what's-new popup\" and you need the parts behind it named\n  before anyone writes a migration.\n- A ledger exists partially — capture but no analysis, entries but no per-user\n  watermark — and you need to know which stage to finish next.\n\nDo not use it to write the notes for one version; that is `release-notes`, in\nthis pack, which makes the semver call, writes the changelog entry and cuts the\nrelease itself. This skill has none of\nthat machinery. Do not use it to build a curated marketing changelog — a ledger\nis derived from merged work, and a page nobody derives is a CMS, not this. Do not use it to notify users of incidents or outages; those need\na status surface with different latency guarantees.\n\n## Prerequisites\n\n1. **A merged-work source you can name.** Either a forge that emits merge events,\n   or a human process that will write entries by hand. Both are supported; a\n   ledger with neither has no input.\n   **Complete when:** you can state the source and, for automatic capture, point\n   at the endpoint that will receive the events.\n2. **A durable store with a unique constraint.** Capture must be able to insert\n   the same event twice and keep one row — forges replay deliveries.\n   **Complete when:** you have named the store and the natural key (repository\n   plus change number is the usual one).\n3. **A scheduler that can run a job once a day.** Cron, a hosted job runner, or a\n   queue with delayed jobs. Analysis and digest are two separate schedules.\n   **Complete when:** you have run a no-op job on that scheduler and seen it fire.\n4. **An authenticated user identity.** The watermark hangs on it. Anonymous\n   sessions can be given a ledger, but it degrades to \"latest N entries\" and you\n   should say so out loud rather than pretend otherwise.\n   **Complete when:** you can name the column the watermark row will key on.\n5. **A decision on the analysis model.** Which model, reached how, and who pays.\n   **Complete when:** the model is reachable from the job runner, not only from a\n   developer machine, and a per-run cost estimate can be printed before the first\n   batch.\n\n## Procedure\n\n1. **Investigate the host application against a bounded checklist.** Framework\n   and version; datastore and migration idiom; job runner and how a schedule is\n   declared; auth and the user table; the chat or mail surface and its posting\n   helper; existing inbound webhook handling; how markdown is rendered in the UI;\n   how roles or groups are represented. Work\n   [the onboarding checklist](references/onboarding-checklist.md) and stop when\n   its items are answered. Do not read the whole codebase.\n2. **Write `docs/release-ledger/implementation.md` in the host repository.** One\n   section per stage of the system model, each naming the concrete file, table,\n   schedule, and helper that will carry it on *this* stack. Record what you could\n   not determine as open questions with a named owner. This document is the\n   deliverable of onboarding; everything after it is implementation against a map\n   that already exists.\n3. **Design the tables from the reference schema.** Queue, entries, dismissals,\n   announcements, sends. Adapt names to the host's conventions and keep the\n   invariants. [The data model reference](references/data-model.md) carries\n   portable SQL and the reason each constraint is there.\n4. **Choose the capture mode, and offer the choice.** Automatic capture from a\n   forge is the default; the `github-webhooks` skill covers endpoint setup,\n   signature verification, and event routing for it — install it from the same\n   pack with `npx skills add crissmoldovan/agent-skills` and follow it rather than\n   hand-rolling a verifier. Manual-only is a first-class mode: announcements plus\n   agent-written entries, no endpoint, no secret to rotate. Ask, and record the\n   answer in the implementation map. The user configures the webhook itself later,\n   from that document.\n5. **Delegate entry authoring to `describe-changes`.** The analysis job owns\n   batching, retry, cost control, and persistence. What an entry *says* — the\n   classification and the three registers, anchored in the diff — belongs to\n   `describe-changes`, and its output contract is what the entry columns should\n   mirror. Do not invent a second description format.\n6. **Build capture first and let it run before analysis exists.** A day of\n   captured payloads is the test fixture for everything downstream, and it proves\n   the queue survives replays before a model bill is attached to it.\n7. **Add analysis, then the popup, then the digest, then announcements.** Each\n   stage is useful on its own. Stop wherever it stops paying.\n8. **State the limitations in the implementation map.** If capture stores only\n   the event payload, entries cannot cite files the payload does not carry, and\n   changes with no linked ticket will have no reporter. Write that down; do not\n   let the popup render an empty \"reported by\" stub instead.\n\n### Core invariants\n\n- **The dismissal watermark is capped at a window** — thirty days is a sensible\n  default. A user returning after a year gets the last thirty days, not four\n  hundred entries.\n- **Every text field is markdown**, in every stage. One renderer, one escaping\n  story, no HTML passthrough.\n- **Announcements are not analysed entries.** Separate table, separate authoring\n  path, same rendering. A pinned announcement carries a start date, an optional\n  end date, and an audience.\n- **Digest sends are recorded and fail loud.** Every attempt writes a row with a\n  status. A zero-entry day records `skipped` with a reason. A run that posted\n  nothing and reports success is the bug this invariant exists to prevent.\n- **Capture is idempotent on the natural key.** Insert, on conflict do nothing.\n\n## Usage Examples\n\n```text\nOnboard a release ledger into this app. Run the stack investigation first and\nshow me the answers before you write anything, then produce\ndocs/release-ledger/implementation.md mapping every stage onto what is actually\nhere. Do not create tables yet.\n```\n\n```text\nWe already capture merged pull requests into a queue table but nothing reads it.\nAdd the nightly analysis stage only: batch the queue, classify and describe each\nrow with describe-changes, and write one ledger entry per change. Print a cost\nestimate for the backlog before the first model call.\n```\n\n```text\nManual ledger, no webhook. Set up the entries, dismissals, and announcements\ntables plus the per-user popup with a 30-day watermark cap, and give me an admin\nform to write an announcement with a start date and an audience.\n```\n\n## Pitfalls\n\n- **Capture placed inside an existing handler that returns early.** If merge\n  events already flow into a handler that filters them — for tickets, for labels,\n  for a naming convention — capture placed inside it inherits that filter and\n  silently loses whatever the filter drops. Measure how many events the existing\n  handler discards before deciding where to hook in. Capture belongs beside such\n  a handler, not within it.\n- **Analysing at capture time.** It couples a model call to a webhook response,\n  which has a hard timeout, and makes every replayed delivery cost money. Capture\n  writes a row; analysis runs later.\n- **A watermark stored per device instead of per user.** Local storage looks\n  simpler and gives the same user a fresh backlog in every browser. The watermark\n  is server state.\n- **Looping and awaiting over the queue.** One model call at a time turns a\n  fifteen-minute batch into hours and gives no partial progress on failure.\n  Batch, cap the batch size, and let each item fail on its own.\n- **A digest that treats \"nothing to send\" as success.** Record it as skipped,\n  with the reason, so an empty channel and a broken job look different in the\n  send table.\n- **Rendering markdown with raw HTML enabled.** Entry text derives from change\n  titles and bodies that anyone with commit access can write. Render markdown,\n  disable HTML passthrough, use an explicit component map.\n- **Targeting announcements from the client.** If the browser asks for \"all\n  announcements\" and filters by audience locally, the audience is advisory.\n  Filter server-side and return only what the caller may see.\n- **Backfilling without an estimate.** A month of merged work is a large model\n  bill arriving as a surprise. Count the input first, print the estimate, cap the\n  batch, and run it through the same path as the nightly job.\n\n## Verification\n\n- [ ] The stack investigation was completed against the checklist and its answers reported.\n- [ ] `docs/release-ledger/implementation.md` exists in the host repository and names a concrete file, table, schedule, or helper for every stage.\n- [ ] Capture mode was offered as a choice and the answer recorded.\n- [ ] Capture is idempotent: the same event delivered twice produces one row, verified by replaying a delivery.\n- [ ] Capture does not sit behind a filter that discards events the ledger needs.\n- [ ] No model call happens on the capture path.\n- [ ] Entry text follows the `describe-changes` output contract, not a second format.\n- [ ] The watermark is server-side, per user, and capped at a window.\n- [ ] Announcements are stored separately from analysed entries and carry schedule and audience.\n- [ ] Audience filtering happens server-side.\n- [ ] Every digest attempt writes a send row, and a zero-entry day is recorded as skipped with a reason.\n- [ ] Markdown rendering has raw HTML disabled.\n- [ ] Known limitations, including missing reporters, are written down rather than rendered as empty stubs.\n\n## Deeper reading\n\n- [System model](references/system-model.md): the six stages in depth, the\n  contract at each boundary, sequences in text form, and what each stage may do\n  when the next one is down.\n- [Onboarding checklist](references/onboarding-checklist.md): the bounded stack\n  investigation, one question per line, with what each answer decides.\n- [Data model](references/data-model.md): portable reference schema for the\n  queue, entries, dismissals, announcements, and sends, with the reason behind\n  each constraint and the watermark query.\n","bodyHtml":"<h2 id=\"release-ledger\">Release ledger</h2>\n<p>A user who was away for two weeks comes back and cannot tell what shipped. The\nchangelog is written for the team, the commit log is unreadable, and the release\nnotes stopped in March. A release ledger fixes that one thing: it records every\nmerged change, describes it in plain language, and shows each user only what\nlanded since <em>they</em> last looked.</p>\n<p>This skill is the onboarding procedure. It does not ship a library. Its output is\na written implementation map, in the host repository, saying where each part of\nthe system lands on the stack that is actually there.</p>\n<p>Three skills divide the work: <strong><code>release-ledger</code></strong> orchestrates, <strong><code>github-webhooks</code></strong>\ncaptures, <strong><code>describe-changes</code></strong> writes the entries. Install the companions from\nthe same pack with <code>npx skills add crissmoldovan/agent-skills</code>, and name them in\nthe implementation map rather than reimplementing what they cover.</p>\n<h3 id=\"the-system-model\">The system model</h3>\n<p>Six stages. Each is a boundary you can build and verify alone.</p>\n<pre><code class=\"language-text\">  merge event ──► capture ──► queue row (raw payload, unanalysed)\n                                  │\n                        nightly   ▼\n                       analysis ──► ledger entry {kind, title, short, medium, detail}\n                                  │\n                announcements ────┤\n              (hand-written,      │\n               scheduled,         ▼\n               audience-targeted) ├──► per-user popup   (entries newer than the user&#39;s watermark)\n                                  └──► daily digest     (entries since the previous digest)\n</code></pre>\n<ol>\n<li><strong>Capture</strong> writes the raw merge payload and nothing else. It never calls a\nmodel, never blocks, and never drops a row because a later stage might not\nlike it.</li>\n<li><strong>The queue</strong> is the unanalysed set. It exists so capture and analysis fail\nindependently: a model outage costs a delayed entry, not a lost one.</li>\n<li><strong>Nightly analysis</strong> turns each queued payload into one ledger entry with a\nclassification and three registers of description. This is where\n<code>describe-changes</code> is invoked.</li>\n<li><strong>The popup</strong> is per user. Each user carries a watermark — the timestamp they\nlast acknowledged — and sees entries newer than it, capped at a window.</li>\n<li><strong>The digest</strong> is per channel. It posts entries created since the previous\ndigest to one chat or mail surface, and records the send.</li>\n<li><strong>Announcements</strong> are hand-written entries that bypass capture and analysis.\nThey carry a schedule and an audience, and render in the same surfaces.</li>\n</ol>\n<p>Read <a href=\"references/system-model.md\">the system model reference</a> for the stage\ncontracts, the failure modes at each boundary, and the sequences in text form.</p>\n<h3 id=\"when-to-use\">When to Use</h3>\n<ul>\n<li>A product has users who log in intermittently and no reliable way to tell them\nwhat changed while they were away.</li>\n<li>A team ships continuously and the release notes have fallen behind, or were\nnever written for the people who use the product.</li>\n<li>Someone asks for &quot;a what&#39;s-new popup&quot; and you need the parts behind it named\nbefore anyone writes a migration.</li>\n<li>A ledger exists partially — capture but no analysis, entries but no per-user\nwatermark — and you need to know which stage to finish next.</li>\n</ul>\n<p>Do not use it to write the notes for one version; that is <code>release-notes</code>, in\nthis pack, which makes the semver call, writes the changelog entry and cuts the\nrelease itself. This skill has none of\nthat machinery. Do not use it to build a curated marketing changelog — a ledger\nis derived from merged work, and a page nobody derives is a CMS, not this. Do not use it to notify users of incidents or outages; those need\na status surface with different latency guarantees.</p>\n<h3 id=\"prerequisites\">Prerequisites</h3>\n<ol>\n<li><strong>A merged-work source you can name.</strong> Either a forge that emits merge events,\nor a human process that will write entries by hand. Both are supported; a\nledger with neither has no input.\n<strong>Complete when:</strong> you can state the source and, for automatic capture, point\nat the endpoint that will receive the events.</li>\n<li><strong>A durable store with a unique constraint.</strong> Capture must be able to insert\nthe same event twice and keep one row — forges replay deliveries.\n<strong>Complete when:</strong> you have named the store and the natural key (repository\nplus change number is the usual one).</li>\n<li><strong>A scheduler that can run a job once a day.</strong> Cron, a hosted job runner, or a\nqueue with delayed jobs. Analysis and digest are two separate schedules.\n<strong>Complete when:</strong> you have run a no-op job on that scheduler and seen it fire.</li>\n<li><strong>An authenticated user identity.</strong> The watermark hangs on it. Anonymous\nsessions can be given a ledger, but it degrades to &quot;latest N entries&quot; and you\nshould say so out loud rather than pretend otherwise.\n<strong>Complete when:</strong> you can name the column the watermark row will key on.</li>\n<li><strong>A decision on the analysis model.</strong> Which model, reached how, and who pays.\n<strong>Complete when:</strong> the model is reachable from the job runner, not only from a\ndeveloper machine, and a per-run cost estimate can be printed before the first\nbatch.</li>\n</ol>\n<h3 id=\"procedure\">Procedure</h3>\n<ol>\n<li><strong>Investigate the host application against a bounded checklist.</strong> Framework\nand version; datastore and migration idiom; job runner and how a schedule is\ndeclared; auth and the user table; the chat or mail surface and its posting\nhelper; existing inbound webhook handling; how markdown is rendered in the UI;\nhow roles or groups are represented. Work\n<a href=\"references/onboarding-checklist.md\">the onboarding checklist</a> and stop when\nits items are answered. Do not read the whole codebase.</li>\n<li><strong>Write <code>docs/release-ledger/implementation.md</code> in the host repository.</strong> One\nsection per stage of the system model, each naming the concrete file, table,\nschedule, and helper that will carry it on <em>this</em> stack. Record what you could\nnot determine as open questions with a named owner. This document is the\ndeliverable of onboarding; everything after it is implementation against a map\nthat already exists.</li>\n<li><strong>Design the tables from the reference schema.</strong> Queue, entries, dismissals,\nannouncements, sends. Adapt names to the host&#39;s conventions and keep the\ninvariants. <a href=\"references/data-model.md\">The data model reference</a> carries\nportable SQL and the reason each constraint is there.</li>\n<li><strong>Choose the capture mode, and offer the choice.</strong> Automatic capture from a\nforge is the default; the <code>github-webhooks</code> skill covers endpoint setup,\nsignature verification, and event routing for it — install it from the same\npack with <code>npx skills add crissmoldovan/agent-skills</code> and follow it rather than\nhand-rolling a verifier. Manual-only is a first-class mode: announcements plus\nagent-written entries, no endpoint, no secret to rotate. Ask, and record the\nanswer in the implementation map. The user configures the webhook itself later,\nfrom that document.</li>\n<li><strong>Delegate entry authoring to <code>describe-changes</code>.</strong> The analysis job owns\nbatching, retry, cost control, and persistence. What an entry <em>says</em> — the\nclassification and the three registers, anchored in the diff — belongs to\n<code>describe-changes</code>, and its output contract is what the entry columns should\nmirror. Do not invent a second description format.</li>\n<li><strong>Build capture first and let it run before analysis exists.</strong> A day of\ncaptured payloads is the test fixture for everything downstream, and it proves\nthe queue survives replays before a model bill is attached to it.</li>\n<li><strong>Add analysis, then the popup, then the digest, then announcements.</strong> Each\nstage is useful on its own. Stop wherever it stops paying.</li>\n<li><strong>State the limitations in the implementation map.</strong> If capture stores only\nthe event payload, entries cannot cite files the payload does not carry, and\nchanges with no linked ticket will have no reporter. Write that down; do not\nlet the popup render an empty &quot;reported by&quot; stub instead.</li>\n</ol>\n<h4 id=\"core-invariants\">Core invariants</h4>\n<ul>\n<li><strong>The dismissal watermark is capped at a window</strong> — thirty days is a sensible\ndefault. A user returning after a year gets the last thirty days, not four\nhundred entries.</li>\n<li><strong>Every text field is markdown</strong>, in every stage. One renderer, one escaping\nstory, no HTML passthrough.</li>\n<li><strong>Announcements are not analysed entries.</strong> Separate table, separate authoring\npath, same rendering. A pinned announcement carries a start date, an optional\nend date, and an audience.</li>\n<li><strong>Digest sends are recorded and fail loud.</strong> Every attempt writes a row with a\nstatus. A zero-entry day records <code>skipped</code> with a reason. A run that posted\nnothing and reports success is the bug this invariant exists to prevent.</li>\n<li><strong>Capture is idempotent on the natural key.</strong> Insert, on conflict do nothing.</li>\n</ul>\n<h3 id=\"usage-examples\">Usage Examples</h3>\n<pre><code class=\"language-text\">Onboard a release ledger into this app. Run the stack investigation first and\nshow me the answers before you write anything, then produce\ndocs/release-ledger/implementation.md mapping every stage onto what is actually\nhere. Do not create tables yet.\n</code></pre>\n<pre><code class=\"language-text\">We already capture merged pull requests into a queue table but nothing reads it.\nAdd the nightly analysis stage only: batch the queue, classify and describe each\nrow with describe-changes, and write one ledger entry per change. Print a cost\nestimate for the backlog before the first model call.\n</code></pre>\n<pre><code class=\"language-text\">Manual ledger, no webhook. Set up the entries, dismissals, and announcements\ntables plus the per-user popup with a 30-day watermark cap, and give me an admin\nform to write an announcement with a start date and an audience.\n</code></pre>\n<h3 id=\"pitfalls\">Pitfalls</h3>\n<ul>\n<li><strong>Capture placed inside an existing handler that returns early.</strong> If merge\nevents already flow into a handler that filters them — for tickets, for labels,\nfor a naming convention — capture placed inside it inherits that filter and\nsilently loses whatever the filter drops. Measure how many events the existing\nhandler discards before deciding where to hook in. Capture belongs beside such\na handler, not within it.</li>\n<li><strong>Analysing at capture time.</strong> It couples a model call to a webhook response,\nwhich has a hard timeout, and makes every replayed delivery cost money. Capture\nwrites a row; analysis runs later.</li>\n<li><strong>A watermark stored per device instead of per user.</strong> Local storage looks\nsimpler and gives the same user a fresh backlog in every browser. The watermark\nis server state.</li>\n<li><strong>Looping and awaiting over the queue.</strong> One model call at a time turns a\nfifteen-minute batch into hours and gives no partial progress on failure.\nBatch, cap the batch size, and let each item fail on its own.</li>\n<li><strong>A digest that treats &quot;nothing to send&quot; as success.</strong> Record it as skipped,\nwith the reason, so an empty channel and a broken job look different in the\nsend table.</li>\n<li><strong>Rendering markdown with raw HTML enabled.</strong> Entry text derives from change\ntitles and bodies that anyone with commit access can write. Render markdown,\ndisable HTML passthrough, use an explicit component map.</li>\n<li><strong>Targeting announcements from the client.</strong> If the browser asks for &quot;all\nannouncements&quot; and filters by audience locally, the audience is advisory.\nFilter server-side and return only what the caller may see.</li>\n<li><strong>Backfilling without an estimate.</strong> A month of merged work is a large model\nbill arriving as a surprise. Count the input first, print the estimate, cap the\nbatch, and run it through the same path as the nightly job.</li>\n</ul>\n<h3 id=\"verification\">Verification</h3>\n<ul>\n<li><input disabled=\"\" type=\"checkbox\"> The stack investigation was completed against the checklist and its answers reported.</li>\n<li><input disabled=\"\" type=\"checkbox\"> <code>docs/release-ledger/implementation.md</code> exists in the host repository and names a concrete file, table, schedule, or helper for every stage.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Capture mode was offered as a choice and the answer recorded.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Capture is idempotent: the same event delivered twice produces one row, verified by replaying a delivery.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Capture does not sit behind a filter that discards events the ledger needs.</li>\n<li><input disabled=\"\" type=\"checkbox\"> No model call happens on the capture path.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Entry text follows the <code>describe-changes</code> output contract, not a second format.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The watermark is server-side, per user, and capped at a window.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Announcements are stored separately from analysed entries and carry schedule and audience.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Audience filtering happens server-side.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Every digest attempt writes a send row, and a zero-entry day is recorded as skipped with a reason.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Markdown rendering has raw HTML disabled.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Known limitations, including missing reporters, are written down rather than rendered as empty stubs.</li>\n</ul>\n<h3 id=\"deeper-reading\">Deeper reading</h3>\n<ul>\n<li><a href=\"references/system-model.md\">System model</a>: the six stages in depth, the\ncontract at each boundary, sequences in text form, and what each stage may do\nwhen the next one is down.</li>\n<li><a href=\"references/onboarding-checklist.md\">Onboarding checklist</a>: the bounded stack\ninvestigation, one question per line, with what each answer decides.</li>\n<li><a href=\"references/data-model.md\">Data model</a>: portable reference schema for the\nqueue, entries, dismissals, announcements, and sends, with the reason behind\neach constraint and the watermark query.</li>\n</ul>\n","outline":["The system model","When to Use","Prerequisites","Procedure","Usage Examples","Pitfalls","Verification","Deeper reading"],"words":2057}
