diff --git a/.github/workflows/proven-lock-gate.yml b/.github/workflows/proven-lock-gate.yml new file mode 100644 index 00000000..2da566e1 --- /dev/null +++ b/.github/workflows/proven-lock-gate.yml @@ -0,0 +1,121 @@ +# SPDX-License-Identifier: MPL-2.0 +# proven-cicd: proven-lock-gate@0.3.3 sha256:870340e4ad1ce67b9b9f7080d9c99782abf800aeb2a14b0410d0a60eb4a4f547 +# Stamped copy of hyperpolymath/proven-cicd-and-workflows templates/proven-lock-gate.yml. +# Do not edit by hand. A changed body fails this gate as drift. The applier +# moves the pinned suite SHA. The line after each `proven-cicd:local-next` +# marker is local and outside the stamp's hash. +# +# The gate judges this repository's actions.lock against its workflows with the +# proven lock kernel. It exits 0 for consistent, 1 for a defect or drift, and 2 +# when it could not run. A run that could not run fails this job: it is never +# skipped and never continue-on-error, so a required check cannot pass without +# a verdict. Every way the gate can fail before its verdict has its own class: +# not_run:pin PROVEN_SHA is not a 40-hex commit +# not_run:identity the suite repository is not the one this gate pins +# (repository id 1326697643 owned by account id 6759885, +# hyperpolymath, after following a rename), it moved to +# another owner, or the name no longer exists: refer, +# never re-run +# not_run:identity-unreadable the repository or owner id could not be read +# (API outage or rate limit): a re-run +# not_run:fetch-missing the pinned commit does not exist in the suite (persistent) +# not_run:fetch the suite could not be fetched after retries (transient) +# not_run:checkout the fetched commit could not be checked out +# not_run:suite-behind the pinned suite is older than this copy: its manifest +# lists an earlier proven-lock-gate (or none). Fix: move +# PROVEN_SHA to a commit whose proven/manifest.json lists +# at least this copy's version +# not_run:suite the checkout is not the pinned commit, is modified, or +# lacks a file or directory the gate runs +# and the suite's own script adds drift, toolchain, build, selftest, extract and +# verdict. The Idris2 RefC runtime is vendored in the suite (dist/), so the build +# needs no network and has no class of its own for a third-party host. +name: Proven lock gate +on: + pull_request: + merge_group: + push: + branches: [main] +permissions: + contents: read +jobs: + proven-lock: + name: Proven lock gate + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + # proven-cicd:local-next + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Judge actions.lock with the proven suite at its pinned commit + env: + # proven-cicd:local-next + PROVEN_SHA: "9009d1dbc49301d098aa3c921f685de4d2ee8e85" + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + fail() { echo "PROVEN_LOCK_CLASS=not_run:$1"; [[ -z ${2:-} ]] || echo "$2" >&2; exit 2; } + [[ $PROVEN_SHA =~ ^[0-9a-f]{40}$ ]] || fail pin + repo=hyperpolymath/proven-cicd-and-workflows + # The suite is pinned by commit; the id pins the repository itself, so a + # recreated repository under the same name is refused. A transfer keeps + # the repository id and GitHub redirects the old name to it, so the + # owner id is pinned as well: a transferred repository is refused, and a + # rename within the owner (same repository id, same owner id) passes. + # Two classes: an id that cannot be read is an availability failure (a + # re-run); an id that differs is a different repository (refer). + # A rename answers 301: follow it (-L) and judge the id it leads to. + # The request and every redirect are HTTPS only (--proto, --proto-redir), + # so a redirect cannot carry the token over plain HTTP. A name that no + # longer exists (404, 410) is permanent, so it is identity; any other + # non-200 (403, 429, 5xx) is availability, a re-run. + code=$(curl -sS -L --proto '=https' --proto-redir '=https' --retry 3 -o "$RUNNER_TEMP/proven-repo.json" -w '%{http_code}' \ + -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/$repo") || + fail identity-unreadable "could not reach the API for $repo" + case $code in + 200) ;; + 404|410) fail identity "$repo does not exist (HTTP $code)" ;; + *) fail identity-unreadable "the API answered HTTP $code for $repo" ;; + esac + id=$(jq -r '.id // empty' "$RUNNER_TEMP/proven-repo.json" 2>/dev/null) || fail identity-unreadable "the reply for $repo is not JSON" + [[ $id =~ ^[0-9]+$ ]] || fail identity-unreadable "the reply for $repo has no id" + [[ $id == 1326697643 ]] || fail identity "$repo has id '$id', not 1326697643" + owner=$(jq -r '.owner.id // empty' "$RUNNER_TEMP/proven-repo.json" 2>/dev/null) || fail identity-unreadable "the reply for $repo has a malformed owner" + [[ $owner =~ ^[0-9]+$ ]] || fail identity-unreadable "the reply for $repo has no owner id" + [[ $owner == 6759885 ]] || + fail identity "$repo (id $id) is owned by account $owner ($(jq -r '.owner.login // "?"' "$RUNNER_TEMP/proven-repo.json" 2>/dev/null)), not 6759885 (hyperpolymath): a transfer" + suite="$RUNNER_TEMP/proven-suite" + git init -q "$suite" + git -C "$suite" remote add origin "https://github.com/$repo.git" + git -C "$suite" config core.sparseCheckout true + printf '%s\n' dist/ scripts/ tests/fixtures/proven-lock/ /proven/manifest.json > "$suite/.git/info/sparse-checkout" + fetched=0 + for delay in 0 10 30; do + sleep "$delay" + if git -C "$suite" fetch -q --depth=1 origin "$PROVEN_SHA" 2>"$RUNNER_TEMP/proven-fetch.err"; then fetched=1; break; fi + # A commit the server does not have will not appear on a retry. + if grep -qiE "not our ref|couldn't find remote ref|unadvertised object|no such remote ref" "$RUNNER_TEMP/proven-fetch.err"; then + fail fetch-missing "$(cat "$RUNNER_TEMP/proven-fetch.err")" + fi + done + [[ $fetched == 1 ]] || fail fetch "$(cat "$RUNNER_TEMP/proven-fetch.err")" + git -C "$suite" checkout -q --detach FETCH_HEAD || fail checkout + [[ $(git -C "$suite" rev-parse HEAD) == "$PROVEN_SHA" ]] || fail suite "checked out $(git -C "$suite" rev-parse HEAD), not $PROVEN_SHA" + [[ -z $(git -C "$suite" status --porcelain) ]] || fail suite "the suite checkout is modified" + # This copy needs a suite at least as new as itself (0.3.0 needs the + # vendored runtime): a pin older than the copy is its own class, so the + # fix is plain (move the pin), not a generic refusal. + mine=$(sed -n '1,2s/^# proven-cicd: proven-lock-gate@\([0-9]*\.[0-9]*\.[0-9]*\) .*/\1/p' "$GITHUB_WORKSPACE/.github/workflows/proven-lock-gate.yml") + [[ -n $mine ]] || fail suite "this copy has no proven-lock-gate stamp" + theirs=$(jq -r '[.artifacts[] | select(.artifact == "proven-lock-gate") | .version][0] // empty' "$suite/proven/manifest.json" 2>/dev/null || true) + [[ -n $theirs && $(printf '%s\n' "$theirs" "$mine" | sort -V | head -n 1) == "$mine" ]] || + fail suite-behind "the suite at $PROVEN_SHA lists proven-lock-gate ${theirs:-nothing}, older than this copy's $mine; move PROVEN_SHA" + for f in scripts/proven-lock-gate.sh scripts/proven-stamp.sh scripts/build-proven-lock.sh \ + scripts/extract-lock-facts.sh dist/proven-lock/proven-lock-verdict.c; do + [[ -f $suite/$f ]] || fail suite "the suite at $PROVEN_SHA lacks $f" + done + for d in dist/proven-lock/runtime/refc dist/proven-lock/runtime/c tests/fixtures/proven-lock; do + [[ -d $suite/$d ]] || fail suite "the suite at $PROVEN_SHA lacks $d/" + done + bash "$suite/scripts/proven-lock-gate.sh" "$GITHUB_WORKSPACE" .github/workflows/proven-lock-gate.yml diff --git a/.github/workflows/proven.yml b/.github/workflows/proven.yml new file mode 100644 index 00000000..4e4971f7 --- /dev/null +++ b/.github/workflows/proven.yml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: MPL-2.0 +# The estate's umbrella gate: ONE caller, ONE required check (`proven / verdict`). +# Do not copy runner jobs in here: a copy freezes and never receives a fix. +# New categories, aspects and checks reach this repository when Dependabot +# (github-actions ecosystem) bumps the pin below. Repo-local content is the +# repo's own tests and fixtures plus .proven.toml (schema proven/manifest/v1). +# +# The job id MUST be `proven` and the job MUST NOT carry `if:` or +# `continue-on-error` (a skipped gate is void, ER-A8). The pin is a full SHA +# with its release tag in the comment; never a branch or a bare tag. +name: Proven + +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] # labeled: bench-approved re-runs the gate + merge_group: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + actions: read + pull-requests: read # bench-approved label lookup + +jobs: + proven: + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/proven.yml@9009d1dbc49301d098aa3c921f685de4d2ee8e85 # v0.1.2 (tag pending) diff --git a/.proven.toml b/.proven.toml new file mode 100644 index 00000000..a983a6e2 --- /dev/null +++ b/.proven.toml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: MPL-2.0 +# Manifest for the proven umbrella gate (schema proven/manifest/v1). +# Release 0.1.0 of the umbrella enforces sweep 1 (unit, smoke, build, p2p) and +# ships runners for rust, elixir, go, node, python, zig and shell only. +schema = "proven/manifest/v1" + +# The Rust suite carries sweep 1. These are the repo's own tests (tests/proven_*.rs, +# tests/p2p_property_tests.rs), mapped in .proven/coverage.tsv. + +# UT: the library unit tests, the same command as `just test`. Spelled out here +# because the umbrella runner image has no `just` (the job failed with +# "just: command not found"). +[categories.unit.rust] +command = "cargo test --locked --lib" + +[categories.smoke.rust] +command = "cargo test --test proven_smoke" + +[categories.p2p.rust] +command = "cargo test --test p2p_property_tests" + +# BLD: compiles the binary with the lockfile frozen and runs tests/proven_build.rs. +[categories.build.rust] +command = "cargo test --locked --test proven_build" + +# Languages the umbrella has no runner for yet. Each is accounted for with a +# reason, never dropped silently. They are verified by their own jobs today +# (idris2-abi-ci, formal-verification, agda-meta-checker, zig-ffi-ci, +# chapel-ci); each reason is removed when the umbrella ships that toolchain. +[languages.ignore.idris2] +reason = "no umbrella toolchain in 0.1.0; src/abi is type-checked by idris2-abi-ci.yml" +[languages.ignore.agda] +reason = "no umbrella toolchain in 0.1.0; checked by agda-meta-checker.yml" +[languages.ignore.coq] +reason = "no umbrella toolchain in 0.1.0; proof fixtures checked by formal-verification.yml" +[languages.ignore.lean] +reason = "no umbrella toolchain in 0.1.0; proof fixtures checked by formal-verification.yml" +[languages.ignore.isabelle] +reason = "no umbrella toolchain in 0.1.0; proof fixtures checked by formal-verification.yml" +[languages.ignore.julia] +reason = "no umbrella toolchain in 0.1.0; the Julia ML layer is exercised by live-provers and training scripts" +[languages.ignore.ocaml] +reason = "no umbrella toolchain in 0.1.0; a single AffineScript compiler-host file" +[languages.ignore.c] +reason = "FFI headers and shims only; compiled and exercised through zig-ffi-ci.yml and the Rust build" +[languages.ignore.javascript] +reason = "build tooling only (CLAUDE.md language policy): Tailwind config and the static UI server script" +[languages.ignore.zig] +reason = "C-ABI bridge; built and tested by zig-ffi-ci.yml until the umbrella's zig runner covers the FFI layout" +[languages.ignore.ada] +reason = "SPARK proof fixtures; checked by spark-theatre-gate.yml" +[languages.ignore.shell] +reason = "build and CI glue; shellcheck and the scripts' own tests run in rust-ci and static-analysis-gate" +[languages.ignore.elixir] +reason = "docs-site is a documentation generator with no test suite yet; its tests are a sweep 2 item in .proven/coverage.tsv" diff --git a/.proven/coverage.tsv b/.proven/coverage.tsv new file mode 100644 index 00000000..e9ea080b --- /dev/null +++ b/.proven/coverage.tsv @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: MPL-2.0 +# Coverage manifest for the proven umbrella (kit/check-coverage.sh). Sweep 1 only: ids not listed are not yet swept. +# id status language ref +UT covered rust src/rust/dispatch.rs +UT covered rust tests/sanity_suite.rs +P2P covered rust tests/p2p_property_tests.rs +SMK covered rust tests/proven_smoke.rs +BLD covered rust tests/proven_build.rs +E2E planned - s2 echidna sweep 2 (rest of CRG C) +EXE planned - s2 echidna sweep 2 (rest of CRG C) +REF planned - s2 echidna sweep 2 (rest of CRG C) +LCY planned - s2 echidna sweep 2 (rest of CRG C) +REG planned - s2 echidna sweep 2 (rest of CRG C) +CTR planned - s2 echidna sweep 2 (rest of CRG C) +PRF planned - s2 echidna sweep 2 (rest of CRG C) +TSF planned - s2 echidna sweep 2 (rest of CRG C) +CDF planned - s2 echidna sweep 2 (rest of CRG C) +PBT planned - s3 echidna sweep 3 (B grade) +MUT planned - s3 echidna sweep 3 (B grade) +FUZ planned - s3 echidna sweep 3 (B grade) +CMP planned - s3 echidna sweep 3 (B grade) +CHS planned - s3 echidna sweep 3 (B grade) +DEP planned - s4 echidna sweep 4 (all 18 plus extras) +SEC planned - s4 echidna sweep 4 (all 18 plus extras) +USA planned - s4 echidna sweep 4 (all 18 plus extras) +IOP planned - s4 echidna sweep 4 (all 18 plus extras) +SAF planned - s4 echidna sweep 4 (all 18 plus extras) +PER planned - s4 echidna sweep 4 (all 18 plus extras) +FUN planned - s4 echidna sweep 4 (all 18 plus extras) +VER planned - s4 echidna sweep 4 (all 18 plus extras) +ACC planned - s4 echidna sweep 4 (all 18 plus extras) +MNT planned - s4 echidna sweep 4 (all 18 plus extras) +PRI planned - s4 echidna sweep 4 (all 18 plus extras) +OBS planned - s4 echidna sweep 4 (all 18 plus extras) +RPR planned - s4 echidna sweep 4 (all 18 plus extras) +PRT planned - s4 echidna sweep 4 (all 18 plus extras) +B-LAT planned - s4 echidna sweep 4 (all 18 plus extras) +B-THR planned - s4 echidna sweep 4 (all 18 plus extras) +B-MEM planned - s4 echidna sweep 4 (all 18 plus extras) +B-STA planned - s4 echidna sweep 4 (all 18 plus extras) +B-BLD planned - s4 echidna sweep 4 (all 18 plus extras) +B-ENG planned - s4 echidna sweep 4 (all 18 plus extras) +B-FFI planned - s4 echidna sweep 4 (all 18 plus extras) diff --git a/tests/proven_build.rs b/tests/proven_build.rs new file mode 100644 index 00000000..7f37ae7d --- /dev/null +++ b/tests/proven_build.rs @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MPL-2.0 +//! BLD (taxonomy category 4): the `echidna` binary artefact exists and is +//! non-empty, and the committed lockfile is current (`cargo update --locked` +//! fails if it would change, and unlike full metadata resolution it needs no +//! registry download). The +//! warnings-denied clean build and its timing run in CI through +//! `kit/lib/build-check.sh` (the cheap form here must not rebuild the tree). +use std::path::Path; +use std::process::Command; + +#[test] +fn the_binary_artifact_exists_and_is_nonempty() { + let p = Path::new(env!("CARGO_BIN_EXE_echidna")); + assert!(p.is_file(), "{} is not a file", p.display()); + assert!(p.metadata().unwrap().len() > 0, "{} is empty", p.display()); +} + +#[test] +fn the_lockfile_resolves_without_network() { + let out = Command::new(env!("CARGO")) + .args(["update", "--workspace", "--locked", "--offline"]) + .current_dir(env!("CARGO_MANIFEST_DIR")) + .output() + .expect("spawn cargo"); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stderr) + ); +} + +// Negative control: a lockfile check must be able to fail. +#[test] +fn a_bogus_manifest_path_is_rejected() { + let out = Command::new(env!("CARGO")) + .args([ + "update", + "--workspace", + "--locked", + "--offline", + "--manifest-path", + "/nonexistent/Cargo.toml", + ]) + .output() + .expect("spawn cargo"); + assert!(!out.status.success()); +} diff --git a/tests/proven_smoke.rs b/tests/proven_smoke.rs new file mode 100644 index 00000000..c5732125 --- /dev/null +++ b/tests/proven_smoke.rs @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MPL-2.0 +//! SMK (taxonomy category 8): the built `echidna` binary starts, answers and +//! exits cleanly. No external prover is needed, so none of these tests can pass +//! by skipping; each asserts on real output and has a negative control. +use std::process::Command; + +fn bin() -> Command { + Command::new(env!("CARGO_BIN_EXE_echidna")) +} + +#[test] +fn version_prints_the_package_version() { + let out = bin().arg("--version").output().expect("spawn echidna"); + assert!(out.status.success(), "exit: {:?}", out.status); + let stdout = String::from_utf8_lossy(&out.stdout); + assert!( + stdout.contains(env!("CARGO_PKG_VERSION")), + "version output {stdout:?} lacks {}", + env!("CARGO_PKG_VERSION") + ); +} + +#[test] +fn help_lists_the_core_subcommands() { + let out = bin().arg("--help").output().expect("spawn echidna"); + assert!(out.status.success()); + let stdout = String::from_utf8_lossy(&out.stdout); + for sub in ["prove", "verify", "list-provers", "server"] { + assert!(stdout.contains(sub), "--help does not mention `{sub}`"); + } +} + +#[test] +fn list_provers_answers_with_at_least_one_backend() { + let out = bin().arg("list-provers").output().expect("spawn echidna"); + assert!( + out.status.success(), + "stderr: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stdout = String::from_utf8_lossy(&out.stdout); + assert!( + stdout.lines().any(|l| l.contains(" - Tier ")), + "list-provers listed no backend:\n{stdout}" + ); +} + +// Negative controls: a smoke test that cannot fail proves nothing. +#[test] +fn unknown_subcommand_exits_nonzero() { + let out = bin() + .arg("no-such-subcommand") + .output() + .expect("spawn echidna"); + assert!(!out.status.success()); +} + +#[test] +fn proving_a_missing_file_exits_nonzero() { + let out = bin() + .args(["prove", "/nonexistent/proven-smoke-input.v"]) + .output() + .expect("spawn echidna"); + assert!(!out.status.success()); + let stderr = String::from_utf8_lossy(&out.stderr); + assert!( + stderr.contains("Failed to parse proof file"), + "expected the missing-file error, got:\n{stderr}" + ); +}