From 7fb032da9b3b39d5d7f3576ecfcfdde6628e240e Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Sun, 22 Mar 2026 17:59:20 +0100 Subject: [PATCH] cli/inspect: Show feature level of sigrefs In order for users to be able to inspect the feature level of Signed References in a repository, have `rad inspect --sigrefs` attempt to load Signed References, and, if successful, print the feature level. --- CHANGELOG.md | 2 ++ crates/radicle-cli/examples/rad-clean.md | 6 ++--- .../examples/rad-id-collaboration.md | 6 ++--- .../examples/rad-id-multi-delegate.md | 6 ++--- .../radicle-cli/examples/rad-id-threshold.md | 6 ++--- crates/radicle-cli/examples/rad-inspect.md | 2 +- crates/radicle-cli/src/commands/inspect.rs | 22 ++++++++++++++++--- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d7d539f..a8d59957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 attacks. Note that this means that a node which upgrades, and subsequently downgrades will appear as a downgrade attacker. +- The `rad inspect --sigrefs` command will now output the feature level of the + signed references entry for each node. ## 1.7.1 diff --git a/crates/radicle-cli/examples/rad-clean.md b/crates/radicle-cli/examples/rad-clean.md index 66f93b16..7187433b 100644 --- a/crates/radicle-cli/examples/rad-clean.md +++ b/crates/radicle-cli/examples/rad-clean.md @@ -18,8 +18,8 @@ Let's also inspect what remotes are in the repository: ``` ~alice $ rad inspect --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 -z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk e9f48ef90fe8592e1b1c95f96c21a59ca1495300 +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 parent +z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk e9f48ef90fe8592e1b1c95f96c21a59ca1495300 parent ``` Now let's clean the `heartwood` project: @@ -34,7 +34,7 @@ Inspecting the remotes again, we see that Bob is now gone: ``` ~alice $ rad inspect --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 parent ``` Note that Bob will be fetched again if we do not untrack his diff --git a/crates/radicle-cli/examples/rad-id-collaboration.md b/crates/radicle-cli/examples/rad-id-collaboration.md index 8320df20..aaf108d8 100644 --- a/crates/radicle-cli/examples/rad-id-collaboration.md +++ b/crates/radicle-cli/examples/rad-id-collaboration.md @@ -162,9 +162,9 @@ $ rad sync --timeout 3s ✓ Fetched repository from 2 seed(s) ✓ Synced with 3 node(s) $ rad inspect rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 1f716870f890be0c13fdd0af9f527af849fec792 -z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk c40018821dc1b41cad75e91e0c9d00827e815324 -z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z 95cd447c57de8d232c6154f5dba0451aa593520e +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 1f716870f890be0c13fdd0af9f527af849fec792 parent +z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk c40018821dc1b41cad75e91e0c9d00827e815324 parent +z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z 95cd447c57de8d232c6154f5dba0451aa593520e parent ``` Since the network is eventually consistent, if Eve decides to `sync` diff --git a/crates/radicle-cli/examples/rad-id-multi-delegate.md b/crates/radicle-cli/examples/rad-id-multi-delegate.md index c297c1c5..882263dc 100644 --- a/crates/radicle-cli/examples/rad-id-multi-delegate.md +++ b/crates/radicle-cli/examples/rad-id-multi-delegate.md @@ -27,9 +27,9 @@ $ rad id --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji │ ● 0656c21 Initial revision alice z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi accepted now │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ $ rad inspect rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi [..] -z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk [..] -z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z [..] +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi [..] parent +z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk [..] parent +z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z [..] parent $ rad inspect rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --delegates did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (alice) did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (bob) diff --git a/crates/radicle-cli/examples/rad-id-threshold.md b/crates/radicle-cli/examples/rad-id-threshold.md index 9ec2800a..8580c522 100644 --- a/crates/radicle-cli/examples/rad-id-threshold.md +++ b/crates/radicle-cli/examples/rad-id-threshold.md @@ -150,7 +150,7 @@ Similarly, she still does not have Bob's `rad/sigrefs`: ``` ~alice $ rad inspect --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi e0e55994a9a234f0b1cd36d8812e2948e2672b7a +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi e0e55994a9a234f0b1cd36d8812e2948e2672b7a parent ``` And she can still list the project, without any worries: @@ -198,6 +198,6 @@ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 2 potential s 🌱 Fetched from z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z 🌱 Fetched from z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk $ rad inspect --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi e0e55994a9a234f0b1cd36d8812e2948e2672b7a -z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk dace6fe948548168a2bb687718949d9b5d9076ee +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi e0e55994a9a234f0b1cd36d8812e2948e2672b7a parent +z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk dace6fe948548168a2bb687718949d9b5d9076ee parent ``` diff --git a/crates/radicle-cli/examples/rad-inspect.md b/crates/radicle-cli/examples/rad-inspect.md index ee8061c6..80761719 100644 --- a/crates/radicle-cli/examples/rad-inspect.md +++ b/crates/radicle-cli/examples/rad-inspect.md @@ -34,7 +34,7 @@ And sigrefs: ``` $ rad inspect --sigrefs -z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 99c549702e2bcfe02b0e68d4a2224fb7a1524529 parent ``` Or display the repository identity's payload and delegates: diff --git a/crates/radicle-cli/src/commands/inspect.rs b/crates/radicle-cli/src/commands/inspect.rs index 9d4fed30..c226c354 100644 --- a/crates/radicle-cli/src/commands/inspect.rs +++ b/crates/radicle-cli/src/commands/inspect.rs @@ -14,7 +14,7 @@ use radicle::identity::{DocAt, Identity}; use radicle::node::policy::SeedingPolicy; use radicle::node::AliasStore as _; use radicle::storage::git::{Repository, Storage}; -use radicle::storage::refs::RefsAt; +use radicle::storage::refs::{FeatureLevel, RefsAt}; use radicle::storage::{ReadRepository, ReadStorage}; use crate::terminal as term; @@ -68,11 +68,27 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> { for remote in repo.remote_ids()? { let remote = remote?; let refs = RefsAt::new(&repo, remote)?; + let sigrefs = refs.load(&repo); println!( - "{:<48} {}", + "{:<48} {} {}", term::format::tertiary(remote.to_human()), - term::format::secondary(refs.at) + term::format::secondary(refs.at), + match sigrefs { + Ok(refs) => { + let level = refs.feature_level(); + let s = level.to_string(); + match level { + FeatureLevel::None => term::format::negative(s), + FeatureLevel::Root => term::format::yellow(s), + FeatureLevel::Parent => term::format::positive(s), + _ => term::format::faint(s), + } + } + Err(err) => { + term::format::negative(err.to_string()) + } + } ); } }