evomimic / map-holons

3 stars 1 forks source link

Implement AddRelatedHolons Dance (Undescribed) #74

Closed evomimic closed 4 months ago

evomimic commented 4 months ago

Summary

This enhancement adds the "_add_related_holons_" dance to the Uniform API. This dance adds one or more staged or existing holons to a named, but undescribed, relationship target of a staged_holon (source). If an entry for relationship_name is not already present in the source holon's relationship_map, this function adds one.

Current State:

The holons zome already includes a native add_related_holons method in the staged_reference.rs file:

pub fn add_related_holons(
    &self, 
    context: &mut HolonsContext, 
    relationship_name: RelationshipName, 
    holons: Vec<HolonReference>, 
) -> Result<(), HolonError> 

In this method,

Proposal

Native Function

No change required to add_related_holons function

Dance Enhancements

_In the dance_request.rs file:_

We need a way to convey the set of holons to be added. Each such holon could be staged or existing. The native reference types provided by the Holons zome (StagedReference and SmartReference) are overkill for this usage. So I propose the following:

pub enum PortableReference {
    Saved(HolonId),
    Staged(StagedIndex)
}
pub enum RequestBody {
    None,
    Holon(Holon),
    TargetHolons(RelationshipName, Vec<PortableReference>) // <=== NEW
    ParameterValues(PropertyMap),
    Index(StagedIndex),
}

_In the holon_dance_adapter.rs file:_

/// *DanceRequest:*
/// - dance_name: "add_related_holons"
/// - dance_type: Command(StagedIndex) -- references the staged holon that is the `source` of the relationship being extended
/// - request_body:
///     _TargetHolons_: whose associated data specifies the RelationshipName and the vector of PortableReferences to the holons being added
///
/// *ResponseBody:*
/// - _StagedIndex_ -- index into staged_holons for the updated source holon
///

In the dancer.rs file:

Testing Enhancements

_In the dance_fixture.rs file:_

_In the dance_tests.rs file:_

Definition of Done:

evomimic commented 4 months ago

All steps completed EXCEPT:

Dance tests all pass, and PR #72 has been merged.