Repository navigation
Every Sandbox gets its own private network, with outbound access - #777
Merged
Merged
Conversation
A namespaces Sandbox's commands now run in a network namespace of their own, joined to the machine by one routed veth pair (lfs<id12> on the machine, eth0 inside) with one /31 of a /16 pool, masqueraded out. One LayerFS-owned nftables table (inet layerfs) keeps siblings apart, lets nothing new in, and closes the launcher's own non-loopback port (Docker Desktop's and apple-container's worker, 0.0.0.0:7070). Two Sandboxes can both bind 127.0.0.1:3000; a Sandbox cannot reach another Sandbox, its daemon's control port or the worker. The daemon stays on the machine's network, so its listener, the worker's dial, lima's forward and the Store connection (the URL as configured) are unchanged. - backend: network::plan (pool, slot, names) and network::resolver (the Sandbox's resolver file; a loopback-only resolver is refused), pure and tested on any OS; local::os::linux::net: netlink codec, rtnetlink links, addresses and routes, the nftables transaction and the forward-policy reader, the netns-scoped abstract-socket lock, the wiring. Hand-encoded over nix sockets: no new dependency. - helper: the outer init stage wires and holds the network before it spawns init-inner on the machine's network (D18: no gate pipe, because inner's pivot_root moves outer's root too); exec enters the init's network namespace first and refuses (by a signal) when it is the machine's; the resolver file is bound at /etc/resolv.conf. - launcher: forwarding, a dropping forward chain (D19), the pool and the resolver are checked before any effect and refused Unavailable with the fix; the table is written at every create (D20) and at every worker start; <sandbox>/network goes into the namespace, daemon and Sandbox records; reopen refuses an init that holds no network of its own. - sandbox.get's long form answers network (lfs<id12> <address>/31). - doctor: machine.network (worker op network.inspect; native on Linux as root) and sandbox.network, report-only with fixes; ids added to the frozen call surface (families, calls.json and pages rebuilt with build.py, which also picked up the pending `profile: normal` example). - machines: lima and apple-container PREPARE and Docker Desktop's worker entry set net.ipv4.ip_forward=1 in their own namespace; a Linux host's is never written. - docs: backends.md "Every namespaces Sandbox's own network" (design, deviations D1-D20, the seven defaults marked owner to confirm, breaking changes), platforms, workers-and-reach, channel and exec, doctor checks and findings, SDK sandbox.get and machine.doctor, and the 2.0.0 manual (calls, machines, migration). - tests: backend root tests in namespaces_lifecycle (own network, the resolver, the table, the join refusal, and with LAYERFS_TEST_NETWORK_ALONE the forwarding and forward-policy refusals); unit tests for the pool, resolver, netlink and nftables encodings. Every Sandbox in namespaces_lifecycle closes port 7070, as one worker's do. Existing tests only gained the new fields. Deleted tests: none. Production LOC: 207,783 -> 209,642 (delta +1,859) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 59,546 -> 61,399 (+1,853) layerfs-control +305, layerfs-machine +2, layerfs-platform +5, layerfs-sandbox +87, layerfs-sandbox-backend +1,454 api 10,325 -> 10,331 (+6) layerfs-api +2, layerfs-cli +4 reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent fd89806 and the staged tree 5ef7902 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
api/crates/layerfs-api/tests/sandbox_network.rs runs spec checks 1-5 and 7 through the call table on the docker machine (LAYERFS_TEST_IMAGE, LAYERFS_BUNDLE) and on each running machine named in LAYERFS_TEST_MACHINES (docker included): two Sandboxes bind 127.0.0.1:3000; a sibling is unreachable by TCP (its address and its loopback), ICMP and UDP (its kernel's counters do not move); out to the internet on an arbitrary port, `git ls-remote` (through LAYERFS_TEST_NET_PROXY where direct HTTPS is filtered) and PostgreSQL by the machine's host name (LAYERFS_TEST_NET_PG, an SSLRequest answered N or S); names resolve; the daemon's control port and a worker's non-loopback port are closed; sandbox get keeps the network and the listener; doctor reports a planted lfs link until it is deleted; remove and a killed daemon take the host end. Commands use only bash, busybox and getent. Without settings it says NOT_RUN and passes. Check 6 (the Store) stays with sandbox_machines.rs and the B6 harness. Deleted tests: none. Production LOC: 209,642 -> 209,642 (delta 0) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,399 -> 61,399 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent d2c5f56 and the staged tree 382fb98 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…over The apple-container leg showed two things the test assumed: direct HTTPS to GitHub is filtered on this network (from the VM's own network too), so LAYERFS_TEST_NET_GIT names another public remote per machine (default GitHub's); and the apple-container kernel has no dummy links, so the planted leftover is a veth pair, which every machine's kernel has, and both of its ends must be gone from the clean report. Deleted tests: none. Production LOC: 209,642 -> 209,642 (delta 0) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,399 -> 61,399 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent 9343542 and the staged tree b492137 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table is never removed on machine removal (no built-in machine is removed), and remove_unused_table is gone; two module comments still named both. Comments only; no tests deleted. Production LOC: 209,642 -> 209,642 (delta 0) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,399 -> 61,399 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 0b00bce and the staged tree (comment-only change) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t intents, client userinfo split Fixes the review of 96e73fa (three should-fix items and the nits). 1. Propagated reach error. A close (`StoreUrl::Cleanup`) swallowed every `route::reached` error (`Err(_) => (None, None)`), so a forced `sandbox.remove` on a docker/lima machine whose PostgreSQL Store's saved login is gone went on and `left` blamed an undialable URL; the real refusal and its fix (`store save-auth ... && store update --auth`) were lost. `route::dialled` now keeps the platform reach refusal (`layerfs_machine::platform::reach`: loopback or socket not shared, or a URL it cannot read; Unsupported/InvalidInput) apart from every other failure: only that refusal lets the close run without a URL; anything else (missing or unnamed saved login, a record with no URL, an unreadable machine record) refuses the close with its own message and fix, as before 20f27f9. `reached` keeps its contract (`dialled(..)?`). 2. Mount intents left behind. Chosen: the caller ends them. A close that ran without a URL left each PostgreSQL mount intent for good (admission never settles PG mount intents and `end_mount` has no other caller), so `branch remove` and `store compact` were refused forever. PostgreSQL Store calls run in the caller's process, which can dial the Store's own URL (the URL the machine could not dial is usually this host's loopback), and the closing side already holds the bound Workspace and Branch ids. So `lifecycle::close`, with no URL, answers those intents in `ending` (`mount_intents::handed`: path, Workspace id, Branch id, hex) instead of ending them, and `route::reach` ends them after any close's answer (`mount_intents::end_handed`, `store_of`'s OpenArgs, one `end_mount` each, no retry); one not ended is a `left` sentence with the caller's own reason, and `ending` is removed from the answer. This is small (one encode/decode pair and one call site), keeps "a Sandbox can always be removed", and ends each intent only after the closing side confirmed stop and delete, exactly as the side itself would have; the refusal option would bring back the parent's "loopback URL blocks every remove" behaviour. The hardcoded "no URL ... was resolved" reason is now used only for a Workspace not bound by Branch id, which the close never records. 3. `secrets::parts` split. It split the userinfo at the last `@` before the first `/`; tokio-postgres 0.7.18 `UrlParser::parse_credentials` takes everything before the first `@` anywhere (checked in the registry source). Now it splits there too, so `with_login` replaces the user part the client reads, `refuse_login` refuses a URL whose client reads a user part (`postgres://localhost/db?x=a@b`), and `target`/`url_user`/ `without_login` read the same host. The review's own example `postgres://localhost?x=a@b` splits the same under both rules (both read host `b`); its neighbours `postgres://localhost/db?x=a@b` and `postgres://a@b@c/db` differed and are in the test. Nits (all fixed; none skipped): - postgres_url: an empty host (`h1,,h2`, `?host=`) is left out instead of refused as a socket (the client's lookup of `""` fails and it dials the next); a host starting `@` is a name, not a socket (the client reads only a leading `/` as a path); the "client's default, a Unix socket" wording now says a URL naming no host is answered as one empty host, which the client refuses (`both host and hostaddr are missing`); the bare `0x` comment no longer claims a glibc behaviour (code unchanged: it is read as zero, which can only read more hosts as addresses). - reach::hint: no hint when the URL gives a `hostaddr` (new `postgres_url::url_hostaddr`): the client dials those addresses alone. - workers-and-reach.md: `cannot reach PostgreSQL Store` is attributed to `launch/local.rs` `unreached`, not `not_connected`. - route.rs: the stale "a mount's Branch" comment. Left as the review said: Status classified Dialled; old-glibc wrap and whitespace forms (note only). Docs: versioned 2.0.0 machines-and-stores.md (forced remove on a machine that cannot dial the URL ends the intents from this computer; other URL failures refuse the remove) and calls.md (remove), architecture workers-and-reach.md (per-call row, hosts row, hint row), sandboxes/README.md (sandbox.remove row), api/sdk/sandbox.md. Tests (fail on the parent, pass here; outputs in the 758-impl notes, fix-96e73fab59-evidence.md): - sandbox_machines `a_forced_remove_says_why_its_store_s_url_cannot_be_made`: lima Sandbox, forced remove with the Store's saved login gone is NotFound "no saved login named gone" with its save-auth line; with no saved login named, InvalidInput with the save-auth && update --auth fix; nothing removed; with the login back, the loopback URL lima cannot dial refuses nothing (parent: Unavailable, machine start). - gc_calls `a_close_without_a_store_url_has_its_caller_end_the_mount_intents` (macOS, LAYERFS_TEST_POSTGRES_URL): real PostgreSQL Store in its own database, a real mount intent, `route::on_machine` Close whose side answers `ending`; afterwards branch remove and store compact are admitted and `left` is empty (parent: branch remove InUse "mounts active"). - postgresql_no_auth `the_login_replaces_the_user_part_its_client_reads` (parent: `postgres://localhost/db?x=a@b` read with no user part). - machine_reach `a_failed_dial_carries_the_loopback_hint_...`: one more address-only case (`db.example.com?hostaddr=10.0.0.6` has no hint). Deleted tests: none. No assertion weakened. Production LOC: 209,642 -> 209,736 (delta +94) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,399 -> 61,493 (+94) layerfs-home -1, layerfs-platform +3, layerfs-sandbox +80, layerfs-sandbox-backend +12 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent dff347d and the staged tree 633acce (git archive of core, engine, control, api into a scratch root) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…v4-only rewrite, home-wide doctor links Fixes the confirmed findings of the independent review of the private network (decisions recorded with it, owner asleep, conservative choices): - F2: the daemon resolves names exactly as before this branch. The daemon's view binds the launcher's /etc/resolv.conf; where a resolver file is written, the outer init stage (which commands already join) holds a mount namespace of its own, a slave copy of the daemon's made after the pivot (the daemon's root is made shared inside the Sandbox's private mount namespace), with the written file bound there alone. Workspace mounts and unmounts the daemon makes later reach commands. A socket-pair gate on the inner stage's stdin orders it: the daemon starts only after the view exists, and a failure ends the Sandbox, so no command runs without it. No per-command cost: exec joins /proc/<init>/ns/mnt as before. - F3: the rewrite keeps only IPv4 nameservers that are not this host's own (loopback, 0.0.0.0), is done whenever the launcher's file names a loopback or an IPv6 server, and refuses Unavailable, naming /etc/resolv.conf, when no IPv4 server is left. - F5: machine.network treats an lfs* link as a leftover only when no Sandbox recorded in the home owns it, whichever machine (native and a Linux Engine docker share a Linux host's namespace; the worker reads only its own machine's records, so the caller matches against all of the home's). - Nit (spec 3.2): an init stage that finds the pool changed or the link present says so on a LAYERFS_SANDBOX_UNAVAILABLE log line; the launcher answers the start Unavailable, not Failed. - F6: the join-failure test writes its marker where the command could (checked by a control as uid 501) and requires the network refusal on stderr. Mutations show it fails when a join failure is not fatal, and when another join fails instead (where the old test passed). - F7: the live sibling ICMP/UDP checks get positive controls: B's ping and UDP to its own host end are answered, and A counts an echo from the machine and its own UDP, before B -> A must move nothing. - F1, F4 (docs, owner to confirm): backends.md now says exactly what is closed (LayerFS ports on the machine's own addresses) and that host-side forwards (lima ssh -L and worker forwards, Docker Desktop's and apple-container's published worker ports) stay reachable through the host gateway name, guarded by the daemon's controller key and the worker's secret, neither readable by a command; doctor's report-only leftovers (no --fix action) are listed as a deviation. Tests: new resolver units (v6-first dual stack, v6-only refusal, loopback and v6 mix), doctor ownership units, an UNAVAILABLE line unit, lifecycle an_init_stage_whose_pool_changed_says_unavailable, the resolver lifecycle test extended (daemon view, mount propagation both ways), the join-failure test strengthened, sandbox_network check 2 controls. Before/after outputs: fix-private-net-evidence.md in the session notes. Deleted tests: none. Production LOC: 209,736 -> 209,868 (delta +132) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,493 -> 61,625 (+132) layerfs-control +23, layerfs-sandbox-backend +109 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent 3cf2cfc and the staged tree da974fa Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntents docs and tests, doctor network on unreadable records Fixes the review of 3cf2cfc (M1, S1, S2, N1, N2), the doctor test broken by d2c5f56, and items 7-9 of the review of 210f032. 1. M1, a password holding `@` leaked through the display strips. `secrets::parts` splits the userinfo at the first `@` anywhere, as tokio-postgres reads it; that split stays only where a login is put into the URL that is dialled (`secrets::with_login`). Everything shown or written down now reads the URL under both readings (`connect::Shown`): the client's and the authority's (last `@` before the first `/`). It drops the wider user part and every login pair (`user`, `*password*`, `passfile`) of the query with no user part or after either reading's. The query is read as the client reads it: a value runs to the next `&`, and a `#` ends nothing. A fragment ahead of the query goes with it, as before. An `@` inside a login pair ends no user part; the pair is dropped whole, so `postgres://h/db?password=p@ss` is `postgres://h/db`, never host `ss`. `without_login` repeats until no reading finds a user part or a login, so one record write leaves a record current. `url_user` never answers a user part that overlaps a login pair. `target` reads the stripped URL. `refuse_login` refuses any `@` (the client reads a user part) or any login pair either reading finds. Callers covered: fix lines (refuse_login_with_fix, login::no_auth_fix and missing_fix via url_user), store get/list rows (connections url and server), StoreRecord::cleaned (store connect/update, own connections, machine remove), store.rs and doctor store_target (target). 2. S1 (docs): the window in which PostgreSQL mount intents handed back by a close can still be left (lost answer, folder removal failing after stop and delete, the caller ending first), and that a retried remove then answers already_gone with an empty `left` while branch remove and store compact stay refused. No new record field. 3. S2: unit tests that `mount_intents::handed` round-trips through `taken` (several intents; one bound by name and one unbound are not handed), and that `end_handed` drops the field and appends to `left`. No no-URL `lifecycle::close` unit check: no cheap seam (it needs a live host and a reopened owner). 4. N1: "a Sandbox can always be read and removed" is qualified in workers-and-reach.md, machines-and-stores.md and the route.rs comment: a missing or unnamed saved login refuses a forced remove. 5. N2: a handed item whose ids do not decode is the `left` sentence "the ids it was handed back do not decode", not "nothing records its Workspace id". 6. doctor_machine_target expected 10 machine checks; d2c5f56 added `machine.network`. The test now pins the count (11) and the ordered id list (machine.network between worker.ping and capacity), and that the one-request stand-in leaves machine.network unknown. 7. Doctor never prints `ip link delete` because records could not be read. `doctor::network::owned_in` replaces the three `record::sandboxes(..).unwrap_or_default()` sites. With a record that cannot be read, machine.network is `unknown`, naming the read, with no leftover list and no delete fix. This holds on the worker's report, the caller's match and `native` on Linux. New stand-in worker mode `network` in the doctor test. 8. Spec-level lifecycle tests run `helper init` on a spec naming a written resolver file, so F2 runs whatever the host's resolver is. One checks the commands' view has the file, the daemon's keeps the machine's, and a daemon-side mount and unmount reach the view and not the machine. The other makes a view that cannot be made: the stage exits 125, the daemon never says it listens, and no process is left. 9. Nits: the outer stage's gate logs an unexpected byte as its error (end of file still means the inner stage failed and logged its own); the helper's `init-inner` doc describes the share and the gate. Docs: versioned 2.0.0 machines-and-stores.md and calls.md (S1, N1); architecture workers-and-reach.md (S1, N1), sqlite-and-postgresql.md (both-readings strip, refuse_login), doctor README and findings (machine.network unknown on unreadable records), sandboxes backends.md (gate bytes, leftovers) and README.md (lifecycle test row). Tests (before/after outputs in the 758-impl notes, fix-3cf2cfc246-evidence.md): - layerfs-store observed_reach `a_password_holding_at_never_shows_and_dialling_keeps_the_client_split`. Before: `postgres://h/db?user=u&password=Zq7@Xw9` shown as `postgres://Xw9`. - layerfs-sandbox lib `mount_intents::tests::*`. Before: the undecodable item said "nothing records its Workspace id". - layerfs-control doctor_machine_target: fails at base (11 vs 10); the unreadable-record segment fails with the fix reverted (warning with `ip link delete`). - layerfs-control lib `doctor::network::tests::an_unreadable_record_leaves_no_owner_list` (new function). - layerfs-sandbox-backend namespaces_lifecycle: two new tests, run as root in a throwaway lima VM (full suite 22 passed; both fail against a helper with the gate wait and the view bind removed). Changed expectation: observed_reach `urls_lose_their_login_and_keep_the_rest` now expects `postgresql://h:1/d?sslmode=require` for `...&PassFile=%2Fp#f`, not `...#f`. The client reads `%2Fp#f` as the password file's value, so the `#f` goes with it. Two cases were added: a `#f` after a non-login pair is kept, and `h/d#x?password=y` becomes `h/d`. Deleted tests: none. No assertion weakened. Production LOC: 209,868 -> 209,953 (delta +85) core 40,989 -> 40,989 (0) engine 96,923 -> 96,923 (0) control 61,625 -> 61,710 (+85) layerfs-control +8, layerfs-sandbox +7, layerfs-sandbox-backend +6, layerfs-store +64 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 210f032 and the staged tree 7556754 (git archive of core, engine, control, api into a scratch root) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd positive controls
The live test failed at its new ICMP control on every machine: a command
runs as uid 501 with no capability, and the runtime layer's busybox ping
opens only a raw socket (CAP_NET_RAW), so it printed "permission denied
(are you root?)" whatever the firewall did. The older sibling check "B
pings A and gets no answer" passed for the same reason, not because of
the firewall. The namespace's ping_group_range already lets any group
open an ICMP datagram socket, and a hand probe through one showed the
product correct (B reaches its host end and 1.1.1.1; A neither answers
nor counts B's echo).
Test only; no product code.
- Check 2, ICMP: every command-side probe (the control from B to its own
host end, and B to A) sends two echoes through an ICMP datagram socket
(SOCK_DGRAM, IPPROTO_ICMP) with the Sandbox image's python3, and must
print "sent" before its outcome, so B to A can no longer pass because
nothing left. An image without python3 fails with a message saying
why; it never skips or passes. The machine-side control (the machine
pings A, A's InEchos rises) stays busybox ping: it runs as root on the
machine, which may open the raw socket.
- Check 2, UDP: each /dev/udp send must succeed (|| exit 1) and print
"sent"; before, the result of B's, A's and the control's sends was
ignored.
- Check 2, TCP, and check 5: the connect probe prints its exit status;
a closed port must be a refusal (rc 1 with bash's "connect:" error) or
no answer (rc 143, ended by busybox timeout), never a tool failure,
which used to read as "refused" too. New controls: B reaches its own
:3000 listener with the same probe; the machine lists the daemon's
127.0.0.1:<port> and, off lima, the worker's :7070 as listening.
- Check 7: the doctor run after the link was deleted asks for the long
form and must show machine.network's outcome "pass" in its tree, so the
link's absence is not an absent check (the short form of a clean report
is {"ok": true} alone).
- Checks 1, 3, 4 were positive already; 6 is the B6 harness; 8 (the
lifecycle join-failure test, fixed under F6) and 9 (units) live in
other files and are unchanged.
- docs/architecture/control/sandboxes/README.md: the test's row says what
the probes check and that check 2 needs python3 in the Sandbox image.
Changed assertions (none weakened):
- "B's ICMP out" (contains "answered" from busybox ping) -> the datagram
probe answers "answered": the old sender could never succeed.
- B -> A ICMP (output lacks "answered") -> the probe sent, and its
outcome is not "answered": adds the sent check.
- B -> A TCP, daemon port, worker port (output lacks "reached") -> the
probe ended refused or unanswered: adds the tool-success check.
- A's own :4000 (output "reached") -> exit status 0: same meaning.
- Clean doctor report (lacks both link names) -> asked in the long
form, it also shows machine.network's outcome "pass".
Deleted tests: none.
Production LOC: 209,953 -> 209,953 (delta 0)
core 40,989 -> 40,989 (0)
engine 96,923 -> 96,923 (0)
control 61,710 -> 61,710 (0)
api 10,331 -> 10,331 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: tools/production_loc.py --root <git archive> --detail on parent aa83393 and the staged tree 59affcd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…postgres reads them Decision of the aa83393 review: two rounds of hand-written URL splitting each leaked a password or moved a Store (M1-M3, S1, S2). A Store's URL is now read only by `postgres::Config` (tokio-postgres 0.7.18's UrlParser), which layerfs-persistence re-exports as `PostgresConfig`/`PostgresHost` (it already depends on postgres; no new dependency, layerfs-store's `postgres` stays a dev-dependency). New `layerfs-store` module `postgresql/address.rs`: - refuse_login (what is dialled or recorded): refuses any `@` or `#` after the scheme (hint: %40 / %23, which the client decodes), a URL the client does not read (passfile, sslpassword, sslkey, sslcert, bad values), and one whose client reads a user or password. - with_login (moved from layerfs-home secrets, with `percent`): refuses a URL refuse_login refuses, then reads the URL it makes back with the client and dials it only if it reads exactly the saved user, password, hosts, hostaddrs, ports and dbname. `secrets::parts` is removed: with no `@` allowed, with_login needs only the scheme. - clean (shown or written): the text after the client's user part, without the pairs the client reads as a login (each asked of the client alone; one holding `@` is kept), `#` written %23. Kept only if the client reads it with no login, the original's hosts/hostaddrs/ports/dbname, and no 3-byte piece of the client's password in it or in the client's user; None when the client does not read the original or its user part holds a `?`. without_login gives the form or `postgresql://<hidden: not an address alone>`; url_user the client's user when a form exists; target the form's hosts, ports and database as the client reads them (S2). - StoreRecord::cleaned keeps a URL with no clean form as it was (never rewritten; the record stays outdated). login::dial refuses a recorded URL that is not an address alone with the record's fix. The fixes (no_auth, missing, outdated: login::fix) remove a machine's own unclean URL with `store disconnect <s> --machine <m>` and replace an unclean Store URL with `store connect <s> <url>` (after `store disconnect <s>` when no login is named). store update --auth dials the cleaned record and refuses one whose URL has no clean form, writing nothing (item 6). layerfs-control's machine connect check names its host from the address without the login. Changed existing expectations (each kept exact): - observed_reach a_password_holding_at...: 5 rows now hidden (the old shown host/db was not the client's, or its user part held a query): user/host None, fix `<url>`, record kept as it was; the dial of `u:Zq7@Xw9@db.example` (password tail sent as host) is now refused. - observed_reach urls_lose_their_login...: sslpassword/PassFile, sslmode=require#f and sslkey/sslcert URLs hidden (the client does not read them); `h/d#x?password=y` -> `h/d%23x` (database d#x, was d). - postgresql_no_auth the_login_replaces...: parts columns now the client's own reading; `localhost/db?x=a@b` and `a@b@c/db` refused, not dialled to host b / b@c. - layerfs-api postgres_refusals: passfile and sslpassword fixes name `<user>`/`<url>` (client does not read them); fragment fix ends `app%23x` (was the wrong database `app`); the sslpassword old record is shown hidden, the 127.0.0.1 assertion moved to an added readable record. No test deleted; no assertion removed. Added: control/crates/layerfs-store/tests/postgresql_url_corpus.rs (365 URLs against postgres::Config: no password piece shown/fixed/stored, same endpoints, idempotent, exact dial, fix --user; update never rewrites). Production LOC: 209,953 -> 209,940 (delta -13) core 40,989 -> 40,989 (0) engine 96,923 -> 96,924 (+1) layerfs-persistence +1 control 61,710 -> 61,696 (-14) layerfs-control +1, layerfs-home -33, layerfs-store +18 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) with_login/percent relocated from layerfs-home to layerfs-store Method: tools/production_loc.py --detail on git archives of parent 19d4928 and the committed tree (cherry-picked from 7a5dfc54c8 on aa83393; parent production LOC identical, the intervening commit is test-only) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s hidden, short passwords checked, machine fixes connect again Fixes of the d194c7e review (layerfs-store postgresql/address.rs, connect.rs, login.rs, update.rs), still deciding everything by tokio-postgres 0.7.18's own reading (`PostgresConfig`), per the aa83393 Decision: - S1: a URL the client does not read names what it refuses only from fixed lists, never other URL text: `sslmode=verify-full`/`verify-ca`/`allow` (an `sslmode` value otherwise), a libpq TLS key (`sslrootcert`, `sslcert`, `sslkey`, ...), the value of a key the client reads (`port`), or a login key (`passfile`, `sslpassword`, and `user`/`password` with an undecodable value or no `=`). The TLS refusal states that `sslmode=require` verifies the server's certificate chain and host name (the engine's postgres-native-tls connector over native-tls built with its defaults: danger_accept_invalid_certs/hostnames false, so OpenSSL verify_hostname and the Security framework's peer name are set). Docs that promised verify-full/verify-ca are corrected (workers-and-reach, engine store postgresql and testing, store.md, versioned calls and machines-and-stores). The engine already refused verify-full at dial (Malformed); no working Store is affected. - S2: `clean` gives no form when the client's user part holds an address or a query: a `?` anywhere in it, a user half (raw or decoded) holding one of `/ ? & = #`, or a `/` followed by `&`, `=` or `#`; `url_user` never answers a user holding one of those. - N1: password pieces are min(3, len) bytes, compared with the shown form as written and percent-decoded, with `target`'s hosts and database (and their encoded forms) and the user. - N2: a machine's own unclean address is replaced with `store connect <s> <url> --machine <m>` when the record names a login; with none (connect --machine cannot dial) it is disconnected first and connected again as the fix's last step, also after a whole-Store disconnect. - N3: `store update --auth`'s refusal fix is built from the record with the requested login. - N4: docs state that a 2.0 record whose URL holds a raw `#` reads outdated and is refused at dial until `store update --auth` rewrites it as `%23`. - N5: every refusal of a URL holding a `#` gives the `%23` hint, and a URL refused only for a `#` or a TLS setting (`address::holds_login` false) gets a fix that only connects the address alone, with no save-auth. - N6: the platform tests' comments cite layerfs-store's `refuse_login`, not the removed `secrets::parts`, and say verify-full is a reach input only. - N7: postgres_refusals checks `store.list` of the hidden sslpassword record again (hidden form, no password, no host). A record whose URL has no clean form keeps that URL, and any password in it, on disk byte for byte until the user runs its fix: the Decision's never-rewrite rule, an exception to "no password in a Store record" for records written before 2.0's rules, now stated in the docs. - N8: the postgresql_status live test reads its login with the client and records the shown form, or, when that is hidden (user == password), the URL after the client's user part, which must be an address alone; it asserts the hidden form for user == password. Run with both URL forms. Tests (each fails on the base sources, passes after; excerpts in fix-d194c7e9df-evidence.md): postgresql_url_corpus gains 24 rows, (a) on min(3,len) pieces as written and decoded, (e) no address-holding user, (f) fixed-vocabulary messages, `#` hint and no-login fixes only for URLs without a login, and two tests pinning the review rows (S1, S2, N1, N5) and the fixes (N2, N3). Changed expectation: an_update_never_rewrites_a_url_to_another_host's fix is now `store connect pg <url> --machine lab && store connect pg <url>` (N2). No test deleted; no assertion removed or weakened. Fuzz (reviewer's harness, final address.rs): fuzz 4 x 400k all invariants held, 0 leaks/misses; new fuzz2 4 x 400k (TLS tokens, refusal vocabulary, no-login refusals, min(3,len) leaks incl. target and decoded forms) clean; writer 400k 0 hits; malformed writer2 2 x 400k: 0 hits on user-part forms. Open: `postgres://h/db&password=X` / `db#password=X` is read by the client as the database name, so it is shown (or accepted) as such. Production LOC: 209,940 -> 210,081 (delta +141) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,696 -> 61,837 (+141) layerfs-store +141 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archives of parent d194c7e and the staged tree ef05e1c Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd whole at their bound A cancelled command's exec group could stay behind, empty, until its Sandbox ended. `run_in` removes the group with one look after the helper reports the command's exit (`cgroup::remove_exec`), but a child signalled by the same cancel can exit after the command did: a process leaves its cgroup in do_exit (cgroup_exit runs before exit_notify), not when it is reaped, so the one look depends on whether that child has run its exit yet. Who reaps orphans is unchanged since f09bfde: the inner init stage is PID 1 of the Sandbox's PID namespace and reaps in a blocking waitpid loop (helper init.rs), commands join the outer stage's pid_for_children; the private-network branch moved neither, and reaping does not decide `populated`. The race is older than this branch; it showed once in namespaces_lifecycle at 57d0aea. Fix: the cancel, which already waits for the group to be empty, removes it (and its Workspace's group when that is empty too) once it reports it empty or finds it empty: `Stoppable::release`, the command group's `remove_exec`, a no-op for a native process group. No retry and no new wait: the cancel's own grace and kill waits are the bound. Test: namespaces_lifecycle `a_cancelled_command_whose_child_ends_after_it_leaves_no_group` forces the late exit (a background child, its streams not the command's, traps SIGTERM and ends 0.5 s after it, while the foreground ends at once) and asserts the group and its Workspace's are gone after the cancel. The existing `a_cancelled_command_and_what_it_started_leave_its_own_group_empty` is unchanged; its immediate `!group.exists()` now holds by construction. sandbox_network: `busybox timeout` signals only the process it runs, so git's `remote-https` helper outlived a timed-out `git ls-remote` with the exec's output and the exec never ended (the lima leg hung at check 3). Every probe bounded in time (TCP connect, github.com:22, git, PostgreSQL) now runs through `bounded`: the probe in a session of its own (`busybox setsid`), a watcher in another that ends the whole group at the bound (TERM, KILL a second later), and the rest of the group and the watcher killed once the probe's own process ended. A new control runs `git ls-remote` against 192.0.2.1 (TEST-NET-1) bounded at 5 s and asserts it fails and the exec returns within 15 s. Docs: backends.md (command cgroup row, Stop::Cgroup row), sandboxes README (both tests' rows). Deleted tests: none. Checks (one run each; lima Ubuntu 24.04.5, 6.8.0-147, as root): - the new test against the parent's product (57d0aea src, this test): FAILED at `assert!(!group.exists())`, the group left with populated 0; with the fix: namespaces_lifecycle 23 passed, drop-chain test alone ok. - in the same VM, an unreaped zombie child leaves its cgroup's populated 0 and the group removable (the diagnosis: exit, not reap, decides it). - macOS: layerfs-sandbox-backend all targets pass; Clippy -D warnings on layerfs-sandbox-backend and layerfs-api (machine) clean on macOS; the Linux image has no Clippy (gap); rustfmt clean. - sandbox_network live: docker (Docker Desktop) and lima (with LAYERFS_TEST_NET_PROXY and the PostgreSQL probe via host.lima.internal) both pass; the 192.0.2.1 git probe ended at its bound with rc 143 in 5.0 s on each. Production LOC: 210,081 -> 210,090 (delta +9) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,837 -> 61,846 (+9) layerfs-sandbox-backend +9 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent 57d0aea and the staged tree 06fb0af Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with a separator hidden, & or # before a key refused Fixes the should-fix findings and nits of the independent review of 57d0aea (PostgreSQL URL handling). - S1: `store update <s> --auth <new>` refused for a URL with no clean form builds its fix from the record as it is (`login::update_fix`), so each step dials with a login that exists. With the record's own login saved: its URL replacements, then `store update <s> --auth <new>` (unless it names <new> already). With none, or one not saved: the steps of a record naming none with <new> and no save-auth (`disconnect --machine` / `update --auth` / `connect --machine`, or `disconnect` / `connect --auth <new>` when the Store's address has no clean form). Every chain was run live against the test server. - S2: `clean` hides a URL whose client user part holds one of `? & # ; ,` (the reviewer's `? & #` plus `;` and `,`: dropping the `/`-followed-by rule alone newly leaked `h:5432/db;password=X@Y` shapes that rule caught), keeps the decoded user-half check, and drops the `/` rule, so raw base64 passwords in pre-2.0 user parts are cleaned again. - S3: a URL whose client reads `&` or `#` (or %26, %23) right before a client or login key and an `=` in a host, the database, `options` or `application_name` is refused with fixed words (a fixed key list, no grammar guessed), never dialled or recorded; its fix names `<url>`; an older record holding one is hidden and never rewritten. - N3: a value the client would read but for a `#` in it is named by that `#`; a refused URL whose hosts and path the client does not read alone, or that holds `&`/`#` before a login key, gets a fix that saves a login. - N4: the `sslrootcert` refusal and docs say where a private CA is trusted: `SSL_CERT_FILE` on Linux (OpenSSL, openssl-probe), the system keychain on macOS (Security framework), checked in the crate sources. - N2: comment that the `connect --machine` step needs the machine running. Changed exact expectations (postgresql_url_corpus.rs): - `a_machine_address_is_connected_again_and_an_update_names_its_login`, N3 case: was `store connect pg <url> --machine lab && store update pg --auth new`, whose first step fails ("no saved login named old"); now `store disconnect pg --machine lab && store update pg --auth new && store connect pg <url> --machine lab` (review S1). - d194 rows: `sslrootcert` gains the private-CA clause (N4); `sslmode=require#f` names the `#` instead of "give sslmode=require" (N3). - the message vocabulary gains the new fixed messages; plain `sslrootcert` is removed from it because it is no longer emitted. No test deleted, no assertion weakened. New: corpus rows, check (g), `an_update_fix_dials_only_with_a_login_that_exists`, `the_57d0aea5ad_review_rows_are_hidden_refused_and_named`. Production LOC: 210,090 -> 210,168 (delta +78) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,846 -> 61,924 (+78) layerfs-store +78 api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archives of parent 650828a and the committed tree (cherry-picked from 4fbb49a97f on 57d0aea, counted there as 210,081 -> 210,159; the intervening 650828a adds +9 in layerfs-sandbox-backend only) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ewrite one
Implements the Decision of review-e0aa26e149 (session decision 2026-11-24,
owner asleep; owner to confirm). Five review rounds each found a new
malformed shape that the "clean an old URL" grammar mishandled, so LayerFS
stops cleaning. Under the owner's 2026-11-19 no-backward-compatibility rule
("old state is not migrated automatically; it shows broken with a reason
and a fix the user runs"), this commit intentionally removes the automatic
cleaning of old records (owner to confirm).
The rule (address.rs):
- `holds_login(url)`: not a postgres(ql):// URL; any `@` after the scheme;
the client (tokio-postgres 0.7.18 `Config::from_str`) cannot parse it or
reads a user or a password; or the percent-decoded URL holds, in any
case, a login key followed by `=` anywhere. Keys: `user`, `password`
(tokio-postgres 0.7.18 `Config::param`), `passfile`, `sslkey`, `sslcert`,
`sslpassword`, `oauth_client_secret` (libpq 18, libpq.so.5.18 in the
postgres:17 image: Database-User, Database-Password,
Database-Password-File, SSL-Client-Key, SSL-Client-Cert,
SSL-Client-Key-Password, OAuth-Client-Secret).
- Such a URL is never shown (fixed HIDDEN form, no `server`), dialled,
stripped or rewritten anywhere: rows, fix lines, messages, doctor,
update, save_own, forget_machine, layerfs-control `store.rs`. Its record
stays byte for byte and reads `broken` `outdated` with a fix the user
runs. Any other URL is shown and stored exactly as written (`shown`);
`target` reads it only then.
- Dialling refuses anything holding a login or a `#`; `with_login` and the
client read-back stay. Non-secret text the client reads as a host,
database or value (`/db&sslmode=require`) is left to the client.
- Deleted: `clean`, `without_login` (now `shown`), `url_user`,
`without_login_pairs`, `holds`, `smuggled`, `smuggled_in`, SMUGGLED, the
`ADDRESS` and S2/S3 separator rules, `StoreRecord::cleaned` (now
`without_old_fields`, used by `store update` only, never touching a URL).
`with_own_connection` changes only that machine's entry.
- Fixes (login.rs) name `<url>` and `<user>` only and dial only with the
login they name, never the record's, so they work when that login no
longer authenticates: a machine's own URL: `store disconnect <s>
--machine <m> && store update <s> --auth <a> && store connect <s> <url>
--machine <m>`; the Store's URL: `store disconnect <s> && store connect
<s> <url> --auth <a> --synchronous-commit <recorded>` and every machine's
own connected again (the first connect accepts `--synchronous-commit`).
`store update` refuses any record keeping a URL that is not an address
alone (also `--synchronous-commit` alone), carrying a given
`--synchronous-commit`. The `outdated` fix names `<auth>` when it
replaces a URL. A refused connect of a URL holding a login on a
connected Store: `save-auth`, those steps, then the connect.
- PRIVATE_CA (review nit 3): Linux system trusted roots, or
`SSL_CERT_FILE` for calls in that process only (a Sandbox's daemon
starts with a cleared environment); macOS login or system keychain.
Verified: every chain traced through the call code and run with the CLI
against the test PostgreSQL (machine native, an old login the server
rejects): 9 of 9 cases end `ready` with no secret in the record.
Tests (none deleted; renamed: urls_lose_their_login_and_keep_the_rest ->
urls_are_shown_as_written_or_hidden_whole,
old_fields_read_outdated_and_a_clean_write_drops_them ->
..._and_an_update_drops_them_but_never_a_url,
every_url_is_shown_written_and_dialled_as_its_client_reads_it ->
..._as_the_rule_says, the_d194c7e9df_review_rows_..._as_their_client_reads
-> ..._as_the_rule_says, an_update_fix_dials_only_with_a_login_that_exists
-> an_update_fix_dials_only_with_the_login_it_names,
an_old_record_reads_outdated_until_its_update_writes_it_clean ->
..._until_its_fix_connects_it_again). The corpus invariants are restated:
(a) no 3-byte piece of the client's password, of any value after a login
key, or of the writer's password, raw or decoded, in anything shown, a
refusal, a fix or a written record except the kept bytes; (b) a shown URL
equals the original and holds no login (checked against an independent
computation); (c) dialled URLs read back exactly; (d) no read or refused
update writes, and save_own/forget_machine keep every URL; (e) refusals in
fixed words, fixes name only `<url>`/`<user>` and save a login exactly when
the URL may hold one. New rows: review e0aa26e S1 (7), S2 (11), every
login key in a value/database/host, N2, N4 and the 768 rv_sep shapes; new
test the_e0aa26e149_review_rows_are_hidden_refused_and_kept.
Changed expectations (each the removed cleaning, owner to confirm):
- shown forms: `postgres://u:Zq7/Xw9@db.example/app`,
`postgres://h/db?pass%77ord=x&...`, `postgres://ab:x@h/db`, the base64
user part (57d0 N1) and `postgres://h/d#x?password=y` were shown without
their login, now HIDDEN; `postgres://h/d#x` and `...dbname=a#b` were
shown with `%23`, now as written; `url_user`'s `--user u|ab|owner|'o'\''k'|'a b'`
is now `<user>`.
- fixes: every fix address is `<url>` (was the clean form, e.g.
`postgresql://127.0.0.1:1/app`, `.../app%23x`, `postgres://h/db`);
`outdated` fixes that connected first with the record's login
(`store connect <s> <url> --machine lab && store update ...`,
`store connect pg <url>`) now disconnect first; a no-login record whose
URL names a user (`--user owner ... && store update pg --auth <auth>`,
doctor_targets pg/old, postgres_connections, postgresql_no_auth) now
connects the Store again with the address alone; whole-Store chains carry
`--synchronous-commit <recorded>`; TLS/`#` refusals of URLs the client
does not read now save a login first (they may hold one).
- refusals: `&`/`#` before a login key gives the login message (was
SMUGGLED); `postgres://h/db&sslmode=require` is accepted (was SMUGGLED);
`store update` refusal message says "keeps a URL that is not an address
alone"; `store update --synchronous-commit` alone on such a record is
refused (it cleaned and wrote before).
- writes: a record with a URL holding a login keeps it on update/save_own/
forget_machine (was cleaned); readdress, save_own and forget_machine no
longer drop old fields (only `store update` does).
Docs: sqlite-and-postgresql.md, machines-and-stores.md, calls.md,
store.md, findings.md, engine/store/postgresql.md.
Production LOC: 210,168 -> 210,088 (delta -80)
core 40,989 -> 40,989 (0)
engine 96,924 -> 96,924 (0)
control 61,924 -> 61,844 (-80) layerfs-store -80
api 10,331 -> 10,331 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: tools/production_loc.py --detail on git archives of parent e0aa26e and the staged tree 0d2a8c5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ps; sandbox_network bound control NOT_RUN where it cannot fire Test and docs follow-ups of review-650828a686 (its Decisions section, session decision 2026-11-24, owner asleep). No product logic change. - F1: a process does not always leave its cgroup before its parent is told. Since Linux 6.19 (d245698d727a) the kernel unlinks an exiting task after exit_notify, at its final context switch (later on PREEMPT_RT); 650828a's message ("cgroup_exit runs before exit_notify") holds before 6.19 only. The remove_exec doc (cgroup.rs) and the Command cgroup row (backends.md) say so, and record the KNOWN GAP for the owner: an uncancelled command's single look in run_in can leave an empty group until the Sandbox ends on >= 6.19; the cancel path is unaffected (it waits for populated 0). A fix (a bounded wait on cgroup.events in the exec return path) costs exec latency: an owner decision. The machines here run 6.8 and 6.18. - F3: KNOWN GAP recorded in backends.md and the remove_exec doc: removing ws-<workspace> per command can race another command's create_exec in the same Workspace (between its two mkdirs); that command fails, reported, never retried. Options: stop removing ws-<id> per command, or a cross-process lock around a Workspace group's create and remove. - Nit 6: the stop-handle row says an early cancel releases the same way. - F2: sandbox_network's TEST-NET-1 control now requires rc=143 and an elapsed time no less than its 5 s bound; where 192.0.2.1 is answered at once (no rc=143, under the bound) it prints NOT_RUN for that control instead of passing, and any other result fails. An image without git prints NOT_RUN for it too. The assertions it had (no rc=0, under 15 s) stay. - Nit 4: BOUNDED's cleanup kills `-- -$p -$w $w`, so a watcher that has not called setsid yet is killed by its pid and the last wait returns. Checks: clippy -D warnings --all-targets on layerfs-api (machine) and layerfs-sandbox-backend (aarch64-apple-darwin and aarch64-unknown-linux-musl); rustfmt; layerfs-sandbox-backend tests on macOS 56 passed; sandbox_network built (--no-run), not run (live E2E leg, not run here). Production LOC: 210,088 -> 210,088 (delta 0) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,844 -> 61,844 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archives of parent 4ed2eb7 and the staged tree e40c6bb Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner accepted the e0aa26e review's Decision (4ed2eb7: a URL that may hold a login is never cleaned, stripped or rewritten; its record shows broken with a fix the user runs) on 2026-11-24, relayed by the coordinating session: "Accept, file S1–S3". The follow-ups S1–S3 are filed as #771 and are not on this branch. The two marks of that rule change from "owner to confirm" to owner-confirmed; every other "owner to confirm" item (the network defaults, doctor --fix, host-forwarded LayerFS ports) stays as it is. Comments and docs only. Production LOC: 210,088 -> 210,088 (delta 0) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,844 -> 61,844 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on git archives of parent 72a31d1 and the staged tree ec00b4c Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bound control required rc=143 and "no sooner than the 5 s bound", but measured the second half with the host's Instant around the exec while the bound itself is a `busybox sleep 5` on the guest's CLOCK_MONOTONIC. On lima (live run aaa5f8362f) the guest clock ran about 1% fast (systemd-timesyncd slewing it forward, lima's guest agent setting it back every 10 s): the bound fired correctly (rc=143) but the host measured 4.963 s, and the test failed. Changed assertion (test only, api/crates/layerfs-api/tests/sandbox_network.rs): - before: match (rc=143, host_elapsed >= 5 s) - after: match (rc=143, guest_elapsed >= 5 s), where guest_elapsed is what `busybox time -p` prints as `real s.cc` around the bounded probe: busybox time reads the guest's CLOCK_MONOTONIC (milliseconds) before it starts the probe and after it ended, the same clock the bound sleeps on. Reason: compare the bound with the clock it runs on; the guest's wall clock (`date`) is no better, lima's agent steps it. Unchanged: the bound stays 5 s, no tolerance; (no 143, < 5 s) is still NOT_RUN (answered at once), any other mix still panics; "rc=0" still fails; the host-side "exec returned within 15 s" ceiling stays as the hang guard. A missing `real` line panics. The BOUNDED line and the panic now print both guest and host elapsed times. No test deleted. Production LOC: 210,088 -> 210,088 (delta 0) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,844 -> 61,844 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail --root on git archives of parent cb2a63c and the staged tree 601943e Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ss takes SIGTERM a_cancelled_command_whose_child_ends_after_it_leaves_no_group failed once in lima (fe61648, 22/23): the cancel answered Signalled(SIGKILL), expected Signalled(SIGTERM). The product did what its contract says (one SIGTERM to each pid of the exec group, 5 s grace, then cgroup.kill); the test armed the cancel too early. The race (dash 0.5.12-6ubuntu5, the VM's /bin/sh; read from its source): - The `armed` marker proved the inner shell had set its TERM trap and forked its background `/bin/sleep 600`, not that the forked child had exec'd it. - A background job is a real fork (evalsubshell -> forkshell, FORK_BG). The child keeps the parent's `onsig` handler until forkchild() -> forkreset() clears the traps and setsignal() puts SIGTERM back to SIG_DFL; it then execs directly (EV_EXIT, no traps left). - A SIGTERM that reaches the child in that window, including before it first runs after the fork, is caught by onsig, which only sets gotsig and pending_sig; the cleared trap never runs it and execve drops the flags. That `sleep 600` outlives the cancel's one SIGTERM round and is killed after 5 s. - Shown in a throwaway Ubuntu 24.04 VM (same kernel and dash): a trapped shell sending SIGTERM to its background `sleep 30` right after the fork left it running 5/5 (unpinned and pinned to one CPU); with no trap 5/5 ended; with a wait for /proc/<pid>/comm = sleep first, 5/5 ended. A second, narrower gap: Debian's dash does not exec the last command of `sh -c` (patch 0004), so the outer shell forked its foreground sleep after the background child. Nothing has a trap there (SIGTERM is SIG_DFL for a non-interactive dash and its children), but the marker did not prove that fork had happened: a fork landing between the cancel's cgroup.procs listing and its signal to the shell would leave that sleep unsignalled too. The change (test only): - The trapped shell writes the marker only after `/proc/$p/comm` of its background child reads `sleep` (polling with /bin/sleep 0.01). The kernel sets comm past the exec's point of no return, before it resets caught handlers to SIG_DFL, so a SIGTERM sent after that read is delivered with the default action and ends it. - The command execs its foreground sleep (`& exec /bin/sleep 600`): it forks nothing after the background child, so every process the SIGTERM must end is in the group before the marker, and the command itself still ends by SIGTERM (143). - The existing 10 s bounded wait for the marker stays the bound. Every assertion is unchanged: >= 500 ms, Signalled(SIGTERM), 143, exec and Workspace groups gone, Sandbox group gone. a_cancelled_command_and_what_it_started_leave_its_own_group_empty has no trap anywhere (setsid execs sleep without forking, since its caller is not a group leader), so it has no lost-signal window; it is unchanged. Checks: rustfmt --check; Clippy -D warnings for layerfs-sandbox-backend all targets on macOS and --target aarch64-unknown-linux-musl (zig cc wrapper); macOS package tests all pass (t.py 22.2 s); Linux binaries from the registered target volume, lima Ubuntu 24.04.5 (6.8.0-147, 2 vCPU, dash 0.5.12-6ubuntu5) as root: namespaces_lifecycle 23 passed / 0 failed (2.27 s), drop-chain test alone (LAYERFS_TEST_NETWORK_ALONE=1, --exact, --test-threads=1) ok. One run each. No test deleted. Production LOC: 210,088 -> 210,088 (delta 0) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,844 -> 61,844 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root <git archive> --detail on parent fe61648 and the staged tree 756e9e9 (identical output) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`a_close_without_a_store_url_has_its_caller_end_the_mount_intents` (3cf2cfc) records the Sandbox's daemon with `machine.update`, which a build without the `machine` feature refuses by design ("machine.update runs on the host", calls/host_only.rs). The test was gated on macOS only, so `cargo test -p layerfs-api --test gc_calls` with LAYERFS_TEST_POSTGRES_URL set and default features failed at that call, before anything it checks. It and the items only it uses (HANDED_BRANCH, handed_back, DroppedDatabase) are now `cfg(all(target_os = "macos", feature = "machine"))`, as other machine tests are (contract.rs, machine_calls.rs). No assertion changed. macOS, LAYERFS_TEST_POSTGRES_URL = the trust-auth test server: - --features machine: 13 passed (the test runs and passes); - default features: 12 passed (the test is not built); - clippy -D warnings clean both ways; rustfmt --check clean. Production LOC: 210,088 -> 210,088 (delta 0) core 40,989 -> 40,989 (0) engine 96,924 -> 96,924 (0) control 61,844 -> 61,844 (0) api 10,331 -> 10,331 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 993055e and the staged tree (test-only change) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Every
namespacesSandbox now gets its own private network, with outbound access to anything. It is one fixed behaviour: there is no option, flag or record field for it. Owner direction, 2026-11-24.127.0.0.1:3000.inet layerfsnftables table: the internet, git remotes, PostgreSQL viahost.docker.internal/host.lima.internal. PostgreSQL is not a special case.127.0.0.53), commands get a rewritten file with the upstream IPv4 servers. The daemon keeps the machine's own file.nix, with no new dependency. The helper holds the namespace, andexecjoins it before dropping privileges; a command that can't join is killed before it starts.lfs*links, pool allocations and a missing table. It is report-only.Also in this branch:
branch removeandstore compactwork again; the caller ends them;broken/outdated, with a fix command the user runs. Other URLs are shown exactly as written.Breaking
127.0.0.1of a Linux host, or Docker ports published as-p 127.0.0.1:…. Those must listen on an address the host routes.localhost.broken/outdatedwith a fix, instead of being cleaned automatically.Owner to confirm (defaults as built)
sandbox.createrefuses whennet.ipv4.ip_forward=0. LayerFS never writes the host's setting.lfs*links.nft flush.--fixaction.Also open: the host-forwarded LayerFS ports (see above).
Tests
sandbox_network§7 checks 1–5 and 7:72a31d1507, and lima again atfe61648598;host.docker.internal/host.lima.internal=N(SSLRequest answered).namespaces_lifecycle, as root in lima: 23/23 at993055e7de.210f032bc4and4ed2eb751a), with no must-fix left.layerfs_v2_0_0+ #758: 2.0 PostgreSQL storage (ancestor-location lists, group-ranged reads) #774 + this branch atfe61648598; the three later commits change tests only):--no-fail-fast: 2,063 passed. Every failure is in base8676948f10's set. Two stand-in-tool flakes (worker_log,machine_probe) passed on re-run, and their files are unchanged.87e46c652a, or passed on re-run. The one exception isgc_calls' new handed-intents test, which needed themachinefeature;0363a8496cgates it, and it passes with--features machine.fe61648598: the lima bound control is timed on the guest clock;993055e7de: the cancel test waits until the child issleep(dash fork-to-exec race);0363a8496c:gc_callsgating.Follow-ups
claude/pg-url-771and will be a separate PR.🤖 Generated with Claude Code