@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,87 @@
1
+ # Roadmap
2
+
3
+ ## Phase 0 — Concept and framing
4
+
5
+ Deliverables:
6
+ - product vision
7
+ - architecture doc
8
+ - scoring doc
9
+ - naming and positioning
10
+ - object model draft
11
+
12
+ Success criteria:
13
+ - a clear product story for MSP weak-signal detection
14
+ - consensus on category: operational memory engine
15
+
16
+ ## Phase 1 — MVP event memory engine
17
+
18
+ Scope:
19
+ - ingest syslog and similar line-oriented logs
20
+ - normalize events
21
+ - fingerprint signatures
22
+ - generate recurrence / burst / self-heal candidates
23
+ - compute human-significance scores
24
+ - emit a daily weak-signal digest
25
+ - design the first external connector contract with LogicMonitor in mind
26
+
27
+ Success criteria:
28
+ - detects recurring self-resolving issues missed by classic alerting
29
+ - produces operator-readable explanations
30
+
31
+ ## Phase 2 — Incident memory and retrieval
32
+
33
+ Scope:
34
+ - promote important candidates into durable incident memory
35
+ - retrieve prior similar incidents
36
+ - support explainable operator queries
37
+ - add runbook hint / lesson promotion
38
+
39
+ Success criteria:
40
+ - answer "have we seen this before?" well
41
+ - surface likely prior causes and related lessons
42
+
43
+ ## Phase 3 — MSP multi-tenant operation
44
+
45
+ Scope:
46
+ - tenant-aware ingestion and scoring
47
+ - per-client baselines
48
+ - cross-tenant pattern memory where allowed
49
+ - technician daily briefs and review workflows
50
+
51
+ Success criteria:
52
+ - useful for a real MSP operating multiple customer environments
53
+ - reduces log blindness and catches weak signals earlier
54
+
55
+ ## Phase 4 — Advanced correlation and operator assistance
56
+
57
+ Scope:
58
+ - maintenance / deployment awareness
59
+ - precursor scoring improvements
60
+ - root-cause hints
61
+ - operator review loops and trust calibration
62
+ - optional agent-assist investigation mode
63
+
64
+ Success criteria:
65
+ - stronger contextual recommendations without becoming a black box
66
+
67
+ ## MVP non-goals
68
+
69
+ The early product should not try to be:
70
+ - a full SIEM
71
+ - a full observability suite
72
+ - a full metrics backend
73
+ - a compliance engine
74
+ - a generic chatbot over all logs
75
+
76
+ ## Proposed next concrete step
77
+
78
+ Build a small demo around one killer scenario:
79
+ - recurring self-healing VPN flaps
80
+ - repeated auth weirdness
81
+ - recurring service restart storm after a maintenance window
82
+
83
+ The first demo should output:
84
+ - weak-signal digest
85
+ - recurrence evidence
86
+ - significance score
87
+ - explanation of why a human should care
@@ -0,0 +1,424 @@
1
+ # Attention Scoring Model
2
+
3
+ _Status: scoring and routing contract for early brAInstem attention behavior_
4
+
5
+ ## Purpose
6
+
7
+ This document defines how brAInstem should think about operator attention.
8
+
9
+ The key governing idea is:
10
+
11
+ > brAInstem should not operate on a naive keep-vs-drop model.
12
+ > It should assign, evolve, and spend **attention**.
13
+
14
+ Scoring exists to support that attention model.
15
+ It is not the product by itself.
16
+
17
+ This document should be read together with:
18
+ - `design-governance.md`
19
+ - `architecture.md`
20
+ - `adapters.md`
21
+ - `v0.0.1.md`
22
+
23
+ ---
24
+
25
+ ## 1. Why attention matters
26
+
27
+ A lot of operationally meaningful patterns begin as tiny events that do not deserve immediate human review.
28
+
29
+ Examples:
30
+ - one brief VPN rekey failure
31
+ - one odd auth burst
32
+ - one short service restart
33
+ - one low-grade warning with no obvious impact
34
+
35
+ Any one of those may be meaningless.
36
+ But if the same pattern:
37
+ - repeats
38
+ - spreads
39
+ - increases in frequency
40
+ - resembles past meaningful issues
41
+ - clusters with other weak signals
42
+
43
+ then it may deserve significantly more attention later.
44
+
45
+ ### Therefore
46
+ brAInstem should avoid treating early weak signals as permanently disposable.
47
+ Instead, it should:
48
+ - assign an initial attention score/band
49
+ - retain enough evidence to re-evaluate later
50
+ - allow weak signals to earn more attention over time
51
+
52
+ ---
53
+
54
+ ## 2. Core design principle
55
+
56
+ ### Wrong model
57
+ - ingest
58
+ - drop or keep
59
+ - maybe summarize later
60
+
61
+ ### Better model
62
+ - ingest
63
+ - canonicalize
64
+ - assign initial attention
65
+ - update attention over time
66
+ - route according to attention band
67
+ - surface or promote only when attention is sufficiently earned
68
+
69
+ This is the central scoring philosophy of brAInstem.
70
+
71
+ ---
72
+
73
+ ## 3. Attention vs severity
74
+
75
+ brAInstem should not confuse:
76
+ - **severity**
77
+ with
78
+ - **attention**
79
+
80
+ ### Severity
81
+ Severity is often source-provided or source-derived.
82
+ It answers something like:
83
+ - how bad does the source think this event is right now?
84
+
85
+ ### Attention
86
+ Attention answers:
87
+ - how much operator attention does this deserve in context?
88
+
89
+ A low-severity event may deserve high attention if it is:
90
+ - recurring
91
+ - self-healing repeatedly
92
+ - spreading
93
+ - historically meaningful
94
+ - likely to become painful later
95
+
96
+ A high-severity event may still deserve high attention, but attention is the broader and more human-centered concept.
97
+
98
+ ---
99
+
100
+ ## 4. Attention layers
101
+
102
+ Attention should be thought about at three levels.
103
+
104
+ ### 4.1 Event attention
105
+ The immediate attention value for an individual canonical event.
106
+
107
+ Used for:
108
+ - immediate routing
109
+ - early retention choice
110
+ - whether to spend more compute now
111
+
112
+ ### 4.2 Signature attention
113
+ The accumulated attention value of a normalized recurring pattern/signature over time.
114
+
115
+ Used for:
116
+ - recurrence interpretation
117
+ - burst detection
118
+ - spread detection
119
+ - low-level weak-signal tracking
120
+
121
+ ### 4.3 Candidate attention
122
+ The operator-facing attention value of a higher-order weak-signal candidate.
123
+
124
+ Used for:
125
+ - interesting items
126
+ - digests
127
+ - review queues
128
+ - promotion decisions
129
+
130
+ ### Design rule
131
+ The system should not rely entirely on a single event-level score.
132
+ It must allow attention to accumulate upward from event → signature → candidate.
133
+
134
+ ---
135
+
136
+ ## 5. Attention bands
137
+
138
+ brAInstem should use explicit attention bands rather than one magical opaque score.
139
+
140
+ Suggested early model:
141
+
142
+ ### `ignore_fast`
143
+ For:
144
+ - clearly low-value noise
145
+ - highly repetitive, low-impact chatter
146
+ - events that should be counted cheaply but not examined deeply
147
+
148
+ Behavior:
149
+ - minimal retention or aggregated counters only
150
+ - no deep discovery work
151
+ - no operator visibility
152
+
153
+ ### `background`
154
+ For:
155
+ - low-value individual events that might matter later if repeated
156
+
157
+ Behavior:
158
+ - retain cheap evidence
159
+ - keep signature/frequency statistics
160
+ - eligible for later attention growth
161
+
162
+ ### `watch`
163
+ For:
164
+ - weak but plausible patterns
165
+ - novelty or recurrence that is not yet worth human interruption
166
+
167
+ Behavior:
168
+ - maintain more context
169
+ - evaluate recurrence windows
170
+ - candidate formation becomes possible
171
+
172
+ ### `investigate`
173
+ For:
174
+ - patterns that likely deserve immediate discovery analysis
175
+
176
+ Behavior:
177
+ - full weak-signal evaluation
178
+ - history comparison
179
+ - explanation generation
180
+
181
+ ### `promote`
182
+ For:
183
+ - operator-visible items
184
+ - digest-worthy patterns
185
+ - candidates that deserve durable memory or review
186
+
187
+ Behavior:
188
+ - surface to humans
189
+ - preserve evidence more fully
190
+ - eligible for incident-memory promotion
191
+
192
+ ### Design rule
193
+ Bands are part of the product behavior.
194
+ They are not just cosmetic labels on top of a number.
195
+
196
+ ---
197
+
198
+ ## 6. Attention score inputs
199
+
200
+ The exact formula can evolve, but early attention should be based on interpretable components.
201
+
202
+ ## Recommended components
203
+
204
+ ### 6.1 Recurrence
205
+ Measures:
206
+ - how often the same signature has happened
207
+ - whether the rate is increasing
208
+ - whether it appears on a recurring schedule/pattern
209
+
210
+ Questions:
211
+ - Has this happened before?
212
+ - Is it becoming more frequent?
213
+ - Is recurrence now strong enough to deserve more attention?
214
+
215
+ ### 6.2 Recovery / self-heal behavior
216
+ Measures:
217
+ - whether the issue self-resolved
218
+ - how quickly it recovered
219
+ - whether repeated self-heal cycles are masking real instability
220
+
221
+ Questions:
222
+ - Did the issue recover too quickly to alert?
223
+ - Is repeat recovery hiding a problem that humans should know about?
224
+
225
+ ### 6.3 Spread
226
+ Measures:
227
+ - number of affected hosts/assets
228
+ - number of affected services
229
+ - possible cross-tenant spread later where allowed
230
+
231
+ Questions:
232
+ - Is this isolated or systemic?
233
+ - Is this becoming a fleet pattern instead of a single-node oddity?
234
+
235
+ ### 6.4 Novelty
236
+ Measures:
237
+ - whether the signal is new in this environment
238
+ - whether the signature shape is unusual locally
239
+ - whether the combination of fields/signals is rare
240
+
241
+ Questions:
242
+ - Have we seen this exact shape here before?
243
+ - Does this deserve attention because it is unfamiliar?
244
+
245
+ ### 6.5 Temporal correlation
246
+ Measures:
247
+ - event clustering in time
248
+ - adjacency to change/maintenance windows
249
+ - adjacency to other weak signals in the same time slice
250
+
251
+ Questions:
252
+ - Did several low-grade signals happen together?
253
+ - Did this show up right after a change?
254
+
255
+ ### 6.6 Human impact likelihood
256
+ Measures likely operator/user pain:
257
+ - support ticket likelihood
258
+ - user-visible degradation likelihood
259
+ - business disruption likelihood
260
+ - trust erosion likelihood
261
+
262
+ Questions:
263
+ - Would a human care if they knew this was happening repeatedly?
264
+ - Could this become user-facing even if it self-heals now?
265
+
266
+ ### 6.7 Precursor likelihood
267
+ Measures whether this pattern tends to precede something worse.
268
+
269
+ Questions:
270
+ - Has this kind of signal historically preceded incidents?
271
+ - Did similar signals show up before earlier outages?
272
+
273
+ ### 6.8 Memory weight
274
+ Measures whether historically similar patterns have proven meaningful in this environment.
275
+
276
+ Questions:
277
+ - In this tenant/environment, does this kind of thing usually matter?
278
+ - Has an operator previously promoted/reviewed similar patterns as important?
279
+
280
+ ### 6.9 Source trust / source criticality (optional but useful)
281
+ Measures:
282
+ - whether the source is operationally important
283
+ - whether the source is known to be noisy/low-value
284
+ - whether the source generally produces trustworthy signals
285
+
286
+ Questions:
287
+ - Should events from this source get a lower or higher starting attention bias?
288
+
289
+ ---
290
+
291
+ ## 7. Suggested early formula shape
292
+
293
+ The exact math does not need to be fancy at first.
294
+
295
+ Early versions should prefer:
296
+ - deterministic components
297
+ - transparent weighting
298
+ - explicit thresholds
299
+ - easy explainability
300
+
301
+ ### Example conceptual model
302
+
303
+ `attention_score = recurrence + recovery + spread + novelty + temporal_correlation + human_impact + precursor + memory_weight (+ source_bias)`
304
+
305
+ Then map the resulting value into an attention band.
306
+
307
+ ### Design rule
308
+ The formula can evolve.
309
+ The explainability contract cannot be sacrificed.
310
+
311
+ ---
312
+
313
+ ## 8. Dynamic attention growth
314
+
315
+ This is one of the most important product behaviors.
316
+
317
+ A weak-signal event should be able to gain more attention later because of:
318
+ - repeated recurrence
319
+ - spread to more assets/services
320
+ - increased frequency
321
+ - co-occurrence with other weak signals
322
+ - matching prior incident memory
323
+ - operator feedback/history
324
+
325
+ ### Example
326
+ One VPN retry event:
327
+ - maybe `background`
328
+
329
+ Ten similar VPN retry events over several days, with rising frequency and historical similarity to a prior outage:
330
+ - now likely `investigate` or `promote`
331
+
332
+ ### Design rule
333
+ Low attention does not mean permanently irrelevant.
334
+ It means currently low-cost, low-interruption, re-evaluable.
335
+
336
+ ---
337
+
338
+ ## 9. Routing behavior
339
+
340
+ Scoring is only useful if it changes system behavior.
341
+
342
+ Attention should drive routing decisions like:
343
+ - ignore cheaply
344
+ - retain in background state
345
+ - watch for recurrence
346
+ - send to discovery apparatus now
347
+ - include in interesting items
348
+ - include in digest
349
+ - promote into durable memory later
350
+
351
+ ### Suggested mapping
352
+ - `ignore_fast` → aggregated counters / short retention
353
+ - `background` → signature tracking only
354
+ - `watch` → lightweight candidate eligibility
355
+ - `investigate` → full discovery path + explainability
356
+ - `promote` → human-facing output + durable memory eligibility
357
+
358
+ ---
359
+
360
+ ## 10. Explainability contract
361
+
362
+ Every surfaced candidate or interesting item should explain:
363
+ - why it was surfaced
364
+ - which attention inputs contributed most
365
+ - what evidence was used
366
+ - whether historical memory influenced the result
367
+ - what uncertainty remains
368
+
369
+ ### Example
370
+ - recurrence: high (9 similar events in 7 days)
371
+ - recovery: medium (self-healed within 45s each time)
372
+ - spread: low (single tenant)
373
+ - precursor: high (matched 2 prior incident memories)
374
+ - attention band: `investigate`
375
+
376
+ ### Design rule
377
+ If the system cannot explain why it spent attention on something, operators will not trust it.
378
+
379
+ ---
380
+
381
+ ## 11. What not to do early
382
+
383
+ ### Do not
384
+ - use opaque black-box ranking as the primary scoring mechanism
385
+ - pretend one score is infallible
386
+ - collapse all routing semantics into one number with no band meaning
387
+ - let source severity fully dominate attention
388
+ - overfit to fancy semantic similarity before recurrence/attention basics work
389
+
390
+ ### Why
391
+ Early trust depends more on:
392
+ - consistency
393
+ - inspectability
394
+ - obviousness of reasons
395
+ than on theoretical sophistication.
396
+
397
+ ---
398
+
399
+ ## 12. v0.0.1 implications
400
+
401
+ For `v0.0.1`, scoring does not need to be mathematically mature.
402
+
403
+ It **does** need to establish:
404
+ - attention as the central concept
405
+ - interpretable components
406
+ - at least one credible weak-signal path (recurrence is enough)
407
+ - operator-legible output tied to attention
408
+
409
+ That is enough for a truthful first release.
410
+
411
+ ---
412
+
413
+ ## 13. Final governing statement
414
+
415
+ Scoring exists so brAInstem can spend operator attention wisely.
416
+
417
+ The goal is not to compute a clever number.
418
+ The goal is to ensure that:
419
+ - tiny signals are not lost forever
420
+ - noisy junk does not dominate human review
421
+ - historically meaningful weak patterns can earn more attention
422
+ - surfaced output feels justified and useful
423
+
424
+ That is the standard the scoring model should serve.