Bedrock.SystemKeys (bedrock v0.7.0)
View SourceThe \xFF/system keys Bedrock writes and reads.
Every key defined here has a named purpose: shard_keys/<end_key> feeds
each commit proxy's routing view (through resolver metadata windows) and
the next recovery's materializer bootstrap; materializers/<tag>/<worker_id> entries
feed the client-facing routing projection served by commit proxies
(FDB's serverList/ analogue - interfaces ride the keyspace), answer
worker rejoin validation, and give recovery's materializer bootstrap
its re-adoption input (read_prior_refs) and the persistence phase's
diff base. To clients the members are hints, unverified and cached;
to recovery they are durable state. distributor_lock/{owner, write} is the distributor's write fence (FDB's MoveKeys lock,
bedrock-q67.21): opaque UIDs read-checked-written inside every
mutating distributor transaction, so ownership is enforced by the
commit pipeline itself. A system key without a
reader is inventory, not communication - unread MACHINERY is deleted,
while durable observability keys stay by decision, named as such;
families return here when their readers do (config authority with
bedrock-q67.25).
Summary
Functions
Distributor write-fence owner UID: distributor_lock/owner (FDB's moveKeysLockOwnerKey)
Distributor write-fence write UID: distributor_lock/write (FDB's moveKeysLockWriteKey)
Membership entry: materializers/<tag>/<worker_id> -> node string.
Prefix covering one tag's members.
Prefix covering every materializer membership entry
Parses a system key into its family. Unknown system keys parse as
:unknown (forward compatibility); non-system keys as :error.
The reserved worker id the distributor's placeholder registers under.
Shard boundary entry: shard_keys/<end_key> -> {tag, start_key} (ceiling search)
Prefix covering every shard boundary entry
Functions
@spec distributor_lock_owner() :: Bedrock.key()
Distributor write-fence owner UID: distributor_lock/owner (FDB's moveKeysLockOwnerKey)
@spec distributor_lock_write() :: Bedrock.key()
Distributor write-fence write UID: distributor_lock/write (FDB's moveKeysLockWriteKey)
@spec materializer_key(Bedrock.range_tag(), Bedrock.Service.Worker.id()) :: Bedrock.key()
Membership entry: materializers/<tag>/<worker_id> -> node string.
Tag-major with the worker id IN the key, so one family answers both
questions FDB needs two for: a prefix scan over a tag gives the shard's
members (FDB's range-major keyServers/<range> -> team), and each
member is individually addressable for removal (FDB's server-major
serverKeys/<server>/<range>). A worker owns exactly one shard and
notices broadcast on the shard's tag, so no per-worker index is needed.
Membership is expressed by key PRESENCE; removal is a clear.
@spec materializer_tag_prefix(Bedrock.range_tag()) :: Bedrock.key()
Prefix covering one tag's members.
The family's standard triple mirrors FDB's (SystemData.cpp):
materializers_prefix/0 is serverKeysRange, materializer_key/2 is
serverKeysKey, and this is serverKeysPrefixFor — the scan that
answers "who serves this shard" without decoding the whole family.
@spec materializers_prefix() :: Bedrock.key()
Prefix covering every materializer membership entry
@spec parse_key(Bedrock.key()) :: {:shard_key, Bedrock.key()} | {:materializer_key, Bedrock.range_tag(), Bedrock.Service.Worker.id()} | {:distributor_lock, :owner | :write} | :unknown | :error
Parses a system key into its family. Unknown system keys parse as
:unknown (forward compatibility); non-system keys as :error.
@spec placeholder_worker_id() :: Bedrock.Service.Worker.id()
The reserved worker id the distributor's placeholder registers under.
A keyspace-level convention, not a distributor detail: routing reads it to prefer real coverage over parking, so it belongs where the family's semantics are defined rather than behind a control-plane module.
@spec shard_key(Bedrock.key()) :: Bedrock.key()
Shard boundary entry: shard_keys/<end_key> -> {tag, start_key} (ceiling search)
@spec shard_keys_prefix() :: Bedrock.key()
Prefix covering every shard boundary entry