Skip to content

Enforcement Map

Condensed from the canonical ENFORCEMENT.md in the repository root.

Which architectural rules are enforced, where, and how. Check this table before adding new rules.

Enforcement Mechanisms

ConstraintEnforcement FileMechanismFailure Mode
Cross-package gateway importsci.js + domain-isolation.test.jsScans for runtime imports outside gateway filesCI failure
Domain isolation (rex <-> sourcevision)domain-isolation.test.jsVerifies no cross-imports between domain packagesTest failure
Orchestration tier boundary (spawn-only)domain-isolation.test.jsChecks orchestration files have no runtime library importsTest failure
Direct node:child_process importsarchitecture-policy.test.jsAllowlist-based scan of all packagesTest failure
Intra-package layering (domain -> CLI)architecture-policy.test.jsEnsures src/core/ never imports from src/cli/Test failure
Gateway contract (hench -> rex)rex-gateway.test.tsEXPECTED_EXPORTS list vs actual re-exportsTest failure
Gateway contract (web -> sourcevision)domain-gateway.test.tsVerifies re-export matches canonical exportTest failure
Type reference identity (web -> rex)type-consistency.test.tstoBe() identity check on re-exported constantsTest failure
Zone health thresholdsci.jsCohesion >= 0.5, coupling <= 0.25 for non-asset zonesCI warning
Hench guard policy limitspolicy.test.tsRate limits, session limits, audit trailTest failure
Server/viewer boundaryci.jsserver/ cannot import ../viewer/CI failure
Required test annotationsarchitecture-policy.test.jsREQUIRED TEST annotation must exist in required test filesTest failure
Integration test growthintegration-coverage-policy.test.jsIntegration files >= 15% of e2e countTest failure
Zone ID consistencyci.js (step 3a)Zone IDs in zones.json match directory namesCI failure
Zone size distributionzone-size-policy.test.tsMax 30% zone sizeTest failure
Community filesci.jsRequires CODE_OF_CONDUCT.mdCI failure
Assistant instruction driftassistant-body-drift.test.jsCLAUDE.md / AGENTS.md must equal the generator outputTest failure
Catalog <-> runtime model defaultscatalog-runtime-contract.test.jsCatalog recommended model equals the runtime defaultTest failure

Configuration

Gateway and boundary rules are defined in gateway-rules.json, consumed by both ci.js and domain-isolation.test.js.

Adding New Rules

  1. Check this table first — the constraint may already be enforced
  2. Choose the right mechanism:
    • Type system (tsc): for API shape contracts
    • Unit/integration test: for fast, focused contract assertions
    • E2E test: for cross-package boundary enforcement
    • CI pipeline (ci.js): for rules needing sourcevision analysis output
  3. Add the rule to this table

Released under the Elastic License 2.0.