# pattern-distillation

> 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-pattern-distillation

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_analysis_workspace["Analysis Workspace"]
n_registry_baseline["Registry Baseline"]
n_compliance_gap["Compliance Gap"]
n_semantic_domain_partitioning["Semantic Domain Partitioning"]
n_behavioral_signature_extraction["Behavioral Signature Extraction"]
n_cross_class_pattern_detection["Cross-Class Pattern Detection"]
n_behavioral_inconsistency["Behavioral Inconsistency"]
n_sequential_chain_duplication["Sequential Chain Duplication"]
n_temporal_coupling_detection["Temporal Coupling Detection"]
n_relational_graph_duplication["Relational Graph Duplication"]
n_causal_wiring_duplication["Causal Wiring Duplication"]
n_anomaly_outlier_detection["Anomaly Outlier Detection"]
n_conceptual_duplication_detection["Conceptual Duplication Detection"]
n_fractal_scale_duplication["Fractal Scale Duplication"]
n_anti_pattern_classification["Anti-Pattern Classification"]
n_anti_pattern_priority_matrix["Anti-Pattern Priority Matrix"]
n_abstraction_boundary_principle["Abstraction Boundary Principle"]
n_base_class_candidate_selection["Base-Class Candidate Selection"]
n_concrete_vs_abstract_responsibility_split["Concrete-vs-Abstract Responsibility Split"]
n_template_method_lifecycle["Template Method Lifecycle"]
n_base_schematic_composition["Base Schematic Composition"]
n_migration_ordering["Migration Ordering"]
n_backup_verified_migration["Backup-Verified Migration"]
n_anti_pattern_elimination_verification["Anti-Pattern Elimination Verification"]
n_registry_regeneration["Registry Regeneration"]
n_anti_reintroduction_gate["Anti-Reintroduction Gate"]
n_distillation_metrics["Distillation Metrics"]
n_pattern_distillation_history["Pattern Distillation History"]
n_pattern_distillation_completion_truthfulness["Completion Truthfulness"]
n_pattern_distiller_kernel["Pattern Distiller Kernel"]
n_pattern_distillation_concern["<Pattern Distillation Concern>"]
n_pattern_distiller_kernel --> n_analysis_workspace
n_pattern_distiller_kernel --> n_registry_baseline
n_pattern_distiller_kernel --> n_compliance_gap
n_pattern_distiller_kernel --> n_semantic_domain_partitioning
n_pattern_distiller_kernel --> n_cross_class_pattern_detection
n_pattern_distiller_kernel --> n_anti_pattern_classification
n_pattern_distiller_kernel --> n_base_class_candidate_selection
n_pattern_distiller_kernel --> n_base_schematic_composition
n_pattern_distiller_kernel --> n_registry_regeneration
n_pattern_distiller_kernel --> n_distillation_metrics
n_pattern_distiller_kernel --> n_behavioral_signature_extraction
n_pattern_distiller_kernel --> n_anti_pattern_priority_matrix
n_pattern_distiller_kernel --> n_migration_ordering
n_pattern_distiller_kernel --> n_backup_verified_migration
n_pattern_distiller_kernel --> n_anti_pattern_elimination_verification
n_pattern_distiller_kernel --> n_pattern_distillation_history
n_pattern_distiller_kernel --> n_pattern_distillation_completion_truthfulness
```

### Analysis Workspace

- Stage: [orient](https://banes-lab.com/records/stage/orient.md)
- Axis: [ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Create a unique analysis session, allocate phase/metric/migration artifact locations, load baseline documentation and registries, write a manifest, and block continuation if required context is unavailable.

Invariant
Architectural refactoring must begin from an auditable workspace with explicit input provenance.

Flow

```text
Session → Workspace → ContextLoad → Manifest → Gate
```

Productions

```bnf
AnalysisWorkspace ::= <SessionId> "->" <WorkspacePath> "->" <ContextResourceSet> "->" <Manifest> "->" <InitializationGate>
InitializationGate ::= "workspace_exists" "," "manifest_written" "," "baseline_docs_loaded" "," "registry_loaded"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
none

Before

```text
Refactoring begins ad hoc, with no auditable record of what it started from.
```

After

```text
session → workspace{phase/metric/migration locations} → load baseline + registries → manifest → block if required context missing
```

### Registry Baseline

- Stage: [orient](https://banes-lab.com/records/stage/orient.md)
- Axis: [ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Read existing architectural registries, extract known base abstractions, count implementations, measure hierarchy depth, and record the current abstraction state before proposing changes.

Invariant
New abstractions must be compared against existing architecture before being created.

Flow

```text
Registry → ExistingAbstractions → ImplementationCounts → HierarchyMetrics → Baseline
```

Productions

```bnf
RegistryBaseline ::= <RegistryData> "->" <BaseAbstractionSet> "->" <ImplementationMetricSet> "->" <HierarchyMetricSet> "->" <BaselineReport>
ImplementationMetricSet ::= "total_base_classes" "," "total_implementations" "," "implementation_count_by_base"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)

Grounds
none

Before

```text
A new base abstraction created without measuring what already exists.
```

After

```text
registry → existing bases + implementation counts + hierarchy depth → current abstraction state, before proposing a change
```

### Compliance Gap

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [probability](https://banes-lab.com/records/reason/math-type-probability.md)
- Yields: number[0,1]

Details

Intent
Discover implementation classes by role, detect which ones conform to expected base abstractions, calculate noncompliance counts, and compute architectural compliance rate.

Invariant
Pattern distillation must distinguish missing adoption from missing abstraction.

Flow

```text
RoleClasses → ExpectedBaseRule → ConformingSet + NonconformingSet → ComplianceRate
```

Productions

```bnf
ComplianceGap ::= <RoleClassSet> "->" <BaseExpectation> "->" <ConformanceScan> "->" <GapReport>
BaseExpectation ::= <RoleName> "extends" <ExpectedBaseClass>
GapReport ::= "noncompliant_count" "," "compliant_count" "," "compliance_rate"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
none

Before

```text
'The Foos don't extend a base' — but is the base missing, or just its adoption?
```

After

```text
role classes → expected base rule → conforming vs nonconforming → compliance rate distinguishing missing adoption from missing abstraction
```

### Semantic Domain Partitioning

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Group implementation resources by semantic role, such as manager, repository, handler, service, controller, adapter, or worker, then analyze each family separately.

Invariant
Reusable abstractions emerge from families of similar responsibility, not arbitrary files.

Flow

```text
ResourceSet → RoleClassifier → SemanticDomains → DomainMetrics
```

Productions

```bnf
SemanticDomainPartitioning ::= <ResourceSet> "->" <RoleClassification> "->" <SemanticDomainSet>
SemanticDomain ::= <DomainName> "," <ResourcePathSet> "," <ClassCount> "," <BehavioralSignatureSet>
RoleClassification ::= "manager" | "repository" | "handler" | "service" | "controller" | "adapter" | "worker" | "unknown"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [performance_scaling](https://banes-lab.com/records/force/performance-scaling.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)

Grounds
none

Before

```text
Abstractions drawn from arbitrary files instead of families of like responsibility.
```

After

```text
resources → classify by role{manager|repository|handler|service|adapter} → per-family analysis
```

### Behavioral Signature Extraction

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Yields: operation

Details

Intent
For each class in a semantic domain, inspect constructor behavior, lifecycle hooks, error handling, state management, dependency acquisition, and public orchestration methods.

Invariant
Base-class candidates require behavioral evidence, not just naming similarity.

Flow

```text
ClassResource → BehaviorScan → Signature → DomainSignatureSet
```

Productions

```bnf
BehavioralSignature ::= <InitializationBehavior> "," <LifecycleBehavior> "," <ErrorHandlingBehavior> "," <StateManagementBehavior> "," <DependencyManagementBehavior> "," <PublicMethodPatternSet>
LifecycleBehavior ::= "initialize" "," "destroy" "," "onInitialize" "," "onDestroy"
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md), [control_coordination](https://banes-lab.com/records/force/control-coordination.md)

Grounds
none

Detector for
[structural](https://banes-lab.com/records/reason/lens-structural.md), [behavioural](https://banes-lab.com/records/reason/lens-behavioural.md)

Before

```text
A base-class candidate proposed on naming similarity alone.
```

After

```text
class → scan{constructor, lifecycle hooks, error handling, state, dependencies, public methods} → behavioral signature (evidence, not names)
```

### Cross-Class Pattern Detection

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Search across semantic domains for repeated imports, repeated initialization, repeated lifecycle code, repeated error handling, repeated state setup, and repeated dependency wiring.

Invariant
Duplication becomes an abstraction candidate when it appears across multiple implementations with the same role.

Flow

```text
DomainSignatures → CrossClassSearch → DuplicatePatternSet
```

Productions

```bnf
CrossClassPatternDetection ::= <BehavioralSignatureSet> "->" <RepeatedStructureSearch> "->" <CrossClassPatternSet>
CrossClassPattern ::= <PatternName> "," <OccurrenceCount> "," <AffectedResourceSet> "," <PatternRole>
PatternRole ::= "initialization" | "lifecycle" | "error_handling" | "state_management" | "dependency_management"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
none

Detector for
[structural](https://banes-lab.com/records/reason/lens-structural.md), [frequency](https://banes-lab.com/records/reason/lens-frequency.md)

Before

```text
One duplicated block noticed; the family-wide repetition stays invisible.
```

After

```text
signatures → search repeated{imports, init, lifecycle, error, state, deps} across the role family → cross-class pattern + occurrence count
```

### Behavioral Inconsistency

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [probability](https://banes-lab.com/records/reason/math-type-probability.md)
- Yields: number[0,1]

Details

Intent
Detect multiple competing implementations of the same behavior, count each variation, compute dominant-pattern consistency, and flag low-consistency behavior for normalization.

Invariant
Inconsistent behavior is an architectural smell even when code is not textually duplicated.

Flow

```text
BehaviorFamily → VariationCounts → ConsistencyRate → NormalizeCandidate
```

Productions

```bnf
BehavioralInconsistency ::= <BehaviorFamily> "->" <VariationSet> "->" <ConsistencyMetric> "->" <InconsistencyVerdict>
ConsistencyMetric ::= "max_variation_count / total_variation_count"
InconsistencyVerdict ::= "consistent" | "weakly_consistent" | "inconsistent"
```

Composes
none

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
none

Detector for
[behavioural](https://banes-lab.com/records/reason/lens-behavioural.md)

Before

```text
Three competing implementations of one behavior, none textually duplicated, so nothing flags.
```

After

```text
behavior family → variation counts → consistency = dominant/total → {consistent | weakly | inconsistent} → normalize the inconsistent
```

### Sequential Chain Duplication

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
For each class in the role family, extract the ordered sequence of orchestration steps, align sequences across the family, and surface repeated ordered chains that no textual-duplication scan would catch.

Invariant
Order-sensitive repetition is duplication even when no contiguous block is textually identical.

Flow

```text
RoleFamily → OrderedCallSequence → SequenceAlignment → RepeatedChainSet
```

Productions

```bnf
SequentialChainDuplication ::= <CallSequenceSet> "->" <SequenceAlignment> "->" <RepeatedOrderedChainSet>
RepeatedOrderedChain ::= <OrderedStepList> "," <OccurrenceCount> "," <AffectedResourceSet>
```

Composes
none

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)

Grounds
[ana-sequential](https://banes-lab.com/records/reason/node-ana-sequential.md)

Detector for
[sequential](https://banes-lab.com/records/reason/lens-sequential.md)

Before

```text
Two classes call the same steps in the same order, but no single block is textually identical, so frequency scanning finds nothing.
```

After

```text
role family → extract ordered call-sequence per class → align sequences → repeated ordered chain + occurrence count
```

### Temporal Coupling Detection

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Detect must-precede and must-follow ordering constraints between operations in each class, intersect them across the role family, and surface the shared temporal-coupling contract that a base lifecycle would centralize.

Invariant
A lifecycle ordering constraint re-encoded across a family is a shared contract, not a per-class detail.

Flow

```text
RoleFamily → OrderingConstraintSet → CrossFamilyIntersection → SharedCouplingContract
```

Productions

```bnf
TemporalCouplingDetection ::= <OrderingConstraintSet> "->" <ConstraintIntersection> "->" <SharedTemporalContractSet>
OrderingConstraint ::= <Operation> "must_precede" <Operation> | <Operation> "must_follow" <Operation>
```

Composes
none

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [control_coordination](https://banes-lab.com/records/force/control-coordination.md)

Grounds
[ana-temporal](https://banes-lab.com/records/reason/node-ana-temporal.md)

Detector for
[temporal](https://banes-lab.com/records/reason/lens-temporal.md)

Before

```text
Every class re-encodes 'call setup before use, teardown after' as scattered ad-hoc ordering, and the shared lifecycle contract stays invisible.
```

After

```text
role family → must-precede/must-follow constraints per class → intersect across family → shared temporal-coupling contract
```

### Relational Graph Duplication

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [graph](https://banes-lab.com/records/reason/math-type-graph.md)
- Yields: edge-list

Details

Intent
Build the dependency-acquisition subgraph for each class, test for isomorphic subgraphs across the role family, and surface repeated object-graph wiring that a base or factory would assemble once.

Invariant
A dependency subgraph reassembled across a family is duplicated structure, distinct from duplicated statements.

Flow

```text
RoleFamily → DependencySubgraph → SubgraphIsomorphism → RepeatedWiringSet
```

Productions

```bnf
RelationalGraphDuplication ::= <DependencySubgraphSet> "->" <IsomorphismScan> "->" <RepeatedWiringSubgraphSet>
RepeatedWiringSubgraph ::= <NodeSet> "," <EdgeSet> "," <OccurrenceCount> "," <AffectedResourceSet>
```

Composes
none

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)

Grounds
[ana-relational](https://banes-lab.com/records/reason/node-ana-relational.md)

Detector for
[relational](https://banes-lab.com/records/reason/lens-relational.md)

Before

```text
The same object graph — acquire A, wire B onto A, hand both to C — is reassembled by hand in every class.
```

After

```text
role family → dependency-acquisition subgraph per class → subgraph isomorphism across family → repeated wiring subgraph
```

### Causal Wiring Duplication

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [graph](https://banes-lab.com/records/reason/math-type-graph.md)
- Yields: edge-list

Details

Intent
Extract cause-to-effect edges (event to handler, failure to recovery, state change to reaction) per class, match trigger/reaction pairs across the role family, and surface repeated causal wiring that a base policy would centralize.

Invariant
Repeated trigger-to-reaction wiring is duplicated causal policy even when the surrounding code differs.

Flow

```text
RoleFamily → CausalEdgeSet → TriggerReactionMatch → RepeatedCausalWiringSet
```

Productions

```bnf
CausalWiringDuplication ::= <CausalEdgeSet> "->" <TriggerReactionMatch> "->" <RepeatedCausalWiringSet>
CausalEdge ::= <Trigger> "causes" <Reaction> "," <OccurrenceCount>
```

Composes
none

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)

Grounds
[ana-causal](https://banes-lab.com/records/reason/node-ana-causal.md)

Detector for
[causal](https://banes-lab.com/records/reason/lens-causal.md)

Before

```text
The same trigger-to-reaction wiring — this event runs that handler, that failure invokes this recovery — is duplicated across the family.
```

After

```text
role family → cause->effect edges per class → match trigger/reaction pairs across family → repeated causal-wiring set
```

### Anomaly Outlier Detection

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [probability](https://banes-lab.com/records/reason/math-type-probability.md)
- Yields: number[0,1]

Details

Intent
Score each class's deviation from the dominant behavioral signature, identify the outliers, and name why each deviates, so inconsistency is localized to the deviant implementation rather than reported as an aggregate rate.

Invariant
Inconsistency is an anomaly to be localized to a deviant implementation, not merely a family-level ratio.

Flow

```text
BehaviorFamily → DominantSignature → DeviationScore → OutlierSet
```

Productions

```bnf
AnomalyOutlierDetection ::= <BehaviorFamily> "->" <DominantSignature> "->" <DeviationScoreSet> "->" <OutlierSet>
Outlier ::= <Resource> "," <DeviationScore> "," <DeviationReason>
```

Composes
none

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

Grounds
[ana-anomaly](https://banes-lab.com/records/reason/node-ana-anomaly.md)

Detector for
[anomaly](https://banes-lab.com/records/reason/lens-anomaly.md)

Before

```text
A family shares one behavior — except the one class that does it differently, and a consistency ratio only reports 'weakly consistent' without naming the deviant.
```

After

```text
behavior family → per-class deviation score against the dominant signature → outlier set + why each deviates → normalize or justify
```

### Conceptual Duplication Detection

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [information-theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- Yields: novelty-score

Details

Intent
Derive a name-independent semantic signature for each behavior (intent, input-to-output shape, effects), cluster behaviors by meaning rather than identifier, and surface same-meaning/different-name clusters that only the semantic lens can detect.

Invariant
Same meaning under different names is duplication that textual, structural, and frequency lenses are blind to.

Flow

```text
RoleFamily → SemanticSignature → MeaningCluster → ConceptualDuplicateSet
```

Productions

```bnf
ConceptualDuplicationDetection ::= <SemanticSignatureSet> "->" <MeaningClustering> "->" <ConceptualDuplicateSet>
SemanticSignature ::= <Intent> "," <InputOutputShape> "," <EffectSet>
```

Composes
none

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)

Grounds
[ana-semantic](https://banes-lab.com/records/reason/node-ana-semantic.md)

Detector for
[semantic](https://banes-lab.com/records/reason/lens-semantic.md)

Before

```text
Two implementations mean the same thing under different names, so no textual, structural, or frequency scan flags them.
```

After

```text
role family → semantic signature per behavior (intent, inputs->outputs, effects) → cluster by meaning not name → same-meaning/different-name set + novelty score
```

### Fractal Scale Duplication

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [topology](https://banes-lab.com/records/reason/math-type-topology.md)
- Yields: boolean

Details

Intent
Test whether a duplication shape recurs at more than one scale (method, class, module), and determine the scale at which the abstraction belongs, so single-scale scanning does not abstract at the wrong level.

Invariant
A shape that recurs across scales must be abstracted at the scale where it is invariant, not only where it was first noticed.

Flow

```text
CandidateShape → MultiScaleRecurrence → ScaleInvariance → AbstractionScale
```

Productions

```bnf
FractalScaleDuplication ::= <CandidateShape> "->" <MultiScaleRecurrenceScan> "->" <ScaleInvarianceVerdict>
ScaleInvarianceVerdict ::= "method_scale" | "class_scale" | "module_scale" | "scale_invariant"
```

Composes
none

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

Grounds
[ana-fractal](https://banes-lab.com/records/reason/node-ana-fractal.md)

Detector for
[fractal](https://banes-lab.com/records/reason/lens-fractal.md)

Before

```text
The distiller scans one scale — the class family — and misses that the same shape repeats at the method level and again at the module level.
```

After

```text
candidate shape → test recurrence at method / class / module scale → scale-invariant duplication + the scale the abstraction belongs at
```

### Anti-Pattern Classification

- Stage: [derive](https://banes-lab.com/records/stage/derive.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Convert duplicated, inconsistent, and architecture-violating findings into anti-pattern records with type, occurrence count, impact, effort, severity, and affected resources.

Invariant
Refactoring targets should be normalized into comparable anti-pattern contracts.

Flow

```text
Finding → AntiPatternRecord → PriorityInput
```

Productions

```bnf
AntiPatternClassification ::= <FindingSet> "->" <AntiPatternSet>
AntiPattern ::= <AntiPatternType> "," <Pattern> "," <OccurrenceCount> "," <Impact> "," <Effort> "," <PriorityRank> "," <AffectedResourceSet>
AntiPatternType ::= "copy_paste_duplication" | "behavioral_inconsistency" | "architectural_violation" | "conceptual_duplication" | "structural_duplication" | "sequential_duplication" | "temporal_coupling" | "relational_duplication" | "causal_duplication" | "scale_duplication"
PriorityRank ::= "critical" | "high" | "medium" | "low"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md), [Custom-Rule Derivation](https://banes-lab.com/records/algo/custom-rule-derivation.md)

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
none

Before

```text
Findings kept as loose notes, not comparable across the backlog.
```

After

```text
findings → anti-pattern records{type, occurrence, impact, effort, severity, affected resources}
```

### Anti-Pattern Priority Matrix

- Stage: [intent](https://banes-lab.com/records/stage/intent.md)
- Axis: [teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- Math type: [optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- Yields: boolean | ranking

Details

Intent
Assign numeric impact and effort scores, calculate priority, sort anti-patterns, and group them into remediation bands.

Invariant
Distillation should address high-value anti-patterns first.

Flow

```text
AntiPattern → ImpactScore + EffortScore → Priority → SortedBacklog
```

Productions

```bnf
PriorityMatrix ::= <AntiPatternSet> "->" <ScoredAntiPatternSet> "->" <PriorityBandSet>
ScoredAntiPattern ::= <AntiPattern> "," <ImpactScore> "," <EffortScore> "," <PriorityValue>
PriorityValue ::= <ImpactScore> "*" <EffortScore>
PriorityBand ::= "priority_1" | "priority_2" | "priority_3"
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
[tel-priority](https://banes-lab.com/records/reason/node-tel-priority.md)

Before

```text
Refactoring picks a target by gut feel, not value.
```

After

```text
anti-patterns → impact * effort → priority → sorted into remediation bands
```

### Abstraction Boundary Principle

- Stage: [derive](https://banes-lab.com/records/stage/derive.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Evaluate each high-priority anti-pattern against boundary principles: universal, invariant, foundational, enforcing, and cognitive-load-reducing.

Invariant
A base abstraction is justified only when the behavior belongs below the subclass boundary.

Flow

```text
AntiPattern → BoundaryPrinciples → PrinciplesMet → AbstractionEligible
```

Productions

```bnf
BoundaryPrincipleEvaluation ::= <AntiPattern> "->" <BoundaryPrincipleSet> "->" <EligibilityVerdict>
BoundaryPrincipleSet ::= "universal" "," "invariant" "," "foundational" "," "enforcing" "," "reducing_load"
EligibilityVerdict ::= "base_candidate" | "utility_candidate" | "composition_candidate" | "local_refactor_only"
```

Composes
none

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)

Grounds
none

Before

```text
Duplication abstracted into a base whether or not the behavior belongs below the subclass boundary.
```

After

```text
anti-pattern → boundary principles{universal, invariant, foundational, enforcing, load-reducing} → {base | utility | composition | local-refactor}
```

### Base-Class Candidate Selection

- Stage: [derive](https://banes-lab.com/records/stage/derive.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Promote an anti-pattern to a base-class candidate only when it satisfies enough boundary principles and applies across a meaningful portion of the semantic domain.

Invariant
Inheritance should encode stable lifecycle or invariant behavior, not incidental reuse.

Flow

```text
AntiPattern + DomainCoverage + BoundaryScore → Candidate|Reject
```

Productions

```bnf
BaseClassCandidateSelection ::= <AntiPattern> "," <DomainCoverage> "," <BoundaryScore> "->" <CandidateVerdict>
CandidateVerdict ::= "create_base_class" | "prefer_composition" | "prefer_utility" | "reject_abstraction"
DomainCoverage ::= "occurrence_count / total_domain_classes"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)

Grounds
none

Before

```text
Incidental reuse promoted to inheritance.
```

After

```text
anti-pattern + domain coverage + boundary score → verdict{create_base | prefer_composition | prefer_utility | reject}
```

### Concrete-vs-Abstract Responsibility Split

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
Partition the family's behavior into what is invariant across every member (the topology preserved under substitution) and what varies per member (the novelty); the invariant set becomes the concrete base, the variant set becomes the abstract seam. The concrete/abstract boundary is derived from the evidence, not read off a fixed lifecycle vocabulary — so the split holds for any paradigm, not only OOP class lifecycles.

Invariant
The concrete/abstract boundary is the invariant/variant boundary of the family, discovered from evidence — never a pre-assumed lifecycle template.

Flow

```text
FamilyBehaviorSet → InvariantPartition + VariantPartition → ConcreteBase + AbstractSeam
```

Productions

```bnf
ResponsibilitySplit ::= <FamilyBehaviorSet> "->" <InvariantSet> "," <VariantSet> "->" <ConcreteBase> "," <AbstractSeamSet>
InvariantSet ::= "behavior identical across every family member"
VariantSet ::= "behavior that differs per family member"
AbstractSeam ::= <VariantBehaviorName> "," <SeamKind>
SeamKind ::= "hook" | "abstract_method" | "injected_strategy" | "parameter"
```

Composes
none

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [control_coordination](https://banes-lab.com/records/force/control-coordination.md)

Grounds
[invariant](https://banes-lab.com/records/reason/substrate-node-invariant.md), [ont-novelty](https://banes-lab.com/records/reason/node-ont-novelty.md)

Before

```text
The split is drawn from a fixed OOP lifecycle vocabulary (constructor/initialize/destroy/onInitialize/executeCore), which pre-decides the shape whether or not the family's behavior matches it.
```

After

```text
family behavior → partition INVARIANT (identical across every member) from VARIANT (differs per member) → invariant set = concrete base, variant set = the abstract seam; the hook names are read from the variant behavior, not assumed
```

### Template Method Lifecycle

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
Define public lifecycle methods that enforce guard checks, call shared setup or cleanup, invoke subclass hooks, and centralize error handling.

Invariant
Template method converts repeated lifecycle code into one predictable behavioral contract.

Flow

```text
PublicMethod → Guard → SharedBehavior → Hook → ErrorPolicy → Result
```

Productions

```bnf
TemplateLifecycle ::= <LifecycleMethod> "->" <GuardCheck> "->" <SharedOperation> "->" <SubclassHook> "->" <ErrorHandlingPolicy>
LifecycleMethod ::= "initialize" | "destroy" | "execute" | "process"
SubclassHook ::= "onInitialize" | "onDestroy" | "onExecute" | "onProcess"
```

Composes
none

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
none

Before

```text
Each subclass re-implements the same guard-setup-cleanup lifecycle.
```

After

```text
public lifecycle method → guard → shared setup/cleanup → subclass hook → centralized error handling → one predictable contract
```

### Base Schematic Composition

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Generate the base abstraction from the selected candidate, enforce size constraints, split if oversized, and record which anti-patterns the abstraction eliminates.

Invariant
Generated abstractions must remain small enough to be maintainable.

Flow

```text
Candidate → GenerateBase → SizeCheck → SplitIfNeeded → BaseArtifact
```

Productions

```bnf
BaseSchematicComposition ::= <BaseClassCandidate> "->" <GeneratedBaseArtifact> "->" <ConstraintCheck> "->" <PersistableBaseArtifact>
ConstraintCheck ::= "line_count <= max_allowed_lines" "," "name_matches_convention" "," "location_matches_architecture"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
none

Before

```text
A base generated so large it becomes the new god object.
```

After

```text
candidate → generate base → size <= max (split if oversized) + name + location conventions → persistable base
```

### Migration Ordering

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
Sort target classes by complexity from lowest to highest, migrate simpler implementations first, and use early migrations to validate the abstraction before complex adoption.

Invariant
Migration risk decreases when the base pattern is proven on low-complexity cases first.

Flow

```text
TargetClasses → ComplexityMetric → SortedMigrationOrder
```

Productions

```bnf
MigrationOrdering ::= <TargetClassSet> "->" <ComplexityScoreSet> "->" <MigrationQueue>
ComplexityScore ::= "line_count" | "method_count" | "dependency_count" | "state_property_count"
MigrationQueue ::= "ascending_complexity"
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
none

Before

```text
The most complex implementation migrated first, and the base is wrong before it's proven.
```

After

```text
target classes → complexity score → migrate ascending complexity → prove the base on simple cases first
```

### Backup-Verified Migration

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
For each target class, create a recoverable checkpoint, refactor it to extend or use the abstraction, verify the removed anti-pattern no longer exists, and restore from backup on failure.

Invariant
Structural migration must be reversible per target artifact.

Flow

```text
Backup → Refactor → Verify → Commit|Restore
```

Productions

```bnf
MigrationExecution ::= <TargetClass> "->" <Checkpoint> "->" <RefactorToBase> "->" <Verification> "->" <MigrationOutcome>
MigrationOutcome ::= "committed" | "restored_from_checkpoint" | "failed_with_log"
```

Composes
none

Composed by
[Custom-Rule Derivation](https://banes-lab.com/records/algo/custom-rule-derivation.md)

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [streaming_dataflow](https://banes-lab.com/records/force/streaming-dataflow.md), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
none

Before

```text
A refactor breaks a target and there is no way back.
```

After

```text
per target → checkpoint → refactor to the base → verify the anti-pattern is gone → commit | restore from checkpoint
```

### Anti-Pattern Elimination Verification

- Stage: [verify](https://banes-lab.com/records/stage/verify.md)
- Axis: [verification](https://banes-lab.com/records/reason/axis-verification.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
After migration, search the entire target scope for old duplicate patterns, allow only approved base-location occurrences, and fail completion if unapproved duplicates remain.

Invariant
Refactoring is incomplete until the old pattern is gone.

Flow

```text
KnownAntiPattern → ScopeSearch → RemainingOccurrences → Pass|Fail
```

Productions

```bnf
AntiPatternElimination ::= <AntiPatternPatternSet> "->" <WholeScopeSearch> "->" <RemainingOccurrenceSet> "->" <EliminationVerdict>
EliminationVerdict ::= "eliminated" | "remaining_unapproved_occurrences" | "base_only_occurrence"
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
[ver-evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)

Before

```text
Distillation declared done while the old pattern still lives at three sites.
```

After

```text
known anti-pattern → search the whole scope → allow only approved base-location occurrences → fail completion on unapproved duplicates
```

### Registry Regeneration

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
After creating or migrating abstractions, regenerate or update the architecture registry, reread it, and confirm the new base and migrated implementations are represented.

Invariant
Architecture metadata must reflect the new implementation truth.

Flow

```text
RefactorResult → RegistryRegeneration → RegistryReadback → RepresentationCheck
```

Productions

```bnf
RegistryRegeneration ::= <MigrationResult> "->" <RegistryUpdate> "->" <UpdatedRegistry> "->" <RegistryVerification>
RegistryVerification ::= "new_base_present" "," "implementation_count_updated" "," "old_pattern_absent_or_marked"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)

Grounds
none

Before

```text
The registry still reflects the pre-refactor architecture.
```

After

```text
migration result → regenerate registry → reread → confirm new base + migrated implementations represented
```

### Anti-Reintroduction Gate

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
After eliminating an anti-pattern, author or strengthen the custom lint rule that statically forbids its reintroduction and any bypass of the new base, build the rule plugin, and regenerate the rule catalog, so the distilled boundary is enforced by a gate rather than by discipline.

Invariant
A distilled pattern is incomplete until a gate forbids its reintroduction — the gate holds the line, not discipline.

Flow

```text
DistilledBoundary → LintRuleAuthored → PluginBuilt → CatalogRegenerated → EnforcedBoundary
```

Productions

```bnf
AntiReintroductionGate ::= <DistilledBoundary> "->" <CustomLintRule> "->" <PluginBuild> "->" <CatalogRegeneration> "->" <EnforcementVerdict>
EnforcementVerdict ::= "gate_active" | "gate_absent"
```

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), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
[constraint](https://banes-lab.com/records/reason/substrate-node-constraint.md)

Before

```text
The distilled base eliminates the duplication today, but nothing stops the developer or the model from reintroducing the same anti-pattern — the gate held only for this run, by discipline.
```

After

```text
distilled boundary → author/strengthen a custom lint rule forbidding the anti-pattern + the base-bypass → build the plugin → regenerate the rule catalog → the boundary is enforced structurally
```

### Distillation Metrics

- Stage: [verify](https://banes-lab.com/records/stage/verify.md)
- Axis: [verification](https://banes-lab.com/records/reason/axis-verification.md)
- Math type: [probability](https://banes-lab.com/records/reason/math-type-probability.md)
- Yields: number[0,1]

Details

Intent
Calculate duplication reduction, code reduction, adoption rate, lines saved, maintenance burden reduction, and cognitive-load reduction after migration.

Invariant
Refactoring should produce measurable architectural ROI.

Flow

```text
BeforeMetrics + AfterMetrics → ReductionMetrics → ROISummary
```

Productions

```bnf
DistillationMetrics ::= <BaselineMetricSet> "," <PostMigrationMetricSet> "->" <FinalMetricSet>
FinalMetricSet ::= "duplication_reduction" "," "code_reduction" "," "base_class_adoption" "," "lines_saved" "," "maintenance_burden_reduction" "," "cognitive_load_reduction"
```

Composes
none

Composed by
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
none

Before

```text
ROI asserted ('much cleaner now') with no numbers.
```

After

```text
before + after → {duplication reduction, code reduction, adoption rate, lines saved, maintenance + cognitive-load reduction}
```

### Pattern Distillation History

- Stage: [commit](https://banes-lab.com/records/stage/commit.md)
- Axis: [representation](https://banes-lab.com/records/reason/axis-representation.md)
- Math type: [information-theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- Yields: hash | novelty-score

Details

Intent
Append the completed analysis summary to a durable history log, store metric snapshots, and preserve lessons learned for future abstraction decisions.

Invariant
Refactoring intelligence improves when outcomes become reusable historical evidence.

Flow

```text
Summary → HistoryAppend → MetricSnapshot → LessonsLearned
```

Productions

```bnf
DistillationHistory ::= <SummaryReport> "->" <HistoryLog> "->" <MetricStore> "->" <ReusableLearningSet>
ReusableLearning ::= <Lesson> "," <Evidence> "," <ApplicabilityContext>
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

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

Grounds
none

Before

```text
Each distillation forgets the last — the same lessons re-learned.
```

After

```text
summary → durable history log + metric snapshots + lessons → reusable evidence for future abstraction decisions
```

### Completion Truthfulness

- Stage: [terminate](https://banes-lab.com/records/stage/terminate.md)
- Axis: [termination](https://banes-lab.com/records/reason/axis-termination.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Mark pattern distillation complete only if workspace, baseline, semantic analysis, anti-pattern classification, abstraction selection, migration, verification, registry update, anti-reintroduction gate, and metrics logging all pass.

Invariant
Completion is an evidence state, not an assertion — and it includes a gate that forbids the anti-pattern's return.

Flow

```text
PhaseGates → VerificationResults → Metrics → Complete|Incomplete
```

Productions

```bnf
DistillationCompletion ::= <InitializationGate> "," <RegistryGate> "," <SemanticAnalysisGate> "," <AntiPatternGate> "," <AbstractionGate> "," <MigrationGate> "," <EnforcementGate> "," <MetricsGate> "->" <CompletionVerdict>
CompletionVerdict ::= "pattern_distillation_complete" | "pattern_distillation_incomplete"
```

Composes
none

Named in the derivation of
[Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
[ter-stop](https://banes-lab.com/records/reason/node-ter-stop.md)

Before

```text
'Done' asserted while verification, registry-update, and the anti-reintroduction gate never ran.
```

After

```text
gates{workspace, baseline, semantic, anti-pattern, abstraction, migration, verification, registry, enforcement, metrics} all pass → complete; else incomplete
```

### Pattern Distiller Kernel

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

Details

Intent
Initialize an analysis workspace, read registry baselines, partition semantic domains, extract behavioral signatures, detect anti-patterns, prioritize them, evaluate abstraction boundaries, compose base schematics, migrate targets, verify elimination, update registries, calculate ROI, and persist history.

Invariant
Pattern distillation is a forensic compiler from repeated behavioral evidence into predictable implementation architecture.

Flow

```text
Workspace → Registry → Semantics → AntiPatterns → Abstraction → Migration → Verification → Metrics → History
```

Productions

```bnf
PatternDistillerKernel ::= <AnalysisWorkspace> "->" <RegistryBaseline> "->" <ComplianceGap> "->" <SemanticDomainPartitioning> "->" <BehavioralSignature> "->" <CrossClassPatternDetection> "->" <AntiPatternClassification> "->" <PriorityMatrix> "->" <BoundaryPrincipleEvaluation> "->" <BaseClassCandidateSelection> "->" <ResponsibilitySplit> "->" <BaseSchematicComposition> "->" <MigrationExecution> "->" <AntiPatternElimination> "->" <RegistryRegeneration> "->" <DistillationMetrics> "->" <DistillationHistory>
```

Composes
[Analysis Workspace](https://banes-lab.com/records/algo/analysis-workspace.md), [Registry Baseline](https://banes-lab.com/records/algo/registry-baseline.md), [Compliance Gap](https://banes-lab.com/records/algo/compliance-gap.md), [Semantic Domain Partitioning](https://banes-lab.com/records/algo/semantic-domain-partitioning.md), [Cross-Class Pattern Detection](https://banes-lab.com/records/algo/cross-class-pattern-detection.md), [Anti-Pattern Classification](https://banes-lab.com/records/algo/anti-pattern-classification.md), [Base-Class Candidate Selection](https://banes-lab.com/records/algo/base-class-candidate-selection.md), [Base Schematic Composition](https://banes-lab.com/records/algo/base-schematic-composition.md), [Registry Regeneration](https://banes-lab.com/records/algo/registry-regeneration.md), [Distillation Metrics](https://banes-lab.com/records/algo/distillation-metrics.md)

Composed by
[Custom-Rule Derivation](https://banes-lab.com/records/algo/custom-rule-derivation.md)

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

Grounds
[derivation-loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)

Derivation map

orient
[Analysis Workspace](https://banes-lab.com/records/algo/analysis-workspace.md)

see
[Behavioral Signature Extraction](https://banes-lab.com/records/algo/behavioral-signature-extraction.md)

derive
[Anti-Pattern Classification](https://banes-lab.com/records/algo/anti-pattern-classification.md)

intent
[Anti-Pattern Priority Matrix](https://banes-lab.com/records/algo/anti-pattern-priority-matrix.md)

project
[Migration Ordering](https://banes-lab.com/records/algo/migration-ordering.md)

act
[Backup-Verified Migration](https://banes-lab.com/records/algo/backup-verified-migration.md)

verify
[Anti-Pattern Elimination Verification](https://banes-lab.com/records/algo/anti-pattern-elimination-verification.md)

commit
[Pattern Distillation History](https://banes-lab.com/records/algo/pattern-distillation-history.md)

terminate
[Completion Truthfulness](https://banes-lab.com/records/algo/pattern-distillation-completion-truthfulness.md)

Before

```text
Repeated behavior abstracted by intuition, migrated irreversibly, never verified.
```

After

```text
workspace → baseline → semantics → anti-patterns → abstraction boundary → base schematic → reversible migration → elimination proof → registry regenerate → ROI → history
```

### <Pattern Distillation Concern>

- Meta record

Details

Intent
<Initialize evidence workspace> → <Measure current architecture> → <Group semantic families> → <Extract behavioral signatures> → <Detect duplicate/inconsistent behavior> → <Score anti-patterns> → <Evaluate abstraction boundary> → <Compose reusable schematic> → <Migrate with rollback> → <Verify old-pattern elimination> → <Record ROI>

Invariant
Any repeated implementation behavior should become a shared abstraction only when evidence proves it is universal, invariant, foundational, enforceable, and cognitively load-reducing.

Flow

```text
Evidence → Semantics → AntiPattern → Boundary → Abstraction → Migration → Verification → Metrics
```

Productions

```bnf
PatternDistillationConcern ::= <EvidenceWorkspace> "->" <ArchitecturalBaseline> "->" <SemanticDomainSet> "->" <BehavioralSignatureSet> "->" <AntiPatternSet> "->" <AbstractionBoundary> "->" <ReusableSchematic> "->" <MigrationPlan> "->" <EliminationVerification> "->" <ROIMetrics>
AbstractionBoundary ::= "universal" "," "invariant" "," "foundational" "," "enforcing" "," "reducing_load"
```

Composes
none

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

Grounds
none

## Links to

- [Orient](https://banes-lab.com/records/stage/orient.md)
- [Ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- [Set Theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- [Pattern Distiller Kernel](https://banes-lab.com/records/algo/pattern-distiller-kernel.md)
- [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)
- [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)
- [See](https://banes-lab.com/records/stage/see.md)
- [Analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- [Probability](https://banes-lab.com/records/reason/math-type-probability.md)
- [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)
- [modularity](https://banes-lab.com/records/force/modularity.md)
- [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)
- [performance_scaling](https://banes-lab.com/records/force/performance-scaling.md)
- [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)
- [control_coordination](https://banes-lab.com/records/force/control-coordination.md)
- [Structural](https://banes-lab.com/records/reason/lens-structural.md)
- [Behavioural](https://banes-lab.com/records/reason/lens-behavioural.md)
- [Frequency](https://banes-lab.com/records/reason/lens-frequency.md)
- [Algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)
- [Ana Sequential](https://banes-lab.com/records/reason/node-ana-sequential.md)
- [Sequential](https://banes-lab.com/records/reason/lens-sequential.md)
- [Ana Temporal](https://banes-lab.com/records/reason/node-ana-temporal.md)
- [Temporal](https://banes-lab.com/records/reason/lens-temporal.md)
- [Graph](https://banes-lab.com/records/reason/math-type-graph.md)
- [Ana Relational](https://banes-lab.com/records/reason/node-ana-relational.md)
- [Relational](https://banes-lab.com/records/reason/lens-relational.md)
- [Ana Causal](https://banes-lab.com/records/reason/node-ana-causal.md)
- [Causal](https://banes-lab.com/records/reason/lens-causal.md)
- [Ana Anomaly](https://banes-lab.com/records/reason/node-ana-anomaly.md)
- [Anomaly](https://banes-lab.com/records/reason/lens-anomaly.md)
- [Information Theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- [Ana Semantic](https://banes-lab.com/records/reason/node-ana-semantic.md)
- [Semantic](https://banes-lab.com/records/reason/lens-semantic.md)
- [Topology](https://banes-lab.com/records/reason/math-type-topology.md)
- [Ana Fractal](https://banes-lab.com/records/reason/node-ana-fractal.md)
- [Fractal](https://banes-lab.com/records/reason/lens-fractal.md)
- [Derive](https://banes-lab.com/records/stage/derive.md)
- [Reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- [Logic](https://banes-lab.com/records/reason/math-type-logic.md)
- [Custom-Rule Derivation](https://banes-lab.com/records/algo/custom-rule-derivation.md)
- [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)
- [Intent](https://banes-lab.com/records/stage/intent.md)
- [Teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- [Optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- [Tel Priority](https://banes-lab.com/records/reason/node-tel-priority.md)
- [Project](https://banes-lab.com/records/stage/project.md)
- [Invariant](https://banes-lab.com/records/reason/substrate-node-invariant.md)
- [Ont Novelty](https://banes-lab.com/records/reason/node-ont-novelty.md)
- [Act](https://banes-lab.com/records/stage/act.md)
- [Formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- [Computation](https://banes-lab.com/records/reason/math-type-computation.md)
- [streaming_dataflow](https://banes-lab.com/records/force/streaming-dataflow.md)
- [Verify](https://banes-lab.com/records/stage/verify.md)
- [Verification](https://banes-lab.com/records/reason/axis-verification.md)
- [Ver Evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)
- [Constraint](https://banes-lab.com/records/reason/substrate-node-constraint.md)
- [Commit](https://banes-lab.com/records/stage/commit.md)
- [Representation](https://banes-lab.com/records/reason/axis-representation.md)
- [Terminate](https://banes-lab.com/records/stage/terminate.md)
- [Termination](https://banes-lab.com/records/reason/axis-termination.md)
- [Ter Stop](https://banes-lab.com/records/reason/node-ter-stop.md)
- [Analysis Workspace](https://banes-lab.com/records/algo/analysis-workspace.md)
- [Registry Baseline](https://banes-lab.com/records/algo/registry-baseline.md)
- [Compliance Gap](https://banes-lab.com/records/algo/compliance-gap.md)
- [Semantic Domain Partitioning](https://banes-lab.com/records/algo/semantic-domain-partitioning.md)
- [Cross-Class Pattern Detection](https://banes-lab.com/records/algo/cross-class-pattern-detection.md)
- [Anti-Pattern Classification](https://banes-lab.com/records/algo/anti-pattern-classification.md)
- [Base-Class Candidate Selection](https://banes-lab.com/records/algo/base-class-candidate-selection.md)
- [Base Schematic Composition](https://banes-lab.com/records/algo/base-schematic-composition.md)
- [Registry Regeneration](https://banes-lab.com/records/algo/registry-regeneration.md)
- [Distillation Metrics](https://banes-lab.com/records/algo/distillation-metrics.md)
- [The derivation loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)
- [Behavioral Signature Extraction](https://banes-lab.com/records/algo/behavioral-signature-extraction.md)
- [Anti-Pattern Priority Matrix](https://banes-lab.com/records/algo/anti-pattern-priority-matrix.md)
- [Migration Ordering](https://banes-lab.com/records/algo/migration-ordering.md)
- [Backup-Verified Migration](https://banes-lab.com/records/algo/backup-verified-migration.md)
- [Anti-Pattern Elimination Verification](https://banes-lab.com/records/algo/anti-pattern-elimination-verification.md)
- [Pattern Distillation History](https://banes-lab.com/records/algo/pattern-distillation-history.md)
- [Completion Truthfulness](https://banes-lab.com/records/algo/pattern-distillation-completion-truthfulness.md)
- [state_transaction](https://banes-lab.com/records/force/state-transaction.md)
