Backfold

A late correction.
A revised estimate.

Feed timestamped observations into Backfold. Correct or withdraw an old value, then query the updated statistics. Fork the stream to keep both histories.

One correction MomentsStream
TimeObservedFork
1044
20407
301010
Mean18.07.0
Edit the sensor stream Loading backfold_wasm.wasm...
Last measured operation
--
20,000-tick FoldTree<KalmanFilter2D, 4>
Exact Marginal log p(y)
--
O(1) at root · Anchor-Centered
Estimated changepoint
--
Cached-subtree scan + exact logBF
Smoothed State @ Query t
--
Click chart to edit / Shift+Click to retract
Raw obs (20,000 ticks) Kalman Filtered Exact O(log T) RTS Smoother (±2σ) Localized Bayesian Changepoint

Running real compiled Rust backfold-core (backfold_wasm.wasm, zero backend server). Click anywhere on the top plot to inject a late-arriving sensor reading; Shift+Click to retract that tick into a missing-observation transition step.

Use Backfold in your stack

Python library
python -m pip install backfold

Add timestamped observations in the event consumer, then query the revised statistics. Run the Python example.

Native MCP server for local CSV files

Build the CLI, place it on your PATH and use this client configuration.

{
  "mcpServers": {
    "backfold": {
      "command": "backfold",
      "args": ["mcp"]
    }
  }
}

Built-in MCP tools (sub-1 MB native binary, zero Python/Node runtime required): backfold_digest_csv, backfold_drill_csv, backfold_kalman_rts_csv (with automatic changepoint shock localization), backfold_covariance_pca_csv, and backfold_ebh_sift_csv.

Verified Live Benchmarks (v0.3.0, max |diff| ≤ 1e-12 vs. Sequential Oracles)

Operator (T = 100,000 late edit)backfold PyEcosystem BaselinePython SpeedupRust vs -O3 Seq Rust
2D Kalman RTS Smooth + log p(y)11.12 µs6,437,010 µs (NumPy RTS)578,868×760× (3,694× @500k)
2D Constant-Velocity Kalman8.82 µs4,563,614 µs (NumPy seq)517,710×760× (3,538× @500k)
Page CUSUM + O(log T) 1st Alarm3.83 µs137,450 µs (Py seq)35,897×454× (2,177× @500k)
CT Irregular-Δt EWMA3.92 µs4,832 µs Pandas / 1,941 µs NumPy1,231× / 495×1,736× (8,152× @500k)
1D Random-Walk Kalman———1,338× (6,185× @500k)
8D Compensated Covariance & PCA15.60 µs5,589 µs (NumPy cov)358×262× (5.68 µs @100k)
8D Discounted Ridge (delayed label)16.95 µs5,921 µs SciPy / 103,981 µs River@10k349× / 7,092×659× (6.11 µs @100k)
106-bit Compensated Moments6.06 µs1,293 µs Pandas / 730 µs NumPy / 273 µs Polars213× / 121× / 45×259× (1,288× @500k)
Arbitrary 60% Range Query (Moments)8.57 µs35.54 µs (NumPy slice)4.1×154× (664× @500k)

Honest Crossover

For strictly append-only, single-pass, in-order aggregation with zero retractions, zero late arrivals, zero range queries, and zero branching, a plain sequential loop wins on initial ingest. On MomentsMonoid, bulk tree build (9.99 ms @ 100k, 51.07 ms @ 500k) breaks even against a single-pass -O3 Rust loop after 31–33 late edits or range queries.