-
feat: add enrichment origins metadata field (#4370)
发布于
2026-06-10 17:23:48 +00:00 Summary
Adds a new
enrichment_originsfield toElementMetadatathat tracks
which model wrote (or contributed to) each enriched attribute.What's new
ElementMetadata.enrichment_origins— a serializeddict[str, list[dict[str, str]]]mapping a written attribute name (e.g.text,
text_as_html,embeddings) to a list of{"type", "provider", "model"}records, in application order. Authoring enrichments overwrite
the list; additive enrichments append, preserving the prior author.ConsolidationStrategy.DICT_LIST_UNIQUE— a new chunking
consolidation strategy fordict[str, list]fields. It unions keys
across elements and, per key, concatenates then dedupes records while
preserving first-seen order. Wired up as the strategy for
enrichment_origins.
Testing
- Unit tests for the new metadata field (
test_elements.py). - Unit tests for the
DICT_LIST_UNIQUEmerge behavior during chunking
(test_base.py).
Summary by cubic
Adds per-attribute enrichment provenance via
ElementMetadata.enrichment_originsand a dict-list merge strategy, and
isolates per-chunk metadata so provenance updates can’t leak across
split chunks.-
New Features
-
ElementMetadata.enrichment_origins: maps an attribute to a list of
{"type","provider","model"}in application order. Authoring
overwrites; additive appends. -
ConsolidationStrategy.DICT_LIST_UNIQUE: unions keys and per-key
concat+dedupes while preserving order; used forenrichment_originsin
chunking. -
Bug Fixes
-
First and continuation split chunks each get a fresh metadata object.
-
Deep-copies
enrichment_originsper chunk and setsis_continuation
on later chunks, preventing any in-place updates from leaking to
siblings or lazy continuations.
Written for commit 7a03b8c9886b6cbdbfcfe647984482f5daaa6724.
Summary will update on new commits.
Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com
下载附件