diff --git a/.github/scripts/pr-guard.mjs b/.github/scripts/pr-guard.mjs index 527e7dec..dfdab99f 100644 --- a/.github/scripts/pr-guard.mjs +++ b/.github/scripts/pr-guard.mjs @@ -37,7 +37,7 @@ const MAX_FINDINGS_PER_FILE = 200; export const RULES = { "contract-locked": { tier: "block", title: "Deployed contract files changed", help: "These files are pinned in contracts/deployed.lock, or stand guard over it (the lock itself, the scripts that check it, .gitmodules, everything under contracts/lib/), and stay byte-identical to what is live. A change for another chain goes in a new copied file (see contracts/src/LaunchFactoryArc.sol)." }, "ci-config": { tier: "block", title: "CI, the guard or code owners changed", help: "Workflow and guard changes come from the maintainers, in a pull request of their own." }, - "release-tooling": { tier: "block", title: "Release and deploy tooling", help: "The deploy and smoke scripts run on a maintainer's machine with the deploy credentials; the migration and its helpers run against the production database on every deploy; the Dockerfile, .dockerignore and fly.toml decide what is built and what runs at release; release-please-config.json decides how releases are cut. They change only in a pull request of their own, which a maintainer merges with the guard bypassed." }, + "release-tooling": { tier: "block", title: "Release and deploy tooling", help: "These paths include scripts that use deployment credentials or broadcast contract deployments, SQL that is applied during releases or production repairs, and configuration that controls builds and releases. They change only in a dedicated maintainer pull request." }, "dev-machine": { tier: "block", title: "Editor, agent or git hook configuration", help: "These files can run commands or steer an AI agent on a maintainer's machine the moment the branch is checked out. The repository tracks none of them." }, "registry-config": { tier: "block", title: "Package manager configuration", help: "A registry, proxy or script setting here redirects every install." }, "secret-file": { tier: "block", title: "A file that holds keys or wallet material", help: "Environment files, key files and wallet files are never committed. If this was real, rotate it now: the branch is public." }, @@ -78,7 +78,9 @@ export const RULES = { const BLOCK_PATHS = [ ["ci-config", /^\.github\/|^(docs\/)?CODEOWNERS$/i], - ["release-tooling", /^app\/scripts\/(deploy\.sh|smoke\.sh|migrate\.mjs)$|^app\/scripts\/lib\/|^app\/(Dockerfile|\.dockerignore|fly\.toml)$|^release-please-config\.json$/i], + ["release-tooling", /^app\/scripts\/(deploy\.sh|smoke\.sh|fly-secrets\.sh|migrate\.mjs|usd-backfill\.ts|rebuild-[^/]+\.sql)$|^app\/scripts\/lib\//i], + ["release-tooling", /^app\/db\/.+\.sql$|^contracts\/script\/DeployLaunchFactory\.s\.sol$/i], + ["release-tooling", /^app\/(Dockerfile|\.dockerignore|fly\.toml)$|^release-please-config\.json$/i], ["dev-machine", /(^|\/)\.(claude|cursor|codex|gemini|qwen|windsurf|continue|aider[^/]*|clinerules|roo|kiro|zed|fleet|junie|amazonq|augment|trae|opencode|goose|vscode|idea|devcontainer|husky|githooks)(\/|$)|(^|\/)(CLAUDE|AGENTS|GEMINI|QWEN)(\.[^/]*)?\.md$|(^|\/)(\.cursorrules|\.clinerules|\.windsurfrules|\.goosehints|\.mcp\.json|opencode\.jsonc?|\.devcontainer\.json|[^/]*\.code-workspace|\.envrc|\.huskyrc(\.[^/]*)?|\.lintstagedrc(\.[^/]*)?|\.pre-commit-config\.ya?ml|\.?lefthook\.ya?ml|\.?mise(\.[^/]*)?\.toml)$/i], ["registry-config", /(^|\/)(\.npmrc|\.yarnrc(\.yml)?|\.pnpmfile\.cjs|pnpm-workspace\.yaml|bunfig\.toml)$/i], ]; diff --git a/.github/scripts/pr-guard.test.mjs b/.github/scripts/pr-guard.test.mjs index d9f5e3c4..e19a2069 100644 --- a/.github/scripts/pr-guard.test.mjs +++ b/.github/scripts/pr-guard.test.mjs @@ -293,9 +293,26 @@ describe("CI and machine configuration", () => { } }); - test("other scripts and the schema stay owner-reviewed, not blocked", () => { + test("production SQL and credentialed deployment paths stay blocked on owner-authored pushes", () => { + const paths = [ + "app/db/schema.sql", + "app/db/concurrent-indexes.sql", + "app/db/migrations/add-index.sql", + "app/scripts/fly-secrets.sh", + "app/scripts/rebuild-holders.sql", + "app/scripts/rebuild-launch-totals.sql", + "app/scripts/usd-backfill.ts", + "contracts/script/DeployLaunchFactory.s.sol", + ]; + const found = check(Object.fromEntries(paths.map((path) => [path, "\n"]))); + assert.deepEqual(of(found, "release-tooling").map((finding) => finding.path).sort(), paths.sort()); + assert.equal(verdict(found, { author: OWNERS[0], pusher: OWNERS[0] }).outcome, "block"); + assert.equal(details(check({ "app/db/schema.sql": null }), "release-tooling"), "deleted"); + }); + + test("other scripts and routine release metadata are outside the release-tooling block", () => { // the manifest and the changelog change in every release pull request: blocking them would block every release - for (const path of ["app/scripts/fix.mjs", "app/scripts/usd-backfill.ts", "app/db/schema.sql", "app/db/concurrent-indexes.sql", "app/fly.staging.toml", "app/scripts/deploy.sh.bak", ".release-please-manifest.json", "app/CHANGELOG.md", "app/scripts/release-notes.mjs"]) { + for (const path of ["app/scripts/fix.mjs", "app/scripts/e2e-edit-fix.mjs", "app/db/README.md", "app/fly.staging.toml", "app/scripts/deploy.sh.bak", ".release-please-manifest.json", "app/CHANGELOG.md", "app/scripts/release-notes.mjs"]) { assert.ok(!rules(check({ [path]: "x\n" })).includes("release-tooling"), path); } }); @@ -972,11 +989,11 @@ describe("application code", () => { assert.deepEqual(rules(check({ "app/src/lib/obf.js": "var _0x4f2a=['log'];\n" })), ["opaque"]); }); - test("security headers, deploy files, migrations and policy files need an owner", () => { + test("security headers, release tooling and policy files use their respective tiers", () => { assert.deepEqual(rules(check({ "app/src/lib/security-headers.ts": "export const csp = \"default-src *\";\n" })), ["security-config"]); // the Dockerfile is release tooling: blocked, which takes the place of the review finding assert.deepEqual(rules(check({ "app/Dockerfile": "FROM node:22-slim\nRUN true\n" })), ["release-tooling"]); - assert.deepEqual(rules(check({ "app/db/schema.sql": "drop table launches;\n" })), ["build-deploy"]); + assert.deepEqual(rules(check({ "app/db/schema.sql": "-- migration\n" })), ["release-tooling"]); assert.deepEqual(rules(check({ "app/scripts/fix.mjs": "console.log(1);\n" })), ["build-deploy"]); assert.deepEqual(rules(check({ "SECURITY.md": "Report to help@elsewhere.example.com\n" })), ["policy"]); assert.deepEqual(rules(check({ ".gitattributes": "*.sol linguist-vendored\n" })), ["git-config"]); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5673a33e..5318b15a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,10 +51,11 @@ your code. It has two answers besides "passed": (`contracts/script/check-deployed-sources.sh`, `contracts/script/check-arc-factory.sh`), to `.gitmodules`, or anything added under `contracts/lib/`. - `ci-config`: anything under `.github/`, or a `CODEOWNERS` file. - - `release-tooling`: the release and deploy tooling: `app/scripts/deploy.sh`, `smoke.sh`, `migrate.mjs` and anything - under `app/scripts/lib/`, `app/Dockerfile`, `app/.dockerignore`, `app/fly.toml`, and `release-please-config.json`. - These run with the deploy credentials or against the production database, or decide how releases are cut, so a - maintainer changes them in a pull request of their own. + - `release-tooling`: `app/scripts/deploy.sh`, `smoke.sh`, `fly-secrets.sh`, `migrate.mjs`, `usd-backfill.ts`, + `rebuild-*.sql`, and files under `app/scripts/lib/`; SQL under `app/db/`; + `contracts/script/DeployLaunchFactory.s.sol`; and `app/Dockerfile`, `app/.dockerignore`, `app/fly.toml`, and + `release-please-config.json`. These paths control releases, use deployment credentials, or supply SQL for + production migrations and repairs. Changes require a dedicated maintainer pull request. - `dev-machine`: editor, agent or git hook configuration (`.vscode/`, `.claude/`, `AGENTS.md`, `.envrc` and the like). - `registry-config`: package manager configuration (`.npmrc` and the like). - `secret-file`, `secret`: a key, wallet or `.env` file, or a credential anywhere in the diff.