# anti-patterns

> Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a…

Page: Ontology · Algorithms
Canonical: https://banes-lab.com/ontology/algorithms#algo-domain-anti-patterns

Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a grammar, what it composes and is composed by, which forces and principles it answers to, what grounds it and what it grounds, and an exemplar where the record carries one. The diagram shows what composes what inside the domain.

Relations diagram

What composes what inside this domain.

```mermaid
flowchart LR
n_anti_pattern_inversion["Anti-Pattern Inversion"]
n_anti_pattern_propagation_kernel["Anti-Pattern Propagation Kernel"]
n_anti_pattern_remediation_algebra["Anti-Pattern Remediation Algebra"]
n_architecture_smell_record["Architecture Smell Record"]
n_anti_pattern_rule_compiler["Anti-Pattern Rule Compiler"]
n_smell_taxonomy["Smell Taxonomy"]
n_anti_pattern_relationship_record["Anti-Pattern Relationship Record"]
n_architecture_anti_pattern["<Architecture Anti-Pattern>"]
```

### Anti-Pattern Inversion

- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Take any desired architectural principle, invert its invariants, identify the recurring violation shape, model its propagation mechanism, define detection signals, and derive its remediation inverse.

Invariant
Every anti-pattern is a stable failure algorithm created by repeated violation of an architectural contract.

Flow

```text
Principle → Invariant → Violation → Propagation → Detection → Remediation
```

Productions

```bnf
AntiPatternInversion ::= <HealthyPrinciple> "->" <RequiredInvariant> "->" <InvariantViolation> "->" <FailurePropagation> "->" <DetectionSignalSet> "->" <RemediationInverse>
AntiPatternRecord ::= <Name> "," <TriggerCondition> "," <DegenerationPath> "," <DetectionSignals> "," <DamageModel> "," <RemediationInverse>
```

Composes
none

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [model_governance](https://banes-lab.com/records/force/model-governance.md)

Grounds
none

Before

```text
Principle: Low Coupling — stated as a goal only; its violations are noticed ad hoc, named inconsistently, and caught late, with no derived failure algorithm.
```

After

```text
Low Coupling → invariant{no bidirectional dependency} → violation{Cyclic Dependency} → propagation{a convenience import closes a cycle, then spreads across modules} → detection{dependency-cycle scan} → remediation{invert the dependency / introduce a port}
```

### Anti-Pattern Propagation Kernel

- Math type: [dynamical-systems](https://banes-lab.com/records/reason/math-type-dynamical-systems.md)
- Yields: boolean | counter

Details

Intent
Start with a local shortcut, repeat it under delivery pressure, normalize it as convention, allow dependent code to form around it, then make remediation expensive through coupling and hidden assumptions.

Invariant
Most architecture anti-patterns become dangerous when a shortcut becomes infrastructure.

Flow

```text
Shortcut → Repetition → Normalization → DependencyFormation → Institutionalization → HighCostRepair
```

Productions

```bnf
AntiPatternPropagation ::= <LocalShortcut> "->" <RepeatedUse> "->" <ImplicitConvention> "->" <DependentCodeFormation> "->" <ArchitecturalDebt> "->" <RemediationCostIncrease>
DebtAmplifier ::= "copy_paste" | "missing_contract" | "missing_owner" | "missing_metric" | "missing_boundary" | "missing_version" | "missing_observability"
```

Composes
none

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
A one-off shortcut — inline a secret to ship a fix — treated as an isolated, cheap, local choice.
```

After

```text
Shortcut{inline secret} → repetition{reused under deadline} → normalization{becomes the team convention} → dependency-formation{configs read it directly} → institutionalization{deploy scripts assume it} → high-cost-repair{rotate the secret and rewire every dependent}
```

### Anti-Pattern Remediation Algebra

- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
For each anti-pattern, identify the missing architectural control, introduce the inverse control, migrate existing dependents, verify absence of the old failure shape, and enforce recurrence prevention.

Invariant
Anti-pattern repair is not complete until the propagation path is blocked.

Flow

```text
AntiPattern → MissingControl → InverseControl → Migration → AbsenceCheck → PreventionGate
```

Productions

```bnf
AntiPatternRemediationAlgebra ::= <AntiPatternRecord> "->" <MissingControl> "->" <InverseArchitecturalControl> "->" <MigrationPlan> "->" <EliminationVerification> "->" <RecurrencePrevention>
MissingControl ::= "boundary" | "contract" | "owner" | "version" | "telemetry" | "schema" | "policy" | "state_isolation" | "dependency_rule"
RecurrencePrevention ::= "static_check" | "contract_test" | "schema_gate" | "architecture_test" | "policy_as_code" | "review_gate" | "runtime_monitor"
```

Composes
none

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
The anti-pattern is deleted at one call site; the propagation path stays open, so it reappears elsewhere next sprint.
```

After

```text
Secret Sprawl → missing-control{no secret authority} → inverse-control{central store + injected access} → migration{repoint every reader} → absence-check{scan finds zero inline secrets} → prevention-gate{lint rule rejects new inline secrets}
```

### Architecture Smell Record

- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Model every smell as a recurring degeneration path with trigger conditions, enabling conditions, detection signals, damage model, remediation inverse, and prevention gate.

Invariant
A smell becomes enforceable when it is represented as a measurable failure contract.

Flow

```text
Smell → Trigger → Degeneration → Detection → Measurement → Remediation → Prevention
```

Productions

```bnf
ArchitectureSmellRecord ::= <SmellName> "," <TriggerCondition> "," <EnablingConditionSet> "," <DegenerationPath> "," <DetectionSignalSet> "," <MetricSet> "," <DamageModel> "," <RemediationInverse> "," <PreventionGate>
PreventionGate ::= "static_check" | "architecture_test" | "contract_test" | "schema_gate" | "review_gate" | "fitness_function" | "runtime_monitor"
```

Composes
none

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [model_governance](https://banes-lab.com/records/force/model-governance.md)

Grounds
none

Before

```text
Smell described in prose ('this class is too big') — unmeasurable, unenforceable, re-argued case by case.
```

After

```text
God Object : trigger{unrelated methods accrete} → degeneration{fan-in/out grows} → detection{LCOM + responsibility count} → measurement{cohesion score below threshold} → remediation{Extract Class} → prevention{architecture test on cohesion}
```

### Anti-Pattern Rule Compiler

- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Convert each smell record into detection checks, measurable thresholds, severity policy, remediation hints, and recurrence-prevention gates.

Invariant
A smell catalog is enforced only once it compiles into rules.

Flow

```text
SmellRecord → DetectionRule → MetricThreshold → Severity → RefactorHint → Gate
```

Productions

```bnf
AntiPatternRuleCompiler ::= <ArchitectureSmellRecordSet> "->" <DetectionRuleSet> "->" <MetricThresholdSet> "->" <SeverityPolicy> "->" <RemediationPlaybookSet> "->" <PreventionGateSet>
CompiledRule ::= <RuleName> "," <Scope> "," <Detector> "," <Threshold> "," <PriorityRank> "," <FailureMessage> "," <RefactorHint> "," <PreventionGate>
```

Composes
[Severity Policy](https://banes-lab.com/records/algo/severity-policy.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
A smell catalog read by the developer — each entry is advice that nothing executes.
```

After

```text
SmellRecord{God Object} → detection-rule{find unrelated method clusters} → metric-threshold{LCOM > 0.7} → severity{error} → refactor-hint{Extract Class} → gate{fails the build}
```

### Smell Taxonomy

- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Group smells by missing control so detection and remediation can be generalized.

Invariant
Most bad practices are symptoms of a missing architectural control.

Flow

```text
Smell → MissingControl → RuleFamily → RemediationFamily
```

Productions

```bnf
SmellTaxonomy ::= <SmellSet> "->" <MissingControlClassification> "->" <RuleFamilySet> "->" <RemediationFamilySet>
MissingControlClassification ::= "missing_boundary" | "missing_contract" | "missing_type" | "missing_owner" | "missing_version" | "missing_validation" | "missing_observability" | "missing_state_control" | "missing_release_control" | "missing_security_control" | "missing_evidence" | "excessive_abstraction" | "excessive_coupling" | "excessive_manual_process"
```

Composes
none

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
Dozens of smells listed flat, each handed its own bespoke, unrelated fix.
```

After

```text
smell-set{Magic Value, Secret Sprawl, Hardcoded Path} → missing-control{single source of truth} → rule-family{no-inline-authority checks} → remediation-family{centralize then inject}
```

### Anti-Pattern Relationship Record

- Math type: [graph](https://banes-lab.com/records/reason/math-type-graph.md)
- Yields: edge-list

Details

Intent
Model every anti-pattern as a typed relationship record: name, scope, causal links, conflicts, degradations, enabled failures, detection signals, measurement, remediation inverse, prevention, and severity.

Invariant
An anti-pattern is enforceable only when it is represented as a typed relationship record.

Productions

```bnf
AntiPatternRelationshipRecord ::= <AntiPatternName> ":" "Anti-Pattern" "," <scope> "," <caused_by> "," <conflicts_with> "," <degrades> "," <enables_failure> "," <detected_by> "," <measured_by> "," <refactored_by> "," <prevented_by> "," <severity>
```

Composes
none

Forces
[architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
none

Before

```text
An anti-pattern named as free text with no typed edges — not resolvable, not gate-checkable, not linkable to the principle it violates.
```

After

```text
Cyclic Dependency : Anti-Pattern, scope{module}, caused_by{convenience import}, conflicts_with{Low Coupling}, degrades{modularity}, enables_failure{build deadlock}, detected_by{cycle scan}, refactored_by{invert dependency}, prevented_by{dependency rule}, severity{mandatory}
```

### <Architecture Anti-Pattern>

- Meta record

Details

Intent
<Local shortcut> → <Missing control> → <Repeated usage> → <Implicit dependency> → <Boundary/contract erosion> → <Systemic fragility> → <Expensive remediation>

Invariant
Every architecture anti-pattern is a reproducible decay path caused by the absence of a specific control: boundary, contract, ownership, versioning, observability, state isolation, or enforcement.

Flow

```text
Shortcut → Drift → Coupling → Fragility → Detection → Inversion
```

Productions

```bnf
ArchitectureAntiPattern ::= <TriggerCondition> "->" <MissingControl> "->" <DegenerationPath> "->" <DamageModel> "->" <DetectionSignalSet> "->" <RemediationInverse> "->" <PreventionGate>
RemediationInverse ::= "introduce_boundary" | "declare_contract" | "centralize_authority" | "assign_owner" | "version_change" | "add_observability" | "isolate_state" | "enforce_policy"
```

Composes
none

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [observability_traceability](https://banes-lab.com/records/force/observability-traceability.md)

Grounds
none

## Links to

- [Logic](https://banes-lab.com/records/reason/math-type-logic.md)
- [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)
- [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)
- [model_governance](https://banes-lab.com/records/force/model-governance.md)
- [Dynamical Systems](https://banes-lab.com/records/reason/math-type-dynamical-systems.md)
- [modularity](https://banes-lab.com/records/force/modularity.md)
- [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)
- [Algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- [Computation](https://banes-lab.com/records/reason/math-type-computation.md)
- [Severity Policy](https://banes-lab.com/records/algo/severity-policy.md)
- [Set Theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- [Graph](https://banes-lab.com/records/reason/math-type-graph.md)
- [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)
- [observability_traceability](https://banes-lab.com/records/force/observability-traceability.md)
