zenith_core/ast/provenance.rs
1//! Provenance block declaration AST types.
2//!
3//! The top-level `provenance` block records per-node origin metadata: each
4//! `origin` entry records WHERE a document node came from (which library/package
5//! and item). It is a sibling of the `assets`/`libraries`/`sections` blocks. The
6//! engine preserves and validates these records — each references a node id AND a
7//! declared library id that must exist — but does NOT act on the link state; the
8//! `linked` flag is round-tripped for external tooling.
9
10use std::collections::BTreeMap;
11
12use super::Span;
13use super::node::UnknownProperty;
14
15/// A single provenance record within a `provenance` block — one node's origin.
16#[derive(Debug, Clone, PartialEq)]
17pub struct ProvenanceDef {
18 /// This record's own unique id. Required.
19 pub id: String,
20 /// The id of the document node this provenance describes. Required; must
21 /// reference an existing node id, a declared token id, or a declared action
22 /// id.
23 pub node: String,
24 /// The declared library/package id this node originated from. Required; must
25 /// reference a `library` declared in the `libraries` block.
26 pub library: String,
27 /// The item name within the library (e.g. "button"). Optional.
28 pub item: Option<String>,
29 /// Link state: `Some(true)` = linked (updates when the library updates),
30 /// `Some(false)` = detached (frozen). `None` = unspecified (treated as linked
31 /// by external tooling). The engine preserves this; it does not act on it.
32 pub linked: Option<bool>,
33 /// Source declaration span, when available.
34 pub source_span: Option<Span>,
35 /// Forward-compat: unrecognized attributes preserved with typed values + annotations.
36 pub unknown_props: BTreeMap<String, UnknownProperty>,
37}