Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Rules #22

Merged
merged 34 commits into from
Nov 30, 2024
Merged

Rules #22

merged 34 commits into from
Nov 30, 2024

Conversation

CyonAlexRDX
Copy link
Contributor

@CyonAlexRDX CyonAlexRDX commented Nov 27, 2024

Important

Implementation of rules laid out in doc
I have NOT yet implemented "Automatic Security Shield Construction"
That will come in a coming PR.

Note

LOC delta is misleading, of the actual 5k code, 3k is unit tests, so "only" cirka 2k lines of PROD code.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 93.81663% with 58 lines in your changes missing coverage. Please review.

Project coverage is 93.8%. Comparing base (a3d1fa6) to head (146fd13).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
crates/rules/src/roles/builder/roles_builder.rs 85.3% 25 Missing ⚠️
...ith_hierarchical_deterministic_factor_instances.rs 79.6% 11 Missing ⚠️
crates/rules-uniffi/src/builder.rs 90.3% 10 Missing ⚠️
...actor_instance_level/role_with_factor_instances.rs 77.1% 8 Missing ⚠️
.../rules/src/roles/abstract_role_builder_or_built.rs 93.0% 3 Missing ⚠️
...s/factor_source_level/roles_with_factor_sources.rs 92.8% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           main     #22      +/-   ##
=======================================
+ Coverage      0   93.8%   +93.8%     
=======================================
  Files         0      24      +24     
  Lines         0     938     +938     
=======================================
+ Hits          0     880     +880     
- Misses        0      58      +58     
Files with missing lines Coverage Δ
...factor_source_in_role_builder_validation_status.rs 100.0% <100.0%> (ø)
...s/src/matrices/abstract_matrix_builder_or_built.rs 100.0% <100.0%> (ø)
crates/rules/src/matrices/builder/error.rs 100.0% <100.0%> (ø)
...rates/rules/src/matrices/builder/matrix_builder.rs 100.0% <100.0%> (ø)
...s/rules/src/matrices/matrix_of_factor_instances.rs 100.0% <100.0%> (ø)
.../rules/src/matrices/matrix_of_factor_source_ids.rs 100.0% <100.0%> (ø)
...tes/rules/src/matrices/matrix_of_factor_sources.rs 100.0% <100.0%> (ø)
...e_level/confirmation_role_with_factor_instances.rs 100.0% <100.0%> (ø)
...stance_level/primary_role_with_factor_instances.rs 100.0% <100.0%> (ø)
...tance_level/recovery_role_with_factor_instances.rs 100.0% <100.0%> (ø)
... and 14 more

@CyonAlexRDX CyonAlexRDX force-pushed the rules branch 2 times, most recently from 7a9e0e2 to 40acef4 Compare November 27, 2024 08:29
… of roles and matrices - with UniFFI implementation.
#[uniffi::export(Debug, Eq, Hash)]
pub struct SecurityStructureOfFactorSourceIds {
wrapped_matrix: MatrixWithFactorSourceIds,
name: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will have an ID as well... the models here in this crate is not 100% accurate yet. What I want reviewed is probably just the implementation of the wrapping? And the API

self.with(|builder| builder.add_factor_source_to_primary_threshold(factor_source_id.inner))
}

pub fn add_factor_source_to_primary_override(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO doc all methods ofc...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im about to write unit tests for this file/cratel Currently I just have one ensuring it works...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Document

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO Document API

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont miss, many tests here :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add unit tests for JSON !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant file, can skip review

use crate::prelude::*;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct AbstractRoleBuilderOrBuilt<F, T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO Document!

}
}

impl RoleBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither method on the RoleBuilder is meant to be pub the idea is that hosts always use a single MatrixBuilder (ShieldBuilder)` and which expose the needed APIs.

}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, thiserror::Error)]
pub enum NotYetValidReason {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In earlier implementations I had one error enum type for each Role, maybe that makes sense, not sure. It results in many more types and more complex translation into RoleBuilderValidation so I deemed it not worth it.

Furtermore, all these violations are "ephemeral" in the sense that they ALL will be translated into CommonError at some point in time...

}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FactorSourceInRoleBuilderValidationStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Split out and document

use NotYetValidReason::*;
use RoleKind::*;

impl RoleBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Document

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont miss, many tests :)

Copy link

@GhenadieVP GhenadieVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall as a structure this looks very good 😍!
I didn't review the very thoroughly in regards to how the rules logic is applied, let me know if you want that.

So I have only one comment to clarify.

@CyonAlexRDX CyonAlexRDX merged commit 0c5f86f into main Nov 30, 2024
6 checks passed
@CyonAlexRDX CyonAlexRDX deleted the rules branch November 30, 2024 07:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants