Repository navigation
Description
Summary
The repo's self-hosted deployment surface (scripts under scripts/deploy/, .env.example, docker-compose.yml, docker-compose.prod.yml, and the user-facing docs/user-docs/guides/deploying-trinity.md + getting-started/setup.md) has accumulated drift against what actually runs Trinity in production. A first-time self-hoster following the current docs hits at least one blocker (agent creation fails) and several misleading-or-broken instructions. Meanwhile, the operational knowledge that keeps real instances alive — the upgrade sequence, the verification probes, the resource thresholds, the "never down/up" rule — lives only in our internal ops runbook and never reaches public users.
This issue is the umbrella to (a) fix the broken/misleading bits in code, scripts, and configs so they match reality, and (b) surface the operational patterns that actually work in production into public-safe form, so the next /generate-user-docs run can produce accurate, complete deployment guides.
Context
Triggered by an audit of the rollout/deployment guides that compared the public docs to the internal production-ops patterns. The comparison surfaced concrete bugs, drift, and gaps. Splitting into one umbrella so we can land the fixes coherently rather than as scattered one-offs.
Findings
A. Broken or misleading scripts
scripts/deploy/start.shdoes not build thetrinity-agent-base:latestimage, butdocs/user-docs/guides/deploying-trinity.mdstep 3 andgetting-started/setup.mdstep 2 both claim it does. Without./scripts/deploy/build-base-image.shfirst, the very first Create Agent click fails because the base image is missing. This is the primary first-run blocker.scripts/deploy/verify-platform.shreferencestrinity-audit-logger(removed), uses port 3000 for the frontend (current is 80), and showsadmin/adminas the default login. It will fail on any current install.scripts/deploy/validate.shreferences a non-existentdeployment/directory, also referencesaudit-loggerand port 3000, and points users to port 3000 in its success message.
B. Drift between .env.example and Compose
These keys are documented in .env.example but are NOT forwarded into the backend container by the dev docker-compose.yml, so setting them in .env is silently inert in dev:
EXTRA_CORS_ORIGINS— drift in both compose filesPUBLIC_CHAT_URL— only present indocker-compose.prod.ymlSLACK_SIGNING_SECRET— only present indocker-compose.prod.ymlTRINITY_GIT_BASE_URL/TRINITY_GIT_API_BASE— only forwarded by thedocker-compose.gitea.ymloverlaySSH_HOST— present in neither compose env blockFRONTEND_URL— only present indocker-compose.prod.yml
Either wire these through dev compose, or annotate .env.example to mark each as "prod-only / requires compose edit / overlay-only." Right now they look functional and aren't.
C. Documentation inaccuracies
guides/deploying-trinity.mdstep 4 instructs the user to/trinity:connectwith URL + username + password. Perdocs/user-docs/abilities/trinity-plugin.mdandcli/trinity-cli.md, that skill expects email-verification or an MCP API key. The instruction is wrong for self-hosted local without email service configured.getting-started/setup.mdsays "On your first visit, Trinity displays a setup wizard" — butdatabase.py:_ensure_admin_userauto-creates the admin user whenADMIN_PASSWORDis set in.env, whilerouters/setup.py+main.pyprint a setup token to logs that's only used whenADMIN_PASSWORDis unset. Both paths exist and the docs explain neither well.- Neither guide mentions
docker-compose.prod.yml,deploy.config.example,scripts/deploy/gcp-deploy.sh,--profile tunnel/TUNNEL_TOKEN, orscripts/deploy/build-base-image.sh.
D. Operational knowledge that never reaches public users
The internal ops runbook captures rules and procedures that are load-bearing in production but absent from public docs. None of the following are exposed to self-hosters:
- Use
docker compose restart, neverdown/up— preserves agent containers and thetrinity-agent-network. Single most important rule. - Rebuild only platform services, not the base image —
docker compose build --no-cache backend frontend mcp-server scheduler. The base image is a separate manual step. - Backup before every update —
~/trinity-data/trinity.dbvia volume-mounted alpinecp. Daily cron + 14-day retention is the standard. - Six health probes after any change — backend
/health, scheduler:8001/health, frontend HTTP 200, redis PONG, MCP/health, Vector:8686/health. /api/ops/fleet/healthis the authoritative agent-side status surface for operators (not just the dashboard).- Resource threshold table with warning/critical bands for: agent context %, host CPU/memory, disk %, error rate/hr, container restarts, DB size, log size.
- Common-recovery patterns: agent stuck >90% context → restart agent; "network not found" on agent start →
docker rm agent-X; docker restart trinity-backend; database locked → check for multiple uvicorn writers. - Update flow has an explicit rollback path: restore DB backup →
git checkout <sha>→ rebuild → restart.
E. Open product questions
These need a decision before we can land the doc rewrite cleanly:
docker-compose.prod.ymlandscripts/deploy/gcp-deploy.sh— keep or kill? They're parallel to the path real production instances actually take. If they're vestigial, delete; if they're the public self-hoster path, document them. Right now they're undocumented.scripts/deploy/verify-platform.shandscripts/deploy/validate.sh— repair or delete? Both are broken against current state; both look replaceable by a single small "post-install verification" probe.- Public guidance on production self-hosting: how opinionated do we want to be? (Resend for email, Cloudflare Tunnel for public access, daily DB-backup cron, etc.) The internal ops setup is opinionated; the public docs are silent.
Acceptance Criteria
Code / scripts / configs
-
scripts/deploy/start.sheither builds the base image automatically or aborts with a clear instruction to runbuild-base-image.shfirst -
scripts/deploy/verify-platform.shandscripts/deploy/validate.share either repaired against current architecture or deleted (with replacement noted) -
.env.exampleis annotated so every key clearly states whether it works in dev compose, prod compose, or requires a compose edit/overlay -
docker-compose.prod.yml/gcp-deploy.sh/deploy.config.exampledecision made and acted on (documented or removed) - First-time setup story (env var vs setup-token wizard) documented in code comments and surfaced in
setup.md
Documentation
-
guides/deploying-trinity.mdrestructured into a hub + spokes covering: local development, single-server self-hosted, public access (Cloudflare Tunnel), upgrading, backup/restore, monitoring -
setup.mdno longer duplicates install instructions fromdeploying-trinity.md -
/trinity:connectstep in deploying guide reflects actual flow (email verification or MCP API key, not username/password) - Public-safe distillation of the operational rules (the eight items in finding D) lands in
guides/deploying/upgrading.mdandguides/deploying/monitoring.md - Resource threshold table and six-probe verification checklist included as reusable reference
Skill
-
.claude/skills/generate-user-docs/SKILL.mdupdated so the next run reproduces the new structure: hub + spokes layout forguides/deploying/, an "operational guide" template extension (pre-flight → action → verify → rollback), and a step that reads internal ops patterns as a source while explicitly forbidding leakage of host-specific details, SSH/sshpass invocations, or instance names
Technical Notes
Files implicated:
scripts/deploy/start.sh,scripts/deploy/verify-platform.sh,scripts/deploy/validate.sh,scripts/deploy/build-base-image.sh.env.exampledocker-compose.yml,docker-compose.prod.yml,docker-compose.gitea.yml,deploy.config.examplesrc/backend/database.py(admin user init),src/backend/routers/setup.py,src/backend/main.py(setup token print)docs/user-docs/guides/deploying-trinity.md,docs/user-docs/getting-started/setup.md,docs/user-docs/getting-started/quick-start.md.claude/skills/generate-user-docs/SKILL.md
Source of truth for operational patterns: the private ops/runbook repo. Pattern transfer must be public-safe — never copy SSH/sshpass invocations, host IPs, instance names, or credentials.
Suggested order: (1) land code/script/config fixes; (2) update the skill; (3) regenerate docs by running the skill against the now-correct codebase.
Activity
vybe commentedon Apr 25, 2026
Parked — partial work on
feature/504-deployment-alignmentThis issue is paused. A feature branch exists with one acceptance criterion already complete:
Branch:
feature/504-deployment-alignmentCommit:
3899682—docs(generate-user-docs): add hub-and-spokes deployment structure and ops-pattern importStatus against acceptance criteria
Skill — ✅ done (on the branch, awaits PR)
.claude/skills/generate-user-docs/SKILL.mdupdated for hub+spokes layout, operational-guide template, ops-pattern import step, and public-safety grepsCode / scripts / configs — ⏸ not started
scripts/deploy/start.shbase-image build behaviorscripts/deploy/verify-platform.sh+validate.sh(repair or delete).env.exampleannotation against compose env blocksdocker-compose.prod.yml/gcp-deploy.sh/deploy.config.exampledecisionDocumentation — ⏸ not started (depends on skill regeneration after code/script fixes land)
guides/deploying-trinity.md→ hub + spokes restructuresetup.mddeduplicated against deploying guide/trinity:connectstep correctedupgrading.md+monitoring.mdBlockers — open product questions
These need decisions before the docs spoke work can land cleanly (Section E in the issue body):
docker-compose.prod.yml+scripts/deploy/gcp-deploy.sh+deploy.config.example: keep or kill?verify-platform.sh+validate.sh: repair against current architecture or delete + replace?When picked up again
feature/504-deployment-alignment(rebase on latestdevfirst)/generate-user-docsagainst the now-correct codebasefix(deploy): align scripts, configs, and docs with production operati…
fix(deploy): align scripts, configs, and docs with production operati…
Release: v0.5.0 (#608)
AndriiPasternak31 commentedon May 12, 2026
Sub-finding: setup-token banner is swallowed before reaching
docker logsThe current AC frames the first-time-setup story as a documentation gap, but there's a runtime visibility bug underneath that the existing wording doesn't catch.
Bug:
src/backend/main.py:335-341uses bareprint()for the "TRINITY FIRST-TIME SETUP REQUIRED" banner and the setup token. Under uvicorn's--reloadparent process, stdout is buffered, so even when the setup-token path is being exercised correctly, the token never reachesdocker logs trinity-backend. Lines 343-358 have the same problem for the agent-enumeration / system-agent-deploy startup output.The pattern drift is obvious — lines 325/327 right above use
logger.info()correctly.Repro (clean):
<worktree>_trinity-data), sosystem_settings.setup_completedis unset../scripts/deploy/start.shdocker logs trinity-backend | grep -i setup→ no banner, no token.POST /api/tokenreturns403 setup_required, and there's no documented way to recover except manuallyINSERT INTO system_settings('setup_completed','true')against the DB.Suggested AC addition (one-line each):
src/backend/main.py:335-341— replace bareprint()withlogger.info()so the setup-token banner reachesdocker logsreliably (or setPYTHONUNBUFFERED=1indocker/backend/Dockerfileas a less-targeted alternative).main.py:346,348,350,355,357(agent enumeration + system agent deploy output) for consistency.docker logs trinity-backendwithin 10s of boot.Discovered while running #474's new integration suite against a fresh phoenix worktree (Conductor) — the worktree-per-compose-project reality means new dev workspaces hit this every time.
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).