Versioning Models, Prompts, Data, and Tools › Artifact lineage: reconstructing what produced an output
Language AI HandbookAll chapters A request execution uses entities such as the manifest and retrieved documents. It produces an output. Recording those relationships lets you work backward from an output to the inputs recorded for it, or forward from a known component to the recorded requests that referenced it. W3C PROV-DM distinguishes the activities that use entities from the production of new entities. W3C PROV-DM
The request record uses the manifest id to identify the release and repeats its human-readable versions for grouping. Document ids record the retrieved items for this request. In a mutable corpus they would also need versioned resolution to recover the retrieved text. The output hash supports byte equality checks against retained text. A hash alone cannot restore that text.
PythonIn [22]Expand
@dataclass(frozen=True)
class RequestRecord:
request_id: str
manifest_id: str
component_versions: dict[str, str] # key -> version, for quick grouping
retrieved_doc_ids: list[str] # data lineage for this request
output_artifact_id: str # sha256 of the UTF-8 output bytesThe manifest id resolves the retained versioned release. The request constructor reads the selected manifest bytes by id. It does not compute a fresh identity from a mutable draft. The repeated component versions make the local example easy to query. For impact analysis based on human labels, enforce unique version labels per component or query by immutable identity.
PythonIn [23]Expand
def make_record(
request_id: str,
mid: str,
docs: list[str],
output_text: str,
store: dict[str, bytes],
) -> RequestRecord:
manifest = json.loads(store[mid])
return RequestRecord(
request_id=request_id,
manifest_id=mid,
component_versions={
key: ref["version"] for key, ref in manifest["components"].items()
},
retrieved_doc_ids=docs[:],
output_artifact_id=content_identity(output_text),
)
sample = make_record(
"req-0001",
stable_id,
docs=["kb-9f8e", "kb-3a2b"],
output_text="According to [kb-9f8e], your order shipped Tuesday.",
store=registry,
)ConsoleOut [24]Expand
request: req-0001
manifest: sha256:36f5a9a25a9a3550 ...
versions: {'embed.kb': 'e5-base-v2', 'index.kb': 'kb-2025-06', 'model': 'gpt-x-2025-06', 'prompt.main': 'v3', 'tools.lookup_order': 'v2'}
retrieved: ['kb-9f8e', 'kb-3a2b']
output id: sha256:ed937ba75c96bf45 ...Forward impact is a group-by over these records. Given a component version, find every record whose component_versions contains it:
PythonIn [25]Expand
# Synthetic log of request records.
rng = random.Random(7)
log: list[RequestRecord] = []
for i in range(200):
mid = route(rng, canary)
doc = f"kb-{rng.randrange(16):04x}"
log.append(make_record(f"req-{i:04d}", mid, [doc], f"answer {i}", registry))
def affected_by_version(
log: list[RequestRecord], key: str, version: str
) -> list[str]:
return [
r.request_id for r in log if r.component_versions.get(key) == version
]ConsoleOut [26]Expand
prompt.main=v3: 176 requests affected prompt.main=v4: 24 requests affected
The query returns requests recorded under the named component version within the retained log. It identifies the affected cohort, while whether a particular answer was wrong still needs review. Gaps from sampling or expired retention limit the result. Joining on exact artifact identities avoids treating two assignments of the same display label as one artifact.
For an historical audit, ask what can be determined from the record before promising a replay. Two requests with the same manifest id can return different documents. Two requests can also see the same document ids with different contents if the ids are mutable. That is why a versioned source snapshot or document revisions belong in the analysis whenever reconstruction requires the specific text. The toy log stores only document ids because its goal is to trace the manifest used by each request.
A version-filtered request list narrows the audit scope. If a report was assembled by joining requests to a moving prompt alias, the current alias target could make earlier results look as if they used the new version. Join on the recorded immutable id or an equivalent stable revision. When aggregating metrics, record the time interval or population and distinguish unlogged cases from cases that have been evaluated and found unaffected.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!