Skip to content

pallets: rustdoc is the API reference, dead variants removed, both gated in CI - #403

Open
ilchu wants to merge 4 commits into
devfrom
ic/pallet-rustdoc-gate
Open

pallets: rustdoc is the API reference, dead variants removed, both gated in CI#403
ilchu wants to merge 4 commits into
devfrom
ic/pallet-rustdoc-gate

Conversation

@ilchu

@ilchu ilchu commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Rustdoc is the API reference

Every call, error, event, field and runtime-API type in the three pallets now carries a short doc comment written for the end user: what a call does and who may call it, what an error means and how to get past it, what an event reports. That text ships in the runtime metadata, so the PAPI descriptors, the subxt bindings and polkadot.js Apps all show the same words. The pallets set #![warn(missing_docs)], and since the clippy job already runs with -D warnings, an undocumented public item now fails CI. Four intra-doc links to private items and one unescaped generic in a module doc are fixed so cargo doc is clean with warnings denied.

This is the mechanical replacement for the hand-written reference docs, which #406 deletes. The review thread on #372 asked whether those docs were worth keeping; they had described seven extrinsics removed in June and missed the two that replaced them, so the answer was no.

Dead variants

Thirteen error and event variants were declared but never raised or emitted. Seven had been dead since the initial commit; the rest lost their last use when negotiation moved off-chain (#105) and when the challenge flow was overhauled (#125). rustc cannot flag these: the enums are exported API and FRAME's macros reference every variant, so dead_code never applies. They are removed and the subxt and PAPI bindings regenerated from a local paseo dev chain. Error and event indices shift, which is why the bindings commit sits right after the removal.

Two of the removed events, AgreementOwnershipTransferred and ProviderAddedToBucket, were placeholders for features that do not exist. The first comes back with a real emitter in #405. The second belongs to the multi-primary join path that #105 removed and that the design still describes; that is parked and tracked separately.

CI check

scripts/check-dead-variants.sh parses the error and event blocks of each pallet and greps its production sources for a use of every variant; the new check-dead-variants job runs it whenever Rust files change and gates basic-checks. No allowlist: a variant lands in the PR that uses it.

@bkontur

bkontur commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

/aireview

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review — advisory only, not a substitute for human review.

Summary

  • Adds comprehensive rustdoc comments across all calls, errors, events, and types in the storage pallets, enforced via #![warn(missing_docs)].
  • Removes unused error and event variants across pallets and regenerates corresponding Subxt and PAPI runtime bindings.
  • Introduces check-dead-variants.sh and wires it into CI to guard against unused pallet error and event variants.

BalanceOf<T>,
>;

/// v0 → v1: re-encodes every stored `DriveInfo` without its `payment` field.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilchu I would remove all the migrations at this stage (can be a follow-up)

@@ -1,13 +1,22 @@
// SPDX-License-Identifier: Apache-2.0

/// Agreement lifecycle: pricing, opening from signed terms, settlement.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilchu does not this duplicate docs in agreements.rs?


for v in $variants; do
if [ "$kind" = error ]; then
pattern="Error::(<T>::)?$v([^A-Za-z0-9_]|$)"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilchu what about Error::<Test> or Error::<Runtime>?

verb="emitted"
fi
# shellcheck disable=SC2086 # $sources is a whitespace-separated file list
if ! grep -qE "$pattern" $sources; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilchu I am not sure now, maybe we can have variant that is not directly used in the repo or lib, but can be used with some provided implementation in the Fellows repo level (most probably does not happen)

Every call, error, event, field and runtime-API type in the three
pallets now carries a short doc comment written for the end user:
what a call does and who may call it, what an error means and how to
get past it, what an event reports. The text ships in the runtime
metadata, so PAPI descriptors, subxt bindings and polkadot.js Apps
all show the same words.

`#![warn(missing_docs)]` on each pallet crate turns a missing doc
into a CI failure, since clippy runs with `-D warnings`. Four
intra-doc links to private items and one unescaped generic in a
module doc are fixed so `cargo doc` is clean with warnings denied.
Seven storage-provider errors, five storage-provider events and one
drive-registry error were declared but never used. Four errors and
three events had been dead since the initial commit; the rest lost
their last use when agreement negotiation moved off-chain and when
the challenge flow was overhauled.

rustc never flagged them: the enums are exported API, and FRAME's
macros reference every variant, so `dead_code` does not apply. Each
one still occupied a slot in the runtime metadata and a type in every
client's generated bindings.

Removed errors: BucketNotFrozen, NotBucketMember,
ChallengeAlreadyExists, InvalidChallengeProof, LeafBeyondCanonical,
InvalidDeletionProof, InvalidMultiaddr, NotAuthorizedToShare.
Removed events: ProviderAddedToBucket, PrimaryAgreementEndedEarly,
AgreementAccepted, AgreementOwnershipTransferred,
AgreementExpiredClaimed.

Error and event indices shift; the bindings are regenerated in the
next commit.
Refreshed from a local paseo dev chain after the variant removal, so
the generated error and event enums match the runtime again. The
pallet rustdoc now travels with the metadata as well, so the generated
Rust and TypeScript carry the same doc comments as the pallets.
rustc cannot flag them: the enums are exported API and FRAME's macros
reference every variant. scripts/check-dead-variants.sh parses the
`#[pallet::error]` and `#[pallet::event]` blocks and greps each
pallet's production sources for a use; the new `check-dead-variants`
job runs it whenever Rust files change and gates `basic-checks`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants