Repository navigation
Description
Problem
The range-sync wire format uses a bound's length byte as a sentinel: 0 means +infinity, anything else is the length of the key prefix that follows (module doc, pkgs/id/src/event_store/range.rs lines 19–24). That makes a zero-length bound unrepresentable — but nothing refuses one. An entry built with upper: Some(vec![]) encodes byte-for-byte identically to upper: None (+infinity), so the encoder silently changes what the entry says, and check_bounds — the documented pre-flight check a caller runs before Party::respond — approves the entry as a finite bound that does not end the flight.
Evidence (pkgs/id/src/event_store/range.rs, main f9268e2; file sha256 identical on the laptop clone at 819889b):
encode_entry(~line 411):Some(b) => { out.push(b.len() as u8); out.extend_from_slice(b); }— withbempty it pushes the0sentinel and no bytes, exactly theNonearm's output.Reader::entry(~line 510):let len = self.byte()? as usize; … let upper = if len == 0 { None } else { Some(…) }— the decoder can never produceSome(vec![]), so the value exists only on the constructing side, where it is silently rewritten.check_bounds(~line 571): treatsSome(bound)as a finite bound — it does not set itsended(+infinity) flag, and an empty bound sorts below every other bound, so[Some([]), Some([1]), None]passes.- Internal producers are safe today only by construction:
Party::separatoralways returns at least one byte, and inbound entries come throughdecode_frame.Entry,frames,check_boundsandParty::respondare the public library surface of/id-range-sync/1, andrespondclones the caller's upper bounds into its answer.
Verified this run (laptop probe, real crate)
Probe: ~/git/fleet/probe-2026-10-30-laneA-zerobound/ (id path dependency, default-features off; range.rs sha256 2e8a2255… matches sandbox main f9268e2):
- Case 1:
frames([Entry { upper: Some(vec![]), mode: Skip }])succeeds (4 wire bytes);decode_framereturns the entry withupper = None; round-trip equality is false.check_boundson the original entry: Ok. - Case 2: the flight
[Some([]), Some([1]), None]passes the sender-sidecheck_bounds; after encode/decode its uppers are[None, Some([1]), None], which the receiver-sidecheck_boundsrejects ("an entry follows +infinity") — a flight the sender's own pre-flight check approved kills the session at the peer. - Case 3:
frames([Some(vec![])])is byte-identical toframes([None]).
Related but distinct: #2595 covers bounds over KEY_LEN (decoder rejection at 73–255, u8 wrap at ≥256). A fix that only refuses len > KEY_LEN does not catch the empty bound — the empty bound is the one length that collides with the format's own sentinel rather than exceeding its limit. This issue tracks that remaining case; the two fixes belong in the same functions (encode_entry/frames and check_bounds).
Why it matters
A bound that silently widens to +infinity changes the meaning of a flight: as the last entry it reconciles the whole remaining key space instead of an empty range; anywhere else it makes the peer reject the flight. Either way the failure surfaces at the wrong layer (a bounds error on the receiver, or a mysteriously widened range), never at the constructor that wrote an unrepresentable value. The module's own pattern is fail-closed at encode time (frame budgets, bound length in the decoder); the empty bound is the one input that slips through because its length is too small, not too large.
Acceptance criteria
frames()(orencode_entry) refuses an entry whose upper bound isSomewith length 0, with an error naming the problem (a bound is a key prefix of 1..=KEY_LEN bytes, orNonefor +infinity).check_boundsalso refuses a zero-length bound, so the documented pre-flight check catches whatrespond()would otherwise clone into its answer and re-encode as +infinity.- Tests cover:
Some(vec![])refused at encode and bycheck_bounds; a 1-byte bound still round-trips;Nonestill encodes as the sentinel. - Existing range.rs tests stay green.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
encode_entrywrites the 0 sentinel forSome(vec![]), the decoder can never produce it, andcheck_boundsapproves it as a finite bound, so a sender-approved flight either widens to the whole key space or is rejected by the receiver's own check_bounds. Verified with a laptop probe against the real crate (range.rs sha256 matches main f9268e2): round-trip of Some(vec![]) returns None, and [Some([]), Some([1]), None] passes sender check_bounds but fails receiver check_bounds after decode. Distinct from id(range-sync): frames() never validates an entry's upper-bound length — bounds over KEY_LEN encode into frames decode_frame itself rejects, ≥256 wraps the u8 length prefix and garbles the entry, and check_bounds approves them all #2595 (bounds over KEY_LEN); the empty bound is the sentinel collision, not the limit.33 remaining items
dezren39 commentedon Nov 2, 2026
agent-note:v1
event: parked
task: 5392 (repo-health-code-pilot, lane A worker shift)
state: parked until 2026-11-02T07:27:07Z — CI pending on PR #4222
progress: fresh revalidation 2026-11-02T07:36Z — PR #4222 OPEN @ 153c5a4; Codex review completed with zero findings; diff is exactly the scoped change (pkgs/id/src/event_store/range.rs, +45/-17). basic + native arm64 checks still QUEUED (runner delay, not failures). The targeted cargo test result from the prior lane never reported, so test verification remains outstanding.
resume: when PR #4222 checks complete green and targeted tests are verified, merge, close #2607, complete task 5392 as fixed_merged.
dezren39 commentedon Nov 2, 2026
agent-note:v1
event: picked_up
task: 5392 (repo-health-code-pilot, lane E worker shift)
state: claimed; resuming PR #4222 from awaiting_ci — CI run 41398870212 still QUEUED since 2026-11-02T06:16Z (runner stall, not a failure); running the targeted test on the laptop to complete verification
resume: merge PR #4222 once targeted tests verified (Codex on head 153c5a4 already completed with zero findings; diff scoped to pkgs/id/src/event_store/range.rs)
id(range-sync): reject empty bounds (#2607) (#4222)
dezren39 commentedon Nov 2, 2026
agent-note:v1
event: done
task: 5392 (repo-health-code-pilot, lane E worker shift)
state: done — fixed_merged. PR #4222 MERGED (squash ddd0d42); #2607 closed.
evidence: laptop cargo test (pkgs/id) range::tests — 20 passed, 0 failed, including test_empty_bounds_are_refused_but_one_byte_and_infinity_round_trip; Codex review on head 153c5a4 completed with zero findings; diff scoped to pkgs/id/src/event_store/range.rs only.
ci note: PR check run 41398870212 was still QUEUED since 2026-11-02T06:16Z at merge time (runner stall, not a failure) — merged under standing merge authority with local test verification; main-tier CI on main will exercise the change.