Skip to main content

Crate spanfold

Crate spanfold 

Source
Expand description

Core Rust primitives for Spanfold.

Spanfold records typed temporal state windows, compares evidence across sources and stages, and exports deterministic audit artifacts. The crate provides strongly typed builders, histories, selectors, comparison plans, liveness helpers, and testing utilities without requiring a hosted runtime.

use spanfold::for_events;

#[derive(Clone)]
struct Event { id: &'static str, active: bool }

let mut pipeline = for_events::<Event>()
    .record_windows()
    .track_window("Active", |event| event.id, |event| event.active)
    .build()?;
pipeline.ingest(Event { id: "one", active: true }, Some("source-a"), None)?;

Re-exports§

pub use export::ComparisonDebugHtmlOptions;
pub use export::ComparisonExportError;
pub use export::ComparisonLlmContextOptions;
pub use export::export_plan_json;
pub use export::export_result_debug_html;
pub use export::export_result_json;
pub use export::export_result_json_lines;
pub use export::export_result_llm_context;
pub use export::export_result_markdown;
pub use export::write_result_json_lines;
pub use pipeline::ChildActivityView;
pub use pipeline::EventPipeline;
pub use pipeline::EventPipelineBuildError;
pub use pipeline::EventPipelineBuilder;
pub use pipeline::EventPipelineMetadata;
pub use pipeline::IngestionError;
pub use pipeline::IngestionResult;
pub use pipeline::RollUpSegmentProjection;
pub use pipeline::WindowEmission;
pub use pipeline::WindowMetadata;
pub use pipeline::WindowOptions;
pub use pipeline::WindowPipelineBuilder;
pub use pipeline::WindowTransitionKind;
pub use pipeline::for_events;
pub use records::ClosedWindow;
pub use records::OpenWindow;
pub use records::SummaryError;
pub use records::WindowAnnotation;
pub use records::WindowAnnotationTarget;
pub use records::WindowBoundaryChange;
pub use records::WindowBoundaryReason;
pub use records::WindowGroupKind;
pub use records::WindowGroupSummary;
pub use records::WindowHistory;
pub use records::WindowHistoryFixture;
pub use records::WindowHistoryFixtureError;
pub use records::WindowHistoryFixtureWindow;
pub use records::WindowHistoryQuery;
pub use records::WindowHistoryRefQuery;
pub use records::WindowHistorySnapshot;
pub use records::WindowMetadataError;
pub use records::WindowOverlap;
pub use records::WindowRecord;
pub use records::WindowRecordId;
pub use records::WindowResidualSegment;
pub use records::WindowSegment;
pub use records::WindowSnapshotQuery;
pub use records::WindowSnapshotRecord;
pub use records::WindowTag;
pub use records::summarize_by_segment;
pub use records::summarize_by_tag;
pub use temporal::TemporalAxis;
pub use temporal::TemporalPoint;
pub use temporal::TemporalPointError;
pub use temporal::TemporalRange;
pub use temporal::TemporalRangeError;

Modules§

export
Portable comparison artifact encoders and atomic file sinks.
pipeline
Event-driven window pipeline and fallible ingestion API.
records
Window history, records, and query/summarization APIs.
temporal
Temporal axes, points, ranges, and domain validation.

Structs§

AlignedComparison
Aligned comparison artifact.
AlignedSegmentArtifact
Aligned segment artifact.
AsOfRow
As-of row.
CohortEvidenceMetadata
Parsed evidence for one cohort-aligned segment.
ComparatorParseError
Detailed comparator declaration parse error.
ComparatorSummary
Comparator summary.
ComparisonChangelogEntry
Deterministic changelog entry between row-finality snapshots.
ComparisonDiagnostic
Structured comparison diagnostic.
ComparisonExtensionBuilder
Builder for immutable, metadata-only comparison extension descriptors.
ComparisonExtensionComparator
Comparator descriptor exposed by a comparison extension.
ComparisonExtensionDescriptor
Immutable comparison extension descriptor.
ComparisonExtensionMetadata
Serializable metadata emitted by a comparison extension.
ComparisonExtensionSelector
Selector descriptor exposed by a comparison extension.
ComparisonNormalizationPolicy
Describes how recorded windows are normalized before comparison.
ComparisonOutputOptions
Describes output preferences for a comparison plan.
ComparisonPlan
Typed comparison plan.
ComparisonResult
Structured comparison result.
ComparisonRowFinality
Finality metadata for a materialized row.
ComparisonRowKindParseError
Error returned when a comparison row-kind label is unsupported.
ComparisonRowMetadataError
Error returned when result rows and finality metadata do not share the canonical count/kind layout.
ComparisonRowWithFinality
Borrowed association between a typed comparison row and its result metadata.
ComparisonRows
Canonical comparator row collections used for storage and serialization.
ComparisonScope
Scope used to select the windows compared by a plan.
ComparisonSelector
Describes a selection used by a window comparison plan.
ContainmentRow
Containment row.
ContractFixture
Parsed contract fixture.
CoverageRow
Coverage for one aligned target-active segment.
CoverageSummary
Aggregate coverage summary for one window name, key, and partition.
ExcludedWindowRecord
Excluded window artifact.
GapRow
Gap row.
HierarchyComparisonResult
Hierarchy comparison result.
HierarchyComparisonRow
One parent/child hierarchy segment.
LaneKey
Stable identity for one tracked source lane.
LaneLivenessSignal
A deterministic lane liveness state change.
LaneLivenessTracker
Deterministic heartbeat/silence tracker for a fixed set of lanes.
LeadLagRow
Lead/lag row.
LeadLagSummary
Summary for one lead/lag comparator declaration.
MissingRow
Missing row.
NormalizedWindowRecord
Normalized window artifact.
OverlapRow
Overlap row.
PreparedComparison
Prepared comparison artifact.
ResidualRow
Residual row.
RowPoint
Exported point for transition-based rows.
RowRange
Exported range for a row.
SourceMatrixCell
One directional source-matrix cell.
SourceMatrixResult
Directional matrix across sources.
SpanfoldAssert
Framework-neutral assertions for Spanfold comparison artifacts.
SpanfoldAssertionError
Assertion failure returned by Spanfold testing helpers.
SpanfoldSnapshot
Snapshot normalization helpers for Spanfold artifacts.
SymmetricDifferenceRow
Symmetric-difference row.
VirtualComparisonClock
Deterministic processing-position clock for comparison tests.
WindowArtifact
Portable selected/excluded/normalized window artifact.
WindowComparisonBuilder
Fluent comparison builder over an existing recorded history.
WindowFilter
Equality filter over tags or segments.

Enums§

AgainstSelection
Comparison-side selection.
AsOfDirection
As-of lookup direction.
AsOfMatchStatus
As-of lookup status.
CohortActivity
Cohort activity rule.
Comparator
Comparator family supported by the Rust implementation.
ComparisonChangeKind
Kind of state transition represented by a changelog entry.
ComparisonDuplicateWindowPolicy
Duplicate normalized-window handling policy.
ComparisonExplanationFormat
Deterministic explanation output format.
ComparisonExtensionBuildError
Error returned when an extension descriptor is incomplete or ambiguous.
ComparisonFinality
Finality state for an emitted row.
ComparisonNullTimestampPolicy
Handling for records that do not have timestamps in event-time comparisons.
ComparisonRowKind
Closed family of rows emitted by comparison results.
ComparisonSelectorError
Selector construction error.
ComparisonSide
The active side for a disagreement segment.
ContainmentStatus
Containment classification for one target-active segment.
DiagnosticSeverity
Diagnostic severity.
FixtureError
Fixture loading and validation error.
HierarchyComparisonRowKind
Hierarchy row interpretation.
LaneLivenessError
Liveness tracker construction and evaluation errors.
LeadLagDirection
Lead/lag direction.
LeadLagTransition
Transition point used for lead/lag measurement.
OpenWindowPolicy
Open-window normalization policy.
PrimitiveValue
JSON-compatible primitive value used by tags, segments, annotations, and fixture/import boundaries.
PrimitiveValueError
Error returned when a primitive value cannot be represented safely.

Functions§

align
Aligns prepared normalized windows into deterministic segments.
compare
Executes a comparison over closed windows.
compare_hierarchy
Builds a hierarchy explanation across parent and child windows.
compare_live
Executes a live comparison by clipping open windows to an evaluation horizon.
compare_sources
Builds a directional source matrix.
create_changelog
Creates a changelog between row-finality snapshots.
prepare
Prepares a comparison without running comparators.
prepare_live
Prepares a live comparison by clipping open windows to an evaluation horizon.
replay_changelog
Replays a changelog over a previous row-finality snapshot.