Repository navigation
Description
Context
types.DistributedCoordinator (pkg/types/interfaces.go) has only ExecuteOperation(ctx, op any) (any, error) and GetStats(). That is enough to run one operation on one node and nothing else: there is no way for a node to tell peers it holds a key, to ask which peers hold one, or to tell them a key is stale. The v0.13.0 cache-warming chain (#140, #141, #142, #143) needs all three, and every one of those issues is blocked on the interface rather than on its own logic.
Body revised 2026-08-08 after #284 landed. Two items in the original are gone, and the two comments below are the record of why. Read them if the change of premise matters; the section following is what to build.
What to implement
Extend pkg/types/interfaces.go:
type DistributedCoordinator interface {
ExecuteOperation(ctx context.Context, op any) (any, error)
GetStats() map[string]any
// Cache coordination
AnnounceKey(ctx context.Context, ann KeyAnnouncement) error
QueryKeyOwnership(ctx context.Context, key string) ([]KeyAnnouncement, error)
InvalidateKey(ctx context.Context, key, etag string) error
}Add to pkg/types:
type KeyAnnouncement struct {
Key string `json:"key"`
NodeID string `json:"node_id"`
ETag string `json:"etag"`
Size int64 `json:"size"`
CachedAt time.Time `json:"cached_at"`
Offset int64 `json:"offset"`
Length int64 `json:"length"` // 0 = full object
}JSON tags rather than bare fields: this crosses the gossip wire, where every neighboring field is snake_case. types.Precondition shipped without tags and had to be fixed in #284 before release; do not repeat it.
Update coordinatorWrapper in internal/distributed/cluster.go to satisfy the widened interface, and add var _ types.DistributedCoordinator = (*coordinatorWrapper)(nil).
ConsistencyLevel is not promoted — it is deleted
The original body proposed moving ConsistencyLevel and its three constants into pkg/types, and adding NegotiateConsistency. Do not. #284 deleted the type. All three levels issued the same unconditional PutObject and differed only in how many nodes issued it, so an agreement between two nodes on a level selected the same request from both — there was nothing to negotiate. What replaced it is per-operation and evaluated by the store: DistributedOperation.Precondition, a types.Precondition. A level enum beside that field would be a second encoding of Precondition.IsZero().
The original acceptance criterion "ConsistencyLevel defined in exactly one place" is therefore satisfied by zero places, and #144 (implement NegotiateConsistency) is closed as not planned.
InvalidateKey takes an ETag
Not InvalidateKey(ctx, key). Gossip is unordered and retransmits, so a receiver handed a bare key cannot tell an invalidation for a version it has already moved past from one for the version it holds. This is requirement R4 of docs/design/conditional-writes-vs-raft.md §1.
CacheInvalidateMessage already carries ETag and Deleted, and GossipProtocol.markInvalidationApplied already keeps a bounded set of applied (key, ETag) pairs — #284 built the receiving half. This issue is the interface those messages travel under, so the signature has to admit the version or the plumbing stops at the interface boundary.
Empty ETag stays legal and means "the caller cannot name a version" — a delete, or an unconditional put whose ETag was not read back. Such an invalidation is applied by every receiver every time, which is safe and merely wasteful.
Stubs return ErrNotSupported, never nil
The original said "stub implementations returning nil/empty are acceptable." Tighten that: a stub that returns nil reports success for work it did not do. #284 deleted a CacheReplicator that added bytes to BytesReplicated when gossip was not running and had never sent anything, and the test that let it survive four releases asserted only that its field was non-nil. AnnounceKey and QueryKeyOwnership have no implementation until #140, so they return types.ErrNotSupported and a caller finds out.
InvalidateKey is not a stub — ClusterManager.InvalidateCacheKey(key, etag) already exists and broadcasts, so wire it through.
Acceptance criteria
KeyAnnouncementdefined inpkg/typeswith JSON tags, and a test pinning the wire namesDistributedCoordinatorcarries the three cache-coordination methodscoordinatorWrappersatisfies it, with the compile-time assertion incluster.goAnnounceKeyandQueryKeyOwnershipreturntypes.ErrNotSupported, asserted witherrors.Is— not asserted to be non-nil, which is the mistake that hidCacheReplicatorInvalidateKeybroadcasts aCacheInvalidateMessagewhoseETagis the one passed in, asserted by receiving it rather than by inspecting the callConsistencyLevelis not reintroduced anywherego build ./...,make lint, andmake testpass
Sequencing
Blocks #140 (AnnounceKey/QueryKeyOwnership implementations) and #142 (cache-warming read). #141 needs InvalidateKey on the write path.
Activity
scttfrdmn commentedon Aug 3, 2026
Heads-up from the CAS decision on #169: part of this issue is now wrong, and the rest survives.
The Raft build-out (#128, #130, #133, #151) is closed as not-the-direction; per-key S3 conditional
writes replace it. That has one specific consequence here.
Drop or revise: this issue proposes promoting
ConsistencyLeveland its three constants frominternal/distributed/coordinator.gointopkg/types:NegotiateConsistencygoes with it. #284 will delete or redefine that taxonomy, so promoting it intothe public types package would be moving a construct into a wider blast radius on its way out. Two
reasons it is going:
ConsistencyStrongis mislabeled.executeStrongConsistencyfans the same PUT with the samebytes to N nodes and calls a majority "strong" — that is a reachability signal, not a consistency
guarantee.
ConsistencySessionandConsistencyEventualare nearly the same function on today's code:both execute on
targetNodes[0]thenreplicateAsyncthe remainder. Session's onlydistinguishing feature is a comment saying it will "try to use the same node for related
operations," and there is no session state anywhere to make that true.
Survives unchanged:
AnnounceKey,QueryKeyOwnership,InvalidateKey,KeyAnnouncement, thecoordinatorWrapperimplementation, and the compile-time assertion. None of that is consensus work— it is cache coordination, and the v0.13.0 warming issues (#140, #141, #142, #143) still need it.
One addition worth making while here: per §1 (R4) of
docs/design/conditional-writes-vs-raft.md, aninvalidation is only ordered correctly if it carries the ETag it was computed from.
KeyAnnouncementalready has anETagfield, soInvalidateKeyshould take one too — otherwise areceiver cannot discard an invalidation referring to a version it has already moved past.
No action needed until #284 is scoped; recording it here so this issue is not implemented as written.
scttfrdmn commentedon Aug 8, 2026
#284 has landed and two of this issue's items no longer hold. Recording it here rather than editing the body, so the change of premise is visible.
Drop
NegotiateConsistencyand theConsistencyLevelpromotion. The type is deleted, not moved.ConsistencyEventual,ConsistencySessionandConsistencyStrongall issued the same unconditionalPutObjectand differed only in how many nodes issued it, so there was nothing to negotiate — an agreement between two nodes on a level selected the same request from both. What replaced it is per-operation and evaluated by the store:DistributedOperation.Precondition, atypes.Precondition. A two-name enum beside it would be a second encoding ofPrecondition.IsZero().So the acceptance criterion "
ConsistencyLeveldefined in exactly one place (pkg/types)" is satisfied by it being defined in zero places, andinternal/distributed/coordinator.gono longer needs to importpkg/typesfor it (it importspkg/typesforPreconditioninstead).InvalidateKeyandAnnounceKeyneed an ETag in the signature.KeyAnnouncementalready has the field;CacheInvalidateMessage(gossip.go) is{Key, From}and carries no version, so a receiver cannot tell an invalidation for a version it has already moved past from one for the version it holds. That is the remaining half of #284's R4 and belongs in whichever of the two lands first — flagging it here because this issue defines the interface those messages travel under.AnnounceKey/QueryKeyOwnershipare unaffected and are what the cache-warming work (#141) actually needs.Suggested revision to the interface:
One other thing to check while implementing:
coordinatorWrappermust not grow a stub that reports success for work it did not do. TheCacheReplicator#284 just deleted counted bytes as replicated when gossip was not running, and the test that let it survive asserted only that its field was non-nil. A stub here should returntypes.ErrNotSupported, notnil.feat(distributed)!: replace the N-identical-PUT fan-out with per-key …
feat(types)!: cache coordination on DistributedCoordinator, with stub…