Commit Graph

787 Commits

Author SHA1 Message Date
Fintan Halpenny 7c92360842 radicle: fix to schemars of DefaultSeedingPolicy
Use `flatten` to remove the extraneous `Scope2` that shows up in the
JSON schema of the Radicle `Config`.
2026-03-05 15:32:44 +01:00
Fintan Halpenny 6291cae592 cli: add `rad config schema` to the `rad-config` test
Adds the `rad config schema` to the `rad-config` test so that changes
to the schema will result in errors, forcing the implementor to ensure
the changes are correct.
2026-03-05 15:32:44 +01:00
Fintan Halpenny f018b434cb node: control debug serialization of FetcherState
Use proxy structs to control the serialized output of `FetcherState`.

These structs convert data inside the `FetcherState` into friendlier
output for the caller of `rad node debug`.
2026-03-05 15:29:42 +01:00
Fintan Halpenny 9ea1ea2433 Revert "node/debug: Use derived serializers"
This reverts commit 5099c25df7.

The `HostName` of the `RateLimiter` could serialize as an invalid JSON
key, resulting in the command panicking.
2026-03-05 15:29:42 +01:00
Defelo e9245b630d cli: don't override existing seeding scope in `rad clone` 2026-02-23 22:34:03 +00:00
Fintan Halpenny b04f487b3a term: Update to 0.17.0 2026-02-20 14:09:35 +00:00
Fintan Halpenny bab3f82abd fetch: Update to 0.17.0 2026-02-20 14:04:16 +00:00
Fintan Halpenny a0b434c320 localtime: add description in Cargo.toml
The description is required for publishing the crate.
2026-02-20 13:48:14 +00:00
Fintan Halpenny 9dba9130f8 core: use "data-types" instead of "data types"
From the reference[^0]:

> Note: crates.io allows a maximum of 5 keywords. Each keyword must be
> ASCII text, have at most 20 characters, start with an alphanumeric
> character, and only contain letters, numbers, _, - or +.

[0]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-keywords-field
2026-02-20 13:38:34 +00:00
Fintan Halpenny f9a36ef7ac systemd: Update to 0.12.0 2026-02-20 13:11:50 +00:00
Fintan Halpenny 18d6ce9477 protocol: Update 0.5.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny c0ae5e32d9 node: Update to 0.17.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny 963b4ded2b crypto: Update to 0.15.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny 84e9ffe4dc cob: Update to 0.18.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny 186d8d30fe cli: Update to 0.18.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny 3a11074600 radicle: Update to 0.21.0 2026-02-19 21:06:43 +01:00
Fintan Halpenny 1566646762 radcile/cob/identity: mark ApplyError as non_exhaustive 2026-02-19 21:06:43 +01:00
Lorenz Leutgeb 30701cc6fb node/runtime: Make `Runtime::run` more readable
A small refactoring that reorders arms of a match and makes them shorter
by precise imports.
2026-02-18 09:36:49 +00:00
Lorenz Leutgeb 057edf55b8 node/reactor: Introduce `LAG_TIMEOUT`
Since the service performs further I/O (e.g. uses SQLite), it can keep
the reactor runtime thread busy for long periods. Emit a warning if that
is the case.

100 ms is quite relaxed, this is to only catch severe cases and avoid
spamming the log.
2026-02-18 09:36:49 +00:00
Lorenz Leutgeb ae06111e07 node/reactor: Rewrite `Runtime::run`
More commentary and slight refactoring in `Runtime::run` to improve
readability.
2026-02-18 09:36:49 +00:00
Lorenz Leutgeb 4d7b942b75
remote-helper: Rename `to_branch_name`
Since `to_branch_name` consumes `self`, it should better be called
`into_branch_name`.

See also
<https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention>.
2026-02-18 00:07:49 +01:00
Lorenz Leutgeb 6d2a99e1ae
remote-helper: Remove Unused Error Variants
Previous minimization of visibility modifiers enables automated
removal of these unused variants.
2026-02-18 00:07:49 +01:00
Lorenz Leutgeb a69420b9b7
remote-helper: Rework Visibility Modifiers
Since this is a binary crate, `pub` is not necessary. By removing `pub`
at the boundary of the crate (`src/main.rs`) and working our way in we
obtain tighter boundaries. This enables dead-code elimination and more
liberal lints (see following two commits).
2026-02-18 00:07:49 +01:00
Adrian Duke d36ed7c8af remote-helper/protocol: Introduce Line and Command
A new module to model the domain of protocol lines and commands
being exchanged is introduced.

This is to increase readability and to pave the way for a
future sans I/O version of the binary crate.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2026-02-18 00:07:35 +01:00
Adrian Duke 27493c2229 remote-helper/service: Introduce `NodeSession`
Prefactor to add a trait capturing behaviour of the node.
2026-02-18 00:04:14 +01:00
Adrian Duke 56253b529e remote-helper/service: Introduce `GitService`
Prefactor to introduce `trait GitService` around the behaviour of
`fetch_pack` and `send_pack`.
2026-02-18 00:03:00 +01:00
Adrian Duke bd30e80b9a remote-helper/list: Remove printing to stdio
Prefactor to aid testing.
2026-02-18 00:00:14 +01:00
Lorenz Leutgeb 119445ce6c
cli-test: Move `let mut args` closer to its uses
In case a `cd` command is to be processed, no replacement of
environment variables in arguments is performed. This means that the
definition of `let mut args` and the replacement itself can be moved
closer to where `args` is then actually used, which is easier to
reason about.
2026-02-17 20:19:26 +01:00
Lorenz Leutgeb 56ece480ee
cli-test: Remove special handling for `rad`
The special handling for `rad` was introduced in commit
`e63f33489055962845c70976bd9a40d0d84c6b1c` without further comment.

Since we control the `$PATH` for spawning `rad`, and it is clear
that `rad` must be on the path, we do not need any special handing.

See also:
 - https://doc.rust-lang.org/std/process/struct.Command.html#method.new
 - https://github.com/rust-lang/rust/issues/15149
 - https://github.com/rust-lang/rust/issues/37519
2026-02-17 20:16:29 +01:00
Lorenz Leutgeb 3cd1af1dd5
cli-test: Configure `escargot` properly
Configuration calls to `escargot` were removed in commit `4894657b`.
An unintentional consequence are spurious failures to invoke freshly
compiled binaries in CLI tests.

Bring back the explicit configuration to remedy.
2026-02-17 18:59:59 +01:00
Lorenz Leutgeb 5aca9bf16a
cli-test: Refactor Path Handling
In the previous refactoring in commit `4894657b`, the order of entries
in `$PATH` was changed unintentionally. Revisit the order and use
nicer APIs to handle paths.
2026-02-17 18:59:59 +01:00
Adrian Duke d88ef3fa66 e2e: Introduce 3 tests for block command
1. It disconnects an active connection.
2. A blocked peer can not connect to us.
3. A blocked peer can not be fetched from.
2026-02-17 16:12:04 +01:00
Fintan Halpenny a4806f2718 node/test: check remote events for `Event::PeerDisconnected`
The node being connected to may be blocking the connecting node.
In this case the service will emit an event that says the connecting
node is disconnected.

Check the events for this event as well as `Event::PeerConnected`.
2026-02-17 16:12:04 +01:00
Adrian Duke 1fa14ef529 protocol/service: Use block list for connections
The service learns to consult the policies database to check if a
`NodeId` is blocked.

When a node is blocked the service will prevent any inbound or
outbound connection.

In the case of an inbound connection, a disconnect must be submitted
to the reactor.

In the case of an outbound connection, nodes are filtered out from any
connection lists, and prevented from submitting a connect to the
reactor.
2026-02-17 16:12:04 +01:00
Adrian Duke 94e0a5128d node: Add block command to control socket
Introduces the ability to explicitly block a peer via the node control
socket. Previously, the node only exposed follow and unfollow commands.
While the underlying policy database schema supported a Block variant,
there was no mechanism to trigger this state via the client handle.

The new block command:

 1. Updates the node's follow policy to Block.
 2. Immediately disconnects the peer if a session is active.
2026-02-17 16:12:04 +01:00
Fintan Halpenny 4286590fd9 fetch: move `Component::from` outside of loop
The previous code would convert the `remote` into a `Component` on
each iteration of the loop.

The conversion now happens outside of the loop and can be reused.
2026-02-17 15:47:31 +01:00
Lorenz Leutgeb 0e9d7607e4 hooks: Enable typos, fix reported errors 2026-02-17 11:35:28 +00:00
Lorenz Leutgeb 5fa68ed814
node: Use `gix_packetline`
`gix-packetline` already is in the dependency closure of `radicle-node`.
Use the well-tested and -used reader instead of ours.
2026-02-16 21:42:59 +01:00
Adrian Duke c96aea0699 node/e2e: Fix test_non_fastforward_identity_doc
This test was flakey.
2026-02-16 21:39:11 +01:00
Adrian Duke 832598ceb7 cli: Warn user about implicit seeding policy
To prepare for future changes, warn users if their config file currently
does not explicitly specify a default seeding policy.

Because there are now potentially multiple warnings generated that all
relate to the configuration file, group these together and adjust the
wording to be more uniform.
2026-02-16 21:39:11 +01:00
Adrian Duke cee3659ed5 radicle: Introduce `radicle::node::config::Scope`
The `SeedingPolicy` type now requires a `Scope`, however existing
configurations allow it to not be specified.

Introduce a `radicle::node::config::Scope` type that allows for an
optional `policy::Scope`. The default value resolves to
`policy::Scope::All`. This preserves backwards compatibility for
existing configurations.
2026-02-16 21:39:11 +01:00
Adrian Duke 306d0afbfe protocol: Note on peering and fetches
As part of the work to change the default scope, one of the tests
surfaced an issue where the topology was Alice <--> Bob <--> Eve,
however because of the previous 'all' scope Alice could receive Eve
references via Bob, but since the scope was changed to 'follow' Alice
would need to have a direct connection to Eve. TODO left here for future
consideration.
2026-02-16 21:39:11 +01:00
Adrian Duke 0684d1ccdf cli: Changed the default scope from all to followed for clone and seed
The previous implementation used 'all' as the default for scope, this
could lead to surprising behaviour where a user would fetch all
references for cloned and seeded repositories. Instead have a progressive,
safe by default value - where it fetches only 'followed' references. Later
a user can decide to set the scope to 'all'. NOTE: the default policy
scope was not changed from 'all' and is intended to be changed at a
later date.
2026-02-16 21:39:11 +01:00
Adrian Duke dd13eed1d0 cli: Do not print scope in block table
Previous implementation used the default scope when a scope wasn't
present. Scope is not present when the policy is block, because block
doesn't have a scope. Instead use an empty string when printing the
block policy.
2026-02-16 21:39:11 +01:00
Adrian Duke b5e8776efd fetch: Improve `refs/rad/id` resolution
The previous resolution would favour one `Oid` over another, due to
the call to `Option::or`.

This was found to result in scenarios where an identity document being
advertised was older than the identity document that the fetching node
already has, and would not fetch namespaces by newly added delegates.

The resolution logic is updated to handle all cases for these `Oid`s,
and when they are both present, uses a commit graph check to see which
one is the latest.

An e2e test is added to check ensure behaviour works correctly.
2026-02-16 21:39:11 +01:00
Fintan Halpenny 84320919e2 node/tests/e2e: use assert_eq! in test
The use of `assert_eq!` will highlight the differences in the two
values when it fails.
2026-02-16 17:13:39 +00:00
Fintan Halpenny 7862e108b6 Update gix-* crates
Fixes [CVE-2026-0810].

The `gix` crates require updating due to the security vulnerability above.
They require updating together in lock-step so both `radicle-fetch`
and `radicle-oid` are affected.

`radicle-oid` handles the non-exhaustive nature of `ObjectId`.

`radicle-fetch` updates to the new API types, however, this comes with
some updates to the `ls_refs` protocol.

A regression is documented in [gitoxide issue 2429].
The regression highlighted that it is the duty of the caller to also
filter the outcome of ls-refs, and `ref-prefix` is simply an
optimisation.

The ls-refs code is refactored to better represent and handle this operation.

[CVE-2026-0810]: https://www.cve.org/CVERecord?id=CVE-2026-0810
[gitoxide issue 2429]: https://github.com/GitoxideLabs/gitoxide/issues/2429
2026-02-16 17:13:39 +00:00
Fintan Halpenny 391571178e fetch: introduce domain type RefPrefix
Better represent the domain by introducing the `RefPrefix` type.
It captures the different `ref-prefix` values that can be used in the
`ls-refs` step of the protocol.

These are turned into their equivalent `ref-prefix` values using
`RefPrefix::into_bstring`.

This better connects the `ProtocolStage::ls_refs` method with the
`ls_refs::run` through the use of the `RefPrefix` type, rather than
any set of `BString` values.
2026-02-16 17:11:32 +00:00
Fintan Halpenny 8070f98a5b fetch/transport/ls_refs: Post-filter of references
The Git protocol specification states about `ls-refs`[^1]:

>    ref-prefix <prefix>
> When specified, only references having a prefix matching one of
> the provided prefixes are displayed. Multiple instances may be
> given, in which case references matching any prefix will be
> shown. Note that this is purely for optimization; a server MAY
> show refs not matching the prefix if it chooses, and clients
> should filter the result themselves.

The `ref-prefix` arguments should not be relied on and post-filtering
after the ls-refs invocation should also be performed.

[^1]: https://git-scm.com/docs/protocol-v2#_ls_refs
2026-02-16 17:10:40 +00:00
Fintan Halpenny 980ed56186 protocol/service: rename `Responder::new` to `Responder::oneshot`
The `Responder` is a oneshot channel where it sends one result and the
other side receives that result.

This surfaced that the `AnnounceRefs` command was returning one result
at a time. At the moment, this is only used for a single namespace,
the local user's.
2026-02-16 13:33:00 +01:00
Fintan Halpenny 0d628a45e2 protocol: refactor to use Responder
Refactors every command that uses a `Sender` to use a `Responder`
instead. There is an exception for `QueryState` since its usage
differs slightly to the other cases.

To make the usage more ergonomic, constructors for the variants that
require a `Responder` are added.
2026-02-16 13:33:00 +01:00
Fintan Halpenny b1eedd3b64 protocol/service: introduce Responder type
Introduce a `Responder` type that wraps a
`crossbeam_channel::Sender<Result<T>>`.

It provides a standard constructor and three sending methods: one for
a `Result`, one for an `Ok` value, and one for an `Err` value.
2026-02-16 13:25:58 +01:00
Fintan Halpenny 61a9b2140f protocol/service: introduce Result synonym
Create a type synonym for `Result<T, Error>`, to simplify result types
being returned by commands in a later change.
2026-02-16 13:25:58 +01:00
Fintan Halpenny 2c1972151d protocol: opaque command error
Refactor `CommandError` to be an opaque, boxed error.
Rename it to `Error`, so that it is imported via `command::Error`.
2026-02-16 13:25:58 +01:00
Fintan Halpenny 38713a8e62 protocol/service: drop `chan` qualifier
Small refactor to drop the `chan` qualifier and use `Sender` directly.
2026-02-16 13:25:58 +01:00
Fintan Halpenny 912a5ca42b protocol/service: create command module
Create a `command` module to house the command related types.
2026-02-16 13:25:58 +01:00
Lorenz Leutgeb fa94638abb radicle/storage/init: Remove placeholder files
These files contain stub texts (see added reference) and only clutter
storage.
2026-02-16 11:16:30 +00:00
Lorenz Leutgeb 7425ae4b49 ssh: Treat "connection refused" on Windows
Slightly relax the conditions under which an error is considered to
indicate that the SSH agent is not running, to accommodate differences
in the API of named pipes on Windows vs. Unix domain sockets.
2026-02-16 09:47:08 +00:00
Lorenz Leutgeb 5099c25df7 node/debug: Use derived serializers
The construction of the debug object is unwieldy, and error prone
(for example, renamed struct members have to be manually renamed
in the serialization code, see "refs" vs. "refsAt").

Use derived serializers where possible to make this easier to maintain.
2026-02-16 09:43:38 +00:00
Lorenz Leutgeb a1fa38018e protocol: Depend on `cypheraddr` not `cyphernet`
`radicle-protocol` depends on `cyphernet`, but only uses the module
`cyphernet::addr`, which is a re-export of `cypheraddr`, which is
unnecessary (as `cypheraddr` alone would do), and invites accidentally
pulling in more dependencies via `cyphernet`.

To prevent accidentally depending on further types from `cyphernet`,
change this to more conservativeley depend on `cypheraddr`.
2026-02-16 09:43:38 +00:00
Lorenz Leutgeb d530f1265e node/test: Remove unused file `environment.rs` 2026-02-16 09:38:37 +00:00
Lorenz Leutgeb 730d696d74 node/test: Bind to loopback interface 2026-02-16 09:38:37 +00:00
Lorenz Leutgeb dfe3b501c7 radicle/git/raw: `Config` not used on Windows
Fix a clippy lint that sneaked in…
2026-02-16 09:24:05 +00:00
Lorenz Leutgeb ed2b36cf9c cli-test: Log line of assertion being executed 2026-02-16 08:39:55 +00:00
Lorenz Leutgeb 9055a2043c cli-test: Add placeholder for executable extension
Help text generated by `clap` contains the full file name (including
extension) of the binary. On Unix-like systems, binaries commonly do not
have any file extension. On Windows, ".exe" is common.

To allow testing such output, introduce a new marker "[EXE]" that is 
substituted accordingly. The idea and syntax is taken from
https://docs.rs/trycmd/1.0.0/trycmd/#toml
2026-02-16 08:39:55 +00:00
Lorenz Leutgeb e831aeb57b cli-test: Do not store `bins` 2026-02-16 08:39:55 +00:00
Lorenz Leutgeb 8fbdd46ce4 cli-test: Cheat to find coreutils on Windows 2026-02-16 08:39:55 +00:00
Lorenz Leutgeb 4894657bcb cli-test: Simplify cargo path handling 2026-02-16 08:39:55 +00:00
Lorenz Leutgeb 25d1974c60 cli-test: Deduplicate populating `bins` 2026-02-16 08:39:55 +00:00
Lorenz Leutgeb 44f52f4c18 cli-test: Fix uses of `PATH_SEPARATOR`
Some occurrences of ":" literals were missed earlier.
2026-02-16 08:39:55 +00:00
Lorenz Leutgeb dd122f10cf cli/test: Ignore `rad_diff` on Windows
The command is deprecated already.
2026-02-16 08:37:20 +00:00
Fintan Halpenny 2d0db3c6b2 CVE-2025-58160
Report: <https://www.cve.org/CVERecord?id=CVE-2025-58160>

This vulnerability was introduced via the `test-log` crate.

Updating to `0.2.19` in turn updates `tracing-subscriber` to `0.3.22`
which is in the acceptable upgrade range.
2026-02-13 17:26:50 +00:00
Lorenz Leutgeb 03bbe52417 signals: Add support for Windows 2026-02-13 15:38:02 +00:00
Lorenz Leutgeb 865abd35e2
protocol/fetcher: Intro `RefsToFetch`
Using empty `Vec`s to mean "all refs" can be confusing. Avoid the chance
of confusion by introduction of a new type that clearly describes which
refs should be fetched.
2026-02-13 15:27:21 +01:00
Lorenz Leutgeb 9081c11b98
protocol/fetcher: Remove `from` from `QueuedFetch` 2026-02-13 15:25:42 +01:00
Lorenz Leutgeb 53a1286901
protocol/service: Remove unnecessary arg 2026-02-13 15:25:42 +01:00
Lorenz Leutgeb 94d7799ffe
protocol/fetcher/state: Typo 2026-02-13 15:25:42 +01:00
Lorenz Leutgeb 56ee626a51
protocol/fetcher: Delete unused file 2026-02-13 15:25:42 +01:00
Fintan Halpenny 613c4e83e0 protocol: separate subscribers by RefsAt
It was found that if a fetch was started for a specific `Vec<RefsAt>`
and a following general, i.e. empty, `Vec<RefsAt>` was queued, the
subscriber for the general one would be removed when the specific
fetch completed.

This behaviour is undesirable, since the general fetch could
potentially fetch more data.

To prevent this from happening, the `Vec<RefsAt>` is added to the
`FetchKey`, so that `subscribers` are matched with the set of
references they want to hear results for.

A test was added for the above scenario.
2026-02-13 12:49:37 +01:00
Fintan Halpenny 993428df56 node: donwgrade log error to trace for disconnection
This is would be a very noisy error since disconnections should be
expected to happen frequently for nodes.

Downgrade the log level to trace.
2026-02-12 14:35:13 +00:00
Fintan Halpenny aeba81f4d9 core: add documentation to `RepoId::from_canonical` 2026-02-12 13:52:28 +01:00
Fintan Halpenny 35a01898e6 core: guard on expected multibase
When decoding an input string for a `RepoId`, the base was never checked.
This change ensures that the base is checked and will error otherwise.

To allow for future base codes, the change introduces a sanctioned set
of base codes, which only contains `Base58Btc` for now.

Tests are added to ensure that parsing is correct and includes a valid
multibase code 'Z', which is not the expected 'z'.
2026-02-12 13:52:28 +01:00
Fintan Halpenny 8ee32168b3 radicle: remove file
The `mod id` statement was removed, but the file was not removed.
Remove the file since it is no longer needed.
2026-02-12 13:52:28 +01:00
Lorenz Leutgeb ebf7d876b4
node: Control via `uds_windows` not `winpipe`
Recent versions of Windows support Unix Domain Sockets natively, see
<https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/>.

By using that feature instead of Windows named pipes, the difference
for handling communication via the control socket comparing Unix-like
systems and Windows becomes smaller:

 1. No special paths like `\.\pipe\…` have to be handled.
 2. Not two I/O mechanisms are abstracted (named pipe and UDS) but
    just one.
 3. `winpipe` relies on background threads while `uds_windows` does
    not.

Once the feature `windows_unix_domain_sockets` (which is tracked at
https://github.com/rust-lang/rust/issues/150487) stabilizes, it will
likely be possible to just drop the dependency `uds_windows` and use
the implementation in `std::os::windows::net` directly.
2026-02-12 10:18:48 +01:00
Lorenz Leutgeb 90cf37c471
node: On Windows, use job for upload-pack child
Reports of zombie (grand)child processes were received. By associating
the `git upload-pack` process with a job, zombies are prevented.
2026-02-11 16:37:56 +01:00
Lorenz Leutgeb 990edbf055
windows: Introduce new crate
node: Use new windows crate to terminate job
2026-02-11 16:37:56 +01:00
Lorenz Leutgeb 50fb228ae4
term/editor: Implement `exists` for Windows
The paths checked by `fn exists` are well-known Unix locations, and not
meaningful to check on Windows.

Provide an implementation of `fn exists` for Windows, which uses
`which.exe` to look for binaries, and use that to provide sane defaults
for Windows.
2026-02-11 10:26:22 +01:00
Lorenz Leutgeb 450b664ad8
term/editor: Use `cfg`-attribute instead of macro
This might result in smaller binaries and is just as readable.
2026-02-11 10:26:22 +01:00
Lorenz Leutgeb 8fb2d96b5c
radicle/profile: No pager from Git on Windows
Git for Windows horribly mangles the configured binaries through a POSIX
`sh`-like environment even on Windows. We might be able to figure out
which `sh.exe` we would have to execute on Windows, but this is too
brittle. Windows users will have to use other mechanisms (like `$EDITOR`
and `$PAGER`) to configure their programs.
2026-02-11 10:26:22 +01:00
Lorenz Leutgeb 930ec175f1
term, cli: `winsplit` over `shlex` on Windows
Command line parsing differs on Windows vs. POSIX compliant operating
systems (just consider the differences in handling `\` for paths vs. as
a marker for escape sequences). Thus, on Windows use `winsplit` to
split command arguments instead of `shlex` for Unix-like OSes.

`winsplit` is a small crate with no other dependencies.
2026-02-11 10:26:22 +01:00
Lorenz Leutgeb fefa28372d cli/init: Canonicalize path before comparison
On Windows, this comparison would fail otherwise.
2026-02-10 10:00:16 +00:00
Lorenz Leutgeb ffbbb374c1 cli-test: Path separation compatible with Windows
Running tests on Windows requires separating the path to executables by
`;`.
2026-02-10 09:55:46 +00:00
Lorenz Leutgeb faeee9f370 crypto: Optionally provide JSON Schema
Providing the schema in `radicle-crypto` saves a lot of repetition
in `radicle`, and can be done via an optional dependency.
2026-02-10 09:39:34 +00:00
Fintan Halpenny 82ad52b169 cob: further restrict TypeName
Domain Names have restrictions on their total length, and the length
of individual labels[^0].

Since `TypeName`s are expected to be reverse domain name strings, the
total length of the internal string should not exceed 255 and each
component should not exceed 63.

[^0]: https://www.rfc-editor.org/rfc/rfc1035#section-2.3.4
2026-02-09 10:09:12 +01:00
Fintan Halpenny fe09cd4a00 cob: split up typename tests
The test name being used is `valid_typenames`, however it tests for
invalid `TypeName`s as well.

The invalid `TypeName` tests are now separated into another test
called `invalid_typenames`.
2026-02-09 10:08:30 +01:00
Fintan Halpenny 204db22bbe cob: enable sha1 feature
Enable the sha1 feature by default for `radicle-oid`.

Without this, the crate cannot be tested in isolation. It results in a
compile error, requiring the feature to be enabled.
2026-02-09 10:08:30 +01:00
Fintan Halpenny 1cab036c33 protocol/service: Wire up `FetcherService`
Wire up the new `FetcherService`. This reduces the `Service` fetch
methods down to:
- `fetch`
- `fetched`
- `dequeue_fetches`
- `fetch_refs_at`

This simplifies the code by off-loading the logic to the `fetcher`
family of types, rather than handling the intricacies in the `Service`
itself.

The `Service` now just performs the necessary I/O based on the
returned events from the `fetcher`.

This also removes the fetching state from the node sessions. This
follows the single responsibility, and sessions now only care about
their connectivity.

Breaking changes:
- The `Connected` state of a peer no longer contains fetching
  information, which was being returned as part of the JSON payload
  result.
- The `rad debug` information for ongoing fetches contained the number
  listeners awaiting for results, this was removed.
2026-02-05 20:04:28 +01:00
Fintan Halpenny 9e20890965 protocol: Introduce `FetcherService`
The `FetcherService` wraps the `FetcherState` alongside keeping track
of subscribers for a given fetch.

Typically, this is a channel for which the fetch result should be sent
to.

These subscribers are coalesced by maintaing a map from `(rid, node)`
pairs to the subscriber.

This continues the sans-IO approach where the type of subscribers are
not specified, but rather are kept as a type parameter – to be
specified by the caller.
2026-02-05 20:04:28 +01:00
Fintan Halpenny f0e3ca3403 protocol: Introduce `FetcherState`
This patch introduces the `FetcherState` which encapsulates the logic
and state for keeping track of fetches.

It uses a sans-IO approach, where the state of fetches transition
based on the current state and provided input.

Callers can then decide to perform I/O based on the returned event.
2026-02-05 20:04:28 +01:00
Fintan Halpenny 7cf73300f6 radicle/storage/refs: Derive `Hash` for `RefsAt` 2026-02-05 20:04:28 +01:00
Fintan Halpenny eccfd6baf3 cli: optional message for issue comments
The `From<String> for Message` implementation has an interesting
interaction between `clap` and how `Message` can be used from the
command line.

Note that `FromStr` is not implemented for `Message` – which usually
what is to be expected for use with `clap`, but in fact, `clap` also
allows `From<String>`.

This would make `Message` be a required option when using `rad issue comment`.

It is not possible to use `default_value_t` because that required an
implementation of `Display`, which in this case we do not want to
implement. Trying to use `default_value = "Message::Edit"` also would
not work – it uses that as the text.

So, the solution is to mark it as optional, and default to
`Message::Edit` when it is not specified.
2026-02-05 19:58:46 +01:00
Fintan Halpenny c33c26fa78 cli: fix casing for warning of preferred_seeds
While the field name will `preferred_seeds` in Rust, the casing for
the JSON file is `preferredSeeds`.
2026-01-28 10:17:36 +00:00
Fintan Halpenny 15adb16135 protocol: missed formatting
Formatting was missed in the `service.rs` file.
2026-01-28 10:16:50 +00:00
Fintan Halpenny 91eb6fc078 protocol: ensure `connect` supports connecting address
Be more defensive by preventing a node, that is not configured for
Tor, to not connect to `.onion` addresses via the `Service::connect`
method.

This means that an `Outbox::connect` should not be produced, and the
address table should not insert an entry.
2026-01-26 18:55:35 +01:00
Fintan Halpenny 36d5a4c8b0 protocol: use helper method
Use the `is_persistent` helper method rather than repeating the
`is_some` check.
2026-01-26 18:55:35 +01:00
Fintan Halpenny 73f9a35033 protocol: reuse session address for reconnect
When maintaining persistent connections, the config was consulted for
a peer address. Multiple addresses for a single `NodeId` can be
listed. This can result in a different address being used for
reconnecting if the `HashSet` returns in a different order.

The original address that was used for connection is in the `Session`,
so this should be used instead.
2026-01-26 18:55:35 +01:00
Defelo 589925e3a3 radicle/node: avoid unnecessary allocations in `Emitter::emit_all` 2026-01-26 17:40:02 +00:00
Defelo 8b1d475170 protocol: batch inventory removals and events in `sync_routing`
The previous implementation would remove routing entries one at a
time.
Improve the performance of this by batching the removal and events
emission.
2026-01-26 17:38:53 +00:00
Lorenz Leutgeb e63c30976e cli/fork: Deprecate
This command is confusing in name and function. Rather than creating
a hard fork of a repository, with a new identity, it pushes the
default branch to the local user's namespace.

Deprecate it and add some help text.
2026-01-23 15:04:16 +00:00
Adrian Duke b937a93892 radicle-cli: more helpful error for non-delegate updates
When a non-delegate attempts to update the identity document, their
action will be rejected.

Provide a better error, along with a hint, to the non-delegate.
2026-01-22 10:38:28 +00:00
Adrian Duke 60959f7e83 cli: promote WithHint hint type to String
Changes the `Error::WithHint::hint` field to use a `String` type instead of
`&'static str`. This allows the caller to provide extra hint
information.

To make it easier to use an `Error::with_hint` constructor is added.
2026-01-22 10:36:47 +00:00
Adrian Duke 67a4a712e4 radicle: add new error type for unauthorized non-delegates
The previous error `UnexpectedState` was opaque, and ended up in a
confusing message when a user would try to edit the identity document
while not being a deleagte themselves.

Instead, provide a more specific error that mentions the `Did`
performing the action, and the action itself.

Note that the `UnexpectedState` variant was matched on during
evaluation, meaning that operations would still appear in the timeline
of the COB. With the change to the other variant, the timeline does
not record the operation anymore.
2026-01-22 10:24:26 +00:00
Lorenz Leutgeb bd5436d791
core: Fix doctest
Two code fences that do not contain are not marked as such, leading to
false negatives when testing `radicle-core`. To remedy, mark these
fences as text.
2026-01-22 10:48:43 +01:00
Fintan Halpenny b41ce2e6fa radicle/canonical: provide public Canonical JSON link
The previous link is now behind an authentication layer.
Replace it with a webarchive link instead.
2026-01-22 09:10:53 +00:00
Defelo a4e66d141e radicle: Allow all references to be included in sigrefs
Previously, the `references_of` implementation restricted the set of
references to certain categories: heads, tags, notes, rad, and cobs.

This is too restrictive to allow peers to share any references they
want. The only exceptions is references `refs/tmp/heads` that are
created for creating patches.
2026-01-21 11:19:06 +00:00
Fintan Halpenny 6d1abd2833 node: downgrade `error!` logs
Evaluate the `error!` logging in `radicle-node`.

The majority of cases, the `error!` is downgraded to `warn!`. These
cases are generally useful to know if there's an issue, but the
operator cannon necessarily do anything about it.

In a few cases, `debug!` was chosen. These are generally when an error
means that a result is not part of an accumulation, or the system will
eventually correct itself during another event or restart.
2026-01-19 17:59:06 +01:00
Fintan Halpenny b020543c4b node: downgrade `warn!` logs
Evaluate the `warn!` logging in `radicle-node`.

If the event is a result of something being suspicious in the running
of the protocol, then it remains a `warn!`.

However, if the system ends up ignoring the event and can continue
without issues, the log level is reduced to `debug!`.
2026-01-19 17:59:06 +01:00
Fintan Halpenny ee1f55420a protocol: downgrade `error!` logs
Evaluate the `error!` logging in `radicle-protocol`.

The majority of cases, the `error!` is downgraded to `warn!`. These
cases are generally useful to know if there's an issue, but the
operator cannon necessarily do anything about it.

In a few cases, `debug!` was chosen. These are generally when an error
means that a result is not part of an accumulation, or the system will
eventually correct itself during another event or restart.

If the previous message started with "Error", then the wording is
changed to say "Failed to".
2026-01-19 17:59:06 +01:00
Fintan Halpenny eeadffa636 node: update comment
The comment mentions a variable `needs_flush`, which is not `write_intent`.
2026-01-19 17:56:56 +01:00
Fintan Halpenny 958422a7c4 node/routing: remove error scenario from Database::prune
A call to `Database::prune` with no limit could result in a
domain-defined overflow error.

If the limit is not provided, then it uses `i64::MAX`. It is
reasonable to expect that if the `usize` provided is more than
`i64::MAX` then the `i64::MAX` value is acceptable to use for pruning.
2026-01-19 17:56:56 +01:00
Fintan Halpenny 95b3d10961 protocol: downgrade `warn!` logs
Evaluate the `warn!` logging in `radicle-protocol`.

If the event is a result of something being suspicious in the running
of the protocol, then it remains a `warn!`.

However, if the system ends up ignoring the event and can continue
without issues, the log level is reduced to `debug!`.
2026-01-19 17:56:56 +01:00
Fintan Halpenny 9236277abf fetch: remove `target: "fetch"`
Going forward, there will be a preference to not use the `target` in
logging, and allow the default of the crate and module to be used
instead.
2026-01-19 17:56:56 +01:00
Fintan Halpenny e3cb36d950 fetch: clean up logging
Evaluate the use of `warn!` and `error!` logging in `radicle-fetch`.

The majority are downgraded to `debug!`, the rest either being
downgraded to `info!` or removed altogether.
2026-01-19 17:56:56 +01:00
Adrian Duke d860ec15b3 cli: Remove dead `fn parse_remote` 2026-01-16 22:52:53 +01:00
Adrian Duke 53cb8da8ff clippy: Deny and fix `must_use_candidate` 2026-01-16 22:52:53 +01:00
Adrian Duke 4c1b7fcd80 clippy: Deny and fix `index_slicing` 2026-01-16 22:52:50 +01:00
Adrian Duke 0855af00a9 clippy: Deny and fix `unneeded_field_pattern` 2026-01-16 22:52:23 +01:00
Adrian Duke 9cc2c869b4 clippy: Deny and fix `wildcard_enum_match_arm` 2026-01-16 22:52:23 +01:00
Adrian Duke 001aba0d29 clippy: Deny and fix `fallible_impl_from`
Instead of changing `impl From<SystemTime> for LocalTime` to `TryFrom`,
the implementation was removed, as there are not many callsites, and
they are well served by `LocalTime::now`.

radicle-localtime: drop TryFrom SystemTime

radicle-node: switch SystemTime usage with LocalTime
2026-01-16 22:52:18 +01:00
Fintan Halpenny 02318f199c radicle: Re-export `radicle_core::RepoId` 2026-01-09 14:04:18 +01:00
Fintan Halpenny 73827f5362 radicle: Re-export `radicle_core::NodeId` 2026-01-09 14:04:04 +01:00
Fintan Halpenny 7c016f9219 core: Introduce NodeId
A type for node IDs, which are Ed25519 public keys, is added to the
`radicle-core` crate.
2026-01-09 14:03:32 +01:00
Fintan Halpenny d5fea6324c core: Introduce RepoId
Introduce the `radicle-core` crate for housing data types that are at
the core of the Radicle protocol. The initial data type being added is
`RepoId`. To make the crate as lightweight as possible many of
dependencies are optional and gated by feature flags.
The crate is marked as `no_std` even though it unconditionally depends
on `radicle-crypto`, which is *not* `no_std`. This is to invite
refactoring of `radicle-crypto` to `no_std` at a later time.
2026-01-09 14:03:27 +01:00
Fintan Halpenny d98033a1ff localtime: localise the localtime dependency
The `localtime` crate was defined by cloudhead, and is a minimal
repository with a single `lib.rs`.

Instead of using it as an external dependency, copy the code directly
into a new workspace crate `radicle-localtime`.

The default `serde` implementation goes through the `LocalTime`'s
seconds values rather than milliseconds, since this is the more common
format. This allows the removal of the `serde_ext` functions.
The one place milliseconds was used was for the
`radicle::cob::common::Timestamp` type, where the `Serialize` and
`Deserialize` implementations are manually written.

It also adds a `schemars` feature to remove `schemars_ext` functions
in `radicle` as well.
2026-01-08 14:58:41 +01:00
Fintan Halpenny 3168107df9 fetch: surface underlying I/O error
The message that is returned by `gix-transport` for I/O errors can be
unhelpful, since it does not provide the reason for what happened.

Instead, surface the error so that it provides more detail for logging.
2026-01-05 18:29:52 +01:00
Fintan Halpenny 75b665ff3a node/wire: manage logs for error establishing connection
Instead of logging all IO errors as an error, match on the kind of the
error, logging an info message, otherwise an error.

These errors are informational, and cannot necessarily be resolved by
the node operator – since it is a matter of not being able to connect
to another end.
2026-01-05 17:57:34 +01:00
Fintan Halpenny 47dc2c562c protocol/service: defensive storage.contains check
In the case of the `storage.contains` call returning an error, it
would be preferable to log the error and continue checking for missing
repositories.
2026-01-05 17:51:43 +01:00
Fintan Halpenny a46f8eb1d5 node: use `outbound.get` over `outbound.get_mut`
The following block did not need mutable access to the `outbound`
value.

To avoid confusion around mutable access, the call was downgraded to
`get` so that the reader can safely know there is no mutation
happening.
2026-01-05 17:45:54 +01:00
Fintan Halpenny b8a6e1a52f radicle/cob/stream: skip commits that do not have a manifest
For some COBs, parent commits can be specified for actions, for
example, patches will bundle their base and head commits as parents.

When the COB stream performs the revwalk, these commits will be
included, and will not have the manifest file – resulting in an error.

Instead, this error can be matched against, and the commit is skipped
instead. The other errors should still be resurfaced, since a commit
with a manifest should be expected to load the operation correctly,
and the commit should exist in the repository when attempting to load
it.

One might argue that a valid operation with a missing manifest could
occur, but that would mean that `radicle-cob` has performed an invalid
write. This is undetectable by the stream API, and is ambiguous with
the case of non-Op commits.
2025-12-28 14:01:01 +00:00
Defelo cf023f750d
cob: allow hyphens in `TypeName`
Also make sure to only allow ASCII characters and add some tests.
2025-12-15 14:30:27 +01:00
Lorenz Leutgeb 4a5a51e6e5
node: Do not mix monotonic and system time
The `struct Epoch` introduced in e404f1038f
inadvertently made `radicle-node` suffer from
https://github.com/rust-lang/rust/issues/87906

That is, updating of the "current time" was skewed *way more*
than expected by a slowly ticking monotonic clock. Such slow
ticking can be caused by suspending the system.
2025-12-04 20:45:51 +01:00
Fintan Halpenny 58305cda32 protocol/limiter: impl AsTokens for limits
Provide `AsTokens` implementations for the `Outbound` and `Inbound`
newtypes of `RateLimit`.

This allows them to be used for the rate limiting method.
2025-12-02 14:18:18 +01:00
Fintan Halpenny c675683da9 protocol: IntoIterator for BoundedVec
Implement `IntoIterator` for the `BoundedVec`.

This allows the use of `into_iter` for returning the owned data,
rather than references via the `Deref` implementation.
2025-12-02 12:55:09 +00:00
Lorenz Leutgeb 37d4ae4a9f radicle/node: Revisit routeability of IP addresses
All IPv6 addresses would be considered globally routeable, even though
the Rust standard library offers convenience functions to check for
loopback, link-local addresses etc.

Improve checks for IPv6 routeability to catch the most obvious cases of
local or unspecified addresses.

Refactor the check for IPv4 routeability to be more readable and refer
to RFCs, IANA lists, and Rust stabilization tracking issues as
appropriate.
2025-12-01 12:34:02 +00:00
Lorenz Leutgeb f9a62e7d8d radicle/node: `Address::is_local` for DNS names
`Address:is_local` would return `false` for all DNS names. This is
incorrect, with one counterexample being the name "localhost", which
generally resolves to a local (usually loopback) address.

The function is changed to catch "localhost", but also the top level
domain ".localhost", which is reserved in RFC 2606, Section 2.

`Address::is_routable` would return `true` for all DNS names. While it
is much harder to decide global routeability based on a domain name, as
these usually have to be resolved to an address before being able to
judge routability, there is one particular class of names, namely local
ones (see above), which are not globally routable.
2025-12-01 12:34:02 +00:00
Lorenz Leutgeb dc624ed518
radicle/node/bootstrap: Remove IP addresses
Due to connection retries in `radicle-node` not choosing new addresses,
mistakenly using an IPv6 address when IPv6 is not supported would result
in failure to bootstrap.

Work around by removing IP addresses again. This means that DNS or Tor
will be required to bootrstrap.
2025-12-01 12:27:53 +01:00
Fintan Halpenny 45abb881a3 node: Only consider onion addresses if configured
There is an unfortunate lack of single-responsibility with handling the
addresses to connect to.

This is a band-aid fix until the point in time where this can better improved.
2025-11-28 21:52:39 +01:00
Fintan Halpenny 93d2ed8c61 cli/completion: Static shell completion for `rad`
Introduce the use of `clap_completion` for generating static completion.
The shells that are supported are the ones that are included in `clap_complete`:
- `bash`,
- `elvish`,
- `zsh`,
- `fish`, and
- `powershell`.

Co-authored-by: Michael Uti <utimichael9@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-11-28 20:47:25 +01:00
Sebastian Martinez 7e5a1ababc radicle: Skip invalid named folders
Instead of failing with an `InvalidId` error in
`radicle::storage::ReadStorage::repositories` for repos that don't have
a valid repository ID, skip them and log a warning.


Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-11-28 20:31:06 +01:00
Fintan Halpenny 0c70e17123 remote-helper: inform the user of an empty patch
The previous message is included in the error:

     ! [remote rejected] master -> refs/patches (patch commits are already included in the base branch)
     
To make it clearer to the user, also print a warning to tell them that the
commit was in the base branch – including the commit SHA:

    warn: attempted to create a patch using the commit f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354, but this commit is already included in the base branch
2025-11-28 20:19:47 +01:00
Fintan Halpenny 28c8c1531f cli/sync: filter seeds without an address
If a seed for syncing does not have an address, the local node will not be able
to connect to it.

These can be filtered out so that no connection attempts are made for these nodes.
2025-11-28 20:05:26 +01:00
Defelo 0ec084fc23 remote-helper: Support push --force-with-lease
Previously, the remote helper would not support the `--force-with-lease` option.
This change introduces this support and ensures that it works as intended.

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2025-11-25 10:48:30 +00:00
Sebastian Martinez 6d0c571ea9 radicle: Return individual results for repo in `repositories_by_id`
Change `repositories_by_id` to return `impl Iterator<Item = Result<RepositoryInfo,
RepositoryError>>`
instead of `Result<Vec<RepositoryInfo>, RepositoryError>`.
This allows callers to handle failures on a per-repository basis rather
than having the
entire operation fail if a single repository lookup fails.

Previously, the method would stop processing and return an error as soon
as any repository failed to load. Now it processes all repositories and
returns individual results, making the API more resilient and giving
callers
more control over error handling.
2025-11-06 10:43:04 +01:00
Lorenz Leutgeb c268e809e9 chore: Fix mistakes discovered by typos 2025-11-04 14:09:07 +00:00
Yaroslav Halchenko 32d77641ab chore: Fix spelling errors with codespell 2025-11-01 12:11:02 +01:00
Lorenz Leutgeb 8e331ce182
node/reactor/transport: Implement `Debug`
The derived implmenetation prints read and write buffers, which is too
much even for trace logging (where we use this trait).
2025-11-01 11:20:43 +01:00
Fintan Halpenny bc1d9ed495 cli: remove lexopt dependency 2025-11-01 11:20:43 +01:00
Fintan Halpenny 83f26abaa0 cli/main: refactor external command
Refactors the external command logic into a struct.

This allows for methods to maitain the logic of an external command.
It also allows for a cleaner output for the executable name – avoiding the debug
output of OsString using `""`.
2025-11-01 11:20:43 +01:00
Fintan Halpenny f60922d125 cli/terminal: make args module private 2025-11-01 11:20:43 +01:00
Fintan Halpenny 961301f643 cli/terminal: clean up args::Error type
The other variants of `terminal::args::Error` were no longer used.
The only variant required is `Error::WithHint`.

The enum is also made private, since it is only used in this crate.
2025-11-01 11:20:43 +01:00
Fintan Halpenny a75db6a695 cli/terminal: remove argument helpers
These helper functions were for parsing arguments passed via lexopt.
Since `clap` is now the parser for these types, these functions are no longer
needed.
2025-11-01 11:20:43 +01:00
Fintan Halpenny fec8a27a36 cli/terminal: remove Help struct
The `Help` struct is no longer needed thanks to `clap`, so it is removed.
2025-11-01 11:20:43 +01:00
Fintan Halpenny e359435040 cli/main: move run_command_fn to main
This call was moved to the `main.rs` file, since that is where it is used.

It is renamed to `run` and its call site is cleaned up.
2025-11-01 11:20:43 +01:00
Fintan Halpenny 7533db62f9 cli/terminal: remove unused parameter 2025-11-01 11:20:43 +01:00
Fintan Halpenny 1f80eb61ed cli/terminal: remove unused trait 2025-11-01 11:20:43 +01:00
Fintan Halpenny d41ac59828 cli/help: remove the help module
The `help` module is no longer needed, since `clap` handles that.

This meant that the re-exports of each command's `ABOUT` could be removed and
the `const`s can now be private.
2025-11-01 11:20:43 +01:00
Fintan Halpenny 23332fa318 cli/main: migrate main to use clap
Now that all commands can be parsed by clap, remove any custom parsing and
directly use `CliArgs::parse`.

The `Diff` command was removed, since only one `external_command` can be
declared for a subcommand. The handling of `rad diff` is now done via the
`External` variant. If the subcommand name is `diff` then this is executed,
otherwise delegate to the possible `rad-{exe}` command.

Also of note, the `rad inspect` command has an alias `rad .`. This changes the
behaviour of `rad . --help`. Before, it would print the help of the `rad`
command. Now, it prints the help of `rad inspect`.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-11-01 11:20:43 +01:00
Fintan Halpenny 5053a1aa77 cli/unseed: rename options to args
Have consistent naming for args
2025-11-01 10:52:13 +01:00
Fintan Halpenny 6ca1292350 cli/unfollow: rename options to args
Have consistent naming for args
2025-11-01 10:52:13 +01:00
Fintan Halpenny 3c89525003 cli/sync: migrate to clap
Due to the idiosyncracies of this command there are a few things to note about
this migration.

The `rad sync` command acts as a default subcommand in itself, in that it has
options that do not apply to its subcommand, `rad sync status`. This means that
the options will print with `rad sync --help`, but they will not print with `rad
sync status`.

The `--inventory` flag is not compatible with any of the other flags and
options, thus they are all marked with `conflicts_with`. This cannot be done for
a positional argument, so `clap` will "helpfully" print out the usage, for
example, as:

    error: the argument '--inventory' cannot be used with '--fetch'

    Usage: rad sync --inventory [RID]

    For more information, try '--help'.

Which is incorrect, since `RID` is ignored. This is explained in the `--help`
documentation for `--inventory`.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-11-01 10:52:13 +01:00
Matthias Beyer d1e19a87b0 cli/patch: migrate patch CLI parsing to clap
Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-10-29 09:11:05 +00:00
Fintan Halpenny 3ea61f0f98 cli/patch: move comment actions
Moving the sub-comment actions to be beside the top level comment action. This
is mostly to provide a better diff for the next commit – that refactors due to
`clap` changes.
2025-10-29 09:11:05 +00:00
Lorenz Leutgeb e404f1038f node: Use `std::time` for reactor and wire
This reduces the exposure to the `localtime` crate, using
`std` instead.
2025-10-29 09:05:52 +00:00
Sebastian Martinez 9bcdd353c9 cli/inbox: Use clap 2025-10-28 12:11:37 +00:00
Johannes Kühlewindt 5741bafa3b radicle/cob/db: Add index for issues and patches
To improve query performance for issues and patches, add a composite
index on "repo" and "id" to the SQLite database schema via a
migration.
2025-10-25 10:22:50 +02:00
Richard Levitte 990e22acff cli/inspect: use Clap
This includes a horrible - but hopefully short-lived - hack to make
`rad .` work.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-10-22 21:14:12 +02:00
Adrian Duke 5ed1b8e579 node: Fix test 'test_concurrent_fetches'
The test 'test_concurrent_fetches' is broken. It asserts over empty
sets nullifying its utility. Correct the test by changing it so that
sets to be asserted against are cloned.
2025-10-22 17:11:23 +02:00
Erik Kundt e8f9d21be3 cli/node: Use clap
Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-10-22 11:27:23 +01:00
Erik Kundt f20c2f215a node: Re-export `PeerAddrParseError`
In order to build higher-level errors that use `PeerAddrParseError`, it
must be re-exported.
2025-10-22 11:27:23 +01:00
Fintan Halpenny 6cfed884bf cli/remote: migrate to clap 2025-10-21 10:12:33 +01:00
Sebastian Martinez f8fe296ceb radicle/rad: Fix typo 2025-10-20 15:09:43 +01:00
Sebastian Martinez 8604d3bcc7 cli/config: Use clap 2025-10-20 12:04:31 +01:00
Erik Kundt 8d90699c30 cli/cob: Use clap 2025-10-20 11:21:58 +01:00
Fintan Halpenny 38ca038a0d cli: fix test regression in 27a85987c3
A test failure was caused in commit
27a85987c3, which expected `STRING`
instead of `ALIAS`.

This change fixes that discrepancy.
2025-10-17 16:57:29 +01:00
Sebastian Martinez c1d9f04963 cli/self: Use clap 2025-10-17 16:45:20 +01:00
Erik Kundt 27a85987c3 cli: Fix argument value names in `auth` and `init`
We decided to use the value names to indicate which type the value
is parsed into (instead of just saying that the value is a `STRING`).

This makes the value names consistent with other commands again.
2025-10-17 13:43:42 +01:00
Lorenz Leutgeb b0beef4391
workspace/rust/clippy: Fix all warnings
Fix clippy warnings following the upgrade of the Rust toolchain to
version 1.90. Almost all are "mismatched_lifetime_syntaxes".
2025-10-17 12:56:43 +02:00
Erik Kundt 407abc6a2c cli/follow: Use clap 2025-10-17 10:50:21 +01:00
Erik Kundt deaf77e5b4 cli/unfollow: Use common DID / NID argument parser 2025-10-17 10:50:21 +01:00
Erik Kundt e488ddb446 cli: Add common value parser for NID / DID 2025-10-17 10:50:21 +01:00
Richard Levitte 06e22434e1 cli/checkout: use Clap 2025-10-17 08:51:10 +02:00
Erik Kundt 28824a3127 cli/init: Fix argument value names 2025-10-17 08:20:30 +02:00
Erik Kundt 634866889f cli/id: Use clap
This implementation works around the fact that `clap` does currently
not support value parsers for a series of values, so representing
`--payload` as a `Vec<Payload>` does not work.

Instead, we parse eveything into a `Vec<String>` and do the validation
on the application side.

Using value parsers for a series of values will probably be supported in
`clap` v5, though.
2025-10-16 18:14:11 +02:00
Lorenz Leutgeb d3ed4bb497 radicle/id: Introduce `PayloadUpsert`
Instead of using triples, introduce a `struct` to carry upserts.
2025-10-16 18:14:11 +02:00
Erik Kundt ec1d754308 cli/unblock: Use clap 2025-10-16 15:31:47 +01:00
Erik Kundt faf19af9de cli: Share common argument types used in `(un)block`
Since `rad block` and `rad unblock` share the same argument type,
`BlockTarget` is moved to the exising `terminal/args.rs` module.
2025-10-16 15:31:47 +01:00
Fintan Halpenny cef0ff571d oid: use `std:#️⃣:Hasher::hash` over `Hasher::write`
Previously, the `RepoId` was backed by the `git2::Oid` type, which has a `Hash`
implementation that uses `std:#️⃣:Hasher::hash`. This uses a length prefixed
form for hashing.

When switching to `radicle_oid::Oid` and implementing `Hash` without the length
prefix, this subtly changed the hashes going forward.

These hashes are used in `BloomFilter`, which is the type underlying `Filter`.
This resulted in cases where a previous `Filter` that certainly contained
`rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5` were suddenly reporting that they did not
contain this repository.

Changing the implementation of `Hash` for `radicle_oid::Oid` fixes this, and is
confirmed by adding the regression test in `filter.rs`.
2025-10-16 15:14:10 +01:00
Erik Kundt d9ae29deaa cli/seed: Use clap 2025-10-16 13:02:06 +02:00
Erik Kundt 80198d68b6 cli: Share value parser for `Scope` 2025-10-16 13:02:06 +02:00
Fintan Halpenny b7a7f55e78 gix: CVE-2025-31130
Update the `gix` family of crates to avoid the vulnerability reported in
[CVE-2025-31130].

Since `gix-hash` is used in two places, its version definition was moved to the
top-level `Cargo.toml`. `cargo` warned that `default-features` not being defined
in the top-level could result in a future error, so that was carried along with
it. This did not affect the build of `radicle-fetch`.

[CVE-2025-31130]: https://www.cve.org/CVERecord?id=CVE-2025-31130
2025-10-15 11:34:01 +01:00
Lorenz Leutgeb 0b3424857e node/reactor: Correctly handle error events
`fn handle_events` would panic, if there were multiple events for one
token, and the first one that happened to be handled was an error.
Indeed it is concerning if a token is encountered that was never
registered before. However, tokens that were just deregistered must be
tracked.

Using `Vec` here seems a bit costly, in the future,
`smallvec::SmallVec` could be considered.

The "unregister" methods are renamed to "deregister" to better line up
with `mio` vocabulary.

Log statements that helped analysis of the panic that occurred here
are overhauled and improved, requiring a `Debug` bound on types that
obviously implement it.
2025-10-15 10:42:27 +01:00
Lorenz Leutgeb 72cf3d1919 cli/diff: Use clap
The implementation of the *deprecated* command is removed, it now
directly invokes `git diff`.
2025-10-15 10:30:34 +02:00
Richard Levitte 384c506489 cli/auth: use Clap 2025-10-14 12:55:33 +01:00
Erik Kundt dfd35480be cli/watch: Use clap 2025-10-14 12:49:16 +02:00
Lorenz Leutgeb efe10f95be
workspace: Enable vendored `libgit2`
Multiple crates are enabling this feature. Do that at the workspace
level.
2025-10-13 16:14:23 +02:00
Lorenz Leutgeb b7cfcfff75
workspace: A Little Less `git2`
Make `git2` an *optional* dependency of `radicle-cob`, and refactor
`radicle` to depend on crates that in turn do not depend on `git2`
*non-optionally*

The main offending dependency of `radicle-cob` is `radicle-git-ext`
from the `radicle-git` workspace in repository
(rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) which *non-optionally* depends on
`git2`.

So, to achieve removal of this dependency:

 1. The crate is refactored to depend on the new crates
    `radicle-git-ref-format` `radicle-git-metadata`, and
    `radicle-oid` introduced in the previous commits, instead of
    `radicle-git-ext`.
 2. Some code from the `radicle-git-ext` crate in the `radicle-git`
    workspace in repository (rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) is
    copied. See `crates/radicle-cob/src/backend/git/commit.rs`.

This cascades to `radicle` and its dependents.

  Firstly, the there is an
`impl Deref<Target=git2::Oid> for radicle_git_ext::Oid`. This made
it very convenient to just deref to obtain the wrapped `git2::Oid`,
so there are many expressions of the shape `*oid` in `radicle` and
its dependents. However `radicle-oid` does not provide
`impl Deref<Target=git2::Oid> for radicle_oid::Oid`, as notably,
`Target` is an associated type, and not a type parameter, so an
implementation of `Deref` would tie the new `Oid` too tightly to a
particular implementation.
Instead, work with `impl From<radicle_oid::Oid> for git2::Oid`
(which can be enabled using the feature flag `radicle-oid/git2`).
This explains the changes from `*oid` to `oid.into()` at every
transition to "`git2` land".

  Secondly, `radicle` and its dependents are refactored to also depend
on `radicle-git-ref-format` and (much less prominently)
`radicle-git-metadata` instead of `radicle-git-ext`
This is to avoid pulling in `git2` via these dependencies.

  Thirdly, as the re-exports in `crates/radicle/src/git.rs` change,
they are at the same time also cleaned up. Notably, the types from
`radicle-git-ref-format` are re-exported under `fmt` only, not "twice".

While overall this obviously is very much a breaking change, these
changes should mostly amount to changing from `Deref` to `Into`, i.e.,
`*oid` → `oid.into()` and rewriting imports for `radicle::git::fmt`.
This is indicated by the mostly mechanical nature of the changes to
`crates/radicle-{cli,node,remote-helper}`.
2025-10-13 16:14:23 +02:00
Lorenz Leutgeb f4a8908727
git-metadata: New crate extract from `radicle-git`
This is just enough to get heartwood going.

Some code from the `radicle-git-ext` crate in the `radicle-git`
workspace in repository (rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) is
copied.
2025-10-13 16:07:39 +02:00
Lorenz Leutgeb 793f53b5f0
oid: New crate
For further details on the crate see its documentation in
`crates/radicle-oid/src/lib.rs`.

Changes to `crates/radicle{,-crypto}/Cargo.toml` are to preserve the
default features of their dependencies `serde` and `schemars`,
which are disabled to support `radicle-oid` being `no_std`.
2025-10-13 15:00:12 +02:00
Lorenz Leutgeb 3fcf2a86da
git-ref-format: New crate
For further details on the crate see its documentation in
`crates/radicle-git-ref-format/src/lib.rs`.
2025-10-13 13:34:15 +02:00
Lorenz Leutgeb 292befdb36 radicle: Add `tempfile` to dev-dependencies
In commit 2149770a4b the dependency
`tempfile` was made optional, and added to be enabled by the feature
flag `test`. However, the *tests of this crate itself* need the
dependency *unconditionally* as they want to create temporary
directories.

This was not noticed earlier, since the error does not surface when
the whole workspace is tested (`cargo test --workspace`), but only
when the crate itself is tested (`cargo test --package=radicle`),
because when testing the workspace, dependents of `radicle` will
enable the `test` feature flag.
2025-10-13 12:26:31 +01:00
Lorenz Leutgeb 84dd89180a radicle: Fix required features for `fastrand`
The `radicle` crate would not build on its own with
`cargo build --package=radicle` because some `fastrand` features were
missing.
2025-10-13 10:39:25 +01:00
Lorenz Leutgeb f232acda74 cli/diff: Print cross-platform line endings 2025-10-13 10:32:17 +01:00
Lorenz Leutgeb d8ab40777d radicle/storage: Fix temporary path generation
`impl Display for RepoId` will produce a `rid:` prefix, which
contains a colon, and this trips up various filesystems. Use
`RepoId::canonicial` instead.
2025-10-13 10:29:09 +01:00
Lorenz Leutgeb 013da67aa1 cli/test: Skip `rad_diff` on macOS
macOS's `sed` requires an argument for `-i`, which we don't provide
in the example. Providing it makes the test fail on Linux.
Since this command is deprecated anyway, we just skip macOS.
2025-10-13 10:27:02 +01:00
Lorenz Leutgeb f7af918190 cli/test: Fix `rad_patch_delete` for macOS
It looks like macOS does not like this command:

    ln: -f: No such file or directory

Since `LICENSE` and `MIT` are both just empty here, we don't need to
link anything.
2025-10-13 10:18:10 +01:00
Lorenz Leutgeb 7d6d2e51d8 cli/test: Clean up testing environment
This is a small cleanup to path generation during testing.
 1. Separate `rad_home` and `unix_home` to avoid confusion.
 2. Remove now unnecessary `trait HasHome`.
 3. Move setting `$USER` to the environment.
 4. Make paths shorter overall, to fix macOS tests.
2025-10-13 08:56:23 +01:00
Lorenz Leutgeb 3780f908a2 radicle/identity: Stabilize tests
The following tests generated an unstable object ID, thus linearizing
history in a different order, causing failures. Fix this by using the
`stable-commits` feature of `radicle-cob`.

    thread 'cob::identity::test::test_identity_redact_revision'
    panicked at crates\radicle\src\cob\identity.rs:1338:9:
    assertion `left == right` failed
      left: [Oid(b4307ded046befba374bf8cd9fd787592ceb615c),
             Oid(a04165e3d3717c5a1413ec78e852bd8e1bb049d4),
             Oid(820d3faf5b507888173b26ccd1a2a81666bd2573),
             Oid(30ca6f078a401bf542049594fbb1c8d2371c9819),
             Oid(9e9c46971014b123a31cd1195078f95c2e319419)]
     right: [Oid(b4307ded046befba374bf8cd9fd787592ceb615c),
             Oid(a04165e3d3717c5a1413ec78e852bd8e1bb049d4),
             Oid(820d3faf5b507888173b26ccd1a2a81666bd2573),
             Oid(9e9c46971014b123a31cd1195078f95c2e319419),
             Oid(30ca6f078a401bf542049594fbb1c8d2371c9819)]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

    thread 'cob::identity::test::test_identity_reject_concurrent'
    panicked at crates\radicle\src\cob\identity.rs:1494:9:
    assertion `left == right` failed
      left: [Oid(b4307ded046befba374bf8cd9fd787592ceb615c),
             Oid(bce4233f6a09d6e9c021ba436e3c6923a1a78f31),
             Oid(7cacb23be7079c16c8ad1b2458ae5bac95a1295b),
             Oid(12b00e2e871b699c84c20427a64e029934c15ec4),
             Oid(07431c8d80c11492ef248e07126370e874de3435),
             Oid(98b42450159a359c2f482652c66d79b05d0af624)]
     right: [Oid(b4307ded046befba374bf8cd9fd787592ceb615c),
             Oid(bce4233f6a09d6e9c021ba436e3c6923a1a78f31),
             Oid(7cacb23be7079c16c8ad1b2458ae5bac95a1295b),
             Oid(98b42450159a359c2f482652c66d79b05d0af624),
             Oid(12b00e2e871b699c84c20427a64e029934c15ec4),
             Oid(07431c8d80c11492ef248e07126370e874de3435)]
2025-10-13 08:49:24 +01:00
Lorenz Leutgeb 60798cdbc3 radicle/profile: Canonicalize during test
Fixes test `profile::test::canonicalize_home`.

Since `Home::new` canonicalizes its argument (which is what the test
wants to ensure), also canonicalize the expected value, which is
especially important on Windows as the canonicalization is more
complex than on Linux.

For example:

    thread 'profile::test::canonicalize_home' panicked at crates\radicle\src\profile.rs:802:9:
    assertion `left == right` failed
      left: "C:\\Users\\runneradmin\\AppData\\Local\\Temp\\.tmpMnNkr6\\Home\\Radicle"
     right: "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\.tmpMnNkr6\\Home\\Radicle"
2025-10-13 08:43:49 +01:00
Lorenz Leutgeb 86b7ef23c6 radicle/git/raw: Limit scope of `RemoteCallbacks`
Found with `cargo clippy --package=radicle`, this is only used in
tests.
2025-10-13 08:34:03 +01:00
Richard Levitte 191c287955 cli/ls: use Clap
This adds `conflicts_with` for `private` and `public` to simplify the logic that checks for the document visibility
(thank you Fintan)

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2025-10-10 17:08:08 +02:00
Richard Levitte 8ba3087cb9 cli/init: use Clap 2025-10-10 16:03:14 +02:00
Lorenz Leutgeb ea562215ea
radicle/git/raw: Introduce `trait ErrorExt`
This extension trait is more ergonomic than what `radicle-git-ext`
provides.
2025-10-10 11:29:24 +02:00
Lorenz Leutgeb 880634acd4
radicle/git/raw: Capture all `git2` re-exports
A refactoring internal to the `radicle` crate, with the goal of
making dependency on `git2` clearer and more controlled.
`radicle::git::raw` is changed from a complete re-export of `git2`
to a module that selectively re-exports (many) members of `git2`.
required to build the workspace (potentially breaking dependents
outside the workspace, but given just how many types are
re-exported, this seems unlikely).

In the future, no more `use git2::…` statements should be added
outside of `crates/radicle/src/git/raw.rs`. This is in an effort to
decrease dependence on `git2` in the future.
2025-10-10 11:29:24 +02:00
Lorenz Leutgeb 633059040c node/wire: Refactor precedence
No change in the logic here, just making this slightly easer to read and
understand.
2025-10-10 09:45:05 +01:00
Lorenz Leutgeb cb7bed5562 node: Remove dependency on amplify 2025-10-10 09:45:05 +01:00
Lorenz Leutgeb 3c3d81a085 node: Use Mio
The dependencies `netservices`, `io-reactor` and `popol` served us well,
however they do not support Windows and are not actively maintained.

This change removes the aforementioned dependencies (and `libc` along
with them). It reuses the integration with `cyphernet` from
`netservices` for Noise and SOCKS.

The new module `reactor` is a rewrite of `io-reactor` on top of Mio.

Note that no tests were changed.
2025-10-10 09:45:05 +01:00
Lorenz Leutgeb b25d80d272
crypto: Depend on `git-ref-format-core` only
The `git-ref-format-core` crate is enough to implement everything
required by `radicle-crypto`, and has a much smaller dependency
footprint than `radicle-git-ext`. Notably, it does not depend on
`git2` and also does not depend on procedural macros.
2025-10-09 17:18:59 +02:00
Lorenz Leutgeb ac572e64e5 node: Support systemd credential for passphrase
While it is possible to pass the passphrase via the environment, e.g.
`EnvironmentFile=<path to file that contains "RAD_PASSPHRASE=…">`
this is less secure than passing it via a file, because the environment
is inherited down the process tree.

Thus, allow using a systemd credential. The ID of the credential must be

    xyz.radicle.node.passphrase

and is not user-configurable.

Passing the passphrase via file is now possible with
`LoadCredential=xyz.radicle.node.passphrase:<path to file that contains passphrase>`

This requires just a bit of plumbing in `radicle-node`.

Because this mechanism is more secure than using the environment
variable `RAD_PASSPHRASE`, it takes priority. That is, if both the
systemd credential is available, *and* the environment variable
`RAD_PASSPHRASE` is set, the former is preferred.

Heads-up:
 1. The contents of the file must be valid UTF-8 (see documentation of
    `std::fs::read_to_string`). Assuming that the passphrase is at some
    point chosen by the user and typed on a keyboard, this does not
    seem like a severe restriction.
 2. The contents of the file are not processed otherwise, i.e. line
    breaks (notably at the end of the file) are not stripped.

The related `issue/8bd040e9de05e7fc27e373ebc1649ff4ad930e7a` asked for a
very similar feature: Passing the passphrase via a file named by the
value of the of the environment variable `RAD_PASSPHRASE_FILE`.
It was also briefly discussed at
<https://radicle.zulipchat.com/#narrow/channel/369277-heartwood/topic/.60RAD_PASSPHRASE_FILE.60/with/529104447>.
2025-10-09 10:03:21 +01:00
Lorenz Leutgeb ae39f24b58 node: Support systemd credential for secret
While it is possible to use systemd credentials via

    LoadCredential=xyz.radicle.node.secret:…
    ExecStart=radicle-node … --secret "${CREDENTIALS_DIRECTORY}/xyz.radicle.node.secret"

Make usage more convenient and directly support passing the secret key
via a systemd credential. The ID of the credential must be

    xyz.radicle.node.secret

and is not user-configurable.

A systemd service unit file might contain:

    LoadCredential=xyz.radicle.node.secret:…
    ExecStart=radicle-node …

This requires just a bit of plumbing in `radicle-node`.

The preference order for the path of the secret key is:
 1. The command line argument `--secret`.
 2. The systemd credential.
 3. The configuration file.
 4. The default location to preserve backward compatibility.

The reason to prefer the systemd credential over the configuration file
is that it uses a mechanism that is influenced by the environment of the
process, which is deemed "closer at runtime" or "more dynamic" than a
configuration file. Ad-hoc overrides are still possible via the
commandline argument.
2025-10-09 10:03:21 +01:00
Lorenz Leutgeb 0c513e981f systemd: Support Credentials
Add `mod credential` with `fn path` which implements a simple lookup of
systemd credentials. See <https://systemd.io/CREDENTIALS/>
2025-10-09 10:03:21 +01:00
Lorenz Leutgeb 8c1073b9c9 cli/publish: Use clap 2025-10-09 10:52:21 +02:00
Lorenz Leutgeb 7effa7c64c
node: Report sync status for given namespaces
The "seeds" command does only take a repository ID, and
carries the implicit assumption that the namespace with the same public
key as the Node ID of the receiving `radicle-node` process should be
used as reference for determining whether other nodes are in sync,
but no other namespace.

In the spirit of separating user and node identity, relax this, so that
the command also carries the public keys relative to which the sync
status should be computed. This allows to inspect sync status for
arbitrary namespaces via command.

For now, this feature is not exposed to the CLI, but `rad sync status`
always passes the public key of the active profile.
2025-10-09 07:55:11 +02:00
Lorenz Leutgeb 9689de9af0
node: Allow announcing refs for given public keys
The "announce references" command does only take a repository ID, and
carries the implicit assumption that the namespace with the same public
key as the Node ID of the receiving `radicle-node` process should be
announced, but no other namespace.

In the spirit of separating user and node identity, relax this, so that
the command also carries the public keys for which the announcement
should be made. This allows to announce arbitrary namespaces out of
storage via command.

For now, this feature is not exposed to the CLI, but rather:
 - `rad sync` always announce for the public key of the active profile.
 - `git-remote-rad` ditto, as it calls the same codepath.
2025-10-09 07:55:10 +02:00
Lorenz Leutgeb 4dbb022d22
radicle/node: Create submodule "command"
Purely for better overview, keeping backwards
compatibility with re-exports.
2025-10-08 23:58:41 +02:00
Lorenz Leutgeb 8e7d193202
radicle: Update `CHANGELOG.md` for next iteration 2025-10-08 23:58:41 +02:00
Lorenz Leutgeb 7b8da0e72f cli/fork: Use clap 2025-10-08 23:31:50 +02:00
Lorenz Leutgeb 3992d519c3 cli/clone: Use clap 2025-10-08 15:52:16 +02:00
Lorenz Leutgeb 7c89045ea0 cli/debug: Use clap 2025-10-08 15:30:18 +02:00
Erik Kundt 2e77d5ef4d cli/block: Improve example values for target argument
This visual representation follows the one that `clap` is generating
for defaults and possible values.
2025-10-07 15:01:57 +02:00
Lorenz Leutgeb 6d698bb794 cli/block: Use clap 2025-10-07 14:20:13 +02:00
Fintan Halpenny ed5a68c1d7 node: mark modules as private
In an effort to reduce the change of version numbers, dependents of
`radicle-node` should not need to know about the modules:
- `control`
- `wire`
- `worker`

These are internal to the `radicle-node` running, and none of its dependents
accessed them.

This resulted in removing two unused type aliases.
2025-10-06 18:57:30 +02:00
Fintan Halpenny 59e09078bb radicle: mark `CheckoutError` as `non_exhaustive`
Recently, this error enum was changed. To ensure it does not cause crate version
changes, in the future, mark it as `non_exhaustive`.
2025-10-06 18:57:30 +02:00
Fintan Halpenny 5b260964cb crypto: mark errors as `non_exhaustive`
To improve crate version churn, mark the error types as `non_exhaustive`.
This removes the need to change the version number of the crate when adding a
new variant.

Note that these errors are never matched on, so no other code is changed in
dependent crates.
2025-10-06 18:57:30 +02:00
Lorenz Leutgeb 30908dcf48 radicle/git/canonical: Actually use qualified refs
Some tests actually do not use qualified patterns. The removed lines
*should* not compile because the `qualified_pattern!` proc macro
*should* validate the string literals at compile time, but it contains
a bug and actually does not assert well-formedness of qualified
refspec patterns. Rectify.
2025-10-06 17:31:12 +01:00
Fintan Halpenny ee041d8d06 crates: bump for release
- `radicle-term`: 0.15.0 -> 0.16.0
- `radicle-node`: 0.15.0 -> 0.16.0
- `radicle-fetch`: 0.15.0 -> 0.16.0
- `radicle-crypto`: 0.13.0 -> 0.14.0
- `radicle-cli`: 0.16.0 -> 0.17.0
- `radicle`: 0.19.0 -> 0.20.0
- `radicle-cob`: 0.16.0 -> 0.17.0
- `radicle-remote-helper`: 0.13.0 -> 0.14.0
- `radicle-protocol`: 0.3.0 -> 0.4.0
- `radicle-systemd`: 0.10.0 -> 0.11.0
2025-10-06 16:36:30 +01:00
Lorenz Leutgeb 2149770a4b
storage: Rewrite temporary repositories for clones
On Windows, all attempts to clone repositories failed with

    Fetch failed for rad:… from z6Mk…: Access is denied. (os error 5)

The reason is that, other than Unix-like systems, it forbids that
directories that are in use are moved.

To improve the situation, take back control over what is moved and
removed exactly by implementing `cleanup` instead of relying
on `impl Drop for tempfile::TempDir`.

A new type `TempRepository` is introduced to capture a repository that can be
used temporarily, and either cleaned up on failure, or moved on success.
This `TempRepository` can be constructed using `Storage::temporary_repository` –
renamed from `Storage::lock_repository` since it is only creating a temporary
resource and not locking it.

In the future (once Rust 1.89 is a little less cutting edge and more
widely available), we may opt for actual locking via
`std::fs::File::lock`.
2025-10-06 11:52:42 +02:00
Lorenz Leutgeb 31a7d3bd3f
fetch: add `Handle::into_inner`
Adds an `into_inner` method to deconstruct the `Handle` back into the underlying
repository type.
2025-10-06 11:52:42 +02:00
Fintan Halpenny e40fe86ff8 fetch: use `AsRef<Repository>`
Allow the fetch interface to accept anything that implements
`AsRef<Repository>`. This allows flexibility in the types that the `Handle` can
accept.

This change is motivated by wanting to introduce a type that is a temporary
repository that wraps a `Repository`.
2025-10-06 11:52:42 +02:00
Fintan Halpenny a163f4e939 fetch: refactor repository access
The interface of the `Handle` has two methods: `Handle::repository` and
`Handle::repository_mut`. However, the calling logic would always access the
`Handle::repo` field.

This is cleaned up by making this field private, and using the
`Handle::repository` method instead. There were no calls to `repository_mut`,
and so the method was removed.
2025-10-06 11:52:42 +02:00
Lorenz Leutgeb 5caa7b302a remote-helper: Check base when matching revisions
It is impossible to preserve the head of a revision and only change
the base of same revision via push.

Strenghthen the precondition for skipping updates to also consider the
base commit.
2025-10-03 11:30:22 +01:00
Lorenz Leutgeb 9bb136105c remote-helper: Only update patch after evaluating base
Without quorum for the default branch, the remote helper would report
an error, suggesting that the patch was not updated, while,
inconsistently, actually updating the ref in storage without creating
a new revision.

    $ git push …
    To rad://z…5/z…z
    …
     ! [remote rejected]       612… -> patches/a77… (…)
    error: failed to push some refs to 'rad://z…5/z…z'
    …
    $ git ls-remote rad://z…5/z…z
    612…        refs/heads/patches/a77…

This is very confusing.

Fix this by using a temporary reference name that is different from the
reference name that the patch would use, implementing cleanup via
`Drop`.

While at it, also move the logic into `patch_base` and share it
between `patch_open` and `patch_update`. Computation of the canonical
head via `stored.canonical_head` is moved to a branch that is only
taken if the user did not specify a base explicitly. This allows to
update patches even when there is no quorum for the default branch.
2025-10-03 11:30:22 +01:00
Lorenz Leutgeb 5cd016b587 radicle-systemd: Guard `mod listen` for Unix
This crate does not build on Windows, because there is a Unix-only `use`
in `mod listen`. To get the crate to build, guard the module
appropriately.
2025-10-02 15:46:56 +01:00
Lorenz Leutgeb 9c8ab7fa62
fetch: Rewrite `git::repository::direct`
This function (and the helpers `ancestry` and `find_and_peel`) are
eagerly peeling to commits, leading to updates of tags that target the
same commit to be missed.

For example, there could be tag two tag objects with *different* OIDs
A and B, from *different* authors, using *different* tag names, signed
with *different* secret keys, and both pointing to *the same* commit C.

The implementation would consider A and B to be the same, just becuase
A and B both peel to C, skipping the update.

This is counterintuitive, and when combined with canonical references
can be quite confusing.

Change this to only reason about an ancestry if the two objects in
question really both are commits directly. Otherwise, treat cases where
no structure can be used as ancestry similarly to non-fast-forward
updates.
2025-10-02 12:31:38 +02:00
Lorenz Leutgeb d9ce078d56 protocol: Decrease log-level for logging ping/pong
When logging writes, use a lower more verbose level for ping and pong,
as these messages are quite noisy.
2025-10-02 10:47:29 +01:00
Lorenz Leutgeb 474b97950b
node/log: Define syslog identifier
The argument passed to `fn logger` would only be used as a fallback.
Make it required to pass an identifier, as this is a good practice.
2025-10-01 16:46:46 +02:00
Lorenz Leutgeb ee49e28766 cli/unfollow: Use clap 2025-10-01 14:36:39 +02:00
Lorenz Leutgeb 6fb1ebec45 cli/clean: Use clap 2025-10-01 14:12:22 +02:00
Lorenz Leutgeb 753b7aef93 cli/path: Use clap 2025-10-01 13:04:28 +02:00
Lorenz Leutgeb 01f9f3fcd4 cli/unseed: Use clap 2025-09-30 15:13:09 +02:00
Lorenz Leutgeb 80bc95269b
cli/stats: Use clap 2025-09-29 16:44:18 +02:00
Lorenz Leutgeb f1c7c98607
cli/issue: Move definition of "about" to args 2025-09-28 19:47:50 +02:00
Christopher Fredén c7bff28452 cli/issue: Use clap
A rewrite of the argument parsing portions of the `rad issue` subcommand
using `clap` instead of `lexopt`.

From a user's perspective, the look-and-feel of `rad issue` does not
change much. Although, the most prominent change is to rely on
`clap`'a default error template which looks a bit different from what we
use usually (`error: ...` vs. `✗ Error: ...`).

Leaving the above restriction aside, subcommand mis-usage is
reported more verbosely.

Also configure `clap` to use colored output for errors and help pages.
In help output, headers are colored with `Magenta` to match the overall
CLI styling.

Specify a type that captures the different actions that can be take
when using the `comment` command: `Comment`, `Reply`, and `Edit`.
Move the functions that run the corresponding actions into a `comment`
module.

To preserve the "default command" behaviour being `rad issue list`,
e.g., `rad issue --solved` behaving like `rad issue list --solved`,
introduce a new type `EmptyArgs`to also parse arguments without a
subcommand. In case no subcommand was parsed, construct `Command::List`
with from `EmptyArgs`.

Co-authored-by: Matthias Beyer <mail@beyermatthias.de>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
Co-authored-by: Erik Kundt <erik@zirkular.io>
Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2025-09-28 18:02:55 +02:00
Lorenz Leutgeb 675a0f81d9
cli: Depend on clap 2025-09-28 18:02:55 +02:00
Lorenz Leutgeb 5a958b5ebd
cli/test: Output of `rad --help`
With migration subcommands to `clap` planned one-by-one,
prepare this to catch regressions.
2025-09-28 18:02:19 +02:00
Lorenz Leutgeb 22720e718b node: Make location of secret key configurable
With this change, the location of the secret SSH key can be configured
through `${RAD_HOME}/config.json` so that the node key does not have to
be placed under `${RAD_HOME}/keys` anymore.

Further, there is now an option to override `config.json` directly when
executing `radicle-node` via the command line argument
`--secret`.

The primary motivation is more flexible deployments, for example
leveraging external secret management solutions, like
<https://systemd.io/CREDENTIALS/>.

The secret key is fingerprinted by taking the fingerprint of the public
key corresponding to the secret key. This allows to detect when the
secret key changes.
2025-09-26 13:03:57 +01:00
Lorenz Leutgeb 5887edf93b
crypto/ssh/keystore: Explicit paths
The implementation of `Keystore` requires a particular layout and naming
of keys. This is a rather strong limitation. Lift it and allow
specifying an arbitrary path for the secret and public key.

As it is possible to derive the public key from the secret key, make
the public key in `Keystore` optional. Also allow constructing
`MemorySigner` can now be initialized without a public key, by
deriving it.
2025-09-26 13:21:38 +02:00
Lorenz Leutgeb 9e1d6b1feb radicle: Detect current repository using `jj`
When using Jujutsu and a non-colocated Git repository, the detection
using `git2` directly fails (just as `git` in a shell would fail)
because there is no `.git` directory found by traversing up the
filesystem hierarchy.

Add an invocation of `jj git root` as a fallback.
2025-09-26 12:03:01 +01:00
Lorenz Leutgeb abc963f2f2 radicle-cli/tests: Add `rad_jj_patch` 2025-09-26 12:03:01 +01:00
Lorenz Leutgeb fd5043d572 radicle-cli-test: Prepare testing with `jj`
Most of this is taken from Jujutsu's own testing setup, see:
98d884827e/cli/tests/common/test_environment.rs (L106-L150)

Not all features are preserved, but this is good enough.
2025-09-26 12:03:01 +01:00
Lorenz Leutgeb 53522288c1 radicle-cli/tests: `fn program_reports_version`
Introduce this `fn` to check whether a program is available.
2025-09-26 12:03:01 +01:00
Lorenz Leutgeb fafb3493dc
cli: Detect key mismatch
When run with a secret and public key that do not cryptographically
match, `fn radicle_cli::terminal::io::signer` would prompt the user
for a password to unlock the secret key, and then carry on with a
mismatching key pair.

Fix this by verifying that the keys match in `MemorySigner::load`
and only swallow errors initializing the signer in cases where
prompting for a password makes sense. It does not make sense in the
case of mismatched keys.
2025-09-26 00:33:59 +02:00
Fintan Halpenny ed8b086045 node: Log Panics
Register a panic handler that logs a backtrace via the `backtrace`
crate, instead of setting `RUST_BACKTRACE`.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xy>
2025-09-24 10:51:34 +01:00
Defelo 0441b048f9
cli: Don't add newlines for empty descriptions in editor 2025-09-23 19:52:54 +02:00
Defelo ae01a42434
radicle: Allow to clear issue descriptions and comments
Previously it was possible to create an issue with an empty description
(i.e. an empty "root" comment), and also to change it later to a
non-empty string, however it was not possible to clear it again.
2025-09-23 19:52:54 +02:00
Defelo ec22c94321
cli/issue: Show previous title in `rad issue edit` editor 2025-09-23 19:52:53 +02:00
Defelo 9f62a82b0b
radicle: Fix `cob::common::Title::new`
The title should be trimmed before checking whether it is empty.
Also added a few tests.
2025-09-23 19:52:52 +02:00
Sebastian Martinez 5fea9ac05c node: Add `--log-logger structured` and `--log-format json`
Optionally depend on crate `structured-logger`. Allow enabling it via
`--log-logger structured`. For future compatibility, provide
`--log-format` which currently only supports JSON.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-09-23 16:33:50 +02:00
Lorenz Leutgeb e563117397 node: Refactor logging initialization
Logging initialization was infallible previously, i.e., a logger would
always have to be chosen, falling back to our own logger
implementation in case of failure with setting up journald submission.

This lead to complexity like attempting to log errors from parsing
arguments, as there is a circular dependency.

Change this to make logging initialization fallible. If it fails, exit
non-zero instead of falling back to another logger. This makes the
initialization code slightly simpler.

At the same time, make choosing the logger possible via the command
line and deprecate `--log`.

Note that we still default to journald if detected.
2025-09-23 16:33:50 +02:00
Yorgos Saslis 9793b4e7b6 systemd: Require Linux for journal module
The dependency `systemd-journal-logger` does not build on macOS, and
there are no tests for other Unixes. Also, systemd is most common on
Linux.

To avoid compilation errors on non-Linux platforms, only depend on the
crate when building on Linux.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-09-19 15:39:53 +02:00
Defelo e70850cb36 remote-helper: Add patch.branch option 2025-09-19 07:57:44 +01:00
Lorenz Leutgeb 7b00bf2e3a cli/patch/review: Obsoletion Warning
As discussed in:
<https://radicle.zulipchat.com/#narrow/channel/369873-Support/topic/new.20to.20reviewing.20patches/with/533862639>
2025-09-17 13:32:50 +01:00
Lorenz Leutgeb 8dd17e2a60 cli/warning: Add `fn obsolete`
A helper to print obsoletion warnings to stderr.
2025-09-17 13:32:46 +01:00
Lorenz Leutgeb 7d1db6a013
cli/diff: Deprecation Warning
This command is just a small wrapper around `git diff` not worth
maintaining.
2025-09-17 10:35:15 +02:00
Lorenz Leutgeb 8558cc2233
cli/self: `--nid` deprecation warning to stderr
Printing the warning to standard output breaks scripts.

Instead, print to standard error.
2025-09-17 10:31:53 +02:00
Lorenz Leutgeb 3fb04623a4
cli/warning: Add `fn deprecate`
A helper to print deprecation warnings to stderr.
2025-09-17 10:31:25 +02:00
Lorenz Leutgeb 2635562c92
cli/node/status: Add `--only nid` 2025-09-17 10:31:21 +02:00
Erik Kundt d2e10fdef6 cli/tests/commands: Clean up test `rad_patch`
This removes the `rad issue` test examples from being used in the
`fn rad_patch` test example execution. Removing it here is fine, since
it is being executed on its own anyways.
2025-09-16 19:40:35 +02:00
Sebastian Martinez 19210faab8 protocol/service: Change `Routing table updated..` from info to debug 2025-09-16 13:38:26 +01:00
Lorenz Leutgeb 86472fdccb
remote-helper/fetch: Improve error handling 2025-09-16 11:51:08 +02:00
Lorenz Leutgeb f542df1833
radicle: Use `git fetch-pack` for "local fetch" 2025-09-16 11:51:08 +02:00
Lorenz Leutgeb 20663a4e39
remote-helper: Use `git send-pack` for "internal push" 2025-09-16 11:44:56 +02:00
Lorenz Leutgeb f9ff484c9e cli: Make `rad patch show` prettier
The output of this command is confusing. It is not clear which of the
hashes printed is that of the revision and which one is the respective
head commit.

Further, the hash is omitted on the initial revision, adding confusion.

Further, the terminology of "revised" vs. "updated" is confusing.

This rewrites `timeline.rs` to drop the distinction between various
revisions (in wording, the small icon is still different) and cleans up
the output.

Attention is paid to alignment of the output. Now all verbs of updates
("accepted", "rejected", "reviewed", "merged") are aligned, and authors
("… by …") are also aligned.

The rewrite itself is not for better code quality or readability.
Note that all the code in this file only accessed via one `fn` by one
callsite in the implementation of `rad patch`.
2025-09-16 11:37:13 +02:00
Lorenz Leutgeb 43246fe6c8 remote-helper: Parse base revision early
Translation of the string passed as the value for push-option base
happens delayed.

Change this by parsing as soon as the value is written.

This also decreases the dependency fingerprint on `radicle-cli`.
2025-09-15 16:28:02 +01:00
Lorenz Leutgeb ef27961866
remote-helper: List `HEAD`
Report the default branch correctly via the symbolic reference `HEAD`.
2025-09-15 17:10:29 +02:00
Fintan Halpenny 14fcf50677 docs: fix doc string linking 2025-09-15 10:34:42 +01:00
Lorenz Leutgeb ee9e6de5f3 remote-helper: Do not assume remote name
Avoid ending up with an upstream to a potentially non-existent remote
when pushing to an anonymous remote.
2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 6b9ff4f99e cli/init: Allow `--setup-signing` with bare repos
The `--setup-signing` flag is a no-op when combined with `--existing`
and errors on bare repositories.

Make it effective in combination with `--existing` and also rewrite it
to support bare repositories, gracefully falling back to just avoid
writing to `.gitsigners`.
2025-09-15 10:21:09 +01:00
Lorenz Leutgeb fd93240b9d cli/git: Remove dead code `fn view_diff` 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 86ea33b0ca cli/clone: Add flag `--bare` 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 766e281d39 radicle: Allow creating bare clones 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb e528c40a07 radicle-cli: Test initializing from bare repos 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 606882f01f remote-helper: Simplify handling of `GIT_DIR`
The contract for Git remote handlers says that we can expect
`GIT_DIR` to be set, and this also simplifies logic regarding
bare vs. non-bare repositories.
2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 354565c579 radicle: Handle `GIT_DIR` more uniformly
Pull specification of the working directory into `radicle::git::run`,
to unify how higher level wrappers pass it down.
2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 4e67467966 remote-helper: Refactor option handling
Group `["option", "progress", ..]`, and `["option", ..]` cases together during
match.

Make the key/value matching cleaner using `ok_or_else` and then matching on the
key value.
2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 876d22b072 remote-helper: Remove unused push error variant 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 550fcccc27 remote-helper: Do not hard-code binary name 2025-09-15 10:21:09 +01:00
Lorenz Leutgeb 897404164b remote-helper: Make crate binary-only
This crate is not a library, i.e., it is not intended to be depended
upon by other crates. Rather, it implements the `git-remote-rad`
binary.

Reflect this by moving `lib.rs` to `main.rs`, merging it with
`git-remote-rad.rs`.
2025-09-15 10:21:09 +01:00
Fintan Halpenny 66adbffd61 term: Use static template in spinner initialization
Use `static` + `LazyLock` to ensure that the templates evaluation only
happens once and the value can be re-used on each subsequent access.
2025-09-15 11:17:35 +02:00
Erik Kundt 8fc37e3316 term: Move to indicatif spinner
This fixes line flodding on narrow terminals and a missing cursor after
cancelation by replacing the custom spinner with an indicatif spinner.
2025-09-15 11:17:35 +02:00
Erik Kundt ee9ecfda76 remote-helper: Remove `SyncWriter` in favor of `PaintTarget` 2025-09-15 11:17:35 +02:00
Erik Kundt 153a8f9fbe node: Remove `SyncWriter` in favor of `PaintTarget` 2025-09-15 11:17:35 +02:00
Erik Kundt 11a109ef41 term: Introduce `PaintTarget`
This introduces a `PaintTarget`, that defines the stream an operation
uses to draw to (`stdout`, `stderr`, `sink`). It will be used in
subsequent commits to configure the new spinner.
2025-09-15 11:17:35 +02:00
Lorenz Leutgeb 379037956a remote-helper: Prevent doubly verifying each push
The context of the invocation of `git push` "internally" by the
remote helper is the same as by the user invoking `git push` most
of the time. That is, these pushes run within the same repository,
thus the configuration for pre-push hooks applies to both. This
leads to every push being verified *twice*.

If the user intends to configure pre-push hooks, then they would
do that on the remote with URL `rad://…`, and so the hook would
be executed before `git-remote-rad` even gets called.

We thus specify `--no-verify` to not verify again.
2025-09-11 16:59:12 +01:00
Lorenz Leutgeb a0f6cbf5f1 radicle: Move interpretation of output to binary
`radicle::git::run` interprets the `Output` returned by the `git`
process. However, depending on the application we have different
requirements for interpreting the output, e.g., how to handle errors.

Make `radicle::git::run` not interpret `Output`, but move this
logic to the respective binary crates (`radicle-remote-helper` and
`radicle-cli`).
2025-09-11 16:59:12 +01:00
Lorenz Leutgeb 0a8317c35f remote-helper: Interpret verbosity option
The `verbosity` option is ignored, which makes it more difficult to
obtain debugging information if the "internal" push, i.e., the
`git push` invocation by `git-remote-rad` fails.

Provide two types for verbosity, and wire them up.
2025-09-11 16:59:12 +01:00
Fintan Halpenny 11e8b89b20 radicle/src/git: additionally specify pruneTags for remote
Ensure that, when adding a remote, `pruneTags` is set to `false` so
that tags are not pruned when fetching from a remote's namespace.
2025-09-11 11:25:34 +01:00
Matthias Beyer 646d4360e7 cli/node: Replace manual pushing with Table::extend()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:29:47 +02:00
Matthias Beyer 2f28232676 cli/issue: Replace manual pushing with Table::extend()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:29:36 +02:00
Matthias Beyer 8554e996b8 cli/diff: Replace manual pushing with Table::extend()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:28:53 +02:00
Matthias Beyer fbef60eed6 cli/sync: Replace manual pushing with Table::extend()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:27:59 +02:00
Matthias Beyer 370ae3643a cli/patch: Replace manual iterator partitioning with Itertools::partition_result()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:40 +02:00
Matthias Beyer 3f489354b6 cli: Add itertools dependency
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:30 +02:00
Matthias Beyer 9c2f97abe1 cli/remote: Replace manual building table from iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:30 +02:00
Matthias Beyer 4bd45cdabd cli/inbox: Replace manual building table from iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:30 +02:00
Matthias Beyer 016cab1dbf term/table: Add Table::with_opts() to set options after Table obj was constructed
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:30 +02:00
Matthias Beyer fb458537b4 cli/patch: Replace manual building table from iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:30 +02:00
Matthias Beyer 41a742ed9b term/table: Add impl FromIterator for Table
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-10 21:23:28 +02:00
Matthias Beyer ff021d5889 cli: Rewrite `#[path="…"]` module declarations
Rewrite module declarations that use the `#[path="…"]` annotation
to the more idomatic `pub mod …` + `pub use …` forms.

For the "self" module, that is not possible because `self` is an
identifier in Rust, and also `r#self` is not admissable as a raw
identifier, so stick to `rad_self`.

Files in submodules were patched as appropriate.
2025-09-10 21:09:29 +02:00
Matthias Beyer 11fc98c9c9
term: Replace manual Extend impl for Table
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-09-07 12:39:32 +02:00
Lorenz Leutgeb f00d1d6743 cli/self: Stop printing information about the node
To get to a point of separating the users' identity from the node, then the `rad
self` command should not display information related to the node so prominently.

The relation between `rad` and `radicle-node` is really similar to that between
`rad` and SSH Agent. They communicate via socket. So, when this connection is
successful, it is printed, but not more.

There may be some re-learning for users here, but it is worth the improvement.

Note that the information being removed here is available via `rad node status`
(see previous commit).
2025-09-04 17:12:19 +03:00
Lorenz Leutgeb e1af550a09 cli/node: Print Node ID
If we ever want to disentangle the users' identity from the node, then
the `rad node` commands must learn to print the information related to
the node, so here we go.
2025-09-04 17:12:19 +03:00
Lorenz Leutgeb 79505fa905 radicle/test/fixtures: Use "radicle.xyz" as `const`
Ideally, we would like to use a name that is compliant with RFC 2606,
such as "radicle.example.com", but this would change *lots* of hashes,
which is not worth the hassle.

Instead, make changing this in the future as easy as changing one
constant.
2025-09-04 16:44:05 +03:00
Lorenz Leutgeb 1a3fda547a radicle/explorer: Allow overriding default URL
This makes the default Radicle Explorer URL configurable at compile-time
via the environment variable `RADICLE_EXPLORER`.

In order to stay backwards compatible, we still default to
"app.radicle.xyz"
2025-09-04 16:44:05 +03:00
Lorenz Leutgeb e2c476a387 radicle/test: Don't hard-code "radicle.xyz" 2025-09-04 16:44:05 +03:00
Lorenz Leutgeb 2127782b74 term: Remove dependency on `anyhow`
As a library crate, it is bad to return such generic errors.

To get there, errors from `inquire` are downcasted.

This allowed to clean up the public interface of `radicle-term`, so that
it does also not leak the `inquire::InquireError` in its public API.
2025-09-04 16:28:20 +03:00
Lorenz Leutgeb edd88a59bf term: Remove `mod command`
This is dead code that imports `anyhow`. On the way to removing the
dependency on `anyhow` from `radicle-term`, it just seems to be a good
idea to remove the cruft.
2025-09-04 16:28:20 +03:00
Lorenz Leutgeb 79d928551b node: Remove dependency on `anyhow`
`anyhow` is only used to capture a handful of errors. It also turns out that
usage of `lexopt` was wrong, since it features `parse_with`, which neatly
integrates with `FromStr`. The types, luckily, implement this trait already –
making for cleaner parsing.

For now, the execution errors are all "transparent", which shouldn't be
much of a regression, if at all.
2025-09-04 16:28:20 +03:00
Matthias Beyer 55cdd880bf radicle-term: Pass in `mut self` rather than rebinding
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:18:33 +02:00
Matthias Beyer 19c484e956 radicle-term: Optimize impl of VStack::children()
This way the Iterator::size_hint() function can be used by the
Extend::extend() implementation, which might safe reallocations for
the underlying buffer.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:18:33 +02:00
Matthias Beyer 93388e366c radicle-term: Preallocate in Line::spaced()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:18:33 +02:00
Matthias Beyer 3036509e42 radicle-term: Add testcase for Line::spaced()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:13:32 +02:00
Matthias Beyer 23b9d30639 radicle: Remove unnecessary clone()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:13:32 +02:00
Matthias Beyer 29a95fb1a6 radicle-fetch: Replace manual std::matches!() impl
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2025-08-27 23:12:50 +02:00
Lorenz Leutgeb ded0d19d59 protocol/wire/test: Define `fn roundtrip` and macro
In many tests we assert that encoding and decoding gives the same
object. Let's call that a "roundrip", and also provide a proc macro to
generate such tests.
2025-08-27 12:48:11 +02:00
Fintan Halpenny bbd1e2cff6 crates: 1.4.0 release
Update crate versions for the 1.4.0 release
2025-08-27 10:30:28 +01:00
Lorenz Leutgeb 819ae5fdf5 node/main: Refactor initialization of logging
It turns out that failing to read configuration resulted in no output,
because the logger would only be set after configuration had been read.

Fix this, by setting the logger early, with a log level that is then
corrected as soon as configuration is available.

While at it, also clean this up to allow logging errors about failure to
set up the logger.
2025-08-27 11:17:18 +02:00
Fintan Halpenny 7d2f0e387c node: e2e test for canonical ref update
Adds a test to ensure that canonical reference updates are received on the node
events stream.

Added a helper to `NodeHandle` for perfoming a commit to a reference and signing
the nodes references, to help with this use case.
2025-08-25 18:49:43 +01:00
Fintan Halpenny 0d96af5d07 node: update default branch for canonical refs
After a fetch is performed, `set_head` is called, which essentially updates the
default branch based on the canonical reference rule for that branch.

Later, `set_canonical_refs` is called, which originally could be the empty set
of rules. This would mean that the event for the default branch would never be
emitted.

The approach taken here is to always use the default branch rule if there are no
rules set in the identity document. Unfortunately, this ends up in computing the
default branch twice, due to `set_head`.

Another approach is to use the result of `set_head` to update the set of
`UpdatedCanonicalRefs`, to prevent the need for defaulting to the default branch
rule. However, this does not prevent the double counting as soon as the rules
are added to the identity document, since the default branch rule will then be
synthesised into the rule set.
2025-08-25 18:49:43 +01:00
Fintan Halpenny c38b9d9e1e node: simplify canonical reference calculation
The logging version was verbose, and not required. It also could end up double
processing canonical reference updates since multiple remotes may update the
same reference.

Instead, use `filter_map` to convert all the reference names, stripping
namespaces, and collect them into a `BTreeSet` to ensure uniqueness.
2025-08-25 18:49:43 +01:00
Fintan Halpenny a8255a2e07 Introduce a node event for canonical reference updates
Whenever the node fetches new updates, it checks if canonical references can be
updated. The node has learned how to return these results and emit them as node
events. This is a breaking change since it adds a new variant the `Event` type,
which is not forwards-compatible.
2025-08-25 18:49:43 +01:00