Provenance errors

Common error signatures

Errors in the provenance module typically occur when building, validating, or rendering citation records. Watch for these failure patterns:

Where errors originate

All three public functions in src/attune_rag/provenance.py are potential raise sites:

How to diagnose

  1. Identify which function raised. The traceback will point to one of the three functions above. A failure in build_citation_record() means the CitationRecord was never valid; a failure in a format_* function means construction succeeded but the data couldn't be rendered.

  2. Inspect the CitationRecord and its hits. After calling build_citation_record(), confirm that record.hits is a non-empty tuple and that each CitedSource has a non-None template_path, category, and a numeric score. An excerpt of None is acceptable — all other fields are required.

  3. Validate ClaimCitation spans against the response text. If the error is in format_claim_citations_markdown(), check that each ClaimCitation.response_span is a (start, end) tuple where both indices are within the bounds of text. A span that exceeds len(text) will produce an index error.

  4. Confirm retrieved_at is a datetime object. build_citation_record() stores retrieved_at directly on CitationRecord. Passing a string or None instead of a datetime instance will cause failures anywhere that field is serialised or compared.

Source files

Tags: provenance, citations, traceability