Skip to content
← Back

Ledgerline

An edge-native event-stream API built around idempotent appends, ordered streams, and SHA-256 tamper evidence.

Live Cloudflare WorkersDurable ObjectsD1TypeScriptHono
Ledgerline: An edge-native event-stream API built around idempotent appends, ordered streams, and SHA-256 tamper evidence.

Live Cloudflare demo, public GitHub repository, and 69 tests in the Workers runtime.

The idea

Ledgerline is a compact integrity service for event streams, audit trails, and systems that need to preserve what happened. Its focus is narrow: make an append safe to retry, keep each stream ordered, and make later verification practical.

What I built

Each stream has its own Cloudflare Durable Object. It serializes mutations, assigns monotonic sequence numbers, stores the idempotency record, links the event into the hash chain, and updates per-minute rollups in one atomic batch. D1 receives confirmed events afterward as an eventually consistent read model for pagination and queries.

Events are hashed over canonical JSON and linked to the prior hash. The verification endpoint recomputes the chain from genesis, identifies the first broken sequence, and compares the result with stored head metadata so a deleted tail is detected too. API keys are stored as hashes, ownership checks return 404 for foreign streams, and each key has its own token bucket.

The hard parts

01

Safe retries over time

An idempotency key is retained for the life of its stream. Retrying it returns the original result instead of appending another event, even long after the first request.

02

Ordering across awaits

A Durable Object is single-threaded, but asynchronous work can still create an interleaving boundary. Mutations run inside blockConcurrencyWhile so a second append cannot observe an incomplete write.

03

Detecting a deleted tail

A clean prefix can still be incomplete. Verification compares the recomputed count and head hash with persisted metadata, so truncation is reported instead of accepted as a shorter valid log.

What’s next

Add richer scenarios to the public walkthrough.