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
- Emergence Over Prescription: Let design emerge from interaction patterns rather than imposing structure
- Composition Over Inheritance: Build complex behaviors by combining simple ones
- Contextual Immutability: Use immutability where it matters most, allowing pragmatic mutability elsewhere
- Introspection First: All components should be observable and self-describing
- Temporal Awareness: Maintain history and enable time travel for debugging
- Adaptive Perspectives: Different views of the same data for different contexts
- Cross-Cutting Integration: Recognize when concerns span components and handle them naturally
- 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 Type | Description | Entry Point | Exit Point | Validation |
---|---|---|---|---|
Network API | HTTP/HTTPS communication with external services | NetworkRequest[T_in] | NetworkResponse[T_out] | Schema validation, response parsing |
File System | Reading/writing files | FileReadRequest | FileContent[T] | Format validation, content parsing |
Database | Data storage and retrieval | QueryRequest[T] | QueryResult[T] | Schema validation, constraint checking |
User Input | Commands or data from user | UserInputData | ValidatedCommand | Type conversion, constraint checking |
Model Provider | LLM API integration | ModelRequest | ModelResponse | Schema validation, content filtering |
Each boundary enforces:
- Explicit Typing: Clear input/output types with no implicit
Any
- Validation: Converting untrusted → validated data
- Error Handling: Dedicated error types for boundary failures
- Telemetry: Logging crossing events for observability
External │ Internal
│
│
Raw JSON ────────────────►│───► Validated DTO ───► Domain Model
│
HTTP Response ◄───────────│◄─── Typed Request ◄─── Business Logic
│
│
Naming Conventions
Prefix/Suffix | Purpose | Examples |
---|---|---|
T , S , R , etc. | Generic type parameters | Generic[T] , Callable[[S], R] |
Raw prefix | Unvalidated external data | RawUserInput , RawApiResponse |
Dto suffix | Data Transfer Objects | UserDto , ConfigurationDto |
Id suffix | Unique identifiers | EntityId , VersionId |
Aware suffix | Classes with a specific capability | PerspectiveAware , EventAware |
Handler suffix | Components that process events/requests | EffectHandler , StreamHandler |
Manager suffix | Components that coordinate resources | ResourceManager , ConnectionManager |
Provider suffix | Sources of data or services | ModelProvider , StorageProvider |
Factory suffix | Components that create other components | StreamFactory , EntityFactory |
Repository suffix | Components that store/retrieve entities | EntityRepository , DocumentRepository |
State suffix | Represents a component state | UnitState , StreamState |
Result suffix | Output of an operation | UnitResult , QueryResult |
Delta suffix | Represents a change to be applied | FunctionDelta , PatchDelta |
Error suffix | Error types | ValidationError , NetworkError |
Core Type Definitions
Category | Type Name | Definition | Used For |
---|---|---|---|
Identity | EntityId | str identifier for any entity | Component identification, reference |
Identity | VersionId | str identifier for a versioned state | Version tracking, history navigation |
Identity | ResourceId | str identifier for a managed resource | Resource lifecycle management |
Identity | EventId | str identifier for an event | Event correlation, deduplication |
Events | EventType | Enum classification of system events | Event routing, filtering |
Events | Event[T] | @dataclass with event data and metadata | Event transmission, history |
State | LifecycleState | Enum of component lifecycle stages | Component state management |
State | StreamState | Enum of streaming operation states | Stream control, monitoring |
Effects | EffectType | Enum classification of side effects | Effect tracking, handling |
Effects | Effect | @dataclass declaration of a side effect | Effect system, traceability |
Resources | ResourceType | Enum classification of system resources | Resource management |
Resources | Resource | @dataclass managed system resource | Resource lifecycle tracking |
Execution | UnitState | Enum of computation unit states | Execution tracking |
Execution | UnitResult[R] | @dataclass result of a computation unit | Result aggregation, error handling |
Network | NetworkRequest[T] | @dataclass wrapper for outgoing requests | Network boundary input |
Network | NetworkResponse[T] | @dataclass wrapper for incoming responses | Network boundary output |
Validation | ValidationResult[T] | @dataclass validated data or errors | Input validation |
Errors | BoundaryError | Base class for system boundary errors | Error 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:
- Adaptive: Changing its behavior based on context and requirements
- Transparent: Providing visibility into its operations
- Resilient: Gracefully handling failures and unexpected conditions
- 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.