Repository navigation
Conversation
… it (#2380) Provisioning a bare cloud VM for Trinity existed in three copies: the Packer bakery, the Packer first-boot script, and a hand-written script pasted into the DigitalOcean deploy doc. They had already drifted — one carried a DOCKER-USER DROP list missing 8081, so the login page answered plain HTTP past the certificate and past the http->https redirect, on the image whose headline design note is that everything reaches users through Caddy on 80/443. `start.sh --provision --cloud <name>` is now the only implementation, in two phases because a snapshot-based image splits them: `--machine-only` (packages, pinned Caddy with the IP-certificate floor asserted, ufw, the firewall unit) is bakeable; `--site-only` (the instance's own IP, the .env keys, the Caddyfile, the certificate) is per-instance. The bakery calls the first, first boot calls the second and continues into the install, and a doc-driven install calls both. firstboot.sh drops from 230 lines to 118 and 01-provision.sh from 176 to 99. It is off by default and refuses unless it is root on Linux with a cloud metadata service answering, so it stays inert on a developer laptop. An ADMIN_PASSWORD in the environment is now written through to .env, so an install script does not have to hand-roll its own .env writer. The firewall rule is inverted rather than enumerated. Everything entering a container from off-box is dropped whatever the port, with two RETURNs ahead of it: replies to connections a container opened (without which agents lose outbound internet), and traffic from Docker's own bridges. Naming what is inside rather than which interface is outside also covers DigitalOcean's private eth1. There is no list left to drift, so the test that policed the list is replaced by one that pins the ordering and the absence of a fourth copy. Also widens the first-run hardening guide to doc-driven DigitalOcean installs, which #2380's author amended their own acceptance criterion to require. The installer records `do-script` — honest, because it refuses to run at all unless DO's metadata service answers — and `hardening_guide_eligible` is a separate gate from `marketplace_install` rather than a widening of it, so the guide reaches these installs without anyone claiming a vendor listing they never came from. Deliberately still provenance and never TLS state: the managed fleet runs plain HTTP behind a tunnel with no domain and a 100.x address, so a posture-based gate would fire on every paying client forever. The https-ip copy gains the renewal caveat, hedged the way that block's own acceptance criterion requires: a ~6-day certificate renewed only while the machine runs is a property of the profile such an install is known to use, so it is stated as what happens after a long shutdown, never as a claim about this instance's live certificate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
…2380) The deploy doc's flow was eight manual steps in DigitalOcean's web console, one of which is "paste this script into a textarea after editing three lines". Seven of those eight can be a script, and the one that cannot — open the URL and sign in — is the human's job anyway. A console click-path also cannot satisfy this work's own acceptance criterion that every command in the doc has been executed verbatim at least once: nobody can execute "tick Advanced Options", so the most error-prone step is the one that ships permanently untested. It prompts rather than shipping a file to edit. "Download this and change four lines" fails the audience the doc exists for, and it puts two secrets in a file on disk; `read -rs` keeps both off the terminal, out of shell history, and out of every file but the droplet's own user-data. Checks come before questions, so a missing doctl is never discovered after collecting two credentials. The password is asked twice because it is the credential for a server that does not exist yet — a typo is not recoverable by retrying, it is a rebuild — and the paid resource is confirmed before it is created. Prompts still read from a pipe, so the whole flow stays drivable in a test: printf 'pw\npw\ntoken\n\n\ny\n' | bash scripts/deploy/trinity-do-create.sh The droplet-side half is unchanged and stays one copy: clone, then `start.sh --provision --cloud digitalocean --hosted --unattended`, the same installer the Packer image runs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
) A cloud instance serves its own user-data verbatim from link-local, for the life of the machine, to anything that can reach it — and on a script-installed droplet that user-data carries the Trinity admin password and the operator's Claude subscription token. Agent containers could reach it. An agent running untrusted model-authored code is precisely the case that must not be able to read the credential that owns the box. Dropped outbound from containers as the RFC 3927 range rather than the well-known 169.254.169.254 host: the property being blocked is "link-local, host-adjacent, not routable", and every cloud publishes its metadata endpoint somewhere in that range, so the single address would have been a DigitalOcean- shaped fix to a general problem. Position is load-bearing and is what the test pins. The DROP sits after the conntrack RETURN (so only the opening packet of a metadata connection is ever evaluated, which is enough — it never establishes) and BEFORE the two bridge RETURNs. Behind them it would be decoration: container-originated traffic RETURNs out of the chain before reaching it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
…ed (#2380) The hardening card's step one told the operator to point DNS at the server and set the Public URL in Settings, then said "whatever terminates TLS in front of it picks up the name". Nothing does. `public_chat_url` is a display and webhook-base setting, and the card's own source comment says so — no code reads it and reconfigures a proxy, a listener or a certificate. On every install this card is shown to, Caddy is holding a single `https://<IP>` site block written at provision time. So the sequence the card produced was: operator sets the URL, install_tls_posture flips to `https-domain` by string-parsing that setting, the card treats step one as complete and advances to the tunnel step, and the domain serves a certificate error because the web server still answers only to the IP. The card retired on a state it had helped break, and the instance was worse off than before it gave the advice. `scripts/deploy/set-domain.sh` does the job the card was describing. It refuses unless DNS already points at this machine — that check is first, before anything is touched, because issuance validates over the name and a stale A record is what turns a working instance into a broken one. Then it rewrites the Caddyfile for the name (no `shortlived` profile: a real name earns an ordinary ~90-day certificate, which is the upgrade being made), validates, reloads, waits for the certificate against the real hostname with the system trust store, and only then tells Trinity its new address. Every failure after the rewrite restores the previous config and reloads, so a bad run ends where it started. The bare IP is kept as a redirect rather than dropped, with its short-lived certificate, so links handed out before the domain existed keep working — a redirect that cannot complete a handshake is not a redirect. It runs on the server because it has to: Trinity is in a container with no host privileges, so it can neither write /etc/caddy/Caddyfile nor reload Caddy. The card now says that, names the command, and keeps every honest claim the previous copy made — it only moves the actor from "whatever is out there, somehow" to something the operator can actually run. That constraint is the same one that already keeps the tunnel step to prose, so the card is now consistent about it. `set_env_key` moves to scripts/deploy/env-file.sh, sourced by both writers: a .env writer that disagrees with itself corrupts credentials silently, and this branch exists because two copies of provisioning logic drifted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
Walking the journey a real operator takes found the previous fix had covered the wrong half. The card said the right thing in its disclosure and still pointed its primary button at the trap. The operator who HAS a domain — exactly who the button was for — clicked "Add a domain", landed on Settings → General → Public URL (a bare input, a Save button, no guard, placeholder `https://your-domain.com`), typed their domain and saved. That sets the name Trinity hands out and reconfigures nothing: Caddy still held only the `https://<IP>` site written at provision time, so the domain served a certificate error while the old IP link kept working and the instance looked fine. `install_tls_posture` then flipped to `https-domain` by string-parsing their own input, the card advanced to the tunnel stage, and the address section carrying the command that would have fixed it — `v-if` on that stage — disappeared. The UI congratulated them on a step it had just helped them break, and removed the way back. So the face carries the command now, not a link to the field. There is no navigation button because there is nowhere useful to navigate: `set-domain.sh` sets the Public URL itself, and setting it by hand is not enough on its own. `select-all` on the block so one click takes the whole line. The disclosure keeps the reasoning, including the sentence saying explicitly that the settings field alone does not do it. The three tests that pinned the old shape are updated rather than deleted, each carrying why the assertion inverted — "links to Settings → General" was a true description of a defect. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
#2380) The last two attempts at this both ended with an operator needing a root shell on the droplet, which a non-engineer following a deploy guide does not have. The constraint that forced it was real — Trinity is containerised and can neither rewrite /etc/caddy/Caddyfile nor reload Caddy — but it was the wrong thing to work around. Inverting the direction removes it entirely: Caddy asks Trinity whether a hostname is allowed, Trinity answers from what an admin saved, and no privilege moves into the container. The provisioned Caddyfile gains a catch-all site with on-demand TLS and an `ask` gate at /api/public/tls-allowed. Save a domain in Settings, point its A record here, and the first visit obtains the certificate. That is the whole step, which is what this card claimed from the beginning. The gate carries the entire security model, so it allows exactly one name: the host of the saved public_chat_url, parsed with urlparse and compared for equality. Substring matching would hand `evil-example.com` a certificate request from a server configured for `example.com`. It fails closed on an unset URL and on a failed settings read — `on_demand` without a working gate turns the instance into a certificate requester for anyone who points DNS at its address, until the ACME account is rate-limited and the operator's own renewals start failing. Executed rather than grepped in the tests: a static check cannot tell an exact match from a substring one, and that difference is the whole of it. set-domain.sh is deleted. It was written for this job two commits ago and is now a second way to do something that works from the browser; keeping it as a "fallback" would have been keeping a path nobody tests for a case that no longer exists. Caddyfile syntax verified against the 2.11.x docs rather than memory: `interval` and `burst` are removed from on_demand_tls, `ask` receives ?domain= and authorises on 2xx. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
…2380) Without this the droplet has no key on it, DigitalOcean emails a root password to the account owner, and the only way to a shell is the browser console. That is fine until something needs looking at, which on a first deploy is exactly when it happens. Attaches keys that already exist on the account — the operator's own, on the operator's account, going onto the operator's server. Nothing is created, uploaded or generated, and an account with no keys behaves exactly as before. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QvfFoqB2v2zPyXJXeyBGbP
`mktemp -t trinity-user-data` takes a bare prefix on macOS/BSD, but GNU coreutils reads the same argument as a template and requires the trailing X's — so on Ubuntu (i.e. every Linux operator) the installer died with "mktemp: too few X's in template" immediately after collecting both secrets and confirming the create. Use a full path template instead: portable on both, and it keeps the umask-077 0600 mode the user-data file needs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LgRv6koYJKzor7ZHoRkGYS
dolho
force-pushed
the
feature/2380-do-provision
branch
from
September 10, 2026 11:49
efd7efc to
aaa3de5
Compare
#2680 landed two build-standard changes on the files this branch restructured: - 01-provision.sh: the pre-install `apt-get full-upgrade` (DO's img-check fails on pending security updates) is kept, now between `apt-get update` and the checkout's own package install. - firstboot.sh: the body is this branch's `start.sh --provision --site-only` call; the `X-DO-MARKETPLACE` header #2680 added to the Caddyfile moves to `provision_site` in start.sh, where the Caddyfile is written now, keyed on the do-marketplace provenance since the same path serves the doc install. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015owqMKD5QDjzZrUTF2Joht
…ddyfile is written now #2680's guard pinned the header inside firstboot.sh's Caddyfile heredoc; #2380 moved that heredoc into `start.sh --provision --site-only`, so the merge left the test asserting a file that no longer writes a Caddyfile. Point it at start.sh and also pin that the header is keyed on the do-marketplace provenance, since the same function serves the doc install. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015owqMKD5QDjzZrUTF2Joht
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #2380.
The branch behind
v0.9.5-rc1/rc2— the one-command DigitalOcean installer plus the provisioning/onboarding work it rides on — has never been opened as a PR againstdev. Opening it as a draft so the diff is reviewable, with one new fix on top.The fix on top
mktemp -t trinity-user-datatakes a bare prefix on macOS/BSD, but GNU coreutils reads the same argument as a template and requires the trailingXs. So on Ubuntu — i.e. every Linux operator — the installer died immediately after collecting both secrets and confirming the create:Reproduced on Ubuntu 24.04 via the published
v0.9.5-rc2raw URL.Now a full path template, portable on both, keeping the
umask 0770600 mode the user-data file needs (it carries the admin password and the Claude subscription token):USER_DATA="$(mktemp "${TMPDIR:-/tmp}/trinity-user-data.XXXXXX")"Verified:
bash -nclean;mktempsmoke test yields-rw-------. The rest of the script was scanned for the other GNU/BSD splits (sed -i,base64 -w,date -v,readlink -f,stat) — clean, this was the only one.Draft, because
dev— wants a rebase/merge before it is landable.TRINITY_IMAGE_TAGdefault both pinv0.9.5-rc2, so nobody gets the fix until a new rc tag is cut (or the fix lands and the tag moves). That call is not made here.Test
TRINITY_IMAGE_TAG=v0.9.5-rc2 bash <(curl -fsSL https://raw.githubusercontent.com/abilityai/trinity/feature/2380-do-provision/scripts/deploy/trinity-do-create.sh)Creates a real ~$48/month droplet. Destroy with
doctl compute droplet delete <name>.🤖 Generated with Claude Code
https://claude.ai/code/session_01LgRv6koYJKzor7ZHoRkGYS