refactor(rcache): make the index-file wire format public as IndexFile - #689
Conversation
`index.shisha`'s wire format is a contract between everything that reads or writes the remote cache index, but it lived in a private `remote_index` module, so out-of-tree writers (build-bot, building per-commit index snapshots) had to restate the record layout by hand. Export it, and name it for what it is. `RemoteIndex` named the in-memory map; the thing consumers actually need is the file: - `remote_index` -> `index_file`, `RemoteIndex` -> `IndexFile` - `IndexEntry` becomes `pub(crate)` — it appears in no public signature, so making the module public shouldn't leak it - module doc states the format as a contract: a headerless array of 68-byte records (32-byte blake3 key, 4 zero flag bytes, 32-byte sha256), ordered by ascending spec_hash The ordering guarantee is load-bearing: it makes serialization a pure function of the entry set, which callers that sign or digest an index file depend on. No behaviour change — rename plus visibility only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe rcache crate's ChangesIndexFile Rename
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant RemoteCache
participant GCS
participant IndexFile
RemoteCache->>GCS: fetch index object
GCS-->>RemoteCache: 404 or bytes
alt 404 Not Found
RemoteCache->>IndexFile: IndexFile::default()
else bytes returned
RemoteCache->>IndexFile: IndexFile::from_reader(bytes)
end
IndexFile-->>RemoteCache: parsed index
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
Requested by @twitchyliquid64 on build-servers#153: build-bot now writes per-commit
index.shishasnapshots and had to restate the 68-byte record layout by hand, becauseremote_indexis a private module. That duplication is a silent-drift hazard — if this format ever changes, an out-of-tree writer keeps emitting the old bytes.Export it, and name it for what it is (per Tom's steer: "probably with a better name, like wire or index file").
RemoteIndexnamed the in-memory map; what consumers need is the file.remote_index→index_file;RemoteIndex→IndexFileIndexEntry→pub(crate): it appears in no public signature, so making the module public shouldn't leak itspec_hashThe ordering guarantee is called out deliberately: because record order is a pure function of the keys, the same entry set always serializes to identical bytes. Callers that sign an index file (build-servers#86) depend on that, and it's the kind of property that's easy to break by accident once it isn't written down.
Consumers then get
IndexFile::default()+Extend<(SpecHash, [u8; 32])>+write_to(), which is byte-identical to the hand-rolled writer it replaces.No behaviour change — rename plus visibility only. Verified in-sandbox:
cargo check -p rcache,cargo fmt --check -p rcache,cargo test -p rcache(11 passed).I went with
index_file/IndexFileoverwiresince the thing has one canonical on-disk home; happy to switch towireif you prefer.Summary by CodeRabbit
New Features
Bug Fixes