Repository navigation
Description
Goal
Catch unintended breaking changes to our public Rust API by snapshotting it with public_api + insta, so any diff to the exported surface shows up in code review instead of in a downstream consumer's build.
The intended test pattern (for reference, not a prescription):
// Run with `INSTA_UPDATE=always cargo test` to update the public API snapshot
#[test]
fn public_api() {
rustup_toolchain::install(public_api::MINIMUM_NIGHTLY_RUST_VERSION).unwrap();
let rustdoc_json = rustdoc_json::Builder::default()
.toolchain(public_api::MINIMUM_NIGHTLY_RUST_VERSION)
.all_features(true)
.build()
.unwrap();
let public_api = public_api::Builder::from_rustdoc_json(rustdoc_json)
.omit_auto_derived_impls(true)
.omit_auto_trait_impls(true)
.omit_blanket_impls(true)
.build()
.unwrap();
insta::assert_snapshot!(public_api);
}Note: the snippet uses
.unwrap(), which our workspace clippy config denies (unwrap_used). Whoever picks this up will need to either gate the test module so the lint doesn't fire on test-only code, or rewrite with proper error propagation (?+Result<(), Box<dyn Error>>).
What needs to happen
- Decide which crates get the snapshot test.
decdn-protocolis the obvious first target: it's the leaf crate other workspace crates and (eventually) external consumers depend on, and it owns the wire types.cache,gossip,incentive,reputationare candidates once their surfaces stabilize.nodeis a binary, so excluded. - Add dev-dependencies to each in-scope crate:
public-api,rustdoc-json,rustup-toolchain,insta. - Add the test (one per crate) and commit the initial
*.snapbaseline alongside it. - Reconcile with the workspace anti-panic policy — see note above on
.unwrap(). - CI: ensure a nightly toolchain is available on the runner.
rustup_toolchain::installwill fetch it on demand, but the build step is slow (rustdoc JSON generation) — consider caching~/.rustupor pinning the nightly used bypublic_api::MINIMUM_NIGHTLY_RUST_VERSIONinrust-toolchain.tomlor a CI step. - Document the update workflow in
CONTRIBUTING.md: `INSTA_UPDATE=always cargo nextest run -p ` (orcargo insta review) when a public API change is intentional, and that the snapshot diff must appear in the same PR as the API change.
Open questions
- Run with
--all-featuresonly, or also a no-features pass?all_features(true)matches the snippet, but if any crate gets feature-gated public items we may want both. - Do we want a single root-level integration test that walks each crate, or per-crate tests? Per-crate keeps
cargo nextest run -p <crate>self-contained, which matches how the rest of the workspace is structured. - How does this interact with
cargo deny/ pre-commit? Probably no interaction, but worth confirming the new dev-deps don't trip license checks.
Why now
We're still pre-1.0 and breakage is expected, but protocol is already cross-crate load-bearing and any silent change to wire types or ALPN message definitions is exactly the kind of regression that would be cheap to catch here and expensive to debug otherwise.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
alpergundogdu commentedon Apr 27, 2026
Worth flagging: probably premature to land this right now. The crates are still in early implementation —
protocolis the most stable surface and even it's actively gaining wire types — so a snapshot test would diff on nearly every commit and become noise rather than signal. Better to revisit once the public surface of at least one crate (likelyprotocol) has settled enough that an unexpected diff is genuinely a red flag worth reviewing.thiras commentedon May 16, 2026
Stability re-assessment (2026-05-16) — partially unblockable, scope to
protocolRevisiting the "probably premature" concern with data. Conclusion: this is now unblockable for
decdn-protocolonly. The blanket objection ("would diff on nearly every commit") is no longer empirically true forprotocol, but remains fully valid for every other candidate crate.Per-crate stability
pubdecls#3962026-05-05 (rate bound)#2312026-04-17, still growing#4682026-05-08 (EWMA just landed)#5672026-05-15 (voucher persist)#5642026-05-15protocol's last public-signature change was #396 (2026-05-05) — addedMessageValidationError/validate()/MAX_RATE_PER_MB, removedALPN_WATCHTOWER. The last 11 days are docs/ADR-only. Caveat: thegossipsubmodule insideprotocol(NodeAnnounce,GossipEnvelope,LoadHint) was added ~1 month ago (#231) but has been settled since.Note
reputation's low churn is immaturity, not stability — ADR 008 EWMA scoring only just landed (#468). A snapshot there would lock in a surface that's about to grow; don't read the low commit count as "settled".Cross-cutting blockers (independent of crate choice)
rust-toolchain.tomlpins stable 1.95.0 (rustfmt+clippy only).public_apineeds nightly rustdoc-JSON.rustup_toolchain::installfetches on-demand but is slow/uncached — CI needs an explicit pinned nightly step. This is the most concrete remaining blocker..unwrap()chain fails workspace clippy (unwrap_used). Needs?+Result<(), Box<dyn Error>>or a test-module lint gate.cargo deny.public-api,rustdoc-json,rustup-toolchain,instanot in tree today; license/advisory clearance unverified (low risk, unconfirmed).Recommendation
decdn-protocolonly, with nightly pinned in CI (not on-demand) and the anti-panic rewrite.cacheis furthest out — most active crate in the workspace).cargo nextest run -p <crate>.Suggest the
blockedlabel be narrowed/removed and the issue re-scoped toprotocol-only as the first deliverable.test(protocol): public API stability snapshot via public_api + insta (#…
test(protocol): public API stability snapshot via public_api + insta (#…
thiras commentedon May 31, 2026
Implemented in #734 (merged 2026-05-31, commit aaa87a2).
Scoped to
decdn-protocolper the issue's 2026-05-16 re-assessment; other crates remain deferred until their surfaces settle. Delivered:crates/protocol/tests/public_api.rs+ committed baselinecrates/protocol/tests/snapshots/public_api__public_api.snappublic-api,rustdoc-json,insta) via[workspace.dependencies]public-api-testfeature +required-featurestarget so it stays out of the defaultcargo nextest --workspacerun?+Result, nounwrap); stable toolchain viaRUSTC_BOOTSTRAP=1(no nightly)public-apiCI job, wired intoci-successtest(protocol): update public-API snapshot for StreamRequest.byte_len…
feat(cache,protocol): range origin pull-through — ADR decision + bao …