Repository navigation
feat(hosting): publish prebuilt images and install from them (#2280) - #2390
Conversation
A fresh VM was spending 5-10 minutes compiling the agent base image (Python + Node + Go + Claude Code, ~1.9 GB) before it served anything. That fails the "one click" bar for every marketplace channel and is rejected outright by managed hosts and template catalogues, which accept pull-only compose files only. This is the gate the whole hosting arc (#2281 DigitalOcean, #2282 Vultr, #2283 Hostinger/Dokploy, #835 Packer) sits behind. - `.github/workflows/publish-images.yml` pushes five images to GHCR on every `v*` tag — the four platform services and the agent base image. `latest` is applied only on a real release tag, so a dispatch smoke build can never become what every hosted install pulls. The checkout sets `submodules: false`, so the published backend is OSS-only by construction rather than by a .dockerignore rule someone can edit. - `docker-compose.hosted.yml` is `docker-compose.prod.yml` with the `build:` blocks replaced by GHCR `image:` refs and nothing else changed. It is generated from prod, not hand-written. - `start.sh --hosted` installs from those images. A flag, not a second script: secret generation, the ADMIN_PASSWORD contract #2381 made honest, DOCKER_GID detection, the health poll and the next-steps card are shared. A parallel installer is the same bug one layer up. Two things that are easy to get wrong, so they are stated: The agent base image is not a compose service and never will be. The backend creates agent containers through the Docker SDK from the literal local tag `trinity-agent-base:latest`, hardcoded in lifecycle.py and allowlisted as `trinity-agent-base:*` by SEC-172, and compose cannot retag — so `--hosted` pulls the GHCR copy and tags it locally. Retagging rather than repointing keeps SEC-172 and the #1809 drift check untouched. A bare `docker compose -f docker-compose.hosted.yml up -d` starts a platform that cannot create a single agent, and fails later at agent-create time rather than at install time. Hence "re-run start.sh --hosted" as the upgrade instruction, never "pull". Two compose files describing one platform is exactly the shape of a bug this repo has shipped five times and named: LOG_* (#1039), the VoIP master switch (#1056), AGENT_AUTH_SECRET (#1707), the container log caps (#1871), and ADMIN_USERNAME as recently as #2381. So tests/unit/test_2280_hosted_compose_parity.py fails CI when the two files disagree on the service set, any third-party pin, the top-level volumes/networks, or any per-service environment/ports/volumes/networks/ depends_on/container_name/restart/cap_*/security_opt/healthcheck value. It compares the raw YAML, not `docker compose config` output: the raw form still holds the unexpanded ${VAR:-default} strings, so a changed default is a diff, where the resolved form would agree whenever the local .env happens to match. Also here: - Build args are per image. Only the backend declares the six provenance ARGs; the scheduler and mcp-server declare none, and an undeclared --build-arg warns on every build. The frontend takes none deliberately — every VITE_* var is inlined into the world-readable bundle, so a published image may only carry values correct for every install, which works only because VITE_API_URL is inert (#722). - The docker/* actions are SHA-pinned, matching this repo's posture for every other third-party action. One of them holds a packages:write token. - Provenance values reach the build-args step through `env:`, never through ${{ }} inside a shell body. The commit subject is chosen by whoever lands the commit, so interpolating it into `run:` is a command-injection sink on a runner holding that token. - TLS on a bare VM is decided and written down (tunnel / private network / operator-run proxy), with plain HTTP on a public IPv4 called out as the one combination to avoid. - The 8 GB floor is stated in the compose header and both install docs, and pinned by the parity test so it cannot quietly drop out. AC4 (the cloud-init user-data example) lives in trinity-ops-public, so #2280 stays open until that lands. Refs #2280
Code review —
|
dolho's review, in order.
High:
1. A `TRINITY_IMAGE_TAG` pinned in `.env` was silently replaced with
`latest` on every run. The script exported an unconditional default
and never read the file, and compose gives the shell environment
precedence over `.env` — so the operator's pin lost, and the summary
printed `Currently pinned to: latest` as though they had chosen it.
That is exactly the unscheduled upgrade the rest of the script warns
about. Now resolved shell/CI > `.env` > `latest`, after `.env` exists,
mirroring the FRONTEND_PORT read. Documented in `.env.example`, which
is where an unattended or marketplace install can persist it.
2. Every documented pin example was a tag that is never published.
`{{version}}` strips the leading `v`, so git tag `v0.9.0` published
`0.9.0` — while four places told operators to set `v0.9.0`, a pull
that fails `manifest unknown`, which start.sh treats as fatal with a
message blaming their spelling. Publishes the v-prefixed alias too:
one extra tag ref, and the release name and the image tag become the
same string.
Medium:
3. `FRONTEND_PORT` was inert — hardcoded `"80:8080"` — while start.sh
offers it as the fix for a port conflict and prints the resulting URL.
Fixed in prod as well as hosted: same inert knob, and diverging the
two files would defeat the parity guard.
4. The documented tunnel never started. `cloudflared` is profile-gated,
so setting `TUNNEL_TOKEN` produced no container and no error, leaving
the instance in the plain-HTTP-on-a-public-IPv4 state the same table
says to avoid. `--hosted` now appends `--profile tunnel` when the
token is set. Documenting the flag instead was rejected: a default
posture that silently no-ops is the finding.
5. Converting a source install in place started from an empty database.
Dev keeps `/data` in a named volume, hosted binds a directory — and
Redis is shared, so the result is half-migrated, not merely fresh.
Refuses with the copy command rather than warning: the failure is
silent, and by the time it is noticed the new DB may be written to.
Low:
6. The compose header pointed twice at `scripts/deploy/hosted-up.sh`,
which does not exist. It is `start.sh --hosted`.
7. The header oversold the file as standalone. It has six relative bind
mounts; ingested without the repo, Docker creates them empty and the
first-run seed finds no manifests, with no error. Pull-only means
"does not build", not "needs nothing on disk" — now stated.
8. A `workflow_dispatch` build stamped provenance from the dispatching
branch, not the tree it built. `type=sha` and `GITHUB_REF_NAME` both
ignore `inputs.ref`. Both now come from the checked-out HEAD.
9. The parity guard was an 18-key allowlist while claiming to cover any
value — it omitted `profiles`, `env_file`, `logging`, `labels`,
`deploy`, `stop_grace_period`, and `profiles` is live on cloudflared
today. Inverted to wholesale: prod minus {build,image} vs hosted minus
{image}. An allowlist only watches keys someone remembered; the drift
that matters is the key nobody thought of.
10. `--hosted` disabled the #1432 Docker Desktop Vector fix outright. The
explicit `-f` defeats override AUTO-merge, but the override is still
applicable — it is now appended by name. The vector service is
byte-identical across both files.
The wholesale guard earned itself twice while writing this: it caught a
`profiles` key the old allowlist ignored, and then caught me reverting
the prod half of finding 3 with a stray `git checkout --`.
Verified with a stubbed docker on PATH: `.env` pin honoured and shell
override still wins; `--profile tunnel` appears only with a token set;
the override file is appended only on a VM-backed runtime; the dev→hosted
guard exits 1; and the dev path still issues a bare `compose up -d` with
no -f, no pull and no profile.
Refs #2280
|
Thanks — all ten verified against the tree before touching anything, all ten real, all ten fixed in 7c5b880. Notes where I did something other than the literal suggestion: 2 (unpublished tag). Took the first option — added 3 ( 4 (tunnel). Made it work rather than documenting the flag. HOST-010 names the tunnel as the default posture for a public instance, and a default that silently no-ops is the finding — 5 (dev → hosted). Refuses and exits rather than warning. The failure is silent, and by the time anyone notices, the empty DB may already have been written to. It prints the volume-copy command; 9 (parity allowlist). Took your inversion — 10 (Vector). Took your suggestion exactly — the override is appended to 7 (not standalone) is the one I have documented rather than solved. The file still carries six relative bind mounts, so it needs the repo checked out beside it; packaging the config into the images is a real change and a separate PR. The header now says so plainly instead of implying a catalogue can ingest it bare. Behaviour verified with a stubbed
|
Code review — re-review at
|
| if [ "$HOSTED" = "1" ]; then | ||
| _data_path="${TRINITY_DATA_PATH:-$(grep -E '^TRINITY_DATA_PATH=' .env 2>/dev/null | tail -1 | cut -d'=' -f2- | tr -d '[:space:]')}" | ||
| _data_path="${_data_path:-./trinity-data}" | ||
| _project=$(basename "$(pwd)" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]') |
There was a problem hiding this comment.
HIGH — the dev→hosted data guard fails open on any checkout directory containing - or _.
_project=$(basename "$(pwd)" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]')That strips hyphens and underscores; Compose's own project-name normalisation keeps them (verified empirically: dir proj_Trin-ity → project proj_trin-ity).
So in a checkout named project_trinity — the layout CLAUDE.md itself documents — or trinity-dev, or a worktree like trinity-140, docker volume inspect "${_project}_trinity-data" looks up projecttrinity_trinity-data, misses, and the guard silently passes. That produces exactly the empty-DB-plus-shared-Redis half-migration it was written to prevent, on the directory names most likely to be in use.
COMPOSE_PROJECT_NAME is also ignored, and this is now a third project-name derivation in the file, disagreeing both with Compose and with the pre-existing volume_exists() (basename "$PWD", no lowercase).
Fix: tr -cd '[:alnum:]_-' plus ${COMPOSE_PROJECT_NAME:-...}, or read the real name from docker compose config --format json.
There was a problem hiding this comment.
Confirmed and fixed — you were right about both halves, and the empirical check was decisive.
docker compose config on this repo's Compose version:
dir project_trinity -> name: project_trinity
dir trinity-dev -> name: trinity-dev
dir proj_Trin-ity!x -> name: proj_trin-ityx
dir --_Foo.Bar -> name: foobar
So the rule is: lowercase, keep [a-z0-9_-], drop everything else, trim leading _/-. tr -cd '[:alnum:]' disagreed on exactly the two characters that appear in every real checkout name.
There is now one compose_project_name() at the top of the file, and volume_exists() uses it too — so the fourth spelling (basename "$PWD", unlowercased) is gone with it. COMPOSE_PROJECT_NAME is honoured with Compose's own precedence (shell over .env), also verified rather than assumed.
I did not read the name back out of docker compose config --format json: it would need a JSON parse with no guaranteed jq on the host, and the guard runs before anything else has proven the compose file resolves. A helper whose output is pinned equal to Compose's gets the same correctness without that dependency.
tests/unit/test_2390_start_sh_env_and_project_name.py executes the helper under bash for every case above, and end-to-end smoke confirms the guard now refuses in both trinity-dev and project_trinity (it passed silently in both before).
| **On a server — pull prebuilt images (`--hosted`). This is the default you want (#2280):** | ||
|
|
||
| ```bash | ||
| git clone https://github.com/abilityai/trinity.git |
There was a problem hiding this comment.
MEDIUM — the documented hosted install creates a one-line .env and thereby suppresses the .env.example copy.
The snippet is git clone ... && cd trinity && echo 'TRINITY_IMAGE_TAG=v0.9.0' >> .env && ./scripts/deploy/start.sh --hosted --unattended.
start.sh copies the template only under if [ ! -f .env ], which is now false — so the install proceeds with a .env holding a single key: no ANTHROPIC_API_KEY, no FRONTEND_URL, no EMAIL_*, no TRINITY_DATA_PATH.
docs/DEPLOYMENT.md gets this right (cp .env.example .env first); this guide, which an installing agent follows verbatim, omits it.
There was a problem hiding this comment.
Fixed. Added cp .env.example .env as the first line, plus a note saying why the order matters, since the failure is invisible at install time:
Copy the template before you append to it.
start.shseeds.envfrom.env.exampleonlyif [ ! -f .env ]. Writing the pin first creates the file, so the seed is skipped and the install proceeds on a.envholding one key [...] The stack still boots, which is what makes it worth calling out: you find out later, one missing knob at a time.
Good catch that this is the guide an agent follows verbatim — DEPLOYMENT.md had it right and this one is the copy that actually gets executed.
| # for a duplicated key. | ||
| resolve_image_tag() { | ||
| if [ -z "${TRINITY_IMAGE_TAG:-}" ]; then | ||
| TRINITY_IMAGE_TAG=$(grep -E '^TRINITY_IMAGE_TAG=' .env 2>/dev/null | tail -1 | cut -d'=' -f2- | tr -d '[:space:]') |
There was a problem hiding this comment.
MEDIUM — resolve_image_tag's naive .env parse is exported, so it overrides Compose's own correct parse.
cut -d'=' -f2- | tr -d '[:space:]' keeps surrounding quotes and swallows inline comments. TRINITY_IMAGE_TAG="v0.9.0" yields "v0.9.0"; TRINITY_IMAGE_TAG=v0.9.0 # pinned yields v0.9.0#pinned.
Compose would have parsed both correctly — but because the value is exported, the shell wins over .env for every service image ref too. The run then dies at the agent-base pull with the tailored message blaming "image-tag spelling", pointing the operator at a .env line that is in fact valid.
Strip surrounding quotes and a trailing #... before exporting.
There was a problem hiding this comment.
Fixed, and generalised — this was four call sites, not one (TRINITY_IMAGE_TAG, TUNNEL_TOKEN, and TRINITY_DATA_PATH in two places), each with its own spelling.
There is now a single env_value() that mirrors compose-go's dotenv rules, with the expected values taken from docker compose config rather than from reading the source:
X="v0.9.0" -> v0.9.0 (quotes stripped)
X=v0.9.0 # pin -> v0.9.0 (inline comment stripped)
X=/srv/my dir -> /srv/my dir (internal spaces preserved)
X='has#hash' -> has#hash ('#' inside quotes is literal)
Your point about the export is the reason this mattered more than it looked, and it is now written into the comment: the value wins over .env for every service ref, so a mis-parse here overrode a valid operator line and then blamed them for it.
Smoke-verified: TRINITY_IMAGE_TAG="v0.9.0" # pinned now pulls ghcr.io/abilityai/trinity-agent-base:v0.9.0.
| # dev stack comes up against an EMPTY database and migrates from zero, while the | ||
| # real one sits untouched in the named volume — and Redis (`redis-data`, a named | ||
| # volume both files share) is NOT reset, so the result is a half-migrated | ||
| # install with live session/lock state pointing at rows that no longer exist. |
There was a problem hiding this comment.
MEDIUM — the reverse switch (hosted → dev) is unguarded, and is the likelier mistake.
The new refusal covers "dev volume exists, hosted bind DB missing". An operator who installed with --hosted and later runs ./scripts/deploy/start.sh without the flag — forgetting it, or following older docs — gets docker-compose.yml, an empty trinity-data named volume and the same shared redis-data: identical half-migrated state, with no warning at all.
A symmetric check (${_data_path}/trinity.db exists && HOSTED != 1 && no dev volume) closes it.
There was a problem hiding this comment.
Agreed, and fixed — and I think you are right that it is the likelier of the two, because it needs no new flag, just a forgotten one.
Rather than bolt on a second independent check, the state is read once and both refusals branch off it:
_dev_volume=0; docker volume inspect "${_project}_trinity-data" >/dev/null 2>&1 && _dev_volume=1
_hosted_db=0; [ -f "${_data_path}/trinity.db" ] && _hosted_db=1so the pair cannot drift into disagreeing about what it found. The reverse message points at the --hosted flag first (the usual cause) and gives the copy-into-the-volume path second.
Smoke-verified: a checkout with trinity-data/trinity.db and no dev volume now refuses a bare ./scripts/deploy/start.sh and prints both routes.
| echo " Copy the data across first (with the stack stopped):" >&2 | ||
| echo " docker compose stop" >&2 | ||
| echo " mkdir -p ${_data_path}" >&2 | ||
| echo " docker run --rm -v ${_project}_trinity-data:/from -v \"\$(pwd)/${_data_path#./}\":/to \\" >&2 |
There was a problem hiding this comment.
LOW — the guard's suggested copy command is wrong for an absolute TRINITY_DATA_PATH.
"$(pwd)/${_data_path#./}" strips only a leading ./, so TRINITY_DATA_PATH=/srv/trinity-data emits -v "/path/to/repo//srv/trinity-data":/to and silently copies the database into the wrong place.
(That value was also run through tr -d '[:space:]' on read, so a path containing spaces is already corrupted before it reaches here.)
There was a problem hiding this comment.
Both fixed.
The path is absolutised by case rather than by prefix-stripping:
case "$_data_path" in
/*) _data_abs="$_data_path" ;;
*) _data_abs="$(pwd)/${_data_path#./}" ;;
esacand _data_abs is what the mkdir -p / docker run -v lines print, quoted.
The parenthetical was the more interesting half: tr -d '[:space:]' is gone from every .env read, so a path containing spaces now survives — that is pinned by a test case (X=/srv/my data/dir -> /srv/my data/dir), matching what docker compose config does with the same line.
Smoke-verified with an absolute TRINITY_DATA_PATH: the printed command carries the path as-is, with no $(pwd) prefix.
| if [ "$HOSTED" = "1" ]; then | ||
| _cf="-f docker-compose.hosted.yml" | ||
| echo "To view logs: docker compose ${_cf} logs -f" | ||
| echo "To stop services: docker compose ${_cf} stop" |
There was a problem hiding this comment.
LOW — the printed hosted commands drop --profile tunnel, so they cannot manage the container the script just started.
With TUNNEL_TOKEN set the script activates the profile (:327), but the summary prints docker compose -f docker-compose.hosted.yml stop / logs -f. Compose acts only on services in the active profile set, so stop leaves trinity-cloudflared running and the tunnel live after the operator believes the stack is down.
Persisting COMPOSE_PROFILES=tunnel in .env — which every later bare compose command inherits — makes the printed commands correct.
There was a problem hiding this comment.
Fixed, and I took the COMPOSE_PROFILES route you suggested — verified first that Compose reads it from .env, and that a duplicated key there resolves last-wins.
persist_compose_profile tunnel appends rather than rewriting in place. Appending is enough given last-wins, and it keeps an operator-authored value out of a sed replacement, where an & or the delimiter would be substitution syntax rather than text. It is additive (COMPOSE_PROFILES=obs becomes obs,tunnel) and a re-run is a no-op, both smoke-verified.
Your framing of the consequence is now the comment on it: stop left the tunnel container running and the instance publicly reachable after the operator had been told the stack was down.
|
|
||
| if [ "$HOSTED" = "1" ]; then | ||
| echo "Pulling platform images (tag: ${TRINITY_IMAGE_TAG})..." | ||
| docker compose "${COMPOSE_FILES[@]}" pull |
There was a problem hiding this comment.
LOW — a failed platform-image pull dies bare on set -e, unlike the base-image pull one screen above.
The agent-base pull has a tailored fatal message naming the tag and the --hosted fallback; docker compose ... pull immediately after has none. The likeliest failure — a tag not yet published, or GHCR denying an anonymous pull — surfaces as a raw Compose error on precisely the install least equipped to interpret it.
There was a problem hiding this comment.
Fixed — it now has a tailored fatal matching the agent-base one, and it names the two causes you identified:
ERROR: could not pull the platform images at tag 'latest'.
Most likely one of:
• the tag does not exist — check TRINITY_IMAGE_TAG against
https://github.com/abilityai/trinity/releases (both 'v0.9.0'
and '0.9.0' are published for the same digest);
• 'denied' / 'unauthorized' — the GHCR package is not public;
report it, it is a publishing fault, not yours;
• no network route to ghcr.io.
The middle line is deliberate after your next comment: an operator hitting a private package should be told it is not theirs to fix, rather than be sent looking for a login.
| @@ -0,0 +1,206 @@ | |||
| name: Publish container images | |||
There was a problem hiding this comment.
LOW — nothing makes the published GHCR packages anonymously pullable, and the failure lands on the operator.
Container packages first created by GITHUB_TOKEN are not reliably public. If any of the five lands private, docker pull ghcr.io/abilityai/trinity-agent-base:latest on a fresh VM fails with denied, and start.sh reports it as a network or tag-spelling problem.
This is the one path the PR itself notes is untestable pre-merge, so a release-checklist line ("set package visibility to public on first publish") or an explicit post-push verification step is worth having.
There was a problem hiding this comment.
Good catch, and this is the one I could not test any other way — so I made CI test it instead of writing it on a checklist.
The workflow now has a post-push Verify anonymous pull step: it fetches the manifest with a scratch DOCKER_CONFIG, so the runner's own ghcr.io login cannot mask a private package, and it retries a few times because visibility/propagation is not instant on a first publish. On failure it emits a GitHub error annotation carrying the fix:
GitHub → Packages →
→ Package settings → Change visibility → Public. This is normally needed only on the first publish of a package.
It runs after the push and fails the job on purpose: the image is already published at that point, so a red step is the signal to flip visibility once, not a lost build.
Paired with a line in DEPLOYMENT.md telling an operator that denied (as opposed to manifest unknown) is a publishing fault and points at that step — so nobody works around it with a login.
I preferred this to querying the packages API for visibility: it exercises the operator's literal path, and needs no permission GITHUB_TOKEN may not have on an org-owned package.
| echo "(See docs/DEPLOYMENT.md → Troubleshooting → Stale platform images.)" | ||
| echo "" | ||
| fi | ||
|
|
There was a problem hiding this comment.
(anchored to the nearest line in this PR's diff; the finding is at scripts/deploy/start.sh:69)
LOW — the port pre-flight still hardcodes 80 after FRONTEND_PORT was made live.
Both prod and hosted now honour ${FRONTEND_PORT:-80}, but the loop still probes 80 8000 8080 6379. An operator who took the message's own advice and set FRONTEND_PORT=8081 keeps being warned about 80 and is never warned about a conflict on 8081.
There was a problem hiding this comment.
Fixed. The loop now probes the configured port:
_preflight_frontend_port="${FRONTEND_PORT:-$(env_value FRONTEND_PORT)}"
_preflight_frontend_port="${_preflight_frontend_port:-80}"
for _pp in "$_preflight_frontend_port" 8000 8080 6379; do ...On a first install there is no .env to read, so it falls back to 80 — which is what will be bound.
Smoke-verified on a host where 80 is listening: with FRONTEND_PORT=9481 and 9481 bound, the message reads Ports already in use: 9481 8000 8080 6379 and says nothing about 80. Previously it was the exact inverse.
…ay Compose does (#2280) Second review round on #2390. Nine findings, and the two that matter share one root cause: start.sh had grown its own approximate copies of rules Compose already owns, and both copies were wrong in the direction that fails silently. **The guard failed open on the directory names most likely to be in use.** The dev->hosted data guard derived the compose project name with `tr -cd '[:alnum:]'`, which strips `_` and `-`. Compose keeps them. So in a checkout named `project_trinity` (the layout CLAUDE.md documents), `trinity-dev`, or a worktree like `trinity-2280`, `docker volume inspect` looked up a name no volume has ever had, missed, and the guard passed — producing exactly the empty-DB-plus-shared-Redis half-migration it exists to prevent. It also ignored COMPOSE_PROJECT_NAME entirely, and was the third spelling of the project name in the file (`volume_exists()` had a fourth: `basename "$PWD"`, unlowercased). There is now one `compose_project_name()`, and its output is asserted equal to `docker compose config`'s own `name:` for every case that broke. **The .env readers overrode Compose's correct parse.** Four call sites ran `grep ... | cut -d'=' -f2- | tr -d '[:space:]'`, which keeps surrounding quotes, swallows an inline ` # comment` into the value, and destroys internal spaces. Compose does the opposite on all three counts. That was not a cosmetic disagreement: the results are `export`ed, and Compose gives the shell environment precedence over `.env` — so `TRINITY_IMAGE_TAG="v0.9.0"` became `"v0.9.0"`, the pull failed, and the error message blamed the operator's spelling for a line that was valid. One `env_value()` now mirrors compose-go's dotenv rules, verified against `docker compose config` rather than against a reading of the source. Also fixed, in order of how they were found: - **The reverse switch is guarded too.** An operator who installed with `--hosted` and later runs the script without the flag gets `docker-compose.yml`, an empty `trinity-data` volume and the same shared `redis-data` — identical half-migrated state, with no warning at all. It is the likelier of the two crossings, because it needs no new flag, just a forgotten one. Both refusals now branch off one read of the state, so they cannot drift. - **The guard's copy command handles an absolute TRINITY_DATA_PATH.** `"$(pwd)/${_data_path#./}"` strips only a leading `./`, so `TRINITY_DATA_PATH=/srv/trinity-data` emitted `/repo//srv/trinity-data` and would have copied the database somewhere nothing reads. A path containing spaces also survives the read now that `tr -d '[:space:]'` is gone. - **The tunnel profile is persisted to `.env`.** Compose acts only on services in the active profile set, so the summary's own `docker compose ... stop` left `trinity-cloudflared` running and the instance publicly reachable after the operator had been told the stack was down. Persisting `COMPOSE_PROFILES=tunnel` makes every later bare command correct, including ones typed weeks from now. Appended rather than rewritten in place: Compose resolves a duplicated key last-wins, which keeps an operator-authored value out of a `sed` replacement. - **A failed platform pull is explained.** It died bare on `set -e`, unlike the agent-base pull one screen above, on precisely the install least equipped to read a raw Compose error — while its two likeliest causes (an unpublished tag, a private GHCR package) name neither. - **The port pre-flight probes the port the Web UI will actually bind.** It hardcoded 80 while both compose files honour `${FRONTEND_PORT:-80}`, so an operator who took the message's own advice kept being warned about 80 and was never warned about their real port. - **The publish workflow proves anonymous pullability.** A container package first created by GITHUB_TOKEN is not reliably public; if one lands private, `docker pull` on a fresh VM fails with `denied` and the failure lands on an operator who can do nothing about it. A post-push step now fetches the manifest with a scratch DOCKER_CONFIG — the operator's exact path, with the runner's own login unable to mask the result — and fails the job with the visibility fix in the error. - **The agent install guide copies `.env.example` before appending to it.** `start.sh` seeds `.env` only `if [ ! -f .env ]`, so writing the image pin first created the file and suppressed the seed; the install then proceeded on a single-key `.env`. It still boots, which is what makes it worth calling out. tests/unit/test_2390_start_sh_env_and_project_name.py executes both helpers under bash rather than grepping for the fix, with the expected values taken from `docker compose config`. Two tail guards fail the build if a third hand-rolled `.env` reader or project-name derivation reappears — both verified to fail when the old forms are put back. Verified: 1739 passed across the parity/packaging/guard/wiring/compose/env selection (the 5 TestCgnatSsrfGuard failures reproduce on an untouched dev checkout — macOS IPv6/DNS). End-to-end smoke of both install paths against a stubbed docker covers every finding: the guard now refuses in `trinity-dev` and `project_trinity`, refuses the reverse switch, prints an absolute copy path, resolves `TRINITY_IMAGE_TAG="v0.9.0" # pinned` to `v0.9.0`, persists `COMPOSE_PROFILES` additively and idempotently, explains a compose-pull failure, and warns about a bound 9481 while staying silent about a listening 80. Refs #2280
/review — re-review after
|
| AC | ||
|---|---|---|
| 1 — publish five images | ✅ | amd64; arm64 deferred with a stated reason |
2 — pull-only hosted compose, same .env contract |
✅ | and guarded wholesale |
| 3 — unattended never prompts / form unreachable | ✅ | via #2381 |
| 4 — cloud-init user-data example | ❌ | cross-repo |
| 5 — TLS decided + documented | ✅ | DEPLOYMENT.md:102 — a real decision table, not a shrug |
| 6 — 8 GB floor stated | ✅ | pinned by a test |
| 7 — both guides reference the pull-only path | ✅ |
AC4's handling is exemplary and I want to say so plainly: reported ❌ in the PR body, Refs not Fixes so #2280 stays open, and recorded in infrastructure.md as 🟡 Partial with the outstanding item named. That is the honest classification, and the requirements file carrying it is what stops "partial" decaying into "done" three weeks from now.
New findings — 2, both minor, neither blocking
[I1] The verify step interpolates ${{ matrix.image }} inside a run: body (Confidence: 7/10)
Two steps above, the PR states the rule and explains it well:
Every value arrives through
env:, never through${{ }}inside the shell body … a command-injection sink.
Then the ::error title= line in Verify anonymous pull does exactly that. It is not exploitable — matrix.image is one of five literals in this file, not attacker-controlled — so this is consistency, not a vulnerability. But the value of a rule like that is being unconditional: the next person copying this step as a template won't know which interpolations were audited. IMAGE is already in env:; the message can use ${IMAGE##*/}.
[I2] A fifth >> .env appender, and none of them guard the trailing newline (Confidence: 6/10 — pre-existing)
persist_compose_profile joins four appenders that already exist on dev. If .env's last line lacks a trailing newline, echo "K=V" >> .env silently concatenates onto it. .env.example ends with \n and the documented install uses echo … >> .env (which adds one), so the shipped paths are safe — this only bites a hand-authored file. Not this PR's to fix, and I'd rather it not grow scope; noting it because the fix is one shared helper and this PR is the natural place someone would later put it.
Summary
- Prior findings: 9/9 fixed, all verified — one demonstrated empirically
- New: 2 informational, 0 blocking
- Plan: 6/7 ACs met, the 7th honestly deferred cross-repo with the issue kept open
- Tests: 33 passed; CI 21 pass / 0 fail
Nothing here blocks. The two things I'd carry into other work from this PR are the inverted parity guard and making CI prove the anonymous-pull path — both are the shape where "someone will remember to check" gets replaced by something that fails loudly.
Review sweep —
|
… `latest`, and stop.sh knows which stack it is stopping (#2280) Addresses the second review round on #2390. Three defects, each silent at authoring time and only visible on a release cut or on a hosted server, plus the docs the capability was missing. C1 — the anonymous-pull verification failed on EVERY publish, before any network call. The step built `ghcr.io/${{ github.repository_owner }}/…` and this owner is literally `Abilityai`; a GHCR repository name must be lowercase, so docker rejects the reference locally ("repository name must be lowercase", reproduced). All five matrix jobs would burn 5x15s retries and exit 1 with `::error title=GHCR package is not public` even when the packages ARE public — destroying exactly the signal the step exists for and, per the workflow's own comment, training everyone to ignore the warnings that matter. The push itself was never affected (docker/metadata-action lowercases its `images:` input) and start.sh already hardcodes `ghcr.io/abilityai/`. Lowercased in the shell body. I1 — a `workflow_dispatch` from a tag ref republished that tag's version tags and repointed `latest` BACKWARDS. `startsWith(github.ref, 'refs/tags/v')` distinguishes tag from branch, not push from dispatch, and dispatching an old tag (the natural way to smoke-test the workflow) rebuilds at a new digest — the agent base bakes "Claude Code (latest)", so the content genuinely differs — silently downgrading every unpinned hosted install on its next `start.sh --hosted`. Gating the explicit `type=raw,value=latest` line alone would have been inert: metadata-action's default `flavor: latest=auto` applies `latest` on any semver tag ref by itself. So: `flavor: latest=false`, and every mutable/version tag now requires `github.event_name == 'push'`. A dispatch publishes `sha-<short>` and nothing else, which is what a smoke build needs; re-cutting a release is re-pushing the git tag, which fires `push`. I2 — stop.sh was not hosted-aware and ran the verb start.sh's own summary forbids. Hosted passes an explicit `-f`, which disables compose's file auto-merge, so a bare `docker compose` in the checkout loads the DEV file. Same project name, so it acts on the same containers — but it knows nothing about `cloudflared`, which the dev file does not define: the tunnel keeps running and the instance stays publicly reachable after "All services stopped". That is the hazard `persist_compose_profile` was added to close, re-entering through the one entry point that change did not touch. The file is now selected from the running stack's own `com.docker.compose.project.config_files` label — compose's record of what created the project, which cannot drift the way a marker file or a `trinity.db`-at-the-bind-path heuristic can — degrading to the dev default when there is no container or no label. And the verb is `stop`, not `down`: `down` removes the platform containers and tears down `trinity-agent-network`, and is what start.sh tells operators not to run in both branches. A script named stop.sh running the forbidden verb was a standing contradiction. Docs: new `docs/memory/feature-flows/hosted-install.md` (publish workflow -> GHCR -> `--hosted` pull/retag -> data-switch guards -> upgrade path, with a Testing section) + the index row and a Recent Updates entry. Fixed three stale "both compose files" claims in architecture.md — there are three now (#2216 DB backup, #1159 agent auth, #1871 x-logging). requirements 8.9 gains HOST-017 and HOST-018 for the two defects above, the corrected HOST-001 tag-gating rule, and the two test files its Tests row omitted. Tests: `tests/unit/test_2280_publish_workflow_and_stop.py` (7) pins all three — no raw mixed-case owner in an image reference and the built one is lowercased; `latest=false` present; every non-sha tag gated on push and the sha tag gated on nothing; stop.sh never runs `compose down` and selects its file from the label. 40 passed across the three #2280/#2390 files.
|
Agreed on all four — thanks, C1 in particular would have burned on the first release cut and told us the packages were private when they were not. Reproduced it locally before fixing: Fixed in 1f3ac10: C1 — the verify step now builds its reference in the shell body and lowercases it ( I1 — took both halves of your note. I2 — took it now rather than as a fast-follow. The dangerous half is introduced by this PR (a hosted Docs — added New guard Process note taken — |
Summary
A fresh VM was spending 5-10 minutes compiling the agent base image (Python + Node + Go + Claude Code, ~1.9 GB) before it served anything. That fails the "one click" bar for every marketplace channel, and managed hosts and template catalogues (Elestio, Dokploy, Coolify, Hostinger Docker Manager) reject a compose file that builds at all. This is the gate the whole hosting arc — #2281 DigitalOcean, #2282 Vultr, #2283 Hostinger/Dokploy, #835 Packer — sits behind.
Three pieces:
.github/workflows/publish-images.ymlpushes five images to GHCR on everyv*tag: the four platform services and the agent base image.latestlands only on a real release tag, so aworkflow_dispatchsmoke build can never silently become what every hosted install pulls. The checkout setssubmodules: false, so the published backend is OSS-only by construction rather than by a.dockerignorerule someone can edit.docker-compose.hosted.yml—docker-compose.prod.ymlwith thebuild:blocks replaced by GHCRimage:refs and nothing else changed. Generated from prod, not hand-written.start.sh --hostedinstalls from those images. A flag, not a second script: secret generation, theADMIN_PASSWORDcontract bug(security): fresh install leaves setup_completed=false with a real admin — unauthenticated /api/setup/admin-password overwrites the admin password #2381 just made honest,DOCKER_GIDdetection, the serving health poll and the next-steps card are all shared. A parallel installer would be the same bug one layer up.The agent base image is not a compose service, and never will be
The backend creates agent containers through the Docker SDK from the literal local tag
trinity-agent-base:latest— hardcoded inservices/agent_service/lifecycle.py, allowlisted astrinity-agent-base:*by SEC-172 — and compose cannot retag. So--hostedpulls the GHCR copy anddocker tags it locally before bringing the stack up.Retagging rather than making the reference configurable is deliberate: it keeps the SEC-172 allowlist and the #1809/#1816 drift check untouched, since both read the container's own
Config.Image, which staystrinity-agent-base:latesteither way. The alternative needed a widened allowlist for no gain.The consequence is worth knowing before someone writes a runbook: a bare
docker compose -f docker-compose.hosted.yml up -dstarts a platform that cannot create a single agent, and it fails later at agent-create time rather than at install time. That is why the upgrade instruction everywhere is "re-runstart.sh --hosted", never "pull".Why the parity test exists
Two compose files describing one platform is exactly the shape of a bug this repo has now shipped five times and named:
LOG_*(#1039), the VoIP master switch (#1056),AGENT_AUTH_SECRET(#1707), the container log caps (#1871), and — as recently as #2381 —ADMIN_USERNAME, present in the dev compose and absent from prod, so anADMIN_USERNAME=rootinstall silently kept provisioningadmin.tests/unit/test_2280_hosted_compose_parity.pyfails CI when hosted and prod disagree on the service set, any third-party image pin, the top-level volumes/networks, or any per-serviceenvironment/ports/volumes/networks/depends_on/container_name/restart/cap_*/security_opt/healthcheck/user/group_addvalue.It compares the raw YAML rather than
docker compose configoutput on purpose: the raw form still carries the unexpanded${VAR:-default}strings, so a changed default (VOIP_ENABLED:-false→:-true) is a diff, where the resolved form would silently agree whenever the local.envhappened to match.I hit the class while building this — I diffed against a stale copy of prod and the guard immediately flagged
ADMIN_USERNAMEas missing. It works.Also in scope
docker/backend/Dockerfiledeclares the six provenance ARGs; the scheduler and mcp-server declare none, and an undeclared--build-argwarns on every build, which trains everyone to ignore the warnings that matter. The frontend takes none deliberately: everyVITE_*var is statically inlined into the world-readable bundle, so a published image may carry only values correct for every install — possible at all only becauseVITE_API_URLis inert (api.jsusesbaseURL: '', nginx proxies same-origin; Config Validation: 5 critical config issues found (2026-05-08) #722 is an explicit warning against wiring it up).docker/*actions are SHA-pinned, matching this repo's posture for every other third-party action (tailscale, pypa, appleboy, google-github-actions). One of them holds apackages:writetoken.env:, never${{ }}inside a shell body. The commit subject is chosen by whoever lands the commit, so interpolating it into arun:script is a command-injection sink on a runner holding that token. Found in my own draft during self-review.-fdisables compose's override auto-merge, so the Docker Desktop Vector fix (bug: Vector docker_logs busy-loops on Docker Desktop — pegs the VM at ~4 cores, GB/day log churn; ship file-source local override #1432) is skipped instead of written as a file that looks like a fix and does nothing; the Show Trinity version in header + git commit/branch detail in Settings #926 git-provenance export is skipped too, since there is nobuild:block to consume it.docs/DEPLOYMENT.mdanddocs/AGENT_INSTALL_GUIDE.md, and pinned by the parity test so it cannot quietly drop out of the compose file.Acceptance criteria
.envcontract--unattendednever prompts; setup form unreachable on a public IPtrinity-ops-public, cross-repo#2280 stays open for AC4 — hence
Refs, notFixes.arm64 is deliberately not here. amd64 covers DigitalOcean Droplets and Vultr Cloud Compute, i.e. every marketplace lane; cross-building the ~1.9 GB agent base under QEMU is slow and flaky. Gate it on Hetzner CAX / Umbrel actually needing it.
Test plan
pytest tests/unit/test_2280_hosted_compose_parity.py— 25 pass.test_service_key_parity[environment]fails; reverted → 25 pass.docker compose -f docker-compose.hosted.yml configresolves clean;diffof resolved hosted vs prod is exactly the build blocks and image refs — every env key, port, volume and network identical.test_1810_1814_version_truth,test_848_inline_auth_compose_wiring,test_ent237_skill_source_env_packaging,test_1076_voice_model_config,test_1987_instance_label,test_canary_env_prod_parity,test_ent14_registry_env_packaging,test_1489_vite_bug_build_args,test_1871_log_config_parity— 148 pass.pytest tests/unit -k "parity or packaging or guard or wiring or compose or env"— 1518 pass. The 5test_mcp_validator.py::TestCgnatSsrfGuardfailures reproduce identically on an untouched checkout (macOS IPv6/DNS environment), verified this session.bash -n scripts/deploy/start.sh.dockeronPATH. Hosted issues exactlypull ghcr.io/abilityai/trinity-agent-base:latest→tag … trinity-agent-base:latest→compose -f docker-compose.hosted.yml pull→compose -f docker-compose.hosted.yml up -d; dev issuescompose up -dwith no-fand no pull, and prints the unchanged dev next-steps card.Review notes
The one thing worth a second opinion is HOST-007 (pull-and-retag vs. making the base-image reference configurable). I went with retagging to avoid widening the SEC-172 allowlist; if anyone would rather have
AGENT_BASE_IMAGEas real config, that is a different PR and a security review, not a tweak to this one.Refs #2280
Generated with Claude Code