tools.feature_atlas.query_atlas module
Step 7: Interactive CLI for querying the Feature Interaction Atlas.
Provides commands for inspecting features, top risks/synergies, feature neighborhoods, and generating the Sarah demo report.
Style matches memory_search.py – ANSI terminal colors, clean
formatting, designed for SSH access.
- Usage:
python -m tools.feature_atlas.query_atlas stats python -m tools.feature_atlas.query_atlas list-features python -m tools.feature_atlas.query_atlas top-risks python -m tools.feature_atlas.query_atlas top-synergies python -m tools.feature_atlas.query_atlas feature-neighborhood CoreMemory python -m tools.feature_atlas.query_atlas explain-pair NCMStateEngine PersonaPrefillLayer python -m tools.feature_atlas.query_atlas missing-evidence python -m tools.feature_atlas.query_atlas sarah-demo python -m tools.feature_atlas.query_atlas –interactive
# fire skull spider – THE WITCH READS HER OWN X-RAY
- class tools.feature_atlas.query_atlas.C[source]
Bases:
objectANSI color/style escape codes for the Atlas CLI’s terminal output.
A namespace of raw SGR escape sequences (
RESET,BOLD,DIMand the color constants) plus smallstaticmethod()helpers such asheader()that wrap text in a style and reset it. Mirrors the palette inmemory_search.pyand is used by thecmd_*query functions andinteractive_modeto colorize results when this module runs as a CLI.- RESET = '\x1b[0m'
- BOLD = '\x1b[1m'
- DIM = '\x1b[2m'
- PURPLE = '\x1b[35m'
- CYAN = '\x1b[36m'
- GREEN = '\x1b[32m'
- YELLOW = '\x1b[33m'
- RED = '\x1b[31m'
- MAGENTA = '\x1b[95m'
- WHITE = '\x1b[97m'
- static header(text)[source]
Wrap
textin bold-purple ANSI codes for a section header.Prefixes the string with
BOLD``+``PURPLEand appendsRESETso the styling does not leak into subsequent output. Called by everycmd_*query function andinteractive_modein this module to render banner-style section titles.
- static entity(text)[source]
Wrap
textin bold-cyan ANSI codes to highlight an entity name.Used to make feature ids and interaction endpoints stand out in terminal output. Called by
cmd_list_features,cmd_top_risks,cmd_top_synergies,cmd_feature_neighborhood, andcmd_explain_pairto style feature/interaction identifiers.
- static score_color(score)[source]
Pick an ANSI color for a 0-1 score using fixed risk thresholds.
Maps scores to a traffic-light scheme: red for
>= 0.7(high), yellow for>= 0.4(medium), and green otherwise (low). Called byC.barto color the filled portion of its meter; no other callers were found in the repository.
- static bar(score, width=20)[source]
Render a colored fixed-width text meter for a 0-1 score.
Fills
int(score * width)cells with#and pads the remainder with dimmed.characters, coloring the filled run viaC.score_color. Used throughout this module to visualize risk, synergy, weirdness, and confidence values incmd_stats,cmd_list_features,cmd_top_risks,cmd_top_synergies,cmd_feature_neighborhood, andcmd_explain_pair.
- async tools.feature_atlas.query_atlas.cmd_stats(graph)[source]
Print summary counts and average scores for the atlas graph.
Renders a terminal overview of the Feature Interaction Atlas: node and edge tallies (features,
CODE_INTERACTS_WITHedges, interaction prompts, completed analyses, pending prompts), a per-category feature breakdown, and average risk/synergy/weirdness/confidence scores across allInteractionAnalysisnodes. Each count comes from a read-only Cypher call tograph.ro_queryagainst the FalkorDB atlas namespace (stargazer_feature_interaction_atlas); per-query failures are caught and printed in red rather than aborting the whole summary. Output goes to stdout viaprintusing the ANSI helpersC.headerandC.bar. Called byinteractive_mode(thestatsREPL command) and byasync_mainfor thestatssubcommand.
- async tools.feature_atlas.query_atlas.cmd_list_features(graph)[source]
Print every
Featurenode grouped by category.Lists all features in the atlas, sorted by category then id, emitting a bold category header whenever the category changes and one line per feature with a confidence meter and human-readable name. The feature rows come from a single read-only
graph.ro_queryagainst the FalkorDB atlas; output is written to stdout viaprintusingC.header,C.entity, andC.bar. When the graph holds no features it prints a dim “No features found” notice and returns early. Called byinteractive_mode(thefeatures/lsREPL command) and byasync_mainfor thelist-featuressubcommand.
- async tools.feature_atlas.query_atlas.cmd_top_risks(graph, limit=10)[source]
Print the highest-risk analyzed interactions, worst first.
Queries
InteractionAnalysisnodes ordered byrisk_scoredescending and prints up tolimitof them, each as a source-to-target heading followed by risk, synergy, and weirdness meters and a word-wrapped summary. Data comes from a single read-onlygraph.ro_queryagainst the FalkorDB atlas; output is written to stdout viaprintusingC.header,C.entity,C.bar, andtextwrap.fill. When no analyses exist it prints a dim notice and returns early. Called byinteractive_mode(therisksREPL command, which parses an optional numeric argument) and byasync_mainfor thetop-riskssubcommand (which passesargs.limit).
- async tools.feature_atlas.query_atlas.cmd_top_synergies(graph, limit=10)[source]
Print the highest-synergy analyzed interactions, best first.
The synergy-ranked counterpart to
cmd_top_risks: queriesInteractionAnalysisnodes ordered bysynergy_scoredescending and prints up tolimitof them, each as a source-to-target heading followed by synergy, risk, and weirdness meters and a word-wrapped summary. Data comes from a single read-onlygraph.ro_queryagainst the FalkorDB atlas; output is written to stdout viaprintusingC.header,C.entity,C.bar, andtextwrap.fill. When no analyses exist it prints a dim notice and returns early. Called byinteractive_mode(thesynergiesREPL command, with an optional numeric argument) and byasync_mainfor thetop-synergiessubcommand (which passesargs.limit).
- async tools.feature_atlas.query_atlas.cmd_feature_neighborhood(graph, feature_id)[source]
Print a full profile of one feature and everything touching it.
Gives a 360-degree view of a single
Feature: its metadata (name, category, confidence meter, description, and first ten source files), then its outgoing and incomingCODE_INTERACTS_WITHedges with mechanism, confidence, and a truncated evidence snippet, and finally up to tenInteractionAnalysisrows that name it as source or target. This issues four separate parameterized read-onlygraph.ro_querycalls against the FalkorDB atlas (all keyed onfeature_idvia$id), and decodes the JSONfilesblob withjson.loads. Output goes to stdout viaprintusingC.header,C.entity,C.bar, andtextwrap.fill; a missing feature prints a red notice and returns early. Called byinteractive_mode(thehood/neighborhoodREPL command) and byasync_mainfor thefeature-neighborhoodsubcommand.
- async tools.feature_atlas.query_atlas.cmd_explain_pair(graph, source_id, target_id)[source]
Print the complete stored analysis for one ordered feature pair.
Looks up the single
InteractionAnalysismatchingsource_id->target_idand renders every recorded field: the narrative sections (summary, direct and indirect interaction, shared state, memory, NCM, routing, and prompt-context effects), the JSON list fields (failure modes, security risks, recommended tests and constraints, source refs), and the four numeric scores with meters. The data comes from one parameterized read-onlygraph.ro_queryagainst the FalkorDB atlas (bound via$sand$t); list fields are parsed withjson.loadswhen stored as strings. Output is written to stdout viaprintusingC.header,C.bar, andtextwrap.fill; a missing pair prints a dim notice and returns early. Called byinteractive_mode(thepair/explainREPL command) and byasync_mainfor theexplain-pairsubcommand.
- async tools.feature_atlas.query_atlas.cmd_missing_evidence(graph)[source]
Print features whose confidence is below 0.5, weakest first.
Surfaces under-evidenced features so a human can prioritize follow-up: selects every
Featurewithconfidence < 0.5, ordered ascending, and prints each id in red alongside its confidence, its source-file count (derived byjson.loadson the storedfilesblob), and its human name. Data comes from one read-onlygraph.ro_queryagainst the FalkorDB atlas; output is written to stdout viaprintusingC.header. When no feature falls below the threshold it prints a green “all features have confidence >= 0.5” message and returns early. Called byinteractive_mode(themissingREPL command) and byasync_mainfor themissing-evidencesubcommand.
- async tools.feature_atlas.query_atlas.cmd_sarah_demo(graph)[source]
Build and print the curated “Sarah” demo report inline.
Lazily imports
generate_demo_reportfromtools.feature_atlas.export_sarah_demo(kept inside the function so the rest of the CLI works even if that module is unavailable), awaits it against the live atlas graph to assemble the formatted demo string, and prints the result to stdout. The report itself runs further read-only queries against the FalkorDB atlas insidegenerate_demo_report. Called byinteractive_mode(thedemo/sarahREPL command) and byasync_mainfor thesarah-demosubcommand.
- tools.feature_atlas.query_atlas.print_banner()[source]
Print the boxed ASCII banner for the atlas query CLI.
Writes a purple/bold framed title block (“FEATURE INTERACTION ATLAS” / “Stargazer Bodygraph”) to stdout via
print. Purely cosmetic with no graph or I/O side effects beyond the terminal write. Called byinteractive_modeonce at REPL startup and byasync_mainbefore each non-interactive subcommand so single-shot invocations are also branded. (Note:memory_search.pydefines its own same-named banner; they are independent.)- Return type:
- Returns:
None. The banner is written to stdout.
- async tools.feature_atlas.query_atlas.interactive_mode(graph)[source]
Run the blocking REPL loop that dispatches atlas query commands.
Prints the banner and a command cheat-sheet, then loops reading lines from stdin via the builtin
input(so it blocks the event loop on terminal I/O), splitting each into a command plus arguments and awaiting the matchingcmd_*coroutine:stats,features/ls,risks/synergies(with an optional numeric limit),hood,pair,missing, anddemo.quit/exit/qand EOF or Ctrl-C break the loop; unknown commands and any exception raised by a handler are reported in red and the loop continues. All work flows through the sharedgraphhandle into the FalkorDB atlas. Called byasync_mainwhen the--interactiveflag is set or the command defaults tointeractive.
- async tools.feature_atlas.query_atlas.async_main()[source]
Parse CLI arguments, open the atlas graph, and dispatch one command.
The asynchronous core of the CLI: it builds the
argparseparser (positional command plus extraargs,--limit/-n, and--interactive/-i), opens a connection to the FalkorDB atlas viaget_atlas_graph(lazily imported fromtools.feature_atlas.atlas_connection), then routes to the appropriate handler:interactive_modefor the interactive flag/command, or one of thecmd_*coroutines (preceded byprint_banner) for a single-shot subcommand.feature-neighborhoodandexplain-pairvalidate that their positional ids are present and otherwise print a usage hint. The Redis connection returned alongside the graph is always closed viarc.aclose()in afinallyblock. Called bymainthroughasyncio.run(async_main()).- Return type:
- Returns:
None.
- tools.feature_atlas.query_atlas.main()[source]
Configure logging and run the async CLI to completion.
The synchronous process entry point: sets up basic
WARNING-level logging and then drives the whole CLI viaasyncio.run(async_main()), which parses arguments, opens the atlas graph, and dispatches the chosen command. Invoked from this module’s__main__guard (e.g.python -m tools.feature_atlas.query_atlas ...); no other internal caller exists.- Return type:
- Returns:
None.