tools.feature_atlas.run_interaction_analysis_swarm module
Step 5: Gemini Flash swarm for interaction analysis.
Loads interaction prompts (already sorted by code evidence count), selects the top N (default 50), and dispatches parallel Gemini Flash agents to analyze each interaction. Handles JSON parse retries with backoff and validates/clamps the returned scores.
Outputs outputs/interaction_analyses.jsonl.
- Usage:
python -m tools.feature_atlas.run_interaction_analysis_swarm
# skull fire infinity – THE SWARM READS THE BODY
- async tools.feature_atlas.run_interaction_analysis_swarm.run_analysis(config=None)[source]
Select the top feature pairs and run the Gemini Flash analysis swarm.
Orchestrates the whole step: it loads the prompt records, picks which pairs to analyze, fans out one Gemini agent per pair under a concurrency cap, and collects the successful results. Pair selection prefers candidates whose code evidence count meets the configured
min_evidence_threshold; if fewer thantop_n_pairsqualify, it pads up totop_n_pairswith the highest-evidence remaining pairs so the swarm always runs at full requested width when prompts are available.Loads the config via
_load_config()when none is passed, reads prompts via_load_prompts(), builds anasyncio.Semaphorefrom theswarm.max_concurrencysetting, and dispatches_analyze_pair()for each selected pair withasyncio.gather()(return_exceptions=True). Each pair’s LLM call goes through the local proxy used bytools.feature_atlas.extract_features_swarm._gemini_generate(); dict results are kept and exceptions are logged and counted as failures via the modulelogger. No Redis, FalkorDB, KG, event bus, or output-file writes happen here – persistence is left toasync_main().Called by
async_main()as the core of the command-line run.- Parameters:
config (
dict[str,Any] |None) – The run configuration; loaded fromconfig.yamlvia_load_config()whenNone. Itsanalysisblock suppliestop_n_pairsandmin_evidence_thresholdand itsswarmblock suppliesmax_concurrency.- Returns:
The successfully completed analysis records (failed pairs are dropped, not represented).
- Return type:
- async tools.feature_atlas.run_interaction_analysis_swarm.async_main()[source]
Run the analysis swarm end to end, persist results, and print a summary.
The asynchronous entry point for this step: it loads the configuration, runs the swarm, writes the completed analyses to disk, and prints a human-readable summary (counts, average and maximum risk and synergy scores, and the top three risk and synergy pairs) plus the elapsed time. This is what turns the in-memory analysis list into the durable
outputs/interaction_analyses.jsonlartifact that later Atlas steps import.Loads config via
_load_config(), delegates the actual analysis torun_analysis()(which drives the Gemini Flash agents through the local proxy), then creates the output directory and writes each record as one JSON line to the module-level_OUTPUT_PATH. The only side effects are that filesystem write and stdout printing; no Redis, FalkorDB, KG, or event bus is touched here.Called by
main()viaasyncio.run();mainin turn runs under this module’s__main__guard.- Return type:
- Returns:
None
- tools.feature_atlas.run_interaction_analysis_swarm.main()[source]
Configure logging and run the analysis swarm from a synchronous context.
The synchronous command-line entry point invoked when this module is run as
python -m tools.feature_atlas.run_interaction_analysis_swarm. It installs a basic INFO-level logging configuration (timestamped, level-tagged lines) so the swarm’s progress and warnings are visible, then drives the async pipeline by handingasync_main()toasyncio.run().Side effects are limited to the global logging configuration and whatever
async_main()does (the JSONL write and stdout summary); no Redis, FalkorDB, KG, or event bus is touched here.Called only from this module’s
if __name__ == "__main__":guard.- Return type:
- Returns:
None