GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Automation and CI / compass / tests

Explore Code Workflow and 8 more files

A GitHub Actions workflow in Cosmic that builds and publishes the site. Runs on push, on a schedule and by hand.

699 lines of YAML and JavaScript from compass, cosmic, cvaa, in 9 files. Topic: Automation and CI. Section 1691 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Compass Test test · compass / tests/compass.test.mjs lines 1–53
  2. CI Chess Workflow automation · cosmic / .github/workflows/ci-chess.yml lines 1–105
  3. Explore Code Workflow automation · cosmic / .github/workflows/explore-code.yml lines 1–147
  4. LiDAR Tr06 Workflow automation · cosmic / .github/workflows/lidar-tr06.yml lines 1–141
  5. CVAA Inoculate Workflow automation · cvaa / .github/workflows/202608301446-inoculate.yml lines 1–37
  6. CVAA Selftest Workflow automation · cvaa / .github/workflows/202608301447-selftest.yml lines 1–115
  7. CVAA Consumer Workflow Template automation · cvaa / consumer-workflow-template.yml lines 1–18
  8. CVAA Antibody Runner other · cvaa / tools/antibody-runner.mjs lines 1–12
  9. CVAA Fleet storage · cvaa / tools/fleet.mjs lines 1–71

Compass Test

A test in the tests folder that checks Compass.

testcompass / tests/compass.test.mjs · lines 1–53 of 53 · Entry point · pattern request (shared by 18 files)

What it does
It tests its inputs. Defines request. Uses libraries node:test, node:assert/strict.
Why it exists in the grid workflow
Domain stage field_execution (path word 'compass'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
Downstream impact
Used directly by 1 file: Verify Workflow (compass).
What it achieves
Defines `request`.
Why it matters
Run by Verify Workflow.
Application
compass · tests · test
Uses
Compass (import), node:test, node:assert/strict
Used by
run by Verify Workflow (workflow run)
Produces
request
Defines here
request
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
compass@e200c888acbcc7af59d7cc38b29806e90b0a50db tests/compass.test.mjs:1-53 · blob ce6a5adab2b01ecaa645804aa9b927a0d933cc0a · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: unknown
import test from 'node:test';
import assert from 'node:assert/strict';
import { evaluate, evaluateBatch, simulateStep, tracking, overlay, deviceHeading } from '../src/compass.mjs';
const now=100000;
const fix={longitude:0,latitude:0,accuracyM:3,timestampMs:now};
const target={coordinates:[1,0]};
const request=mode=>({mode,fix,target,nowMs:now});
test('same physical mathematics for all position sources',()=>{
 const a=evaluate(request('observed')),b=evaluate(request('simulated')),c=evaluate(request('replay'));
 assert.deepEqual(a.guidance,b.guidance);assert.deepEqual(a.guidance,c.guidance);
 assert.equal(b.mode,'simulated');assert.equal(a.guidance.bearingDeg,90);
 assert.ok(Math.abs(a.guidance.distanceM-111319.490793)<0.001);
});
test('stale poor invalid and missing fixes do not guide',()=>{
 for (const [f,status] of [[null,'missing'],[{...fix,timestampMs:now-10001},'stale'],[{...fix,accuracyM:31},'poor'],[{...fix,longitude:181},'invalid']]){
  const a=evaluate({...request('simulated'),fix:f});assert.equal(a.status,status);assert.equal(a.guidance,null);
 }
});
test('within uncertainty and antipodal bearing suppressed',()=>{
 assert.equal(evaluate({...request('observed'),target:{coordinates:[0,0]}}).guidance.bearingDeg,null);
 assert.equal(evaluate({...request('simulated'),target:{coordinates:[180,0]}}).status,'bearing_undetermined');
});
test('explicit mode and clock, invalid target',()=>{
 assert.throws(()=>evaluate(request('unknown')),/INVALID_POSITION_SOURCE/);
 assert.throws(()=>evaluate({...request('simulated'),nowMs:undefined}),/EXPLICIT_CLOCK_REQUIRED/);
 assert.equal(evaluate({...request('simulated'),target:{coordinates:[181,0]}}).status,'invalid_target');
});
test('simulated step round trip and dateline',()=>{
 const step=simulateStep({longitude:179.999,latitude:0,distanceM:1000,bearingDeg:90,timestampMs:now});
 assert.equal(step.mode,'simulated');assert.ok(step.fix.longitude<0);
 const a=evaluate({mode:step.mode,fix:step.fix,target:{coordinates:[179.999,0]},nowMs:now});
 assert.ok(Math.abs(a.guidance.distanceM-1000)<0.001);
 assert.equal(a.guidance.bearingDeg,270);
});
test('bounded deterministic 10000-agent calculation',()=>{
 const requests=Array.from({length:10000},(_,i)=>({mode:'simulated',fix:{...fix,longitude:i/10000},target,nowMs:now}));
 const out=evaluateBatch(requests);assert.equal(out.length,10000);
 assert.ok(out.every(x=>x.mode==='simulated'&&x.status==='usable'&&x.guidance.bearingDeg===90));
 assert.deepEqual(out,evaluateBatch(requests));
 assert.throws(()=>evaluateBatch([...requests,requests[0]]),/BATCH_LIMIT/);
});
test('route tracking and overlay distinguish physical and synthetic positions',()=>{
 const coordinates=[[0,0],[0.001,0],[0.002,0]];
 const req={mode:'simulated',fix:{...fix,longitude:0.0005},nowMs:now};
 const a=tracking({type:'LineString',coordinates})(req);assert.equal(a.status,'ok');assert.equal(a.mode,'simulated');
 const b=overlay(coordinates)(req);
 assert.ok(b.features.some(f=>f.properties.role==='simulated-position'));
 assert.ok(!b.features.some(f=>f.properties.role==='measured-gps'));
});
test('device heading reference remains explicit',()=>{
 assert.equal(deviceHeading({webkitCompassHeading:90,beta:0,gamma:0},0).reference,'magnetic');
 assert.equal(deviceHeading({alpha:270,absolute:true,beta:0,gamma:0},0).reference,'sensor');
});

CI Chess Workflow

A GitHub Actions workflow in Cosmic. Runs on push and by hand.

automationcosmic / .github/workflows/ci-chess.yml · lines 1–105 of 105 · Entry point

What it does
It runs automated jobs on GitHub Actions. Side effects: makes network requests; starts processes.
Inputs & outputs
Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid).
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Advisory new-code + chess gate on every push (GAUNTLET-17, adopted by CAPSTAN-41).
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
cosmic · .github/workflows · workflow
Uses
Test Pilot Static (workflow run), Test Pilot Browser (workflow run), Test Pilot Geo (workflow run)
Used by
none found
Produces
none declared
Defines here
ci-chess
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 .github/workflows/ci-chess.yml:1-105 · blob 2c4603c535fa97528baddc44460a85b25f46057c · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: network, process · domain stage: unknown · users: none · canonical: unknown
# Advisory new-code + chess gate on every push (GAUNTLET-17, adopted 2026-12-05 by CAPSTAN-41).
# Separate from explore-code.yml so it can never block or slow the Pages deploy; every tool step has continue-on-error.
#
# Base commit = the commit the LIVE Explore Code cut read (deployed build_graph.json repos[cosmic].commit).
# If that cannot be fetched, newcode.py falls back to github.event.before, then HEAD~1.
# newcode.py exits 1 only for exact duplicates of more than 20 lines; chess_gate.py exits 1 only if a check FAILs.
# Neither failure fails the workflow; it shows as a red step marked "continue-on-error" in the run.

name: ci-chess

on:
  push:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

jobs:
  newcode-and-chess:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
        with:
          path: cosmic
          fetch-depth: 0            # newcode.py diffs base..HEAD

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - run: pip install pyarrow numpy

      - name: Reference code (VEDIC extractor, Ventus Grid Engine, bng.mjs; all public, all optional)
        continue-on-error: true
        run: |
          git clone -q --depth 1 https://github.com/Ventusltd/vedic- vedic- || echo "::warning::vedic- not cloned; builtin-lite extractor"
          git clone -q --depth 1 https://github.com/Ventusltd/ventus-grid-engine clones/ventus-grid-engine || echo "::warning::grid engine not cloned; export-name list used"
          git clone -q --depth 1 --filter=blob:none --sparse https://github.com/Ventusltd/energy-transition-simulator clones/energy-transition-simulator \
            && git -C clones/energy-transition-simulator sparse-checkout set prototype/mod/engine || echo "::warning::bng.mjs not cloned"

      - name: Deployed graph (the last deployed cut)
        continue-on-error: true
        run: |
          mkdir -p ci-out
          curl -fsSL --retry 2 "${EXPLORE_BASE:-https://code.globalgrid2050.com/explore-code/}build_graph.json" -o ci-out/build_graph.json \
            || { echo "::warning::deployed build_graph.json not reachable; base falls back to the push's before commit"; rm -f ci-out/build_graph.json; }

      - name: New-code hunter (advisory)
        id: newcode
        continue-on-error: true
        env:
          VEDIC_FINGERPRINTS: ${{ github.workspace }}/vedic-/fingerprints
          GRID_ENGINE: ${{ github.workspace }}/clones/ventus-grid-engine
          BNG_MJS: ${{ github.workspace }}/clones/energy-transition-simulator/prototype/mod/engine/bng.mjs
        run: |
          BASE_ARGS=""
          if [ ! -f ci-out/build_graph.json ]; then BASE_ARGS="--base ${{ github.event.before }}"; fi
          python cosmic/tools/explore/ci/newcode.py --repo cosmic --name cosmic $BASE_ARGS \
            --graph "$( [ -f ci-out/build_graph.json ] && echo ci-out/build_graph.json || echo '' )" \
            --out ci-out/ci-newcode.md --json ci-out/ci-newcode.json

      - name: Chess regression gate (advisory)
        id: chess
        continue-on-error: true
        run: |
          G=""; [ -f ci-out/build_graph.json ] && G=ci-out/build_graph.json
          python cosmic/tools/explore/ci/chess_gate.py --graph "$G" --newcode ci-out/ci-newcode.json --out-dir ci-out

      - name: Job summary
        if: always()
        run: |
          { [ -f ci-out/ci-newcode.md ] && cat ci-out/ci-newcode.md || echo "newcode.py wrote no report"; echo; \
            [ -f ci-out/ci-chess.md ] && cat ci-out/ci-chess.md || echo "chess_gate.py wrote no report"; } >> "$GITHUB_STEP_SUMMARY"
          echo "newcode: ${{ steps.newcode.outcome }} · chess: ${{ steps.chess.outcome }}" >> "$GITHUB_STEP_SUMMARY"

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: ci-chess
          path: |
            ci-out/*.md
            ci-out/*.json
            ci-out/release-board.html
            ci-out/chess/index.html
          if-no-files-found: ignore

  # Pilot / Drone View browser regression (review round 2, item 4): Playwright Chromium at 390x844 and 1366x768,
  # offline mode, contract surface, vicinity query states, overlap and tap-target checks. Advisory like the rest.
  pilot-browser:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
      - run: pip install pytest playwright && python -m playwright install --with-deps chromium
      - name: Pilot static + browser tests
        continue-on-error: true
        run: python -m pytest -q tools/explore/theme/test_pilot_static.py tools/explore/theme/test_pilot_browser.py tools/explore/theme/test_pilot_geo.py

Explore Code Workflow

A GitHub Actions workflow in Cosmic that builds and publishes the site. Runs on push, on a schedule and by hand.

automationcosmic / .github/workflows/explore-code.yml · lines 1–147 of 147 · Entry point

What it does
It builds and publishes its content. Side effects: makes network requests; starts processes; uses storage (browser storage, DuckDB or Parquet).
Inputs & outputs
In: DuckDB queries. Out: GitHub Pages deployment.
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Runs `cosmic/tools/explore/build.py`, `cosmic/tools/explore/clean/ci.py` and `cosmic/tools/explore/visualise.py`; publishes to GitHub Pages.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
cosmic · .github/workflows · workflow
Uses
none found
Used by
none found
Produces
none declared
Defines here
explore-code
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 .github/workflows/explore-code.yml:1-147 · blob 3c3afc13f921062fc224ab4a234711d27d2e46f7 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: network, process, storage · domain stage: unknown · users: none · canonical: unknown
name: explore-code

# Publishes this repository's site together with Explore Code, built on GitHub's machine.
# Explore Code reads every public Ventusltd repository at HEAD and writes about 2,000 static pages,
# Parquet tables and a DuckDB search page. Nothing it generates is committed: the pages go straight
# to GitHub Pages as an artifact, so this repository does not grow.
#
# Needs Pages "Build and deployment: Source" set to "GitHub Actions" (one time):
#   gh api -X PUT repos/Ventusltd/cosmic/pages -f build_type=workflow
# Because Pages then serves this workflow's output, it also runs on every push, so the existing
# cosmic site keeps deploying exactly as before.

on:
  push:
    branches: [main]
  schedule:
    - cron: '41 3 * * *'
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: pages
  cancel-in-progress: false

env:
  EXPLORE_BASE: ${{ vars.EXPLORE_BASE || 'https://code.globalgrid2050.com/explore-code/' }}

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4
        with:
          path: cosmic

      - name: Kuiper's non-public digest check
        uses: actions/checkout@v4
        with:
          repository: Ventusltd/kuiper-belt
          path: kuiper
          sparse-checkout: tools

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - run: pip install duckdb pyarrow numpy
      - run: sudo npm install --silent --prefix /opt/npm-tools acorn acorn-walk || echo "::warning::acorn not installed; identity extra will be skipped"

      - name: Clone every public repository (one commit each, files over 1 MB left on GitHub)
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          mkdir clones
          gh api --paginate 'users/Ventusltd/repos?type=owner&per_page=100' \
            --jq '.[] | select(.private == false and .fork == false and .archived == false) | .name' > repos.txt
          echo "$(wc -l < repos.txt) public repositories"
          while read -r r; do
            GIT_LFS_SKIP_SMUDGE=1 timeout 900 git clone -q --depth 1 --filter=blob:limit=1m \
              "https://github.com/Ventusltd/$r" "clones/$r" || echo "::warning::could not clone $r"
          done < repos.txt

      - name: Self-hosted DuckDB-WASM for search (optional; search.html falls back to jsDelivr)
        run: |
          set +e
          D="$PWD/_work/duckdb"; N="$PWD/_work/ddnpm"; mkdir -p "$D" "$N"
          if ! (cd "$N" && npm install --silent --no-audit --no-fund @duckdb/duckdb-wasm@1.29.0 esbuild@0.24); then
            echo "::warning::DuckDB-WASM download failed; search uses jsDelivr"; rm -rf "$D"; exit 0
          fi
          W="$N/node_modules/@duckdb/duckdb-wasm/dist"
          "$N/node_modules/.bin/esbuild" "$W/duckdb-browser.mjs" --bundle --format=esm --minify --log-level=warning \
            --outfile="$D/duckdb-browser.mjs" || { echo "::warning::DuckDB-WASM bundle failed; search uses jsDelivr"; rm -rf "$D"; exit 0; }
          for f in duckdb-eh.wasm duckdb-browser-eh.worker.js duckdb-mvp.wasm duckdb-browser-mvp.worker.js; do
            cp "$W/$f" "$D/" || echo "::warning::DuckDB-WASM $f missing"
          done
          for v in wasm_eh wasm_mvp; do
            mkdir -p "$D/ext/v1.1.1/$v"
            curl -fsSL --retry 2 -o "$D/ext/v1.1.1/$v/parquet.duckdb_extension.wasm" \
              "https://extensions.duckdb.org/v1.1.1/$v/parquet.duckdb_extension.wasm" \
              || { echo "::warning::parquet extension ($v) not downloaded; DuckDB fetches it itself"; rm -f "$D/ext/v1.1.1/$v/parquet.duckdb_extension.wasm"; }
          done
          echo 1.29.0 > "$D/VERSION"
          du -sh "$D"
          exit 0

      - name: Assemble the site
        run: |
          mkdir _site
          tar --exclude=./.git --exclude=./.github -C cosmic -cf - . | tar -C _site -xf -
          DUCK=""
          [ -f _work/duckdb/VERSION ] && DUCK="--duckdb-dir _work/duckdb"
          python cosmic/tools/explore/build.py --src clones --out _site/explore-code \
            --base "$EXPLORE_BASE" --kuiper-tools kuiper/tools $DUCK
          # Clean view (tools/explore/clean/CONTRACT.md): proposals from this build's own outputs -> manifest -> a second
          # build with --clean-manifest. Fail-safe: any failure publishes the first build, without the cleaned view.
          if [ -f cosmic/tools/explore/clean/ci.py ]; then
            if timeout 1500 python cosmic/tools/explore/clean/ci.py --graph _site/explore-code/build_graph.json --src clones \
                 --work _work/clean --out _work/clean/manifest.json && [ -f _work/clean/manifest.json ]; then
              if python cosmic/tools/explore/build.py --src clones --out _work/clean-site \
                   --base "$EXPLORE_BASE" --kuiper-tools kuiper/tools $DUCK --clean-manifest _work/clean/manifest.json \
                 && [ -f _work/clean-site/index.html ] && [ -f _work/clean-site/set-aside.html ] && [ -f _work/clean-site/build_graph.json ]; then
                rm -rf _site/explore-code && mv _work/clean-site _site/explore-code
              else
                echo "::warning::clean rebuild failed; publishing without the cleaned view"
              fi
            else
              echo "::warning::clean manifest not made; publishing without the cleaned view"
            fi
          fi
          if [ -f cosmic/tools/explore/visualise.py ] && [ -f _site/explore-code/build_graph.json ]; then
            python cosmic/tools/explore/visualise.py --graph _site/explore-code/build_graph.json --out _site/explore-code/visual
          fi
          if [ -f cosmic/tools/explore/extras.py ] && [ -f _site/explore-code/build_graph.json ]; then
            timeout 1800 python cosmic/tools/explore/extras.py --site _site/explore-code \
              --graph _site/explore-code/build_graph.json --src clones --link-index \
              || echo "::warning::extras.py did not finish; the site is published without some extras"
          fi
          if [ ! -f _site/robots.txt ]; then
            printf 'User-agent: *\nAllow: /\n' > _site/robots.txt
            if [ -f _site/explore-code/robots-sitemaps.txt ]; then
              sed 's/^/Sitemap: /' _site/explore-code/robots-sitemaps.txt >> _site/robots.txt
            else
              printf 'Sitemap: %ssitemap.xml\n' "$EXPLORE_BASE" >> _site/robots.txt
            fi
          fi
          touch _site/.nojekyll
          du -sh _site _site/explore-code
          ls _site/explore-code/s | wc -l

      - uses: actions/upload-pages-artifact@v3
        with:
          path: _site

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v4

LiDAR Tr06 Workflow

A GitHub Actions workflow in Cosmic that builds and publishes the site. Runs by hand and on release.

automationcosmic / .github/workflows/lidar-tr06.yml · lines 1–141 of 141 · Entry point

What it does
It builds and publishes LiDAR terrain. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage site_feasibility (path word 'lidar'): substation-to-site feasibility (terrain, LiDAR and connection evidence before design), a journey named in Ventus Ltd's brief. Domain terms in the code: LiDAR terrain.
Inputs & outputs
In: JSON file index.json; JSON file sources.json; JSON file probe.json. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326, Web Mercator / EPSG:3857.
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Runs LiDAR Fetch DTM (`tools/lidar/fetch_dtm.py`) and LiDAR Build Tiles (`tools/lidar/build_tiles.py`).
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
cosmic · .github/workflows · workflow
Uses
none found
Used by
none found
Produces
none declared
Defines here
lidar-tr06
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 .github/workflows/lidar-tr06.yml:1-141 · blob 84f476806b763f45cc6fb74f079b0e6c9e1989d0 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: site_feasibility · users: IPP_developer, landowner_planner · canonical: unknown
name: lidar-tr06

# LiDAR proof of concept (TRIGPOINT-62; plan in the LiDAR VERDICT, section 9): one OS 10 km square of Environment
# Agency 1 m DTM -> Terrarium height tiles z14-z16 on the Web-Mercator grid that the satellite imagery uses.
# Run by hand only (Actions tab -> lidar-tr06 -> Run workflow), so it never slows the main deploy.
# Commits nothing. Publishes:
#   - a workflow artifact "lidar-<square>" (tiles tarball, .pmtiles, index.json, probe.json, sources.json, 30 days)
#   - a GitHub Release "lidar-<square>" holding the same files (kept until replaced), from which the deploy
#     workflow can unpack lidar/ into the Pages site (snippet in tools/lidar/README.md)
# Free sources only: Source Cooperative rebalance-earth/ea-dem COGs, else the EA WCS for the same product. OGL v3.
# GDAL from apt (Ubuntu 24.04: GDAL 3.8.4), PROJ OSTN15 grid from cdn.proj.org via projsync.

on:
  workflow_dispatch:
    inputs:
      square:
        description: 'OS 10 km square (TR06 = Faversham / Cleve Hill)'
        default: 'TR06'
      source:
        description: 'auto (Source Cooperative, then EA WCS) | sourcecoop | ea-wcs'
        default: 'auto'
      format:
        description: 'png (safest) | webp (lossless)'
        default: 'png'
      vstep:
        description: 'height quantum in metres (0.0625 = 6 cm; 0 = full 1/256 m)'
        default: '0.0625'
      release:
        description: 'also publish a GitHub Release asset (true/false)'
        default: 'true'

permissions:
  contents: write          # only for the Release; nothing is pushed

concurrency:
  group: lidar-${{ github.event.inputs.square }}
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-24.04
    timeout-minutes: 90
    env:
      SQUARE: ${{ github.event.inputs.square }}
      SOURCE: ${{ github.event.inputs.source }}
      FORMAT: ${{ github.event.inputs.format }}
      VSTEP: ${{ github.event.inputs.vstep }}
    steps:
      - uses: actions/checkout@v4
        with:
          sparse-checkout: tools/lidar

      - name: Check the inputs
        run: |
          echo "$SQUARE" | grep -Eq '^[A-Za-z]{2}[0-9]{2}$' || { echo "::error::square must look like TR06"; exit 1; }
          case "$SOURCE" in auto|sourcecoop|ea-wcs) ;; *) echo "::error::bad source"; exit 1;; esac
          case "$FORMAT" in png|webp) ;; *) echo "::error::bad format"; exit 1;; esac
          echo "$VSTEP" | grep -Eq '^[0-9.]+$' || { echo "::error::bad vstep"; exit 1; }
          echo "SQ=$(echo "$SQUARE" | tr 'A-Z' 'a-z')" >> "$GITHUB_ENV"

      - name: Install GDAL, PROJ, numpy, Pillow (apt) and pmtiles (pip)
        run: |
          sudo apt-get update -q
          sudo apt-get install -y -q --no-install-recommends gdal-bin python3-gdal python3-numpy python3-pil proj-bin proj-data
          /usr/bin/python3 -m pip install --user --break-system-packages -q 'pmtiles>=3.4,<4'
          gdalinfo --version; projinfo 2>&1 | head -1 || true
          /usr/bin/python3 -c "from osgeo import gdal; import numpy, PIL, pmtiles; print('python', gdal.__version__, numpy.__version__, PIL.__version__)"
          gdalinfo --formats | grep -i gtiff; gdalinfo --format GTiff | grep -io 'LERC[_A-Z]*' | sort -u | tr '\n' ' '; echo

      - name: OSTN15 grid for the OSGB36 -> WGS84 step
        run: |
          projsync --file uk_os_OSTN15_NTv2_OSGBtoETRS.tif --user-writable-directory \
            || echo "::warning::OSTN15 grid not downloaded; PROJ uses the 7-parameter Helmert (about 2 m)"
          projinfo -s EPSG:27700 -t EPSG:3857 --spatial-test intersects --summary | head -4 | tee work-proj.txt
          grep -q OSTN15 work-proj.txt && echo "OSTN15 in use" || echo "::warning::OSTN15 not the first operation"

      - name: Download the 1 m DTM for the square
        run: |
          mkdir -p work/src
          /usr/bin/python3 tools/lidar/fetch_dtm.py --square "$SQUARE" --source "$SOURCE" --out work/src
          for f in work/src/*.tif; do gdalinfo "$f" | grep -E 'Size is|COMPRESSION|NoData' | tr '\n' ' '; echo " $f"; done

      - name: Build Terrarium tiles z14-z16, PMTiles and index.json
        run: |
          mkdir -p work/site/lidar
          /usr/bin/python3 tools/lidar/build_tiles.py --src work/src/*.tif --square "$SQUARE" \
            --sources work/src/sources.json --out work/site/lidar --zooms 14 15 16 \
            --format "$FORMAT" --vstep "$VSTEP" --probe --max-total-mb 300 \
            --run-url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
          cp work/src/sources.json work/site/lidar/sources-$SQ.json

      - name: Package (tiles tarball) and report measured bytes
        run: |
          mkdir -p dist
          tar -czf "dist/lidar-$SQ-tiles.tar.gz" -C work/site lidar
          mv "work/site/lidar-$SQ.pmtiles" dist/ 2>/dev/null || true
          cp work/site/lidar/index.json work/site/lidar/probe.json work/src/sources.json dist/ 2>/dev/null || true
          ls -l dist
          /usr/bin/python3 - <<'EOF' >> "$GITHUB_STEP_SUMMARY"
          import json, os
          sq = os.environ['SQUARE'].upper()
          e = json.load(open('work/site/lidar/index.json'))['squares'][0]
          src = json.load(open('work/src/sources.json'))
          print(f"## LiDAR {sq}: measured tile bytes\n")
          print(f"Source: {src['source']} ({src['bytes']:,} B downloaded in {len(src['files'])} files). "
                f"Reprojection: {e['reprojection']['operation']}\n")
          print("| zoom | tiles | total B | mean B | median B | p95 B | max B |\n|---|---|---|---|---|---|---|")
          for z, s in e['stats'].items():
              if s.get('count'):
                  print(f"| {z} | {s['count']} | {s['bytes_total']:,} | {s['bytes_mean']:,} | {s['bytes_median']:,} | {s['bytes_p95']:,} | {s['bytes_max']:,} |")
          print(f"\nTotal {e['total_bytes']:,} B ({e['total_bytes'] / 1e6:.1f} MB); z16 block ~{e['tile_m_at_centre']} m; "
                f"format {e['format']}, vstep {e['vstep_m']} m. Mean z16 block at 0.5 Mbps (62,500 B/s): "
                f"{e['stats']['16'].get('bytes_mean', 0) / 62500:.2f} s; 3x3 ring {9 * e['stats']['16'].get('bytes_mean', 0) / 62500:.1f} s.\n")
          try:
              p = json.load(open('work/site/lidar/probe.json'))
              print("### Other encodings, same z16 heights (sample)\n\n| encoding | tiles | mean B | median B |\n|---|---|---|---|")
              for k, s in p.items():
                  if isinstance(s, dict) and s.get('count'):
                      print(f"| {k} | {s['count']} | {s['bytes_mean']:,} | {s['bytes_median']:,} |")
          except FileNotFoundError:
              pass
          EOF
          cat "$GITHUB_STEP_SUMMARY"

      - uses: actions/upload-artifact@v4
        with:
          name: lidar-${{ env.SQ }}
          path: dist/
          retention-days: 30
          compression-level: 0       # already compressed

      - name: Publish the Release asset (replaces the previous build of this square)
        if: github.event.inputs.release == 'true'
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          TAG="lidar-$SQ"
          NOTE="EA LIDAR Composite DTM 1 m for OS square $SQUARE as Terrarium z14-z16 tiles. Built by run $GITHUB_RUN_ID. Contains Environment Agency information (c) Environment Agency and/or database right, OGL v3."
          gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --title "LiDAR $SQUARE (data, not code)" --notes "$NOTE" --latest=false
          gh release upload "$TAG" dist/* --clobber
          gh release edit "$TAG" --notes "$NOTE"

CVAA Inoculate Workflow

A GitHub Actions workflow. Runs when called.

automationcvaa / .github/workflows/202608301446-inoculate.yml · lines 1–37 of 37 · version 2026-08-30 14:46 · Entry point

What it does
It runs automated jobs on GitHub Actions. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'cvaa'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Runs CVAA Selftest (`tools/selftest.mjs`) and `../cvaa/inoculate.mjs`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
cvaa · .github/workflows · workflow
Uses
CVAA Selftest (workflow run)
Used by
none found
Produces
none declared
Defines here
202608301446 Inoculate (reusable)
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cvaa@dc04524c4df79e90642b8b7c00729e67cdf52855 .github/workflows/202608301446-inoculate.yml:1-37 · blob c8f884f5c24ba5ef348688d2edca43974725c964 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: agent_infra · users: ai_agent · canonical: unknown
name: 202608301446 Inoculate (reusable)
on:
  workflow_call:
    inputs:
      cvaa_sha:
        type: string
        required: true
permissions:
  contents: read
  security-events: write
jobs:
  inoculate:
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          path: repo
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          repository: Ventusltd/cvaa
          ref: ${{ inputs.cvaa_sha }}
          path: cvaa
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
        with:
          node-version: '22'
      - run: cd cvaa && node tools/selftest.mjs
      - run: cd repo && node ../cvaa/inoculate.mjs . --sarif ../cvaa.sarif
      - uses: github/codeql-action/upload-sarif@74c1aea9df7c0f02e9b7bfe4a8935abf2e5e3aa6
        if: always()
        with:
          sarif_file: cvaa.sarif
          category: cvaa

CVAA Selftest Workflow

A GitHub Actions workflow. Runs on push, on pull requests and by hand.

automationcvaa / .github/workflows/202608301447-selftest.yml · lines 1–115 of 115 · version 2026-08-30 14:47 · Entry point

What it does
It runs automated jobs on GitHub Actions. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'cvaa'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file fleet.json.
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Named “Self-test and full-history fleet audit”; runs CVAA Selftest (`tools/selftest.mjs`), CVAA Inoculate (`inoculate.mjs`) and `cvaa/tools/fleet.mjs`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
cvaa · .github/workflows · workflow
Uses
CVAA Selftest (workflow run), CVAA Inoculate (workflow run)
Used by
none found
Produces
none declared
Defines here
202608301447 Self-test and full-history fleet audit
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cvaa@dc04524c4df79e90642b8b7c00729e67cdf52855 .github/workflows/202608301447-selftest.yml:1-115 · blob 62fd5ee9a9fbed1e00f442418fdfc3932b3c1323 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unknown
name: 202608301447 Self-test and full-history fleet audit
on:
  push:
  pull_request:
  workflow_dispatch:
permissions:
  contents: read
jobs:
  selftest:
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
        with:
          node-version: '22'
      - name: History is complete, not shallow
        run: |
          set -euo pipefail
          test "$(git rev-parse --is-shallow-repository)" = false
          test "$(git rev-list --count HEAD)" -gt 1

      - name: Every vaccine on disk is in the lock, and every lock entry on disk
        run: |
          set -euo pipefail
          files=$(find vaccines -maxdepth 1 -type f -name '*.md' | wc -l)
          lock=$(node -e "console.log(Object.keys(JSON.parse(require('fs').readFileSync('vaccines.lock','utf8'))).length)")
          echo "vaccine files: $files   lock entries: $lock"
          test "$files" -eq "$lock"

      - name: Antibodies fire on disease and stay silent on health
        run: |
          set -euo pipefail
          node tools/selftest.mjs | tee /tmp/selftest.log
          test "$(tail -n 1 /tmp/selftest.log)" = 'all antibodies fire on disease and stay silent on health'

      - name: The registry has no findings against itself
        run: |
          set -euo pipefail
          node inoculate.mjs . --no-write | tee /tmp/inoculate.log
          test "$(tail -n 1 /tmp/inoculate.log)" = 'no findings, but 5 rule(s) were not evaluated; immunity is not established'

      - name: The JSON run record agrees with the registry on disk
        run: |
          set -euo pipefail
          node inoculate.mjs . --no-write --json > /tmp/run.jsonl
          node - <<'NODE'
          const fs = require('fs');
          const lines = fs.readFileSync('/tmp/run.jsonl','utf8').split('\n').filter(l => l.startsWith('{"schema":"cvaa.run.v1"'));
          if (lines.length !== 1) throw new Error(`expected one JSON record, got ${lines.length}`);
          const run = JSON.parse(lines[0]);
          if (run.status !== 'immune') throw new Error(`registry state is ${run.status}`);
          if (run.shallow !== false || run.context?.commit_count < 2) throw new Error('history context is incomplete');
          if (run.findings !== 0) throw new Error(`registry has ${run.findings} finding(s)`);
          const skipped = run.results.filter(result => result.state === 'skipped').map(result => result.vaccine);
          if (JSON.stringify(skipped) !== JSON.stringify(['dead-ends-explained', 'quantum-star-protocol', 'cells-compute-or-say-programmable', 'gpu-reuse-before-new-infrastructure', 'kuiper-belt-no-private-names'])) throw new Error(`unexpected non-evaluated rules: ${skipped.join(', ')}`);
          const active = fs.readdirSync('vaccines').filter(f => f.endsWith('.md'))
            .filter(f => !/^superseded_by:/m.test(fs.readFileSync(`vaccines/${f}`, 'utf8'))).length;
          if (run.results.length !== active) throw new Error(`expected ${active} active results (vaccines on file minus superseded), got ${run.results.length}`);
          NODE

  fleet-audit:
    needs: selftest
    if: ${{ always() && needs.selftest.result == 'success' }}
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          path: cvaa
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          repository: Ventusltd/gridatlas
          path: repos/gridatlas
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          repository: Ventusltd/pipelinenews
          path: repos/pipelinenews
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
        with:
          node-version: '22'
      - name: Run current three-repository fleet table
        shell: bash
        run: |
          set -euo pipefail
          node cvaa/tools/fleet.mjs cvaa repos/gridatlas repos/pipelinenews --json-out fleet.json | tee fleet.txt
          node - <<'NODE'
          const fleet = require('./fleet.json');
          const names = fleet.repositories.map(r => r.name);
          if (fleet.schema !== 'cvaa.fleet.v1') throw new Error('wrong fleet schema');
          for (const required of ['cvaa', 'gridatlas', 'pipelinenews']) {
            if (!names.includes(required)) throw new Error(`missing repository: ${required}; found ${names}`);
          }
          if (fleet.repositories.some(r => r.shallow)) throw new Error('fleet contains a shallow checkout');
          NODE
          {
            echo '## CVAA fleet audit'
            echo
            echo '```text'
            cat fleet.txt
            echo '```'
          } >> "$GITHUB_STEP_SUMMARY"

CVAA Consumer Workflow Template

A configuration file that copies to `/.github/workflows/` `-inoculate.yml`. Runs on push, on pull requests and on a schedule.

automationcvaa / consumer-workflow-template.yml · lines 1–18 of 18 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'cvaa'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
What it achieves
That is the whole integration.
Why it matters
No other file in the estate was found to import it.
Application
cvaa · / · configuration
Uses
none found
Used by
none found
Produces
none declared
Defines here
Inoculate against hostile amnesia
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cvaa@dc04524c4df79e90642b8b7c00729e67cdf52855 consumer-workflow-template.yml:1-18 · blob f1fc8715fb5819af44a601c0758eda4861289784 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
# Copy to <repo>/.github/workflows/<12-digit-timestamp>-inoculate.yml. That is the whole integration.
# Replace both SHAs with the commit of Ventusltd/cvaa you have reviewed. Never use @main.
# Full-history contract: the pinned reusable workflow checks out both the consumer and CVAA with fetch-depth: 0.
name: Inoculate against hostile amnesia
on:
  push:
  pull_request:
  schedule:
    - cron: '17 */6 * * *'
  workflow_dispatch:
permissions:
  contents: read
  security-events: write
jobs:
  cvaa:
    uses: Ventusltd/cvaa/.github/workflows/202608301446-inoculate.yml@REPLACE_WITH_40_CHAR_SHA
    with:
      cvaa_sha: REPLACE_WITH_40_CHAR_SHA

CVAA Antibody Runner

A JavaScript module in the tools folder.

othercvaa / tools/antibody-runner.mjs · lines 1–12 of 12 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'cvaa'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
What it achieves
Runs one antibody. Receives {code, ctx} on stdin, prints {ok, r} or {ok:false, e}.
Why it matters
No other file in the estate was found to import it.
Application
cvaa · tools · JavaScript module
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cvaa@dc04524c4df79e90642b8b7c00729e67cdf52855 tools/antibody-runner.mjs:1-12 · blob 799d8f625e5c475e65c20075d464b327a844b769 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
// Runs one antibody. Receives {code, ctx} on stdin, prints {ok, r} or {ok:false, e}. Nothing else.
let buf = ''; process.stdin.setEncoding('utf8'); for await (const c of process.stdin) buf += c;
const { code, ctx } = JSON.parse(buf); const pathSet = new Set(ctx.paths || []); ctx.exists = p => pathSet.has(p);
try {
  const antibody = (0, eval)('(' + code.replace(/^\s*export\s+default\s*/, '').trim().replace(/;\s*$/, '') + ')');
  const r = await antibody(ctx);
  // A non-array used to become [], which reads as immune. An antibody that cannot
  // evaluate its question returns { skip: "why" } and the caller reports a skip.
  if (r && !Array.isArray(r) && typeof r.skip === 'string')
    process.stdout.write(JSON.stringify({ ok: true, r: [], skip: r.skip }));
  else process.stdout.write(JSON.stringify({ ok: true, r: Array.isArray(r) ? r : [] }));
} catch (e) { process.stdout.write(JSON.stringify({ ok: false, e: String(e && e.message || e) })); }

CVAA Fleet

A JavaScript module in the tools folder.

storagecvaa / tools/fleet.mjs · lines 1–71 of 71 · Not reached from any entry point (candidate for review)

What it does
It lists and searches its content. Uses libraries node:child_process, node:fs, node:path, node:url. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'cvaa'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: command-line arguments.
What it achieves
Immunity table across repositories.
Why it matters
No other file in the estate was found to import it.
Application
cvaa · tools · JavaScript module
Uses
CVAA Inoculate (script call), node:child_process, node:fs, node:path, node:url
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cvaa@dc04524c4df79e90642b8b7c00729e67cdf52855 tools/fleet.mjs:1-71 · blob b55af6d425b2041c71985f4827058aa4e4a2b5f8 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
// tools/fleet.mjs <repo>... [--json-out file] — immunity table across repositories
import { spawnSync } from 'node:child_process';
import { writeFileSync } from 'node:fs';
import { basename, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const argv = process.argv.slice(2);
let jsonOut = null;
const repos = [];
for (let i = 0; i < argv.length; i++) {
  if (argv[i] === '--json-out') {
    jsonOut = argv[++i];
    if (!jsonOut) throw new Error('--json-out requires a file path');
  } else repos.push(argv[i]);
}
if (!repos.length) {
  console.error('usage: node tools/fleet.mjs <repo>... [--json-out file]');
  process.exit(2);
}

const inoculate = fileURLToPath(new URL('../inoculate.mjs', import.meta.url));
const repositoryRuns = [];
const seenNames = new Map();
const vaccineOrder = [];
const table = new Map();
for (const repo of repos) {
  const run = spawnSync(process.execPath, [inoculate, repo, '--no-write', '--json'], {
    encoding: 'utf8',
    maxBuffer: 32 * 1024 * 1024
  });
  const lines = String(run.stdout || '').split('\n').filter(Boolean);
  const jsonLine = [...lines].reverse().find(line => line.startsWith('{"schema":"cvaa.run.v1"'));
  if (!jsonLine) {
    console.error(run.stderr || run.stdout || `no CVAA JSON produced for ${repo}`);
    process.exit(1);
  }
  const parsed = JSON.parse(jsonLine);
  const baseName = basename(resolve(repo)) || 'repo';
  const ordinal = (seenNames.get(baseName) || 0) + 1;
  seenNames.set(baseName, ordinal);
  const name = ordinal === 1 ? baseName : `${baseName}-${ordinal}`;
  const warnings = parsed.results.reduce((n, result) => n + (result.level === 'warning' ? result.findings.length : 0), 0);
  repositoryRuns.push({ name, path: repo, exit_code: run.status, errors: parsed.findings, warnings, shallow: parsed.shallow, results: parsed.results });
  for (const result of parsed.results) {
    if (!vaccineOrder.includes(result.vaccine)) vaccineOrder.push(result.vaccine);
    if (!table.has(result.vaccine)) table.set(result.vaccine, new Map());
    const state = result.findings.length
      ? (result.level === 'error' ? `FAIL ${result.findings.length}` : `warn ${result.findings.length}`)
      : 'ok';
    table.get(result.vaccine).set(name, state);
  }
}

const names = repositoryRuns.map(run => run.name);
console.log('vaccine'.padEnd(32) + names.map(name => name.padStart(16)).join(''));
for (const vaccine of vaccineOrder) {
  console.log(vaccine.padEnd(32) + names.map(name => (table.get(vaccine)?.get(name) || '-').padStart(16)).join(''));
}
console.log('errors'.padEnd(32) + repositoryRuns.map(run => String(run.errors).padStart(16)).join(''));
console.log('warnings'.padEnd(32) + repositoryRuns.map(run => String(run.warnings).padStart(16)).join(''));

const payload = {
  schema: 'cvaa.fleet.v1',
  generated_at: new Date().toISOString(),
  repositories: repositoryRuns,
  vaccines: vaccineOrder.map(vaccine => ({
    vaccine,
    repositories: Object.fromEntries(names.map(name => [name, table.get(vaccine)?.get(name) || '-']))
  }))
};
if (jsonOut) writeFileSync(jsonOut, JSON.stringify(payload, null, 2) + '\n');