Module profile

Module profile 

Source
Expand description

Adapter-profile overlay merge — leaf-replace semantics (CONTEXT.md §adapter profile).

A profile is a named sparse overlay on its parent adapter manifest. The merge rule is leaf-replace: a profile key replaces the whole value at that path — tables recurse key-by-key, but every non-table value (scalar, array, datetime) overrides wholesale. Arrays are replaced, never spliced or appended. Keys present only in the parent survive; keys present only in the overlay are added. The merged [toml::Value] re-deserializes into a complete crate::Manifest, so the profile behaves as a distinct adapter option everywhere a bare adapter_name rides.

This is a pure function with no I/O; the unit table below is its contract.

Functions§

as_file_pointer
A [strings] value that is a file pointer (M12-W3, REQ-MANIFEST-5): a value-position table with EXACTLY one key, file, whose value is a string — e.g. key = { file = "rel/path" }. Returns that relative path. The exactly-one-key rule is the disambiguation (doyle): any OTHER table shape (including one that merely contains a file key alongside others) stays an opaque nested strings tree, so existing nested trees are untouched (back-compat). This single-key table shape IS reserved as the pointer form — a literal { file = … } value cannot double as inline data. The pointer is resolved to the file’s contents lazily at get-string time, never here.
check_tighten_only
Consent floors are tighten-only (CONTEXT.md §adapter profile): a profile may demand more approval than its parent, never less. Refused at registration if the merged profile loosens an approval-class floor (require_approval, or the at-cap over_cap behavior). Capacity limits (max_instances_per_owner) are not approval-class and are not floored here.
merge_leaf_replace
Leaf-replace deep merge of overlay onto base.
resolve
Resolve a shipped profile ([profiles.<name>] declared on parent) into a complete, validated manifest — the merged view a <adapter>:<profile> address selects. A bare adapter name never calls this (it uses the parent unmodified).
resolve_overlay
Apply an arbitrary sparse overlay onto parent — the shared core of both shipped-profile (resolve) and local-profile (registry) resolution. Serializes the parent to a [Value], leaf-replace-merges the overlay, re-deserializes, drops the profile catalogue from the resolved view, then re-runs the manifest invariants and the tighten-only consent floor.
set_string_at
Set value at a dot-separated key_path in a [strings] tree, creating intermediate tables as needed (the write half of set-string). Errors on an empty path segment or a path that traverses an existing non-table leaf.
split_option
Split an adapter option string into (adapter, profile?) on the first : — the canonical composite addressing form. A bare name (no :) yields (name, None) and resolves to the parent unmodified; <adapter>:<profile> yields (adapter, Some(profile)). The split is on the first : so an adapter name itself may not contain one (it never does), while a profile name may.
string_at
Read a dot-separated key_path out of a [strings] KV tree: each segment indexes a nested table, the final segment’s value is returned. None if any segment is missing or a non-final segment is not a table. Used by spt adapter get-string after the profile overlay has merged the tree.