Commit Graph

2453 Commits

Author SHA1 Message Date
Lorenz Leutgeb c7f3c47f9a systemd: Add module for logging to the journal 2025-08-07 08:30:59 +01:00
Lorenz Leutgeb 2776e003dc systemd: Move socket activation to module 2025-08-07 08:30:59 +01:00
Fintan Halpenny 7a9d4512f9 radicle: fix Canonical::quorum doc link 2025-08-05 15:00:26 +01:00
Lorenz Leutgeb 5d467418be term: Revert using inquire to spawn editor
This is morally a revert of 70fb0d3fef
while additionally getting to compile
`crates/radicle-term/src/editor.rs` on Windows.

To get the changes that were made on top of the revert, check

  git diff 70fb0d3fef~1 <this commit> -- crates/radicle-term/src/editor.rs

There were reports of the inquire editor being unrealiable.
2025-08-05 15:09:43 +02:00
Lorenz Leutgeb 4934473b86 cli/node: Improve log rotation
Only the latest log was kept as `node.log.old`. Now, log files are
numbered (`node.log.1`, `node.log.2` and so on). Also `node.log` is now
a hard link to the current log file. `rad node stop` will delete
`node.log` (note that `node.log.x` stays intact) and `rad node start`
will delete `node.log` before it creates `node.log.y` in case the node
crashed.

Also, when running in foreground mode, now a log file is created. It
just contains the hint that the node was started in foreground mode,
just to avoid confusion.

The implementation is split into a sans I/O part as `struct LogRotator`,
while the I/O counterpart is captured by `struct LogRotatorFileSystem`.
2025-08-04 17:13:11 +02:00
Lorenz Leutgeb 3d352f23e6 canonical: Support Annotated Tags
The logic for computing canonical references conflated the semantics of
annotated and lighweight tags, yielding confusing/wrong results. The
main culprit was the call to `peel_to_commit` in
`impl ReadRepository for Repository`, peeling tag objects away.

To resolve this, we separate out quroum computation per object type: one
implementation for commits, and one for tags.

Also move  move canonical error types and methods into their own
module to have a cleaner file structure for the main logic.

Capture the `BTreeMap<Oid, u8>` type into a `Votes` struct, with its own API.

We were getting the objects from the repository twice – once in `Canonical::new`
and once again in `ensure_commit_or_tag` – so the latter was removed.

Use an `enum CanonicalObject` to specify which object types the canonical
process supports.

During `converges`, separate commits and tags, and ensure that we are only
looking at objects of one type. Note, that Fintan think this is actually the
*wrong* place to do it because we already filter the objects – so we should
keep track of that information higher up the callstack.

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2025-08-04 17:00:54 +02:00
Erik Kundt 54fd8c40a0 node: clean up logging
Do not print errors to stderr anymore if logger is not enabled
2025-07-30 13:41:17 +01:00
Fintan Halpenny 174792813a node: register backtrace
To better help debugging when things go wrong after `radicle-node` crashes,
`RUST_BACKTRACE` is registered in the `main`. According to this [StackOverflow
answer][so], this should not affect performance

[so]: https://stackoverflow.com/questions/29421727/how-much-overhead-does-rust-backtrace-1-have/45402131#45402131
2025-07-30 13:41:17 +01:00
Fintan Halpenny 0aaa81f82a cli: mention binary names as part of unknown
When we fail to get the info for the binary names of `radicle-node` and
`git-remote-rad`, we still mention the binary name which is usually a part of
their output.
2025-07-28 11:38:24 +01:00
Lorenz Leutgeb fdb1ac4e3a radicle: Fix clippy::result_large_err
After upgrading from Rust 1.85 to 1.88 in 586eefc, clippy started
warning about large error types. Box action to make
`radicle::cob::patch::Error` lighter.
2025-07-27 23:32:39 +02:00
Lorenz Leutgeb 5bab3f9cc0 clippy: Allow doc_overindented_list_items
After upgrading from Rust 1.85 to 1.88 in 586eefc3e4,
clippy now warns about "overindented" lines in comments. I did not
manage to fix this by hand without breaking the second level of the
lists in question.

See
 - https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
 - https://github.com/rust-lang/rust-clippy/issues/14275
2025-07-27 23:32:02 +02:00
Lorenz Leutgeb 9068033789 chore: Automated fixes generated by clippy 2025-07-25 11:25:05 +02:00
Lorenz Leutgeb 586eefc3e4 rust-toolchain: 1.85 → 1.88 2025-07-24 17:43:12 +02:00
Sebastian Martinez efeefd0daa chore(debian/changelog): update package version to match upstream 2025-07-23 11:34:20 +02:00
Fintan Halpenny 2a47bc0c7d term: provide default HELP message
Provide a default message that informs the user of the `(e)`, `(enter)`, and
`(esc)` functionality.

Unfortunately, it is not possible to provide any message that is better
customised to each case, due to `inquire` requiring a `'a` lifetime on all its
inputs – this rules out providing any kind of `String` input.

The first paramter of `Editor::new` can already be used to provide more
contextual information. The second parameter is left configurable, but for now
`Editor::HELP` is used everywhere.
2025-07-23 10:31:15 +02:00
Fintan Halpenny a998ce691d ssh: provide path on connect error
Provide the path that is being used for connecting to the SSH agent, when an I/O
error occurs.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 8224819fed radicle/profile: Enable home detection on Windows
To avoid that users on Windows have to explcitly set `HOME`, also accept
`USERPROFILE` which is considered equivalent.

To avoid repeating to join `.radicle`, split the logic up into two
phases. Also take care to provide a good error message, as this error is
fatal and user-facing.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 1e0a14ddcf ssh: Remove dependency on log 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 8e6279a382 ssh: Remove dependency on byteorder 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 95b3303eb9 term: Remove unused dependency shlex 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 009436efac ssh: Use winpipe for SSH agent on Windows
The trait `radicle_ssh::agent::client::ClientStream` trait was
simplified, because `winpipe::WinStream` is so similar to
`std::os::unix::net::UnixStream` that we can just use the same
implementation for both platforms.

However, obtaining the process identifier of the SSH agent process is
not common on Windows, so we instead track the path that we used to
connect to the agent. This is also helpful on Unix. In some cases, the
path will even contain the process identifier. The path is printed by
`rad self`.

Errors are cleaned up, and error messages are improved.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 0705501537 radicle: Depend on winpipe for Windows support 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 08b535d567 radicle: Only set file limits on Unix 2025-07-23 10:31:13 +02:00
Lorenz Leutgeb e7fb5647ac term: Remove dependency on libc
Introducing the new enum `TerminalFile` to model which standard stream
stream the terminal uses allows us to remove the dependency on `libc`
which does not build on Windows.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb 70fb0d3fef term: Use inquire for spawning the editor
`radicle-term` includes quite a lot of rather "low-level" logic to spawn
the preferred editor of the user. In particular, this logic is
platform-dependent and only works on Unix-like platforms.

Also, `radicle-term` already depends on `inquire` which features an
editor prompt. It is a cross-platform solution to spawn the editor.
This commit changes the implementation of `Editor` to be a wrapper of
`inquire::Editor`, keeping the interface mostly intact.

Downsides:
 - We cannot edit a file "in place" this way, instead we have to read
   it, as `inquire` only supports editing temporary files. This can also
   be viewed as a benefit, as we lessen the risk of corruption of these
   files.
 - `inquire::Editor` contains borrows, so it is quite cumbersome to
   extend it with a custom mechanism for looking up the preferred
   editor. The lookup logic was kept, but needs to be invoked by the
   caller. In the future we might consider just using the logic provided
   by `inquire` or requesting a change to `inquire`.
 - The prompt is a bit strange. It does not show the current state of
   the output, see <https://github.com/mikaelmello/inquire/issues/280>
   and <https://github.com/mikaelmello/inquire/pull/271>.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb a28fd65e89 term/ansi: Remove unused Windows module 2025-07-23 10:30:33 +02:00
Lorenz Leutgeb d46d36ecee term/spinner: Only handle signals on Unix
The `radicle-signals` crate only supports Unix, so using it prevents
`radicle-term` to build on Windows.

Of course, this means that non-Unix platforms will not support any
signal handling at all, but at least we can build.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb 92d77f9ec3 crypto/ssh/keystore: Reduce scope of DirBuilderExt
Directory builder extensions are platform specific and only available on
Unix. Move their use into a conditionally compiled block, so that we can
build on Windows.
2025-07-23 10:30:33 +02:00
Sekhat Temporus 37ea81766e cli: improve default branch pick
When using `rad init` the default branch for the project can be predetermined by
inspecting the working copy repository.

To improve the experience, it will first check `init.defaultBranch` in the Git
configuration file.

If it does not find this, it falls back to choosing the default head of the
repository at the time. This may be HEAD, and in this case it will error and
provide helpful information.

The repository may also not have any default head at the time, and this also
results in an error and hint.
2025-07-23 07:43:27 +01:00
Ivan Stanković 85ddcace0a docs: fix installation instructions in README.md
Crates have been moved, so make sure the paths are correct.
2025-07-20 15:33:12 +00:00
Tobias Hunger 7c4b71ab82 radicle: Keep pinned repos ordered in config
Do not return them in a random order in radicle-httpd,
so that we can have them in a defined order in
radicle-explorer.
2025-07-19 12:59:02 +01:00
Fintan Halpenny 1fa30e2e88 cli: test missing commits for canonical quorum
Test the scenario where 2 delegates are collaborating, where one delegate is
missing the other's commit while pushing to the default branch.
2025-07-19 12:32:45 +01:00
Fintan Halpenny afe64d5175 remote-helper: improve canonical handling
This set of changes refactors the canonical handling by isolating the business
logic into another type, `Canonical`.

The functionality remains the same, but certain error scenarios are better
handled. Primarily, the commits of the inner `Canonical` type are checked to see
if they exist in the working copy, and if not, provide a more useful message
about which commit was missing or invalid for which DID.
2025-07-19 12:32:31 +01:00
Fintan Halpenny 14444a43ea remote-helper: refactor pushing action
Reduce the nesting of if statements by using a `PushAction` enum that is
constructed by checking the `dst` reference and parsing the correct action, one
of:

- `OpenPatch`
- `UpdatePatch`
- `PushRef`

This makes the intent of the code a little bit more clear and reduces the tabbing
of big code blocks. It also captures the error specifically for handling the
parsing of this `dst` reference.
2025-07-19 10:53:51 +01:00
Tobias Hunger a9f75d47ec remote-helper: allow any revision in push src
This allows any revision that can resolve to an object. The `src` side of the
refspec is resolved to its corresponding `Oid` which is further used for remote
helper pushing and patch creation/update.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-07-18 22:22:43 +01:00
Tobias Hunger da72557cf7 git-remote-rad: Allow pushing from bare repositories
Bare git repositories are meant to fetch into/push from and
fetching works, but pushing from a bare repo into radicle-storage
was prohibited.

This is a problem for me as I want to use `jj`, which uses
a bare git repository in the back (when not co-located into
a "normal" git repository).
2025-07-18 22:04:07 +01:00
Lorenz Leutgeb 271ef497d7 crypto: Fix scope of `ssh-key` dependency
`radicle-crypto` is the only crate that actually depends on `ssh-key`. I
overlooked that previously and added it as a workspace dependency. Now I
am limiting its scope again.
2025-07-18 21:52:43 +01:00
Lorenz Leutgeb 0e3f3f03d2 cli: Improve formatting of Node IDs and addresses
Pay more attention to when a Node ID is displayed in compact form. As
this was sometimes used to save space, e.g. in `rad node status` in
combination with long node addresses (like .onion names), also implement
a compact format for node addresses and use that instead in some cases.
Progress notifications in spinners keep the short form.
2025-07-18 21:44:06 +01:00
Fintan Halpenny 010d5134e8 protocol: fix `Frame` docstring
The `[T]` and `[I]` are interpretted as links when running `cargo doc`. This
table is surrounded in a code fence to prevent this, but also provide a better
view of the table when rendered to HTML.
2025-07-17 08:57:50 +01:00
Lorenz Leutgeb 3c5668edd2 protocol: Reimplement encoding on top of `bytes` 2025-07-16 21:15:55 +02:00
Lorenz Leutgeb 1c20f64a26 node, protocol: Refactor
Mostly changes of `use`s and moving components to `radicle-protocol`,
with the goal of just getting `radicle-node` to work on top of the new
`radicle-protocol` crate.
2025-07-16 21:15:52 +02:00
Lorenz Leutgeb 61c468778a protocol: Create skeleton by moving from radicle-node
This commit will not build. If you are reading this while bisecting,
please skip this commit. It is not fixed to build to get clean renames.
2025-07-16 21:12:42 +02:00
Lorenz Leutgeb b9759c5868 radicle: Make `node::Link` copy and add `is_*`
This will allow us to replace `netservices::LinkDirection` with
`radicle::node::Link` in a drop-in manner.
2025-07-16 21:12:42 +02:00
Fintan Halpenny 408d4f27e7 chore: add canonical references to CHANGELOG 2025-07-16 16:54:43 +02:00
Fintan Halpenny 8201225166 cli: test canonical tags
Add a test to exercise adding canonical reference rules and pushing new
canonical tags.

A change in `rad id` was required to allow adding a new payload to the document,
i.e. one that does not already exist.

Adding rules is also documented in the man page for `rad id`.
2025-07-16 16:54:43 +02:00
Fintan Halpenny ff365e2d8b radicle: disallow default branch
Ensure that the default branch is only ever synthesized from the `Doc`'s
`threshold` and `delegates` value. If the rule is ever written into a `RawDoc`,
then the update of the that `RawDoc` must go through the `update::veryify`
function, which checks that the rule is not present.
2025-07-16 16:41:16 +02:00
Fintan Halpenny a69397386a cli: extract document update logic
The business logic of modifying the identity document should not live in the CLI
code for updating said document.

Instead, we extract out that logic into separate update functions and these are
using from the CLI instead.
2025-07-16 16:41:16 +02:00
Fintan Halpenny 7f646666bc radicle: canonical references payload 2025-07-16 16:41:16 +02:00
Fintan Halpenny af6cf03acd radicle: canonical reference rules
Introduce the `rules` module beneath `canonical`. The implementation follows
the Canonical References RIP[^0].

A `Rule` defines the DIDs and threshold required to get the canonical tip
for a reference (or set of references). Since a `Rule` has some specific
validation rules, there can be two versions of a `Rule`. The `RawRule` is one
that can be easily constructed, serialized, and deserialized. It must then be
validated into a `ValidRule`, which validates any constraints, and can be used
in the computing of a canonical tip.

For convenience, a set of `ValidRule`s is wrapped into the `Rules` type, which
also has a further constraint that each rule refers to a specific `refspec`.

[0]: 1d1ce874f7
2025-07-16 16:41:16 +02:00
Fintan Halpenny fb8681f5bc radicle: `connect` returns `ConnectError`
Refactor the `connect` method to return a `ConnectError` so that it can be
reported via logging at call sites, and returned as an error from the node
handle.
2025-07-16 15:47:10 +02:00