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.

fix(ci): three main breakers — harness fan-out context, and an empty matrix serialising as [""] (#1218)

Beenu Arora48e6af04815b
diff --git a/.github/workflows/reproducible-builds.yml b/.github/workflows/reproducible-builds.yml
index 0572288a3..533bf3e4e 100644
--- a/.github/workflows/reproducible-builds.yml
+++ b/.github/workflows/reproducible-builds.yml
@@ -288,8 +288,26 @@ jobs:
lockonly+=("$service")
fi
done
- printf 'images=%s\n' "$(printf '%s\n' "${images[@]}" | jq -R . | jq -sc .)" >> "$GITHUB_OUTPUT"
- printf 'lockonly=%s\n' "$(printf '%s\n' "${lockonly[@]}" | jq -R . | jq -sc .)" >> "$GITHUB_OUTPUT"
+ # An empty array must serialise to `[]`, not to `[""]`.
+ #
+ # `printf '%s\n' "${empty[@]}"` prints one blank line rather than
+ # nothing, so piping it through jq yielded a single empty-string
+ # element and the matrix ran one job for a service with no name.
+ # That is what put `poetry -C services/` in the log and failed the
+ # lock-only leg, and it is also why the coverage check reported
+ # "14 of 13 services" -- the phantom counted. Every service here
+ # currently has a Dockerfile, so `lockonly` is empty and the bug
+ # was reachable the moment the last image-less service gained one.
+ emit() {
+ local name="$1"; shift
+ if [ "$#" -eq 0 ]; then
+ printf '%s=[]\n' "$name" >> "$GITHUB_OUTPUT"
+ else
+ printf '%s=%s\n' "$name" "$(printf '%s\n' "$@" | jq -R . | jq -sc .)" >> "$GITHUB_OUTPUT"
+ fi
+ }
+ emit images "${images[@]}"
+ emit lockonly "${lockonly[@]}"
printf 'total=%s\n' "$total" >> "$GITHUB_OUTPUT"
echo "$total service(s): ${#images[@]} with an image, ${#lockonly[@]} lock-only"
diff --git a/scripts/perf/load_harness.py b/scripts/perf/load_harness.py
index 932d4a3c0..a9c18a7b4 100644
--- a/scripts/perf/load_harness.py
+++ b/scripts/perf/load_harness.py
@@ -227,6 +227,61 @@ def compose_target(project_dir: Path, compose_files: list[str], ingest_url: str)
)
+def _fusion_replicas(target: Target) -> int | None:
+ """How many fusion containers were actually running, or None.
+
+ Counted from the runtime rather than from a compose file, because a file
+ says what was requested and a rate is produced by what was running. Both
+ deployment shapes already expose a listing command for the resource
+ sampler, so this reads the same source the samples came from.
+ """
+ if not target.stats:
+ return None
+ try:
+ done = subprocess.run( # noqa: S603 - fixed argv, same prefix the sampler uses
+ target.stats, capture_output=True, text=True, timeout=45, check=False
+ )
+ except (OSError, subprocess.TimeoutExpired):
+ return None
+ if done.returncode != 0:
+ return None
+ # A fusion container is named for its service in both runtimes; a worker
+ # or a one-shot named after it is not a replica serving the spine.
+ count = sum(1 for line in done.stdout.splitlines() if "fusion" in line.split("\t")[0].split()[0].lower())
+ return count or None
+
+
+def _kafka_partitions(target: Target, group: str = _FUSION_GROUP) -> int | None:
+ """Partitions the fusion group is consuming, or None.
+
+ Read from the same `--describe` output the lag measurement uses, which
+ prints one row per partition, so this adds no new dependency and cannot
+ disagree with the lag figure published beside it.
+ """
+ if not target.kafka:
+ return None
+ try:
+ done = subprocess.run( # noqa: S603
+ [*target.kafka, "--bootstrap-server", "localhost:9092", "--describe", "--group", group],
+ capture_output=True,
+ text=True,
+ timeout=60,
+ check=False,
+ )
+ except (OSError, subprocess.TimeoutExpired):
+ return None
+ if done.returncode != 0:
+ return None
+ partitions: set[str] = set()
+ for line in done.stdout.splitlines():
+ fields = line.split()
+ # GROUP TOPIC PARTITION ...; the header and blank lines have no digit
+ # in the third column.
+ if len(fields) >= 3 and fields[2].isdigit():
+ partitions.add(f"{fields[1]}:{fields[2]}")
+ return len(partitions) or None
+
+
def kubernetes_target(namespace: str, release: str, ingest_url: str, postgres_ref: str, kafka_ref: str) -> Target:
kubectl = ["kubectl", "-n", namespace]
return Target(
@@ -718,6 +773,22 @@ def main(argv: list[str] | None = None) -> int:
}
if args.target == "compose":
shape["hosts"] = 1
+ # `throughput_claims.py` requires both of these beside an alert-path rate,
+ # and it is right to: that rate is the one a reader uses to decide whether
+ # a deployment keeps up, and it means nothing without the fan-out it was
+ # measured at. Both are *read from the running deployment* -- a default
+ # written down here would be a guess that looks like a measurement, which
+ # is the failure the required-context rule exists to catch.
+ #
+ # Omitted, not defaulted, when the deployment cannot be asked. The grader
+ # then says the number is unreproducible, which is true, instead of
+ # publishing it beside a replica count nobody verified.
+ replicas = _fusion_replicas(target)
+ if replicas is not None:
+ shape["fusion_replicas"] = replicas
+ partitions = _kafka_partitions(target)
+ if partitions is not None:
+ shape["kafka_partitions"] = partitions
report = build_report(
target=target,