src/History.bend fails
raw source on the hub · import ber-core-store@0.1.2.0/src/History.bend as History
11 imports
import Base import ./Reading.bend as Reading import ./LogicalKey.bend as LogicalKey import ./ContentHash.bend as ContentHash import ./StateTree.bend as StateTree import ./Staging.bend as Staging import ./ContentObject.bend as ContentObject import ./JsonAdapter.bend as JsonAdapter import ./Value.bend as Value import ./Store.bend as Store import bend-kit-json@0.3.0.0/json.bend as Json
Types
type CommitMeta source · line 21 · raw
Data
One metadata key/value field.
Field@field_key:String -> @field_value:String -> CommitMeta
type Commit source · line 25 · raw
Data
Identifier, parents, tree hash, timestamp, metadata and certificate.
Make@commit_identifier:String -> @parent_commit_identifiers:List<&2, String> -> @tree_hash:String -> @timestamp:Nat -> @metadata:List<&2, CommitMeta> -> @certificate_hash:Maybe<&2, String> -> Commit
Definitions
def commit_identifier_of source · line 29 · raw
@commit_value:Commit -> String
Projects the identifier out of a commit.
def commit_tree_of source · line 35 · raw
@commit_value:Commit -> String
Projects the tree hash out of a commit.
def meta_pair_to_json source · line 41 · raw
@meta_field:CommitMeta -> 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val
Encodes one metadata field as a two-item array.
def meta_list_to_json source · line 47 · raw
@metadata:List<&2, CommitMeta> -> List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Encodes the metadata list.
def encode_parent_list source · line 55 · raw
@parent_commit_identifiers:List<&2, String> -> List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Encodes parent identifiers as strings.
def finalize_commit_document source · line 63 · raw
@parents_field:Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @tree_field:Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @meta_field:Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> String
Encodes the parents/tree/meta document canonically.
def serialize_commit source · line 67 · raw
@parent_commit_identifiers:List<&2, String> -> @metadata:List<&2, CommitMeta> -> @tree_hash_value:String -> String
Serializes parents, tree and metadata; the hashed bytes.
def prepend_meta_field source · line 71 · raw
@field_key:String -> @field_value:String -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Conses a decoded meta field onto the tail.
def prepend_meta_value source · line 79 · raw
@field_key:String -> @value_maybe:Maybe<&2, String> -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Unwraps the field value, then prepends.
def prepend_meta_texts source · line 87 · raw
@key_maybe:Maybe<&2, String> -> @value_maybe:Maybe<&2, String> -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Unwraps the key text, then continues.
def prepend_meta_items source · line 95 · raw
@pair_items:List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Decodes one [key, value] array; None on wrong shape.
def prepend_parsed_meta source · line 103 · raw
@pair_maybe:Maybe<&2, List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>> -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Unwraps the pair array, then decodes.
def prepend_meta_entry source · line 111 · raw
@head_item:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> @parsed_tail:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, List<&2, CommitMeta>>
Decodes one metadata item.
def parse_meta_list source · line 115 · raw
@meta_items:List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Maybe<&2, List<&2, CommitMeta>>
Decodes the metadata array; None on any bad item.
def verify_commit_text source · line 123 · raw
@text_matches:Bool -> @+requested_identifier:String -> @+parent_list:List<&2, String> -> @+tree_text:String -> @+parsed_meta:List<&2, CommitMeta> -> Maybe<&2, Commit>
Accepts only when re-serialization matches stored bytes.
def finish_commit_meta source · line 131 · raw
@+requested_identifier:String -> @+stored_text:String -> @+parent_list:List<&2, String> -> @+tree_text:String -> @meta_maybe:Maybe<&2, List<&2, CommitMeta>> -> Maybe<&2, Commit>
Continues commit extraction once metadata decodes.
def finish_commit source · line 139 · raw
@+requested_identifier:String -> @+stored_text:String -> @+parent_list:List<&2, String> -> @+tree_text:String -> @meta_items_maybe:Maybe<&2, List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>> -> Maybe<&2, Commit>
Continues commit extraction once the meta items decode.
def finish_meta_array source · line 147 · raw
@+requested_identifier:String -> @+stored_text:String -> @+parent_list:List<&2, String> -> @+tree_text:String -> @meta_maybe:Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Maybe<&2, Commit>
Unwraps the meta array, then continues.
def tree_maybe_as_text source · line 155 · raw
@tree_maybe:Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Maybe<&2, String>
Unwraps the tree field as text.
def extract_commit_meta source · line 163 · raw
@+requested_identifier:String -> @+stored_text:String -> @+parent_list:List<&2, String> -> @tree_text_maybe:Maybe<&2, String> -> @+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, Commit>
Continues commit extraction once the tree text decodes.
def extract_commit_tree source · line 171 · raw
@+requested_identifier:String -> @+stored_text:String -> @parent_strings_maybe:Maybe<&2, List<&2, String>> -> @tree_maybe:Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, Commit>
Continues commit extraction once parents decode.
def extract_parents_items source · line 179 · raw
@+requested_identifier:String -> @+stored_text:String -> @items_maybe:Maybe<&2, List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>> -> @+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, Commit>
Unwraps the parent items, then continues.
def extract_parents_array source · line 187 · raw
@+requested_identifier:String -> @+stored_text:String -> @parents_maybe:Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, Commit>
Unwraps the parents field, then continues.
def extract_commit_parents source · line 195 · raw
@+requested_identifier:String -> @+stored_text:String -> @+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, Commit>
Reads the parents field of the document.
def commit_from_parse source · line 199 · raw
@requested_identifier:String -> @stored_text:String -> @parse_result:Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Maybe<&2, Commit>
Builds the commit from parsed JSON; None on malformed input.
def parse_commit_text source · line 207 · raw
@requested_identifier:String -> @+stored_text:String -> Maybe<&2, Commit>
Parses stored commit text.
def parse_commit source · line 211 · raw
@requested_identifier:String -> @stored_maybe:Maybe<&2, String> -> Maybe<&2, Commit>
Parses loaded text; missing storage reads as None.
def load_commit source · line 219 · raw
@+requested_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, Commit>>
Loads and verifies a commit by identifier.
def empty_unit source · line 225 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Unit>
Empty Sess result of unit type.
def empty_pair_list source · line 230 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Empty Sess result of entry-list type.
def empty_tree_maybe source · line 235 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode>>
Empty Sess result of tree type.
def persist_commit source · line 240 · raw
@+parent_commit_identifiers:List<&2, String> -> @+metadata:List<&2, CommitMeta> -> @+tree_hash_value:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Commit>
Serializes, hashes and stores a commit.
def persist_tree source · line 248 · raw
@+merged_entries:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, String>
Hashes and stores a merged entry list as a tree.
def write_each_index source · line 255 · raw
@merged_entries:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> @+commit_value:Commit -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Unit>
Writes one version-index entry per merged entry.
def clear_stage_keys source · line 266 · raw
@+session_identifier:String -> @merged_entries:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Unit>
Removes staged keys consumed by the commit.
def persist_index_and_clear source · line 277 · raw
@+session_identifier:String -> @+merged_entries:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> @+commit_value:Commit -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Unit>
Writes the index and clears the stage in sequence.
def materialize_commit source · line 285 · raw
@+session_identifier:String -> @+parent_commit_identifiers:List<&2, String> -> @metadata:List<&2, CommitMeta> -> @+merged_entries:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Commit>
Persists tree, commit and index, then clears the stage.
def parse_tree_text source · line 293 · raw
@tree_hash_value:String -> @tree_maybe:Maybe<&2, String> -> Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode>
Parses loaded tree text.
def load_tree_text source · line 301 · raw
@+tree_hash_value:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode>>
Loads a tree by hash.
def load_tree_by_commit source · line 307 · raw
@commit_maybe:Maybe<&2, Commit> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode>>
Loads the tree a commit points at.
def read_tree_at source · line 315 · raw
@+commit_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode>>
Reads the tree for a commit identifier.
def base_or_empty source · line 322 · raw
@tree_maybe:Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/StateTree.StateTreeNode> -> List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>
Missing base trees read as empty.
def load_parent_tree source · line 330 · raw
@head_parent:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Loads the first parent entries.
def load_base_entries source · line 336 · raw
@parent_commit_identifiers:List<&2, String> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Loads base entries; root commits start empty.
def prepend_pair_maybe source · line 344 · raw
@+head_key:String -> @head_value_maybe:Maybe<&2, String> -> @tail_pairs:List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>
Skips missing staged values, keeps present ones.
def prepend_loaded_pair source · line 352 · raw
@+session_identifier:String -> @+head_key:String -> @tail_action:0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Loads one staged value and prepends it.
def load_each_pair source · line 359 · raw
@+session_identifier:String -> @staged_keys:List<&2, String> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Loads every staged key in the manifest.
def collect_staged_pairs source · line 367 · raw
@+session_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Collects the session staged pairs.
def create_commit source · line 374 · raw
@+session_identifier:String -> @+parent_commit_identifiers:List<&2, String> -> @metadata:List<&2, CommitMeta> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Commit>
Materializes stage plus base into a new commit.
def commit_parents_of source · line 383 · raw
@commit_value:Commit -> List<&2, String>
Versioned reads walk the first-parent chain with Nat fuel; unknown commits contribute "" links that never match a real index key.
def empty_string_list source · line 389 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, String>>
Empty Sess result of string-list type.
def empty_entry_maybe source · line 394 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Empty Sess result of entry type.
def empty_value_maybe source · line 399 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Empty Op result of value type.
def empty_text_maybe source · line 404 · raw
0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, String>>
Empty Op result of text type (commit identifiers, not values).
def first_parent_name source · line 409 · raw
@parent_identifiers:List<&2, String> -> String
Heads the parent list; root commits yield empty.
def first_parent_text source · line 417 · raw
@commit_maybe:Maybe<&2, Commit> -> String
Heads the parent list; unknown commits yield empty.
def fuel_for_empty source · line 427 · raw
@is_empty:Bool -> @gated_left:Nat -> Nat
Unknown links end the walk: their index probes can never hit, so search results are unchanged while misses stop descending (empty parent text is terminal: missing commits and parentless roots both resolve to "").
def fuel_for_parent source · line 435 · raw
@+parent_text:String -> @gated_left:Nat -> Nat
Gates the remaining fuel on parent emptiness.
def walk_commit_chain source · line 441 · raw
@checker_fuel:Nat -> @gated_fuel:Nat -> @+commit_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, List<&2, String>>
Walks first-parents with fuel; newest first. checker_fuel decreases every level for the termination checker; gated_fuel carries the early stop. Callers pass the same fuel twice.
def decide_search_hit source · line 455 · raw
@stored_maybe:Maybe<&2, String> -> @+lookup_key:String -> @tail_result:Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>
A stored value wins; otherwise the tail result.
def search_chain_entries source · line 463 · raw
@ancestor_chain:List<&2, String> -> @+namespace_name:String -> @+record_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry>>
Searches the ancestor chain newest-first.
def payload_or_empty source · line 475 · raw
@loaded_maybe:Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/ContentObject.ContentObject> -> Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>
Projects the payload out of a loaded object.
def load_object_payload source · line 483 · raw
@+value_hash:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Loads an object payload by content hash.
def decide_resolve_value source · line 489 · raw
@is_tombstone:Bool -> @+stored_value:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Tombstones read as absent; hashes load payloads.
def resolve_entry_value source · line 497 · raw
@+stored_value:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Resolves one stored index value.
def resolve_found_entry source · line 501 · raw
@found_maybe:Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Reading.ChainEntry> -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Resolves a found chain entry to its payload.
def read_value_at source · line 509 · raw
@+namespace_name:String -> @+record_identifier:String -> @+commit_identifier:String -> 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Store.Op<&2, Maybe<&2, 0x785d1b078f7f99a4ee2b9c7798398bc9/src/Value.Value>>
Reads a namespaced value at a commit.