Holon Caching #190
evomimic
started this conversation in
Design Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
This discussion focuses on the design for holon caching strategies on both the client-side (TypeScript) and guest-side (Rust) components of the MAP architecture. Note that caching is only employed for previously committed Holons. Holons being staged for commit are handled separately.
Caching Requirements
Design Challenges
This section describes various design challenges associated with meeting the caching requirements.
Handling Local and External Holon Ids
Background
A
HolonId
can either beLocal
orExternal
:Each HolonSpace has its own LocalSpaceManager. The LocalSpaceManager owns a LocalCacheManager and zero or more ExternalSpaceManagers, each with their own ExternalCacheManager. Local Holons are cached by the LocalCacheManager, external Holons are cached by the ExternalCacheManager owned by the ExternalSpaceManager associated with their space_id.
The LocalSpaceManager offers a
get_rc_holon
method for getting access to a cached holon. Retrieving a Holon involves first determining which space manager is responsible for caching that Holon based on its HolonId.The Challenge
Cache misses for
LocalIds
are resolved by the localCacheManager
by fetching the Holon from the local persistent store (using a Persistence Layer method). Cache misses for ExternalIds are resolved by theOutboundSpaceProxy's
CacheManager
invoking afetch_holon
dance on the HolonSpace that owns the holon (via a Dance Layer method). This creates a dependency challenge since the Dance Layer is "above" (and therefore has a dependency on) the Shared Objects layer.Proposal
Unified Holon Access
Define a
HolonCacheAccess
trait in the Shared Objects Layer that provides a single entry-point method for holon retrieval:fn get_rc_holon(&self, id: HolonId) -> Result<Rc<RefCell<Holon>>, HolonError>
The
get_rc_holon
method provides shared ownership of a potentially mutable, cached holon, enabling efficient reuse and incremental loading of its data. If the requested holon is in the cache, it returns the cached instance. Otherwise, it resolves the holon (locally or externally), caches it, and then returns it. The return type ofRc<RefCell<Holon>>
ensures:HolonResolver
When the
get_rc_holon
method encounters a cache miss (i.e., it cannot find the desired holon in its cache) it needs to resolve the cache miss. This design applies the Strategy Design Pattern to resolve the cache miss in a way that preserves the dependency requirements of the MAP Holons architecture:dance_layer -> reference_layer -> shared_objects_layer -> persistence_layer
The following trait is defined in the Shared Objects Layer:
Implementations of this trait encapsulate different strategies for fetching the holon based on its LocalId.
The
LocalPersistenceResolver
defined in the Shared Objects layer handles resolution of holons stored locally (backed by persistence layer functions).The
ExternalDanceResolver
defined in the Dance layer handles resolution of holons in external spaces by invoking afetch_holon
dance on the external space.Holon Cache Manager
Caching of holons is handled by a
HolonCacheManager
that has been injected with aHolonResolver
trait object.HolonSpaceManager
The
HolonSpaceManager
coordinates local and outbound interactions, maintaining references to both itslocal_cache_manager
and itsoutbound_space_proxies
.Outbound Space Proxy
The
OutboundSpaceProxy
caches external holons and handles outbound requests to external spaces, including resolving holons through external dances.Initializing the HolonSpaceManager
The
HolonSpaceManager
needs to be configured withExternalHolonResolvers
for each of itsOutboundSpaceProxies
. Since these resolvers are defined in the DanceLayer,HolonSpaceManager
initialization needs to be initiated from the Dance layer.The details of how the Dance layer can determine the set of OutboundSpaceProxies to initialize will be explored in a later discussion specifically focused on interactions between Holon Spaces.
Interactions
Impacts
To realize the design presented here requires the following enhancements:
Shared Objects Layer
API changes
In the shared_objects/api module:
Define a HolonCacheAccess trait with a single method:
fn get_rc_holon(&self, holon_id: &HolonId)-> Result<Rc<RefCell<Holon>>, HolonError>
Delete HolonCacheBehavior trait in space_manager.rs
Define HolonResolver in
THIS SECTION STILL NEEDS TO BE ADDED
Beta Was this translation helpful? Give feedback.
All reactions