tools.feature_atlas.detect_code_interactions module
Step 3: Detect code-grounded interactions between features.
Static analysis only: analyzes imports, shared files, shared data stores, and shared env vars between feature pairs using the repo symbol index.
Outputs outputs/code_interactions.json and loads CODE_INTERACTS_WITH
edges into FalkorDB.
- Usage:
python -m tools.feature_atlas.detect_code_interactions
# fire skull – FINDING THE NERVES BETWEEN ORGANS
- tools.feature_atlas.detect_code_interactions.detect_static_interactions(features, symbols)[source]
Detect code-grounded interactions between feature pairs via static analysis.
The first and only phase of the interaction detector: it cross-references the feature registry against the repo symbol index to surface edges that are evidenced purely by code structure, without any LLM or runtime inspection. For every ordered pair of features it emits an interaction when they share a file (mechanism
shared_memory_layer), when one imports a file owned by the other (mechanismdirect_import), when they share a declared data store (mechanismshared_falkordb_graph,shared_redis_db, orshared_vector_storedepending on the store name), or when they reference the same environment variable (mechanismshared_env_var). Each edge carries a confidence score and human-readable evidence string. The results are deduplicated so that only the highest-confidence interaction survives per source, target, and mechanism triple, and the surviving and pre-dedup counts are logged.Internally it builds its lookup structures by calling
_build_file_to_features()and_build_import_graph(), and resolves imports back to owning files via_module_to_filepath(). It is a pure in-memory computation with no Redis, knowledge-graph, LLM, HTTP, or filesystem side effects of its own.Invoked by
async_main()in this module, which then persists the returned edges to FalkorDB; no other internal callers were found.- Parameters:
- Return type:
- Returns:
A deduplicated list of interaction edge dictionaries, each describing a source feature, target feature, mechanism, confidence, supporting file and symbol references, an evidence string, and a direction label.
- async tools.feature_atlas.detect_code_interactions.load_interactions_to_falkor(interactions)[source]
Persist detected interactions as CODE_INTERACTS_WITH edges in FalkorDB.
Opens a connection to the atlas graph via
tools.feature_atlas.atlas_connection.get_atlas_graph()and, for each interaction, upserts the correspondingCODE_INTERACTS_WITHrelationship by callingtools.feature_atlas.atlas_connection.merge_code_interaction(). Individual failures are caught and logged so one bad edge does not abort the whole load, and the underlying Redis client is closed before returning. This mutates the FalkorDBstargazer_feature_interaction_atlasgraph and holds a network connection for the duration of the load.Invoked by
async_main()in this module; no other internal callers were found.
- async tools.feature_atlas.detect_code_interactions.async_main()[source]
Run the full code-interaction detection step end to end.
Orchestrates step 3 of the Feature Atlas pipeline: it loads the feature registry and symbol index from disk via
_load_features()and_load_symbols(), runsdetect_static_interactions()to compute the edges, writes them tooutputs/code_interactions.json, then persists them to FalkorDB throughload_interactions_to_falkor(). It finishes by printing a human-readable summary that breaks the edges down by mechanism and reports timing and the output path. Side effects therefore span the filesystem (the output JSON) and the FalkorDB atlas graph (via the load helper); it also logs progress at INFO level.Invoked by
main()in this module’s__main__guard and imported asasync_mainbytools.feature_atlas.run_atlas.step_detect_interactions()(thedetect-interactionsstep of the atlas runner); no other internal callers were found.- Return type:
- Returns:
None.
- tools.feature_atlas.detect_code_interactions.main()[source]
Synchronous entry point for the code-interaction detection step.
Configures root logging at INFO level and drives the async pipeline by calling
asyncio.run(async_main()), which loads the registry and symbol index, computes the interactions, writesoutputs/code_interactions.json, and loads the edges into FalkorDB. All Redis, FalkorDB, and filesystem side effects happen transitively insideasync_main(); this wrapper only sets up logging and starts the event loop.Invoked from the module’s
if __name__ == "__main__"guard viapython -m tools.feature_atlas.detect_code_interactions; no other internal callers were found.- Return type:
- Returns:
None.