tools.feature_atlas.generate_interaction_prompts module

Step 4: Generate interaction analysis prompts for all feature pairs.

Creates structured prompts for each directed pair (A, B) that include: - Feature A & B descriptions + evidence - Known code interactions between them - The strict JSON output template

Outputs outputs/interaction_prompts.jsonl and loads InteractionPrompt nodes into FalkorDB.

Usage:

python -m tools.feature_atlas.generate_interaction_prompts

# fire – ALL DIRECTED NERVE MAPPINGS

tools.feature_atlas.generate_interaction_prompts.generate_prompt(source_feat, target_feat, interactions)[source]

Assemble the full LLM analysis prompt for one directed feature pair.

Combines per-feature summaries from _feature_summary() and the code-evidence block from _interaction_evidence() with a fixed instruction header, scoring guide, and the strict JSON output schema (_ANALYSIS_TEMPLATE) into a single prompt string. The prompt directs the downstream model to analyze how feature A affects feature B across direct, indirect, memory, NCM/persona, and routing dimensions and to emit only template-conforming JSON. Pure string assembly; this function does not itself call any LLM, Redis, or knowledge graph (the prompt is consumed later by the interaction-analysis swarm).

Called by generate_all_prompts(), once for every ordered pair of distinct features.

Parameters:
  • source_feat (dict[str, Any]) – The feature-registry record for feature A (the source).

  • target_feat (dict[str, Any]) – The feature-registry record for feature B (the target).

  • interactions (list[dict[str, Any]]) – All detected code-interaction records, used to build the evidence section.

Return type:

str

Returns:

The fully rendered prompt string for this directed pair.

tools.feature_atlas.generate_interaction_prompts.generate_all_prompts(features, interactions)[source]

Generate prompts for all directed feature pairs.

Returns list of {source_id, target_id, prompt, evidence_count}.

Return type:

list[dict[str, Any]]

Parameters:
async tools.feature_atlas.generate_interaction_prompts.load_prompts_to_falkor(prompts)[source]

Persist the generated prompts as InteractionPrompt nodes in FalkorDB.

Opens the Feature Atlas graph via atlas_connection.get_atlas_graph (which also returns the underlying Redis client) and, for each prompt, calls merge_interaction_prompt to upsert a node keyed by source and target id with status="pending" and the prompt text truncated to 10,000 characters. Per-prompt failures are caught and logged via the module logger so one bad write does not abort the batch, and the Redis client is closed with aclose before returning. Side effects: writes to the FalkorDB knowledge graph and opens/closes a Redis connection.

Called by async_main() after the prompts have been generated and written to disk.

Parameters:

prompts (list[dict[str, Any]]) – The prompt records to load, each containing source_id, target_id, and prompt.

Return type:

int

Returns:

The number of prompts successfully merged into the graph.

async tools.feature_atlas.generate_interaction_prompts.async_main()[source]

Run atlas step 4: build every pair prompt, persist, and report.

The async driver that ties the module together: it loads the feature registry and code interactions via _load_features() and _load_interactions(), generates a prompt for every directed pair with generate_all_prompts(), sorts them by evidence count (most-grounded first), writes them as JSONL to outputs/interaction_prompts.jsonl (the module-level _OUTPUT_PATH), loads them into FalkorDB via load_prompts_to_falkor(), and prints a summary of totals and elapsed time. Side effects: reads input JSON files, creates the output directory and writes the JSONL file, writes to the knowledge graph, logs, and prints to stdout.

Called by main() (via asyncio.run) and dispatched as a subprocess step by run_atlas.py, which imports this coroutine as run.

Return type:

None

tools.feature_atlas.generate_interaction_prompts.main()[source]

Synchronous wrapper that runs the step-4 prompt generation.

Configures basic logging and drives the async pipeline by calling asyncio.run(async_main()). This is the plain command-line entry point (python -m tools.feature_atlas.generate_interaction_prompts); all real work, including the filesystem and FalkorDB side effects, happens inside async_main().

Called by the module’s __main__ guard at the bottom of this file.

Return type:

None