makeover-webview 0.130.0

The webview renderer for makeover-layout. Emits CSS, and is the one renderer that needs no palette: var() is the late binding, so resolution stays with the browser. With the build feature, writes a consumer's generated frontend files and checks the hand-written ones against them.
Documentation
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
//! The vocabulary check: a hand-written rule that collides with a generated
//! class, and generated classes no markup uses.

use std::path::{Path, PathBuf};

use super::{Source, drop_layers, frontend_css, layers_ordered_below_makeover, read, shown};
use crate::Emit;
use crate::build::rerun;
use crate::css_lex::is_ident;

/// A reviewed exception to [`Vocabulary`]: a collision the app has read and
/// kept, with a note beside it saying why.
///
/// It expires when the collision does: an exception that no longer collides
/// fails the check. It silences the class and element passes only; see
/// [`Vocabulary`] for the cancel pass, which no exception covers.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Allow<'a> {
    /// A hand-written rule on a generated class takes one of its properties.
    Class {
        /// The class, unprefixed as the stylesheet spells it.
        class: &'a str,
        /// The property both set.
        property: &'a str,
    },
    /// A bare element rule takes a property the generated sheet sets on a class
    /// that element carries.
    Element {
        /// The element the rule selects.
        element: &'a str,
        /// The generated class it reaches.
        class: &'a str,
        /// The property both set.
        property: &'a str,
    },
}

impl<'a> Allow<'a> {
    /// See [`Allow::Class`].
    pub const fn class(class: &'a str, property: &'a str) -> Self {
        Self::Class { class, property }
    }

    /// See [`Allow::Element`].
    pub const fn element(element: &'a str, class: &'a str, property: &'a str) -> Self {
        Self::Element {
            element,
            class,
            property,
        }
    }
}

/// Fail the build if a hand-written stylesheet takes a property the generated
/// one already sets, on the same class or on an element that carries it.
///
/// The generated sheet sits in `@layer makeover`. App CSS beats it whatever
/// the specificity, either by being unlayered or by sitting in a layer the
/// app's order statement puts after `makeover`, so an app declaration for a
/// property makeover already sets wins and the design system's value for that
/// component stops applying.
///
/// Classes are compared by property, not by name: an app rule on a generated
/// class that sets only properties the generated rule does not set passes.
///
/// # Three passes
///
/// - **Class pass.** An app rule whose subject names a generated class and
///   sets a property the generated sheet sets on that class.
///   [`Allow::class`] silences one `(class, property)` pair.
/// - **Element pass.** A rule with no class in it, such as
///   `button { color: var(--content) }`, setting a property the generated
///   sheet sets on a class that element can carry
///   (`crate::vocabulary::ELEMENT_CLASSES`). [`Allow::element`] silences one
///   `(element, class, property)` triple. Not reported: a scoped rule
///   (`.page button`), and a property the same sheet also names on that
///   class from a rule of at least the element rule's specificity (a tie goes
///   to the class rule). `.field` does not outrank `input[type="text"]`.
/// - **Cancel pass.** An app rule on the bare class (`.button { color }`,
///   no variant on its selector) setting a property the generated sheet sets
///   on a variant arm of that class (`.button[data-tone="danger"]`,
///   `.button:disabled`). From its later layer the bare rule beats every such
///   arm. **No [`Allow`] silences this pass**, including an [`Allow::class`]
///   for the same pair. The remedy is to restate each cancelled arm in the
///   app's sheet on its own selector, after the bare rule (for example
///   `.button[data-tone="danger"] { color: revert-layer }`), or to delete the
///   declaration.
///
/// A rule inside a layer ordered before `makeover`, by [`Vocabulary::beneath`]
/// or by the sheet's own `@layer` order statement, is not reported by any
/// pass. A handoff with `revert-layer` on the arms makeover paints is not
/// reported either: it is the usual remedy, a statement in the stylesheet
/// rather than an entry in the build script.
///
/// # The exception list
///
/// An [`Allow`] names a pairing the app has reviewed and kept. An [`Allow`]
/// that no longer collides fails the check.
///
/// ```no_run
/// use makeover_webview::build::drift::{Allow, Vocabulary};
///
/// Vocabulary::in_frontend("frontend")
///     .generated(&["layout.css"])
///     // Reviewed: the card's shadow is the app's, on the hover arm only.
///     .allow(Allow::class("card", "box-shadow"))
///     .run(&makeover_webview::Emit::default());
/// ```
#[derive(Debug, Clone)]
#[must_use = "a check does nothing until it is run"]
pub struct Vocabulary<'a> {
    source: Source,
    generated: Vec<&'a str>,
    upstream: Vec<&'a str>,
    allowed: Vec<Allow<'a>>,
    beneath: Vec<&'a str>,
}

impl<'a> Vocabulary<'a> {
    /// Every `.css` under `frontend/css`, recursively.
    pub fn in_frontend(frontend: impl AsRef<Path>) -> Self {
        Self::from(Source::Frontend(frontend.as_ref().to_path_buf()))
    }

    /// A named list of stylesheets rather than a tree.
    ///
    /// For a frontend with no directory a scan can point at. A stylesheet not
    /// on the list is not checked.
    pub fn files<P: AsRef<Path>>(paths: &[P]) -> Self {
        Self::from(Source::files(paths))
    }

    fn from(source: Source) -> Self {
        Self {
            source,
            generated: Vec::new(),
            upstream: Vec::new(),
            allowed: Vec::new(),
            beneath: Vec::new(),
        }
    }

    /// Sheets this crate writes, which are skipped. Relative to `frontend/css` for
    /// [`in_frontend`](Self::in_frontend); matched against the end of each path
    /// for [`files`](Self::files).
    pub fn generated(mut self, names: &[&'a str]) -> Self {
        self.generated.extend_from_slice(names);
        self
    }

    /// The text of stylesheets that sit between makeover and the app and own
    /// the classes they style as makeover owns its own.
    ///
    /// quasi-webview's `SCREEN_CSS` is one; the app that links both crates
    /// hands it in. A hand-written sheet is checked against
    /// makeover's sheet and every upstream sheet together. A file whose text
    /// *is* an upstream sheet, the copy an app serves from its frontend, is
    /// checked against makeover alone and never read as clashing with itself.
    pub fn upstream(mut self, sheets: &[&'a str]) -> Self {
        self.upstream.extend_from_slice(sheets);
        self
    }

    /// Cascade layers the app orders before `makeover`, by name.
    ///
    /// A rule inside one loses to every generated rule whatever its selector,
    /// so it cannot take a property from the design system and is not read.
    /// For example a reset: `@layer reset, makeover, ...` with
    /// `* { margin: 0; padding: 0 }` inside `@layer reset { }`. An order
    /// stated only in the app's markup is not read by this check; naming the
    /// layer here states it.
    pub fn beneath(mut self, layers: &[&'a str]) -> Self {
        self.beneath.extend_from_slice(layers);
        self
    }

    /// A reviewed exception. See [`Allow`].
    pub fn allow(mut self, allow: Allow<'a>) -> Self {
        self.allowed.push(allow);
        self
    }

    /// Several reviewed exceptions, for a list the app keeps as a `const`.
    pub fn allowing(mut self, allows: impl IntoIterator<Item = Allow<'a>>) -> Self {
        self.allowed.extend(allows);
        self
    }

    /// Run the check against the stylesheet `opts` generates. Emits
    /// `cargo::rerun-if-changed` for every file it read.
    ///
    /// # Panics
    ///
    /// If a directory or listed file cannot be read; if a bare-class rule
    /// cancels a generated variant arm it does not restate (the cancel pass,
    /// whatever the [`Allow`] list says); if any hand-written sheet takes a
    /// generated property in the class or element pass without an [`Allow`];
    /// or if an [`Allow`] no longer collides.
    pub fn run(&self, opts: &Emit) {
        let classes: Vec<(&str, &str)> = self
            .allowed
            .iter()
            .filter_map(|allow| match *allow {
                Allow::Class { class, property } => Some((class, property)),
                Allow::Element { .. } => None,
            })
            .collect();
        let elements: Vec<(&str, &str, &str)> = self
            .allowed
            .iter()
            .filter_map(|allow| match *allow {
                Allow::Element {
                    element,
                    class,
                    property,
                } => Some((element, class, property)),
                Allow::Class { .. } => None,
            })
            .collect();
        match &self.source {
            Source::Frontend(frontend) => {
                let (css, files) = frontend_css(frontend);
                let files: Vec<PathBuf> = files
                    .into_iter()
                    .filter(|p| !self.generated.contains(&shown(p, Some(&css)).as_str()))
                    .collect();
                check_vocabulary_paths(
                    &files,
                    opts,
                    Some(frontend),
                    &self.upstream,
                    &self.beneath,
                    &classes,
                    &elements,
                );
            }
            Source::Files(paths) => {
                let files: Vec<PathBuf> = paths
                    .iter()
                    .filter(|p| !self.generated.iter().any(|name| p.ends_with(name)))
                    .cloned()
                    .collect();
                check_vocabulary_paths(
                    &files,
                    opts,
                    None,
                    &self.upstream,
                    &self.beneath,
                    &classes,
                    &elements,
                );
            }
        }
    }
}

/// The check itself. `root`, when given, is stripped from reported paths.
fn check_vocabulary_paths(
    paths: &[PathBuf],
    opts: &Emit,
    root: Option<&Path>,
    upstream: &[&str],
    beneath: &[&str],
    allowed: &[(&str, &str)],
    allowed_elements: &[(&str, &str, &str)],
) {
    let sheet = crate::stylesheet(opts);
    let makeover = crate::vocabulary::declarations_by_class(&sheet);
    // What a hand-written sheet answers to: makeover's classes and every
    // upstream sheet's, merged per class.
    let mut owned = makeover.clone();
    for sheet in upstream {
        for (class, properties) in crate::vocabulary::declarations_by_class(sheet) {
            owned.entry(class).or_default().extend(properties);
        }
    }
    // The same two views one level down: per arm rather than per class, so a
    // variant the generated sheet styles is not folded into its base.
    let makeover_variants = crate::vocabulary::variants_by_class(&sheet);
    let mut owned_variants = makeover_variants.clone();
    for sheet in upstream {
        for (class, arms) in crate::vocabulary::variants_by_class(sheet) {
            let entry = owned_variants.entry(class).or_default();
            for (arm, properties) in arms {
                entry.entry(arm).or_default().extend(properties);
            }
        }
    }
    let mut cancels: Vec<String> = Vec::new();
    let mut clashes: Vec<String> = Vec::new();
    let mut seen: Vec<(String, String)> = Vec::new();
    let mut element_clashes: Vec<String> = Vec::new();
    let mut element_seen: Vec<(String, String, String)> = Vec::new();

    for path in paths {
        rerun(path);
        let raw = read(path);
        let name = shown(path, root);
        // An upstream sheet served from the frontend answers to makeover alone:
        // measured against itself every declaration in it would clash.
        let (generated, variants) = if upstream.contains(&raw.as_str()) {
            (&makeover, &makeover_variants)
        } else {
            (&owned, &owned_variants)
        };
        // A layer ordered before `makeover` cannot beat it, so its rules are
        // not read. See `Vocabulary::beneath`.
        let raw = drop_layers(&raw, beneath);
        // A layer this sheet's own statement orders below makeover cannot beat
        // it either, so no pass reports a rule there. Its pairs still count as
        // seen, so an `Allow` naming one is not stale.
        let own_below = layers_ordered_below_makeover(&raw);
        let own_below: Vec<&str> = own_below.iter().map(String::as_str).collect();
        let above = drop_layers(&raw, &own_below);
        // Read the app's sheet the same way the crate reads its own, or the two
        // sides are not comparable.
        let local = crate::vocabulary::declarations_by_class(&raw);
        let local_above = crate::vocabulary::declarations_by_class(&above);
        for (class, properties) in &local {
            let Some(theirs) = generated.get(class) else {
                continue;
            };
            for property in properties.intersection(theirs) {
                seen.push((class.clone(), property.clone()));
                let wins = local_above
                    .get(class)
                    .is_some_and(|above| above.contains(property));
                if !wins || allowed.contains(&(class.as_str(), property.as_str())) {
                    continue;
                }
                clashes.push(format!("  {name}  .{class} {{ {property} }}"));
            }
        }

        // The layer pass. A rule on the bare class reaches every element
        // carrying it, and from a later layer it beats every variant the design
        // system styles on that class, whatever their specificity. The class
        // pass cannot see this once the pair is reviewed: an `Allow` for
        // (button, color) written for one arm licensed cancelling
        // `[data-tone="danger"]` too, and goingson's destructive buttons lost
        // their tone that way. So no `Allow` silences it. The remedy is always
        // available: restate the variant, on its own arm, in the app's sheet.
        let bare = crate::vocabulary::bare_declarations(&above);
        let restated = crate::vocabulary::mentions_by_arm(&raw);
        for (class, properties) in &bare {
            let Some(arms) = variants.get(class) else {
                continue;
            };
            for property in properties {
                let lost: Vec<&str> = arms
                    .iter()
                    .filter(|(arm, theirs)| {
                        theirs.contains(property)
                            && !restated
                                .get(arm.as_str())
                                .is_some_and(|mentioned| mentioned.contains(property))
                    })
                    .map(|(arm, _)| arm.as_str())
                    .collect();
                if lost.is_empty() {
                    continue;
                }
                cancels.push(format!(
                    "  {name}  .{class} {{ {property} }}  cancels  {}",
                    lost.iter()
                        .map(|arm| format!("{arm} {{ {property} }}"))
                        .collect::<Vec<_>>()
                        .join(", ")
                ));
            }
        }

        // The second pass: a rule carrying no class at all, which the first one
        // cannot see. What the app says about the class itself settles the
        // pair, but only from a rule that outranks the element rule. Both are
        // the app's and both are in the same layer, so this one contest is
        // decided by specificity. `.field` does not beat `input[type="text"]`.
        let mentioned = crate::vocabulary::mentions_by_class(&raw);
        let by_element = crate::vocabulary::declarations_by_element(&raw);
        let by_element_above = crate::vocabulary::declarations_by_element(&above);
        for (element, properties) in &by_element {
            for class in crate::vocabulary::classes_for_element(element, opts) {
                let Some(theirs) = generated.get(&class) else {
                    continue;
                };
                for (property, rank) in properties {
                    if !theirs.contains(property) {
                        continue;
                    }
                    // A tie goes to the class rule: at equal specificity the
                    // later rule wins, and a remedy is written after the rule
                    // it remedies.
                    let spoken_for = mentioned
                        .get(&class)
                        .and_then(|properties| properties.get(property))
                        .is_some_and(|theirs| theirs >= rank);
                    if spoken_for {
                        continue;
                    }
                    element_seen.push((element.clone(), class.clone(), property.clone()));
                    let wins = by_element_above
                        .get(element)
                        .is_some_and(|above| above.contains_key(property));
                    if !wins
                        || allowed_elements.contains(&(
                            element.as_str(),
                            class.as_str(),
                            property.as_str(),
                        ))
                    {
                        continue;
                    }
                    element_clashes.push(format!(
                        "  {name}  {element} {{ {property} }}  beats  .{class} {{ {property} }}"
                    ));
                }
            }
        }
    }

    assert!(
        cancels.is_empty(),
        "{} hand-written rule(s) on a bare generated class set a property the \
         design system varies on that class by state, tone or context. The app \
         sheet sits in a later cascade layer than @layer makeover, and layers \
         resolve before specificity, so each of these beats every variant named \
         beside it, everywhere:\n{}\n\nDelete the declaration, or restate each \
         cancelled variant in the app's sheet on its own arm, after the bare rule \
         (`color: revert-layer` hands the design system's value back). That is \
         the remedy the cascade allows; an allowed-list entry does not cover \
         this, because the reviewed pair is the class and the variants are \
         what it silently takes.",
        cancels.len(),
        cancels.join("\n")
    );

    assert!(
        clashes.is_empty(),
        "{} hand-written declaration(s) take a property the generated stylesheet, \
         or an upstream sheet named to this check, already sets on the same \
         class. App CSS wins over @layer makeover, whether by a later layer or \
         by being unlayered, so each of these wins over the design system \
         silently:\n{}\n\nDelete the declaration, or, if \
         it is a deliberate pairing on a different selector arm, add \
         (class, property) to this check's allowed list and say why beside it. \
         Count the consumers before deciding a divergence is worth keeping.",
        clashes.len(),
        clashes.join("\n")
    );

    assert!(
        element_clashes.is_empty(),
        "{} hand-written element rule(s) take a property the generated \
         stylesheet sets on a class that element carries. App CSS wins over \
         @layer makeover, whether by a later layer or by being unlayered, so a \
         described component rendered on one of these elements loses the \
         design system's version of that property silently, which can draw a \
         destructive act like an ordinary one:\n{}\n\nHand the \
         property back on the arms makeover paints \
         (`.{{class}}:disabled {{ color: revert-layer }}`), scope the element \
         rule so it stops reaching described markup, or add \
         (element, class, property) to this check's allowed-elements list and \
         say why beside it.",
        element_clashes.len(),
        element_clashes.join("\n")
    );

    assert_no_stale("allowed", allowed, |(class, property)| {
        seen.contains(&((*class).to_string(), (*property).to_string()))
    });
    assert_no_stale(
        "allowed-elements",
        allowed_elements,
        |(element, class, property)| {
            element_seen.contains(&(
                (*element).to_string(),
                (*class).to_string(),
                (*property).to_string(),
            ))
        },
    );
}

/// Fail on an allowed-list entry that no longer collides with anything.
fn assert_no_stale<T: std::fmt::Debug>(list: &str, entries: &[T], used: impl Fn(&T) -> bool) {
    let stale: Vec<&T> = entries.iter().filter(|entry| !used(entry)).collect();
    assert!(
        stale.is_empty(),
        "the {list} list declares {stale:?}, which no longer collides with \
         anything. Delete the entries: an exception nobody is using is where the \
         next real collision lands and reads as company."
    );
}

/// Whether `haystack` names `class` whole, rather than as part of a longer
/// name: `min-1` must not be read as used because `min-16` is, and `row` must
/// not be read as used because `row-flex` or `flex-row` is.
pub(super) fn haystack_names(haystack: &str, class: &str) -> bool {
    haystack.match_indices(class).any(|(at, found)| {
        haystack[..at]
            .chars()
            .next_back()
            .is_none_or(|c| !is_ident(c))
            && haystack[at + found.len()..]
                .chars()
                .next()
                .is_none_or(|c| !is_ident(c))
    })
}

/// Every maximal run of identifier characters in `haystack`: the names
/// [`haystack_names`] would find whole, gathered in one pass.
pub(super) fn haystack_words(haystack: &str) -> std::collections::HashSet<&str> {
    haystack
        .split(|c: char| !is_ident(c))
        .filter(|word| !word.is_empty())
        .collect()
}

/// Warn when the generated vocabulary has grown dead, and fail when it grows
/// deader than the recorded high-water mark.
///
/// A generated class is unused when its name appears whole in none of the
/// `markup` files. The check is one-sided: more unused classes than
/// `high_water` fails; fewer warns and asks for `high_water` to be lowered.
///
/// `markup` is every file that can carry a class: templates, `.js`, `.html`,
/// and any Rust that writes markup. A class is counted as used if its name
/// appears whole in any of them, however that file builds its class strings.
///
/// # Panics
///
/// If a listed file cannot be read, or if more classes are unused than
/// `high_water`.
pub fn check_vocabulary_use<P: AsRef<Path>>(markup: &[P], opts: &Emit, high_water: usize) {
    let generated = crate::vocabulary::names(opts);
    let mut haystack = String::new();
    for path in markup {
        let path = path.as_ref();
        rerun(path);
        haystack.push_str(&read(path));
        haystack.push('\n');
    }

    // A ladder is one piece of vocabulary, not one per rung. A column carries
    // whichever `min-N` rung its floor lands on and a table whichever `short-N`
    // `stacks-N`, `tiles-N` and `drop-*-N` rungs its floors need, so no site names every rung and counting each
    // would seal the dead count at the ladder's length. A ladder is used if any
    // rung is, and counted once if none is.
    const LADDERS: &[&str] = &[
        "min-",
        "short-",
        "stacks-",
        "tiles-",
        "drop-optional-",
        "drop-secondary-",
    ];
    let rung_of = |class: &str| -> Option<&'static str> {
        let name = class.strip_prefix(opts.class_prefix)?;
        LADDERS.iter().copied().find(|ladder| {
            name.strip_prefix(ladder)
                .is_some_and(|n| !n.is_empty() && n.bytes().all(|b| b.is_ascii_digit()))
        })
    };
    // One pass over the markup, then a lookup per class. A class is an
    // identifier, so the set holds it exactly when the haystack names it whole;
    // anything else is searched for.
    let words = haystack_words(&haystack);
    let named = |class: &str| {
        if class.chars().all(is_ident) {
            words.contains(class)
        } else {
            haystack_names(&haystack, class)
        }
    };
    let mut unused: Vec<String> = generated
        .iter()
        .filter(|class| rung_of(class).is_none() && !named(class))
        .cloned()
        .collect();
    for ladder in LADDERS {
        let rungs: Vec<&String> = generated
            .iter()
            .filter(|class| rung_of(class) == Some(ladder))
            .collect();
        if !rungs.is_empty() && !rungs.iter().any(|class| named(class)) {
            unused.push(format!("{}{ladder}N", opts.class_prefix));
        }
    }

    assert!(
        unused.len() <= high_water,
        "{} of {} generated classes are emitted by no markup, above the recorded {}. \
         The vocabulary grew or the markup stopped using it:\n{}",
        unused.len(),
        generated.len(),
        high_water,
        unused
            .iter()
            .map(|c| format!("  .{c}"))
            .collect::<Vec<_>>()
            .join("\n")
    );

    if unused.len() < high_water {
        println!(
            "cargo::warning=dead makeover vocabulary is down to {} from a sealed {}; \
             lower the seal so it cannot grow back",
            unused.len(),
            high_water
        );
    }
}