# Introducing IMPACT: Why Does This PR Actually Affect?

Did you ever look at a one-line code change and thought, *okay, but what else could this break?*

That question led me to build *IMPACT*, a Python PR review tool for [Graph Hacks by WeMakeDevs and FalkorDB](https://www.wemakedevs.org/hackathons/falkordb). 🚀

A diff shows what changed. It doesn't always show the functions that call that code, or which tests might be affected. IMPACT maps these relations in *FalkorDB*, then follows them to produce a graph you can inspect.

## Testing the idea

I started with a small checkout repo instead of a huge project. It has pricing, cart, checkout, receipts, and a few tests—enough for one change to travel through different files.

Then I broke the coupon calculation on purpose:

```python
# Before
discount_cents = min(subtotal_cents, coupon_cents)

# After
discount_cents = coupon_cents
```

A $30 coupon on a $20 cart now gives a negative total. The receipt test expects `0` but gets `-1000`. The checkout test raises an error because it refuses to charge a negative amount. The normal-coupon test still passes.

I wanted IMPACT to find those tests from the code relationships, and to show me *why* it picked them.

## Following the calls

IMPACT stores files and functions in FalkorDB, with a `CALLS` connection whenever one function calls another. In the demo, checkout eventually reaches the changed `apply_coupon` function through cart and pricing code.

When `apply_coupon` changes, IMPACT walks those connections backwards. It finds seven reachable callers, including three tests. One of the test paths is four calls long—something I wouldn't get from looking at the diff alone.

This is the Cypher query behind it:

```cypher
MATCH p = (caller:Function)-[:CALLS*1..4]->(changed:Function {id: $id})
RETURN caller.id, caller.is_test, length(p), [n IN nodes(p) | n.id]
```

The HTML report uses those same paths. Click a test, and you can follow its connection back to the changed code.

Getting there took a few tries. I got stuck connecting to FalkorDB at first, and later had to fix a shortest-path query to use the syntax FalkorDB accepts. The `doctor` command now checks the connection and graph queries before I run a review.

## Who should review the change?

I added another question to the demo: *who knows this part of the code, and why was it written this way?*

For that, I made a small, fictional company dataset. It links a code file to its owner, her team, and three source records: a decision about coupon limits, a support ticket about negative charges, and a team chat. IMPACT puts those links in FalkorDB alongside the call graph. Ask it about `apply_coupon`, and it suggests Maya Chen as a reviewer and points to the records behind that suggestion.

You can see the same context in the HTML report next to the test paths. It's a demo of the idea, with synthetic people and documents; it doesn't connect to a real company's Slack or ticket system yet.

## The AI part

At first, I thought an AI agent for this hackathon might have to be a chatbot. For IMPACT, the useful action turned out to be choosing what to inspect and which test to prioritize.

The AI step is optional. The model calls a FalkorDB tool, looks at the affected code, and picks a test to inspect first. IMPACT checks that the choice is actually connected to the change. Then the test runner supplies the real pass, fail, or error result.

If I leave out the AI API key, the graph analysis and test selection still work.

## What I'd improve next

IMPACT can also take a public GitHub PR URL and generate a Markdown review. It has an option to post that review as a PR comment.

The parser is still static Python analysis. Dynamic calls and runtime imports may be missed, so a call path means *possible impact*. I want to try it on more repositories and see where it needs to improve.

I'm entering with IMPACT in *Track 01: Agents That Act on Connected Data* and *Track 03: Company Brain*. The first follows the code graph to help review a change; the second adds the people and decisions connected to that code.

If you review Python PRs, would seeing both the path to a suggested test and the reason behind a past decision help you? 🤔

🎥 Demo: [https://cap.so/s/ayymw5gzz6qw9ds](https://cap.so/s/ayymw5gzz6qw9ds)
💻 Source code: [https://github.com/Omar8345/IMPACT](https://github.com/Omar8345/IMPACT)
