Skip to content

Context Causality

Mantra v0.11.0 introduces Context Causality. Through AI-powered analysis, it automatically establishes logical connections between "reference files" and "code changes," revealing why the AI wrote the code the way it did.

Why Do We Need Causality Analysis?

During complex AI sessions, the AI often reads multiple files (such as documentation, base classes, or utility functions) as context before outputting code. Traditional tools only show that these files were read, but they can't tell you exactly which part of the content influenced the final code generation.

Causality Analysis solves this problem:

  • Magnetic Association: Directly associates high-confidence reference snippets next to the corresponding code diff blocks.
  • Highlight Tracking: Hovering over a code change automatically illuminates the source material it referenced.
  • Context Aggregation: Aggregates and displays all mentioned files in the message details.

Core Features

1. Automatic Mentioned Files Extraction

The parser can now automatically extract file paths from tool calls like read_file and display a list of all files involved in the message header.

2. Context Promotion (Reference Blocks)

The execution results of tools (such as the content of read files) are no longer just rigid text; they are promoted to "Reference Blocks" with semantic meaning.

3. AI Causality Mapping

Through background AI tasks, the system analyzes the causal logic between Reference Block and CodeDiff:

  • High Confidence (> 0.8): Treated as a direct cause, displayed with strong visual association in the UI.
  • Low Confidence (< 0.3): Treated as background knowledge, stored away in the sidebar.

Interactive Experience

  • Hover Preview: In the narrative panel, hovering over a segment of code changes automatically connects it to the referenced document snippet via lines or highlights.
  • Context Panel: Clicking the "Context" icon next to a message lets you view the complete data dependency graph for that message.

Next Steps