- Category: B. Software Architecture
- English term: Architectural Fitness Function
- Related: CI/CD Gate and Automated Merge · Deterministic Verification · Architecture Characteristics (-ilities) · Grounding and Source Verification · Hallucination Mitigation
General Meaning
A core concept of Evolutionary Architecture, an Architectural Fitness Function is an objective mechanism that assesses how close a system is to achieving its target architecture characteristics (security, performance, modularity, regulatory compliance, and dependency direction).
Unlike unit tests that verify isolated business logic, fitness functions use deterministic static analysis and automated checks in CI/CD pipelines to guard system-wide structural constraints and operational rules against gradual erosion.
Why It Matters
- Preventing architectural erosion and drift: Immediately catches unauthorized dependencies, layout violations, or banned expressions even when multiple AI agents contribute code concurrently.
- Reducing manual human review burden: Replaces subjective human or LLM judgment with fast, repeatable, mechanical pass/fail checks.
- Making continuous evolution safe: Proves mathematically on every commit that refactoring or adding features has not broken non-functional guarantees.
How the Site Factory Uses It
The Site Factory deploys deterministic Python inspection scripts as architectural fitness functions across every repository: (1) Content & Policy Reviewer (engine/review.py) checks site/ for forbidden promotional words, non-footer advertisements, misplaced disclaimers, required transparency/privacy pages, CSP headers, and internal broken links (exit 0 = pass, 1 = findings block publication, 2 = broken site); (2) Source Grounding Verifier (engine/check_sources.py) verifies that every number on a page exists verbatim in records.json and official source quotes (exit 0 = grounded, 1 = hallucination detected); (3) Blueprint Validator (engine/validate_design.py) verifies design.json against the JSON Schema; and (4) Watchdog tests in CI verify cross-file rule consistency (ops/rules_index.json vs. prose docs) and links.
These fitness functions run as mandatory pre-merge and pre-deploy gates, automatically blocking any PR or site release that violates a single rule.
Caveats & Operational Rules
- Never delegate pass/fail fitness checks to an LLM: Probabilistic AI models waver on edge cases; fitness functions must be deterministic Python parsers and regex checks.
- Mechanically enforce the 'subtract, don't add' principle: AI agents love adding well-meaning disclaimers and external links;
engine/review.pymechanically rejects top-of-page disclaimers and unapproved external links to keep pages clean.
Related Terms
- CI/CD Gate and Automated Merge
- Deterministic Verification
- Architecture Characteristics (-ilities)
- Grounding and Source Verification
- Hallucination Mitigation
References
- Book: Neal Ford, Rebecca Parsons & Patrick Kua, *Building Evolutionary Architectures*, Chapter 2 (Fitness Functions)
Verified: 2026-11-08