From 9262dc3026df5aface0a057bdf13327446598473 Mon Sep 17 00:00:00 2001 From: Active Inference Institute Date: Thu, 12 Nov 2026 08:32:27 -0800 Subject: [PATCH] gnn: adopt the shared gnn.importers reader at v5.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pin moves from v5.0.3 at 8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1 — a revision that predates src/gnn/importers.py — to v5.1.0 at 75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf, the release that ships it. The interim local reader goes away instead of being reimplemented: * blockference.gnn.load_pin, GNN_PIN_PATH and their pin-shape tests are deleted; the shared reader owns pin discovery, shape normalization and the pointer check. * the gnn arm runs `python -m gnn.importers check --repo . --require-pointer --workflow .github/workflows/ci.yml --job gnn-conformance` from the pinned runtime, then the drift check and the deep pinned-parser conformance check. * scripts/gnn_importer_report.py is the only bridge: it prints the normalized pin and the gnn-importer-variables/v1 map from an interpreter where gnn is importable, which is what validate_gnn_spec.py and manuscript_variables.py consume. * the gnn_* manuscript variables come from importer_variables, so the prose and the conformance job cannot disagree about the pinned revision. * CI provisions the runtime from the two pin fields with a plain JSON read; the workflow keeps no pin reader. Pin and pointer validation, spec parsing, the semantic validator, the B-orientation check, the consistency checker and the recorded parser digests all run against 75c834bd. The gate selection `--arm all --arm test --arm render` passes on this tree. --- .github/AGENTS.md | 3 +- .github/GNN.md | 13 +- .github/workflows/README.md | 3 +- .github/workflows/ci.yml | 12 +- AGENTS.md | 10 +- README.md | 9 +- TODO.md | 10 ++ blockference/gnn.py | 25 +--- docs/_generated/gate-metrics.md | 30 ++--- docs/_generated/gate-timings.json | 152 ++++++++++++++++++---- docs/_generated/manuscript-variables.json | 16 +-- docs/development.md | 7 +- docs/gate.md | 23 ++-- docs/gnn.md | 68 +++++++--- docs/manuscript/09_reproducibility.md | 5 +- scripts/README.md | 8 +- scripts/gnn_importer_report.py | 70 ++++++++++ scripts/manuscript_variables.py | 67 +++++++--- scripts/release_check.py | 42 +++++- scripts/validate_gnn_spec.py | 76 +++++++++-- specs/README.md | 12 +- specs/gnn-pin.json | 12 +- tests/test_gnn_spec.py | 41 +----- tests/test_release_gate.py | 52 ++++++++ 24 files changed, 561 insertions(+), 205 deletions(-) create mode 100644 scripts/gnn_importer_report.py diff --git a/.github/AGENTS.md b/.github/AGENTS.md index 88c1fa9..e99e74d 100644 --- a/.github/AGENTS.md +++ b/.github/AGENTS.md @@ -6,7 +6,8 @@ contains only Python 3.11 and runs `--arm test-full`. The `gnn-conformance` job (display name `gnn conformance (pinned)`) runs `--arm all` on Python 3.12 with `GNN_RUNTIME_PYTHON` set to the separate runtime provisioned from `specs/gnn-pin.json`. There is no separate `gate` job. Pinned conformance always runs in the `gnn` -arm; missing runtime dependencies must fail, never skip. PDF rendering remains +arm, where the shared `python -m gnn.importers check --repo .` reads the pin and +the pointer; missing runtime dependencies must fail, never skip. PDF rendering remains an explicit local `--arm render` selection. The workflow uses pinned `astral-sh/setup-uv` directly, not the Institute composite; see [`../docs/gate.md`](../docs/gate.md) for the exact action and command map. diff --git a/.github/GNN.md b/.github/GNN.md index 86aa03e..2111b66 100644 --- a/.github/GNN.md +++ b/.github/GNN.md @@ -3,14 +3,19 @@ `gnn conformance (pinned)` is the display name of job `gnn-conformance` in `.github/workflows/ci.yml`. It reads `specs/gnn-pin.json` (schema `gnn-importer-pin/v1`), which pins -`ActiveInferenceInstitute/Generalized_Notation_Notation` at `v5.0.3` -(`8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`) and records SHA-256 digests for +`ActiveInferenceInstitute/Generalized_Notation_Notation` at `v5.1.0` +(`75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`) and records SHA-256 digests for the five parser files under `src/gnn/`. The job installs that commit into a separate Python 3.12 runtime, then invokes the canonical release gate with `--arm all` and `GNN_RUNTIME_PYTHON` set to that runtime. Its `gnn` -arm always performs both the offline drift check and real pinned validation; -a missing runtime fails instead of skipping conformance. See +arm runs the estate's shared reader, +`python -m gnn.importers check --repo . --require-pointer --workflow +.github/workflows/ci.yml --job gnn-conformance`, from that runtime, then the +offline drift check and the deep pinned-parser conformance check. The reader +owns pin discovery and validation, and reports a pointer that fails to name the +pin file, the pinned revision, the workflow or the job. A missing runtime +fails instead of skipping conformance. See [`docs/gate.md`](../docs/gate.md) for the complete job and arm map, and [`docs/gnn.md`](../docs/gnn.md) for standalone validation commands. diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 145cbfc..309eea2 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -10,7 +10,8 @@ release gate in two jobs: The second job retains the display name `gnn conformance (pinned)` and installs the revision in [`../../specs/gnn-pin.json`](../../specs/gnn-pin.json) into a -separate runtime. The full suite runs on both Python versions; all other release +separate runtime; its `gnn` arm then calls the shared +`python -m gnn.importers check --repo .` from that runtime. The full suite runs on both Python versions; all other release arms run with conformance on Python 3.12. Missing pinned-runtime validation fails the gate. There is no separate `gate` job, and PDF rendering remains an explicit local arm. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa59498..985d003 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,9 @@ jobs: # Validates the committed GNN specification with the parser pinned in # specs/gnn-pin.json. The pinned revision is installed into a separate runtime # because the GNN distribution requires numpy>=2 while this package - # resolves numpy 1.x; the validator verifies the installed parser file - # digests against the pin record before parsing. + # resolves numpy 1.x. The gnn arm runs the shared `python -m gnn.importers + # check` from that runtime, and the validator verifies the installed parser + # file digests against the pin record before parsing. name: gnn conformance (pinned) runs-on: ubuntu-latest @@ -83,8 +84,11 @@ jobs: id: runtime run: | set -euo pipefail - REPO=$(uv run --no-sync python -c "from blockference.gnn import load_pin; print(load_pin()['repository'])") - COMMIT=$(uv run --no-sync python -c "from blockference.gnn import load_pin; print(load_pin()['commit'])") + # Provisioning needs only the two install coordinates. The pin itself is + # validated by the shared reader in the release arms below, so the + # workflow keeps no pin reader of its own. + REPO=$(uv run --no-sync python -c "import json; print(json.load(open('specs/gnn-pin.json', encoding='utf-8'))['repository'])") + COMMIT=$(uv run --no-sync python -c "import json; print(json.load(open('specs/gnn-pin.json', encoding='utf-8'))['commit'])") uv venv --python 3.12 "$RUNNER_TEMP/gnn-runtime" # The install follows specs/gnn-pin.json; a pin bump re-points it. uv pip install --python "$RUNNER_TEMP/gnn-runtime/bin/python" \ diff --git a/AGENTS.md b/AGENTS.md index 5eafe29..f86f0e2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,10 +24,12 @@ The grid-world model is declared in `specs/gridworld_3x3.gnn.md` (Generalized Notation Notation) and generated from the implementation by `blockference.gnn.render_spec`; `uv run python scripts/export_gnn_spec.py --check` fails when the committed document drifts. The upstream parser is -pinned in `specs/gnn-pin.json` (GNN v5.0.3, commit `8f293d9ba`), and -`scripts/validate_gnn_spec.py` parses the document with that revision, builds -the runtime model from the declared parameters, and requires the declared -matrices to match. That check needs an external runtime (`GNN_ROOT` or +pinned in `specs/gnn-pin.json` (GNN v5.1.0, commit `75c834bd8`), and +`python -m gnn.importers check --repo .` reads that pin and the `.github/GNN.md` +pointer while `scripts/validate_gnn_spec.py` parses the document with that +revision, builds the runtime model from the declared parameters, and requires the +declared matrices to match. Do not add a second pin reader: the shared reader is +upstream. Both checks need an external runtime (`GNN_ROOT` or `GNN_RUNTIME_PYTHON`); the required `gnn-conformance` CI job provisions one from the pin and runs `scripts/release_check.py --arm gnn`. Do not hand-edit `specs/gridworld_3x3.gnn.md`: change the model or fixture in diff --git a/README.md b/README.md index f6b6b22..f2291a2 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,11 @@ The grid-world generative model is declared in [Generalized Notation Notation](https://github.com/ActiveInferenceInstitute/Generalized_Notation_Notation) (GNN). The document is generated from the implementation and validated against the upstream parser pinned in [`specs/gnn-pin.json`](specs/gnn-pin.json) -(schema `gnn-importer-pin/v1`, GNN v5.0.3, commit -`8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`): the validator reads the declared parameters -back, builds the runtime model from them, and requires the declared matrices to -match exactly. See [`docs/gnn.md`](docs/gnn.md) for the commands and the +(schema `gnn-importer-pin/v1`, GNN v5.1.0, commit +`75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`): the estate's shared reader +`gnn.importers` validates that pin and the [`.github/GNN.md`](.github/GNN.md) +pointer, and the validator reads the declared parameters back, builds the runtime +model from them, and requires the declared matrices to match exactly. See [`docs/gnn.md`](docs/gnn.md) for the commands and the conformance contract. GNN maintains a [downstream adoption diff --git a/TODO.md b/TODO.md index e60cf1b..d757d86 100644 --- a/TODO.md +++ b/TODO.md @@ -55,6 +55,16 @@ Items are grouped by the size of the documentation change required: - [x] Document receipt imports, including the failed offline package baseline cache miss, without claiming a speedup; distinguish the declared NumPy range from the actual lockfile resolution. +- [x] Cut over to the shared GNN pin reader. The pin moved from `v5.0.3` at + `8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1` — a revision that predates + `src/gnn/importers.py` — to `v5.1.0` at + `75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`, and the interim local reader + (`blockference.gnn.load_pin` plus its pin-shape tests) is deleted. The + `gnn` arm now runs `python -m gnn.importers check --repo . --require-pointer + --workflow .github/workflows/ci.yml --job gnn-conformance` from the pinned + runtime, and the `gnn_*` manuscript variables come from + `gnn.importers.importer_variables` through + `scripts/gnn_importer_report.py`. No copy of the reader is vendored. ## Major diff --git a/blockference/gnn.py b/blockference/gnn.py index ecd5a34..c27f6a9 100644 --- a/blockference/gnn.py +++ b/blockference/gnn.py @@ -16,13 +16,13 @@ model *from* the parsed document and compare it with the declared matrices. The pin record in ``specs/gnn-pin.json`` names the exact upstream revision whose -parser validates the document; see ``docs/gnn.md`` for the commands. +parser validates the document. The pin is read by the upstream +``gnn.importers`` reader, which this repository calls instead of keeping its own; +see ``docs/gnn.md`` for the commands. """ from __future__ import annotations -import json -import re from collections.abc import Iterable, Mapping, Sequence from dataclasses import dataclass from pathlib import Path @@ -34,13 +34,11 @@ from blockference.gridference import ActiveGridference, make_grid __all__ = [ - "GNN_PIN_PATH", "GNN_SPEC_PATH", "SPEC_DIR", "GridWorldSpecParameters", "build_spec_model", "declared_arrays", - "load_pin", "parameters_from_parsed", "render_spec", "spec_arrays", @@ -50,7 +48,6 @@ ROOT = Path(__file__).resolve().parents[1] SPEC_DIR = ROOT / "specs" GNN_SPEC_PATH = SPEC_DIR / "gridworld_3x3.gnn.md" -GNN_PIN_PATH = SPEC_DIR / "gnn-pin.json" #: GNN language revision declared by the document header. GNN_LANGUAGE_VERSION = "GNN v1.1" @@ -152,22 +149,6 @@ def spec_arrays(parameters: GridWorldSpecParameters | None = None) -> dict[str, } -def load_pin(path: Path | None = None) -> dict[str, Any]: - """Return the upstream pin, rejecting records outside the local pin contract.""" - - pin = json.loads((path or GNN_PIN_PATH).read_text(encoding="utf-8")) - if not isinstance(pin, dict): - raise ValueError("invalid GNN pin: expected a JSON object") - if pin.get("schema") != "gnn-importer-pin/v1": - raise ValueError("invalid GNN pin schema: expected gnn-importer-pin/v1") - if pin.get("tag") != "v5.0.3": - raise ValueError("invalid GNN pin tag: expected v5.0.3") - commit = pin.get("commit") - if not isinstance(commit, str) or re.fullmatch(r"[0-9a-fA-F]{40}", commit) is None: - raise ValueError("invalid GNN pin commit: expected a full 40-hex revision") - return pin - - def _format_value(value: float) -> str: return f"{float(value):.1f}" diff --git a/docs/_generated/gate-metrics.md b/docs/_generated/gate-metrics.md index c059928..0ad72e7 100644 --- a/docs/_generated/gate-metrics.md +++ b/docs/_generated/gate-metrics.md @@ -2,9 +2,9 @@ -Measured wall times from recorded canonical gate observations on `macOS-27.0.1-arm64-arm-64bit` with Python 3.12.16 at `2026-11-12T13:56:34Z`. +Measured wall times from recorded canonical gate observations on `macOS-27.0.1-arm64-arm-64bit` with Python 3.12.16 at `2026-11-12T16:30:49Z`. -First successful measurements retained for each arm. Package initially failed twice because offline pandas wheel metadata was unavailable; only package and the not-yet-run render arm were then run after SHA-256-verified acquisition of the exact pandas wheel in uv.lock. Those failures remain in this receipt’s runs. UV_FIND_LINKS pointed to that verified local wheelhouse for the successful package run. Baseline and after test selections differ by the new regression cases. No speedup is claimed. Audit refresh retains the earlier observations and two failed full-suite runs in runs; the notebook validator initially recursed into gitignored, untracked GNN migration build output. That output was moved aside without tracked changes for the successful 103-test run, then restored. Current lint, types, docs, GNN, render and full-suite observations are refreshed; other arm observations remain historical. The fresh render artifact was identified by the gate producer from source commit 2193be7b0be3fc429f4a8d159d4b96b249b12060. +First successful measurements retained for each arm. Package initially failed twice because offline pandas wheel metadata was unavailable; only package and the not-yet-run render arm were then run after SHA-256-verified acquisition of the exact pandas wheel in uv.lock. Those failures remain in this receipt’s runs. UV_FIND_LINKS pointed to that verified local wheelhouse for the successful package run. Baseline and after test selections differ by the new regression cases. No speedup is claimed. Audit refresh retains the earlier observations and two failed full-suite runs in runs; the notebook validator initially recursed into gitignored, untracked GNN migration build output. That output was moved aside without tracked changes for the successful 103-test run, then restored. Current lint, types, docs, GNN, render and full-suite observations are refreshed; other arm observations remain historical. The fresh render artifact was identified by the gate producer from source commit 2193be7b0be3fc429f4a8d159d4b96b249b12060. Recorded after the shared gnn.importers cutover: the gnn arm runs python -m gnn.importers check --repo . with --require-pointer, then the specification drift check and the deep pinned-parser conformance check, and the manuscript arm reads its gnn_* variables from the pinned runtime. GNN_RUNTIME_PYTHON pointed at the GNN v5.1.0 checkout's own virtual environment. No speedup is claimed. Refresh with: @@ -21,15 +21,15 @@ uv run python scripts/gate_metrics.py --record-timings /tmp/gate-after.json | Arm | Before (s) | Before status | After (s) | After status | After command | | --- | --- | --- | --- | --- | --- | | `lint` | 0.11 | passed | 0.03 | passed | `uv run ruff check blockference tests GRTs scripts` | -| `types` | 0.61 | passed | 1.06 | passed | `uv run mypy blockference` | -| `test` | 33.27 | passed | 4.82 | passed | `uv run pytest -m not slow` | -| `test-full` | 55.38 | passed | 44.22 | passed | `uv run pytest --cov=blockference --cov-report=term --cov-report=xml --cov-fail-under=90` | -| `docs` | 7.45 | passed | 5.28 | passed | `uv run python scripts/check_docs_links.py` | -| `manuscript` | 6.04 | passed | 3.24 | passed | `uv run python scripts/manuscript_variables.py --check` | -| `gnn` | 2.78 | passed | 2.0 | passed | `uv run python scripts/export_gnn_spec.py --check` | -| `smoke` | 3.48 | passed | 2.55 | passed | `uv run blockference pipeline --config configs/smoke.yml --output-root /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-gate-vx7lf7ds/output --run-name gate_smoke` | -| `package` | 0.08 | failed | 14.86 | passed | `uv build` | -| `render` | 4.04 | passed | 4.46 | passed | `uv run python scripts/build_manuscript.py --render pdf` | +| `types` | 0.61 | passed | 0.22 | passed | `uv run mypy blockference` | +| `test` | 33.27 | passed | 7.12 | passed | `uv run pytest -m not slow` | +| `test-full` | 55.38 | passed | 32.97 | passed | `uv run pytest --cov=blockference --cov-report=term --cov-report=xml --cov-fail-under=90` | +| `docs` | 7.45 | passed | 3.97 | passed | `uv run python scripts/check_docs_links.py` | +| `manuscript` | 6.04 | passed | 3.5 | passed | `uv run python scripts/manuscript_variables.py --check` | +| `gnn` | 2.78 | passed | 2.04 | passed | `uv run python scripts/export_gnn_spec.py --check` | +| `smoke` | 3.48 | passed | 2.72 | passed | `uv run blockference pipeline --config configs/smoke.yml --output-root /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/output --run-name gate_smoke` | +| `package` | 0.08 | failed | 8.91 | passed | `uv build` | +| `render` | 4.04 | passed | 3.59 | passed | `uv run python scripts/build_manuscript.py --render pdf` | Baseline workloads that are not equivalent to their arms: @@ -43,13 +43,13 @@ The baseline and current receipts are historical evidence. Timings include host | Selection | Collected tests | | --- | --- | -| full suite | 103 | -| fast (`-m "not slow"`) | 90 | +| full suite | 97 | +| fast (`-m "not slow"`) | 84 | | slow (`-m slow`) | 13 | -Recorded run: 103 passed, 0 skipped. +Recorded run: 97 passed, 0 skipped. -`test-full` recorded 91.02% line coverage of `blockference` (floor 90%). +`test-full` recorded 90.96% line coverage of `blockference` (floor 90%). ## Receipts diff --git a/docs/_generated/gate-timings.json b/docs/_generated/gate-timings.json index 05ca8f3..fa76faa 100644 --- a/docs/_generated/gate-timings.json +++ b/docs/_generated/gate-timings.json @@ -5,15 +5,16 @@ "uv run python scripts/check_docs_links.py", "uv run python scripts/gate_metrics.py --check" ], - "seconds": 5.28, + "seconds": 3.97, "status": "passed" }, "gnn": { "commands": [ "uv run python scripts/export_gnn_spec.py --check", - "uv run python scripts/validate_gnn_spec.py --gnn-runtime /private/tmp/gnn-rt-503/bin/python --json" + "/Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/Generalized_Notation_Notation/.venv/bin/python -m gnn.importers check --repo . --require-pointer --workflow .github/workflows/ci.yml --job gnn-conformance", + "uv run python scripts/validate_gnn_spec.py --gnn-runtime /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/Generalized_Notation_Notation/.venv/bin/python --json" ], - "seconds": 2.0, + "seconds": 2.04, "status": "passed" }, "lint": { @@ -30,67 +31,67 @@ "uv run python scripts/build_manuscript.py", "uv run python scripts/build_manuscript.py --check" ], - "seconds": 3.24, + "seconds": 3.5, "status": "passed" }, "package": { "commands": [ "uv build", - "uv export --locked --no-dev --no-emit-project --no-hashes --output-file /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-package-kki5eqz6/constraints.txt", - "uv venv --python /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/.venv/bin/python /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-package-kki5eqz6/venv", - "uv pip install --python /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-package-kki5eqz6/venv/bin/python --constraint /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-package-kki5eqz6/constraints.txt /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/dist/active_blockference-1.0.0-py3-none-any.whl", - "/private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-package-kki5eqz6/venv/bin/python -I -c from blockference import GridWorld; assert GridWorld(2, {'agent': (0, 0)}).current_state == {'agent': (0, 0)}" + "uv export --locked --no-dev --no-emit-project --no-hashes --output-file /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/constraints.txt", + "uv venv --python /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/.venv/bin/python /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv", + "uv pip install --python /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv/bin/python --constraint /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/constraints.txt /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/dist/active_blockference-1.0.0-py3-none-any.whl", + "/var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv/bin/python -I -c from blockference import GridWorld; assert GridWorld(2, {'agent': (0, 0)}).current_state == {'agent': (0, 0)}" ], - "seconds": 14.86, + "seconds": 8.91, "status": "passed" }, "render": { "artifact": { - "bytes": 262701, + "bytes": 263025, "path": "docs/_build/manuscript/activeblockference.pdf", - "sha256": "77ee9b6ef9c83cc8b26ce5bd9130baa851ce5168b5d4207f3e2b3e16ce884f88", - "source_commit": "2193be7b0be3fc429f4a8d159d4b96b249b12060" + "sha256": "0648f74a7adfe24192f33ff5c6fb9b9ad62ba00e098601fa2ee5d24c42e7e38e", + "source_commit": "9f17b5e242a734a4483ec3889019a83951193ca8" }, "commands": [ "uv run python scripts/build_manuscript.py --render pdf" ], - "seconds": 4.46, + "seconds": 3.59, "status": "passed" }, "smoke": { "commands": [ - "uv run blockference pipeline --config configs/smoke.yml --output-root /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-gate-vx7lf7ds/output --run-name gate_smoke", - "uv run blockference validation --run-dir /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-gate-vx7lf7ds/output/gate_smoke", - "uv run blockference run --config configs/smoke.yml --output /private/tmp/activeblockference-estate.8EbtJ4/tmp/activeblockference-gate-vx7lf7ds/run.csv" + "uv run blockference pipeline --config configs/smoke.yml --output-root /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/output --run-name gate_smoke", + "uv run blockference validation --run-dir /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/output/gate_smoke", + "uv run blockference run --config configs/smoke.yml --output /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/run.csv" ], - "seconds": 2.55, + "seconds": 2.72, "status": "passed" }, "test": { "commands": [ "uv run pytest -m not slow" ], - "seconds": 4.82, + "seconds": 7.12, "status": "passed" }, "test-full": { "commands": [ "uv run pytest --cov=blockference --cov-report=term --cov-report=xml --cov-fail-under=90" ], - "seconds": 44.22, + "seconds": 32.97, "status": "passed" }, "types": { "commands": [ "uv run mypy blockference" ], - "seconds": 1.06, + "seconds": 0.22, "status": "passed" } }, - "completed": "2026-11-12T15:01:53Z", - "conditions": "First successful measurements retained for each arm. Package initially failed twice because offline pandas wheel metadata was unavailable; only package and the not-yet-run render arm were then run after SHA-256-verified acquisition of the exact pandas wheel in uv.lock. Those failures remain in this receipt\u2019s runs. UV_FIND_LINKS pointed to that verified local wheelhouse for the successful package run. Baseline and after test selections differ by the new regression cases. No speedup is claimed. Audit refresh retains the earlier observations and two failed full-suite runs in runs; the notebook validator initially recursed into gitignored, untracked GNN migration build output. That output was moved aside without tracked changes for the successful 103-test run, then restored. Current lint, types, docs, GNN, render and full-suite observations are refreshed; other arm observations remain historical. The fresh render artifact was identified by the gate producer from source commit 2193be7b0be3fc429f4a8d159d4b96b249b12060.", - "generated": "2026-11-12T13:56:34Z", + "completed": "2026-11-12T16:30:49Z", + "conditions": "First successful measurements retained for each arm. Package initially failed twice because offline pandas wheel metadata was unavailable; only package and the not-yet-run render arm were then run after SHA-256-verified acquisition of the exact pandas wheel in uv.lock. Those failures remain in this receipt\u2019s runs. UV_FIND_LINKS pointed to that verified local wheelhouse for the successful package run. Baseline and after test selections differ by the new regression cases. No speedup is claimed. Audit refresh retains the earlier observations and two failed full-suite runs in runs; the notebook validator initially recursed into gitignored, untracked GNN migration build output. That output was moved aside without tracked changes for the successful 103-test run, then restored. Current lint, types, docs, GNN, render and full-suite observations are refreshed; other arm observations remain historical. The fresh render artifact was identified by the gate producer from source commit 2193be7b0be3fc429f4a8d159d4b96b249b12060. Recorded after the shared gnn.importers cutover: the gnn arm runs python -m gnn.importers check --repo . with --require-pointer, then the specification drift check and the deep pinned-parser conformance check, and the manuscript arm reads its gnn_* variables from the pinned runtime. GNN_RUNTIME_PYTHON pointed at the GNN v5.1.0 checkout's own virtual environment. No speedup is claimed.", + "generated": "2026-11-12T16:30:49Z", "host": "macOS-27.0.1-arm64-arm-64bit", "python": "3.12.16", "runs": [ @@ -318,12 +319,113 @@ "passed": 103, "skipped": 0 } + }, + { + "arms": { + "docs": { + "commands": [ + "uv run python scripts/check_docs_links.py", + "uv run python scripts/gate_metrics.py --check" + ], + "seconds": 3.97, + "status": "passed" + }, + "gnn": { + "commands": [ + "uv run python scripts/export_gnn_spec.py --check", + "/Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/Generalized_Notation_Notation/.venv/bin/python -m gnn.importers check --repo . --require-pointer --workflow .github/workflows/ci.yml --job gnn-conformance", + "uv run python scripts/validate_gnn_spec.py --gnn-runtime /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/Generalized_Notation_Notation/.venv/bin/python --json" + ], + "seconds": 2.04, + "status": "passed" + }, + "lint": { + "commands": [ + "uv run ruff check blockference tests GRTs scripts" + ], + "seconds": 0.03, + "status": "passed" + }, + "manuscript": { + "commands": [ + "uv run python scripts/manuscript_variables.py --check", + "uv run python scripts/validate_manuscript.py", + "uv run python scripts/build_manuscript.py", + "uv run python scripts/build_manuscript.py --check" + ], + "seconds": 3.5, + "status": "passed" + }, + "package": { + "commands": [ + "uv build", + "uv export --locked --no-dev --no-emit-project --no-hashes --output-file /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/constraints.txt", + "uv venv --python /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/.venv/bin/python /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv", + "uv pip install --python /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv/bin/python --constraint /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/constraints.txt /Users/friedman/Documents/Git/gitvault/Username/ActiveInferenceInstitute/Public/ActiveBlockference/dist/active_blockference-1.0.0-py3-none-any.whl", + "/var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-package-slxeykv5/venv/bin/python -I -c from blockference import GridWorld; assert GridWorld(2, {'agent': (0, 0)}).current_state == {'agent': (0, 0)}" + ], + "seconds": 8.91, + "status": "passed" + }, + "render": { + "artifact": { + "bytes": 263025, + "path": "docs/_build/manuscript/activeblockference.pdf", + "sha256": "0648f74a7adfe24192f33ff5c6fb9b9ad62ba00e098601fa2ee5d24c42e7e38e", + "source_commit": "9f17b5e242a734a4483ec3889019a83951193ca8" + }, + "commands": [ + "uv run python scripts/build_manuscript.py --render pdf" + ], + "seconds": 3.59, + "status": "passed" + }, + "smoke": { + "commands": [ + "uv run blockference pipeline --config configs/smoke.yml --output-root /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/output --run-name gate_smoke", + "uv run blockference validation --run-dir /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/output/gate_smoke", + "uv run blockference run --config configs/smoke.yml --output /var/folders/qs/rxkntx5d4hlgz0c7x8v15gym0000gn/T/activeblockference-gate-xizbjknp/run.csv" + ], + "seconds": 2.72, + "status": "passed" + }, + "test": { + "commands": [ + "uv run pytest -m not slow" + ], + "seconds": 7.12, + "status": "passed" + }, + "test-full": { + "commands": [ + "uv run pytest --cov=blockference --cov-report=term --cov-report=xml --cov-fail-under=90" + ], + "seconds": 32.97, + "status": "passed" + }, + "types": { + "commands": [ + "uv run mypy blockference" + ], + "seconds": 0.22, + "status": "passed" + } + }, + "generated": "2026-11-12T16:30:49Z", + "host": "macOS-27.0.1-arm64-arm-64bit", + "python": "3.12.16", + "schema": "activeblockference-gate/v1", + "tests": { + "coverage_percent": 90.96, + "passed": 97, + "skipped": 0 + } } ], "schema": "activeblockference-gate/v1", "tests": { - "coverage_percent": 91.02, - "passed": 103, + "coverage_percent": 90.96, + "passed": 97, "skipped": 0 } } diff --git a/docs/_generated/manuscript-variables.json b/docs/_generated/manuscript-variables.json index c5c5fb8..402c1a6 100644 --- a/docs/_generated/manuscript-variables.json +++ b/docs/_generated/manuscript-variables.json @@ -9,13 +9,13 @@ "experiment_seed": 17, "experiment_timesteps": 6, "gate_entry_point": "scripts/release_check.py", - "gnn_commit": "8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1", + "gnn_commit": "75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf", "gnn_job_key": "gnn-conformance", "gnn_job_name": "gnn conformance (pinned)", "gnn_pin_path": "specs/gnn-pin.json", "gnn_pin_schema": "gnn-importer-pin/v1", - "gnn_repository": "https://github.com/ActiveInferenceInstitute/Generalized_Notation_Notation", - "gnn_tag": "v5.0.3", + "gnn_repository": "ActiveInferenceInstitute/Generalized_Notation_Notation", + "gnn_tag": "v5.1.0", "package_version": "1.0.0", "python_requires": "3.11+", "schema": "manuscript-variables/v1", @@ -30,13 +30,13 @@ "experiment_seed": "configs/manuscript.yml seed", "experiment_timesteps": "configs/manuscript.yml simulation.timesteps", "gate_entry_point": "scripts/release_check.py", - "gnn_commit": "specs/gnn-pin.json commit", + "gnn_commit": "gnn.importers.importer_variables commit", "gnn_job_key": ".github/workflows/ci.yml GNN job key", "gnn_job_name": ".github/workflows/ci.yml GNN job name", - "gnn_pin_path": "specs/gnn-pin.json", - "gnn_pin_schema": "specs/gnn-pin.json schema", - "gnn_repository": "specs/gnn-pin.json repository", - "gnn_tag": "specs/gnn-pin.json tag", + "gnn_pin_path": "gnn.importers.importer_variables pin_path", + "gnn_pin_schema": "gnn.importers.importer_variables pin_schema", + "gnn_repository": "gnn.importers.importer_variables repository", + "gnn_tag": "gnn.importers.importer_variables tag", "package_version": "pyproject.toml [project].version", "python_requires": "pyproject.toml [project].requires-python" } diff --git a/docs/development.md b/docs/development.md index 494964b..379b2b9 100644 --- a/docs/development.md +++ b/docs/development.md @@ -11,8 +11,8 @@ uv run python scripts/release_check.py --arm all --gnn-runtime /path/to/gnn-runt [`gate.md`](gate.md) lists every arm and CI job; `--list` prints the exact commands. The fast default runs lint, types, the fast test selection, and docs. The release gate adds the full suite with the 90% coverage floor, manuscript -validation/build/drift checks, the GNN drift and conformance checks, pipeline -smoke runs, and the wheel import check. +validation/build/drift checks, the GNN pin/pointer reader, drift and conformance +checks, pipeline smoke runs, and the wheel import check. mypy targets the `requires-python` floor (`python_version = "3.11"` in `pyproject.toml`), so one run covers the minimum supported stubs. Notebook @@ -21,7 +21,8 @@ the `slow` marker and are excluded from `--arm test`. The recorded before/after arm times, including the render arm, are in [`_generated/gate-metrics.md`](_generated/gate-metrics.md). -The `gnn` arm always runs pinned parser conformance +The `gnn` arm always runs the shared `python -m gnn.importers check --repo .` +pin and pointer reader plus pinned parser conformance (`scripts/validate_gnn_spec.py`); it fails without the external runtime rather than skipping validation. Replace the runtime path above with an installed pinned interpreter, or configure the source-checkout route in [`gnn.md`](gnn.md). diff --git a/docs/gate.md b/docs/gate.md index e0996a5..bf04992 100644 --- a/docs/gate.md +++ b/docs/gate.md @@ -33,8 +33,8 @@ measurements. | `test` | `uv run pytest -m "not slow"` | no | | `test-full` | `uv run pytest --cov=blockference --cov-report=term --cov-report=xml --cov-fail-under=90` | yes | | `docs` | `scripts/check_docs_links.py`, `scripts/gate_metrics.py --check` | yes | -| `manuscript` | `scripts/manuscript_variables.py --check`, `scripts/validate_manuscript.py`, `scripts/build_manuscript.py`, `scripts/build_manuscript.py --check` | yes | -| `gnn` | `scripts/export_gnn_spec.py --check` and real pinned `scripts/validate_gnn_spec.py` validation; missing runtime fails | yes | +| `manuscript` | `scripts/manuscript_variables.py --check`, `scripts/validate_manuscript.py`, `scripts/build_manuscript.py`, `scripts/build_manuscript.py --check`; the `gnn_*` variables come from `gnn.importers` in the pinned runtime | yes | +| `gnn` | `scripts/export_gnn_spec.py --check`, the shared `python -m gnn.importers check --repo .` pin and pointer check, and real pinned `scripts/validate_gnn_spec.py` validation; missing runtime fails | yes | | `smoke` | pipeline, validation, and standalone `run` JSON smoke checks in a temporary directory | yes | | `package` | `uv build`, locked `uv export` constraints for clean-wheel dependencies, and isolated import outside the source tree | yes | | `render` | `scripts/build_manuscript.py --render pdf` (Pandoc + XeLaTeX) | no | @@ -49,8 +49,8 @@ the fast arm. They stay in `test-full`. The canonical pin is [`../specs/gnn-pin.json`](../specs/gnn-pin.json) with schema `gnn-importer-pin/v1`. It pins -`ActiveInferenceInstitute/Generalized_Notation_Notation` at `v5.0.3` -(`8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`) and records SHA-256 digests for the +`ActiveInferenceInstitute/Generalized_Notation_Notation` at `v5.1.0` +(`75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`) and records SHA-256 digests for the five parser files under `src/gnn/`. The pointer [`../.github/GNN.md`](../.github/GNN.md) records exactly what the conformance job parses. @@ -58,11 +58,18 @@ job parses. The conformance job's key is `gnn-conformance` and its display name is `gnn conformance (pinned)`. -The `gnn` arm always runs both the offline drift check and real pinned-parser -conformance. Select an installed pinned runtime with `--gnn-runtime` or +The pin, the pointer and the specification are read by the estate's shared +reader, `gnn.importers`, so this repository carries no copy of the pin shape. The +`gnn` arm runs `python -m gnn.importers check --repo . --require-pointer +--workflow .github/workflows/ci.yml --job gnn-conformance` from the pinned +runtime, then the offline drift check, then real pinned-parser conformance. + +Select an installed pinned runtime with `--gnn-runtime` or `GNN_RUNTIME_PYTHON`, or supply a pinned source checkout via `GNN_ROOT` as -described in [`gnn.md`](gnn.md). Missing or invalid runtime dependencies fail the -arm and therefore `all`; conformance is never silently skipped. +described in [`gnn.md`](gnn.md); with `GNN_ROOT` and no runtime named, the +checkout's own `.venv/bin/python` is used. Missing or invalid runtime +dependencies fail the arm and therefore `all`; conformance is never silently +skipped. ## GitHub Actions diff --git a/docs/gnn.md b/docs/gnn.md index d0c817a..4f20754 100644 --- a/docs/gnn.md +++ b/docs/gnn.md @@ -13,8 +13,8 @@ Python code and are checked against it. `B[next_state, previous_state, action]`, one-hot preference `C`, one-hot prior `D`, and the uniform policy prior `E` over the five affordances. * `specs/gnn-pin.json` — the pin record (schema `gnn-importer-pin/v1`): - upstream repository, tag `v5.0.3`, commit - `8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`, recorded date, and SHA-256 + upstream repository, tag `v5.1.0`, commit + `75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`, recorded date, and SHA-256 digests of the parser files that validate the document. The document is generated from the implementation by @@ -22,9 +22,38 @@ The document is generated from the implementation by `ActiveGridference`, so the document cannot describe a model the package does not build. +## The pin is read by `gnn.importers`, not here + +The pin record is read and validated by the estate's shared reader, +`gnn.importers` in the pinned upstream revision. This repository keeps no copy +of that logic: + +* the artifact uses `read_pin`, `find_pin`, `check_pointer` and + `importer_variables` from that module; +* the release gate's `gnn` arm calls `python -m gnn.importers check --repo .` + from the pinned runtime; +* `scripts/gnn_importer_report.py` is the only bridge: it runs in an + interpreter where `gnn` is importable and prints the normalized pin and the + `gnn-importer-variables/v1` map as JSON for + `scripts/validate_gnn_spec.py` and `scripts/manuscript_variables.py`. + +The cutover replaced the interim local reader. Until this change `specs/gnn-pin.json` +pinned `v5.0.3` at `8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`, a revision that +predates `gnn.importers`, so `blockference.gnn.load_pin` rejected records outside +`gnn-importer-pin/v1`, required tag `v5.0.3`, and required a full 40-hex commit. +The pin now names `v5.1.0` at +`75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`, the first release that ships +`src/gnn/importers.py`, and `load_pin` is deleted rather than reimplemented. +`python -m gnn.importers` cannot run against the old revision, which is why the +adoption follows the pin and not the contract date. + ## Commands ```bash +# The shared reader, from the pinned runtime (release gate, `gnn` arm) +"$GNN_RUNTIME_PYTHON" -m gnn.importers check --repo . --require-pointer \ + --workflow .github/workflows/ci.yml --job gnn-conformance + # Regenerate the document, or verify it is current (release gate) uv run python scripts/export_gnn_spec.py uv run python scripts/export_gnn_spec.py --check @@ -45,23 +74,27 @@ development is never imported. `GNN_PYTHON` (or `--gnn-runtime`) selects the interpreter that has the parser dependencies; the GNN checkout's own `.venv` works. Exit codes are `0` pass, `1` conformance failure, and `2` pinned runtime or checkout unavailable — an unavailable run is reported as not run, never as a -pass. +pass. With `GNN_ROOT` set and no runtime named, the gate uses the checkout's own +`.venv/bin/python` for both the reader and the pin. CI's `gnn-conformance` job (display name `gnn conformance (pinned)`) runs the full `all` selection on Python 3.12, provisioning a separate pinned runtime because GNN requires NumPy 2.x while the library's committed lock resolves -NumPy 1.x. Locally, the `gnn` arm always runs both specification drift and real -parser conformance, using `--gnn-runtime`, `GNN_RUNTIME_PYTHON`, or `GNN_ROOT`. -An unavailable runtime fails the arm and `all`; no opt-in requirement flag or -skip mode is needed. See [`gate.md`](gate.md) for the canonical gate commands +NumPy 1.x. That runtime is also what the `manuscript` arm uses for the `gnn_*` +documented variables, whose values come from `gnn.importers.importer_variables`. +An unavailable runtime fails the `gnn` arm and `all`; no opt-in requirement flag +or skip mode is needed. See [`gate.md`](gate.md) for the canonical gate commands and exact CI map. ## What the validation checks -1. The pin: the resolved commit equals `specs/gnn-pin.json` and every recorded - parser file digest matches. +1. The pin and the pointer: `gnn.importers` reports the pin file, its schema, + `repository`, `tag` and 40-hex `commit`, and requires + [`.github/GNN.md`](../.github/GNN.md) to name the pin file, the pinned + revision, `.github/workflows/ci.yml`, and job `gnn-conformance`. 2. The document parses with the pinned `gnn` parser with no errors or warnings, - and the parser version equals the pinned tag. + and the parser version equals the pinned tag; every recorded parser digest + matches the installed (or archived) parser files. 3. The declared `ModelParameters` are read back and used to build the runtime model, whose `A`/`B`/`C`/`D`/`E` arrays must equal the declared matrices exactly; declared `StateSpaceBlock` dimensions must match the array shapes. @@ -83,13 +116,9 @@ The receipt is written to `docs/_build/gnn/validation-receipt.json` * `render_spec(parameters)` — the document text. * `parameters_from_parsed(payload)` / `declared_arrays(payload)` — read a pinned parser payload back into parameters and matrices. -* `load_pin()` — the recorded upstream pin, requiring schema - `gnn-importer-pin/v1`, tag `v5.0.3`, and a full 40-hex commit. Invalid records - raise `ValueError` naming the field. This interim local reader remains in use - because the estate pin predates `gnn.importers`; shared-reader adoption requires - a pin containing that upstream API, not a vendored copy. - CI provisioning uses this same reader in the locked package environment, - rather than independently loading unvalidated JSON. + +Reading the pin is not part of this package: `gnn.importers` owns that, and the +gate calls it from the pinned runtime. ## Scope @@ -106,4 +135,7 @@ framework runtime. owns the notation, parser, and renderers, and its [framework integration guide](https://github.com/ActiveInferenceInstitute/Generalized_Notation_Notation/blob/main/docs/gnn/integration/framework_integration_guide.md) documents the render/execute pipeline; the optional `BlockferenceAgent` adapter -connects this package to the `pymdp` ecosystem that GNN also targets. +connects this package to the `pymdp` ecosystem that GNN also targets. The +GNN–FEP workflow-group contract that binds the twenty-two importing repositories +to this one reader is +[`docs/workflows/gnn-fep.md`](https://github.com/ActiveInferenceInstitute/Generalized_Notation_Notation/blob/main/docs/workflows/gnn-fep.md). diff --git a/docs/manuscript/09_reproducibility.md b/docs/manuscript/09_reproducibility.md index bcf7d12..875b764 100644 --- a/docs/manuscript/09_reproducibility.md +++ b/docs/manuscript/09_reproducibility.md @@ -21,7 +21,10 @@ The generative-model declaration is checked against the pinned upstream parser: commit `{{gnn_commit}}`. The conformance job key is `{{gnn_job_key}}` with display name `{{gnn_job_name}}`; the pointer [`../../.github/GNN.md`](../../.github/GNN.md) records exactly what that job -parses. +parses. The pin and the pointer are validated by the estate's shared reader, +`python -m gnn.importers check --repo .`, which the `gnn` arm runs from the +pinned runtime; those same `gnn.importers` facts are what the variables above +declare, so prose and conformance cannot disagree about the pinned revision. The canonical command emits a run tree whose completed `manifest.json` and independently written `validation_report.json` agree. `PipelineResult.ok` and diff --git a/scripts/README.md b/scripts/README.md index ad543eb..a2306ce 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -6,7 +6,7 @@ Repository gates and generators, all run from the repository root: |---|---| | `release_check.py` | The canonical gate: composable arms for lint, types, fast/full tests, docs, manuscript, GNN, smoke, package, and render. | | `gate_metrics.py` | Imports disjoint baseline receipts with repeatable `--record-baseline PATH` and one current receipt with `--record-timings PATH`, writes `docs/_generated/gate-metrics.md`, and checks drift with `--check`. | -| `manuscript_variables.py` | Derives `docs/_generated/manuscript-variables.json` from `pyproject.toml`, the GNN pin, and CI; `--check` gates drift. | +| `manuscript_variables.py` | Derives `docs/_generated/manuscript-variables.json` from `pyproject.toml`, CI, and the `gnn_*` keys that `gnn.importers.importer_variables` produces in the pinned runtime; `--check` gates drift. | | `check_docs_links.py` | Validates internal Markdown links and anchors across tracked documentation. | | `build_manuscript.py` | Builds the manuscript and its figures, injects declared variables, and renders with Pandoc (`--render pdf\|html`). | | `validate_manuscript.py` | Fail-closed manuscript validation, including declared variables. | @@ -14,11 +14,13 @@ Repository gates and generators, all run from the repository root: | `validate_notebooks.py` | Notebook hygiene checks before execution. | | `export_gnn_spec.py` | Writes or verifies `specs/gridworld_3x3.gnn.md` from the implementation. | | `validate_gnn_spec.py` | Validates the committed specification with the pinned parser, using a separate interpreter selected by `--gnn-runtime` or the documented environment variables. | -| `gnn_parser_probe.py` | The only module that imports the upstream `gnn` package; runs as a subprocess under the pin. | +| `gnn_parser_probe.py` | Imports the upstream `gnn` parser; runs as a subprocess under the pin. | +| `gnn_importer_report.py` | Imports the upstream `gnn.importers` reader and prints this repository's normalized pin and `gnn-importer-variables/v1` map for the two scripts above. | Run the release selection with a pinned GNN runtime configured before publishing; the no-argument default is the fast selection. The `gnn` arm always -runs real pinned conformance and fails if its runtime is unavailable. +runs the shared `python -m gnn.importers check --repo .` and real pinned +conformance, and fails if its runtime is unavailable. [`../docs/gate.md`](../docs/gate.md) owns the arm commands, CI mapping, `--timings PATH` recording and metrics-import workflow. diff --git a/scripts/gnn_importer_report.py b/scripts/gnn_importer_report.py new file mode 100644 index 0000000..dc93182 --- /dev/null +++ b/scripts/gnn_importer_report.py @@ -0,0 +1,70 @@ +"""Print the upstream ``gnn.importers`` reading of this repository's GNN pin. + +``gnn.importers`` is the estate's single reader for a GNN pin (discovery, shape +normalization, pointer checks and the ``gnn-importer-variables/v1`` map). This +module is the bridge that calls it from a Python process: it runs in an +interpreter where ``gnn`` is importable, and prints the normalized pin plus the +GNN-derived manuscript variables as JSON. Neither this repository nor its +scripts re-implement the pin shape. + +Run it with the pinned runtime (``GNN_RUNTIME_PYTHON``), or with a pinned source +checkout first on ``PYTHONPATH``. ``scripts/validate_gnn_spec.py`` and +``scripts/manuscript_variables.py`` invoke it; the release gate's ``gnn`` arm +calls ``python -m gnn.importers check`` directly and does not need this bridge. + +Usage (normally invoked by those scripts, not by hand): + + GNN_RUNTIME_PYTHON/bin/python scripts/gnn_importer_report.py --repo . +""" + +from __future__ import annotations + +import argparse +import json +import sys +from pathlib import Path +from typing import Any + +from gnn.importers import find_pin, importer_variables, read_pin + + +def report( + repo_root: Path, *, job: str | None = None, job_name: str | None = None +) -> dict[str, Any]: + """Return the shared reader's pin record and manuscript variables.""" + + pin_path = find_pin(repo_root) + if pin_path is None: + raise SystemExit(f"no GNN pin file found under {repo_root}") + pin = read_pin(pin_path) + parser_files = pin.raw.get("parser_files") + return { + "pin": { + "path": pin.path.relative_to(repo_root).as_posix(), + "schema": pin.schema, + "repository": pin.repository, + "tag": pin.tag, + "commit": pin.commit, + "recorded": pin.recorded, + "spec_files": list(pin.spec_files), + "parser_files": parser_files if isinstance(parser_files, dict) else {}, + }, + "variables": importer_variables(pin, repo_root=repo_root, job=job, job_name=job_name), + } + + +def main(argv: list[str] | None = None) -> int: + """Print the report for one repository checkout.""" + + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--repo", type=Path, default=Path(".")) + parser.add_argument("--job", help="conformance job key the pointer and variables name") + parser.add_argument("--job-name", help="display name of that job") + args = parser.parse_args(argv) + payload = report(args.repo.resolve(), job=args.job, job_name=args.job_name) + sys.stdout.write(json.dumps(payload, indent=2, sort_keys=True) + "\n") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/manuscript_variables.py b/scripts/manuscript_variables.py index 1c7831a..087e2f6 100644 --- a/scripts/manuscript_variables.py +++ b/scripts/manuscript_variables.py @@ -3,13 +3,18 @@ Manuscript prose uses ``{{token}}`` placeholders; the declared values come from this generated file rather than from hand-copied literals. The values are read from ``pyproject.toml`` (Python floor and package version), the executable -manuscript configuration, the canonical GNN pin, and the CI workflow. +manuscript configuration, the CI workflow, and the upstream ``gnn.importers`` +reader for the ``gnn_*`` keys. The reader needs the pinned GNN runtime +(``GNN_RUNTIME_PYTHON``) because its distribution resolves NumPy 2.x while this +package resolves NumPy 1.x. """ from __future__ import annotations import argparse import json +import os +import subprocess import sys import tomllib from pathlib import Path @@ -18,8 +23,8 @@ ROOT = Path(__file__).resolve().parents[1] VARIABLES_PATH = ROOT / "docs" / "_generated" / "manuscript-variables.json" -PIN_PATH = ROOT / "specs" / "gnn-pin.json" WORKFLOW_PATH = ROOT / ".github" / "workflows" / "ci.yml" +REPORT = ROOT / "scripts" / "gnn_importer_report.py" SCHEMA = "manuscript-variables/v1" MANUSCRIPT_CONFIG_PATH = ROOT / "docs" / "manuscript" / "config.yaml" @@ -44,12 +49,50 @@ def _gnn_job() -> tuple[str, str]: raise ValueError("no GNN conformance job in .github/workflows/ci.yml") +def _gnn_interpreter() -> str: + """Return the interpreter that has the pinned GNN distribution installed.""" + + runtime = os.environ.get("GNN_RUNTIME_PYTHON") + if runtime and Path(runtime).is_file(): + return runtime + return sys.executable + + +def _gnn_variables(job_key: str, job_name: str) -> dict[str, str]: + """Return the ``gnn_*`` keys from ``gnn.importers.importer_variables``.""" + + completed = subprocess.run( + [ + _gnn_interpreter(), + str(REPORT), + "--repo", str(ROOT), + "--job", job_key, + "--job-name", job_name, + ], + cwd=ROOT, + stdin=subprocess.DEVNULL, + capture_output=True, + text=True, + check=False, + ) + if completed.returncode != 0: + detail = (completed.stderr or completed.stdout).strip().splitlines() + raise ValueError( + "the shared gnn.importers reader could not produce the gnn_* variables: " + + (" | ".join(detail[-3:]) if detail else "no output") + + "; set GNN_RUNTIME_PYTHON to the pinned GNN runtime" + ) + variables = dict(json.loads(completed.stdout)["variables"]) + variables.pop("schema", None) # gnn-importer-variables/v1 names the map, not this file + return variables + + def build() -> dict[str, object]: """Return the declared manuscript variables and their sources.""" project = _project() - pin = json.loads(PIN_PATH.read_text(encoding="utf-8")) job_key, job_name = _gnn_job() + gnn = _gnn_variables(job_key, job_name) metadata = yaml.safe_load(MANUSCRIPT_CONFIG_PATH.read_text(encoding="utf-8")) config_path = metadata["experiment"]["config_path"] config = yaml.safe_load((ROOT / config_path).read_text(encoding="utf-8")) @@ -80,23 +123,17 @@ def build() -> dict[str, object]: "python_requires": _python_requires(str(project["requires-python"])), "package_version": str(project["version"]), "gate_entry_point": "scripts/release_check.py", - "gnn_pin_path": "specs/gnn-pin.json", - "gnn_pin_schema": str(pin["schema"]), - "gnn_repository": str(pin["repository"]), - "gnn_tag": str(pin["tag"]), - "gnn_commit": str(pin["commit"]), - "gnn_job_key": job_key, - "gnn_job_name": job_name, + **gnn, **experiment_values, "sources": { "python_requires": "pyproject.toml [project].requires-python", "package_version": "pyproject.toml [project].version", "gate_entry_point": "scripts/release_check.py", - "gnn_pin_path": "specs/gnn-pin.json", - "gnn_pin_schema": "specs/gnn-pin.json schema", - "gnn_repository": "specs/gnn-pin.json repository", - "gnn_tag": "specs/gnn-pin.json tag", - "gnn_commit": "specs/gnn-pin.json commit", + "gnn_pin_path": "gnn.importers.importer_variables pin_path", + "gnn_pin_schema": "gnn.importers.importer_variables pin_schema", + "gnn_repository": "gnn.importers.importer_variables repository", + "gnn_tag": "gnn.importers.importer_variables tag", + "gnn_commit": "gnn.importers.importer_variables commit", "gnn_job_key": ".github/workflows/ci.yml GNN job key", "gnn_job_name": ".github/workflows/ci.yml GNN job name", **experiment_sources, diff --git a/scripts/release_check.py b/scripts/release_check.py index 689fd64..11f5e88 100644 --- a/scripts/release_check.py +++ b/scripts/release_check.py @@ -13,7 +13,8 @@ * ``test-full`` -- the whole suite with the 90% coverage floor. * ``docs`` -- Markdown links/anchors and the generated gate metrics. * ``manuscript`` -- variables freshness, source validation, build, and drift. -* ``gnn`` -- specification drift and pinned-parser conformance. +* ``gnn`` -- the shared ``gnn.importers`` pin check, specification drift, and + pinned-parser conformance. * ``smoke`` -- pipeline, validation, and standalone ``run`` JSON smoke checks. * ``package`` -- wheel build and clean virtualenv import. * ``render`` -- render the manuscript to PDF (needs Pandoc and XeLaTeX). @@ -72,7 +73,7 @@ "test-full": "full pytest suite with the 90% coverage floor", "docs": "Markdown links/anchors and generated gate metrics", "manuscript": "manuscript variables, validation, build, and drift check", - "gnn": "GNN specification drift and pinned-parser conformance", + "gnn": "GNN pin/pointer check, specification drift, and pinned-parser conformance", "smoke": "pipeline, validation, and run JSON smoke checks", "package": "wheel build and clean virtualenv import", "render": "manuscript PDF render (Pandoc + XeLaTeX)", @@ -121,6 +122,24 @@ def _changed_paths() -> set[str]: } +def _checkout_runtime() -> str | None: + """Return the interpreter of the GNN checkout named by ``GNN_ROOT``, if any. + + A source checkout is an alternative to an installed pinned runtime. The + reader has to run in the same environment as the pinned parser, so the + checkout's own virtual environment supplies it. + """ + + root = os.environ.get("GNN_ROOT") + if not root: + return None + relative = Path("Scripts" if os.name == "nt" else "bin") / ( + "python.exe" if os.name == "nt" else "python" + ) + candidate = Path(root) / ".venv" / relative + return str(candidate) if candidate.is_file() else None + + def _assert_json(command: list[str]) -> None: """Run one command whose last output line must be a passing JSON verdict.""" @@ -173,6 +192,15 @@ def _plan( ] if arm == "gnn": commands = [["uv", "run", "python", "scripts/export_gnn_spec.py", "--check"]] + if gnn_runtime: + commands.append( + [ + gnn_runtime, "-m", "gnn.importers", "check", "--repo", ".", + "--require-pointer", + "--workflow", ".github/workflows/ci.yml", + "--job", "gnn-conformance", + ] + ) validator = ["uv", "run", "python", "scripts/validate_gnn_spec.py", "--json"] if gnn_runtime: validator[-1:-1] = ["--gnn-runtime", gnn_runtime] @@ -321,11 +349,17 @@ def main(argv: list[str] | None = None) -> int: parser.add_argument("--list", action="store_true", help="list arms and their commands") parser.add_argument("--timings", type=Path, help="write a JSON runtime receipt") parser.add_argument("--json", action="store_true", help="print a JSON summary") - parser.add_argument("--gnn-runtime", help="interpreter with the pinned GNN distribution") + parser.add_argument( + "--gnn-runtime", + help="interpreter with the pinned GNN distribution (default: $GNN_RUNTIME_PYTHON, " + "else the GNN checkout's own .venv under $GNN_ROOT)", + ) args = parser.parse_args(argv) selected = _selected(args.arm or []) - gnn_runtime = args.gnn_runtime or os.environ.get("GNN_RUNTIME_PYTHON") + gnn_runtime = ( + args.gnn_runtime or os.environ.get("GNN_RUNTIME_PYTHON") or _checkout_runtime() + ) if args.list: for arm in (*ALIASES, *ARM_ORDER): print(f"{arm:10s} {ARM_HELP[arm]}") diff --git a/scripts/validate_gnn_spec.py b/scripts/validate_gnn_spec.py index 55ef3b3..2a78744 100644 --- a/scripts/validate_gnn_spec.py +++ b/scripts/validate_gnn_spec.py @@ -1,7 +1,9 @@ """Validate the committed GNN specification with the pinned upstream parser. The canonical GNN pin is recorded in ``specs/gnn-pin.json`` (repository, tag, -commit, and SHA-256 digests of the parser files). This script supports two +commit, and SHA-256 digests of the parser files). The pin is read by the +upstream ``gnn.importers`` reader through ``scripts/gnn_importer_report.py``, so +this repository carries no copy of the pin shape. This script supports two verified sources for that pin: * a GNN git checkout (``--gnn-root`` or ``GNN_ROOT``): the pinned commit is @@ -47,10 +49,8 @@ import numpy as np from blockference.gnn import ( - GNN_PIN_PATH, GNN_SPEC_PATH, declared_arrays, - load_pin, parameters_from_parsed, render_spec, spec_arrays, @@ -59,6 +59,7 @@ ROOT = Path(__file__).resolve().parents[1] PROBE = ROOT / "scripts" / "gnn_parser_probe.py" +REPORT = ROOT / "scripts" / "gnn_importer_report.py" DEFAULT_RECEIPT = ROOT / "docs" / "_build" / "gnn" / "validation-receipt.json" PACKAGE_PREFIX = "src/gnn/" @@ -75,11 +76,45 @@ def _sha256(path: Path) -> str: return digest.hexdigest() -def _verify_digests(package_dir: Path, pin: dict[str, Any], *, origin: str) -> dict[str, str]: +def read_importer_report(python: str, *, source: Path | None = None) -> dict[str, Any]: + """Return the shared ``gnn.importers`` reading of this repository's pin. + + ``source`` puts a GNN source tree first on ``PYTHONPATH``, which is how a + checkout supplies the reader when no installed distribution is present. + """ + + environment = dict(os.environ) + if source is not None: + existing = environment.get("PYTHONPATH", "") + environment["PYTHONPATH"] = str(source) + ( + os.pathsep + existing if existing else "" + ) + completed = subprocess.run( + [python, str(REPORT), "--repo", str(ROOT)], + capture_output=True, + text=True, + check=False, + env=environment, + ) + if completed.returncode != 0: + detail = (completed.stderr or completed.stdout).strip().splitlines() + tail = " | ".join(detail[-3:]) if detail else "no output" + raise Unavailable( + f"the shared gnn.importers reader could not be run with {python}: {tail}. " + "Supply --gnn-runtime/GNN_RUNTIME_PYTHON, or --python naming an interpreter " + "with the pinned GNN distribution, or a GNN checkout via GNN_ROOT." + ) + payload = json.loads(completed.stdout) + if not isinstance(payload, dict) or not isinstance(payload.get("pin"), dict): + raise Unavailable(f"the shared gnn.importers reader returned no pin: {payload!r}") + return payload + + +def _verify_digests(package_dir: Path, digests: dict[str, str], *, origin: str) -> dict[str, str]: """Verify every recorded parser digest under an installed ``gnn`` package.""" observed: dict[str, str] = {} - for relative, expected in sorted(pin["parser_files"].items()): + for relative, expected in sorted(digests.items()): suffix = relative[len(PACKAGE_PREFIX) :] if relative.startswith(PACKAGE_PREFIX) else relative path = package_dir / suffix if not path.is_file(): @@ -93,13 +128,16 @@ def _verify_digests(package_dir: Path, pin: dict[str, Any], *, origin: str) -> d return observed -def materialize_pin(gnn_root: Path, pin: dict[str, Any]) -> tuple[Path, str]: - """Return a directory holding the pinned source tree and how it was obtained.""" +def materialize_pin(gnn_root: Path, pin: dict[str, Any], target: Path) -> tuple[Path, str]: + """Materialize the pinned commit into ``target`` and return it with its origin. + + ``target`` belongs to the caller, so a run leaves no materialized tree behind. + """ if not gnn_root.is_dir(): raise Unavailable(f"GNN checkout is not a directory: {gnn_root}") if not (gnn_root / ".git").exists(): - _verify_digests(gnn_root / "src" / "gnn", pin, origin=str(gnn_root)) + _verify_digests(gnn_root / "src" / "gnn", pin["parser_files"], origin=str(gnn_root)) return gnn_root, f"digest-verified source tree {gnn_root} (no git metadata)" commit = pin["commit"] @@ -116,7 +154,7 @@ def materialize_pin(gnn_root: Path, pin: dict[str, Any]) -> tuple[Path, str]: f"resolved commit {resolved.stdout.strip()} differs from the pin {commit}" ) - target = Path(tempfile.mkdtemp(prefix="activeblockference-gnn-pin-")) + target.mkdir(parents=True, exist_ok=True) archive = target / "pinned.tar" completed = subprocess.run( ["git", "-C", str(gnn_root), "archive", "--format=tar", f"--output={archive}", commit], @@ -132,7 +170,7 @@ def materialize_pin(gnn_root: Path, pin: dict[str, Any]) -> tuple[Path, str]: except TypeError: # pragma: no cover - Python < 3.12 fallback handle.extractall(target) archive.unlink() - _verify_digests(target / "src" / "gnn", pin, origin=f"archive of {commit}") + _verify_digests(target / "src" / "gnn", pin["parser_files"], origin=f"archive of {commit}") return target, f"git archive of {commit}" @@ -287,12 +325,10 @@ def main(argv: list[str] | None = None) -> int: help="parser interpreter used with --gnn-root (default: $GNN_PYTHON or this interpreter)", ) parser.add_argument("--spec", type=Path, default=GNN_SPEC_PATH) - parser.add_argument("--pin", type=Path, default=GNN_PIN_PATH) parser.add_argument("--receipt", type=Path, default=DEFAULT_RECEIPT) parser.add_argument("--json", action="store_true", help="print the receipt to stdout") args = parser.parse_args(argv) - pin = load_pin(args.pin) if args.gnn_root is None and not args.gnn_runtime: print( "gnn validation not run: supply --gnn-root/GNN_ROOT or --gnn-runtime/" @@ -301,11 +337,23 @@ def main(argv: list[str] | None = None) -> int: ) return 2 + reader_python = args.gnn_runtime or args.python or sys.executable + try: + pin = read_importer_report( + reader_python, + source=args.gnn_root / "src" if args.gnn_root is not None else None, + )["pin"] + except Unavailable as exc: + print(f"gnn validation not run: {exc}", file=sys.stderr) + return 2 + with tempfile.TemporaryDirectory(prefix="activeblockference-gnn-") as directory: output = Path(directory) / "probe.json" try: if args.gnn_root is not None: - source, origin = materialize_pin(args.gnn_root, pin) + source, origin = materialize_pin( + args.gnn_root, pin, Path(directory) / "gnn-pin" + ) payload = run_probe( args.python or sys.executable, args.spec, output, source=source ) @@ -313,7 +361,7 @@ def main(argv: list[str] | None = None) -> int: source = None payload = run_probe(args.gnn_runtime, args.spec, output, source=None) package_dir = Path(str(payload["gnn_module"])).resolve().parent - _verify_digests(package_dir, pin, origin=args.gnn_runtime) + _verify_digests(package_dir, pin["parser_files"], origin=args.gnn_runtime) origin = f"installed runtime {args.gnn_runtime} ({package_dir})" except Unavailable as exc: print(f"gnn validation not run: {exc}", file=sys.stderr) diff --git a/specs/README.md b/specs/README.md index 9d9899a..d2fc8a0 100644 --- a/specs/README.md +++ b/specs/README.md @@ -2,10 +2,12 @@ - [`gridworld_3x3.gnn.md`](gridworld_3x3.gnn.md) — the GNN declaration of the 3x3 grid-world model, generated from the implementation. -- [`gnn-pin.json`](gnn-pin.json) — the upstream repository, tag `v5.0.3`, commit - `8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1`, and the SHA-256 of each parser - file, under schema `gnn-importer-pin/v1`. +- [`gnn-pin.json`](gnn-pin.json) — the upstream repository, tag `v5.1.0`, commit + `75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf`, and the SHA-256 of each parser + file, under schema `gnn-importer-pin/v1`. The pin is read by the upstream + `gnn.importers` reader, not by a local copy. Verify: `uv run python scripts/export_gnn_spec.py --check`, then -`uv run python scripts/validate_gnn_spec.py`. The spec renderer is -[`../blockference/gnn.py`](../blockference/gnn.py). +`python -m gnn.importers check --repo .` and +`uv run python scripts/validate_gnn_spec.py` in the pinned runtime. The spec +renderer is [`../blockference/gnn.py`](../blockference/gnn.py). diff --git a/specs/gnn-pin.json b/specs/gnn-pin.json index 6f8b86b..0bad7d1 100644 --- a/specs/gnn-pin.json +++ b/specs/gnn-pin.json @@ -1,14 +1,14 @@ { "schema": "gnn-importer-pin/v1", "repository": "https://github.com/ActiveInferenceInstitute/Generalized_Notation_Notation", - "tag": "v5.0.3", - "commit": "8f293d9ba810e6eda5c09842d9c7ed9ffa5f92c1", + "tag": "v5.1.0", + "commit": "75c834bd8519dc7b5adc4d24f16bf393cfd1ecdf", "recorded": "2026-11-12", "parser_files": { - "src/gnn/__init__.py": "4303d2cec14db42ad1a3f9ca557aaf48f42efc6b1566bcf099d2bf878c2b26ff", - "src/gnn/parsers/__init__.py": "257f10d65b54ed2cc421fe25257d6ae506dc3dbde8685b7a5672aba06f0c4991", - "src/gnn/parsers/common.py": "c27da82a05058ec2f96b4c675374a848e64535122bf3a63155a47b8b23e3076e", - "src/gnn/parsers/markdown_parser.py": "24a30ea7e67d597e891fe16e521e13be5f2013af90eeb282cfe257940b281e82", + "src/gnn/__init__.py": "908848847f2fb938f65b3ea0b17252ab6d2129ad2f0b427bca8761a81083d10d", + "src/gnn/parsers/__init__.py": "a08df88ecf239a094254f7dc4ef0ea57aff697075f777a3993702ca8d45803ea", + "src/gnn/parsers/common.py": "ade640beffbf18e6f99dc7b9e3ac5993e5a183652da096ceeb0014b77f3f5527", + "src/gnn/parsers/markdown_parser.py": "150f2994dc7e95bea30e7b226d86220eb319fcff64489503df20a307cf7b097c", "src/gnn/parsers/markdown_parser_parameter.py": "2e94e88c79b8998387f2a1c53fe88dcc45adc498c47c30f7ec3bd577a8072061" } } diff --git a/tests/test_gnn_spec.py b/tests/test_gnn_spec.py index d800e77..89cf4cc 100644 --- a/tests/test_gnn_spec.py +++ b/tests/test_gnn_spec.py @@ -16,7 +16,6 @@ GNN_SPEC_PATH, build_spec_model, declared_arrays, - load_pin, parameters_from_parsed, render_spec, spec_arrays, @@ -69,44 +68,6 @@ def _parsed_payload() -> dict: } -def test_local_pin_reader_accepts_the_committed_contract(): - pin = load_pin() - assert pin["schema"] == "gnn-importer-pin/v1" - assert pin["tag"] == "v5.0.3" - assert len(pin["commit"]) == 40 - - -@pytest.mark.parametrize( - ("field", "value", "message"), - [ - ("schema", None, "schema"), - ("schema", "unknown/v1", "schema"), - ("tag", None, "tag"), - ("tag", "v5.0.4", "tag"), - ("commit", None, "commit"), - ("commit", "8f293d9b", "commit"), - ("commit", "z" * 40, "commit"), - ], -) -def test_local_pin_reader_rejects_invalid_declared_fields(tmp_path, field, value, message): - pin = load_pin() - if value is None: - del pin[field] - else: - pin[field] = value - path = tmp_path / "pin.json" - path.write_text(json.dumps(pin), encoding="utf-8") - with pytest.raises(ValueError, match=f"invalid GNN pin {message}"): - load_pin(path) - - -def test_local_pin_reader_rejects_non_object_json(tmp_path): - path = tmp_path / "pin.json" - path.write_text("[]", encoding="utf-8") - with pytest.raises(ValueError, match="expected a JSON object"): - load_pin(path) - - def test_committed_spec_is_generated_from_the_implementation(): assert exporter.check() == [] @@ -234,6 +195,6 @@ def test_pinned_parser_validates_the_committed_spec(tmp_path): payload = json.loads(receipt.read_text(encoding="utf-8")) assert payload["ok"] is True assert payload["failures"] == [] - assert payload["gnn_version"] == "5.0.3" + assert payload["gnn_version"] == "5.1.0" assert payload["orientation"] == ["canonical"] assert payload["consistency_score"] == 1.0 diff --git a/tests/test_release_gate.py b/tests/test_release_gate.py index 974202b..a6320b3 100644 --- a/tests/test_release_gate.py +++ b/tests/test_release_gate.py @@ -16,6 +16,58 @@ ROOT = Path(__file__).resolve().parents[1] +def test_gnn_arm_runs_the_shared_pin_reader_before_conformance(): + runtime = "/opt/gnn-runtime/bin/python" + plan = gate._plan("gnn", workdir=Path(""), gnn_runtime=runtime) + + assert plan is not None + assert plan[0] == ["uv", "run", "python", "scripts/export_gnn_spec.py", "--check"] + assert plan[1] == [ + runtime, + "-m", + "gnn.importers", + "check", + "--repo", + ".", + "--require-pointer", + "--workflow", + ".github/workflows/ci.yml", + "--job", + "gnn-conformance", + ] + assert plan[2] == [ + "uv", + "run", + "python", + "scripts/validate_gnn_spec.py", + "--gnn-runtime", + runtime, + "--json", + ] + + +def test_gnn_arm_omits_the_reader_without_a_runtime(): + plan = gate._plan("gnn", workdir=Path(""), gnn_runtime=None) + + assert plan is not None + assert not any("gnn.importers" in " ".join(command) for command in plan) + + +def test_checkout_runtime_comes_from_the_gnn_checkout(tmp_path, monkeypatch): + relative = Path("Scripts" if os.name == "nt" else "bin") / ( + "python.exe" if os.name == "nt" else "python" + ) + python = tmp_path / ".venv" / relative + python.parent.mkdir(parents=True) + python.write_text("", encoding="utf-8") + + monkeypatch.setenv("GNN_ROOT", str(tmp_path)) + assert gate._checkout_runtime() == str(python) + + monkeypatch.delenv("GNN_ROOT") + assert gate._checkout_runtime() is None + + def test_gnn_arm_without_runtime_cannot_write_a_passing_receipt(tmp_path): environment = dict(os.environ, UV_OFFLINE="1", UV_NO_SYNC="1") for name in ("GNN_ROOT", "GNN_RUNTIME_PYTHON", "GNN_PYTHON"):