evomimic / map-holons

3 stars 1 forks source link

Refactor and Enhance SmartLinks #114

Closed evomimic closed 3 months ago

evomimic commented 3 months ago

As we gear up to add MAP Descriptors and the Query Engine to the architecture, we need to flesh out and simplify more of the SmartLinks model.

Dependencies

None

Current State

Proposal

Consolidate SmartLink related functionality into the smartlink.rs file. This file should define all of the SmartLink related data structures and behaviors.

In the smartlink.rs file

In the holon.rs file

In the holon_collection.rs file

Delete the smart_link_manager.rs file

In the relationship.rs file

Testing

There is still no code that invokes the load_realationship_map function, so there is no real way to test if that function works, but we can ensure nothing else breaks.

Definition of Done

There is still no code that invokes the load_realationship_map function, so there is no real way to test if that function works, but we can ensure nothing else breaks.

dauphin3 commented 3 months ago

@evomimic for create_link_tag() how are the smart_property_values concatenated into a String?

https://github.com/evomimic/map-holons/wiki/SmartLink-Manager says "Null-separated values (serialized into a String) for each of the properties listed in the access_path for this SmartLink. These values allow the Query Engine to filter/sort SmartLinks without having to fetch the target holon."

so I know that we are doing away with access paths and now just passing through the property values themselves, but my question is twofold:

  1. when creating the bytes, am I pushing bytes.extend_from_slice(UNICODE_NUL_STR.as_bytes()); after each value?
  2. does the property name get included in the String, and if so, how should that look?
dauphin3 commented 3 months ago

@evomimic should we be passing smart_property_values into get_relationship_links() ? or is that unnecessary as it is not a filter that will be used in this function? if so, should that feature also be added to load_relationship_map() ?

evomimic commented 3 months ago

@evomimic should we be passing smart_property_values into get_relationship_links() ? or is that unnecessary as it is not a filter that will be used in this function? if so, should that feature also be added to load_relationship_map() ?

No. Under the current design, we always load all links for a relationship into the Shared Objects Layer. Filtering is only applied in the Query Layer.

evomimic commented 3 months ago

@evomimic for create_link_tag() how are the smart_property_values concatenated into a String? I know that we are doing away with access paths and now just passing through the property values themselves, but my question is twofold:

  1. when creating the bytes, am I pushing bytes.extend_from_slice(UNICODE_NUL_STR.as_bytes()); after each value?
  2. does the property name get included in the String, and if so, how should that look?

I have updated SmartLink Manager wiki with answers to both questions. We ARE storing both property_names and property_values in the SmartLink. See the wiki page for delimiters used.

dauphin3 commented 3 months ago

@evomimic when parsing the link tag to build the PropertyMap, there is currently no way to identify the PropertyValue as the corresponding BaseValue type. A potential solution is to add another separator symbol after Ⓥ. We would need one for each: StringValue, IntegerValue, BooleanValue, EnumValue

evomimic commented 3 months ago

@dauphin3 : Yea... more problems arising due to lack of descriptors.

For the short term, the only value I need in the SmartLink is the key value (if defined) and that is a MapString. Here's the short-term workaround:

in holon_collection.rs / save_smartlinks_for_collection function:

in the smart_reference.rs file

Instead of getting the key from the referenced holon (which forces retrieval of the holon), we should get the key from the SmartLink itself.

dauphin3 commented 3 months ago

Change signature of create_link_tag to create_link_tag(input: SmartLink)->LinkTag

  • Encode relationship_name and smart_property_values (if supplied) in the tag

@evomimic I am using this fn to build a link_tag from the possible parameters it could contain, and so for example in get_relationship_links() I don't have all of the necessary info to pass an entire Smartlink but still need to create a link_tag for filtering reasons and therefore some options could be: 1) keep unchanged 2) have 2 fns create_link_tag_from_smartlink and create_link_tag_xx ie create_link_tag_from_parameters etc 3) keep as is in this issue and then determine some other logic for get_relationship_links 4) construct a different, all encompassing function -- or alternative set of fns

evomimic commented 3 months ago

Change signature of create_link_tag to create_link_tag(input: SmartLink)->LinkTag

  • Encode relationship_name and smart_property_values (if supplied) in the tag

@evomimic I am using this fn to build a link_tag from the possible parameters it could contain, and so for example in get_relationship_links() I don't have all of the necessary info to pass an entire Smartlink but still need to create a link_tag for filtering reasons and therefore some options could be:

  1. keep unchanged
  2. have 2 fns create_link_tag_from_smartlink and create_link_tag_xx ie create_link_tag_from_parameters etc
  3. keep as is in this issue and then determine some other logic for get_relationship_links
  4. construct a different, all encompassing function -- or alternative set of fns

Change signature of create_link_tag to create_link_tag(input: SmartLink)->LinkTag

  • Encode relationship_name and smart_property_values (if supplied) in the tag

@evomimic I am using this fn to build a link_tag from the possible parameters it could contain, and so for example in get_relationship_links() I don't have all of the necessary info to pass an entire Smartlink but still need to create a link_tag for filtering reasons and therefore some options could be:

  1. keep unchanged
  2. have 2 fns create_link_tag_from_smartlink and create_link_tag_xx ie create_link_tag_from_parameters etc
  3. keep as is in this issue and then determine some other logic for get_relationship_links
  4. construct a different, all encompassing function -- or alternative set of fns

You're right. SmartLink is overkill as input parameter to create_link_tag. Let's use keep what we have for now (option 1).