Repository navigation
feat(hosting): Packer bundle for the DigitalOcean Marketplace 1-Click (#2281) - #2471
Conversation
…#2281) Builds an Ubuntu 24.04 snapshot from the prebuilt GHCR images (#2280) rather than from source: a 1-Click that compiles the agent base image on first boot fails the one-click bar, which is why #2280 gates this. Build time bakes Docker, Caddy, ufw, a pinned Trinity checkout at /opt/trinity, and all five images with the agent base retagged locally. First boot does only what is droplet-specific: resolve the admin password, write .env, close the Docker/ufw gap, issue a certificate for the droplet's own IP, and run `start.sh --hosted --unattended`. Four decisions worth stating, each with a failure mode behind it: - `image_tag` is required and rejects `latest`. A snapshot resolving `latest` at first boot would serve a different Trinity on every droplet created from one reviewed image, and Marketplace review approves a specific artifact. - The admin password comes from the MOTD, read via the control panel's browser Console — no SSH client needed. DigitalOcean 1-Clicks have no vendor-defined input form at deploy time (only the Managed Database checkbox), so it cannot be collected in the UI. An operator may override it through Additional Options -> Startup scripts, but only as `#cloud-config` write_files: 1-Click per-instance code runs from cloud-init's `scripts-per-instance`, which runs BEFORE `scripts-user`, so a user-data shell script would land after first boot had already generated a password and started Trinity. - Docker publishes past ufw. docker-compose.hosted.yml exposes 8000, 8080, 8686 and the OTel ports on 0.0.0.0, and Docker's iptables rules are consulted before ufw's chain, so `ufw deny 8000` on such a droplet is inert. First boot inserts a DOCKER-USER DROP for those ports on eth0 — the one chain Docker leaves to the operator and evaluates first. Host and inter-container access is unchanged. - First boot calls the same scripts/deploy/start.sh every other install uses. A marketplace-specific copy of the installer is the shape that has gone stale here before (#1039, #1056, #1707, #1871). The build's last step is DigitalOcean's own 90-cleanup.sh then 99-img-check.sh, in that order and last, so the snapshot is never created from a droplet that would be rejected at review, and nothing runs after the check to reintroduce what it verified was gone. Not yet exercised: `packer build` and img-check need the GHCR images, which do not exist until the first `v*` tag publishes them. Refs #2281, #2280
… validates
`packer validate` refused the whole template:
Error: Invalid validation error message
on trinity.pkr.hcl line 45, in variable "image_tag":
Validation error message must be at least one full sentence starting
with an uppercase letter and ending with a period or question mark.
The message began with the lowercase variable name. Reworded to lead with
"The image_tag variable ...".
This is not cosmetic: the failure is at the template level, so it fired
before any builder ran and made the image_tag guard — the thing that stops
a snapshot being built from a moving `latest` — unreachable. Both paths
are now exercised: a pinned tag validates, and `-var image_tag=latest` is
refused by the rule at trinity.pkr.hcl:43.
vybe
left a comment
There was a problem hiding this comment.
/validate-pr found one blocking gap; everything else is clean.
❌ packer/digitalocean/files/var/lib/cloud/scripts/per-instance/001-trinity is not in the PR. The body's file table lists it (seven files; the diff has six), 01-provision.sh:426 installs it, the README and firstboot.sh header both reference it — but the branch tree doesn't contain it (verified via git/trees on the head ref). Looks like a locally-written but never-git added file: your own verification note says "shellcheck on all five scripts", and only four scripts are committed.
Impact: packer build dies at the provisioner (install: cannot stat .../001-trinity) — or if it somehow survived, the snapshot ships with no boot hook and every droplet boots to nothing. Since packer build is deliberately deferred to the first release with GHCR images, this would surface exactly at the vendor-submission moment.
- Commit
files/var/lib/cloud/scripts/per-instance/001-trinity(the thin hook) - Consider a one-line guard in CI or
01-provision.shasserting everyinstallsource exists — this class (file referenced by the bundle but untracked) is invisible topacker validate,shellcheck, and every check that ran
Non-blocking notes: Refs #2281 (non-closing) is correct here given the human-gated listing steps — but that means no status auto-promotion on #2281; bump it manually when this lands. The ADMIN_PASSWORD grep hits are runtime derivations (urandom / user-data), not secrets — fine.
…nd verify one was The whole no-domain HTTPS story rests on Caddy obtaining a Let's Encrypt certificate for the droplet's bare IP. Two things made that a hope rather than a property. **Caddy was unpinned.** `apt-get install caddy` took whatever the stable repo happened to hold. Caddy could not issue IP certificates at all until recently — caddyserver/caddy#7399, where v2.10.0 fails outright with "subject '<ip>' cannot have public IP certificate"; the IPv4 fix landed via mholt/acmez#47 (2025-12-17) and IPv6 was not resolved until 2026-04-25, so v2.11.3 (2026-05-12) is the first stable release carrying both. It worked only because today's stable is new enough: a silent dependency on a moving upstream for the property this image is built around. Now pinned to 2.11.4 with a 2.11.3 floor asserted at build time — the assertion survives an edited pin, a version dropped from the repo, and a `caddy upgrade` on a running droplet, none of which the pin alone covers. Deliberately not `apt-mark hold`: forward versions carry the fix and holding would block security updates for the life of the droplet. **Nothing checked whether issuance succeeded.** The failure was silent and worse than silent: Caddy serves a TLS error, first boot still exits 0, and the MOTD prints a confident `https://<ip>` URL — so the user's first contact with Trinity is a browser warning on a box that reported success. First boot now polls its own public IP with normal certificate verification for ~150s and records the verdict to `/etc/trinity/tls-status`. The probe deliberately does not use `curl -f`. Trinity has not started yet (that is step 6), so Caddy answers 502 — which is the point: without `-f`, curl treats an HTTP error as success, so a zero exit means the handshake completed and the chain validated against the system trust store. That is exactly the claim under test, and nothing weaker separates a real Let's Encrypt certificate from Caddy falling back to its internal CA. Never fatal. A droplet serving HTTP with an honest banner is far better than one that refuses to finish booting, so the MOTD derives its scheme from the verified status rather than from what the Caddyfile intended, and says plainly that traffic is unencrypted when it is. Also updates the MOTD's next-steps line from "locking the instance to a VPN" to the Cloudflare Tunnel path, per the #2380 decision: a VPN breaks every inbound integration (Telegram, WhatsApp, VoIP, public links, x402, inbound A2A, webhook triggers — everything that calls us; only Slack survives, on Socket Mode), while a tunnel reaches the same "nothing listening on the public interface" outcome with all of them intact. Verified: `packer validate` passes; the version comparison accepts 2.11.3/2.11.4/2.12.0 and rejects 2.10.0/2.11.2; the MOTD renders correctly for both tls-status values; bash -n and shellcheck -S warning clean on all five scripts. Refs #2281, #2380
…ng (#2281) `packer/digitalocean/files/var/lib/cloud/scripts/per-instance/001-trinity` — the hook that makes a droplet do anything on first boot — was written locally and never committed. `.gitignore` carries the bare setuptools patterns `var/` and `lib/`, which git applies at every depth, so `git add packer/` skipped it and `git status` stayed clean. The bundle under `files/` mirrors a target filesystem, so the collision is structural rather than unlucky: a future `files/usr/lib/...` would go the same way. The whole payload tree is therefore re-included, following the `parts/` precedent already in the file — directory first, since git cannot re-include a file whose parent directory is excluded, then `**` to beat both bare patterns for everything below. It sits inside that block deliberately, so the later `.env` / `*.log` rules still apply underneath and a stray secret in the bundle stays ignored. Nothing that ran on the PR could have caught this. `packer validate` never reads the payload tree, `shellcheck` only sees the files it is handed, and `packer build` — which would have died at `install: cannot stat` — is deferred to the first release with GHCR images, i.e. to the vendor-submission moment. So `tests/unit/test_2281_packer_bundle_tracked.py` asserts every `install ... /tmp/trinity-files/<path>` source in 01-provision.sh is tracked, via `git ls-files` rather than `os.path.exists` — so it also fails on the developer's machine where the file is present-but-untracked, which is the state the bug was written in.
|
Fixed in a14f3f7 — and the cause is worth recording, because "never
I put the guard in the unit suite rather than the provision script because Noted on |
dolho
left a comment
There was a problem hiding this comment.
/review Report
Scope: CLEAN — the diff is exactly the #2281 Packer bundle plus the gitignore re-include and its tracked-files guard. The two findings the PR flags for reviewer attention (Docker-past-ufw, 99-img-check.sh spelling) both check out — I verified the hosted compose bindings and the marketplace-partners tree name myself.
Critical (block merge)
[C1] Port 8081 is internet-reachable and bypasses Caddy/TLS entirely (Confidence: 9/10)
firstboot.sh sets FRONTEND_PORT=8081, and docker-compose.hosted.yml:499 publishes it on all interfaces:
ports:
- "${FRONTEND_PORT:-80}:8080"Docker publishes on 0.0.0.0 by default, and — as this PR's own README correctly explains — ufw is silently inert for Docker-published ports. The DOCKER-USER DROP rule covers 8000,8080,8686,4317,4318,8889,13133 but not 8081. So the plain-HTTP frontend (the login page included) is directly reachable at http://<droplet-ip>:8081 from the internet, sidestepping both the TLS termination and the http→https permanent redirect — on the image whose headline design note is "Everything a user needs is served by Caddy on 80/443."
Fix: add 8081 to both multiport lists (the -C probe and the -I insert) in firstboot.sh step 4. (Binding loopback via FRONTEND_PORT=127.0.0.1:8081 also works with compose short syntax, but it would confuse start.sh's printed URL — the DROP-list addition is the minimal fix consistent with the existing design.)
Informational
[I1] The DOCKER-USER rules can silently evaporate at first reboot (Confidence: 8/10)
firstboot.sh installs iptables-persistent at first boot with >/dev/null 2>&1 || true, and netfilter-persistent save the same. If either fails (transient apt mirror issue, debconf hiccup — first boot is exactly when apt is busiest), nothing is logged, the boot still reports success, and the droplet's next reboot restores none of the DROP rules — 8000/8080/8686 quietly reopen with zero symptom. Suggest: install iptables-persistent at build time in 01-provision.sh (deterministic, apt already exercised there, baked once for every droplet), keep only the save at first boot, and let its failure at least reach the tee'd log instead of /dev/null.
[I2] otel-collector image is not pre-pulled — first boot pulls it (Confidence: 9/10)
docker-compose.hosted.yml starts otel/opentelemetry-collector-contrib:0.120.0 by default (no profiles: — unlike cloudflared, which is correctly skippable under profiles: [tunnel]). The provisioner pulls redis/vector/alpine but not this one, so first boot pulls a few hundred MB — against the "first boot pulls nothing / this is the entire point of the snapshot" design goal. One more docker pull line in the third-party block fixes it.
[I3] set_env corrupts a user-supplied password containing |, &, or \ (Confidence: 7/10)
The user-data password path feeds sed -i "s|^${key}=.*|${key}=${value}|" unescaped. A password with | breaks the expression, & expands to the matched text, \ escapes — and the failure is the silent kind: .env holds a mangled value while the MOTD says "admin / the password you supplied in user-data". Since the generated path is A-Za-z0-9-only, only the user-supplied path is exposed. Escaping the replacement (or grep -v + append) closes it.
[I4] marketplace-partners is cloned unpinned and its scripts run as root at build time (Confidence: 6/10)
90-cleanup-and-check.sh clones DO's repo at HEAD and executes two scripts as root as the last thing that touches the certified image. Pinning a reviewed commit SHA turns a third-party moving target into a reviewed input. (Mild — it's DigitalOcean's own canonical repo — but the snapshot is the artifact a vendor review approves.)
Clean categories
- Secrets/credentials: nothing baked at build time; password 0600 root-only; MOTD deliberately never re-echoes a user-chosen password. ✓
- gitignore collision + guard test: verified the bare
var//lib/swallow and thattest_2281_packer_bundle_tracked.pyusesgit ls-files(catches present-but-untracked, the actual failure mode) + mode assertion. Nice guard. - Caddy floor: version assertion survives pin edits and
caddy upgrade; the no-apt-mark holdtradeoff is reasoned and stated. ✓ - TLS verification honesty: the probe distinguishes real-LE-cert from internal-CA fallback, and the MOTD scheme follows what was verified, not intended. ✓
- Idempotency: the
iptables -Cprobe before-I, the re-runnable firstboot with its own retry line in the MOTD. ✓
Summary
- Critical: 1 — the :8081 TLS bypass must be closed before this ships to a vendor review.
- Informational: 4.
- Overall this is careful work — the design notes are the best part of the bundle, and C1 is a one-line fix inside a step that already exists.
🤖 Generated with Claude Code
…2281) Addresses dolho's review. C1 is the one that shipped a security hole; the other four are the silent-failure class this bundle is otherwise careful about. C1 — the SPA was reachable on plain HTTP, past Caddy. First boot moves the frontend to FRONTEND_PORT=8081 so Caddy can own 80/443, and compose publishes it with the short syntax `"${FRONTEND_PORT:-80}:8080"`, which binds 0.0.0.0. The DOCKER-USER DROP list covered 8000/8080/8686 and the OTel ports but not 8081, so the login page answered on http://<ip>:8081 — past the certificate and past the http->https redirect the whole image is built around. 8081 added, and the probe and the insert now read ONE variable: two hand-kept lists that disagree means the -C probe never matches its own rule and every re-run of first boot stacks another DROP. The list is hand-maintained against a compose file in another directory, which is this repo's most-shipped bug (#1039, #1056, #1707, #1871, #2381) — so tests/unit/test_2281_firstboot_port_exposure.py asserts every host port the hosted compose publishes on an external interface appears in DROP_PORTS, resolving ${FRONTEND_PORT} from first boot's own `set_env` line. Verified it fails on the pre-fix list naming exactly {'frontend': [8081]}. `packer build` could not have caught this even once it runs: the rule is installed correctly, it simply does not cover the port. I1 — the DROP rules could evaporate at the first reboot. `apt-get install iptables-persistent` ran at first boot as `>/dev/null 2>&1 || true`, at the busiest apt moment a droplet ever has; a transient mirror failure then made the save impossible, silently, and the ports reopened at the next reboot with no symptom anywhere. The install moves to build time (deterministic, baked once, debconf preseeded so a non-interactive Packer run cannot hang on the autosave prompt) and first boot keeps only the save — whose failure now says so on the tee'd log, naming the re-run. I2 — the OTel collector was not pre-pulled. It is not profile-gated in docker-compose.hosted.yml, unlike cloudflared, so start.sh --hosted starts it on every droplet and first boot was fetching a few hundred MB — against the one property this snapshot exists to have. Pulled at build time, with the tag read from the checkout rather than hardcoded so a bump in compose cannot leave this line pinning a stale one. I3 — a user-supplied password containing | & or \ was silently mangled. set_env substituted user-controlled text into the replacement half of `sed "s|^k=.*|k=$value|"`, where & expands to the whole match, \ escapes and | ends the expression. It now rewrites the line instead, which needs no escaping at all; verified byte-exact round-trip for `p|a&s\sw#ord`. Only the user-data path was exposed — the generated password is A-Za-z0-9. I4 — marketplace-partners was cloned at HEAD and its two scripts run as root as the last thing to touch the image a vendor review approves. Pinned to b708788 (master @ 2026-07-16) via fetch-by-SHA, since a shallow clone can only take a ref. Verified: bash -n and shellcheck -S warning clean on all five scripts; the new guard fails on the old list and passes on the new one; 16 tests green across the two #2281 guards and the #2280 compose parity suite. Refs #2281
|
Thanks — all five verified against the branch and reproduced before fixing. Pushed as C1 — :8081 TLS bypass (blocking)Confirmed exactly as described:
The deeper problem is that the list is maintained by hand against a compose file in another directory, which is this repo's most-shipped bug shape (#1039, #1056, #1707, #1871, #2381). So there is now a guard: Worth stating why the guard is repo-side: I1 — persistence could evaporate at first rebootConfirmed: both Took your suggested shape. The install moves to First boot keeps only the save, and its failure now prints to the tee'd log naming the re-run command instead of vanishing. I2 — otel-collector not pre-pulledConfirmed, and it is started unconditionally: Pulled at build time. One deviation from a literal one-line fix: the tag is read out of the checked-out I3 —
|
Superseded: C1 (:8081 DROP) and I1–I4 all fixed in e96c1a7 with a compose↔DROP-list parity guard (test_2281_firstboot_port_exposure.py). Verified locally: 16 hosting tests green after merging dev; pinned marketplace-partners SHA + scripts resolve.
vybe
left a comment
There was a problem hiding this comment.
/validate-pr re-run on e96c1a7 — approving.
- Both blocking findings closed:
001-trinityis committed (100755) behind a.gitignorere-include +git ls-filesguard; :8081 is in the singleDROP_PORTSlist with a compose↔DROP-list parity test that fails on the old state. - I1–I4 verified against the branch:
iptables-persistentbaked at build with debconf preseed,netfilter-persistent savefailure now loud; OTel image resolved from the checked-out compose;set_envrewrites the line (no sed escaping);marketplace-partnerspinned tob708788(confirmed the SHA and both scripts exist upstream). - Merged current
devinto the branch locally: clean, 16 hosting tests green (both #2281 guards + the #2280 parity suite). CI 19 pass / 0 fail. - Security scan clean; no frontend, backend, compose or Dockerfile changes; five scripts 100755, no symlinks.
Non-blocking, for a follow-up: a §8.10 entry in docs/memory/requirements/infrastructure.md for the 1-Click bundle (HOST-010 records the Caddy/IP-cert decision but not the bundle's first-boot contract); and $ in a user-data password will still hit compose's .env interpolation on the same user-supplied path as the # residual you noted.
…iteral date (#2497) `get_fleet_executions` defaults to `hours=24`. The `TestListReadersCarryTheColumn` fixture inserted `started_at = "2026-09-01T10:00:00Z"`, so `test_fleet_list_returns_turn_integrity` passed every run until 2026-09-02 10:00 UTC and then failed every `dev` push after it — run 33634096378, `assert 0 == 1`, with no code change anywhere. First seen on the #2471 merge; reproduced identically on the pre-merge commit dd91056, so it is the fixture's clock, not a regression. Both timestamps now come from `datetime.now(timezone.utc)`, in the `utc_now_iso()` shape the readers parse. The sibling `get_agent_executions_summary` test never windowed, which is why only one of the two went red. Refs #2467 Claude-Session: https://claude.ai/code/session_012d5K93m76zw4Rn193FXvsJ Co-authored-by: sim <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
`publish-images.yml` gated its `type=raw,value=latest` rule on `startsWith(github.ref, 'refs/tags/v')`. That expression answers "is this a version tag", not "is this a version anyone should be running", so pushing a release candidate (`v0.9.5-rc1`) would move `latest` and every unpinned hosted install would pull the RC on its next `start.sh --hosted`. This is the hazard the workflow already documents one paragraph above — it guards `workflow_dispatch` against exactly this, and the same door was left open for pre-release tag pushes. It matters now because an RC is the prerequisite for the DigitalOcean snapshot (#2281/#2471): the marketplace build needs GHCR images from a tag cut BEFORE the payload is blessed, which makes the RC the one tag that must never become the default pull. The `-` test IS the semver prerelease rule (spec item 9), so it needs no list of rc/beta/alpha spellings to keep current. It cannot be delegated to metadata-action: its documented prerelease handling ("pre-release will only extend {{version}}") applies to `type=semver` entries — which is why `{{major}}.{{minor}}` needs no guard of its own — and has no effect at all on a `type=raw` value. `{{version}}` and `v{{version}}` are deliberately untouched: an RC must stay pullable by its exact tag, which is the whole point of cutting one. Only the mutable pointer is withheld. Guarded by tests/unit/test_2471_publish_images_prerelease_latest.py — verified to fail against the pre-fix expression. Claude-Session: https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
`trinity-do-create.sh` hardcodes the release it installs:
TRINITY_IMAGE_TAG="${TRINITY_IMAGE_TAG:-v0.9.5-rc2}"
That default IS what operators get — the guide tells them to run the script
straight off a tag with no environment set. So on the day `v0.9.5` is cut, a
script fetched from the v0.9.5 tag still clones and pulls `v0.9.5-rc2` unless
someone remembers this one line.
Nothing catches it today. It is not a syntax error, the rc2 images still exist
and still pull, and the install SUCCEEDS — it just installs the previous release
candidate. The operator cannot tell, and neither can CI: the release checklist's
"VERSION match" step compares the VERSION file to the tag, not this script to
either.
The guard ties them together. It passes now (VERSION `0.9.5-rc2`, default
`v0.9.5-rc2`) and fails the moment VERSION is bumped for the cut — which is
exactly when someone needs telling. Verified by mutation: setting VERSION to
`0.9.5` produces
AssertionError: trinity-do-create.sh installs v0.9.5-rc2 but VERSION says 0.9.5.
A second case pins the `v` prefix. One string feeds both `git clone --branch`
(needs the git ref) and `docker pull` (published under both spellings), so only
the `v` form works for both — the #2471 failure, where `v0.9.5-rc1` shipped
without its v-prefixed image alias and left no tag value able to build the
marketplace snapshot.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB
…st boot (#2380) (#2683) * fix(deploy): snap doctl cannot read /tmp, and an apostrophe kills first boot (#2380) Two fixes to the DigitalOcean installer, found QA'ing it across macOS and Linux. Neither is visible on the machine it was written on. **A snap-installed doctl has a private /tmp.** On most Linux distributions doctl comes from snap, and a snap runs in its own mount namespace — a file written to the real /tmp is not there when doctl opens it, so it fails on a file that demonstrably exists: Error: open /tmp/trinity-user-data.XXXXXX: no such file or directory Snap's `home` interface can read non-hidden paths under $HOME, so a snap doctl gets the file there instead; everyone else keeps TMPDIR. The name stays visible because that interface denies dotfiles too, `umask 077` still makes it 0600, and the EXIT trap still removes it. Reported by dolho, who hit it on Linux. The `mktemp -t` half of his finding is already on this branch (aaa3de5). A snap doctl with no usable $HOME now fails at that point with an explanation, rather than at the droplet-create call with a path error, after both prompts. **A single quote in either secret breaks the droplet's first boot.** Both are interpolated into single-quoted assignments in the user-data, so a `'` inside one closes the string early: export ADMIN_PASSWORD='Tr0ub4dor's!Horse' bash: unexpected EOF while looking for matching `'' Not a hypothetical input — the password rules require a special character and `'` is one, so that password passes this script's own check and the backend's. The failure is expensive out of proportion to the typo: the droplet is created and billing before first boot runs, the operator watches a 15-minute progress bar end in a timeout, and the cause is invisible without reading the install log. Both secrets now go through `_shquote` (the portable `'\''` idiom). Verified on both platforms rather than reasoned about — macOS bash 3.2 and ubuntu:24.04 bash 5.2 / GNU coreutils 9.4, driving the real prompt flow with a stubbed doctl and diffing the generated user-data: - `mktemp -t trinity-user-data` → macOS OK, Linux `too few X's in template` - the full template → both OK, mode 0600 - snap-detection truth table → identical on both - password round-trip → 7/7 both platforms, including apostrophes, backticks, backslashes, tabs and non-ASCII; the unfixed script fails the apostrophe cases with a syntax error `tests/unit/test_2380_installer_portability.py` pins all three. The round-trip guard is executed, not pattern-matched — it runs the script's own `_shquote` and lets a shell parse the result back, so it catches any breakage rather than the one spelling that was wrong. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * test(deploy): the installer's default tag must track VERSION (#2380) `trinity-do-create.sh` hardcodes the release it installs: TRINITY_IMAGE_TAG="${TRINITY_IMAGE_TAG:-v0.9.5-rc2}" That default IS what operators get — the guide tells them to run the script straight off a tag with no environment set. So on the day `v0.9.5` is cut, a script fetched from the v0.9.5 tag still clones and pulls `v0.9.5-rc2` unless someone remembers this one line. Nothing catches it today. It is not a syntax error, the rc2 images still exist and still pull, and the install SUCCEEDS — it just installs the previous release candidate. The operator cannot tell, and neither can CI: the release checklist's "VERSION match" step compares the VERSION file to the tag, not this script to either. The guard ties them together. It passes now (VERSION `0.9.5-rc2`, default `v0.9.5-rc2`) and fails the moment VERSION is bumped for the cut — which is exactly when someone needs telling. Verified by mutation: setting VERSION to `0.9.5` produces AssertionError: trinity-do-create.sh installs v0.9.5-rc2 but VERSION says 0.9.5. A second case pins the `v` prefix. One string feeds both `git clone --branch` (needs the git ref) and `docker pull` (published under both spellings), so only the `v` form works for both — the #2471 failure, where `v0.9.5-rc1` shipped without its v-prefixed image alias and left no tag value able to build the marketplace snapshot. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * fix(deploy): refuse before the prompts, quote the tag, and test the installer by running it (#2380) Addresses review I1-I3 on #2683. I1: the snap-doctl-without-$HOME refusal ran after both secret prompts, breaking the script's own "checks first, questions second" rule. The USER_DATA_DIR decision moves into the pre-flight block beside `doctl account get`; mktemp stays where it was. I2: TRINITY_IMAGE_TAG was the third single-quoted interpolation in the user-data heredoc and the only unquoted one. It now goes through _shquote, and the static guard asserts the rule (every '${...}' in the heredoc is a _Q value) instead of two spellings of it. I3: the guards grepped for the quoted spelling and never ran the script. New tests run the real installer against a stub doctl (package and snap paths, apostrophes and shell metacharacters in the password, token and tag), then `bash -n` the captured user-data and evaluate its real export lines and subscription call in context, and assert a snap doctl without $HOME is refused before any question. Running it found a fourth defect: under `set -u`, bash < 4.4 (macOS's /bin/bash is 3.2) treats an empty "${SSH_ARGS[@]}" as unbound, so an account with no SSH keys died at "Creating the droplet...", after both secrets were typed. Expanded as ${SSH_ARGS[@]+"${SSH_ARGS[@]}"}. Each fix was checked by reverting it: the tests fail on every revert. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…er, and a domain that gets a certificate (#2380) (#2707) * feat(deploy): one installer provisions the machine, three callers use 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 * feat(deploy): a prompting DigitalOcean installer, not a file to edit (#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 * fix(deploy): containers cannot read the instance metadata service (#2380) 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 * feat(deploy): make "add a domain" actually work, not just be advertised (#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 * fix(onboarding): the card's one action is the one that works (#2380) 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 * feat(deploy): adding a domain is a settings field, not a shell command (#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 * fix(deploy): attach the account's SSH keys to the droplet it creates (#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 * fix(deploy): portable mktemp in the DigitalOcean installer (#2380) `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 * test(deploy): the X-DO-MARKETPLACE guard reads start.sh, where the Caddyfile 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 * test(deploy): restore the two firewall guards the port-list rewrite dropped (#2380) 6104b0e deleted test_2281_firstboot_port_exposure.py because the DOCKER-USER rule no longer enumerates ports, so the tests that policed the list had nothing left to check. Two of its five tests were never about the list, and they went with the file: - ufw and iptables-persistent are never both installed. ufw Breaks iptables-persistent, so installing it to persist the rules makes apt remove ufw, and the install dies later at `ufw --force reset`. - the firewall rules are re-applied on every boot. Without iptables-persistent, trinity-docker-firewall.service is the only thing that survives a reboot; without it every Docker-published port reopens after the first restart (#2281 review I1). Both are back in test_2380_provision_single_source.py, pointed at where the code lives now: start.sh --provision installs ufw and writes the unit as a heredoc, so the tests read that heredoc instead of a shipped unit file. Each was checked against a mutation of start.sh (iptables-persistent added, the enable line removed, After=docker.service removed) and fails on each. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * fix(deploy): snap doctl cannot read /tmp, and an apostrophe kills first boot (#2380) (#2683) * fix(deploy): snap doctl cannot read /tmp, and an apostrophe kills first boot (#2380) Two fixes to the DigitalOcean installer, found QA'ing it across macOS and Linux. Neither is visible on the machine it was written on. **A snap-installed doctl has a private /tmp.** On most Linux distributions doctl comes from snap, and a snap runs in its own mount namespace — a file written to the real /tmp is not there when doctl opens it, so it fails on a file that demonstrably exists: Error: open /tmp/trinity-user-data.XXXXXX: no such file or directory Snap's `home` interface can read non-hidden paths under $HOME, so a snap doctl gets the file there instead; everyone else keeps TMPDIR. The name stays visible because that interface denies dotfiles too, `umask 077` still makes it 0600, and the EXIT trap still removes it. Reported by dolho, who hit it on Linux. The `mktemp -t` half of his finding is already on this branch (aaa3de5). A snap doctl with no usable $HOME now fails at that point with an explanation, rather than at the droplet-create call with a path error, after both prompts. **A single quote in either secret breaks the droplet's first boot.** Both are interpolated into single-quoted assignments in the user-data, so a `'` inside one closes the string early: export ADMIN_PASSWORD='Tr0ub4dor's!Horse' bash: unexpected EOF while looking for matching `'' Not a hypothetical input — the password rules require a special character and `'` is one, so that password passes this script's own check and the backend's. The failure is expensive out of proportion to the typo: the droplet is created and billing before first boot runs, the operator watches a 15-minute progress bar end in a timeout, and the cause is invisible without reading the install log. Both secrets now go through `_shquote` (the portable `'\''` idiom). Verified on both platforms rather than reasoned about — macOS bash 3.2 and ubuntu:24.04 bash 5.2 / GNU coreutils 9.4, driving the real prompt flow with a stubbed doctl and diffing the generated user-data: - `mktemp -t trinity-user-data` → macOS OK, Linux `too few X's in template` - the full template → both OK, mode 0600 - snap-detection truth table → identical on both - password round-trip → 7/7 both platforms, including apostrophes, backticks, backslashes, tabs and non-ASCII; the unfixed script fails the apostrophe cases with a syntax error `tests/unit/test_2380_installer_portability.py` pins all three. The round-trip guard is executed, not pattern-matched — it runs the script's own `_shquote` and lets a shell parse the result back, so it catches any breakage rather than the one spelling that was wrong. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * test(deploy): the installer's default tag must track VERSION (#2380) `trinity-do-create.sh` hardcodes the release it installs: TRINITY_IMAGE_TAG="${TRINITY_IMAGE_TAG:-v0.9.5-rc2}" That default IS what operators get — the guide tells them to run the script straight off a tag with no environment set. So on the day `v0.9.5` is cut, a script fetched from the v0.9.5 tag still clones and pulls `v0.9.5-rc2` unless someone remembers this one line. Nothing catches it today. It is not a syntax error, the rc2 images still exist and still pull, and the install SUCCEEDS — it just installs the previous release candidate. The operator cannot tell, and neither can CI: the release checklist's "VERSION match" step compares the VERSION file to the tag, not this script to either. The guard ties them together. It passes now (VERSION `0.9.5-rc2`, default `v0.9.5-rc2`) and fails the moment VERSION is bumped for the cut — which is exactly when someone needs telling. Verified by mutation: setting VERSION to `0.9.5` produces AssertionError: trinity-do-create.sh installs v0.9.5-rc2 but VERSION says 0.9.5. A second case pins the `v` prefix. One string feeds both `git clone --branch` (needs the git ref) and `docker pull` (published under both spellings), so only the `v` form works for both — the #2471 failure, where `v0.9.5-rc1` shipped without its v-prefixed image alias and left no tag value able to build the marketplace snapshot. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * fix(deploy): refuse before the prompts, quote the tag, and test the installer by running it (#2380) Addresses review I1-I3 on #2683. I1: the snap-doctl-without-$HOME refusal ran after both secret prompts, breaking the script's own "checks first, questions second" rule. The USER_DATA_DIR decision moves into the pre-flight block beside `doctl account get`; mktemp stays where it was. I2: TRINITY_IMAGE_TAG was the third single-quoted interpolation in the user-data heredoc and the only unquoted one. It now goes through _shquote, and the static guard asserts the rule (every '${...}' in the heredoc is a _Q value) instead of two spellings of it. I3: the guards grepped for the quoted spelling and never ran the script. New tests run the real installer against a stub doctl (package and snap paths, apostrophes and shell metacharacters in the password, token and tag), then `bash -n` the captured user-data and evaluate its real export lines and subscription call in context, and assert a snap doctl without $HOME is refused before any question. Running it found a fourth defect: under `set -u`, bash < 4.4 (macOS's /bin/bash is 3.2) treats an empty "${SSH_ARGS[@]}" as unbound, so an account with no SSH keys died at "Creating the droplet...", after both secrets were typed. Expanded as ${SSH_ARGS[@]+"${SSH_ARGS[@]}"}. Each fix was checked by reverting it: the tests fail on every revert. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> * docs(deploy): describe the provisioning path, installer, firewall and TLS gate (#2380) /validate-pr on #2707 found the branch shipping new capability without the requirements and feature-flow updates CLAUDE.md requires. Written from the code at this commit, not from the PR body. Requirements (docs/memory/requirements/infrastructure.md): - Corrected: HOST-010 and the section 8.10 description, PROV-006 (flags now carry hardening_guide_eligible), PROV-009 (the second path has been a Cloudflare Tunnel since #2564, not a VPN), PROV-010 (a two-stage card gated on hardening_guide_eligible, with a domain field), PROV-011 (start.sh --provision now writes TRINITY_INSTALL_SOURCE). - Added: PROV-012 one provisioning implementation, three callers; PROV-013 the portless container firewall and the metadata-service block; PROV-014 the prompting installer and do-script provenance; PROV-015 the on-demand TLS ask gate. Feature flows: install-provenance (two-stage card, do-script, hardening_guide_eligible, the domain field and ask gate; fixes both stale claims in #2593), hosted-install (a Provision Layer section), telemetry-sharing (the IntersectionObserver gate from #2593), and their index rows. Stale sentences in agent-lifecycle.md, backend.md, api-endpoints.md and DEPLOYMENT.md corrected. Fixes #2593 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * chore(deploy): drop references to set-domain.sh, which no longer exists (#2380) 0423e6c replaced scripts/deploy/set-domain.sh with a Settings field, but two comments still named it as env-file.sh's second caller, and the provisioning test kept an unused path constant pointing at it. start.sh is now the only script that sources env-file.sh; the comments say so. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * test(deploy): pin the on-demand site block and reach the ask gate through FastAPI (#2380) Review follow-ups on #2707, all mechanical. The Caddyfile guard asserted `"on_demand" in body`, which the global `on_demand_tls` option already satisfies: deleting the catch-all `https:// { tls { on_demand } }` site — the entire "add a domain" feature — passed every test. It now extracts the heredoc and asserts that site as a block, and that the bare-IP site still asks for a short-lived certificate. Checked by deleting the block: the test fails. Nothing reached GET /api/public/tls-allowed through FastAPI. The decision (exact hostname, fail closed) is proved by exec-slicing the function, which cannot see the route's path, its query parameter, or whether it gained an auth dependency — and Caddy holds no credential, so a 401 there would refuse every certificate with the failure visible only in a live handshake. A new test mounts the real router and calls the real URL. Settings' install-source label map had no entry for `do-script`, so a script-installed droplet showed the raw value. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Oleksii Dolhov <[email protected]>
…otfix `main` carried five commits that never came back to `dev`, and the one that matters is the Abilityai#2398 hotfix (Abilityai#2406): `_is_sensitive_kv_key` was still `re.search(r'(?:.*TOKEN.*)\Z', key)`, quadratic in key length, on a thread holding the GIL. Measured 0.32s at 4 KB and 40s at 44 KB; a py-spy watchdog caught it 14 times across three agents. `key` is whatever preceded an `=` in `_KV_LINE_RE` and is unbounded, and recursive `sanitize_dict` reaches it from stream-json tool results — so multi-KB keys are the normal case, not an adversarial one. Found by /release pre-flight while cutting v0.9.5-rc1. That RC becomes the DigitalOcean Marketplace snapshot (Abilityai#2281/Abilityai#2471), so tagging `dev` as-is would have shipped a known, production-observed DoS in a public image. Each branch had a sanitizer fix the other lacked, which is why this is a merge and not a cherry-pick in either direction: `dev` has the Abilityai#2208 `sk-` family consolidation (`sk-svcacct-` and anything after it), `main` has the Abilityai#2398 containment rewrite. Both are present on both copies after the merge, verified by grep and by the 195 tests across the five sanitizer suites. Conflict resolution, for the record: - `src/backend/utils/credential_sanitizer.py` and its agent-server sibling both auto-merged cleanly. They are NOT byte-identical vendored twins — the Invariant Abilityai#5 mirror set is credential_paths / model_context / safe_yaml / mcp_validator — so no parity obligation attaches and the independent merges are legitimate. - `src/backend/enterprise` resolved to **dev's** pin (90f2f2cb), which is three commits AHEAD of main's (2a5def35) and has it as an ancestor — verified, not assumed. Taking main's would have rolled the paid tree backwards. Verified: 195 tests pass across test_2398 / test_2208 / test_1661 / test_credential_sanitizer_{agent,backend}; alembic version line still resolves to exactly 1 head (0049); the merge touched no migration on either track. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK
…ials without a terminal (trinity-enterprise#580, #581, #582) (#2715) * feat(deploy): one installer provisions the machine, three callers use 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 * feat(deploy): a prompting DigitalOcean installer, not a file to edit (#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 * fix(deploy): containers cannot read the instance metadata service (#2380) 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 * feat(deploy): make "add a domain" actually work, not just be advertised (#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 * fix(onboarding): the card's one action is the one that works (#2380) 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 * feat(deploy): adding a domain is a settings field, not a shell command (#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 * fix(deploy): attach the account's SSH keys to the droplet it creates (#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 * fix(deploy): portable mktemp in the DigitalOcean installer (#2380) `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 * test(deploy): the X-DO-MARKETPLACE guard reads start.sh, where the Caddyfile 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 * test(deploy): restore the two firewall guards the port-list rewrite dropped (#2380) 6104b0e deleted test_2281_firstboot_port_exposure.py because the DOCKER-USER rule no longer enumerates ports, so the tests that policed the list had nothing left to check. Two of its five tests were never about the list, and they went with the file: - ufw and iptables-persistent are never both installed. ufw Breaks iptables-persistent, so installing it to persist the rules makes apt remove ufw, and the install dies later at `ufw --force reset`. - the firewall rules are re-applied on every boot. Without iptables-persistent, trinity-docker-firewall.service is the only thing that survives a reboot; without it every Docker-published port reopens after the first restart (#2281 review I1). Both are back in test_2380_provision_single_source.py, pointed at where the code lives now: start.sh --provision installs ufw and writes the unit as a heredoc, so the tests read that heredoc instead of a shipped unit file. Each was checked against a mutation of start.sh (iptables-persistent added, the enable line removed, After=docker.service removed) and fails on each. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * feat(onboarding): browser admin claim, one first-run overlay, credentials without a terminal Abilityai/trinity-enterprise#580 — marketplace admin claim A DigitalOcean 1-Click first boot no longer generates an admin password. With no user-data password, ADMIN_PASSWORD stays blank and ADMIN_PASSWORD_SOURCE= browser tells start.sh that is deliberate, so the first browser visitor creates the admin at /setup (email, password, product-updates consent). The MOTD prints the URL to claim, never a password. An operator-supplied password (cloud-init user-data, including trinity-do-create.sh) still pre-provisions the admin and keeps the wizard closed. The prod/hosted compose files move from `:?` to `?`: an unset password still refuses to render; an explicitly blank one is the claim path. The backend already handled a blank password; only docstrings change. The accepted risk (the window before the first visit) is written down in DEPLOYMENT.md -> Security Recommendations. Abilityai/trinity-enterprise#581 — one first-run overlay Replaces the dashboard card ladder (HardeningGuide, FinishSetupCard, FrontDeskPanel, OnboardingWizard) with one blocking, teleported overlay: a rail over a conditional step registry (firstRunSteps.js, pure and unit-tested), steps secure / email / claude / keys / agent / sharing, welcome and done panels, the schematic illustrations, and TrinityMark.vue shared with /setup. Completion is derived from existing state, and only skips and "Finish later" persist. Unlike the spec, `keys` and `agent` never open the overlay on their own, so an established fleet does not see it on every new browser. ActivationChecklist stays inline. /setup logs the operator in after the claim. Re-runnable from Settings -> General and ?onboarding=1. Abilityai/trinity-enterprise#582 — credentials inside first-run The Claude step (the only required step) takes a subscription token or an API key, validates it with Anthropic before saving, and names the fix on bad input. The first credential is connected to the agents that had none, so the starter fleet can run immediately. Optional GitHub, Resend and Gemini keys persist through the encrypted secret-settings path (ent#435) with admin-only endpoints, and runtime reads resolve the saved setting before the env. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * fix(onboarding): close the claim paths review found outside the marketplace Pre-landing review and a diff-scoped security audit of the previous commit. Claim path (Abilityai/trinity-enterprise#580): - docker-compose.prod.yml is back to `${ADMIN_PASSWORD:?}`. Neither start.sh nor the marketplace uses it, so relaxing it only let a source build that forgot its password boot with an open /setup. - docker-compose.hosted.yml passes ADMIN_PASSWORD_SOURCE (default `unset`) to the backend, and /api/setup/admin-password refuses a blank-password claim unless the source is `browser`. The #2381 existing-admin check still runs first; the dev compose (variable absent) keeps its wizard. - start.sh decides a blank password with env_value, so `ADMIN_PASSWORD=""`, `''` or a trailing space no longer count as set, and writes a generated password with set_env_key. First credential (Abilityai/trinity-enterprise#582): - Agents come from the DB rather than a Docker listing that swallows errors. Agents with a successful execution are skipped, so fleets that authenticate per agent keep their own key. Agents with a running execution are not restarted. The responses carry an int `connected_agents`, and seeding re-runs the idempotent connect so agents created during the save are not missed. - Gemini-runtime agents resolve the saved Gemini key before the env. - subscriptions router gains its `# mcp:` header. Overlay (Abilityai/trinity-enterprise#581): - Auto-login after /setup uses the claimed email, not a hardcoded 'admin'. - The Claude step reports the real connected count and says a re-paste replaces the saved credential. - setup_started is recorded only when the overlay opens on its own and the claude or agent step applies. - Exports orphaned by the absorbed components are deleted; docs that still described them now point at FirstRunOverlay / firstRunSteps.js. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * chore(release): 0.9.5-rc3 Release candidate cut from feature/ent580-582-first-run so the marketplace browser-claim, the first-run overlay and the in-browser credential steps (Abilityai/trinity-enterprise#580, #581, #582) can be tested on a real 1-Click snapshot before their PR opens. rc1 and rc2 were cut from feature/2380-do-provision the same way; rc2 stays immutable. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * fix(deploy): snap doctl cannot read /tmp, and an apostrophe kills first boot (#2380) (#2683) * fix(deploy): snap doctl cannot read /tmp, and an apostrophe kills first boot (#2380) Two fixes to the DigitalOcean installer, found QA'ing it across macOS and Linux. Neither is visible on the machine it was written on. **A snap-installed doctl has a private /tmp.** On most Linux distributions doctl comes from snap, and a snap runs in its own mount namespace — a file written to the real /tmp is not there when doctl opens it, so it fails on a file that demonstrably exists: Error: open /tmp/trinity-user-data.XXXXXX: no such file or directory Snap's `home` interface can read non-hidden paths under $HOME, so a snap doctl gets the file there instead; everyone else keeps TMPDIR. The name stays visible because that interface denies dotfiles too, `umask 077` still makes it 0600, and the EXIT trap still removes it. Reported by dolho, who hit it on Linux. The `mktemp -t` half of his finding is already on this branch (aaa3de5). A snap doctl with no usable $HOME now fails at that point with an explanation, rather than at the droplet-create call with a path error, after both prompts. **A single quote in either secret breaks the droplet's first boot.** Both are interpolated into single-quoted assignments in the user-data, so a `'` inside one closes the string early: export ADMIN_PASSWORD='Tr0ub4dor's!Horse' bash: unexpected EOF while looking for matching `'' Not a hypothetical input — the password rules require a special character and `'` is one, so that password passes this script's own check and the backend's. The failure is expensive out of proportion to the typo: the droplet is created and billing before first boot runs, the operator watches a 15-minute progress bar end in a timeout, and the cause is invisible without reading the install log. Both secrets now go through `_shquote` (the portable `'\''` idiom). Verified on both platforms rather than reasoned about — macOS bash 3.2 and ubuntu:24.04 bash 5.2 / GNU coreutils 9.4, driving the real prompt flow with a stubbed doctl and diffing the generated user-data: - `mktemp -t trinity-user-data` → macOS OK, Linux `too few X's in template` - the full template → both OK, mode 0600 - snap-detection truth table → identical on both - password round-trip → 7/7 both platforms, including apostrophes, backticks, backslashes, tabs and non-ASCII; the unfixed script fails the apostrophe cases with a syntax error `tests/unit/test_2380_installer_portability.py` pins all three. The round-trip guard is executed, not pattern-matched — it runs the script's own `_shquote` and lets a shell parse the result back, so it catches any breakage rather than the one spelling that was wrong. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * test(deploy): the installer's default tag must track VERSION (#2380) `trinity-do-create.sh` hardcodes the release it installs: TRINITY_IMAGE_TAG="${TRINITY_IMAGE_TAG:-v0.9.5-rc2}" That default IS what operators get — the guide tells them to run the script straight off a tag with no environment set. So on the day `v0.9.5` is cut, a script fetched from the v0.9.5 tag still clones and pulls `v0.9.5-rc2` unless someone remembers this one line. Nothing catches it today. It is not a syntax error, the rc2 images still exist and still pull, and the install SUCCEEDS — it just installs the previous release candidate. The operator cannot tell, and neither can CI: the release checklist's "VERSION match" step compares the VERSION file to the tag, not this script to either. The guard ties them together. It passes now (VERSION `0.9.5-rc2`, default `v0.9.5-rc2`) and fails the moment VERSION is bumped for the cut — which is exactly when someone needs telling. Verified by mutation: setting VERSION to `0.9.5` produces AssertionError: trinity-do-create.sh installs v0.9.5-rc2 but VERSION says 0.9.5. A second case pins the `v` prefix. One string feeds both `git clone --branch` (needs the git ref) and `docker pull` (published under both spellings), so only the `v` form works for both — the #2471 failure, where `v0.9.5-rc1` shipped without its v-prefixed image alias and left no tag value able to build the marketplace snapshot. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011sj48trT3XmyaSus4GUtXB * fix(deploy): refuse before the prompts, quote the tag, and test the installer by running it (#2380) Addresses review I1-I3 on #2683. I1: the snap-doctl-without-$HOME refusal ran after both secret prompts, breaking the script's own "checks first, questions second" rule. The USER_DATA_DIR decision moves into the pre-flight block beside `doctl account get`; mktemp stays where it was. I2: TRINITY_IMAGE_TAG was the third single-quoted interpolation in the user-data heredoc and the only unquoted one. It now goes through _shquote, and the static guard asserts the rule (every '${...}' in the heredoc is a _Q value) instead of two spellings of it. I3: the guards grepped for the quoted spelling and never ran the script. New tests run the real installer against a stub doctl (package and snap paths, apostrophes and shell metacharacters in the password, token and tag), then `bash -n` the captured user-data and evaluate its real export lines and subscription call in context, and assert a snap doctl without $HOME is refused before any question. Running it found a fourth defect: under `set -u`, bash < 4.4 (macOS's /bin/bash is 3.2) treats an empty "${SSH_ARGS[@]}" as unbound, so an account with no SSH keys died at "Creating the droplet...", after both secrets were typed. Expanded as ${SSH_ARGS[@]+"${SSH_ARGS[@]}"}. Each fix was checked by reverting it: the tests fail on every revert. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> * docs(deploy): describe the provisioning path, installer, firewall and TLS gate (#2380) /validate-pr on #2707 found the branch shipping new capability without the requirements and feature-flow updates CLAUDE.md requires. Written from the code at this commit, not from the PR body. Requirements (docs/memory/requirements/infrastructure.md): - Corrected: HOST-010 and the section 8.10 description, PROV-006 (flags now carry hardening_guide_eligible), PROV-009 (the second path has been a Cloudflare Tunnel since #2564, not a VPN), PROV-010 (a two-stage card gated on hardening_guide_eligible, with a domain field), PROV-011 (start.sh --provision now writes TRINITY_INSTALL_SOURCE). - Added: PROV-012 one provisioning implementation, three callers; PROV-013 the portless container firewall and the metadata-service block; PROV-014 the prompting installer and do-script provenance; PROV-015 the on-demand TLS ask gate. Feature flows: install-provenance (two-stage card, do-script, hardening_guide_eligible, the domain field and ask gate; fixes both stale claims in #2593), hosted-install (a Provision Layer section), telemetry-sharing (the IntersectionObserver gate from #2593), and their index rows. Stale sentences in agent-lifecycle.md, backend.md, api-endpoints.md and DEPLOYMENT.md corrected. Fixes #2593 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * chore(deploy): drop references to set-domain.sh, which no longer exists (#2380) 0423e6c replaced scripts/deploy/set-domain.sh with a Settings field, but two comments still named it as env-file.sh's second caller, and the provisioning test kept an unused path constant pointing at it. start.sh is now the only script that sources env-file.sh; the comments say so. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * fix(subscriptions): run the narrowed first-credential connect before the #2572 sweep The merge put dev's #2572 credential-less sweep ahead of ent#582's connect_agents_to_first_credential. The sweep has no notion of an agent that already authenticates some other way, so running first it would assign and restart agents ent#582 deliberately skips (any agent with a successful execution, and any agent mid-execution), and leave the first-run step reporting `connected_agents: 0` because nothing was left to connect. Swapped: the narrow pass runs first and reports its count, and the sweep then picks up whatever is genuinely credential-less. Also rewrites the first-run section of the setup guide, which #2746 synced while describing the card stack ent#581 retires ("at most one first-run card", "Not now snoozes for two weeks"). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PdRMazCDYVoxqLFw6uKm3a * fix(ci): linear from-address parser (CodeQL ReDoS) and stub get_gemini_api_key in telegram backfill test - platform_keys_service.from_address_domain: replace the single regex that CodeQL flagged as py/polynomial-redos with partition + single-class fullmatch; same accept/reject set, pinned by a parametrized test and a hostile-input timing check. - test_telegram_webhook_backfill: the settings_service stub lacked get_gemini_api_key, which routers/settings.py now imports (ent#582). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011y53gTcB3fTAHhJc3xxpkx --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Oleksii Dolhov <[email protected]>
Refs #2281 (does not close it — the vendor application and listing are separate, human-gated steps).
What
The Packer bundle that produces the DigitalOcean Marketplace 1-Click snapshot. Seven files under a new top-level
packer/:trinity.pkr.hclimage_tagrequired andlatestrefusedscripts/01-provision.shscripts/90-cleanup-and-check.sh90-cleanup.shthen99-img-check.sh, last provisionerfiles/opt/trinity-firstboot/firstboot.sh.env,DOCKER-USERrules, Caddyfile,start.sh --hosted --unattendedfiles/var/lib/cloud/scripts/per-instance/001-trinityfiles/etc/update-motd.d/99-trinityREADME.mdNothing baked into the snapshot is droplet-specific: the admin password, the droplet's own IP and the certificate are all resolved at first boot.
Two findings worth a reviewer's attention
Docker publishes past ufw.
docker-compose.hosted.ymlpublishes 8000, 8080, 8686 and the OTel ports on0.0.0.0, and Docker's iptables rules are traversed before ufw's, so aufw deny 8000on a public droplet is silently inert. Handled here with aDOCKER-USERDROP oneth0. Worth knowing beyond this PR:docker-compose.prod.ymlcarries the identical bindings, so this is not specific to the hosted file or to droplets — being filed separately.Path correction. DO's script is
99-img-check.sh(hyphen), notimg_check.shas #2281's AC2 spells it. Verified against thedigitalocean/marketplace-partnerstree.Verification
packer validate— caught a real defect, fixed in c6b49fc. HCL requires a validation message to start with an uppercase letter; theimage_tagmessage began with the lowercase variable name, so the whole template failed to validate before any builder ran — which made theimage_tag != "latest"guard unreachable. Both paths now exercised: a pinned tag validates,-var image_tag=latestis refused by the rule attrinity.pkr.hcl:43.caddy validateon the generated Caddyfile (heredoc extracted, IP substituted, run throughcaddy:2) — valid configuration.packer fmt -check,bash -nandshellcheck -S warningon all five scripts — clean.Not verified, and it gates the listing rather than this PR:
packer build— needs a DO token and the GHCR images, which do not exist yet:publish-images.ymlhas never run, because the newest tagv0.9.0predates it. The snapshot must be built from the first release that carries both that workflow and bug(security): fresh install leaves setup_completed=false with a real admin — unauthenticated /api/setup/admin-password overwrites the admin password #2381.firstboot.sh:116relies on Let's Encrypt issuing for bare IPs via theshortlivedACME profile. If that is not generally available, first boot lands on a certificate error and the listing is dead on arrival. Nothing in this repo checks it — worth confirming before the vendor submission.DOCKER-USERrules, systemd units.Sequencing
This does not block on the release, but the snapshot it produces does. Order is: cut a release →
publish-images.ymlfires →packer build -var image_tag=<that tag>→ submit the snapshot ID in the Vendor Portal.🤖 Generated with Claude Code
https://claude.ai/code/session_01218nVkqK7vU2jy9R73s4jT