Skip to main content

Crate perishables_core

Crate perishables_core 

Source
Expand description

Trust-layer checks for Open Knowledge Format bundles.

This crate recomputes trust tiers from current verifications only, checks verification currency, and walks superseded_by chains. It performs no writes. Every instant comes from a pinned AuditClock, so the same bundle and the same clock always give the same findings.

The public surface includes the four locked calls consumed by downstream upkeep engines: recompute_tier, check_currency, walk_supersession, and check_supersession. Finding codes live in the closed FindingCode enum and never change meaning once published.

§Example

use perishables_core::{
    AuditClock, Bundle, Concept, Tier, VerifiedEvent, check_currency, recompute_tier,
};

let clock = AuditClock::parse("2026-11-20").expect("valid date");
let concept = Concept {
    id: "metrics/revenue".to_string(),
    concept_type: "Metric".to_string(),
    status: "stable".to_string(),
    superseded_by: None,
    generated_at: AuditClock::parse("2026-06-20T14:00:00Z").map(|c| c.epoch_seconds),
    generated_text: Some("2026-06-20T14:00:00Z".to_string()),
    stale_after_text: Some("2026-12-31T00:00:00Z".to_string()),
    stale_after: AuditClock::parse("2026-12-31T00:00:00Z").map(|c| c.epoch_seconds),
    verified: vec![VerifiedEvent {
        by: Some("human:reviewer".to_string()),
        at_text: Some("2026-06-25T09:00:00Z".to_string()),
        at: AuditClock::parse("2026-06-25T09:00:00Z").map(|c| c.epoch_seconds),
    }],
    sources: Vec::new(),
    citations: Vec::new(),
    runtime: None,
    parameters: Vec::new(),
    code_blocks: Vec::new(),
    file_code: None,
    claimed_result: None,
};

let report = recompute_tier(&concept, &clock);
assert_eq!(report.recomputed_tier, Tier::HumanReviewed);

let bundle = Bundle::from_concepts(vec![concept]);
assert!(check_currency(&bundle, &clock).is_empty());

Structs§

AuditClock
A pinned instant. The library never reads the system clock.
Bundle
A loaded bundle.
ChainReport
The result of walking one supersession chain.
Concept
One concept and the trust fields the checks read.
EventReport
The classification of one verification event, with its reason.
Finding
One finding, tied to one concept and one rule.
InfoNote
One piece of information reported without tripping the audit gate.
Parameter
One declared parameter of an Attested Computation.
SourceRef
One entry of a concept sources list.
TierReport
The result of recomputing one concept tier.
VerifiedEvent
One verification event as recorded in frontmatter, before any judgement about its currency or shape.

Enums§

ChainTerminal
How a supersession chain ends.
EventClass
How one verification event classifies against its concept.
FindingCode
A closed set of finding codes, shared with the corpus labels.
Tier
A trust tier, derived and never stored.

Functions§

check_currency
Check verification currency across a whole bundle. Call two of the locked interface.
check_drift
Check source drift against recorded SHA-256 content hashes.
check_freshness
Check freshness against the pinned clock.
check_provenance
Check provenance completeness.
check_supersession
Check every supersession chain in a bundle. Call four of the locked interface.
info_notes
Information notes for a bundle, covering stale deprecated concepts, concepts with no recorded provenance, SPEC 12.1 fallback targets, and explicit source modification ordering facts.
recompute_tier
Recompute the trust tier of one concept from its current verifications only. Call one of the locked interface.
sha256_hex
The SHA-256 digest of a byte string, as lowercase hex.
sort_findings
Sort findings into deterministic report order by concept id, then rule id, then detail.
walk_supersession
Walk one supersession chain to its end. Call three of the locked interface.