Skip to main content

sightloom_analysis/
pattern.rs

1//! Pattern records produced by analysis backends.
2
3#[cfg(feature = "alloc")]
4extern crate alloc;
5
6#[cfg(feature = "alloc")]
7use alloc::vec::Vec;
8
9use sightloom_core::{EventId, PatternId, SubjectId};
10
11/// Pattern kind tags.
12#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13pub enum PatternKind {
14    /// Time-of-day habit.
15    TimeOfDay,
16    /// Day-of-week habit.
17    DayOfWeek,
18    /// Visit periodicity.
19    VisitPeriodicity,
20    /// Dwell distribution.
21    DwellDistribution,
22    /// Route sequence.
23    RouteSequence,
24    /// Co-occurrence habit.
25    CoOccurrence,
26    /// Event-before-event chain.
27    EventBeforeEvent,
28    /// Expected absence window.
29    ExpectedAbsence,
30    /// Group formation.
31    GroupFormation,
32    /// Application-defined.
33    Custom,
34}
35
36/// Stored pattern record.
37#[derive(Clone, Debug, PartialEq)]
38pub struct PatternRecord {
39    /// Pattern id.
40    pub pattern_id: PatternId,
41    /// Kind.
42    pub kind: PatternKind,
43    /// Optional subject scope.
44    pub subject_id: Option<SubjectId>,
45    /// Confidence in `0.0..=1.0` (not clamped).
46    pub confidence: f32,
47    /// Supporting event ids.
48    pub evidence_events: Vec<EventId>,
49    /// Free-form host tag.
50    pub tag: u32,
51}