Repository navigation
Description
Context
ConsensusEngine in internal/distributed/consensus.go stores the Raft log as a bare []*LogEntry slice. This makes it impossible to swap in a persistent backing store without touching the consensus engine directly, which precludes the bbolt WAL planned for v0.13.0.
What to implement
Create internal/distributed/log/interface.go with a ConsensusLog interface:
type ConsensusLog interface {
Append(entry *LogEntry) error
Get(index uint64) (*LogEntry, error)
Slice(lo, hi uint64) ([]*LogEntry, error)
LastIndex() uint64
LastTerm() uint64
TruncateSuffix(fromIndex uint64) error
TruncatePrefix(upToIndex uint64) error // needed for log compaction (v0.13.0)
}Interface doc comment must explicitly note it is designed to accept a bbolt or etcd-raft backing store as a future drop-in.
Create internal/distributed/log/memory.go with MemoryLog implementing the interface (wraps the existing []*LogEntry logic).
Replace the ce.log []*LogEntry field in ConsensusEngine with ce.log ConsensusLog. Inject via NewConsensusEngine, defaulting to log.NewMemoryLog(). Update all index arithmetic (getLastLogIndex, getLastLogTerm, becomeLeader, handleNetworkAppendEntries, sendAppendEntries) to go through interface methods.
Acceptance criteria
ConsensusLoginterface exists with documented design intentMemoryLogpasses table-driven unit tests covering: Append, Get, Slice, TruncateSuffix, TruncatePrefix, LastIndex/LastTerm- All existing consensus tests pass with
-race:go test -race ./internal/distributed/... - No behavior changes — this is a pure refactor
Sequencing
Must land before A1-3 (PersistentState uses the same log package) and A2-1 (FUSE wiring requires stable interfaces).
Activity
scttfrdmn commentedon Aug 3, 2026
Closing as not-the-direction, per the decision on #169.
The evaluation in
docs/design/conditional-writes-vs-raft.mdrecommends per-key S3 conditional writes (CAS) over a replicated log, and that recommendation has been adopted. §1 of the doc is the reason this specific issue goes: there is nothing to replicate. S3 is the sole source of truth, every node reaches it, and no node holds authoritative state that a log would be recovering. AConsensusLogwould order entries that nothing appends —applyLogEntry(consensus.go) is three empty comment arms today, and nothing appendsEntryTypeOperationat all.What replaces it: per-key compare-and-swap for coordination, gossip for membership. See the four issues opened under §5, in particular the
Backend.PutObjectIfwork.Not closing because the issue is badly specified — it isn't. Closing because the layer it belongs to is not being built.
Reference: https://github.com/scttfrdmn/objectfs/blob/main/docs/design/conditional-writes-vs-raft.md
docs: record the CAS decision where the code claims otherwise (#286)
docs: the Raft closure list is five, not four (#287)