# Deploy rubric (draft v2) Draft; the real content is open decision 7 and moves to the devops vault later. Each rule has an id the reviewer cites as evidence. "Breaks" says when a finding is `bad` (blocks GO); otherwise it is `todo`. Where it runs decides how hard a finding is. Code that runs on its own once deployed (the app, jobs, cron, migrations and seeds in the deploy) is held to "Breaks". A one-off command that someone runs by hand after deploy is a `post_deploy` step: a weakness in its failure path (a step outside the transaction, a rerun that skips a follow-up) is `todo`, and the post-deploy step says how to check the result and recover. It is still `bad` when running it as written, on the happy path, damages data. ## R1 · Can be rolled back A schema migration has a working rollback (`down()` or equivalent) that restores the previous shape and data. Breaks: a migration whose up() changes or removes existing data or structure without a rollback, or that drops or renames an existing column or table without a plan to restore its data. A rollback that removes only what up() created is fine; a migration that only creates new tables or columns may leave down() empty (`todo` at most). ## R2 · Existing data is safe Code or scripts that update or delete existing rows are scoped (clear filter, date range) and have a restore point. Breaks: an unscoped update or delete, or a rewrite of historical data with no backup or dry run. ## R3 · Every reader is updated When a field, column, table, endpoint or event changes, every place that reads it (jobs, reports, cron, other services, the frontend) is updated in the same release or stays compatible. Breaks: a remaining reader of the old shape. ## R4 · No secrets, config is declared No credentials, tokens or private keys in code or fixtures. New environment variables or config keys are named in the MR description. Breaks: a secret in the diff. A missing config note is `todo`. ## R5 · Right target The target branch matches the environment the MR says it is for. Teams promote to production through their own release branches (for example `rc/*`) or a twin MR to development, so commit hashes on production often differ from development: never judge release history from commit hashes or branch lists. At most `todo`: when a production MR gives no sign that the same change was tested on development or staging, ask for the link. ## R6 · Post-deploy steps are written down Anything that must happen after deploy (run a migration, upgrade a module, backfill, clear a cache, a feature flag) is listed. These become `post_deploy` steps. Missing ones are `todo`. ## R7 · One thing per MR The MR does what its title says. Unrelated changes are `todo` (split or explain). Release branches that bundle several reviewed changes on purpose are fine. ## R8 · Checked before asking A behaviour change has tests, or the description says how it was checked. Missing evidence is `todo`; a test change that weakens or deletes assertions is `bad`. ## R9 · Safe deploy order Read how this repository deploys (CI files, deploy scripts, Dockerfiles, runbooks). New code must not serve traffic before the schema it needs exists: migrations run, and succeed, before the new version replaces the old one; a failing step must not leave the new version running on the old schema. Breaks: the deploy starts the new version before migrations it depends on, or continues after a failed migration or seed. ## R10 · What it needs from elsewhere List what this change needs that lives outside this repository: endpoints, response fields, tables, queues, other services. When the change calls or reads something that does not exist in its counterpart yet (an API the frontend calls, a field it reads, a topic it consumes), it must deploy after that counterpart. `waiting` when it depends on another change that is not deployed yet, naming what it needs; `todo` when unsure. Look for the counterpart in the MR description and links. ## R11 · Safe to run twice One-off commands, backfills, normalizations and data migrations give the same result when run again, and skip or report rows they already handled. Breaks: a rerun changes data again, double counts, or produces a different result. ## R12 · Corrections check what they overwrite A data correction writes only rows it has identified by stable business keys (document number, code), and checks that each value it replaces is still the expected old value before writing (compare first, or `WHERE value = old`). `todo` when it overwrites without checking the old value, or when it relies on a hardcoded database id (user, company, warehouse, actor) that is not resolved or checked in the target environment. Breaks: a hardcoded id decides which rows are changed and is not checked against the target environment. ## R13 · Deploy setup belongs to devops How the application is built, shipped and run is owned by devops, not by the MR's developer: CI files, Dockerfiles, compose files, deploy scripts and manifests, runners, registries, servers and CI variables. Cite R13 on every `bad` or `todo` finding about them, in addition to the rule that decides its kind (a deploy order that breaks is still `bad` under R9). The text says what is wrong, never how to change the CI or deploy setup: devops is tagged and fixes it, and the developer should not edit deploy setup to pass review. When the MR itself changes deploy setup, add a `todo` citing R13 that devops must check that change, even when it looks right. Answers to mentions follow the same rule: deploy and CI questions go to devops; do not suggest CI edits to the developer.