Expand description
Command/Event/Query Architecture for Headless Core
This module implements the “Headless Core with Multi-Adapter” pattern that enables:
- GUI adapters (Iced, Dioxus) to control the application through execute/query/subscribe
- AI agents to control the application via MCP server
- CLI tools to automate workflows
- Test harnesses to verify behavior
§Architecture
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Iced GUI │ │ Dioxus GUI │ │ MCP Server │ │ CLI │
│ (Adapter) │ │ (Adapter) │ │ (Adapter) │ │ (Adapter) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │ │
└────────────────┼────────────────┼────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────┐
│ CommunitasApp (Core) │
│ execute(cmd) / query(q) / sub(s) │
└─────────────────────────────────────┘§Key Principles
-
All mutations via Commands - Every state change MUST go through a command. No adapter should directly mutate state.
-
Events record what happened - After a command executes, it produces events that describe what changed. These events can be replayed for debugging/testing.
-
Queries for reads - All state reads go through the Query enum. This enables caching, access control, and consistent responses across adapters.
-
Subscriptions for reactivity - Adapters subscribe to event streams to update their UI when state changes.
Structs§
- Canvas
Element Response - Canvas element response data
- Canvas
Snapshot Response - Canvas snapshot response data
- Chunk
Read Response - Chunk read response data
- Chunked
Write Progress Response - Chunked write progress response
- Command
Error - Error type for command execution
- Contact
Response - Contact response data
- Disk
Info Response - Disk info response data
- Disk
Stats Response - Disk stats response data
- Entity
Response - Entity response data
- File
Info Response - File info response data
- File
Metadata Response - File metadata response (without content)
- File
Preview Response - File preview response data
- Invite
Response - Invite response data
- Kanban
Board Response - Kanban board response data
- Kanban
Card Response - Kanban card response data
- Kanban
Column Response - Kanban column response data
- Member
Response - Member response data
- Message
Response - Message response data
- Presence
Response - Presence response data
- Query
Error - Error type for query execution
- Reaction
Response - Resumable
Transfer Response - Resumable transfer info
- Resume
Verification Response - Resume verification response data
- Search
Result - Search result with message and match context.
- Sync
State Response - Sync state response data
- Website
Response - Website response data
Enums§
- Command
- Commands represent all possible mutations to the application state.
- Disk
Type Arg - Disk type argument for commands (serializable)
- Event
- Events describe what changed as a result of a command.
- Query
- Queries represent all possible reads from the application state.
- Query
Response - Response types for queries
- Resume
Capability Response - Resume capability response
- Subscription
- Subscription types for reactive updates
Type Aliases§
- AgentId
- x0x agent identifier (64-character hex string).
- Command
Result - Result of executing a command
- Query
Result - Result of running a query