evomimic / map-holons

3 stars 1 forks source link

Implement AbandonStagedChanges Dance #79

Closed evomimic closed 1 month ago

evomimic commented 2 months ago

Summary

This enhancement adds the _abandon_staged_changes_ dance to the Uniform API. This dance marks a staged_holon as Abandoned . Staged holons marked Abandoned are simply ignored during commit processing -- they are not saved to the persistent store. Once a staged_holon has been abandoned, further attempts to access the holon will return a (newly introduced) NotAccessible error.

Current State:

There is no native functionality that supports this function.

However, some existing native functionality needs to modified:

Proposal

Enhance Native Holons Functionality

_In the holon_error.rs file within the Holons zome:_

    #[error("{0} access not allowed while holon is in {1} state")]
    NotAccessible(String, String),

In the holon.rs file within the Holons zome:

This function should return Ok if the requested access_type is allowed given the current state of the holon. Otherwise, return a NotAccessible error.

 - If requested access_type is `Read`, return true if and only if the holon's state is: `New`, `Fetched`, `Changed`, or `Saved`
 - If requested access_type is `Write`, return true if and only if the holon's state is: `New`, `Fetched`, or `Changed`,

_In the staged_reference.rs file within the Holons zome:_

_In the commit_manager.rs file:_

Dance Enhancements

_In the holon_dance_adapter.rs file:_

/// *DanceRequest:*
/// - dance_name: "abandon_staged_changes"
/// - dance_type: Command(StagedIndex) -- references the staged holon whose changes are being abandoned
/// - request_body: None
///   
///
/// *ResponseBody:*
/// - an Index into staged_holons that references the updated holon.
///

In the dancer.rs file:

_In the dance_response.rs file:_

Testing Enhancements

New files:

_In the test_data_types.rs file:_

_In the dance_fixture.rs file:_

_In the dance_tests.rs file:_

Definition of Done:

dauphin3 commented 1 month ago

@evomimic What is the associated ResponseStatusCode for HolonError::NotAccessible

evomimic commented 1 month ago

@evomimic What is the associated ResponseStatusCode for HolonError::NotAccessible

NotAuthorized

dauphin3 commented 1 month ago

@evomimic What is the associated ResponseStatusCode for HolonError::NotAccessible

NotAuthorized @evomimic confirm: 401 - Unauthorized

I also see in the issue checklist, under dance_response.rs file it says to map to BadRequest, should it instead be Unauthorized? Is spelling correct or should the A be capital?

evomimic commented 1 month ago

Yea. I noticed that also after sending my reply. Probably BadRequest is better. NotAuthorized typically refers to a permissions issue.

dauphin3 commented 1 month ago

@evomimic how to ensure relationship is populated?

evomimic commented 1 month ago

@dauphin3 : Hmmm... right. I don't think that will be possible until we implement #84. Currently, holon's try_from_node function is not loading the relationship_map (and we probably don't want to until we have RelationshipDescriptor's to guide the process). So there is not currently any way to tell which relationships have been populated.

Recommendation: Skip the relationship match.