Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
Refuse a release tag that does not carry the version it claims (#253)
Fabio Rovai6982f826e8a0
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex 61799a86..80afce4f 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -28,6 +28,13 @@ jobs:steps:- uses: actions/checkout@v4+ # Only on a tag push, where this workflow publishes an image. A tag that+ # does not carry its own version produces an image whose binary reports+ # the previous release, and nothing downstream can tell.+ - name: Verify the tag carries the version it claims+ if: startsWith(github.ref, 'refs/tags/v')+ run: scripts/check-release-version.sh "${{ github.ref_name }}"+- name: Free disk spacerun: |sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/powershell /usr/local/share/chromium /usr/local/share/edgediff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 05ca855d..5b4e1bdc 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -4,7 +4,20 @@ on:tags: ['v*']jobs:+ # The tag and the Cargo.toml version are set by separate commits, so a tag can+ # land before the bump. When it does the release builds and publishes cleanly+ # while the binary reports the previous version, which is a silent failure that+ # flatters the release. Checked before anything is built, so no artifact+ # carrying the wrong number is ever produced.+ verify-version:+ timeout-minutes: 5+ runs-on: ubuntu-22.04+ steps:+ - uses: actions/checkout@v4+ - run: scripts/check-release-version.sh "${{ github.ref_name }}"+build:+ needs: verify-versiontimeout-minutes: 60strategy:fail-fast: false@@ -67,6 +80,12 @@ jobs:# certificate at all, so a visitor met a front page whose central claim the# page itself could not demonstrate. These binaries are a few MB each.checkers:+ # The same gate `build` has. Without it this job builds the whole Lean+ # development on a tag that is already known to be wrong: nothing is+ # PUBLISHED, because `release` needs `build` which needs the gate, but+ # the work is done anyway and the claim that nothing is built before+ # the check was not true of this job.+ needs: verify-versiontimeout-minutes: 30runs-on: ubuntu-lateststeps:@@ -134,6 +153,33 @@ jobs:mv "${dir}open-ontologies" "${dir}open-ontologies-${target}"fidone+ # THE BINARY ITSELF, ASKED WHAT IT IS.+ #+ # `verify-version` compares the tag to Cargo.toml before anything builds,+ # which catches the cause. This catches the HARM, and they are not the+ # same check: a correct tag can still ship a stale binary if a cache+ # returns an object built from another tree, and nothing upstream of here+ # would notice. `status` is the only version the engine reports about+ # itself, so running it is the one question that cannot be answered+ # wrongly by accident.+ #+ # The Linux build runs on this runner, so this is a real execution and+ # not a second reading of the same file.+ - name: The published binary reports the version of its tag+ run: |+ set -euo pipefail+ want="${GITHUB_REF_NAME#v}"+ bin="open-ontologies-x86_64-unknown-linux-gnu/open-ontologies-x86_64-unknown-linux-gnu"+ chmod +x "$bin"+ got=$("./$bin" status | python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])')+ echo "tag $GITHUB_REF_NAME wants $want; the binary reports $got"+ if [ "$got" != "$want" ]; then+ echo "::error::the binary about to be published reports $got and the tag claims $want."+ echo "Nothing downstream can tell these apart: status is the only version the engine"+ echo "reports about itself, so an artifact recorded against this release would carry"+ echo "the wrong engine. Refusing to publish."+ exit 1+ fi- name: Generate SHASUMS.txtrun: |# Strip the artifact directory so the listed names match the assetdiff --git a/scripts/check-release-version.sh b/scripts/check-release-version.shnew file mode 100755index 00000000..7a1d649c--- /dev/null+++ b/scripts/check-release-version.sh@@ -0,0 +1,82 @@+#!/usr/bin/env bash+#+# Fail when a release tag does not carry the version it claims.+#+# The tag and the `version` field in Cargo.toml are set by separate commits, so+# a tag can land before the bump. When it does, the release builds and publishes+# cleanly while the binary reports the previous version. `status` is the only+# version the engine reports about itself, so anything recording which engine+# produced an artifact records the wrong one, and a consumer pinning a release+# and verifying by the reported version cannot tell a correct build from a+# failed pin.+#+# It is a silent failure and it flatters the release: everything is green, the+# artifacts exist, and only the number is wrong.+#+# Three tags already carry it. v1.2.1 and v1.4.0 ship the previous version, and+# so does v1.6.0, the current release, which reports 1.5.0.+#+# Usage:+# scripts/check-release-version.sh v1.6.0 # check one tag against Cargo.toml+# scripts/check-release-version.sh --all # audit every v* tag in the repo+#+# In CI the release workflow calls the single-tag form before anything is built,+# so a mismatched tag fails before an artifact carrying the wrong number exists.++set -euo pipefail++cargo_version() {+ # The [package] version, read without assuming a TOML parser is installed.+ awk '+ /^\[package\]/ { in_package = 1; next }+ /^\[/ { in_package = 0 }+ in_package && /^version[[:space:]]*=/ {+ gsub(/^version[[:space:]]*=[[:space:]]*"/, "")+ gsub(/".*$/, "")+ exit+ }+ ' "${1:-Cargo.toml}"+}++check_one() {+ local tag="$1" declared="$2" expected="${1#v}"+ if [ "$declared" != "$expected" ]; then+ printf '%s: Cargo.toml says %s\n' "$tag" "${declared:-<unset>}"+ return 1+ fi+ return 0+}++if [ "${1:-}" = "--all" ]; then+ failed=0+ while read -r tag; do+ declared="$(git show "${tag}:Cargo.toml" 2>/dev/null | cargo_version /dev/stdin || true)"+ check_one "$tag" "$declared" || failed=$((failed + 1))+ done < <(git tag --list 'v*' --sort=v:refname)+ if [ "$failed" -gt 0 ]; then+ printf '\n%d tag(s) do not carry the version they claim.\n' "$failed"+ exit 1+ fi+ echo "every v* tag carries the version it claims"+ exit 0+fi++tag="${1:-}"+if [ -z "$tag" ]; then+ echo "usage: $0 <tag>|--all" >&2+ exit 2+fi++declared="$(cargo_version Cargo.toml)"+if check_one "$tag" "$declared"; then+ printf '%s matches Cargo.toml version %s\n' "$tag" "$declared"+ exit 0+fi+cat >&2 <<MSG++The tag being released does not match the version the binary will report.+Bump Cargo.toml to ${tag#v} and move the tag onto that commit, or tag the+commit that already carries it.+MSG+exit 1