Files
Convivo/docs/prod-parity-plan.md
T
940bc5b160 chore(parity): record prod⇄dev⇄repo parity execution + fix stale schedule test
- 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 <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
2026-10-16 17:56:09 +02:00

9.7 KiB

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 Dockerfiles (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.