Skip to content

Verify pinned parser digests before the gnn arm parses, and always ask upstream for the pin tag - #31

Merged
docxology merged 1 commit into
mainfrom
fix/gnn-arm-verify-before-parse
Nov 12, 2026
Merged

docxology merged 1 commit into
mainfrom
fix/gnn-arm-verify-before-parse

Conversation

@docxology

Copy link
Copy Markdown
Collaborator

Both findings reproduce on main at 248f98a.

P1: the gnn arm parsed before it verified parser digests

The arm ran python -m gnn.importers check before scripts/validate_gnn_spec.py. gnn.importers check calls _validate_spec, which imports the installed parser and parses every spec file, so a tampered pinned parser ran before the pin digests were checked.

Reproduced with a tampered pinned file (src/gnn/parsers/markdown_parser.py, which the pin records) exposed on PYTHONPATH, running the repository gate arm:

GNN_RUNTIME_PYTHON=<gnn-venv-python> PYTHONPATH=/tmp/p1/gnnrt uv run --no-sync python scripts/release_check.py --arm gnn

Before, the tampered parser is imported, the reader prints its verdict, and only then does the digest check abort:

$ <runtime> -m gnn.importers check --repo . --require-pointer --workflow .github/workflows/ci.yml --job gnn-conformance
  specs: 1
  pointer: .github/GNN.md -> ok
  verdict: ok
$ uv run python scripts/validate_gnn_spec.py --gnn-runtime <runtime> --verify-tag-remote --json
gnn validation not run: pinned parser file digest mismatch for parsers/markdown_parser.py ...
release gate failed

A marker the tampered module writes on import exists after that run, so the parser did execute. After the reorder the digest failure is the first gnn step, gnn.importers check never runs, and the marker is absent.

P2: --verify-tag-remote did not ask upstream when a local tag existed

tag_binding returned the locally resolved tag and never ran git ls-remote when the checkout had the tag.

Reproduced offline with a local bare upstream whose tag moved to another commit after the clone:

upstream tag -> ff9fd99fc1c9fd5e37c0f9feed39dd48c89391e6
local tag    -> 732da926259711bb25355b748870b013261255a5  (the pin commit)
binding      -> verified, resolved 732da9..., detail "local object store /tmp/p2/stale/local"
failures     -> []

and at CLI level with an unreachable upstream, the run exited 0 and recorded local object store. After the fix the same invocation exits 2 (not run) when upstream cannot answer, and with upstream reachable the receipt records git ls-remote.

Change

  • scripts/release_check.py: the gnn arm runs the validator first, so the digests are verified before any arm command parses.
  • scripts/validate_gnn_spec.py: tag_binding always queries upstream when remote is requested; a local tag no longer short-circuits it, and a failed query stays unresolvable-offline (never a pass).
  • tests/test_release_gate.py: pins the arm order (digest verification before any parsing command) and keeps the exact plan assertion.
  • tests/test_gnn_pin_binding.py: stale-local-tag and unanswerable-upstream cases, using real git and no network.
  • Docs: docs/gate.md, docs/gnn.md, scripts/README.md, and the regenerated docs/_generated/gate-metrics.md.

Gate

GNN_RUNTIME_PYTHON=<pinned GNN v5.1.0 venv> uv run python scripts/release_check.py --arm all

lint, types, test-full (115 passed, coverage 90.96%), docs, manuscript, gnn, smoke, package: all passed; release gate passed.

Pre-fix, the new tests fail: test_remote_is_consulted_when_the_local_tag_resolves and test_remote_that_cannot_answer_never_accepts_the_local_tag (binding came back verified from the local store), test_gnn_arm_verifies_the_pinned_parser_digests_before_it_parses (assert 2 < 1) and test_gnn_arm_runs_the_shared_pin_reader_after_digest_verification (reported command order). All pass at a48cd78.

scripts/release_check.py's gnn arm ran python -m gnn.importers check before scripts/validate_gnn_spec.py. The shared reader parses every *.gnn.md with the installed parser (gnn.importers._validate_spec), so a tampered pinned parser was executed, and its verdict trusted, before the pin's digests were checked. The validator now runs first: it verifies the digests before it parses, and the arm aborts there when they do not match.

--verify-tag-remote accepted a locally resolved tag without asking upstream, so a tag that moved after a checkout fetched it passed. tag_binding always queries git ls-remote when the flag is given: the upstream answer decides, and an unanswerable upstream ends the run as not run rather than a pass.

Reproduced with a tampered src/gnn/parsers/markdown_parser.py (a pinned file): before the reorder gnn.importers check imported it and printed 'verdict: ok' ahead of the digest mismatch; after it the arm stops at the digest check and the parser never runs. A local bare remote whose tag moved off the pinned commit was accepted from a stale checkout; it now fails as tag-commit-mismatch.

tests/test_release_gate.py pins the order (digest verification before any parsing) and tests/test_gnn_pin_binding.py covers the stale local tag and the unanswerable upstream with real git and no network. gate-metrics.md is regenerated for the new test count (115).
@docxology
docxology merged commit 756c747 into main Nov 12, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant