Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
Merge PR #1319: depth 3.4 — behavioural baselines in CORE
beenuar8c841cfcf819
diff --cc DEPTH_PROGRESS.mdindex 395295860,4e653ff2d..edfd2376b--- a/DEPTH_PROGRESS.md+++ b/DEPTH_PROGRESS.md@@@ -77,21 -70,9 +77,24 @@@ is written. Next free at capture: migra| migration `113` | 8.1 — `113_entitlement_enforcement.sql` | claimed || ADR `0011` | 8.1 — truncating a hash-chained audit log | claimed |+| migration `104` | 5.4 stateful user/manager verification (verification requests, answers, tenant opt-in) | claimed |+| migration `105` | 5.6 plain-language playbook drafts (draft, preview, approval) | claimed |++Lane B claimed `102`/`103` and landed that claim on `main` first, so Lane C's+two moved to `104`/`105` and `102_playbook_verification.sql` was renamed with+it. Both lanes had claimed before writing, as the plan requires -- what the+rule cannot prevent is two lanes claiming the same free number before either+merges, so re-read `services/api/migrations/` **and** this table before+picking one.+| migration `110` | 6.1 — `110_ai_assets.sql` | claimed |+| migration `111` | 6.4 — `111_ai_agent_identities.sql` | claimed |+| ADR `0011` | 6.6 — AI containment arms off by default, and the rollback a kill-switch needs | claimed |+| — | 5.4 — `104_playbook_verification.sql` on `depth/5.4-5.6-lane-c`, and 7.1 — `104_phishing_campaigns.sql` on `depth/7.1-7.3-phishing` | **collision, unresolved here.** Both lanes wrote a `104` on a branch without a row in this table. Phase 9's `104` is the one with a claim, so these two need renumbering by their own lanes; recorded rather than renamed from outside, because renaming another lane's migration from here is how a branch comes back to a file that no longer exists |+| migration `110` | 7.1 — `110_phishing_campaigns.sql` | claimed |+| migration `111` | 7.2 — `111_phishing_message_analysis.sql` | claimed |+ | ~~migration `110`~~ | ~~3.4 — `110_entity_baselines.sql`~~ | **released**, ADR-0011 put the baselines in the Redis fusion already runs, so there is no table |+ | migration `111` | 3.7 — `111_detection_coverage.sql` | claimed |+ | ADR `0011` | 3.4 — behavioural baselines in CORE | **landed**, `docs/decisions/0011-behavioural-baselines-in-core.md`, accepted |Highest migration on `main` at claim time was `101_audit_immutable_nullify.sql`,so `095`--`101` were taken by sibling lanes between the capture above and this@@@ -115,23 -91,11 +118,28 @@@ sub-items that need no schema — the cinternationalisation and accessibility — claim no number. The same releaserule applies: an unused number is struck, not silently skipped.+**Phase 6 moved `105`/`106` to `110`/`111` on 2026-10-11**, because Phase 9's+claim for `104`--`109` reached this table on `main` first and a claim table+nobody defers to is not a coordination mechanism. The lesson is the one this+section already states and that three lanes still fell to: the table is+authoritative only for lanes that write to it **before** the file, and four+branches now carry a `104` or a `105` that was never claimed here. Reading+`main` is not enough; read `git ls-tree` over every `origin/*` branch as+well, which is what found this.+Phase 7 claimed `104` and `105` on the same day and **lost the race**: Phase 9+merged to `main` first, so Phase 7 renumbered to `110` and `111` rather than+leaving two files with one number each. Both lanes re-read the directory+before claiming and both read `101`, which is the shape a claim table cannot+prevent on its own — the table is the tiebreak, and whoever lands second+moves. Recorded because the next lane will hit it too: re-read+`DEPTH_PROGRESS.md` on `origin/main`, not only the migrations directory, and+expect to renumber if a sibling merged between the claim and the pull+request.+ Phase 3 re-read `services/api/migrations/` on 2026-10-11 before claiming:+ `101_audit_immutable_nullify.sql` was still the highest on `main` and `102`+ through `109` were already spoken for above, so Phase 3 takes `110` for the+ 3.4 baseline store and `111` for the 3.7 coverage store. ADR `0011` is the+ next free number in `docs/decisions/` after 2.7 landed `0010`.## Phase 0: Kickoff@@@ -458,83 -422,135 +466,212 @@@ Instead, every selector field, `group-bagainst the emitted-field namespace with **no ceiling**, which caught threeinvented fields on the first run of the gate.+### D11 -- A durable `wait` suspended the run and then carried on++Found while building 5.4 on 5.3's pause, and fixed here because 5.4 inherits+it. `_control_wait` writes a pause row and returns `StepStatus.PENDING` with+`paused: True`, and the run loop broke out only for `StepType.APPROVAL` --+so a `wait` long enough to become durable, or any `wait` with+`until: callback`, wrote its row and then ran every step after it. When the+callback or the sweeper later resumed from `step_index + 1`, those steps ran+a **second** time.++Nothing caught it because the two tests that exercise the durable path assert+on the pause row and on the resume, not on what the first half of the run did+afterwards -- and the shipped packs contain no `wait`, so no replay exercised+it either. The run loop now stops on any step that returns PENDING with a+`pause_id`, keyed on the result rather than on the step type, because the same+control step both sleeps in process (no pause) and suspends (a pause) and the+type cannot tell those apart.++Negative control: reverting that break fails+`test_a_durable_pause_stops_the_run` plus two others, recorded in the pull+request.++### D12 -- The manager comes from SCIM only, and the lookup is three sources deep++The plan says "from SCIM or IdP data". Implemented as the step's own+`manager` parameter, then the run context (where identity enrichment puts one+when the alert carried it), then `aisoc_scim_users.manager_ref` -- the+enterprise extension's `manager.value`, which the column was missing+entirely, so every sync delivered the attribute and every sync dropped it.++**A live per-request lookup against Entra or Okta is not implemented**, and+is named here rather than left to be inferred: it needs a vendor credential+in the agents service, which today holds none, and the escalation runs on a+sweeper with no tenant session. A tenant that provisions through SCIM has the+data; a tenant that does not will see `no_manager` and the run resumes with+that outcome rather than hanging.++`context_import.py` writes a `manager_id` edge into Neo4j, which would be a+fourth source. Not used: the agents service has an asyncpg pool and no Neo4j+driver, and adding one for an escalation is a dependency the item does not+justify.+### D11 -- The plan says `valid_to`; this schema says `valid_until`++Item 2.5 asks for versioned snapshots with `valid_from` / `valid_to`. The one+existing table in this database that bounds a fact in time is `identity_edges`+(migration 018), and it spells the closing column `valid_until`. Adopting the+plan's spelling would put two names for one concept in one schema, and the+next person to write a point-in-time query would have to know which table+they were in before they could write a `WHERE`. The existing spelling wins;+`posture_snapshots` uses `valid_from` / `valid_until`, and the deviation is+recorded here rather than made silently.++### D12 -- Eleven API tests are already failing on `main`, and nothing grades them++The full `services/api` suite run for 2.5 reported 4,774 passed and 11 failed.+All eleven are in `test_alert_list_priority_sort.py` and+`test_alert_tiles_cover_the_whole_result_set.py`, neither of which this branch+touches, and all eleven fail identically on a clean `git archive origin/main`+export with the same error: `list_alerts() missing 1 required positional+argument: 'http_request'`. The handler grew a `Request` parameter; the two+test files call it directly and were not updated.++What makes this worth a deviation rather than a footnote is why it is still+open on a branch-protected `main` with twenty-eight required checks. Both+files open with "Run against live Postgres: the defect is an `ORDER BY`, and a+fake session that answers any query cannot tell one ordering from another" --+and their fixture skips when no database answers. The only job that runs them+is `Python — Tests`, which sets `DATABASE_URL` to a host with no Postgres+behind it, so the fixture skips and the job is green. Neither file is named by+any workflow in `.github/workflows/`, so no live-Postgres job runs them+either. The suite that exists to prove the priority ordering has therefore+never graded it, and the signature break has been invisible since it landed.++Fixing them belongs to item 2.6, which wires the priority score and the queue+ordering these very tests cover; the fix lands there together with a workflow+that actually runs them against a database, because repairing the assertions+without that would restore a test nothing executes.+ ### D9 -- Five of the 45 "unreachable" rules were never unreachable++ `scripts/check_detection_fields.py` carries its own copy of the matcher's+ operator suffixes, under a comment saying it mirrors+ `detection_matcher.OPERATORS`. It did not. `neq` had been added to the+ matcher and not to the gate, so `approver_role_neq: "codeowner"` — which the+ engine reads correctly as `approver_role` with `!=` — was reported as a rule+ naming a field called `approver_role_neq`. Five rules were counted against+ the ratchet for a defect that had already been fixed.++ The same comparison in the other direction found a worse one: the gate+ listed `not_startswith_any` and `not_endswith`, which the **matcher** did not+ implement. Three shipped rules use `path_not_startswith_any`, so the matcher+ read the whole string as a field name and all three could never fire — while+ the gate, stripping a suffix nothing implemented, reported them reachable.+ Both operators are now implemented in the vendored matcher and the canonical+ one, the fixture synthesiser knows them, and+ `test_the_gate_and_the_matcher_agree_on_every_operator` compares the two+ lists in both directions.++ ### D10 -- 18 rules are retired rather than fixed, and why each one is++ The plan says of one family: "build them where cheap, otherwise quarantine+ with a reason". Applied to all three families, that leaves 18 rules that need+ work belonging to another item, recorded individually in+ `scripts/enrichment_decisions.py`:++ | kind | n | needs |+ |---|---|---|+ | `needs-connector-field` | 9 | a field the vendor has and no connector surfaces — depth plan 2.2 |+ | `needs-external-source` | 6 | a registry, a credential report or a factor record — 2.5 and beyond |+ | `needs-inventory` | 3 | an inventory this platform does not hold (DC machine accounts, privileged OAuth scopes) |++ `scripts/check_enrichment_decisions.py` is what stops this being a way to+ move the ratchet: it fails if a retired rule's fields are all resolvable.+ Proved by retiring a working rule and watching it fail.++ The line that mattered most was refusing a plausible substitute.+ `domain_age_days` wants a domain's registration age from a registry; the+ first-seen store could have answered "when this deployment first saw it" and+ the number would have looked right in a diff. It would also have fired the+ rule on most of the internet. Five such age-of-a-thing fields are named in a+ test that forbids the first-seen store from ever growing them.++ ### D11 -- Identity privilege reads a table a tenant must populate++ The `*_priv` booleans resolve from `identity_nodes.privilege_tier >= 2`, the+ column migration 018 created for the question. The table's only writer is+ `POST /api/v1/identity-graph/nodes`, so a tenant that has imported no+ directory gets **no key at all** and those 18 rules stay silent — they are+ reachable "when the tenant has identity data", the same standard this gate+ already applies to a vendor-payload field. That is weaker than "reachable on+ any deployment" and is stated rather than glossed. Depth plan 2.5's posture+ collectors are what will populate it automatically.++ Four booleans in the same family are deliberately **not** computed —+ `scope_priv`, `act_as_user_priv`, `gpo_link_priv` and `account_is_dc` — and+ are among the 18 above. Each has no subject field any source emits, and+ guessing a subject would produce a boolean that is confidently wrong rather+ than absent.++ ### D12 -- The "behavioural baseline" family named the wrong piece of work++ `check_detection_fields.py` classified an unreachable field into a family so+ the headline number would be actionable. Its behavioural pattern was+ `_baseline|_deviation|^active_|_is_first_`, and `^active_` is not a+ behavioural shape at all. It matched the only two rules left on the ratchet:++ | rule | field | what it actually needs |+ |---|---|---|+ | `det-endpoint-146` | `active_state` | a systemd unit state from a host agent |+ | `det-identity-015` | `active_p0_or_p1_incident` | the tenant's ITSM incident queue |++ So the gate reported "2 rules need depth plan 3.4" when the true answer was+ **zero**, and building 3.4 exactly as specified would not have moved the+ number by one. A gate pointing at the wrong piece of work is worse than one+ pointing at none, because the named thing gets built and the next reader+ concludes the fix failed.++ The pattern now matches the shape `baselines.py` actually produces+ (`^baseline_|_baseline$|_deviation$`), and a new `external system context`+ family carries the ITSM rule. `MAX_UNREACHABLE` stays at **2** — this is a+ reclassification and not a fix, and lowering a ceiling on the strength of+ relabelling is the move this file exists to refuse.++ Two consequences worth stating. The behavioural family is now genuinely+ empty, so 3.4 closes no unreachable rule and is not credited with any; it+ earns its place by making 3.5's rules possible, which is a different claim.+ And D9's lesson repeated one level up: a gate that keeps its own description+ of another component drifts from it, and here the drift was in the+ classifier rather than in the operator list.++ ### D13 -- D9, D10 and D11 were written, merged, and lost on `main`++ PR #1226 (depth 3.3) added three deviation sections. None of them is on+ `main`. The item log still cites "(gate operator drift, D9)" and "18 retired+ with a reason (D10)", so the tracker has spent two days pointing at+ explanations a reader could not find, and the same merge truncated 3.2's+ checklist paragraph mid-sentence and left a stale unchecked duplicate+ beneath it.++ Nothing was wrong with the branch; the loss happened in a conflict+ resolution that took `main`'s side of this file wholesale. That is the+ documented failure mode for a file several lanes write to at once, and the+ documented remedy — keep both sides' paragraphs, never take one side whole —+ is the one that would have prevented it.++ All three are restored here verbatim from the merge commit rather than+ rewritten from memory, which is why D11 keeps its original number and this+ phase's own new deviations take D12 and D13.++ ### D14 -- A rule of this lane's own was a bare anomaly, and its own gate caught it++ Depth plan 3.5 is explicit that an anomaly is *"a typed signal, not an alert+ on its own"*. `ta-saas-oauth-app-volume-spike` was written with+ `baseline_oauth_app_volume_z_gte` as its entire clause -- an alert on an+ anomaly, which is the one thing the item says not to build. It passed+ `generate_detections --check`, the truth table, the reachability gate and+ the generic fixture replay, because every one of those asks whether a rule+ is well-formed and can fire, and it was and it could.++ What caught it was the family's own gate asserting that each rule reads a+ threat condition *as well as* a baseline. The rule now also requires+ `event_type: oauth_token_event`.++ The reusable half is that the generic gates could not have caught it. A+ corpus-wide gate checks the properties every rule shares; a property that+ belongs to one family has to be asserted by that family, and writing that+ assertion is part of adding the family rather than a later tidy-up.## Phase 1: Verdict quality you can publishdiff --cc docs/detections/truth-table.mdindex 3177c9609,9ca3178d3..e129a1e45--- a/docs/detections/truth-table.md+++ b/docs/detections/truth-table.md@@@ -19,11 -19,11 +19,11 @@@ lever that reaches the engine is addin| metric | count ||--------|------:|- | rules on disk (total) | 6991 |- | **executable (loaded by the engine)** | **2511** |+ | rules on disk (total) | 7015 |+ | **executable (loaded by the engine)** | **2535** || non-executable (provenance/coverage only) | 4480 || — of which: enabled, but no compiled spec | 0 |-| windowed rules in `windowed_ruleset.json` | 72 |+| windowed rules in `windowed_ruleset.json` | 76 |The windowed figure is its own row rather than part of the headline becausea windowed rule is a different kind of thing: it counts events or distinctdiff --cc services/fusion/app/workers/consumer.pyindex 804a10004,5fcccb6ff..db3d496bb--- a/services/fusion/app/workers/consumer.py+++ b/services/fusion/app/workers/consumer.py@@@ -71,10 -57,9 +71,11 @@@ class FusionWorkerdetector: DetectionEngine | None = None,windowed_detector: WindowedDetectionEngine | None = None,first_seen: Any | None = None,+ baselines: Any | None = None,ueba_cache: UebaSignalCache | None = None,overlays: OverlayCache | None = None,+ sessions: SessionStore | None = None,+ ai_assets: AiAssetRecorder | None = None,) -> None:self._engine = engineself._sink = sink@@@ -82,11 -67,9 +83,13 @@@self._detector = detectorself._windowed = windowed_detectorself._first_seen = first_seen+ #: Depth plan 3.4 behavioural baselines, computed in CORE.+ self._baselines = baselinesself._ueba_cache = ueba_cache+ #: Depth 6.1 — the observed AI estate. Optional in the same sense the+ #: lake writer is: a deployment that passes nothing behaves exactly+ #: as before, and `main.py` passes one on every profile.+ self._ai_assets = ai_assets#: Per-tenant detection tuning (parity 5.4). Optional, so a#: deployment that passes nothing behaves exactly as before.self._overlays = overlays