Strategy, planning, risk, and execution preflight own executable fields. LLM output is never order authority.
Document control
- Document ID
- RS-ARC-001
- Status
- Implementation-aligned baseline
- Effective date
- 30 August 2026
- Scope
- Hackathon paper runtime
- Architecture style
- Modular monolith, isolated roles
- Primary platform
- Docker Compose / Linux ARM64
- System of record
- PostgreSQL 18
- Authority boundary
- Execution worker only
Executive architecture view
The platform separates public visibility, deterministic decisioning, LLM advice, economic-context collection, durable control, and credentialed execution into distinct process and network boundaries. Every permitted order originates as a deterministic semantic signal and remains unchanged through both advisory gates.
The market thesis and economic assessment may return only ALLOW_UNCHANGED or VETO.
Missing, stale, mismatched, unavailable, uncertain, or unreconciled state ends in refusal without broker mutation.
Canonical hashes, immutable commands, transactional outbox/inbox, and broker-event projections preserve decision lineage.
Scope boundary. This design has no LIVE mode, live hostname, or live credential route. Alpaca economic inputs are market/news proxy context, not official CPI, employment, GDP, or central-bank release data.
Physical architecture
The implemented deployment uses hardened role-specific containers, file-mounted secrets, private bridge networks, and one internal PostgreSQL service. Solid lines are implemented paths; dashed lines identify external scheduling or a controlled future read-model connection.
Physical deployment and trust zones
Container, network, secret, and external-service boundaries
Container hardening
- Read-only root filesystem; bounded writable tmpfs.
- All Linux capabilities dropped; no-new-privileges enforced.
- CPU, memory, and process-count limits declared per service.
- Role-specific images exclude forbidden packages and credentials.
Network intent
- Agent and database networks are internal Docker bridges.
- Public API, model egress, data egress, and broker egress are separate.
- Bridge names express trust intent; production still requires FQDN egress enforcement.
- PostgreSQL publishes no host port.
Logical architecture
The logical design keeps strategy semantics, advice, exact order construction, authorization, and external effects in separate modules joined by versioned contracts. The central invariant is that advisory output can veto but cannot transform executable intent.
Layered component model
Responsibilities, dependency direction, and authority boundaries
Data-flow architecture
Two coordinated flows operate at different cadences: one pre-market economic-context capture per trading date, and a per-signal decision/execution flow. Every refusal converges on the durable signal audit without producing an order.
End-to-end data flow with refusal branches
Morning context lane, per-signal lane, and broker evidence loop
Data architecture and contract ownership
All decision and execution payloads are strict V1 contracts with canonical content hashes. PostgreSQL stores operational truth; JSON Schema snapshots are committed for integration and replay.
| Information object | Authoritative producer | Persistence / cadence | Primary binding or invariant | Consumers |
|---|---|---|---|---|
| MarketSnapshotV1 | Execution-zone ingress or frozen exporter | Per decision snapshot | Feed identity, timestamps, quality flags, content hash | Features, planner, risk, replay |
| StrategyEvaluationV1 | Isolated registered plug-in | Per signal | Registry-pinned plug-in/config/content identity | Resolver, advisory, audit |
| AgentThesisV1 | Agent worker | Per signal, TTL-bound | Context, evaluation, model-input, model and prompt hashes | Deterministic resolver |
| DailyEconomicContextV1 | Economic-context worker | Once per trading date | Collection config, source request, causality, expiry | Economics advisory gate |
| EconomicAssessmentV1 | Agent worker | Per semantic intent, TTL-bound | Daily context, evaluation, trade intent, model-input hash | Economic gate, audit |
| TradeIntentV1 | Deterministic resolver | Per allowed signal | Original semantic tuple; advisory may not alter it | Order planner |
| OrderPlanV1 | Order planner | Per exact order proposal | Exact legs, quantity, debit, TIF, deterministic client ID | Risk, preflight, execution |
| RiskInputV1 / RiskDecisionV1 | Decision worker / risk kernel | Per plan, short TTL | Plan plus all market/account/control/release hashes | Outbox, execution preflight |
| ExecuteApprovedPlanV1 | Decision worker | Transactional outbox | Immutable command and identical risk-input binding | Execution worker inbox |
| BrokerEventV1 | Execution worker | Append-only per observed transition | Client order ID, broker state, occurrence time | Reconciler, reservations, audit projection |
| SignalDecisionAuditV1 | Decision worker; execution projection | One logical row per signal | Decision reason, economic lineage, conservative placement state | Operators, read models, evidence review |
Security and authority boundaries
Decision boundary
- No Alpaca package or competition credential in the decision container.
- Strategy plug-ins receive no network, filesystem, database, account, model, or broker object.
- LLM requests exclude account, exact contract, quantity, price, risk, and execution state.
- Only the unchanged deterministic intent can pass an advisory gate.
Execution boundary
- Only the execution worker receives the competition paper key and expected account ID.
- Preflight revalidates hashes, TTLs, quotes, control mode, release, allowlist, and reconciliation.
- Uncertain submission is reconciled by deterministic client order ID before retry.
- Unknown broker state retains conservative risk reservation.
Data-collection boundary
- A separate Alpaca data key is mounted only into the one-shot collector.
- The collector image has no planner, risk kernel, execution core, or broker adapter.
- One claim is made before any provider call; same-day retry is prohibited after failure.
- Market/news proxies are never represented as official economic releases.
Persistence boundary
- PostgreSQL is internal, has no host port, and uses a non-superuser runtime role.
- Risk reservation and outbox enqueue are committed atomically.
- Decision job completion and signal audit persistence are atomic.
- Public read models must use a separately provisioned SELECT-only identity.
Operations, resilience, and observability
| Quality attribute | Design mechanism | Safe degraded behavior | Evidence |
|---|---|---|---|
| Safety | Closed operating modes, bounded-risk templates, hash-bound approvals, independent preflight | Reject or NO_TRADE; no live fallback | Risk and security tests; decision tape |
| Availability | Durable jobs, leases, outbox/inbox, deterministic client IDs | Retry only internal work; reconcile uncertain external effects | Job/outbox state and broker events |
| Consistency | PostgreSQL transactions, compare-and-swap versions, advisory locks | Fail conflicting approval or lease claim | Versioned snapshots and reservation rows |
| Auditability | Canonical hashes, frozen V1 artifacts, supplemental reason metadata | Preserve refusal as a first-class result | signal_decision_audit_v1 |
| Performance | Economic context fetched once each morning and reused all day | Missing cache produces no order rather than intraday refresh | Daily context status and request hash |
| Recoverability | Persistent PostgreSQL volume, append-only broker events, reconciliation-first restart | Hold reservation and remain non-entry-capable until known | Reconciliation state and terminal event |
Failure-mode policy
Before outbox enqueue
- Strategy, model, economic context, binding, TTL, planning, or risk failure produces a durable refusal.
- No exact broker command is created for semantic or economic vetoes.
- Failed morning collection remains terminal for the date.
After outbox enqueue
- Execution replays independent preflight against latest reconciled state.
- Submission-start fencing prevents blind duplicate broker effects.
- Terminal broker evidence updates the same signal audit and is not rewritten by stale events.
Key architecture decisions
Architecture acceptance criteria
| Control objective | Required evidence | Status |
|---|---|---|
| Advisory output cannot alter direction, template, horizon, size, contract, price, or risk | Contract validation and resolver/economic-gate tests | Implemented |
| Economic veto occurs before order planning and outbox publication | Deterministic veto fixture and durable-worker test | Implemented |
| Every generated signal records decision and actual-placement state | Signal audit schema, atomic persistence, broker-event projection test | Implemented |
| Daily economic input is captured once and reused | One-claim storage invariant and cache behavior tests | Implemented |
| Execution is restricted to paper endpoint and expected account | Deployment configuration and execution preflight tests | Implemented |
| Production FQDN egress allowlists match logical network intent | Deployment firewall policy and connectivity evidence | Operator-owned |
| Public read API uses SELECT-only projections from PostgreSQL | Read-model DB identity and negative mutation tests | Target |
| Container topology executes successfully in Docker | Compose build, migration, health, and role-connectivity run | Environment pending |