Skip to content

Proofs (jcs): first-party key ordering and escaping with Pearlite contracts and a Verus model, not yet run - #53

Merged
hyperpolymath merged 4 commits into
mainfrom
claude/beta-proof-jcs
Dec 2, 2026
Merged

hyperpolymath merged 4 commits into
mainfrom
claude/beta-proof-jcs

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Proof module 1 of the beta track: src/jcs.rs. No verifier has been run. The owner ruled that provers run from the pinned hyperpolymath/prover-images, which has no Creusot or Verus image yet, so every proof row in this PR is OPEN. What this PR does is make the code provable, write the contracts, and give executed TESTED evidence that behaviour is unchanged.

Design decision (for the owner)

Key ordering used str::encode_utf16().cmp() and escaping used serde_json::to_string. Neither can be given more than an assumed contract in Creusot, so a proof "on the production code" would have proved almost nothing first-party.

  • Implemented, and my recommendation (most elegant and correct): move both into src/jcs_core.rs, a dependency-free byte-level module. UTF-16 code-unit order on well-formed UTF-8 is plain byte order after one permutation of the byte values EE..=F4; escaping only ever touches bytes below 0x20, " and \. Both become short loops over &[u8] that Creusot handles directly, and the trusted base for these two properties shrinks to "a str is UTF-8".
  • Alternative, most conservative: leave the code alone and record assumed contracts for encode_utf16 and serde_json::to_string. Zero production change; the two properties stay ASSUMED for good.
  • Further option not taken here: after sorting keys, check by a linear scan that they are strictly increasing, and refuse otherwise. That would prove member order without trusting sort_by (creusot-std 0.15.0 has no contract for it), at the cost of a new error path. Needs an owner ruling because it touches the public error enum.

What is in the PR

Path Content
src/jcs_core.rs cmp_utf16, write_string_literal, Pearlite contracts and lemmas behind cfg(creusot), differential unit tests
src/jcs.rs calls the core; std::cmp::Ordering import and the serde_json escaping calls removed
verification/creusot/ harness crate that includes src/jcs_core.rs by path; controls.rs has 2 true controls and 2 false controls (feature false-control); tests/contracts_parse.rs is a syntax check
verification/verus/jcs_model.rs Verus model of the same definitions
verification/PROOF-STATUS.adoc new section with rows J-1 to J-9 and assumptions A-1 to A-5
Cargo.toml check-cfg for cfg(creusot) only; no new dependency in the shipped crate

The Verus file is a separately written model. Per policy §1.2 a Verus result on it would not be a proof of the production code and is not a second independent witness: one author, one specification, SMT solvers on both sides.

Evidence (executed here, rustc 1.99.1, Linux x86_64)

Check Result
cargo test --locked --all-features 166 passed, 0 failed
cargo test --locked --lib jcs_core (differential, vs the old implementation) 6 passed
Escaping: every Unicode scalar value vs serde_json::to_string 1,112,064 values, all equal
Ordering: every scalar value vs 29 boundary values, both argument orders, vs encode_utf16().cmp() all equal
Ordering: all 1,111 strings of up to 3 characters over 10 boundary characters, pairwise all equal
Planted mutants of src/jcs_core.rs (false control for the tests) 5 of 5 fail the tests
cargo test --manifest-path verification/creusot/Cargo.toml (pearlite-syn 0.15.0) 33 + 4 contract terms parse; 3 malformed terms refused
cargo clippy --locked --all-targets --all-features -- -D warnings, cargo fmt --check clean
cargo bench --locked, median of 9, canonical-object-v1 1,228,646 ns before, 997,985 ns after (one local run each; not a baseline)
scripts/proven-coverage.sh no new uncovered line; one new unreachable exclusion (bytes F5..FF); still exits 1 for the pre-existing parse_jcs lines reported in #50

Not executed: Creusot, Why3, Verus, Z3, CVC5, Kani. No image digests exist to cite. The pearlite-syn check is syntax only: it does not type-check the contracts, and I expect some to need adjustment on first contact with the verifier (lemma bodies are empty; Seq equalities may need ext_eq hints). MSRV, macOS and Windows jobs were not run locally.

Kani: not applicable. #[forbid(unsafe_code)] holds in the library and the binary and there is no FFI.

Row census

Denominator: the 9 obligations J-1 to J-9 added to PROOF-STATUS.adoc.

Token Count Rows
PROVEN 0
PROVEN-WITH-AXIOMS 0
TESTED 3 J-3 UTF-16 conformance, J-5 escape table, J-9 number rendering
ASSUMED 0
OPEN 6 J-1, J-2, J-4, J-6, J-7, J-8

Assumptions recorded: 5 (serde_json, ryu-js, sort_by, i64::to_string, str is UTF-8), all ASSUMED. Engineering proofs are not PWG-graded.

Open points

  • J-3 (the permutation trick really is UTF-16 order) is tested exhaustively only for single characters against a boundary set and for short strings. A proof needs a first-party model of UTF-8 and UTF-16 encoding, because creusot-std's char::to_utf8 is opaque. This is the hardest remaining statement and may be better stated once as theory.
  • creusot-std is LGPL-2.1-or-later. It is a dependency of the harness only and is not linked into ijson-jcs. No licence file was touched.
  • Independent of Holes first: fail closed under serde_json arbitrary_precision; no CLI panic on unwritable stderr #50; the two touch different lines of .proven/coverage-exclusions.tsv.

Generated by Claude Code

…ts (not yet run)

Move UTF-16 key ordering and string escaping out of str::encode_utf16 and
serde_json::to_string into src/jcs_core.rs, a dependency-free byte-level
module, so both properties can be proved on shipped code.

- cmp_utf16: lexicographic byte order after one permutation of EE..F4,
  which is UTF-16 code-unit order on well-formed UTF-8.
- write_string_literal: RFC 8785 section 3.2.2.2 escaping, per byte.
- Pearlite contracts behind cfg(creusot), written against creusot-std
  0.15.0. No verifier has been run; every proof row is OPEN.
- verification/creusot: harness that includes the production file by path,
  with true and false controls, and a pearlite-syn syntax check.
- verification/verus/jcs_model.rs: a model of the same definitions, not run.
- Differential tests: exhaustive over all scalar values for escaping and
  against a boundary set for ordering; counted tests for the new lines.
- verification/PROOF-STATUS.adoc: ledger section for the canonical writer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDfneftEg71bUadt3v3
@gitnotebooks

gitnotebooks Bot commented Dec 1, 2026

Copy link
Copy Markdown

Review these changes at https://app.gitnotebooks.com/hyperpolymath/ijson-jcs/pull/53

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4d1a1e0c-a674-497b-b6f4-f65f8744e8cd
Commits

Reviewing files that changed from the base of the PR and between da2269a and 9338e73.

Files ignored due to path filters: 2

  • .proven/coverage-exclusions.tsv is excluded by !**/*.tsv
  • verification/creusot/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 17

  • .github/workflows/ci.yml
  • Cargo.toml
  • docs/RELEASING.adoc
  • scripts/proofs/gate.sh
  • scripts/tests/proof-gate-test.sh
  • src/jcs.rs
  • src/jcs_core.rs
  • src/lib.rs
  • tests/proven_mutation_kills.rs
  • verification/PROOF-STATUS.adoc
  • verification/creusot/Cargo.toml
  • verification/creusot/README.adoc
  • verification/creusot/SCOPE
  • verification/creusot/src/controls.rs
  • verification/creusot/src/lib.rs
  • verification/creusot/tests/contracts_parse.rs
  • verification/verus/jcs_model.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

… the beta gate definition (#54)

Stacked on #53 (base branch `claude/beta-proof-jcs`), because the gate
runs the harness that PR adds. Review #53 first.

**No prover has run.** This PR adds the gate that will run one, tests
the gate's own logic, and defines the beta gate. The proof gate is
deliberately not wired to a workflow: no Creusot or Verus image exists
in `hyperpolymath/prover-images` (Agda and Lean only, read at
`c972dc9`).

## What is in the PR

| Path | Content |
|---|---|
| `scripts/proofs/gate.sh` | The proof gate |
| `verification/creusot/SCOPE` | The production files the harness must
include by path |
| `scripts/tests/proof-gate-test.sh` | Fixtures for the gate, against
stub verifiers |
| `.github/workflows/ci.yml` | Two steps: contract syntax check, gate
self-test. Both named as not evidence |
| `docs/RELEASING.adoc` | "What beta means" and the beta gates, beside
the preview gates |
| `verification/PROOF-STATUS.adoc` | Owner ruling, verifier state on
2026-12-01, Kani statement |

## What the gate requires

1. `PROVER_IMAGE` pinned as `NAME[:TAG]@sha256:<64 hex>`.
2. A non-empty production scope: every file in `SCOPE` exists and is
included by path in the harness.
3. Inputs identical to the commit.
4. True control: the verifier accepts the production scope and the true
controls.
5. False control: with `--features false-control` the verifier refuses,
and its output names every false control.

It then writes a receipt (canonical I-JSON, checked with this
repository's own `ijson-jcs check --profile library`) holding the
commit, the image, the invocation and the sha256 of each input. A stub
run writes `"verifier":"stub"` and the beta gate rejects that.

## Evidence (executed here)

`bash scripts/tests/proof-gate-test.sh`: 11 of 11 cases behave as
required.

| Case | Expected | Result |
|---|---|---|
| honest stub | pass, receipt has commit, input digest, both refused
controls | ok |
| stub accepts everything | fail: false controls accepted | ok |
| stub refuses everything | fail: production scope refused | ok |
| refusal that names no control | fail | ok |
| refusal that names one of two controls | fail | ok |
| image by tag only | fail | ok |
| no image | fail | ok |
| empty `SCOPE` | fail | ok |
| harness no longer includes the production file | fail | ok |
| input edited after the commit | fail | ok |
| false controls removed | fail | ok |

Also: `cargo test --locked --all-features` 166 passed, 0 failed; harness
syntax check 2 passed. `shellcheck` is not installed here, so the two
scripts were not linted.

## Not done, stated plainly

- The verifier invocation (`PROOF_VERIFIER_CMD`, default `cargo creusot
prove`) is a guess until an image exists. The gate has only ever run
against stubs.
- The check that a refusal "names the false control" greps the
verifier's output. The real output format is unknown; it may need
tightening so a control named in a passing line does not count.
- No Verus gate yet; it follows the same shape once an image exists.
- No workflow runs the real gate. Unwired is not done.

## Row census

Denominator: the 9 obligations J-1 to J-9 from #53. This PR changes
none: `PROVEN` 0, `TESTED` 3, `OPEN` 6. It adds no proof evidence.

## For the owner

The beta gate text in `docs/RELEASING.adoc` is a proposal: in particular
which rows must be `PROVEN` for beta (I named J-1, J-2, J-4, J-6, J-7
and the reader's termination, panic-freedom and duplicate rejection),
and that an `OPEN` row blocks the tag unless ruled out of scope in
writing.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ng: new error variant) (#57)

Owner ruling of 2026-12-01 (hardening a): prove member order instead of
trusting `sort_by`. Stacked on #55 (base `claude/beta-proof-reader`),
the top of the #53 → #54 → #55 stack.

## Breaking change

`CanonicalizationError` gains a variant, `MemberOrder`. The enum is not
`#[non_exhaustive]`, so downstream code that matches it without a
wildcard arm stops compiling. This lands before any 0.1 tag, as ruled,
and is recorded in a new `CHANGELOG.adoc`.

## Change

`write_object_jcs` still sorts with `slice::sort_by`, but then calls
`jcs_core::strictly_increasing` and returns `MemberOrder` unless every
adjacent pair of keys is in strict UTF-16 order. Under a strict total
order, a strictly increasing sequence is the one sorted arrangement of
its keys, so anything written is in canonical order. What is trusted of
the sort shrinks from "sorted" to "a permutation of its input"
(assumption A-3, reworded).

Members are collected once as `(key bytes, value)` pairs, which removes
the per-key map lookup. No input is known to trigger the new error.

## Evidence (rustc 1.99.1)

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 170 passed, 0 failed |
| Must-fail controls:
`strictly_increasing_refuses_disorder_and_repeats`,
`test_member_order_is_certified_not_trusted` | 9 disordered or repeated
key sequences refused, including a pair sorted as UTF-8 but not as
UTF-16 |
| Planted mutants of the check | 2 of 2 fail the tests |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 6 contract terms parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | two new `unreachable` exclusions (the
refusal and the `return false`), each named with the unit test that
executes it; no other new uncovered line |
| `cargo bench --locked`, `canonical-object-v1`, median of 9 | 858,880
ns (997,985 ns on #53; one local run each, not a baseline) |

One thing the tests cannot show: deleting the call to
`certify_member_order` would not fail any test, because the standard
sort never returns disorder. That call is three lines read by eye; the
check it calls is what carries the contract.

No verifier has been run.

## Ledger

`J-6` (members written in strictly increasing order): status stays
`OPEN`; scope now names `strictly_increasing` and its contract, and says
which three lines are outside Creusot's scope. `A-3` narrowed to
"permutation". Census unchanged: 16 obligations, `PROVEN` 0, `TESTED` 8,
`OPEN` 8; 7 `ASSUMED` boundaries.

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <noreply@anthropic.com>
@hyperpolymath
hyperpolymath marked this pull request as ready for review December 2, 2026 22:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T22:57:16.564988Z 789685b Draft marked ready
🔒 Security Review ✅ Completed 2026-12-02T22:56:28.567692Z 789685b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) December 2, 2026 22:52
hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ndering evidence (not yet run) (#58)

Stacked on #57 (base `claude/beta-member-order`), the top of the #53 →
#54 → #55 → #57 stack. Follows the owner rulings of 2026-12-02: beta
covers every ledger surface; keep the integer fast path and prove it;
specify tests, do not prove them.

**No verifier has been run.** Nothing here is `PROVEN`.

## What is in the PR

| Path | Content |
|---|---|
| `src/framing_core.rs` | `matches_canonical` (the canonical bytes,
optionally plus one line feed) and `line_end` (where a line stops),
dependency-free, with Pearlite contracts behind `cfg(creusot)` |
| `src/profile.rs`, `src/records.rs` | call the core; behaviour
unchanged |
| `verification/creusot/` | includes the new file by path; one more true
control and one more false control; `SCOPE` and the gate self-test
follow |
| `tests/integer_rendering.rs` | J-9 evidence: integer fast path against
the ryu-js path |
| `verification/PROOF-STATUS.adoc` | new sections: profiles and framing
(F-1 to F-6), command-line tool (C-1 to C-5, boundary A-8), and a table
giving each test file's oracle, inputs and what a pass shows |

Not written, by agreement with the hub until the first Creusot run:
contracts on `classify`, `Records::parse`, `canonicalize_records`, the
JSON-LD entry point and the whole CLI, and the `std::fs` / `std::io`
boundary specification (A-8). Their rows exist and say so.

## Evidence (executed here, rustc 1.99.1)

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 177 passed, 0 failed |
| `matches_canonical` against the previous rule | all pairs of 364 short
byte strings, both settings, equal |
| `line_end` and the record splitter against the previous splitter |
every start in those strings; 3,280 inputs; equal |
| Planted mutants of `src/framing_core.rs` | 4 of 4 fail the tests |
| `tests/integer_rendering.rs` | exhaustive for magnitudes up to 2^17,
±8 around powers of two and ten, 200,000 sampled: fast path and ryu-js
path give the same bytes |
| Wider run of the same comparison (scratch program, not committed;
ryu-js 1.0.3) | 134,217,729 exhaustive, 18,448 boundary and 200,000,000
sampled values, all equal; fast path 26.0 vs 43.8 ns per value on large
integers, 17.3 vs 53.6 on small ones (one machine, one run) |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 13 + 8 contract terms
parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | no new uncovered line; one counted test
added to reach the mismatch branch through `classify` |

While writing `matches_canonical` I introduced and caught a subtraction
that would have underflowed on an empty input; the test for it
(`matches_canonical(b"", b"{}", true)`) is in the file.

## Row census

Denominator: 27 obligations across the four sections (J 9, R 7, F 6, C
5).

| Token | Count |
|---|---|
| `PROVEN` | 0 |
| `PROVEN-WITH-AXIOMS` | 0 |
| `TESTED` | 19 |
| `ASSUMED` | 0 |
| `OPEN` | 8 |

Trust boundaries: 8, all `ASSUMED`; A-8 (`std::fs`, `std::io`) has no
written specification yet. Under the beta gate, `TESTED` blocks a tag
exactly as `OPEN` does, so all 27 remain to be proved. Engineering
proofs are not PWG-graded.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@hyperpolymath
hyperpolymath merged commit 723343f into main Dec 2, 2026
7 of 9 checks passed
@hyperpolymath
hyperpolymath deleted the claude/beta-proof-jcs branch December 2, 2026 22:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 789685b34c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proofs/gate.sh
Comment on lines +81 to +82
"$engine" run --rm --network none -v "$root:/work:ro" -w "/work/$harness" "$image" \
sh -c "$verifier_cmd ${features[*]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provide a writable Cargo target directory

The real-verifier path mounts the entire repository at /work read-only and then runs Cargo from /work/verification/creusot, so a default cargo creusot prove cannot create its target directory or other build artifacts and the true-control run fails before verification. I checked cargo build --help, which describes --target-dir as the “Directory for all generated artifacts”; set that directory to writable container storage or mount a writable target volume while keeping the source read-only.

Useful? React with 👍 / 👎.

Comment thread scripts/proofs/gate.sh
Comment on lines +98 to +100
for control in "${false_controls[@]}"; do
grep -qF "$control" target/proofs/false-control.log \
|| fail "verifier refused, but not because of $control"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require proof-failure diagnostics for false controls

Any nonzero exit passes this check as long as both function names occur somewhere in the log; for example, a verifier stub that prints both names, then reports a missing solver and exits 1 is accepted. Thus an infrastructure, compilation, or type-checking failure can produce a successful proof receipt without demonstrating that the verifier rejected either false proposition, contrary to the gate's stated negative-control guarantee. Validate structured verifier goal failures, including the absence of unrelated fatal errors, rather than matching name substrings.

Useful? React with 👍 / 👎.

Comment thread scripts/proofs/gate.sh
Comment on lines +69 to +72
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind the proof gate implementation to the receipt

The cleanliness check and receipt inputs omit scripts/proofs/gate.sh itself, so running a locally modified gate still records the unmodified HEAD commit and can emit a receipt that appears to describe that committed revision. This also contradicts the script's claim that the tracked tree is clean for the result. Include the gate script among the checked and hashed inputs, or reject all tracked modifications before invoking the verifier.

Useful? React with 👍 / 👎.

Comment thread scripts/proofs/gate.sh
Comment on lines +60 to +61
grep -qF "#[path = \"../../../$file\"]" "$harness/src/lib.rs" \
|| fail "harness does not include $file by path"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify that scope paths are active Rust modules

This substring check also accepts a path attribute inside a comment or string, so the harness can stop compiling a file listed in SCOPE while the gate still claims that file was verified and includes its digest in the receipt. For example, replacing the active module declaration with // #[path = "../../../src/jcs_core.rs"] satisfies this test; if the controls are adjusted to compile independently, the real verifier can pass without reading the production file. Parse the harness or otherwise validate an active path-qualified module declaration rather than grepping its text.

Useful? React with 👍 / 👎.

Comment thread scripts/proofs/gate.sh
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)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape configurable values when writing the JSON receipt

PROOF_VERIFIER_CMD is an arbitrary shell command, but it is interpolated directly into a quoted JSON string. A legitimate invocation containing a double quote or backslash, such as one with a quoted argument, therefore makes the supposedly successful receipt invalid JSON even though verification passed. Generate the receipt through a JSON serializer, or correctly escape every interpolated string before writing it.

Useful? React with 👍 / 👎.

Comment thread scripts/proofs/gate.sh
receipt=target/proofs/creusot-receipt.json
image=${PROVER_IMAGE:-}
engine=${ENGINE:-podman}
verifier_cmd=${PROOF_VERIFIER_CMD:-cargo creusot prove}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Report the verifier that was actually executed

PROOF_VERIFIER_CMD may name any command, yet every non-stub receipt unconditionally records "verifier":"creusot". A wrapper or different executable that returns success for the true run and a name-bearing failure for the false run therefore produces a receipt satisfying the beta check that verifier is not stub, even though Creusot never ran. Restrict the override to an audited Creusot invocation or derive and validate the verifier identity recorded in the receipt from the executable actually launched.

Useful? React with 👍 / 👎.

hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ng: new error variant) (#57)

Owner ruling of 2026-12-01 (hardening a): prove member order instead of
trusting `sort_by`. Stacked on #55 (base `claude/beta-proof-reader`),
the top of the #53 → #54 → #55 stack.

`CanonicalizationError` gains a variant, `MemberOrder`. The enum is not
`#[non_exhaustive]`, so downstream code that matches it without a
wildcard arm stops compiling. This lands before any 0.1 tag, as ruled,
and is recorded in a new `CHANGELOG.adoc`.

`write_object_jcs` still sorts with `slice::sort_by`, but then calls
`jcs_core::strictly_increasing` and returns `MemberOrder` unless every
adjacent pair of keys is in strict UTF-16 order. Under a strict total
order, a strictly increasing sequence is the one sorted arrangement of
its keys, so anything written is in canonical order. What is trusted of
the sort shrinks from "sorted" to "a permutation of its input"
(assumption A-3, reworded).

Members are collected once as `(key bytes, value)` pairs, which removes
the per-key map lookup. No input is known to trigger the new error.

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 170 passed, 0 failed |
| Must-fail controls:
`strictly_increasing_refuses_disorder_and_repeats`,
`test_member_order_is_certified_not_trusted` | 9 disordered or repeated
key sequences refused, including a pair sorted as UTF-8 but not as
UTF-16 |
| Planted mutants of the check | 2 of 2 fail the tests |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 6 contract terms parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | two new `unreachable` exclusions (the
refusal and the `return false`), each named with the unit test that
executes it; no other new uncovered line |
| `cargo bench --locked`, `canonical-object-v1`, median of 9 | 858,880
ns (997,985 ns on #53; one local run each, not a baseline) |

One thing the tests cannot show: deleting the call to
`certify_member_order` would not fail any test, because the standard
sort never returns disorder. That call is three lines read by eye; the
check it calls is what carries the contract.

No verifier has been run.

`J-6` (members written in strictly increasing order): status stays
`OPEN`; scope now names `strictly_increasing` and its contract, and says
which three lines are outside Creusot's scope. `A-3` narrowed to
"permutation". Census unchanged: 16 obligations, `PROVEN` 0, `TESTED` 8,
`OPEN` 8; 7 `ASSUMED` boundaries.

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ndering evidence (not yet run) (#58)

Stacked on #57 (base `claude/beta-member-order`), the top of the #53 →
#54 → #55 → #57 stack. Follows the owner rulings of 2026-12-02: beta
covers every ledger surface; keep the integer fast path and prove it;
specify tests, do not prove them.

**No verifier has been run.** Nothing here is `PROVEN`.

## What is in the PR

| Path | Content |
|---|---|
| `src/framing_core.rs` | `matches_canonical` (the canonical bytes,
optionally plus one line feed) and `line_end` (where a line stops),
dependency-free, with Pearlite contracts behind `cfg(creusot)` |
| `src/profile.rs`, `src/records.rs` | call the core; behaviour
unchanged |
| `verification/creusot/` | includes the new file by path; one more true
control and one more false control; `SCOPE` and the gate self-test
follow |
| `tests/integer_rendering.rs` | J-9 evidence: integer fast path against
the ryu-js path |
| `verification/PROOF-STATUS.adoc` | new sections: profiles and framing
(F-1 to F-6), command-line tool (C-1 to C-5, boundary A-8), and a table
giving each test file's oracle, inputs and what a pass shows |

Not written, by agreement with the hub until the first Creusot run:
contracts on `classify`, `Records::parse`, `canonicalize_records`, the
JSON-LD entry point and the whole CLI, and the `std::fs` / `std::io`
boundary specification (A-8). Their rows exist and say so.

## Evidence (executed here, rustc 1.99.1)

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 177 passed, 0 failed |
| `matches_canonical` against the previous rule | all pairs of 364 short
byte strings, both settings, equal |
| `line_end` and the record splitter against the previous splitter |
every start in those strings; 3,280 inputs; equal |
| Planted mutants of `src/framing_core.rs` | 4 of 4 fail the tests |
| `tests/integer_rendering.rs` | exhaustive for magnitudes up to 2^17,
±8 around powers of two and ten, 200,000 sampled: fast path and ryu-js
path give the same bytes |
| Wider run of the same comparison (scratch program, not committed;
ryu-js 1.0.3) | 134,217,729 exhaustive, 18,448 boundary and 200,000,000
sampled values, all equal; fast path 26.0 vs 43.8 ns per value on large
integers, 17.3 vs 53.6 on small ones (one machine, one run) |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 13 + 8 contract terms
parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | no new uncovered line; one counted test
added to reach the mismatch branch through `classify` |

While writing `matches_canonical` I introduced and caught a subtraction
that would have underflowed on an empty input; the test for it
(`matches_canonical(b"", b"{}", true)`) is in the file.

## Row census

Denominator: 27 obligations across the four sections (J 9, R 7, F 6, C
5).

| Token | Count |
|---|---|
| `PROVEN` | 0 |
| `PROVEN-WITH-AXIOMS` | 0 |
| `TESTED` | 19 |
| `ASSUMED` | 0 |
| `OPEN` | 8 |

Trust boundaries: 8, all `ASSUMED`; A-8 (`std::fs`, `std::io`) has no
written specification yet. Under the beta gate, `TESTED` blocks a tag
exactly as `OPEN` does, so all 27 remain to be proved. Engineering
proofs are not PWG-graded.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ng: new error variant) (#57)

Owner ruling of 2026-12-01 (hardening a): prove member order instead of
trusting `sort_by`. Stacked on #55 (base `claude/beta-proof-reader`),
the top of the #53 → #54 → #55 stack.

`CanonicalizationError` gains a variant, `MemberOrder`. The enum is not
`#[non_exhaustive]`, so downstream code that matches it without a
wildcard arm stops compiling. This lands before any 0.1 tag, as ruled,
and is recorded in a new `CHANGELOG.adoc`.

`write_object_jcs` still sorts with `slice::sort_by`, but then calls
`jcs_core::strictly_increasing` and returns `MemberOrder` unless every
adjacent pair of keys is in strict UTF-16 order. Under a strict total
order, a strictly increasing sequence is the one sorted arrangement of
its keys, so anything written is in canonical order. What is trusted of
the sort shrinks from "sorted" to "a permutation of its input"
(assumption A-3, reworded).

Members are collected once as `(key bytes, value)` pairs, which removes
the per-key map lookup. No input is known to trigger the new error.

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 170 passed, 0 failed |
| Must-fail controls:
`strictly_increasing_refuses_disorder_and_repeats`,
`test_member_order_is_certified_not_trusted` | 9 disordered or repeated
key sequences refused, including a pair sorted as UTF-8 but not as
UTF-16 |
| Planted mutants of the check | 2 of 2 fail the tests |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 6 contract terms parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | two new `unreachable` exclusions (the
refusal and the `return false`), each named with the unit test that
executes it; no other new uncovered line |
| `cargo bench --locked`, `canonical-object-v1`, median of 9 | 858,880
ns (997,985 ns on #53; one local run each, not a baseline) |

One thing the tests cannot show: deleting the call to
`certify_member_order` would not fail any test, because the standard
sort never returns disorder. That call is three lines read by eye; the
check it calls is what carries the contract.

No verifier has been run.

`J-6` (members written in strictly increasing order): status stays
`OPEN`; scope now names `strictly_increasing` and its contract, and says
which three lines are outside Creusot's scope. `A-3` narrowed to
"permutation". Census unchanged: 16 obligations, `PROVEN` 0, `TESTED` 8,
`OPEN` 8; 7 `ASSUMED` boundaries.

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Dec 2, 2026
…ndering evidence (not yet run) (#58)

Stacked on #57 (base `claude/beta-member-order`), the top of the #53 →
#54 → #55 → #57 stack. Follows the owner rulings of 2026-12-02: beta
covers every ledger surface; keep the integer fast path and prove it;
specify tests, do not prove them.

**No verifier has been run.** Nothing here is `PROVEN`.

## What is in the PR

| Path | Content |
|---|---|
| `src/framing_core.rs` | `matches_canonical` (the canonical bytes,
optionally plus one line feed) and `line_end` (where a line stops),
dependency-free, with Pearlite contracts behind `cfg(creusot)` |
| `src/profile.rs`, `src/records.rs` | call the core; behaviour
unchanged |
| `verification/creusot/` | includes the new file by path; one more true
control and one more false control; `SCOPE` and the gate self-test
follow |
| `tests/integer_rendering.rs` | J-9 evidence: integer fast path against
the ryu-js path |
| `verification/PROOF-STATUS.adoc` | new sections: profiles and framing
(F-1 to F-6), command-line tool (C-1 to C-5, boundary A-8), and a table
giving each test file's oracle, inputs and what a pass shows |

Not written, by agreement with the hub until the first Creusot run:
contracts on `classify`, `Records::parse`, `canonicalize_records`, the
JSON-LD entry point and the whole CLI, and the `std::fs` / `std::io`
boundary specification (A-8). Their rows exist and say so.

## Evidence (executed here, rustc 1.99.1)

| Check | Result |
|---|---|
| `cargo test --locked --all-features` | 177 passed, 0 failed |
| `matches_canonical` against the previous rule | all pairs of 364 short
byte strings, both settings, equal |
| `line_end` and the record splitter against the previous splitter |
every start in those strings; 3,280 inputs; equal |
| Planted mutants of `src/framing_core.rs` | 4 of 4 fail the tests |
| `tests/integer_rendering.rs` | exhaustive for magnitudes up to 2^17,
±8 around powers of two and ten, 200,000 sampled: fast path and ryu-js
path give the same bytes |
| Wider run of the same comparison (scratch program, not committed;
ryu-js 1.0.3) | 134,217,729 exhaustive, 18,448 boundary and 200,000,000
sampled values, all equal; fast path 26.0 vs 43.8 ns per value on large
integers, 17.3 vs 53.6 on small ones (one machine, one run) |
| pearlite-syn 0.15.0 syntax check | 37 + 7 + 13 + 8 contract terms
parse |
| `scripts/tests/proof-gate-test.sh` (stub verifiers) | 11 of 11 cases |
| clippy `-D warnings`, `cargo fmt --check` | clean |
| `scripts/proven-coverage.sh` | no new uncovered line; one counted test
added to reach the mismatch branch through `classify` |

While writing `matches_canonical` I introduced and caught a subtraction
that would have underflowed on an empty input; the test for it
(`matches_canonical(b"", b"{}", true)`) is in the file.

## Row census

Denominator: 27 obligations across the four sections (J 9, R 7, F 6, C
5).

| Token | Count |
|---|---|
| `PROVEN` | 0 |
| `PROVEN-WITH-AXIOMS` | 0 |
| `TESTED` | 19 |
| `ASSUMED` | 0 |
| `OPEN` | 8 |

Trust boundaries: 8, all `ASSUMED`; A-8 (`std::fs`, `std::io`) has no
written specification yet. Under the beta gate, `TESTED` blocks a tag
exactly as `OPEN` does, so all 27 remain to be proved. Engineering
proofs are not PWG-graded.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants