idiolect-records 0.7.0

Rust record types mirroring the dev.idiolect.* Lexicon family.
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
// @generated by idiolect-codegen. do not edit.
// source: dev.idiolect.bounty

//! A declaration that a translation, verification, or adapter is wanted, with terms. `constraints` is a structured ThConstraint tagged-union set and `eligibility` is a ThEligibility combinator tree; reward.summary stays narrative, externalRef stays the machine-actionable hook. Per P5, the project does not intermediate fulfillment: payment, review, and acceptance happen on external rails referenced here.

#![allow(
    missing_docs,
    clippy::doc_markdown,
    clippy::struct_excessive_bools,
    clippy::derive_partial_eq_without_eq,
    clippy::large_enum_variant
)]
use serde::{Deserialize, Serialize};

/// A request primitive. Someone states what they want (a lens, a verification, an adapter) and the structured constraints + eligibility they require; fulfillment is resolved off-substrate.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Bounty {
    /// Grounding for the bouletic attitude. Omit when the repo owner is the requester (self-asserted). Set explicitly when a third party is attributing the wanting to another party — the basis records on what grounds the attribution is made (community policy, an off-atproto signal, or derivation from another record).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub basis: Option<crate::generated::dev::idiolect::defs::Basis>,
    /// Structured constraints the deliverable must satisfy. Matching is structural: consumers dispatch on the tagged variant.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub constraints: Option<Vec<BountyConstraints>>,
    /// Structured eligibility predicate in postfix-operator form: each item is either an atomic predicate or a combinator (and/or/not) that pops its operands from the running stack. An empty array means 'no eligibility restriction'. A single atomic item is the lone predicate.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub eligibility: Option<Vec<BountyEligibility>>,
    /// Once fulfilled, points to the deliverable record (lens, verification, or adapter).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub fulfillment: Option<idiolect_records::AtUri>,
    pub occurred_at: idiolect_records::Datetime,
    pub requester: idiolect_records::Did,
    /// Reward terms. The bounty record does not transact; `externalRef` is the machine-actionable hook; `summary` is narrative.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reward: Option<BountyReward>,
    /// Open-enum lifecycle slug declared by the requester. Resolved against `statusVocab` when present.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<BountyStatus>,
    /// Vocabulary the `status` slug resolves against.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status_vocab: Option<crate::generated::dev::idiolect::defs::VocabRef>,
    /// What is being requested. Exactly one of: a lens between two schemas, a verification of a lens, or an adapter for a framework.
    pub wants: BountyWants,
}

impl crate::Record for Bounty {
    const NSID: &'static str = "dev.idiolect.bounty";
}

/// A verification kind (and optionally a specific property) the deliverable must pass.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintConformance {
    /// Open-enum verification-kind slug. Resolved against `kindVocab` when present.
    pub kind: ConstraintConformanceKind,
    /// Vocabulary the `kind` slug resolves against.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind_vocab: Option<crate::generated::dev::idiolect::defs::VocabRef>,
    /// Optional specific property the verification must establish.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub property: Option<crate::generated::dev::idiolect::defs::LensProperty>,
}

/// Datetime deadline with optional grace window.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintDeadline {
    pub deadline: idiolect_records::Datetime,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grace_seconds: Option<i64>,
}

/// Another bounty this one waits on. Claims are ineligible until the dependency's status is `fulfilled`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintDependency {
    pub bounty: idiolect_records::AtUri,
}

/// License requirement expressed as an SPDX expression plus optional allow/deny lists.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintLicense {
    /// Explicit allowlist of SPDX identifiers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub allow: Option<Vec<String>>,
    /// Explicit denylist of SPDX identifiers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub deny: Option<Vec<String>>,
    /// SPDX expression the deliverable must satisfy (e.g. 'MIT OR Apache-2.0').
    pub spdx: String,
}

/// Quantitative performance bound (latency, throughput, error rate) the deliverable must meet.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintPerformance {
    /// How `metric` relates to `threshold`. Default 'le' if omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cmp: Option<ConstraintPerformanceCmp>,
    /// Metric identifier (e.g. 'p99-latency-ms', 'throughput-rps', 'error-rate').
    pub metric: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sample_size: Option<i64>,
    /// Numeric threshold. Comparison direction is carried by `cmp`.
    pub threshold: f64,
}

/// Combinator: conjoin the top two predicates on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityAnd {}

/// Atomic predicate: claimer's DID matches exactly.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityDid {
    pub did: idiolect_records::Did,
}

/// Atomic predicate: claimer is a member of the named community.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityMember {
    pub community: idiolect_records::AtUri,
}

/// Combinator: negate the top predicate on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityNot {}

/// Combinator: disjoin the top two predicates on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityOr {}

/// Atomic predicate: claimer has published a verification for the named lens property.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityVerificationFor {
    pub property: crate::generated::dev::idiolect::defs::LensProperty,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantAdapter {
    pub framework: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub version_range: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantLens {
    /// Whether the requested lens must be invertible.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub bidirectional: Option<bool>,
    pub source: crate::generated::dev::idiolect::defs::SchemaRef,
    pub target: crate::generated::dev::idiolect::defs::SchemaRef,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantVerification {
    /// Open-enum verification-kind slug. Resolved against `kindVocab` when present, otherwise against the canonical idiolect verification-kinds vocabulary.
    pub kind: WantVerificationKind,
    /// Vocabulary the `kind` slug resolves against.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind_vocab: Option<crate::generated::dev::idiolect::defs::VocabRef>,
    pub lens: crate::generated::dev::idiolect::defs::LensRef,
}

/// ConstraintConformanceKind. Open-enum slug; known values are kebab-cased; community-extended values pass through as `Other(String)`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ConstraintConformanceKind {
    RoundtripTest,
    PropertyTest,
    FormalProof,
    ConformanceTest,
    StaticCheck,
    ConvergencePreserving,
    /// Community-extended slug not present in the lexicon's
    /// `knownValues`. Resolves through the sibling
    /// `*Vocab` field on the containing record.
    Other(String),
}
impl ConstraintConformanceKind {
    /// Wire-form slug for this value. Known variants render
    /// kebab-case; the fallback variant passes through verbatim.
    #[must_use]
    pub fn as_str(&self) -> &str {
        match self {
            Self::RoundtripTest => "roundtrip-test",
            Self::PropertyTest => "property-test",
            Self::FormalProof => "formal-proof",
            Self::ConformanceTest => "conformance-test",
            Self::StaticCheck => "static-check",
            Self::ConvergencePreserving => "convergence-preserving",
            Self::Other(s) => s.as_str(),
        }
    }
    /// Whether this slug is subsumed by `ancestor` under the
    /// `subsumed_by` relation in the supplied vocab. Reflexive:
    /// every slug is subsumed by itself.
    #[must_use]
    pub fn is_subsumed_by(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        ancestor: &str,
    ) -> bool {
        vocab.is_subsumed_by(self.as_str(), ancestor)
    }
    /// Whether this slug satisfies a requirement of `target`
    /// under the named `relation` in the supplied vocab.
    /// Generalises `is_subsumed_by` to any directed relation
    /// (e.g. `stronger_than`, `provides_at_least`,
    /// `equivalent_to`). Reflexive: a slug satisfies itself.
    #[must_use]
    pub fn satisfies(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        relation: &str,
        target: &str,
    ) -> bool {
        if self.as_str() == target {
            return true;
        }
        vocab
            .walk_relation(self.as_str(), relation, false)
            .iter()
            .any(|n| n == target)
    }
    /// Translate this slug across vocabularies via
    /// `equivalent_to` edges. Returns the translated slug as
    /// a target enum value when a translation exists, `None`
    /// when no path is found (callers fall back to passing
    /// the slug through verbatim, which is wire-compatible).
    #[must_use]
    pub fn translate_to<T: From<String>>(
        &self,
        src_vocab_uri: &str,
        tgt_vocab_uri: &str,
        registry: &idiolect_records::vocab::VocabRegistry,
    ) -> Option<T> {
        registry
            .translate(src_vocab_uri, tgt_vocab_uri, self.as_str())
            .map(T::from)
    }
}
impl From<String> for ConstraintConformanceKind {
    fn from(s: String) -> Self {
        match s.as_str() {
            "roundtrip-test" => Self::RoundtripTest,
            "property-test" => Self::PropertyTest,
            "formal-proof" => Self::FormalProof,
            "conformance-test" => Self::ConformanceTest,
            "static-check" => Self::StaticCheck,
            "convergence-preserving" => Self::ConvergencePreserving,
            _ => Self::Other(s),
        }
    }
}
impl From<&str> for ConstraintConformanceKind {
    fn from(s: &str) -> Self {
        match s {
            "roundtrip-test" => Self::RoundtripTest,
            "property-test" => Self::PropertyTest,
            "formal-proof" => Self::FormalProof,
            "conformance-test" => Self::ConformanceTest,
            "static-check" => Self::StaticCheck,
            "convergence-preserving" => Self::ConvergencePreserving,
            _ => Self::Other(s.to_owned()),
        }
    }
}
impl serde::Serialize for ConstraintConformanceKind {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for ConstraintConformanceKind {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = String::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

/// ConstraintPerformanceCmp.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ConstraintPerformanceCmp {
    Lt,
    Le,
    Eq,
    Ge,
    Gt,
}

/// WantVerificationKind. Open-enum slug; known values are kebab-cased; community-extended values pass through as `Other(String)`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum WantVerificationKind {
    RoundtripTest,
    PropertyTest,
    FormalProof,
    ConformanceTest,
    StaticCheck,
    ConvergencePreserving,
    /// Community-extended slug not present in the lexicon's
    /// `knownValues`. Resolves through the sibling
    /// `*Vocab` field on the containing record.
    Other(String),
}
impl WantVerificationKind {
    /// Wire-form slug for this value. Known variants render
    /// kebab-case; the fallback variant passes through verbatim.
    #[must_use]
    pub fn as_str(&self) -> &str {
        match self {
            Self::RoundtripTest => "roundtrip-test",
            Self::PropertyTest => "property-test",
            Self::FormalProof => "formal-proof",
            Self::ConformanceTest => "conformance-test",
            Self::StaticCheck => "static-check",
            Self::ConvergencePreserving => "convergence-preserving",
            Self::Other(s) => s.as_str(),
        }
    }
    /// Whether this slug is subsumed by `ancestor` under the
    /// `subsumed_by` relation in the supplied vocab. Reflexive:
    /// every slug is subsumed by itself.
    #[must_use]
    pub fn is_subsumed_by(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        ancestor: &str,
    ) -> bool {
        vocab.is_subsumed_by(self.as_str(), ancestor)
    }
    /// Whether this slug satisfies a requirement of `target`
    /// under the named `relation` in the supplied vocab.
    /// Generalises `is_subsumed_by` to any directed relation
    /// (e.g. `stronger_than`, `provides_at_least`,
    /// `equivalent_to`). Reflexive: a slug satisfies itself.
    #[must_use]
    pub fn satisfies(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        relation: &str,
        target: &str,
    ) -> bool {
        if self.as_str() == target {
            return true;
        }
        vocab
            .walk_relation(self.as_str(), relation, false)
            .iter()
            .any(|n| n == target)
    }
    /// Translate this slug across vocabularies via
    /// `equivalent_to` edges. Returns the translated slug as
    /// a target enum value when a translation exists, `None`
    /// when no path is found (callers fall back to passing
    /// the slug through verbatim, which is wire-compatible).
    #[must_use]
    pub fn translate_to<T: From<String>>(
        &self,
        src_vocab_uri: &str,
        tgt_vocab_uri: &str,
        registry: &idiolect_records::vocab::VocabRegistry,
    ) -> Option<T> {
        registry
            .translate(src_vocab_uri, tgt_vocab_uri, self.as_str())
            .map(T::from)
    }
}
impl From<String> for WantVerificationKind {
    fn from(s: String) -> Self {
        match s.as_str() {
            "roundtrip-test" => Self::RoundtripTest,
            "property-test" => Self::PropertyTest,
            "formal-proof" => Self::FormalProof,
            "conformance-test" => Self::ConformanceTest,
            "static-check" => Self::StaticCheck,
            "convergence-preserving" => Self::ConvergencePreserving,
            _ => Self::Other(s),
        }
    }
}
impl From<&str> for WantVerificationKind {
    fn from(s: &str) -> Self {
        match s {
            "roundtrip-test" => Self::RoundtripTest,
            "property-test" => Self::PropertyTest,
            "formal-proof" => Self::FormalProof,
            "conformance-test" => Self::ConformanceTest,
            "static-check" => Self::StaticCheck,
            "convergence-preserving" => Self::ConvergencePreserving,
            _ => Self::Other(s.to_owned()),
        }
    }
}
impl serde::Serialize for WantVerificationKind {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for WantVerificationKind {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = String::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

/// BountyConstraints tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyConstraints {
    #[serde(rename = "dev.idiolect.bounty#constraintPerformance")]
    ConstraintPerformance(ConstraintPerformance),
    #[serde(rename = "dev.idiolect.bounty#constraintConformance")]
    ConstraintConformance(ConstraintConformance),
    #[serde(rename = "dev.idiolect.bounty#constraintLicense")]
    ConstraintLicense(ConstraintLicense),
    #[serde(rename = "dev.idiolect.bounty#constraintDeadline")]
    ConstraintDeadline(ConstraintDeadline),
    #[serde(rename = "dev.idiolect.bounty#constraintDependency")]
    ConstraintDependency(ConstraintDependency),
}

/// BountyEligibility tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyEligibility {
    #[serde(rename = "dev.idiolect.bounty#eligibilityMember")]
    EligibilityMember(EligibilityMember),
    #[serde(rename = "dev.idiolect.bounty#eligibilityVerificationFor")]
    EligibilityVerificationFor(EligibilityVerificationFor),
    #[serde(rename = "dev.idiolect.bounty#eligibilityDid")]
    EligibilityDid(EligibilityDid),
    #[serde(rename = "dev.idiolect.bounty#eligibilityAnd")]
    EligibilityAnd(EligibilityAnd),
    #[serde(rename = "dev.idiolect.bounty#eligibilityOr")]
    EligibilityOr(EligibilityOr),
    #[serde(rename = "dev.idiolect.bounty#eligibilityNot")]
    EligibilityNot(EligibilityNot),
}

/// BountyWants tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyWants {
    #[serde(rename = "dev.idiolect.bounty#wantLens")]
    WantLens(WantLens),
    #[serde(rename = "dev.idiolect.bounty#wantVerification")]
    WantVerification(WantVerification),
    #[serde(rename = "dev.idiolect.bounty#wantAdapter")]
    WantAdapter(WantAdapter),
}

/// BountyStatus. Open-enum slug; known values are kebab-cased; community-extended values pass through as `Other(String)`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BountyStatus {
    Open,
    Claimed,
    Fulfilled,
    Withdrawn,
    /// Community-extended slug not present in the lexicon's
    /// `knownValues`. Resolves through the sibling
    /// `*Vocab` field on the containing record.
    Other(String),
}
impl BountyStatus {
    /// Wire-form slug for this value. Known variants render
    /// kebab-case; the fallback variant passes through verbatim.
    #[must_use]
    pub fn as_str(&self) -> &str {
        match self {
            Self::Open => "open",
            Self::Claimed => "claimed",
            Self::Fulfilled => "fulfilled",
            Self::Withdrawn => "withdrawn",
            Self::Other(s) => s.as_str(),
        }
    }
    /// Whether this slug is subsumed by `ancestor` under the
    /// `subsumed_by` relation in the supplied vocab. Reflexive:
    /// every slug is subsumed by itself.
    #[must_use]
    pub fn is_subsumed_by(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        ancestor: &str,
    ) -> bool {
        vocab.is_subsumed_by(self.as_str(), ancestor)
    }
    /// Whether this slug satisfies a requirement of `target`
    /// under the named `relation` in the supplied vocab.
    /// Generalises `is_subsumed_by` to any directed relation
    /// (e.g. `stronger_than`, `provides_at_least`,
    /// `equivalent_to`). Reflexive: a slug satisfies itself.
    #[must_use]
    pub fn satisfies(
        &self,
        vocab: &idiolect_records::vocab::VocabGraph,
        relation: &str,
        target: &str,
    ) -> bool {
        if self.as_str() == target {
            return true;
        }
        vocab
            .walk_relation(self.as_str(), relation, false)
            .iter()
            .any(|n| n == target)
    }
    /// Translate this slug across vocabularies via
    /// `equivalent_to` edges. Returns the translated slug as
    /// a target enum value when a translation exists, `None`
    /// when no path is found (callers fall back to passing
    /// the slug through verbatim, which is wire-compatible).
    #[must_use]
    pub fn translate_to<T: From<String>>(
        &self,
        src_vocab_uri: &str,
        tgt_vocab_uri: &str,
        registry: &idiolect_records::vocab::VocabRegistry,
    ) -> Option<T> {
        registry
            .translate(src_vocab_uri, tgt_vocab_uri, self.as_str())
            .map(T::from)
    }
}
impl From<String> for BountyStatus {
    fn from(s: String) -> Self {
        match s.as_str() {
            "open" => Self::Open,
            "claimed" => Self::Claimed,
            "fulfilled" => Self::Fulfilled,
            "withdrawn" => Self::Withdrawn,
            _ => Self::Other(s),
        }
    }
}
impl From<&str> for BountyStatus {
    fn from(s: &str) -> Self {
        match s {
            "open" => Self::Open,
            "claimed" => Self::Claimed,
            "fulfilled" => Self::Fulfilled,
            "withdrawn" => Self::Withdrawn,
            _ => Self::Other(s.to_owned()),
        }
    }
}
impl serde::Serialize for BountyStatus {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl<'de> serde::Deserialize<'de> for BountyStatus {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = String::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

/// Reward terms. The bounty record does not transact; `externalRef` is the machine-actionable hook; `summary` is narrative.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BountyReward {
    /// URL pointing to the rail that handles actual reward (grant portal, payment platform, attestation service).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub external_ref: Option<idiolect_records::Uri>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub summary: Option<String>,
}