This document defines the minimum enforcement mechanisms required to make the constitution operational.
Architectural rules that are not checked will decay.
Therefore, the repository must enforce structural integrity through automation wherever practical.
At minimum, CI must enforce:
- Dependency boundary checks
- Forbidden transport/framework usage in core
- Restricted environment access
- Configuration schema validation
- Conformance test execution
- Structural PR checklist completion
- Pull request title convention
The repository must define and enforce allowed dependency directions between these roles:
- contracts
- core
- adapters
- plugin contracts
- plugin implementations
- composition roots
- tests
- core must not depend on adapters
- core must not depend on concrete plugin implementations
- contracts must not depend on implementations
- plugin contracts must not depend on implementation modules
- adapters must not select implementations directly except in approved composition roots
- plugin implementations must not depend directly on sibling plugin implementations unless explicitly allowed
- Python:
import-linter,deptry, AST checks - Go: custom package dependency checks,
golangci-lintrules - Rust: crate/module boundary checks via linting + workspace conventions
- TS/JS: ESLint import rules, dependency-cruiser
- Java/Kotlin: ArchUnit
- Polyglot: custom graph checks in CI
Core must remain transport-agnostic.
- HTTP/web frameworks
- RPC frameworks
- request/response types
- transport-specific exception/status types
fastapiflaskstarlettegrpcHTTPException- web request/response objects
- protocol transport status/result objects
- linter banned import rules
- AST-based forbidden symbol checks
- grep-based CI checks as a baseline
Raw environment access must be limited to:
- config loading modules
- bootstrap/composition root modules
- test bootstrap or fixtures
os.getenvos.environ- equivalent language runtime environment access
This prevents scattered mode selection, hidden wiring logic, and environment-dependent behavior leaking into business code.
Configuration must be validated against an explicit schema.
- unknown keys fail validation
- required fields are enforced
- invalid enum/mode values fail validation
- startup fails early on invalid config
Configuration must cover:
- implementation selection
- endpoints
- timeouts
- feature flags
- secret sources
- environment/mode selection
Every declared Service API, Plugin API, and replaceable capability contract must map to conformance tests.
- changed contracts trigger corresponding conformance tests
- protected branches should run all conformance suites or a validated equivalent
- new implementations are blocked from merging without contract coverage
- unit tests
- conformance / contract tests
- integration tests
- end-to-end tests
Conformance tests are mandatory for boundary contracts.
PRs affecting boundaries must include completed structural analysis.
- title matching
<type>(<scope>): <concise outcome>with an allowed type fromfeat,fix,refactor,docs,test,ci,build,perf, orchore; scope is required - whether a contract changed
- if changed, what kind of contract
- affected consumers
- affected implementations
- compatibility status
- migration/deprecation plan if needed
- whether a waiver is required
- PR template required
.github/workflows/pr-title.ymlvalidates every PR title and reports the stableValidate PR titlestatus check- protected-branch rulesets must require
Validate PR title; the workflow result alone does not block merging unless the status check is required - reviewer must confirm completion
- bots may reject PRs missing required sections
Waivers are allowed only for explicit invariant violations.
- linked from PR
- owner assigned
- review or expiry date present
- exact rule named
- removal plan documented
- PRs claiming exceptions without waiver are rejected
- expired waivers trigger review failure or warning escalation
CI should flag or fail on likely structural violations, including:
- transport framework imports in core
- concrete implementation imports outside composition roots or tests
- raw environment access outside config/bootstrap
- hardcoded external URLs or tokens
- contract changes without associated conformance updates
- new top-level package/directory without declared role
Not every detection must block immediately, but all should at least surface in review.
Even before stronger tooling is installed, use simple fail-fast checks.
! grep -R "from fastapi import\|import fastapi\|HTTPException\|starlette\|grpc" src/core! grep -R "os.getenv\|os.environ" src --exclude-dir=config --exclude-dir=bootstrap --exclude-dir=tests! grep -R "from .*plugins\|import .*plugins" src/core src/adapters src/contracts! grep -R "https\?://" src/core src/adapters src/pluginsThese are crude but useful until AST or dependency-graph checks are in place.
[importlinter]
root_package = your_project
[importlinter:contract:core_no_adapters]
name = core must not import adapters
type = forbidden
source_modules =
your_project.core
forbidden_modules =
your_project.adapters
[importlinter:contract:core_no_plugins]
name = core must not import plugin implementations
type = forbidden
source_modules =
your_project.core
forbidden_modules =
your_project.plugins
[importlinter:contract:contracts_no_plugins]
name = contracts must not import plugin implementations
type = forbidden
source_modules =
your_project.contracts
your_project.plugin_api
forbidden_modules =
your_project.plugins
[importlinter:contract:adapters_no_plugins]
name = adapters must not import plugins directly
type = forbidden
source_modules =
your_project.adapters
forbidden_modules =
your_project.pluginsIf bootstrap or composition-root modules need exceptions, place them in a separate package and exempt them explicitly.
- adopt PR template
- add grep-based anti-drift checks
- define composition roots
- define architectural role map
- add dependency boundary tooling
- add config schema validation gate
- add conformance test suite mapping
- add waiver process
- AST-based forbidden import/symbol checks
- changed-contract detection
- auto-labeled structural PRs
- automated expiry reminders for waivers
A repository may claim compliance with the constitution only if it has at least:
- documented architectural roles
- declared composition roots
- boundary checks in CI
- validated configuration
- conformance tests for boundary contracts
- structural PR review process
- waiver mechanism
Without these, compliance is aspirational rather than enforced.