feat(net): name the req/resp allocation bounds and prove the wire-size theorem - #75
Merged
Conversation
…e theorem Deliver #70: closed-form allocation constants derived from the proven NET-1/NET-2 acceptance bounds, as the basis for an upstream normative preallocation proposal. - varintSize models encode_varint's LEB128 byte count (varint.py); varintSize_le_of_lt_pow bounds it by the 7-bit group count. - MAX_COMPRESSED_PAYLOAD_SIZE (12,234,410 B): snappy worst-case expansion of a maximal in-bound payload, matching the reader gate. - MAX_LENGTH_PREFIX_SIZE (4 B): any accepted declared length encodes in at most 4 varint bytes (128^4 > MAX_PAYLOAD_SIZE). - MAX_REQUEST_WIRE_SIZE (12,234,414 B) with request_wire_bound: for any accepted request, length prefix plus compressed payload fit in the constant — for every decompressor, so a conforming client may preallocate exactly this much per req/resp stream and under-allocation is impossible by theorem.
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
Delivers #70 (promote proven req/resp payload bounds to normative allocation constants).
New file
LeanSpec/Networking/Allocation.lean, building on NET-1/NET-2 (payload_size_bound,compressed_size_bound):varintSize— LEB128 byte count, mirroring upstreamvarint.py'sencode_varint7-bit-group loop, withvarintSize_le_of_lt_pow.MAX_COMPRESSED_PAYLOAD_SIZE= 12 234 410 bytes (rfl-proved closed form): snappy's worst-case expansion (n + n/6 + 1024) of a maximal in-bound payload.MAX_LENGTH_PREFIX_SIZE= 4 bytes: any declared length the reader can accept encodes in ≤ 4 varint bytes (128^4 > MAX_PAYLOAD_SIZE).MAX_REQUEST_WIRE_SIZE= 12 234 414 bytes, with the headline theoremrequest_wire_bound: for any request the reader accepts, varint prefix + compressed payload fit in the constant — for every decompressor (snappy enters the model as a parameter).This is the machine-checked basis for the upstream proposal (spec-feedback.md format): "clients MAY preallocate 12 234 414 bytes per req/resp stream; a conforming reader never buffers more". Under-allocation is impossible by theorem; over-allocation is waste the constant eliminates.
All theorems sorry-free;
lake buildpasses.Closes #70