eredu-runtime 0.1.0

Backend-neutral model execution runtime for Eredu
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
//! Backend-neutral cache storage transition protocol.

use serde::{Deserialize, Serialize};

use eredu_core::cache::{CacheBlockId, CacheTier};

/// Stable phase of one cache block's physical resources.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum CacheStoragePhase {
    /// The execution backend owns device resources.
    Device,
    /// Device resources are retained while a host copy is produced.
    DemotingToHost,
    /// Host resources exist without a durable backing.
    HostUnbacked,
    /// Host resources are retained by an exact disk-write operation.
    HostWriting,
    /// Host resources have a durable backing.
    HostBacked,
    /// Only the durable backing is resident.
    DiskReady,
    /// A disk-read operation owns the backing and an admitted host allocation.
    DiskReading,
}

impl CacheStoragePhase {
    /// Logical accounting tier for the phase.
    pub const fn tier(self) -> CacheTier {
        match self {
            Self::Device | Self::DemotingToHost => CacheTier::Device,
            Self::HostUnbacked | Self::HostWriting | Self::HostBacked => CacheTier::Host,
            Self::DiskReady | Self::DiskReading => CacheTier::Disk,
        }
    }
}

/// Kind of asynchronous backing-store operation.
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum CacheIoOperationKind {
    /// Publish host resources to a durable backing.
    Write,
    /// Reconstruct host resources from a durable backing.
    Read,
}

/// Exact identity of one backing-store operation.
#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct CacheIoOperationKey {
    /// Cache generation in which the operation was submitted.
    pub generation: u64,
    /// Block whose resources the operation owns.
    pub id: CacheBlockId,
    /// Direction of the operation.
    pub kind: CacheIoOperationKind,
}

/// Opaque backend host-demotion completion with stable identity.
pub trait CacheHostDemotionOperation {
    /// Block whose device resources the operation owns.
    fn block_id(&self) -> &CacheBlockId;

    /// Monotonic operation identity within the backend cache session.
    fn operation_id(&self) -> u64;
}

/// Opaque backend I/O completion with an exact neutral key.
pub trait CacheIoOperation {
    /// Returns the operation identity owned by this completion.
    fn key(&self) -> &CacheIoOperationKey;
}

/// Exact rollback ownership returned by a host-to-device promotion.
#[derive(Debug)]
pub struct CacheHostPromotion<H> {
    id: CacheBlockId,
    source: CacheStoragePhase,
    host: H,
}

/// Canonical physical-resource state machine for one cache block.
///
/// `D`, `H`, and `B` are backend-owned device, host, and backing resources.
/// `HD` and `IO` are backend-owned exact completions. Private resource slots
/// prevent a backend from constructing contradictory phase/resource states.
#[derive(Debug, Clone)]
pub struct CacheBlockStorage<D, H, B, HD, IO> {
    id: CacheBlockId,
    phase: CacheStoragePhase,
    device: Option<D>,
    host: Option<H>,
    backing: Option<B>,
    host_demotion: Option<HD>,
    io: Option<IO>,
}

impl<D, H, B, HD, IO> CacheBlockStorage<D, H, B, HD, IO> {
    /// Creates device residency, optionally retaining an existing backing.
    pub fn device(id: CacheBlockId, device: D, backing: Option<B>) -> Self {
        Self {
            id,
            phase: CacheStoragePhase::Device,
            device: Some(device),
            host: None,
            backing,
            host_demotion: None,
            io: None,
        }
    }

    /// Creates host residency, optionally retaining an existing backing.
    pub fn host(id: CacheBlockId, host: H, backing: Option<B>) -> Self {
        Self {
            id,
            phase: if backing.is_some() {
                CacheStoragePhase::HostBacked
            } else {
                CacheStoragePhase::HostUnbacked
            },
            device: None,
            host: Some(host),
            backing,
            host_demotion: None,
            io: None,
        }
    }

    /// Creates ready backing-only residency.
    pub fn disk(id: CacheBlockId, backing: B) -> Self {
        Self {
            id,
            phase: CacheStoragePhase::DiskReady,
            device: None,
            host: None,
            backing: Some(backing),
            host_demotion: None,
            io: None,
        }
    }

    /// Current canonical phase.
    pub const fn phase(&self) -> CacheStoragePhase {
        self.phase
    }

    /// Block whose physical resources are owned by this state machine.
    pub const fn id(&self) -> &CacheBlockId {
        &self.id
    }

    /// Current logical accounting tier.
    pub const fn tier(&self) -> CacheTier {
        self.phase.tier()
    }

    /// Backend device resources, including while a demotion is pending.
    pub fn device_resource(&self) -> Option<&D> {
        self.device.as_ref()
    }

    /// Backend host resources.
    pub fn host_resource(&self) -> Option<&H> {
        self.host.as_ref()
    }

    /// Durable backing retained by the current phase.
    pub fn backing(&self) -> Option<&B> {
        self.backing.as_ref()
    }

    /// Exact pending host-demotion completion.
    pub fn host_demotion(&self) -> Option<&HD> {
        self.host_demotion.as_ref()
    }

    /// Exact pending backing-store completion.
    pub fn io(&self) -> Option<&IO> {
        self.io.as_ref()
    }
}

impl<D, H, B, HD: CacheHostDemotionOperation, IO: CacheIoOperation>
    CacheBlockStorage<D, H, B, HD, IO>
{
    /// Returns whether the exact backing-store operation is pending.
    pub fn io_matches(&self, key: &CacheIoOperationKey) -> bool {
        self.io.as_ref().is_some_and(|io| io.key() == key)
    }

    /// Fails the operation only when the exact key is still pending.
    pub fn fail_io_if_matches(&mut self, key: &CacheIoOperationKey) -> bool {
        if self.io_matches(key) {
            self.fail_io(key)
                .expect("matching pending I/O has a valid source phase");
            true
        } else {
            false
        }
    }

    /// Begins an exact device-to-host transition while retaining device state.
    pub fn begin_host_demotion(&mut self, operation: HD) -> Result<(), CacheStorageError> {
        self.require_phase(CacheStoragePhase::Device)?;
        self.require_block(operation.block_id())?;
        if self.backing.is_some() {
            return Err(CacheStorageError::BackingAlreadyExists);
        }
        self.host_demotion = Some(operation);
        self.phase = CacheStoragePhase::DemotingToHost;
        Ok(())
    }

    /// Commits the matching host demotion and returns released device resources.
    pub fn finish_host_demotion(
        &mut self,
        operation_id: u64,
        host: H,
    ) -> Result<(D, HD), CacheStorageError> {
        self.require_host_demotion(operation_id)?;
        let device = self
            .device
            .take()
            .expect("demoting phase retains device resources");
        let operation = self
            .host_demotion
            .take()
            .expect("demoting phase retains its exact operation");
        self.host = Some(host);
        self.phase = CacheStoragePhase::HostUnbacked;
        Ok((device, operation))
    }

    /// Abandons the matching host demotion and restores device residency.
    pub fn fail_host_demotion(&mut self, operation_id: u64) -> Result<HD, CacheStorageError> {
        self.require_host_demotion(operation_id)?;
        let operation = self
            .host_demotion
            .take()
            .expect("demoting phase retains its exact operation");
        self.phase = CacheStoragePhase::Device;
        Ok(operation)
    }

    /// Releases backed device resources directly to backing-only residency.
    pub fn release_device_to_disk(&mut self) -> Result<D, CacheStorageError> {
        self.require_phase(CacheStoragePhase::Device)?;
        if self.backing.is_none() {
            return Err(CacheStorageError::BackingRequired);
        }
        let device = self
            .device
            .take()
            .expect("device phase owns device resources");
        self.phase = CacheStoragePhase::DiskReady;
        Ok(device)
    }

    /// Releases backed host resources directly to backing-only residency.
    pub fn release_host_to_disk(&mut self) -> Result<H, CacheStorageError> {
        self.require_phase(CacheStoragePhase::HostBacked)?;
        let host = self
            .host
            .take()
            .expect("host-backed phase owns host resources");
        self.phase = CacheStoragePhase::DiskReady;
        Ok(host)
    }

    /// Starts the exact write that owns unbacked host resources.
    pub fn begin_write(&mut self, operation: IO) -> Result<(), CacheStorageError> {
        self.require_phase(CacheStoragePhase::HostUnbacked)?;
        self.require_block(&operation.key().id)?;
        self.require_kind(operation.key(), CacheIoOperationKind::Write)?;
        self.io = Some(operation);
        self.phase = CacheStoragePhase::HostWriting;
        Ok(())
    }

    /// Commits the matching write and returns released host resources.
    pub fn finish_write(
        &mut self,
        key: &CacheIoOperationKey,
        backing: B,
    ) -> Result<(H, IO), CacheStorageError> {
        self.require_io(CacheStoragePhase::HostWriting, key)?;
        let host = self
            .host
            .take()
            .expect("host-writing phase retains host resources");
        let operation = self.io.take().expect("host-writing phase retains I/O");
        self.backing = Some(backing);
        self.phase = CacheStoragePhase::DiskReady;
        Ok((host, operation))
    }

    /// Starts the exact read that owns backing-only resources.
    pub fn begin_read(&mut self, operation: IO) -> Result<(), CacheStorageError> {
        self.require_phase(CacheStoragePhase::DiskReady)?;
        self.require_block(&operation.key().id)?;
        self.require_kind(operation.key(), CacheIoOperationKind::Read)?;
        self.io = Some(operation);
        self.phase = CacheStoragePhase::DiskReading;
        Ok(())
    }

    /// Commits the matching read while retaining its durable backing.
    pub fn finish_read(
        &mut self,
        key: &CacheIoOperationKey,
        host: H,
    ) -> Result<IO, CacheStorageError> {
        self.require_io(CacheStoragePhase::DiskReading, key)?;
        let operation = self.io.take().expect("disk-reading phase retains I/O");
        self.host = Some(host);
        self.phase = CacheStoragePhase::HostBacked;
        Ok(operation)
    }

    /// Cancels or fails the matching I/O and restores its stable source phase.
    pub fn fail_io(&mut self, key: &CacheIoOperationKey) -> Result<IO, CacheStorageError> {
        let stable = match self.phase {
            CacheStoragePhase::HostWriting => CacheStoragePhase::HostUnbacked,
            CacheStoragePhase::DiskReading => CacheStoragePhase::DiskReady,
            actual => return Err(CacheStorageError::IoNotPending { actual }),
        };
        self.require_io(self.phase, key)?;
        let operation = self.io.take().expect("pending phase retains I/O");
        self.phase = stable;
        Ok(operation)
    }

    /// Promotes stable host resources to device residency.
    pub fn promote_host(&mut self, device: D) -> Result<CacheHostPromotion<H>, CacheStorageError> {
        if !matches!(
            self.phase,
            CacheStoragePhase::HostUnbacked | CacheStoragePhase::HostBacked
        ) {
            return Err(CacheStorageError::InvalidPhase {
                expected: CacheStoragePhase::HostUnbacked,
                actual: self.phase,
            });
        }
        let source = self.phase;
        let host = self
            .host
            .take()
            .expect("stable host phase owns host resources");
        self.device = Some(device);
        self.phase = CacheStoragePhase::Device;
        Ok(CacheHostPromotion {
            id: self.id.clone(),
            source,
            host,
        })
    }

    /// Restores host resources after a rejected promotion.
    pub fn restore_host(
        &mut self,
        promotion: CacheHostPromotion<H>,
    ) -> Result<D, CacheStorageError> {
        self.require_phase(CacheStoragePhase::Device)?;
        self.require_block(&promotion.id)?;
        let expected_source = if self.backing.is_some() {
            CacheStoragePhase::HostBacked
        } else {
            CacheStoragePhase::HostUnbacked
        };
        if promotion.source != expected_source {
            return Err(CacheStorageError::InvalidPhase {
                expected: expected_source,
                actual: promotion.source,
            });
        }
        let device = self
            .device
            .take()
            .expect("device phase owns device resources");
        self.host = Some(promotion.host);
        self.phase = promotion.source;
        Ok(device)
    }

    fn require_phase(&self, expected: CacheStoragePhase) -> Result<(), CacheStorageError> {
        if self.phase == expected {
            Ok(())
        } else {
            Err(CacheStorageError::InvalidPhase {
                expected,
                actual: self.phase,
            })
        }
    }

    fn require_host_demotion(&self, operation_id: u64) -> Result<(), CacheStorageError> {
        self.require_phase(CacheStoragePhase::DemotingToHost)?;
        let actual = self
            .host_demotion
            .as_ref()
            .expect("demoting phase retains its exact operation")
            .operation_id();
        if actual == operation_id {
            Ok(())
        } else {
            Err(CacheStorageError::HostDemotionMismatch {
                expected: actual,
                actual: operation_id,
            })
        }
    }

    fn require_io(
        &self,
        phase: CacheStoragePhase,
        key: &CacheIoOperationKey,
    ) -> Result<(), CacheStorageError> {
        self.require_phase(phase)?;
        let expected = self
            .io
            .as_ref()
            .expect("pending I/O phase retains its exact operation")
            .key();
        if expected == key {
            Ok(())
        } else {
            Err(CacheStorageError::IoMismatch {
                expected: Box::new(expected.clone()),
                actual: Box::new(key.clone()),
            })
        }
    }

    fn require_kind(
        &self,
        key: &CacheIoOperationKey,
        expected: CacheIoOperationKind,
    ) -> Result<(), CacheStorageError> {
        if key.kind == expected {
            Ok(())
        } else {
            Err(CacheStorageError::IoKindMismatch {
                expected,
                actual: key.kind,
            })
        }
    }

    fn require_block(&self, actual: &CacheBlockId) -> Result<(), CacheStorageError> {
        if actual == &self.id {
            Ok(())
        } else {
            Err(CacheStorageError::BlockMismatch {
                expected: Box::new(self.id.clone()),
                actual: Box::new(actual.clone()),
            })
        }
    }
}

/// Illegal cache storage phase transition or completion observation.
#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
pub enum CacheStorageError {
    /// An operation belongs to a different cache block.
    #[error("cache storage block mismatch: expected {expected:?}, observed {actual:?}")]
    BlockMismatch {
        /// Block owned by the state machine.
        expected: Box<CacheBlockId>,
        /// Block owned by the presented operation.
        actual: Box<CacheBlockId>,
    },
    /// An operation is not legal from the current phase.
    #[error("cache storage phase is {actual:?}, expected {expected:?}")]
    InvalidPhase {
        /// Required source phase.
        expected: CacheStoragePhase,
        /// Observed source phase.
        actual: CacheStoragePhase,
    },
    /// No backing-store operation is pending in the current phase.
    #[error("cache storage phase {actual:?} has no pending I/O")]
    IoNotPending {
        /// Observed stable or unrelated phase.
        actual: CacheStoragePhase,
    },
    /// A device block already had a durable backing.
    #[error("cache storage already has a durable backing")]
    BackingAlreadyExists,
    /// A direct release required a durable backing.
    #[error("cache storage requires a durable backing")]
    BackingRequired,
    /// A different host-demotion completion attempted to resolve the phase.
    #[error("host demotion operation mismatch: expected {expected}, observed {actual}")]
    HostDemotionMismatch {
        /// Operation retained by the state machine.
        expected: u64,
        /// Operation presented by the backend.
        actual: u64,
    },
    /// A different backing-store completion attempted to resolve the phase.
    #[error("cache I/O operation mismatch: expected {expected:?}, observed {actual:?}")]
    IoMismatch {
        /// Operation retained by the state machine.
        expected: Box<CacheIoOperationKey>,
        /// Operation presented by the backend.
        actual: Box<CacheIoOperationKey>,
    },
    /// A read/write completion was submitted to the opposite transition.
    #[error("cache I/O kind is {actual:?}, expected {expected:?}")]
    IoKindMismatch {
        /// Required operation direction.
        expected: CacheIoOperationKind,
        /// Observed operation direction.
        actual: CacheIoOperationKind,
    },
}

#[cfg(test)]
mod tests {
    use super::*;
    use eredu_core::cache::CacheRepresentation;

    #[derive(Debug, Clone, Eq, PartialEq)]
    struct HostOp {
        id: CacheBlockId,
        operation_id: u64,
    }

    impl CacheHostDemotionOperation for HostOp {
        fn block_id(&self) -> &CacheBlockId {
            &self.id
        }

        fn operation_id(&self) -> u64 {
            self.operation_id
        }
    }

    #[derive(Debug, Clone, Eq, PartialEq)]
    struct IoOp(CacheIoOperationKey);

    impl CacheIoOperation for IoOp {
        fn key(&self) -> &CacheIoOperationKey {
            &self.0
        }
    }

    fn block() -> CacheBlockId {
        CacheBlockId {
            session_id: 1,
            global_layer: 2,
            representation: CacheRepresentation::KeyValue,
            start: 0,
            end: 4,
            rank: None,
        }
    }

    fn io(kind: CacheIoOperationKind, generation: u64) -> IoOp {
        IoOp(CacheIoOperationKey {
            generation,
            id: block(),
            kind,
        })
    }

    #[test]
    fn exact_host_demotion_commits_or_rolls_back_without_losing_device_state() {
        let id = block();
        let mut storage = CacheBlockStorage::<_, String, String, _, IoOp>::device(
            id.clone(),
            "device".to_owned(),
            None,
        );
        storage
            .begin_host_demotion(HostOp {
                id,
                operation_id: 7,
            })
            .unwrap();
        assert_eq!(storage.phase(), CacheStoragePhase::DemotingToHost);
        assert_eq!(
            storage.finish_host_demotion(8, "host".to_owned()),
            Err(CacheStorageError::HostDemotionMismatch {
                expected: 7,
                actual: 8,
            })
        );
        assert_eq!(
            storage.device_resource().map(String::as_str),
            Some("device")
        );
        storage.fail_host_demotion(7).unwrap();
        assert_eq!(storage.phase(), CacheStoragePhase::Device);
    }

    #[test]
    fn write_read_and_promotion_follow_one_exact_transaction_chain() {
        let mut storage = CacheBlockStorage::<String, String, String, HostOp, _>::host(
            block(),
            "host".to_owned(),
            None,
        );
        let write = io(CacheIoOperationKind::Write, 3);
        storage.begin_write(write.clone()).unwrap();
        let stale = io(CacheIoOperationKind::Write, 2);
        assert!(matches!(
            storage.finish_write(stale.key(), "disk".to_owned()),
            Err(CacheStorageError::IoMismatch { .. })
        ));
        let (host, observed) = storage
            .finish_write(write.key(), "disk".to_owned())
            .unwrap();
        assert_eq!(host, "host");
        assert_eq!(observed, write);
        assert_eq!(storage.phase(), CacheStoragePhase::DiskReady);

        let read = io(CacheIoOperationKind::Read, 4);
        storage.begin_read(read.clone()).unwrap();
        storage
            .finish_read(read.key(), "host-2".to_owned())
            .unwrap();
        assert_eq!(storage.phase(), CacheStoragePhase::HostBacked);
        let promotion = storage.promote_host("device-2".to_owned()).unwrap();
        assert_eq!(promotion.host, "host-2");
        assert_eq!(storage.backing().map(String::as_str), Some("disk"));
        storage.release_device_to_disk().unwrap();
        assert_eq!(storage.phase(), CacheStoragePhase::DiskReady);
    }

    #[test]
    fn failed_io_restores_the_stable_source_phase() {
        let mut write = CacheBlockStorage::<String, _, String, HostOp, _>::host(block(), 3u8, None);
        let write_op = io(CacheIoOperationKind::Write, 1);
        write.begin_write(write_op.clone()).unwrap();
        assert_eq!(write.fail_io(write_op.key()).unwrap(), write_op);
        assert_eq!(write.phase(), CacheStoragePhase::HostUnbacked);

        let mut read =
            CacheBlockStorage::<String, u8, _, HostOp, _>::disk(block(), "disk".to_owned());
        let read_op = io(CacheIoOperationKind::Read, 1);
        read.begin_read(read_op.clone()).unwrap();
        assert_eq!(read.fail_io(read_op.key()).unwrap(), read_op);
        assert_eq!(read.phase(), CacheStoragePhase::DiskReady);
    }

    #[test]
    fn operation_for_another_block_fails_without_changing_phase() {
        let owned = block();
        let mut foreign = block();
        foreign.global_layer += 1;
        let mut storage =
            CacheBlockStorage::<String, u8, String, HostOp, _>::host(owned.clone(), 3, None);
        let operation = IoOp(CacheIoOperationKey {
            generation: 1,
            id: foreign.clone(),
            kind: CacheIoOperationKind::Write,
        });

        assert_eq!(
            storage.begin_write(operation),
            Err(CacheStorageError::BlockMismatch {
                expected: Box::new(owned),
                actual: Box::new(foreign),
            })
        );
        assert_eq!(storage.phase(), CacheStoragePhase::HostUnbacked);
    }

    #[test]
    fn phase_and_operation_identity_round_trip_portably() {
        let key = io(CacheIoOperationKind::Read, 9).0;
        let encoded = serde_json::to_string(&(CacheStoragePhase::DiskReading, &key)).unwrap();
        let decoded: (CacheStoragePhase, CacheIoOperationKey) =
            serde_json::from_str(&encoded).unwrap();
        assert_eq!(decoded, (CacheStoragePhase::DiskReading, key));
    }
}