π― Objective
Deploy Queen as a self-improving container service with HTTP/JSON API,
WebSocket realtime updates, and autonomous improvement loop via .tri + .t27 pipeline.
π Context
Queen UI (SwiftUI) = native macOS only. For cloud deployment and autonomous
self-improvement, we need containerized Queen-as-a-Service.
Existing code to build upon:
src/tri/queen/self_learning.zig β Self-learning engine (Phase 5)
src/tri/queen/episodes.zig β Episode management
src/tri/queen/experience.zig β Experience recall
src/tri/queen/lotus_cycle.zig β Lotus Cycle (Phase 4)
src/tri/queen/tri27_bridge.zig β TRI-27 integration (15/15 tests)
src/tri/queen/github_comment.zig β GitHub commenting
π Architecture
βββββββββββββββββ Railway Container βββββββββββββββββ
β Queen Backend (Zig) β HTTP/JSON + WebSocket β
β Self-Improvement Loop β .tri spec β .t27 exec β
β Frontend (React+Vite) β Three Kingdoms Dashboard β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Checklist (tri CLI flow)
Phase 1: Backend API (Week 1)
Phase 2: Frontend (Week 2)
Phase 3: Docker + Deploy (Week 3)
Phase 4: Self-Improvement Integration (Week 4)
Phase 5: Validation (Week 5)
π§ Agent Instructions
tri dev scan β read this issue + .trinity/experience/similar_tasks.json
tri dev pick --smart β Phase 1 first (backend_server.zig is critical path)
tri issue comment 476 β π [RESEARCH] Step 1/10
tri spec create β reuse specs/tri/queen/self_improvement.tri template
tri gen β .tri β .zig + tri issue comment "βοΈ [CODEGEN]"
tri test β IF FAIL β save to .trinity/mistakes/
tri verdict --toxic β compare with past verdicts
tri experience save β save episode + learnings + mistakes
tri git commit β tri issue comment "β
[DONE]"
tri loop decide β continue to next phase or stop
β οΈ Constraints
- Do NOT touch
apps/queen/ (SwiftUI β leave as-is)
- Reuse existing
src/tri/queen/*.zig β DO NOT rewrite
- Railway preferred over Fly.io (MCP already integrated)
- Max container memory: 512MB (Railway free tier)
- All endpoints must return JSON with
ΟΒ²+Οβ»Β²=3 validation header
π Dependencies
π Success Criteria
π― Objective
Deploy Queen as a self-improving container service with HTTP/JSON API,
WebSocket realtime updates, and autonomous improvement loop via .tri + .t27 pipeline.
π Context
Queen UI (SwiftUI) = native macOS only. For cloud deployment and autonomous
self-improvement, we need containerized Queen-as-a-Service.
Existing code to build upon:
src/tri/queen/self_learning.zigβ Self-learning engine (Phase 5)src/tri/queen/episodes.zigβ Episode managementsrc/tri/queen/experience.zigβ Experience recallsrc/tri/queen/lotus_cycle.zigβ Lotus Cycle (Phase 4)src/tri/queen/tri27_bridge.zigβ TRI-27 integration (15/15 tests)src/tri/queen/github_comment.zigβ GitHub commentingπ Architecture
π Checklist (tri CLI flow)
Phase 1: Backend API (Week 1)
src/tri/queen/backend_server.zigβ HTTP/JSON + WebSocketsrc/tri/queen/auto_improve.zigβ self-improvement orchestrationsrc/tri/queen/episode_to_tri.zigβ episode β .tri spec converterbuild.zigβ addqueen-backendbuild targetsrc/tri/main.zigβ addtri queen-backendcommandPhase 2: Frontend (Week 2)
apps/queen-web/β React + Vite appPhase 3: Docker + Deploy (Week 3)
deploy/Dockerfile.queenβ multi-stage build.github/workflows/queen-deploy.ymlβ CI/CD to Railwaydeploy/fly.toml.queenβ Fly.io alternative configPhase 4: Self-Improvement Integration (Week 4)
specs/tri/queen/self_improvement.triβ pipeline spec.trinity/queen/tri27_config.jsonβ auto-adapt settingsPhase 5: Validation (Week 5)
zig build queen-backend && ./zig-out/bin/queen-backend --testdocker build -f deploy/Dockerfile.queen -t queen:test .curl http://localhost:8080/healthβ 200 OKcurl -X POST http://localhost:8080/api/improveβ triggers loopdocs/queen/CONTAINER.mdπ§ Agent Instructions
apps/queen/(SwiftUI β leave as-is)src/tri/queen/*.zigβ DO NOT rewriteΟΒ²+Οβ»Β²=3validation headerπ Dependencies
π Success Criteria
queen-backendbinary builds clean