Module working_set
Expand description
The AppData components one commit touches, each decoded once.
A WorkingSet holds the state of every component that one commit’s
AppDataUpdate proposals touch. It applies each Update payload in
memory and encodes each touched component once at the end, so the work
of a commit is linear in the bytes it carries and the state it touches,
however its changes are split across proposals. The byte-level
[apply_app_data_update_payload] decodes and encodes the whole
component for each proposal instead.
§Same verdict, same error class
Members must agree on every commit, so for every input an update returns
the result [apply_app_data_update_payload] returns for the same prior
value: the same new value, or an error of the same
ComponentSourceError variant. Each update runs the same checks in the
same order:
- the element bound on the payload alone,
- immutability: an immutable component that is present is not overwritten,
- the payload decode and, for
COMPONENT_REGISTRY, the registry’s write invariants, - the decode of the committed value, on the component’s first update,
- the delta, mutation by mutation,
- UTF-8 values in a
TLS_MAP_INBOX_ID_STRINGmap, - the snapshot bound, then the element bound, on a field-bounded component,
- the group-root length.
A snapshot over its bound after any one proposal fails that proposal, even when a later proposal would shrink it. Error text is not part of a verdict, and a few messages are shorter than the byte-level ones.
§Lazy decoding and type resolution
A component’s committed bytes are decoded when an update or a read first
needs its entries. WorkingSet::remove never decodes them and never
resolves the component’s type, as staging does not today. An update
resolves the type exactly where [apply_app_data_update_payload] does:
for the payload bound of a bounded component, and for the apply of a
component with no built-in Component impl. A caller that resolves a
type where today’s code does, such as validation of a Remove, calls
WorkingSet::component_type. The registry is the pre-commit one for
the whole commit, so each type is resolved once.
§RemoveByHash
A set’s hash index is built on the first RemoveByHash and kept current
as keys come and go. Every hash in a delta resolves against the set
before that delta and before any of its mutations, and a resolution
failure comes first, as in TlsSet::apply_delta: [Insert(k), RemoveByHash(h(k))] with k absent fails with KeyNotFound.
§Atomic updates and checkpoints
An update that fails leaves the working set as it was. A
WorkingSet::checkpoint marks a point that WorkingSet::rollback
returns to, undoing every update and removal since, including the
entries, the hash index, the snapshot length, and the counts. A sender
uses one around each pending proposal it considers keeping.
§Registry reads
WorkingSet::get returns an entry’s raw bytes. A registry entry that
the registry does not recognize still has bytes, so read registry
policy through WorkingSet::registry_entry, which hides it as
ComponentRegistry::get does.
§Memory
A decoded collection keeps its committed entries in the committed bytes,
as ranges, and the values the commit writes in one byte arena, so a map
of n committed entries costs about 16n bytes beyond its bytes.
Structs§
- Checkpoint
- A point that
WorkingSet::rollbackreturns to. - Working
Set - The AppData components one commit’s proposals touch, each decoded once.
Type Aliases§
- Component
States - Each written component’s state: its bytes, or
Noneonce removed. A state can be the commit-log signer’s private key, so each is wiped on drop.