Title: id(range-sync): a zero-length upper bound encodes as +infinity — Some(vec![]) is the one bound length the sentinel swallows, and check_bounds approves it as finite · Issue #2607 · developing-today/code · GitHub
Open Graph Title: id(range-sync): a zero-length upper bound encodes as +infinity — Some(vec![]) is the one bound length the sentinel swallows, and check_bounds approves it as finite · Issue #2607 · developing-today/code
X Title: id(range-sync): a zero-length upper bound encodes as +infinity — Some(vec![]) is the one bound length the sentinel swallows, and check_bounds approves it as finite · Issue #2607 · developing-today/code
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-leng...
Open Graph 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...
X 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/r...
Opengraph URL: https://github.com/developing-today/code/issues/2607
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(range-sync): a zero-length upper bound encodes as +infinity — Some(vec![]) is the one bound length the sentinel swallows, and check_bounds approves it as finite","articleBody":"## Problem\n\nThe 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.\n\nEvidence (pkgs/id/src/event_store/range.rs, main f9268e24; file sha256 identical on the laptop clone at 819889bb):\n\n- `encode_entry` (~line 411): `Some(b) => { out.push(b.len() as u8); out.extend_from_slice(b); }` — with `b` empty it pushes the `0` sentinel and no bytes, exactly the `None` arm's output.\n- `Reader::entry` (~line 510): `let len = self.byte()? as usize; … let upper = if len == 0 { None } else { Some(…) }` — the decoder can never produce `Some(vec![])`, so the value exists only on the constructing side, where it is silently rewritten.\n- `check_bounds` (~line 571): treats `Some(bound)` as a finite bound — it does not set its `ended` (+infinity) flag, and an empty bound sorts below every other bound, so `[Some([]), Some([1]), None]` passes.\n- Internal producers are safe today only by construction: `Party::separator` always returns at least one byte, and inbound entries come through `decode_frame`. `Entry`, `frames`, `check_bounds` and `Party::respond` are the public library surface of `/id-range-sync/1`, and `respond` clones the caller's upper bounds into its answer.\n\n## Verified this run (laptop probe, real crate)\n\nProbe: ~/git/fleet/probe-2026-10-30-laneA-zerobound/ (`id` path dependency, default-features off; range.rs sha256 2e8a2255… matches sandbox main f9268e24):\n\n- Case 1: `frames([Entry { upper: Some(vec![]), mode: Skip }])` succeeds (4 wire bytes); `decode_frame` returns the entry with `upper = None`; round-trip equality is **false**. `check_bounds` on the original entry: Ok.\n- Case 2: the flight `[Some([]), Some([1]), None]` passes the sender-side `check_bounds`; after encode/decode its uppers are `[None, Some([1]), None]`, which the receiver-side `check_bounds` **rejects** (\"an entry follows +infinity\") — a flight the sender's own pre-flight check approved kills the session at the peer.\n- Case 3: `frames([Some(vec![])])` is byte-identical to `frames([None])`.\n\nRelated 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`).\n\n## Why it matters\n\nA 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.\n\n## Acceptance criteria\n\n- `frames()` (or `encode_entry`) refuses an entry whose upper bound is `Some` with length 0, with an error naming the problem (a bound is a key prefix of 1..=KEY_LEN bytes, or `None` for +infinity).\n- `check_bounds` also refuses a zero-length bound, so the documented pre-flight check catches what `respond()` would otherwise clone into its answer and re-encode as +infinity.\n- Tests cover: `Some(vec![])` refused at encode and by `check_bounds`; a 1-byte bound still round-trips; `None` still encodes as the sentinel.\n- Existing range.rs tests stay green.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-30T06:47:48Z","url":"https://github.com/developing-today/code/issues/2607"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ade6702d-a3e9-1df2-0a0b-e1cf2a7de4c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FE4:32B444:55D80:72A54:6B07585D |
| html-safe-nonce | c36985e96eaf47bfeeb0c6dd2751747af4bf0be9be75e62a6bd1801d03d63916 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkU0OjMyQjQ0NDo1NUQ4MDo3MkE1NDo2QjA3NTg1RCIsInZpc2l0b3JfaWQiOiI3MzQ5MjEzMzg3NzQ0MDQxMDUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 80d4bd290d895e11eacd7e859a6e46f837f1d86cd64efd05900f293879b03ec4 |
| hovercard-subject-tag | issue:6114594696 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/2607/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aff823d0cf42acb07bd539fbf4827ead59a54478fa7f96807628d48c8e0c0610/developing-today/code/issues/2607 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aff823d0cf42acb07bd539fbf4827ead59a54478fa7f96807628d48c8e0c0610/developing-today/code/issues/2607 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | e8a742cfa7d479a227a6a6e03ec8d1b3f77f746d4752d7d11136b478718b9658 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7bda31a5f68d83542e3adebba328d48747c5f604 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width