Repository navigation
Proofs (jcs): first-party key ordering and escaping with Pearlite contracts and a Verus model, not yet run - #53
Draft
hyperpolymath wants to merge 1 commit into
Draft
hyperpolymath wants to merge 1 commit into
hyperpolymath wants to merge 1 commit into
Conversation
…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
|
Review these changes at https://app.gitnotebooks.com/hyperpolymath/ijson-jcs/pull/53 |
|
Warning Review limit reachedYou'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 47 minutes. View limit details
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. |
|
❌ The last analysis has failed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proof module 1 of the beta track:
src/jcs.rs. No verifier has been run. The owner ruled that provers run from the pinnedhyperpolymath/prover-images, which has no Creusot or Verus image yet, so every proof row in this PR isOPEN. What this PR does is make the code provable, write the contracts, and give executedTESTEDevidence that behaviour is unchanged.Design decision (for the owner)
Key ordering used
str::encode_utf16().cmp()and escaping usedserde_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.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 valuesEE..=F4; escaping only ever touches bytes below0x20,"and\. Both become short loops over&[u8]that Creusot handles directly, and the trusted base for these two properties shrinks to "astris UTF-8".encode_utf16andserde_json::to_string. Zero production change; the two properties stayASSUMEDfor good.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
src/jcs_core.rscmp_utf16,write_string_literal, Pearlite contracts and lemmas behindcfg(creusot), differential unit testssrc/jcs.rsstd::cmp::Orderingimport and the serde_json escaping calls removedverification/creusot/src/jcs_core.rsby path;controls.rshas 2 true controls and 2 false controls (featurefalse-control);tests/contracts_parse.rsis a syntax checkverification/verus/jcs_model.rsverification/PROOF-STATUS.adocCargo.tomlcheck-cfgforcfg(creusot)only; no new dependency in the shipped crateThe 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)
cargo test --locked --all-featurescargo test --locked --lib jcs_core(differential, vs the old implementation)serde_json::to_stringencode_utf16().cmp()src/jcs_core.rs(false control for the tests)cargo test --manifest-path verification/creusot/Cargo.toml(pearlite-syn 0.15.0)cargo clippy --locked --all-targets --all-features -- -D warnings,cargo fmt --checkcargo bench --locked, median of 9,canonical-object-v1scripts/proven-coverage.shunreachableexclusion (bytesF5..FF); still exits 1 for the pre-existingparse_jcslines reported in #50Not 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;
Seqequalities may needext_eqhints). 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.PROVENPROVEN-WITH-AXIOMSTESTEDASSUMEDOPENAssumptions recorded: 5 (serde_json, ryu-js,
sort_by,i64::to_string,stris UTF-8), allASSUMED. Engineering proofs are not PWG-graded.Open points
char::to_utf8is opaque. This is the hardest remaining statement and may be better stated once as theory.ijson-jcs. No licence file was touched..proven/coverage-exclusions.tsv.Generated by Claude Code