Skip to main content

Bundle

Struct Bundle 

Source
pub struct Bundle {
    pub concepts: Vec<Concept>,
    pub okf_version: Option<String>,
    pub files: Option<BTreeSet<String>>,
    pub source_bytes: BTreeMap<String, Vec<u8>>,
    pub source_modified: BTreeMap<String, i64>,
}
Expand description

A loaded bundle.

Fields§

§concepts: Vec<Concept>

Concepts in sorted id order.

§okf_version: Option<String>

The okf_version declared by the bundle index, when any.

§files: Option<BTreeSet<String>>

Every file in the bundle as a POSIX-relative path, when the bundle was loaded from disk. In-memory bundles carry None, and checks that need the inventory skip file existence checks.

§source_bytes: BTreeMap<String, Vec<u8>>

The bytes of in-bundle sources that record a content hash, keyed by bundle-relative path.

§source_modified: BTreeMap<String, i64>

Explicit source modification instants supplied by a caller (for example from version-control commit timestamps), as epoch seconds keyed by bundle-relative path. Disk loads leave this map empty so host filesystem mtime never alters audit output.

Implementations§

Source§

impl Bundle

Source

pub fn uses_v02_fallback(&self) -> bool

Whether the SPEC 12.1 fallbacks apply to this bundle. They apply when the bundle declares version 0.2 or earlier, or declares no version at all. A declared version that does not parse is treated as current, never as an old version.

Source

pub fn load(root: &Path) -> Result<Bundle>

Load every concept under a bundle root directory.

Examples found in repository?
examples/audit_bundle.rs (line 13)
10fn main() {
11    let fixture_dir =
12        PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../corpus/fixtures/clean-healthy-chain");
13    let bundle = Bundle::load(&fixture_dir).expect("load clean-healthy-chain fixture");
14    let clock = AuditClock::parse("2026-11-20").expect("parse pinned audit date");
15
16    println!(
17        "Loaded bundle with {} concepts at {}",
18        bundle.concepts.len(),
19        clock
20    );
21
22    for concept in &bundle.concepts {
23        let tier = recompute_tier(concept, &clock);
24        println!(
25            "  concept={} raw={} recomputed={}",
26            tier.concept_id,
27            tier.raw_tier.name(),
28            tier.recomputed_tier.name()
29        );
30    }
31
32    let chain = walk_supersession(&bundle, "metrics/old-revenue");
33    assert_eq!(chain.terminal, ChainTerminal::Terminated);
34    println!(
35        "  chain start={} hops={:?} terminal={:?}",
36        chain.start, chain.hops, chain.terminal
37    );
38
39    let revenue = bundle
40        .concept("metrics/revenue")
41        .expect("metrics/revenue exists");
42    assert_eq!(
43        recompute_tier(revenue, &clock).recomputed_tier,
44        Tier::HumanReviewed
45    );
46
47    let mut findings = check_currency(&bundle, &clock);
48    findings.extend(check_supersession(&bundle));
49    findings.extend(check_freshness(&bundle, &clock));
50    findings.extend(check_provenance(&bundle));
51    findings.extend(check_drift(&bundle));
52    assert!(
53        findings.is_empty(),
54        "expected zero findings, got {findings:?}"
55    );
56
57    let notes = info_notes(&bundle, &clock);
58    println!(
59        "Audit passed with {} findings and {} info notes.",
60        findings.len(),
61        notes.len()
62    );
63}
Source

pub fn from_concepts(concepts: Vec<Concept>) -> Bundle

Build a bundle from in-memory concepts.

Source

pub fn concept(&self, id: &str) -> Option<&Concept>

Look up one concept by id.

Examples found in repository?
examples/audit_bundle.rs (line 40)
10fn main() {
11    let fixture_dir =
12        PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../corpus/fixtures/clean-healthy-chain");
13    let bundle = Bundle::load(&fixture_dir).expect("load clean-healthy-chain fixture");
14    let clock = AuditClock::parse("2026-11-20").expect("parse pinned audit date");
15
16    println!(
17        "Loaded bundle with {} concepts at {}",
18        bundle.concepts.len(),
19        clock
20    );
21
22    for concept in &bundle.concepts {
23        let tier = recompute_tier(concept, &clock);
24        println!(
25            "  concept={} raw={} recomputed={}",
26            tier.concept_id,
27            tier.raw_tier.name(),
28            tier.recomputed_tier.name()
29        );
30    }
31
32    let chain = walk_supersession(&bundle, "metrics/old-revenue");
33    assert_eq!(chain.terminal, ChainTerminal::Terminated);
34    println!(
35        "  chain start={} hops={:?} terminal={:?}",
36        chain.start, chain.hops, chain.terminal
37    );
38
39    let revenue = bundle
40        .concept("metrics/revenue")
41        .expect("metrics/revenue exists");
42    assert_eq!(
43        recompute_tier(revenue, &clock).recomputed_tier,
44        Tier::HumanReviewed
45    );
46
47    let mut findings = check_currency(&bundle, &clock);
48    findings.extend(check_supersession(&bundle));
49    findings.extend(check_freshness(&bundle, &clock));
50    findings.extend(check_provenance(&bundle));
51    findings.extend(check_drift(&bundle));
52    assert!(
53        findings.is_empty(),
54        "expected zero findings, got {findings:?}"
55    );
56
57    let notes = info_notes(&bundle, &clock);
58    println!(
59        "Audit passed with {} findings and {} info notes.",
60        findings.len(),
61        notes.len()
62    );
63}

Trait Implementations§

Source§

impl Clone for Bundle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Bundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Bundle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Bundle

Source§

impl PartialEq for Bundle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Bundle

Auto Trait Implementations§

§

impl Forget for Bundle

§

impl Freeze for Bundle

§

impl Move for Bundle

§

impl RefUnwindSafe for Bundle

§

impl Send for Bundle

§

impl Sync for Bundle

§

impl Unpin for Bundle

§

impl UnsafeUnpin for Bundle

§

impl UnwindSafe for Bundle

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.