adler-core 0.14.0

Core engine for the Adler OSINT username-search tool.
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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
//! Stable identity-clustering models built from structured profile evidence.
//!
//! This module intentionally lives alongside the older [`crate::correlate`]
//! report. The legacy report remains useful for compact CLI output, while
//! these serde-compatible types are the foundation for Web, MCP, and future
//! investigation reports.

use std::collections::{BTreeMap, BTreeSet};

use serde::{Deserialize, Serialize};

use crate::check::{CheckOutcome, MatchKind};
use crate::confidence::ConfidenceScore;
use crate::profile::{ProfileEvidence, ProfileEvidenceKind};

const LINK_THRESHOLD: u8 = 60;
const EXTERNAL_LINK_SCORE: u8 = 90;
const AVATAR_URL_SCORE: u8 = 85;
const DISPLAY_NAME_SCORE: u8 = 60;
const BIO_PHRASE_SCORE: u8 = 65;
const LOCATION_SCORE: u8 = 45;
const MAX_CLUSTER_CONFIDENCE: u8 = 95;
const MIN_DISPLAY_NAME_CHARS: usize = 8;
const MIN_DISPLAY_NAME_TOKENS: usize = 2;
const MIN_BIO_PHRASE_TOKENS: usize = 3;

const BIO_STOP_WORDS: &[&str] = &[
    "about", "and", "are", "for", "from", "has", "have", "into", "that", "the", "this", "was",
    "were", "with", "you", "your",
];

/// A positive profile observation suitable for identity-level reasoning.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ObservedProfile {
    /// Site name that produced the positive result.
    pub site: String,
    /// Username or handle being investigated.
    pub username: String,
    /// Concrete profile URL that was observed.
    pub url: String,
    /// Structured profile facts extracted from the result.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub evidence: Vec<ProfileEvidence>,
    /// Per-profile verdict confidence.
    pub confidence: ConfidenceScore,
    /// Earliest observation timestamp among the profile evidence items.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub observed_at_ms: Option<u64>,
}

impl ObservedProfile {
    /// Build an observed profile from a `Found` outcome with structured
    /// profile evidence.
    #[must_use]
    pub fn from_outcome(username: &str, outcome: &CheckOutcome) -> Option<Self> {
        if outcome.kind != MatchKind::Found || outcome.profile_evidence.is_empty() {
            return None;
        }

        let observed_at_ms = outcome
            .profile_evidence
            .iter()
            .filter_map(|evidence| evidence.source.observed_at_ms)
            .min();

        Some(Self {
            site: outcome.site.clone(),
            username: username.to_owned(),
            url: outcome.url.clone(),
            evidence: outcome.profile_evidence.clone(),
            confidence: outcome.confidence.clone(),
            observed_at_ms,
        })
    }
}

/// A deterministic candidate group of profiles that likely belong together.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct IdentityCluster {
    /// Stable deterministic identifier within this clustering result.
    pub id: String,
    /// Observed profiles included in the cluster.
    pub members: Vec<ObservedProfile>,
    /// Cluster-level confidence in `0..=100`, separate from per-profile
    /// verdict confidence.
    pub confidence: u8,
    /// Evidence reasons that linked the cluster members.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub reasons: Vec<ClusterReason>,
    /// Whether the cluster is linked only by weak or ambiguous evidence.
    pub uncertain: bool,
}

/// Deterministic reasons used to link observed profiles.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum ClusterReason {
    /// Profiles share the same normalized display name.
    SharedDisplayName {
        /// Normalized shared display name.
        value: String,
    },
    /// Profiles share a normalized phrase from their biography text.
    SharedBioPhrase {
        /// Shared normalized biography phrase.
        phrase: String,
    },
    /// Profiles share the same normalized external link.
    SharedExternalLink {
        /// Normalized external URL or link value.
        value: String,
    },
    /// Profiles share the same normalized location.
    SharedLocation {
        /// Normalized shared location value.
        value: String,
    },
    /// Profiles share the same normalized avatar URL.
    SharedAvatarUrl {
        /// Normalized avatar URL.
        value: String,
    },
    /// Profiles historically appeared together in repeated scans.
    HistoricalCoOccurrence,
}

/// Build deterministic identity clusters from scan outcomes.
///
/// Only `Found` outcomes with structured `profile_evidence` are considered.
/// The supplied `username` is copied into each observed profile, but username
/// equality is never used as a linking signal.
#[must_use]
pub fn build_identity_clusters(username: &str, outcomes: &[CheckOutcome]) -> Vec<IdentityCluster> {
    let mut profiles: Vec<ObservedProfile> = outcomes
        .iter()
        .filter_map(|outcome| ObservedProfile::from_outcome(username, outcome))
        .collect();

    profiles.sort_by(|left, right| {
        left.site
            .cmp(&right.site)
            .then_with(|| left.url.cmp(&right.url))
    });

    cluster_observed_profiles(&profiles)
}

fn cluster_observed_profiles(profiles: &[ObservedProfile]) -> Vec<IdentityCluster> {
    if profiles.len() < 2 {
        return Vec::new();
    }

    let mut union_find = UnionFind::new(profiles.len());
    let mut links = Vec::new();

    for left in 0..profiles.len() {
        for right in (left + 1)..profiles.len() {
            if let Some(link) = profile_link(left, right, &profiles[left], &profiles[right]) {
                union_find.union(left, right);
                links.push(link);
            }
        }
    }

    let mut by_root: BTreeMap<usize, Vec<usize>> = BTreeMap::new();
    for index in 0..profiles.len() {
        by_root
            .entry(union_find.find(index))
            .or_default()
            .push(index);
    }

    let mut clusters = Vec::new();
    for member_indices in by_root.values().filter(|members| members.len() >= 2) {
        let members_set: BTreeSet<usize> = member_indices.iter().copied().collect();
        let cluster_links: Vec<&ProfileLink> = links
            .iter()
            .filter(|link| members_set.contains(&link.left) && members_set.contains(&link.right))
            .collect();

        if cluster_links.is_empty() {
            continue;
        }

        let reasons = cluster_reasons(&cluster_links);
        let mut members: Vec<ObservedProfile> = member_indices
            .iter()
            .map(|&index| profiles[index].clone())
            .collect();
        members.sort_by(|left, right| {
            left.site
                .cmp(&right.site)
                .then_with(|| left.url.cmp(&right.url))
        });

        clusters.push(IdentityCluster {
            id: String::new(),
            members,
            confidence: cluster_confidence(&cluster_links),
            reasons,
            uncertain: cluster_links.iter().any(|link| !link.strong),
        });
    }

    clusters.sort_by(|left, right| {
        right
            .confidence
            .cmp(&left.confidence)
            .then_with(|| member_order(left).cmp(member_order(right)))
    });

    for (index, cluster) in clusters.iter_mut().enumerate() {
        cluster.id = format!("identity-{index:04}", index = index + 1);
    }

    clusters
}

fn cluster_reasons(links: &[&ProfileLink]) -> Vec<ClusterReason> {
    links
        .iter()
        .flat_map(|link| link.reasons.iter().cloned())
        .collect::<BTreeSet<_>>()
        .into_iter()
        .collect()
}

fn cluster_confidence(links: &[&ProfileLink]) -> u8 {
    let sum: u32 = links.iter().map(|link| u32::from(link.score)).sum();
    let count = u32::try_from(links.len()).unwrap_or(u32::MAX);
    let rounded = (sum + (count / 2)) / count;
    u8::try_from(rounded).unwrap_or(MAX_CLUSTER_CONFIDENCE)
}

fn member_order(cluster: &IdentityCluster) -> impl Iterator<Item = (&String, &String)> {
    cluster
        .members
        .iter()
        .map(|member| (&member.site, &member.url))
}

#[derive(Debug, Clone)]
struct ProfileLink {
    left: usize,
    right: usize,
    score: u8,
    reasons: Vec<ClusterReason>,
    strong: bool,
}

fn profile_link(
    left: usize,
    right: usize,
    left_profile: &ObservedProfile,
    right_profile: &ObservedProfile,
) -> Option<ProfileLink> {
    let mut signals = Vec::new();

    if let Some(value) = shared_value(
        left_profile,
        right_profile,
        ProfileEvidenceKind::ExternalLink,
        normalize_url,
    ) {
        signals.push(LinkSignal::strong(
            EXTERNAL_LINK_SCORE,
            ClusterReason::SharedExternalLink { value },
        ));
    }

    if let Some(value) = shared_value(
        left_profile,
        right_profile,
        ProfileEvidenceKind::AvatarUrl,
        normalize_url,
    ) {
        signals.push(LinkSignal::strong(
            AVATAR_URL_SCORE,
            ClusterReason::SharedAvatarUrl { value },
        ));
    }

    if let Some(value) = shared_value(
        left_profile,
        right_profile,
        ProfileEvidenceKind::DisplayName,
        normalize_text,
    )
    .filter(|value| conservative_display_name(value))
    {
        signals.push(LinkSignal::weak(
            DISPLAY_NAME_SCORE,
            ClusterReason::SharedDisplayName { value },
        ));
    }

    if let Some(phrase) = shared_bio_phrase(left_profile, right_profile) {
        signals.push(LinkSignal::weak(
            BIO_PHRASE_SCORE,
            ClusterReason::SharedBioPhrase { phrase },
        ));
    }

    if let Some(value) = shared_value(
        left_profile,
        right_profile,
        ProfileEvidenceKind::Location,
        normalize_text,
    ) {
        signals.push(LinkSignal::weak(
            LOCATION_SCORE,
            ClusterReason::SharedLocation { value },
        ));
    }

    if signals.is_empty() {
        return None;
    }

    let strong = signals.iter().any(|signal| signal.strong);
    let score = signals
        .iter()
        .map(|signal| signal.score)
        .fold(0_u8, u8::saturating_add)
        .min(MAX_CLUSTER_CONFIDENCE);
    if score < LINK_THRESHOLD {
        return None;
    }

    Some(ProfileLink {
        left,
        right,
        score,
        reasons: signals.into_iter().map(|signal| signal.reason).collect(),
        strong,
    })
}

#[derive(Debug, Clone)]
struct LinkSignal {
    score: u8,
    reason: ClusterReason,
    strong: bool,
}

impl LinkSignal {
    const fn strong(score: u8, reason: ClusterReason) -> Self {
        Self {
            score,
            reason,
            strong: true,
        }
    }

    const fn weak(score: u8, reason: ClusterReason) -> Self {
        Self {
            score,
            reason,
            strong: false,
        }
    }
}

fn shared_value(
    left_profile: &ObservedProfile,
    right_profile: &ObservedProfile,
    kind: ProfileEvidenceKind,
    normalize: fn(&str) -> String,
) -> Option<String> {
    let left_values = normalized_values(left_profile, kind, normalize);
    let right_values = normalized_values(right_profile, kind, normalize);
    left_values.intersection(&right_values).next().cloned()
}

fn normalized_values(
    profile: &ObservedProfile,
    kind: ProfileEvidenceKind,
    normalize: fn(&str) -> String,
) -> BTreeSet<String> {
    profile
        .evidence
        .iter()
        .filter(|evidence| evidence.kind == kind)
        .map(|evidence| normalize(&evidence.value))
        .filter(|value| !value.is_empty())
        .collect()
}

fn shared_bio_phrase(
    left_profile: &ObservedProfile,
    right_profile: &ObservedProfile,
) -> Option<String> {
    let left_phrases = bio_phrases(left_profile);
    let right_phrases = bio_phrases(right_profile);
    left_phrases.intersection(&right_phrases).next().cloned()
}

fn bio_phrases(profile: &ObservedProfile) -> BTreeSet<String> {
    profile
        .evidence
        .iter()
        .filter(|evidence| evidence.kind == ProfileEvidenceKind::Bio)
        .flat_map(|evidence| phrase_windows(&evidence.value))
        .collect()
}

fn phrase_windows(value: &str) -> BTreeSet<String> {
    let tokens = significant_tokens(value);
    if tokens.len() < MIN_BIO_PHRASE_TOKENS {
        return BTreeSet::new();
    }
    tokens
        .windows(MIN_BIO_PHRASE_TOKENS)
        .map(|window| window.join(" "))
        .collect()
}

fn significant_tokens(value: &str) -> Vec<String> {
    normalize_text(value)
        .split_whitespace()
        .filter(|token| token.chars().count() >= 3)
        .filter(|token| !BIO_STOP_WORDS.contains(token))
        .map(str::to_owned)
        .collect()
}

fn conservative_display_name(value: &str) -> bool {
    value.split_whitespace().count() >= MIN_DISPLAY_NAME_TOKENS
        && value.chars().filter(|ch| ch.is_alphanumeric()).count() >= MIN_DISPLAY_NAME_CHARS
}

fn normalize_text(value: &str) -> String {
    let mut normalized = String::with_capacity(value.len());
    for ch in value.chars() {
        if ch.is_alphanumeric() {
            for lower in ch.to_lowercase() {
                normalized.push(lower);
            }
        } else {
            normalized.push(' ');
        }
    }
    normalized.split_whitespace().collect::<Vec<_>>().join(" ")
}

fn normalize_url(value: &str) -> String {
    let trimmed = value.trim();
    if trimmed.is_empty() {
        return String::new();
    }

    let Ok(parsed) = url::Url::parse(trimmed) else {
        return normalize_text(trimmed);
    };

    let Some(host) = parsed.host_str() else {
        return parsed.to_string().trim_end_matches('/').to_lowercase();
    };

    let scheme = parsed.scheme().to_lowercase();
    let host = host.to_lowercase();
    let port = parsed
        .port()
        .map(|port| format!(":{port}"))
        .unwrap_or_default();
    let path = parsed.path().trim_end_matches('/');
    let path = if path.is_empty() { "/" } else { path };
    let query = parsed
        .query()
        .map(|query| format!("?{query}"))
        .unwrap_or_default();

    format!("{scheme}://{host}{port}{path}{query}")
}

struct UnionFind {
    parent: Vec<usize>,
}

impl UnionFind {
    fn new(len: usize) -> Self {
        Self {
            parent: (0..len).collect(),
        }
    }

    fn find(&mut self, node: usize) -> usize {
        let mut root = node;
        while self.parent[root] != root {
            root = self.parent[root];
        }

        let mut current = node;
        while self.parent[current] != root {
            let parent = self.parent[current];
            self.parent[current] = root;
            current = parent;
        }

        root
    }

    fn union(&mut self, left: usize, right: usize) {
        let left_root = self.find(left);
        let right_root = self.find(right);
        if left_root != right_root {
            self.parent[left_root] = right_root;
        }
    }
}

#[cfg(test)]
mod tests {
    use std::collections::BTreeMap;

    use super::*;
    use crate::{ConfidenceScore, TransportTier};

    fn found(site: &str, fields: &[(&str, &str)]) -> CheckOutcome {
        let url = format!("https://{}.example/alice", site.to_lowercase());
        let profile_evidence = fields
            .iter()
            .map(|(field, value)| ProfileEvidence::from_enrichment(site, &url, field, value))
            .collect();
        let mut outcome = CheckOutcome {
            site: site.to_owned(),
            url,
            kind: MatchKind::Found,
            reason: None,
            elapsed_ms: 10,
            enrichment: BTreeMap::new(),
            evidence: vec!["HTTP 200 (status_found)".to_owned()],
            profile_evidence,
            confidence: ConfidenceScore::default(),
            transport: Some(TransportTier::Http),
            escalations: 0,
        };
        outcome.refresh_confidence();
        outcome
    }

    #[test]
    fn shared_external_link_clusters_profiles() {
        let clusters = build_identity_clusters(
            "alice",
            &[
                found(
                    "GitHub",
                    &[("name", "Alice Example"), ("website", "https://Alice.dev/")],
                ),
                found("GitLab", &[("website", "https://alice.dev")]),
            ],
        );

        assert_eq!(clusters.len(), 1);
        assert_eq!(clusters[0].confidence, 90);
        assert!(!clusters[0].uncertain);
        assert_eq!(clusters[0].members[0].site, "GitHub");
        assert_eq!(clusters[0].members[1].site, "GitLab");
        assert!(
            clusters[0]
                .reasons
                .contains(&ClusterReason::SharedExternalLink {
                    value: "https://alice.dev/".to_owned(),
                })
        );
    }

    #[test]
    fn shared_display_name_clusters_only_above_conservative_threshold() {
        let strong_name = build_identity_clusters(
            "alice",
            &[
                found("GitHub", &[("name", "Alice Example")]),
                found("Mastodon", &[("name", "alice example")]),
            ],
        );
        assert_eq!(strong_name.len(), 1);
        assert!(strong_name[0].uncertain);
        assert_eq!(strong_name[0].confidence, 60);
        assert!(
            strong_name[0]
                .reasons
                .contains(&ClusterReason::SharedDisplayName {
                    value: "alice example".to_owned(),
                })
        );

        let weak_name = build_identity_clusters(
            "alice",
            &[
                found("GitHub", &[("name", "Alice")]),
                found("Mastodon", &[("name", "alice")]),
            ],
        );
        assert!(weak_name.is_empty());
    }

    #[test]
    fn username_only_matches_do_not_cluster() {
        let clusters =
            build_identity_clusters("alice", &[found("GitHub", &[]), found("GitLab", &[])]);

        assert!(clusters.is_empty());
    }

    #[test]
    fn username_evidence_only_matches_do_not_cluster() {
        let mut github = found("GitHub", &[]);
        github.profile_evidence = vec![ProfileEvidence::from_signal_username(
            "GitHub",
            &github.url,
            "alice",
            Some(100),
            None,
        )];
        github.refresh_confidence();

        let mut gitlab = found("GitLab", &[]);
        gitlab.profile_evidence = vec![ProfileEvidence::from_signal_username(
            "GitLab",
            &gitlab.url,
            "alice",
            Some(100),
            None,
        )];
        gitlab.refresh_confidence();

        let clusters = build_identity_clusters("alice", &[github, gitlab]);

        assert!(clusters.is_empty());
    }

    #[test]
    fn unrelated_profiles_remain_separate() {
        let clusters = build_identity_clusters(
            "alice",
            &[
                found(
                    "GitHub",
                    &[("name", "Alice Example"), ("website", "https://alice.dev")],
                ),
                found(
                    "Twitch",
                    &[("name", "Bob Example"), ("website", "https://bob.example")],
                ),
            ],
        );

        assert!(clusters.is_empty());
    }

    #[test]
    fn ambiguous_bio_phrase_links_are_marked_uncertain() {
        let clusters = build_identity_clusters(
            "alice",
            &[
                found("GitHub", &[("bio", "Rust systems researcher and builder")]),
                found("GitLab", &[("bio", "Rust systems researcher in Berlin")]),
            ],
        );

        assert_eq!(clusters.len(), 1);
        assert!(clusters[0].uncertain);
        assert_eq!(clusters[0].confidence, 65);
        assert!(
            clusters[0]
                .reasons
                .contains(&ClusterReason::SharedBioPhrase {
                    phrase: "rust systems researcher".to_owned(),
                })
        );
    }

    #[test]
    fn cluster_with_any_weak_edge_is_uncertain() {
        let clusters = build_identity_clusters(
            "alice",
            &[
                found("GitHub", &[("website", "https://alice.dev")]),
                found(
                    "GitLab",
                    &[("website", "https://alice.dev"), ("name", "Alice Example")],
                ),
                found("Mastodon", &[("name", "Alice Example")]),
            ],
        );

        assert_eq!(clusters.len(), 1);
        assert_eq!(clusters[0].members.len(), 3);
        assert!(clusters[0].uncertain);
        assert!(
            clusters[0]
                .reasons
                .contains(&ClusterReason::SharedExternalLink {
                    value: "https://alice.dev/".to_owned(),
                })
        );
        assert!(
            clusters[0]
                .reasons
                .contains(&ClusterReason::SharedDisplayName {
                    value: "alice example".to_owned(),
                })
        );
    }

    #[test]
    fn observed_profile_uses_earliest_evidence_timestamp() {
        let mut outcome = found("GitHub", &[("name", "Alice Example"), ("bio", "Rust")]);
        outcome.profile_evidence[0].source.observed_at_ms = Some(200);
        outcome.profile_evidence[1].source.observed_at_ms = Some(100);

        let observed = ObservedProfile::from_outcome("alice", &outcome).unwrap();

        assert_eq!(observed.observed_at_ms, Some(100));
        assert_eq!(observed.username, "alice");
    }

    #[test]
    fn not_found_outcomes_are_ignored_even_with_profile_evidence() {
        let mut outcome = found("GitHub", &[("name", "Alice Example")]);
        outcome.kind = MatchKind::NotFound;

        assert!(build_identity_clusters("alice", &[outcome]).is_empty());
    }

    #[test]
    fn cluster_reason_serializes_as_snake_case_tagged_data() {
        let reason = ClusterReason::SharedAvatarUrl {
            value: "https://cdn.example/avatar.png".to_owned(),
        };
        let json = serde_json::to_value(reason).unwrap();

        assert_eq!(json["kind"], "shared_avatar_url");
        assert_eq!(json["value"], "https://cdn.example/avatar.png");
    }
}