1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
//! 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`] — the
//! `serde_json::Map<String, Value>` receiver used by every JSON-shaped
//! `metadata.annotations` / label map / spec-body slot the reconciler
//! emits to K8s through SSA-time `serde_json::Value` bodies.
//! * [`BTreeMapStrExt::insert_str`] (this trait) — the
//! `BTreeMap<String, String>` receiver used by every K8s-canonical
//! ObjectMeta annotations / labels slot AND every ConfigMap `.data`
//! slot the workspace stamps through the `kube-rs` typed API surface
//! (which reifies `ObjectMeta.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 stamping
//! `annotations::POOL` + `annotations::POOL_SLOT` into the fresh
//! member Process's `metadata.annotations` map right after `Process::
//! new`. Both restated the same `<map>.insert(<key>.to_string(),
//! <val>.to_string())` shape.
//! * `tatara-export-worker::write_receipt` × 1 — the receipt-CM `.data`
//! seed stamping the `(configmap-key, payload)` pair into the fresh
//! `BTreeMap` right before the [`crate::configmap::with_data`]
//! composer wraps it as a `ConfigMap` wire 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).
use BTreeMap;
/// 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.
///
/// Peer of [`crate::json_object::JsonMapStrExt`] on the same
/// "insert a string at a string key" write axis, split by receiver
/// type (JSON-shaped `Map<String, Value>` vs K8s-canonical
/// `BTreeMap<String, String>`). See the module docs for the naming
/// rationale (why `insert_str` and not `insert`) and the callsite
/// audit.