Inferensys

Prompt

Source Provenance Tracking Prompt for Audit Trails

A practical prompt playbook for generating fully traceable, audit-ready answers with complete evidence lineage, document IDs, retrieval timestamps, and chunk references for compliance workflows.
Auditor reviewing AI-generated audit trail on laptop, blockchain-like immutable records visible, home office evening.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the compliance job, the required inputs, and the operational boundaries for the Source Provenance Tracking Prompt.

Use this prompt when you need to generate an answer that is not just factually grounded, but fully auditable. The primary job is to produce a response where every single claim is explicitly linked to its origin: a specific document ID, a retrieval timestamp, and a chunk reference. This is essential for compliance workflows in finance, healthcare, and legal domains where downstream reviewers or auditors must verify the exact lineage of information without redoing the entire research process. The ideal user is an AI engineer or compliance architect integrating a Retrieval-Augmented Generation (RAG) system into a regulated product where evidence traceability is a hard requirement, not a nice-to-have.

The prompt requires a specific set of structured inputs to function correctly. You must supply a [USER_QUERY], a [RETRIEVED_CONTEXT] array where each object contains doc_id, chunk_id, content, and retrieval_timestamp, and an [AUDIT_REQUIREMENTS] block specifying the expected provenance granularity. The prompt is designed to fail safely: if the model cannot trace a claim back to a source, it must explicitly flag the gap in a missing_provenance alert rather than silently generating an unmoored statement. Do not use this prompt for low-latency chat applications where the overhead of structured provenance generation would degrade user experience, or in scenarios where the retrieval source lacks stable identifiers.

Before deploying this prompt, you must implement a validation harness that checks the output schema, not just the text. The expected output is a JSON object containing an answer string, a provenance_chain array, and a provenance_completeness score. A post-processing script should verify that every sentence in the answer marked as a claim has a corresponding entry in the provenance_chain. If the provenance_completeness score falls below your defined threshold, the system should either trigger a retry with stricter instructions or escalate the request for human review. Avoid using this prompt with models that have weak instruction-following for complex JSON schemas, as partial or malformed provenance objects will break the audit trail.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Source Provenance Tracking Prompt delivers reliable audit trails and where it introduces risk. Use these cards to decide if this prompt fits your compliance workflow before integrating it into a production harness.

01

Good Fit: Regulated Audit Workflows

Use when: you need complete evidence lineage for compliance reviews, external audits, or internal governance. The prompt produces document IDs, retrieval timestamps, and chunk references per claim. Guardrail: pair with a provenance completeness validator that flags missing source metadata before the output reaches a reviewer.

02

Bad Fit: Real-Time Chat with No Retrieval Log

Avoid when: your system does not capture retrieval metadata at inference time. The prompt cannot fabricate provenance fields it never received. Guardrail: instrument your retrieval pipeline to emit source IDs, timestamps, and chunk offsets before invoking this prompt. If the harness cannot provide those inputs, use a simpler citation prompt instead.

03

Required Inputs: Retrieval Metadata Payload

Risk: the prompt will hallucinate provenance fields if the input lacks structured retrieval metadata. Guardrail: enforce a strict input schema requiring source_id, retrieval_timestamp, chunk_index, and content_hash per passage. Validate the payload before prompt assembly and abort if required fields are missing.

04

Operational Risk: Token Budget Explosion

Risk: full provenance chains with timestamps and chunk references consume significant context window space, especially for multi-document answers. Guardrail: set a token budget for provenance metadata and truncate low-relevance source details first. Log when provenance is compressed so auditors know what was omitted.

05

Operational Risk: Stale Provenance in Cached Context

Risk: cached prompts with embedded provenance timestamps can become stale, misleading auditors about when evidence was retrieved. Guardrail: include a prompt_assembly_timestamp in the output and compare it against retrieval_timestamp fields. Flag outputs where the gap exceeds your freshness threshold.

06

Escalation Trigger: Missing Provenance Alerts

Risk: silent provenance gaps erode audit trust. If a claim cannot be traced to a source, the output should not pretend otherwise. Guardrail: configure the prompt to emit a structured missing_provenance alert per unsupported claim. Route outputs with alerts to human review before they enter the audit record.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating audit-ready answers with complete source provenance chains, including document IDs, retrieval timestamps, and chunk references.

This template is designed for compliance workflows where every claim must be traceable to its origin. It instructs the model to produce an answer where each factual statement is accompanied by a full provenance record, including the source document identifier, the retrieval timestamp, and the specific chunk or section reference. Use this template when downstream auditors, regulators, or internal review processes require a complete, machine-readable lineage from output back to source data. Do not use this template for low-latency chat applications where provenance overhead would degrade user experience.

text
You are an audit-grade assistant. Your task is to answer the user's question using ONLY the provided [CONTEXT] passages. You must produce a response that includes a complete provenance chain for every factual claim.

## INPUT
User Question: [USER_QUESTION]

## CONTEXT
[CONTEXT]

## OUTPUT_SCHEMA
Your response must be a valid JSON object with the following structure:
{
  "answer_id": "[GENERATE_A_UNIQUE_ID]",
  "answer_summary": "A concise summary of the answer.",
  "claims": [
    {
      "claim_id": "claim-1",
      "claim_text": "The exact factual statement made.",
      "provenance": [
        {
          "source_document_id": "[DOC_ID]",
          "source_chunk_id": "[CHUNK_ID]",
          "retrieval_timestamp": "[TIMESTAMP]",
          "source_text_excerpt": "The exact text from the source supporting this claim."
        }
      ],
      "confidence": "HIGH | MEDIUM | LOW",
      "confidence_rationale": "Brief explanation for the confidence level."
    }
  ],
  "missing_provenance_alerts": [
    {
      "alert_type": "MISSING_SOURCE | STALE_TIMESTAMP | CONFLICTING_EVIDENCE",
      "detail": "Description of the provenance gap.",
      "affected_claim_ids": ["claim-1"]
    }
  ],
  "audit_trail_completeness": "COMPLETE | PARTIAL | INCOMPLETE"
}

## CONSTRAINTS
1. Every claim in the 'claims' array MUST have at least one entry in its 'provenance' array.
2. If a claim cannot be fully supported by the provided [CONTEXT], set its confidence to LOW and add a MISSING_SOURCE alert.
3. If a source's retrieval timestamp is older than [STALENESS_THRESHOLD_HOURS] hours, add a STALE_TIMESTAMP alert.
4. If two sources provide conflicting information for the same claim, add a CONFLICTING_EVIDENCE alert and set the claim's confidence to LOW.
5. Do not invent any source_document_id, source_chunk_id, or retrieval_timestamp. Use only the metadata provided in the [CONTEXT] passages.
6. If the [CONTEXT] is empty or contains no relevant information, return an empty 'claims' array, set 'audit_trail_completeness' to INCOMPLETE, and add a single MISSING_SOURCE alert explaining the gap.

To adapt this template, replace the [USER_QUESTION] and [CONTEXT] placeholders with your application's runtime values. The [CONTEXT] placeholder should be populated with pre-formatted text blocks, each prepended with its metadata (document ID, chunk ID, timestamp) in a consistent, parseable format. The [STALENESS_THRESHOLD_HOURS] placeholder should be set to your organization's data freshness policy. Before deploying, validate that your retrieval pipeline consistently provides the required metadata fields; a missing retrieval_timestamp in the source data will cause the model to either hallucinate a value or trigger a false MISSING_SOURCE alert. Always pair this prompt with a post-generation validation step that parses the JSON output and programmatically verifies that every source_document_id exists in your system of record.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Source Provenance Tracking Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the input is well-formed and safe to use.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The original question or request that triggered the provenance-tracked answer

What were the Q3 revenue adjustments for the EMEA region?

Must be non-empty string. Check for injection patterns before insertion. Log original query for audit trail.

[RETRIEVED_DOCUMENTS]

Array of retrieved documents with IDs, content, and metadata including timestamps and chunk references

[{"doc_id": "fin-2024-q3-emea", "chunk_id": 4, "content": "EMEA revenue adjusted by...", "retrieved_at": "2025-01-15T14:32:00Z", "source": "internal-finance-db"}]

Each document must have doc_id, chunk_id, content, and retrieved_at fields. Validate array is non-empty. Check for duplicate chunk_ids. Verify timestamps are ISO 8601.

[SOURCE_AUTHORITY_MAP]

Mapping of source identifiers to authority levels and trust scores for evidence weighting

{"internal-finance-db": {"authority": "high", "trust_score": 0.95}, "public-filings": {"authority": "medium", "trust_score": 0.80}}

Must be valid JSON object. Every source in RETRIEVED_DOCUMENTS must have an entry. Authority values must be from allowed enum: high, medium, low, unknown. Trust scores must be floats between 0.0 and 1.0.

[AUDIT_TRAIL_REQUIREMENTS]

Specification of what provenance metadata must be included in the output for compliance

{"required_fields": ["doc_id", "chunk_id", "retrieved_at", "source"], "require_confidence": true, "require_missing_evidence_flags": true}

Must be valid JSON object. required_fields array must not be empty. Boolean fields must be true or false. Validate that required_fields match available document metadata fields.

[CONFIDENCE_THRESHOLD]

Minimum confidence score below which claims should be flagged or withheld

0.70

Must be a float between 0.0 and 1.0. Values below 0.5 should trigger a review warning. Null allowed if confidence gating is disabled.

[MAX_CLAIMS_PER_SOURCE]

Upper limit on how many distinct claims can be attributed to a single source chunk to prevent over-reliance

5

Must be a positive integer. Values above 10 should trigger a review warning. Used to detect when a single chunk is being over-cited.

[OUTPUT_SCHEMA]

Expected JSON schema for the provenance-tracked answer output

{"type": "object", "properties": {"answer": {"type": "string"}, "claims": {"type": "array", "items": {"type": "object", "properties": {"claim_text": {"type": "string"}, "sources": {"type": "array"}, "confidence": {"type": "number"}}}}}}

Must be valid JSON Schema. Validate with a schema parser before use. Schema must include answer, claims, and sources fields at minimum. Reject schemas that allow unbounded arrays without limits.

[MISSING_EVIDENCE_ALERT_TEMPLATE]

Template for the alert message when required provenance information is absent from retrieved documents

WARNING: The following claim could not be fully traced to source evidence: [CLAIM_TEXT]. Missing fields: [MISSING_FIELDS].

Must be a non-empty string. Must contain [CLAIM_TEXT] and [MISSING_FIELDS] placeholders. Validate that the template produces valid output when placeholders are substituted with realistic values.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Source Provenance Tracking Prompt into a production audit trail system with validation, retries, and human review gates.

The Source Provenance Tracking Prompt is not a standalone chat interaction—it is a component inside a broader compliance pipeline. The typical harness wraps the prompt in a retrieval step, a generation step, a structured validation step, and a persistence step that writes the audit record. Before calling the model, assemble the [INPUT] (the user question or analysis request) and the [CONTEXT] (retrieved documents with their IDs, chunk references, and retrieval timestamps). The [OUTPUT_SCHEMA] should be a strict JSON schema that includes a claims array where each claim object has claim_text, source_document_id, source_chunk_id, retrieval_timestamp, and confidence fields. The [CONSTRAINTS] block should enforce that every claim must have a non-null source reference and that claims without provenance must be listed in a separate unattributed_claims array with an explicit provenance_gap reason.

After the model returns, run a provenance completeness validator before the output enters any audit log. This validator checks that every claim in the claims array has a populated source_document_id and source_chunk_id, that the referenced document IDs actually exist in the retrieval set you provided, and that the retrieval_timestamp values are within an acceptable freshness window. If the validator finds unattributed claims in the main claims array (not the unattributed_claims array), or if source references point to documents not in the input context, flag the output for repair. Implement a retry loop with a maximum of two additional attempts: on retry, append the validation errors to the prompt as [PREVIOUS_ERRORS] and instruct the model to fix the provenance gaps or move unsupported claims to the unattributed_claims array. If the third attempt still fails validation, escalate to a human review queue rather than silently accepting a broken audit trail. Log every attempt, the validation results, and the final disposition (accepted, repaired, or escalated) with timestamps and operator IDs.

For high-risk compliance workflows, add a human approval gate even when validation passes. Route outputs with low confidence scores, multiple unattributed claims, or source conflicts to a review interface that displays the original question, the retrieved documents, and the model's provenance chain side by side. The reviewer can approve, reject, or amend the audit record before it is persisted. When choosing a model, prefer variants with strong instruction-following for structured output (GPT-4o, Claude 3.5 Sonnet, or equivalent). Avoid models known to drop fields or invent source references under pressure. Wire the entire harness into your observability stack: trace every prompt assembly, model response, validation result, retry, and human action so that the audit trail itself is auditable. The prompt is the instruction layer—the harness is what makes it trustworthy in production.

IMPLEMENTATION TABLE

Expected Output Contract

Each field the prompt must return, its type, whether it is required, and the validation rule to apply before accepting the output.

Field or ElementType or FormatRequiredValidation Rule

answer_summary

string

Must be non-empty and under 500 characters. Parse check for length and null.

provenance_chain

array of objects

Array must contain at least one object. Schema check for array type and minItems=1.

provenance_chain[].document_id

string

Must match pattern doc-[a-z0-9]+. Regex validation required.

provenance_chain[].chunk_id

string

Must match pattern chunk-[a-z0-9]+. Regex validation required.

provenance_chain[].retrieval_timestamp

ISO 8601 string

Must parse as valid UTC datetime. Format check with date-fns or equivalent.

provenance_chain[].relevance_score

number

Must be between 0.0 and 1.0 inclusive. Range check required.

missing_provenance_alerts

array of strings

Each string must be non-empty. Array can be empty if no gaps. Schema check for array of strings.

audit_trail_completeness

string

Must be one of complete, partial, none. Enum check required.

PRACTICAL GUARDRAILS

Common Failure Modes

Source provenance tracking fails in predictable ways when the prompt, retrieval pipeline, or output validation are misaligned. These cards cover the most common failure modes and practical mitigations.

01

Silent Provenance Dropout

What to watch: The model generates an answer with citations but omits document IDs, retrieval timestamps, or chunk references for some claims. The output looks grounded but is partially untraceable. Guardrail: Add a post-generation validator that checks every claim has a complete provenance tuple (doc_id, timestamp, chunk_ref). If any claim is missing a field, trigger a repair prompt or flag for human review.

02

Fabricated Source References

What to watch: The model invents plausible-looking document IDs, timestamps, or chunk references that do not exist in the retrieval set. This is a hallucination pattern specific to provenance tracking. Guardrail: Cross-reference every output provenance identifier against the actual retrieval payload. Reject any reference not present in the source set and log the mismatch for eval review.

03

Provenance-Chain Truncation

What to watch: The model provides a source reference but omits intermediate retrieval steps, query rewrites, or re-ranking decisions that led to that source. The audit trail is incomplete for compliance review. Guardrail: Structure the prompt to require a full provenance chain per claim: original query → rewritten query → retrieval method → ranked position → document ID → chunk reference. Validate chain completeness before accepting the output.

04

Timestamp Staleness Without Warning

What to watch: The model returns provenance with retrieval timestamps but does not flag when those timestamps are older than a freshness threshold. Compliance reviewers may assume the evidence is current. Guardrail: Include a freshness threshold in the prompt and require an explicit staleness warning field when any source timestamp exceeds the threshold. Validate that the warning appears when expected.

05

Provenance-Answer Misalignment

What to watch: The model cites a source that exists in the retrieval set but the cited passage does not actually support the claim it is attached to. The provenance is real but the mapping is wrong. Guardrail: Implement an evidence-to-claim alignment check using a separate verification prompt or LLM judge. Flag claim-source pairs where the cited passage does not contain the asserted fact.

06

Missing-Provenance Blind Spot

What to watch: The model generates claims that have no provenance at all, often when synthesizing across sources or filling gaps with parametric knowledge. These unsupported claims blend into the output. Guardrail: Require the prompt to output a structured missing_provenance_alerts array for any claim that cannot be traced to a source. Add a post-check that counts unsupported claims and escalates if they exceed a threshold.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the Source Provenance Tracking Prompt before production deployment. Each row defines a pass standard, a failure signal, and a concrete test method to verify audit trail completeness.

CriterionPass StandardFailure SignalTest Method

Provenance Completeness

Every factual claim includes a [DOC_ID], [CHUNK_ID], and [RETRIEVAL_TIMESTAMP]

Output contains unsupported claims without provenance anchors or uses placeholder IDs

Parse output for claim-anchor pairs; count claims with null or missing provenance fields

Citation Format Compliance

All citations match the required format: [DOC_ID:CHUNK_ID:RETRIEVAL_TIMESTAMP]

Citations use inconsistent separators, missing components, or unstructured text instead of the required format

Regex validation against the expected citation pattern; flag any non-matching citation strings

Missing Provenance Alert Trigger

Prompt generates a structured alert when input evidence lacks required provenance metadata

Prompt synthesizes provenance from partial metadata or silently omits missing-provenance warnings

Provide input with intentionally stripped metadata; check output for the missing-provenance alert block

Audit Trail Completeness

Output includes a full audit trail section listing all source documents, retrieval timestamps, and chunk references used

Audit trail section is absent, incomplete, or lists sources that were not actually cited in the answer

Diff the audit trail document list against the cited documents in the answer; flag mismatches or omissions

Temporal Ordering Accuracy

Provenance entries are ordered by [RETRIEVAL_TIMESTAMP] descending in the audit trail

Timestamps are out of sequence, missing, or use inconsistent timezone formatting

Parse all timestamps in the audit trail; verify descending sort order and ISO-8601 format compliance

Confidence-Anchored Attribution

Each claim includes a [CONFIDENCE_SCORE] between 0.0 and 1.0 derived from source reliability

Confidence scores are absent, uniformly 1.0, or not traceable to a specific source reliability metric

Sample 10 claims; verify each has a numeric confidence score and cross-reference against source metadata

Abstention for Unprovable Claims

Prompt refuses to generate claims when no provenance metadata is available and returns a structured abstention

Prompt generates plausible-sounding provenance or fabricates document IDs when input lacks evidence

Provide empty or null provenance input; assert output contains the abstention template and zero generated claims

Provenance Chain Integrity

Output preserves the full chain: [QUERY] -> [RETRIEVED_DOC] -> [CHUNK] -> [CLAIM] without broken links

Intermediate retrieval steps are skipped, or claims reference documents not present in the retrieval log

Trace each claim back through the audit trail to the original retrieval log entry; flag orphaned claims

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt template. Remove strict schema enforcement and allow the model to return provenance chains in natural language. Use a simpler instruction: 'For every claim in your answer, cite the document ID, retrieval timestamp, and chunk reference. If you cannot cite a source, mark it as [UNVERIFIED].'

Watch for

  • Missing provenance fields when the model skips optional citations
  • Overly broad instructions producing verbose but incomplete chains
  • No validation of whether cited chunks actually contain the claimed information
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.