Skip to content

feat(koinon): temporal baseline engine with Welford's algorithm#14

Merged
forkwright merged 2 commits into
mainfrom
p0-03/temporal-baseline
Mar 14, 2026
Merged

feat(koinon): temporal baseline engine with Welford's algorithm#14
forkwright merged 2 commits into
mainfrom
p0-03/temporal-baseline

Conversation

@forkwright
Copy link
Copy Markdown
Owner

Summary

  • Welford's online algorithm for running mean/variance/stddev in O(1) memory
  • TimeWindowedBaseline with ring buffer eviction (count + age)
  • TemporalBucketedBaseline with 168 buckets (7 days × 24 hours)
  • AnomalyScore classification (Normal/Elevated/Anomalous/InsufficientData)
  • Baseline::merge for parallel computation via parallel Welford merge
  • proptest property-based testing: convergence, merge correctness, z-score identity

Test plan

  • cargo test --workspace — 71/71 unit + proptest tests pass
  • cargo clippy --workspace --all-targets -- -D warnings — zero warnings
  • cargo fmt --all -- --check — format clean
  • Verify convergence: 1000 proptest cases × 10K observations from N(μ, σ) → mean within 0.1σ, stddev within 0.1σ

Observations

  • TemporalBucketedBaseline::bucket() returns Option<&Baseline> rather than &Baseline as specified, because panic = "deny" at the workspace level makes a panicking out-of-bounds access impossible. The Option return correctly signals invalid day/hour indices. File: crates/koinon/src/baseline.rs.
  • AnomalyScore is #[non_exhaustive] per RUST.md policy; consumers outside the crate must add a wildcard arm when matching.

🤖 Generated with Claude Code

- Welford's online algorithm for running mean/variance/stddev in O(1) memory
- TimeWindowedBaseline with ring buffer eviction (count + age)
- TemporalBucketedBaseline with 168 buckets (7 days x 24 hours)
- AnomalyScore classification (Normal/Elevated/Anomalous/InsufficientData)
- Baseline merge for parallel computation
- proptest property-based testing: convergence, merge correctness, z-score identity
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Large PR detected — 4 files, 890 lines changed.

Consider splitting into smaller PRs for easier review. Not a blocker, just a signal.

/tmp was exhausted by leftover temp dirs, causing tamper_log tests
to fail with ENOSPC when creating temporary files. No code changes
required; re-triggering CI after disk space was freed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@forkwright forkwright merged commit 5dadc33 into main Mar 14, 2026
13 checks passed
@forkwright forkwright deleted the p0-03/temporal-baseline branch March 14, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant