Repository navigation
Description
Follow-ups from the structural review pass on #3934 (abilityai/trinity-enterprise#873). None blocks that PR: each is a latent gap under an unusual Docker or operator setup, or a tidy-up. The review's one should-fix (a trusted-only X-Forwarded-For chain through nginx was refused instead of falling back) is fixed on the PR itself.
1. preflight_proxy_network prints "Nothing was changed" after .env was already changed on a managed host — scripts/deploy/start.sh: on a provisioned host set_env_key FRONTEND_BIND_ADDRESS 127.0.0.1 runs in the managed-Caddy block before preflight_proxy_network || exit 1. With a conflicting network: rc=1, stderr says "Nothing was changed.", .env now holds the key. Harmless (loopback is the intended end state) but the message is wrong; test_a_conflicting_network_stops_the_upgrade_before_anything_changes runs with managed=False so it misses it. Move the preflight above the managed-host block or soften the message.
2. A non-root start.sh --hosted on a provisioned host silently skips the Caddy migration — provision_managed_caddy returns 1 when not root, so MANAGED_CADDY=0: no bind-address move, no re-render, no message. A docker-group user upgrading a 1-Click droplet without sudo stays in plain mode (every visitor shares the gateway bucket) and is not told. Warn when /etc/trinity/public-ip exists but the script is not root.
3. scope["trinity.client_ip"] is written on every request but nothing in src/ reads it — utils/client_ip.py middleware. Only test_the_scope_is_rewritten_in_place_and_headers_untouched reads it. Either feed the provenance into something (audit details, for example) or drop the key.
4. The two platform subnets are spelled out in two modules — utils/client_ip.py (AGENT_NETWORK, PLATFORM_NETWORK) and services/a2a_trusted_networks.py (PLATFORM_NETWORKS) both write 172.28.0.0/16 and 172.29.0.0/16; the latter already imports platform_networks() from the former. Also: nothing ties the 172.30.0 default in start.sh and docker/frontend/Dockerfile.prod to DEFAULT_PROXY_PREFIX, and start.sh does not refuse a prefix inside 172.28/172.29 on a fresh install (the backend does, at startup). The compose-vs-backend topology is already pinned by test_rendered_ingress_topology_matches_the_backend_trust.
5. The listener probe proves the PROXY listener answers, not that the client address is believed — scripts/deploy/probe-proxy-listener.sh accepts any 200 for GET /; nginx serves that whether or not the connection came from set_real_ip_from ${TRINITY_PROXY_GATEWAY}. If loopback-published traffic arrives from an address other than <prefix>.1 (rootless Docker or another port driver; unverified), Caddy switches to proxy mode and every visitor is still one address, with no warning. Unlikely on rootful Linux Docker since gateway and network derive from one prefix. Also minor: the 5x2s retry loop in start.sh discards its result and provision_caddyfile probes again right after, so the loop only works as a delay.
6. Gateway trust on :8082 depends on Docker's inter-bridge isolation — src/frontend/nginx.conf trusts PROXY protocol from <prefix>.1. If forwarding from the agent network to the ingress network were ever allowed (iptables: false plus host NAT, a nat-unprotected gateway mode, or a DOCKER-USER ACCEPT), an agent reaching 172.30.0.2:8082 would arrive masqueraded as 172.30.0.1 and could forge any PROXY source. Today Docker's isolation chains drop it, docker-firewall.sh uses RETURN not ACCEPT, and verify-client-ip.sh checks an agent cannot connect. Worth one line in docs/memory/architecture/security.md saying the guard is a host property, not a code property.
7. IPv6 on the ingress network would fail silently into one shared bucket — docker-compose.prod.yml / docker-compose.hosted.yml do not set enable_ipv6: false on trinity-proxy. A daemon whose default-network-opts enable IPv6 (unverified) could give nginx and the backend v6 addresses; nginx dialling the backend over v6 resolves as provenance=peer for nginx's address, sharing one bucket with no fallback warning. Pinning enable_ipv6: false costs nothing. Separately: IPv6 visitors are now keyed per /128; /64 keying for the per-IP limits is worth deciding.
Evidence for 1 and the fixed finding came from driving the real start.sh harness (test_ent873_caddy_upgrade.py) and calling resolve() directly; verify-client-ip.sh was not re-run for this review (it needs docker:dind).
Activity