Commit Graph

371 Commits

Author SHA1 Message Date
Alexis Sellier f73389fc62
cli: Make `rad node connect` work like `--connect`
It was using a different syntax.
2023-07-04 00:26:31 +02:00
Alexis Sellier d6e8f0c53e
httpd: Implement `EditCodeComment` in route 2023-07-03 12:31:05 +02:00
Alexis Sellier 369fc7637c
cob: Use new `Immutable` lattice for merges
Instead of `Redactable`, which is not needed since we have an `LWWMap`,
we use a new `Immutable` semilattice.
2023-07-03 12:31:05 +02:00
Alexis Sellier 11b32725c8
cob: Implement review code commenting 2023-07-03 12:31:05 +02:00
Alexis Sellier 45e87a63b9
cob: Changes to patch code review CRDT
This patch incorporates several important changes to code review:

* Code review verdict is no longer editable
  * Made reviews redactable instead
* Renamed review top-level comment to "summary"
* Renamed inline comments to "comments"
* Made inline comments addressable by `EntryId`
  * This is to allow for editing
* Removed inline comments from review creation
  * Added a `CodeComment` action instead
* Removed `Semilattice` instance from `Review`
  * Added a `EditReview` action instead to have more control
* Made it valid for revisions to be redacted concurrently with a review/merge

Most of these changes are needed to support proper inline code comments.
2023-07-03 12:31:05 +02:00
Alexis Sellier e4ab523669
cob: Move comment reactions to comment
To simplify the code, we move comment reactions to the comment struct
itself.
2023-07-03 12:31:05 +02:00
Alexis Sellier 8b010c27a2
cob: Improvements to COB logic
There were a few subtle issues with the apply logic of certain COBs
that should be fixed now.

Note that the underlying store guarantees exactly-once delivery, and so
it does not make sense to test idempotence at the patch level.
2023-07-03 12:31:05 +02:00
Alexis Sellier e32e28f8b4
cli: Implement `rad node stop` 2023-06-29 17:58:07 +02:00
Alexis Sellier 63ff4717dc
cli: Implement hunk-based code review
Review code with an interface similar to `git add -p`.
2023-06-22 11:15:42 +02:00
Alexis Sellier 22360f8c25
radicle: Change review data in patch COB
* `CodeLocation` had a `blob` and `commit` field. These are redundant,
  since the review lives under a revision.
  We also change the line range to be diff-compatible, with an old and
  new range. The ranges are optional to account for different scenarios
  like file deletion, move etc.
* `CodeComment` had redundant getters which were removed in favor of
  public fields. We also remove the `timestamp` field, as it will be
  the same as the review timestamp.
2023-06-22 11:15:42 +02:00
Alexis Sellier b25c2e452b
cli: Setup tracking branch on `rad patch checkout`
Just like when opening a new patch, we setup a tracking branch on patch
checkout, so that patches can be updated via a push.
2023-06-21 17:01:56 +02:00
Alexis Sellier cb576cf8c3
cli: Allow setting a different patch base on push
Using `-o patch.base=<oid>`, users can specify a different patch base,
when creating or updating a patch.
2023-06-15 10:25:32 +02:00
Alexis Sellier 48f44f4af5
cli: Fix ahead/behind and diff behavior
In certain cases, eg. after a rebase, or when patches are stacked, the
"ahead/behind" and/or the diff stats can be wrong.

This fixes it.
2023-06-13 13:16:00 +02:00
Alexis Sellier 5502676aa7
Fixes and improvements to alias handling
* Return the correct alias from a node announcement, stripping '\0'
  bytes.
* Accept `AliasStore` types as references and as owned.
* Store a `null` in the database if the alias received is empty.
2023-06-13 11:09:42 +02:00
Alexis Sellier 3d803b2498
cli: Remove `rad patch open`
Remove this command in favor of the `git push` flow.

We also remove the `rad/patches` remote configuration which wasn't
working properly with `git fetch --all`.
2023-06-07 15:57:11 +02:00
Alexis Sellier ff7338de17
node: Always send node announcement on handshake
Previously, we only sent the announcement when there were external
addresses. But it contains other information like the node alias,
therefore we always send it.

Since the proof-of-work can be expensive to compute everytime, we add
the ability to load the local node announcement from the file system.

We also change the proof-of-work parameters so that they are relaxed
when running in debug mode, instead of when running tests.

Finally, we remove the boolean validation of the PoW. Instead, we store
the work per-node, in the database, to be used in the future in case of
DoS attacks or network congestion.
2023-06-07 11:39:23 +02:00
Slack Coder 65763a2ad2
cli: Enable redacting patch revisions
Use `rad patch redact <revision-id>` to redact (delete) a patch
revision.
2023-06-02 17:30:13 +02:00
xphoniex 13bea902b2
radicle: Create `Aliases` and use it in `httpd`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-06-02 14:50:49 +02:00
xphoniex 0cae3c0967
radicle: Implement `AliasStore` for address `Book` 2023-06-02 14:49:30 +02:00
xphoniex f526465f1b
radicle: Make addresses.db accessible from profile
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-06-02 14:49:20 +02:00
xphoniex 738d0dcbad
node: Introduce `AliasStore` trait
httpd: use the `AliasStore` trait

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-06-02 14:48:33 +02:00
Alexis Sellier 4652f309b4
Update to Rust 1.70 2023-06-02 14:40:44 +02:00
xphoniex fd91cf4d28
node: Add access to routing.db on `profile`
httpd: Use routing.db to return `trackings` of an RID

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-06-02 13:42:44 +02:00
Alexis Sellier b60569d3cb
cob: Test deterministic traversal order
We test to make sure that in the event of concurrent operations,
traversal order is deterministic.

This required some changes to the testing infrastructure. We're also
able to simplify the `Actor` type that now has redundant functionality.
2023-05-30 16:31:01 +02:00
Alexis Sellier 0e14dacb99
cob: Simplify graph evaluation
Simplify graph traversal and evaluation by building in some of the
functionality into `radicle-dag`, namely the pruning fold.

We avoid building vectors of graph nodes this way, and simply iterate
over the graph in one go.
2023-05-30 16:31:01 +02:00
Slack Coder f2d4b9acc2
cli: Support `rad issue edit`
Support editing an issue via the command line.
2023-05-29 12:22:51 +02:00
Alexis Sellier aa8394a838
cob: Make errors more consistent across COBs
Though these are perhaps not the final error types, we name them the same
across COBs and have them work the same way.

All COB modules now have a `Error` enum.

In a future change, we may want the `FromHistory` trait to support
multiple error types, eg. one for `apply` and one for `validate`.
2023-05-29 11:33:29 +02:00
Alexis Sellier eeaf380067
cob: Add validation step when loading COBs
This adds a simple `validate` function to COBs that is run on load. It
allows COBs to check whether they are valid, once all operations are
loaded, and return an error if not.
2023-05-29 11:27:04 +02:00
Alexis Sellier e6baeab0c9
cob: Guarantee there is always a latest revision
We change `Patch::latest` to always return something, because a patch is
malformed if it doesn't have at least one revision, and thus would not
load in the first place.

This also implies that there is a latest revision in the face of
concurrent updates.

Note that currently, traversal order for concurrent updates is still random.
This will be fixed in another patch.
2023-05-26 10:31:00 +02:00
Alexis Sellier 37d6c03026
radicle: Fix a documentation issue 2023-05-26 10:31:00 +02:00
Alexis Sellier e41d67544c
cob: Add `reviewers` field on `Patch`
We aren't ready to support this yet from an end-user perspective, but
we add it in the COB already to prepare.
2023-05-26 10:31:00 +02:00
Alexis Sellier ac60069a33
cob: Remove `description` from `Patch`
Since patches always have a "root" revision, use that revision's description
as the patch description.
2023-05-26 10:31:00 +02:00
Alexis Sellier e18f01cab4
radicle: Be more lenient when applying merge ops
Before this change, if a merge op referred to a commit that was not on
the default branch, the merge op and all descendant ops would be pruned.

This is a bad idea because the state of the default branch can change
*after* the merge op is created, which is out of the control of the
merge op author.

Therefore, instead of exiting, we keep processing ops (but ignore the
merge), in case the merge is invalid for this specific reason.
2023-05-25 11:29:54 +02:00
Alexis Sellier 664aa570e6
node: Spawn a thread for each control connection
Previously, only one connection to the node control socket could be
handled at a time. This usually worked fine, but if one connection hangs
for whatever reason, no other process can access the node.
2023-05-24 11:33:55 +02:00
Alexis Sellier 45a4578724
cli: Move `announce` function to `node` library
This will be used in more than one place.
2023-05-23 16:11:42 +02:00
Alexis Sellier 8e89976937
cli: Verify merge, remove `rad merge` command
When applying a `Merge` action, we verify that the commit is in the
history of the default branch of that user.

Since this is not the case when issuing a `rad merge`, and since that
command is no longer needed with the push-based merge, we remove the
`rad merge` command completely.
2023-05-23 16:11:42 +02:00
Alexis Sellier 2d55ffba81
cob: Redesign merge state
Move `merges` from `Revision` to `Patch`, and key them by actor.

This ensures that only one merge is possible per actor. We also make
sure that only one revision can be merged at a time, and signal a
conflict if more than one revision is considered merged.

Finally, we make sure that merges have the same target-branch commit
to be considered equal.
2023-05-19 18:40:46 +02:00
Alexis Sellier 94cd7658b1
cli: Merge patches on `git push`
Allows patches to have their state updated to `Merged` with a `git push`
to the default branch.

Currently, due to the limitations of the COB store, this requires a
linear search through all patches. This will eventually become a problem
when projects have thousands of patches, so we should look into
long-term solutions.
2023-05-16 21:11:57 +02:00
xphoniex ae5982cd6b
httpd: Add `alias` field to certain routes
* `/patches`, `/issues`, `/remotes`

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-05-16 12:40:07 +02:00
Sebastian Martinez d8711a8d43
radicle: ensure stable sigrefs commit
When updating sigrefs with `storage::refs::save` we weren't checking
the `RAD_COMMIT_TIME` variable, so the sigrefs commit was using current
time, and we weren't able to reproduce a deterministic sigrefs commit.

Make `refs::save` reproducible in debug mode using `debug_assertions`
and checking the `RAD_COMMIT_TIME` environment variable.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-05-16 12:35:16 +02:00
Alexis Sellier f72b448114
cli: Fix `rad patch show` with merged patches
We were not correctly calculating the base commit. Simply
using the latest revision base does the job for now.
2023-05-15 12:22:09 +02:00
Slack Coder 39239fea51
radicle: Allow editing issue description
Enable editing an Issue's description, returning an error if its not
available.
2023-05-14 13:53:19 +02:00
Alexis Sellier 5ccd74aa8a
Use `tmp` namespace for temporary refs during push
The `refs/tmp` namespace is used by Git for the purpose of storing
temporary refs. We use it here instead of `refs/patch` to indicate
that the refs can be safely deleted.
2023-05-13 23:27:03 +02:00
Alexis Sellier 7d68df86d1
radicle: Only sign known refs
This change ensures that we only sign refs in known categories. This
prevents accidently signing a temporary ref or malformed ref.
2023-05-13 23:08:12 +02:00
Alexis Sellier fd1237b2db
cli: Use `git push` to open or update patches
This adds the ability to the git-remote-helper to open and update
patches via a `git push` to the magic ref `refs/patches` and
`refs/heads/patches/<patch-id>`.

The main change is that we had to move away from offering the `connect`
capability in the remote helper, to offering `push` and `fetch`
individually.

To get a feel for how this works, see the `rad-patch-via-push.md`
example.
2023-05-12 12:22:08 +02:00
Vincenzo Palazzo b29321dbf7
cob: Fix recursion bug in TryFrom of Reference
This commit addresses the issue of recursion in the TryFrom
call of Reference by resolving the parent in a lazy way.

Due to constraints posed by the need to access `git2::Repository`
or `git2::Commit` to resolve the parent, this commit decides to
pull out the parent resolution logic from the `cob::object::Commit`
module and move it inside the `cob::store::Store` implementation by adding
a new method `parents_of`.

Suggested-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Tested-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-05-09 10:11:36 +02:00
Fintan Halpenny 8508eab8fa
radicle: update radicle-git-ext
This change updates to the latest radicle-git-ext, which required a
few changes within the radicle family of crates.

One set of changes is that the radicle-git-ext crate subsumes
git-commit, git-trailers, and git-ref-format -- so all those imports
go through radicle-git-ext.

The commit code requires that parent `Oid`s point to commits, which
made some tests fail. One of the reasons for these failures is that
the patch tests used fabricated `Oid`s and so the verification would
fail. This is fixed by allowing the test context code to create
`PatchRequest`s that create valid commits.
The other reason for failure was that the identity `Action` passed an
`Oid` that pointed to a blob. This is fixed by removing that code and
making a note of it in documentation.

The final major change was moving the Refspec type into git-ref-format
and removing the AsRefspecs trait. The trait was not required and
could its usage could be replaced by simpler code.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:36:15 +01:00
Alexis Sellier 293a76948f
Update `SignedRefs::save` function
* Remove redundant `remote` parameter
* Fix commit message and remove redundant remote
2023-05-08 11:13:55 +02:00
Fintan Halpenny 2ff6bf2fc4
cli: remove the 'rad' remote during `rad rm`
If the 'rad' remote is still in the git config, then some of the CLI
tooling will think the project exists -- even after running `rad rm`.

For example, in the current state, if `rad rm` is followed by `rad
init` then the operation will fail.

During `rad rm`, attempt to delete the 'rad' remote.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:49:18 +02:00
Alexis Sellier ca0abc4356
node: Keep track of connection attempts
When attempting to connect to a peer, and when succeeding, write the timestamp
to the database.

This will allow us to better select addresses and not retry peers to
soon.
2023-05-05 17:23:52 +02:00