Repository navigation
PostgreSQL Store URLs dialled as configured; loopback refused with a host hint - #772
Merged
Merged
Conversation
…r machine Every Sandbox call on a PostgreSQL Store on a docker machine on Docker Desktop ran `docker exec <worker> getent ahostsv4 host.docker.internal` in the caller (D-8, 67f2f10) to rewrite a loopback URL: 52-103 ms in the `route` step of create, mount, exec, Commit, unmount and remove (#758 B6 diagnosis), enough alone to fail the C17 Commit row. Owner direction (2026-11-24): PostgreSQL configuration is the user's; LayerFS dials the URL as configured, from local or remote, and rewrites nothing. - reach: the URL is returned exactly as given on every platform. Each adapter now only declares its `Loopback` (`Shared` or `Apart(this host)`) and `reach::dial` is the one check. On a machine that does not share the caller's loopback (docker on Docker Desktop, lima, apple-container) a URL naming it, or a Unix socket of the caller, is refused `Unsupported`, naming what the machine calls this host (`host.docker.internal`, `host.lima.internal`, the recorded apple-container gateway) and `layerfs store connect <store> <url> --machine <m>`. native and docker on a Linux Engine are `Shared`. Removed: `Loopback::Alias`/`Lookup`, docker's `host_address` (unix and the Windows stub), apple-container's per-call gateway read for reach, lima's 192.168.5.2 rewrite and the `sslmode=verify-full` refusal (nothing is rewritten now). No provider command runs for any Sandbox call's URL. - Loopback detection covers localhost (any case, final dot), 127.0.0.0/8, ::1 in any spelling and ::ffff:127.x.x.x, on every host the string names: host lists, `host=`/`hostaddr=` parameters (now dialled as given after the check) and libpq key=value words (`conninfo_hosts`). A name that only resolves to loopback is not resolved in the caller: its one dial fails in the worker's reach check / `store.reach`, which append `platform::loopback_hint`, the refusal's own advice (it was an apple-container-only hint). No retry. - Sandbox names: the namespaces init stage binds the launcher's /etc/resolv.conf and /etc/hosts read-only over the Sandbox root's (an empty mount point is made in the Sandbox's own upper layer when the image lacks one; a link is replaced there; an image /etc that is not a plain directory keeps its own). A Sandbox shares its machine's network namespace, so it now resolves `host.docker.internal`, lima's hosts entries and DNS names as its worker does. The files land on the root's /etc only; `HelperSpec::resolver_targets` refuses a start where the Sandbox directory (where Workspaces are mounted) or a bind would hold one, so they never enter a Workspace, a diff or a Commit. - Daemon start failure no longer says the root has no resolver files. - Docs: control/machines/{README,platforms,workers-and-reach}.md, sandboxes/{backends,daemon-channel-and-exec}.md, stores-and-projects/sqlite-and-postgresql.md. Breaking: a Store URL naming 127.0.0.1/localhost no longer reaches its server from docker (Docker Desktop), lima or apple-container Sandboxes; give that machine its own URL (`store connect ... --machine`) or the Store a host the machine resolves. Tests: machine_reach.rs and conformance.rs reach sections rewritten for the new contract (every loopback form, sockets, the hint, verify-full dialled, no provider tool runs: `a_docker_sandbox_call_runs_no_docker_command` fails on the parent, which ran `docker exec` and rewrote); namespaces_protocol `resolver_files_land_on_the_root_s_etc_never_in_a_workspace`; sandbox_machines: the lima refusal, and the live docker PostgreSQL leg now gives the docker machine its own host.docker.internal URL and checks names resolve in the Sandbox while its Workspace shows no change and an UpToDate Commit. Replaced, as their contract was removed by the owner (rewrite, lookup, verify-full refusal): machine_reach `each_platform_rewrites_a_loopback_host`, `apple_container_reads_its_gateway_only_for_a_loopback_url`, `apple_container_uses_the_gateway_its_start_recorded`, `a_rewrite_is_refused_for_verify_full`, `docker_reads_its_worker_s_host_address_only_for_a_loopback_url`, `a_url_reach_cannot_read_is_refused_off_native`; conformance `a_url_reach_cannot_rewrite_is_refused_unless_the_loopback_is_shared` (renamed `..._cannot_check_...`). Production LOC: 207,613 -> 207,708 (delta +95) core 40,989 -> 40,989 (0) engine 96,933 -> 96,933 (0) control 59,366 -> 59,461 (+95) layerfs-control +1, layerfs-platform -12, layerfs-sandbox -15, layerfs-sandbox-backend +121 api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archive of parent 8676948 and of the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…legs The two docker legs called `machine.update` and `machine.start` with a `name` argument, which the 2.0 call surface refuses (`machine.update: unknown argument name`), so neither live leg reached its Sandbox. They now pass `machine`, as the native leg already did. Found by the #758 docker live check: with it the PostgreSQL leg passed on Docker Desktop 29.5.2 (native and docker, the docker machine given its own host.docker.internal URL, names resolving in the Sandbox, Workspace unchanged, Commit UpToDate). Deleted tests: none. Production LOC: 207,708 -> 207,708 (delta 0) core 40,989 -> 40,989 (0) engine 96,933 -> 96,933 (0) control 59,461 -> 59,461 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail; test-only change, no production file touched Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent review of 20f27f9/f09bfdec25 (dial PostgreSQL Store URLs as configured). Each finding was checked in code first; all held. - Hosts are read as the client reads them (findings 1, 2). The daemon's client is tokio-postgres 0.7.18 (`Config::from_str`, `UrlParser`); `postgres_url::url_hosts` now follows it: the userinfo ends at the first `@` anywhere, the host list ends at the first `/` or `?` and splits at `,` before each host's `[...]` or first `:`; hosts, query keys and `hostaddr` values are percent-decoded (`%XX`, other `%` kept) and a host decoding to a path is a socket. `@%6Cocalhost`, `@%31%32%37.0.0.1`, `?host=%6Cocalhost`, `?h%6Fst=localhost` and `?hostaddr=%31%32%37.0.0.1` were dialled as given on lima/Docker Desktop/apple-container; they are refused now. Valid lists `@h1:5432,h2`, `@h1,[2001:db8::1]` and `@[::1]:5432,h2` were refused InvalidInput; the remote ones are dialled now and the one naming ::1 is the Unsupported loopback refusal. A `host=` value the client takes as one host is still split at `,`, so no part goes unchecked. `PostgresUrl` and `conninfo_hosts` are gone. - Loopback (finding 3): `0.0.0.0` and `::` (and their mapped forms) count; every IPv4 form `inet_aton` reads (glibc and musl: `127.1`, `2130706433`, `127.000.000.001`, `0x7f.1`, `017700000001`), which `getaddrinfo` dials, is read by `postgres_url::ip` (no new dependency); an IPv6 zone id (`[::1%25lo]`, `::1%lo`) is dropped before parsing. - Operations that never dial the URL skip it (finding 4). `Op::store_url`: create (its daemon and reach check), Commit (head, `expected`) and status (head) dial it and keep the refusal; a close dials it only to end the mount intents a forced unmount left, so it now runs without a URL the machine cannot dial and names those intents in `left`; sandbox.get's reads, mount, exec, cancel and unmount ask only the daemon and no longer resolve or check the URL. A Sandbox can always be read and removed. The worker requires the URL only for the operations that dial it. - The loopback hint (finding 5) is added only on an Apart machine, only when the URL names a host by name (`loopback_hint(spec, store, url)`), and only when no connection was made (`layerfs_store::postgresql::open::not_connected`: the client's `error connecting to server`/`timeout waiting for server`, a silent dial, the session's no-connection words), never after a server answer (a refused login, a missing database, a refused setting). One attempt. - The refusal and hint name the Store: `layerfs store connect <name> <url> --machine <machine>` (finding 6; `reach(spec, store, url)`). - key=value branch deleted (finding 7): `reach` is called only from `route::reached` with `url_on`'s URL, built by `secrets::with_login`, whose `parts` refuses anything but postgres:// and postgresql://; the libpq-words parser was unreachable. A key=value string given to `reach` is now InvalidInput ("not one postgres:// URL its client reads"); the refusal at its real place is covered by the new `postgresql_no_auth::a_key_value_address_is_refused_before_anything_dials_it`. - A create whose daemon makes no connection to PostgreSQL (after the reach check passed) adds the same conditional hint (finding 8): the caller's hint now travels in `Host::reach_hint` to `launch::local::unreached`. Daemon starts happen only in sandbox.create (reopen reconnects to a running daemon and starts none). - `store connect --machine` no longer demands `pg_read_all_stats` or the database's CREATE (coordinator item). `check::check` (the machine's check, run in `store.reach` or here, and `store doctor`) refused `Denied` on every privilege `postgresql_access` listed, and that list held the two compaction-only privileges (access.rs: "a compaction reads another backend's pg_stat_activity row", "a compaction creates the scratch schema"); the first connect checks neither. They are dropped from `postgresql_access`: it lists what a Sandbox's reads and writes need (schema USAGE and CREATE, TEMP, table and sequence privileges), and `compaction_missing` still refuses a compaction without them. - Docs: workers-and-reach.md reach section (client reading, loopback forms, hint rule, per-operation URL use), backends.md (history phrasing removed, postgres_url row), machines/README.md, api/sdk/sandbox.md (the removed resolver-files note), versioned 2.0.0 machines-and-stores.md (no rewrite) and calls.md (loopback only on native and Linux Engine docker; the connect check's privileges), engine store/postgresql.md and stores-and-projects/sqlite-and-postgresql.md (privileges). - sandbox_machines (finding 10): the VM leg calls `machine.get` with `machine` and `with: [live]` (2.0 has no `machine.status`). Tests (fail on the parent, pass here): - machine_reach `a_loopback_host_is_refused_where_the_loopback_is_not_shared` (percent-encoded hosts/keys/values, first-`@`, list forms, 0.0.0.0, ::, inet_aton forms, zone ids), `a_unix_socket_...` (encoded socket host parameters), `a_failed_dial_carries_the_loopback_hint_...` (no hint for an address-only URL; Store named), `every_other_host_...` (valid lists, non-loopback inet_aton forms), `a_url_reach_cannot_read_...` (what the client refuses to read); conformance reach tests likewise. - postgresql_compact `a_machine_s_connection_check_asks_only_what_a_sandbox_needs` (parent: missing CREATE on the database, pg_read_all_stats). - sandbox_machines `a_sandbox_runs_where_its_store_can_be_reached`: a Sandbox on a lima machine with a loopback Store URL is read and its remove reaches the machine (parent: remove refused Unsupported loopback). - observed_reach `only_a_dial_no_server_answered_is_not_connected` (real client errors: closed port, unresolvable name; server answers: refused setting, missing database) and launch::local `a_daemon_that_made_no_connection_carries_the_caller_s_hint`: new API, absent on the parent. Corrected assertions (wrong before, not loosened): - machine_reach `a_url_reach_cannot_read_is_refused_off_a_shared_loopback` pinned `postgres://lfs:pw@[::1]:5432,h2/db` as InvalidInput. That URL is a valid host list naming ::1; tokio-postgres dials it. It is now the Unsupported loopback refusal (in loopback_forms). Likewise `postgres://lfs:pw/x@localhost/db`, pinned InvalidInput as "not read": the client ends the userinfo at the first `@` and dials localhost, so it is now the loopback refusal. - The advice text assertions name the Store (`store connect pg <url> --machine dev`) instead of the `<store>` placeholder (finding 6). Deleted tests (the dead libpq key=value path, finding 7): machine_reach loopback_forms entries `host=localhost user=lfs ...`, `host = 'db1,127.0.0.9' ...`, `host=db1 hostaddr=::1 ...`; socket entries `dbname=layerfs ...`, `host=/tmp dbname=layerfs`; every_other_host entry `host=db.example.com port=5433 ...`; conformance every_other entry `host=db.example.com password=...`. Three of them now sit in the cannot-read lists as InvalidInput (conformance `host=localhost ...` and `dbname=layerfs ...` expect InvalidInput instead of Unsupported). No test function was deleted. Not in scope (a later change replaces the resolver binds): binding the launcher's live /etc/resolv.conf inode goes stale when the launcher's resolver replaces the file by rename. Production LOC: 207,708 -> 207,783 (delta +75) core 40,989 -> 40,989 (0) engine 96,933 -> 96,923 (-10) layerfs-persistence -10 control 59,461 -> 59,546 (+85) layerfs-control +3, layerfs-platform +10, layerfs-sandbox +47, layerfs-sandbox-backend +13, layerfs-store +12 api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archive of parent f09bfde and of the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompact test 96e73fa added `a_machine_s_connection_check_asks_only_what_a_sandbox_needs` to the PostgreSQL AC-44 suite without regenerating the committed matrix report, so `the_sqlite_half_of_the_acceptance_matrix_is_executed_and_reported` failed with "the report is stale". Regenerated with UPDATE_REPORT=1 on macOS; the only change is "(32 tests" -> "(33 tests". The test passes without UPDATE_REPORT afterwards. Docs: no architecture impact (a generated test report under core/docs/issues). Deleted tests: none. Production LOC: 207,783 -> 207,783 (delta 0) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 59,546 -> 59,546 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 96e73fa and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96e73fa gave `machine::reach` a Store argument (`reach(spec, store, url)`) and updated `machine_reach` and `conformance`, but not this Linux-only test, so `cargo test -p layerfs-platform --test localhost_reach` did not compile on Linux. It now passes "pg", as `conformance` does. The assertion is unchanged: every URL comes back exactly as given on native and docker, and no tool is asked. Linux run (tools/worktree.py cargo --platform linux): localhost_reach 1 passed; the batch's other targets as on base 8676948 (doctor_provider's two docker.sock tests fail on base too). Production LOC: 207,783 -> 207,783 (delta 0) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 59,546 -> 59,546 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent fd89806 and the staged tree (test-only change) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostgreSQL configuration is the user's. LayerFS now dials a Store URL exactly as configured and never rewrites it. This was the owner's direction on 2026-11-24.
No URL rewrite.
Removed: the per-call
docker exec <worker> getent ahostsv4 host.docker.internal(52–103 ms in the route step of every Sandbox call on Docker Desktop), lima's192.168.5.2rewrite, apple-container's per-call gateway read, and thesslmode=verify-fullrefusal.Diagnostic B6 C17 sample on docker/PostgreSQL, before → after:
Loopback refused, with a hint. On a machine that doesn't share the caller's loopback (docker on Docker Desktop, lima, apple-container), a URL naming loopback, or a Unix socket of the caller, is refused
Unsupported. The message names what the machine calls this host (host.docker.internal,host.lima.internal, the apple-container gateway) andlayerfs store connect <store> <url> --machine <m>. native and docker on a Linux Engine share the loopback and pass the URL through.Names resolve like the machine. A Sandbox binds its machine's
/etc/resolv.confand/etc/hostsread-only.URL reading matches tokio-postgres: percent-encoding, host lists,
0.0.0.0/[::], legacy IPv4 forms, zone ids. The hint is not attached to auth failures or to hosts that are down.Commits
20f27f9ec0f09bfdec2596e73fab59fd898060bef2b26c694flocalhost_reach: pass the Store name tomachine::reach(the Linux test didn't compile)Breaking
A Store URL naming
127.0.0.1/localhostno longer reaches its server from docker (Docker Desktop), lima or apple-container Sandboxes. Give the machine its own address:layerfs store connect <store> postgres://…@host.docker.internal:<port>/… --machine <m>. The B6 harness needs that per-machine connect, and its role needspg_read_all_statsfor the per-machine reach check.Tests
All runs used
tools/worktree.pyagainstf2b26c694f/fd898060be.--no-fail-fast, 1,400 tests passed. Every failure is also a failure on base8676948f10:host_installfusectl, the daemon binary not built,doctor_providerdocker.sock,machine_deadline, the macOS-onlysandbox_get_no_leaseon Linux,backup_rotateandstore_transfer_crash(root ignores permissions),sandbox_modules_never_import_workspaceandretire_failure_….lp176_image_recovery×6 (macOS native has no Sandbox images; checked on base) andsandbox_modules_never_import_workspace.Known, fixed in the follow-up
These come from the second review of
96e73fab59. They are fixed onclaude/sandbox-private-net(3cf2cfc246and later), which merges next:sandbox removewhose saved login is missing loses the real refusal.branch removeandstore compactstay refused.secrets::partssplits the login at the last@while the client splits at the first. This doesn't leak a password.Not in this PR: #758 (its frozen gate failed; waiting on the owner) and the Sandbox private network (next PR).
🤖 Generated with Claude Code