~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

PDS_BIND_ADDRESS: the server listens where it is told, 127.0.0.1 by default

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:serve/bind-address

PDS_BIND_ADDRESS lets the server listen on an address other than 127.0.0.1, so it can run in a container or behind a proxy on another machine. Unset, nothing changes.

Claude Opus 5.5 · high

What changes

Spec. spec/PDS.md: PDS_BIND_ADDRESS, an IPv4 or IPv6 address, 127.0.0.1 by default. The server listens on that address alone: bound to ::1, it does not answer on 127.0.0.1. /metrics stays on the loopback. A value that is no address as written (localhost, [::1], a port with it) exits 1 before anything reaches standard output; an address it cannot listen on exits 1 too. spec/OPERATIONS.md's Starts gives the checks.

Harness. checks/operations.mjs, in the end-of-run lifecycle: as the run starts it, the server does not answer on the machine's first non-loopback IPv4 address. Started with 0.0.0.0, it answers there and on 127.0.0.1. Started with ::1, it answers on [::1] and not on 127.0.0.1. Each part runs where the machine has that address. localhost and [::1] join the starts that must exit 1.

Server. pds-server's run reads the variable before the start line and binds (address, PDS_PORT). pds serve --help names it.

Why

The server was reachable only from a proxy on the same host, which rules out Railway, Fly, k8s and any container platform. The loopback stays the default: a server put before the internet by mistake is worse than one that must be told where to listen.

How it was checked

  • Before the server change, the new check fails: step 31 (seed 1): the server's listener differs, with 0.0.0.0: no answer on 192.168.12.196 within 30 s.
  • Planted bug: always binding 0.0.0.0. It fails at the first check: an answer on 192.168.12.196 with the variable unset. Put back.
  • With the change, compare.mjs --steps 30 --seed 1 passes with all four parts run: listening on 0.0.0.0, listening on ::1, and both bad values refused.
  • just quick here; just gates is left to the pull's gates workflow.

Shortcomings

  • On a machine with no non-loopback IPv4 address, the default and 0.0.0.0 parts are skipped. Without IPv6's loopback (Docker with IPv6 off), the ::1 part is skipped. The bad values always run.
  • :: is not run: whether it takes IPv4 too is the system's choice, and the spec says so rather than check it.
  • /metrics cannot be reached from another container. That is OPERATIONS.md's design, left as it is.
Approved

This adds PDS_BIND_ADDRESS. It is read before the start line, parsed as an IP address, and used for the listener's bind. It defaults to 127.0.0.1, and an empty value counts as unset.

  • Spec: the change is in spec/PDS.md and in OPERATIONS.md's Starts, and the README states what is built without history.
  • Harness: the new checks only add constraints. The unset case must not answer on the outside address. 0.0.0.0 must answer on both addresses. ::1 must answer on [::1] and not on 127.0.0.1. localhost and [::1] must exit 1. The parts that need an outside address or the IPv6 loopback skip when the machine lacks one, and the pull says so.
  • Server: it uses only std and tokio and adds no crates.

One gap, which I do not hold the approval for. The spec says an address no interface has makes pds serve exit 1 with why on standard error, and the server's bind-failure path does that. No harness check covers it, though. If you want it covered, a start with a non-local address such as 203.0.113.1 would show it. If you would rather not require it, say in the spec that it is unchecked.

Merged as af117b9