FailLoud Playground / Guides

My agent's report says it sent 12 emails. How do I check the counts against the actual items?

Short answer

Never trust the summary number — reconcile it against the itemized record in the same document. FailLoud FL004 count_mismatch does this mechanically: every reported count is compared with the list it claims to count, and every total with the sum of its parts. On the shipped example: “Count for 'delivered' is reported as 12 but the itemized record contains 9 item(s)” — twice, for two different counts, in one run.

Why counts lie politely

Reports count actions attempted; audiences read them as actions completed. The summary number is generated by the same component that did the work, from its intentions; the itemized list is the only part of the document that was ever true. When the two disagree, the list wins — and the disagreement itself is the finding, because every dashboard downstream already consumed the summary.

The technique

  1. Pair each reported count with its itemized record (counts.sent ↔ items.sent).
  2. Compare lengths. A mismatch is an error with both numbers attached — never a silent correction.
  3. Check totals against the sum of their parts.
  4. Where a count has no itemized record at all, say unverifiable — do not invent a verdict.
$ failloud check examples/failing_output.json --only FL004
[FL004] count_mismatch — FAIL
  ✗ $.counts.delivered — Count for 'delivered' is reported as 12 but the
    itemized record at $.items.delivered contains 9 item(s).
  ✗ $.counts.sent — Count for 'sent' is reported as 12 but the itemized
    record at $.items.sent contains 9 item(s).

Counts against the world, not just the document

An output can be internally consistent and still wrong — 9 claimed, 9 listed, and one of them bounced an hour later. FailLoud's second pass (failloud recheck) re-judges reported counts against a later system-of-record snapshot: on the shipped example the record shows 8 delivered against the reported 9, and the verdict is CONTRADICTED, exit 1.