Skip to content

feat: cold-start seeding — behavioral profiler persistence and seed/export#12

Merged
Crank-Git merged 1 commit into
mainfrom
feat/p2-cold-start-seed
Apr 11, 2026
Merged

feat: cold-start seeding — behavioral profiler persistence and seed/export#12
Crank-Git merged 1 commit into
mainfrom
feat/p2-cold-start-seed

Conversation

@Crank-Git
Copy link
Copy Markdown
Owner

Summary

  • anomaly: BehaviorProfileEntry DTO with Serialize()/Merge() on BehaviorProfiler; merge is additive (sums counts) so seeding from multiple sources is idempotent
  • storage: schema migration v4 adds behavior_profiles table; SaveBehaviorProfiles/LoadBehaviorProfiles methods
  • cmd: seed subcommand copies profiles from a backup DB into current sensor; export-profiles dumps profiles as JSON lines for inspection or transfer
  • main: persistLoop saves behavioral profiles every 30s and on clean shutdown; profiles loaded at startup, eliminating the 24h cold-start blind spot

Why

The behavioral profiler requires min_seen=50 observations before firing — on a redeployed sensor this blind spot can last up to 24h. Seeding from a backup DB instantly provides that history. Additive merge means seeding from multiple sources is safe and idempotent.

Test plan

  • TestBehaviorProfiler_SerializeEmpty — empty profiler serializes to zero entries
  • TestBehaviorProfiler_SerializeMergeRoundTrip — serialize → merge → re-serialize produces identical state
  • TestBehaviorProfiler_MergeAddsToExisting — merge sums counts additively
  • TestBehaviorProfiler_MergeEmptyNoOp — merging empty slice leaves state unchanged
  • TestStore_SaveLoadBehaviorProfiles_Empty — empty save/load round-trips correctly
  • TestStore_SaveLoadBehaviorProfiles_RoundTrip — profiles survive a full save/load cycle
  • TestStore_SaveBehaviorProfiles_Idempotent — double-save produces single set of rows
  • TestRunSeed_MissingSource — errors on missing source DB
  • TestRunSeed_SameSourceAndDest — errors when source == destination
  • TestRunSeed_RoundTrip — profiles seeded from src appear in dst
  • TestRunExportProfiles_MissingDB — errors on missing DB
  • TestRunExportProfiles_EmptyDB — succeeds with zero entries
  • All 11 packages green

🤖 Generated with Claude Code

…xport subcommands

Eliminates the 24h cold-start blind spot where a redeployed sensor needs
min_seen=50 observations before the behavioral profiler can fire alerts.

- anomaly: BehaviorProfileEntry DTO with Serialize()/Merge() on BehaviorProfiler;
  Merge is additive (sums counts) so seeding from multiple sources is idempotent
- anomaly: Evaluator wrappers SerializeBehaviorProfiles()/LoadBehaviorProfiles()
- storage: migrate.go v4 — behavior_profiles table (anchor_key, companion_key,
  count, total_seen, last_updated); SaveBehaviorProfiles/LoadBehaviorProfiles
- cmd: seed subcommand copies profiles from a backup DB into current sensor DB;
  export-profiles dumps profiles as JSON lines for inspection/transfer
- main: persistLoop saves behavioral profiles every 30s and on shutdown;
  profiles loaded at startup via initPipeline

Tests: 4 anomaly tests, 3 storage tests, 5 cmd tests (round-trip, idempotent,
error paths); all 11 packages green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Crank-Git Crank-Git merged commit 0f1a528 into main Apr 11, 2026
1 check passed
Crank-Git added a commit that referenced this pull request May 9, 2026
feat: cold-start seeding — behavioral profiler persistence and seed/export
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