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.

Merge remote-tracking branch 'origin/main' into depth/9.5-hunt-reports

Beenu Arora3c349de4dc2d
diff --cc DEPTH_PROGRESS.md
index 99a2b0b82,52b94ffa9..eb83bac9a
--- a/DEPTH_PROGRESS.md
+++ b/DEPTH_PROGRESS.md
@@@ -418,33 -462,33 +462,56 @@@ invented fields on the first run of th
## Phase 9: Analyst surfaces
- [ ] **9.1** MCP over streamable HTTP (parity 6.6)
- - [ ] **9.2** Semantic memory (parity 6.5)
+ - [x] **9.2** Semantic memory (parity 6.5). All three bullets of parity 6.5
+ closed, and the third one — "replay shows the accuracy delta" — produced a
+ result that changed the design rather than confirming it. `aisoc_memory_items`
+ (migration `105`) is the store of record for past cases, runbooks and
+ institutional memory; Qdrant is an index over it, reached through its REST
+ API so this service gains no dependency and its lockfile does not move.
+ Every item carries an author, a source, a scope, an expiry and a state, and
+ the author is the **authenticated principal**, never the body — provenance a
+ caller can set is not provenance. Two claims about one subject suspend
+ **both** sides and recall returns neither until an analyst settles it;
+ preferring the newer one silently restores a bad entry the next time the job
+ that wrote it runs, which is the case the feature exists for. Recall is
+ tenant-scoped in the Qdrant filter itself and `search()` **raises** rather
+ than offering an unscoped branch. With no embedding backend recall is 503
+ with the reason, never an empty list. `kind='case'` is written automatically
+ by the case-closure path, so the half of the "exists unwired" family that
+ reachability analysis cannot see — a table every surface reads and nothing
+ writes — does not apply. Measured by
+ `scripts/score_memory_recall.py` (12 hand-authored low-overlap probes,
+ mean lexical overlap 0.166, `is_synthetic: true`); its self-test is wired
+ into `ci.yml :: python-lint`. 17 new tests, api suite +17. Live end to end
+ against real Postgres 16, real Qdrant v1.7.0 and a real embedding backend,
+ recorded in the PR. **The measurement is published as it came out, and it is
+ unflattering:** see D11.
- [ ] **9.3** Case depth (parity 5.6 remainder)
- [ ] **9.4** War rooms
-- [ ] **9.5** Hunt to report
+- [x] **9.5** Hunt to report. A natural-language hunt or a retro-hunt
+ sighting becomes a stored report answering what, how, where and when, with
+ ledger citations, readable as JSON or HTML and exportable as PDF through
+ the **same WeasyPrint path and the same unavailability error** the weekly
+ digest uses — one renderer, because two drift and the PDF stops matching
+ the page somebody approved. Three refusals carry the item: a hunt that has
+ never run is refused (a report about an unexecuted query is a statement
+ about the query, not the estate), an **uncited report is refused at
+ persist time** (an uncited report is an assertion), and a section that
+ cannot be derived stays **empty** and renders as "not recorded" rather
+ than as a confident sentence about nothing. The retro-hunt builder
+ computes the gap between when intelligence arrived and when the estate
+ first saw the indicator, which is the number a retro-hunt exists to
+ produce and which a reader would otherwise get by subtracting two
+ timestamps. Graded by `.github/workflows/hunt-report-live.yml` against a
+ real Postgres with three negative controls. 14 new tests. The live suite
+ earned its keep three times on its first run: `alerts` has no singular
+ `affected_host` (it is `affected_hosts`, a JSONB array, and `entities` is
+ what fusion actually writes), `investigation_events` has **no `case_id` at
+ all** so the ledger is only reachable by joining `investigation_runs`, and
+ that table's `case_id` is TEXT rather than UUID so binding a UUID raises
+ in asyncpg instead of coercing. Each would have shipped under a SQLite
+ stand-in, and the middle one would have cited an empty set on every
+ report.
- [ ] **9.6** Native responder
## Phase 10: Close the books
@@@ -456,7 -500,7 +523,8 @@@
| Date | Item | What happened |
|---|---|---|
+| 2026-10-11 | 9.5 | Reproduced: `grep -n hunt` across `app/services/report_builder.py` and `app/api/v1/endpoints/reports.py` returned nothing — the report surface and the hunt surface did not know about each other, so a hunt produced rows and a retro-hunt produced a sightings row and neither produced anything a person could read or forward. Built the four-section report, the citation rule, the two builders and the JSON/HTML/PDF export. Three negative controls in the live workflow: allowing an uncited report, filling an empty section with a sentence, and reporting a hunt that never ran each have to turn the suite red. The live run found three schema facts a stand-in would have hidden, recorded in the item above. |
+ | 2026-10-11 | 9.2 | Reproduced: `knowledge_base.py` searched with `to_tsvector`/`plainto_tsquery` and nothing else; `grep -rn qdrant services/api/app/` found only the migration runner and the tenant-deletion sweep, no recall path; and no memory row anywhere carried an author, a source, a scope, an expiry or a state. Built the store of record, the Qdrant index over it, the conflict state machine, the case-closure writer and the recall scorer. Two negative controls recorded in the PR: restoring last-write-wins on a contradiction fails three tests, and restoring vector truncation fails one. The measurement is negative and is published as such — see D11, which also records that it caught the truncation defect. |
| 2026-10-07 | 0.1 | This file created at base commit `1b8bc2d4`. |
| 2026-10-07 | 0.2 | Every figure re-derived. Two matched exactly (detections, unreachable families); executor arms measured 74 against a captured 73; the cloud/identity/SaaS/code figure measured 395 against a captured 461 on a grouping the plan does not pin, recorded above. Two measurement caveats found: executable and quarantined overlap by 1,724 rules, and the "69% Windows" figure does not reproduce from the index. |
| 2026-10-09 | 4.3 | Reproduced: `check_retention_window.py` on the unmodified tree reported six problems — the lake deleting at 90 days against a 3,650-day cap, no `MODIFY TTL` migration, tiering deleting at 90, and the purge worker calling neither `alerts_under_legal_hold` nor `may_purge` and reporting nothing withheld. Fixed all but the cold-query bullet. Four negative controls recorded in the PR, including the positive control: a purge stuck closed withholds every tenant and fails four of the eight hold tests, which is the only thing that separates a working control from commendable caution. One pre-existing test (`test_storage_tiering.py`) pinned the 90-day tiering DELETE and now reads the shared constant; `test_retention_worker.py`'s session double could not answer the new holds query, so the worker failed closed and five of its cases failed — the double was taught the query rather than the fail-closed behaviour relaxed. |