# Intent.Common.DriftReporting

This module gives an application one drift report. Other modules check it for drift between the model and the code, and this module runs those checks on every Software Factory run, logs their findings and writes the report.

## How a check reports

A module adds a check by subclassing `DriftReporterBase`, a factory extension, and implementing `Report(IDriftContext context)`. After template execution, once every template's output is built and before anything is staged, this module calls each registered reporter in its `Order`. A reporter adds its findings to named Areas through `context.Area(...)`. If a reporter throws, the error is logged under its name and the other reporters still run.

## After a Software Factory run

- **Drift errors:** the run logs one error with each Area's error and warning counts and the report's path, e.g. `Drift in Domain: 2 errors, 1 warning`.
- **Only warnings:** the run logs one warning in the same form.
- **Any findings:** the run stages the report at `.intent/drift/<application>/DriftReport.mdx`, in the folder holding the solution's `.isln`, which git ignores. The report is listed as a new file in the run's changes.
- **No findings:** the run leaves no report. Every run outside CI/CD starts by deleting the last report, including one an earlier version of this module left at `.cache/drift/<application>/DriftReport.mdx`.
- **CI/CD runs** (`--param ensure-no-outstanding-changes=true`): the run writes no report. Its error lists every finding instead, and a drift error ends the run with an exception, so the pipeline fails.

## The report

The report opens with a summary of each Area's errors and warnings. Each Area has a table per category:

- **Model / Code:** the model and the code disagree.
- **Code / Code:** code breaks a rule about other code.
- **Code:** the code alone has a problem, or a check's own configuration is wrong.

In each row, **Subject** is what the finding is about (a model element or a file), **Against** is what it was compared with, and **Finding** says what is wrong.

## AI instruction

The module generates an always-on AI instruction, `drift-report`, that tells agents where drift findings appear after a run and how to read the report. Every application in the solution writes the same file, so the instruction gives the path as `.intent/drift/<Application Name>/DriftReport.mdx`.
