ml_switcheroo.semantics.merging¶
Merging Logic for Semantic Knowledge Base.
This module handles the aggregation of disparate knowledge sources (Specs, Snapshots) into the central SemanticsManager. It resolves conflicts based on Tier Precedence and merging framework-specific configurations.
Handles: - Merging Specification Tiers (Math, Neural, Extras). - Merging Snapshot Overlays (Framework mappings). - Conflict resolution and prioritization (Warning vs Silencing). - Merging Framework Traits and Import Maps. - Merging Patterns.
Attributes¶
Functions¶
Maps a loading priority integer to a Semantic Tier. |
|
|
Merges new framework configurations (from __frameworks__ block) into the master. |
|
Append new patterns to the master list, avoiding duplicates by name. |
|
Merges content from a Specification file (hub) into the manager state. |
|
Merges a mapping overlay file (snapshot) into the main data. |
Module Contents¶
- ml_switcheroo.semantics.merging.TIER_PRECEDENCE¶
- ml_switcheroo.semantics.merging.infer_tier_from_priority(priority: int) ml_switcheroo.enums.SemanticTier[source]¶
Maps a loading priority integer to a Semantic Tier.
- Parameters:
priority (int) – Loading order (10=Math, 20=Neural, etc).
- Returns:
The inferred tier enum.
- Return type:
- ml_switcheroo.semantics.merging.merge_frameworks(master_configs: Dict[str, Dict], new_configs: Dict[str, Any]) None[source]¶
Merges new framework configurations (from __frameworks__ block) into the master. Updates in-place.
- Parameters:
master_configs – The central framework definitions dictionary.
new_configs – Dictionary of framework traits to merge.
- ml_switcheroo.semantics.merging.merge_patterns(master_patterns: List[ml_switcheroo.semantics.schema.PatternDef], new_patterns: List[Any]) None[source]¶
Append new patterns to the master list, avoiding duplicates by name.
- ml_switcheroo.semantics.merging.merge_tier_data(data: Dict[str, Dict], key_origins: Dict[str, str], framework_configs: Dict[str, Dict], new_content: Dict[str, Any], tier: ml_switcheroo.enums.SemanticTier, patterns: List[ml_switcheroo.semantics.schema.PatternDef] | None = None, is_internal: bool = False) None[source]¶
Merges content from a Specification file (hub) into the manager state.
Handles precedence logic: Neural definitions overwrite Array definitions silently for upgrades. Duplicate definitions at the same tier level with conflicting signatures trigger warnings only if signatures are ambiguous (same length, different names). Otherwise, prefers the richer signature (Superset/Length).
- Parameters:
data – Master dictionary of operations.
key_origins – Dict tracking where an op was defined (Math vs Neural).
framework_configs – Master dictionary of framework traits.
new_content – The JSON content being loaded.
tier – The Semantic Tier of the file being loaded.
patterns – Master list of fusion patterns (optional).
is_internal – If True, marks entries as internal defaults which can be silently overwritten.
- ml_switcheroo.semantics.merging.merge_overlay_data(data: Dict[str, Dict], key_origins: Dict[str, str], framework_configs: Dict[str, Dict], test_templates: Dict[str, Dict], content: Dict[str, Any], filename: str) None[source]¶
Merges a mapping overlay file (snapshot) into the main data.
Snapshots contain framework-specific implementation overlays (“Spokes”) that attach to the Abstract Operations (“Hub”).
- Parameters:
data – Master dictionary of operations.
key_origins – Dict tracking tier origins.
framework_configs – Master dictionary of framework traits.
test_templates – Master dictionary of testing templates.
content – The JSON content of the snapshot file.
filename – Filename for metadata inference if needed.