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.

docs(4.4): scale-hint guide, three claim rows, and the 4.4 progress entry

Beenu Arora566c6a459ad4
diff --git a/DEPTH_PROGRESS.md b/DEPTH_PROGRESS.md
index 27683a06f..e1640b09c 100644
--- a/DEPTH_PROGRESS.md
+++ b/DEPTH_PROGRESS.md
@@ -519,7 +519,77 @@ invented fields on the first run of the gate.
rather than only its own subjects, because both purges are bulk
statements. Narrowing that needs a per-subject predicate on each store
and is follow-up.
-- [ ] **4.4** Throughput (parity 6.9) and a cloud-hardware run
+- [~] **4.4** Throughput (parity 6.9) and a cloud-hardware run. **Every
+ parity 6.9 bullet is closed; the cloud-hardware run is not, and cannot
+ be from here.**
+
+ **Rules indexed — on required fields, not log source.** The engine ran
+ every rule against every event, and its own docstring already recorded
+ why a log-source index could not be the fix: connector product names
+ do not line up with spec products, a product-based pre-filter was
+ tried once and reverted for silently dropping real matches, and a
+ mapping table leaves every new connector one missing entry away from a
+ detection that stops firing. `match_when` is an AND at the top level,
+ so a rule that requires a field the event does not carry cannot match
+ it — strictly more selective than log source and provably lossless.
+ "Required" is decided by **running the real matcher against an empty
+ event**, which is how writing the test found that `neq` requires its
+ field in this matcher despite reading like a negation; a hand-written
+ operator list would have been wrong in the direction that drops
+ detections. Measured: 2,511 rules, 1,751 indexed (69.74%), 797
+ candidates for a routine cloud event (68.3% fewer), 2.760 → 1.066
+ ms/event over 2,000 iterations.
+
+ **Ordering per entity.** Ingest keyed every message `tenant:event_id`,
+ unique per event, so nothing about one entity was ordered relative to
+ anything — while fusion correlates on `{tenant}:{entity}:{tactic}`.
+ Now `tenant:entity` in the same precedence the correlation key uses,
+ held equal by a test, because a partition key disagreeing with the
+ correlation key routes an entity's events to a partition and then
+ correlates them under a different name.
+
+ **Concurrent triage.** Auto-triage awaited one LLM call at a time.
+ Concurrency is per entity, not global: alerts about one host are the
+ ones most likely to be one incident and triage reads memory earlier
+ triages of that entity wrote, so racing them turns a deterministic
+ verdict into a coin toss. Offsets commit only after the in-flight
+ window drains, with a time bound as well as a count.
+
+ **Lag hints.** `GET /scale-hint` publishes the backlog and a suggested
+ replica count. AiSOC does not act on it — ADR-0011 records why — and
+ the per-replica budget is derived from the published realistic-mix run
+ rather than chosen, with a test that reads the committed result file
+ and fails if the two drift.
+
+ **Realistic mix.** `--alert-every N` sends one alerting event every
+ Nth and routine telemetry in between. Published run: 6,000 events
+ saturating at 1-in-100, **0 of 5,940 routine events raised an alert**,
+ 0 missing, 0 duplicates, p95 event-to-alert 1,195 ms, ingest 122.6
+ events/s.
+
+ **The first attempt at that run measured a routine alert rate of
+ 1.00** — every "benign" event became an alert. Not the corpus firing:
+ the load path sends an undeclared connector type, the ingest
+ normalizer's generic fallback files it as class 2001 Security Finding,
+ and the promoter promotes OCSF category 2 unconditionally. **Eight of
+ the twelve declared profiles are category 2**, so on those connectors
+ no event can be routine whatever it contains. Also fixed: "missing
+ events" was counted against every accepted event, so a perfect mix run
+ reported losing 99% of its traffic.
+
+ ADR `0011`. 51 new tests (12 index, 8 partition key, 18 entity lanes,
+ 13 scale hint). Three claim rows; matrix 309 rows, 306 GATED.
+
+ **`[~]` and not `[x]`, for one reason: there is no cloud-hardware
+ run.** No cloud instance has been provisioned for this project, so
+ every figure on the performance page comes from a laptop or from a
+ kind cluster on it. The plan's 5,000 events/s at p95 under 2 s target
+ is therefore an aim rather than a result, and the page says so, with
+ the exact command that would close it once an instance exists. A
+ second, smaller caveat recorded there too: the published mix run went
+ through the **published images**, not a build of this branch, so it is
+ not a measurement of the rule index — that is measured separately and
+ in process.
- [ ] **4.5** Deployment completeness (parity 6.8)
## Phase 5: Response that finishes
@@ -577,6 +647,7 @@ invented fields on the first run of the gate.
| 2026-10-07 | 0.3 | `make up` and `make smoke` (10/10) pass. Injection suite and load-harness baselines committed. `make up-full` deferred (D2) and hosted model rows blocked (D3). Fixing D1 was a precondition for the load-harness baseline. |
| 2026-10-09 | 3.3 | Identity privilege (18 rules) and a per-tenant first-seen store (2) built; 5 rules were never unreachable (gate operator drift, D9); 18 retired with a reason (D10). `MAX_UNREACHABLE` 45 → 2, the two remaining both needing the 3.4 baseline. Two matcher operators three shipped rules already used were implemented. |
| 2026-10-09 | 3.2 | Ordered and unordered sequences in the windowed engine; all four translatable Sigma correlation types compile, seven refusal reasons recorded. No upstream correlation rule exists in this tree to import (D8), so the corpus is first-party and labelled as such. |
+| 2026-10-11 | 4.4 | Every parity 6.9 bullet closed; the cloud-hardware run is not possible from here and is recorded as unmeasured rather than implied. Rule index on required fields (lossless, proven by replaying every fixture both ways; 68.3% fewer candidates, 2.6x on evaluation), entity partition key held equal to the correlation key, per-entity concurrent triage, lag-based scale hint derived from the published run. The realistic mix found that eight of twelve connector profiles are category 2 and are promoted unconditionally, so on those connectors no event can be routine — the first run measured a routine alert rate of 1.00. ADR-0011; matrix 309 rows, 306 GATED. |
| 2026-10-11 | 4.3 | Third bullet closed. Reproduced: `check_retention_window.py` with the new rules reported no cold-query estimator, no job surface and no job table on the pre-fix tree. Built `lake_cold_query.py` (EXPLAIN ESTIMATE + system.parts + system.processes, no invented throughput or price), `lake_query_runner.py` and migration `111`. Negative control: removing the `status = 'queued'` predicate makes both interleaved transactions claim one job and the live suite goes red. The first version of that test — five gathered claims — passed under the broken implementation and was replaced. 26 pure + 12 live tests; matrix 306 rows, 303 GATED. |
| 2026-10-11 | 4.2 | Reproduced: `check_standard_inputs.py` against the pre-fix tree reported no OTLP package, no Kafka input and no TAXII server — the only TAXII-shaped route being a demo-gated sample list. Built all three, after moving the consumer-health classifier out of `graph_ws` into `streamhealth` so the new Kafka consumer shares the table rather than copying it. Negative controls recorded in the PR: a timestamp-only TAXII cursor loses an indicator in the single-row pagination walk (measured — 3 of 4), and nineteen gate injections each go red. Writing it found four defects, including an OTLP template nobody could mint a token for and a gate rule that read an error message instead of the behaviour. Ingest Go suite green; api projection suite 37; live TAXII suite 15. |
| 2026-10-09 | 4.1 | Reproduced: `check_cloud_native_collection.py` on the unmodified tree reported all three collection paths absent. Implemented `aws_cloudtrail_s3` (SQS-notified S3 objects; management events, data events and VPC flow logs; delete-after-emit), `gcp_pubsub` (REST pull on a log-sink subscription; ack-after-read) and `azure_event_hubs` (Capture blobs over the Data Lake Gen2 JSON API, with a focused Avro OCF reader). Negative controls recorded in the PR: deleting the SQS message before the object is read, acknowledging the Pub/Sub batch before it is built, ignoring the Avro union branch index, and ignoring the flow-log header line each fail a named test, and all were restored. Connectors suite 1014 -> 1098 passed. |
diff --git a/apps/docs/docs/operations/performance.md b/apps/docs/docs/operations/performance.md
index 869dabb9e..0364ef2af 100644
--- a/apps/docs/docs/operations/performance.md
+++ b/apps/docs/docs/operations/performance.md
@@ -251,6 +251,57 @@ measured values: GitHub runners are shared, throttled and noisy, and a gate
that fires on runner jitter gets disabled within a week. **A passing perf job
is not evidence that any number on this page still holds on your hardware.**
+## Scaling on lag
+
+`GET /scale-hint` on the fusion service publishes the consumer backlog
+and a suggested replica count. AiSOC does not scale itself — an
+autoscaler belongs to the cluster, would need write access to the
+orchestrator, and would fight whatever scaler you already run. ADR-0011
+records that decision.
+
+```json
+{
+ "status": "ok",
+ "lag_messages": 31204,
+ "lag_measured": true,
+ "replica_eps": 122.56,
+ "drain_target_seconds": 120.0,
+ "suggested_replicas": 3,
+ "basis": "31204 message(s) backlog, cleared in 120s at 122.6 events/s per replica"
+}
+```
+
+`replica_eps` defaults to the ingest rate measured in the realistic-mix
+run above, which is a laptop's figure. Set `AISOC_FUSION_REPLICA_EPS` to
+your own and the hint is derived from that instead;
+`AISOC_FUSION_DRAIN_TARGET_SECONDS` changes how fast you want a backlog
+cleared.
+
+`lag_measured: false` means the backlog could not be read — no partition
+assignment yet, or a broker that did not answer. It is **not** zero
+backlog, and a scaler should treat it as no signal rather than as an
+all-clear.
+
+A KEDA `ScaledObject` consuming it:
+
+```yaml
+apiVersion: keda.sh/v1alpha1
+kind: ScaledObject
+metadata:
+ name: aisoc-fusion
+spec:
+ scaleTargetRef:
+ name: aisoc-fusion
+ minReplicaCount: 1
+ maxReplicaCount: 20
+ triggers:
+ - type: metrics-api
+ metadata:
+ targetValue: "1"
+ url: "http://aisoc-fusion:8000/scale-hint"
+ valueLocation: "suggested_replicas"
+```
+
## No cloud-hardware run exists yet, and that is a gap
The depth plan asks for a run on stated cloud hardware, aiming at a
diff --git a/docs/audit/CLAIM_TO_GATE_MATRIX.md b/docs/audit/CLAIM_TO_GATE_MATRIX.md
index 2cf41dc4b..6f8dcb532 100644
--- a/docs/audit/CLAIM_TO_GATE_MATRIX.md
+++ b/docs/audit/CLAIM_TO_GATE_MATRIX.md
@@ -18,6 +18,9 @@ Statuses: `GATED` (a CI job fails when the claim stops being true) · `PARTIAL`
| A customer's own Kafka topics can be consumed directly, and the consumer can tell a fault that will never clear from one that might | `apps/docs/docs/connectors/kafka-input.md`; depth plan 4.2 / parity 6.10 | `ci.yml :: python-lint` (`check_standard_inputs.py`: the input uses the shared `streamhealth` classifier rather than a second copy of the table, names all three failure classes, sets `ErrorLogger` on the reader — with a `GroupID` set that is where every dial, join and rebalance failure goes while the fetch stays blocked — splits the broker list on commas because `kafka.TCP` is variadic, takes the tenant from the resolved token, and is parsed, constructed, started and named per source in `/readyz`) + `ci.yml` ingest Go job (`internal/kafkainput`, 22 cases driving the real loop through a scripted reader: a record carrying a different tenant in its payload *and* a header still lands under the token's; a `RebalanceInProgress` is transient and the loop continues, because it happens on every deploy; a `TopicAuthorizationFailed` stops the loop with the operator action in the readiness detail; an empty record is poison, is counted, does not mark the subscription unhealthy and **is** committed, because a poison record that is not committed is re-read forever; a publish failure does **not** commit; and an idle subscription reports attached with 'nothing has arrived yet' rather than looking broken) | core | GATED | The permanent set is enumerated rather than derived from `kafka.Error.Temporary()`, which answers a different question: `RebalanceInProgress` is non-retriable in the protocol's sense and routine in practice. **No live broker has been exercised** — the loop is driven through a scripted reader, so what is proven is the failure handling rather than the wire protocol, which is kafka-go's |
| Indicators can be published to a partner over TAXII 2.1, from this tenant's own store, without losing one to pagination | `apps/docs/docs/operations/taxii-server.md`; depth plan 4.2 / parity 6.10 | `taxii-live.yml :: TAXII pages every indicator exactly once, and only this tenant's` (real Postgres, every migration applied, 15 cases through the real route functions: another tenant's collection is not found by id or by alias, no other tenant's indicator appears in a page, a collection filter narrows what is published, the manifest pages by the same cursor as objects, a corrupt `next` is a 400 rather than a silent restart, and the walk that matters pages the collection one indicator at a time and requires all four back exactly once. The job asserts migration 110's paging index exists rather than assuming it, greps the run for a skip so the suite cannot pass by not running, and carries a negative control that replaces the `(updated_at, id)` row-value cursor with the bare timestamp comparison and requires the walk to go red — measured: it returns 3 of 4) + `ci.yml` api job (`test_taxii_projection.py`, 37 pure cases over the STIX projection: a quote in a value is escaped per the grammar and the backslash before it, timestamps carry a literal Z, the TLP marking is the id the specification fixes, the STIX id is derived from the row, an unknown filter key is refused rather than ignored) + `ci.yml :: python-lint` (`check_standard_inputs.py`: all six routes a client walks, `added_after`, the row-value cursor, tenant from the principal, `can_write` pinned false, RLS and the paging index in the migration) | core | GATED | Read-only by design: `can_write` is false on every collection and a write answers 403 naming the posture, because an inbound TAXII write is an outside party inserting indicators that drive this tenant's detections. `cve` is refused rather than published as a malformed pattern, with the reason served at `/taxii/unpublished-types` from the same table the projection uses. **No third-party TAXII client has been run against this server** — conformance is asserted against the specification's shapes, not against a client's behaviour |
| A query over the cold tier reports what it will read and how far it has got, instead of timing out silently | `apps/docs/docs/operations/cold-tier-queries.md`; depth plan 4.3 | `lake-query-jobs-live.yml :: One replica claims a cold scan, and a finished job stays finished` (real Postgres, every migration applied, 12 cases: two **explicitly interleaved** transactions claim one job and exactly one wins, a cancelled job is not overwritten by a late finish, a late progress read does not resurrect a finished job, an unknown denominator stores NULL rather than a number, and another tenant's job id is a 404. The job asserts `progress_ratio` is nullable in the live schema, greps the run for a skip so the suite cannot pass by not running, and carries a negative control removing the `status = 'queued'` predicate, after which both transactions claim the job and the suite must go red) + `ci.yml :: Python — Tests` (api, `test_lake_cold_query.py`, 26 cases: the planner's output is summed by column name so a reorder cannot swap rows and parts, an unreadable column set raises rather than returning zero, an unrecognised disk counts as warm, a progress ratio with no denominator is None and one past its estimate is clamped, and **no money figure is produced without a configured retrieval price**) + `ci.yml :: python-lint` (`check_retention_window.py --self-test`, eight cold-query rules added with one injection each: an estimate this code derives rather than asking the planner, no warm/cold split, an unguarded ratio denominator, a claim two replicas can both win, a terminal state a late finish can overwrite, a cold query still routed synchronously, and jobs that exist in the ORM and in no database) | full | GATED | **`estimated_usd` is null unless a deployment configures `AISOC_LAKE_COLD_RETRIEVAL_USD_PER_GB`.** `docs/decisions/storage-cost-model.json` prices residency, not reads, and quoting it for a scan would be the wrong number stated confidently. The routing rule is structural rather than a predicted duration, because predicting one needs a bytes-per-second figure measured on the deployment's own hardware. **No ClickHouse has been exercised against this** — there is no ClickHouse in CI or on this machine, so `EXPLAIN ESTIMATE`, the `system.parts` join and the `system.processes` progress read are asserted against ClickHouse's documented shapes and the parsing of them is tested on recorded rows; what is proven live is the job lifecycle, which is where the concurrency defects are |
+| Fusion does not run every detection rule against every event | `docs/decisions/0011-how-fusion-scales.md`; depth plan 4.4 / parity 6.9 | `ci.yml :: Python — Tests` (fusion, `test_rule_index_is_lossless.py`, 12 cases: **every committed detection fixture is replayed through the indexed path and the full corpus and the hit lists must be identical and in the same order**, plus 200 random non-matching events and the empty event, because fixtures are synthesised from the rules they test and only exercise the matching case. The classification is asserted to be executed rather than enumerated — for every field the index calls required, the real matcher is asserted to refuse an empty event) | core | GATED | Indexed on **required fields, not log source**, which is what the plan asks for: connector product names do not line up with spec products, a product-based pre-filter was tried once and reverted for silently dropping real matches, and a mapping table leaves every new connector one missing entry away from a detection that stops firing. Measured: 2,511 rules, 1,751 indexed (69.74%), 797 candidates for a routine cloud event (68.3% fewer), 2.760 → 1.066 ms/event over 2,000 iterations. The indexed fraction is pinned just under the measurement so it can only ratchet up. Writing the test found that `neq` **requires** its field in this matcher despite reading like a negation, which a hand-written operator list would have got wrong in the direction that drops detections |
+| One entity's events are ordered, and triage runs concurrently across entities | `docs/decisions/0011-how-fusion-scales.md`; depth plan 4.4 / parity 6.9 | `ci.yml` ingest Go job (`internal/publisher`, 8 cases: two events about one host share a partition key, two hosts do not, the same hostname in two tenants does not, the precedence matches `RawAlert.correlation_key()` field for field, and an event naming nobody falls back to its own id rather than to the tenant — which would be a hot partition) + `ci.yml :: Python — Tests` (agents, `test_entity_lanes.py`, 18 cases: one entity's alerts complete in arrival order **with the first deliberately the slowest**, two entities overlap, peak concurrency is the bound, a failing alert does not take its lane down, and 50 entities leave zero lanes retained) | core | GATED | The partition key was `tenant:event_id`, unique per event, so nothing about one entity was ordered relative to anything — while fusion correlates on `{tenant}:{entity}:{tactic}`. A partition key disagreeing with the correlation key would route an entity's events to a partition and correlate them under another name, correct-looking from either end, so a test holds the two orders equal. Triage commits offsets only after the in-flight window drains, with a time bound as well as a count: without it a topic quieter than the concurrency bound leaves finished work uncommitted and every restart replays it |
+| The load harness measures a pipeline where most events do not alert, and the autoscaling hint is derived from that run | `apps/docs/docs/operations/performance.md`; depth plan 4.4 / parity 6.9 | `ci.yml :: Python — Tests` (`tests/test_load_harness_realistic_mix.py`, 8 cases: the Go and Python benign markers are equal and the SQL cannot confuse them even though one is a prefix of the other, the delivery ratio is taken against the alerting population so a lossless mix run reports 1.0 rather than 0.01, an all-alerting run reports the benign rate as **not measured** rather than 0.0, a result file written before the mix existed still grades, and a ceiling on an unmeasured rate fails rather than passes) + fusion `test_scale_hint.py` (13 cases, including one that **reads the committed result file** and fails if `PUBLISHED_REPLICA_EPS` drifts from the run it names) + `check_perf_results.py` (every committed result carries its hardware, its date and the not-an-SLO label) | core | GATED | Published run: 6,000 events saturating at 1-in-100, **0 of 5,940 routine events raised an alert**, 0 missing, 0 duplicates, p95 event-to-alert 1,195 ms, ingest 122.6 events/s. The first attempt measured a routine alert rate of **1.00** — the load path's undeclared connector type falls to a generic profile filed as class 2001, and the promoter promotes category 2 unconditionally, so on eight of the twelve declared profiles no event can be routine. **No cloud-hardware run exists**: no instance has been provisioned for this project, so the plan's 5,000 events/s target is an aim rather than a result and the page says so with the command that would close it. The published run also predates the rule index — it ran against the published images — which the page states |
| Investigation Ledger stores every step | README L61, L169 | `ci.yml :: Python — Lint & Type-check` (`check_ledger_replay_contract.py` — response model ↔ console type, client requests ↔ router decorators, and `seq` ordering/uniqueness, each in both directions) + `ci.yml :: Python — Tests` (`test_investigation_replay.py`, 37 cases over `/replay`, `/events`, `/explain`; removing `ORDER BY seq` fails five of them) | core | GATED | — |
| Public eval harness gates every PR | README L62, L77 | `ci.yml :: p1-eval` | core | GATED (but suites are self-consistency; see reality report) | Phase 4 |
| Alert-reduction is a real measurement | README / benchmark page | `ci.yml :: python-test` (fusion) runs `test_alert_reduction_real.py`, which groups a 1 000-alert stream with `RawAlert.correlation_key()` — the method `Correlator` actually calls — and bounds the ratio on both sides, because a floor alone is satisfied by a key that collapses everything into one incident | core | GATED | the legacy suite's 75.3% stays published for continuity and is labelled as not describing this product; the measurement is still a synthetic workload, as the benchmark page states |
@@ -317,8 +320,8 @@ Statuses: `GATED` (a CI job fails when the claim stops being true) · `PARTIAL`
## Summary
-- Total: 306
-- GATED: 303
+- Total: 309
+- GATED: 306
- PARTIAL: 3
- NO GATE: 0