Architecture

Event sourcing, CQRS, workspace isolation, and the internals of Syntropic137

Event Sourcing

Syntropic137 uses event sourcing as its core persistence pattern. Instead of storing current state, every state change is recorded as an immutable event. The current state is derived by replaying events.

Two Event Types

Syntropic137 distinguishes between two kinds of events, each optimized for its use case:

Domain EventsObservability Events
PurposeBusiness logic, state transitionsTelemetry, metrics, audit logs
StorageTimescaleDB (append-only, replay-safe)TimescaleDB (hypertable, time-series optimized)
PipelineCommand → Aggregate → Event → ProjectionAgent stdout → API stream processor → AgentEventStore → TimescaleDB
ValidationAggregate invariants, can be rejectedSchema validation only, append-only
ExamplesWorkflowTemplateCreated, WorkflowExecutionStartedtool_execution_started, token_usage

CQRS

Commands and queries are strictly separated. Commands modify state through aggregates; queries read from pre-built projections stored in PostgreSQL.

Commands: CreateWorkflowTemplateCommand, ExecuteWorkflowCommand, CancelExecutionCommand, ResumeExecutionCommand, RegisterTriggerCommand, PauseTriggerCommand, DeleteTriggerCommand, and more.

Events: Every command produces one or more events: WorkflowTemplateCreated, WorkflowExecutionStarted, ExecutionResumed, WorkflowCompleted, github.TriggerRegistered, etc.

Projections: Pre-computed read models subscribed to domain events and stored in PostgreSQL. Includes a repo_correlation projection that maps repositories to workflow executions for cross-context insight queries.

Domain Model

Syntropic137 is organized into six bounded contexts. The diagram below is a simplified view; the generated list of every aggregate per context is in the repository README.

Real-Time Communication

Syntropic137 uses Server-Sent Events (SSE) for real-time monitoring of executions: progress updates, tool events, token metrics, and state changes all stream over a single connection:

GET /api/v1/sse/executions/{execution_id}

Global activity across all executions streams from GET /api/v1/sse/activity. From the CLI, syn watch execution <id> and syn watch activity follow the same streams.

Control commands are sent via standard REST API calls rather than a persistent connection.

Execution State Machine

NOT_STARTED→ start →RUNNING→ finish →COMPLETED
RUNNING→ error →FAILED
RUNNING→ interrupt →INTERRUPTED
RUNNING→ cancel →CANCELLED

Cancel: The platform checks for a cancel every few lines of agent output and interrupts the agent. Injecting a message into a running agent is not supported: the API refuses it (HTTP 501) and queues nothing, so cancel and start again with a corrected task.

Resume: A FAILED or INTERRUPTED execution can be resumed, which creates a new execution. See Resuming Failed Executions.

Performance

Both event pipelines are optimized for their access patterns. Domain events use append-only writes with aggregate-level consistency. Observability events use TimescaleDB hypertables with automatic partitioning for high-throughput ingestion. Read models are stored in PostgreSQL.

On this page