ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
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
use core::time::Duration;

use std::sync::{Arc, Mutex};

use jiff::SignedDuration;

use crate::{
  BoxedError,
  drive::{
    Delivery, Failure, Item, ItemId, LifecycleTap, NodeName, Observation, Payload, Station, Taps,
    ack_channel, channel, open, reply,
  },
};

use super::super::{
  DeadlinePolicy, DropNewest, DropOldest, Missed, Occupancy, OverflowDecision, OverflowPolicy,
  Policies, PollUpstream, QueryDeadline, RetryDecision, RetryPolicy, TickDecision, TickPolicy,
};

/// What the framework's own observations look like once a tap has seen them.
///
/// Each arm is recorded in the vocabulary an assertion reads rather than kept whole, because an
/// [`Observation`] borrows what it was shown — the same reason a journal row is built at the tap
/// rather than queued raw.
#[derive(Debug, Clone, PartialEq, Eq)]
enum Seen {
  Arrived(Station),
  Retrying {
    attempt: u32,
    after: Option<i128>,
  },
  Shed {
    key: String,
    decision: OverflowDecision,
  },
  GivenUp {
    attempt: u32,
    error: Option<String>,
  },
  Expired {
    budget: i128,
  },
  PolicyFailed {
    concern: String,
    error: String,
  },
  Lapped {
    poll: PollUpstream,
  },
}

/// A tap that keeps every arm, so a proof can name the one it is after.
#[derive(Debug, Default)]
struct Watching {
  seen: Mutex<Vec<(String, Seen)>>,
}

impl Watching {
  fn seen(&self) -> Vec<(String, Seen)> {
    self.seen.lock().expect("the watch").clone()
  }

  /// Everything seen for whichever node, which is what a one-node fixture is asking for.
  fn arms(&self) -> Vec<Seen> {
    self.seen().into_iter().map(|(_, arm)| arm).collect()
  }
}

impl LifecycleTap for Watching {
  fn observe(&self, node: &NodeName, observation: &Observation) {
    let arm = match observation {
      Observation::Arrived(arrival) => Seen::Arrived(arrival.station()),
      Observation::Retrying { attempt, after } => Seen::Retrying {
        attempt: *attempt,
        after: after.map(|after| after.as_millis()),
      },
      Observation::Shed { key, decision, .. } => Seen::Shed {
        key: key.to_string(),
        decision: *decision,
      },
      Observation::GivenUp { attempt, failure } => Seen::GivenUp {
        attempt: *attempt,
        error: failure.as_ref().map(ToString::to_string),
      },
      Observation::Expired { budget } => Seen::Expired {
        budget: budget.as_millis(),
      },
      Observation::PolicyFailed { concern, error } => Seen::PolicyFailed {
        concern: concern.as_str().to_owned(),
        error: error.to_string(),
      },
      Observation::Lapped { poll } => Seen::Lapped { poll: *poll },
    };
    self
      .seen
      .lock()
      .expect("the watch")
      .push((node.as_str().to_owned(), arm));
  }
}

/// A watching tap and the composite it is registered in.
fn watched() -> (Arc<Watching>, Taps) {
  let tap = Arc::new(Watching::default());
  let taps = Taps::new().with(tap.clone());
  (tap, taps)
}

/// The error every mad advisor below hands back.
#[derive(Debug, derive_more::Display)]
#[display("the advisor is unwell")]
struct Unwell;

impl core::error::Error for Unwell {}

/// A policy for every concern that refuses to decide — 叉 A's whole subject.
struct Mad;

impl TickPolicy for Mad {
  fn on_missed(&self, _missed: Missed) -> Result<TickDecision, BoxedError> {
    Err(Box::new(Unwell))
  }
}

impl RetryPolicy for Mad {
  fn on_failure(
    &self,
    _attempt: u32,
    _error: &(dyn core::error::Error + 'static),
  ) -> Result<RetryDecision, BoxedError> {
    Err(Box::new(Unwell))
  }
}

impl OverflowPolicy for Mad {
  fn on_full(&self, _occupancy: Occupancy) -> Result<OverflowDecision, BoxedError> {
    Err(Box::new(Unwell))
  }
}

impl DeadlinePolicy for Mad {
  fn deadline(&self) -> Result<Option<SignedDuration>, BoxedError> {
    Err(Box::new(Unwell))
  }
}

/// An operator's failure, as a station carries one.
#[derive(Debug, derive_more::Display)]
#[display("the store would not answer")]
struct Refused;

impl core::error::Error for Refused {}

// ── 叉 A: a mad advisor is recorded and the factory keeps running ───────────────────────────────

/// **叉 A, ALL FOUR CONCERNS.** A policy that answers `Err` is recorded through the tap — typed and
/// naming its concern — and the framework takes the SHIPPED decision. *Advice failed* never becomes
/// *data failed*.
#[test]
fn a_policy_that_refuses_is_recorded_and_the_shipped_default_is_taken() {
  let (tap, taps) = watched();
  let policies = Policies::new()
    .with_tick_policy(Box::new(Mad))
    .with_retry_policy(Box::new(Mad))
    .with_overflow_policy(Box::new(Mad))
    .with_deadline_policy(Box::new(Mad));

  assert_eq!(
    policies
      .ticks("decode", taps.clone())
      .on_missed(Missed::new(PollUpstream::new(0), 6)),
    TickDecision::Coalesce
  );
  assert_eq!(
    policies
      .retries("decode", taps.clone())
      .on_failure(1, &Refused),
    RetryDecision::GiveUp
  );
  assert_eq!(
    policies
      .sheds("decode", taps.clone())
      .on_full(Occupancy::bounded(4, 4)),
    OverflowDecision::Block
  );
  assert_eq!(policies.deadlines("decode", taps).resolve(None), None);

  let concerns: Vec<String> = tap
    .arms()
    .into_iter()
    .filter_map(|arm| match arm {
      Seen::PolicyFailed { concern, error } => {
        assert_eq!(
          error, "the advisor is unwell",
          "the error keeps its own words"
        );
        Some(concern)
      }
      _ => None,
    })
    .collect();
  assert_eq!(
    concerns,
    ["tick", "retry", "overflow", "deadline"],
    "one record per sick advisor, each naming which seat it sat in"
  );
  assert!(
    tap.seen().iter().all(|(node, _)| node == "decode"),
    "and every record names the node the gate speaks for"
  );
}

/// A healthy policy is recorded NOWHERE — the tap only hears about sickness.
#[test]
fn a_policy_that_decides_leaves_no_record_of_its_own() {
  let (tap, taps) = watched();
  let policies = Policies::new();
  assert_eq!(
    policies
      .ticks("decode", taps.clone())
      .on_missed(Missed::new(PollUpstream::new(0), 3)),
    TickDecision::Coalesce
  );
  assert_eq!(
    policies
      .sheds("decode", taps)
      .on_full(Occupancy::bounded(4, 4)),
    OverflowDecision::Block
  );
  assert!(tap.seen().is_empty());
}

// ── the retry seat ─────────────────────────────────────────────────────────────────────────────

/// **THE SEAT IS `Station::is_settled`.** A station that settles never reaches the policy at all,
/// which is what makes this the seat the R-line named rather than a new place to check.
#[test]
fn a_settled_station_answers_give_up_without_asking_anybody() {
  let (tap, taps) = watched();
  /// A policy that would retry ANYTHING it were asked about.
  struct Always;

  impl RetryPolicy for Always {
    fn on_failure(
      &self,
      _attempt: u32,
      _error: &(dyn core::error::Error + 'static),
    ) -> Result<RetryDecision, BoxedError> {
      Ok(RetryDecision::Retry { after: None })
    }
  }

  let retries = Policies::new()
    .with_retry_policy(Box::new(Always))
    .retries("decode", taps);

  for station in [Station::Persisted, Station::Processed, Station::Skipped] {
    assert_eq!(
      retries.settling(station, 1, None),
      RetryDecision::GiveUp,
      "an outcome is not a thing to try again"
    );
  }
  assert!(
    tap.seen().is_empty(),
    "and a policy that was never asked leaves no record"
  );

  assert_eq!(
    retries.settling(Station::Failed, 1, Some(&Failure::new(Refused))),
    RetryDecision::Retry { after: None },
    "the one station that holds the window is the one that asks"
  );
}

/// **RETRIED, THEN GIVEN UP — and every one of those decisions observed.** The record is written
/// where the decision is MADE, so what a tap counts is what the policy answered. The ending is in
/// that count since C-2: an exhausted retry used to be the one decision a deployment could not
/// watch.
#[test]
fn a_failing_settle_is_retried_twice_and_then_given_up_on() {
  let (tap, taps) = watched();

  /// Two tries with a backoff, then stop — an ordinary deployment policy.
  struct Twice;

  impl RetryPolicy for Twice {
    fn on_failure(
      &self,
      attempt: u32,
      error: &(dyn core::error::Error + 'static),
    ) -> Result<RetryDecision, BoxedError> {
      assert_eq!(
        error.to_string(),
        "the store would not answer",
        "the policy is shown the failure's own error and not a rendering of the station"
      );
      if attempt >= 3 {
        return Ok(RetryDecision::GiveUp);
      }
      Ok(RetryDecision::Retry {
        after: Some(SignedDuration::from_millis(i64::from(attempt) * 50)),
      })
    }
  }

  let retries = Policies::new()
    .with_retry_policy(Box::new(Twice))
    .retries("decode", taps);
  let failure = Failure::new(Refused);

  let decisions: Vec<RetryDecision> = (1..=3)
    .map(|attempt| retries.settling(Station::Failed, attempt, Some(&failure)))
    .collect();
  assert_eq!(
    decisions,
    [
      RetryDecision::Retry {
        after: Some(SignedDuration::from_millis(50))
      },
      RetryDecision::Retry {
        after: Some(SignedDuration::from_millis(100))
      },
      RetryDecision::GiveUp,
    ]
  );
  assert_eq!(
    tap.arms(),
    [
      Seen::Retrying {
        attempt: 1,
        after: Some(50)
      },
      Seen::Retrying {
        attempt: 2,
        after: Some(100)
      },
      Seen::GivenUp {
        attempt: 3,
        error: Some("the store would not answer".to_owned())
      },
    ],
    "two scheduled retries and the stop that ended them — a stop is not a retry, and it is not \
     silence either"
  );
}

// ── the overflow seat ──────────────────────────────────────────────────────────────────────────

/// One delivery carrying `keys`, with a token nobody is going to read.
fn delivery(keys: &[u64]) -> Delivery<u64, ItemId> {
  let (ack, answers) = ack_channel();
  // The answers are dropped on purpose: what is under test is the SEND, and a sender that hung up
  // is the ack law's business rather than the policy's.
  drop(answers);
  Delivery::new(
    Payload::Batch(
      keys
        .iter()
        .map(|&key| Item::new(ItemId::new(key), key))
        .collect(),
    ),
    ack,
  )
}

/// **BLOCK IS TODAY'S POSTURE, MEASURED.** The shipped policy waits for room, so a full edge makes
/// the sender wait and loses nothing.
#[test]
fn the_shipped_overflow_policy_waits_and_sheds_nothing() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(1);
  let evictor = inbox.evictor();
  let sheds = Policies::new().sheds("reels", taps);

  assert!(
    sheds
      .deliver(&outbox, Some(&evictor), delivery(&[1]))
      .is_sent(),
    "the first goes in, the edge having room"
  );

  // The second would block forever, so the room is made first: what is being pinned is that BLOCK
  // does not drop, and a drained edge is where that is observable without a second thread.
  assert!(inbox.drain().count() >= 1);
  assert!(
    sheds
      .deliver(&outbox, Some(&evictor), delivery(&[2]))
      .is_sent()
  );
  assert!(
    tap.seen().is_empty(),
    "and nothing was shed, so there is no obituary"
  );
}

/// **DROP-NEWEST REFUSES THE ARRIVAL**, and the obituary names the COMPLETE item key of everything
/// the refused delivery carried.
#[test]
fn drop_newest_refuses_the_arrival_and_names_every_key_it_carried() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(1);
  let evictor = inbox.evictor();
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropNewest))
    .sheds("reels", taps);

  assert!(
    sheds
      .deliver(&outbox, Some(&evictor), delivery(&[1]))
      .is_sent()
  );
  let handover = sheds.deliver(&outbox, Some(&evictor), delivery(&[7, 8]));
  assert!(handover.is_shed());
  match handover {
    super::Handover::Dropped(dropped) => {
      assert_eq!(
        dropped.payload().len(),
        2,
        "and it comes back to be settled"
      )
    }
    other => panic!("drop-newest refuses the arrival, and this said {other:?}"),
  }
  assert_eq!(
    tap.arms(),
    [
      Seen::Shed {
        key: "item#7".to_owned(),
        decision: OverflowDecision::DropNewest
      },
      Seen::Shed {
        key: "item#8".to_owned(),
        decision: OverflowDecision::DropNewest
      },
    ],
    "one obituary per ITEM, each carrying the key its node addresses it by"
  );
  assert_eq!(
    inbox.len(),
    1,
    "and the queue was left exactly as it was — drop-newest touches nothing already in flight"
  );
}

/// **DROP-OLDEST MAKES ROOM**, and the obituary is for the item that was already in the queue.
#[test]
fn drop_oldest_evicts_the_queued_item_and_the_arrival_goes_in() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(1);
  let evictor = inbox.evictor();
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropOldest))
    .sheds("reels", taps);

  assert!(
    sheds
      .deliver(&outbox, Some(&evictor), delivery(&[1]))
      .is_sent()
  );
  let handover = sheds.deliver(&outbox, Some(&evictor), delivery(&[2]));
  assert!(handover.is_sent() && handover.is_shed());
  match handover {
    super::Handover::Evicted(evicted) => assert_eq!(
      evicted.payload().keys().next(),
      Some(&ItemId::new(1)),
      "what came back is the OLD delivery, for its holder to settle"
    ),
    other => panic!("drop-oldest evicts, and this said {other:?}"),
  }
  assert_eq!(
    tap.arms(),
    [Seen::Shed {
      key: "item#1".to_owned(),
      decision: OverflowDecision::DropOldest
    }]
  );

  let queued: Vec<ItemId> = inbox
    .drain()
    .filter_map(|wake| match wake {
      crate::Wake::Delivered(delivery) => delivery.payload().keys().next().copied(),
      _ => None,
    })
    .collect();
  assert_eq!(
    queued,
    [ItemId::new(2)],
    "and the newest is what the consumer will see"
  );
}

/// A consumer that has gone hands the delivery back UNSHED — [`Outbox::deliver`]'s own contract,
/// kept. A departure is not a policy's business, so nothing is mourned for it.
#[test]
fn a_departed_consumer_gets_the_delivery_back_and_nothing_is_mourned() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(1);
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropNewest))
    .sheds("reels", taps);

  assert!(sheds.deliver(&outbox, None, delivery(&[1])).is_sent());
  drop(inbox);

  let handover = sheds.deliver(&outbox, None, delivery(&[9]));
  assert!(
    matches!(handover, super::Handover::Gone(_)),
    "the edge is full AND gone, and the second fact is the one that answers"
  );
  assert!(
    !tap
      .arms()
      .iter()
      .any(|arm| matches!(arm, Seen::Shed { .. })),
    "a delivery no policy dropped has no obituary"
  );
}

/// **THE HAND IS OPTIONAL, AND THE RECORD SAYS WHAT HAPPENED.** A sender with no [`Evictor`] cannot
/// reach the far end of the queue, so drop-oldest loses the one item it has — and the obituary
/// reads `drop_newest`, because that is the shed that occurred.
#[test]
fn drop_oldest_without_a_hand_loses_the_arrival_and_records_that_it_did() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(1);
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropOldest))
    .sheds("reels", taps);

  assert!(sheds.deliver(&outbox, None, delivery(&[1])).is_sent());
  let handover = sheds.deliver(&outbox, None, delivery(&[2]));
  assert!(matches!(handover, super::Handover::Dropped(_)));
  assert_eq!(
    tap.arms(),
    [Seen::Shed {
      key: "item#2".to_owned(),
      decision: OverflowDecision::DropNewest
    }],
    "the record is of the shed and not of the wish"
  );
  assert_eq!(
    inbox.len(),
    1,
    "and the queue is untouched — with no hand there was nothing to take out of it"
  );
}

/// A queue with nothing in it to evict is the same story as no hand at all — the consumer drained
/// the edge between the refusal and the look.
#[test]
fn drop_oldest_with_nothing_left_to_evict_loses_the_arrival() {
  let (tap, taps) = watched();
  let (outbox, inbox) = channel::<ItemId, u64>(0);
  let evictor = inbox.evictor();
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropOldest))
    .sheds("reels", taps);

  // A rendezvous edge holds nothing, so the first send is already full and there is nothing queued.
  let handover = sheds.deliver(&outbox, Some(&evictor), delivery(&[5]));
  assert!(matches!(handover, super::Handover::Dropped(_)));
  assert_eq!(
    tap.arms(),
    [Seen::Shed {
      key: "item#5".to_owned(),
      decision: OverflowDecision::DropNewest
    }]
  );
}

/// An UNBOUNDED edge is opened through the same door and never reaches the policy, there being no
/// full to answer — which is exactly why the pair is refused at launch instead of here.
#[test]
fn an_unbounded_edge_never_asks_the_policy_anything() {
  let (tap, taps) = watched();
  let (outbox, inbox) = open::<ItemId, u64>(crate::ChannelOptions::Unbounded);
  let evictor = inbox.evictor();
  let sheds = Policies::new()
    .with_overflow_policy(Box::new(DropNewest))
    .sheds("reels", taps);

  for key in 0..64 {
    assert!(matches!(
      sheds.deliver(&outbox, Some(&evictor), delivery(&[key])),
      super::Handover::Sent
    ));
  }
  assert!(tap.seen().is_empty());
  assert_eq!(inbox.len(), 64);
}

// ── the deadline seat ──────────────────────────────────────────────────────────────────────────

/// **叉 B: EXPLICIT BEATS AMBIENT.** A call site that named a budget keeps it, and the policy is
/// never even asked.
#[test]
fn a_call_sites_own_budget_wins_and_the_policy_is_not_consulted() {
  let (tap, taps) = watched();
  let deadlines = Policies::new()
    .with_deadline_policy(Box::new(Mad))
    .deadlines("search", taps);

  assert_eq!(
    deadlines.resolve(Some(Duration::from_millis(25))),
    Some(Duration::from_millis(25))
  );
  assert!(
    tap.seen().is_empty(),
    "a mad advisor that is never asked cannot even be reported — which is what `never over it` means"
  );
}

/// The policy answers the SILENT caller, and only that one.
#[test]
fn the_ambient_budget_answers_where_the_call_site_said_nothing() {
  let (_tap, taps) = watched();
  let deadlines = Policies::new()
    .with_deadline_policy(Box::new(QueryDeadline::of(SignedDuration::from_millis(40))))
    .deadlines("search", taps);

  assert_eq!(deadlines.resolve(None), Some(Duration::from_millis(40)));
  assert_eq!(
    Policies::new()
      .deadlines("search", Taps::new())
      .resolve(None),
    None,
    "and the shipped default is today's behaviour: as long as it takes"
  );
}

/// A budget already in the past is *do not wait* rather than a refusal — an advisor's arithmetic
/// mistake must not become a launch failure.
#[test]
fn a_negative_ambient_budget_is_no_wait_at_all() {
  let deadlines = Policies::new()
    .with_deadline_policy(Box::new(QueryDeadline::of(SignedDuration::from_secs(-5))))
    .deadlines("search", Taps::new());
  assert_eq!(deadlines.resolve(None), Some(Duration::ZERO));
}

/// **A BREACH REACHES THE CALLER**, through the door's own vocabulary: a question that outlived its
/// ambient budget answers [`QueryError::TimedOut`], exactly as one that outlived an explicit
/// `take_within` does.
#[test]
fn a_question_that_outlives_the_ambient_budget_times_out() {
  let deadlines = Policies::new()
    .with_deadline_policy(Box::new(QueryDeadline::of(SignedDuration::from_millis(20))))
    .deadlines("search", Taps::new());

  let (held, awaiting) = reply::<u64>();
  let answer = deadlines.take(awaiting, None);
  assert_eq!(
    answer.expect_err("nobody answered inside the budget"),
    crate::QueryError::TimedOut
  );
  // Held to the end on purpose: a dropped reply would have answered `Dropped` and proved nothing
  // about the budget.
  drop(held);

  let (held, awaiting) = reply::<u64>();
  assert!(held.answer(7));
  assert_eq!(
    deadlines.take(awaiting, None).expect("answered in time"),
    7,
    "and an answer inside the budget is simply the answer"
  );
}

/// A mad deadline advisor is reported and the door reverts to waiting — 叉 A at the fourth seat,
/// through the WAIT rather than through the resolution.
#[test]
fn a_mad_deadline_advisor_leaves_the_door_waiting_as_it_always_did() {
  let (tap, taps) = watched();
  let deadlines = Policies::new()
    .with_deadline_policy(Box::new(Mad))
    .deadlines("search", taps);

  let (held, awaiting) = reply::<u64>();
  assert!(held.answer(3));
  assert_eq!(deadlines.take(awaiting, None).expect("answered"), 3);
  assert_eq!(
    tap.arms(),
    [Seen::PolicyFailed {
      concern: "deadline".to_owned(),
      error: "the advisor is unwell".to_owned()
    }]
  );
}