carlos / platform Public

fresh-box-446: a freshly bootstrapped box can run a born-HA host

Bootstrap applies its tmpfiles conf before it arms any unit, so
/run/carlos-control is root:carlos (not root:root from the socket) on the
first start. A born-HA record mints the nested paths whatever the box's
layout answer is, as a rootfs row does, so a fresh box that mints before
its first nested-default decision can still wake it. Spec: the later
443-to-NLB-only follow-up. Census census-ruling-fresh-box-446 proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev c33b0115dbf4a70dec900cee9e8609fcc65afcb1 parent de23fa5
8 files changed, +103 −2
  • docs/superpowers/notes/census-proposal-fresh-box-446.md +23 −0
  • docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md +2 −0
  • internal/host/bootstrap.go +12 −0
  • internal/host/host_test.go +29 −0
  • internal/provision/reconcile.go +5 −2
  • internal/provision/reconcile_test.go +24 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-fresh-box-446.tsv +7 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/notes/census-proposal-fresh-box-446.md b/docs/superpowers/notes/census-proposal-fresh-box-446.md
new file mode 100644
index 000000000..1624f0533
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-fresh-box-446.md
@@ -0,0 +1,23 @@
+# Census approval: fresh-box-446
+
+Ruling `census-ruling-fresh-box-446`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/provision/reconcile.go` `RouteFor` | body | unchanged (13) | #446: a born-HA record mints the nested paths whatever nested says, as a rootfs row already does; same reads |
+
+Envelopes re-pinned: `internal/host`, `internal/provision`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/provision/reconcile.go` `RouteFor`: authority, task C,E3. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos); also root, in the claim root's landing registration (ClaimRootHTTP.rootLandingRoute) and the relocation install (relocationRecord): census-ruling-seeded-instances's body with two more fields from the record: the row's lifetime pair (rec.Incarnation, rec.MoveSeq), so a row minted outside a move takes the record's lifetime and its last move's sequence (0, 0 for a fieldless record with no move history); every caller gets it, the root ones included: the root callers (ClaimRootHTTP.rootLandingRoute, relocationRecord) now mint (0, move_seq) on a claims-on record, a non-zero sequence once that record has had an offline move (move_seq advances on claims-on offline moves too), which moves Fingerprint and SnapshotFingerprint once for that row; main's C,E3 authority retained; self-serve moves 1 Task 7 (fix round 1: root callers named);rev3=census-ruling-region-ha-p1a;basis=the agent's reconcile passes, and also root's callers (rootupdates.go, rootinventory_install.go and relocationinstall.go on HEAD): one more field copied from the record, HA: rec.HA, so a row minted from a record stamped HA carries the sticky born-HA mark; the record is the console-written instance record each caller already read; root's own code reads nothing of Route.HA, and Fingerprint does not include it (SnapshotFingerprint does, for a set mark); the same nine sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2: the row is minted with the record's Runtime (the console-written instance record, guarded by WriteRecord's runtimeFixed); a rootfs row always gets the nested socket and db path under dataDir and no seed or seed source; the paths are computed from the host, not read from the record
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- reads `internal/host/bootstrap.go:bootstrapWith`: +file:Command; keeps authority, task A,C,G,J4
+
+Seal: `fe61ef9b2ecbb7d3d2049b8e6c9746ee08d3ea32dc1e65455e126771447f403f` → `fe61ef9b2ecbb7d3d2049b8e6c9746ee08d3ea32dc1e65455e126771447f403f`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-fresh-box-446.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
index 7a4e33a31..da8ad3b62 100644
--- a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
+++ b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md
@@ -497,6 +497,8 @@ Today the module makes one `aws_instance` and one `aws_eip` (`main.tf:536-587`).
- the backhaul port from the VPC CIDR.
Drills check public traffic from outside the VPC.
+
+ **Later: close 443 to everything but the NLB** (follow-up, 2026-10-28). Port 80 already admits only the NLB. 443 stays open from anywhere only for cross-region backhaul. Once forwarding (§6) exists, backhaul dials the far region's NLB address instead of a box's, and the target box forwards to the holder. Then 443 admits only the NLB's security group, and no box address bypasses the NLB's health and drain. Private links between regions (peering or a transit gateway) were rejected for this: the default VPCs all use 172.31.0.0/16 and cannot peer.
- **The termination rule and queue:** unchanged. **Alarms:** §20.
### 12.2 IAM
diff --git a/internal/host/bootstrap.go b/internal/host/bootstrap.go
index 05939e3e8..a889c110b 100644
--- a/internal/host/bootstrap.go
+++ b/internal/host/bootstrap.go
@@ -288,6 +288,14 @@ func systemctlPlanArming(units, armed []string) [][]string {
// daemon. Both places that install the drop-in call this explicitly instead.
var journaldReload = []string{"restart", "systemd-journald"}
+// tmpfilesApply applies the conf a live bootstrap just wrote, before it arms
+// any unit (#446). Starting carlos-instance-control.socket creates
+// /run/carlos-control itself, root:root, and only the conf's line gives it
+// group carlos; a fresh box that waited for its next boot had an agent
+// refused at the control socket. The self-update apply does the same after
+// it installs the conf (systemapply.go).
+var tmpfilesApply = []string{"systemd-tmpfiles", "--create", "/etc/tmpfiles.d/carlos.conf"}
+
// RunBootstrap is the `carlos bootstrap` verb. Idempotent — safe to re-run
// (which is also how a box enrolls a new socket consumer after the fact).
func RunBootstrap(args []string) {
@@ -593,6 +601,7 @@ func bootstrapWith(root string, consumers []string, planJSON bool) error {
for _, args := range privilegedPlan(consumers) {
fmt.Printf(" %s\n", strings.Join(args, " "))
}
+ fmt.Printf(" %s\n", strings.Join(tmpfilesApply, " "))
for _, args := range systemctlPlan(enabledUnits) {
fmt.Printf(" systemctl %s\n", strings.Join(args, " "))
}
@@ -604,6 +613,9 @@ func bootstrapWith(root string, consumers []string, planJSON bool) error {
if err := repairOffcloudCredentials("/etc/carlos/credentials"); err != nil {
return err
}
+ if out, err := exec.Command(tmpfilesApply[0], tmpfilesApply[1:]...).CombinedOutput(); err != nil {
+ return fmt.Errorf("%s: %v: %s", strings.Join(tmpfilesApply, " "), err, strings.TrimSpace(string(out)))
+ }
for _, args := range systemctlPlan(enabledUnits) {
if err := systemctl(args...); err != nil {
return err
diff --git a/internal/host/host_test.go b/internal/host/host_test.go
index d96d2c955..c23acbca4 100644
--- a/internal/host/host_test.go
+++ b/internal/host/host_test.go
@@ -7,6 +7,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
+ "io"
"log"
"net"
"os"
@@ -1981,3 +1982,31 @@ func TestSystemUnitsSelectPrevByTheFloor(t *testing.T) {
})
}
}
+
+// TestBootstrapAppliesTmpfilesBeforeArming pins #446's first fault: a live
+// bootstrap applies its tmpfiles conf before it starts any unit. Starting
+// carlos-instance-control.socket creates /run/carlos-control itself, root:root,
+// and only the tmpfiles line gives it group carlos, so a fresh box whose conf
+// waited for its next boot had an agent refused at the control socket. The
+// staging run prints the same sequence a live run executes.
+func TestBootstrapAppliesTmpfilesBeforeArming(t *testing.T) {
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal(err)
+ }
+ stdout := os.Stdout
+ os.Stdout = w
+ berr := bootstrap(t.TempDir(), nil)
+ os.Stdout = stdout
+ w.Close()
+ b, _ := io.ReadAll(r)
+ if berr != nil {
+ t.Fatalf("bootstrap: %v", berr)
+ }
+ out := string(b)
+ tmp := strings.Index(out, "systemd-tmpfiles --create /etc/tmpfiles.d/carlos.conf")
+ start := strings.Index(out, "systemctl start")
+ if tmp < 0 || start < 0 || tmp > start {
+ t.Fatalf("the plan must apply the tmpfiles conf before it starts units (tmpfiles at %d, start at %d):\n%s", tmp, start, out)
+ }
+}
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go
index 1bfe7abe7..dec39b96e 100644
--- a/internal/provision/reconcile.go
+++ b/internal/provision/reconcile.go
@@ -554,8 +554,11 @@ func RouteFor(rec Record, dataDir, seed string, nested bool, policy *UpdatePolic
rt.DBPath = DefaultDBPath(dataDir, rec.Host)
// Only an activator-managed row has a nested shape: an unflagged
// socket route is another supervisor's process, whose paths stay
- // flat in every release (design §8.2 step 1).
- if nested && rt.Hibernate {
+ // flat in every release (design §8.2 step 1). A born-HA row is
+ // nested whatever nested says (#446): it wakes only nested (region
+ // HA P1a), and a fresh box mints before its first nested-default
+ // decision, so a flat mint could never wake on it.
+ if (nested || rec.HA) && rt.Hibernate {
rt.Socket = NestedSocket(rec.Host)
rt.DBPath = NestedDBPath(dataDir, rec.Host)
}
diff --git a/internal/provision/reconcile_test.go b/internal/provision/reconcile_test.go
index 4427454c6..49a36bbad 100644
--- a/internal/provision/reconcile_test.go
+++ b/internal/provision/reconcile_test.go
@@ -3778,3 +3778,27 @@ func TestShapeMismatchIgnoresAssets(t *testing.T) {
t.Fatalf("differing asset columns blocked adoption: %q, want a match", shapeMismatch(b, a))
}
}
+
+// TestRouteForBornHAIsAlwaysNested pins #446's second fault: a born-HA row
+// is minted at the nested paths whatever the box's layout answer is, as a
+// rootfs row is. A born-HA host wakes only nested (region HA P1a), and a
+// fresh box mints before its first nested-default decision; minted flat, the
+// row could never wake there and the layout pass refuses to move a host with
+// nothing local. A legacy row on the same box keeps the flat mint.
+func TestRouteForBornHAIsAlwaysNested(t *testing.T) {
+ ha := Record{Host: "ha.example.com", App: "web", Account: "bab", Channel: "edge", HA: true}
+ rt := RouteFor(ha, "/data", "", false, nil)
+ if rt.DBPath != NestedDBPath("/data", ha.Host) || rt.Socket != NestedSocket(ha.Host) {
+ t.Fatalf("born-HA row minted at db %q socket %q; want the nested paths %q, %q",
+ rt.DBPath, rt.Socket, NestedDBPath("/data", ha.Host), NestedSocket(ha.Host))
+ }
+ if !rt.HA {
+ t.Fatal("born-HA row lost its HA flag")
+ }
+ legacy := ha
+ legacy.Host, legacy.HA = "legacy.example.com", false
+ lt := RouteFor(legacy, "/data", "", false, nil)
+ if lt.DBPath != DefaultDBPath("/data", legacy.Host) || lt.Socket != DefaultSocket(legacy.Host) {
+ t.Fatalf("legacy row on a box not yet nested minted at db %q socket %q; want flat", lt.DBPath, lt.Socket)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 2373f96be..36d94a001 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -26,3 +26,4 @@ plan14-root-reads-edge-roll-blip.tsv 886863e79986b005cf52aa11445a49c1bbc3fb9b55b
plan14-root-reads-cert-warm-propagation-443.tsv 886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f
plan14-root-reads-console-budget-cold-warm.tsv 886863e79986b005cf52aa11445a49c1bbc3fb9b55bce25915fc21d0e65f1b7f
plan14-root-reads-console-slow-writes.tsv fe61ef9b2ecbb7d3d2049b8e6c9746ee08d3ea32dc1e65455e126771447f403f
+plan14-root-reads-fresh-box-446.tsv fe61ef9b2ecbb7d3d2049b8e6c9746ee08d3ea32dc1e65455e126771447f403f
diff --git a/internal/provision/testdata/plan14-root-reads-fresh-box-446.tsv b/internal/provision/testdata/plan14-root-reads-fresh-box-446.tsv
new file mode 100644
index 000000000..6de560f5f
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-fresh-box-446.tsv
@@ -0,0 +1,7 @@
+# Census overlay fresh-box-446, written by census-propose (#369). census-ruling-fresh-box-446, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-fresh-box-446.md.
+# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 new dispositions: 1 reads re-frozen at their disposition with the claim, 0 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+internal/provision/reconcile.go RouteFor authority C,E3 rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos); also root, in the claim root's landing registration (ClaimRootHTTP.rootLandingRoute) and the relocation install (relocationRecord): census-ruling-seeded-instances's body with two more fields from the record: the row's lifetime pair (rec.Incarnation, rec.MoveSeq), so a row minted outside a move takes the record's lifetime and its last move's sequence (0, 0 for a fieldless record with no move history); every caller gets it, the root ones included: the root callers (ClaimRootHTTP.rootLandingRoute, relocationRecord) now mint (0, move_seq) on a claims-on record, a non-zero sequence once that record has had an offline move (move_seq advances on claims-on offline moves too), which moves Fingerprint and SnapshotFingerprint once for that row; main's C,E3 authority retained; self-serve moves 1 Task 7 (fix round 1: root callers named);rev3=census-ruling-region-ha-p1a;basis=the agent's reconcile passes, and also root's callers (rootupdates.go, rootinventory_install.go and relocationinstall.go on HEAD): one more field copied from the record, HA: rec.HA, so a row minted from a record stamped HA carries the sticky born-HA mark; the record is the console-written instance record each caller already read; root's own code reads nothing of Route.HA, and Fingerprint does not include it (SnapshotFingerprint does, for a set mark); the same nine sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2: the row is minted with the record's Runtime (the console-written instance record, guarded by WriteRecord's runtimeFixed); a rootfs row always gets the nested socket and db path under dataDir and no seed or seed source; the paths are computed from the host, not read from the record;rev3=census-ruling-fresh-box-446;basis=#446: a born-HA record mints the nested paths whatever nested says, as a rootfs row already does; same reads registry:Addr@2533,registry:Addrs@2542,registry:DBPath@1506,registry:DBPath@2029,registry:DBPath@2451,registry:Health@2552,registry:Hibernate@1973,registry:Seed@2497,registry:SeedSource@2506,registry:Socket@1468,registry:Socket@1991,registry:Socket@2414,whole:Route@2590 c9fcc1af4c9609d89634bdf571d3374c30d0bec2477477114ec7290d236f2cd1
+internal/host/bootstrap.go bootstrapWith authority A,C,G,J4 root-input;kept=A,C,G;scope=protected-decision-only;rev3=census-ruling-region-ha-p1a;basis=root (carlos bootstrap, cloud-init or an operator; also the staging-root and -plan-json path system apply's stagePlan runs): after the units are written, calls retireUnits(root, retiredUnits) (retiredunits.go, a new unit on this card) to disable, stop and remove carlos-system-join.path and .service, which an earlier build installed; an error there fails the bootstrap; enabledUnits (a var, not a census unit) no longer lists carlos-system-join.path; the same two sites, no read added in this body;rev3=census-ruling-fresh-box-446;basis=#446: a live bootstrap runs systemd-tmpfiles --create /etc/tmpfiles.d/carlos.conf (the conf it just wrote, a fixed path) after the credentials repair and before arming units; a failure fails the bootstrap; the staging run prints the same step file:Command@11307,file:ReadFile@461,file:ReadFile@6867 f140d3f7c5f9569b094a55936a584becac8b3d7606ee9beff1713c141091f05e
+@coverage internal/host bfdd1804a54897b458bed296d352a17b9ca191ddd0609294fdf09941b1ee8d4a
+@coverage internal/provision 8147aeb165cc9b72055266ab4986112643b9f7bb6aee2dd478fcc33e302c9979