Intelligent Chargeback Agent · CIRI

What the tests protect

There are 1235, and what sets them apart is not the count: 132 of them do not verify code. They verify the deliverable — that the n8n workflow is wired up, that the README's numbers are the real ones, that the reports that travel open without internet. Things that break no import and break the delivery.

1235test cases

1082 unit · 119 integration · 34 E2E

92.4%statement coverage

the CI's number, on a clean checkout. It fails below 85

47files

one per piece; none mixes domains

3steps on every push

lint, tests with a coverage floor, n8n wiring

Three layers, three different things

Each layer tests something the previous one cannot. Keeping them apart matters because they cost different amounts: the top ones run in a couple of minutes and on every push; the bottom one calls the model and the deployed API, so it is run by hand.

1082unit

The logic, in isolationon every push

Guardrails, SLA evaluation, parsing what the model returns, building the vector-store query. No network and no model; the disk is only read —the workflow, the docs, the reports that travel— and the only thing written is SQLite in memory. They test decisions, not integrations.

119integration

The pieces togetheron every push

The whole pipeline with the model mocked, the routes with their real dependencies, startup with Qdrant down. They test that the internal wiring exists — that one service receives what the other sends, not that each works on its own.

34E2E

Against the deployed APIby hand

They call Render and the real model. They stay out of CI on purpose: they depend on Render being awake and on there being credit, and a test that fails for something outside the code tells you nothing.

Coverage by package

Measured over api/app. The CI floor is 85%: it is not there to show off a number but so that a drop shows up in the diff that caused it.

reports
100.0% · 30
domain
99.5% · 600
analysis
96.2% · 132
services
94.7% · 529
llm
91.7% · 348
routes
91.4% · 659
observability
91.2% · 160
data
88.5% · 338
rag
87.5% · 353
(root)
86.5% · 333

The three lowest are low for different reasons, and only one of them is the usual one. In rag it is indeed depending on something external answering: the calls to the embedder and the creation of Qdrant collections, which covering fully would mean mocking the world until the test stops meaning anything. In data the gap is a different one: reading the Excel file, plus the DDL and the migration seed, which run once when the database is created. At the package root, the app's startup and the dependency wiring. None of the three falls below the floor.

Sixteen defects that broke no import

This is the part that usually does not exist. Every line is a concrete way to break the delivery without breaking a single import: defects that do not show up in the call tree but in what comes out — the HTTP response, the workflow, the documentation, the HTML that travels.

What is watchedHow it would look if it failedWho watches it
That stopAndError aborts before any node answers A malformed transaction_id would return 200 with an empty body: identical to a success test_workflows_n8n
That the human-approval form does not publish its URL The case would wait 24 h for a decision nobody would know where to make test_workflows_n8n
That the reports depend on a CDN for their styles Opened from the ZIP without a network, they would come out as stacked plain text test_documentacion_verificable
That choosing “n8n Production” runs the direct pipeline A report that would look like it came from the orchestration without having gone through it test_panel_n8n
That a freshly computed analysis is labelled as an old recording The banner would say “prebuilt case” over an analysis one second old test_report_generator
That a run on a free model reports an invented cost With no known rate it would fall back to Sonnet's: $0.1050 for something that costs zero test_langfuse_stats_fetch
That the prompts do not survive a change of model Reasoning before the JSON, trailing commas, the list wrapped in an object test_compatibilidad_modelos
The documentation could promise a score the package does not reach A number with no provenance is disproved with one command test_documentacion_verificable
That a verdict with a misspelled enum auto-approves the chargeback Crypto with score 8 and BLOCKED/FAILED verdicts would give APPROVE, with no HITL and no alerts test_guardrails
That the deployed panel's “Analyze” button returns an error It would be enough to ask for Anthropic keys and not look at demo mode test_panel_n8n
That the alerts depend on how the case comes in A HITL through the direct pipeline would leave no trace; the same case through n8n would test_guardrails
Thresholds and enums duplicated inside the report template A suspended merchant painted green, or a threshold that moves and a report that does not test_report_generator
That the SLA is measured from the purchase date when there is no open claim Hundreds of days of breach and USD 15 of compensation on a case just opened test_analysis
That editing a policy does not invalidate the cached reports It would be reindexed in Qdrant and the report would come out the same, byte for byte test_policies_crud
That the panel's stream goes silent during the long steps The browser would cut off on its own, and it would look like a cold start with the service warm test_modo_demo
The report declared a prompt version that was not the one that ran It said v1_ —the module's name— for prompts that are on v3.2 test_report_generator

Why this is in a diagram and not in a README

A coverage number does not say whether the tests are any good. You can reach 90% by executing code without asserting anything about it. What does say something is which concrete defect cannot come back, and that is only visible by reading why each test was written.

The sixteen above have something in common: none of them broke an import. The workflow imported, the report generated, the panel returned HTML. They failed where nobody was looking — in the HTTP response, in the banner, in the file that travels inside the ZIP. That is why the suite watches the deliverable and not only the code.

Running them: pytest tests/unit tests/integration -q With coverage: --cov=api/app --cov-fail-under=85 CI: .github/workflows/tests.yml