Sign in

    moonbitemporal

    Bitemporal facts, interval supersession evidence and decision review

    bitemporal
    temporal
    audit
    history
    revision
    Download zip
    Author
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    10 days ago
    Downloads
    20

    No dependencies

    #MoonBitemporal

    Pure MoonBit bitemporal revision and as-of query core. It records separate valid and knowledge times, preserves retroactive corrections, and exposes point queries, timelines, impact reports, archive exchange and a high-volume builder. See README.md for executable examples, integration boundaries and verification commands.

    #Install as a dependency

    moon add yyyt0807/moonbitemporal@0.2.0

    Import the library in the consuming package's moon.pkg:

    import { "yyyt0807/moonbitemporal" @temporal, }

    Repository owner and maintenance commit identity: yyyt0807. License: Apache-2.0.

    #0.2.0: correction evidence and historical decision review

    supersession_fragments explains prior winners over a correction's valid span, including same-value source changes. capture_decision and audit_decisions retain facts used by business operations and identify which need recomputation after a late correction. See Rust bitemporal-runtime comparison, complete scenarios, and reference provenance. Evidence is structural JSON without cryptographic signatures; database persistence and business rule execution belong to callers.

    moon run examples/decision_review --target wasm-gc moon run examples/access_review --target wasm-gc moon run examples/correction_evidence --target wasm-gc

    #十月第二轮:完整批次分页与多键联合覆盖

    Ledger::batches_since(None, max_batches~, max_revisions~) 从账本起点读取完整原子批次;传 Some(known_at) 则严格读取该游标之后的批次。结果的 next_known_at() 可继续请求,has_more() 区分结束;首批超过修订预算会报错,避免不前进的空页。空游标能包含 Int64 最小时间戳,无须做游标加一。

    joint_assigned_spans(keys, bounds, known_at, max_keys~, max_segments~) 返回全部指定键同时有值的最大有效区间;不比较值、不执行授权规则,空键集返回整个 bounds。查询键先以有界集合去重再排序,重复键不占额外唯一键预算。运行 moon run examples/maintenance --target wasm-gc。详见 功能与边界。

    TemporalError

    pub(all) suberror TemporalError {
    InvalidSpan(String)
    EmptyKey
    EmptyBatch
    KnowledgeTimeNotIncreasing(previous~ : Int64, proposed~ : Int64)
    OverlappingBatchChanges(key~ : String, first~ : Int, second~ : Int)
    TooManyRevisions(maximum~ : Int)
    TooManySegments(maximum~ : Int)
    InvalidInstant(String)
    InvalidArchive(String)
    InvalidRevisionIndex(Int)
    DuplicateArchiveKey
    UnboundedDuration
    DurationOverflow
    TooManyKeys(maximum~ : Int)
    InvalidPage(String)
    DivergentHistory(index~ : Int)
    TooManyCells(maximum~ : Int)
    InvalidDecision(String)
    TooManyDecisions(maximum~ : Int)
    }

    Errors returned before an invalid revision can enter a ledger.

    TemporalError::code

    fn TemporalError::code(self : TemporalError) -> String

    BatchPage

    pub struct BatchPage {
    batches : Array[KnowledgeBatch]
    next_known_at : Int64?
    has_more : Bool
    }

    An incremental page that never splits one atomic knowledge-time commit.

    BatchPage::batches

    fn BatchPage::batches(self : BatchPage) -> Array[KnowledgeBatch]

    BatchPage::has_more

    fn BatchPage::has_more(self : BatchPage) -> Bool

    BatchPage::next_known_at

    fn BatchPage::next_known_at(self : BatchPage) -> Int64?

    Change

    pub struct Change {
    key : String
    valid : Span
    value : String?
    }

    A value assignment or tombstone before it is committed.

    Change::delete

    fn Change::delete(key : String, valid : Span) -> Change

    Change::key

    fn Change::key(self : Change) -> String

    Change::put

    fn Change::put(key : String, valid : Span, value : String) -> Change

    Change::valid

    fn Change::valid(self : Change) -> Span

    Change::value

    fn Change::value(self : Change) -> String?

    ChangeReport

    pub struct ChangeReport {
    entries : Array[KeyChangeReport]
    keys_examined : Int
    fragments : Int
    bounds : Span
    before_known : Int64
    after_known : Int64
    }

    Bounded blast-radius report across all keys in two independent ledgers. Entries are sorted by key; a key appears only when its effective value differs on at least one valid-time fragment.

    ChangeReport::after_known

    fn ChangeReport::after_known(self : ChangeReport) -> Int64

    ChangeReport::before_known

    fn ChangeReport::before_known(self : ChangeReport) -> Int64

    ChangeReport::bounds

    fn ChangeReport::bounds(self : ChangeReport) -> Span

    ChangeReport::entries

    ChangeReport::fragment_count

    fn ChangeReport::fragment_count(self : ChangeReport) -> Int

    ChangeReport::is_empty

    fn ChangeReport::is_empty(self : ChangeReport) -> Bool

    ChangeReport::keys_changed

    fn ChangeReport::keys_changed(self : ChangeReport) -> Int

    ChangeReport::keys_examined

    fn ChangeReport::keys_examined(self : ChangeReport) -> Int

    ChangeReport::to_json

    fn ChangeReport::to_json(self : ChangeReport) -> Json

    Versioned JSON evidence for downstream dashboards or review workflows. All 64-bit instants are encoded as decimal strings so JavaScript consumers cannot silently round them. A null value denotes absence or withdrawal according to the corresponding before/after side of the change.

    ChangeReport::to_json_string

    fn ChangeReport::to_json_string(self : ChangeReport) -> String

    CommitReport

    pub struct CommitReport {
    next : Ledger
    impacts : Array[Impact]
    known_at : Int64
    appended : Int
    }

    A validated commit and its value-level impact. The original ledger remains usable, so callers may inspect the report before choosing to retain next.

    CommitReport::appended

    fn CommitReport::appended(self : CommitReport) -> Int

    CommitReport::changed_fragment_count

    fn CommitReport::changed_fragment_count(self : CommitReport) -> Int

    CommitReport::impacts

    fn CommitReport::impacts(self : CommitReport) -> Array[Impact]

    CommitReport::known_at

    fn CommitReport::known_at(self : CommitReport) -> Int64

    CommitReport::next

    fn CommitReport::next(self : CommitReport) -> Ledger

    Coverage

    pub struct Coverage {
    total : Int64
    assigned : Int64
    withdrawn : Int64
    unclaimed : Int64
    values : Array[ValueDuration]
    }

    Duration totals distinguish a never-claimed gap from an explicit deletion.

    Coverage::assigned

    fn Coverage::assigned(self : Coverage) -> Int64

    Coverage::total

    fn Coverage::total(self : Coverage) -> Int64

    Coverage::unclaimed

    fn Coverage::unclaimed(self : Coverage) -> Int64

    Coverage::values

    fn Coverage::values(self : Coverage) -> Array[ValueDuration]

    Coverage::withdrawn

    fn Coverage::withdrawn(self : Coverage) -> Int64

    DecisionAudit

    pub struct DecisionAudit {
    decision : DecisionEvidence
    review_known : Int64
    current : Revision?
    }

    Review evidence including both versions, even if neither value changed.

    DecisionAudit::current

    fn DecisionAudit::current(self : DecisionAudit) -> Revision?

    DecisionAudit::decision

    DecisionAudit::needs_recompute

    fn DecisionAudit::needs_recompute(self : DecisionAudit) -> Bool

    A gap and a withdrawal differ, despite both having no effective value.

    DecisionAudit::provenance_changed

    fn DecisionAudit::provenance_changed(self : DecisionAudit) -> Bool

    Identical values with a new winning claim still change provenance.

    DecisionAudit::review_known

    fn DecisionAudit::review_known(self : DecisionAudit) -> Int64

    DecisionAudit::to_json

    fn DecisionAudit::to_json(self : DecisionAudit) -> Json

    DecisionEvidence

    pub struct DecisionEvidence {
    id : String
    key : String
    valid_at : Int64
    known_at : Int64
    source : Revision?
    }

    A fact used by a caller's decision at two explicit instants. This captures fact evidence, not the application's full rule or computed business result.

    DecisionEvidence::id

    fn DecisionEvidence::id(self : DecisionEvidence) -> String

    DecisionEvidence::key

    fn DecisionEvidence::key(self : DecisionEvidence) -> String

    DecisionEvidence::known_at

    fn DecisionEvidence::known_at(self : DecisionEvidence) -> Int64

    DecisionEvidence::source

    DecisionEvidence::valid_at

    fn DecisionEvidence::valid_at(self : DecisionEvidence) -> Int64

    DecisionEvidence::value

    fn DecisionEvidence::value(self : DecisionEvidence) -> String?

    DecisionTrace

    pub struct DecisionTrace {
    key : String
    valid_at : Int64
    known_at : Int64
    candidates : Array[Revision]
    truncated : Bool
    }

    The applicable claim chain for a point query, newest first. The first candidate is the winner; later entries are superseded but still auditable.

    DecisionTrace::candidates

    fn DecisionTrace::candidates(self : DecisionTrace) -> Array[Revision]

    DecisionTrace::key

    fn DecisionTrace::key(self : DecisionTrace) -> String

    DecisionTrace::known_at

    fn DecisionTrace::known_at(self : DecisionTrace) -> Int64

    DecisionTrace::superseded_count

    fn DecisionTrace::superseded_count(self : DecisionTrace) -> Int

    DecisionTrace::truncated

    fn DecisionTrace::truncated(self : DecisionTrace) -> Bool

    DecisionTrace::valid_at

    fn DecisionTrace::valid_at(self : DecisionTrace) -> Int64

    DecisionTrace::value

    fn DecisionTrace::value(self : DecisionTrace) -> String?

    DecisionTrace::winner

    fn DecisionTrace::winner(self : DecisionTrace) -> Revision?

    Fact

    pub struct Fact {
    key : String
    value : String
    source : Revision
    }

    A visible keyed value in a single two-clock view.

    Fact::key

    fn Fact::key(self : Fact) -> String

    Fact::source

    fn Fact::source(self : Fact) -> Revision

    Fact::value

    fn Fact::value(self : Fact) -> String

    Impact

    pub struct Impact {
    key : String
    valid : Span
    before : String?
    after : String?
    previous_source : Revision?
    revision : Revision
    }

    A valid-time fragment whose effective value changed because of one revision.

    Impact::after

    fn Impact::after(self : Impact) -> String?

    Impact::before

    fn Impact::before(self : Impact) -> String?

    Impact::key

    fn Impact::key(self : Impact) -> String

    Impact::previous_source

    fn Impact::previous_source(self : Impact) -> Revision?

    Impact::revision

    fn Impact::revision(self : Impact) -> Revision

    Impact::valid

    fn Impact::valid(self : Impact) -> Span

    KeyChangeReport

    pub struct KeyChangeReport {
    key : String
    fragments : Array[WindowChange]
    }

    Every changed valid-time fragment for one key. Fragments are ordered by valid-time start and never overlap.

    KeyChangeReport::fragment_count

    fn KeyChangeReport::fragment_count(self : KeyChangeReport) -> Int

    KeyChangeReport::fragments

    KeyChangeReport::key

    fn KeyChangeReport::key(self : KeyChangeReport) -> String

    KeyChangeReport::to_json

    fn KeyChangeReport::to_json(self : KeyChangeReport) -> Json

    KnowledgeBatch

    pub struct KnowledgeBatch {
    known_at : Int64
    revisions : Array[Revision]
    }

    One atomic commit group from the append log. Its revisions retain their global sequence numbers and original valid spans.

    KnowledgeBatch::known_at

    fn KnowledgeBatch::known_at(self : KnowledgeBatch) -> Int64

    KnowledgeBatch::revisions

    fn KnowledgeBatch::revisions(self : KnowledgeBatch) -> Array[Revision]

    KnowledgeBatch::size

    fn KnowledgeBatch::size(self : KnowledgeBatch) -> Int

    KnowledgeSegment

    pub struct KnowledgeSegment {
    known : Span
    source : Revision?
    }

    One interval of knowledge time during which the selected valid-time value came from the same revision. source=None means no claim had yet arrived.

    KnowledgeSegment::is_unclaimed

    fn KnowledgeSegment::is_unclaimed(self : KnowledgeSegment) -> Bool

    KnowledgeSegment::is_withdrawn

    fn KnowledgeSegment::is_withdrawn(self : KnowledgeSegment) -> Bool

    KnowledgeSegment::known

    KnowledgeSegment::source

    KnowledgeSegment::value

    fn KnowledgeSegment::value(self : KnowledgeSegment) -> String?

    Ledger

    pub struct Ledger {
    revisions : Array[Revision]
    index : Map[String, Array[Int]]
    latest_time : Int64?
    maximum : Int
    }

    Immutable, append-only revision ledger. A successful commit returns a new ledger.

    Ledger::append_json

    fn Ledger::append_json(self : Ledger, value : Json) -> Ledger raise TemporalError

    Parse a validated archive tail and append it to the receiver.

    Ledger::append_json_string

    fn Ledger::append_json_string(self : Ledger, text : String, max_chars? : Int) -> Ledger raise TemporalError

    Ledger::append_ledger

    fn Ledger::append_ledger(self : Ledger, incoming : Ledger) -> Ledger raise TemporalError

    Replay every batch from another validated ledger after the receiver's last knowledge time. This is useful for a transport adapter carrying archive tails. Failure leaves the original immutable ledger untouched.

    Ledger::as_known_at

    fn Ledger::as_known_at(self : Ledger, cutoff : Int64) -> Ledger

    Materialize the ledger prefix known at or before a chosen instant. The resulting ledger can be archived independently, preserving earlier views.

    Ledger::audit_decisions

    fn Ledger::audit_decisions(self : Ledger, decisions : Array[DecisionEvidence], review_known : Int64, max_decisions? : Int) -> Array[DecisionAudit] raise TemporalError

    Preserve request order, require unique decision IDs and reject evidence whose original winning claim disagrees with this ledger. Review cannot precede capture. This checks queried claims, not the entire archive lineage.

    Ledger::batch_at

    fn Ledger::batch_at(self : Ledger, known_at : Int64) -> KnowledgeBatch?

    Locate an exact knowledge-time commit by binary search. This lets event adapters replay or inspect a batch without scanning every historical key.

    Ledger::batches_since

    fn Ledger::batches_since(self : Ledger, known_after : Int64?, max_batches? : Int, max_revisions? : Int) -> BatchPage raise TemporalError

    Return whole batches strictly after Some(cursor), or from the beginning with None (including the minimum Int64 time). A first batch exceeding max_revisions is an error, rather than a non-progressing empty page.

    Ledger::capture_decision

    fn Ledger::capture_decision(self : Ledger, id : String, key : String, valid_at : Int64, known_at : Int64) -> DecisionEvidence raise TemporalError

    Ledger::change_report

    fn Ledger::change_report(self : Ledger, bounds : Span, before_known : Int64, after_known : Int64, max_keys? : Int, max_fragments? : Int) -> ChangeReport raise TemporalError

    Run the same blast-radius comparison against two knowledge-time views of a single append-only ledger.

    Ledger::commit

    fn Ledger::commit(self : Ledger, known_at : Int64, changes : Array[Change]) -> Ledger raise TemporalError

    Validate the entire batch before appending any revision.

    Ledger::commit_with_report

    fn Ledger::commit_with_report(self : Ledger, known_at : Int64, changes : Array[Change], max_impacts? : Int) -> CommitReport raise TemporalError

    Prepare an atomic batch and report exactly which value fragments would change. Retain report.next() to accept it, or discard it to dry-run.

    Ledger::contains_key

    fn Ledger::contains_key(self : Ledger, key : String, valid_at : Int64, known_at : Int64) -> Bool

    Ledger::coverage

    fn Ledger::coverage(self : Ledger, key : String, bounds : Span, known_at : Int64, max_segments? : Int) -> Coverage raise TemporalError

    Aggregate the amount of valid time assigned to each value. Instants are abstract units; the caller decides whether one unit means a day, second or another scale. No floating-point arithmetic or calendar rules are used.

    Ledger::diff_knowledge

    fn Ledger::diff_knowledge(self : Ledger, valid_at : Int64, before_at : Int64, after_at : Int64) -> Array[ValueChange]

    Compare what was believed at two knowledge times for one valid instant.

    Ledger::diff_timeline

    fn Ledger::diff_timeline(self : Ledger, key : String, bounds : Span, before_known : Int64, after_known : Int64, max_segments? : Int) -> Array[WindowChange] raise TemporalError

    Compare two complete valid-time timelines with a linear two-pointer merge. Unchanged fragments are omitted; adjacent equal changes are coalesced.

    Ledger::diff_valid

    fn Ledger::diff_valid(self : Ledger, before_at : Int64, after_at : Int64, known_at : Int64) -> Array[ValueChange]

    Compare two valid instants according to one knowledge-time view.

    Ledger::first_divergence

    fn Ledger::first_divergence(self : Ledger, other : Ledger) -> Int?

    Return the first divergent position if the archives disagree, or None when either archive is a prefix of the other.

    Ledger::from_json

    fn Ledger::from_json(value : Json, maximum? : Int) -> Ledger raise TemporalError

    Import a schema-v1 archive by replaying validated atomic batches.

    Ledger::from_json_string

    fn Ledger::from_json_string(text : String, maximum? : Int, max_chars? : Int) -> Ledger raise TemporalError

    Parse a bounded JSON archive before replaying its revisions.

    Ledger::get

    fn Ledger::get(self : Ledger, key : String, valid_at : Int64, known_at : Int64) -> String?

    Return the effective value; both an absent claim and a tombstone yield None.

    Ledger::history

    fn Ledger::history(self : Ledger, key : String) -> Array[Revision]

    All historical claims about one key, in append order.

    Ledger::history_count

    fn Ledger::history_count(self : Ledger, key : String) -> Int

    The number of revisions about a key, independent of current visibility.

    Ledger::history_page

    fn Ledger::history_page(self : Ledger, key : String, offset : Int, max_items : Int) -> RevisionPage raise TemporalError

    Page through revisions for one key. Offsets are positions in that key's history, while each returned revision retains its global sequence number.

    Ledger::impact_of_revision

    fn Ledger::impact_of_revision(self : Ledger, index : Int, max_segments? : Int) -> Array[Impact] raise TemporalError

    Partition one revision's declared valid span by prior claims and report only fragments where the effective value changed. The current ledger may contain later revisions; they do not affect this historical impact calculation.

    Ledger::is_prefix_of

    fn Ledger::is_prefix_of(self : Ledger, other : Ledger) -> Bool

    Whether this ledger's entire sequence is an exact prefix of other.

    Ledger::joint_assigned_spans

    fn Ledger::joint_assigned_spans(self : Ledger, keys : Array[String], bounds : Span, known_at : Int64, max_keys? : Int, max_segments? : Int) -> Array[Span] raise TemporalError

    Maximal valid spans on which every selected key has an assigned value. Empty selection is the whole bounds. This does not compare the values.

    Ledger::keys

    fn Ledger::keys(self : Ledger) -> Array[String]

    Every distinct key in deterministic lexical order, including deleted keys.

    Ledger::knowledge_timeline

    fn Ledger::knowledge_timeline(self : Ledger, key : String, valid_at : Int64, bounds : Span, max_segments? : Int) -> Array[KnowledgeSegment] raise TemporalError

    Show how the application's belief about one valid instant evolved over a knowledge-time window. This is the dual of Ledger::timeline.

    Ledger::latest_time

    fn Ledger::latest_time(self : Ledger) -> Int64?

    Ledger::matching_spans

    fn Ledger::matching_spans(self : Ledger, key : String, bounds : Span, known_at : Int64, filter : SpanFilter, max_segments? : Int) -> Array[Span] raise TemporalError

    Return maximal spans matching a semantic state, merging adjacent matching segments even if their winning revision identities differ.

    Ledger::new

    fn Ledger::new(maximum? : Int) -> Ledger raise TemporalError

    Ledger::observe

    fn Ledger::observe(self : Ledger, key : String, valid_at : Int64, known_at : Int64) -> Revision?

    The winning claim at both selected instants, including a tombstone if present.

    Ledger::page

    fn Ledger::page(self : Ledger, offset : Int, max_items : Int) -> RevisionPage raise TemporalError

    Page through the full append log without copying unrelated revisions.

    Ledger::reconcile

    fn Ledger::reconcile(self : Ledger, remote : Ledger) -> Ledger raise TemporalError

    Reconcile a full remote archive with local state. If one log is an exact prefix of the other, return the longer log as a detached local ledger. Divergent shared history is rejected at the first differing sequence. This operation provides content consistency, not cryptographic integrity; transport authentication and durable transaction ordering belong to callers.

    Ledger::revision

    fn Ledger::revision(self : Ledger, index : Int) -> Revision?

    Ledger::revision_count

    fn Ledger::revision_count(self : Ledger) -> Int

    Ledger::sample_matrix

    fn Ledger::sample_matrix(self : Ledger, key : String, valid_samples : Array[Int64], knowledge_samples : Array[Int64], max_cells? : Int) -> TemporalMatrix raise TemporalError

    Sample the two-clock surface of one key with explicit resource bounds. This is useful for audit tables, visualizations and differential testing; use timeline for complete unsampled interval coverage.

    Ledger::select_keys

    fn Ledger::select_keys(self : Ledger, keys : Array[String]) -> Ledger

    Materialize only requested keys. Sequence numbers are renumbered in the projection; knowledge instants and valid spans retain their original values.

    Ledger::snapshot

    fn Ledger::snapshot(self : Ledger, valid_at : Int64, known_at : Int64) -> Array[Fact]

    Visible values at one valid and knowledge instant, sorted by key.

    Ledger::snapshot_selected

    fn Ledger::snapshot_selected(self : Ledger, keys : Array[String], valid_at : Int64, known_at : Int64, max_keys? : Int) -> Array[Fact] raise TemporalError

    Return only the requested keys from a two-clock snapshot. Duplicate keys are removed, results are in lexical order, and the key budget is checked before any point queries. Useful when an API response needs a small field set from a ledger containing many unrelated keys.

    Ledger::snapshot_timeline

    fn Ledger::snapshot_timeline(self : Ledger, keys : Array[String], bounds : Span, known_at : Int64, max_keys? : Int, max_segments? : Int) -> Array[SnapshotSegment] raise TemporalError

    Reconstruct simultaneous facts for a bounded set of keys across a valid window. Boundaries are emitted whenever any requested key's source changes.

    Ledger::stats

    fn Ledger::stats(self : Ledger) -> LedgerStats

    Scan the append log once for statistics useful to storage adapters.

    Ledger::supersession_fragments

    fn Ledger::supersession_fragments(self : Ledger, index : Int, max_fragments? : Int) -> Array[SupersessionFragment] raise TemporalError

    Partition a revision's whole valid span by the prior winners. Gaps, withdrawals and same-value reassertions are included. Later revisions do not alter this historical receipt. Sequence IDs are local to this archive.

    Ledger::timeline

    fn Ledger::timeline(self : Ledger, key : String, bounds : Span, known_at : Int64, max_segments? : Int) -> Array[Segment] raise TemporalError

    Reconstruct every winner across a bounded valid-time window. The output also includes never-assigned gaps and explicit tombstones.

    Ledger::to_json

    fn Ledger::to_json(self : Ledger) -> Json

    Export versioned data using decimal strings for all Int64 instants.

    Ledger::to_json_since

    fn Ledger::to_json_since(self : Ledger, cutoff : Int64) -> Json

    Export only revisions accepted strictly after cutoff. The receiver must already contain all earlier revisions or understand it is receiving a tail.

    Ledger::to_json_string

    fn Ledger::to_json_string(self : Ledger) -> String

    Ledger::trace

    fn Ledger::trace(self : Ledger, key : String, valid_at : Int64, known_at : Int64, max_candidates? : Int) -> DecisionTrace raise TemporalError

    Explain precedence for one point without exposing unrelated keys or valid intervals. The limit caps returned claims but never discards the winner.

    Ledger::visible_count

    fn Ledger::visible_count(self : Ledger, valid_at : Int64, known_at : Int64) -> Int

    Number of visible keyed facts at a two-clock point.

    LedgerBuilder

    pub struct LedgerBuilder {
    revisions : Array[Revision]
    index : Map[String, Array[Int]]
    latest_time : Int64?
    maximum : Int
    batches : Int
    }

    Efficient mutable ingest path for applications that accept many batches. Ledger::commit is convenient for small immutable histories but copies the previous log and rebuilds its index on every call. Builder appends in place and makes an isolated immutable snapshot only when freeze is requested.

    LedgerBuilder::append

    fn LedgerBuilder::append(self : LedgerBuilder, known_at : Int64, changes : Array[Change]) -> Unit raise TemporalError

    Validate all changes before modifying either the log or the per-key index. On rejection, the builder retains its prior state.

    LedgerBuilder::batch_count

    fn LedgerBuilder::batch_count(self : LedgerBuilder) -> Int

    LedgerBuilder::freeze

    fn LedgerBuilder::freeze(self : LedgerBuilder) -> Ledger

    Return a detached immutable checkpoint. Keeping this value while appending further batches to the builder is safe.

    LedgerBuilder::from_ledger

    fn LedgerBuilder::from_ledger(source : Ledger) -> LedgerBuilder

    Continue ingesting after an immutable checkpoint. Arrays are copied so subsequent builder appends cannot mutate the supplied ledger.

    LedgerBuilder::get

    fn LedgerBuilder::get(self : LedgerBuilder, key : String, valid_at : Int64, known_at : Int64) -> String?

    LedgerBuilder::latest_time

    fn LedgerBuilder::latest_time(self : LedgerBuilder) -> Int64?

    LedgerBuilder::new

    fn LedgerBuilder::new(maximum? : Int) -> LedgerBuilder raise TemporalError

    LedgerBuilder::observe

    fn LedgerBuilder::observe(self : LedgerBuilder, key : String, valid_at : Int64, known_at : Int64) -> Revision?

    Query the current builder without allocating a full ledger checkpoint.

    LedgerBuilder::remaining_capacity

    fn LedgerBuilder::remaining_capacity(self : LedgerBuilder) -> Int

    LedgerBuilder::revision_count

    fn LedgerBuilder::revision_count(self : LedgerBuilder) -> Int

    LedgerStats

    pub struct LedgerStats {
    revisions : Int
    keys : Int
    batches : Int
    tombstones : Int
    open_valid_spans : Int
    most_revised_key : String?
    most_revisions_for_key : Int
    first_knowledge_time : Int64?
    latest_knowledge_time : Int64?
    }

    Aggregate operational metadata. Values and keys are not included except for the most revised key, so callers can log counts separately from data.

    LedgerStats::batches

    fn LedgerStats::batches(self : LedgerStats) -> Int

    LedgerStats::first_knowledge_time

    fn LedgerStats::first_knowledge_time(self : LedgerStats) -> Int64?

    LedgerStats::keys

    fn LedgerStats::keys(self : LedgerStats) -> Int

    LedgerStats::latest_knowledge_time

    fn LedgerStats::latest_knowledge_time(self : LedgerStats) -> Int64?

    LedgerStats::most_revised_key

    fn LedgerStats::most_revised_key(self : LedgerStats) -> String?

    LedgerStats::most_revisions_for_key

    fn LedgerStats::most_revisions_for_key(self : LedgerStats) -> Int

    LedgerStats::open_valid_spans

    fn LedgerStats::open_valid_spans(self : LedgerStats) -> Int

    LedgerStats::revisions

    fn LedgerStats::revisions(self : LedgerStats) -> Int

    LedgerStats::tombstones

    fn LedgerStats::tombstones(self : LedgerStats) -> Int

    MatrixCell

    pub struct MatrixCell {
    valid_at : Int64
    known_at : Int64
    source : Revision?
    }

    One cell in a sampled valid-time × knowledge-time matrix. A missing source means no claim was known; a source with value=None is a withdrawal.

    MatrixCell::is_unclaimed

    fn MatrixCell::is_unclaimed(self : MatrixCell) -> Bool

    MatrixCell::is_withdrawn

    fn MatrixCell::is_withdrawn(self : MatrixCell) -> Bool

    MatrixCell::known_at

    fn MatrixCell::known_at(self : MatrixCell) -> Int64

    MatrixCell::source

    fn MatrixCell::source(self : MatrixCell) -> Revision?

    MatrixCell::to_json

    fn MatrixCell::to_json(self : MatrixCell) -> Json

    MatrixCell::valid_at

    fn MatrixCell::valid_at(self : MatrixCell) -> Int64

    MatrixCell::value

    fn MatrixCell::value(self : MatrixCell) -> String?

    Revision

    pub struct Revision {
    key : String
    valid : Span
    known_at : Int64
    value : String?
    sequence : Int
    }

    A committed claim. Sequence is a stable, zero-based append position.

    Revision::key

    fn Revision::key(self : Revision) -> String

    Revision::known_at

    fn Revision::known_at(self : Revision) -> Int64

    Revision::sequence

    fn Revision::sequence(self : Revision) -> Int

    Revision::valid

    fn Revision::valid(self : Revision) -> Span

    Revision::value

    fn Revision::value(self : Revision) -> String?

    RevisionPage

    pub struct RevisionPage {
    items : Array[Revision]
    offset : Int
    total : Int
    next_offset : Int?
    }

    One bounded page of immutable revisions. next_offset is the offset to request next, or None when this page reaches the end of the sequence.

    RevisionPage::is_empty

    fn RevisionPage::is_empty(self : RevisionPage) -> Bool

    RevisionPage::items

    fn RevisionPage::items(self : RevisionPage) -> Array[Revision]

    RevisionPage::next_offset

    fn RevisionPage::next_offset(self : RevisionPage) -> Int?

    RevisionPage::offset

    fn RevisionPage::offset(self : RevisionPage) -> Int

    RevisionPage::total

    fn RevisionPage::total(self : RevisionPage) -> Int

    Segment

    pub struct Segment {
    valid : Span
    source : Revision?
    }

    One maximal interval on which the winning revision is constant.

    Segment::is_deleted

    fn Segment::is_deleted(self : Segment) -> Bool

    Segment::is_gap

    fn Segment::is_gap(self : Segment) -> Bool

    Segment::source

    fn Segment::source(self : Segment) -> Revision?

    Segment::valid

    fn Segment::valid(self : Segment) -> Span

    Segment::value

    fn Segment::value(self : Segment) -> String?

    SnapshotSegment

    pub struct SnapshotSegment {
    valid : Span
    facts : Array[Fact]
    }

    One valid-time slice with the visible facts for the requested key set.

    SnapshotSegment::facts

    SnapshotSegment::valid

    fn SnapshotSegment::valid(self : SnapshotSegment) -> Span

    SnapshotSegment::value

    fn SnapshotSegment::value(self : SnapshotSegment, key : String) -> String?

    Span

    pub struct Span {
    start : Int64
    end : Int64?
    }

    Half-open valid-time span. None means an unbounded right endpoint.

    Span::coalesce

    fn Span::coalesce(self : Span, other : Span) -> Span?

    Merge overlapping or adjacent spans; return None for disjoint spans.

    Span::contains

    fn Span::contains(self : Span, instant : Int64) -> Bool

    Span::covers

    fn Span::covers(self : Span, other : Span) -> Bool

    Span::end

    fn Span::end(self : Span) -> Int64?

    Span::intersection

    fn Span::intersection(self : Span, other : Span) -> Span?

    Span::new

    fn Span::new(start : Int64, end : Int64) -> Span raise TemporalError

    Span::open

    fn Span::open(start : Int64) -> Span

    Span::overlaps

    fn Span::overlaps(self : Span, other : Span) -> Bool

    Span::start

    fn Span::start(self : Span) -> Int64

    Span::subtract

    fn Span::subtract(self : Span, other : Span) -> Array[Span]

    Difference of two spans, ordered by starting time.

    Span::touches

    fn Span::touches(self : Span, other : Span) -> Bool

    Whether two spans share a boundary but no interior.

    SpanFilter

    pub(all) enum SpanFilter {
    Assigned
    Equals(String)
    Withdrawn
    Unclaimed
    }

    Select a semantic state from a two-clock valid-time timeline.

    SupersessionFragment

    pub struct SupersessionFragment {
    valid : Span
    previous : Revision?
    replacement : Revision
    }

    One interval covered by a new revision, retaining the immediately prior winning claim even when its value is identical. Not a cryptographic receipt.

    SupersessionFragment::previous

    SupersessionFragment::replacement

    SupersessionFragment::to_json

    Complete claim content accompanies the local sequence references; callers may authenticate this deterministic JSON externally. No digest is supplied.

    SupersessionFragment::valid

    SupersessionFragment::value_changed

    fn SupersessionFragment::value_changed(self : SupersessionFragment) -> Bool

    TemporalMatrix

    pub struct TemporalMatrix {
    key : String
    valid_samples : Array[Int64]
    knowledge_samples : Array[Int64]
    cells : Array[MatrixCell]
    }

    Row-major sample grid: rows follow caller-provided valid instants, columns follow caller-provided knowledge instants. Input order and duplicates are intentionally preserved for direct alignment with external data tables.

    TemporalMatrix::cell

    fn TemporalMatrix::cell(self : TemporalMatrix, row : Int, column : Int) -> MatrixCell?

    TemporalMatrix::cell_count

    fn TemporalMatrix::cell_count(self : TemporalMatrix) -> Int

    TemporalMatrix::changed_rows

    fn TemporalMatrix::changed_rows(self : TemporalMatrix, before_column : Int, after_column : Int) -> Int

    Count sampled valid instants whose value differs between two knowledge columns. Duplicate valid samples count separately because input positions represent rows supplied by the caller.

    TemporalMatrix::column

    fn TemporalMatrix::column(self : TemporalMatrix, index : Int) -> Array[MatrixCell]

    TemporalMatrix::columns

    fn TemporalMatrix::columns(self : TemporalMatrix) -> Int

    TemporalMatrix::key

    fn TemporalMatrix::key(self : TemporalMatrix) -> String

    TemporalMatrix::knowledge_samples

    fn TemporalMatrix::knowledge_samples(self : TemporalMatrix) -> Array[Int64]

    TemporalMatrix::row

    fn TemporalMatrix::row(self : TemporalMatrix, index : Int) -> Array[MatrixCell]

    TemporalMatrix::rows

    fn TemporalMatrix::rows(self : TemporalMatrix) -> Int

    TemporalMatrix::to_json

    fn TemporalMatrix::to_json(self : TemporalMatrix) -> Json

    Export a sampled matrix in the same row-major order as cell access.

    TemporalMatrix::to_json_string

    fn TemporalMatrix::to_json_string(self : TemporalMatrix) -> String

    TemporalMatrix::valid_samples

    fn TemporalMatrix::valid_samples(self : TemporalMatrix) -> Array[Int64]

    ValueChange

    pub struct ValueChange {
    key : String
    before : String?
    after : String?
    before_source : Revision?
    after_source : Revision?
    }

    Value-level change between two chosen views of the same set of keys.

    ValueChange::after

    fn ValueChange::after(self : ValueChange) -> String?

    ValueChange::after_source

    fn ValueChange::after_source(self : ValueChange) -> Revision?

    ValueChange::before

    fn ValueChange::before(self : ValueChange) -> String?

    ValueChange::before_source

    fn ValueChange::before_source(self : ValueChange) -> Revision?

    ValueChange::key

    fn ValueChange::key(self : ValueChange) -> String

    ValueDuration

    pub struct ValueDuration {
    value : String
    duration : Int64
    }

    Duration for one distinct assigned value inside a finite query window.

    ValueDuration::duration

    fn ValueDuration::duration(self : ValueDuration) -> Int64

    ValueDuration::value

    fn ValueDuration::value(self : ValueDuration) -> String

    WindowChange

    pub struct WindowChange {
    valid : Span
    before : String?
    after : String?
    }

    A maximal valid-time fragment whose effective value changed between two knowledge-time views.

    WindowChange::after

    fn WindowChange::after(self : WindowChange) -> String?

    WindowChange::before

    fn WindowChange::before(self : WindowChange) -> String?

    WindowChange::to_json

    fn WindowChange::to_json(self : WindowChange) -> Json

    WindowChange::valid

    fn WindowChange::valid(self : WindowChange) -> Span

    compare_all_keys

    fn compare_all_keys(before : Ledger, after : Ledger, bounds : Span, before_known : Int64, after_known : Int64, max_keys? : Int, max_fragments? : Int) -> ChangeReport raise TemporalError

    Compare effective values across every key and a bounded valid-time window. Limits are checked before unbounded reports can be returned; callers should split large domains by key or valid-time range when a limit is reached.

    compare_ledgers

    fn compare_ledgers(before_ledger : Ledger, after_ledger : Ledger, key : String, bounds : Span, before_known : Int64, after_known : Int64, max_segments? : Int) -> Array[WindowChange] raise TemporalError

    Compare independent ledgers, such as a deployed archive and a candidate archive, without assuming they share a common append history.

    format_instant

    fn format_instant(value : Int64) -> String

    gaps

    fn gaps(input : Array[Span], bounds : Span) -> Array[Span]

    The portions of bounds not covered by any input span.

    normalize_spans

    fn normalize_spans(input : Array[Span], bounds : Span) -> Array[Span]

    Clip an ordered collection against a bounding span and merge the result.

    parse_instant

    fn parse_instant(text : String) -> Int64 raise TemporalError

    Parse a canonical signed 64-bit decimal instant without floating-point loss.