Tracing Generated Answers Back to Their Sources
This lesson covers registering sources, carrying attribution through RAG and auditing with CloudTrail, so an organisation can show which data sources informed any generated answer and who changed the system.
Learning outcomes
After completing this lesson, you will be able to:
- Register data sources in the Glue Data Catalog.
- Carry attribution from ingestion metadata to citations.
- Audit system changes with CloudTrail.
Registering data sources
Governance teams cannot approve or audit AI systems without knowing which data they use. The AWS Glue Data Catalog is a central registry of datasets, recording each one's location, schema, classification, owner and other properties. Crawlers can populate it automatically by scanning Amazon S3 locations and databases.
Registering every source used for retrieval, fine-tuning or analytics, with business metadata such as the data owner, sensitivity level and approved uses, lets governance teams see which data feeds which AI systems and check that each source is approved for that purpose. When a dataset is later found to be inaccurate or to contain data that should not have been used, the catalogue shows which knowledge bases and models are affected.
Attribution in generated content
Attribution flows from metadata. During ingestion, each document carries its source system, source URL or identifier, version, author and effective date as metadata, which Bedrock Knowledge Bases store with every chunk. At query time, RetrieveAndGenerate returns citations mapping parts of the answer to retrieved chunks and their metadata; with Retrieve, the application includes chunk identifiers in the prompt and asks the model to cite them. The application shows sources to users and stores them in decision logs. Generated content can also carry metadata, such as a tag that it was AI-generated and the model and prompt version that produced it.
The following diagram shows the trail from a disputed answer, given two months earlier, to its sources.

From source to citation
Audit logging with CloudTrail
Traceability also requires knowing who changed a generative AI system and when. AWS CloudTrail records API activity across the account: the creation and modification of knowledge bases, data sources and ingestion jobs; changes to guardrails, prompts, agents and flows; IAM changes; and, when data events are enabled, operations such as retrievals and agent invocations. If an assistant suddenly starts answering differently, CloudTrail shows whether someone changed its prompt, guardrail or data source beforehand.
Organisation trails deliver logs from every account to a central, protected S3 bucket with log file integrity validation, which proves the logs have not been altered, and Amazon Athena queries over the trail answer audit questions. CloudTrail shows who did what; invocation logs and decision logs show what the model received and produced. The following table summarises the traceability sources.
| Question | Source |
|---|---|
| Which datasets feed this AI system? | Glue Data Catalog registrations |
| Which documents supported this answer? | Citations and chunk metadata in decision logs |
| Who changed the knowledge base or guardrail? | CloudTrail management events |
| What did the model receive and return? | Model invocation logs |
Who changed what?
A disputed answer
A customer disputes advice given by an assistant two months ago. Legal needs to know which policy documents supported it and whether the knowledge base had been changed recently.
The decision log for the request lists the citations, whose metadata gives document IDs and versions; the Glue Data Catalog shows the source system and owner; CloudTrail shows the ingestion jobs and data source changes in the preceding weeks and who started them.
Which service records who changed a knowledge base or guardrail?
Show answer
AWS CloudTrail.
Exam Tips
Remember for the exam
- Register AI data sources in the Glue Data Catalog with owners and sensitivity.
- Carry source metadata through ingestion; store citations with responses.
- CloudTrail answers who changed knowledge bases, prompts and guardrails.