Skip to main content

Crate choir_sequencer

Crate choir_sequencer 

Source
Expand description

Single-writer per-repo sequencer (DECISIONS.md D2): the Phase-0 spike.

One OS thread owns the op log; all workspaces submit ops through cloned handles and receive the assigned (seq, hash) synchronously. This is the in-process second implementation required by the actor-runtime seam (D3); the Rivet-backed implementation must pass the same conformance tests.

§Examples

use choir_oplog::MemLog;
use choir_sequencer::Sequencer;

let sequencer = Sequencer::spawn(Box::new(MemLog::new()));
let handle = sequencer.handle();
let accepted = handle.submit("agent-1", b"op".to_vec());
assert_eq!(accepted.seq, 0);
let log = sequencer.shutdown();
assert_eq!(log.len(), 1);

§Where this sits

docs/architecture.md is the map of the whole workspace. This crate is the single writer itself (D2): one thread per repository decides the total order.

It builds on choir_oplog.

Modules§

fairness
Per-actor admission quotas in front of the single writer.
journal
A structured, append-only decision journal: what the writer decided, why, and how long it took, one JSON object per line.
lag
Production measurement of the merge-decision latency gate.

Structs§

Accepted
The sequencer’s acknowledgement of a durably ordered op.
AdmitAll
The default policy: everything is admitted (localhost/dev shape).
Sequencer
Owns the single writer thread; the only component allowed to append to the repo’s OpLog.
SequencerHandle
Cloneable client handle; one per workspace/agent.
Submission
An operation offered to the sequencer on an attribution channel.

Traits§

SubmitPolicy
Admission policy run inside the writer thread, before an op is ordered. This is where L8 signature verification and L1 view CAS plug into L2 without the sequencer depending on either layer.