Skip to content
archived Visibility internal Owner erik@uvilo.com Approver _ Created 2026-07-11 Updated 2026-07-11

Orchestration State 2

Related plan: Orchestration Plan 2


  • ✅ Task 1 — Scaffold the Orchestrator Railway Service
    • ✅ Create orchestrator/ directory at repo root
    • ✅ Initialize TypeScript project: package.json, tsconfig.json, .gitignore
    • ✅ Install dependencies: hono, @hono/node-server, dotenv, pg, cuid2, eventsource
    • ✅ Create entry point: src/index.ts — Hono server on PORT
    • ✅ Add health endpoint: GET /health
    • ✅ Add basic project structure files (auth, chat-client, dispatcher, db, types)
    • ✅ Add scripts to package.json: dev, build, typecheck
    • ✅ Verify service starts locally and responds on /health
  • ✅ Task 2 — Implement JWT Auth Manager
    • ✅ Create src/auth.ts with AuthManager class
    • ✅ Implement login(email, password) flow
    • ✅ Implement refresh(refreshToken) flow (no Authorization header)
    • ✅ Implement getValidToken() with auto-refresh
    • ✅ Handle orchestrator restart: full re-login
    • ✅ Add browser User-Agent header to all requests
    • ✅ Store credentials in Railway env vars
    • ✅ Unit test: login → getValidToken → wait → getValidToken triggers refresh
  • ✅ Task 3 — Implement UI Chat API Client
    • ✅ Create src/chat-client.ts with ChatClient class
    • ✅ Implement invokeAgent()
    • ✅ Implement subscribeToStream() with SSE parsing
    • ✅ Implement checkStatus()
    • ✅ Implement abortGeneration()
    • ✅ Create src/types.ts with all TypeScript interfaces
    • Integration test: invoke agent, subscribe to stream, capture final event
  • ✅ Task 4 — Implement Postgres Orchestration State
    • ✅ Create src/db.ts with Postgres connection + pooling
    • ✅ Create AgentJob table schema
    • ✅ Create Project table schema
    • ✅ Create indexes
    • ✅ Configure FORGE_DB_URL env var
    • ✅ Create src/ids.ts with Cuid2 ID generation
    • ✅ Add helper functions: createJob(), updateJobStatus(), getJob(), upsertProject(), getActiveProjects()
    • ✅ Create forge database on Railway VectorDB and run DDL
  • ✅ Task 5 — Implement Basic HTTP Dispatcher
    • ✅ Create src/dispatcher.ts with dispatch logic
    • ✅ Implement POST /orchestrator/run endpoint
    • ✅ Implement disconnect mode
    • ✅ Implement monitor mode placeholder
    • ✅ Add GET /orchestrator/jobs/:jobId status endpoint
    • ✅ Add GET /orchestrator/jobs list endpoint
    • ✅ Wire up dispatcher routes in src/index.ts
    • Integration test: invoke agent via endpoint, verify job in Postgres
  • ✴️ Task 6 — Deploy Orchestrator to Railway
    • ✅ Add railway.json config
    • ✅ Create Railway service Forge Orchestrator with env vars
    • ✅ Deploy and verify /health, auth login, Postgres connection
    • ✴️ End-to-end test: POST /orchestrator/run → agent runs → job tracked