Skip to main content

max / makenotwork

Log the discarded tier-price install, and correct two stale docs tier_prices.rs: install_test_default discarded the OnceLock Err, so a racing install was invisible. Warn and keep the first table, matching install_global. Losing the race is the documented outcome, not a fault. tagtree docs: the TagIndex section described a two-tier suggestion strategy the code outgrew. Document the real three tiers and the bulk operations. pom serve.rs: the dead-letter delete reused the post-delivery wording. A failed delete there re-drops the row, it does not re-send.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-30 23:49 UTC
Signed with PGP, not checked
Commit: 2b730c53d989d3f96124396c8226ca950c9d285a
Parent: 8104661
3 files changed, +27 insertions, -8 deletions
@@ -150,7 +150,8 @@
150 150 // once, so a second call means two config sources exist and the
151 151 // second one is being ignored.
152 152 tracing::warn!(
153 - "TierPrices::install_global called more than once; keeping the first install"
153 + "TierPrices::install_global called a second time; the new table is ignored and \
154 + the first install stays in force"
154 155 );
155 156 }
156 157 }
@@ -179,10 +180,14 @@
179 180 let a = Assumptions::load("docs/business/assumptions.toml")
180 181 .expect("test setup: load canonical assumptions.toml");
181 182 let tp = TierPrices::from_assumptions(&a);
182 - // Ignored deliberately: concurrent tests race to install here and the
183 - // values are identical, so losing the race is the documented outcome
184 - // rather than a failure.
185 - let _ = GLOBAL.set(tp);
183 + // Losing the race is the documented outcome rather than a failure:
184 + // concurrent tests install identical values.
185 + if GLOBAL.set(tp).is_err() {
186 + tracing::warn!(
187 + "TierPrices::install_test_default raced a concurrent install; the fixture is \
188 + ignored and the first table stays in force"
189 + );
190 + }
186 191 }
187 192 }
188 193
@@ -179,7 +179,7 @@
179 179 alert_id = p.id,
180 180 alert_key = %p.alert_key,
181 181 error = %e,
182 - "pending alert delete failed, alert will re-send"
182 + "pending alert delete failed, the drop retries next tick"
183 183 );
184 184 }
185 185 } else {
@@ -74,12 +74,26 @@
74 74
75 75 ### TagIndex (Autocomplete)
76 76
77 - Sorted `Vec<String>` with binary-search lookup. Two-tier suggestion strategy:
77 + Sorted `Vec<String>` with binary-search lookup. Three suggestion tiers, each running only if the one before it left room under `limit`:
78 78
79 79 1. **Path prefix** (tier 1): binary search for tags whose full path starts with input. O(log n + k).
80 80 2. **Segment prefix** (tier 2): linear scan for tags where any non-first segment starts with input. Only runs if tier 1 didn't fill the limit and input has no dots. A segment index gates entry: if no known segment starts with input, scan is skipped in O(log m).
81 + 3. **Fuzzy segment** (tier 3): linear scan for tags with any segment within Levenshtein distance 2 of input, sorted by distance then lexicographically. Skips tags already returned by tiers 1 and 2.
81 82
82 - Key methods: `new()`, `empty()`, `insert()`, `remove()`, `rebuild()`, `contains()`, `suggest(input, limit)`, `suggest_with_status(input, limit)`.
83 + `suggest(input, limit)` runs tiers 1 and 2. `suggest_fuzzy(input, limit)` runs all three: it calls `suggest` first and appends tier-3 hits. Within each tier results are sorted, and earlier tiers come first.
84 +
85 + Key methods: `new()`, `empty()`, `insert()`, `remove()`, `rebuild()`, `contains()`, `len()`, `is_empty()`, `iter()`, `suggest(input, limit)`, `suggest_with_status(input, limit)` (adds a flag for whether input is itself a tag), `suggest_fuzzy(input, limit)`.
86 +
87 + `insert()` and `remove()` keep sorted order. `remove()` does not prune orphaned segments; call `rebuild()` when segment accuracy matters after many removals.
88 +
89 + ### Bulk Operations (free functions over `&mut TagIndex`)
90 +
91 + Each rewrites the index in place and returns a count.
92 +
93 + - `rename_prefix_bulk(old, new, index)`: apply `rename_prefix` to every tag, rebuilding the index. Returns tags modified.
94 + - `remove_subtree(prefix, index)`: drop `prefix` and all its descendants. Returns tags removed.
95 + - `merge_tags(source, target, index)`: rewrite the `source` prefix to `target` across the subtree, deduplicating collisions with tags already under `target`. Implemented as a call through to `rename_prefix_bulk`. Returns tags moved.
96 + - `batch_rename(operations, index)`: apply `(old, new)` prefix renames in order. Returns the sum of per-operation counts, so a tag renamed twice counts twice.
83 97
84 98 ## Integration Patterns
85 99