Skip to main content

Module working_set

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:

  1. the element bound on the payload alone,
  2. immutability: an immutable component that is present is not overwritten,
  3. the payload decode and, for COMPONENT_REGISTRY, the registry’s write invariants,
  4. the decode of the committed value, on the component’s first update,
  5. the delta, mutation by mutation,
  6. UTF-8 values in a TLS_MAP_INBOX_ID_STRING map,
  7. the snapshot bound, then the element bound, on a field-bounded component,
  8. 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::rollback returns to.
WorkingSet
The AppData components one commit’s proposals touch, each decoded once.

Type Aliases§

ComponentStates
Each written component’s state: its bytes, or None once removed. A state can be the commit-log signer’s private key, so each is wiped on drop.