Introduce Spectral Sentinel — an online subspace anomaly detector#827
Open
da2ce7 wants to merge 1 commit into
Open
Introduce Spectral Sentinel — an online subspace anomaly detector#827da2ce7 wants to merge 1 commit into
da2ce7 wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #827 +/- ##
===========================================
+ Coverage 68.52% 72.37% +3.85%
===========================================
Files 161 175 +14
Lines 13111 15757 +2646
Branches 13111 15757 +2646
===========================================
+ Hits 8984 11404 +2420
- Misses 3853 4048 +195
- Partials 274 305 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
98b82af to
0d4bf03
Compare
0d4bf03 to
84defab
Compare
Introduce the new sub-package called "sentinel", that observes positionally structured observation streams.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A sentinel is not a judge. It stands watch, keeps its bearings, and reports what has changed.
That is the idea behind Spectral Sentinel. It does not decide whether a pattern is dangerous, important, or actionable. It measures structure in a stream, learns what has been ordinary so far, and returns statistical readouts when new observations depart from the learned geometry.
The "spectral" part is literal: each selected region is modelled with low-rank subspace trackers, and a second tier models the spectrum of those scores across related cells. The "sentinel" part is restraint: the crate observes, scores, and reports, but policy stays with the host.
Summary
This PR adds
torrust-sentinelto the workspace: a library crate for hierarchical online subspace anomaly detection over positionally structured observation streams.It is built on top of Mudlark. Mudlark provides the adaptive spatial substrate — regions that receive more observation volume earn finer resolution, quiet regions remain coarse. Spectral Sentinel uses that structure to decide where statistical trackers are worth maintaining. It selects significant V-Tree entries, closes them under G-tree ancestry so every selected cell has a complete ancestor chain back to the root, and scores incoming batches against learned subspace models at every selected scale.
The simplest way to think about it: Mudlark decides where the stream has shape; Sentinel measures whether the recent shape still looks like what that region has learned to expect.
The crate is deliberately policy-free. Reports carry raw measurements — four scoring axes (novelty, displacement, surprise, coherence), maturity, baselines, CUSUM drift accumulators, geometry, contour summaries, and health snapshots. They do not encode threat levels, recommended actions, or decisions. The host reads the measurements and decides what they mean.
The core invariant is feed-forward: every input value updates Mudlark with exactly one unit of observation volume. Anomaly scores never flow back into the spatial index. That keeps spatial adaptation driven by traffic structure, not by the detector's own conclusions. Temporal policy is host-controlled: Sentinel never applies decay automatically.
A second analysis tier — coordination trackers — runs at internal G-tree nodes whose subtrees both contribute competitive cells. It scores cross-cell patterns of the four axes, so a coordinated shift that no single cell would flag still surfaces in the report.
Contents
The addition is substantial, but almost entirely self-contained within
packages/sentinel.torrust-sentinelcrate (0.1.0) with a narrow public surface exposed through flat crate-root re-exportsSpectralSentinel<C, V, N>as the generic engine, withSentinel128andSentinel64aliases for the common domain widthsSentinelConfig,NoiseSchedule, andSvdStrategyfor host-controlled measurement parameters, with structuredConfigError/ConfigErrors/ConfigWarningvalidation rather than panicsGNodeIdserdesupport (off by default; pulls intorrust-mudlark/serde)#[test]functions across crate-level tests (src/tests/) and integration tests (tests/), plus the README compiled as a doc-test via#[cfg(doctest)] include_str!pedagogy.rs,pedagogy_advanced.rs) written to be read end-to-end as a walkthrough of the public surfaceChanges outside sentinel
Cargo.toml/Cargo.lock—packages/sentineladded as a workspace member; lock file regenerated for the new dependency closure (faer,rand_distr, plus dev-onlycriterionandtracing-subscriber)AGENTS.md— adds Sentinel'sS-cross-reference prefix to the package table and ADR examplesReviewing this
The best starting point is the public surface:
packages/sentinel/src/lib.rs→packages/sentinel/docs/api.md→packages/sentinel/README.mdFrom there, the main implementation path is
src/sentinel/mod.rsfor the orchestrator,src/analysis_set.rsfor competitive selection and ancestor closure,src/sentinel/tracker.rsfor per-cell scoring,src/sentinel/{cusum,staging,warming_thread}.rsfor drift and warm-up, andsrc/maths/for the SVD plumbing.For a focused review, I would look at:
d, narrow rank gaps) and the debug-mode oracle pathThe pedagogy tests are intended to be readable end-to-end; running
cargo test -p torrust-sentinel --test pedagogy -- --nocaptureproduces a narrated walk through the public surface.Notes
0.1.0. The public surface is intentional, but follows pre-1.0 SemVer rules until the crate reaches 1.0.unsafecode;#![forbid(unsafe_code)]at the crate root.serdeis opt-in.S-cross-reference prefix added in this PR.