diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 446794688..b6613db1d 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -20,6 +20,12 @@ Upstream's final release was **`v26.3.0`** (archived). Our line continues from t | `v26.3.1` | Upstream 26.3.0 **rebuilt on our infra** (Gitea CI/registry, fork ffmpeg base) — **no application changes**. A patch bump, because nothing functional changed. | | `v26.4.0` | Reserved for our **first release that carries actual app changes** (e.g. the #1 M3U fix). Later 2026 releases: `26.5.0`, `26.6.0`, …; a new year resets to `27.1.0`. | +**Before cutting a release — consolidate `docs/decisions.md`.** The log is append-only between releases +(ersatztv#303 H9), so a release boundary is where superseded entries get pruned/merged and the Index +refreshed. Fold and drop any entry marked `> **Superseded …**`, then commit with `[decisions-edit]` in +the message (the append-only guard blocks history edits otherwise). Mark-and-keep during the arc, +consolidate here. + **Cutting a release:** push a `vYY.N.P` tag on `main` → CI builds `:prod` + `:` + `:`. Prod's `media-servers` compose **follows the floating `:prod` tag** (Timothy's decision, 2026-07-11 — reverted from the version-pin approach), so **Komodo's Global Auto Update** (`poll_for_updates` is on for all stacks) detects the new `:prod` digest and redeploys the media-servers stack — no CI push to server-management, no manual pin bump. ⚠️ **Open caveat:** confirm Global Auto Update runs the #553 host-side **pre-deploy backup** hook; if it doesn't, a release would deploy without a backup — fall back to a manual `execute DeployStack media-servers` (which *does* run pre-deploy). See `homelab-docs/Docker/ErsatzTV.md` + the `komodo` skill. **Gotcha:** never put a `[skip ci]` token in a commit you intend to tag — Gitea reads skip-ci from the *tagged* commit and will **suppress the release build**. (Also, `workflow_dispatch` on a tag ref isn't supported on this Gitea version, so the tag *push* must do the triggering.) Release commits, and anything you'll tag, must not contain skip-ci. @@ -106,8 +112,19 @@ one case that's easy to forget and easy to detect: a PR that touches a SPA scree `::warning::` annotation (never fails the build — it's a reminder, not a gate; prose-doc gates get gamed with token edits). Deliberately has **no** `setup-dotnet`/`setup-node` (and thus no `actions/cache`), so it can't hit the cache-save hangs seen on the VM-127 runner -(server-management#570). It does not cover the other doc obligations in the CLAUDE.md table -(api-conventions, domain-model, decisions, spa-conventions) — those stay on the author. +(server-management#570). It does not cover the remaining doc obligations in the CLAUDE.md table +(domain-model, spa-conventions) — those stay on the author. (The API contract is mechanized by the +blocking `api-docs` job, and `docs/decisions.md` by the blocking `decisions-guard` job below.) + +### `decisions-guard` job (blocking, PR-only) + +Enforces the `docs/decisions.md` append-only convention (ersatztv#303 H9): fails a PR whose +merge-base diff **deletes or modifies** any existing line of that file, unless a commit in the range +carries the `[decisions-edit]` token (for a factual fix or a documented supersession — see the +`decisions.md` header). Pure insertions (a normal new entry: TOC line + appended block) pass. It runs +the same `.claude/hooks/decisions-guard.sh` the Husky `commit-msg` hook uses (`range` mode vs +`staged` mode), so local and CI enforcement share one implementation and can't drift. Like +`docs-reminder`, it's a seconds-long `git diff` with no dotnet/node setup (`runs-on: small`). ## Dockerfile notes (`docker/Dockerfile`) @@ -287,15 +304,23 @@ entirely in `web/`), the wiring is: ErsatzTV.sln --verify-no-changes --include ` — a formatting violation blocks the commit. The .cs step is **skipped entirely when no .cs is staged**, so web-only commits don't pay the sln-load cost; when it does run it's scoped to the staged - files (~6-7s wall in practice, dominated by the workspace load). + files (~6-7s wall in practice, dominated by the workspace load); (c) **H3** (ersatztv#303) — + refuses a staged **root-level `*.png`** (`git diff --cached --name-only | grep -E '^[^/]+\.png$'`), + belt-and-suspenders with the `.gitignore` screenshot rule so a forced `git add -f` still can't land + a review/debug screenshot at the repo root. Nested `*.png` (real assets) pass. 2. **`pre-push`** — CI-parity gate: `cd web && npm run check:api && npm run lint && npm run typecheck && npm run build`. `check:api` guards generated-OpenAPI drift (`ErsatzTV/wwwroot/openapi/v1.json` → `web/src/api/generated/v1.d.ts`); the full lint/typecheck/build catch a staged change that breaks an *unstaged* file (lint-staged only sees staged files). Any failure blocks the push. -3. **`commit-msg`** — enforces the CLAUDE.md protocol: the message must carry a - `Co-Authored-By:` trailer, else the commit is rejected. Merge commits are exempt - (detected via `git rev-parse --verify MERGE_HEAD`). +3. **`commit-msg`** — (a) enforces the CLAUDE.md protocol: the message must carry a + `Co-Authored-By:` trailer, else the commit is rejected (merge commits are exempt, detected + via `git rev-parse --verify MERGE_HEAD`); (b) **H9** (ersatztv#303) — runs + `.claude/hooks/decisions-guard.sh staged "$1"`, which blocks the commit if it deletes/modifies + an existing line of `docs/decisions.md` unless the message carries the `[decisions-edit]` token. + Append-only enforcement; see `docs/decisions.md` header for the supersession/consolidation rules. + The same script backs the blocking **`decisions-guard`** CI job (`range` mode over the PR's + merge-base diff) so local and CI enforcement can't drift. - **Worktree/subdir gotcha**: git exports `GIT_DIR` (and friends) while running hooks. In a worktree or any subdir, an explicit `GIT_DIR` makes nested `git` commands mislocate the diff --git a/docs/decisions.md b/docs/decisions.md index f34aadbd6..473278ca1 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -1,9 +1,23 @@ # Decisions — append-only log Purpose: why the codebase does what it does, so agents don't "fix" an established convention or -relitigate a settled call. Append new entries at the bottom in date order; never edit or delete -past entries except to fix a factual error. **Update this doc in the same PR that changes any fact -below (or that establishes a new convention worth recording).** +relitigate a settled call. Append new entries at the bottom in date order (plus a TOC line in the +Index); **update this doc in the same PR that changes any fact below** (or that establishes a new +convention worth recording). + +**Append-only, enforced (ersatztv#303 H9).** A commit or PR that *deletes or modifies* an existing +line is blocked by the Husky `commit-msg` hook and the CI `decisions-guard` job; insertions anywhere +are always allowed. The block is lifted only by the **`[decisions-edit]`** token in the commit +message, for the two legitimate reasons to touch history: +- **Fix a factual error** in a past entry. +- **Supersede a reversed decision** — add the new dated entry, then prepend a + `> **Superseded YYYY-MM by .**` banner to the old entry and tag its Index line + `(superseded)`. Keep the old entry — *why we changed our mind* is the point; never silently rewrite it. + +**Consolidation** (prune/merge superseded entries, refresh the Index) is a step in the release +checklist (`docs/ci-cd.md` → Versioning & releases), done at each release/milestone with +`[decisions-edit]` — not ad hoc mid-arc. This keeps append-only from accreting stale, contradictory +entries between releases. --- @@ -56,6 +70,7 @@ below (or that establishes a new convention worth recording).** - [2026-07-12 — Browser SPA session auth: `/api` accepts session OR machine key (#295 PR1, server-only)](#2026-07-12--browser-spa-session-auth-api-accepts-session-or-machine-key-295-pr1-server-only) - [2026-07-12 — Merge-consent derived from state via a `## Done-when` issue checklist (#303 H6)](#2026-07-12--merge-consent-derived-from-state-via-a--done-when-issue-checklist-303-h6) - [2026-07-12 — Blocking CI gate for API-contract artifacts (#303 H4/H5)](#2026-07-12--blocking-ci-gate-for-api-contract-artifacts-303-h45) +- [2026-07-12 — decisions.md is append-only, enforced; root-screenshot guard (#303 H9/H3)](#2026-07-12--decisionsmd-is-append-only-enforced-root-screenshot-guard-303-h9h3) --- @@ -1323,3 +1338,24 @@ including the 244 auth `security`/`401` blocks), so CI can trust regenerate-and- local-only: `update-openapi.sh` runs `dotnet-getdocument` against the already-built assembly, so a stale `bin/` silently yields a stale spec — always `dotnet build` first (see `api-conventions.md` §5). CI is immune (no `bin/` on a fresh checkout). + +## 2026-07-12 — decisions.md is append-only, enforced; root-screenshot guard (#303 H9/H3) + +**This log is append-only by construction, not just by convention.** A commit or PR that deletes or +modifies an existing line of `docs/decisions.md` is blocked — by the Husky `commit-msg` hook +(`.claude/hooks/decisions-guard.sh staged`) locally and the blocking `decisions-guard` CI job (same +script, `range` mode) on PRs. Insertions anywhere are always allowed, so a normal new entry (TOC line +near the top + a block appended at the bottom, both pure insertions) passes untouched. Detection is +`git diff --numstat` deleted-count > 0, which is robust to markdown `-` list markers (a byte-level `-` +prefix would false-match). The block is lifted only by the literal **`[decisions-edit]`** token in the +commit message, reserved for two cases: fixing a factual error, and superseding a reversed decision +(add the new entry, prepend a `> **Superseded …**` banner to the old one, tag its Index line +`(superseded)` — keep the old rationale, never silently rewrite). **Consolidation** of superseded +entries is a release-checklist step (`docs/ci-cd.md` → Versioning & releases), so append-only doesn't +accrete contradictory history between releases (Timothy's call, 2026-07-12: mark-and-keep on reversal, +consolidate at each milestone). + +Companion guard **H3**: the Husky `pre-commit` hook refuses a staged **root-level `*.png`** (a +review/debug screenshot dropped at the repo root) — belt-and-suspenders with the `.gitignore` rule, so +a forced `git add -f` still can't land one. Nested `*.png` (real assets) are unaffected. Rationale for +both: the methodology review (#303) — make the process rules derivations/hooks, not prose to remember.