Skip to documentation

Design system / Sources & standards

Current repository source

ADR-0033-risk-based-quality-gates-and-merge-policy.md

docs/decisions/ADR-0033-risk-based-quality-gates-and-merge-policy.md

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

# ADR-0033: Risk-based quality gates and merge policy

## Status

accepted

## Date

2026-07-14

## Context

ADR-0011 establishes runtime guardrails, but the project lacks a shared policy for selecting tests, reviewing UI behavior, scanning architectural impact, and handling checks that cannot pass locally. A generic instruction to run "relevant" checks is too discretionary for a growing multi-surface application.

## Options considered

1. **CI-only enforcement**
   - Rely on automated checks after code is pushed.
   - Pros: consistent enforcement.
   - Cons: feedback arrives late and does not guide risk-based test selection or ADR review during implementation.

2. **Agent guidance without independent review**
   - Provide a quality skill and let the implementation agent self-certify.
   - Pros: minimal workflow overhead.
   - Cons: leaves blind spots in test selection and architecture impact assessment.

3. **Risk-based quality skill plus read-only review (chosen)**
   - Define a baseline gate, add tests based on changed behavior, and have an independent reviewer identify merge blockers before shipping.
   - Pros: early feedback, clear ownership, and proportional verification without requiring full browser suites for every change.
   - Cons: adds a deliberate review step before shipment.

## Decision

- Extend ADR-0011 with a risk-based quality gate, without changing its accepted runtime-guardrail scope.
- Every delivery pre-flight runs `git diff --check`, `npm run test:migrations`, `npm run test`, `npm run test:guardrails`, and `npm run build`.
- The gate adds targeted verification based on the diff:
  - Interactive UI: test visible loading, success, error, and empty states affected by the change; test behavior hooks separately when they own transitions or effects.
  - Route, auth, redirect, upload, or other browser-critical flows: run or add focused Playwright coverage when the changed flow is not adequately proven below the browser boundary.
  - Domain, controller, persistence, authorization, and migration changes: add or update focused contract and failure-path tests.
- A read-only quality reviewer runs after functionality is complete and before shipping. It classifies risk, verifies test selection, reviews ADR impact, and reports merge blockers.
- `/shipit` loads the quality-gate skill and invokes the reviewer before commit/push.
- Local verification is the PR merge gate. A green local quality gate is sufficient to merge into `dev`; the resulting `dev` deployment is the next-environment validation step.
- The project does not require a production-mode local test suite. Production behavior is validated through controlled promotion from `dev` to `main` under the existing branch and deployment policy.
- Local-only test-auth helpers may support browser verification when they are unavailable outside local development. Their local behavior is covered by the focused browser test; a separate production-mode test is not required by this quality gate.
- Browser E2E tests may assume documented local demo tenants, users, and events are available. Do not require preemptive fixture provisioning or cleanup when the test's purpose is application behavior rather than fixture management. Diagnose and restore a missing demo fixture only when an E2E test fails for that reason.
- A PR may be opened with failed or unavailable local checks only when its description records the command, reason, risk, owner/follow-up, and merge-blocking status. Such a PR must not merge until all applicable local gates are green.

## Rationale

The project already has useful point controls for migrations and runtime guardrails. A risk-based gate turns them into a coherent delivery practice while reserving costly browser tests for workflows that cross meaningful boundaries. Separating implementation from read-only quality review makes missing coverage and ADR impact visible before a commit or merge decision is made.

## Consequences

- Testing effort follows changed behavior and risk rather than raw file count.
- Component tests focus on user-observable outcomes; hooks receive focused state/effect tests; end-to-end tests remain reserved for cross-boundary workflows.
- Quality exceptions are visible and temporary rather than silently skipped; `dev` deployment provides the next validation environment after merge.
- Static enforcement is deferred until several PRs validate stable, high-confidence rules.

## Frontend documentation check — clarification (2026-10-20)

Component additions, changes and refactors are checked against applicable ADRs, theming rules and frontend development guidance before implementation. Before completion, the public design system must reflect the current components, examples and usage guidance. A no-update assessment requires an explicit reason.

The canonical authoring workflow lives in `frontend-component-architecture`; `quality-gate`, quality review and PR review verify it. Authors and reviewers load `asd-ste100` and any additional writing skills required by applicable guidance. Architectural/theming violations, materially stale examples, missing required documentation and material writing-guide violations fail this check. Minor wording suggestions alone do not fail it.

This clarifies the existing frontend quality-review scope. It does not require a new ADR for each component change or alter runtime architecture, deployment or test-selection policy.

## References

- ADR-0011 - Runtime guardrails baseline
- ADR-0020 - Proxy matcher policy and coverage tests
- ADR-0031 - Frontend component taxonomy and product instances
- ADR-0032 - Client behavior and state escalation
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.