From 940bc5b160f40879e965c9b603e9847508833052 Mon Sep 17 00:00:00 2001 From: Jose Lago Date: Fri, 16 Oct 2026 17:56:09 +0200 Subject: [PATCH] =?UTF-8?q?chore(parity):=20record=20prod=E2=87=84dev?= =?UTF-8?q?=E2=87=84repo=20parity=20execution=20+=20fix=20stale=20schedule?= =?UTF-8?q?=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - docs/prod-parity-plan.md: audit + phased plan, now marked EXECUTED with the autonomous decisions (target=HEAD, data preserved, bonus shipped at 0, whole-tree deploy). - docs/releases/2026-10-16.md: append the parity release record (schema + ledger + whole-tree code deploy, backups/rollback tags, 151/151 e2e, 46-assert live rollback smoke, autosync preserved, dev==prod==repo). - e2e/admin-schedule.spec.ts: drop the stale 'Evaluate' disabled assertion (button removed from the codebase in 821907b). Co-authored-by: Stephan Charles Co-authored-by: Amelia Hernandez Co-authored-by: Markus Franz Co-authored-by: Sabrina Hota Co-authored-by: Nilüfer Doğan --- docs/prod-parity-plan.md | 174 +++++++++++++++++++++++++++++++ docs/releases/2026-10-16.md | 75 +++++++++++++ e2e/tests/admin-schedule.spec.ts | 1 - 3 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 docs/prod-parity-plan.md diff --git a/docs/prod-parity-plan.md b/docs/prod-parity-plan.md new file mode 100644 index 0000000..c1f0b43 --- /dev/null +++ b/docs/prod-parity-plan.md @@ -0,0 +1,174 @@ +# Prod ⇄ Dev ⇄ Repo Parity Plan + +Goal (as requested): production must be **identical to development in schema and +everything**, done correctly. + +## Source-of-truth decision (important) + +The audit shows **dev is not a faithful mirror of the repo either**, so "identical +to dev" is the wrong literal target — it would copy a *broken* state to prod. The +correct source of truth is **git `HEAD`**, and both dev and prod are brought to it. + +Evidence (read-only audit, 2026-10-16): + +- **Schema diff (dev vs prod):** the *only* difference is one function — + `get_talk_cohort` exists in dev, not in prod. Everything else (tables, columns, + indexes, policies, triggers, grants, other functions) is byte-identical. +- **But neither dev nor prod has the full `20260920000000_talk_networking` + migration.** Both are missing: + - `events.talk_networking_bonus` column, + - the re-created `accept_connection` (prod **and** dev still return the old + `public.connections` shape with **no `shared_talk`**), + - the widened `points_log.category` CHECK (no `'talk_networking'`). + Dev only has part 3 (`get_talk_cohort`) — a partial, inconsistent state. +- **Repo code depends on the full migration**: `Networking.tsx` reads + `event.talk_networking_bonus` + calls `getTalkCohort`; `Events.tsx` saves + `talk_networking_bonus`; `Connections.tsx`/`acceptConnection` expect + `shared_talk`; `Reports.tsx` calls the sidecar `POST /export`. +- **Ledger:** dev and prod ledgers are *identical* (29 rows) and both omit the + same 9 September migrations — those were applied to both schemas before ledger + tracking existed. So the ledger is not the real delta; the schema dump is. +- **Code drift (prod behind repo, strict subset):** + - sidecar `server.js` 632 lines (prod) vs 933 (repo); prod has **no `/export` + route** and **no `pdfkit`** dependency. Repo sidecar still contains all the + pretix code (autosync preserved). + - admin: prod lacks `views/Reports.tsx`; `App/api/types/Activity/Events` are + behind. Every "prod-only" line is stale (the repo retains the feature). + - attendee: prod behind (no Networking quick-action, `getTalkCohort`, + composite `accept_connection`). +- **Config/manifest drift (bidirectional):** + - `apps/sidecar/package.json` — repo adds `pdfkit` (prod lacks). + - `apps/sidecar/Dockerfile` — **prod is better**: `npm ci` + copies + `package-lock.json`; repo uses `npm install`. + - `apps/convivo/nginx.conf.template` — **repo is better**: adds + `Cache-Control: no-cache` on `index.html` (bundle freshness); prod lacks. + - `apps/admin/vite.config.ts` — repo uses `loadEnv` for the sidecar proxy + target (dev-only; no effect on the built bundle). + - `docker-compose.yml`, both `Dockerfile`s (admin/app), admin nginx template — + already match. + +## Scope boundary + +- **In scope (must be identical):** DB schema, migration ledger, all three apps' + source, build manifests, Dockerfiles, nginx/vite config, Supabase core config. +- **Out of scope (must NOT be overwritten):** production **data** (real + attendees/registrations), and **secrets/env** (`.env`, pretix API key, SMTP, + JWT, GoTrue/kong runtime). "Identical" applies to committed files + schema, not + live data or credentials. + +## Plan (phased, each phase gated by verification) + +### Phase 0 — Fold prod's genuine improvements into the repo first +So the repo becomes the single superset and "copy repo → prod" loses nothing: +1. `apps/sidecar/Dockerfile`: adopt prod's `npm ci` + `COPY package-lock.json`. +2. Commit; verify a clean `npm ci` build locally. + +### Phase 1 — Schema parity (dev **and** prod → repo) +1. Full DB backup of prod (and dev) before any DDL. +2. Apply `20260920000000_talk_networking` to **both** dev and prod + (idempotent: `add column if not exists`, `drop … if exists` + recreate, + `create or replace`, widened CHECK). Record its ledger row. +3. Backfill ledger rows for the other 8 September migrations in **both** + (already applied; just recorded) so `ledger == repo migration set`. +4. **Gate:** re-dump both schemas, normalized diff must be **empty**, and both + ledgers must list all 38 repo migrations. +5. **Live-behavior note:** the new `accept_connection` awards + `talk_networking_bonus` (default **2**) to same-talk pairs. On prod this is a + real scoring change. Decide: ship with default 2, or set the active event's + bonus to 0 at cutover and enable later. + +### Phase 2 — Code parity (prod = clean checkout of repo `HEAD`) +Because prod is a strict subset, the correct move is a **whole-tree** deploy of +each app from the repo (not scoped overlays): +1. Replace `apps/{admin,sidecar,convivo}/src`, `package.json`, + `package-lock.json`, `Dockerfile`, `vite.config.ts`, `nginx.conf.template` + with repo `HEAD` versions. +2. **Gate:** build all three locally; record bundle hashes. + +### Phase 3 — Config parity +1. Adopt repo `HEAD` for the divergent config files (after Phase 0 folds in + prod's `npm ci`). `admin/vite.config.ts` loadEnv is harmless in prod. +2. Leave `docker-compose.yml` (matches) and all `.env`/secrets untouched. + +### Phase 4 — Deploy prod (all three services) +1. Backup dir + rollback image tags for admin, sidecar, app. +2. `docker compose build` + `up -d --no-deps` for **convivo-admin, + convivo-sidecar, convivo-app**. +3. **Gate:** `nginx -t`; live bundles match the locally built hashes; all + containers healthy; pretix autosync + sessionize poller still running; + unrelated Supabase containers unchanged. + +### Phase 5 — End-to-end verification vs prod +1. API-mocked suites (admin + attendee) against `https://admin.appe.at` / + `https://convivo.appe.at`. +2. Live smoke: a real `accept_connection` (verify `shared_talk` + bonus path), + a Reports `/export` (csv/xlsx/pdf), a Networking cohort load, pretix + + sessionize sync runs. +3. Final schema/source/config diffs (prod vs repo) → all empty. + +### Phase 6 — Dev parity +Confirm dev == prod == repo (schema dump + ledger + source). Dev already gets the +Phase 1 migration; re-verify. + +## Validation performed (read-only / rolled-back, no state changed) + +- **`talk_networking` migration applies cleanly.** Ran it inside a transaction + against dev and asserted, then **rolled back** (dev `bonus_col_now=0` after): + `events.talk_networking_bonus` column ✓, `get_talk_cohort` ✓, + `accept_connection` returns `shared_talk` ✓, `points_log` CHECK widened to + include `talk_networking` ✓. So Phase 1 step 2 is proven safe/idempotent. +- **Sidecar `npm ci` is viable.** Repo `apps/sidecar/package-lock.json` already + contains `pdfkit` and matches `package.json` deps (cheerio, ipaddr.js, pdfkit, + xlsx). So Phase 0 (adopt prod's `npm ci` Dockerfile) will resolve cleanly. +- **Schema delta is exactly one function.** Full normalized `pg_dump` diff of + dev vs prod public schema: only `get_talk_cohort` differs (plus pg_dump's + random `\restrict` tokens). This is the authoritative proof that the 8 other + September migrations are already applied in prod (dev, which runs the apps, + has them and is identical to prod except that one function). + +## Execution status + +**EXECUTED 2026-10-16 (autonomous, with a clean-slate fallback authorized).** All +phases completed and verified; prod data preserved (no clean-slate needed). + +- **Phase 0** — `apps/sidecar/Dockerfile` now uses `npm ci` + copies the + lockfile. Committed `93d188a`, pushed to `origin/main`. +- **Phase 1** — `20260920000000_talk_networking` applied to **dev and prod** + (single transaction each; all four objects verified). Ledger backfilled with + the 9 previously-untracked migrations in **both** → `ledger = 38` everywhere. + Active event `talk_networking_bonus` set to **0** on both (no surprise live + scoring change; enable later by setting the column). **Normalized schema diff + dev vs prod = empty** (2583 lines each, byte-identical). +- **Phase 2/3/4** — whole-tree deploy of all three apps from `HEAD`. Prod app + tree now **byte-identical** to the repo payload (`diff -rq` empty); stale + `.orig` backups removed; `docker-compose.yml` already matched. Rollback tags + `convivo-{app,admin,sidecar}:rollback-parity-20261016T154937Z` + full DB dump + + source backup under `/home/APPE/convivo-backups/parity-20261016T154937Z` + and `parity-20261016T154507Z`. +- **Phase 5** — live bundles `index-DtIEihnG.js` (attendee) and + `index-CitZP5XQ.js` (admin) match the local HEAD builds exactly; sidecar + `/health` ok, `/export` route + `pdfkit` present, pretix + sessionize autosync + still running (0 errors). Mocked e2e vs prod **151/151** (after removing one + stale `Evaluate` assertion). Live rollback-only `leaderboard_tests.sql` smoke + on prod: **46 assertions passed**, data unchanged after `ROLLBACK`. +- **Phase 6** — dev == prod == repo for schema, ledger, and app source. + +## Decisions taken (autonomous) + +1. **Target = repo `HEAD`** (not literal dev, which was partially broken). +2. **Data preserved** via the migration path — clean-slate not required. +3. **`talk_networking_bonus` shipped at 0** on the active event (column default + stays 2 for new events; the feature is inert until the column is raised). +4. **Whole-tree deploy** from `HEAD` (the point of "identical"), gated by a + build-before-`up` step so a build failure would have caused zero downtime. + +## Original risk register (now resolved) +1. **Target = repo HEAD, not dev** (dev is partially broken). Confirm. +2. **Data preserved** (prod keeps live data; only schema/code/config synced). Confirm. +3. **Live scoring change** from `talk_networking_bonus` default 2 — enable now or + start at 0? +4. **Whole-tree deploy** replaces prod's scoped-overlay history with a clean repo + checkout — this is the point of "identical", but it is a larger blast radius + than prior deploys. Confirm. +5. Secrets/env/GoTrue/kong runtime are never overwritten — parity is committed + files + schema only. diff --git a/docs/releases/2026-10-16.md b/docs/releases/2026-10-16.md index 15dc4b9..34aad3c 100644 --- a/docs/releases/2026-10-16.md +++ b/docs/releases/2026-10-16.md @@ -82,3 +82,78 @@ tests against it. - `nginx -t` ok; attendee + admin HTTP/HTTPS 200; only `convivo-app` recreated; all unrelated container IDs preserved. - 41/41 mocked browser tests pass against `https://convivo.appe.at`. + +--- + +# Production ⇄ Dev ⇄ Repo Parity (2026-10-16) + +Follow-up release that brought **production fully up to date with the +repository** and made **dev and prod schema-identical**. See +`docs/prod-parity-plan.md` for the audit and phased plan; this records the +execution. + +## Why + +Prior deploys were scoped overlays because production's source had drifted +behind the repo (it predated Networking, `get_talk_cohort`, the composite +`accept_connection`, Reports export, etc.). The audit also showed **dev was not +a clean mirror either** — neither dev nor prod had the full +`20260920000000_talk_networking` migration (both lacked the bonus column, the +`shared_talk`-returning `accept_connection`, and the widened `points_log` +CHECK). The correct source of truth is git `HEAD`; both databases were brought +to it. + +## Schema parity + +- Applied `20260920000000_talk_networking` to **dev and prod** (single + transaction each): `events.talk_networking_bonus`, re-created + `accept_connection` (returns `shared_talk`, awards the bonus via + `_award_points`), widened `points_log.category` CHECK, `get_talk_cohort`. +- Backfilled the migration ledger with the 9 previously-untracked migrations in + **both** databases → `ledger = 38` everywhere (matches the repo file set). +- Set the active event's `talk_networking_bonus` to **0** on both, so the new + bonus path is inert until deliberately enabled (column default stays 2 for + new events). +- **Gate:** normalized `pg_dump` of the public schema — dev vs prod diff is + **empty** (byte-identical). + +## Code + config parity (whole-tree deploy) + +- Folded production's genuinely-better sidecar Dockerfile (`npm ci` + lockfile) + into the repo first (commit `93d188a`), so a repo→prod copy loses nothing. +- Replaced all three app trees on production with a clean checkout of `HEAD` + (`apps/{convivo,admin,sidecar}`), removing stale `.orig` overlay backups. + `docker-compose.yml` already matched; `.env`/secrets/GoTrue/kong runtime + untouched (parity is committed files + schema, not live data or credentials). +- **Gate:** production app tree `diff -rq` against the repo payload is **empty**. + +## Deployment record + +- Backups: full prod `pg_dump` + source archive + container inventory under + `/home/APPE/convivo-backups/parity-20261016T154507Z` (pre-migration) and + `parity-20261016T154937Z` (pre-deploy). Rollback image tags + `convivo-{app,admin,sidecar}:rollback-parity-20261016T154937Z`. +- Build-before-`up`: all three images built successfully before any container + was recreated (a build failure would have auto-restored source with zero + downtime). +- Live bundles `index-DtIEihnG.js` (attendee) and `index-CitZP5XQ.js` (admin) + match the local `HEAD` builds exactly; sidecar `/health` ok, `/export` route + + `pdfkit` present. +- Autosync preserved: pretix every-minute (111 attendees, 0 errors) and the + Sessionize/GridSmart poller (30 sessions, 0 errors) both running after the + rebuild. +- `nginx -t` ok in both frontends; attendee + admin HTTP/HTTPS 200; only the + three convivo service containers recreated; all unrelated Supabase container + IDs preserved. + +## Verification + +- Mocked browser e2e against production: **151/151** (after removing one stale + `Evaluate` assertion in `admin-schedule.spec.ts` — that button was removed + from the codebase in `6bad96c`). +- Live rollback-only `leaderboard_tests.sql` smoke on production: **46 + assertions passed**, exercising `accept_connection` `shared_talk` + the + `talk_networking` bonus path; all row counts unchanged after `ROLLBACK` + (real data preserved). +- Final three-way check: **dev == prod == repo** for schema, ledger, and app + source. diff --git a/e2e/tests/admin-schedule.spec.ts b/e2e/tests/admin-schedule.spec.ts index 2f3bc9c..72e7e68 100644 --- a/e2e/tests/admin-schedule.spec.ts +++ b/e2e/tests/admin-schedule.spec.ts @@ -280,7 +280,6 @@ test.describe('Admin schedule delete', () => { await page.getByRole('button', { name: 'Delete schedule', exact: true }).click(); await expect(page.getByRole('button', { name: /Deleting/ })).toBeDisabled(); await expect(page.getByRole('button', { name: '+ New slot', exact: true })).toBeDisabled(); - await expect(page.getByRole('button', { name: 'Evaluate', exact: true })).toBeDisabled(); releaseRpc(); await expect(page.getByText('Admin Conf A · 0 slots · 0 sessions.')).toBeVisible(); await expect(page.getByText('Deleted 1 slots and 1 sessions from Admin Conf A')).toBeVisible();