Skip to content

Check member order after sorting instead of trusting the sort (breaking: new error variant) - #57

Draft
hyperpolymath wants to merge 1 commit into
claude/beta-proof-readerfrom
claude/beta-member-order
Draft

hyperpolymath wants to merge 1 commit into
claude/beta-proof-readerfrom
claude/beta-member-order

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

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

Owner ruling of 2026-12-01. write_object_jcs sorts members with
slice::sort_by and then requires their keys to be strictly increasing in
UTF-16 code-unit order (jcs_core::strictly_increasing, with a Pearlite
contract); otherwise it returns CanonicalizationError::MemberOrder. The
trusted part of the sort shrinks to its being a permutation.

BREAKING: CanonicalizationError gains the variant MemberOrder; the enum
is not non_exhaustive. Recorded in the new CHANGELOG.adoc.

Members are now collected once as (key bytes, value) pairs, which also
removes the per-key map lookup. No verifier has been run; J-6 stays OPEN.

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

gitnotebooks Bot commented Dec 2, 2026

Copy link
Copy Markdown

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

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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: a9c4ac13-b941-40a1-b3f9-c206fa6a8ae7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

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