Expand description
Substrate primitive over std::collections::BTreeMap<String, String>
— the ONE substrate owner of the <map>.insert(<k>.to_string(), <v>.to_string()) string-string insertion shape every K8s-carrier
writer (ObjectMeta annotations / labels, ConfigMap data)
restates by hand at the &str × &str → BTreeMap write boundary.
Receiver-shape peer of crate::json_object::JsonMapStrExt::insert_str
on the “insert a string at a string key” write axis, partitioned by
CARRIER TYPE:
crate::json_object::JsonMapStrExt::insert_str— theserde_json::Map<String, Value>receiver used by every JSON-shapedmetadata.annotations/ label map / spec-body slot the reconciler emits to K8s through SSA-timeserde_json::Valuebodies.BTreeMapStrExt::insert_str(this trait) — theBTreeMap<String, String>receiver used by every K8s-canonical ObjectMeta annotations / labels slot AND every ConfigMap.dataslot the workspace stamps through thekube-rstyped API surface (which reifiesObjectMeta.annotations: Option<BTreeMap<String, String>>verbatim).
The two traits deliberately share the insert_str method name AND
the (impl Into<String>, impl Into<String>) argument shape so a
caller who imports either substrate reaches the same-shape write
call at the same-name method, regardless of whether the receiver is
the JSON-side Map<String, Value> or the K8s-typed-API-side
BTreeMap<String, String>. A future new carrier (e.g. a
HashMap<String, String> receiver for a lightweight fixture map,
or a secrecy::Secret<String> value-slot for encrypted secret
payloads) adds one impl arm here without splitting the substrate
into a third trait.
Pre-lift the shape was hand-authored at THREE production sites across two workspace crates past the ★★ PRIME-DIRECTIVE ≥ 2 duplication threshold:
tatara-pool-reconciler::controller_pool::build_member_process× 2 — the pool-membership annotation seed stampingannotations::POOL+annotations::POOL_SLOTinto the fresh member Process’smetadata.annotationsmap right afterProcess:: new. Both restated the same<map>.insert(<key>.to_string(), <val>.to_string())shape.tatara-export-worker::write_receipt× 1 — the receipt-CM.dataseed stamping the(configmap-key, payload)pair into the freshBTreeMapright before thecrate::configmap::with_datacomposer wraps it as aConfigMapwire body.
All three sites walked the SAME two-position insert shape verbatim,
differing only in the &str / &'static str key + the &str /
numeric-.to_string() value at each callsite. Post-lift each
callsite reads <map>.insert_str(<key>, <val>) and the string-
string write shape lives at ONE substrate owner here.
§Naming — insert_str, not insert
Same discipline as the sibling
crate::json_object::JsonMapStrExt::insert_str — the trait method
deliberately does NOT collide with the inherent BTreeMap::insert
(which takes (String, String) positionally). A name collision
would let a caller who has BTreeMapStrExt in scope resolve to
the inherent method by accident (inherent methods win over trait
methods in method resolution) and silently drop the Into<String>
coerce on either slot. The _str suffix names the intent: both
slots project the caller’s borrowed handle into an owned String
at the substrate, not at every callsite.
Theory anchor: THEORY.md §VI.1 (generation over composition — the
<map>.insert(<k>.to_string(), <v>.to_string()) shape recurred at
three hand-authored production sites across two workspace crates
past the ★★ PRIME-DIRECTIVE ≥ 2 duplication trigger, and is lifted
to ONE substrate owner here). THEORY.md §II.1 invariant 5
(composition preserves proofs — a regression that drifts the write
shape at ONE consumer surfaces at the substrate pin rather than as
silent per-emit skew across every K8s-carrier annotations / labels
/ ConfigMap-data writer).
Traits§
- BTree
MapStr Ext - Substrate extension trait over
BTreeMap<String, String>— the ONE substrate owner of the<map>.insert(<k>.to_string(), <v>.to_string ())string-string insertion shape every K8s-carrier writer (ObjectMeta annotations / labels, ConfigMap.data) hand-authored at the callsite pre-lift.