Repository navigation
Conversation
codec/proto and codec/multiformats each cut a window of Varint.maxBytes bytes before they call Varint.decodeB?. The window now lives in codec/varint as decodeAt?, which answers the value and the position after the varint. Both readVarintAt helpers call it and map its error into their own. The varint suite pins decodeAt? to decode? over the tail from every offset of the generated inputs. Closes etheorem#66
Contributor
|
Good work. This is what #66 asked for: One line still describes the old shape. |
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.
Summary
codec/varintgainsVarint.decodeAt?, the varint reader at an offset of aByteArray.codec/protoandcodec/multiformatsread their varints through it. The window ofVarint.maxBytesbytes now has one home (PRINCIPLES 1.5).Closes #66
What changed
codec/varint:decodeAt? : ByteArray → Nat → Except DecodeError (UVarint × Nat)inVarint/Bytes.lean. It cuts a window of 9 bytes at most and answers the value and the position after the varint. A#guardchecks one read at an offset.codec/proto:Pb.readVarintAtcallsVarint.decodeAt?and maps the error intoError.framing.codec/multiformats:Wire.readVarintAtdoes the same. Its callers inComponentWire,Multihash, andCiddo not change.Tests/Varint.lean: the suite pinsdecodeAt? b postodecode?over the tail frompos. It runs every offset of the prefix and seeded inputs, one past the end included. Two more checks read a varint behind 100 bytes and refuse a continuation run past the budget.packages/codec/varint/docs/ARCHITECTURE.md: the public surface listsdecodeAt?, and the harness paragraph names the offset pin.Streams.Framing.readstays as it is. It reads from aBufReaderthroughr.peek Varint.maxBytes, and the peek already holds the window. It has noByteArrayoffset fordecodeAt?to take.Test plan
lake build(every package, on the pinned toolchain) is green.lake testpasses, and passes again under+RTS -N1.property test, and with a test for its length cap.
and the description names the spec section the change follows.
(PLAN W5.9) is green.
Risk / trust footprint
none
Notes for reviewers
decodeAt?returns the position after the varint, as the tworeadVarintAtcallers used it, anddecodeB?keeps the consumed count. The proto and multiformats suites pin both decoders to their models, so they cover the swap.LICENSE (LGPL version 3)
🤖 Generated with Claude Code