plan: edge fence build notes and the reporting trace (#990)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+67
−21
docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md+67 −21
CI failed — run details
diff --git a/docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md b/docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md| index f46c7a42b..61f8c8888 100644 |
| --- a/docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md |
| +++ b/docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md |
| @@ -292,29 +292,29 @@ no self-address exemption. |
| ### Task 2: `internal/edgefence` |
| -- [ ] `Rules(addrs []netip.Addr) (string, error)`: the table above, |
| +- [x] `Rules(addrs []netip.Addr) (string, error)`: the table above, |
| addresses sorted and validated (global unicast, single IP). |
| -- [ ] `Expected(addrs) string`: the readback `nft -s -nn -y` prints for |
| +- [x] `Expected(addrs) string`: the readback `nft -s -nn -y` prints for |
| that table, from evidence 7's capture. |
| -- [ ] Linux: `Install(ctx)`, `Verify(ctx)` and `Present(ctx)`, running |
| +- [x] Linux: `Install(ctx)`, `Verify(ctx)` and `Present(ctx)`, running |
| `nft` the way `hairpin/native_linux.go` does. Other OS: an |
| `ErrUnsupported` stub, so the CLI still cross-compiles. |
| -- [ ] Tests: render; readback matches; a numeric cgroup id is a |
| +- [x] Tests: render; readback matches; a numeric cgroup id is a |
| mismatch; a missing table is a mismatch; the reject line's |
| `meta l4proto 6` form; no address renders no table. |
| ### Task 3: control service integration |
| -- [ ] `denyLocalAddrs`: on non-group boxes, enable/refresh/fail as |
| +- [x] `denyLocalAddrs`: on non-group boxes, enable/refresh/fail as |
| above; `applyLocalDeny` gets the exempted set. |
| -- [ ] Startup verification in `Run`, before `Serve`. |
| -- [ ] Check-before-start at every start site under the slice. |
| -- [ ] `fenceActive` in `denyLoopWith`'s condition. |
| -- [ ] Remember the state and the reason (`fenceActive`, `fenceReason`) |
| +- [x] Startup verification in `Run`, before `Serve`. |
| +- [x] Check-before-start at every start site under the slice. |
| +- [x] `fenceActive` in `denyLoopWith`'s condition. |
| +- [x] Remember the state and the reason (`fenceActive`, `fenceReason`) |
| for reporting. |
| -- [ ] An operator off switch: `CARLOS_EDGE_FENCE=off` in host.env keeps |
| +- [x] An operator off switch: `CARLOS_EDGE_FENCE=off` in host.env keeps |
| the full deny (the rollback path without a release). |
| -- [ ] Tests, with fakes for systemctl and nft: the exemption only after |
| +- [x] Tests, with fakes for systemctl and nft: the exemption only after |
| a verified readback; a failed install, a failed readback and a stale |
| cgroup id each restore the full deny; startup with a leftover |
| exemption and a missing table restores the full deny before `Serve`; |
| @@ -324,31 +324,77 @@ no self-address exemption. |
| ### Task 4: units |
| -- [ ] `carlos-instance-control.service`: `RestrictAddressFamilies=AF_UNIX |
| +- [x] `carlos-instance-control.service`: `RestrictAddressFamilies=AF_UNIX |
| AF_NETLINK` (nft talks netlink; the group drop-in already does this |
| on group boxes). |
| -- [ ] `carlos-instances.slice` and `carlos.slice`: `RefuseManualStop=yes`, |
| +- [x] `carlos-instances.slice` and `carlos.slice`: `RefuseManualStop=yes`, |
| with the comment naming the remaining levers. The control service |
| starts `carlos-instances.slice`. |
| -- [ ] Missing `nft` binary or a failed load: full deny, reported. |
| +- [x] Missing `nft` binary or a failed load: full deny, reported. |
| ### Task 5: the probe and the guard |
| -- [ ] `box-addr` stays as it is (UDP `EPERM` on every box address). |
| -- [ ] New `box-addr-ports`: TCP to a non-web port on each box address |
| +- [x] `box-addr` stays as it is (UDP `EPERM` on every box address). |
| +- [x] New `box-addr-ports`: TCP to a non-web port on each box address |
| is refused (reset or `EPERM`, not a connect). |
| -- [ ] New `box-addr-edge`: TCP 443 on each box address connects when |
| +- [x] New `box-addr-edge`: TCP 443 on each box address connects when |
| the fence is active; `unverified` when it is off, with the reason. |
| -- [ ] Guard test for evidence 8's three facts: `carlos-app@` keeps an |
| +- [x] Guard test for evidence 8's three facts: `carlos-app@` keeps an |
| empty `CapabilityBoundingSet=`; no unit outside the instances slice |
| other than `carlos-edge.service` grants `CAP_NET_BIND_SERVICE`; |
| nothing the tree installs sets `ip_unprivileged_port_start`. |
| +### Build notes (Tasks 2–5, 2026-11-13) |
| + |
| +Where the build departed from the text above, and why: |
| + |
| +- **One choke point for starts.** Instead of a check at each of the 13 |
| + start sites, `guardStarts` wraps the service's `Systemctl` once in |
| + `runWithClaim`; `TestEveryStartIsSeenByTheFenceCheck` fails on a start |
| + through any other systemctl. Two such paths exist and are covered: |
| + the egress asserter's `try-restart` (through `RestartAllowed`, |
| + `bindEgressFence`) and claim units' own systemctl (the fence stays |
| + **off in claims mode**, reason "host claims mode"; claims are |
| + shelved). |
| +- **A flushed or stale fence is reloaded**, not just reported: the |
| + refresh and the pre-start check reinstall and re-verify, and fall |
| + back to the whole deny only if that fails. The invariant holds either |
| + way; a reload keeps same-box calls working through an nftables |
| + reload. |
| +- **The refresh does not re-set an unchanged deny** (`set-property` |
| + re-attaches the slice's BPF filters under every instance); the probe |
| + path still re-applies as before. |
| +- **A start is refused** until this service has applied a deny |
| + (`errFenceUnknown`), so a failed startup check cannot leave an |
| + unchecked leftover exemption in force for new instances. |
| +- **Units**: the claims-mode control unit rewrite matched the old |
| + `RestrictAddressFamilies=AF_UNIX` line exactly; it now matches the new |
| + line (it would have silently dropped `AF_INET`/`AF_INET6`). |
| +- **Probe**: the fenced addresses are marked in the existing |
| + `box-addrs` file (`<addr> edge`) rather than a second file, so the |
| + probes' exact `/opt/carlos` listings and bind mounts are unchanged. |
| + `box-addr-ports` dials TCP 22 (ssh, the listener a box most often |
| + has); `box-addr-edge` is never `fail`, so an edge restart does not |
| + take the box out of service. |
| +- **Policy point for review:** `adopt_advice.go` says the platform never |
| + writes the firewall on fixed boxes (spec §4b, §5a, the IMDS role |
| + gate). The fence is a platform-owned table that only restricts the |
| + instances slice's own traffic and opens nothing, as the group hairpin |
| + already is on group boxes; the reviewer should confirm that reading. |
| + |
| ### Task 6: reporting |
| -- [ ] The box report carries the fence state and reason, and |
| - `carlos instances list` shows "same-box calls: on" or "off: <reason>" |
| - per box (UX pass first, per AGENTS.md). |
| +- [ ] The box report carries the fence state and reason, and the CLI |
| + shows it per box (UX pass first, per AGENTS.md). |
| + |
| +**Where (traced 2026-11-13):** `carlos instances list` has one row per |
| +instance, not per box, and shows nothing from the probe today. The |
| +per-box pattern is `carlos status --layout`'s `exec-sandbox:` line |
| +(`status_instances.go` `printExecSandboxStatus`, fed by |
| +`status.LayoutReport.ExecSandbox`, filled in `internal/host/layoutleg.go` |
| +from the control service's `/ready` report). The fence state would take |
| +the same path: a field on `ProbeReport`, then `LayoutReport`, then |
| +`apiStatusLayoutBox`, then one line per box. |
| ### Task 7: census, review, drill |