Skip to content
Draft
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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
name: "Clippy",
run: "bash scripts/ci/run.sh clippy cargo clippy --locked --all-targets --all-features -- -D warnings",
},
{
# Syntax only: Creusot's own parser reads every contract. No prover runs.
name: "Proof contracts parse (pearlite-syn, no verifier)",
run: "bash scripts/ci/run.sh contracts-parse cargo test --locked --manifest-path verification/creusot/Cargo.toml",
},
{
# Tests the gate's logic against stub verifiers. Not proof evidence:
# the real gate runs only from a digest-pinned prover image.
name: "Proof gate self-test (stub verifier, not evidence)",
run: "bash scripts/ci/run.sh proof-gate-selftest bash scripts/tests/proof-gate-test.sh",
},
],
},
msrv: {
Expand Down
42 changes: 42 additions & 0 deletions docs/RELEASING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,48 @@ commit kyq may already pin; it does not change what kyq consumes.
are still `OPEN` (no Creusot, Verus or Kani result exists), and that tests
are empirical evidence, not proof.

== What "beta" means

Owner ruling of 2026-12-01: beta needs real proofs. A *beta* is a signed tag
`v0.1.0-beta.N` plus a GitHub pre-release. As for a preview, only the owner
tags, signs and publishes, and nothing is published to crates.io by this gate.

The preview gate lets the release notes say the proofs are `OPEN`. The beta
gate does not.

== Beta gates (all must hold on the tagged commit)

. Every preview gate above, except gate 4, which gates 3 to 6 below replace.
. No known soundness hole is open: no input for which the library or CLI
emits wrong canonical bytes, accepts non-I-JSON, panics, or reports a
wrong exit status. Each hole found has a must-fail test in the tree.
. The proof gate passes on the tagged commit: `scripts/proofs/gate.sh`, run
from a prover image pinned by digest from `hyperpolymath/prover-images`,
never from a toolchain installed ad hoc. The gate requires a non-empty
production scope included by path, a true control the verifier accepts and
false controls it refuses by name, and writes a receipt holding the commit,
the image digest, the invocation and the sha256 of every input. The receipt's
`commit` equals the tagged commit and its `verifier` is not `stub`.
. In `verification/PROOF-STATUS.adoc`, these rows are `PROVEN`, or `PROVEN`
relative to assumptions the row names, with a receipt:
key ordering contract and total order (J-1, J-2), string escaping (J-4),
member order and byte determinism (J-6, J-7), and for the reader the
termination variant under `MAX_DEPTH`, panic-freedom and duplicate rejection
before insertion. A row that is `TESTED` at beta is listed in the release
notes with its bounds; a row that is `OPEN` blocks the tag unless the owner
rules, in writing in that file, that it is out of scope for beta.
. Every trust boundary the proofs rest on is an `ASSUMED` row naming the
dependency and version (serde_json, ryu-js, Rust std). The release notes
repeat that list. The Verus model is reported as a model: it is not a proof
of the shipped code and not a second independent witness (policy §1.2).
. The release notes give the row census with its denominator, per status
token, and never a percentage. Engineering proofs carry no Proof Witness
Grade.

The proof gate is not wired to a workflow yet: no Creusot or Verus image
exists. Until one does, CI runs only the contract syntax check and the gate's
self-test against stub verifiers, and neither is proof evidence.

== Owner checklist

. Merge the pending standards proposal only after its required checks have run
Expand Down
115 changes: 115 additions & 0 deletions scripts/proofs/gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
#
# Proof gate for the Creusot harness in verification/creusot.
#
# The gate passes only if all of these hold:
# 1. the verifier image is pinned by digest (NAME[:TAG]@sha256:<64 hex>);
# 2. the production scope is not empty: every file in
# verification/creusot/SCOPE exists and is included by the harness;
# 3. the tracked tree is clean, so the result describes one revision;
# 4. TRUE control: the verifier accepts the production scope and the true
# controls;
# 5. FALSE control: with the `false-control` feature the verifier refuses,
# and its output names every false control in controls.rs.
# It then writes a receipt that binds the result to the commit and to the
# sha256 of every input file. An accepted false control, or a refusal that
# does not name the false controls, fails the gate.
#
# The verifier invocation (PROOF_VERIFIER_CMD) has NOT been confirmed against
# a real Creusot image: none exists yet in hyperpolymath/prover-images. Until
# it has, this gate has only ever run against the stub in
# scripts/tests/proof-gate-test.sh, and a stub run is not evidence.
set -euo pipefail

root=$(cd "$(dirname "$0")/../.." && pwd)
harness=verification/creusot
receipt=target/proofs/creusot-receipt.json
image=${PROVER_IMAGE:-}
engine=${ENGINE:-podman}
verifier_cmd=${PROOF_VERIFIER_CMD:-cargo creusot prove}
stub=${PROOF_GATE_STUB:-}

while (($#)); do
case $1 in
--root) root=$(cd "$2" && pwd); shift 2 ;;
--receipt) receipt=$2; shift 2 ;;
*) echo "usage: gate.sh [--root DIR] [--receipt FILE]" >&2; exit 2 ;;
esac
done
cd "$root"

fail() { echo "proof-gate: FAIL: $*" >&2; exit 1; }

# 1. Pinned image. A stub run names itself instead and can never be mistaken
# for a verifier run: the receipt records it.
if [[ -n $stub ]]; then
[[ -x $stub ]] || fail "PROOF_GATE_STUB is not executable: $stub"
image="stub:not-a-verifier"
echo "proof-gate: STUB verifier in use; this run is not evidence" >&2
elif [[ ! $image =~ ^[a-z0-9][a-z0-9._/-]*(:[A-Za-z0-9._-]+)?@sha256:[0-9a-f]{64}$ ]]; then
fail "PROVER_IMAGE must be pinned as NAME[:TAG]@sha256:<64 hex>, got '${image}'"
fi

# 2. Non-empty production scope, included by path.
[[ -f $harness/SCOPE ]] || fail "$harness/SCOPE is missing"
mapfile -t scope < <(grep -v '^[[:space:]]*\(#\|$\)' "$harness/SCOPE")
((${#scope[@]} > 0)) || fail "production scope is empty"
for file in "${scope[@]}"; do
[[ -f $file ]] || fail "scope file does not exist: $file"
grep -qF "#[path = \"../../../$file\"]" "$harness/src/lib.rs" \
|| fail "harness does not include $file by path"
done

# The false controls the refusal must name.
mapfile -t false_controls < <(sed -n 's/^pub fn \(false_control_[a-z0-9_]*\)(.*/\1/p' "$harness/src/controls.rs")
((${#false_controls[@]} > 0)) || fail "no false control found in $harness/src/controls.rs"
grep -q '^pub fn true_control_' "$harness/src/controls.rs" || fail "no true control found"

# 3. One revision.
inputs=("${scope[@]}" "$harness/Cargo.toml" "$harness/Cargo.lock" "$harness/src/lib.rs" "$harness/src/controls.rs" "$harness/SCOPE")
commit=$(git rev-parse HEAD) || fail "not a git checkout"
[[ -z $(git status --porcelain -- "${inputs[@]}") ]] || fail "inputs differ from commit $commit"

# Run the verifier in the harness directory. $1 is the control: true or false.
run_verifier() {
local features=()
[[ $1 == false ]] && features=(--features false-control)

Check warning on line 77 in scripts/proofs/gate.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_ijson-jcs&issues=AaIzgEBW4fXp5ZvxLn32&open=AaIzgEBW4fXp5ZvxLn32&pullRequest=54
if [[ -n $stub ]]; then
(cd "$harness" && "$stub" "$1")

Check warning on line 79 in scripts/proofs/gate.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_ijson-jcs&issues=AaIzgEBW4fXp5ZvxLn33&open=AaIzgEBW4fXp5ZvxLn33&pullRequest=54
else
"$engine" run --rm --network none -v "$root:/work:ro" -w "/work/$harness" "$image" \
sh -c "$verifier_cmd ${features[*]}"
fi
}

mkdir -p "$(dirname "$receipt")" target/proofs
rm -f "$receipt"

# 4. TRUE control.
status=0
run_verifier true >target/proofs/true-control.log 2>&1 || status=$?
((status == 0)) || { tail -n 40 target/proofs/true-control.log >&2; fail "verifier refused the production scope (exit $status)"; }

# 5. FALSE control.
status=0
run_verifier false >target/proofs/false-control.log 2>&1 || status=$?
((status != 0)) || fail "verifier ACCEPTED the false controls; the check cannot fail, so it shows nothing"
for control in "${false_controls[@]}"; do
grep -qF "$control" target/proofs/false-control.log \
|| fail "verifier refused, but not because of $control"
done

# Receipt: commit, image, invocation, and the digest of every input.
{
printf '{"commit":"%s","controls":{"false_refused":[' "$commit"
sep=
for control in "${false_controls[@]}"; do printf '%s"%s"' "$sep" "$control"; sep=,; done
printf '],"true_accepted":true},"gate":"creusot","image":"%s","inputs":{' "$image"
sep=
for file in $(printf '%s\n' "${inputs[@]}" | LC_ALL=C sort); do
printf '%s"%s":"%s"' "$sep" "$file" "$(sha256sum "$file" | cut -d' ' -f1)"; sep=,
done
printf '},"invocation":"%s","verifier":"%s"}' "$verifier_cmd" "$([[ -n $stub ]] && echo stub || echo creusot)"
} >"$receipt"
echo "proof-gate: PASS at $commit with $image; receipt $receipt"
94 changes: 94 additions & 0 deletions scripts/tests/proof-gate-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
#
# Firing and silence fixtures for scripts/proofs/gate.sh, run against STUB
# verifiers. This tests the gate's own logic: that it passes on an honest
# verifier and fails on each way a proof gate can be empty or dishonest. It
# runs no prover and is not proof evidence.
set -euo pipefail
cd "$(dirname "$0")/../.."
gate=$PWD/scripts/proofs/gate.sh
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
fail=0

# A throwaway repository holding the gate's inputs at one commit.
fixture() {
local dir=$work/$1
mkdir -p "$dir/src" "$dir/verification"
cp src/jcs_core.rs "$dir/src/"
cp -r verification/creusot "$dir/verification/"
rm -rf "$dir/verification/creusot/target"
git -C "$dir" init -q
git -C "$dir" -c user.name=fixture -c user.email=fixture@example.invalid \
-c commit.gpgsign=false add -A
git -C "$dir" -c user.name=fixture -c user.email=fixture@example.invalid \
-c commit.gpgsign=false commit -q -m fixture
echo "$dir"
}

# Stub verifiers. $1 is "true" or "false" (which control is being run).
stub() {
local path=$work/stub-$1
printf '#!/usr/bin/env bash\n%s\n' "$2" >"$path"
chmod +x "$path"
echo "$path"
}
honest=$(stub honest 'if [[ $1 == false ]]; then echo "error: false_control_ordering: goal not proved"; echo "error: false_control_literal: goal not proved"; exit 1; fi')
accepts_all=$(stub accepts-all 'exit 0')
refuses_all=$(stub refuses-all 'echo "error: toolchain missing"; exit 1')
wrong_reason=$(stub wrong-reason 'if [[ $1 == false ]]; then echo "error: could not compile"; exit 1; fi')
one_control=$(stub one-control 'if [[ $1 == false ]]; then echo "error: false_control_ordering: goal not proved"; exit 1; fi')

# case NAME WANT_EXIT WANT_PHRASE ENV... (run in a fresh fixture, after an
# optional mutation given as MUTATE='shell command run in the fixture').
case_() {
local name=$1 want=$2 phrase=$3 dir got out
shift 3
dir=$(fixture "$name")
if [[ -n ${MUTATE:-} ]]; then (cd "$dir" && eval "$MUTATE"); fi
set +e
out=$(env "$@" bash "$gate" --root "$dir" --receipt "$dir/target/receipt.json" 2>&1)
got=$?
set -e
if [[ $got != "$want" || $out != *"$phrase"* ]]; then
echo "FAIL $name: exit $got (want $want), output: $out" >&2
fail=1
elif [[ $want == 0 && ! -s $dir/target/receipt.json ]]; then
echo "FAIL $name: passed without a receipt" >&2
fail=1
elif [[ $want != 0 && -e $dir/target/receipt.json ]]; then
echo "FAIL $name: failed but left a receipt" >&2
fail=1
else
echo "ok $name"
fi
}

# Silence: an honest verifier passes, and the receipt binds commit and inputs.
case_ honest 0 "proof-gate: PASS" PROOF_GATE_STUB="$honest"
receipt=$work/honest/target/receipt.json
commit=$(git -C "$work/honest" rev-parse HEAD)
digest=$(sha256sum "$work/honest/src/jcs_core.rs" | cut -d' ' -f1)
for want in "\"commit\":\"$commit\"" "\"src/jcs_core.rs\":\"$digest\"" '"verifier":"stub"' \
'"false_refused":["false_control_ordering","false_control_literal"]'; do
grep -qF "$want" "$receipt" || { echo "FAIL receipt lacks $want" >&2; fail=1; }
done

# Firing: each way the gate could be empty or dishonest.
case_ false-control-accepted 1 "ACCEPTED the false controls" PROOF_GATE_STUB="$accepts_all"
case_ true-control-refused 1 "refused the production scope" PROOF_GATE_STUB="$refuses_all"
case_ refused-for-another-reason 1 "but not because of false_control_ordering" PROOF_GATE_STUB="$wrong_reason"
case_ one-false-control-not-refused 1 "but not because of false_control_literal" PROOF_GATE_STUB="$one_control"
case_ image-not-pinned 1 "must be pinned" PROVER_IMAGE="ghcr.io/hyperpolymath/prover-images/creusot:latest"
case_ image-missing 1 "must be pinned"
MUTATE=': >verification/creusot/SCOPE' \
case_ empty-scope 1 "production scope is empty" PROOF_GATE_STUB="$honest"
MUTATE='sed -i "/jcs_core/d" verification/creusot/src/lib.rs' \
case_ scope-not-included 1 "does not include src/jcs_core.rs by path" PROOF_GATE_STUB="$honest"
MUTATE='echo "// edit" >>src/jcs_core.rs' \
case_ dirty-inputs 1 "inputs differ from commit" PROOF_GATE_STUB="$honest"
MUTATE='sed -i "s/^pub fn false_control_/pub fn renamed_/" verification/creusot/src/controls.rs; git -c user.name=f -c user.email=f@example.invalid -c commit.gpgsign=false commit -qam no-controls' \
case_ no-false-control 1 "no false control found" PROOF_GATE_STUB="$honest"

exit "$fail"
41 changes: 37 additions & 4 deletions verification/PROOF-STATUS.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// SPDX-License-Identifier: CC-BY-SA-4.0
= ijson-jcs proof scopes
:revdate: 2026-11-16
:revdate: 2026-12-01

First-party Rust uses Creusot for implementation verification, Pearlite for
contracts and ghost specifications, and complementary Verus models. No proof
receipt for this repository is claimed by this ledger. Every scope below is
OPEN; tests, compilation and imported kyq proofs do not discharge these goals.
contracts and ghost specifications, and complementary Verus models. Pearlite
is Creusot's specification language, not a third verifier, and a Verus model
is not a second independent witness (policy §1.2). No proof receipt for this
repository is claimed by this ledger: no Creusot, Verus or Kani run exists.
Rows are `OPEN`, `TESTED` or `ASSUMED`; none is `PROVEN`. Tests, compilation,
the contract syntax check and imported kyq proofs do not discharge these goals.
Engineering proofs are not graded on the Proof Witness ladder (policy §8.1).

Owner ruling of 2026-12-01: the target is beta with real proofs, and provers
run from the estate's digest-pinned `hyperpolymath/prover-images`, not from
toolchains installed in a session. That repository has Agda and Lean images
only (read at commit `c972dc9`), so no Creusot or Verus obligation has been
run. The beta gate is in `docs/RELEASING.adoc`; the gate script is
`scripts/proofs/gate.sh`.

[cols="2,4,4",options="header"]
|===
Expand Down Expand Up @@ -156,6 +167,28 @@ integer tokens outside ±(2^53−1), `parse_jcs` does not
Only `cargo build`, `cargo test`, `cargo clippy` and `cargo fmt --check` were
run, and they produce `TESTED` evidence at most.

State on 2026-12-01: unchanged. No Creusot, Why3, Verus, Kani, Z3 or CVC5 was
run, by ruling (see the top of this file) and because no pinned image exists.
What did run, and what it is worth:

[cols="3,2,3",options="header"]
|===
|Check |Tool and version |What it shows
|Contract syntax (`verification/creusot/tests/contracts_parse.rs`)
|pearlite-syn 0.15.0, rustc 1.99.1
|The contracts are well-formed Pearlite. Not type-checked; proves nothing.
|Proof gate self-test (`scripts/tests/proof-gate-test.sh`)
|bash, stub verifiers
|The gate passes on an honest verifier and fails in 10 planted cases
(accepted false control, refused true control, refusal for another reason,
one false control not refused, unpinned or missing image, empty scope, scope
not included, dirty inputs, no false control). Not proof evidence.
|===

Kani, restated for the whole repository: `src/lib.rs` and
`src/bin/ijson-jcs.rs` both carry `#![forbid(unsafe_code)]`, and there is no
FFI, so no `unsafe` or FFI seam exists and Kani has no required scope here.

Kani: the crate has `#![forbid(unsafe_code)]` and no FFI in the library, so
there is no seam of the kind policy §4.1 reserves for Kani, and it is not
applicable to `parse_jcs`. A bounded Kani harness on the byte scan in
Expand Down
6 changes: 6 additions & 0 deletions verification/creusot/SCOPE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: MPL-2.0
# Production files the Creusot harness must include by path, one per line,
# relative to the repository root. The proof gate refuses to run when a file
# listed here is missing or is not included by verification/creusot/src/lib.rs,
# so the verified scope cannot silently become empty.
src/jcs_core.rs
Loading