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
A scoreboard that can go stale loudly, and two modules go get can resolve (#738)
Beenu Arorae8ab790e34ff
diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.ymlindex 44c028de4..301d71957 100644--- a/.github/workflows/link-check.yml+++ b/.github/workflows/link-check.yml@@ -106,3 +106,11 @@ jobs:- name: Every github.com/beenuar/AiSOC link resolves to a real pathrun: python3 scripts/check_repo_self_links.py++ # The same failure shape, one layer down. Both published Go SDKs+ # declared `github.com/beenuar/aisoc/<name>` — wrong case, missing the+ # `packages/` prefix — so `go get` resolved neither. Nothing caught it+ # because every in-repo consumer used a replace directive: the tree+ # built perfectly and the published artifact did not exist.+ - name: Every published Go module path resolves+ run: python3 scripts/check_go_module_paths.pydiff --git a/.github/workflows/live-agent-eval.yml b/.github/workflows/live-agent-eval.ymlindex 01e9fc06b..3961c1a81 100644--- a/.github/workflows/live-agent-eval.yml+++ b/.github/workflows/live-agent-eval.yml@@ -42,7 +42,14 @@ on:- cron: '0 3 * * 2'permissions:- contents: read+ # `write` so this job can do the thing the docs already promised and nothing+ # implemented: append a row to the public scoreboard. It previously had+ # `read`, so even a perfectly successful run could not have published its+ # result if it tried — which is why the table sat frozen at 2026-07-13 for+ # ten weeks across three releases while the page above it advertised a+ # weekly cadence.+ contents: write+ pull-requests: writeconcurrency:group: live-agent-eval-${{ github.ref }}@@ -149,6 +156,35 @@ jobs:if-no-files-found: warnretention-days: 30+ # Substrate, and labelled as such. The row carries substrate:true and+ # eval_mode:substrate-only, and check_scoreboard's honesty check refuses+ # any other combination — appending a deterministic row must never look+ # like live-agent performance. The live half stays unpublished until+ # there is a funded provider key, which is an account action.+ - name: Append a substrate row to the public scoreboard+ if: github.event_name == 'schedule' && github.ref == 'refs/heads/main'+ run: |+ set -euo pipefail+ cd services/agents+ python3 ../../scripts/check_scoreboard.py --append+ cd ../..+ if git diff --quiet apps/docs/static/data/scoreboard.json; then+ echo "No change to append."+ exit 0+ fi+ git config user.name "aisoc-bot"+ git config user.email "[email protected]"+ BRANCH="scoreboard/$(date -u +%Y-%m-%d)"+ git checkout -b "$BRANCH"+ git add apps/docs/static/data/scoreboard.json+ git commit -m "chore(scoreboard): append substrate row for $(date -u +%Y-%m-%d)"+ git push origin "$BRANCH"+ gh pr create --base main --head "$BRANCH" \+ --title "chore(scoreboard): substrate row for $(date -u +%Y-%m-%d)" \+ --body "Appended by \`live-agent-eval.yml\`. Substrate row (deterministic, no LLM) — not live-agent performance."+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+- name: Ollama log on failureif: failure()run: tail -100 "$RUNNER_TEMP/ollama.log" || truediff --git a/ROADMAP.md b/ROADMAP.mdindex 3ab274b5a..956590d85 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -70,7 +70,7 @@ The claim-to-gate matrix stands at **108 rows — 99 GATED / 9 PARTIAL / 0 NO GA- [x] Public REST API v1 at `/api/v1`, OpenAPI 3.1 at `docs/openapi.yaml`- [x] GraphQL gateway (Strawberry) proxying REST- [x] Scoped API tokens (`cases:read`, `playbooks:run`, `plugins:install`)-- [x] Auto-generated client SDKs: `@aisoc/sdk` (TypeScript), `aisoc-sdk` (Python/PyPI), `github.com/beenuar/aisoc/sdk-go`+- [x] Auto-generated client SDKs: `@aisoc/sdk` (TypeScript), `aisoc-sdk` (Python/PyPI), `github.com/beenuar/AiSOC/packages/sdk-go`- [x] Docusaurus docs site at `docs/site/`, deployed to GitHub Pages- [x] Demo Lab: `pnpm aisoc:lab` one-command full-stack + Conti-style ransomware scenario- [x] 4 reference plugins: Okta connector, YARA enricher, Slack quarantine responder, MTTR sparkline widgetdiff --git a/apps/docs/docs/architecture/overview.md b/apps/docs/docs/architecture/overview.mdindex e478cc84c..df43edf5c 100644--- a/apps/docs/docs/architecture/overview.md+++ b/apps/docs/docs/architecture/overview.md@@ -39,10 +39,10 @@ AiSOC/│ ├── ocsf/ # OCSF normalization helpers│ ├── sdk-ts/ # TypeScript client SDK for AiSOC API (npm: @aisoc/sdk, lands in v8.0)│ ├── sdk-py/ # Async Python client SDK (PyPI: aisoc-sdk, lands in v8.0)-│ ├── sdk-go/ # Go client SDK + models (module: github.com/beenuar/aisoc/sdk-go)+│ ├── sdk-go/ # Go client SDK + models (module: github.com/beenuar/AiSOC/packages/sdk-go)│ ├── plugin-sdk-ts/ # TypeScript plugin development SDK│ ├── plugin-sdk-py/ # Python plugin development SDK (PyPI: aisoc-plugin-sdk, lands in v8.0)-│ ├── plugin-sdk-go/ # Go plugin development SDK (module: github.com/beenuar/aisoc/plugin-sdk-go)+│ ├── plugin-sdk-go/ # Go plugin development SDK (module: github.com/beenuar/AiSOC/packages/plugin-sdk-go)│ └── aisoc-cli/ # CLI: scaffold / validate / publish plugins & detections (PyPI: aisoc-cli, lands in v8.0)├── detections/ # Community Sigma detection rules (YAML) — 800+ native├── hunts/ # Hunt-as-Code YAML definitions (hypothesis + indicators + schedule)diff --git a/apps/docs/docs/plugins/go-sdk.md b/apps/docs/docs/plugins/go-sdk.mdindex e09e2444b..e023caed2 100644--- a/apps/docs/docs/plugins/go-sdk.md+++ b/apps/docs/docs/plugins/go-sdk.md@@ -7,7 +7,7 @@ sidebar_position: 3## Installation```bash-go get github.com/beenuar/aisoc/plugin-sdk-go+go get github.com/beenuar/AiSOC/packages/plugin-sdk-go```## Quick Start: Enricher@@ -17,7 +17,7 @@ package mainimport ("context"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")type IPReputationEnricher struct {diff --git a/apps/docs/static/data/scoreboard.json b/apps/docs/static/data/scoreboard.jsonindex 17e878684..8b86b1eb4 100644--- a/apps/docs/static/data/scoreboard.json+++ b/apps/docs/static/data/scoreboard.json@@ -2,6 +2,28 @@"$schema": "./scoreboard.schema.json","_readme": "Append-only public benchmark scoreboard. Each row is one eval run. Substrate rows (no LLM, deterministic) are marked substrate:true and MUST NOT be quoted as live agent performance. Wet-eval rows (substrate:false) are appended by the T5.5 weekly CI workflow once it lands. Newest row first.","rows": [+ {+ "date": "2026-09-23",+ "agent_version": "v8.1.1",+ "commit_sha": "4ea86852",+ "substrate": true,+ "eval_mode": "substrate-only",+ "mitre_accuracy": 0.97,+ "mitre_accuracy_per_template": 0.964,+ "alert_reduction": 0.753,+ "investigation_completeness": 0.942,+ "response_quality": 1.0,+ "playbook_completion_rate": 0.505,+ "mtc_p50_seconds": null,+ "mtc_p95_seconds": null,+ "tokens_total": 0,+ "usd_total": 0.0,+ "tokens_mean_per_investigation": 0,+ "usd_mean_per_investigation": 0.0,+ "rate_card_model": "deterministic",+ "rate_card_dated": "2026-07",+ "notes": "Phase E1 — per-PR deterministic substrate gate, CI-enforced by scripts/check_scoreboard.py: the live LangGraph agent runs its tactic prediction over the 200-incident corpus with NO LLM (deterministic tier), and this row's mitre_accuracy must match a fresh CI run within 0.02 or CI fails. tokens/USD are 0 because the deterministic tier makes no LLM calls. Live-LLM (substrate:false) rows with real token/USD/latency come from the funded weekly wet-eval.yml job. Do not quote this substrate row as live-agent-with-LLM performance."+ },{"date": "2026-07-13","agent_version": "v7.5.0",@@ -30,11 +52,11 @@"commit_sha": "4ff1b7f4","substrate": true,"eval_mode": "substrate-only",- "mitre_accuracy": 0.970,+ "mitre_accuracy": 0.97,"mitre_accuracy_per_template": 0.964,"alert_reduction": 0.753,"investigation_completeness": 0.942,- "response_quality": 1.000,+ "response_quality": 1.0,"playbook_completion_rate": 0.505,"mtc_p50_seconds": null,"mtc_p95_seconds": null,diff --git a/packages/plugin-sdk-go/README.md b/packages/plugin-sdk-go/README.mdindex 52692a038..c7a9b4280 100644--- a/packages/plugin-sdk-go/README.md+++ b/packages/plugin-sdk-go/README.md@@ -6,7 +6,7 @@ actions, and data-source connectors.## Installation```bash-go get github.com/beenuar/aisoc/plugin-sdk-go+go get github.com/beenuar/AiSOC/packages/plugin-sdk-go```## Quick Start@@ -18,7 +18,7 @@ package mainimport ("context"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")type VTEnricher struct{ aisoc.BasePlugin }diff --git a/packages/plugin-sdk-go/aisoc/client_test.go b/packages/plugin-sdk-go/aisoc/client_test.goindex ee4a9fbcb..2c11603ee 100644--- a/packages/plugin-sdk-go/aisoc/client_test.go+++ b/packages/plugin-sdk-go/aisoc/client_test.go@@ -7,7 +7,7 @@ import ("net/http/httptest""testing"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// newTestServer returns a test HTTP server that handles the given pattern.diff --git a/packages/plugin-sdk-go/aisoc/loader_test.go b/packages/plugin-sdk-go/aisoc/loader_test.goindex 02b6d10eb..cc42879c0 100644--- a/packages/plugin-sdk-go/aisoc/loader_test.go+++ b/packages/plugin-sdk-go/aisoc/loader_test.go@@ -7,7 +7,7 @@ import ("path/filepath""testing"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")func writeManifest(t *testing.T, dir string, content map[string]any) {diff --git a/packages/plugin-sdk-go/aisoc/registry_test.go b/packages/plugin-sdk-go/aisoc/registry_test.goindex dd844b007..3649a7029 100644--- a/packages/plugin-sdk-go/aisoc/registry_test.go+++ b/packages/plugin-sdk-go/aisoc/registry_test.go@@ -4,7 +4,7 @@ import ("context""testing"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// ── mock enricher ──────────────────────────────────────────────────────────diff --git a/packages/plugin-sdk-go/examples/enricher/main.go b/packages/plugin-sdk-go/examples/enricher/main.goindex 17da32e69..8beca36ee 100644--- a/packages/plugin-sdk-go/examples/enricher/main.go+++ b/packages/plugin-sdk-go/examples/enricher/main.go@@ -6,7 +6,7 @@ import ("fmt""log"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// IPReputationEnricher checks a fictional reputation API.diff --git a/packages/plugin-sdk-go/go.mod b/packages/plugin-sdk-go/go.modindex 4db140f51..1d9688192 100644--- a/packages/plugin-sdk-go/go.mod+++ b/packages/plugin-sdk-go/go.mod@@ -1,3 +1,3 @@-module github.com/beenuar/aisoc/plugin-sdk-go+module github.com/beenuar/AiSOC/packages/plugin-sdk-gogo 1.26diff --git a/packages/sdk-go/go.mod b/packages/sdk-go/go.modindex 05da32be9..0a01e15ee 100644--- a/packages/sdk-go/go.mod+++ b/packages/sdk-go/go.mod@@ -1,3 +1,3 @@-module github.com/beenuar/aisoc/sdk-go+module github.com/beenuar/AiSOC/packages/sdk-gogo 1.26diff --git a/plugins/cloudflare-waf/go/main.go b/plugins/cloudflare-waf/go/main.goindex 5999ac5bf..0e26ee766 100644--- a/plugins/cloudflare-waf/go/main.go+++ b/plugins/cloudflare-waf/go/main.go@@ -15,7 +15,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")const apiBase = "https://api.cloudflare.com/client/v4"diff --git a/plugins/datadog-incidents/go/main.go b/plugins/datadog-incidents/go/main.goindex 327592186..3bbb81802 100644--- a/plugins/datadog-incidents/go/main.go+++ b/plugins/datadog-incidents/go/main.go@@ -10,7 +10,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// DatadogConnector implements aisoc.Connector for the Datadog Incidents/Signals APIs.diff --git a/plugins/github-audit/go/main.go b/plugins/github-audit/go/main.goindex 687af4413..349f78a78 100644--- a/plugins/github-audit/go/main.go+++ b/plugins/github-audit/go/main.go@@ -15,7 +15,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// GitHubAuditConnector implements aisoc.Connector against the GitHub Audit Log API.diff --git a/plugins/gitlab-audit/go/main.go b/plugins/gitlab-audit/go/main.goindex 428822e28..dcfe94a16 100644--- a/plugins/gitlab-audit/go/main.go+++ b/plugins/gitlab-audit/go/main.go@@ -12,7 +12,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// GitLabConnector implements aisoc.Connector for the GitLab audit events API.diff --git a/plugins/jamf-mdm/go/main.go b/plugins/jamf-mdm/go/main.goindex 61d930af1..401d541f5 100644--- a/plugins/jamf-mdm/go/main.go+++ b/plugins/jamf-mdm/go/main.go@@ -20,7 +20,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// JamfConnector implements the aisoc.Connector interface for Jamf Pro.diff --git a/plugins/mttr-widget/go/main.go b/plugins/mttr-widget/go/main.goindex d579d5e33..62f102073 100644--- a/plugins/mttr-widget/go/main.go+++ b/plugins/mttr-widget/go/main.go@@ -22,7 +22,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")const defaultAPIBase = "http://api:8000"diff --git a/plugins/notion-incidents/go/main.go b/plugins/notion-incidents/go/main.goindex 1abd1135d..373524cc8 100644--- a/plugins/notion-incidents/go/main.go+++ b/plugins/notion-incidents/go/main.go@@ -11,7 +11,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")const apiBase = "https://api.notion.com/v1"diff --git a/plugins/okta-connector/go/main.go b/plugins/okta-connector/go/main.goindex 38f73c08c..3b11ff792 100644--- a/plugins/okta-connector/go/main.go+++ b/plugins/okta-connector/go/main.go@@ -17,7 +17,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// OktaConnector is a connector + action plugin for the Okta Identity Cloud.diff --git a/plugins/onepassword-events/go/main.go b/plugins/onepassword-events/go/main.goindex be09290eb..2e04bdf39 100644--- a/plugins/onepassword-events/go/main.go+++ b/plugins/onepassword-events/go/main.go@@ -14,7 +14,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")var regionHosts = map[string]string{diff --git a/plugins/pagerduty-paging/go/main.go b/plugins/pagerduty-paging/go/main.goindex 426e42b94..7e29a3bc3 100644--- a/plugins/pagerduty-paging/go/main.go+++ b/plugins/pagerduty-paging/go/main.go@@ -11,7 +11,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")const eventsURL = "https://events.pagerduty.com/v2/enqueue"diff --git a/plugins/slack-quarantine/go/main.go b/plugins/slack-quarantine/go/main.goindex ece71d848..76319f2f1 100644--- a/plugins/slack-quarantine/go/main.go+++ b/plugins/slack-quarantine/go/main.go@@ -11,7 +11,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// SlackQuarantineNotifier implements aisoc.Action for Slack-based response comms.diff --git a/plugins/snowflake-events/go/main.go b/plugins/snowflake-events/go/main.goindex 92039b3e3..aa9ebafe7 100644--- a/plugins/snowflake-events/go/main.go+++ b/plugins/snowflake-events/go/main.go@@ -13,7 +13,7 @@ import ("fmt""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc"// _ "github.com/snowflakedb/gosnowflake")diff --git a/plugins/tailscale-acl/go/main.go b/plugins/tailscale-acl/go/main.goindex c52e9b988..1ee95a28d 100644--- a/plugins/tailscale-acl/go/main.go+++ b/plugins/tailscale-acl/go/main.go@@ -13,7 +13,7 @@ import ("net/http""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")const tsAPIBase = "https://api.tailscale.com/api/v2"diff --git a/plugins/twilio-sms/go/main.go b/plugins/twilio-sms/go/main.goindex a6eeaf747..8b1d6c1c1 100644--- a/plugins/twilio-sms/go/main.go+++ b/plugins/twilio-sms/go/main.go@@ -12,7 +12,7 @@ import ("strings""time"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// TwilioAction implements aisoc.Action for sending SMS via Twilio.diff --git a/plugins/yara-enricher/go/main.go b/plugins/yara-enricher/go/main.goindex f6e2c8baf..1f6bce9e9 100644--- a/plugins/yara-enricher/go/main.go+++ b/plugins/yara-enricher/go/main.go@@ -15,7 +15,7 @@ import ("path/filepath""strings"- "github.com/beenuar/aisoc/plugin-sdk-go/aisoc"+ "github.com/beenuar/AiSOC/packages/plugin-sdk-go/aisoc")// YaraEnricher implements aisoc.Enricher for file-based YARA scanning.diff --git a/scripts/check_go_module_paths.py b/scripts/check_go_module_paths.pynew file mode 100755index 000000000..b61039e05--- /dev/null+++ b/scripts/check_go_module_paths.py@@ -0,0 +1,81 @@+#!/usr/bin/env python3+"""Every published Go module must declare a path `go get` can resolve.++Both published SDKs declared `github.com/beenuar/aisoc/<name>`:++ * wrong case — the repository is `AiSOC`, and Go module paths are+ case-sensitive against the VCS path;+ * missing the `packages/` prefix — the directory the module lives in.++So `go get github.com/beenuar/aisoc/sdk-go` resolved to nothing, and neither+SDK was installable by anyone outside this repository. Nothing caught it+because every in-repo consumer used a `replace` directive or a relative+import, which is exactly the shape that hides a broken published path: the+tree builds perfectly and the artifact does not exist.++This is a path check, not a network check. It runs offline and deterministically+and asserts the declared module path matches where the directory actually is.+"""++from __future__ import annotations++import re+import sys+from pathlib import Path++ROOT = Path(__file__).resolve().parent.parent++#: The canonical repository path, matching the GitHub org and repo casing.+REPO_PATH = "github.com/beenuar/AiSOC"++#: Directories whose modules are published for external consumption. A module+#: under services/ is internal to a deployable image and is not `go get`-able+#: by design, so only these are checked.+PUBLISHED_ROOTS = ("packages",)++_MODULE_RE = re.compile(r"^module\s+(\S+)", re.MULTILINE)+++def declared_path(go_mod: Path) -> str | None:+ match = _MODULE_RE.search(go_mod.read_text(encoding="utf-8"))+ return match.group(1) if match else None+++def expected_path(go_mod: Path) -> str:+ return f"{REPO_PATH}/{go_mod.parent.relative_to(ROOT).as_posix()}"+++def main() -> int:+ problems: list[str] = []+ checked = 0++ for root in PUBLISHED_ROOTS:+ for go_mod in sorted((ROOT / root).rglob("go.mod")):+ if "node_modules" in go_mod.parts:+ continue+ checked += 1+ declared = declared_path(go_mod)+ expected = expected_path(go_mod)+ rel = go_mod.relative_to(ROOT)++ if declared is None:+ problems.append(f"{rel}: no `module` directive")+ elif declared != expected:+ problems.append(+ f"{rel}: declares `{declared}` but lives at `{expected}`. "+ "`go get` resolves the module path against the VCS path, and it is "+ "case-sensitive, so this module is not installable."+ )++ if problems:+ print("GO MODULE PATH GATE FAILED:", file=sys.stderr)+ for problem in problems:+ print(f" - {problem}", file=sys.stderr)+ return 1++ print(f"OK: {checked} published Go module path(s) resolve against {REPO_PATH}.")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/scripts/check_scoreboard.py b/scripts/check_scoreboard.pyindex 84d2e398f..58543843b 100644--- a/scripts/check_scoreboard.py+++ b/scripts/check_scoreboard.py@@ -34,6 +34,7 @@ from __future__ import annotationsimport argparseimport jsonimport sys+from datetime import datefrom pathlib import PathROOT = Path(__file__).resolve().parent.parent@@ -59,11 +60,60 @@ def _load() -> dict:return json.loads(SCOREBOARD.read_text(encoding="utf-8"))+#: How stale the published scoreboard may be before this gate fails.+#:+#: The page above the table says rows are appended weekly. It sat frozen at+#: 2026-07-13 / v7.5.0 for ten weeks across three releases and **every check+#: in the repository passed throughout**, because "freshness" here meant the+#: accuracy *value* was current and nothing ever read the row's date.+#:+#: 45 days rather than 7: the weekly job needs a funded provider key it does+#: not have, so a 7-day ceiling would red `main` permanently for a reason no+#: contributor can fix, and a gate people route around is worse than none.+#: This catches the failure that actually happened — a scoreboard going stale+#: for a season while claiming to be weekly.+MAX_SCOREBOARD_AGE_DAYS = 45++def _newest_substrate_row(data: dict) -> dict | None:- for row in data.get("rows", []):- if row.get("substrate") is True:- return row- return None+ """The newest substrate row *by date*, not by position in the file.++ This used to return the first row with ``substrate: true`` and the file+ is only conventionally newest-first, so a row appended in the wrong place+ would have silently become the one every check measured.+ """+ substrate = [row for row in data.get("rows", []) if row.get("substrate") is True]+ if not substrate:+ return None+ return max(substrate, key=lambda row: str(row.get("date", "")))+++def _newest_row(data: dict) -> dict | None:+ rows = data.get("rows", [])+ return max(rows, key=lambda row: str(row.get("date", ""))) if rows else None+++def _staleness_errors(data: dict, today: date | None = None) -> list[str]:+ """Fail when the published table has gone quiet while promising weekly rows."""+ newest = _newest_row(data)+ if newest is None:+ return ["scoreboard has no rows at all"]++ raw = str(newest.get("date", ""))+ try:+ newest_date = date.fromisoformat(raw)+ except ValueError:+ return [f"newest row has an unparseable date: {raw!r}"]++ age = ((today or date.today()) - newest_date).days+ if age <= MAX_SCOREBOARD_AGE_DAYS:+ return []+ return [+ f"the newest scoreboard row is {age} days old ({raw}), over the "+ f"{MAX_SCOREBOARD_AGE_DAYS}-day ceiling. The benchmark page says rows are "+ "appended weekly. Either append a run, or change what the page claims — "+ "a table that has gone quiet for a season must not keep advertising a cadence."+ ]def _validate_schema(data: dict) -> list[str]:@@ -98,7 +148,7 @@ def check() -> int:print(f"ERROR: {SCOREBOARD.relative_to(ROOT)} missing", file=sys.stderr)return 1data = _load()- errors = _validate_schema(data) + _validate_honesty(data)+ errors = _validate_schema(data) + _validate_honesty(data) + _staleness_errors(data)row = _newest_substrate_row(data)if row is None:@@ -131,16 +181,97 @@ def refresh() -> int:return 1live = _live_accuracy()row["mitre_accuracy"] = live+ # Re-stamp the row. --refresh rewrote only the accuracy, so a refreshed+ # row kept a months-old date and commit_sha: the number described today's+ # code and the row said it was measured in July. That is a worse claim+ # than a stale number, because it looks current.+ row["date"] = date.today().isoformat()+ row["commit_sha"] = _head_sha() or row.get("commit_sha", "")+ row["agent_version"] = _tree_version() or row.get("agent_version", "")+ SCOREBOARD.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")+ print(f"refreshed newest substrate row -> accuracy {live}, dated {row['date']}, {row['commit_sha']}")+ return 0+++def _head_sha() -> str:+ """Short HEAD sha, or empty when git is unavailable."""+ import subprocess # noqa: PLC0415 — only needed on the refresh path++ try:+ out = subprocess.run(+ ["git", "rev-parse", "--short=8", "HEAD"],+ capture_output=True,+ text=True,+ check=True,+ cwd=ROOT,+ )+ except (OSError, subprocess.CalledProcessError):+ return ""+ return out.stdout.strip()+++def _tree_version() -> str:+ """The version in the working tree, not a remembered one."""+ version_file = ROOT / "VERSION"+ if not version_file.exists():+ return ""+ return "v" + version_file.read_text(encoding="utf-8").strip()+++def append() -> int:+ """Append one substrate row from a fresh deterministic run.++ The scoreboard had no writer at all. `wet-eval.yml` rewrites+ `benchmark.md` and a snapshot file and never touches `scoreboard.json`;+ `live-agent-eval.yml` runs a real Ollama-hosted agent and has+ `permissions: contents: read`, so it could not have written one if it+ tried. The docs promise an auto-PR appending a row, and nothing+ implements it. That is why the table sat frozen for ten weeks across+ three releases with every check passing.++ This is the substrate half only, and it is labelled as such — the row+ carries `substrate: true` and `eval_mode: substrate-only`, and the+ honesty check refuses any other combination. Appending a substrate row+ does not and must not look like live-agent performance.+ """+ data = _load()+ rows = data.setdefault("rows", [])+ today = date.today().isoformat()+ sha = _head_sha()++ # (date, commit_sha) is the row key. Re-running on the same commit on the+ # same day is a no-op rather than a duplicate.+ if any(r.get("date") == today and r.get("commit_sha") == sha for r in rows):+ print(f"OK: a row for {today} @ {sha} already exists; nothing appended")+ return 0++ template = _newest_substrate_row(data)+ if template is None:+ print("ERROR: no existing substrate row to take a shape from", file=sys.stderr)+ return 1++ row = dict(template)+ row["date"] = today+ row["commit_sha"] = sha+ row["agent_version"] = _tree_version() or row.get("agent_version", "")+ row["mitre_accuracy"] = _live_accuracy()+ row["substrate"] = True+ row["eval_mode"] = "substrate-only"++ rows.insert(0, row)SCOREBOARD.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")- print(f"refreshed newest substrate row mitre_accuracy -> {live}")+ print(f"appended substrate row {today} @ {sha}: mitre_accuracy={row['mitre_accuracy']}")return 0def main() -> int:parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--append", action="store_true", help="append a substrate row from a fresh run")parser.add_argument("--refresh", action="store_true", help="rewrite the newest substrate row's mitre_accuracy")parser.add_argument("--check", action="store_true", help="validate + freshness-gate (default action)")args = parser.parse_args()+ if args.append:+ return append()return refresh() if args.refresh else check()