Skip to content

armgit / AiSOC

Public Imported from GitHub
0

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.

test(api): lock the investigate-launch forward-walk gate

Alexandru Mateescu7211e46d06e2
diff --git a/services/api/tests/test_investigate_launch_status_gate.py b/services/api/tests/test_investigate_launch_status_gate.py
new file mode 100644
index 000000000..5594c7c78
--- /dev/null
+++ b/services/api/tests/test_investigate_launch_status_gate.py
@@ -0,0 +1,45 @@
+"""Launching an agent investigation must advance the case's status.
+
+The defect
+----------
+The v17 canonical ladder declares `new -> triaged` only, and the launch
+path gated its status bump with `_status_transition_ok(current,
+"investigating")` — a strict one-edge check. Cases created at `new`
+(auto-triage default) therefore never advanced: the gate returned False,
+no UPDATE ran, and the failure was silent because nothing raised.
+
+The launch gate is deliberately *not* the PATCH gate. An investigation is
+a deliberate analyst action on the case, so it may walk forward along the
+ladder; PATCH stays one-edge-only, and terminal cases stay terminal —
+reopening is the explicit POST /reopen path.
+"""
+
+from __future__ import annotations
+
+import pytest
+from app.api.v1.endpoints.cases import (
+ _forward_to_investigating_ok,
+ _status_transition_ok,
+)
+
+
[email protected]("status", ["new", "triaged"])
+def test_launch_advances_open_pre_investigating_cases(status: str) -> None:
+ # The exact regression: `new` used to be rejected here.
+ assert _forward_to_investigating_ok(status) is True
+
+
[email protected]("status", ["investigating", "contained"])
+def test_launch_never_moves_backwards_or_repeats(status: str) -> None:
+ assert _forward_to_investigating_ok(status) is False
+
+
[email protected]("status", ["resolved", "closed"])
+def test_launch_never_touches_terminal_cases(status: str) -> None:
+ assert _forward_to_investigating_ok(status) is False
+
+
+def test_patch_stays_one_edge_only() -> None:
+ # The strict ladder gate is unchanged: new cannot PATCH to investigating.
+ assert _status_transition_ok("new", "investigating") is False
+ assert _status_transition_ok("triaged", "investigating") is True