Testing and Change Safety
Layered tests and schema checks protect BookWorm behavior, service boundaries, and contract compatibility.
Purpose and Scope
Testing and change safety establish evidence that code, contracts, policies, data effects, and user journeys remain acceptable from development through release. These rules apply to shared foundations and every frontend, API, worker, event, integration, and AI boundary.
Visual Reference
Verification and Release Gates
Loading graph...
Core Rules and Standards
- Test at the lowest useful boundary. Use fast unit and component tests for local behavior and raise the test level only for interaction or deployment evidence.
- Verify contracts independently. Providers and consumers must prove compatibility for APIs and event schemas before deployment.
- Protect architectural boundaries. Automated checks must prevent forbidden dependencies and preserve capability ownership.
- Test behavior, not implementation. Assert domain outcomes, observable API effects, access decisions, and recoverable failure behavior.
- Require quality gates. Formatting, static analysis, tests, security checks, contract checks, and documentation checks must pass before promotion.
- Make releases reversible. Deploy behind feature or traffic controls when rollback or staged observation is useful.
- Use explicit rollback criteria. A release halts or rolls back for health, error, latency, security, privacy, contract, or business-signal breaches agreed by the owner.
A green build proves only the evidence it exercises. Critical compatibility, privacy, migration, and rollout risks require targeted tests or a documented human release gate.
Mechanism / How It Works
| Layer | Primary Evidence |
|---|---|
| Unit | Domain rules, validation, state transitions, pure transformations, and failure classification |
| Component | UI behavior, endpoint behavior, handler behavior, policy decisions, and data access boundaries |
| Integration | Real interactions among a host and its database, broker, cache, identity, or external dependency |
| Contract | Consumer/provider compatibility for HTTP, RPC, events, AI tools, and message envelopes |
| End-to-end | Critical journeys across frontends, gateways, capabilities, and asynchronous completion |
| Architecture | Dependency direction, domain isolation, forbidden references, and infrastructure conventions |
Verification and Release Gates
Local evidence
Run focused tests and formatting or static checks while code is still under development.
Change evidence
Run the relevant unit, contract, architecture, integration, and user-flow checks for the changed boundary.
Promotion gate
Require security, privacy, schema, coverage, migration, and quality checks to pass before deployment.
Controlled rollout
Deploy incrementally, observe health and business signals, and retain the previous reversible artifact.
Decision and rollback
Promote when agreed criteria hold; halt or roll back when a breach is detected or the outcome cannot be verified.
Rollout and Rollback Criteria
| Concern | Promote When | Roll Back or Halt When |
|---|---|---|
| Availability | Readiness and liveness remain stable at the approved threshold | Health probes fail or traffic sheds unexpectedly |
| Latency and errors | Error and latency budgets remain within release limits | Sustained breaches correlate with the change |
| Contracts | Consumers pass compatibility checks and replay remains safe | Additive or breaking incompatibility appears |
| Privacy and security | Policy tests pass and no secrets or PII leak is detected | Unauthorized access, PII exposure, or policy bypass occurs |
| Business outcome | Authoritative state and key journeys complete correctly | Reconciliation gaps, duplicate side effects, or incorrect outcomes appear |
Verification and Governance
- Map each shared library or boundary change to its owning test layer and contract.
- Keep known gaps explicit and prioritize them with release risk.
- Review failed, flaky, or skipped tests as release evidence, not merely CI noise.
- Retain rollback evidence and operational criteria with every promoted release.
Related Documentation
- Testing ExecutionCustom DocTesting ExecutionHow to run backend, frontend, contract, browser, and documentation checks locally and interpret their results.Ownerarchitecture-enabling-teamOpen doc — Test commands and focused execution.
- Testing MatrixCustom DocTesting MatrixReference tables for test scope, dependencies, local and CI execution triggers, and passing criteria.Ownerarchitecture-enabling-teamOpen doc — Framework and coverage details.
- Pull Request ProcessCustom DocPull Request ProcessPrepare a focused draft, satisfy automated checks and review, and merge a contribution safely.Ownerarchitecture-enabling-teamOpen doc — Pull-request and review requirements.