interplane.Get Omega
Read in your language

aien-receipts

Append-only AIEN verification receipts, indexed by repository and exact source commit. Read verdicts, signatures and retained logs before making a claim.

Brought by drakestapleton

GitHub aien-dev/aien-receipts#7 (code only)

closed derived 54d2d7fbb1ae9f22 #7

Imported from GitHub aien-dev/aien-receipts#7 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base ffe7e0747f37c56f963d04c6dc2c4b77ffaccd02 · Head f8c977577a44b3a5bad9ee15bee85b1375d58a38

Fetch it

A git bundle of the pull request's head, 61472 bytes.

curl -fsSL https://interplane.io/drakestapleton/aien-receipts/patches/54d2d7fbb1ae9f22.bundle -o 54d2d7fbb1ae9f22.bundle
git fetch 54d2d7fbb1ae9f22.bundle refs/pull/7/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-receipts
7
f8c977577a44b3a5bad9ee15bee85b1375d58a38
{"kind":"github-import","owner":"aien-dev","repo":"aien-receipts","number":7,"url":"https://github.com/aien-dev/aien-receipts/pull/7","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:40Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/audit-attest.yml b/.github/workflows/audit-attest.yml
new file mode 100644
index 0000000..cc2c838
--- /dev/null
+++ b/.github/workflows/audit-attest.yml
@@ -0,0 +1,81 @@
+# Org audit stamps: re-check every new stamp on a GitHub-hosted runner, then sign it.
+# Scope (ADR 0033 addendum, aien-dev/aien-architecture-mv#337): runs only for audit/stamps/**.
+# A stamp is attested only when stamp.py validates it and, for public repositories,
+# verify.py reproduces every reproducible check output byte for byte at the stamped commit.
+name: audit-attest
+
+on:
+  push:
+    branches: [main]
+    paths: ["audit/stamps/**"]
+
+permissions: {}
+
+concurrency:
+  group: audit-attest
+  cancel-in-progress: false
+
+jobs:
+  attest:
+    runs-on: ubuntu-24.04
+    timeout-minutes: 120
+    permissions:
+      contents: read
+      id-token: write       # Sigstore signing identity for the attestation
+      attestations: write   # store the attestation on this repository
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
+        with:
+          python-version: "3.12"
+      - name: Install pinned tools (sha256-checked against audit/tools/tools.lock.json)
+        run: python3 audit/tools/install_tools.py "$RUNNER_TEMP/tools"
+      - name: Tests
+        run: python3 -m unittest discover -s audit/tests
+        env:
+          AUDIT_TOOLS: ${{ runner.temp }}/tools
+      - name: Re-check new stamps
+        id: check
+        env:
+          BEFORE: ${{ github.event.before }}
+          AFTER: ${{ github.sha }}
+          AUDIT_TOOLS: ${{ runner.temp }}/tools
+        run: |
+          set -euo pipefail
+          git diff --name-only --diff-filter=AM "$BEFORE" "$AFTER" -- audit/stamps \
+            | awk -F/ 'NF >= 5 { print $1 "/" $2 "/" $3 "/" $4 }' | sort -u > "$RUNNER_TEMP/stamps.txt"
+          : > "$RUNNER_TEMP/subjects.txt"
+          while read -r d; do
+            [ -f "$d/stamp.json" ] || { echo "::error::$d has files but no stamp.json"; exit 1; }
+            vis=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["subject"]["visibility"])' "$d/stamp.json")
+            if [ "$vis" = public ]; then
+              repo=$(basename "$(dirname "$d")"); sha=$(basename "$d")
+              gd="$RUNNER_TEMP/src/$repo"
+              git init -q "$gd"
+              git -C "$gd" fetch -q "https://github.com/${GITHUB_REPOSITORY_OWNER}/$repo" "$sha"
+              git -C "$gd" worktree add -q --detach "$gd-wt" "$sha"
+              python3 audit/tools/verify.py "$d" --rerun "$gd" --worktree "$gd-wt" --tools "$AUDIT_TOOLS"
+            else
+              # private: nobody outside can re-run it; validated and signed as self-reported
+              python3 audit/tools/verify.py "$d"
+            fi
+            find "$d" -type f | sort >> "$RUNNER_TEMP/subjects.txt"
+          done < "$RUNNER_TEMP/stamps.txt"
+          if [ -s "$RUNNER_TEMP/subjects.txt" ]; then
+            echo "any=true" >> "$GITHUB_OUTPUT"
+          else
+            echo "any=false" >> "$GITHUB_OUTPUT"
+          fi
+          {
+            echo "subjects<<EOF"
+            cat "$RUNNER_TEMP/subjects.txt"
+            echo "EOF"
+          } >> "$GITHUB_OUTPUT"
+      - name: Sign
+        if: steps.check.outputs.any == 'true'
+        uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
+        with:
+          subject-path: ${{ steps.check.outputs.subjects }}
diff --git a/.github/workflows/audit-refresh.yml b/.github/workflows/audit-refresh.yml
new file mode 100644
index 0000000..3f819a3
--- /dev/null
+++ b/.github/workflows/audit-refresh.yml
@@ -0,0 +1,72 @@
+# Org audit refresh: mark stamps STALE when a repository's default-branch HEAD moves past the
+# stamped commit, and recount the public lines of code at every HEAD.
+# Scope (ADR 0033 addendum, aien-dev/aien-architecture-mv#337): this job may change exactly
+# audit/status.json, audit/loc/latest.json and audit/loc/history.jsonl; it fails without
+# pushing if anything else changed. Existing receipt bundles are never touched.
+name: audit-refresh
+
+on:
+  schedule:
+    - cron: "17 5 * * *"
+  workflow_dispatch:
+
+permissions: {}
+
+concurrency:
+  group: audit-refresh
+  cancel-in-progress: false
+
+jobs:
+  refresh:
+    runs-on: ubuntu-24.04
+    timeout-minutes: 180
+    permissions:
+      contents: write   # push the three mutable audit files to main
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with:
+          persist-credentials: false
+      - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
+        with:
+          python-version: "3.12"
+      - name: Install pinned scc (sha256-checked against audit/tools/tools.lock.json)
+        run: python3 audit/tools/install_tools.py "$RUNNER_TEMP/tools" --only scc
+      - name: Stamp status
+        run: |
+          set -uo pipefail
+          python3 audit/tools/status.py audit/stamps --out audit/status.json --org "$GITHUB_REPOSITORY_OWNER"
+          rc=$?
+          # 3 = some HEAD could not be read; those rows say UNKNOWN, which is still worth publishing
+          [ "$rc" -eq 0 ] || [ "$rc" -eq 3 ] || exit "$rc"
+      - name: Live line count
+        env:
+          GITHUB_TOKEN: ${{ github.token }}
+        run: |
+          set -uo pipefail
+          python3 audit/tools/loc_live.py --config audit/loc/repos.json --tools "$RUNNER_TEMP/tools" \
+            --latest audit/loc/latest.json --history audit/loc/history.jsonl
+          rc=$?
+          # 3 = some repository NOT_COUNTED; latest.json lists it with the reason
+          [ "$rc" -eq 0 ] || [ "$rc" -eq 3 ] || exit "$rc"
+      - name: Refuse changes outside the three mutable files
+        run: |
+          set -euo pipefail
+          git status --porcelain --untracked-files=all | cut -c4- | sort > "$RUNNER_TEMP/changed.txt"
+          printf '%s\n' audit/loc/history.jsonl audit/loc/latest.json audit/status.json > "$RUNNER_TEMP/allowed.txt"
+          extra=$(comm -23 "$RUNNER_TEMP/changed.txt" "$RUNNER_TEMP/allowed.txt")
+          if [ -n "$extra" ]; then
+            echo "::error::refresh touched files outside its scope:"; echo "$extra"; exit 1
+          fi
+      - name: Commit and push
+        env:
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          set -euo pipefail
+          if git diff --quiet && [ -z "$(git status --porcelain)" ]; then echo "no change"; exit 0; fi
+          git config user.name "github-actions[bot]"
+          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+          git add audit/status.json audit/loc/latest.json audit/loc/history.jsonl
+          git commit -q -m "audit: refresh stamp status and live line count"
+          auth=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 -w0)
+          echo "::add-mask::$auth"
+          git -c http.extraheader="AUTHORIZATION: basic $auth" push origin HEAD:main
diff --git a/AGENTS.md b/AGENTS.md
index 7f5df6c..99c009a 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,6 +1,6 @@
 # aien-receipts (append-only shelf of signed AIEN verification bundles)
 
-> Data-only repository. When the Spark judge (the verification pipeline on the project's NVIDIA DGX Spark) checks a commit of an `aien-dev` repository, it signs the result and publishes it here as `<repo>/<sha>/bundle.json`. Consuming repositories verify a bundle with `aien-test verify-bundle` against the public key and gate list on their own base branch. There is no code, no build and no workflow in this repository.
+> Data-only repository. When the Spark judge (the verification pipeline on the project's NVIDIA DGX Spark) checks a commit of an `aien-dev` repository, it signs the result and publishes it here as `<repo>/<sha>/bundle.json`. Consuming repositories verify a bundle with `aien-test verify-bundle` against the public key and gate list on their own base branch. Bundles have no code, no build and no workflow. The one exception is the org audit under `audit/` (see below).
 
 Shared rules: read https://www.aienos.com/agents/RULES.md first. This file adds what is specific to this repository; where the two differ, this file wins here.
 
@@ -39,7 +39,7 @@ To verify a bundle, follow `docs/verify-one-bundle.md`: it clones the shelf, the
 
 - Append only. A bundle for a given `<repo>/<sha>` is published once and never rewritten. This is a convention: the `main` ruleset blocks force pushes and branch deletion, not edits.
 - A new verification of the same commit must carry the same bytes.
-- No workflows run here. Do not add `.github/workflows` or any other CI.
+- Workflows are allowed only for the org audit under `audit/`: `.github/workflows/audit-attest.yml` (signs stamps) and `.github/workflows/audit-refresh.yml` (marks stamps STALE, recounts lines of code). The owner approved this on 2026-10-26; the scope is recorded in the ADR 0033 addendum (aien-dev/aien-architecture-mv#337). No other workflow or CI may be added, and no workflow may touch a bundle. The refresh job writes only `audit/status.json`, `audit/loc/latest.json` and `audit/loc/history.jsonl`. Read `audit/README.md` before changing anything under `audit/`.
 - When reasoning about a bundle, use the trust anchors from the consuming repository's base branch. Never use a key that appears only inside a bundle.
 - The verdict of record is the Spark's commit status `AIEN Verification (Spark)`. A hosted check named `AIEN Verification` only bridges to it; green there means the bridge ran, not that the commit passed. A valid signature authenticates the recorded statement, not the correctness or sufficiency of the tests behind it.
 - When citing a bundle in a claim, quote its path and the `backend` of its checks. A `host` backend means the gate ran on the host, not on the GPU.
diff --git a/README.md b/README.md
index 3f3f1e2..b0bdeb3 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@ verification pipeline on the project's NVIDIA DGX Spark) checks a commit, it sig
 publishes that bundle here. Readers can verify its signature, commit binding, declared gate
 verdicts and receipt digests. This shelf does **not** contain the underlying per-gate receipt
 bodies, commands, stdout, stderr or raw logs; a signature alone cannot re-run or audit the tests.
-This repository holds data only: no code, no workflows, no secrets.
+This repository holds data only: no code, no workflows, no secrets. The single exception is the
+org audit under [`audit/`](audit/README.md), which carries its own checker and two workflows.
 
 Supports [Sovereign Intelligence (SI)](https://github.com/aien-dev/sovereign-intelligence).
 Every claim the project makes is meant to resolve to a bundle on this shelf.
@@ -74,7 +75,8 @@ Neither a signature-only check nor a green advisory PR check replaces the full s
 - Append only (a convention: the branch has no protection rule that enforces it). A bundle for a
   given `<repo>/<sha>` is published once and never rewritten.
   A new verification of the same commit is a new commit here that must carry the same bytes.
-- No workflows run in this repository.
+- No workflows run on the bundles. The only workflows are the two org-audit jobs scoped to
+  `audit/` (approved by the owner on 2026-10-26; ADR 0033 addendum, aien-dev/aien-architecture-mv#337).
 - Published by the AIEN verification pipeline on the DGX Spark; see the `aien-architecture`
   repository for the pipeline doctrine (ADR 0033, manifest v2).
 
diff --git a/audit/README.md b/audit/README.md
new file mode 100644
index 0000000..fb25414
--- /dev/null
+++ b/audit/README.md
@@ -0,0 +1,181 @@
+# Org audit of aien-dev
+
+> "We believe that an open source community is only as open as we are, as transparent as we are.
+> Transparency will set us free." (the project owner, 2026-10-26)
+
+This directory publishes what has been checked in every `aien-dev` repository, what has not, and
+how anyone can re-check it. It is separate from the signed Spark bundles in the rest of this
+repository: nothing here edits or replaces a bundle.
+
+Scope and approval: the owner approved workflows for this subtree on 2026-10-26. The scope is recorded in
+the ADR 0033 addendum, aien-dev/aien-architecture-mv#337. Until that addendum merges, this subtree
+is a proposal.
+
+## What a stamp says, and what it does not
+
+A stamp (`stamps/<repo>/<sha>/stamp.json`) describes one commit. It keeps two kinds of evidence apart:
+
+- **DETERMINISTIC-CHECKED**: tools in `tools/tools.lock.json`, pinned by version and SHA-256, run by
+  `tools/checks.py`. Each check records tool, version, command and the SHA-256 of its output, so
+  anyone can re-run it (see [VERIFY.md](VERIFY.md)).
+- **MODEL-REVIEWED**: a named model at a named effort read a stated number of files. Each review
+  records the files covered out of the total and the SHA-256 of its report. A model review is an
+  opinion with evidence, not a proof; partial coverage is shown as partial.
+
+Verdicts are `PASS`, `PASS-WITH-NOTES` or `FAIL`, plus a list of NOT_RUN items. `tools/stamp.py`
+refuses a stamp that claims a better verdict than its own contents allow: an open high or critical
+finding forces `FAIL`; any NOT_RUN item, incomplete check, untriaged hit, open finding, incomplete
+review or missing review caps it at `PASS-WITH-NOTES`.
+
+Upstream forks are `UPSTREAM-FORK`, pinned to the upstream merge-base; only our diff is checked and
+reviewed. The 11 private repositories appear only as `private-01` .. `private-11` with a salted
+SHA-256 commitment; their stamps are self-reported, because nobody outside can re-run them.
+
+## Checks
+
+| Id | Check | Tool |
+|---|---|---|
+| C1 | secrets in the full history | gitleaks (`--redact`) |
+| C2 | root LICENSE, SPDX headers and package-manifest licence fields agree (by licence family) | checks.py |
+| C3 | home paths, private and CGNAT IPv4 addresses, non-noreply e-mail addresses (e-mail and IP values hashed in the output) | checks.py |
+| C4 | relative Markdown links resolve at the commit | checks.py |
+| C5 | static analysis | semgrep with rules pinned by commit (config rebuilt by `tools/semgrep_config.py`, SHA-256 in the lock) |
+| C6 | GitHub workflow hygiene | actionlint, zizmor |
+| C8 | status words (PASS, QUALIFIED, DEPLOYED ...) with nothing cited on the same line | checks.py |
+| C9 | committed crumb data equals what `crumb compile` writes | crumb, built from pinned source |
+| C11 | known advisories in lock files (live database, dated, not byte-reproducible) | osv-scanner |
+
+`FLAGGED` means the tool reported something that a person still has to triage; it is not a finding
+until triaged. `INCOMPLETE` means the tool did not cover every file (for example a semgrep parse
+error); it never counts as a pass.
+
+## Coverage on 2026-10-26
+
+No stamp is published yet. The table is the state of the working run behind the first stamps,
+each repository at its default-branch HEAD on 2026-10-26: C2 and C4 from checker
+`aien-audit-checks/3` (nested licences, SPDX header grammar, full-tree link resolution), every
+other column from `aien-audit-checks/2`. P = PASS, F = FLAGGED, I = INCOMPLETE, N = NOT_RUN.
+A FLAGGED cell is raw tool output; per-item triage (false positive, accepted, defect, patched)
+happens before a stamp and is recorded in the stamp, not in this table.
+
+| Repository | Kind | Commit | C1 | C2 | C3 | C4 | C5 | C6 | C8 | C9 | C11 | Model review |
+|---|---|---|---|---|---|---|---|---|---|---|---|---|
+| .github | FIRST-PARTY | `2a9e2282ef9a` | P | P | F | F | P | P | F | P | P | NONE |
+| aegis-runtime-mv | FIRST-PARTY | `a39788b0eaaa` | P | P | F | F | I | F | F | P | F | NONE |
+| agent-archive | FIRST-PARTY | `e102eb6bf343` | P | P | P | P | P | P | P | F | P | NONE |
+| aien-architecture-mv | FIRST-PARTY | `fabf7b765a29` | F | F | F | F | I | F | F | P | P | NONE |
+| aien-edge | FIRST-PARTY | `fce984350062` | P | P | F | P | P | P | P | P | F | NONE |
+| aien-harness | ARCHIVED | `2da4b5a3a010` | P | P | F | P | F | F | F | P | P | NONE |
+| aien-local-stack | ARCHIVED | `2ef0b913657d` | P | P | P | P | F | F | P | P | F | NONE |
+| aien-protocols-mv | FIRST-PARTY | `f3785177fcaa` | P | P | F | P | I | F | P | P | F | NONE |
+| aien-receipts | FIRST-PARTY | `2998d9888292` | F | P | P | P | P | P | F | P | P | NONE |
+| aien-rig | FIRST-PARTY | `2a9bef612b59` | P | P | P | P | P | P | P | P | P | NONE |
+| aien-sovereign-core-mv | FIRST-PARTY | `f30eb963918d` | F | P | F | F | I | F | F | P | F | NONE |
+| aien-train | FIRST-PARTY | `b6c33e3a8261` | P | P | P | P | P | P | P | P | P | NONE |
+| aien-translate | FIRST-PARTY | `fc09dfe90e01` | P | P | P | P | F | P | P | P | P | NONE |
+| aien-yardsticks | ARCHIVED | `6c66814788b5` | P | F | F | P | F | P | P | F | P | NONE |
+| aienix | FIRST-PARTY | `292a38cd0357` | P | P | P | P | P | P | P | F | P | NONE |
+| AienOS-nv | FIRST-PARTY | `240ee9affd10` | P | P | F | P | F | P | P | P | P | NONE |
+| aienos.com | FIRST-PARTY | `8139afd7e231` | F | P | F | P | I | F | P | F | P | PARTIAL: live-site security survey (no shell; several items NOT_RUN); source tree not model-reviewed |
+| aienux | FIRST-PARTY | `659ddd2d7e3e` | F | P | F | P | I | F | F | F | P | PARTIAL: 8 slices planned; 1F, 2F, 2O failed on HTTP 429; 3F 37/127, 3O 15/127, 4F 15/117, 4O 41/117 files; others not started |
+| allen | FIRST-PARTY | `a36dcfc6b69c` | P | P | F | P | P | P | P | P | P | NONE |
+| arm-trusted-firmware | UPSTREAM-FORK | `92591fe59f5b` | P | F | P | P | P | P | P | P | F | NONE |
+| atlas | FIRST-PARTY | `c624eb489275` | P | P | P | P | I | P | F | P | P | NONE |
+| benchmarks-mv | FIRST-PARTY | `0f369dbc852b` | F | P | F | F | I | F | F | P | F | NONE |
+| cortex | FIRST-PARTY | `e9f87bc8b61f` | P | P | P | P | P | P | P | P | P | NONE |
+| cortex-rs | ARCHIVED | `3f9365fb37f1` | P | P | F | P | I | F | F | P | F | NONE |
+| crumb-spec-mv | ARCHIVED | `e2dc22ea78df` | P | P | F | P | F | F | F | F | F | NONE |
+| CUDApp | FIRST-PARTY | `780a0af1f08c` | P | F | F | P | I | P | F | P | P | PARTIAL: one reviewer pass (CudaAuditFable, report outside this repo); paired security-reviewer pass has no report |
+| edk2 | UPSTREAM-FORK | `d7d4f09ff815` | P | P | P | P | P | P | P | P | P | NONE |
+| edk2-non-osi | UPSTREAM-FORK | `2f029c7fdd3e` | P | F | P | P | P | P | P | P | P | NONE |
+| edk2-platforms | UPSTREAM-FORK | `8e1779b538bc` | P | P | P | P | P | P | P | P | P | NONE |
+| encounter | ARCHIVED | `4937786098a2` | P | F | P | P | P | P | P | P | P | NONE |
+| harvester | ARCHIVED | `0fa381acd0cf` | P | P | F | P | F | F | F | P | F | NONE |
+| interplane-mv | FIRST-PARTY | `1de1b0065b2e` | F | P | F | P | I | F | F | P | F | NONE |
+| interplane.io | FIRST-PARTY | `62d5b27beea1` | P | P | P | P | P | P | F | F | F | NONE |
+| mobhub | FIRST-PARTY | `5e1130654715` | F | P | F | P | P | P | F | F | F | NONE |
+| MojoLlama | ARCHIVED | `249949d1c3fe` | P | P | F | P | I | F | P | P | F | NONE |
+| odysseus | UPSTREAM-FORK | `27764b0c8b26` | P | P | F | P | I | P | P | P | P | NONE |
+| omega-bridge | FIRST-PARTY | `358c50510579` | P | P | F | P | I | P | F | P | P | NONE |
+| omega-harness | FIRST-PARTY | `eb07daf4ae9a` | P | P | P | P | P | P | P | P | P | NONE |
+| omega-mv | FIRST-PARTY | `77ebd3fd5910` | F | F | F | P | I | F | F | F | P | NONE |
+| omega-projects | FIRST-PARTY | `4f405e1093b9` | P | P | P | P | P | P | P | P | P | NONE |
+| omnet | FIRST-PARTY | `83f605b14720` | F | P | F | F | I | P | P | P | N | NONE |
+| omtex | FIRST-PARTY | `9071a0685922` | P | P | P | P | I | P | F | P | P | NONE |
+| open-humanity | FIRST-PARTY | `38c0c1c48de5` | F | P | F | F | F | P | F | P | F | NONE |
+| physics-mv | FIRST-PARTY | `8e92aa629c94` | P | P | F | P | I | F | F | P | P | NONE |
+| physics0 | ARCHIVED | `fe587d2c7433` | P | P | P | P | P | P | P | P | P | NONE |
+| pi-register | FIRST-PARTY | `4935b8a03ca9` | P | P | F | P | P | P | P | F | P | NONE |
+| rad-id-sync | ARCHIVED | `235666135afd` | F | P | F | P | F | F | F | F | P | NONE |
+| readings-window | FIRST-PARTY | `c6e2ab345983` | P | P | P | P | P | P | P | F | P | NONE |
+| rpi5-uefi | UPSTREAM-FORK | `da0cceee29ed` | P | F | P | P | P | P | P | P | P | NONE |
+| sovereign-intelligence | FIRST-PARTY | `75662d15ff53` | F | P | F | P | I | F | F | P | P | NONE |
+| spark-adapters | ARCHIVED | `edd9aa10c0ed` | P | P | F | P | F | F | F | P | P | NONE |
+| spark-connector | FIRST-PARTY | `c25797453076` | P | P | P | P | P | P | P | P | P | NONE |
+| spark-crumbs-mv | ARCHIVED | `156633e1af13` | P | P | F | P | F | F | F | P | P | NONE |
+| spark-debugger | ARCHIVED | `dc907a4ebc0d` | P | P | F | P | F | F | F | P | P | NONE |
+| spark-dream | ARCHIVED | `fc8726847e9f` | P | P | F | P | F | F | F | P | P | NONE |
+| spark-hive | ARCHIVED | `52f6b9cc1a0c` | P | P | F | P | F | F | F | P | P | NONE |
+| spark-inquisitor | ARCHIVED | `0efa3e4dcd26` | F | P | F | P | I | F | F | P | P | NONE |
+| spark-rsi-mv | FIRST-PARTY | `fc13d3f77e6c` | F | P | F | F | I | F | F | P | F | NONE |
+| spark-supervisor | FIRST-PARTY | `371ffbebfbd8` | P | F | F | P | F | F | F | P | P | NONE |
+| synapse | FIRST-PARTY | `099a980fedab` | F | P | F | P | I | F | F | P | P | NONE |
+| t3code | UPSTREAM-FORK | `ecad5ad8fe45` | P | P | F | P | P | P | P | P | F | NONE |
+| translate | UPSTREAM-FORK | `7e7c982ebc03` | P | P | P | P | P | F | P | P | P | NONE |
+| private-01 | FIRST-PARTY | — | P | F | F | P | F | P | P | P | P | NONE |
+| private-02 | FIRST-PARTY | — | P | P | F | P | I | P | P | P | P | NONE |
+| private-03 | FIRST-PARTY | — | F | F | F | P | P | P | P | P | P | NONE |
+| private-04 | FIRST-PARTY | — | P | F | F | P | I | P | P | P | P | NONE |
+| private-05 | FIRST-PARTY | — | P | F | F | P | I | P | F | F | P | NONE |
+| private-06 | FIRST-PARTY | — | P | P | F | P | F | P | F | P | P | NONE |
+| private-07 | FIRST-PARTY | — | P | P | P | P | I | P | F | P | P | PARTIAL: one reviewer pass, report private; no security-reviewer report |
+| private-08 | FIRST-PARTY | — | P | P | F | P | I | P | P | P | P | NONE |
+| private-09 | FIRST-PARTY | — | F | P | F | P | I | P | F | P | P | NONE |
+| private-10 | FIRST-PARTY | — | F | P | F | P | I | P | P | P | P | NONE |
+| private-11 | FIRST-PARTY | — | P | F | F | P | I | P | F | P | P | NONE |
+
+The public repository `aien` was created after this pin set; it is counted in `loc/latest.json`
+(flagged `unlisted`) but has not been checked yet.
+
+Model reviews still to run are listed in the pull request that added this directory. Triage of the
+FLAGGED items is part of each stamp, not of this table.
+
+## Disclosures
+
+Problems the audit found in already-published claims. Private repositories appear by their
+`private-NN` id; historical bytes are never edited, corrections sit beside them.
+
+- 2026-10-26, private-09 (Omega evidence shelf): the historical receipts M8
+  (`omega_program_core_qualification_receipt.json`) and M9
+  (`omega_synthesis_v0_qualification_receipt.json`) say `QUALIFIED / PASS`, but their provenance
+  does not support it. Both were regenerated in omega-mv commit `469f53c1` by
+  `tests/run_m8_gates.sh` and `tests/run_m9_gates.sh`, which write a hardcoded earlier commit
+  identity; the commit M9 names does not exist in omega-mv. Disposition:
+  `REFUSED_UNSUPPORTED_PROVENANCE` for admission, recorded in adjacent `.correction.json` files
+  (M8 merged, M9 pending review). The original bytes are unchanged. Proposed upstream fix: the gate
+  scripts record `git rev-parse HEAD` of a clean tree instead of a default (NOT_RUN: no omega-mv
+  change yet).
+
+## Live line count
+
+`loc/latest.json` is the count of first-party code in every public repository at its current HEAD,
+made with scc at the version in `loc/repos.json`. Forks count only the lines we added on top of the
+upstream merge-base. `loc/history.jsonl` gains a line only when a count changes. Private
+repositories are not counted here.
+
+## Jobs
+
+- `.github/workflows/audit-attest.yml` runs when a stamp is pushed: it validates the stamp, re-runs
+  its checks at the stamped commit on a GitHub-hosted runner, and signs it with a GitHub artifact
+  attestation.
+- `.github/workflows/audit-refresh.yml` runs daily: it marks stamps `STALE` when a repository's
+  default branch has moved past the stamped commit (`status.json`) and recounts lines of code. It may
+  change only `status.json`, `loc/latest.json` and `loc/history.jsonl`, and fails without pushing if
+  anything else changed.
+
+## Host dependencies
+
+The checker and its helpers are Python, and the scanners are third-party binaries. They are pinned in
+`tools/tools.lock.json`. The project rule is first-party code in Omega; these Python tools are a recorded
+exception until an Omega port exists (proposal: port `stamp.py`, `status.py` and `loc.py`'s
+bookkeeping to `.om` first, since they are pure data checks; the scanners stay as verification oracles).
diff --git a/audit/VERIFY.md b/audit/VERIFY.md
new file mode 100644
index 0000000..e72e08a
--- /dev/null
+++ b/audit/VERIFY.md
@@ -0,0 +1,63 @@
+# Verifying an org audit stamp yourself
+
+Every step below runs on your own machine against public data. You need `git`, Python 3.10+,
+a C compiler (for the pinned `crumb` checker) and, for the signature, the GitHub CLI.
+
+## 1. Install the pinned tools
+
+```sh
+git clone https://github.com/aien-dev/aien-receipts && cd aien-receipts
+python3 audit/tools/install_tools.py /tmp/audit-tools
+```
+
+The installer downloads every binary listed in `audit/tools/tools.lock.json` and refuses any file whose
+SHA-256 differs from the lock. Python tools (semgrep, zizmor) are pip-installed at exact versions into
+`/tmp/audit-tools/venv`; the semgrep rules are checked out at the pinned commit; `crumb.c` is fetched
+from `aien-architecture-mv` at the pinned commit and its SHA-256 compared before it is built.
+
+## 2. Check that the stamp is well formed
+
+```sh
+python3 audit/tools/verify.py audit/stamps/<repo>/<sha>
+```
+
+This validates the schema, recomputes the SHA-256 of every check output and review report the stamp
+cites, and recomputes the verdict ceiling: a stamp may never claim a better verdict than its own
+contents allow (see `audit/tools/stamp.py`).
+
+## 3. Re-run the deterministic checks (public repositories)
+
+```sh
+git init -q /tmp/src && git -C /tmp/src fetch -q https://github.com/aien-dev/<repo> <sha>
+git -C /tmp/src worktree add -q --detach /tmp/wt <sha>
+python3 audit/tools/verify.py audit/stamps/<repo>/<sha> --rerun /tmp/src --worktree /tmp/wt --tools /tmp/audit-tools
+```
+
+Exit codes: `0` every reproducible check output matched byte for byte; `1` a mismatch (named on
+stderr); `2` NOT_RUN, because the checker source, the tool lock or a tool version differs from the one
+the stamp recorded. `2` is not a pass. C11 (dependency advisories) queries the live OSV database, so it
+is recorded with its date and is not compared.
+
+## 4. Check the signature
+
+```sh
+gh attestation verify audit/stamps/<repo>/<sha>/stamp.json --repo aien-dev/aien-receipts \
+  --signer-workflow aien-dev/aien-receipts/.github/workflows/audit-attest.yml
+```
+
+A valid attestation shows that the `audit-attest` workflow, on a GitHub-hosted runner, validated the
+stamp and re-ran its checks before signing. It does not show that a model review was right or complete:
+read the review reports in the stamp directory and their `files_covered`.
+
+## 5. Is the stamp current?
+
+`audit/status.json` is refreshed daily. `CURRENT` means the default-branch HEAD still equals the
+stamped commit; `STALE` means HEAD has moved and the stamp describes an older tree; `UNKNOWN` means
+HEAD could not be read; `NOT_CHECKABLE` marks private repositories; `SUPERSEDED` means a newer stamp
+exists. You can check one yourself: `git ls-remote https://github.com/aien-dev/<repo> HEAD`.
+
+## Private repositories
+
+They appear only as `private-01` .. `private-11` with a salted SHA-256 commitment
+(`sha256("<salt>:<name>")`). Their stamps carry `self_reported: true`: nobody outside can re-run
+them, so step 3 does not apply, and the signature attests only that the stamp was well formed.
diff --git a/audit/loc/history.jsonl b/audit/loc/history.jsonl
new file mode 100644
index 0000000..f59f88e
--- /dev/null
+++ b/audit/loc/history.jsonl
@@ -0,0 +1 @@
+{"date":"2026-10-26","heads":{".github":"2a9e2282ef9ac3909109a9aa6cffee5867c08247","AienOS-nv":"240ee9affd100afed5c272059e43668d8f971f45","CUDApp":"780a0af1f08c1786ea53a4e8702ca8bb1396fdbb","MojoLlama":"249949d1c3fe839bb5e156f91e9c5fd8d3dc7990","aegis-runtime-mv":"a39788b0eaaabc694dfa17652420e35b7dc3eda5","agent-archive":"e102eb6bf3434b0f510c595cbaad097c9e29a1ca","aien":"a36dcfc6b69c338f38ace7c77b3255c4fb2f820c","aien-architecture-mv":"fabf7b765a29d1e9b7d45c5b52852ee39bbfad56","aien-edge":"fce9843500629b7049853a9bedd41990e2c8bf39","aien-harness":"2da4b5a3a010db4b9fc5157fc761efe088b93421","aien-local-stack":"2ef0b913657dbf1d12969b4858fb23979bcd2e7e","aien-protocols-mv":"f3785177fcaaab7c0f2ce1126616e9fecb4e47b4","aien-receipts":"2998d98882921d1430c9eba99f5ad87d8a7dfc0d","aien-rig":"2a9bef612b598f0cb823cda0a33c44fd8ee013ad","aien-sovereign-core-mv":"f30eb963918d71dd2998b1cb936c251429417de1","aien-train":"b6c33e3a82611361b37c651df70d9a645045773a","aien-translate":"fc09dfe90e0170e422e44febb6de08c7f0c3a460","aien-yardsticks":"6c66814788b55163e1867fe9c358b424f79a79e1","aienix":"292a38cd0357b61bf1659d4cd6931012f335819e","aienos.com":"deebe99863a4a97d45d711649b06ae95da14d821","aienux":"659ddd2d7e3e140cb9bf942c3171cbd9cf3d092e","allen":"a36dcfc6b69c338f38ace7c77b3255c4fb2f820c","arm-trusted-firmware":"92591fe59f5b53efe56b57d91df0b086b4885721","atlas":"c624eb489275bc046cec3686af3010b8dcc7eec0","benchmarks-mv":"0f369dbc852b2e9364ed55c6e19a7e285cd424c1","cortex":"3d2432aabb8cb3d8e602ac8af6160c9cb713b220","cortex-rs":"3f9365fb37f1cf3a979d95c740046878ebe20d14","crumb-spec-mv":"e2dc22ea78df7d12d2ca5f2e74e3b3f064a16c9b","edk2":"d7d4f09ff815794761f84d06e307001afe6376c4","edk2-non-osi":"2f029c7fdd3e964d470427e97ca7dec00cf0a3b3","edk2-platforms":"8e1779b538bcc1e6dc68d7df625394f933651d7a","encounter":"4937786098a2cc3011d6ef421cda4259af63bf2e","harvester":"0fa381acd0cf9ed99746932136f25c92dc5a1d52","interplane-mv":"1de1b0065b2e667d8d7a23ffc3d75aeb65bf864b","interplane.io":"62d5b27beea12c8fb75d266ffc456304af1768ae","mobhub":"5e1130654715d9b46a8903d40b52d2035233a47c","odysseus":"27764b0c8b2680241bb2c8b59a821f09208c459d","omega-bridge":"358c505105793f202ad2b0c32a8623b606e029cd","omega-harness":"eb07daf4ae9a3aa4cab66049a60c3f3c2be2aced","omega-mv":"705c0f010e782408c270f66d67462bb46170e5b5","omega-projects":"4f405e1093b923d8252cead889c4669b7e0c3cdf","omnet":"83f605b147205bd912b085afdcf24402df24b5e5","omtex":"4c86614a1ee09a5b8ca4da6c2f4a7bc958d1fd64","open-humanity":"38c0c1c48de5ccc58dc350c946f0b42830e048d1","physics-mv":"8e92aa629c945d9574952b49ac4a2b04ef52ab06","physics0":"fe587d2c74336f9032ac7424e0ae6ddc5b540fd6","pi-register":"4935b8a03ca93b4dddaf83bb9a99784dfdffcb3b","rad-id-sync":"235666135afd9a014f712f6fefc3cc2b2213d509","readings-window":"c6e2ab34598303f2d9f72bf1194e19074bdf51a6","rpi5-uefi":"da0cceee29ed729ee12436671ccb39260ba55862","sovereign-intelligence":"2e33cffda59153eddebc6533ce34923df5c7cd10","spark-adapters":"edd9aa10c0ed3274b0ed8cdab1a1447977fb5df9","spark-connector":"c257974530764e10e8769091ce3a88793024403f","spark-crumbs-mv":"156633e1af13fe4f9819db0064534dd7cf9ae8fb","spark-debugger":"dc907a4ebc0dd6154c483c37efe415d602d8f388","spark-dream":"fc8726847e9f4b7d98acc450580e25b9f27d580d","spark-hive":"52f6b9cc1a0c54a0d01ad20f5b94ea3951e29ad0","spark-inquisitor":"0efa3e4dcd269352714134a333d9fe4ca3e6dd8a","spark-rsi-mv":"fc13d3f77e6cfec789fce1b0e15125df8feac3d8","spark-supervisor":"371ffbebfbd89512d9fc0d76e260e9ade49ea9d8","synapse":"099a980fedab8a6797bbf0358b8c5502c8045142","t3code":"ecad5ad8fe45e8e512ad11664a6f5e8b1f89cda5","translate":"7e7c982ebc03a2c900b12662e8c24c9e696929bd"},"not_counted":0,"totals":{"by_language":{"AWK":162,"Assembly":11741,"Autoconf":2477,"BASH":1066,"C":395641,"C Header":33259,"C++":34,"Cuda":153,"D":143,"Dockerfile":194,"Go":1923,"GraphQL":13,"HEX":357,"JavaScript":9377,"Lean":1162,"Makefile":8427,"Mojo":15735,"OSC (legacy Omega)":2897,"Omega":121606,"Powershell":46,"Python":44373,"Rust":539027,"SQL":89,"Shell":85747,"Windows Resource-Definition Script":3,"Zig":26,"jq":1462,"sed":5},"distinct_first_party_code_all":2106010,"distinct_first_party_executable_code":1277145,"first_party_code_all":2142522,"first_party_executable_code":1284010,"repositories":63}}
diff --git a/audit/loc/latest.json b/audit/loc/latest.json
new file mode 100644
index 0000000..82adec0
--- /dev/null
+++ b/audit/loc/latest.json
@@ -0,0 +1,740 @@
+{
+ "loc_tool": "aien-audit-loc/2",
+ "not_counted": 0,
+ "org": "aien-dev",
+ "repositories": [
+  {
+   "commit": "2a9e2282ef9ac3909109a9aa6cffee5867c08247",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": ".github",
+   "sha256": "4e4eebef2cff34717391d9909dc619a9b53ea9771d79878056caeb5446fe9bba",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "240ee9affd100afed5c272059e43668d8f971f45",
+   "first_party_executable_code": 5265,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "AienOS-nv",
+   "sha256": "412a6e0e41418a9a216f0194e2b41eaa81b0ade37368d777a5abcbc665ffa5d4",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "780a0af1f08c1786ea53a4e8702ca8bb1396fdbb",
+   "first_party_executable_code": 49889,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "CUDApp",
+   "sha256": "d1f9124c90ca6b32e1c06532b98781931cc0d507856d0c9b64ec9901c454dabf",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "249949d1c3fe839bb5e156f91e9c5fd8d3dc7990",
+   "first_party_executable_code": 57819,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "MojoLlama",
+   "sha256": "c2e59722d7be109dc7ae986a96376791915919cfaa847029436c34584f7d773f",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "a39788b0eaaabc694dfa17652420e35b7dc3eda5",
+   "first_party_executable_code": 12022,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aegis-runtime-mv",
+   "sha256": "6d823a51433a08e85dd15f1803a914fa0cb5835519c33b342993650f80d9b83d",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "e102eb6bf3434b0f510c595cbaad097c9e29a1ca",
+   "first_party_executable_code": 1173,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "agent-archive",
+   "sha256": "c7ae1bb3bff52cc56daf9570c84ef53b2bf65c10e54696bac8e4dad043498446",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "a36dcfc6b69c338f38ace7c77b3255c4fb2f820c",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien",
+   "sha256": "884e65434aab52a96167a6bc7cf40b245e154bc4dcf4fb001f5421fe5fcaa1b2",
+   "state": "COUNTED",
+   "unlisted": true
+  },
+  {
+   "commit": "fabf7b765a29d1e9b7d45c5b52852ee39bbfad56",
+   "first_party_executable_code": 12490,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-architecture-mv",
+   "sha256": "18627ec31b75fc5a4df13947a9645dfb8b02436c7f7391edf5f3b310facf91da",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "fce9843500629b7049853a9bedd41990e2c8bf39",
+   "first_party_executable_code": 784,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-edge",
+   "sha256": "15c684a83fdcfd5e05dbe501632977c7a35b5ce55cc877f1c1f685aeff2916a8",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2da4b5a3a010db4b9fc5157fc761efe088b93421",
+   "first_party_executable_code": 521,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "aien-harness",
+   "sha256": "276a50092f426c07b5afe7790558ded6799ff5416f79f7586d3b0f0123b04082",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2ef0b913657dbf1d12969b4858fb23979bcd2e7e",
+   "first_party_executable_code": 1304,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "aien-local-stack",
+   "sha256": "f71596054cb6e5d9c26b069787a9fd5ad57b3a44f6a683cf98384915469d09de",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "f3785177fcaaab7c0f2ce1126616e9fecb4e47b4",
+   "first_party_executable_code": 8825,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-protocols-mv",
+   "sha256": "c05fe2ba0a71dc9afe2fd454ad84620fd1500d4453f9d279a4018f87c7b8c99d",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2998d98882921d1430c9eba99f5ad87d8a7dfc0d",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-receipts",
+   "sha256": "3dc85df07fe15a3c1f136ecbd8250dccd4e815e878b94e42e98c351c59dcce08",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2a9bef612b598f0cb823cda0a33c44fd8ee013ad",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-rig",
+   "sha256": "3a5cc998fb3dcab3a24d7084a422a8b8652f475ea7a31f37e59ae19da73ca474",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "f30eb963918d71dd2998b1cb936c251429417de1",
+   "first_party_executable_code": 298386,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-sovereign-core-mv",
+   "sha256": "537e7e231e72a89b532d60789a488829a983e799117cc09ac3ada1c87c168223",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "b6c33e3a82611361b37c651df70d9a645045773a",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-train",
+   "sha256": "8033963d03595f8f1ba2d1f26b64cb5523a8d429819cfb86eff8438d37cccaaf",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "fc09dfe90e0170e422e44febb6de08c7f0c3a460",
+   "first_party_executable_code": 2316,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aien-translate",
+   "sha256": "b7c197aa57e7a0667a369d602527b4164fdc9a60b6f855d673eb4282212c21c9",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "6c66814788b55163e1867fe9c358b424f79a79e1",
+   "first_party_executable_code": 2251,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "aien-yardsticks",
+   "sha256": "995494c81e89efe9540525cd590afdab0dad4c5a3de984c31cabd216857645f2",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "292a38cd0357b61bf1659d4cd6931012f335819e",
+   "first_party_executable_code": 54,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aienix",
+   "sha256": "86cb779eed9e393a29b1a4e01911c2850cf867387b59528ecb2a7edab452e712",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "deebe99863a4a97d45d711649b06ae95da14d821",
+   "first_party_executable_code": 23869,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aienos.com",
+   "sha256": "2cca8e7b3cac83f3207bcba7f5314f82ec6075632903e3c9a0761697e76d2de4",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "659ddd2d7e3e140cb9bf942c3171cbd9cf3d092e",
+   "first_party_executable_code": 175778,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "aienux",
+   "sha256": "0338f57a87bd76103cffe50f2117bb6f6aa65b725f03063f428768e1ce94e43c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "a36dcfc6b69c338f38ace7c77b3255c4fb2f820c",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "allen",
+   "sha256": "12c3d7fa508136b5d23e3502777c539b9812671b07bed9535faf1165532e0f61",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "92591fe59f5b53efe56b57d91df0b086b4885721",
+   "first_party_executable_code": 0,
+   "fork_base": "01610b0d32d746104dd4dacf179c65d69adaaf0a",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "arm-trusted-firmware",
+   "sha256": "f399bf3ba03e00ae14e2bfe40059ab392a2c13b804573ee260192df0555c700d",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "c624eb489275bc046cec3686af3010b8dcc7eec0",
+   "first_party_executable_code": 1857,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "atlas",
+   "sha256": "ef4aec8ceb34dc4b16d8d5cf1db5d335b9b7418c123bb0093067ab06662bbfa4",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "0f369dbc852b2e9364ed55c6e19a7e285cd424c1",
+   "first_party_executable_code": 7765,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "benchmarks-mv",
+   "sha256": "2a1e260ccf8eddead83147385423215ab75758b7202b4c47db2948822cce5410",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "3d2432aabb8cb3d8e602ac8af6160c9cb713b220",
+   "first_party_executable_code": 19098,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "cortex",
+   "sha256": "51b1a68f9e929c989263f5f837bece9d9d86a14ff08b67b5c59f7b747034b0d0",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "3f9365fb37f1cf3a979d95c740046878ebe20d14",
+   "first_party_executable_code": 2360,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "cortex-rs",
+   "sha256": "3bdc91047af1a2f4a014b8cd8d38da3c598c4d677554ef4c6fe2608bb0c0d406",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "e2dc22ea78df7d12d2ca5f2e74e3b3f064a16c9b",
+   "first_party_executable_code": 678,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "crumb-spec-mv",
+   "sha256": "521c33243cf69ce8683fb122fb2a28d5735cdd5f3f773b10995d56fa85235f6b",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "d7d4f09ff815794761f84d06e307001afe6376c4",
+   "first_party_executable_code": 0,
+   "fork_base": "d7d4f09ff815794761f84d06e307001afe6376c4",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "edk2",
+   "sha256": "37cd0ef50ad4ca88af176b4f6468c6fb20d5e3bf8a33f0f8e7ad6dafcbb8ace9",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2f029c7fdd3e964d470427e97ca7dec00cf0a3b3",
+   "first_party_executable_code": 0,
+   "fork_base": "7ac12d81e02b323bffdf1ef3c188ea33c2185c91",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "edk2-non-osi",
+   "sha256": "47302ccda441a96daffd762d7e41f939753db4dc72ad7619384a4017a271e051",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "8e1779b538bcc1e6dc68d7df625394f933651d7a",
+   "first_party_executable_code": 0,
+   "fork_base": "8e1779b538bcc1e6dc68d7df625394f933651d7a",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "edk2-platforms",
+   "sha256": "93753e52d8b34981cde8b02ec8f6aa5946a5669d9b95fe721e4a62ad3ef950a9",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "4937786098a2cc3011d6ef421cda4259af63bf2e",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "encounter",
+   "sha256": "40ad244ae454524f63ec988b508c241acac1a440ac9d2f9b596af39d93ad3ae3",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "0fa381acd0cf9ed99746932136f25c92dc5a1d52",
+   "first_party_executable_code": 377,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "harvester",
+   "sha256": "8c4238eb79c2ca2c5feb6f16b6e5f01393af383eb4da09c21f7b349f0c87fe6c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "1de1b0065b2e667d8d7a23ffc3d75aeb65bf864b",
+   "first_party_executable_code": 29919,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "interplane-mv",
+   "sha256": "0f609088c3e1a461bddb90e72f94fce1d1643568d73f7968022a9a90e6177743",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "62d5b27beea12c8fb75d266ffc456304af1768ae",
+   "first_party_executable_code": 943,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "interplane.io",
+   "sha256": "f190fb0c249fe5560040eb83f88bbdab626c9a9e3a14d1a8b9305579e86f074c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "5e1130654715d9b46a8903d40b52d2035233a47c",
+   "first_party_executable_code": 3589,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "mobhub",
+   "sha256": "08b9c5ff090f4d120a65fde5ed443ce16d134c75dd2bbc55e89cd9cb58a4e30a",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "27764b0c8b2680241bb2c8b59a821f09208c459d",
+   "first_party_executable_code": 2158,
+   "fork_base": "a8c147b238db01dbd00b57774ed8b453f1e43971",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "odysseus",
+   "sha256": "c1df38dee9ab4382c5d3e37a5e837553cbf84761d0a2c5ad02c409e90206301f",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "358c505105793f202ad2b0c32a8623b606e029cd",
+   "first_party_executable_code": 6612,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omega-bridge",
+   "sha256": "08ba8a1fe8714dc57e9b02675d48330729e07cdd43774102e0f7d2f30ff56394",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "eb07daf4ae9a3aa4cab66049a60c3f3c2be2aced",
+   "first_party_executable_code": 60,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omega-harness",
+   "sha256": "c97da98bfc6af7e97ac63a37bca49c469e8462b6acb289b8fe619943b5ba534c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "705c0f010e782408c270f66d67462bb46170e5b5",
+   "first_party_executable_code": 389575,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omega-mv",
+   "sha256": "f557cbe4a18007c00e6edf8479f2ed6e4bf62afd7b2f81dc5119629c12fff163",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "4f405e1093b923d8252cead889c4669b7e0c3cdf",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omega-projects",
+   "sha256": "cefeec2d7a990c520568da60fa57a01549a4e2f1776915b47f936da440bd6bd1",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "83f605b147205bd912b085afdcf24402df24b5e5",
+   "first_party_executable_code": 16389,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omnet",
+   "sha256": "213a0ed4cefc66c5750508852b5f58bf2d3bcba13facad7ba882da9e1910612c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "4c86614a1ee09a5b8ca4da6c2f4a7bc958d1fd64",
+   "first_party_executable_code": 1948,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "omtex",
+   "sha256": "03ece5ef9122059a2faa7920e546018dbdd27b01eefcc6b551bd308e2abed5f2",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "38c0c1c48de5ccc58dc350c946f0b42830e048d1",
+   "first_party_executable_code": 7796,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "open-humanity",
+   "sha256": "60571b8e50d976ccbc3d7a3b348f0a02f7322d70c06b928f95bde29f3d77dd89",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "8e92aa629c945d9574952b49ac4a2b04ef52ab06",
+   "first_party_executable_code": 15584,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "physics-mv",
+   "sha256": "81b6c25cdee75474678ac2575df9e62aa1f8f6b4fdb315c455d9df174ca5fc52",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "fe587d2c74336f9032ac7424e0ae6ddc5b540fd6",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "physics0",
+   "sha256": "d59532d3e26556f31e99f95f59c23c7c32fc74ef1daafd07fdbe781c085c7ec8",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "4935b8a03ca93b4dddaf83bb9a99784dfdffcb3b",
+   "first_party_executable_code": 341,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "pi-register",
+   "sha256": "8e6cc2851bbea1b360d0c28f9fa1d9ec32ad850a69b9b63f34fe0e6b65c84ea3",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "235666135afd9a014f712f6fefc3cc2b2213d509",
+   "first_party_executable_code": 339,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "rad-id-sync",
+   "sha256": "2e35001a56649d1ccf00e6f43fe3ae68a341a226fae6a06290e7ce3584ca8f6c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "c6e2ab34598303f2d9f72bf1194e19074bdf51a6",
+   "first_party_executable_code": 926,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "readings-window",
+   "sha256": "135cb02607c980fe277df5f08e42463e963ab77da809c542fe7bedf589dea19a",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "da0cceee29ed729ee12436671ccb39260ba55862",
+   "first_party_executable_code": 0,
+   "fork_base": "a6135b06d661b5f11bbf4bd742b42a1919b264dc",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "rpi5-uefi",
+   "sha256": "cc443b5e593ecaa9b245f1b08bd4f44d6f0c9665256799d1d0e69c8274494183",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "2e33cffda59153eddebc6533ce34923df5c7cd10",
+   "first_party_executable_code": 15926,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "sovereign-intelligence",
+   "sha256": "4fb180e337985b48f2da9502ec186f9436c30d761f7f156abb19ab83c5bc79ab",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "edd9aa10c0ed3274b0ed8cdab1a1447977fb5df9",
+   "first_party_executable_code": 1414,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-adapters",
+   "sha256": "3a2a2d6e0a74635a4bcd74a3d2c2022ec19c4f4d5c7cb87bc698b6b8e41b97b2",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "c257974530764e10e8769091ce3a88793024403f",
+   "first_party_executable_code": 0,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "spark-connector",
+   "sha256": "30be84ba487eb1276d93ffbd3423ceea1623ce8009c2c76a1770401d1def0221",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "156633e1af13fe4f9819db0064534dd7cf9ae8fb",
+   "first_party_executable_code": 848,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-crumbs-mv",
+   "sha256": "f9ca4eb0e6ceae113accf1151ff7dd1346cc68271a9617fab84c23538db5ea91",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "dc907a4ebc0dd6154c483c37efe415d602d8f388",
+   "first_party_executable_code": 569,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-debugger",
+   "sha256": "a7404ff07aa4178bfb36e2341f787d9a77c9191fe157ce9595b01c88cf50c332",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "fc8726847e9f4b7d98acc450580e25b9f27d580d",
+   "first_party_executable_code": 649,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-dream",
+   "sha256": "7b691255b909f17473168aec8dc668d9e42822d811d2270c3408e51e9637dfb3",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "52f6b9cc1a0c54a0d01ad20f5b94ea3951e29ad0",
+   "first_party_executable_code": 2405,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-hive",
+   "sha256": "81c26a2d8fcf45926b6e1655c34cb1abafc606f1d1a4960a1eb488a783c4342c",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "0efa3e4dcd269352714134a333d9fe4ca3e6dd8a",
+   "first_party_executable_code": 3008,
+   "fork_base": "",
+   "kind": "ARCHIVED",
+   "mode": "full-tree",
+   "repository": "spark-inquisitor",
+   "sha256": "7c65f342d51d8aae5c25639b5a497cdb9eea5292d5e59145e92a8193f7733a5b",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "fc13d3f77e6cfec789fce1b0e15125df8feac3d8",
+   "first_party_executable_code": 28049,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "spark-rsi-mv",
+   "sha256": "5d07df5f25631bc87f83f08b0e55390baa30d2a4f0f594ee356dd38130078e81",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "371ffbebfbd89512d9fc0d76e260e9ade49ea9d8",
+   "first_party_executable_code": 418,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "spark-supervisor",
+   "sha256": "1c125241600dd9028d0882a940891bb951ddb5b814a400f0a5cac8665b99eaa8",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "099a980fedab8a6797bbf0358b8c5502c8045142",
+   "first_party_executable_code": 69664,
+   "fork_base": "",
+   "kind": "FIRST-PARTY",
+   "mode": "full-tree",
+   "repository": "synapse",
+   "sha256": "008d5d6f2777839676dcc561f8bbe46c1e9daf1457b3dcd5c67cb1ec6bf5c4ef",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "ecad5ad8fe45e8e512ad11664a6f5e8b1f89cda5",
+   "first_party_executable_code": 0,
+   "fork_base": "98a6246d07624432a6e6d0ab4fb87bede90a49a6",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "t3code",
+   "sha256": "2abb050a68d164b80155ed37454ec7c1e7e78233424b546afbec27e78ba08a14",
+   "state": "COUNTED",
+   "unlisted": false
+  },
+  {
+   "commit": "7e7c982ebc03a2c900b12662e8c24c9e696929bd",
+   "first_party_executable_code": 0,
+   "fork_base": "df9d77c85399470d10e2cb610f17e294ac107740",
+   "kind": "UPSTREAM-FORK",
+   "mode": "fork-diff",
+   "repository": "translate",
+   "sha256": "c8a15e0e95d24644768820e28bbc84ed10ea81e54fcf0117152085c115adbd01",
+   "state": "COUNTED",
+   "unlisted": false
+  }
+ ],
+ "scc_version": "4.1.0",
+ "schema": "aien-audit-loc-live/1",
+ "scope": "public repositories only; private repositories are not counted here",
+ "totals": {
+  "by_language": {
+   "AWK": 162,
+   "Assembly": 11741,
+   "Autoconf": 2477,
+   "BASH": 1066,
+   "C": 395641,
+   "C Header": 33259,
+   "C++": 34,
+   "Cuda": 153,
+   "D": 143,
+   "Dockerfile": 194,
+   "Go": 1923,
+   "GraphQL": 13,
+   "HEX": 357,
+   "JavaScript": 9377,
+   "Lean": 1162,
+   "Makefile": 8427,
+   "Mojo": 15735,
+   "OSC (legacy Omega)": 2897,
+   "Omega": 121606,
+   "Powershell": 46,
+   "Python": 44373,
+   "Rust": 539027,
+   "SQL": 89,
+   "Shell": 85747,
+   "Windows Resource-Definition Script": 3,
+   "Zig": 26,
+   "jq": 1462,
+   "sed": 5
+  },
+  "distinct_first_party_code_all": 2106010,
+  "distinct_first_party_executable_code": 1277145,
+  "first_party_code_all": 2142522,
+  "first_party_executable_code": 1284010,
+  "repositories": 63
+ }
+}
diff --git a/audit/loc/repos.json b/audit/loc/repos.json
new file mode 100644
index 0000000..eb65a90
--- /dev/null
+++ b/audit/loc/repos.json
@@ -0,0 +1,296 @@
+{
+ "note": "Public repositories. Forks pin the upstream merge-base; only our diff is counted. A public repository missing here is still counted (or reported NOT_COUNTED) by loc_live.py.",
+ "org": "aien-dev",
+ "repositories": [
+  {
+   "kind": "FIRST-PARTY",
+   "name": ".github"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "AienOS-nv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "CUDApp"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "MojoLlama"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aegis-runtime-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "agent-archive"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-architecture-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-edge"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "aien-harness"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "aien-local-stack"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-protocols-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-receipts"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-rig"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-sovereign-core-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-train"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aien-translate"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "aien-yardsticks"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aienix"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aienos.com"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "aienux"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "allen"
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "arm-trusted-firmware",
+   "upstream": {
+    "base_sha": "01610b0d32d746104dd4dacf179c65d69adaaf0a",
+    "ref": "master",
+    "repository": "worproject/arm-trusted-firmware"
+   }
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "atlas"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "benchmarks-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "cortex"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "cortex-rs"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "crumb-spec-mv"
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "edk2",
+   "upstream": {
+    "base_sha": "d7d4f09ff815794761f84d06e307001afe6376c4",
+    "ref": "bootmanagerlib-sdmmc-desc",
+    "repository": "worproject/edk2"
+   }
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "edk2-non-osi",
+   "upstream": {
+    "base_sha": "7ac12d81e02b323bffdf1ef3c188ea33c2185c91",
+    "ref": "master",
+    "repository": "tianocore/edk2-non-osi"
+   }
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "edk2-platforms",
+   "upstream": {
+    "base_sha": "8e1779b538bcc1e6dc68d7df625394f933651d7a",
+    "ref": "rpi5-dev",
+    "repository": "worproject/edk2-platforms"
+   }
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "encounter"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "harvester"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "interplane-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "interplane.io"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "mobhub"
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "odysseus",
+   "upstream": {
+    "base_sha": "a8c147b238db01dbd00b57774ed8b453f1e43971",
+    "ref": "codex/review-7011-editor-server-20261015",
+    "repository": "odysseus-dev/odysseus"
+   }
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omega-bridge"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omega-harness"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omega-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omega-projects"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omnet"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "omtex"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "open-humanity"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "physics-mv"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "physics0"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "pi-register"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "rad-id-sync"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "readings-window"
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "rpi5-uefi",
+   "upstream": {
+    "base_sha": "a6135b06d661b5f11bbf4bd742b42a1919b264dc",
+    "ref": "master",
+    "repository": "worproject/rpi5-uefi"
+   }
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "sovereign-intelligence"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-adapters"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "spark-connector"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-crumbs-mv"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-debugger"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-dream"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-hive"
+  },
+  {
+   "kind": "ARCHIVED",
+   "name": "spark-inquisitor"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "spark-rsi-mv"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "spark-supervisor"
+  },
+  {
+   "kind": "FIRST-PARTY",
+   "name": "synapse"
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "t3code",
+   "upstream": {
+    "base_sha": "98a6246d07624432a6e6d0ab4fb87bede90a49a6",
+    "ref": "batch-07-pr-media/context",
+    "repository": "pingdotgg/t3code"
+   }
+  },
+  {
+   "kind": "UPSTREAM-FORK",
+   "name": "translate",
+   "upstream": {
+    "base_sha": "df9d77c85399470d10e2cb610f17e294ac107740",
+    "ref": "master",
+    "repository": "xnx3/translate"
+   }
+  }
+ ],
+ "scc_version": "4.1.0",
+ "schema": "aien-audit-loc-repos/1"
+}
diff --git a/audit/tests/test_audit.py b/audit/tests/test_audit.py
new file mode 100644
index 0000000..4090f07
--- /dev/null
+++ b/audit/tests/test_audit.py
@@ -0,0 +1,396 @@
+"""Tests for the org audit tools. Run: python3 -m unittest discover -s audit/tests -v
+
+Every test builds its own git repository and, where a scanner is involved, a fake
+scanner script with a chosen version and exit code, so the tests need no network
+and no installed scanners. Each guard has a negative control: the same input with
+the guard's condition flipped must change the outcome.
+"""
+import hashlib, json, os, shutil, subprocess, sys, tempfile, unittest
+
+TOOLS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tools")
+sys.path.insert(0, TOOLS)
+import checks  # noqa: E402
+import loc  # noqa: E402
+import stamp  # noqa: E402
+import status  # noqa: E402
+import verify  # noqa: E402
+
+GIT_ENV = {"GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "t@example.invalid", "GIT_COMMITTER_NAME": "t",
+           "GIT_COMMITTER_EMAIL": "t@example.invalid", "GIT_AUTHOR_DATE": "2026-01-01T00:00:00Z",
+           "GIT_COMMITTER_DATE": "2026-01-01T00:00:00Z"}
+
+
+def sh(*cmd, cwd=None):
+    return subprocess.run(cmd, cwd=cwd, check=True, capture_output=True, env={**os.environ, **GIT_ENV}).stdout.decode().strip()
+
+
+def make_repo(root, files):
+    os.makedirs(root, exist_ok=True)
+    sh("git", "init", "-q", "-b", "main", root)
+    return commit(root, files)
+
+
+def commit(root, files, msg="c"):
+    for p, data in files.items():
+        full = os.path.join(root, p)
+        os.makedirs(os.path.dirname(full), exist_ok=True)
+        with open(full, "wb") as fh:
+            fh.write(data if isinstance(data, bytes) else data.encode())
+    sh("git", "add", "-A", cwd=root)
+    sh("git", "commit", "-q", "-m", msg, cwd=root)
+    return sh("git", "rev-parse", "HEAD", cwd=root)
+
+
+def fake_tool(path, version, body):
+    os.makedirs(os.path.dirname(path), exist_ok=True)
+    with open(path, "w") as fh:
+        fh.write("#!/bin/sh\ncase \"$1\" in --version|-version|version) echo '%s'; exit 0;; esac\n%s\n" % (version, body))
+    os.chmod(path, 0o755)
+
+
+class Base(unittest.TestCase):
+    def setUp(self):
+        self.tmp = tempfile.mkdtemp(prefix="aien-audit-test-")
+        self.addCleanup(shutil.rmtree, self.tmp)
+        self.tools = os.path.join(self.tmp, "tools")
+        os.makedirs(self.tools)
+        self.lock = {"schema": "aien-audit-tools-lock/1", "tools": {
+            "osv-scanner": {"version": "2.7.0", "version_cmd": ["--version"]},
+            "venv/bin/semgrep": {"version": "1.182.1", "version_cmd": ["--version"]}},
+            "semgrep_rules": {"config_sha256": ""}}
+        self.lock_path = os.path.join(self.tmp, "tools.lock.json")
+        self.write_lock()
+
+    def write_lock(self):
+        with open(self.lock_path, "w") as fh:
+            json.dump(self.lock, fh)
+
+    def run_checks(self, repo, sha, only, name="r"):
+        out = os.path.join(self.tmp, "out-" + only.replace(",", "_"))
+        doc = checks.run_all(repo, sha, name, out, tools=self.tools, only=only, lock_path=self.lock_path)
+        return doc, {c["check"]: c for c in doc["checks"]}, out
+
+
+class TestCheckerHardening(Base):
+    def test_output_hash_covers_written_bytes(self):
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"LICENSE": "MIT License\n", "a.py": "print(1)\n"})
+        doc, by, out = self.run_checks(repo, sha, "C2")
+        c = by["C2-license"]
+        with open(os.path.join(out, "C2-license.json"), "rb") as fh:
+            self.assertEqual(hashlib.sha256(fh.read()).hexdigest(), c["output_sha256"])
+
+    def test_fork_root_license_outside_diff_is_seen(self):
+        repo = os.path.join(self.tmp, "fork")
+        base = make_repo(repo, {"License.txt": "Apache License, Version 2.0\n", "up.c": "int x;\n"})
+        head = commit(repo, {"ours.c": "int y;\n"})
+        doc = checks.run_all(repo, head, "f", os.path.join(self.tmp, "out-fork"), fork_base=base,
+                             tools=self.tools, only="C2", lock_path=self.lock_path)
+        c2 = {c["check"]: c for c in doc["checks"]}["C2-license"]
+        self.assertEqual(c2["summary"]["root"], {"License.txt": "Apache-2.0"})
+        self.assertEqual(c2["status"], "PASS")
+        # negative control: no licence anywhere in the tree is still flagged
+        bare = os.path.join(self.tmp, "bare")
+        sha = make_repo(bare, {"a.c": "int z;\n"})
+        doc, by, out = self.run_checks(bare, sha, "C2")
+        self.assertEqual(by["C2-license"]["status"], "FLAGGED")
+
+    def test_license_signature_survives_reflow(self):
+        self.assertEqual(checks.ident("Redistribution and use in source\n   and binary forms"), "BSD")
+        self.assertEqual(checks.ident("See docs/license.rst"), "UNRECOGNIZED")  # negative control
+
+    def test_license_ident_takes_spdx_and_earliest_signature(self):
+        dual = ("x is dual-licensed\nSPDX-License-Identifier: MIT OR GPL-2.0-only\n\nMIT License\n"
+                "Permission is hereby granted, free of charge\nGNU GENERAL PUBLIC LICENSE\n"
+                "use the GNU Lesser General Public License instead\n")
+        self.assertEqual(checks.ident(dual), "MIT OR GPL-2.0-only")
+        gpl = "GNU GENERAL PUBLIC LICENSE\nVersion 2\n... use the GNU Lesser General Public License instead.\n"
+        self.assertEqual(checks.ident(gpl), "GPL")  # list order would have said LGPL
+        self.assertEqual(checks.ident("Apache License\nVersion 2.0, January 2004\n"), "Apache-2.0")
+
+    def test_spdx_tag_quoted_in_prose_is_not_a_header(self):
+        prose = "They carry SPDX-License-Identifier: GPL-2.0-only and remain under\nGPL-2.0-only.\n"
+        self.assertEqual(checks.SPDX_RE.findall(prose), [])
+        self.assertEqual(checks.SPDX_RE.findall("/* SPDX-License-Identifier: GPL-2.0-only */\n"),
+                         ["GPL-2.0-only"])  # negative control: a real header still parses
+        self.assertEqual(checks.SPDX_RE.findall("# SPDX-License-Identifier: (MIT OR Apache-2.0) AND BSD-3-Clause\n"),
+                         ["(MIT OR Apache-2.0) AND BSD-3-Clause"])
+        self.assertEqual(checks.SPDX_RE.findall("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"),
+                         ["Apache-2.0 WITH LLVM-exception"])
+
+    def test_custom_license_wrapping_apache_text_is_unrecognized(self):
+        wrapper = ("Sovereign Resource Commons License 1.0 (SRCL-1.0)\nAll rights reserved.\n"
+                   "Licensed under the Apache License, Version 2.0 subject to conditions precedent.\n")
+        self.assertEqual(checks.ident(wrapper), "UNRECOGNIZED")
+        self.assertEqual(checks.ident("MIT License\nCopyright (c) 2026 X\nPermission is hereby granted, free of charge"),
+                         "MIT")  # negative control: an unversioned title before the signature is not a wrapper
+        repo = os.path.join(self.tmp, "wrapper")
+        sha = make_repo(repo, {"LICENSE": wrapper, "License-History.txt": "old terms\n",
+                               "Cargo.toml": '[package]\nlicense = "SRCL-1.0"\n'})
+        doc, by, out = self.run_checks(repo, sha, "C2")
+        with open(os.path.join(out, "C2-license.json")) as fh:
+            kinds = [i["kind"] for i in json.load(fh)["items"]]
+        self.assertEqual(kinds, ["unrecognized-root-license", "unrecognized-root-license", "manifest-differs-from-root"])
+
+    def test_nested_license_governs_its_subtree(self):
+        agpl = "GNU AFFERO GENERAL PUBLIC LICENSE\n"
+        repo = os.path.join(self.tmp, "nested")
+        sha = make_repo(repo, {"LICENSE": "Apache License, Version 2.0\n",
+                               "adapters/a/LICENSE": agpl,
+                               "adapters/a/Cargo.toml": '[package]\nlicense = "AGPL-3.0-or-later"\n',
+                               "tools/b/Cargo.toml": '[package]\nlicense = "AGPL-3.0-or-later"\n'})
+        doc, by, out = self.run_checks(repo, sha, "C2")
+        with open(os.path.join(out, "C2-license.json")) as fh:
+            items = json.load(fh)["items"]
+        # adapters/a is covered by its own LICENSE; tools/b is the negative control
+        self.assertEqual(items, [{"kind": "manifest-differs-from-root", "license": "AGPL-3.0-or-later",
+                                  "files": ["tools/b/Cargo.toml"]}])
+
+    def test_fork_link_to_unchanged_upstream_file_resolves(self):
+        repo = os.path.join(self.tmp, "fork")
+        base = make_repo(repo, {"docs/guide.md": "# g\n"})
+        head = commit(repo, {"NOTES.md": "[g](docs/guide.md) [gone](docs/missing.md) `alloc[T](n)`\n"
+                                         "See [`docs/also-gone.md`](docs/also-gone.md).\n"})
+        doc = checks.run_all(repo, head, "f", os.path.join(self.tmp, "out-fork4"), fork_base=base,
+                             tools=self.tools, only="C4", lock_path=self.lock_path)
+        c4 = {c["check"]: c for c in doc["checks"]}["C4-internal-links"]
+        with open(os.path.join(self.tmp, "out-fork4", "C4-internal-links.json")) as fh:
+            targets = [i["target"] for i in json.load(fh)]
+        self.assertEqual(targets, ["docs/missing.md", "docs/also-gone.md"])  # missing links are the negative control
+        self.assertEqual(c4["count"], 2)
+
+    def test_missing_scanner_is_not_run(self):
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"Cargo.lock": "# lock\n"})
+        old = os.environ["PATH"]
+        gitbin = os.path.join(self.tmp, "gitonly")
+        os.makedirs(gitbin)
+        os.symlink(shutil.which("git"), os.path.join(gitbin, "git"))
+        os.environ["PATH"] = gitbin  # git, and no osv-scanner anywhere
+        try:
+            _, by, _ = self.run_checks(repo, sha, "C11")
+        finally:
+            os.environ["PATH"] = old
+        self.assertEqual(by["C11-dep-advisories"]["status"], "NOT_RUN")
+
+    def test_unpinned_version_is_not_run(self):
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"Cargo.lock": "# lock\n"})
+        fake_tool(os.path.join(self.tools, "osv-scanner"), "osv-scanner version: 2.7.01", "echo '{\"results\":[]}'")
+        _, by, _ = self.run_checks(repo, sha, "C11")
+        self.assertEqual(by["C11-dep-advisories"]["status"], "NOT_RUN")
+        self.assertIn("pins 2.7.0", by["C11-dep-advisories"]["note"])
+        # negative control: the pinned version runs
+        fake_tool(os.path.join(self.tools, "osv-scanner"), "osv-scanner version: 2.7.0", "echo '{\"results\":[]}'")
+        _, by, _ = self.run_checks(repo, sha, "C11")
+        self.assertEqual(by["C11-dep-advisories"]["status"], "PASS")
+
+    def test_osv_exit_codes(self):
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"Cargo.lock": "# lock\n"})
+        tool = os.path.join(self.tools, "osv-scanner")
+        vuln = ('{"results":[{"source":{"path":"\'"$6"\'/Cargo.lock"},"packages":[{"package":{"name":"bincode",'
+                '"version":"1.3.3"},"vulnerabilities":[{"id":"RUSTSEC-2025-0141"}]}]}]}')
+        cases = [("echo '{\"results\":[]}'; exit 0", "PASS"),
+                 ("echo '%s'; exit 1" % vuln, "FLAGGED"),
+                 ("echo '{\"results\":[]}'; exit 1", "NOT_RUN"),  # says vulnerable, lists none
+                 ("echo 'no packages' >&2; exit 128", "NOT_RUN"),
+                 ("exit 2", "NOT_RUN")]
+        for body, want in cases:
+            with self.subTest(body=body):
+                fake_tool(tool, "osv-scanner version: 2.7.0", body)
+                _, by, _ = self.run_checks(repo, sha, "C11")
+                self.assertEqual(by["C11-dep-advisories"]["status"], want)
+
+    def test_semgrep_list_error_type_is_incomplete(self):
+        self.assertEqual(checks.semgrep_error_type({"type": ["PartialParsing", [{"line": 1}]]}), "PartialParsing")
+        self.assertEqual(checks.semgrep_error_type({"type": "Timeout"}), "Timeout")
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"a.py": "print(1)\n"})
+        cfg = b"rules: []\n"
+        with open(os.path.join(self.tools, "semgrep-config.yaml"), "wb") as fh:
+            fh.write(cfg)
+        self.lock["semgrep_rules"]["config_sha256"] = hashlib.sha256(cfg).hexdigest()
+        self.write_lock()
+        sg = os.path.join(self.tools, "venv", "bin", "semgrep")
+        write_out = ('while [ "$1" != "--output" ]; do shift; done; out=$2; echo \'%s\' > "$out"; exit 0')
+        err = '{"results":[],"errors":[{"type":["PartialParsing",[{"line":1}]]}],"paths":{"skipped":[]}}'
+        fake_tool(sg, "1.182.1", write_out % err)
+        _, by, _ = self.run_checks(repo, sha, "C5")
+        self.assertEqual(by["C5-semgrep"]["status"], "INCOMPLETE")
+        # negative control: no errors, no skips -> PASS
+        fake_tool(sg, "1.182.1", write_out % '{"results":[],"errors":[],"paths":{"skipped":[]}}')
+        _, by, _ = self.run_checks(repo, sha, "C5")
+        self.assertEqual(by["C5-semgrep"]["status"], "PASS")
+        # a config that is not the pinned one is refused
+        with open(os.path.join(self.tools, "semgrep-config.yaml"), "wb") as fh:
+            fh.write(b"rules: [] # edited\n")
+        _, by, _ = self.run_checks(repo, sha, "C5")
+        self.assertEqual(by["C5-semgrep"]["status"], "NOT_RUN")
+
+    def test_crashed_check_is_not_run(self):
+        repo = os.path.join(self.tmp, "repo")
+        sha = make_repo(repo, {"a.py": "print(1)\n"})
+        orig = checks.CHECKS["C2"]
+        checks.CHECKS["C2"] = lambda ctx: 1 / 0
+        try:
+            _, by, _ = self.run_checks(repo, sha, "C2")
+        finally:
+            checks.CHECKS["C2"] = orig
+        self.assertEqual(by["C2-license"]["status"], "NOT_RUN")
+        self.assertIn("ZeroDivisionError", by["C2-license"]["note"])
+
+
+class TestForkLoc(Base):
+    def test_modified_upstream_file_counts_added_lines_only(self):
+        repo = os.path.join(self.tmp, "fork")
+        base = make_repo(repo, {"up.py": "".join("x%d = %d\n" % (i, i) for i in range(100))})
+        head = commit(repo, {"up.py": "".join("x%d = %d\n" % (i, i) for i in range(98)) + "y = 1\n\nz = 2\n",
+                             "ours.py": "a = 1\nb = 2\n"})
+        scc = shutil.which("scc") or os.path.join(os.environ.get("AUDIT_TOOLS", ""), "scc")
+        if not os.path.exists(scc):
+            self.skipTest("scc not installed (NOT_RUN)")
+        doc = loc.count(repo, head, "fork", base, scc, [])
+        by = {f["path"]: f for f in doc["files"]}
+        self.assertEqual(by["up.py"]["code"], 2)  # y, z; the two deleted lines are not subtracted
+        self.assertTrue(by["up.py"]["fork_modified"])
+        self.assertEqual(by["ours.py"]["code"], 2)
+        self.assertNotIn("fork_modified", by["ours.py"])
+
+    def test_org_totals_dedupe_identical_blobs(self):
+        f = {"category": "first_party", "language": "Python", "executable": True, "code": 10, "blob": "b1"}
+        docs = [{"repository": "a", "files": [dict(f, path="x.py")]}, {"repository": "b", "files": [dict(f, path="y.py")]}]
+        t = loc.org_totals(docs)
+        self.assertEqual(t["first_party_executable_code"], 20)
+        self.assertEqual(t["distinct_first_party_executable_code"], 10)
+
+
+def write_stamp(root, ident, st, files):
+    d = os.path.join(root, ident, st["subject"]["commit"])
+    os.makedirs(d, exist_ok=True)
+    for p, data in files.items():
+        os.makedirs(os.path.dirname(os.path.join(d, p)), exist_ok=True)
+        with open(os.path.join(d, p), "wb") as fh:
+            fh.write(data)
+    with open(os.path.join(d, "stamp.json"), "w") as fh:
+        json.dump(st, fh, indent=1)
+    return d
+
+
+class TestStamp(Base):
+    def setUp(self):
+        super().setUp()
+        self.repo = os.path.join(self.tmp, "repo")
+        self.sha = make_repo(self.repo, {"LICENSE": "MIT License\n", "a.py": "print(1)\n"})
+        self.doc, by, out = self.run_checks(self.repo, self.sha, "C2")
+        with open(os.path.join(out, "C2-license.json"), "rb") as fh:
+            self.c2 = fh.read()
+        self.report = b"# review\nno findings\n"
+        self.st = {
+            "schema": "aien-audit-stamp/1",
+            "subject": {"visibility": "public", "repository": "repo", "kind": "FIRST-PARTY", "commit": self.sha,
+                        "tree": sh("git", "rev-parse", self.sha + "^{tree}", cwd=self.repo)},
+            "deterministic_checked": {"mode": "full-tree", "fork_base": None, "checker": self.doc["checker"],
+                                      "tools_lock_sha256": self.doc["tools_lock_sha256"],
+                                      # every FLAGGED item counted as triaged, as a reviewer would record it
+                                      "checks": [dict(c, triaged=c["count"] or 0) for c in self.doc["checks"]]},
+            "model_reviewed": [{"agent_role": "reviewer", "model": "m", "effort": "high", "files_covered": 2,
+                                "files_total": 2, "report": "reviews/r.md",
+                                "report_sha256": hashlib.sha256(self.report).hexdigest(), "complete": True}],
+            "findings": [], "not_run": [], "verdict": "PASS", "self_reported": False}
+        self.stamps = os.path.join(self.tmp, "stamps")
+
+    def put(self, st=None, files=None, ident="repo"):
+        return write_stamp(self.stamps, ident, st or self.st,
+                           files or {"checks/C2-license.json": self.c2, "reviews/r.md": self.report})
+
+    def test_valid_stamp(self):
+        self.assertEqual(stamp.validate(self.put()), [])
+
+    def test_tampered_check_output(self):
+        self.assertTrue(any("does not match" in e for e in
+                            stamp.validate(self.put(files={"checks/C2-license.json": self.c2 + b" ",
+                                                           "reviews/r.md": self.report}))))
+
+    def test_verdict_better_than_contents(self):
+        self.st["not_run"] = [{"item": "C1-secrets", "reason": "gitleaks missing"}]
+        self.assertTrue(any("better than the contents allow" in e for e in stamp.validate(self.put())))
+        self.st["verdict"] = "PASS-WITH-NOTES"  # negative control
+        self.assertEqual(stamp.validate(self.put()), [])
+
+    def test_open_high_finding_forces_fail(self):
+        self.st["verdict"] = "PASS-WITH-NOTES"
+        self.st["findings"] = [{"id": "F1", "source": "MODEL", "severity": "high", "status": "OPEN"}]
+        self.assertTrue(any("FAIL" in e for e in stamp.validate(self.put())))
+
+    def test_incomplete_review_cannot_claim_complete(self):
+        self.st["model_reviewed"][0]["files_covered"] = 1
+        self.assertTrue(any("marked complete" in e for e in stamp.validate(self.put())))
+
+    def test_forbidden_words(self):
+        for w in ("pristine", "Approved", "certified"):
+            with self.subTest(w=w):
+                self.st["note"] = "this repo is %s" % w
+                self.assertTrue(any("forbidden word" in e for e in stamp.validate(self.put())))
+
+    def test_fork_requires_fork_diff(self):
+        self.st["subject"]["kind"] = "UPSTREAM-FORK"
+        self.st["subject"]["upstream"] = {"repository": "up/repo", "base_sha": "a" * 40}
+        self.assertTrue(any("fork-diff" in e for e in stamp.validate(self.put())))
+
+    def test_private_stamp_must_not_leak_name(self):
+        salts = {"private-01": {"name": "secret-thing", "salt": "ab" * 32}}
+        salts["private-01"]["commitment"] = stamp.commitment(salts["private-01"]["salt"], "secret-thing")
+        sp = os.path.join(self.tmp, "salts.json")
+        with open(sp, "w") as fh:
+            json.dump(salts, fh)
+        sub = self.st["subject"]
+        del sub["repository"]
+        sub.update(visibility="private", anonymous_id="private-01", name_commitment=salts["private-01"]["commitment"])
+        self.st["self_reported"] = True
+        self.assertEqual(stamp.validate(self.put(ident="private-01"), sp), [])
+        self.st["note"] = "see secret-thing for context"
+        self.assertTrue(any("private repository name" in e for e in stamp.validate(self.put(ident="private-01"), sp)))
+        del self.st["note"]
+        sub["name_commitment"] = "0" * 64
+        self.assertTrue(any("name_commitment" in e for e in stamp.validate(self.put(ident="private-01"), sp)))
+
+    def test_rerun_reproduces_and_detects_substitution(self):
+        d = self.put()
+        code, msgs = verify.rerun(d, self.repo, "", self.tools, lock_path=self.lock_path)
+        self.assertEqual((code, msgs), (0, []))
+        # negative control: a stamp whose recorded output was swapped (consistently, so the hash
+        # check alone passes) must fail the rerun
+        fake = b'{"swapped":true}\n'
+        self.st["deterministic_checked"]["checks"][0]["output_sha256"] = hashlib.sha256(fake).hexdigest()
+        d = self.put(files={"checks/C2-license.json": fake, "reviews/r.md": self.report})
+        self.assertEqual(stamp.validate(d), [])
+        code, msgs = verify.rerun(d, self.repo, "", self.tools, lock_path=self.lock_path)
+        self.assertEqual(code, 1)
+
+
+class TestStatus(Base):
+    def test_stale_sha_negative_control(self):
+        repo = os.path.join(self.tmp, "repo")
+        a = make_repo(repo, {"a.py": "1\n"})
+        b = commit(repo, {"a.py": "2\n"})
+        stamps = os.path.join(self.tmp, "stamps")
+        write_stamp(stamps, "repo", {"subject": {"visibility": "public", "repository": "repo", "commit": a},
+                                     "verdict": "PASS-WITH-NOTES", "stamped_at": "2026-10-26"}, {})
+        self.assertEqual(status.compute(stamps, "org", {"repo": a})["stamps"][0]["state"], "CURRENT")
+        self.assertEqual(status.compute(stamps, "org", {"repo": b})["stamps"][0]["state"], "STALE")
+        self.assertEqual(status.compute(stamps, "org", {})["stamps"][0]["state"], "UNKNOWN")
+
+    def test_private_is_not_checkable_and_older_superseded(self):
+        stamps = os.path.join(self.tmp, "stamps")
+        write_stamp(stamps, "private-01", {"subject": {"visibility": "private", "commit": "1" * 40},
+                                           "verdict": "PASS-WITH-NOTES", "stamped_at": "2026-10-26"}, {})
+        write_stamp(stamps, "repo", {"subject": {"visibility": "public", "commit": "2" * 40}, "stamped_at": "2026-10-01"}, {})
+        write_stamp(stamps, "repo", {"subject": {"visibility": "public", "commit": "3" * 40}, "stamped_at": "2026-10-26"}, {})
+        rows = status.compute(stamps, "org", {"repo": "3" * 40})["stamps"]
+        self.assertEqual([(r["id"], r["state"]) for r in rows],
+                         [("private-01", "NOT_CHECKABLE"), ("repo", "CURRENT"), ("repo", "SUPERSEDED")])
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/audit/tools/checks.py b/audit/tools/checks.py
new file mode 100755
index 0000000..9a7f4c7
--- /dev/null
+++ b/audit/tools/checks.py
@@ -0,0 +1,687 @@
+#!/usr/bin/env python3
+"""Deterministic audit checks for one repository at one commit.
+
+Usage:
+  checks.py <git-dir> <sha> --repo NAME --out DIR [--fork-base SHA] [--tools DIR] [--worktree DIR] [--only C1,C5]
+
+The tree is read raw from git objects (loc.materialize), never checked out.
+Each check writes DIR/<id>.json (normalized, sorted, no timestamps) and the
+summary DIR/checks.json lists, per check: tool and version, the exact command,
+status, counts, the sha256 of exactly the bytes written to DIR/<id>.json, and
+whether a second run on another machine must give the same hash (reproducible)
+or is a dated snapshot (advisory databases).
+
+Tools are pinned in tools.lock.json; a tool whose printed version differs from
+the lock is treated as missing, so a result is never produced by an unpinned tool.
+
+Status values:
+  PASS        tool ran over every target and reported nothing
+  FLAGGED     tool ran and reported items; each needs triage (recorded as findings in the stamp)
+  INCOMPLETE  tool ran but some targets were not analysed (parse errors, timeouts, one of two
+              scanners missing); the gaps are listed. Never counts as PASS.
+  NOT_RUN     tool could not run here (missing, wrong version, crashed); the reason is recorded
+A FLAGGED check is not a failure by itself: the stamp's findings say what each item was.
+Files that text checks did not read (binary, larger than TEXT_LIMIT, symlinks, submodules)
+are listed in checks.json under "not_scanned".
+"""
+import argparse, fnmatch, hashlib, ipaddress, json, os, re, shutil, subprocess, sys, tempfile
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import loc  # noqa: E402
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+TEXT_LIMIT = 2_000_000  # bytes; larger blobs are scanned by gitleaks only
+CHECKER_VERSION = "aien-audit-checks/3"
+LOCK_PATH = os.path.join(HERE, "tools.lock.json")
+
+
+def canonical(obj):
+    return json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode() + b"\n"
+
+
+def run(cmd, **kw):
+    return subprocess.run(cmd, capture_output=True, **kw)
+
+
+def ver(cmd):
+    try:
+        r = run(cmd, text=True, timeout=120)
+        return ((r.stdout or r.stderr).strip().splitlines() or [""])[0]
+    except Exception as e:  # noqa: BLE001
+        return "unavailable: " + type(e).__name__
+
+
+def load_lock(path=LOCK_PATH):
+    with open(path, "rb") as fh:
+        data = fh.read()
+    return json.loads(data), hashlib.sha256(data).hexdigest()
+
+
+class Ctx:
+    def __init__(self, gd, sha, repo, fork_base, tools, root, entries, cats, lock=None):
+        self.gd, self.sha, self.repo, self.fork_base, self.tools = gd, sha, repo, fork_base, tools
+        self.root, self.entries, self.cats = root, entries, cats
+        self.lock = lock if lock is not None else {"tools": {}}
+        self.not_scanned = {}  # path -> reason, for files the text checks could not read
+        self.extra_paths = []
+        self.wt = ""
+
+    def tool(self, name):
+        """Return (path, version, reason). path is None when the tool is missing or not the pinned version."""
+        p = os.path.join(self.tools, name)
+        p = p if os.path.exists(p) else shutil.which(os.path.basename(name))
+        if not p:
+            return None, "", f"{name} not installed"
+        pin = self.lock.get("tools", {}).get(name)
+        if not pin:
+            return None, "", f"{name} has no pin in tools.lock.json"
+        v = ver([p, *pin["version_cmd"]])
+        if not re.search(r"(?<![0-9.])%s(?![0-9])" % re.escape(pin["version"]), v):
+            return None, v, f"{name} reports {v!r}, tools.lock.json pins {pin['version']}"
+        return p, v, ""
+
+    def texts(self, categories=("first_party", "generated", "evidence")):
+        for p in self.paths(categories):
+            full = os.path.join(self.root, p)
+            if os.path.getsize(full) > TEXT_LIMIT:
+                self.not_scanned[p] = "larger than %d bytes" % TEXT_LIMIT
+                continue
+            with open(full, "rb") as fh:
+                data = fh.read()
+            if b"\0" in data[:8000]:
+                self.not_scanned[p] = "binary (NUL byte in first 8000 bytes)"
+                continue
+            yield p, data.decode("utf-8", "replace")
+
+    def paths(self, categories):
+        return [p for p in sorted(self.cats) if self.cats[p][0] in categories]
+
+
+def result(check, tool, version, command, items, reproducible=True, note="", status=None, payload=None):
+    """Summary entry plus the exact bytes to write. output_sha256 always covers those bytes."""
+    norm = canonical(items if payload is None else payload)
+    if status is None:
+        status = "FLAGGED" if items else "PASS"
+    return {"check": check, "tool": tool, "version": version, "command": command, "status": status,
+            "count": len(items) if isinstance(items, list) else None,
+            "output_sha256": hashlib.sha256(norm).hexdigest(), "reproducible": reproducible, "note": note}, norm
+
+
+def not_run(check, tool, reason, version="", reproducible=True):
+    return result(check, tool, version, "", [], status="NOT_RUN", note=reason, reproducible=reproducible)
+
+
+# C1: secrets over history ----------------------------------------------------------------------
+def c1(ctx):
+    gl, v, why = ctx.tool("gitleaks")
+    if not gl:
+        return not_run("C1-secrets", "gitleaks", why, v)
+    rng = f"{ctx.fork_base}..{ctx.sha}" if ctx.fork_base else ctx.sha
+    with tempfile.TemporaryDirectory() as t:
+        rep = os.path.join(t, "r.json")
+        cmd = [gl, "git", "--no-banner", "--redact", "--exit-code", "0", "--report-format", "json",
+               "--report-path", rep, "--log-opts", rng, ctx.gd]
+        r = run(cmd)
+        if r.returncode != 0 or not os.path.exists(rep):
+            return not_run("C1-secrets", "gitleaks", "gitleaks exit %d: %s" % (r.returncode, r.stderr.decode()[-300:]), v)
+        with open(rep) as fh:
+            raw = json.load(fh) or []
+    items = sorted({(f["RuleID"], f["File"], f["Commit"], f["StartLine"]) for f in raw})
+    items = [{"rule": a, "file": b, "commit": c, "line": d} for a, b, c, d in items]
+    cmd_s = f"gitleaks git --no-banner --redact --exit-code 0 --report-format json --log-opts {rng} <git-dir>"
+    return result("C1-secrets", "gitleaks", v, cmd_s, items,
+                  note="history reachable from the commit" + (" since the upstream merge-base" if ctx.fork_base else "")
+                  + "; secrets redacted by gitleaks; each hit is triaged in findings")
+
+
+# C2: license consistency -----------------------------------------------------------------------
+LICENSE_SIGS = [
+    ("AGPL-3.0", r"GNU AFFERO GENERAL PUBLIC LICENSE"),
+    ("LGPL", r"GNU LESSER GENERAL PUBLIC LICENSE"),
+    ("GPL", r"GNU GENERAL PUBLIC LICENSE"),
+    ("Apache-2.0", r"Apache License,?\s+Version 2\.0"),
+    ("MPL-2.0", r"Mozilla Public License,? (version|v\.?) ?2\.0"),
+    ("MIT", r"Permission is hereby granted, free of charge"),
+    ("BSD", r"Redistribution and use in source and binary forms"),
+    ("Unlicense", r"This is free and unencumbered software"),
+    ("CC-BY-4.0", r"Creative Commons Attribution 4\.0"),
+    ("CC0-1.0", r"CC0 1\.0 Universal"),
+    ("BSD-2-Clause-Patent", r"BSD-2-Clause-Patent"),
+    ("Community-Spec-1.0", r"Community Specification License 1\.0"),
+]
+# An SPDX expression: ids joined by AND/OR/WITH (either case), optional parens, ending the line or
+# comment. Prose that merely mentions the tag ("... GPL-2.0-only and remain under") does not match.
+_SPDX_ID = r"\(*[A-Za-z0-9.+\-]+\)*"
+SPDX_RE = re.compile(r"SPDX-License-Identifier:\s*(" + _SPDX_ID + r"(?:\s+(?:AND|OR|WITH|and|or|with)\s+"
+                     + _SPDX_ID + r")*)\s*(?:\*/|-->|$)", re.M)
+CARGO_RE = re.compile(r'^\s*license\s*=\s*"([^"]+)"', re.M)
+LICENSE_FILE_RE = re.compile(r"(?i)^((LICEN[SC]E|COPYING|UNLICENSE)([.-].*)?|.+\.LICEN[SC]E)$")
+
+
+def ident(text):
+    """Name the licence a licence file grants: an SPDX expression it declares in its first 1 KB wins;
+    otherwise the signature that appears EARLIEST in the text (a GPL text mentions the LGPL further down,
+    a dual-licence file names both). A file that opens with its own versioned licence title before the
+    first known signature (a custom licence wrapping Apache text) is UNRECOGNIZED, not the wrapped licence."""
+    m = SPDX_RE.search(text[:1000])
+    if m:
+        return m.group(1).strip()
+    text = re.sub(r"\s+", " ", text)  # reflowed licence text (license.rst) still matches its signature
+    hits = [(mm.start(), name) for name, rx in LICENSE_SIGS for mm in [re.search(rx, text, re.I)] if mm]
+    if not hits:
+        return "UNRECOGNIZED"
+    start, name = min(hits)
+    if re.search(r"\bLicen[sc]e,?\s+(v(ersion)?\.?\s*)?\d", text[:start], re.I):
+        return "UNRECOGNIZED"
+    return name
+
+
+def families(expr):
+    return set(re.findall(r"[A-Za-z0-9.\-+]+", expr)) - {"OR", "AND", "WITH", "or", "and", "with"}
+
+
+def c2(ctx):
+    # Licence files are read from the audited commit itself, not from the scanned file set: in fork-diff mode
+    # the upstream LICENSE is unchanged, so it is outside the diff but still governs the tree. A licence file
+    # in a subdirectory (adapters/x/LICENSE, om/tka/tailscale.LICENSE) also governs the files below it.
+    root_lic, dir_lic = {}, {}
+    for _mode, typ, _oid, p in loc.tree_entries(ctx.gd, ctx.sha):
+        base = p.rsplit("/", 1)[-1]
+        if typ != "blob" or not LICENSE_FILE_RE.match(base):
+            continue
+        name = ident(loc.git(ctx.gd, "cat-file", "blob", "%s:%s" % (ctx.sha, p)).decode("utf-8", "replace"))
+        if "/" not in p:
+            if not base.lower().endswith(".license"):
+                root_lic[p] = name
+        elif name != "UNRECOGNIZED":
+            dir_lic.setdefault(p.rsplit("/", 1)[0], set()).update(families(name))
+    spdx, manifests = {}, {}
+    for p, t in ctx.texts(("first_party",)):
+        for m in SPDX_RE.finditer(t[:4000]):
+            spdx.setdefault(m.group(1).strip(), []).append(p)
+        base = os.path.basename(p)
+        if base == "Cargo.toml":
+            for m in CARGO_RE.finditer(t):
+                manifests.setdefault(m.group(1), []).append(p)
+        elif base == "package.json":
+            try:
+                v = json.loads(t).get("license")
+                if isinstance(v, str):
+                    manifests.setdefault(v, []).append(p)
+            except ValueError:
+                pass
+        elif base == "pyproject.toml":
+            m = re.search(r'^\s*license\s*=\s*(?:\{\s*text\s*=\s*)?"([^"]+)"', t, re.M)
+            if m:
+                manifests.setdefault(m.group(1), []).append(p)
+    declared = set()
+    for name in root_lic.values():
+        if name != "UNRECOGNIZED":
+            declared |= families(name)
+    items = []
+    if not root_lic:
+        items.append({"kind": "no-root-license"})
+    for name, f in sorted(root_lic.items()):
+        # LICENSE/COPYING itself must be recognized; an extra root file (License-History.txt) only matters
+        # when nothing at the root is recognized.
+        stem = name.rsplit(".", 1)[0].upper()
+        if f == "UNRECOGNIZED" and (stem in ("LICENSE", "LICENCE", "COPYING") or not declared):
+            items.append({"kind": "unrecognized-root-license", "file": name})
+
+    def governing(path):
+        found = set(declared)
+        parts = path.split("/")[:-1]
+        for i in range(1, len(parts) + 1):
+            found |= dir_lic.get("/".join(parts[:i]), set())
+        return found
+
+    def compatible(expr, path):
+        toks = families(expr)
+        for d in governing(path):
+            for tk in toks:
+                if tk.upper().startswith(d.upper().split("-")[0]):
+                    return True
+        return False
+
+    for expr, ps in sorted(spdx.items()):
+        bad = sorted(p for p in ps if not compatible(expr, p))
+        if bad:
+            items.append({"kind": "spdx-differs-from-root", "spdx": expr, "files": len(bad), "examples": bad[:5]})
+    for expr, ps in sorted(manifests.items()):
+        bad = sorted(p for p in ps if not compatible(expr, p))
+        if bad:
+            items.append({"kind": "manifest-differs-from-root", "license": expr, "files": bad[:10]})
+    summary = {"root": root_lic, "spdx": {k: len(v) for k, v in sorted(spdx.items())},
+               "manifests": {k: len(v) for k, v in sorted(manifests.items())},
+               "nested": {d: sorted(v) for d, v in sorted(dir_lic.items())}}
+    payload = {"items": items, "summary": summary}
+    r, norm = result("C2-license", "checks.py", CHECKER_VERSION,
+                     "root and nested LICENSE text signatures vs SPDX headers (first 4 KB) vs Cargo.toml/package.json/pyproject license",
+                     items, payload=payload,
+                     note="heuristic match by license family; mismatches are decisions for the owner, not proof of violation")
+    r["summary"] = summary
+    return r, norm
+
+
+# C3: private paths, internal addresses, personal emails ---------------------------------------
+PRIV_PATTERNS = {
+    "home-path": re.compile(r"/home/[a-z_][a-z0-9_-]{1,31}/"),
+    "mac-user-path": re.compile(r"/Users/[A-Za-z][A-Za-z0-9._-]{0,31}/"),
+    "ipv4": re.compile(r"(?<![\d.])(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?![\d.])"),
+    "email": re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}"),
+}
+CGNAT = ipaddress.ip_network("100.64.0.0/10")
+RFC1918 = [ipaddress.ip_network(n) for n in ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16")]
+SAFE_EMAIL = re.compile(r"(noreply|no-reply|example\.(com|org|net)|users\.noreply\.github\.com|localhost|\.invalid$|\.test$)", re.I)
+ORG_EMAIL = re.compile(r"@aienos\.com$", re.I)
+
+
+def ip_class(s):
+    try:
+        ip = ipaddress.ip_address(s)
+    except ValueError:
+        return None
+    if ip in CGNAT:
+        return "ip-cgnat-tailnet"
+    if any(ip in n for n in RFC1918):
+        return "ip-rfc1918"
+    return None
+
+
+def c3(ctx):
+    items = []
+    for p, t in ctx.texts(("first_party", "generated", "evidence")):
+        cat = ctx.cats[p][0]
+        for n, line in enumerate(t.split("\n"), 1):
+            for kind, rx in PRIV_PATTERNS.items():
+                for m in rx.finditer(line):
+                    val = m.group(0)
+                    if kind == "ipv4":
+                        k = ip_class(m.group(1))
+                        if not k:
+                            continue
+                    elif kind == "email":
+                        if SAFE_EMAIL.search(val):
+                            continue
+                        k = "email-org-domain" if ORG_EMAIL.search(val) else "email"
+                    else:
+                        k = kind
+                    if k.startswith(("email", "ip-")):
+                        # published stamps must not re-broadcast addresses; the digest is still reproducible
+                        val = "sha256:" + hashlib.sha256(val.encode()).hexdigest()[:16]
+                    items.append({"kind": k, "file": p, "line": n, "category": cat, "value": val})
+    items.sort(key=lambda i: (i["file"], i["line"], i["kind"], i["value"]))
+    counts = {}
+    for i in items:
+        key = i["kind"] + "@" + i["category"]
+        counts[key] = counts.get(key, 0) + 1
+    r, norm = result("C3-privacy", "checks.py", CHECKER_VERSION,
+                     "regex: /home/<user>/, /Users/<user>/, 100.64.0.0/10 and RFC1918 IPv4, non-noreply emails; "
+                     "first_party+generated+evidence text files", items,
+                     note="presence is not proof of harm (paths in docs/evidence are often intended); each kind is triaged; "
+                          "email and IP values are recorded as sha256:<first 16 hex> of the matched text")
+    r["counts"] = dict(sorted(counts.items()))
+    return r, norm
+
+
+# C4: internal relative links in Markdown ------------------------------------------------------
+MD_LINK = re.compile(r"\[[^\]]*\]\(\s*<?([^)\s>]+)>?(?:\s+\"[^\"]*\")?\s*\)")
+INLINE_CODE = re.compile(r"`[^`]*`")
+
+
+def c4(ctx):
+    # Targets resolve against every path in the audited commit, not only the scanned set: in fork-diff mode
+    # a link from our file may point at an unchanged upstream file.
+    tracked = {e[3] for e in loc.tree_entries(ctx.gd, ctx.sha)}
+    dirs = set()
+    for p in tracked:
+        parts = p.split("/")
+        for i in range(1, len(parts)):
+            dirs.add("/".join(parts[:i]))
+    items = []
+    for p, t in ctx.texts(("first_party",)):
+        if not p.lower().endswith((".md", ".markdown")):
+            continue
+        in_code = False
+        for n, line in enumerate(t.split("\n"), 1):
+            if line.lstrip().startswith("```"):
+                in_code = not in_code
+                continue
+            if in_code:
+                continue
+            # inline code spans are not links (`alloc[T](n)` is call syntax); "[`x`](y)" keeps its target
+            for m in MD_LINK.finditer(INLINE_CODE.sub("", line)):
+                tgt = m.group(1)
+                if re.match(r"^[a-z][a-z0-9+.-]*:", tgt, re.I) or tgt.startswith("#") or tgt.startswith("//"):
+                    continue
+                path = tgt.split("#", 1)[0].split("?", 1)[0]
+                if not path:
+                    continue
+                from urllib.parse import unquote
+                path = unquote(path)
+                if path.startswith("/"):
+                    res = path.lstrip("/")
+                else:
+                    res = os.path.normpath(os.path.join(os.path.dirname(p), path)).replace(os.sep, "/")
+                res = res.rstrip("/")
+                if res.startswith(".."):
+                    items.append({"file": p, "line": n, "target": tgt, "reason": "escapes repository"})
+                elif res not in tracked and res not in dirs and res != ".":
+                    items.append({"file": p, "line": n, "target": tgt, "reason": "not in tree"})
+    items.sort(key=lambda i: (i["file"], i["line"], i["target"]))
+    return result("C4-internal-links", "checks.py", CHECKER_VERSION,
+                  "Markdown relative links resolved against the commit's tree (code fences and inline code skipped)", items,
+                  note="external URLs are not checked here (not reproducible)")
+
+
+# C5: semgrep static analysis -------------------------------------------------------------------
+def semgrep_error_type(e):
+    t = e.get("type", "")
+    # semgrep emits either "Timeout" or ["PartialParsing", [locations...]]
+    return str(t[0]) if isinstance(t, list) and t else str(t)
+
+
+def c5(ctx):
+    sg, v, why = ctx.tool("venv/bin/semgrep")
+    cfg = os.path.join(ctx.tools, "semgrep-config.yaml")
+    if not sg:
+        return not_run("C5-semgrep", "semgrep", why, v)
+    if not os.path.exists(cfg):
+        return not_run("C5-semgrep", "semgrep", "semgrep-config.yaml missing (build it with semgrep_config.py)", v)
+    with open(cfg, "rb") as fh:
+        cfg_sha = hashlib.sha256(fh.read()).hexdigest()
+    want = ctx.lock.get("semgrep_rules", {}).get("config_sha256")
+    if cfg_sha != want:
+        return not_run("C5-semgrep", "semgrep", f"semgrep-config.yaml sha256 {cfg_sha} != tools.lock.json {want}", v)
+    targets = ctx.paths(("first_party",))
+    if not targets:
+        return result("C5-semgrep", "semgrep", v, "", [], note="no first-party files")
+    with tempfile.TemporaryDirectory() as t:
+        rep = os.path.join(t, "out.json")
+        cmd = [sg, "scan", "--metrics", "off", "--disable-version-check", "--no-git-ignore", "--jobs", "2",
+               "--timeout", "30", "--max-target-bytes", str(TEXT_LIMIT), "--config", cfg, "--json", "--output", rep,
+               "--quiet"]
+        # Scan only first-party files: copy them into a separate tree so vendored code is excluded.
+        scan = os.path.join(t, "scan")
+        for p in targets:
+            dst = os.path.join(scan, p)
+            os.makedirs(os.path.dirname(dst), exist_ok=True)
+            shutil.copyfile(os.path.join(ctx.root, p), dst)
+        r = run(cmd + [scan], cwd=t, env={**os.environ, "SEMGREP_SEND_METRICS": "off"})
+        if not os.path.exists(rep):
+            return not_run("C5-semgrep", "semgrep", "semgrep exit %d: %s" % (r.returncode, r.stderr.decode()[-300:]), v)
+        try:
+            with open(rep) as fh:
+                out = json.load(fh)
+        except ValueError:
+            return not_run("C5-semgrep", "semgrep", "semgrep exit %d wrote unparsable JSON" % r.returncode, v)
+    items = sorted({(x["check_id"].split(".")[-1], os.path.relpath(x["path"], scan), x["start"]["line"],
+                     x["extra"].get("severity", "")) for x in out.get("results", [])})
+    items = [{"rule": a, "file": b, "line": c, "severity": d} for a, b, c, d in items]
+    errors = sorted({(semgrep_error_type(e), os.path.relpath(e["path"], scan) if e.get("path") else "")
+                     for e in out.get("errors", [])})
+    errors = [{"type": a, "file": b} for a, b in errors]
+    skipped = sorted({(os.path.relpath(s.get("path", scan), scan), str(s.get("reason", "")))
+                      for s in (out.get("paths", {}) or {}).get("skipped", []) or []})
+    skipped = [{"file": a, "reason": b} for a, b in skipped]
+    status = None
+    note = "pattern-based; hits are triaged. CodeQL is not part of this checker"
+    if errors or skipped or r.returncode not in (0, 1):
+        status = "INCOMPLETE"
+        note += "; %d error(s) and %d skipped target(s) listed in the output, exit %d" % (len(errors), len(skipped), r.returncode)
+    res, norm = result("C5-semgrep", "semgrep", v,
+                       "semgrep scan --metrics off --no-git-ignore --jobs 2 --timeout 30 --config semgrep-config.yaml "
+                       "(semgrep-rules @ pinned commit, ERROR+WARNING rules for bash/c/python/js/ts/rust/dockerfile/"
+                       "github-actions/generic secrets+ci) over first-party files", items, status=status, note=note,
+                       payload={"items": items, "errors": errors, "skipped": skipped})
+    res["errors"] = len(errors)
+    res["skipped_targets"] = len(skipped)
+    res["targets"] = len(targets)
+    res["config_sha256"] = cfg_sha
+    return res, norm
+
+
+# C6: workflow security ---------------------------------------------------------------------------
+def c6(ctx):
+    wfs = [p for p in sorted(ctx.cats) if re.match(r"^\.github/workflows/[^/]+\.ya?ml$", p)]
+    if not wfs:
+        r, n = result("C6-workflows", "zizmor+actionlint", "", "", [], note="no workflows in .github/workflows")
+        r["status"] = "PASS"
+        r["workflows"] = 0
+        return r, n
+    items, gaps = [], []
+    (zz, vz, wz), (al, va, wa) = ctx.tool("venv/bin/zizmor"), ctx.tool("actionlint")
+    wdir = os.path.join(ctx.root, ".github", "workflows")
+    if not zz:
+        gaps.append(wz)
+    else:
+        r = run([zz, "--offline", "--no-progress", "--format", "json", "--min-severity", "low", wdir])
+        # zizmor: 0 = no findings, 10..14 = findings by severity, anything else = the tool failed
+        try:
+            if r.returncode != 0 and not 10 <= r.returncode <= 14:
+                raise ValueError("exit %d" % r.returncode)
+            for f in json.loads(r.stdout or b"[]"):
+                loc0 = (f.get("locations") or [{}])[0]
+                sym = loc0.get("symbolic", {})
+                key = sym.get("key", {})
+                lk = key.get("Local", {}) if isinstance(key, dict) else {}
+                path = lk.get("verbatim_path") or lk.get("given_path") or ""
+                line = (loc0.get("concrete", {}).get("location", {}).get("start_point", {}) or {}).get("row", -1) + 1
+                items.append({"tool": "zizmor", "rule": f.get("ident", ""), "severity": f.get("determinations", {}).get("severity", ""),
+                              "file": os.path.relpath(path, ctx.root) if path.startswith("/") else path, "line": line})
+        except ValueError as e:
+            gaps.append("zizmor failed (%s): %s" % (e, r.stderr.decode("utf-8", "replace")[-200:]))
+    if not al:
+        gaps.append(wa)
+    else:
+        r = run([al, "-format", "{{json .}}", *[os.path.join(ctx.root, w) for w in wfs]], cwd=ctx.root)
+        # actionlint: 0 = clean, 1 = problems found, 2/3 = the tool failed
+        try:
+            if r.returncode not in (0, 1):
+                raise ValueError("exit %d" % r.returncode)
+            for e in json.loads(r.stdout or b"[]"):
+                items.append({"tool": "actionlint", "rule": e.get("kind", ""), "severity": "",
+                              "file": os.path.relpath(e.get("filepath", ""), ctx.root), "line": e.get("line", 0)})
+        except ValueError as e:
+            gaps.append("actionlint failed (%s): %s" % (e, r.stderr.decode("utf-8", "replace")[-200:]))
+    if len(gaps) == 2:
+        return not_run("C6-workflows", "zizmor+actionlint", "; ".join(gaps), f"{vz}; {va}")
+    items = [dict(t) for t in sorted({tuple(sorted(i.items())) for i in items})]
+    items.sort(key=lambda i: (i["tool"], i["file"], i["line"], i["rule"]))
+    res, norm = result("C6-workflows", "zizmor+actionlint", f"{vz}; {va}",
+                       "zizmor --offline --min-severity low .github/workflows; actionlint <workflows>", items,
+                       status="INCOMPLETE" if gaps else None, payload={"items": items, "gaps": gaps},
+                       note="zizmor offline mode: no online audits (e.g. known-vulnerable actions)"
+                            + ("; " + "; ".join(gaps) if gaps else ""))
+    res["workflows"] = len(wfs)
+    return res, norm
+
+
+# C8: claims without a resolvable citation ----------------------------------------------------
+CLAIM = re.compile(r"\b(PASS(ED)?|QUALIFIED|VERIFIED|DEPLOYED|PRODUCTION[- ]READY|BATTLE[- ]TESTED|100% )\b")
+CITE = re.compile(r"(\]\(|https?://|`[^`]*[/.][^`]*`|\b[0-9a-f]{7,40}\b|#\d+|\b[\w./-]+\.(json|log|md|txt|jsonl|sh|om|rs|c|py)\b|NOT_RUN|PROPOSED)")
+
+
+def c8(ctx):
+    items = []
+    for p, t in ctx.texts(("first_party",)):
+        if not p.lower().endswith(".md") or p.count("/") > 1:
+            continue
+        in_code = False
+        for n, line in enumerate(t.split("\n"), 1):
+            if line.lstrip().startswith("```"):
+                in_code = not in_code
+                continue
+            if in_code or not CLAIM.search(line):
+                continue
+            if not CITE.search(line):
+                items.append({"file": p, "line": n, "text": line.strip()[:160]})
+    return result("C8-uncited-claims", "checks.py", CHECKER_VERSION,
+                  "top-level and one-deep Markdown lines containing PASS/QUALIFIED/VERIFIED/DEPLOYED/PRODUCTION-READY "
+                  "with no link, path, commit sha or issue reference on the same line", items,
+                  note="heuristic: a hit means the line itself cites nothing, not that the claim is false")
+
+
+# C9: crumb structure -----------------------------------------------------------------------------
+def c9(ctx):
+    crumbs = [p for p in ctx.cats if os.path.basename(p) == ".crumb"]
+    if not crumbs:
+        return result("C9-crumb", "crumb", "", "", [], status="PASS", note="no .crumb files")
+    pin = ctx.lock.get("crumb", {})
+    tool = "crumb (%s@%s %s)" % (pin.get("repository", "?"), pin.get("commit", "?"), pin.get("source", "?"))
+    if not ctx.wt:
+        return not_run("C9-crumb", tool, "no worktree given")
+    wt_head = run(["git", "-C", ctx.wt, "rev-parse", "HEAD"]).stdout.decode().strip()
+    if wt_head != ctx.sha or run(["git", "-C", ctx.wt, "status", "--porcelain"]).stdout.strip():
+        return not_run("C9-crumb", tool, "worktree is not a clean checkout of the audited commit (HEAD %s)" % wt_head[:12])
+    cr, src = os.path.join(ctx.tools, "crumb-arch"), os.path.join(ctx.tools, "crumb.c")
+    if not (os.path.exists(cr) and os.path.exists(src)):
+        return not_run("C9-crumb", tool, "crumb-arch binary or its crumb.c source missing from the tools directory")
+    with open(src, "rb") as fh:
+        src_sha = hashlib.sha256(fh.read()).hexdigest()
+    if src_sha != pin.get("source_sha256"):
+        return not_run("C9-crumb", tool, f"crumb.c sha256 {src_sha} != tools.lock.json {pin.get('source_sha256')}")
+    r = run([cr, "verify", ctx.wt], cwd=ctx.wt)
+    out = (r.stdout + r.stderr).decode("utf-8", "replace")
+    out = out.replace(ctx.wt, "<worktree>")
+    items = [] if r.returncode == 0 else [{"exit": r.returncode, "output": out.strip()[-2000:]}]
+    res, norm = result("C9-crumb", tool, "source sha256 " + src_sha,
+                       "crumb verify <worktree at commit>", items,
+                       note="RFC-0003: committed crumb data equals what compile would write")
+    res["crumb_files"] = len(crumbs)
+    return res, norm
+
+
+# C11: dependency advisories (snapshot) ----------------------------------------------------------
+def c11(ctx):
+    osv, v, why = ctx.tool("osv-scanner")
+    if not osv:
+        return not_run("C11-dep-advisories", "osv-scanner", why, v, reproducible=False)
+    with tempfile.TemporaryDirectory() as t:
+        scan = os.path.join(t, "scan")
+        n = 0
+        for p in ctx.paths(("first_party", "generated")):
+            if os.path.basename(p) in LOCKFILES:
+                dst = os.path.join(scan, p)
+                os.makedirs(os.path.dirname(dst), exist_ok=True)
+                shutil.copyfile(os.path.join(ctx.root, p), dst)
+                n += 1
+        if not n:
+            return result("C11-dep-advisories", "osv-scanner", v, "", [], reproducible=False, note="no lockfiles")
+        r = run([osv, "scan", "source", "-r", "--format", "json", scan])
+        # osv-scanner: 0 = no vulnerabilities, 1 = vulnerabilities found, 128 = no packages found, other = error
+        if r.returncode not in (0, 1):
+            why = "no packages parsed from %d lockfile(s)" % n if r.returncode == 128 else "osv-scanner failed"
+            return not_run("C11-dep-advisories", "osv-scanner",
+                           "%s (exit %d): %s" % (why, r.returncode, r.stderr.decode("utf-8", "replace")[-300:]), v,
+                           reproducible=False)
+        try:
+            out = json.loads(r.stdout or b"")
+        except ValueError:
+            return not_run("C11-dep-advisories", "osv-scanner", "exit %d with unparsable JSON" % r.returncode, v,
+                           reproducible=False)
+    items = []
+    for res in out.get("results", []) or []:
+        src = os.path.relpath(res["source"]["path"], scan)
+        for pk in res.get("packages", []):
+            for vv in pk.get("vulnerabilities", []):
+                items.append({"lockfile": src, "package": pk["package"]["name"], "version": pk["package"].get("version", ""),
+                              "id": vv["id"]})
+    items = sorted(items, key=lambda i: (i["lockfile"], i["package"], i["version"], i["id"]))
+    if r.returncode == 1 and not items:
+        return not_run("C11-dep-advisories", "osv-scanner", "exit 1 (vulnerabilities) but none parsed from JSON", v,
+                       reproducible=False)
+    res, norm = result("C11-dep-advisories", "osv-scanner", v,
+                       "osv-scanner scan source -r --format json <lockfiles>", items, reproducible=False,
+                       note=f"{n} lockfile(s); OSV database queried online at run time, so results are a dated snapshot")
+    res["lockfiles"] = n
+    return res, norm
+
+
+LOCKFILES = ("Cargo.lock", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "poetry.lock", "uv.lock", "Pipfile.lock",
+             "go.sum", "requirements.txt", "Gemfile.lock", "composer.lock")
+
+
+CHECKS = {"C1": c1, "C2": c2, "C3": c3, "C4": c4, "C5": c5, "C6": c6, "C8": c8, "C9": c9, "C11": c11}
+CHECK_NAMES = {"C1": "C1-secrets", "C2": "C2-license", "C3": "C3-privacy", "C4": "C4-internal-links", "C5": "C5-semgrep",
+               "C6": "C6-workflows", "C8": "C8-uncited-claims", "C9": "C9-crumb", "C11": "C11-dep-advisories"}
+
+
+def checker_sha256():
+    h = hashlib.sha256()
+    for name in ("checks.py", "loc.py"):
+        with open(os.path.join(HERE, name), "rb") as fh:
+            h.update(name.encode() + b"\0" + hashlib.sha256(fh.read()).hexdigest().encode() + b"\n")
+    return h.hexdigest()
+
+
+def run_all(gd, sha, repo, out, fork_base="", tools=HERE, worktree="", only="", lock_path=LOCK_PATH):
+    sha = loc.git(gd, "rev-parse", sha + "^{commit}").decode().strip()
+    if fork_base:
+        fork_base = loc.git(gd, "rev-parse", fork_base + "^{commit}").decode().strip()
+    lock, lock_sha = load_lock(lock_path)
+    extra = []
+    cj = os.path.join(HERE, "classify.json")
+    if os.path.exists(cj):
+        with open(cj) as fh:
+            extra = json.load(fh).get(repo, [])
+    entries, not_scanned = [], {}
+    for mode, typ, oid, path in loc.tree_entries(gd, sha):
+        if typ == "blob" and mode != "120000":
+            entries.append((mode, typ, oid, path))
+        else:
+            not_scanned[path] = "submodule (gitlink)" if typ == "commit" else "symlink"
+    if fork_base:
+        diff = loc.git(gd, "diff", "--no-renames", "-z", "--name-only", "--diff-filter=AM", fork_base, sha).split(b"\0")
+        keep = {d.decode("utf-8", "surrogateescape") for d in diff if d}
+        entries = [e for e in entries if e[3] in keep]
+        not_scanned = {p: r for p, r in not_scanned.items() if p in keep}
+    os.makedirs(out, exist_ok=True)
+    at = loc.attrs(gd, sha, [e[3] for e in entries])
+    with tempfile.TemporaryDirectory(prefix="aien-checks-") as root:
+        heads = loc.materialize(gd, entries, root)
+        cats = {p: loc.classify(p, heads[p][0], at.get(p, set()), extra) for p in heads}
+        ctx = Ctx(gd, sha, repo, fork_base, tools, root, entries, cats, lock)
+        ctx.extra_paths = list(not_scanned)
+        ctx.wt = worktree
+        summary = []
+        for cid, fn in CHECKS.items():
+            if only and cid not in only.split(","):
+                continue
+            try:
+                r, norm = fn(ctx)
+            except Exception as e:  # noqa: BLE001 - a crashed check is NOT_RUN, never a silent gap
+                r, norm = not_run(CHECK_NAMES[cid], "checks.py", "checker crashed: %s: %s" % (type(e).__name__, str(e)[:300]))
+            with open(os.path.join(out, r["check"] + ".json"), "wb") as fh:
+                fh.write(norm)
+            summary.append(r)
+            print(f"{repo} {r['check']} {r['status']} {r['count']}", file=sys.stderr)
+        not_scanned.update(ctx.not_scanned)
+    doc = {"schema": "aien-audit-checks/2", "repository": repo, "commit": sha,
+           "mode": "fork-diff" if fork_base else "full-tree", "fork_base": fork_base or None,
+           "checker": {"version": CHECKER_VERSION, "sha256": checker_sha256()}, "tools_lock_sha256": lock_sha,
+           "files": len(entries), "checks": summary,
+           "not_scanned": [{"path": p, "reason": not_scanned[p]} for p in sorted(not_scanned)]}
+    data = canonical(doc)
+    with open(os.path.join(out, "checks.json"), "wb") as fh:
+        fh.write(data)
+    return doc
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("gitdir")
+    ap.add_argument("sha")
+    ap.add_argument("--repo", required=True)
+    ap.add_argument("--out", required=True)
+    ap.add_argument("--fork-base", default="")
+    ap.add_argument("--tools", default=os.environ.get("AUDIT_TOOLS", HERE))
+    ap.add_argument("--worktree", default="", help="checkout at <sha> for tools that need a work tree (crumb)")
+    ap.add_argument("--only", default="")
+    ap.add_argument("--lock", default=LOCK_PATH)
+    a = ap.parse_args()
+    run_all(a.gitdir, a.sha, a.repo, a.out, a.fork_base, a.tools, a.worktree, a.only, a.lock)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/install_tools.py b/audit/tools/install_tools.py
new file mode 100755
index 0000000..441fe7e
--- /dev/null
+++ b/audit/tools/install_tools.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+"""Install the pinned audit tools into DIR, refusing anything whose sha256 differs from tools.lock.json.
+
+Usage: install_tools.py DIR [--arch linux_amd64|linux_arm64]
+
+Downloads each binary named in the lock and checks the publisher's sha256 before
+unpacking; installs semgrep and zizmor into DIR/venv with exact == version pins
+(pip does not hash-check these; checks.py re-checks the printed versions); fetches semgrep-rules at the locked commit and rebuilds
+semgrep-config.yaml (semgrep_config.py checks its sha256); fetches crumb.c at the
+locked commit, checks its sha256 and builds DIR/crumb-arch. Exit 1 on any mismatch.
+"""
+import argparse, hashlib, io, json, os, platform, shutil, subprocess, sys, tarfile, urllib.request
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+
+
+def fetch(url):
+    with urllib.request.urlopen(url, timeout=120) as r:
+        return r.read()
+
+
+def run(*cmd, **kw):
+    subprocess.run(cmd, check=True, **kw)
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("dir")
+    ap.add_argument("--arch", default={"x86_64": "linux_amd64", "aarch64": "linux_arm64"}.get(platform.machine(), ""))
+    ap.add_argument("--only", default="", help="comma-separated binary names; skips pip, semgrep-rules and crumb")
+    a = ap.parse_args()
+    with open(os.path.join(HERE, "tools.lock.json")) as fh:
+        lock = json.load(fh)
+    os.makedirs(a.dir, exist_ok=True)
+    only = set(filter(None, a.only.split(",")))
+    for name, t in lock["tools"].items():
+        if only and name not in only:
+            continue
+        if "downloads" in t:
+            d = t["downloads"].get(a.arch)
+            if not d:
+                sys.exit("%s: no pinned download for %s" % (name, a.arch))
+            data = fetch(d["url"])
+            got = hashlib.sha256(data).hexdigest()
+            if got != d["sha256"]:
+                sys.exit("%s: sha256 %s != lock %s" % (name, got, d["sha256"]))
+            dest = os.path.join(a.dir, name)
+            if "member" in d:
+                with tarfile.open(fileobj=io.BytesIO(data)) as tf:
+                    m = tf.getmember(d["member"])
+                    with tf.extractfile(m) as src, open(dest, "wb") as out:
+                        shutil.copyfileobj(src, out)
+            else:
+                with open(dest, "wb") as out:
+                    out.write(data)
+            os.chmod(dest, 0o755)
+            print("%s %s %s" % (got, name, t["version"]))
+    if only:
+        return
+    venv = os.path.join(a.dir, "venv")
+    run(sys.executable, "-m", "venv", venv)
+    pins = [t["pip"] for t in lock["tools"].values() if "pip" in t] + ["pyyaml==" + lock["semgrep_rules"]["pyyaml"]]
+    run(os.path.join(venv, "bin", "pip"), "install", "--quiet", *pins)
+    sr = lock["semgrep_rules"]
+    rules = os.path.join(a.dir, "semgrep-rules")
+    run("git", "init", "-q", rules)
+    run("git", "-C", rules, "fetch", "-q", "--depth", "1", sr["repository"], sr["commit"])
+    run("git", "-C", rules, "checkout", "-q", "FETCH_HEAD")
+    run(os.path.join(venv, "bin", "python"), os.path.join(HERE, "semgrep_config.py"), rules,
+        os.path.join(a.dir, "semgrep-config.yaml"))
+    cr = lock["crumb"]
+    url = cr["repository"].replace("https://github.com/", "https://raw.githubusercontent.com/") + "/%s/%s" % (cr["commit"], cr["source"])
+    src = fetch(url)
+    got = hashlib.sha256(src).hexdigest()
+    if got != cr["source_sha256"]:
+        sys.exit("crumb.c sha256 %s != lock %s" % (got, cr["source_sha256"]))
+    with open(os.path.join(a.dir, "crumb.c"), "wb") as fh:
+        fh.write(src)
+    run("cc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror", "-o", os.path.join(a.dir, "crumb-arch"),
+        os.path.join(a.dir, "crumb.c"))
+    print("%s crumb.c" % got)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/loc.py b/audit/tools/loc.py
new file mode 100755
index 0000000..61a703b
--- /dev/null
+++ b/audit/tools/loc.py
@@ -0,0 +1,315 @@
+#!/usr/bin/env python3
+"""Deterministic line-of-code count for one repository at one commit.
+
+Usage:
+  loc.py <git-dir> <sha> [--repo NAME] [--fork-base SHA] [--scc PATH] [--out FILE]
+
+Only the tracked blobs of <sha> are counted, read raw from the object store
+(no checkout, no .gitignore, no line-ending filters), so two machines with the
+same pinned scc get the same bytes out. Omega (.om) is counted here because scc
+has no Omega definition: a line is blank when it holds only whitespace, a
+comment when its first word is `note`, and code otherwise.
+
+Every file is put in exactly one category:
+  first_party  - our own source
+  vendored     - copied third-party code (vendor/, third_party/, linguist-vendored, ...)
+  generated    - machine-written files (generated markers, linguist-generated, lockfiles, *.min.*)
+  evidence     - recorded run artifacts under evidence/ or receipts/ trees
+The rules are in RULES below and in classify.json (per-repository additions).
+"""
+import argparse, fnmatch, hashlib, json, os, re, subprocess, sys, tempfile
+
+TOOL_VERSION = "aien-audit-loc/2"
+
+# Languages that are data, markup, prose or styling, not executable code.
+NON_EXECUTABLE = {
+    "JSON", "JSONL", "JSONC", "YAML", "TOML", "INI", "XML", "SVG", "HTML", "XHTML", "CSS", "SCSS", "Sass", "LESS",
+    "Markdown", "Plain Text", "Text", "ReStructuredText", "AsciiDoc", "Org", "TeX", "LaTeX", "BibTeX",
+    "CSV", "TSV", "License", "gitignore", "gitattributes", "Gitignore", "Docker ignore", "Properties File",
+    "Jupyter", "Patch", "Diff", "Unknown", "Protocol Buffers", "Cap'n Proto", "Device Tree", "Rich Text Format",
+    "Wiki", "Systemd", "Hex", "Intel HEX", "Mustache", "Handlebars", "Jinja", "Twig", "Liquid",
+}
+VENDOR_DIRS = {"vendor", "vendored", "third_party", "third-party", "thirdparty", "3rdparty", "node_modules",
+               "external", "extern", "deps", "bower_components", ".cargo-vendor"}
+EVIDENCE_DIRS = {"evidence", "receipts"}
+GENERATED_NAMES = {"Cargo.lock", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "poetry.lock", "uv.lock",
+                   "Pipfile.lock", "go.sum", "composer.lock", "Gemfile.lock", "bun.lockb", "flake.lock"}
+GENERATED_GLOBS = ["*.min.js", "*.min.css", "*.min.mjs", "*.map", "*.pb.go", "*_pb2.py"]
+GENERATED_MARKER = re.compile(rb"(@generated|do not edit|auto-generated|autogenerated|code generated by)", re.I)
+
+SCC_FLAGS = ["--no-ignore", "--no-gitignore", "--no-gitmodule", "--no-scc-ignore", "--no-config",
+             "--no-cocomo", "--no-complexity", "--no-size", "--by-file", "--format", "json",
+             "--exclude-file", "", "--count-as-pattern", "*.osc:OSC (legacy Omega):Rust"]
+
+
+def git(gd, *args, inp=None):
+    return subprocess.run(["git", "-C", gd, *args], input=inp, capture_output=True, check=True).stdout
+
+
+def tree_entries(gd, sha):
+    out = git(gd, "ls-tree", "-r", "-z", "--full-tree", sha)
+    for rec in out.split(b"\0"):
+        if not rec:
+            continue
+        meta, path = rec.split(b"\t", 1)
+        mode, typ, oid = meta.split(b" ")
+        yield mode.decode(), typ.decode(), oid.decode(), path.decode("utf-8", "surrogateescape")
+
+
+def attrs(gd, sha, paths):
+    if not paths:
+        return {}
+    inp = "\0".join(paths).encode("utf-8", "surrogateescape") + b"\0"
+    out = git(gd, "check-attr", "-z", "--source", sha, "--stdin", "linguist-vendored", "linguist-generated",
+              "linguist-documentation", inp=inp)
+    f = out.split(b"\0")
+    res = {}
+    for i in range(0, len(f) - 2, 3):
+        p, a, v = f[i].decode("utf-8", "surrogateescape"), f[i + 1].decode(), f[i + 2].decode()
+        if v in ("set", "true"):
+            res.setdefault(p, set()).add(a)
+    return res
+
+
+def classify(path, head, attr, extra):
+    parts = path.split("/")
+    for rule in extra:
+        if fnmatch.fnmatchcase(path, rule["glob"]):
+            return rule["category"], "classify.json: " + rule["reason"]
+    if "linguist-vendored" in attr:
+        return "vendored", ".gitattributes linguist-vendored"
+    if "linguist-generated" in attr:
+        return "generated", ".gitattributes linguist-generated"
+    for d in parts[:-1]:
+        if d in VENDOR_DIRS:
+            return "vendored", "directory " + d + "/"
+    for d in parts[:-1]:
+        if d in EVIDENCE_DIRS:
+            return "evidence", "directory " + d + "/"
+    name = parts[-1]
+    if name in GENERATED_NAMES:
+        return "generated", "lockfile"
+    for g in GENERATED_GLOBS:
+        if fnmatch.fnmatchcase(name, g):
+            return "generated", "pattern " + g
+    if GENERATED_MARKER.search(head):
+        return "generated", "generated marker in first 5 lines"
+    return "first_party", ""
+
+
+def count_omega(data):
+    blank = comment = code = 0
+    for line in data.split(b"\n") if data else []:
+        s = line.strip()
+        if not s:
+            blank += 1
+        elif s.split(None, 1)[0] == b"note":
+            comment += 1
+        else:
+            code += 1
+    if data.endswith(b"\n"):
+        blank -= 1  # the empty string after the final newline is not a line
+    return blank, comment, code
+
+
+def materialize(gd, entries, root):
+    oids = [e[2] for e in entries]
+    if not oids:
+        return {}
+    heads = {}
+    # a file, not a pipe: writing every request first would deadlock on large trees
+    with tempfile.TemporaryFile() as req:
+        req.write(("\n".join(oids) + "\n").encode())
+        req.seek(0)
+        with subprocess.Popen(["git", "-C", gd, "cat-file", "--batch"], stdin=req, stdout=subprocess.PIPE) as p:
+            for (_, _, oid, path) in entries:
+                hdr = p.stdout.readline().split()
+                if len(hdr) != 3 or hdr[0].decode() != oid:
+                    raise ValueError("git cat-file: %s for %s" % (b" ".join(hdr).decode(errors="replace"), path))
+                data = p.stdout.read(int(hdr[2]))
+                p.stdout.read(1)
+                full = os.path.join(root, path)
+                os.makedirs(os.path.dirname(full), exist_ok=True)
+                with open(full, "wb") as fh:
+                    fh.write(data)
+                heads[path] = (b"\n".join(data.split(b"\n", 5)[:5]), data if path.endswith(".om") else None)
+    if p.returncode != 0:
+        raise ValueError("git cat-file exit %d" % p.returncode)
+    return heads
+
+
+def run_scc(scc, root):
+    out = subprocess.run([scc, *SCC_FLAGS, root], capture_output=True, check=True).stdout
+    per_file = {}
+    for lang in json.loads(out or b"[]"):
+        for f in lang.get("Files") or []:
+            rel = os.path.relpath(f["Location"], root)
+            per_file[rel] = (lang["Name"], f["Blank"], f["Comment"], f["Code"])
+    return per_file
+
+
+def scc_version(scc):
+    return subprocess.run([scc, "--version"], capture_output=True, text=True).stdout.strip()
+
+
+def fork_added_lines(gd, base, sha, paths):
+    """Non-blank lines added by our commits to each modified upstream file (git diff -U0, no renames)."""
+    if not paths:
+        return {}
+    out = git(gd, "-c", "core.quotePath=false", "diff", "--no-renames", "--no-color", "--no-ext-diff", "-U0",
+              "--src-prefix=a/", "--dst-prefix=b/", base, sha, "--", *[":(literal)" + p for p in paths])
+    counts, cur, in_header = {}, None, False
+    for line in out.split(b"\n"):
+        if line.startswith(b"diff --git "):
+            in_header, cur = True, None
+        elif in_header and line.startswith(b"+++ "):
+            name = line[4:].rstrip(b"\t")  # git appends a tab to names that contain a space
+            cur = None if name == b"/dev/null" else name[2:].decode("utf-8", "surrogateescape")
+            if cur is not None:
+                counts.setdefault(cur, 0)
+        elif line.startswith(b"@@"):
+            in_header = False
+        elif not in_header and line.startswith(b"+") and cur is not None and line[1:].strip():
+            counts[cur] += 1
+    return counts
+
+
+def org_totals(docs):
+    """Org-wide totals over per-repository results. `distinct` counts each blob once across repositories,
+    so code copied between repositories is not counted twice."""
+    total = {"repositories": len(docs), "first_party_executable_code": 0, "first_party_code_all": 0,
+             "distinct_first_party_executable_code": 0, "distinct_first_party_code_all": 0, "by_language": {}}
+    seen = set()
+    for d in sorted(docs, key=lambda d: d["repository"]):
+        for f in d["files"]:
+            if f["category"] != "first_party":
+                continue
+            total["first_party_code_all"] += f["code"]
+            if f["executable"]:
+                total["first_party_executable_code"] += f["code"]
+            # a fork-modified file's count is a diff, not the blob's content, so it is never deduplicated
+            key = (f["blob"], f["language"]) if not f.get("fork_modified") else (d["repository"], f["path"])
+            if key in seen:
+                continue
+            seen.add(key)
+            total["distinct_first_party_code_all"] += f["code"]
+            if f["executable"]:
+                total["distinct_first_party_executable_code"] += f["code"]
+                bl = total["by_language"].setdefault(f["language"], 0)
+                total["by_language"][f["language"]] = bl + f["code"]
+    total["by_language"] = dict(sorted(total["by_language"].items(), key=lambda kv: (-kv[1], kv[0])))
+    return total
+
+
+def count(gd, sha, repo, fork_base, scc, extra):
+    sha = git(gd, "rev-parse", sha + "^{commit}").decode().strip()
+    tree = git(gd, "rev-parse", sha + "^{tree}").decode().strip()
+    entries, skipped = [], {"gitlink": 0, "symlink": 0, "binary_or_unknown_language": 0}
+    for mode, typ, oid, path in tree_entries(gd, sha):
+        if typ == "commit":
+            skipped["gitlink"] += 1
+        elif mode == "120000":
+            skipped["symlink"] += 1
+        else:
+            entries.append((mode, typ, oid, path))
+    changed, added_lines = None, {}
+    if fork_base:
+        fork_base = git(gd, "rev-parse", fork_base + "^{commit}").decode().strip()
+        diff = git(gd, "diff", "--no-renames", "-z", "--name-status", fork_base, sha).split(b"\0")
+        changed = {}
+        for i in range(0, len(diff) - 1, 2):
+            st = diff[i].decode()
+            if st and st[0] in "AM":
+                changed[diff[i + 1].decode("utf-8", "surrogateescape")] = st[0]
+        entries = [e for e in entries if e[3] in changed]
+        added_lines = fork_added_lines(gd, fork_base, sha, sorted(p for p, s in changed.items() if s == "M"))
+    oids = {e[3]: e[2] for e in entries}
+    paths = [e[3] for e in entries]
+    at = attrs(gd, sha, paths)
+    with tempfile.TemporaryDirectory(prefix="aien-loc-") as root:
+        heads = materialize(gd, entries, root)
+        per_file = run_scc(scc, root)
+    files = []
+    for p in sorted(paths):
+        head, omdata = heads[p]
+        if p.endswith(".om"):
+            b, c, k = count_omega(omdata)
+            lang = ("Omega", b, c, k)
+        else:
+            lang = per_file.get(p)
+        if lang is None:
+            skipped["binary_or_unknown_language"] += 1
+            continue
+        cat, why = classify(p, head, at.get(p, set()), extra)
+        name, b, c, k = lang
+        rec = {"path": p, "blob": oids[p], "language": name, "category": cat, "reason": why,
+               "code": k, "comment": c, "blank": b, "executable": name not in NON_EXECUTABLE}
+        if fork_base and changed.get(p) == "M":
+            # A diff hunk has no language context, so comments cannot be told from code here:
+            # count every non-blank line our commits added to the upstream file.
+            rec.update({"code": added_lines.get(p, 0), "comment": 0, "blank": 0, "fork_modified": True})
+        files.append(rec)
+    summary = {}
+    for f in files:
+        cat = summary.setdefault(f["category"], {"files": 0, "code_executable": 0, "code_all": 0, "by_language": {}})
+        cat["files"] += 1
+        cat["code_all"] += f["code"]
+        if f["executable"]:
+            cat["code_executable"] += f["code"]
+        bl = cat["by_language"].setdefault(f["language"], {"files": 0, "code": 0, "comment": 0, "blank": 0,
+                                                            "executable": f["executable"]})
+        bl["files"] += 1
+        bl["code"] += f["code"]
+        bl["comment"] += f["comment"]
+        bl["blank"] += f["blank"]
+    result = {
+        "schema": "aien-audit-loc/2",
+        "repository": repo,
+        "commit": sha,
+        "tree": tree,
+        "mode": "fork-diff" if fork_base else "full-tree",
+        "fork_base": fork_base,
+        "tools": {"counter": TOOL_VERSION, "scc": scc_version(scc)},
+        "definition": "code = lines that are neither blank nor comment; executable = language not in NON_EXECUTABLE "
+                      "(data, markup, prose, styling); Omega .om counted by this script (comment = first word `note`)."
+                      + (" Fork mode: files we added count in full; for upstream files we modified, code = non-blank "
+                         "lines added relative to the upstream merge-base (comments included, deletions not subtracted)."
+                         if fork_base else ""),
+        "skipped": skipped,
+        "first_party_executable_code": summary.get("first_party", {}).get("code_executable", 0),
+        "categories": summary,
+        "files": files,
+    }
+    return result
+
+
+def canonical(obj):
+    return json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode() + b"\n"
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("gitdir")
+    ap.add_argument("sha")
+    ap.add_argument("--repo", default="")
+    ap.add_argument("--fork-base", default="")
+    ap.add_argument("--scc", default=os.environ.get("SCC", "scc"))
+    ap.add_argument("--classify", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "classify.json"))
+    ap.add_argument("--out", default="-")
+    a = ap.parse_args()
+    extra = []
+    if os.path.exists(a.classify):
+        extra = json.load(open(a.classify)).get(a.repo, [])
+    res = count(a.gitdir, a.sha, a.repo, a.fork_base, a.scc, extra)
+    data = canonical(res)
+    if a.out == "-":
+        sys.stdout.buffer.write(data)
+    else:
+        with open(a.out, "wb") as fh:
+            fh.write(data)
+    print(json.dumps({"repository": a.repo, "commit": res["commit"], "first_party_executable_code":
+                      res["first_party_executable_code"], "sha256": hashlib.sha256(data).hexdigest()}), file=sys.stderr)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/loc_live.py b/audit/tools/loc_live.py
new file mode 100755
index 0000000..8bd0740
--- /dev/null
+++ b/audit/tools/loc_live.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python3
+"""Recount the org's lines of code at every public default-branch HEAD.
+
+Usage:
+  loc_live.py --config audit/loc/repos.json --tools DIR --latest audit/loc/latest.json
+              --history audit/loc/history.jsonl [--date YYYY-MM-DD] [--work DIR] [--no-discover]
+
+repos.json names the public repositories and, for each fork, the upstream repository
+and the upstream merge-base we diverged from. Every public repository the GitHub API
+lists for the org is counted; one missing from repos.json is counted as first-party
+full-tree if it is not a fork, and is NOT_COUNTED (with the reason) if it is a fork
+without a pinned base, so new repositories never vanish from the total silently.
+
+Each repository is fetched at its HEAD and counted with loc.py (forks in fork-diff
+mode against the pinned base, which must still be an ancestor of HEAD; otherwise
+the fork is NOT_COUNTED until the base is re-pinned). Totals come from
+loc.org_totals: `distinct_*` counts each identical blob once across repositories.
+
+latest.json carries no clock time, so an unchanged org rewrites identical bytes.
+history.jsonl gains one line, stamped with --date, only when a HEAD or a total moved.
+Private repositories are not counted here; nobody outside can re-run them.
+Exit 0 when every listed repository was counted, 3 when any is NOT_COUNTED.
+"""
+import argparse, datetime, hashlib, json, os, subprocess, sys, tempfile, urllib.request
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, HERE)
+import loc  # noqa: E402
+
+
+def git(*args, cwd=None):
+    return subprocess.run(["git", *args], cwd=cwd, capture_output=True, check=True,
+                          env=dict(os.environ, GIT_TERMINAL_PROMPT="0")).stdout
+
+
+def org_public_repos(org):
+    """[(name, fork, archived)] for every public repository, from the REST API."""
+    out, page = [], 1
+    tok = os.environ.get("GITHUB_TOKEN", "")
+    while True:
+        req = urllib.request.Request("https://api.github.com/orgs/%s/repos?type=public&per_page=100&page=%d" % (org, page),
+                                     headers={"Accept": "application/vnd.github+json",
+                                              **({"Authorization": "Bearer " + tok} if tok else {})})
+        with urllib.request.urlopen(req, timeout=60) as r:
+            batch = json.load(r)
+        out += [(b["name"], b["fork"], b["archived"]) for b in batch if not b["private"]]
+        if len(batch) < 100:
+            return out
+        page += 1
+
+
+def fetch(org, name, work, fork_base):
+    gd = os.path.join(work, name + ".git")
+    if not os.path.isdir(gd):
+        git("init", "-q", "--bare", gd)
+    url = "https://github.com/%s/%s" % (org, name)
+    head = git("ls-remote", url, "HEAD").decode().split("\t", 1)[0].strip()
+    if fork_base:
+        # blobless: the fork diff reads only the blobs our commits touched; the rest are never fetched.
+        # The pinned upstream base arrives with HEAD's history when it is still an ancestor.
+        if not _has_remote(gd):
+            git("-C", gd, "remote", "add", "origin", url)
+            git("-C", gd, "config", "remote.origin.promisor", "true")
+            git("-C", gd, "config", "remote.origin.partialclonefilter", "blob:none")
+            git("-C", gd, "config", "extensions.partialClone", "origin")
+        git("-C", gd, "fetch", "-q", "--filter=blob:none", "origin", head)
+    else:
+        git("-C", gd, "fetch", "-q", "--depth", "1", url, head)
+    return gd, head
+
+
+def _has_remote(gd):
+    return subprocess.run(["git", "-C", gd, "remote", "get-url", "origin"], capture_output=True).returncode == 0
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("--config", required=True)
+    ap.add_argument("--tools", required=True)
+    ap.add_argument("--latest", required=True)
+    ap.add_argument("--history", required=True)
+    ap.add_argument("--date", default=datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"))
+    ap.add_argument("--work", default="")
+    ap.add_argument("--no-discover", action="store_true", help="count only repos.json (tests)")
+    a = ap.parse_args()
+    with open(a.config) as fh:
+        cfg = json.load(fh)
+    org = cfg["org"]
+    listed = {r["name"]: r for r in cfg["repositories"]}
+    if not a.no_discover:
+        for name, fork, archived in org_public_repos(org):
+            if name not in listed:
+                listed[name] = {"name": name, "kind": "UPSTREAM-FORK" if fork else ("ARCHIVED" if archived else "FIRST-PARTY"),
+                                "unlisted": True}
+    scc = os.path.join(a.tools, "scc")
+    classify = os.path.join(HERE, "classify.json")
+    extra_all = json.load(open(classify)) if os.path.exists(classify) else {}
+    docs, rows = [], []
+    with tempfile.TemporaryDirectory(prefix="aien-loc-live-") as tmp:
+        work = a.work or tmp
+        for name in sorted(listed):
+            r = listed[name]
+            row = {"repository": name, "kind": r["kind"]}
+            base = (r.get("upstream") or {}).get("base_sha", "")
+            if r["kind"] == "UPSTREAM-FORK" and not base:
+                rows.append(dict(row, state="NOT_COUNTED", reason="fork without a pinned upstream base in repos.json"))
+                continue
+            try:
+                gd, head = fetch(org, name, work, base)
+                if base and subprocess.run(["git", "-C", gd, "merge-base", "--is-ancestor", base, head],
+                                           capture_output=True).returncode != 0:
+                    rows.append(dict(row, state="NOT_COUNTED", commit=head,
+                                     reason="pinned upstream base is not an ancestor of HEAD; re-pin it"))
+                    continue
+                doc = loc.count(gd, head, name, base, scc, extra_all.get(name, []))
+            except (subprocess.CalledProcessError, OSError, ValueError) as e:
+                rows.append(dict(row, state="NOT_COUNTED", reason="%s: %s" % (type(e).__name__, str(e)[:200])))
+                continue
+            docs.append(doc)
+            rows.append(dict(row, state="COUNTED", commit=doc["commit"], mode=doc["mode"],
+                             fork_base=doc.get("fork_base"), unlisted=bool(r.get("unlisted")),
+                             first_party_executable_code=doc["first_party_executable_code"],
+                             sha256=hashlib.sha256(loc.canonical(doc)).hexdigest()))
+    latest = {"schema": "aien-audit-loc-live/1", "org": org, "loc_tool": loc.TOOL_VERSION,
+              "scc_version": cfg.get("scc_version"), "repositories": rows, "totals": loc.org_totals(docs),
+              "not_counted": sum(r["state"] == "NOT_COUNTED" for r in rows),
+              "scope": "public repositories only; private repositories are not counted here"}
+    old = None
+    if os.path.exists(a.latest):
+        with open(a.latest) as fh:
+            old = json.load(fh)
+    with open(a.latest, "w") as fh:
+        fh.write(json.dumps(latest, indent=1, sort_keys=True) + "\n")
+    if old != latest:
+        line = {"date": a.date, "totals": latest["totals"], "not_counted": latest["not_counted"],
+                "heads": {r["repository"]: r.get("commit") for r in rows}}
+        with open(a.history, "a") as fh:
+            fh.write(json.dumps(line, sort_keys=True, separators=(",", ":")) + "\n")
+    t = latest["totals"]
+    print("repos=%d counted=%d not_counted=%d first_party_executable=%d distinct=%d" % (
+        len(rows), len(docs), latest["not_counted"], t["first_party_executable_code"], t["distinct_first_party_executable_code"]))
+    sys.exit(3 if latest["not_counted"] else 0)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/semgrep_config.py b/audit/tools/semgrep_config.py
new file mode 100755
index 0000000..f599c14
--- /dev/null
+++ b/audit/tools/semgrep_config.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+"""Build semgrep-config.yaml from a semgrep-rules checkout pinned in tools.lock.json.
+
+Usage: semgrep_config.py <semgrep-rules-checkout> <out.yaml>
+
+Takes every rule file under the locked directories (test files excluded), keeps
+rules whose severity is in the locked list, and writes one YAML document with
+PyYAML's safe_dump(sort_keys=True). Exits 1 unless the checkout is at the locked
+commit, PyYAML is the locked version and the output sha256 equals config_sha256.
+"""
+import glob, hashlib, json, os, subprocess, sys
+
+import yaml
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+
+
+def build(root, lock):
+    sr = lock["semgrep_rules"]
+    rules = []
+    for d in sr["directories"]:
+        for p in sorted(glob.glob(os.path.join(root, d, "**", "*.yaml"), recursive=True)):
+            if p.endswith(".test.yaml") or "/tests/" in p:
+                continue
+            try:
+                with open(p) as fh:
+                    doc = yaml.safe_load(fh)
+            except yaml.YAMLError:
+                continue
+            if not isinstance(doc, dict) or "rules" not in doc:
+                continue
+            rules += [r for r in doc["rules"] if r.get("severity") in sr["severities"]]
+    return yaml.safe_dump({"rules": rules}, sort_keys=True).encode()
+
+
+def main():
+    if len(sys.argv) != 3:
+        sys.exit(__doc__)
+    root, out = sys.argv[1], sys.argv[2]
+    with open(os.path.join(HERE, "tools.lock.json")) as fh:
+        lock = json.load(fh)
+    sr = lock["semgrep_rules"]
+    head = subprocess.run(["git", "-C", root, "rev-parse", "HEAD"], capture_output=True, text=True).stdout.strip()
+    if head != sr["commit"]:
+        sys.exit("semgrep-rules checkout is at %r, lock wants %s" % (head, sr["commit"]))
+    if yaml.__version__ != sr["pyyaml"]:
+        sys.exit("PyYAML %s, lock wants %s" % (yaml.__version__, sr["pyyaml"]))
+    data = build(root, lock)
+    got = hashlib.sha256(data).hexdigest()
+    if got != sr["config_sha256"]:
+        sys.exit("built config sha256 %s != lock %s" % (got, sr["config_sha256"]))
+    with open(out, "wb") as fh:
+        fh.write(data)
+    print("%s %s" % (got, out))
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/stamp.py b/audit/tools/stamp.py
new file mode 100755
index 0000000..92be810
--- /dev/null
+++ b/audit/tools/stamp.py
@@ -0,0 +1,218 @@
+#!/usr/bin/env python3
+"""Validate an org audit stamp (schema aien-audit-stamp/1).
+
+Usage:
+  stamp.py validate <stamp-dir> [--salts FILE]
+
+A stamp lives at audit/stamps/<repo-or-private-NN>/<sha>/stamp.json, next to the
+checks/ directory written by checks.py and the review reports it cites. The rules
+below are mechanical; they say what a stamp may claim, not whether a review is right.
+
+  * verdict is one of PASS, PASS-WITH-NOTES, FAIL; no stamp text says "pristine",
+    "approved", "certified" or "flawless".
+  * deterministic_checked and model_reviewed are separate lists. Every check names
+    tool, version, command and output_sha256; every review names agent role, model,
+    effort, files covered and the sha256 of its report, which must be in the stamp dir.
+  * the claimed verdict is never better than verdict_ceiling(): any open high or
+    critical finding is FAIL; any NOT_RUN item, INCOMPLETE or NOT_RUN check,
+    untriaged FLAGGED item, open finding, incomplete review, or no review at all
+    caps the verdict at PASS-WITH-NOTES.
+  * UPSTREAM-FORK subjects pin the upstream merge-base and the checks ran in fork-diff
+    mode against that same base.
+  * private subjects carry only an anonymous id (private-01 .. private-99) and a
+    salted SHA-256 commitment; with --salts, the real names must not appear anywhere.
+
+Exit 0 valid, 1 invalid (reasons on stderr), 2 usage error.
+"""
+import argparse, hashlib, json, os, re, sys
+
+SCHEMA = "aien-audit-stamp/1"
+VERDICTS = ("PASS", "PASS-WITH-NOTES", "FAIL")
+RANK = {"PASS": 0, "PASS-WITH-NOTES": 1, "FAIL": 2}
+FORBIDDEN = re.compile(r"\b(pristine|approved|certified|flawless)\b", re.I)
+SHA40 = re.compile(r"^[0-9a-f]{40}$")
+SHA64 = re.compile(r"^[0-9a-f]{64}$")
+ANON = re.compile(r"^private-\d{2}$")
+KINDS = ("FIRST-PARTY", "UPSTREAM-FORK", "ARCHIVED")
+CHECK_STATUS = ("PASS", "FLAGGED", "INCOMPLETE", "NOT_RUN")
+FINDING_STATUS = ("OPEN", "FIXED", "ACCEPTED", "FALSE-POSITIVE")
+SEVERITIES = ("critical", "high", "medium", "low", "info")
+
+
+def strings(o):
+    if isinstance(o, str):
+        yield o
+    elif isinstance(o, dict):
+        for k, v in o.items():
+            yield k
+            yield from strings(v)
+    elif isinstance(o, list):
+        for v in o:
+            yield from strings(v)
+
+
+def verdict_ceiling(st):
+    """Best verdict the stamp's own contents allow, with the reasons that capped it."""
+    reasons = []
+    findings = st.get("findings", [])
+    if any(f.get("status") == "OPEN" and f.get("severity") in ("critical", "high") for f in findings):
+        return "FAIL", ["open critical/high finding"]
+    if st.get("not_run"):
+        reasons.append("%d NOT_RUN item(s)" % len(st["not_run"]))
+    for c in st.get("deterministic_checked", {}).get("checks", []):
+        if c.get("status") in ("NOT_RUN", "INCOMPLETE"):
+            reasons.append("check %s is %s" % (c.get("check"), c.get("status")))
+        elif c.get("status") == "FLAGGED" and c.get("triaged", 0) < (c.get("count") or 0):
+            reasons.append("check %s has %d untriaged item(s)" % (c.get("check"), (c.get("count") or 0) - c.get("triaged", 0)))
+    if any(f.get("status") == "OPEN" for f in findings):
+        reasons.append("open finding(s)")
+    reviews = st.get("model_reviewed", [])
+    if not reviews:
+        reasons.append("no model review")
+    for r in reviews:
+        if not r.get("complete"):
+            reasons.append("review %s/%s incomplete (%s of %s files)" % (r.get("agent_role"), r.get("model"),
+                                                                           r.get("files_covered"), r.get("files_total")))
+    return ("PASS-WITH-NOTES" if reasons else "PASS"), reasons
+
+
+def validate(stamp_dir, salts=None):
+    errs = []
+    path = os.path.join(stamp_dir, "stamp.json")
+    try:
+        with open(path, "rb") as fh:
+            raw = fh.read()
+        st = json.loads(raw)
+    except (OSError, ValueError) as e:
+        return ["cannot read stamp.json: %s" % e]
+    if st.get("schema") != SCHEMA:
+        errs.append("schema must be %s" % SCHEMA)
+    for s in strings(st):
+        m = FORBIDDEN.search(s)
+        if m:
+            errs.append("forbidden word %r in stamp text" % m.group(0))
+            break
+    sub = st.get("subject", {})
+    commit = sub.get("commit", "")
+    if not SHA40.match(commit):
+        errs.append("subject.commit must be a full 40-hex sha")
+    if os.path.basename(os.path.normpath(stamp_dir)) != commit:
+        errs.append("stamp directory name must equal subject.commit")
+    if not SHA40.match(sub.get("tree", "")):
+        errs.append("subject.tree must be a full 40-hex sha")
+    if sub.get("kind") not in KINDS:
+        errs.append("subject.kind must be one of %s" % ", ".join(KINDS))
+    ident = os.path.basename(os.path.dirname(os.path.normpath(stamp_dir)))
+    if sub.get("visibility") == "private":
+        if "repository" in sub:
+            errs.append("private subject must not carry a repository name")
+        if not ANON.match(sub.get("anonymous_id", "")) or sub.get("anonymous_id") != ident:
+            errs.append("private subject needs anonymous_id private-NN equal to the stamp's parent directory")
+        if not SHA64.match(sub.get("name_commitment", "")):
+            errs.append("private subject needs a 64-hex name_commitment")
+        if st.get("self_reported") is not True:
+            errs.append("private stamp must set self_reported: true")
+    elif sub.get("visibility") == "public":
+        if sub.get("repository") != ident:
+            errs.append("public subject.repository must equal the stamp's parent directory")
+        if "anonymous_id" in sub or "name_commitment" in sub:
+            errs.append("public subject must not carry anonymous fields")
+    else:
+        errs.append("subject.visibility must be public or private")
+    dc = st.get("deterministic_checked", {})
+    if sub.get("kind") == "UPSTREAM-FORK":
+        up = sub.get("upstream", {})
+        if not up.get("repository") or not SHA40.match(up.get("base_sha", "")):
+            errs.append("UPSTREAM-FORK needs upstream.repository and a 40-hex upstream.base_sha")
+        elif dc.get("mode") != "fork-diff" or dc.get("fork_base") != up.get("base_sha"):
+            errs.append("UPSTREAM-FORK checks must run in fork-diff mode against upstream.base_sha")
+    checks = dc.get("checks")
+    if not isinstance(checks, list) or not checks:
+        errs.append("deterministic_checked.checks must be a non-empty list")
+        checks = []
+    for c in checks:
+        for k in ("check", "tool", "version", "command", "output_sha256", "status"):
+            if k not in c:
+                errs.append("check %s lacks %s" % (c.get("check", "?"), k))
+        if c.get("status") not in CHECK_STATUS:
+            errs.append("check %s has status %r" % (c.get("check"), c.get("status")))
+        if c.get("output_sha256") and not SHA64.match(c["output_sha256"]):
+            errs.append("check %s output_sha256 is not 64 hex" % c.get("check"))
+        f = os.path.join(stamp_dir, "checks", "%s.json" % c.get("check"))
+        if os.path.exists(f):
+            with open(f, "rb") as fh:
+                if hashlib.sha256(fh.read()).hexdigest() != c.get("output_sha256"):
+                    errs.append("checks/%s.json does not match its output_sha256" % c.get("check"))
+        elif c.get("status") != "NOT_RUN":
+            errs.append("checks/%s.json missing" % c.get("check"))
+    for r in st.get("model_reviewed", []):
+        for k in ("agent_role", "model", "effort", "files_covered", "files_total", "report", "report_sha256", "complete"):
+            if k not in r:
+                errs.append("review lacks %s" % k)
+        rp = os.path.normpath(os.path.join(stamp_dir, r.get("report", "")))
+        if not rp.startswith(os.path.normpath(stamp_dir) + os.sep):
+            errs.append("review report %r is outside the stamp directory" % r.get("report"))
+        elif not os.path.exists(rp):
+            errs.append("review report %s missing" % r.get("report"))
+        else:
+            with open(rp, "rb") as fh:
+                if hashlib.sha256(fh.read()).hexdigest() != r.get("report_sha256"):
+                    errs.append("review report %s does not match report_sha256" % r.get("report"))
+        if r.get("complete") and r.get("files_covered") != r.get("files_total"):
+            errs.append("review marked complete but covers %s of %s files" % (r.get("files_covered"), r.get("files_total")))
+    for f in st.get("findings", []):
+        if f.get("source") not in ("DETERMINISTIC", "MODEL"):
+            errs.append("finding %s source must be DETERMINISTIC or MODEL" % f.get("id"))
+        if f.get("status") not in FINDING_STATUS:
+            errs.append("finding %s status must be one of %s" % (f.get("id"), ", ".join(FINDING_STATUS)))
+        if f.get("severity") not in SEVERITIES:
+            errs.append("finding %s severity must be one of %s" % (f.get("id"), ", ".join(SEVERITIES)))
+        if f.get("status") == "FIXED" and not f.get("fix"):
+            errs.append("finding %s is FIXED without a fix reference" % f.get("id"))
+    for n in st.get("not_run", []):
+        if not n.get("item") or not n.get("reason"):
+            errs.append("not_run entries need item and reason")
+    v = st.get("verdict")
+    if v not in VERDICTS:
+        errs.append("verdict must be one of %s" % ", ".join(VERDICTS))
+    else:
+        ceil, why = verdict_ceiling(st)
+        if RANK[v] < RANK[ceil]:
+            errs.append("verdict %s is better than the contents allow (%s: %s)" % (v, ceil, "; ".join(why)))
+    if salts:
+        with open(salts) as fh:
+            sd = json.load(fh)  # {"private-NN": {"name", "salt", "commitment"}}, kept off the shelf at mode 0600
+        low = raw.decode("utf-8", "replace").lower()
+        for e in sd.values():
+            if re.search(r"(?<![a-z0-9_.-])%s(?![a-z0-9_-])" % re.escape(e["name"].lower()), low):
+                errs.append("a private repository name appears in the stamp")
+                break
+        if sub.get("visibility") == "private":
+            ent = sd.get(sub.get("anonymous_id"))
+            if not ent or commitment(ent["salt"], ent["name"]) != sub.get("name_commitment"):
+                errs.append("name_commitment does not match the private salt record")
+    return errs
+
+
+def commitment(salt, name):
+    """sha256("<salt hex>:<repository name>"), the form used when the salts were drawn on 2026-10-26."""
+    return hashlib.sha256(f"{salt}:{name}".encode()).hexdigest()
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    sp = ap.add_subparsers(dest="cmd", required=True)
+    v = sp.add_parser("validate")
+    v.add_argument("stamp_dir")
+    v.add_argument("--salts", default="")
+    a = ap.parse_args()
+    errs = validate(a.stamp_dir, a.salts or None)
+    for e in errs:
+        print("INVALID: " + e, file=sys.stderr)
+    if not errs:
+        print("VALID " + a.stamp_dir)
+    sys.exit(1 if errs else 0)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/status.py b/audit/tools/status.py
new file mode 100755
index 0000000..8929e89
--- /dev/null
+++ b/audit/tools/status.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+"""Mark each org audit stamp CURRENT, STALE, UNKNOWN or NOT_CHECKABLE.
+
+Usage:
+  status.py <stamps-dir> --out audit/status.json [--org aien-dev] [--heads FILE]
+
+For every public stamp the repository's default-branch HEAD is looked up with
+`git ls-remote https://github.com/<org>/<repo> HEAD` (or read from --heads, a JSON
+map repo -> sha, used by the tests). The newest stamp of a repository is
+
+  CURRENT        HEAD equals the stamped commit
+  STALE          HEAD has moved past the stamped commit
+  UNKNOWN        HEAD could not be read; never treated as CURRENT
+  NOT_CHECKABLE  private stamp (self-reported; nobody outside can read the HEAD)
+
+Older stamps of the same repository are SUPERSEDED. The output carries no clock
+time, so a run that sees the same HEADs writes the same bytes and the workflow
+commits nothing.
+"""
+import argparse, json, os, re, subprocess, sys
+
+SHA40 = re.compile(r"^[0-9a-f]{40}$")
+
+
+def ls_remote_head(org, repo):
+    try:
+        p = subprocess.run(["git", "ls-remote", "https://github.com/%s/%s" % (org, repo), "HEAD"],
+                           capture_output=True, text=True, timeout=60,
+                           env=dict(os.environ, GIT_TERMINAL_PROMPT="0"))
+    except (OSError, subprocess.TimeoutExpired) as e:
+        return None, "ls-remote failed: %s" % type(e).__name__
+    sha = p.stdout.split("\t", 1)[0].strip()
+    if p.returncode != 0 or not SHA40.match(sha):
+        return None, "ls-remote exit %d" % p.returncode
+    return sha, ""
+
+
+def collect(stamps_dir):
+    by_id = {}
+    if not os.path.isdir(stamps_dir):  # no stamps published yet
+        return by_id
+    for ident in sorted(os.listdir(stamps_dir)):
+        d = os.path.join(stamps_dir, ident)
+        if not os.path.isdir(d):
+            continue
+        for sha in sorted(os.listdir(d)):
+            f = os.path.join(d, sha, "stamp.json")
+            if os.path.isfile(f):
+                with open(f) as fh:
+                    st = json.load(fh)
+                by_id.setdefault(ident, []).append(st)
+    return by_id
+
+
+def compute(stamps_dir, org, heads=None):
+    rows = []
+    for ident, sts in collect(stamps_dir).items():
+        # newest = latest stamped_at date, then commit for a total order
+        sts.sort(key=lambda s: (s.get("stamped_at", ""), s["subject"]["commit"]))
+        newest = sts[-1]
+        for st in sts[:-1]:
+            rows.append({"id": ident, "commit": st["subject"]["commit"], "verdict": st.get("verdict"),
+                         "state": "SUPERSEDED", "head": None, "note": "a newer stamp exists"})
+        sub = newest["subject"]
+        row = {"id": ident, "commit": sub["commit"], "verdict": newest.get("verdict")}
+        if sub.get("visibility") == "private":
+            row.update(state="NOT_CHECKABLE", head=None, note="private repository; stamp is self-reported")
+        else:
+            if heads is not None:
+                head, why = heads.get(ident), "no HEAD supplied"
+            else:
+                head, why = ls_remote_head(org, ident)
+            if not head:
+                row.update(state="UNKNOWN", head=None, note=why)
+            elif head == sub["commit"]:
+                row.update(state="CURRENT", head=head, note="")
+            else:
+                row.update(state="STALE", head=head, note="default-branch HEAD moved past the stamped commit")
+        rows.append(row)
+    rows.sort(key=lambda r: (r["id"], r["state"] == "SUPERSEDED", r["commit"]))
+    return {"schema": "aien-audit-status/1", "org": org, "stamps": rows}
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("stamps_dir")
+    ap.add_argument("--out", required=True)
+    ap.add_argument("--org", default="aien-dev")
+    ap.add_argument("--heads", default="")
+    a = ap.parse_args()
+    heads = None
+    if a.heads:
+        with open(a.heads) as fh:
+            heads = json.load(fh)
+    doc = compute(a.stamps_dir, a.org, heads)
+    data = json.dumps(doc, indent=1, sort_keys=True) + "\n"
+    with open(a.out, "w") as fh:
+        fh.write(data)
+    unknown = sum(r["state"] == "UNKNOWN" for r in doc["stamps"])
+    print("stamps=%d stale=%d unknown=%d" % (len(doc["stamps"]), sum(r["state"] == "STALE" for r in doc["stamps"]), unknown))
+    sys.exit(3 if unknown else 0)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/audit/tools/tools.lock.json b/audit/tools/tools.lock.json
new file mode 100644
index 0000000..5a1b06d
--- /dev/null
+++ b/audit/tools/tools.lock.json
@@ -0,0 +1,54 @@
+{
+  "schema": "aien-audit-tools-lock/1",
+  "note": "Every deterministic check runs only with these tool versions. checks.py refuses (NOT_RUN) when the version printed by a tool does not contain `version`. Download sha256 values are the publishers' own checksum files.",
+  "tools": {
+    "gitleaks": {
+      "version": "8.30.1",
+      "version_cmd": ["version"],
+      "downloads": {
+        "linux_amd64": {"url": "https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz", "sha256": "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb", "member": "gitleaks"},
+        "linux_arm64": {"url": "https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_arm64.tar.gz", "sha256": "e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080", "member": "gitleaks"}
+      }
+    },
+    "scc": {
+      "version": "4.1.0",
+      "version_cmd": ["--version"],
+      "downloads": {
+        "linux_amd64": {"url": "https://github.com/boyter/scc/releases/download/v4.1.0/scc_Linux_x86_64.tar.gz", "sha256": "c7328436d3027f4357d3d7853f7dc3ac2bbcb4ca08f1adad91a27c593884079b", "member": "scc"},
+        "linux_arm64": {"url": "https://github.com/boyter/scc/releases/download/v4.1.0/scc_Linux_arm64.tar.gz", "sha256": "6e0d2a1f8d3540ba7df185477dec40bb7340f1b214bfd303147de5cad2bd7b8b", "member": "scc"}
+      }
+    },
+    "actionlint": {
+      "version": "1.7.12",
+      "version_cmd": ["-version"],
+      "downloads": {
+        "linux_amd64": {"url": "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz", "sha256": "8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8", "member": "actionlint"},
+        "linux_arm64": {"url": "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_arm64.tar.gz", "sha256": "325e971b6ba9bfa504672e29be93c24981eeb1c07576d730e9f7c8805afff0c6", "member": "actionlint"}
+      }
+    },
+    "osv-scanner": {
+      "version": "2.7.0",
+      "version_cmd": ["--version"],
+      "downloads": {
+        "linux_amd64": {"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_amd64", "sha256": "160c6253e2922e9e0a6a9771c5c4c40a4b3c6090b34a3cdd5e80c96cc2e4218b"},
+        "linux_arm64": {"url": "https://github.com/google/osv-scanner/releases/download/v2.7.0/osv-scanner_linux_arm64", "sha256": "4061ef4c021ed3c47f203b818f337e351336cc5cd67c0274fc36bd1dfc728dd7"}
+      }
+    },
+    "venv/bin/semgrep": {"version": "1.182.1", "version_cmd": ["--version"], "pip": "semgrep==1.182.1"},
+    "venv/bin/zizmor": {"version": "1.31.1", "version_cmd": ["--version"], "pip": "zizmor==1.31.1"}
+  },
+  "semgrep_rules": {
+    "repository": "https://github.com/semgrep/semgrep-rules",
+    "commit": "16b9e6d45f10649f6a531ec4838ed9924372c3bc",
+    "directories": ["bash", "c", "python", "javascript", "typescript", "rust", "dockerfile", "yaml/github-actions", "generic/secrets", "generic/ci"],
+    "severities": ["ERROR", "WARNING"],
+    "pyyaml": "6.0.2",
+    "config_sha256": "8d5bfd8c428cb71859540801b42377e65cca661db45c6722c19b9dc1b3791225"
+  },
+  "crumb": {
+    "repository": "https://github.com/aien-dev/aien-architecture-mv",
+    "commit": "c461b430a1598de8e673620935a3584ea91fa9c0",
+    "source": "tools/crumb/crumb.c",
+    "source_sha256": "3cab424b076134715000e66111709cbc7632d1fc5907cf87626c3e2641f7b0b7"
+  }
+}
diff --git a/audit/tools/verify.py b/audit/tools/verify.py
new file mode 100755
index 0000000..f97fa82
--- /dev/null
+++ b/audit/tools/verify.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+"""Check an org audit stamp from outside.
+
+Usage:
+  verify.py <stamp-dir> [--rerun GITDIR] [--worktree DIR] [--tools DIR] [--salts FILE]
+
+Step 1 always runs: stamp.py's validation (schema, verdict ceiling, file hashes).
+Step 2 runs with --rerun: checks.py is run again at the stamped commit from GITDIR
+(a clone of the stamped repository), and every check's output_sha256 must equal the
+stamped value. A different checker or tools lock cannot reproduce the stamp, so that
+case is reported as NOT_RUN rather than as a match or a mismatch.
+
+Exit 0 verified, 1 invalid or mismatched, 2 NOT_RUN (could not reproduce).
+"""
+import argparse, json, os, sys, tempfile
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, HERE)
+import checks  # noqa: E402
+import stamp  # noqa: E402
+
+
+def rerun(stamp_dir, gitdir, worktree, tools, lock_path=checks.LOCK_PATH):
+    with open(os.path.join(stamp_dir, "stamp.json")) as fh:
+        st = json.load(fh)
+    dc = st["deterministic_checked"]
+    _, lock_sha = checks.load_lock(lock_path)
+    if dc.get("checker", {}).get("sha256") != checks.checker_sha256():
+        return 2, ["stamp was made by checker %s; this checkout is %s" % (dc.get("checker", {}).get("sha256"),
+                                                                          checks.checker_sha256())]
+    if dc.get("tools_lock_sha256") != lock_sha:
+        return 2, ["stamp used tools lock %s; this checkout has %s" % (dc.get("tools_lock_sha256"), lock_sha)]
+    repo = st["subject"].get("repository") or st["subject"]["anonymous_id"]
+    with tempfile.TemporaryDirectory(prefix="aien-verify-") as out:
+        doc = checks.run_all(gitdir, st["subject"]["commit"], repo, out, dc.get("fork_base") or "", tools, worktree,
+                             lock_path=lock_path)
+    got = {c["check"]: c for c in doc["checks"]}
+    errs = []
+    skipped = []
+    for c in dc["checks"]:
+        g = got.get(c["check"])
+        if c.get("reproducible") is False:
+            skipped.append(c["check"])  # e.g. OSV advisories: an online database queried at stamp time
+            continue
+        if g is None:
+            errs.append("%s: not produced by the rerun" % c["check"])
+        elif g["status"] == "NOT_RUN" and c["status"] != "NOT_RUN":
+            return 2, ["%s: tool unavailable here (%s)" % (c["check"], g.get("note", ""))]
+        elif g["output_sha256"] != c["output_sha256"]:
+            errs.append("%s: output %s, stamp says %s" % (c["check"], g["output_sha256"], c["output_sha256"]))
+    if not errs and skipped:
+        print("not reproducible by design, not compared: " + ", ".join(skipped), file=sys.stderr)
+    return (1 if errs else 0), errs
+
+
+def main():
+    ap = argparse.ArgumentParser()
+    ap.add_argument("stamp_dir")
+    ap.add_argument("--rerun", default="", help="git dir of the stamped repository")
+    ap.add_argument("--worktree", default="")
+    ap.add_argument("--tools", default=os.environ.get("AUDIT_TOOLS", HERE))
+    ap.add_argument("--salts", default="")
+    a = ap.parse_args()
+    errs = stamp.validate(a.stamp_dir, a.salts or None)
+    if errs:
+        for e in errs:
+            print("INVALID: " + e, file=sys.stderr)
+        sys.exit(1)
+    if not a.rerun:
+        print("VALID (hashes and verdict ceiling); rerun NOT_RUN: pass --rerun GITDIR to reproduce the checks")
+        sys.exit(0)
+    code, msgs = rerun(a.stamp_dir, a.rerun, a.worktree, a.tools)
+    for m in msgs:
+        print(("MISMATCH: " if code == 1 else "NOT_RUN: ") + m, file=sys.stderr)
+    if code == 0:
+        print("VERIFIED " + a.stamp_dir)
+    sys.exit(code)
+
+
+if __name__ == "__main__":
+    main()