qualia_core_db/modalities/capacity.rs
1//! Juridical capacity & state-transition (§18, legal_logic.md).
2//!
3//! Obligations and stipulations are only valid if the asserting agent had the legal/cognitive
4//! capacity to form them. This module is a **conservative** engine over the *existing*
5//! guardianship ontology vocabulary (`values:juridicalCapacity`, `CoercedConsentFlag`,
6//! `VoidableStipulation`, `values:guardian`, `survivesDeath`) — it wires terms Timothy already
7//! coined; it does not invent new sensitive vocabulary.
8//!
9//! Handled with gravity, two deliberate semantic choices (both from the spec, both the
10//! legally-careful reading — flagged here, not silently assumed):
11//! * **Duress → VOIDABLE, not void.** A stipulation made under coercion is voidable *at the
12//! victim's election* — it is NOT automatically nullified. Auto-nullifying would strip the
13//! victim of the choice to keep or undo it. (`◇Void`, not `Void`.)
14//! * **Guardianship carries the dependent's weight, it does not replace the dependent.** A
15//! guardian acts *on behalf of* the dependent; the legal weight is the dependent's.
16
17/// An agent's juridical capacity for an act.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
19pub enum CapacityStatus {
20 /// Full legal/cognitive capacity — stipulations are binding.
21 #[default]
22 Intact,
23 /// Capacity is impaired (e.g. minority, incapacity) — stipulations are not binding.
24 Impaired,
25 /// Capacity present but the act was coerced — the stipulation is *voidable*.
26 UnderDuress,
27}
28
29/// A stipulation by the agent is **binding** only when capacity is `Intact`.
30#[inline]
31pub fn stipulation_binding(capacity: CapacityStatus) -> bool {
32 matches!(capacity, CapacityStatus::Intact)
33}
34
35/// A stipulation made `UnderDuress` is **voidable at the victim's election** (CoercedConsentFlag
36/// → VoidableStipulation). Returns true iff the agent may elect to void it — NOT that it is
37/// already void (that choice stays with the victim).
38#[inline]
39pub fn stipulation_voidable(capacity: CapacityStatus) -> bool {
40 matches!(capacity, CapacityStatus::UnderDuress)
41}
42
43/// Guardianship / delegation: when a guardianship relation holds, a guardian's act carries the
44/// **dependent's** legal weight (`values:actsOnBehalfOf`). Returns the identity whose weight
45/// the act bears — the dependent under guardianship, else the actor themselves.
46#[inline]
47pub fn effective_principal(actor: u64, dependent: u64, has_guardianship: bool) -> u64 {
48 if has_guardianship {
49 dependent
50 } else {
51 actor
52 }
53}
54
55/// Posthumous standing: a representative may prosecute the **surviving** claims of a deceased
56/// agent (`BreachRecord(survivesDeath)` + representative standing). True iff the agent is
57/// deceased AND a representative stands for them.
58#[inline]
59pub fn posthumous_standing(deceased: bool, has_representative: bool) -> bool {
60 deceased && has_representative
61}
62
63// ─── Jurisdiction-specific capacity thresholds ──────────────────────────────────────
64
65/// Does `age_years` meet a jurisdiction's `majority_age`? The threshold is **supplied by the
66/// caller** (jurisdiction-specific — 18 in most, 21 in some, mental-health-act variations) so
67/// the engine never bakes one jurisdiction's law in as universal.
68#[inline]
69pub fn meets_age_of_majority(age_years: u32, majority_age: u32) -> bool {
70 age_years >= majority_age
71}
72
73/// Derive capacity from age against a jurisdiction threshold: below majority → `Impaired`
74/// (minority); at/above → `Intact`. Coercion is layered separately ([`capacity_under_pressure`]).
75pub fn capacity_from_age(age_years: u32, majority_age: u32) -> CapacityStatus {
76 if meets_age_of_majority(age_years, majority_age) {
77 CapacityStatus::Intact
78 } else {
79 CapacityStatus::Impaired
80 }
81}
82
83// ─── Coercion / duress detection (relational imbalance → voidable) ──────────────────
84
85/// Map a relational power-imbalance signal to a duress finding. `imbalance` is a normalised
86/// `[0,1]` measure of relational asymmetry (dependency / authority / economic capture); an
87/// `explicit_threat` forces duress regardless. At/above `threshold`, or under an explicit
88/// threat, the act is coerced → the resulting stipulation is *voidable* (never auto-void; the
89/// election stays with the victim — see module header).
90pub fn detect_duress(imbalance: f32, explicit_threat: bool, threshold: f32) -> bool {
91 explicit_threat || imbalance >= threshold
92}
93
94/// Capacity under relational pressure: an otherwise-`Intact` agent whose act is coerced becomes
95/// `UnderDuress` (voidable). Duress never upgrades an already-`Impaired` capacity.
96pub fn capacity_under_pressure(
97 base: CapacityStatus,
98 imbalance: f32,
99 explicit_threat: bool,
100 threshold: f32,
101) -> CapacityStatus {
102 if base == CapacityStatus::Intact && detect_duress(imbalance, explicit_threat, threshold) {
103 CapacityStatus::UnderDuress
104 } else {
105 base
106 }
107}
108
109// ─── Temporary impairment with time-decay (e.g. intoxication clearance) ─────────────
110
111/// A transient impairment decaying linearly toward zero — a conservative clearance model
112/// (e.g. intoxication). `initial` is the level in `[0,1]` at t0; `rate` is decay per elapsed
113/// time unit. Returns the clamped residual level at `elapsed` units.
114pub fn decayed_impairment(initial: f32, elapsed: f32, rate: f32) -> f32 {
115 (initial - rate * elapsed).clamp(0.0, 1.0)
116}
117
118/// Capacity under a *transient* impairment: while the decayed level is at/above `threshold` the
119/// agent is `Impaired`; once it decays below, capacity self-clears to `Intact`. Distinct from
120/// durable incapacity (which does not decay).
121pub fn transient_capacity(initial: f32, elapsed: f32, rate: f32, threshold: f32) -> CapacityStatus {
122 if decayed_impairment(initial, elapsed, rate) >= threshold {
123 CapacityStatus::Impaired
124 } else {
125 CapacityStatus::Intact
126 }
127}
128
129// ─── Selective right-delegation (guardianship mechanism) ────────────────────────────
130//
131// NOTE: the *vocabulary* of guardianship domains (the 17+ domains of agency in Timothy's
132// CopyOfGuardianShipRelations design) is his to coin. This module deliberately operates over
133// OPAQUE caller-supplied domain identifiers (u64 hashes) — wiring the *mechanism* of selective
134// delegation without inventing sensitive guardianship vocabulary.
135
136/// Selective delegation: `authorized_domains` enumerate exactly the domains of agency delegated
137/// to a guardian. The guardian may act in `requested_domain` iff it is among them — no domain
138/// ⇒ no authority (selective, never plenary).
139pub fn guardianship_authorized(authorized_domains: &[u64], requested_domain: u64) -> bool {
140 authorized_domains.contains(&requested_domain)
141}
142
143/// Domain-scoped effective principal: a guardian's act carries the dependent's weight ONLY
144/// within a delegated domain; outside the delegated set the guardian cannot bind the dependent
145/// (the act falls back to the actor's own weight).
146pub fn effective_principal_scoped(
147 actor: u64,
148 dependent: u64,
149 authorized_domains: &[u64],
150 requested_domain: u64,
151) -> u64 {
152 if guardianship_authorized(authorized_domains, requested_domain) {
153 dependent
154 } else {
155 actor
156 }
157}
158
159// ─── Delegation chains: attenuation + cascading revocation (ZCAP/Macaroon-style) ────
160//
161// Still mechanism-only over opaque domain ids — no guardianship vocabulary coined here. A
162// delegatee can never gain MORE authority than the delegator (attenuation), and revoking a
163// domain withdraws it immediately wherever it appears (cascading revocation).
164
165/// **Attenuation:** a sub-delegation's `child_domains` are valid only if a SUBSET of the
166/// delegator's `parent_domains` — a delegatee never receives more authority than the delegator
167/// holds. (Empty child set trivially attenuates.)
168pub fn delegation_attenuates(parent_domains: &[u64], child_domains: &[u64]) -> bool {
169 child_domains.iter().all(|d| parent_domains.contains(d))
170}
171
172/// Authority after **cascading revocation**: a guardian may act in `requested_domain` iff it is
173/// authorized AND not present in the `revoked_domains` set (revocation withdraws it immediately).
174pub fn authorized_after_revocation(authorized: &[u64], revoked: &[u64], requested: u64) -> bool {
175 guardianship_authorized(authorized, requested) && !revoked.contains(&requested)
176}
177
178/// A multi-link delegation **chain** authorizes `requested_domain` iff: the root holds it, every
179/// link attenuates its predecessor (subset), and the domain survives at every level (no link
180/// silently re-broadens authority). `chain[0]` is the root delegation; each later link is a
181/// sub-delegation. Zero-heap (slice of slices).
182pub fn chain_authorizes(chain: &[&[u64]], requested_domain: u64) -> bool {
183 if chain.is_empty() || !chain[0].contains(&requested_domain) {
184 return false;
185 }
186 for w in chain.windows(2) {
187 if !delegation_attenuates(w[0], w[1]) || !w[1].contains(&requested_domain) {
188 return false;
189 }
190 }
191 true
192}
193
194// ─── Graduated & Kinship Capacity (Gillick & Supported Decision-Making) ────────────
195
196/// Graduated competence evaluation parameters for an agent facing a specific act.
197/// Models Gillick competence where capacity is dynamic and decision-relative rather than
198/// an absolute binary toggle.
199#[derive(Debug, Clone, Copy, PartialEq)]
200pub struct GraduatedCompetence {
201 /// Assessed comprehension and maturity score in `[0.0, 1.0]`.
202 pub understanding_score: f32,
203 /// Inherent cognitive/legal complexity of the decision in `[0.0, 1.0]`.
204 pub decision_complexity: f32,
205}
206
207impl GraduatedCompetence {
208 /// Pair an assessed understanding score with a decision's inherent
209 /// complexity — both normalized to `[0.0, 1.0]` (not clamped here;
210 /// callers supply normalized values).
211 #[inline]
212 pub const fn new(understanding_score: f32, decision_complexity: f32) -> Self {
213 Self {
214 understanding_score,
215 decision_complexity,
216 }
217 }
218
219 /// Whether self-standing competence is achieved without auxiliary support.
220 #[inline]
221 pub fn is_self_standing(&self) -> bool {
222 self.understanding_score >= self.decision_complexity
223 }
224}
225
226/// Endorsement from a kinship circle, elder, parent, or trusted decision-making advocate.
227#[derive(Debug, Clone, Copy, PartialEq)]
228pub struct KinshipEndorsement {
229 /// DID hash of the endorsing custodian / elder / supporter.
230 pub supporter_did: u64,
231 /// Cultural or legal role (e.g. `q_hash("role:elder")`, `q_hash("role:parent")`).
232 pub role_hash: u64,
233 /// Verified confidence / weight of the endorsement in `[0.0, 1.0]`.
234 pub weight: f32,
235}
236
237/// Evaluate graduated capacity under Gillick competence and supported decision-making.
238///
239/// Rules:
240/// 1. If an authorized elder or parent asserts an active veto (`elder_veto == true`),
241/// capacity is `UnderDuress` (voidable / suspended) to safeguard the dependent.
242/// 2. If the agent's individual `understanding_score >= decision_complexity`, they possess
243/// autonomous Gillick competence (`CapacityStatus::Intact`).
244/// 3. If individual competence is insufficient, supported decision-making is evaluated:
245/// endorsers with `weight >= min_endorsement_weight` are counted. If the count reaches
246/// `required_quorum` and the collective support bridges the gap, returns `CapacityStatus::Intact`.
247/// 4. Otherwise returns `CapacityStatus::Impaired`.
248pub fn eval_graduated_capacity(
249 competence: GraduatedCompetence,
250 endorsements: &[KinshipEndorsement],
251 min_endorsement_weight: f32,
252 required_quorum: usize,
253 elder_veto: bool,
254) -> CapacityStatus {
255 if elder_veto {
256 return CapacityStatus::UnderDuress;
257 }
258
259 if competence.is_self_standing() {
260 return CapacityStatus::Intact;
261 }
262
263 let mut valid_count = 0usize;
264 let mut total_supported_weight = 0.0f32;
265
266 for e in endorsements {
267 if e.weight >= min_endorsement_weight {
268 valid_count += 1;
269 total_supported_weight += e.weight;
270 }
271 }
272
273 if valid_count >= required_quorum {
274 // Supported capacity bridges up to 50% extra complexity deficit based on collective weight
275 let support_boost = (total_supported_weight / valid_count.max(1) as f32) * 0.5;
276 if (competence.understanding_score + support_boost) >= competence.decision_complexity {
277 return CapacityStatus::Intact;
278 }
279 }
280
281 CapacityStatus::Impaired
282}
283
284// ─── Digital Probate & Succession Semantics ────────────────────────────────────────
285
286/// Testamentary delegation terms specifying successor rights upon mortality event.
287#[derive(Debug, Clone, Copy, PartialEq, Eq)]
288pub struct TestamentaryClause<'a> {
289 /// Deceased or testator entity DID hash.
290 pub testator: u64,
291 /// Designated heir or successor representative DID hash.
292 pub successor: u64,
293 /// Authorized domains of transmission (opaque u64 domain hashes).
294 pub delegated_domains: &'a [u64],
295 /// Whether this grant explicitly survives death (`survivesDeath`).
296 pub survives_death: bool,
297}
298
299/// Attested succession/mortality event from a mortality oracle or civil registry.
300#[derive(Debug, Clone, Copy, PartialEq, Eq)]
301pub struct SuccessionEvent {
302 /// Decedent DID hash.
303 pub decedent: u64,
304 /// Mortality oracle or registrar DID hash.
305 pub oracle: u64,
306 /// Attestation epoch timestamp.
307 pub attestation_epoch: u32,
308 /// Whether the death attestation has been cryptographically verified.
309 pub verified: bool,
310}
311
312/// Predicate URI hash for claims surviving death (`values:survivesDeath`).
313#[inline]
314pub fn survives_death_predicate() -> u64 {
315 crate::q_hash("values:survivesDeath")
316}
317
318/// Predicate URI hash for testamentary successor (`values:testamentarySuccessor`).
319#[inline]
320pub fn testamentary_successor_predicate() -> u64 {
321 crate::q_hash("values:testamentarySuccessor")
322}
323
324/// Evaluates whether a successor holds standing to exercise authority in a requested domain
325/// under a testamentary clause and verified succession event.
326pub fn eval_succession_standing(
327 clause: &TestamentaryClause,
328 event: Option<&SuccessionEvent>,
329 requested_domain: u64,
330) -> bool {
331 let Some(ev) = event else {
332 return false;
333 };
334
335 if !ev.verified || ev.decedent != clause.testator {
336 return false;
337 }
338
339 if !clause.survives_death {
340 return false;
341 }
342
343 clause.delegated_domains.contains(&requested_domain)
344}
345
346/// Filters an input stream of Quins for claims that survive the decedent's death.
347/// Matches Quins whose predicate equals `values:survivesDeath` or subject equals `decedent`.
348pub fn filter_surviving_claims(
349 claims: &[crate::NQuin],
350 decedent: u64,
351 out: &mut [crate::NQuin],
352) -> usize {
353 let surv_pred = survives_death_predicate();
354 let mut count = 0usize;
355
356 for &c in claims {
357 if count >= out.len() {
358 break;
359 }
360 if c.subject == decedent && (c.predicate == surv_pred || (c.metadata & 0x01) != 0) {
361 out[count] = c;
362 count += 1;
363 }
364 }
365
366 count
367}
368
369#[cfg(test)]
370mod tests {
371 use super::*;
372
373 #[test]
374 fn capacity_gates_binding() {
375 assert!(stipulation_binding(CapacityStatus::Intact));
376 assert!(!stipulation_binding(CapacityStatus::Impaired));
377 assert!(!stipulation_binding(CapacityStatus::UnderDuress));
378 }
379
380 #[test]
381 fn duress_is_voidable_not_void() {
382 // Under duress: the victim MAY void — not auto-nullified, and not binding either.
383 assert!(stipulation_voidable(CapacityStatus::UnderDuress));
384 assert!(!stipulation_binding(CapacityStatus::UnderDuress));
385 // Intact / impaired are not "voidable for duress".
386 assert!(!stipulation_voidable(CapacityStatus::Intact));
387 assert!(!stipulation_voidable(CapacityStatus::Impaired));
388 }
389
390 #[test]
391 fn guardianship_carries_the_dependents_weight() {
392 let guardian = 0xA1;
393 let dependent = 0xB2;
394 assert_eq!(effective_principal(guardian, dependent, true), dependent);
395 assert_eq!(effective_principal(guardian, dependent, false), guardian);
396 }
397
398 #[test]
399 fn posthumous_claims_need_a_representative() {
400 assert!(posthumous_standing(true, true));
401 assert!(!posthumous_standing(true, false)); // deceased, no representative → no standing
402 assert!(!posthumous_standing(false, true)); // alive → they hold their own standing
403 }
404
405 #[test]
406 fn age_of_majority_is_jurisdiction_parametric() {
407 // 18-majority jurisdiction.
408 assert_eq!(capacity_from_age(17, 18), CapacityStatus::Impaired);
409 assert_eq!(capacity_from_age(18, 18), CapacityStatus::Intact);
410 // 21-majority jurisdiction: the same 18-year-old is a minor.
411 assert_eq!(capacity_from_age(18, 21), CapacityStatus::Impaired);
412 assert!(!stipulation_binding(capacity_from_age(17, 18)));
413 }
414
415 #[test]
416 fn relational_imbalance_and_threats_yield_voidable_duress() {
417 // High relational imbalance → duress → voidable (not auto-void, not binding).
418 let c = capacity_under_pressure(CapacityStatus::Intact, 0.9, false, 0.7);
419 assert_eq!(c, CapacityStatus::UnderDuress);
420 assert!(stipulation_voidable(c));
421 assert!(!stipulation_binding(c));
422 // An explicit threat forces duress regardless of measured imbalance.
423 assert!(detect_duress(0.0, true, 0.7));
424 // Below threshold, no threat → capacity unchanged.
425 assert_eq!(
426 capacity_under_pressure(CapacityStatus::Intact, 0.3, false, 0.7),
427 CapacityStatus::Intact
428 );
429 // Duress never "upgrades" an already-impaired (minor) agent.
430 assert_eq!(
431 capacity_under_pressure(CapacityStatus::Impaired, 0.9, true, 0.7),
432 CapacityStatus::Impaired
433 );
434 }
435
436 #[test]
437 fn transient_impairment_decays_and_self_clears() {
438 // Fully impaired at t0, decaying 0.1/unit, threshold 0.5.
439 assert!(decayed_impairment(1.0, 0.0, 0.1) > 0.99);
440 assert_eq!(
441 transient_capacity(1.0, 0.0, 0.1, 0.5),
442 CapacityStatus::Impaired
443 );
444 // After 6 units → level 0.4 < 0.5 → self-cleared.
445 assert!((decayed_impairment(1.0, 6.0, 0.1) - 0.4).abs() < 1e-6);
446 assert_eq!(
447 transient_capacity(1.0, 6.0, 0.1, 0.5),
448 CapacityStatus::Intact
449 );
450 // Never goes negative.
451 assert_eq!(decayed_impairment(0.2, 100.0, 0.1), 0.0);
452 }
453
454 #[test]
455 fn guardianship_delegation_is_selective_not_plenary() {
456 let (guardian, dependent) = (0xA1u64, 0xB2u64);
457 let medical = crate::q_hash("domain:medical");
458 let financial = crate::q_hash("domain:financial");
459 let legal = crate::q_hash("domain:legal");
460 let delegated = [medical, financial]; // legal NOT delegated
461
462 assert!(guardianship_authorized(&delegated, medical));
463 assert!(!guardianship_authorized(&delegated, legal));
464 // In a delegated domain the guardian carries the dependent's weight…
465 assert_eq!(
466 effective_principal_scoped(guardian, dependent, &delegated, financial),
467 dependent
468 );
469 // …but outside the delegated set they cannot bind the dependent.
470 assert_eq!(
471 effective_principal_scoped(guardian, dependent, &delegated, legal),
472 guardian
473 );
474 }
475
476 #[test]
477 fn delegation_attenuates_revokes_and_chains() {
478 let medical = crate::q_hash("domain:medical");
479 let financial = crate::q_hash("domain:financial");
480 let legal = crate::q_hash("domain:legal");
481
482 // Attenuation: a sub-delegation must be a subset of the parent's authority.
483 assert!(delegation_attenuates(
484 &[medical, financial, legal],
485 &[medical, financial]
486 ));
487 assert!(
488 !delegation_attenuates(&[medical], &[medical, legal]),
489 "cannot broaden authority"
490 );
491 assert!(delegation_attenuates(&[medical], &[]));
492
493 // Cascading revocation withdraws a domain immediately.
494 let authorized = [medical, financial];
495 assert!(authorized_after_revocation(&authorized, &[], medical));
496 assert!(
497 !authorized_after_revocation(&authorized, &[medical], medical),
498 "revoked → withdrawn"
499 );
500 assert!(authorized_after_revocation(
501 &authorized,
502 &[medical],
503 financial
504 ));
505
506 // A delegation chain: root{med,fin,legal} → sub{med,fin} → subsub{med}.
507 let root: &[u64] = &[medical, financial, legal];
508 let sub: &[u64] = &[medical, financial];
509 let subsub: &[u64] = &[medical];
510 let chain = [root, sub, subsub];
511 assert!(
512 chain_authorizes(&chain, medical),
513 "medical survives the whole chain"
514 );
515 assert!(
516 !chain_authorizes(&chain, financial),
517 "financial dropped at the last link"
518 );
519 assert!(
520 !chain_authorizes(&chain, legal),
521 "legal dropped after the root"
522 );
523 // A chain that tries to RE-BROADEN (sub adds legal the parent lacks) fails attenuation.
524 let bad_sub: &[u64] = &[medical, legal];
525 assert!(!chain_authorizes(&[sub, bad_sub], legal));
526 assert!(!chain_authorizes(&[], medical));
527 }
528
529 #[test]
530 fn test_graduated_capacity_and_kinship_endorsement() {
531 let comp = GraduatedCompetence::new(0.6, 0.5);
532 assert!(comp.is_self_standing());
533 assert_eq!(
534 eval_graduated_capacity(comp, &[], 0.5, 1, false),
535 CapacityStatus::Intact
536 );
537
538 // Insufficient individual competence: score 0.4 < complexity 0.7
539 let minor_comp = GraduatedCompetence::new(0.4, 0.7);
540 assert!(!minor_comp.is_self_standing());
541 assert_eq!(
542 eval_graduated_capacity(minor_comp, &[], 0.5, 1, false),
543 CapacityStatus::Impaired
544 );
545
546 // With kinship support meeting quorum (2 elders/parents)
547 let endorsements = [
548 KinshipEndorsement {
549 supporter_did: 0xC1,
550 role_hash: crate::q_hash("role:parent"),
551 weight: 0.8,
552 },
553 KinshipEndorsement {
554 supporter_did: 0xC2,
555 role_hash: crate::q_hash("role:elder"),
556 weight: 0.9,
557 },
558 ];
559 assert_eq!(
560 eval_graduated_capacity(minor_comp, &endorsements, 0.7, 2, false),
561 CapacityStatus::Intact
562 );
563
564 // Elder veto forces UnderDuress even with valid support
565 assert_eq!(
566 eval_graduated_capacity(minor_comp, &endorsements, 0.7, 2, true),
567 CapacityStatus::UnderDuress
568 );
569 }
570
571 #[test]
572 fn test_digital_probate_and_succession_standing() {
573 let testator = 0xD1;
574 let heir = 0xD2;
575 let domain_land = crate::q_hash("domain:custodial_land");
576 let domain_finance = crate::q_hash("domain:finance");
577
578 let clause = TestamentaryClause {
579 testator,
580 successor: heir,
581 delegated_domains: &[domain_land],
582 survives_death: true,
583 };
584
585 // Before death attested: no standing
586 assert!(!eval_succession_standing(&clause, None, domain_land));
587
588 // Unverified event: no standing
589 let unverified_ev = SuccessionEvent {
590 decedent: testator,
591 oracle: 0x99,
592 attestation_epoch: 1000,
593 verified: false,
594 };
595 assert!(!eval_succession_standing(
596 &clause,
597 Some(&unverified_ev),
598 domain_land
599 ));
600
601 // Verified event: standing in domain_land, but not finance
602 let verified_ev = SuccessionEvent {
603 decedent: testator,
604 oracle: 0x99,
605 attestation_epoch: 1000,
606 verified: true,
607 };
608 assert!(eval_succession_standing(
609 &clause,
610 Some(&verified_ev),
611 domain_land
612 ));
613 assert!(!eval_succession_standing(
614 &clause,
615 Some(&verified_ev),
616 domain_finance
617 ));
618
619 // Surviving claims filtering
620 let mut q1 = crate::NQuin {
621 subject: testator,
622 predicate: survives_death_predicate(),
623 object: 0x123,
624 context: 0,
625 metadata: 0,
626 parity: 0,
627 };
628 q1.parity = q1.subject ^ q1.predicate ^ q1.object ^ q1.context;
629
630 let mut q2 = crate::NQuin {
631 subject: testator,
632 predicate: crate::q_hash("claims:ordinary"),
633 object: 0x456,
634 context: 0,
635 metadata: 0,
636 parity: 0,
637 };
638 q2.parity = q2.subject ^ q2.predicate ^ q2.object ^ q2.context;
639
640 let mut out = [crate::NQuin::default(); 4];
641 let n = filter_surviving_claims(&[q1, q2], testator, &mut out);
642 assert_eq!(n, 1);
643 assert_eq!(out[0].object, 0x123);
644 }
645}