chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
|
|
|
|
# QUALITY_GATES.md — executable frontend gates
|
|
|
|
|
|
|
|
|
|
|
|
The single command that runs **every** gate, locally and in CI:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
npm run verify
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
`verify` chains: `format:check` → `lint` → `build` (`tsc -b && vite build`) →
|
2026-09-10 19:15:14 -04:00
|
|
|
|
`test` (`vitest run`) → `governance`. Governance also runs the repository
|
2026-09-18 14:30:20 -04:00
|
|
|
|
gates: Terraform import-plan checker, Terraform formatting and validation, the
|
|
|
|
|
|
HCP run guard, CloudFront verify, workflow shell checks, and G13 (app/Terraform
|
|
|
|
|
|
isolation). A task is not done until this is green.
|
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
|
|
|
|
|
|
|
|
|
|
## Gate matrix
|
|
|
|
|
|
|
2026-09-19 20:20:30 +00:00
|
|
|
|
| Gate | Command / rule source | Enforced by | Scope |
|
|
|
|
|
|
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------- |
|
|
|
|
|
|
| Formatting | `npm run format:check` (Prettier) | `verify` + lint-staged | Whole repo |
|
|
|
|
|
|
| Lint, zero warnings | `npm run lint` → `eslint . --max-warnings=0` | `verify` + CI | Governed TS/TSX (`eslint.config.js`) |
|
|
|
|
|
|
| Type-check + production build | `npm run build` → `tsc -b && vite build` | `verify` + CI | Whole app |
|
|
|
|
|
|
| Unit tests | `npm test` → `vitest run` | `verify` + CI | `src/test/**`, `config/**/*.test.ts` |
|
|
|
|
|
|
| Conditional rendering (no `: null`) | `no-restricted-syntax` in `eslint.config.js` | lint | Governed TSX |
|
|
|
|
|
|
| Boolean-only JSX `&&` | `seahaven/no-non-boolean-jsx-and` (type-aware) in `eslint-rules/` | lint | Governed TSX |
|
|
|
|
|
|
| Shared `Text` typography | `no-restricted-syntax` (raw `p`/`h1`–`h6`) + `seahaven/no-vp-error-outside-text` | lint | Governed TSX |
|
|
|
|
|
|
| Hooks correctness | `eslint-plugin-react-hooks` recommended (incl. `exhaustive-deps`) under zero-warnings | lint | Governed TS/TSX |
|
|
|
|
|
|
| Godfile ratchet (file length) | `scripts/governance-check.mjs` + `scripts/governance-baseline.json` | `governance` | `src/**`, `config/**` (non-test) |
|
|
|
|
|
|
| Changed-file maintainability | `scripts/governance-check.mjs` → ESLint (`complexity`, `max-lines-per-function`, `max-params`, `max-depth`) | `governance` | Changed TS/TSX vs base ref |
|
|
|
|
|
|
| Terraform import-plan contract | `npm run test:terraform-import-plan` → `scripts/test-terraform-import-plan-check.py` | `governance` + CI | Synthetic plan JSON + canonical maps |
|
|
|
|
|
|
| Terraform formatting/validation | `npm run test:terraform` → `scripts/terraform-validate.mjs` | `governance` + CI | `terraform/live/dev`, `terraform/live/staging` |
|
|
|
|
|
|
| HCP run guard | `npm run test:hcp-run-guard` → `scripts/test-hcp-run-guard.py` | `governance` + CI | Workspace invariants + apply reconcile |
|
|
|
|
|
|
| CloudFront release verify | `npm run test:cloudfront-release-verify` → `scripts/test-verify-cloudfront-release.sh` | `governance` + CI | Stubbed aws/curl |
|
|
|
|
|
|
| GitHub workflow shell | `npm run test:github-workflows` → `scripts/check-github-workflows.sh` | `governance` + CI | `bash -n` + actionlint |
|
|
|
|
|
|
| G13 App/Terraform isolation | `python3 scripts/check_app_terraform_isolation.py` vs merge-base of `GOVERNANCE_BASE` (merge_group: each first-parent commit) | `governance` + CI | Deployable app files vs `terraform/` (live: PR, merge_group, local) |
|
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
|
|
|
|
|
|
|
|
|
|
## No-false-pass guarantees
|
|
|
|
|
|
|
|
|
|
|
|
- **`--max-warnings=0`** — a warning is a failure. There is no "warning-only"
|
|
|
|
|
|
backlog; rules ship green (see AGENTS.md → How to add a convention).
|
|
|
|
|
|
- **Type-aware rules fail closed** — `seahaven/no-non-boolean-jsx-and` reports
|
|
|
|
|
|
when type services are unavailable rather than silently claiming safety.
|
|
|
|
|
|
- **Godfile ratchet is monotonic** — any new file over the cap, new baseline
|
|
|
|
|
|
entry, global cap increase, per-file cap increase, or growth beyond a frozen
|
|
|
|
|
|
legacy cap fails. Only cap reductions and entry removals are allowed.
|
|
|
|
|
|
- **Changed-file maintainability fails closed without a valid base** — in CI the
|
|
|
|
|
|
base ref is derived from `GITHUB_BASE_REF` (PR) or `github.event.before`
|
|
|
|
|
|
(push). An absent or unresolvable base is a failure, not a pass.
|
2026-09-10 19:15:14 -04:00
|
|
|
|
- **Terraform gates never touch live state** — `terraform init -backend=false
|
|
|
|
|
|
-lockfile=readonly` and `validate` run offline; the plan checker is tested
|
|
|
|
|
|
against synthetic plan JSON. Real import and controlled-update plans from HCP
|
|
|
|
|
|
are migration evidence reviewed by a human before an approved apply
|
2026-09-18 14:30:20 -04:00
|
|
|
|
(`terraform/README.md`). G13 fails a diff that contains both `terraform/`
|
|
|
|
|
|
and deployable application files (`src/`, `public/`, `pages/`, `config/`,
|
2026-09-18 17:13:32 -04:00
|
|
|
|
`index.html`, Vite/tsconfig, or `.env*`). Workflow,
|
2026-09-18 14:30:20 -04:00
|
|
|
|
docs, and gate-script changes may travel with either side. Runtime isolation
|
|
|
|
|
|
stays: `deploy-web.yaml` ignores `terraform/**`, and app-only tags skip HCP
|
|
|
|
|
|
when workspace trigger patterns miss.
|
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
|
|
|
|
|
|
|
|
|
|
## Where the gates run
|
|
|
|
|
|
|
|
|
|
|
|
- **Locally:** `npm run verify`. `lint-staged` (via Husky) re-runs ESLint +
|
|
|
|
|
|
Prettier on staged files at commit; commitlint enforces Conventional Commits.
|
2026-09-19 15:22:38 -04:00
|
|
|
|
- **CI ([`.github/workflows/ci.yaml`](.github/workflows/ci.yaml)):** this
|
|
|
|
|
|
repository owns every job. `static` (`format:check` + `lint`), `build`
|
2026-09-19 15:41:10 -04:00
|
|
|
|
(`tsc -b && vite build`), `unit` (`vitest run` in four shards), `visual`
|
2026-09-19 15:29:45 -04:00
|
|
|
|
(Playwright visual), `browser-smoke` (`npm run test:e2e`), and `governance`
|
|
|
|
|
|
(`npm run governance`, with Terraform 1.16.0) run in parallel. `ci-complete`
|
|
|
|
|
|
fails unless all of those jobs succeeded and is the required merge-queue
|
|
|
|
|
|
check. Live G13 runs on
|
2026-09-19 20:20:30 +00:00
|
|
|
|
`pull_request` (merge-base range), `merge_group` (each queued PR as a
|
|
|
|
|
|
first-parent commit), and locally. It skips `push`. A Terraform-only PR
|
|
|
|
|
|
stacked with an app-only PR still passes; a mixed change set still fails.
|
|
|
|
|
|
Terraform fmt/validate and the related unit tests run inside `governance` on
|
|
|
|
|
|
every event.
|
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
|
|
|
|
|
|
|
|
|
|
## Toolchain pin
|
|
|
|
|
|
|
|
|
|
|
|
Node ≥ 22.22.1 (CI uses Node 24); npm 11.16.0 via `packageManager` (use
|
|
|
|
|
|
`corepack npm …` if your default `npm` is older). The lockfile is
|
2026-09-10 19:15:14 -04:00
|
|
|
|
`package-lock.json` v3; install with `npm ci`. Governance also needs
|
2026-09-11 13:40:14 -04:00
|
|
|
|
`terraform` (CI: 1.16.0; `versions.tf` accepts `>= 1.14.0, < 2.0.0`) and
|
2026-09-10 19:15:14 -04:00
|
|
|
|
`python3` (3.10+) on `PATH`.
|