-
Notifications
You must be signed in to change notification settings - Fork 1
MAP Type System
The MAP platform is built around a structured and layered type system that supports self-describing, active holons. Each layer serves a specific purpose and role in the system, from foundational storage types to dynamic, agent-defined extensions.
BaseTypes are the foundational, portable types in the MAP system. The BaseType determines how a given value will actually be represented in different programming language environments. (i.e., TypeScript and JSON on the client and Rust on the server-side). The BaseTypes layer includes both scalar types (e.g., MapInteger, MapString) and compound types (e.g., MapBytes). It also includes types defined by the Holochain hdk (e.g., ActionHash, Record). The set of BaseTypes is fixed for any given version of the MAP. Changes or additions to any of these types requires a recompile of the MAP code and an evolution of the persistent data stored using a prior version of the MAP.
- Scalar Types: Simple, atomic values such as integers, strings, and booleans.
-
Non-Scalar Types: Includes
MapBytes
, which is used to represent raw binary data, such as hash digests, commonly used as identifiers in the system.
#[derive(Clone, PartialEq, Eq, new)]
pub enum BaseType {
String(MapString), // Portable string type
Integer(MapInteger), // Portable integer type
Boolean(MapBoolean), // Portable boolean type
Bytes(MapBytes), // Portable binary type (e.g., hash digest)
Enum(MapEnumValue), // Portable enum value
}
- CoreTypes build upon BaseTypes to introduce semantically meaningful types required by the MAP core code. Examples, include PropertyName, RelationshipName, HolonId.
- CoreTypes are defined in terms of BaseTypes to ensure portability and consistency.
- Examples include identifiers, names, and other semantically enriched types.
-
PropertyName
: WrapsMapString
, representing a property name. -
HolonId
: Represents a unique identifier for a Holon. -
RelationshipName
: WrapsMapString
, representing the name of a relationship.
CoreTypes are organized into the following groups via the CoreType enum. Numbers in parentheses indicate the current number of core types within that group:
- DanceType (TBD)
- EnumVariantType (16)
- HolonType (24)
- IndexedType (2)
- PropertyType (24)
- RelationshipType (27)
- ValueType (8)
- DescriptorTypes define metadata and constraints for the values of a given type. Each BaseType has a corresponding DescriptorType. For example, IntegerDescriptorType defines the metadata about MapIntegers. This could include min and max allowable values for instances of that type, a human-readable name and description of the type and more.
- Each BaseType has a corresponding DescriptorType.
- DescriptorTypes can specify constraints like minimum/maximum values, length restrictions, or other rules.
-
IntegerDescriptorType
: Specifies min/max constraints forMapInteger
. -
StringDescriptorType
: Specifies length constraints forMapString
.
- CoreDescriptorTypes describe the types that the MAP core code depends on. are the reserved DescriptorTypes that the MAP core code depends on.
- Each BaseType can be associated with one or more CoreDescriptorTypes.
- CoreDescriptorTypes are critical to the functioning of the MAP and are not customizable by agents.
pub enum CoreStringDescriptorType {
#[default]
MapStringType,
PropertyNameType,
RelationshipNameType,
SemanticVersionType,
}
ExtensionDescriptorTypes allow agents (developers) to define custom types dynamically without requiring recompilation of the MAP core. These types provide a flexible way for agents to extend the MAP Type System for their own applications, tailoring it to specific use cases.
-
Agent-Defined:
- ExtensionDescriptorTypes are created and managed by agents to support application-specific needs.
- They are not part of the MAP core and operate independently of core system upgrades.
-
Dynamic:
- Developers can add new types without recompiling the MAP core or migrating data structures.
-
Flexibility:
- These types allow agents to define rich metadata for custom types, including validation rules, relationships, and semantics.
-
Reserved Names:
- To avoid conflicts, agents cannot use reserved CoreDescriptorType names when defining their own types.