Commit Graph

176 Commits

Author SHA1 Message Date
Alexis Sellier f7aac06a8f
cli: Polish `assign` and `unassign` commands 2023-03-13 12:27:47 +01:00
Alexis Sellier 8e5627d28a
node: Rename `tracked_repo` -> `repo_policies`
I was finding the current naming misleading, as the returned entries
could be for blocked repos/nodes.
2023-03-13 11:41:07 +01:00
Alexis Sellier b33fb2a33d
cli-test: Improve testing framework logging
Show which file is being run.
2023-03-13 11:38:33 +01:00
Vincenzo Palazzo f8aa1daedb
cli: show the issue when it is created
Show the issue when it is created to give feedback to the user.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-12 19:26:28 +01:00
Slack Coder 166f7e7cc2
cli: Minimize patch info on creation
Reduce noise when showing patch information to the user on creation by
only showing the git branch name and not the commit reference.
2023-03-11 18:38:54 +01:00
Alexis Sellier 34a2d1a9dc
cli: use canonical head for patch target
Correct assumptions made about how patching work in `rad patch`.  Make
the default Patch target a `git ref` in place of a target 'peer'.

Use the canonical head as the git reference.  This is head of the
project's master branch which project delegates have concensus on.
2023-03-11 18:38:54 +01:00
Alexis Sellier aacacf872f
cob: Use `EntryId` as the operation identifier
By introducing a small limitation: only allowing entries in the change
graph to be addressable, instead of individual operations; we
drastically simplify the CRDT implementation.

There are four advantages:

1. Op ids are just regular SHA-1s
2. There's no need for relative IDs, ops never refer to other ops within the
   same commit
3. There's no need for a nonce, since commits can't collide, and neither can op IDs
4. `OpId` can just be an alias of `EntryId`

The disadvantage of course, is that we have to be mindful of how we
create op transactions, since each transaction creates an addressable
unit. For example, we must not include multiple patch revisions in the
same transaction.
2023-03-09 17:08:56 +01:00
Alexis Sellier adbf6f5bf5
cli: Improve `patch` command
Cleanup and simplify output of patch command.
2023-03-08 20:23:49 +01:00
Alexis Sellier 1168f2ddb5
cli: Update `track` command
Allows the `track` command to be used to track nodes and repos.
2023-03-08 15:32:34 +01:00
Fintan Halpenny 1e8f5b2259
node: determine fetching namespace based on repo policy
To determine the correct Namespaces to use, the repo Policy and Scope
are consulted.

If the policy is Block then this is a failure state and is reported to
the other end.

Otherwise, if the policy is Track, then the scope is checked. For the
Trusted Scope then the Namespaces should consist of all tracked nodes
and delegates for the given repository. However, the repository might
not exist and so it is necessary for the whole repository to be
fetched.

For the All Scope, all Namespaces are fetched.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:33:41 +00:00
Fintan Halpenny 3b015a9325
radicle: accept Scope as track_repo argument
The method `track_repo` only accepted the RID as the argument for
tracking.

Instead, allow passing Scope as an argument for tracking a
repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Fintan Halpenny b82584617b
node: store Scope in tracking config
The tracking configuration has no way of consulting for a configured
scope.

This change allows the storing of this scope inside the tracking
`Config` -- currently unused.

The default Scope is chosen as Trusted, so that nodes do not
implicitly track any other node. If this behaviour is desired -- for
example, for seed nodes -- then All should be chosen.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Fintan Halpenny 39be7db1e9
radicle: make alias optional
Previously the alias field was simply a string which could possibly be
empty. Some checks were made to see if this string was empty.

Instead, make the logic more obvious by making the alias field
optional.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Vincenzo Palazzo 0e491fae79
cli: fix command line silent abort
Fix the command line silents abort when the
the `EDITOR` variable is not specified.

With this commit the result is reported below

```
➜  rio git:(main) RAD_PASSPHRASE=12345 rad issue open
✗ Issue failed: editor not configured: the `EDITOR` environment variable is not set
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-08 12:25:11 +01:00
Alexis Sellier c3a5aced07
node: Handle case of crossing fetch requests
It is possible for a pair of nodes to concurrently ask each other
to fetch some repo. These "crossing" requests are problematic,
because the nodes end up waiting for each other to reply, and
the reply never comes.

With this change, the node pair agrees on proceeding with one of
the fetches, while canceling the other.
2023-03-07 16:22:22 +01:00
Fintan Halpenny ad63583bee
cli: rad node example
Tests the rad node CLI subcommand.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Fintan Halpenny ed985f6fe0
cli: rad node
This adds a rad node subcommand to the CLI.

The subcommand aims to fulfill the following requirements:

- Checking the node status (rad node status)
- Connecting to the node's control socket (rad node connect)
- Printing out our routing table (rad node routing)
- Printing out our tracking policies (rad node tracking)

The following are yet to be implemented:

- Starting the node (rad node start)
- Stopping the node (rad node stop)

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Alexis Sellier 5fb5df2e61
cli: Update `inquire` crate 2023-03-07 10:39:45 +01:00
Alexis Sellier 85df613682
cli: Implement automatic issue announcement 2023-03-07 08:40:20 +01:00
Alexis Sellier cb3b7a3765
cli: Implement `patch delete` 2023-03-06 15:45:54 +01:00
Alexis Sellier 9000a626d7
Use commit oid for COB parent
We were using the blob oid, which was causing the commit tree to
be invalid.
2023-03-06 15:39:34 +01:00
Alexis Sellier fb2c388a5d
cli: Properly trim `patch` message 2023-03-06 15:39:07 +01:00
Alexis Sellier 35f22ba37a
cli: Update `init` help for consistency 2023-03-06 15:38:42 +01:00
Alexis Sellier be5c9c9258
cli: Add `--verbose` flag to `init` 2023-03-06 15:38:42 +01:00
Alexis Sellier c8c44c884c
cli: Allow `init` without running node 2023-03-06 15:38:42 +01:00
Alexis Sellier e69be6051d
cli: Give more control over `init` announcement
Instead of always announcing the inventory, by default we don't.
Users can run `rad push` to trigger an announcement.
2023-03-06 15:38:42 +01:00
Alexis Sellier 8c22012d61
Remove need to pass public key in cob store 2023-03-06 10:56:20 +01:00
Alexis Sellier 44f3984159
Sign COB refs after modification 2023-03-06 10:42:26 +01:00
Alexis Sellier 02304875ce
Initialize `radicle-term` crate
We split out all non-radicle terminal functionality so that it can be
accessed by `radicle-node` without importing `radicle-cli`.
2023-03-06 10:22:50 +01:00
Alexis Sellier 82d858314f cli: Fix `rad rm` prompt 2023-03-04 22:28:45 +01:00
Slack Coder dd7e3923b5 cli: expose `rad fetch`
Make `rad fetch` accessible via the command line.  It appears to be
accidently left out.
2023-03-03 09:59:45 -05:00
Alexis Sellier de71c5d9b1
cli: Implement `--fetch` on `rad patch` 2023-03-02 17:00:31 +01:00
Alexis Sellier 43bd5fca00
cli: Implement `rad fetch` command 2023-03-02 17:00:27 +01:00
Alexis Sellier 5f59493c70
cob: Don't require a local fork to exist
Before this change, the identity document would be loaded for the
COB signer. This meant that a fork would be needed for that signer.

After this change, it's no longer necessary, since the identity doc
head is computed from available remotes.

While making those changes, it was also apparent that some of the
identity-related functions had bad names and error types, this
was fixed as well.
2023-03-01 15:40:30 +01:00
Alexis Sellier 2a687502c5
cli: Improve `rad inspect`
* Don't always require auth
* Fix `--refs` sub-command
2023-03-01 13:03:42 +01:00
Alexis Sellier 892f02bc43
cli: Improve `rad-auth` first authentication 2023-03-01 13:03:42 +01:00
Alexis Sellier e4b44370d3
cli: Register key on first `auth`
Registers the secret key with ssh-agent when `rad auth` is first called.
2023-03-01 13:03:42 +01:00
Alexis Sellier 68aca5dd65
cli: Don't fork if we already have a fork 2023-02-27 18:27:52 +01:00
Alexis Sellier 207030d2e1
cli: Don't fail clone if we have repo locally 2023-02-27 18:19:02 +01:00
Fintan Halpenny c70dc71b18
node: improve seeds information
Previously, the seeds information would only consist of the connected
NodeIds.

Improve on this by adding any disconnected and fetching seeds as
well. A seed can either be disconnected, connected, or fetching --
where fetching implies connected.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-27 17:48:11 +01:00
Alexis Sellier 06a92d52d9
cob: Use hashes for operation ids
It's fairly easy for a user to (by mistake or intentionally) create two
operations with the same OpId. This patch makes it much less likely,
and ensures that if the OpId is equal, it's because the operations
are identical.
2023-02-27 17:11:48 +01:00
Alexis Sellier 0a93fa833e
cli: Simplify & improve CLI output
Improvements to the CLI output as well as converging towards
`termion` as a backend.

The crates we were using for prompting and spinners were based on
a terminal backend called `console`, which is not really used
anywhere else. There were also limitations in terms of the output
of these crates.

Therefore, we switched to the `inquire` crate for prompting, using
the `termion` backend, which is very standard.

Additionally, we simplify the terminal output to use symbols:

! for Warning
✓ for Success
✗ for Error

... Instead of a mix of words and symbols.

We also include a modified version of the `yansi` crate which plays
well with our table formatting functions by automatically truncating
and padding output in a unicode-aware way.
2023-02-27 17:10:52 +01:00
Fintan Halpenny f9dbd590a4
cli: add missing commands for rad_help
The assign, id, and unassign help messages were missing from the rad
help command.

Add them to complete the list.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-24 11:41:19 +01:00
Alexis Sellier 7e1b2b6222
crypto: Cleanup `hash` module
Remove `Digest` type and use `ssh-key` for formatting public ssh key.
2023-02-17 10:51:27 +01:00
Fintan Halpenny ef0628c48e
Exchange From for TryFrom for PathBuf and Home
The `From` implementation would allow someone to create a `Home` in an
incorrect fashion, for example the path is not canonical.

Exchange `From` for a `TryFrom` implementation.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-17 10:37:39 +01:00
Sebastian Martinez b04451a1bd
Use `Did` in a bunch more places
Instead of showing just public keys we need to show the fully qualified
spec for a NID which is prefixed by `did🔑` While we want to maintain
`Author` and `ActorId` for internal use.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-02-16 18:01:42 +01:00
Fintan Halpenny 2b5552546c
cli: add rid function for Id parsing
Adds helper for parsing the Id type in CLI arguments.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-16 17:07:14 +01:00
Fintan Halpenny 5477a3615f
radicle-cli: use Did across CLI
The CLI commands and output use PublicKey, ActorId, and NodeId for
peer identifiers.

Instead Did should be standardised for use in CLI arguments and
outputs.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-16 17:07:14 +01:00
Fintan Halpenny b57a4606f6
cli: add did function for args parsing
Adds a standard for parsing the Did type for the CLI commands.

It attempts to parse the Did type. If it fails then it checks if the
operator passed a PublicKey and suggests using `did:key` instead.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-16 17:07:14 +01:00
Alexis Sellier 950fae209d
Make `ReadStorage` more usable
Previously, we were not able to access a `ReadRepository` instance
through `ReadStorage`. With this change, we are able to.
2023-02-15 22:08:20 +01:00