{ "category": "architecture", "tier": "leaf", "check": { "by": [ "the fitness functions, contract tests and architecture tests each contract names", "the reviews a contract names where no automated check exists" ], "population": "every module and boundary the contract governs", "freshness": "a verdict stands until the module, its dependencies or the contract changes", "refusal": "a failing fitness function or contract test blocks the release", "observation": "the traces and health signals the observability contracts require, which locate a contract failure in production", "evidence": "none: the catalog states this check as a class, so a watched run belongs to each system that adopts it", "authority": "the contract, which the module and its tests conform to" }, "records": [ { "id": "document-truth-alignment", "mathType": "logic", "yields": "boolean", "title": "Document Truth Alignment", "intent": "For any document that states facts about a codebase, separate invariant facts (counts, paths, names, and the doc-type's structural schema) from variant prose, bind each invariant to a code-derived value through a stable key, compile the document from a template, and gate the output so a stated fact can never drift from the code it describes.", "invariant": "A document is well-formed iff every rendered invariant equals its resolved code-truth and every doc-type-required meta-concern is present in order; prose is free.", "flow": [ "Concern", "Variant", "Invariant", "TruthKey", "Deriver", "Template", "Compilation", "DriftGate" ], "productions": [ { "lhs": "DocumentTruth", "rhs": " \"+\" \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "InvariantBinding", "rhs": " \",\" \",\" \",\" " } ], "composes": [], "force": [ "correctness_verification", "contract_compatibility", "modularity" ], "exemplar": { "before": "A doc states 'the system has 12 modules' — a hand-typed count that drifts the moment a module is added.", "after": "invariant{moduleCount} → truth-key{modules.length} → deriver{scan workspaces} → template{'... has {moduleCount} modules'} → drift-gate{rendered == derived, else fail}", "lang": "flow", "medium": "composite" } }, { "id": "architectural-contract-kernel", "mathType": "computation", "yields": "procedure", "title": "Architectural Contract Kernel", "intent": "For any programmatic system, identify architectural concerns, define explicit contracts for each concern, bind implementations to those contracts, validate invariants, observe behavior, and evolve through versioned change.", "invariant": "Architecture is a graph of bounded contracts whose nodes expose stable intent and whose edges preserve compatibility, causality, and governance.", "flow": [ "Concern", "Boundary", "Contract", "Implementation", "Verification", "Observation", "Evolution" ], "productions": [ { "lhs": "ArchitectureKernel", "rhs": " \"→\" \"→\" \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "ConcernContract", "rhs": " \",\" \",\" \",\" \",\" \",\" \",\" " } ], "composes": [], "force": [ "contract_compatibility", "correctness_verification", "security_governance", "causality_ordering" ], "exemplar": { "before": "class FooService { save(f) { db.write(f); log(f); notify(f); } }", "after": "interface FooPort { save(f: Foo): Promise; }\nclass FooService implements FooPort {\n constructor(private repo: FooRepo, private events: EventSink) {}\n async save(f: Foo) { await this.repo.save(f); this.events.emit({ type: \"FooSaved\", f }); }\n}", "lang": "ts", "medium": "code" } }, { "id": "responsibility-boundary", "mathType": "set-theory", "yields": "set | boolean", "title": "Responsibility Boundary", "intent": "Partition behavior into cohesive units, assign each unit one reason to change, hide internal details, expose only intentional interfaces, and reject cross-boundary leakage.", "invariant": "Modularity is achieved when responsibility, knowledge, and change pressure are localized.", "flow": [ "Behavior", "Responsibility", "Boundary", "Interface", "Encapsulation", "Replaceability" ], "productions": [ { "lhs": "ResponsibilityBoundary", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "ModuleBoundary", "rhs": "\"single_responsibility\" \",\" \"high_cohesion\" \",\" \"low_coupling\" \",\" \"information_hiding\" \",\" \"replaceable_implementation\"" } ], "composes": [], "force": [ "modularity", "contract_compatibility" ], "exemplar": { "before": "class FooUtil { parse() {} save() {} render() {} notify() {} }", "after": "class FooParser { parse() {} }\nclass FooRepository { save() {} }\nclass FooView { render() {} }", "lang": "ts", "medium": "code" } }, { "id": "coupling-control", "mathType": "graph", "yields": "edge-list", "title": "Coupling Control", "intent": "Detect dependency directions, invert dependencies toward abstractions, restrict imports to approved boundaries, and preserve autonomy between modules.", "invariant": "Low coupling is enforced by making dependencies point at contracts instead of concrete implementations.", "flow": [ "ConcreteDependency", "AbstractionBoundary", "DependencyRule", "ImportValidation" ], "productions": [ { "lhs": "CouplingControl", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "DependencyRule", "rhs": "\"depend_on_interface\" | \"depend_on_port\" | \"same_boundary_only\" | \"adapter_required\"" } ], "composes": [], "force": [ "modularity", "contract_compatibility" ], "exemplar": { "before": "import { SqlFooStore } from \"./infra/sql\";\nclass FooService { store = new SqlFooStore(); }", "after": "interface FooStore { save(f: Foo): Promise; }\nclass FooService { constructor(private store: FooStore) {} }", "lang": "ts", "medium": "code" } }, { "id": "interface-contract", "mathType": "logic", "yields": "boolean", "title": "Interface Contract", "intent": "Define explicit interfaces with preconditions, postconditions, invariants, error semantics, version rules, and compatibility guarantees before implementation.", "invariant": "Interfaces are executable promises between independently changeable parts.", "flow": [ "Intent", "Interface", "Preconditions", "Postconditions", "Compatibility", "Implementation" ], "productions": [ { "lhs": "InterfaceContract", "rhs": " \",\" \",\" \",\" \",\" \",\" \",\" " }, { "lhs": "CompatibilityRule", "rhs": "\"backward_compatible\" | \"forward_compatible\" | \"breaking_change_requires_new_version\"" } ], "composes": [], "force": [ "contract_compatibility", "semantic_consistency" ], "exemplar": { "before": "function doFoo(a, b, n) {}", "after": "interface FooOp {\n (a: Foo, b: Bar, n: number): Result;\n}", "lang": "ts", "medium": "code" } }, { "id": "substitutability", "mathType": "logic", "yields": "boolean", "title": "Substitutability", "intent": "Validate that every implementation of an abstraction preserves the abstraction’s behavior, accepts valid parent inputs, returns valid parent outputs, and does not strengthen forbidden constraints.", "invariant": "Polymorphism is safe only when behavioral subtyping holds.", "flow": [ "Interface", "Implementation", "ContractCheck", "Substitute|Reject" ], "productions": [ { "lhs": "Substitutability", "rhs": " \"→\" \"→\" \"→\" " }, { "lhs": "BehavioralCompatibilityCheck", "rhs": "\"preconditions_not_stronger\" \",\" \"postconditions_not_weaker\" \",\" \"invariants_preserved\" \",\" \"errors_compatible\"" } ], "composes": [], "force": [ "contract_compatibility", "correctness_verification" ], "exemplar": { "before": "class ReadOnlyFooStore extends FooStore { save() { throw new Error(\"unsupported\"); } }", "after": "interface FooReader { find(id: FooId): Foo | undefined; }\ninterface FooWriter extends FooReader { save(f: Foo): void; }\nclass ReadOnlyFooStore implements FooReader { find(id: FooId) { return fooCache.get(id); } }", "lang": "ts", "medium": "code" } }, { "id": "canonical-data", "mathType": "set-theory", "yields": "set | boolean", "title": "Canonical Data", "intent": "Normalize incoming data into a canonical schema, validate types and semantics, preserve one source of truth, and translate at system boundaries only.", "invariant": "Semantic consistency requires one canonical model and controlled translation at edges.", "flow": [ "RawData", "Validate", "Normalize", "CanonicalModel", "BoundaryTranslation" ], "productions": [ { "lhs": "CanonicalDataFlow", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "CanonicalModel", "rhs": " \",\" \",\" \",\" \",\" " } ], "composes": [], "force": [ "modularity", "semantic_consistency", "correctness_verification", "model_governance" ], "exemplar": { "before": "function useFoo(raw) { const name = raw.name ?? raw.Name ?? raw.title; }", "after": "function toCanonicalFoo(raw: unknown): Foo { return { id: fooId(raw), name: pickName(raw) }; }", "lang": "ts", "medium": "code" } }, { "id": "domain-boundary", "mathType": "topology", "yields": "boolean", "title": "Domain Boundary", "intent": "Identify bounded contexts, define the ubiquitous language and the owner of each context's model, map the relationships between contexts, and use anti-corruption layers where semantics differ.", "invariant": "Domain architecture protects meaning by making semantic boundaries explicit.", "flow": [ "Domain", "BoundedContext", "Language", "ContextMap", "TranslationBoundary" ], "productions": [ { "lhs": "DomainBoundary", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "IntegrationPolicy", "rhs": "\"shared_kernel\" | \"customer_supplier\" | \"anti_corruption_layer\" | \"published_language\" | \"separate_ways\"" } ], "composes": [], "force": [ "modularity", "semantic_consistency", "domain_boundary" ], "exemplar": { "before": "fooContext.use(sharedBaz);\nbarContext.use(sharedBaz);", "after": "function toBarBaz(f: FooBaz): BarBaz { return { id: f.id }; }", "lang": "ts", "medium": "code" } }, { "id": "self-description-manifest", "mathType": "set-theory", "yields": "set | boolean", "title": "Self-Description Manifest", "intent": "Require every component to declare identity, capabilities, contracts, dependencies, configuration, health model, and version metadata in a machine-readable manifest.", "invariant": "Runtime systems become discoverable and governable when components describe themselves.", "flow": [ "Component", "Manifest", "CapabilityDeclaration", "Discovery", "Validation" ], "productions": [ { "lhs": "SelfDescription", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "Manifest", "rhs": "\"identity\" \",\" \"version\" \",\" \"capabilities\" \",\" \"dependencies\" \",\" \"contracts\" \",\" \"configuration\" \",\" \"health\"" } ], "composes": [], "force": [ "contract_compatibility", "model_governance" ], "exemplar": { "before": "export class FooPlugin { transform(x) { return x; } }", "after": "export const manifest = { identity: \"foo-plugin\", version: \"1.2.0\", capabilities: [\"transform\"], contracts: [\"FooPort@1\"], dependencies: [] };", "lang": "ts", "medium": "code" } }, { "id": "runtime-discovery", "mathType": "set-theory", "yields": "set | boolean", "title": "Runtime Discovery", "intent": "Discover available components by manifest, convention, registry, or service endpoint; validate discovered candidates against contracts; bind dynamically only after compatibility checks.", "invariant": "Dynamic binding is safe only when discovery is filtered by explicit contracts.", "flow": [ "DiscoverySource", "CandidateSet", "ContractValidation", "Binding", "RuntimeUse" ], "productions": [ { "lhs": "RuntimeDiscovery", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "DiscoveryMechanism", "rhs": "\"manifest\" | \"registry\" | \"service_discovery\" | \"convention\" | \"configuration\"" } ], "composes": [], "force": [ "contract_compatibility", "runtime_extensibility", "correctness_verification" ], "principleRef": "runtime-discovery", "exemplar": { "before": "const plugin = new KnownFooPlugin();", "after": "const candidates = registry.discover({ capability: \"transform\" });\nconst bound = candidates.filter((c) => satisfies(c.contract, FooPortV1));", "lang": "ts", "medium": "code" } }, { "id": "extension-point", "mathType": "logic", "yields": "boolean", "title": "Extension Point", "intent": "Define stable extension contracts, register implementations through IoC or plugin registries, isolate plugin failures, and expose deterministic loading order.", "invariant": "Extensibility requires stable hooks, controlled registration, and observable binding.", "flow": [ "ExtensionContract", "PluginRegistration", "DependencyInjection", "Isolation", "Dispatch" ], "productions": [ { "lhs": "ExtensionArchitecture", "rhs": " \"→\" \"→\" \"→\" \"→\" " }, { "lhs": "BindingPolicy", "rhs": "\"dependency_injection\" | \"service_registry\" | \"service_locator\" | \"manual_registration\" | \"auto_discovery\"" } ], "composes": [], "force": [ "contract_compatibility", "runtime_extensibility", "correctness_verification", "observability_traceability" ], "exemplar": { "before": "switch (kind) { case \"foo\": doFoo(); break; case \"bar\": doBar(); break; }", "after": "registry.register(\"foo\", fooHandler);\nregistry.register(\"bar\", barHandler);\nregistry.get(kind)?.handle(input);", "lang": "ts", "medium": "code" } }, { "id": "construction-boundary", "mathType": "computation", "yields": "procedure", "title": "Construction Boundary", "intent": "Hide object creation behind factories, builders, prototypes, or abstract factories so callers depend on creation contracts rather than concrete constructors.", "invariant": "Creation logic is a boundary and should be replaceable independently from usage logic.", "flow": [ "CreationRequest", "ConstructionContract", "Factory|Builder|Prototype", "Instance" ], "productions": [ { "lhs": "ConstructionBoundary", "rhs": " \"→\" \"→\" \"→\" " }, { "lhs": "ConstructionStrategy", "rhs": "\"factory\" | \"factory_method\" | \"abstract_factory\" | \"builder\" | \"prototype\"" } ], "composes": [], "force": [ "modularity", "contract_compatibility", "object_creation" ], "exemplar": { "before": "const c = new FooConnection(host, port, user, pw);", "after": "const c = fooConnectionFactory.create(config);", "lang": "ts", "medium": "code" } }, { "id": "structural-mediation", "mathType": "algebra", "yields": "ordered-structure", "title": "Structural Mediation", "intent": "Insert adapters, facades, proxies, bridges, or decorators where incompatible structure, access control, abstraction separation, or behavior layering is required.", "invariant": "Structural patterns reshape access without corrupting the core contract.", "flow": [ "ClientNeed", "StructuralMismatch", "MediatingPattern", "CompatibleInterface" ], "productions": [ { "lhs": "StructuralMediation", "rhs": " \"→\" \"→\" \"→\" " }, { "lhs": "StructuralPattern", "rhs": "\"adapter\" | \"facade\" | \"proxy\" | \"bridge\" | \"decorator\"" } ], "composes": [], "force": [ "modularity", "contract_compatibility" ], "exemplar": { "before": "legacyFooApi.call(new FooXmlPayload(foo));", "after": "class FooAdapter implements FooPort {\n constructor(private legacy: FooXmlApi) {}\n save(f: Foo) { return this.legacy.call(toFooXml(f)); }\n}", "lang": "ts", "medium": "code" } }, { "id": "behavioral-dispatch", "mathType": "logic", "yields": "boolean", "title": "Behavioral Dispatch", "intent": "Externalize variable behavior into strategies, template hooks, observers, or mediators while preserving stable orchestration contracts.", "invariant": "Behavioral variation belongs behind dispatch contracts, not scattered conditionals.", "flow": [ "StableFlow", "VariationPoint", "DispatchPattern", "RuntimeBehavior" ], "productions": [ { "lhs": "BehavioralDispatch", "rhs": " \"→\" \"→\" \"→\" " }, { "lhs": "BehaviorPattern", "rhs": "\"strategy\" | \"template_method\" | \"observer\" | \"mediator\" | \"polymorphic_dispatch\"" } ], "composes": [], "force": [ "contract_compatibility", "control_coordination" ], "exemplar": { "before": "function handleFoo(f) { if (f.kind === \"a\") { return runA(f); } else if (f.kind === \"b\") { return runB(f); } }", "after": "const strategies: Record = { a: fooStrategyA, b: fooStrategyB };\nfunction handleFoo(f: Foo) { return strategies[f.kind].run(f); }", "lang": "ts", "medium": "code" } }, { "id": "architectural-style-boundary", "mathType": "optimization", "yields": "boolean | ranking", "title": "Architectural Style Boundary", "intent": "Select an architectural style, from a monolith or modular monolith to layered, hexagonal or microservices, by dependency direction, deployment autonomy, domain complexity, team topology, operational maturity and change isolation needs, then enforce the style through boundary rules.", "invariant": "Architecture style is a macro-contract for dependency flow and deployment shape.", "flow": [ "SystemForces", "StyleSelection", "BoundaryRules", "FitnessValidation" ], "productions": [ { "lhs": "ArchitectureStyle", "rhs": " \"→\"