carlos / platform Public

same-box-edge-fence

Same-box calls through the edge (#990)

Since v0.28.17 (#367) nested instances are denied every address of their own box. systemd's IPAddressDeny= has no ports, so that also blocks the edge: an app cannot call another app by hostname when both are on the same box, though it can when they are on different boxes. Jelly on console.carlos.exciting.io is held at v0.28.11 for this.

This branch lets instances reach the box's own global addresses on TCP 80 and 443 only, and keeps everything else #367 closed:

  • internal/edgefence renders, loads and reads back an nft table, carlos_edge_fence, one output chain scoped by socket cgroupv2 to carlos.slice/carlos-instances.slice: 80/443 accept, other TCP reset, everything else dropped.
  • instance-control takes an address out of the slice deny only while that table reads back exactly as rendered; every failure applies the whole deny. Every unit start checks the fence first (one wrapper on systemctl, guarded by a source-scan test); the deny refresh re-reads it every 10 s and reloads it after an nftables flush or a slice recreation.
  • Units: AF_NETLINK for instance-control; RefuseManualStop on carlos.slice and carlos-instances.slice.
  • Probe: box-addr-ports (TCP 22 must not connect on any box address) and box-addr-edge (the edge answers on fenced addresses; never fails readiness).
  • carlos status --layout prints one line per box: same-box calls: on, off (reason), not needed (reason) or unknown.
  • Off on group boxes (the region HA hairpin applies), in claims mode, with CARLOS_EDGE_FENCE=off, and where the public address is not on the box.

Plan, evidence, build notes and drill: docs/superpowers/plans/2026-11-13-same-box-calls-edge-fence.md.

Tested

  • Unit tests for the table, the readback (fixture from a real kernel), every failure path, the start guard, the refresh and retry, the probe lines and the CLI line; key tests mutation-checked.
  • Two namespace experiments on hal, and a drill on the load-test box (Debian 13, public v4 /32 and global v6 on eth0): the edge went from timeout to HTTP 303 on both families, :22 refused at once, UDP EPERM; a recreated slice, an nft table deletion and a control restart each ended with the fence reloaded or the whole deny in place within one tick. The drill found two issues, both fixed on the branch. The box was restored afterwards.

Review and census

  • Branch review round 1 (Codex): brief docs/superpowers/reviews/CODEX-REVIEW-BRIEF-same-box-edge-fence.md; pending.
  • Census card: docs/superpowers/notes/census-proposal-same-box-edge-fence.md; the same reviewer approves it.
Commits 13
Discussions 0 0 open
Tasks 0/0 done

Discussions

  • No discussions on this branch yet.

Tasks

  • No tasks yet.

Activity