Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .cicd-hygiene-allow
Original file line number Diff line number Diff line change
@@ -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/**
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ 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`
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
Expand Down
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
113 changes: 113 additions & 0 deletions test/proven_report.ml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/test_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
48 changes: 48 additions & 0 deletions test/test_proven_report.ml
Original file line number Diff line number Diff line change
@@ -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 ]
32 changes: 28 additions & 4 deletions tools/ci/governance-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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)
Expand All @@ -38,7 +38,7 @@
# --- [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
Expand All @@ -48,7 +48,7 @@

# --- [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 \
Expand All @@ -66,7 +66,7 @@
# 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)"
Expand All @@ -76,6 +76,30 @@
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"

Check warning on line 90 in tools/ci/governance-standalone.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_affinescript&issues=AaIVDLebCPd5tZl6lNbR&open=AaIVDLebCPd5tZl6lNbR&pullRequest=807

Check failure on line 90 in tools/ci/governance-standalone.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_affinescript&issues=AaIVDLebCPd5tZl6lNbQ&open=AaIVDLebCPd5tZl6lNbQ&pullRequest=807
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"
Loading
Loading