Skip to content

feat: permission annotations in Rust doc comments and codegen#209

Open
filvecchiato wants to merge 2 commits into
mainfrom
docs/permission-requirements
Open

feat: permission annotations in Rust doc comments and codegen#209
filvecchiato wants to merge 2 commits into
mainfrom
docs/permission-requirements

Conversation

@filvecchiato

@filvecchiato filvecchiato commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Embeds # Permissions sections in API trait method doc comments (rust/crates/truapi/src/api/*.rs) declaring each method's authentication, prompt, permission gate, and denial error requirements
  • Extends truapi-codegen to parse # Permissions from rustdoc JSON and emit permissions metadata in generated TypeScript service descriptors
  • Adds MethodPermissions type to services-types.ts for downstream consumers (explorer, playground)
  • Includes docs/host-permission-requirements.md — the canonical permission matrix covering all ~55 TrUAPI methods across four tiers

Methods with no permission requirements carry no annotation. Annotated methods declare a combination of auth, prompt, permission, and denial_error keys.

Test plan

  • cargo build --workspace compiles cleanly
  • cargo clippy --workspace --all-targets --all-features -- -D warnings passes
  • cargo test --workspace passes
  • ./scripts/codegen.sh regenerates TS with permissions objects in services.ts
  • Verify generated permissions appear correctly in deployed explorer/playground

@filvecchiato filvecchiato requested a review from a team June 10, 2026 14:17

@pgherveou pgherveou left a comment

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.

not sure the audit files belong here.
they should probably be issues in the related repo instead.

We should think of a way to automate this.
e2e tests should validate that permission gated methods show the permission modal on top of checking the results

Comment thread docs/host-permission-requirements.md
Comment thread dotli-permission-audit.md Outdated
Comment thread dotli-permission-audit.md Outdated
@filvecchiato

Copy link
Copy Markdown
Collaborator Author

Host-specific permission compliance issues filed:

  • paritytech/dotli#545
  • paritytech/polkadot-desktop#616
  • paritytech/polkadot-app-android-v2#849
  • paritytech/polkadot-app-ios-v2#1108

@filvecchiato filvecchiato force-pushed the docs/permission-requirements branch 4 times, most recently from 8b33234 to d520726 Compare June 11, 2026 19:25

@pgherveou pgherveou left a comment

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.

We should really add these information directly in the rust docstring, so that host that implement it can get the information directly from the definitions.

We can then, extract that to enrich the explorer with these informations.
I believe that will be easier to consume from the explorer than searching markdown in the repo

Comment thread dotli-permission-audit.md Outdated
@filvecchiato filvecchiato force-pushed the docs/permission-requirements branch from ff535b3 to d28d214 Compare June 22, 2026 09:40
@filvecchiato filvecchiato changed the title docs: TrUAPI host permission requirements matrix feat: permission annotations in Rust doc comments and codegen Jun 22, 2026
Embed `# Permissions` sections in API trait method doc comments so
hosts can extract permission requirements directly from the rustdoc
JSON output. The codegen pipeline parses these sections and emits
`permissions` metadata in the generated TypeScript playground/explorer
service descriptors.

Methods with no permission requirements carry no `# Permissions`
section at all. Annotated methods declare a combination of:
- **auth**: whether authentication is required
- **prompt**: user-facing confirmation dialog
- **permission**: named permission gate (RemotePermission/DevicePermission)
- **denial_error**: error variant returned on denial

Includes `docs/host-permission-requirements.md` — the canonical
permission matrix for all TrUAPI methods across tiers.
@filvecchiato filvecchiato force-pushed the docs/permission-requirements branch from d28d214 to fd47c43 Compare June 22, 2026 09:41
@filvecchiato filvecchiato requested a review from pgherveou June 22, 2026 11:27
@filvecchiato filvecchiato enabled auto-merge June 23, 2026 07:50
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