@simbimbo/brainstem 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +99 -3
  3. package/brainstem/__init__.py +3 -0
  4. package/brainstem/api.py +131 -0
  5. package/brainstem/connectors/__init__.py +1 -0
  6. package/brainstem/connectors/logicmonitor.py +26 -0
  7. package/brainstem/connectors/types.py +16 -0
  8. package/brainstem/demo.py +64 -0
  9. package/brainstem/fingerprint.py +44 -0
  10. package/brainstem/ingest.py +101 -0
  11. package/brainstem/instrumentation.py +38 -0
  12. package/brainstem/interesting.py +62 -0
  13. package/brainstem/models.py +78 -0
  14. package/brainstem/recurrence.py +112 -0
  15. package/brainstem/scoring.py +38 -0
  16. package/brainstem/storage.py +182 -0
  17. package/docs/adapters.md +435 -0
  18. package/docs/api.md +380 -0
  19. package/docs/architecture.md +333 -0
  20. package/docs/connectors.md +66 -0
  21. package/docs/data-model.md +290 -0
  22. package/docs/design-governance.md +595 -0
  23. package/docs/mvp-flow.md +109 -0
  24. package/docs/roadmap.md +87 -0
  25. package/docs/scoring.md +424 -0
  26. package/docs/v0.0.1.md +277 -0
  27. package/docs/vision.md +85 -0
  28. package/package.json +6 -14
  29. package/pyproject.toml +18 -0
  30. package/tests/fixtures/sample_syslog.log +6 -0
  31. package/tests/test_api.py +72 -0
  32. package/tests/test_canonicalization.py +28 -0
  33. package/tests/test_demo.py +25 -0
  34. package/tests/test_fingerprint.py +22 -0
  35. package/tests/test_ingest.py +15 -0
  36. package/tests/test_instrumentation.py +16 -0
  37. package/tests/test_interesting.py +36 -0
  38. package/tests/test_logicmonitor.py +22 -0
  39. package/tests/test_recurrence.py +16 -0
  40. package/tests/test_scoring.py +21 -0
  41. package/tests/test_storage.py +26 -0
@@ -0,0 +1,21 @@
1
+ from brainstem.scoring import score_candidate
2
+
3
+
4
+ def test_score_candidate_returns_band() -> None:
5
+ candidate = score_candidate(
6
+ recurrence=0.8,
7
+ recovery=0.7,
8
+ spread=0.4,
9
+ novelty=0.5,
10
+ impact=0.8,
11
+ precursor=0.7,
12
+ memory_weight=0.6,
13
+ )
14
+ assert candidate.score_total > 0
15
+ assert candidate.decision_band in {
16
+ "ignore",
17
+ "watch",
18
+ "review",
19
+ "urgent_human_review",
20
+ "promote_to_incident_memory",
21
+ }
@@ -0,0 +1,26 @@
1
+ from pathlib import Path
2
+
3
+ from brainstem.ingest import ingest_syslog_lines, signatures_for_events
4
+ from brainstem.recurrence import build_recurrence_candidates
5
+ from brainstem.storage import init_db, list_candidates, store_candidates, store_events, store_signatures
6
+
7
+
8
+ def test_storage_round_trip(tmp_path: Path) -> None:
9
+ db_path = tmp_path / 'brainstem.sqlite3'
10
+ init_db(str(db_path))
11
+ lines = [
12
+ 'Mar 22 00:00:01 fw-01 charon: VPN tunnel dropped and recovered',
13
+ 'Mar 22 00:00:03 fw-01 charon: VPN tunnel dropped and recovered',
14
+ 'Mar 22 00:00:05 fw-01 charon: VPN tunnel dropped and recovered',
15
+ ]
16
+ events = ingest_syslog_lines(lines, tenant_id='client-a', source_path='/var/log/syslog')
17
+ signatures = signatures_for_events(events)
18
+ candidates = build_recurrence_candidates(events, signatures, threshold=2)
19
+
20
+ assert store_events(events, str(db_path)) == 3
21
+ assert store_signatures(signatures, str(db_path)) == 3
22
+ assert store_candidates(candidates, str(db_path)) >= 1
23
+
24
+ rows = list_candidates(str(db_path), limit=10)
25
+ assert rows
26
+ assert rows[0]['title']