# 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). 🚀

![IMPACT traces a changed function through callers to the tests it reaches](https://raw.githubusercontent.com/Omar8345/IMPACT/master/assets/impact-banner.png align="center")

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.

![A developer discovering another bug](https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExMnpoZHg5ZWRhcWMwcHAydjR4djByNjg3d3hkaWFvZGo1ZWtjMHdrdSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/tGED68BogsXXcocK8l/giphy.webp align="center")

*One line later...*

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

![IMPACT runs the graph-selected tests and records their real results](https://omar8345.github.io/IMPACT/blog-assets/impact-selected-tests.gif align="center")

*The graph selects the relevant tests; the test runner records what actually happened.*

## 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.

![Mind blown reaction](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExbmFlcXB6OTl0eGNicW44aHB1cmo3YW51YTVtNnIycmg2bm9vOTNrdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/xThtakjeewjf7J3T4k/giphy.webp align="center")

*Me after seeing how far one line can travel.*

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.

![Selecting a test in IMPACT highlights its call path to the changed function](https://omar8345.github.io/IMPACT/blog-assets/impact-call-path.gif align="center")

*Selecting a test reveals the exact path connecting it to the changed function.*

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.

## Taking it to a real PR

The broken checkout demo was useful, but I also wanted to see what IMPACT would say about a fix. So I put the checkout code in a separate [sample repo](https://github.com/Omar8345/impact-checkout-demo) and opened [a PR that caps oversized coupons](https://github.com/Omar8345/impact-checkout-demo/pull/1).

IMPACT picked three tests from the graph and ran them on both commits. Two failed on the base and passed on the PR; the normal-coupon test passed on both. That tells me more than a list of tests to run: I can see whether the change actually fixed the cases it was meant to fix. [Here's the report with the paths and results](https://omar8345.github.io/IMPACT/checkout-pr/).

![IMPACT report comparing the base commit with the pull request](https://omar8345.github.io/IMPACT/blog-assets/impact-report.png align="center")

*The same graph-selected tests on both commits: two now pass, with no new failures.*

I then put the same review into [GitHub Actions](https://github.com/Omar8345/impact-checkout-demo/blob/main/.github/workflows/impact-review.yml). A Python PR now starts a temporary FalkorDB instance, generates the graph and report, compares the tests, and [updates a comment on the PR](https://github.com/Omar8345/impact-checkout-demo/pull/1#issuecomment-6247534059). I tested that with an [automatic run](https://github.com/Omar8345/impact-checkout-demo/actions/runs/39111057836). The workflow doesn't need an AI key; the graph and test results are enough for this part.

I also tried IMPACT on [a larger HTTPie PR](https://omar8345.github.io/IMPACT/httpie-pr-1327/). It found 18 test targets that expanded to 43 cases: 34 passed, nine remote-service cases skipped, and none failed. I like the small checkout example for explaining the idea, but this one showed me what the report looks like with a lot more code.

## Three cases, measured separately

I then ran a controlled benchmark with 15 independent mutations across a 24-test fixture. IMPACT selected every failure-revealing test instance: 29 out of 29, while avoiding 69.2% of the executions a full suite would require. That is controlled ground truth, not a claim about every repository.

The two public PRs are useful case studies, but they answer a different question. Requests #6644 had one graph-selected test, and it passed; a reliable full-suite comparison was not completed. HTTPie #1327 selected 43 of 1,012 collected cases, a 95.8% reduction: 34 passed and 9 remote-service cases were skipped. Those are selected-test outcomes, not failure recall, and I am not claiming 100% real-world accuracy. [The three-case evidence page is here](https://omar8345.github.io/IMPACT/evaluation/).

The hosted analyzer is now live at [impact-analyzer-cy2a.onrender.com](https://impact-analyzer-cy2a.onrender.com). Paste a public GitHub PR URL to get a shareable graph-backed report; hosted analysis does not run repository tests.

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 keep trying it on different repositories and improve the coverage where it falls short.

I'm entering 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://youtu.be/mbj6c4p4VNk  
💻 Source code: https://github.com/Omar8345/IMPACT
