Skip to content

The Matrix: Core Services Architecture

This document outlines the visionary architecture for Atlas’s core services - a meta-framework that provides deep introspection, composition, and dynamic reconfiguration capabilities. While some elements will be implemented in the current development cycle, others represent future possibilities that align with the long-term vision.

Architectural Philosophy

The Matrix architecture embraces a vision for a system that is not only powerful and flexible but also deeply introspectable, composable, and self-modifying.

Key Design Principles

  1. Emergence Over Prescription: Let design emerge from interaction patterns rather than imposing structure
  2. Composition Over Inheritance: Build complex behaviors by combining simple ones
  3. Contextual Immutability: Use immutability where it matters most, allowing pragmatic mutability elsewhere
  4. Introspection First: All components should be observable and self-describing
  5. Temporal Awareness: Maintain history and enable time travel for debugging
  6. Adaptive Perspectives: Different views of the same data for different contexts
  7. Cross-Cutting Integration: Recognize when concerns span components and handle them naturally
  8. Dependency Discovery: Components discover what they need rather than being explicit wiring

Type System & Core Primitives

The Matrix architecture is built on a foundation of clearly defined types that represent the fundamental building blocks of our system. These primitives serve both as documentation and as runtime guidance through Python’s type system.

System Boundaries

System boundaries are interfaces where data crosses between controlled and uncontrolled domains. Each boundary requires explicit typing, validation, and error handling:

Boundary TypeDescriptionEntry PointExit PointValidation
Network APIHTTP/HTTPS communication with external servicesNetworkRequest[T_in]NetworkResponse[T_out]Schema validation, response parsing
File SystemReading/writing filesFileReadRequestFileContent[T]Format validation, content parsing
DatabaseData storage and retrievalQueryRequest[T]QueryResult[T]Schema validation, constraint checking
User InputCommands or data from userUserInputDataValidatedCommandType conversion, constraint checking
Model ProviderLLM API integrationModelRequestModelResponseSchema validation, content filtering

Each boundary enforces:

  1. Explicit Typing: Clear input/output types with no implicit Any
  2. Validation: Converting untrusted → validated data
  3. Error Handling: Dedicated error types for boundary failures
  4. Telemetry: Logging crossing events for observability
External                  │                  Internal


Raw JSON ────────────────►│───► Validated DTO ───► Domain Model

HTTP Response ◄───────────│◄─── Typed Request ◄─── Business Logic

Naming Conventions

Prefix/SuffixPurposeExamples
T, S, R, etc.Generic type parametersGeneric[T], Callable[[S], R]
Raw prefixUnvalidated external dataRawUserInput, RawApiResponse
Dto suffixData Transfer ObjectsUserDto, ConfigurationDto
Id suffixUnique identifiersEntityId, VersionId
Aware suffixClasses with a specific capabilityPerspectiveAware, EventAware
Handler suffixComponents that process events/requestsEffectHandler, StreamHandler
Manager suffixComponents that coordinate resourcesResourceManager, ConnectionManager
Provider suffixSources of data or servicesModelProvider, StorageProvider
Factory suffixComponents that create other componentsStreamFactory, EntityFactory
Repository suffixComponents that store/retrieve entitiesEntityRepository, DocumentRepository
State suffixRepresents a component stateUnitState, StreamState
Result suffixOutput of an operationUnitResult, QueryResult
Delta suffixRepresents a change to be appliedFunctionDelta, PatchDelta
Error suffixError typesValidationError, NetworkError

Core Type Definitions

CategoryType NameDefinitionUsed For
IdentityEntityIdstr identifier for any entityComponent identification, reference
IdentityVersionIdstr identifier for a versioned stateVersion tracking, history navigation
IdentityResourceIdstr identifier for a managed resourceResource lifecycle management
IdentityEventIdstr identifier for an eventEvent correlation, deduplication
EventsEventTypeEnum classification of system eventsEvent routing, filtering
EventsEvent[T]@dataclass with event data and metadataEvent transmission, history
StateLifecycleStateEnum of component lifecycle stagesComponent state management
StateStreamStateEnum of streaming operation statesStream control, monitoring
EffectsEffectTypeEnum classification of side effectsEffect tracking, handling
EffectsEffect@dataclass declaration of a side effectEffect system, traceability
ResourcesResourceTypeEnum classification of system resourcesResource management
ResourcesResource@dataclass managed system resourceResource lifecycle tracking
ExecutionUnitStateEnum of computation unit statesExecution tracking
ExecutionUnitResult[R]@dataclass result of a computation unitResult aggregation, error handling
NetworkNetworkRequest[T]@dataclass wrapper for outgoing requestsNetwork boundary input
NetworkNetworkResponse[T]@dataclass wrapper for incoming responsesNetwork boundary output
ValidationValidationResult[T]@dataclass validated data or errorsInput validation
ErrorsBoundaryErrorBase class for system boundary errorsError classification

Core Interface Hierarchy

Observable[E]
├── EventEmitter         # Emits typed events
├── StateContainer       # Contains observable state
└── ResourceProvider     # Provides observable resources

Versioned[S]
├── TemporalStore        # Stores complete version history
└── VersionedEntity      # Entity with version history

Projectable[S, P]
├── PerspectiveAware     # Multiple views of same data
└── StateProjector       # Projects state through transformations

Effectful[V]
├── EffectMonad          # Tracks effects in computation chains
└── EffectfulOperation   # Operations with explicit effects

QuantumUnit[S, R]
├── ComputeUnit          # Basic computation unit
└── TransformUnit        # Data transformation unit

Boundary[T_in, T_out]
├── NetworkBoundary      # HTTP/API boundaries
├── FileBoundary         # File system boundaries
├── DatabaseBoundary     # Database access boundaries
└── UserInterfaceBoundary # User input boundaries

Conclusion: The Vision for Atlas

The Matrix architecture represents a long-term vision for Atlas - a system that is not only powerful and flexible but also deeply introspectable, composable, and self-modifying. While we’ll implement this architecture incrementally, keeping the full vision in mind ensures that each step moves us toward a cohesive, unified system.

By building on these architectural patterns, Atlas will become:

  1. Adaptive: Changing its behavior based on context and requirements
  2. Transparent: Providing visibility into its operations
  3. Resilient: Gracefully handling failures and unexpected conditions
  4. Evolvable: Growing and changing without requiring complete rewrites

The true power of Atlas will emerge not just from what it can do, but from how its components interact, compose, and evolve over time.

Released under the MIT License.