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..72e85ead --- /dev/null +++ b/.github/workflows/proven.yml @@ -0,0 +1,32 @@ +# 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: + # PIN: main of proven-cicd-and-workflows after #168 merged; the v0.1.0 tag is not cut yet (owner). Re-pin to the tag SHA if it differs. + 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..2bc75903 --- /dev/null +++ b/.proven.toml @@ -0,0 +1,126 @@ +# SPDX-License-Identifier: MPL-2.0 +# Manifest (schema proven/manifest/v1); see hyperpolymath/proven-cicd-and-workflows docs/PROVEN-ADOPTION.adoc. +schema = "proven/manifest/v1" + +# Sweep 1 runs through tests/{unit,smoke,build,p2p}.sh (shell) and the Zig standalone FFI build they drive. + +[languages.ignore.ada] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.agda] +reason = "Proof or specification sources checked by their own gates (header-theory.yml, echidna-verify.yml), not by a unit runner; the umbrella has no checker for this language in release 0.1. Agda moves to the proven-tests-and-benches kit check when kit-v0.1.0 is tagged." + +[languages.ignore.c] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.clojure] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.coq] +reason = "Proof or specification sources checked by their own gates (header-theory.yml, echidna-verify.yml), not by a unit runner; the umbrella has no checker for this language in release 0.1. Agda moves to the proven-tests-and-benches kit check when kit-v0.1.0 is tagged." + +[languages.ignore.cpp] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.crystal] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.deno] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.elixir] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.gleam] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.go] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.haskell] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.java] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.julia] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.kotlin] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.lean] +reason = "Proof or specification sources checked by their own gates (header-theory.yml, echidna-verify.yml), not by a unit runner; the umbrella has no checker for this language in release 0.1. Agda moves to the proven-tests-and-benches kit check when kit-v0.1.0 is tagged." + +[languages.ignore.lua] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.nim] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.node] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.ocaml] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.php] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.python] +reason = "Residual: bindings/hy is a Hy (Python-hosted) binding with a pyproject.toml; estate Python ban means no Python test source here. Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.ruby] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.rust] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.scala] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.swift] +reason = "Thin binding over the libproven C ABI (CLAUDE.md boundary rule); its tests need the Idris-built libproven, which the umbrella cannot provision in release 0.1. Tracked in .proven/LATER.adoc for sweep 2 onwards." + +[languages.ignore.tla] +reason = "Proof or specification sources checked by their own gates (header-theory.yml, echidna-verify.yml), not by a unit runner; the umbrella has no checker for this language in release 0.1. Agda moves to the proven-tests-and-benches kit check when kit-v0.1.0 is tagged." + +[categories.unit.idris2.waiver] +reason = "The Idris 2 0.8.0 evidence scripts (header-refc.yml, idris2-ci.yml) need a toolchain the umbrella cannot install in release 0.1; they keep running in their own workflows. Expires when idris2 lands in v0.2." +until = "2026-12-10" + +[categories.smoke.idris2.waiver] +reason = "The Idris 2 0.8.0 evidence scripts (header-refc.yml, idris2-ci.yml) need a toolchain the umbrella cannot install in release 0.1; they keep running in their own workflows. Expires when idris2 lands in v0.2." +until = "2026-12-10" + +[categories.build.idris2.waiver] +reason = "The Idris 2 0.8.0 evidence scripts (header-refc.yml, idris2-ci.yml) need a toolchain the umbrella cannot install in release 0.1; they keep running in their own workflows. Expires when idris2 lands in v0.2." +until = "2026-12-10" + +[categories.p2p.idris2.waiver] +reason = "The Idris 2 0.8.0 evidence scripts (header-refc.yml, idris2-ci.yml) need a toolchain the umbrella cannot install in release 0.1; they keep running in their own workflows. Expires when idris2 lands in v0.2." +until = "2026-12-10" + +[categories.unit] +command = "bash tests/unit.sh" + +[categories.smoke] +command = "bash tests/smoke.sh" + +[categories.build] +command = "bash tests/build.sh" + +[categories.p2p] +command = "bash tests/p2p.sh" +[categories.unit.shell] +na = "tests/unit.sh needs the zig toolchain, which only the zig job provisions; that job runs it" + +[categories.smoke.shell] +na = "tests/smoke.sh needs the zig toolchain, which only the zig job provisions; that job runs it" + +[categories.build.shell] +na = "tests/build.sh needs the zig toolchain, which only the zig job provisions; that job runs it" + +[categories.p2p.shell] +na = "tests/p2p.sh needs the zig toolchain, which only the zig job provisions; that job runs it" + diff --git a/.proven/LATER.adoc b/.proven/LATER.adoc new file mode 100644 index 00000000..ed9d362a --- /dev/null +++ b/.proven/LATER.adoc @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: CC-BY-SA-4.0 += Later list (proven swap) + +Items deliberately deferred by the swap PR, so nothing passes on absence. + +* Sweep 2 (regression, proof-regression, type-safe, coupling/drift), sweep 3 (B grade), sweep 4. +* Idris2 provisioning in the umbrella (v0.2); idris2 waivers in `.proven.toml` expire 2026-12-10. +* Proof witnesses and full agda `--cubical`. +* Replace vendored `tests/kit/` with the umbrella-provided copy once kit-v0.1.0 exists; add a drift check. +* Unify the Idris lexer shared by the escape-hatch gate and the proof census. diff --git a/.proven/coverage.tsv b/.proven/coverage.tsv new file mode 100644 index 00000000..bec3cfcb --- /dev/null +++ b/.proven/coverage.tsv @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: MPL-2.0 +# proven coverage manifest (kit format). Sweep 1 gates: unit, smoke, build, p2p. +# planned = honest progress for a later sweep; never a pass for a sweep already due. +UT covered bash tests/unit.sh +P2P covered bash tests/p2p.sh +E2E planned - s2 +BLD covered bash tests/build.sh +EXE planned - s3 +REF planned - s2 +LCY planned - s3 +SMK covered bash tests/smoke.sh +PBT planned - s3 +MUT planned - s3 +FUZ planned - s3 +CTR planned - s2 +REG planned - s2 +CHS planned - s3 +CMP planned - s3 +PRF planned - s2 +TSF planned - s2 +CDF planned - s2 +DEP planned - s4 +SEC planned - s4 +USA planned - s4 +IOP planned - s4 +SAF planned - s4 +PER planned - s4 +FUN planned - s4 +VER planned - s4 +ACC planned - s4 +MNT planned - s4 +PRI planned - s4 +OBS planned - s4 +RPR planned - s4 +PRT planned - s4 +B-LAT planned - s4 +B-THR planned - s4 +B-MEM planned - s4 +B-STA planned - s4 +B-BLD planned - s4 +B-ENG planned - s4 +B-FFI planned - s4 diff --git a/tests/build.sh b/tests/build.sh new file mode 100755 index 00000000..2bfbf7ce --- /dev/null +++ b/tests/build.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# BLD (sweep 1): the Zig standalone FFI library builds, every shell script parses, and +# a deliberately broken script is rejected. A missing zig is a failure (DOG-01), never a skip. +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 2 +. tests/kit/lib/ptb.sh +command -v zig >/dev/null || { echo "build: zig not found; absence is not a pass" >&2; exit 2; } +mapfile -d '' scripts < <(git ls-files -z -- 'scripts/*.sh' 'tests/*.sh') +[[ ${#scripts[@]} -gt 0 ]] || { echo "build: no shell scripts found" >&2; exit 2; } +for s in "${scripts[@]}"; do ptb_ok "BLD-syntax-$s" bash -n "$s"; done +ptb_fails BLD-negative-control-syntax bash -n <(echo 'if then fi') +ptb_ok BLD-zig-standalone-lib zig build --build-file ffi/zig/build_standalone.zig +ptb_ok BLD-zig-lib-artifact test -s ffi/zig/zig-out/lib/libproven_ffi.a +ptb_done diff --git a/tests/kit/PROVENANCE.adoc b/tests/kit/PROVENANCE.adoc new file mode 100644 index 00000000..82d82166 --- /dev/null +++ b/tests/kit/PROVENANCE.adoc @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: CC-BY-SA-4.0 += Vendored kit provenance + +Files in this directory are unchanged copies of `kit/` in +hyperpolymath/proven-tests-and-benches at 55c9a152c5dc028b6a8da945b10812329101d36f +(PR 121, pre-tag). Do not edit them here. Replace with the pin to `kit-v0.1.0` +as F1 documents once that tag exists (see `.proven/LATER.adoc`). diff --git a/tests/kit/check-coverage.sh b/tests/kit/check-coverage.sh new file mode 100755 index 00000000..8d3acca7 --- /dev/null +++ b/tests/kit/check-coverage.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# check-coverage.sh — fail-closed check of a repo's coverage manifest. +# +# Usage: kit/check-coverage.sh [--root DIR] [--through-sweep N] [MANIFEST] +# MANIFEST defaults to /.proven/coverage.tsv +# +# Manifest: tab-separated, '#' comments, columns: +# id status language ref +# status covered | na | planned +# covered ref = path (relative to root) of an existing, non-empty file +# na ref = written reason, at least 20 characters, not a placeholder +# planned ref = 's1'..'s4' (optionally followed by text): the sweep that will cover it. +# Honest progress, not a pass: a planned row whose sweep is <= --through-sweep +# is a VIOLATION (it was due). Default --through-sweep is 4, so by default +# every planned row fails; a repo on sweep 1 gates with --through-sweep 1. +# language the language of the test, or '-' for na rows +# Every id in kit/ids.tsv (18 categories, 14 aspects, 7 bench kinds) must have at +# least one row. A missing id is a FAILURE, not a pass (A3 G3 / ER-A8 / DOG-01). +# +# Exit: 0 all ids accounted for; 1 violation; 2 no check performed +# (manifest missing/unreadable/empty, or ids.tsv missing). 2 is never a pass. +set -u +here="$(cd "$(dirname "$0")" && pwd)" +root="." +through=4 +manifest="" +while [ $# -gt 0 ]; do + case "$1" in + --root) root="$2"; shift 2 ;; + --through-sweep) through="$2"; shift 2 ;; + *) manifest="$1"; shift ;; + esac +done +case "$through" in 1|2|3|4) ;; *) echo "NO CHECK PERFORMED: --through-sweep must be 1-4" >&2; exit 2 ;; esac +[ -n "$manifest" ] || manifest="$root/.proven/coverage.tsv" +ids="$here/ids.tsv" +[ -r "$ids" ] || { echo "NO CHECK PERFORMED: $ids unreadable" >&2; exit 2; } +[ -r "$manifest" ] || { echo "NO CHECK PERFORMED: manifest $manifest missing or unreadable" >&2; exit 2; } +rows=$(grep -vc -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$manifest") +[ "$rows" -gt 0 ] || { echo "NO CHECK PERFORMED: manifest $manifest has no rows" >&2; exit 2; } + +awk -F'\t' -v through="$through" -v root="$root" -v idsfile="$ids" ' +function bad(msg) { print "VIOLATION: " msg > "/dev/stderr"; fails++ } +BEGIN { + while ((getline line < idsfile) > 0) { + if (line ~ /^#/ || line ~ /^[[:space:]]*$/) continue + split(line, f, "\t"); known[f[2]] = f[1]; order[++n] = f[2] + } + split("n/a na none todo tbd tba later later. - n.a. not-applicable", ph, " ") + for (i in ph) placeholder[ph[i]] = 1 +} +/^[[:space:]]*#/ || /^[[:space:]]*$/ { next } +{ + id = $1; st = $2; lang = $3; ref = $4 + if (!(id in known)) { bad("line " NR ": unknown id \"" id "\""); next } + if (st == "covered") { + if (lang == "" || lang == "-") bad("line " NR ": " id " covered but language missing") + p = (ref ~ /^\//) ? ref : root "/" ref + cmd = "test -s \"" p "\"" + if (system(cmd) != 0) bad("line " NR ": " id " covered but ref \"" ref "\" is missing or empty") + else seen[id] = 1 + } else if (st == "na") { + r = ref; gsub(/^[ \t]+|[ \t]+$/, "", r) + if (length(r) < 20 || (tolower(r) in placeholder)) bad("line " NR ": " id " na without a real reason (need >= 20 chars)") + else seen[id] = 1 + } else if (st == "planned") { + if (ref !~ /^s[1-4]([ \t]|$)/) bad("line " NR ": " id " planned needs ref s1..s4 (the sweep that covers it)") + else { + sw = substr(ref, 2, 1) + 0 + if (sw <= through) bad("line " NR ": " id " planned for sweep " sw " but sweeps through " through " are due") + else { planned[id] = sw; seen[id] = 1; np++ } + } + } else bad("line " NR ": " id " status \"" st "\" is not covered|na|planned") +} +END { + for (i = 1; i <= n; i++) if (!(order[i] in seen)) bad("id " order[i] " (" known[order[i]] ") has no valid row - absence is a failure") + if (fails > 0) { print fails " violation(s)" > "/dev/stderr"; exit 1 } + if (np > 0) print "OK through sweep " through ": all " n " ids accounted for, " np " planned for later sweeps (not covered yet)" + else print "OK: all " n " ids accounted for" +}' "$manifest" diff --git a/tests/kit/ids.tsv b/tests/kit/ids.tsv new file mode 100644 index 00000000..e0d0a1cb --- /dev/null +++ b/tests/kit/ids.tsv @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: MPL-2.0 +# Canonical ids from TESTING-TAXONOMY.adoc (Appendix A, Appendix B, Part IV). +# kind id name +category UT Unit +category P2P Point-to-Point +category E2E End-to-End +category BLD Build +category EXE Execution & Runtime +category REF Reflexive +category LCY Lifecycle +category SMK Smoke +category PBT Property-Based +category MUT Mutation +category FUZ Fuzz +category CTR Contract/Invariant +category REG Regression +category CHS Chaos/Resilience +category CMP Compatibility +category PRF Proof Regression +category TSF Type-Safe +category CDF Coupling/Drift-freedom +aspect DEP Dependability +aspect SEC Security +aspect USA Usability +aspect IOP Interoperability +aspect SAF Safety +aspect PER Performance +aspect FUN Functionality +aspect VER Versability +aspect ACC Accessibility +aspect MNT Maintainability +aspect PRI Privacy +aspect OBS Observability +aspect RPR Reproducibility +aspect PRT Portability +bench B-LAT Latency +bench B-THR Throughput +bench B-MEM Memory +bench B-STA Startup +bench B-BLD Build time +bench B-ENG Energy +bench B-FFI FFI overhead diff --git a/tests/kit/lib/ptb.sh b/tests/kit/lib/ptb.sh new file mode 100755 index 00000000..2569afa8 --- /dev/null +++ b/tests/kit/lib/ptb.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# ptb.sh — tiny fail-closed test helpers for Bash suites. Source it. +# ptb_eq NAME WANT GOT ptb_ok NAME CMD... ptb_fails NAME CMD... +# ptb_done exits non-zero if any failed OR if zero ran (DOG-01) +# A suite that runs no assertions is a failure, not a pass. +PTB_PASS=0; PTB_FAIL=0 +ptb_eq() { if [ "$2" = "$3" ]; then PTB_PASS=$((PTB_PASS+1)); else PTB_FAIL=$((PTB_FAIL+1)); echo "FAIL $1: want [$2] got [$3]"; fi; } +ptb_ok() { local n="$1"; shift; if "$@" >/dev/null 2>&1; then PTB_PASS=$((PTB_PASS+1)); else PTB_FAIL=$((PTB_FAIL+1)); echo "FAIL $n: expected success: $*"; fi; } +ptb_fails() { local n="$1"; shift; if "$@" >/dev/null 2>&1; then PTB_FAIL=$((PTB_FAIL+1)); echo "FAIL $n: expected failure (negative control passed): $*"; else PTB_PASS=$((PTB_PASS+1)); fi; } +ptb_done() { + echo "ptb: $PTB_PASS passed, $PTB_FAIL failed" + [ "$PTB_FAIL" -eq 0 ] || exit 1 + [ "$PTB_PASS" -gt 0 ] || { echo "ptb: NO ASSERTIONS RAN - that is a failure, not a pass" >&2; exit 2; } + exit 0 +} diff --git a/tests/kit/lib/smoke.sh b/tests/kit/lib/smoke.sh new file mode 100755 index 00000000..a0afb56b --- /dev/null +++ b/tests/kit/lib/smoke.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# smoke.sh — language-agnostic smoke test (SMK). The built artefact starts, +# answers, and exits cleanly within a time limit. +# smoke.sh [--timeout SECS] --expect REGEX -- CMD [ARGS...] +# Pass: exit 0, output non-empty AND matches REGEX. Fail 1: otherwise. +# Exit 2: nothing was run (CMD missing / not executable): absence is not a pass. +set -u +t=10; re="" +while [ $# -gt 0 ]; do case "$1" in --timeout) t="$2"; shift 2 ;; --expect) re="$2"; shift 2 ;; --) shift; break ;; *) break ;; esac; done +[ -n "$re" ] && [ $# -gt 0 ] || { echo "NO CHECK PERFORMED: usage: smoke.sh --expect REGEX -- CMD..." >&2; exit 2; } +command -v "$1" >/dev/null 2>&1 || [ -x "$1" ] || { echo "NO CHECK PERFORMED: $1 not found" >&2; exit 2; } +out=$(timeout "$t" "$@" 2>&1); rc=$? +[ "$rc" -eq 0 ] || { echo "SMOKE FAIL: exit $rc (124 = timeout): $*" >&2; exit 1; } +[ -n "$out" ] || { echo "SMOKE FAIL: empty output: $*" >&2; exit 1; } +printf '%s' "$out" | grep -Eq -- "$re" || { echo "SMOKE FAIL: output does not match /$re/: $out" >&2; exit 1; } +echo "SMOKE OK: $*" diff --git a/tests/p2p.sh b/tests/p2p.sh new file mode 100755 index 00000000..85ba3223 --- /dev/null +++ b/tests/p2p.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# P2P (sweep 1): the producer-to-consumer seams that need no Idris: RefC staging into the +# Zig tree and the native symbol validator reading a real archive. Real components on both +# sides of each seam; planted-failure controls prove each seam rejects bad input. +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 2 +. tests/kit/lib/ptb.sh +ptb_ok P2P-refc-staging-seam bash tests/check-refc-staging.sh +ptb_ok P2P-header-staging-seam bash scripts/test-header-staging.sh +ptb_ok P2P-native-symbol-validator-seam bash tests/check-native-nif-exports.sh +ptb_ok P2P-abi-ledger-vs-header bash scripts/test-abi-ledger.sh +ptb_done diff --git a/tests/smoke.sh b/tests/smoke.sh new file mode 100755 index 00000000..58a68f66 --- /dev/null +++ b/tests/smoke.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# SMK (sweep 1): the standalone FFI entry starts and answers. Without an Idris backend it +# must refuse with status -99 rather than guess (fail-closed), which its Zig test asserts; +# here the real test binary is built and run, and a failing run fails the smoke. +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 2 +. tests/kit/lib/ptb.sh +command -v zig >/dev/null || { echo "smoke: zig not found; absence is not a pass" >&2; exit 2; } +out=$(zig build test --build-file ffi/zig/build_standalone.zig --summary all 2>&1); rc=$? +ptb_eq SMK-zig-standalone-tests-exit 0 "$rc" +case $out in *"tests passed"*) ptb_ok SMK-tests-executed true ;; *) ptb_fails SMK-tests-executed true ;; esac +ptb_fails SMK-missing-binary-is-not-a-pass tests/kit/lib/smoke.sh --expect x -- /nonexistent/binary +ptb_done diff --git a/tests/unit.sh b/tests/unit.sh new file mode 100755 index 00000000..08b5d3c0 --- /dev/null +++ b/tests/unit.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# UT (sweep 1): every toolchain-free test script, run as one assertion each, plus a +# negative control proving a failing script is reported as a failure. +# Scripts that need Idris 2 0.8.0 are NOT run here (the umbrella cannot provision it +# in v0.1); they stay in header-refc.yml and are waived in .proven.toml until v0.2. +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 2 +. tests/kit/lib/ptb.sh +for t in scripts/test-abi-ledger.sh scripts/test-header-staging.sh scripts/test-refc-staging.sh \ + tests/check-native-nif-exports.sh tests/check-refc-staging.sh; do + [[ -f $t ]] || { echo "unit: listed test $t is missing"; exit 2; } + ptb_ok "UT-$t" bash "$t" +done +bad=$(mktemp); printf '#!/usr/bin/env bash\nexit 1\n' > "$bad" +ptb_fails UT-negative-control-failing-script bash "$bad" +rm -f "$bad" +ptb_ok UT-coverage-manifest bash tests/kit/check-coverage.sh --through-sweep 1 .proven/coverage.tsv +ptb_done