Repository navigation
Exact value sizes: encoded_len, and the specification's size vectors run against the encoders - #118
Merged
Merged
Conversation
added 5 commits
November 11, 2026 07:49
…'s size vectors encoded_len(&value) encodes into a CountBuf, so it is the length of what encode writes by construction, with no allocation (packed@1 stays no_std); JSON and MessagePack write through std::io::Write over the same sink. The conformance crate reads the new `size` op: each witness's value is encoded as the case's type (a new fixed_string, char[N], for it) and must give the witness's bytes exactly, encoded_len must agree, and the case must say what it holds. The sizes-* features are claimed and reported, a proptest checks encoded_len against encode in every format, and each rule a profile's sizes states is checked to be proven by passing cases.
…the rendered form)
…the runtime renders them)
Kinflou
marked this pull request as ready for review
November 11, 2026 00:14
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.
Step 2 of per-format sizing (the plan: exact value sizes, and proof of the specification's size vectors against the real encoders).
Vendors the specification at
9a7142c395b2aefb7d4d77e9b36c74187c6f0199, the merge commit of ComlineProject/specification#4. Its witness bytes came from an independent model of the encoders, not from the runtime, and this PR first proved them against the real runtime while #4 was open (atf3df87b); every one of the 1,049 witnesses matched. The merge commit has the same content.What it adds
WireFormat::encoded_len(&value) -> Result<usize, RuntimeError>, a default method on the trait. It runsencodeinto aCountBuf(the existing countingBufMut: no allocation,no_std), so it is the length of whatencodewrites by construction, and fails asencodedoes (a value over its bounds).json@1andmsgpack@1write throughstd::io::Writeover the sameBufMut, so they count there too; no per-format counter is needed.sizeop in the conformance crate (Op::Size,Input::Size(SizeIn)):bytes;questionsasks the implementation oneencodequestion per witness (as the case'stype), so the ops protocol gains nothing and other runtimes answer the encodes they already do;judgerequires each answer to be exactly the witness's bytes, and the case to be self-consistent (minwitness isminbytes,maxwitnessmaxbytes,betweenin range, nomaxwitness wheremaxisnull);runalso requiresencoded_lento give each witness's length.Type::FixedString { len }for{"fixed_string": {"len": N}}(char[N]), written as a string like the others.sizes-packed,sizes-msgpackandsizes-jsonare claimed insupport/rust.jsonand reported inreports/rust.json. Their vectors are written by the specification, sovectors_are_currentdoesn't regenerate them (a feature of onlysizecases is "proven, not produced").size_rules_are_proven: everyproven_byin a profile'ssizesnames a case that exists and passes.encoded_len(v) == encode(v).len()for random values in each format; a core test for the same and for a bound error.Nothing to revert
origin/mainhas neither thecomline-coredependency nor aformat/size.rsstub (those are only in the local checkout's uncommitted work), so there is nothing to revert here.comline-runtimestays free of core.Cargo.lockis unchanged.Test plan
CI only: the conformance crate's tests (
rust_support_is_proven,size_rules_are_proven,the_runner_passes_the_reference,vectors_write_back_as_read), the reference process replay, the new properties,check.sh.