ml_switcheroo.cli.handlers.discovery¶
Discovery & Standards Command Handlers.
This module implements the logic for populating the Semantic Knowledge Base via Automated Discovery and Specification Imports.
It handles: 1. Ingestion: Importing external standards (ONNX, Array API) and Internal Golden Sets (Hub). 2. Scaffolding: Generating skeleton mappings. 3. Discovery: Identifying Neural Layers via Consensus and linking them to the Semantic Hub.
Functions¶
|
Handles the 'scaffold' command. |
|
Handles the 'import-spec' command. |
|
Handles 'sync-standards' command. |
Module Contents¶
- ml_switcheroo.cli.handlers.discovery.handle_scaffold(frameworks: list[str], out_dir: pathlib.Path) int¶
Handles the ‘scaffold’ command.
Iterates through provided frameworks.
Uses FrameworkAdapter.discovery_heuristics regexes to fuzzy match framework APIs against known specs or structural conventions.
Populates semantic specs (Hub) and framework mappings (Spokes/Snapshots).
- Parameters:
frameworks (list[str]) – List of framework package names to scaffold (e.g., [‘torch’, ‘jax’]).
out_dir (Path) – The root directory for generating the knowledge base. Defaults to the package source if None.
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.discovery.handle_import_spec(target: pathlib.Path) int¶
Handles the ‘import-spec’ command.
Parses upstream standards documentation or stubs and merges the definitions into the local semantics Hub.
- Parameters:
target (Path) – Code resource to import (‘internal’, .md file, or directory).
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.discovery.handle_sync_standards(categories: List[str], frameworks: List[str] | None, dry_run: bool) int¶
Handles ‘sync-standards’ command.
Invokes the Consensus Engine to automatically discover new Abstract Operations by finding commonalities across multiple framework API surfaces. Writes the results to k_discovered.json (The Unofficial/Discovered Standard).
- Parameters:
categories (List[str]) – List of category strings (layer, loss, etc.) to scan.
frameworks (Optional[List[str]]) – List of framework keys to scan. Defaults to installed/registered frameworks.
dry_run (bool) – If True, prints results without saving.
- Returns:
Exit code.
- Return type:
int