v0.1.0 · 17 tests

Every cell has a past.

Time travel for Quilt cells. Fork, rewind, replay, merge. The killer feature that makes Quilt a database, not just a runtime.

npm install quilt-time → Try the demo
Live demo

Step through the history

budget-timeline.yaml
5 versions 2 forks
t=5 · spent = 2770

Current values (present)

budget.total5000
spent2770
remaining2230
statusok

Forks

History

t=0start: spent = 2770
t=1set rent 2200 → spent 3170
t=2set food 800 → spent 3370
t=3🌿 fork: experiment
t=4set rent 1500 (experiment)
t=5set food 600 (experiment)
The API

Five operations. One model.

at(t) — the value at any past time

Every cell has history. Ask for the value at any timestamp. The engine returns the latest version whose timestamp ≤ t.

const q = new QuiltTime(); q.set('counter', 0); q.set('counter', 1); q.set('counter', 2); q.at('counter', 1); // 0 q.at('counter', 2); // 1 q.at('counter', 3); // 2 q.get('counter'); // 2 (current)

fork() — like git branch

Snapshot the engine at a point in time. Continue with new changes. Later, rewind to the fork or merge with another fork.

const v1 = q.fork('experiment'); q.set('counter', 999); q.rewind(v1); // back to 2 q.get('counter'); // 2

diff(from, to) — what changed

Get a per-cell summary of what changed between two times. Useful for "what's different between these two reports?"

q.diff(0, 100); // { // counter: { from: 0, to: 2 }, // flag: { from: null, to: true } // }

replay() — walk forward

Iterate the events that happened after a fork, in order. Useful for "replay this user's session" or "show me everything that happened".

for (const e of q.replay(v1)) { console.log(e.cid, e.value, e.t); } // counter 500 6 // counter 600 7

merge() — combine two engines

Take two engines, merge their histories. Conflicts resolved deterministically by Lamport clock + tiebreaker. Save, share, sync.

const a = new QuiltTime(); a.set('x', 1, { t: 1 }); const b = new QuiltTime(); b.set('y', 2, { t: 1 }); const m = QuiltTime.merge(a, b); m.get('x'); // 1 m.get('y'); // 2
Use cases

What you can build

Undo without a stack

Every cell has its own undo. Just rewind the affected cell to the previous version.

"What was my balance 6 months ago?"

Just ask. The history knows.

Branching scenarios

Try a different budget. If it doesn't work out, rewind.

Real-time collaboration

Two peers, two engines, merge. No server needed.

Audit log

Every cell knows every change. Compliance is built in.

Time-travel debugging

Replay the cell graph. See what the state was at each step.

Drop it in. Five minutes.

No dependencies. No build step. Just import and go.

$ npm install quilt-time
View on GitHub → Back to Quilt