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
Readiness that means something, and one install path (#727)
Beenu Arora7d1c4b4cfb56
diff --git a/infra/compose/docker-compose.demo.yml b/infra/compose/docker-compose.demo.ymlindex 1d07302f3..a5ec8dc8a 100644--- a/infra/compose/docker-compose.demo.yml+++ b/infra/compose/docker-compose.demo.yml@@ -1,14 +1,34 @@###############################################################################-# AiSOC - AI Security Operations Center-# Docker Compose - Slim Demo Profile (time-to-wow under 5 minutes)+# AiSOC - UI preview over a pre-seeded database. NOT the product pipeline.#-# This profile pulls prebuilt images from GHCR instead of building locally,-# and only includes the 6 services required to demo a triaging investigation:-# postgres, redis, zookeeper, kafka, api, agents, realtime, web+# ┌───────────────────────────────────────────────────────────────────┐+# │ This stack does NOT run the AiSOC pipeline. │+# │ │+# │ It has no ingest service and no fusion service, and it sets │+# │ AISOC_DISABLE_KAFKA=true. Everything visible in the console came │+# │ from `seed_demo.py` writing synthetic rows straight into │+# │ Postgres. No event is normalized, detected, correlated or │+# │ promoted, because none of the code that does those things is │+# │ running. │+# │ │+# │ Use it to look at the interface. Do not use it to evaluate │+# │ whether AiSOC works — it cannot answer that question. │+# └───────────────────────────────────────────────────────────────────┘#-# Optional heavyweights (clickhouse, opensearch, qdrant, neo4j, kafka-ui,-# enrichment, fusion, ingest, threatintel, ueba, honeytokens, purple-team,-# actions, connectors, monitoring) are intentionally excluded.+# For a stack that actually processes events, use the CORE profile, which is+# the default and what `install.sh`, the README and CI all use:+#+# make up # 10 services, the real pipeline+# make smoke # prove it: one real event -> a retrievable alert+# make demo # then add the same synthetic data, clearly labelled+#+# This file was the documented quick start until v8.2. A user followed the+# README, saw a populated console, and concluded the platform worked having+# never run the platform. It is kept only for screenshots and UI work.+#+# Included: postgres, redis, zookeeper, kafka, api, agents, realtime, web, seed+# Absent: ingest, fusion, connectors, enrichment, clickhouse, neo4j, qdrant,+# opensearch, threatintel, ueba, actions — i.e. most of the product## Usage:# pnpm aisoc:demodiff --git a/install.sh b/install.shindex f7ea88dbf..69d465e40 100755--- a/install.sh+++ b/install.sh@@ -759,9 +759,14 @@ run_demo() {info " cd $REPO_ROOT && pnpm aisoc:demo"return 0fi- section "Launching AiSOC demo stack"- info "Handing off to 'pnpm aisoc:demo' — this will pull images, start the"- info "stack, seed the showcase ransomware case, and open your browser."+ section "Starting AiSOC (CORE profile)"+ info "Starting the 10-service CORE stack: postgres, redis, kafka, ingest,"+ info "fusion, api, agents, realtime and the web console."+ info ""+ info "This is the same stack 'make up' starts and the same one CI tests."+ info "It runs the real pipeline: an event you send is normalized, placed on"+ info "the event spine, evaluated against the detection corpus, correlated"+ info "and written as an alert."echo# In non-interactive / headless contexts (CI, ssh without DISPLAY, --non-interactive),@@ -781,16 +786,21 @@ run_demo() {# script. Run docker via `sg docker` if the user was just added to the# group and hasn't logged out — otherwise pnpm aisoc:demo will explode on# its very first `docker compose` call.+ # One architecture, one command. This used to hand off to+ # `pnpm aisoc:demo`, which started a *different* nine-service compose file+ # with no ingest service, no fusion service and Kafka disabled — its only+ # content came from a seed script writing rows straight into Postgres. A+ # user followed the README, saw a populated console and concluded the+ # platform worked, having never run the platform.+ #+ # `make up` is now the only path, so what the installer starts, what the+ # README documents and what CI tests are the same stack.if [ "$DOCKER_NEEDS_NEWGRP" = "1" ] && have sg; then- # `sg` spawns a fresh shell that wipes our env, so re-export AISOC_NO_BROWSER- # inline if we set it.- local pre=""- [ "$need_no_browser" = "1" ] && pre="AISOC_NO_BROWSER=1 "- sg docker -c "cd '$REPO_ROOT' && ${pre}pnpm aisoc:demo ${DEMO_FLAGS[*]:-}" \- || { err "pnpm aisoc:demo exited non-zero."; exit 3; }+ sg docker -c "cd '$REPO_ROOT' && make up" \+ || { err "'make up' exited non-zero."; exit 3; }else- ( cd "$REPO_ROOT" && pnpm aisoc:demo "${DEMO_FLAGS[@]}" ) \- || { err "pnpm aisoc:demo exited non-zero."; exit 3; }+ ( cd "$REPO_ROOT" && make up ) \+ || { err "'make up' exited non-zero."; exit 3; }fi}diff --git a/scripts/doctor.sh b/scripts/doctor.shindex f6b7d0784..c7006da9d 100755--- a/scripts/doctor.sh+++ b/scripts/doctor.sh@@ -228,6 +228,19 @@ check_http_service() {check_http_service api "${AISOC_API_URL:-http://localhost:8000}/health" "docker compose logs api | tail -40"check_http_service ingest-worker "${AISOC_INGEST_URL:-http://localhost:8081}/health" "docker compose logs ingest-worker | tail -40"+# Liveness says the process is up. Readiness says it can do its job. For+# ingest the difference is Kafka: without it every accepted event is dropped+# while /health keeps answering 200.+if svc_running ingest-worker; then+ ready_code="$(http_ok "${AISOC_INGEST_URL:-http://localhost:8081}/readyz" 8)"+ case "$ready_code" in+ 200) pass "ingest-worker ready (kafka reachable)" ;;+ 503) fail "ingest-worker is alive but NOT ready — it cannot reach Kafka, so ingested events are dropped" "curl -s ${AISOC_INGEST_URL:-http://localhost:8081}/readyz # prints the reason" ;;+ 404) warn "ingest-worker has no /readyz — running an image older than v8.2" "docker compose build ingest-worker && docker compose up -d ingest-worker" ;;+ *) warn "ingest-worker /readyz returned $ready_code" "docker compose logs ingest-worker | tail -30" ;;+ esac+fi+# Fusion has no HTTP health route in every build, so it is checked by whether# its consumer actually joined the group — the thing that matters.if svc_running fusion; thendiff --git a/services/ingest/internal/handler/handler.go b/services/ingest/internal/handler/handler.goindex b674dc6d1..8a1394881 100644--- a/services/ingest/internal/handler/handler.go+++ b/services/ingest/internal/handler/handler.go@@ -173,6 +173,9 @@ func (h *Handler) IngestEvents(w http.ResponseWriter, r *http.Request) {}// Health handles GET /health+// Health is liveness: is this process running at all? It deliberately checks+// nothing else, so a restart loop is distinguishable from a dependency+// outage.func (h *Handler) Health(w http.ResponseWriter, r *http.Request) {writeJSON(w, http.StatusOK, map[string]interface{}{"status": "ok",@@ -181,6 +184,49 @@ func (h *Handler) Health(w http.ResponseWriter, r *http.Request) {})}+// Livez is the Kubernetes spelling of Health. Same answer, conventional name.+func (h *Handler) Livez(w http.ResponseWriter, r *http.Request) {+ h.Health(w, r)+}++// Readyz is readiness: can this service do its job right now?+//+// For ingest that means one thing — is Kafka reachable. Without it every+// accepted event is dropped, and the service used to report a cheerful 200+// throughout, so "ingest is healthy" and "nothing is reaching the pipeline"+// were simultaneously true with no way to tell from the outside.+//+// 503 with the reason, rather than 200 with a status field, so a load+// balancer and a human both get a usable answer.+func (h *Handler) Readyz(w http.ResponseWriter, r *http.Request) {+ ctx, cancel := context.WithTimeout(r.Context(), 3*time.Second)+ defer cancel()++ if h.pub == nil {+ writeJSON(w, http.StatusServiceUnavailable, map[string]interface{}{+ "status": "not_ready",+ "service": "ingest",+ "reason": "no kafka publisher configured",+ })+ return+ }+ if err := h.pub.Ready(ctx); err != nil {+ writeJSON(w, http.StatusServiceUnavailable, map[string]interface{}{+ "status": "not_ready",+ "service": "ingest",+ "reason": err.Error(),+ "hint": "docker compose logs kafka | tail -40",+ })+ return+ }+ writeJSON(w, http.StatusOK, map[string]interface{}{+ "status": "ready",+ "service": "ingest",+ "checks": map[string]string{"kafka": "reachable"},+ "timestamp": time.Now().UTC().Format(time.RFC3339),+ })+}+func writeJSON(w http.ResponseWriter, status int, v interface{}) {w.Header().Set("Content-Type", "application/json")w.WriteHeader(status)diff --git a/services/ingest/internal/publisher/publisher.go b/services/ingest/internal/publisher/publisher.goindex 5bd68907e..b6e780271 100644--- a/services/ingest/internal/publisher/publisher.go+++ b/services/ingest/internal/publisher/publisher.go@@ -5,6 +5,8 @@ import ("context""encoding/json""fmt"+ "net"+ "time""github.com/beenuar/aisoc/services/ingest/internal/config""github.com/beenuar/aisoc/services/ingest/internal/enrichment"@@ -16,10 +18,10 @@ import (// Publisher sends normalized events to Kafkatype Publisher struct {- writer *kafka.Writer- vulnWriter *kafka.Writer // dedicated writer for VULNERABILITY_MATCH topic- graphWriter *kafka.Writer // dedicated writer for security.graph_updates (T1.1, v8.0)- cfg *config.Config+ writer *kafka.Writer+ vulnWriter *kafka.Writer // dedicated writer for VULNERABILITY_MATCH topic+ graphWriter *kafka.Writer // dedicated writer for security.graph_updates (T1.1, v8.0)+ cfg *config.Config}// New creates a new Kafka publisher@@ -196,6 +198,30 @@ func (p *Publisher) PublishBatch(ctx context.Context, events []*normalizer.Normareturn nil}+// Ready reports whether the Kafka broker is actually reachable.+//+// This is the difference between liveness and readiness for this service:+// the process can be perfectly alive while the broker is unreachable, and in+// that state every ingested event is accepted and then dropped. An operator+// or a load balancer needs to tell those apart, and /health could not --- it+// returned 200 unconditionally.+//+// Dialing is deliberate rather than reading a cached connection state:+// kafka-go reconnects lazily, so a cached "connected" flag is stale in+// exactly the situation this is meant to catch.+func (p *Publisher) Ready(ctx context.Context) error {+ addr := p.writer.Addr+ if addr == nil {+ return fmt.Errorf("no kafka address configured")+ }+ d := &net.Dialer{Timeout: 2 * time.Second}+ conn, err := d.DialContext(ctx, addr.Network(), addr.String())+ if err != nil {+ return fmt.Errorf("kafka unreachable at %s: %w", addr.String(), err)+ }+ return conn.Close()+}+// Close shuts down the Kafka writersfunc (p *Publisher) Close() {if err := p.writer.Close(); err != nil {diff --git a/services/ingest/internal/server/server.go b/services/ingest/internal/server/server.goindex 73a41ba42..42af625b9 100644--- a/services/ingest/internal/server/server.go+++ b/services/ingest/internal/server/server.go@@ -100,7 +100,13 @@ func New(cfg *config.Config, h *handler.Handler, inboxHandler *inbox.Handler, gr}))// Routes+ // Liveness and readiness are separate questions, and this service only+ // answered the first one. /health returned 200 whether or not Kafka was+ // reachable — so "ingest is healthy" and "every event is being dropped"+ // could both be true at once. /readyz probes the broker.r.Get("/health", h.Health)+ r.Get("/livez", h.Livez)+ r.Get("/readyz", h.Readyz)r.Get("/metrics", promhttp.Handler().ServeHTTP)r.Route("/v1", func(r chi.Router) {