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
fix(ci): the second grading's residue, in four pieces
beenuar4ffa8e99e92d
diff --git a/scripts/check_tenant_query_predicates.py b/scripts/check_tenant_query_predicates.pyindex 468bb9a6d..450f0d16d 100644--- a/scripts/check_tenant_query_predicates.py+++ b/scripts/check_tenant_query_predicates.py@@ -397,22 +397,6 @@ RATCHET: dict[str, str] = {"id, binds set_rls_context to the row's own tenant before acting, and refuses without the ""token — the tenant comes from the row the bot named, never from the caller"),- "services/api/app/services/lake_query_runner.py::claim_statement::lake_query_jobs": (- "the claim is one conditional UPDATE by job id where status = 'queued' — a worker claiming "- "work enqueued by tenant-scoped routes, the same shape as approval_expiry.run_once. The "- "routes that create and read jobs bind the tenant; the runner executes whichever replica won"- ),- "services/api/app/services/lake_query_runner.py::_record_progress::lake_query_jobs": (- "progress lands on the claimed job by id; the claim above is what decided whose job it is"- ),- "services/api/app/services/lake_query_runner.py::_finish::lake_query_jobs": (- "terminal state lands on the claimed job by id, guarded so a finished job is never revived; "- "same claim-then-act shape as _record_progress"- ),- "services/api/app/services/lake_query_runner.py::list_stuck_jobs::lake_query_jobs": (- "the stuck sweep asks 'which running jobs lost their runner', tenant-unbound by the same "- "discover-a-working-set reasoning as due_deliveries; it only moves jobs to a terminal state"- ),"services/api/app/services/war_room.py::sync_war_room::aisoc_case_war_rooms": ("the sweep is a pure function of the case row: it reads the room by id handed to it by the ""worker's cross-tenant discovery below, and every post it writes is keyed to that room; the "@@ -483,7 +467,15 @@ RATCHET: dict[str, str] = {# ceiling with a spare slot in it and the list held 41. The ceiling now# equals the list, so the next unscoped statement has to be argued for# rather than absorbed — which is what this number is for.-MAX_RATCHET = 44+# 44 -> 50 (the 2026-10-12 merge train): seven entries for depth 5.4's signed+# answer link and verification sweeper, 9.4's war-room sweep, decision route+# and worker discovery — each the credential-lookup or discover-a-working-set+# shape already recorded above, verified in code before being recorded. Four+# more were written for the lake job runner and then deleted again in the same+# change: fixing lake_query_jobs' WITH CHECK (the unbound-session arm every+# sibling policy carries) moved those statements onto the RLS-context credit,+# which this gate's stale-entry check correctly refused to double-count.+MAX_RATCHET = 50# ---------------------------------------------------------------------------diff --git a/scripts/validate_detections.py b/scripts/validate_detections.pyindex 33ea4c0cf..a81817b26 100755--- a/scripts/validate_detections.py+++ b/scripts/validate_detections.py@@ -8,7 +8,7 @@ Validates all YAML detection rules under ``detections/`` for:- Required fields (``id``, ``name``, ``severity``, ``detection``)- Severity is one of: ``low | medium | high | critical``- Category is one of:- ``network | endpoint | cloud | identity | application | data-exfil``+ ``network | endpoint | cloud | identity | application | data-exfil | threat-anomaly``- No duplicate ``id`` values across all tiers- ``id`` prefix matches the rule's tier (``det-`` for native,``<source>-...`` for imported tiers)@@ -21,7 +21,7 @@ Validates all YAML detection rules under ``detections/`` for:Tiering-------* **native** — ``detections/{network,endpoint,cloud,identity,application,- data-exfil}/*.yaml``. Strict: fixtures + provenance optional.+ data-exfil,threat-anomaly}/*.yaml``. Strict: fixtures + provenance optional.* **imported** — ``detections/{sigma,car,splunk,chronicle}-imports/<category>/*.yaml`` (and ``.../_quarantine/<category>/*.yaml`` for rules thatparsed but cannot run as-is). Provenance required, fixtures optional.@@ -85,6 +85,11 @@ VALID_CATEGORIES = {"identity","application","data-exfil",+ # Depth 3.4: rules whose clauses read the behavioural-baseline fields the+ # fusion enrichment computes (rarity, peer deviation, volume). Built+ # through the same generator as every other native rule, with the same+ # det- ids and paired fixtures, so the native contract applies unchanged.+ "threat-anomaly",}REQUIRED_FIELDS = ["id", "name", "severity", "detection"]diff --git a/services/api/app/services/lake_query_runner.py b/services/api/app/services/lake_query_runner.pyindex 442059709..b8f21b725 100644--- a/services/api/app/services/lake_query_runner.py+++ b/services/api/app/services/lake_query_runner.py@@ -28,7 +28,6 @@ again.from __future__ import annotationsimport asyncio-import contextlibimport loggingimport uuidfrom datetime import UTC, datetime@@ -231,8 +230,10 @@ async def run_job(returnfinally:poller.cancel()- with contextlib.suppress(asyncio.CancelledError):- _ = await poller # the await is the point: let the cancellation settle+ # Bound rather than discarded, the shape the fusion ticker test pins:+ # `return_exceptions=True` hands back how the poller ended instead of+ # raising it, and the cancellation is settled either way.+ _ = await asyncio.gather(poller, return_exceptions=True)await _finish(session_factory,diff --git a/tests/isolation/test_verification_pause_live.py b/tests/isolation/test_verification_pause_live.pyindex 1eea6d784..102de92e9 100644--- a/tests/isolation/test_verification_pause_live.py+++ b/tests/isolation/test_verification_pause_live.py@@ -130,7 +130,9 @@ async def wired(pool: Any, monkeypatch: pytest.MonkeyPatch) -> AsyncIterator[tuptenant_id = str(uuid.uuid4())async with pool.acquire() as conn:- await conn.execute("INSERT INTO tenants (id, name) VALUES ($1::uuid, 'live')", tenant_id)+ # `slug` is NOT NULL since 001_init; derived from the id so two+ # module-scoped runs cannot collide on the UNIQUE constraint.+ await conn.execute("INSERT INTO tenants (id, name, slug) VALUES ($1::uuid, 'live', 'live-' || left($1, 8))", tenant_id)yield playbook_pause, tenant_id@@ -267,7 +269,11 @@ async def test_the_policy_table_is_tenant_scoped_and_default_deny(pool: object)tenant_a, tenant_b = str(uuid.uuid4()), str(uuid.uuid4())async with pool.acquire() as conn: # type: ignore[attr-defined]- await conn.execute("INSERT INTO tenants (id, name) VALUES ($1::uuid, 'a'), ($2::uuid, 'b')", tenant_a, tenant_b)+ await conn.execute(+ "INSERT INTO tenants (id, name, slug) VALUES ($1::uuid, 'a', 'a-' || left($1, 8)), ($2::uuid, 'b', 'b-' || left($2, 8))",+ tenant_a,+ tenant_b,+ )await conn.execute("INSERT INTO aisoc_verification_policies (tenant_id, alert_class) VALUES ($1::uuid, 'impossible_travel')",tenant_a,