Concepts

State windows are the unit of evidence.

A latest-state table tells you what is true now. A state window tells you when a predicate was true, for which key, from which source, and with what context. Everything else in Spanfold builds on that record.

Problem

Latest state erases the shape of the incident.

If a device is healthy now, a latest-state table cannot show that it was offline earlier, which provider saw it, how long it lasted, or whether another provider missed it. That missing duration is usually the evidence needed for debugging, audit, and quality checks.

Solution

Record predicate truth as a half-open range.

A window opens when the active predicate becomes true for a key and closes when it becomes false. Think of it as [start, end): active at the start point and no longer active at the end point. That convention lets touching windows line up without overlapping by one unit.

var pipeline = Spanfold.Spanfold
    .For<DeviceSignal>()
    .RecordWindows()
    .Window("DeviceOffline", window => window
        .Key(signal => signal.DeviceId)
        .ActiveWhen(signal => !signal.IsOnline))
    .Build();

What is stored

A window carries identity, time, and context.

Window name and key

The state family and logical entity, such as DeviceOffline for device-17.

Source and partition

The lane that reported the state and the runtime partition that owns its state machine.

Temporal range

Processing positions or timestamps for the start and end of active state.

Segments and tags

Boundary context and descriptive metadata preserved for later filtering, comparison, and export.