From bf89e77d3d96630119f8e9947f4a9a9df408309a Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:30:20 +0000 Subject: [PATCH 1/3] ci(governance): vendor proven-cicd required-files and code-hygiene gates (advisory) Copy two gates from hyperpolymath/proven-cicd-and-workflows at 50a443f01b1b85e4957b893a6f1a0ed2e8a52459 into tools/ci/proven/ and run them as checks [5] and [6] of tools/ci/governance-standalone.sh. Findings print as warnings and do not fail the gate; only a failed self-test of the vendored hygiene checker does. CI/gate, ci.yml and actions.lock are unchanged, so the standalone CI (#603/#604) stays as it is. Findings at adoption: MAINTAINERS never names the repository owner, and 147 debt markers have no issue link. .cicd-hygiene-allow excludes the vendored gates (they name the markers) and formal/K1_CodegenPreservation.v, whose header states the no-Admitted rule in words. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw --- .cicd-hygiene-allow | 12 ++ CHANGELOG.adoc | 5 + tools/ci/governance-standalone.sh | 32 +++- tools/ci/proven/VENDOR.adoc | 69 ++++++++ tools/ci/proven/code-hygiene-check.sh | 84 ++++++++++ tools/ci/proven/required-files-check.sh | 178 +++++++++++++++++++++ tools/ci/proven/test-code-hygiene-check.sh | 53 ++++++ 7 files changed, 429 insertions(+), 4 deletions(-) create mode 100644 .cicd-hygiene-allow create mode 100644 tools/ci/proven/VENDOR.adoc create mode 100755 tools/ci/proven/code-hygiene-check.sh create mode 100755 tools/ci/proven/required-files-check.sh create mode 100755 tools/ci/proven/test-code-hygiene-check.sh diff --git a/.cicd-hygiene-allow b/.cicd-hygiene-allow new file mode 100644 index 00000000..b470dc07 --- /dev/null +++ b/.cicd-hygiene-allow @@ -0,0 +1,12 @@ +# Paths excluded from tools/ci/proven/code-hygiene-check.sh (vendored from +# hyperpolymath/proven-cicd-and-workflows). Keep this list short and give a +# reason for every entry. +# +# The file's header comment states the rule "NO `Admitted`, NO `Axiom`, NO +# `postulate`"; the scanner reads the words as circumventions. The no-escape +# rule for formal/*.v is enforced by formal/justfile (Print Assumptions). +formal/K1_CodegenPreservation.v + +# The hygiene gate and its fixtures name the markers they look for, and the +# required-files gate lists "TODO: update" as a placeholder pattern. +tools/ci/proven/** diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 8c2a9575..1765c395 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -185,6 +185,11 @@ JSR publish (#303) ==== CI +* ci(governance): adopt two hyperpolymath/proven-cicd-and-workflows gates, +vendored at 50a443f into `tools/ci/proven/`: required files and code hygiene +(untracked debt markers, proof escapes). They run as advisory checks [5] and +[6] of `tools/ci/governance-standalone.sh` and do not fail it; `CI/gate`, +`ci.yml` and `actions.lock` are unchanged. Exclusions in `.cicd-hygiene-allow` * fix(ci): `CI` never started from 2026-10-11 (startup_failure, zero jobs) because Dependabot #782 bumped actions in ci.yml without regenerating `.github/workflows/actions.lock`. The lock now matches every workflow diff --git a/tools/ci/governance-standalone.sh b/tools/ci/governance-standalone.sh index 0d4f3816..3d06abbb 100755 --- a/tools/ci/governance-standalone.sh +++ b/tools/ci/governance-standalone.sh @@ -26,7 +26,7 @@ err() { printf '::error::%s\n' "$*"; fail=1; } echo "== Governance gate (standalone) ==" # --- [1] Jekyll artifacts are banned (estate SSG is hyperpolymath/casket-ssg) -echo "[1/4] Jekyll artifacts" +echo "[1/6] Jekyll artifacts" jekyll=$(find . \( -path ./.git -o -path ./_build -o -path ./node_modules \) -prune -o \ \( -name '_config.yml' -o -name 'Gemfile' -o -iname 'jekyll*.yml' \ -o -iname 'jekyll-gh-pages*.yml' \) -print 2>/dev/null || true) @@ -38,7 +38,7 @@ else note "none"; fi # --- [2] MPL-1.0 license headers are banned (must be MPL-2.0) --------------- # Match the actual SPDX identifier, not mere prose mentions of the ban (the # policy docs legitimately discuss MPL-1.0). -echo "[2/4] MPL-1.0 SPDX headers" +echo "[2/6] MPL-1.0 SPDX headers" mpl1=$(grep -rIl --exclude-dir=.git --exclude-dir=_build --exclude-dir=node_modules \ -E 'SPDX-License-Identifier:[[:space:]]*MPL-1\.0' . 2>/dev/null || true) if [ -n "$mpl1" ]; then @@ -48,7 +48,7 @@ else note "none"; fi # --- [3] DOC-FORMAT (delta): newly-added docs/ files must be .adoc ---------- # Community-health files keep their canonical .md names. -echo "[3/4] DOC-FORMAT (newly-added docs/ files must be .adoc)" +echo "[3/6] DOC-FORMAT (newly-added docs/ files must be .adoc)" base="${1:-${GOVERNANCE_BASE_REF:-${GITHUB_BASE_REF:-}}}" if [ -n "$base" ] && git rev-parse --verify --quiet "origin/$base" >/dev/null 2>&1; then added=$(git diff --name-only --diff-filter=A "origin/$base...HEAD" -- 'docs/' 2>/dev/null \ @@ -66,7 +66,7 @@ fi # A workflow whose actions drift from the lockfile never starts (GitHub reports # a startup_failure with zero jobs). Dependabot bumps do exactly that unless the # lock is regenerated: CI was silently not running from 2026-10-11 (#782). -echo "[4/4] actions.lock consistency" +echo "[4/6] actions.lock consistency" if ! lock_out=$(./tools/ci/check-actions-lock.sh 2>&1); then printf '%s\n' "$lock_out" | grep '::error::' | sed 's/^::error:: *//' | while IFS= read -r l; do err "$l"; done err "actions.lock is out of step with the workflows (run gh actions-lock)" @@ -76,6 +76,30 @@ if ! test_out=$(./tools/ci/test-check-actions-lock.sh 2>&1); then err "the actions.lock guard failed its own regression tests (tools/ci/test-check-actions-lock.sh)" else note "$(printf '%s\n' "$test_out" | tail -1)"; fi +# --- [5]/[6] proven-cicd-and-workflows gates, ADVISORY ---------------------- +# Vendored from hyperpolymath/proven-cicd-and-workflows (tools/ci/proven/, +# pinned in VENDOR.adoc). They report as warnings and never set $fail: the +# tree does not pass them yet, and making them blocking is an owner decision. +advisory() { # $1 = label, rest = command + label=$1; shift + if out=$("$@" 2>&1); then note "pass" + else + n=$(printf '%s\n' "$out" | grep -cE '^[^:[:space:]]+:[0-9]+:' || true) + printf '%s\n' "$out" | grep '::error::' | sed 's/^::error:: *//' | while IFS= read -r l; do + printf '::warning::%s (advisory): %s\n' "$label" "$l"; done + [ "$n" -gt 0 ] && note "$n flagged source line(s); run $1 for the list" + note "advisory only: not counted as a failure" + fi +} +echo "[5/6] required files (proven-cicd, advisory)" +advisory required-files ./tools/ci/proven/required-files-check.sh +echo "[6/6] code hygiene: untracked debt markers, proof escapes (proven-cicd, advisory)" +if ! st=$(./tools/ci/proven/test-code-hygiene-check.sh 2>&1); then + err "the vendored code-hygiene check failed its own controls (tools/ci/proven/test-code-hygiene-check.sh)" + printf '%s\n' "$st" | tail -3 | sed 's/^/ /' +fi +advisory code-hygiene ./tools/ci/proven/code-hygiene-check.sh + echo if [ "$fail" -ne 0 ]; then echo "Governance gate: FAIL"; exit 1; fi echo "Governance gate: PASS" diff --git a/tools/ci/proven/VENDOR.adoc b/tools/ci/proven/VENDOR.adoc new file mode 100644 index 00000000..06308121 --- /dev/null +++ b/tools/ci/proven/VENDOR.adoc @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MPL-2.0 += Vendored proven-cicd-and-workflows gates + +Source:: `hyperpolymath/proven-cicd-and-workflows` +Pinned commit:: `50a443f01b1b85e4957b893a6f1a0ed2e8a52459` +Licence of the source:: MPL-2.0 (headers kept as shipped) + +[cols="2,3,3"] +|=== +| File here | Upstream | Change + +| `code-hygiene-check.sh` +| `actions/code-hygiene-check/check.sh` +| a "vendored from" comment only + +| `test-code-hygiene-check.sh` +| `actions/code-hygiene-check/test.sh` +| the checker path (`check.sh` -> `code-hygiene-check.sh`) and the comment + +| `required-files-check.sh` +| `actions/required-files-check/action.yml`, the `run:` block +| extracted to a script; `REPO_OWNER` / `REPO_NAME` default to the Actions + environment instead of the `github` context +|=== + +== Why vendored, not called + +The framework's own consumer model calls its reusable workflows and actions +by remote SHA, removes them from `.github/workflows/actions.lock`, and adds a +second producer of the `CI/gate` status. This repository's CI is standalone +(#603/#604), every `uses:` must match `actions.lock`, and `CI/gate` is the one +required check on `main`. Copying the scripts keeps all three. + +== How they run + +`tools/ci/governance-standalone.sh` runs them as checks [5] and [6]. They are +*advisory*: findings print as warnings and do not fail the gate. Only a failed +self-test of the vendored hygiene checker (its positive and negative controls) +fails the gate, because then the advisory result itself cannot be trusted. + +Run them on their own: + +---- +tools/ci/proven/required-files-check.sh +tools/ci/proven/code-hygiene-check.sh # uses .cicd-hygiene-allow +tools/ci/proven/test-code-hygiene-check.sh +---- + +== Findings when adopted (2026-11-25) + +* required-files: `MAINTAINERS` names `@metadatastician` and never the + repository owner `hyperpolymath`; the gate reads that as an unedited + template. Owner to decide; not changed here. +* code-hygiene: 147 TODO / FIXME / XXX / HACK / STUB markers without an + issue link (`MARKER(#N)`), most in `tools/affine-pkg/src` and `runtime/src`. + No proof escapes outside `.cicd-hygiene-allow`. + +== Making them blocking + +Swap `advisory …` for a failing call in `governance-standalone.sh` once the +tree passes. That, and any adoption of the remote reusable workflows, is an +owner decision. + +== Updating + +Copy the three files from the new upstream commit, re-apply the changes in +the table, update the pinned commit above and in each file's comment, and run +`tools/ci/proven/test-code-hygiene-check.sh` and +`tools/ci/governance-standalone.sh`. diff --git a/tools/ci/proven/code-hygiene-check.sh b/tools/ci/proven/code-hygiene-check.sh new file mode 100755 index 00000000..9cb8c75b --- /dev/null +++ b/tools/ci/proven/code-hygiene-check.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Vendored verbatim from hyperpolymath/proven-cicd-and-workflows +# actions/code-hygiene-check/ at 50a443f01b1b85e4957b893a6f1a0ed2e8a52459 +# (see tools/ci/proven/VENDOR.adoc); only the checker path was renamed. +# Distinguish untracked implementation debt from prose, templates, generated +# metadata, and issue-linked work. Proof circumventions remain a separate, +# stricter check over proof languages only. +set -uo pipefail +fail=0 + +readonly allow_file='.cicd-hygiene-allow' +allow_args=() +if [[ -f "$allow_file" ]]; then + echo "Using allowlist $allow_file:" + while IFS= read -r pat || [[ -n "$pat" ]]; do + case "$pat" in + ''|'#'*) continue ;; + *) + echo " exclude: $pat" + allow_args+=(":(exclude)$pat") + ;; + esac + done < "$allow_file" +fi + +# The horizon is deliberately explicit. These are implementation-language +# files, wherever they occur in the tree. Documentation, workflows, +# machine-readable templates, packaging recipes, and container templates are +# not silently relabelled as application source. +exclude_paths=( + ':(exclude).github/**' ':(exclude).githooks/**' + ':(exclude).machine_readable/**' ':(exclude)docs/**' + ':(exclude)packaging/**' ':(exclude)container/**' + ":(exclude)$allow_file" +) + +source_paths=( + '*.adb' '*.ads' '*.affine' '*.agda' '*.bash' '*.c' '*.cc' '*.clj' '*.cljs' + '*.cjs' '*.cpp' '*.cr' '*.cts' '*.cxx' '*.eph' '*.erl' '*.ex' '*.exs' + '*.fish' '*.fs' + '*.fsx' '*.gleam' '*.go' '*.h' '*.hh' '*.hpp' '*.hs' '*.idr' '*.java' + '*.js' '*.jsx' '*.kt' '*.kts' '*.lean' '*.lhs' '*.lua' '*.m' '*.mjs' + '*.ml' '*.mli' '*.mm' '*.mts' '*.nu' + '*.php' '*.pl' '*.pm' '*.py' '*.r' '*.rb' '*.res' '*.resi' '*.roc' '*.rs' + '*.scala' '*.sh' '*.sol' '*.sql' '*.swift' '*.thy' '*.ts' '*.tsx' '*.v' + '*.vala' '*.vapi' '*.zig' + "${exclude_paths[@]}" +) + +echo 'Scanning implementation source for untracked debt markers...' +debt="$({ git grep --untracked -n -E -w 'TODO|FIXME|XXX|HACK|STUB' -- \ + "${source_paths[@]}" "${allow_args[@]+"${allow_args[@]}"}" || true; } \ + | perl -ne 'print if /:[0-9]+:.*\b(?:TODO|FIXME|XXX|HACK|STUB)\b(?!\(#[0-9]+\))/')" +if [[ -n "$debt" ]]; then + echo '::error::Untracked debt markers found in implementation source:' >&2 + printf '%s\n' "$debt" + echo '::error::Resolve the debt or link it as MARKER(#issue).' >&2 + fail=1 +else + echo ' none.' +fi + +echo 'Scanning proof code for undeclared circumventions...' +circ="$({ git grep --untracked -n -E -w 'sorry|believe_me|admit|postulate|assert_total' -- \ + '*.idr' '*.lean' '*.v' '*.agda' '*.thy' \ + "${exclude_paths[@]}" \ + "${allow_args[@]+"${allow_args[@]}"}" || true; } \ + | grep -vE ':[0-9]+:[[:space:]]*(\|\|\||--|//|\(\*)' || true)" +if [[ -n "$circ" ]]; then + echo '::error::Undeclared proof circumventions found:' >&2 + printf '%s\n' "$circ" + echo "::error::If sanctioned, isolate the axioms, list the module in $allow_file," >&2 + echo '::error::and enforce the exact count with a trusted-base check.' >&2 + fail=1 +else + echo ' none.' +fi + +if [[ "$fail" -eq 1 ]]; then + echo '::error::Code hygiene gate failed.' >&2 + exit 1 +fi +echo 'Hygiene check passed.' diff --git a/tools/ci/proven/required-files-check.sh b/tools/ci/proven/required-files-check.sh new file mode 100755 index 00000000..e5c363eb --- /dev/null +++ b/tools/ci/proven/required-files-check.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# Vendored from hyperpolymath/proven-cicd-and-workflows +# actions/required-files-check/action.yml (run: block, verbatim) at +# 50a443f01b1b85e4957b893a6f1a0ed2e8a52459. See tools/ci/proven/VENDOR.adoc. +# The composite action took REPO_OWNER / REPO_NAME from the github context; +# here they default to the Actions environment. +REPO_OWNER="${REPO_OWNER:-${GITHUB_REPOSITORY_OWNER:-hyperpolymath}}" +REPO_NAME="${REPO_NAME:-${GITHUB_REPOSITORY:-hyperpolymath/affinescript}}" + +# Accepted placements widened per owner ruling 2026-09-19: estate +# repos legitimately keep governance docs under docs/ (and GitHub +# renders under .github/) — rsr-template-repo itself was failing on +# layout, not on substance. Root forms still win (first hit). +# Template-repo mode: see below. +# +# Presence-only checking rewards filler. This gate previously demanded +# ARCHITECTURE.md / MAINTAINERS.adoc / GOVERNANCE.md and checked only +# that the paths existed — so the cheapest way to pass was to commit +# template boilerplate. That happened: an estate repo acquired an +# ARCHITECTURE.md describing a directory layout it does not have, a +# MAINTAINERS naming a different account as owner, and a mise.toml +# pinning `zig = "latest"` against that repo's own .tool-versions. +# All three would have passed. So: presence, THEN format, THEN substance. +# +# Format policy (estate): +# .adoc documentation (default) +# .md wiki content only — plus a transitional allowance for the +# GitHub-mandated files, which are migrating to berrywiki format +# .txt licence texts +# fixed names GitHub or convention dictates (CODEOWNERS, funding.yml, +# NOTICE, AUTHORS, MAINTAINERS) keep their form +# GitHub runs a composite step as `bash --noprofile --norc -e -o pipefail`. +# That `-e` comes from the harness, not from here, and `set -uo pipefail` +# does NOT clear it. It directly contradicts this gate's design: the whole +# script accumulates `fail=1` so it can report EVERY defect and exit once +# at the end. Under `-e` the first non-zero command kills the step instead, +# silently, before the line that would have explained itself. +# Measured 2026-09-22 on pons-asinorum: a comment-only CODEOWNERS made +# `grep -v ... | wc -l` exit 1, which killed the step one line ABOVE the +# message declaring that exact file valid. The count sites below are also +# individually guarded, so the contract survives someone re-adding `-e`. +set +e +set -uo pipefail +fail=0 + +# --- template-repo mode ------------------------------------------- +# An un-instantiated template legitimately SHIPS {{OWNER}}/{{AUTHOR}} +# placeholders and self-references its own template name; judging it +# like an instantiated repo is a category error. Detection is explicit +# and auditable: the repo name says it is a template. +TEMPLATE_MODE=0 +case "${REPO_NAME##*/}" in + *-template|*-template-repo) TEMPLATE_MODE=1 ;; +esac +if [ "$TEMPLATE_MODE" -eq 1 ]; then + echo " template repo detected ($REPO_NAME): instantiation placeholders are the shipped product" +fi + +# --- presence, accepting every policy-legal form ------------------- +# "name:form1,form2,..." — first existing form wins. +declare -a required=( + ".editorconfig:.editorconfig" + ".gitignore:.gitignore" + ".gitattributes:.gitattributes" + "CODEOWNERS:CODEOWNERS,.github/CODEOWNERS,docs/CODEOWNERS" + "GOVERNANCE:GOVERNANCE.adoc,GOVERNANCE.md,docs/GOVERNANCE.adoc,docs/GOVERNANCE.md,.github/GOVERNANCE.adoc,.github/GOVERNANCE.md" + "ARCHITECTURE:ARCHITECTURE.adoc,ARCHITECTURE.md,docs/ARCHITECTURE.adoc,docs/ARCHITECTURE.md,docs/architecture/README.adoc,TOPOLOGY.adoc,TOPOLOGY.md" + "MAINTAINERS:MAINTAINERS,MAINTAINERS.adoc,MAINTAINERS.md,docs/MAINTAINERS,docs/MAINTAINERS.adoc,docs/MAINTAINERS.md" + "toolchain:.tool-versions,.mise.toml,mise.toml" +) + +declare -A found=() +for spec in "${required[@]}"; do + name="${spec%%:*}"; forms="${spec#*:}" + hit="" + IFS=',' read -ra cands <<< "$forms" + for c in "${cands[@]}"; do [ -f "$c" ] && { hit="$c"; break; }; done + if [ -z "$hit" ]; then + echo "::error::Missing required file: $name (accepted: $forms)" + fail=1 + else + found["$name"]="$hit" + echo " found $name -> $hit" + fi +done + +# --- substance: a file that exists but says nothing is not a file -- +PLACEHOLDERS_BASE='TODO: update| "$fixture/src/main.rs" +printf '%s\n' 'TODO in documentation is explanatory.' > "$fixture/docs/design.md" +printf '%s\n' 'example = believe_me value' > "$fixture/docs/example.idr" +printf '%s\n' '// marker in the filename is not debt' > "$fixture/src/TODO.rs" +printf '%s\n' '# TODO: workflow follow-up' > "$fixture/.github/workflows/ci.yml" +printf '%s\n' 'TODO: fill this template' > "$fixture/.machine_readable/templates/example.ncl" +git -C "$fixture" add . +git -C "$fixture" commit -qm fixture + +(cd "$fixture" && bash "$checker") + +printf '%s\n' '// TODO: TypeScript implementation debt' > "$fixture/src/app.ts" +if (cd "$fixture" && bash "$checker"); then + echo 'FAIL: untracked TypeScript debt was accepted' >&2 + exit 1 +fi +printf '%s\n' '// clean TypeScript source' > "$fixture/src/app.ts" + +printf '%s\n' '// TODO: untracked implementation debt' > "$fixture/src/main.rs" +if (cd "$fixture" && bash "$checker"); then + echo 'FAIL: untracked source debt was accepted' >&2 + exit 1 +fi + +printf '%s\n' '// TODO(#123): tracked implementation debt' > "$fixture/src/main.rs" +(cd "$fixture" && bash "$checker") + +printf '%s\n' 'proof = believe_me value' > "$fixture/src/Safety.idr" +if (cd "$fixture" && bash "$checker"); then + echo 'FAIL: proof circumvention was accepted' >&2 + exit 1 +fi + +printf '%s' 'src/Safety.idr' > "$fixture/.cicd-hygiene-allow" +(cd "$fixture" && bash "$checker") +echo 'All code-hygiene positive and negative controls passed.' From 1b354cd6815a4c652f8185bfac4e4ee44c81079e Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:34:35 +0000 Subject: [PATCH 2/3] ci(test): Proven-Tests run report for the lexer suite (advisory) Adopt the hyperpolymath/proven-tests-and-benches contract with an OCaml producer, since the framework's emitter is Python. PROVEN_REPORT=FILE makes test_main.exe write a schema_version-2 report for test/test_lexer.ml instead of running Alcotest. tools/ci/proven/proven-report.sh builds the framework's Rust validator proven-evidence at a pinned commit and runs emit and check. Every entry is Unproven (no proof ladder) and FixtureDebt (no demonstrated firing fixture). The contract keeps debt out of the pass/fail ledger, so the emitter exits 1 when any test does not pass; test/test_proven_report.ml pins that. The CI build job runs the script as a continue-on-error step; no uses: ref changes, so actions.lock is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw --- .github/workflows/ci.yml | 7 ++ CHANGELOG.adoc | 9 ++- test/dune | 2 +- test/proven_report.ml | 113 +++++++++++++++++++++++++++++++ test/test_main.ml | 13 ++++ test/test_proven_report.ml | 48 +++++++++++++ tools/ci/proven/VENDOR.adoc | 39 ++++++++++- tools/ci/proven/proven-report.sh | 53 +++++++++++++++ 8 files changed, 280 insertions(+), 4 deletions(-) create mode 100644 test/proven_report.ml create mode 100644 test/test_proven_report.ml create mode 100755 tools/ci/proven/proven-report.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4bb1ca3..a4f501a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,13 @@ jobs: run: | set -o pipefail opam exec -- dune runtest 2>&1 | tee runtest.log + - name: Proven-Tests run report, lexer suite (advisory) + # hyperpolymath/proven-tests-and-benches contract: an OCaml emitter + # (test/proven_report.ml) validated by the framework's pinned Rust + # checker. Advisory while adoption is a first slice: it never fails + # the job. See tools/ci/proven/VENDOR.adoc#proven-tests. + continue-on-error: true + run: opam exec -- ./tools/ci/proven/proven-report.sh - name: Consumer on-ramp example (issue #771) # The consumer-facing contract this project owes its downstream # readers: a host surface declared with `extern fn`, compiled to diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 1765c395..ecc1148f 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -188,8 +188,13 @@ JSR publish (#303) * ci(governance): adopt two hyperpolymath/proven-cicd-and-workflows gates, vendored at 50a443f into `tools/ci/proven/`: required files and code hygiene (untracked debt markers, proof escapes). They run as advisory checks [5] and -[6] of `tools/ci/governance-standalone.sh` and do not fail it; `CI/gate`, -`ci.yml` and `actions.lock` are unchanged. Exclusions in `.cicd-hygiene-allow` +[6] of `tools/ci/governance-standalone.sh` and do not fail it; `CI/gate` +and `actions.lock` are unchanged. Exclusions in `.cicd-hygiene-allow` +* ci(test): Proven-Tests run report for the lexer suite +(hyperpolymath/proven-tests-and-benches contract). `test/proven_report.ml` +emits it in OCaml; `tools/ci/proven/proven-report.sh` validates it with the +framework's pinned Rust checker `proven-evidence`; an advisory CI step. All 16 +entries are `Unproven` and `FixtureDebt`; a failing test still fails the emitter * fix(ci): `CI` never started from 2026-10-11 (startup_failure, zero jobs) because Dependabot #782 bumped actions in ci.yml without regenerating `.github/workflows/actions.lock`. The lock now matches every workflow diff --git a/test/dune b/test/dune index 47df4eda..4c5bb097 100644 --- a/test/dune +++ b/test/dune @@ -1,6 +1,6 @@ (test (name test_main) - (libraries affinescript borrow_polonius alcotest str unix) + (libraries affinescript borrow_polonius alcotest str unix yojson) (deps (source_tree golden) (source_tree e2e) diff --git a/test/proven_report.ml b/test/proven_report.ml new file mode 100644 index 00000000..b34dd512 --- /dev/null +++ b/test/proven_report.ml @@ -0,0 +1,113 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* SPDX-FileCopyrightText: 2026 hyperpolymath *) + +(** Proven-Tests run report (schema_version 2) for an Alcotest suite. + + The producer half of the hyperpolymath/proven-tests-and-benches + integration contract, written in OCaml because the framework's own + emitter is Python. The report is checked by the framework's Rust + validator, [proven-evidence check] (see tools/ci/proven/proven-report.sh). + + Every entry is stated at the tier its evidence supports and no higher: + [Unproven], with an empty proof ladder. None of these tests yet carries + a demonstrated firing fixture (an input with the defect, shown to make + the test fail), so each one is [FixtureDebt], referencing + [debt_ref]. The contract leaves debt entries out of the pass/fail + ledger, so the emitter itself fails when any test does not pass: + a failure never disappears into the debt column. *) + +let debt_ref = + "hyperpolymath/affinescript tools/ci/proven/VENDOR.adoc#proven-tests \ + (no demonstrated firing fixture yet)" + +(* The size of the taxonomy's (category, aspect) lattice, as pinned in the + contract (contract-version.json, LATTICE_CELLS in proven-evidence). *) +let cat_aspect_cells = 238 + +type outcome = Passed | Failed of string + +let outcome_json = function + | Passed -> `Assoc [ ("outcome", `String "passed") ] + | Failed m -> `Assoc [ ("outcome", `String "failed"); ("message", `String m) ] + +let run_case (f : unit -> unit) : outcome * int = + let t0 = Unix.gettimeofday () in + let r = + try f (); Passed with + (* An Alcotest check failure and any other exception both mean the test + did not pass; the contract's "error" outcome is not distinguished. *) + | e -> Failed (Printexc.to_string e) + in + (r, int_of_float ((Unix.gettimeofday () -. t0) *. 1000.)) + +let entry ~module_path (name, _speed, f) = + let outcome, ms = run_case f in + let json = + `Assoc + [ ( "test_id", + `Assoc + [ ("module_path", `String module_path); + ("test_name", `String name); + ("line_number", `Int 0) ] ); + ("category", `String "Unit"); + ("aspect", `String "Functionality"); + ("typesafe_category", `Null); + ("provenance", `String "Unproven"); + ("evidence", `Assoc []); + ("proof_ladder", `List []); + ("result", outcome_json outcome); + ("fixture_obligation", `String "FixtureDebt"); + ("fixture_debt_ref", `String debt_ref); + ("duration_ms", `Int ms) ] + in + (json, outcome) + +(** Run [tests] and write the report to [path]. Returns the number of + tests that did not pass. *) +let write ~suite ~module_path ~path tests = + let results = List.map (entry ~module_path) tests in + let n = List.length results in + let not_passed = + List.length (List.filter (fun (_, o) -> o <> Passed) results) + in + (* Debt entries count in the tier tally only (contract counting rule). *) + let summary = + `Assoc + [ ("passed", `Int 0); ("failed", `Int 0); ("errors", `Int 0); + ("skipped", `Int 0); ("total", `Int 0); + ("actually_proven", `Int 0); ("provisionally_proven", `Int 0); + ("unproven", `Int n); ("covered_cells", `Int 0); + ("cat_aspect_cells", `Int cat_aspect_cells); + ("lattice_covered", `Int 0) ] + in + let doc = + `Assoc + [ ("schema_version", `Int 2); + ("suite", `String suite); + ("generated_at", + `String + (let t = Unix.gmtime (Unix.time ()) in + Printf.sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ" + (t.tm_year + 1900) (t.tm_mon + 1) t.tm_mday + t.tm_hour t.tm_min t.tm_sec)); + ("toolchain", + `Assoc [ ("ocaml", `String Sys.ocaml_version); + ("runner", `String "alcotest") ]); + ("summary", summary); + ("entries", `List (List.map fst results)) ] + in + Yojson.Safe.to_file path doc; + List.iter + (fun (j, o) -> + match o, j with + | Passed, _ -> () + | Failed m, `Assoc kv -> + let name = + match List.assoc "test_id" kv with + | `Assoc t -> (match List.assoc "test_name" t with `String s -> s | _ -> "?") + | _ -> "?" + in + Printf.eprintf "proven-report: %s did not pass: %s\n" name m + | _ -> ()) + results; + not_passed diff --git a/test/test_main.ml b/test/test_main.ml index d9304a2e..2999b69d 100644 --- a/test/test_main.ml +++ b/test/test_main.ml @@ -3,10 +3,23 @@ (** Main test runner for AffineScript *) +(* [PROVEN_REPORT=FILE]: write a Proven-Tests run report for the lexer suite + instead of running Alcotest (tools/ci/proven/proven-report.sh). *) +let () = + match Sys.getenv_opt "PROVEN_REPORT" with + | Some path when path <> "" -> + let bad = + Proven_report.write ~suite:"affinescript-lexer" + ~module_path:"test/test_lexer.ml" ~path Test_lexer.tests + in + exit (if bad = 0 then 0 else 1) + | _ -> () + let () = Alcotest.run "AffineScript" ([ ("Lexer", Test_lexer.tests); + ("Proven-Tests report emitter", Test_proven_report.tests); (* ("Parser", Test_parser.tests); *) (* TODO: Re-enable when test_parser is implemented *) ("Golden", Test_golden.tests); ("Examples", Test_golden.example_tests); diff --git a/test/test_proven_report.ml b/test/test_proven_report.ml new file mode 100644 index 00000000..8b8c0538 --- /dev/null +++ b/test/test_proven_report.ml @@ -0,0 +1,48 @@ +(* SPDX-License-Identifier: MPL-2.0 *) +(* SPDX-FileCopyrightText: 2026 hyperpolymath *) + +(** The Proven-Tests report emitter (test/proven_report.ml) must never hide a + failing test, and must never claim more than [Unproven]. *) + +let read path = Yojson.Safe.from_file path + +let member k = function + | `Assoc kv -> (try List.assoc k kv with Not_found -> `Null) + | _ -> `Null + +let test_failure_is_reported () = + let path = Filename.temp_file "proven" ".json" in + let cases = + [ ("ok", `Quick, (fun () -> ())); + ("bad", `Quick, (fun () -> Alcotest.(check int) "x" 1 2)) ] + in + let saved = Unix.dup Unix.stderr in + let null = Unix.openfile "/dev/null" [ Unix.O_WRONLY ] 0 in + Unix.dup2 null Unix.stderr; + let bad = + Fun.protect + ~finally:(fun () -> Unix.dup2 saved Unix.stderr; Unix.close null) + (fun () -> Proven_report.write ~suite:"t" ~module_path:"m" ~path cases) + in + Alcotest.(check int) "one test did not pass" 1 bad; + let doc = read path in + Sys.remove path; + let entries = match member "entries" doc with `List l -> l | _ -> [] in + let outcomes = + List.map (fun e -> member "outcome" (member "result" e)) entries + in + Alcotest.(check (list string)) "outcomes kept per entry" [ "passed"; "failed" ] + (List.map (function `String s -> s | _ -> "?") outcomes); + List.iter + (fun e -> + Alcotest.(check string) "tier" "Unproven" + (match member "provenance" e with `String s -> s | _ -> "?"); + Alcotest.(check bool) "empty proof ladder" true + (member "proof_ladder" e = `List [])) + entries; + Alcotest.(check bool) "summary tallies both as unproven" true + (member "unproven" (member "summary" doc) = `Int 2) + +let tests = + [ Alcotest.test_case "a failing test is reported, not hidden" `Quick + test_failure_is_reported ] diff --git a/tools/ci/proven/VENDOR.adoc b/tools/ci/proven/VENDOR.adoc index 06308121..aaf43397 100644 --- a/tools/ci/proven/VENDOR.adoc +++ b/tools/ci/proven/VENDOR.adoc @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -= Vendored proven-cicd-and-workflows gates += proven-* framework adoption Source:: `hyperpolymath/proven-cicd-and-workflows` Pinned commit:: `50a443f01b1b85e4957b893a6f1a0ed2e8a52459` @@ -67,3 +67,40 @@ Copy the three files from the new upstream commit, re-apply the changes in the table, update the pinned commit above and in each file's comment, and run `tools/ci/proven/test-code-hygiene-check.sh` and `tools/ci/governance-standalone.sh`. + +[[proven-tests]] +== proven-tests-and-benches: lexer run report + +Not vendored: only the contract is used. `test/proven_report.ml` is an OCaml +producer of the schema_version-2 run report (the framework's own emitter and +validator are Python, which this repository does not use). +`PROVEN_REPORT=FILE test_main.exe` writes the report for the lexer suite +(`test/test_lexer.ml`) instead of running Alcotest. +`tools/ci/proven/proven-report.sh` builds the framework's Rust validator, +`proven-evidence`, from + +Source:: `hyperpolymath/proven-tests-and-benches`, + `integrations/contract/proven-tests/downstream/rust/proven-evidence` +Pinned commit:: `f90bacbe3a5fa1869239fcb9175757509464aa13` + +and runs `emit` and `check` on the report. The contract's own pin +(`contract-version.json`, `2eaa6535…`) predates the crate's `Cargo.lock`, so +it cannot be built with `--locked`; the newer commit is pinned instead. + +The CI `build` job runs it as a step with `continue-on-error: true`, so it +reports without failing the job. + +What the report claims, and why: + +* Every entry is `Unproven` with an empty proof ladder: no lexer test has a + mechanised theorem or a safety certificate behind it. +* Every entry is `FixtureDebt`: no test yet has a *demonstrated* firing + fixture (an input with the defect, shown to make the test fail). The + contract leaves debt entries out of the pass/fail ledger, so the summary + shows 0 tests and 16 unproven. To keep failures visible anyway, the + emitter exits 1 when any test does not pass, and the entry records the + real outcome; `test/test_proven_report.ml` pins that behaviour. + +Next steps: add silence/firing fixture pairs to tests (moving them from +`FixtureDebt` to `Fixtures`, where they count), then extend the report to +more suites. diff --git a/tools/ci/proven/proven-report.sh b/tools/ci/proven/proven-report.sh new file mode 100755 index 00000000..2f327f16 --- /dev/null +++ b/tools/ci/proven/proven-report.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# Emit the Proven-Tests run report for the lexer suite and validate it with +# the framework's own Rust checker, proven-evidence (hyperpolymath/ +# proven-tests-and-benches, pinned below). See VENDOR.adoc#proven-tests. +# +# Usage: tools/ci/proven/proven-report.sh [OUT_DIR] (default _build/proven) +# PROVEN_EVIDENCE=/path/to/proven-evidence skips the fetch and build. +# +# Exit codes follow the contract: 0 conforms, 1 does not conform (or a test +# did not pass), 2 no check was performed (a tool or input was missing). +set -euo pipefail + +readonly pin_repo='https://github.com/hyperpolymath/proven-tests-and-benches.git' +readonly pin_commit='f90bacbe3a5fa1869239fcb9175757509464aa13' +readonly crate='integrations/contract/proven-tests/downstream/rust/proven-evidence' + +out="${1:-_build/proven}" +mkdir -p "$out" +out="$(cd "$out" && pwd)" + +checker="${PROVEN_EVIDENCE:-}" +if [[ -z "$checker" ]]; then + for tool in git cargo; do + command -v "$tool" >/dev/null 2>&1 || { echo "proven-report: '$tool' not found" >&2; exit 2; } + done + src="$out/proven-tests-and-benches" + if [[ ! -d "$src/.git" ]]; then + git init -q "$src" + git -C "$src" remote add origin "$pin_repo" + fi + git -C "$src" fetch -q --depth 1 origin "$pin_commit" || { echo "proven-report: cannot fetch $pin_commit" >&2; exit 2; } + git -C "$src" checkout -q --detach FETCH_HEAD + [[ "$(git -C "$src" rev-parse HEAD)" == "$pin_commit" ]] || { echo "proven-report: pin mismatch" >&2; exit 2; } + cargo build -q --release --locked --manifest-path "$src/$crate/Cargo.toml" || exit 2 + checker="$src/$crate/target/release/proven-evidence" +fi +[[ -x "$checker" ]] || { echo "proven-report: no proven-evidence at $checker" >&2; exit 2; } + +report="$out/proven-run-report.json" +summary="$out/proven-summary.json" +rc=0 +PROVEN_REPORT="$report" dune exec --no-print-directory test/test_main.exe >/dev/null || rc=$? +[[ -f "$report" ]] || { echo "proven-report: no report written" >&2; exit 2; } + +"$checker" emit "$report" "$summary" +"$checker" check "$report" "$summary" +if [[ "$rc" -ne 0 ]]; then + echo "proven-report: a lexer test did not pass (see above)" >&2 + exit 1 +fi +echo "proven-report: $report conforms to the Proven-Tests contract (pinned $pin_commit)" From 58ab9b0669204f12d190fd16029bbf5f6d6291b1 Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:43:05 +0000 Subject: [PATCH 3/3] fix(ci): fetch proven-tests-and-benches outside the working tree The proven-report step cloned the framework into _build/proven/, and the DEED gate (tools/check-deed-gates.sh) then found that repository's .a2ml files and failed the build job. Fetch it under $RUNNER_TEMP (or $TMPDIR) instead; PROVEN_SRC overrides the location. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw --- tools/ci/proven/proven-report.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/ci/proven/proven-report.sh b/tools/ci/proven/proven-report.sh index 2f327f16..dd833a14 100755 --- a/tools/ci/proven/proven-report.sh +++ b/tools/ci/proven/proven-report.sh @@ -6,7 +6,8 @@ # proven-tests-and-benches, pinned below). See VENDOR.adoc#proven-tests. # # Usage: tools/ci/proven/proven-report.sh [OUT_DIR] (default _build/proven) -# PROVEN_EVIDENCE=/path/to/proven-evidence skips the fetch and build. +# PROVEN_EVIDENCE=/path/to/proven-evidence skips the fetch and build; +# PROVEN_SRC sets where the framework is fetched (outside the tree). # # Exit codes follow the contract: 0 conforms, 1 does not conform (or a test # did not pass), 2 no check was performed (a tool or input was missing). @@ -25,7 +26,9 @@ if [[ -z "$checker" ]]; then for tool in git cargo; do command -v "$tool" >/dev/null 2>&1 || { echo "proven-report: '$tool' not found" >&2; exit 2; } done - src="$out/proven-tests-and-benches" + # Outside the working tree: the framework repo carries .a2ml files, which + # this repo's DEED gate (tools/check-deed-gates.sh) refuses anywhere in it. + src="${PROVEN_SRC:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}/proven-tests-and-benches}" if [[ ! -d "$src/.git" ]]; then git init -q "$src" git -C "$src" remote add origin "$pin_repo"