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(devcontainer): honest cold-start KPI + system-wide uv/ruff (#371)

Beenu Arora1bd2d21581aa
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 7f8e3e696..8d5209fc4 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -86,13 +86,19 @@ RUN set -eux; \
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
ENV PATH="/usr/local/go/bin:${PATH}"
-# ─── Python toolchain (uv) ──────────────────────────────────────────────────
+# ─── Python toolchain (uv + ruff) ───────────────────────────────────────────
# `uv` is the canonical Python package manager for AiSOC services. Installing
# it at image-build time means a fresh codespace can run `uv sync` against
# `services/api/uv.lock` immediately, with no further network round-trips.
-RUN pipx ensurepath \
- && pipx install uv \
- && pipx install ruff
+#
+# We install via `pip` (with `--break-system-packages` to opt out of PEP 668)
+# rather than `pipx` so the binaries land in `/usr/local/bin` where they are
+# on PATH for *every* user in the container — `root` during the build,
+# `node` at runtime, and any uid the workflow runner gates the container to.
+# The previous pipx approach installed to `/root/.local/bin/`, which is
+# unreadable by `node` (uid 1000) and broke the cold-start KPI probe.
+RUN python3.11 -m pip install --break-system-packages --no-cache-dir \
+ uv ruff
# ─── pnpm via corepack ──────────────────────────────────────────────────────
RUN corepack enable \
diff --git a/.github/workflows/devcontainer-coldstart.yml b/.github/workflows/devcontainer-coldstart.yml
index 15d0e5623..13b501e85 100644
--- a/.github/workflows/devcontainer-coldstart.yml
+++ b/.github/workflows/devcontainer-coldstart.yml
@@ -10,13 +10,21 @@ name: Devcontainer · cold-start KPI
# longer holds for Codespaces users — release-blocking.
#
# Strategy: pull the published `ghcr.io/beenuar/aisoc-devcontainer:latest`
-# (the same image Codespaces resolves) and exec the acceptance harness
-# inside it. We measure two budgets independently:
+# (the same image Codespaces resolves) and verify it is immediately useful
+# as a dev environment. We measure two budgets independently:
#
-# 1. image pull + `onCreateCommand` (pnpm install warm-store) — the
-# "before you can run anything" phase. Budget: 60 s.
-# 2. `pnpm aisoc:acceptance --cold` — the same wall-clock measurement
-# used by the WS-A buyer acceptance gate. Budget: 5 min.
+# 1. image pull — the "before any keystroke is possible" phase.
+# Budget: 60 s.
+# 2. toolchain ready — every executable a contributor needs on PATH
+# (node, pnpm, python3.11, uv, ruff, go, gh, docker, docker compose,
+# rg, jq) responds to `--version` from inside a single `docker run`.
+# This is what the user actually experiences when they open
+# Codespaces: from `docker pull` complete to first usable shell.
+# Budget: 30 s.
+#
+# We deliberately do NOT boot the full `infra/compose/docker-compose.demo.yml`
+# stack here — that's an acceptance gate, not a cold-start KPI. The full
+# stack acceptance gate lives in the WS-A buyer-journey workflow.
#
# A regression on either budget fails the workflow.
@@ -29,7 +37,14 @@ on:
branches: [main]
paths:
- '.devcontainer/**'
- - 'scripts/aisoc-acceptance.ts'
+ - '.github/workflows/devcontainer-coldstart.yml'
+ # PRs that touch this workflow run the toolchain probe against the
+ # currently-published `:latest` image. That validates the workflow's
+ # logic without needing a fresh image (the build & publish workflow's
+ # PR job verifies the Dockerfile separately).
+ pull_request:
+ branches: [main]
+ paths:
- '.github/workflows/devcontainer-coldstart.yml'
workflow_dispatch:
@@ -51,7 +66,7 @@ jobs:
# canonical record of any KPI change.
env:
PHASE_PULL_BUDGET: '60'
- PHASE_ACCEPTANCE_BUDGET: '300'
+ PHASE_TOOLCHAIN_BUDGET: '30'
steps:
- uses: actions/checkout@v7
@@ -75,24 +90,35 @@ jobs:
exit 1
fi
- - name: Phase 2 — boot + aisoc-acceptance --cold (KPI budget ${{ env.PHASE_ACCEPTANCE_BUDGET }}s)
+ - name: Phase 2 — toolchain ready (KPI budget ${{ env.PHASE_TOOLCHAIN_BUDGET }}s)
run: |
set -euo pipefail
start=$(date +%s)
+ # Single `docker run` exec'ing one batch-script that pokes every
+ # tool we promise in `apps/docs/docs/operations/codespaces.md`.
+ # If any binary is missing or unconfigured the run fails fast,
+ # surfacing exactly which `--version` invocation broke. Output is
+ # streamed directly to the job log — no inside-container
+ # redirection that would swallow errors on container exit.
docker run --rm \
- -v "${GITHUB_WORKSPACE}:/workspaces/AiSOC" \
- -v /var/run/docker.sock:/var/run/docker.sock \
- -w /workspaces/AiSOC \
- -e AISOC_DEV_MODE=1 \
ghcr.io/beenuar/aisoc-devcontainer:latest \
bash -lc '
set -euo pipefail
- pnpm install --frozen-lockfile=false >/tmp/pnpm.log 2>&1
- pnpm aisoc:acceptance:cold --budget-ms '"${PHASE_ACCEPTANCE_BUDGET}"'000
+ echo "── node ──"; node --version
+ echo "── pnpm ──"; pnpm --version
+ echo "── python3.11 ──"; python3.11 --version
+ echo "── uv ──"; uv --version
+ echo "── ruff ──"; ruff --version
+ echo "── go ──"; go version
+ echo "── gh ──"; gh --version | head -1
+ echo "── docker (cli) ──"; docker --version
+ echo "── docker compose ──"; docker compose version
+ echo "── ripgrep ──"; rg --version | head -1
+ echo "── jq ──"; jq --version
'
elapsed=$(( $(date +%s) - start ))
- echo "::notice title=devcontainer-acceptance-seconds::${elapsed}"
- if [ "$elapsed" -gt "${PHASE_ACCEPTANCE_BUDGET}" ]; then
- echo "::error::aisoc-acceptance --cold took ${elapsed}s, over budget of ${PHASE_ACCEPTANCE_BUDGET}s." >&2
+ echo "::notice title=devcontainer-toolchain-seconds::${elapsed}"
+ if [ "$elapsed" -gt "${PHASE_TOOLCHAIN_BUDGET}" ]; then
+ echo "::error::Devcontainer toolchain check took ${elapsed}s, over budget of ${PHASE_TOOLCHAIN_BUDGET}s." >&2
exit 1
fi
diff --git a/apps/docs/docs/operations/codespaces.md b/apps/docs/docs/operations/codespaces.md
index ed49c8c8c..6863bd8bf 100644
--- a/apps/docs/docs/operations/codespaces.md
+++ b/apps/docs/docs/operations/codespaces.md
@@ -1,9 +1,12 @@
# Codespaces & devcontainers
AiSOC ships a prebuilt devcontainer image so a fresh Codespace boots from
-clone-link to a green `pnpm aisoc:demo` in **about 30 seconds**, down from
-roughly 5 minutes when the same image was assembled from
-`features:` on every cold start.
+clone-link to **a usable dev shell in about 30 seconds**, down from
+roughly 5 minutes when the same image was assembled from `features:` on
+every cold start. (Booting the full demo stack still takes a few
+minutes — that's a docker-pull problem, not a devcontainer-assembly
+problem — but you can start typing, running tests, and editing code
+within ~30 s of the Codespace opening.)
## What's prebuilt
@@ -14,7 +17,10 @@ on every push to `main`. It carries:
- Node 20 + `[email protected]` via `corepack`
- Python 3.11 + [`uv`](https://github.com/astral-sh/uv) + `ruff`
- Go 1.22
-- `docker` + `docker-compose-plugin`
+- Docker CE 20.x (`docker.io`) + Compose v2 plugin
+ (pinned at `v2.29.7`, fetched from the upstream binary release into
+ `/usr/local/lib/docker/cli-plugins/` so `docker compose ...` works
+ out of the box)
- GitHub CLI (`gh`)
- `ripgrep`, `jq`, `build-essential` (for native deps in `npm`/`pip`)
- A warm pnpm store directory so the codespace's first `pnpm install`
@@ -27,11 +33,16 @@ the publisher at
## Cold-start budget
+The KPI we hold ourselves to is _time-to-first-keystroke in a Codespace_,
+not _time-to-running-demo-stack_. The full demo stack still needs to
+pull multi-GB service images and start a Postgres / Redis / Kafka /
+service ladder — that is measured separately by the WS-A buyer
+acceptance gate.
+
| Phase | Budget | Source of truth |
|---|---|---|
| `docker pull` of the devcontainer image | 60 s | `PHASE_PULL_BUDGET` |
-| `pnpm install --frozen-lockfile=false` (warm store) | included in pull phase | `onCreateCommand` |
-| `pnpm aisoc:acceptance --cold` | 5 min | `PHASE_ACCEPTANCE_BUDGET` |
+| Toolchain ready (every `--version` on PATH) | 30 s | `PHASE_TOOLCHAIN_BUDGET` |
Both budgets are gated by
[`.github/workflows/devcontainer-coldstart.yml`](https://github.com/beenuar/AiSOC/blob/main/.github/workflows/devcontainer-coldstart.yml),