pub fn materialize_token(
target: &mut Document,
packs: &[LibraryPack],
pkg_id: &str,
item: &str,
id_base: &str,
) -> Result<TokenAddOutcome, AddError>Expand description
Materialize the filter-token item pkg_id#item into target, returning the
TokenAddOutcome describing what was added.
This is the PURE core of a library add for a TOKEN item: it mutates the
parsed target Document in place and performs NO filesystem or process
I/O. Unlike super::materialize, it inserts NO instance and requires NO
page. Steps:
- Resolve the FIRST pack in
packswhose id ==pkg_id(project shadows preset); load its fullzenith_core::Document. - Find the FILTER token whose id ==
item. - Collect the filter token’s transitive color-token deps
(
collect_filter_dep_ids). - Ensure the target’s tokens block has a format (adopt the pack’s when empty).
- Copy the dep tokens THEN the filter token into the target (dedup by id +
conflict warnings, via the shared
copy_tokens). - Record a
librariesentry forpkg_id(if absent). - Record a unique
provenancerecord whosenodeis the filter-token id — skipped if an identical(node, library, item)provenance already exists.
§Errors
Returns AddError when the package or item is unknown (the message lists
the available options).