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
//! Tests for `is_cosmetic_alias_of_parent` — the noise-suppressor
//! that stops the /usage breakdown from rendering trivial-alias
//! variants under their canonical parent group.
//!
//! Regression context: 2026-05-30 user screenshot showed
//! `qwen-3.7-max` (parent) with `qwen3.7-max` (child, no hyphen
//! between `qwen` and `3.7`) listed as a separate variant under it.
//! Same model, different cosmetic separator — listing both is pure
//! noise. The SQL normalization already collapses them into the
//! same canonical parent for the total row, but the breakdown
//! tree still rendered the raw variant.
use crate::usage::data::is_cosmetic_alias_of_parent;
#[test]
fn no_separator_vs_hyphen_separator_is_alias() {
// The exact incident from the screenshot.
assert!(is_cosmetic_alias_of_parent("qwen3.7-max", "qwen-3.7-max"));
assert!(is_cosmetic_alias_of_parent("qwen-3.7-max", "qwen3.7-max"));
}
#[test]
fn dotted_vs_dashed_version_is_alias() {
// `qwen-3-7-max` (dash separators on version) vs the canonical
// `qwen-3.7-max` (dot). Both surface forms exist in the wild.
assert!(is_cosmetic_alias_of_parent("qwen-3-7-max", "qwen-3.7-max"));
assert!(is_cosmetic_alias_of_parent("qwen3-7-max", "qwen-3.7-max"));
}
#[test]
fn display_name_with_spaces_is_alias() {
// The model registry sometimes records the human-readable
// display name. Same model, just formatted for a label.
assert!(is_cosmetic_alias_of_parent("Qwen 3.7 Max", "qwen-3.7-max"));
assert!(is_cosmetic_alias_of_parent("QWEN 3.7 MAX", "qwen-3.7-max"));
}
#[test]
fn preview_variant_is_not_an_alias() {
// -preview is a meaningfully different model (different
// weights, different API endpoint). Must NOT collapse.
assert!(!is_cosmetic_alias_of_parent(
"qwen-3.7-max-preview",
"qwen-3.7-max"
));
assert!(!is_cosmetic_alias_of_parent(
"qwen3.7-max-preview",
"qwen-3.7-max"
));
}
#[test]
fn dated_snapshot_is_not_an_alias() {
// -20260520 is a pinned snapshot. Even if the SQL groups it
// under qwen-3.7-max for the total row, the breakdown should
// still surface it because seeing "30% of spend was on the
// dated snapshot" is useful operational info.
assert!(!is_cosmetic_alias_of_parent(
"qwen-3.7-max-20260520",
"qwen-3.7-max"
));
assert!(!is_cosmetic_alias_of_parent(
"qwen3.7-max-20260520",
"qwen-3.7-max"
));
}
#[test]
fn latest_series_invite_beta_is_not_an_alias() {
// The `qwen-latest-series-invite-beta-v34` channel has its own
// canonical form. Showing it as a variant of qwen-3.7-max is
// useful — that's how the user knows what's funding the spend.
assert!(!is_cosmetic_alias_of_parent(
"qwen-latest-series-invite-beta-v34",
"qwen-3.7-max"
));
}
#[test]
fn empty_strings_compare_equal() {
// Defensive: both empty → canonically same. The caller
// shouldn't be invoking with empty model names, but the
// function should not panic.
assert!(is_cosmetic_alias_of_parent("", ""));
}
#[test]
fn whitespace_only_collapses_to_empty() {
// `" "` and `""` canonicalize to the same empty string.
assert!(is_cosmetic_alias_of_parent(" ", ""));
}
#[test]
fn unrelated_models_are_not_aliases() {
assert!(!is_cosmetic_alias_of_parent("opus-4-6", "qwen-3.7-max"));
assert!(!is_cosmetic_alias_of_parent(
"qwen-3.6-plus",
"qwen-3.7-max"
));
assert!(!is_cosmetic_alias_of_parent("kimi-k2.6", "qwen-3.7-max"));
}
#[test]
fn version_family_difference_is_not_an_alias() {
// `qwen-3.6-max` vs `qwen-3.7-max` — different version
// families. MUST NOT collapse even though the prefix matches.
assert!(!is_cosmetic_alias_of_parent("qwen-3.6-max", "qwen-3.7-max"));
assert!(!is_cosmetic_alias_of_parent("qwen3.6-max", "qwen-3.7-max"));
}
#[test]
fn underscore_vs_dash_is_alias() {
// Some model registries use underscores. Same canonical form
// since both `_` and `-` are non-alphanumeric.
assert!(is_cosmetic_alias_of_parent("qwen_3_7_max", "qwen-3.7-max"));
}
#[test]
fn slash_separator_is_alias() {
// Provider-prefixed forms like `qwen/3.7-max` should also
// canonicalize the same.
assert!(is_cosmetic_alias_of_parent("qwen/3.7-max", "qwen-3.7-max"));
}
#[test]
fn case_only_difference_is_alias() {
assert!(is_cosmetic_alias_of_parent("Qwen-3.7-Max", "qwen-3.7-max"));
}