oxirs-core 0.2.2

Core RDF and SPARQL functionality for OxiRS - native Rust implementation with zero dependencies
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
//! Time-series optimization for temporal RDF
//!
//! This module provides specialized storage for temporal RDF data,
//! optimizing for time-based queries and temporal reasoning.

use crate::model::{Literal, Term, Triple, TriplePattern};
use crate::OxirsError;
use chrono::{DateTime, Duration, Utc};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap, VecDeque};
use std::ops::Bound;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::RwLock;

/// Temporal storage configuration
#[derive(Debug, Clone)]
pub struct TemporalConfig {
    /// Base path for temporal data
    pub path: PathBuf,
    /// Time bucket duration
    pub bucket_duration: Duration,
    /// Retention policy
    pub retention: RetentionPolicy,
    /// Indexing strategy
    pub indexing: TemporalIndexing,
    /// Enable temporal compression
    pub compression: bool,
}

impl Default for TemporalConfig {
    fn default() -> Self {
        TemporalConfig {
            path: PathBuf::from("/var/oxirs/temporal"),
            bucket_duration: Duration::hours(1),
            retention: RetentionPolicy::Days(365),
            indexing: TemporalIndexing::default(),
            compression: true,
        }
    }
}

/// Retention policy for temporal data
#[derive(Clone)]
pub enum RetentionPolicy {
    /// Keep data forever
    Forever,
    /// Keep data for N days
    Days(u32),
    /// Keep data for N months
    Months(u32),
    /// Keep last N versions
    Versions(u32),
    /// Custom policy function
    Custom(Arc<dyn Fn(&TemporalTriple) -> bool + Send + Sync>),
}

impl std::fmt::Debug for RetentionPolicy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            RetentionPolicy::Forever => write!(f, "Forever"),
            RetentionPolicy::Days(n) => write!(f, "Days({n})"),
            RetentionPolicy::Months(n) => write!(f, "Months({n})"),
            RetentionPolicy::Versions(n) => write!(f, "Versions({n})"),
            RetentionPolicy::Custom(_) => write!(f, "Custom(<function>)"),
        }
    }
}

/// Temporal indexing strategy
#[derive(Debug, Clone)]
pub struct TemporalIndexing {
    /// Index by time intervals
    pub interval_index: bool,
    /// Index by entity history
    pub entity_index: bool,
    /// Index by change events
    pub change_index: bool,
    /// Enable Allen interval relations
    pub allen_relations: bool,
}

impl Default for TemporalIndexing {
    fn default() -> Self {
        TemporalIndexing {
            interval_index: true,
            entity_index: true,
            change_index: true,
            allen_relations: false,
        }
    }
}

/// Temporal triple with time metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemporalTriple {
    /// The base triple
    pub triple: Triple,
    /// Valid time start
    pub valid_from: DateTime<Utc>,
    /// Valid time end (None means currently valid)
    pub valid_to: Option<DateTime<Utc>>,
    /// Transaction time
    pub transaction_time: DateTime<Utc>,
    /// Additional temporal metadata
    pub metadata: TemporalMetadata,
}

/// Temporal metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemporalMetadata {
    /// Certainty factor (0.0 - 1.0)
    pub certainty: Option<f64>,
    /// Provenance information
    pub provenance: Option<String>,
    /// Is this a predicted/inferred value
    pub predicted: bool,
    /// Temporal granularity
    pub granularity: TemporalGranularity,
}

/// Temporal granularity
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TemporalGranularity {
    Nanosecond,
    Microsecond,
    Millisecond,
    Second,
    Minute,
    Hour,
    Day,
    Month,
    Year,
}

/// Temporal storage engine
pub struct TemporalStorage {
    config: TemporalConfig,
    /// Time-bucketed storage
    buckets: Arc<RwLock<BTreeMap<DateTime<Utc>, Bucket>>>,
    /// Interval index
    #[allow(dead_code)]
    interval_index: Arc<RwLock<IntervalIndex>>,
    /// Entity history index
    entity_index: Arc<RwLock<EntityIndex>>,
    /// Change event index
    change_index: Arc<RwLock<ChangeIndex>>,
    /// Statistics
    stats: Arc<RwLock<TemporalStats>>,
}

/// Time bucket for efficient temporal storage
struct Bucket {
    /// Start time of bucket
    #[allow(dead_code)]
    start_time: DateTime<Utc>,
    /// Triples in this bucket
    triples: Vec<TemporalTriple>,
    /// Bucket statistics
    stats: BucketStats,
}

/// Bucket statistics
#[derive(Debug, Default)]
struct BucketStats {
    triple_count: usize,
    #[allow(dead_code)]
    compressed_size: Option<usize>,
    last_access: DateTime<Utc>,
}

/// Interval index for temporal queries
struct IntervalIndex {
    /// Interval tree for efficient range queries
    #[allow(dead_code)]
    intervals: IntervalTree<DateTime<Utc>, TemporalTriple>,
}

/// Entity history index
struct EntityIndex {
    /// Entity URI to history mapping
    entity_history: HashMap<String, EntityHistory>,
}

/// Entity history
#[derive(Debug, Clone)]
pub struct EntityHistory {
    /// Chronological list of states
    states: BTreeMap<DateTime<Utc>, EntityState>,
    /// Change events
    #[allow(dead_code)]
    changes: Vec<ChangeEvent>,
}

/// Entity state at a point in time
#[derive(Debug, Clone)]
struct EntityState {
    /// Properties at this time
    properties: HashMap<String, Vec<Literal>>,
    /// Relationships at this time
    relationships: HashMap<String, Vec<String>>,
}

/// Change event
#[derive(Debug, Clone)]
pub struct ChangeEvent {
    /// Time of change
    #[allow(dead_code)]
    timestamp: DateTime<Utc>,
    /// Type of change
    #[allow(dead_code)]
    change_type: ChangeType,
    /// Changed property/relationship
    property: String,
    /// Old value
    #[allow(dead_code)]
    old_value: Option<Term>,
    /// New value
    #[allow(dead_code)]
    new_value: Option<Term>,
}

/// Type of change
#[derive(Debug, Clone)]
enum ChangeType {
    Insert,
    #[allow(dead_code)]
    Update,
    #[allow(dead_code)]
    Delete,
}

/// Change event index
struct ChangeIndex {
    /// Recent changes queue
    recent_changes: VecDeque<ChangeEvent>,
    /// Changes by property
    property_changes: HashMap<String, Vec<ChangeEvent>>,
}

/// Temporal statistics
#[derive(Debug, Default)]
struct TemporalStats {
    total_triples: u64,
    active_triples: u64,
    historical_triples: u64,
    #[allow(dead_code)]
    total_buckets: u64,
    #[allow(dead_code)]
    compression_ratio: f64,
    #[allow(dead_code)]
    avg_query_time_ms: f64,
}

/// Interval tree for temporal queries (simplified placeholder)
struct IntervalTree<K, V> {
    _key: std::marker::PhantomData<K>,
    _value: std::marker::PhantomData<V>,
}

impl<K, V> IntervalTree<K, V> {
    fn new() -> Self {
        IntervalTree {
            _key: std::marker::PhantomData,
            _value: std::marker::PhantomData,
        }
    }
}

impl TemporalStorage {
    /// Create new temporal storage
    pub async fn new(config: TemporalConfig) -> Result<Self, OxirsError> {
        std::fs::create_dir_all(&config.path)?;

        Ok(TemporalStorage {
            config,
            buckets: Arc::new(RwLock::new(BTreeMap::new())),
            interval_index: Arc::new(RwLock::new(IntervalIndex {
                intervals: IntervalTree::new(),
            })),
            entity_index: Arc::new(RwLock::new(EntityIndex {
                entity_history: HashMap::new(),
            })),
            change_index: Arc::new(RwLock::new(ChangeIndex {
                recent_changes: VecDeque::with_capacity(10000),
                property_changes: HashMap::new(),
            })),
            stats: Arc::new(RwLock::new(TemporalStats::default())),
        })
    }

    /// Store a temporal triple
    pub async fn store_temporal(
        &self,
        triple: Triple,
        valid_from: DateTime<Utc>,
        valid_to: Option<DateTime<Utc>>,
        metadata: Option<TemporalMetadata>,
    ) -> Result<(), OxirsError> {
        let temporal_triple = TemporalTriple {
            triple: triple.clone(),
            valid_from,
            valid_to,
            transaction_time: Utc::now(),
            metadata: metadata.unwrap_or(TemporalMetadata {
                certainty: None,
                provenance: None,
                predicted: false,
                granularity: TemporalGranularity::Second,
            }),
        };

        // Determine bucket
        let bucket_time = self.get_bucket_time(valid_from);

        // Store in bucket
        {
            let mut buckets = self.buckets.write().await;
            let bucket = buckets.entry(bucket_time).or_insert_with(|| Bucket {
                start_time: bucket_time,
                triples: Vec::new(),
                stats: BucketStats::default(),
            });

            bucket.triples.push(temporal_triple.clone());
            bucket.stats.triple_count += 1;
            bucket.stats.last_access = Utc::now();
        }

        // Update indexes
        if self.config.indexing.entity_index {
            self.update_entity_index(&temporal_triple).await?;
        }

        if self.config.indexing.change_index {
            self.update_change_index(&temporal_triple).await?;
        }

        // Update stats
        let mut stats = self.stats.write().await;
        stats.total_triples += 1;
        if valid_to.is_none() {
            stats.active_triples += 1;
        } else {
            stats.historical_triples += 1;
        }

        Ok(())
    }

    /// Query triples at a specific time point
    pub async fn query_at_time(
        &self,
        pattern: &TriplePattern,
        time: DateTime<Utc>,
    ) -> Result<Vec<Triple>, OxirsError> {
        let mut results = Vec::new();

        // Search relevant buckets
        let buckets = self.buckets.read().await;
        for (_, bucket) in buckets.iter() {
            for temporal in &bucket.triples {
                // Check if triple is valid at the given time
                if temporal.valid_from <= time {
                    if let Some(valid_to) = temporal.valid_to {
                        if valid_to < time {
                            continue;
                        }
                    }

                    // Check if pattern matches
                    if pattern.matches(&temporal.triple) {
                        results.push(temporal.triple.clone());
                    }
                }
            }
        }

        Ok(results)
    }

    /// Query triples within a time range
    pub async fn query_time_range(
        &self,
        pattern: &TriplePattern,
        start: DateTime<Utc>,
        end: DateTime<Utc>,
    ) -> Result<Vec<TemporalTriple>, OxirsError> {
        let mut results = Vec::new();

        // Get relevant buckets
        let start_bucket = self.get_bucket_time(start);
        let end_bucket = self.get_bucket_time(end);

        let buckets = self.buckets.read().await;
        let range = buckets.range((Bound::Included(start_bucket), Bound::Included(end_bucket)));

        for (_, bucket) in range {
            for temporal in &bucket.triples {
                // Check temporal overlap
                if temporal.valid_from <= end {
                    if let Some(valid_to) = temporal.valid_to {
                        if valid_to < start {
                            continue;
                        }
                    }

                    // Check pattern match
                    if pattern.matches(&temporal.triple) {
                        results.push(temporal.clone());
                    }
                }
            }
        }

        Ok(results)
    }

    /// Get entity history
    pub async fn get_entity_history(
        &self,
        entity_uri: &str,
    ) -> Result<Option<EntityHistory>, OxirsError> {
        let entity_index = self.entity_index.read().await;
        Ok(entity_index.entity_history.get(entity_uri).cloned())
    }

    /// Get recent changes
    pub async fn get_recent_changes(&self, limit: usize) -> Result<Vec<ChangeEvent>, OxirsError> {
        let change_index = self.change_index.read().await;
        Ok(change_index
            .recent_changes
            .iter()
            .take(limit)
            .cloned()
            .collect())
    }

    /// Perform temporal reasoning
    pub async fn temporal_reason(
        &self,
        query: TemporalQuery,
    ) -> Result<TemporalResult, OxirsError> {
        match query {
            TemporalQuery::AllenRelation {
                triple1: _,
                triple2: _,
                relation: _,
            } => {
                // Implement Allen's interval algebra
                Ok(TemporalResult::Boolean(false)) // Placeholder
            }
            TemporalQuery::TemporalPath {
                start: _,
                end: _,
                predicate: _,
                max_hops: _,
            } => {
                // Find temporal paths between entities
                Ok(TemporalResult::Paths(Vec::new())) // Placeholder
            }
            TemporalQuery::ChangeDetection {
                entity: _,
                property: _,
                threshold: _,
            } => {
                // Detect significant changes
                Ok(TemporalResult::Changes(Vec::new())) // Placeholder
            }
            TemporalQuery::TrendAnalysis {
                entity: _,
                property: _,
                window: _,
            } => {
                // Analyze trends over time
                Ok(TemporalResult::Trend(TrendData::default())) // Placeholder
            }
        }
    }

    /// Apply retention policy
    pub async fn apply_retention(&self) -> Result<usize, OxirsError> {
        let mut removed = 0;
        let now = Utc::now();

        let mut buckets = self.buckets.write().await;
        let mut to_remove = Vec::new();

        for (bucket_time, bucket) in buckets.iter_mut() {
            match &self.config.retention {
                RetentionPolicy::Days(days) => {
                    let cutoff = now - Duration::days(*days as i64);
                    if *bucket_time < cutoff {
                        to_remove.push(*bucket_time);
                        removed += bucket.triples.len();
                    }
                }
                RetentionPolicy::Months(months) => {
                    let cutoff = now - Duration::days((*months as i64) * 30);
                    if *bucket_time < cutoff {
                        to_remove.push(*bucket_time);
                        removed += bucket.triples.len();
                    }
                }
                _ => {} // Other policies not implemented in this example
            }
        }

        for bucket_time in to_remove {
            buckets.remove(&bucket_time);
        }

        // Update stats
        let mut stats = self.stats.write().await;
        stats.total_triples = stats.total_triples.saturating_sub(removed as u64);

        Ok(removed)
    }

    /// Get bucket time for a given timestamp
    fn get_bucket_time(&self, time: DateTime<Utc>) -> DateTime<Utc> {
        let bucket_seconds = self.config.bucket_duration.num_seconds();
        let timestamp = time.timestamp();
        let bucket_timestamp = (timestamp / bucket_seconds) * bucket_seconds;
        DateTime::from_timestamp(bucket_timestamp, 0).expect("bucket timestamp should be valid")
    }

    /// Update entity index
    async fn update_entity_index(&self, temporal: &TemporalTriple) -> Result<(), OxirsError> {
        let mut entity_index = self.entity_index.write().await;

        // Extract entity URI from subject
        let entity_uri = match temporal.triple.subject() {
            crate::model::Subject::NamedNode(nn) => nn.as_str().to_string(),
            _ => return Ok(()), // Skip non-URI subjects
        };

        let history = entity_index
            .entity_history
            .entry(entity_uri)
            .or_insert_with(|| EntityHistory {
                states: BTreeMap::new(),
                changes: Vec::new(),
            });

        // Update entity state
        let state = history
            .states
            .entry(temporal.valid_from)
            .or_insert_with(|| EntityState {
                properties: HashMap::new(),
                relationships: HashMap::new(),
            });

        // Add property or relationship
        let predicate_uri = match temporal.triple.predicate() {
            crate::model::Predicate::NamedNode(nn) => nn.as_str(),
            crate::model::Predicate::Variable(v) => v.as_str(),
        };
        match temporal.triple.object() {
            crate::model::Object::Literal(lit) => {
                state
                    .properties
                    .entry(predicate_uri.to_string())
                    .or_insert_with(Vec::new)
                    .push(lit.clone());
            }
            crate::model::Object::NamedNode(nn) => {
                state
                    .relationships
                    .entry(predicate_uri.to_string())
                    .or_insert_with(Vec::new)
                    .push(nn.as_str().to_string());
            }
            _ => {}
        }

        Ok(())
    }

    /// Update change index
    async fn update_change_index(&self, temporal: &TemporalTriple) -> Result<(), OxirsError> {
        let mut change_index = self.change_index.write().await;

        let change = ChangeEvent {
            timestamp: temporal.valid_from,
            change_type: ChangeType::Insert,
            property: match temporal.triple.predicate() {
                crate::model::Predicate::NamedNode(nn) => nn.as_str(),
                crate::model::Predicate::Variable(v) => v.as_str(),
            }
            .to_string(),
            old_value: None,
            new_value: Some(Term::from_object(temporal.triple.object())),
        };

        // Add to recent changes
        change_index.recent_changes.push_front(change.clone());
        if change_index.recent_changes.len() > 10000 {
            change_index.recent_changes.pop_back();
        }

        // Index by property
        change_index
            .property_changes
            .entry(change.property.clone())
            .or_insert_with(Vec::new)
            .push(change);

        Ok(())
    }
}

/// Temporal query types
#[derive(Debug, Clone)]
pub enum TemporalQuery {
    /// Allen interval relation query
    AllenRelation {
        triple1: Box<TemporalTriple>,
        triple2: Box<TemporalTriple>,
        relation: AllenRelation,
    },
    /// Temporal path query
    TemporalPath {
        start: String,
        end: String,
        predicate: Option<String>,
        max_hops: usize,
    },
    /// Change detection query
    ChangeDetection {
        entity: String,
        property: String,
        threshold: f64,
    },
    /// Trend analysis query
    TrendAnalysis {
        entity: String,
        property: String,
        window: Duration,
    },
}

/// Allen's interval relations
#[derive(Debug, Clone)]
pub enum AllenRelation {
    Before,
    After,
    Meets,
    MetBy,
    Overlaps,
    OverlappedBy,
    Starts,
    StartedBy,
    During,
    Contains,
    Finishes,
    FinishedBy,
    Equals,
}

/// Temporal query result
#[derive(Debug)]
pub enum TemporalResult {
    Boolean(bool),
    Paths(Vec<Vec<TemporalTriple>>),
    Changes(Vec<ChangeEvent>),
    Trend(TrendData),
}

/// Trend analysis data
#[derive(Debug, Default)]
pub struct TrendData {
    pub slope: f64,
    pub intercept: f64,
    pub r_squared: f64,
    pub predictions: Vec<(DateTime<Utc>, f64)>,
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::model::NamedNode;

    #[tokio::test]
    async fn test_temporal_storage() {
        let config = TemporalConfig {
            path: PathBuf::from("/tmp/oxirs_temporal_test"),
            ..Default::default()
        };

        let storage = TemporalStorage::new(config)
            .await
            .expect("async operation should succeed");

        // Create temporal triple
        let triple = Triple::new(
            NamedNode::new("http://example.org/person1").expect("valid IRI"),
            NamedNode::new("http://example.org/age").expect("valid IRI"),
            crate::model::Object::Literal(Literal::new("25")),
        );

        let valid_from = Utc::now() - Duration::days(365);
        let valid_to = Some(Utc::now() - Duration::days(180));

        // Store temporal triple
        storage
            .store_temporal(triple.clone(), valid_from, valid_to, None)
            .await
            .expect("operation should succeed");

        // Query at a time when triple was valid
        let query_time = Utc::now() - Duration::days(270);
        let pattern = TriplePattern::new(
            Some(crate::model::SubjectPattern::NamedNode(
                NamedNode::new("http://example.org/person1").expect("valid IRI"),
            )),
            None,
            None,
        );

        let results = storage
            .query_at_time(&pattern, query_time)
            .await
            .expect("async operation should succeed");
        assert_eq!(results.len(), 1);
        assert_eq!(results[0], triple);

        // Query at current time (should be empty as triple is no longer valid)
        let current_results = storage
            .query_at_time(&pattern, Utc::now())
            .await
            .expect("async operation should succeed");
        assert_eq!(current_results.len(), 0);
    }

    #[tokio::test]
    async fn test_entity_history() {
        let config = TemporalConfig {
            path: PathBuf::from("/tmp/oxirs_temporal_history"),
            ..Default::default()
        };

        let storage = TemporalStorage::new(config)
            .await
            .expect("async operation should succeed");

        let entity = "http://example.org/person1";

        // Store multiple versions of age
        for age in 20..=25 {
            let triple = Triple::new(
                NamedNode::new(entity).expect("valid IRI"),
                NamedNode::new("http://example.org/age").expect("valid IRI"),
                crate::model::Object::Literal(Literal::new(age.to_string())),
            );

            let valid_from = Utc::now() - Duration::days((26 - age) as i64 * 365);
            storage
                .store_temporal(triple, valid_from, None, None)
                .await
                .expect("operation should succeed");
        }

        // Get entity history
        let history = storage
            .get_entity_history(entity)
            .await
            .expect("async operation should succeed");
        assert!(history.is_some());

        let history = history.expect("history should be available");
        assert_eq!(history.states.len(), 6);
    }
}