mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-28 06:44:51 -06:00
e057c364b8
* Fix console proxy regressions and add workstream task field (#21) Bug fixes: - Fix collector polling unversioned /api/dashboard (404 after API versioning PR) — nodes showed red/unreachable, no workstreams - Fix SSE proxy dropping all data events — upstream sends \r\n line endings but proxy split on \n\n only; normalize before parsing - Fix workstream state stuck on idle — on_state_change() only broadcasted via SSE but never updated ws.state on the Workstream object; dashboard polling now sees correct attention/running states - Fix deep-link switchTab early return — when ?ws_id matched the only workstream, switchTab bailed (wsId === currentWsId) before establishing SSE connection; inline init instead of delegating - Fix console banner covering dashboard overlay — inject <style> offsetting .dashboard-overlay below the 32px banner Enhancements: - Add turnstone branding to console proxy banner (turnstone │ Console │ node-id) - Add initial_message field to CreateWorkstreamMessage protocol and console "New Workstream" modal (Task textarea, sent as first message) - Refactor SSE proxy to use shared httpx client with 30s read timeout instead of per-request client creation - Increase approval timeout default from 300s to 3600s (1 hour) Updated: Python SDK, TypeScript SDK, OpenAPI specs, MQ client, API schemas, MQ protocol diagram, SDK docs. * Address PR #21 review feedback (4 items) - Log unknown state strings in on_state_change instead of silently swallowing; remove unnecessary KeyError catch - Wrap initial_message POST in _handle_create_ws with error handling so workstream creation success isn't masked by send failure - Strip all \r from SSE chunks instead of replacing \r\n, fixing chunk-boundary split edge case - Add tests for initial_message wiring in directed and pool targeting * Refactor SSE proxy to use httpx-sse aconnect_sse Replace manual SSE chunk buffering/parsing with httpx_sse.aconnect_sse() which handles line endings, event types, and all SSE spec edge cases. Eliminates the \r\n chunk-boundary bug class entirely. Event types are now always forwarded (sse.event defaults to "message" per spec).
232 lines
6.8 KiB
YAML
232 lines
6.8 KiB
YAML
# =============================================================================
|
|
# Turnstone Docker Compose Stack
|
|
#
|
|
# Usage:
|
|
# Default (SQLite): docker compose up
|
|
# Production (PG): DB_BACKEND=postgresql docker compose --profile production up
|
|
# (or set DB_BACKEND=postgresql in .env)
|
|
# With simulator: docker compose --profile sim up
|
|
# Scale bridges: docker compose up --scale bridge=3
|
|
# =============================================================================
|
|
|
|
name: turnstone
|
|
|
|
networks:
|
|
turnstone-net:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
redis-data:
|
|
turnstone-data:
|
|
postgres-data:
|
|
|
|
services:
|
|
# -------------------------------------------------------------------
|
|
# PostgreSQL — production database (profile: production)
|
|
# -------------------------------------------------------------------
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
profiles:
|
|
- production
|
|
environment:
|
|
POSTGRES_DB: turnstone
|
|
POSTGRES_USER: ${POSTGRES_USER:-turnstone}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required for production profile}
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql/data
|
|
networks:
|
|
- turnstone-net
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-turnstone}"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 512M
|
|
cpus: '1.0'
|
|
restart: unless-stopped
|
|
|
|
# -------------------------------------------------------------------
|
|
# Redis — message broker, pub/sub, node registry
|
|
# -------------------------------------------------------------------
|
|
redis:
|
|
image: redis:7.4-alpine
|
|
command:
|
|
- sh
|
|
- -c
|
|
- >-
|
|
redis-server
|
|
--save 60 1
|
|
--loglevel warning
|
|
$${REDIS_PASSWORD:+--requirepass $$REDIS_PASSWORD}
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
|
volumes:
|
|
- redis-data:/data
|
|
networks:
|
|
- turnstone-net
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- redis-cli $${REDIS_PASSWORD:+-a $$REDIS_PASSWORD} ping | grep -q PONG
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
# -------------------------------------------------------------------
|
|
# turnstone-server — Web UI + chat workstreams + LLM interaction
|
|
# -------------------------------------------------------------------
|
|
server:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
command:
|
|
- sh
|
|
- -c
|
|
- >-
|
|
turnstone-server
|
|
--host 0.0.0.0
|
|
--port 8080
|
|
--base-url "$${LLM_BASE_URL}"
|
|
--api-key "$${OPENAI_API_KEY}"
|
|
$${MODEL:+--model $$MODEL}
|
|
$${SKIP_PERMISSIONS:+--skip-permissions}
|
|
ports:
|
|
- "${SERVER_PORT:-8080}:8080"
|
|
volumes:
|
|
- turnstone-data:/data
|
|
environment:
|
|
- LLM_BASE_URL=${LLM_BASE_URL:-http://host.docker.internal:8000/v1}
|
|
- OPENAI_API_KEY=${OPENAI_API_KEY:-dummy}
|
|
- TAVILY_API_KEY=${TAVILY_API_KEY:-}
|
|
- SKIP_PERMISSIONS=${SKIP_PERMISSIONS:-}
|
|
- TURNSTONE_AUTH_ENABLED=${TURNSTONE_AUTH_ENABLED:-}
|
|
- TURNSTONE_AUTH_TOKEN=${TURNSTONE_AUTH_TOKEN:-}
|
|
- MODEL=${MODEL:-}
|
|
- TURNSTONE_DB_BACKEND=${DB_BACKEND:-sqlite}
|
|
- TURNSTONE_DB_URL=${DATABASE_URL:-}
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
networks:
|
|
- turnstone-net
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
postgres:
|
|
condition: service_healthy
|
|
required: false
|
|
healthcheck:
|
|
test: ["CMD", "python", "/usr/local/bin/healthcheck.py", "http://127.0.0.1:8080/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 15s
|
|
restart: unless-stopped
|
|
|
|
# -------------------------------------------------------------------
|
|
# turnstone-bridge — Redis <-> HTTP bridge for multi-node routing
|
|
# Node ID auto-generated from container hostname (no --node-id needed)
|
|
# -------------------------------------------------------------------
|
|
bridge:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
command:
|
|
- turnstone-bridge
|
|
- --server-url=http://server:8080
|
|
- --redis-host=redis
|
|
- --redis-port=6379
|
|
- --heartbeat-ttl=${HEARTBEAT_TTL:-60}
|
|
- --approval-timeout=${APPROVAL_TIMEOUT:-3600}
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
|
- TURNSTONE_AUTH_TOKEN=${TURNSTONE_AUTH_TOKEN:-}
|
|
networks:
|
|
- turnstone-net
|
|
depends_on:
|
|
server:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
# -------------------------------------------------------------------
|
|
# turnstone-console — Cluster dashboard
|
|
# -------------------------------------------------------------------
|
|
console:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
command:
|
|
- turnstone-console
|
|
- --host=0.0.0.0
|
|
- --port=8090
|
|
- --redis-host=redis
|
|
- --redis-port=6379
|
|
- --poll-interval=${CONSOLE_POLL_INTERVAL:-10}
|
|
ports:
|
|
- "${CONSOLE_PORT:-8090}:8090"
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
|
- TURNSTONE_AUTH_ENABLED=${TURNSTONE_AUTH_ENABLED:-}
|
|
- TURNSTONE_AUTH_TOKEN=${TURNSTONE_AUTH_TOKEN:-}
|
|
networks:
|
|
- turnstone-net
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "/usr/local/bin/healthcheck.py", "http://127.0.0.1:8090/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
# -------------------------------------------------------------------
|
|
# turnstone-sim — Multi-node cluster simulator (no LLM needed)
|
|
# Start with: docker compose --profile sim up
|
|
# -------------------------------------------------------------------
|
|
sim:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
profiles:
|
|
- sim
|
|
command:
|
|
- sh
|
|
- -c
|
|
- >-
|
|
turnstone-sim
|
|
--nodes "$${SIM_NODES}"
|
|
--scenario "$${SIM_SCENARIO}"
|
|
--duration "$${SIM_DURATION}"
|
|
--mps "$${SIM_MPS}"
|
|
--redis-host redis
|
|
--redis-port 6379
|
|
--log-level "$${SIM_LOG_LEVEL}"
|
|
$${SIM_SEED:+--seed $$SIM_SEED}
|
|
$${SIM_METRICS_FILE:+--metrics-file $$SIM_METRICS_FILE}
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
|
- SIM_NODES=${SIM_NODES:-100}
|
|
- SIM_SCENARIO=${SIM_SCENARIO:-steady}
|
|
- SIM_DURATION=${SIM_DURATION:-60}
|
|
- SIM_MPS=${SIM_MPS:-5.0}
|
|
- SIM_LOG_LEVEL=${SIM_LOG_LEVEL:-INFO}
|
|
- SIM_SEED=${SIM_SEED:-}
|
|
- SIM_METRICS_FILE=${SIM_METRICS_FILE:-}
|
|
networks:
|
|
- turnstone-net
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
restart: "no"
|