carlos / platform Public

hosts used: proven group members don't refuse region creates

The coverage check (S4) refused every data-kind create in a region whose
edges files named a box completion had not recorded. Each group
replacement mints a new g- reference, so every replacement blocked its
region until the history was completed again offline (#421, #527).

Paul's ruling on #421 (option A, 2026-11-06): skip a box: target only
when the current HA capacity observation proved the box a group member
of that region (signed identity verified, reference = haGroupReference
of it, no conflict, no fixed pin, every edges file naming it its own).
Its data bucket stays checked; unproven or stale evidence refuses as
before; nothing is written to the mode. Recorded in the nearest-region
spec. Opus review READY, P3s fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from hostname-history-group-members into main.
claude agent, operated by paul@keymail.dev 3ce8532975d4d9688a0c75bc65533ec3df01bf69 parent 72c4946
5 files changed, +289 −1
  • docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md +2 −0
  • internal/console/hacapacity.go +31 −0
  • internal/console/hacapacity_observe.go +2 −0
  • internal/console/hostsused.go +30 −1
  • internal/console/hostsused_groupmember_test.go +224 −0

CI passed — run details

diff --git a/docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md b/docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md
index e72858822..e1103bb0b 100644
--- a/docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md
+++ b/docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md
@@ -56,6 +56,8 @@ Deleted history and noncurrent versions are not sources, because they are harmle
**A fleet created after completion is recorded at its first box (#519, 2026-11-02).** Activation records every fleet on its roster, so a fleet the history has not recorded was created since. No box of it existed before completion, so none holds its old data. Its first add-box, with the console serving, records the fleet as examined before it adds the box: its targets are its bucket, its boxes so far and the new box, and the new label is its first box (`first_box`). Its next add-box is N9 like any recorded fleet's, except its first-box label while no box of that label is active, which completes the enrollment. A box is never added before the record lands and never detached, so a write of the mode that errs, lands late or never lands is finished by the same add-box again (Paul's ruling on Astra r2; `TestNewFleetEnrollmentSimulation`). A bucket that a closed fleet also uses was never scanned: such a fleet is left unrecorded and completes offline, as before. **What this takes on trust (Paul, 2026-11-02, on Astra r1 P1 1):** the console never reads a fleet's bucket or boxes, so storage the owner names is examined as new, as anything they copy into an examined fleet's storage later would be. The first-box label stays completable after a detach, on the same terms. A registry restored to a snapshot from before activation is outside it too.
+**A group member that joins a region is not a target the history waits for (Paul's ruling on #421, 2026-11-06, option A).** S4's coverage check refuses every data-kind create in a region whose edges files name a box that completion did not record, because a box that joins from infra may carry old data on its disk. Each replacement in a region's Auto Scaling group mints a new `g-` reference, so before this ruling every replacement refused all data-kind creates in its region, legacy creates included, until the history was completed again offline. A group box cannot carry old data: it starts from the launch template with a root volume deleted on termination, `restore-box` refuses group boxes (durability §3.1 item 3), it runs no unit, platform or non-hibernating records (region HA §6.1), and it holds only copies of state in its region's data bucket. So the coverage check skips a box's `box:` target only when the current HA capacity observation proved the box a group member of that region: its edges file was read within the region's scope, its signed identity verified, its reference is `haGroupReference` of that identity's account and instance, no other file conflicts with it, the configuration does not pin its reference as a fixed box, and every edges file naming it is its own (key and `box_id` are its reference) (`provenGroupTarget`). The box's data bucket stays a checked target. A member the observation has not proved, or no observation, or a stale one, refuses as before. Nothing is written to the mode: the excused box never becomes a recorded target. **What this takes on trust:** a box whose host.env an operator deliberately switches to `CARLOS_BOX_REFERENCE=group` is treated as a group box. The proof needs a fresh edges file. A terminated member's file is deleted by the departure scan, and until it is, that file refuses as before.
+
## 3a. The activation window (accepted 2026-10-26)
A one-time maintenance window wraps the inventory. It closes round 3's P1: a marked allocation started before activation and still pending could otherwise publish over old data after `complete` (recovery's "our slot, absent record" branch, lifetimes_recovery.go:204).
diff --git a/internal/console/hacapacity.go b/internal/console/hacapacity.go
index c2fab489a..a0fd67e3a 100644
--- a/internal/console/hacapacity.go
+++ b/internal/console/hacapacity.go
@@ -204,6 +204,32 @@ func HADataStoreRegions(cfg Config) (map[string]HADataStore, error) {
return regions, nil
}
+// provenGroupMember reports whether this generation proved ref a box its
+// region's group launched, in region (the record-vocabulary placement code,
+// "" for the home): ref's edges file was read within region's scope, its
+// signed identity verified, ref is haGroupReference of that identity's
+// account and instance, and no other file conflicts with it. The hostname
+// history's coverage check excuses only such a box's box: target (Paul's
+// ruling on #421, 2026-11-06); the caller checks the observation is
+// available.
+func (o *HACapacityObservation) provenGroupMember(region, ref string) bool {
+ if o == nil || o.config == nil {
+ return false
+ }
+ if region == "" {
+ region = o.config.home
+ }
+ if _, pinned := o.config.FixedBoxes[ref]; pinned {
+ return false // the operator declared it fixed
+ }
+ for _, f := range o.files {
+ if f.ref == ref {
+ return f.group && f.region == region && !f.malformed && f.identityCode == "" && f.instance != ""
+ }
+ }
+ return false
+}
+
func haGroupReference(account, instance string) string {
sum := sha256.Sum256([]byte("carlos-box-ref-v1|" + account + "|" + instance))
return "g-" + hex.EncodeToString(sum[:])[:20]
@@ -248,6 +274,11 @@ type haCapacityFile struct {
instance string
report *status.Box
statusCode string
+ // region is the configured region whose scope admitted the file, and
+ // group that its signed identity derives its reference
+ // (haGroupReference): set by observe, read by provenGroupMember.
+ region string
+ group bool
}
// HACapacityObservation retains producer evidence. Its fields and collections
diff --git a/internal/console/hacapacity_observe.go b/internal/console/hacapacity_observe.go
index 819eb1969..714528b2a 100644
--- a/internal/console/hacapacity_observe.go
+++ b/internal/console/hacapacity_observe.go
@@ -424,6 +424,8 @@ func (o *haObserver) observe(ctx context.Context, start time.Time) *HACapacityOb
continue
}
f.instance = ev.Cloud.InstanceID
+ f.region = region
+ f.group = strings.HasPrefix(f.ref, "g-") && f.ref == haGroupReference(ev.Cloud.Account, f.instance)
instances[f.instance] = append(instances[f.instance], i)
if strings.HasPrefix(f.ref, "g-") && f.ref != haGroupReference(ev.Cloud.Account, f.instance) {
f.identityCode = "instance_conflict"
diff --git a/internal/console/hostsused.go b/internal/console/hostsused.go
index 184b03994..15133cf81 100644
--- a/internal/console/hostsused.go
+++ b/internal/console/hostsused.go
@@ -8,10 +8,12 @@ import (
"net/http"
"os"
"slices"
+ "strings"
"sync"
"time"
"github.com/carlosframework/platform/internal/alerting"
+ "github.com/carlosframework/platform/internal/edgesfile"
"github.com/carlosframework/platform/internal/geo"
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/registry"
@@ -221,7 +223,9 @@ func (s *Server) hostsTargetRefusal(ctx context.Context, region string) *doorRef
// region's target set is fixed once recorded). A box added to a fleet
// since is refused at its own door (addFleetBoxRecorded); a box that joins
// a region does so from infra, so a create there is refused here until
-// the history is completed again. Targets that cannot be read refuse (S5).
+// the history is completed again, unless the HA capacity observation
+// proved it a group member (provenGroupTarget; its data bucket is still
+// checked). Targets that cannot be read refuse (S5).
// It reads the edges files (one snapshot, which also names the place), or
// the registry for a fleet, once per data-kind create while the history is
// active.
@@ -258,6 +262,7 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
}
now, recorded = rosterRegions(snap)["region:"+region], st.RegionTargets
place = snapshotPlaceName(snap, region, s.homeRegionOut(region))
+ now = slices.DeleteFunc(now, func(t string) bool { return s.provenGroupTarget(snap, region, t) })
}
for _, t := range now {
if !slices.Contains(recorded, t) {
@@ -271,6 +276,30 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
return nil
}
+// provenGroupTarget reports whether t is the box: target of a box the
+// current HA capacity observation proved its region's group launched
+// (provenGroupMember): such a box is not a target the history waits for
+// (Paul's ruling on #421, 2026-11-06). Every replacement mints a new
+// reference, and a group box starts from the launch template with a fresh
+// disk, is never restored onto (durability §3.1 item 3), and holds only
+// copies of state in its region's data bucket, which stays a target
+// checked here. No observation, or one that is stale, proves nothing. Every
+// file in snap naming the box must be the box's own (its key and box_id
+// are its reference), so another file cannot hide behind a proven name.
+func (s *Server) provenGroupTarget(snap edgesSnapshot, region, t string) bool {
+ ref, ok := strings.CutPrefix(t, "box:")
+ if !ok || !edgesfile.IsGroupReference(ref) {
+ return false
+ }
+ for _, f := range snap.Files {
+ if f.Box == ref && (f.Key != edgesfile.Key(ref) || f.BoxID != ref) {
+ return false
+ }
+ }
+ obs, ok := s.HACapacity()
+ return ok && obs.provenGroupMember(region, ref)
+}
+
// snapshotPlaceName is a region's place name from the snapshot already
// read (placeOf's rule: the AWS region its boxes publish, else fallback),
// so the refusal costs no second read.
diff --git a/internal/console/hostsused_groupmember_test.go b/internal/console/hostsused_groupmember_test.go
new file mode 100644
index 000000000..440d9298f
--- /dev/null
+++ b/internal/console/hostsused_groupmember_test.go
@@ -0,0 +1,224 @@
+package console
+
+// A box its region's group launched is not a target the hostname history
+// waits for (Paul's ruling on #421, 2026-11-06, option A). Every
+// replacement mints a new g- reference, and before this ruling each one
+// refused every data-kind create in its region until the history was
+// completed again offline. A group box starts from the launch template
+// with a fresh disk, cannot be restored onto (durability §3.1 item 3) and
+// holds only copies of state in the region's data bucket, which stays a
+// checked target. So the coverage check excuses a box: target only when
+// the current HA capacity observation proved it a group member: its signed
+// identity verified and its reference haGroupReference of that identity.
+// Anything less is refused as before.
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/boxid"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+const groupTestInstance = "i-0fedcba9876543210"
+
+// groupMemberCase is a console whose home region's history was completed
+// with one fixed box (leo) and the region's bucket, after which a group
+// member published its edges file.
+type groupMemberCase struct {
+ fx *consoleFixture
+ ref string
+ o *haObserver
+}
+
+func newGroupMemberCase(t *testing.T) groupMemberCase {
+ return newGroupMemberCaseFor(t, groupTestInstance)
+}
+
+func newGroupMemberCaseFor(t *testing.T, instance string) groupMemberCase {
+ t.Helper()
+ fx := newConsoleFixture(t)
+ putHostsEdges(t, fx.rel, "leo", "", "test-data")
+ activeAsNow(t, fx.srv)
+ ref := haGroupReference(moveTestAccount, instance)
+ putMemberEdges(t, fx.rel, ref, "", "test-data")
+ return groupMemberCase{fx: fx, ref: ref}
+}
+
+// putMemberEdges is putHostsEdges for a group member, which publishes its
+// box_id (region HA spec 1 §5.1).
+func putMemberEdges(t *testing.T, st release.Store, ref, placement, bucket string) {
+ t.Helper()
+ body := `{"v":1,"box":"` + ref + `","box_id":"` + ref + `","eip":"192.0.2.1","region":"eu-west-1","placement":"` + placement + `","data_bucket":"` + bucket + `","hosts":{}}`
+ key := edgesFilePrefix + ref + ".json"
+ _, etag, _ := st.Get(context.Background(), key)
+ if _, err := st.Put(context.Background(), key, []byte(body), etag); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// observe publishes the member's evidence to the HA capacity observation's
+// store: its edges file (the golden publisher's body, under ref), a signed
+// identity for instance, and a fresh status; then observes at "at" and
+// installs the observer on the console.
+func (c *groupMemberCase) observe(t *testing.T, instance string, at time.Time, edit func(map[string]any)) {
+ t.Helper()
+ o, store, signer := haFixture(t)
+ now := time.Now().UTC()
+ haPut(t, store, edgesFilePrefix+"leo.json", haEdit(t, haGolden(t), func(m map[string]any) {
+ m["generation"] = now.Format(time.RFC3339Nano)
+ }))
+ haPut(t, store, edgesFilePrefix+c.ref+".json", haEdit(t, haGolden(t), func(m map[string]any) {
+ m["box"], m["box_id"] = c.ref, c.ref
+ m["box_role"], m["admitted"] = "booting", false
+ m["generation"] = now.Format(time.RFC3339Nano)
+ if edit != nil {
+ edit(m)
+ }
+ }))
+ _, raw := signer.Record(t, c.ref, moveTestAccount, "eu-west-1", instance)
+ haPut(t, store, boxid.Key(c.ref), raw)
+ haPut(t, store, haStatusPrefix+c.ref+".json", []byte(fmt.Sprintf(`{"label":%q,"generated_at":%q,"metrics":{"instance_id":%q}}`, c.ref, now.Format(time.RFC3339Nano), instance)))
+ o.current.Store(o.observe(context.Background(), at))
+ c.fx.srv.haCapacity.Store(o)
+ c.o = o
+}
+
+// proven fails the test unless the observation proved the member at home,
+// so a refusal subtest cannot pass for want of the proof it varies.
+func (c groupMemberCase) proven(t *testing.T) {
+ t.Helper()
+ if _, ok := c.fx.srv.HACapacity(); !ok || !c.o.current.Load().provenGroupMember("", c.ref) {
+ t.Fatal("the member was not proven at home: the case tests nothing")
+ }
+}
+
+func (c groupMemberCase) coverage(t *testing.T) *doorRefusal {
+ t.Helper()
+ return c.fx.srv.hostsCoverageRefusal(context.Background(), "")
+}
+
+func wantS4(t *testing.T, what string, ref *doorRefusal) {
+ t.Helper()
+ if ref == nil || ref.Status != http.StatusConflict {
+ t.Fatalf("%s: coverage = %+v, want 409 S4", what, ref)
+ }
+}
+
+// TestProvenGroupMemberJoinsRegion: a proven group member that joined the
+// home region after completion does not refuse creates there, and the
+// whole admission (gateDataCreate) passes.
+func TestProvenGroupMemberJoinsRegion(t *testing.T) {
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ if ref := c.coverage(t); ref != nil {
+ t.Fatalf("coverage with a proven group member = %+v, want admitted", ref)
+ }
+ if ref := c.fx.srv.gateDataCreate(context.Background(), "new.example.com", ""); ref != nil {
+ t.Fatalf("admission with a proven group member = %+v, want admitted", ref)
+ }
+}
+
+// TestUnprovenGroupMemberRefused: everything short of the proof refuses,
+// as before the ruling.
+func TestUnprovenGroupMemberRefused(t *testing.T) {
+ t.Run("no observation", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ wantS4(t, "no observation", c.coverage(t))
+ })
+ t.Run("stale observation", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ at := time.Now().UTC().Add(-haCapacityLifetime - time.Second)
+ c.observe(t, groupTestInstance, at, func(m map[string]any) { m["generation"] = at.Format(time.RFC3339Nano) })
+ if !c.o.current.Load().provenGroupMember("", c.ref) {
+ t.Fatal("the member was not proven when observed: the case tests nothing")
+ }
+ wantS4(t, "stale observation", c.coverage(t))
+ })
+ t.Run("reference not derived from its identity", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ c.observe(t, "i-0aaaaaaaaaaaaaaaa", time.Now().UTC(), nil)
+ wantS4(t, "a g- reference another instance's identity signs", c.coverage(t))
+ })
+ t.Run("proven in another region", func(t *testing.T) {
+ // Proven as a member of the home's group, but listed in de's
+ // edges: de's coverage does not take the home's proof.
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ if !c.o.current.Load().provenGroupMember("", c.ref) {
+ t.Fatal("the member was not proven at home: the case tests nothing")
+ }
+ putMemberEdges(t, c.fx.rel, c.ref, "de", "test-data")
+ wantS4(t, "a member proven in another region", c.fx.srv.hostsCoverageRefusal(context.Background(), "de"))
+ })
+ t.Run("a fixed box joins", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ c.proven(t)
+ putHostsEdges(t, c.fx.rel, "late", "", "test-data")
+ wantS4(t, "a fixed box beside a proven member", c.coverage(t))
+ })
+ t.Run("a new data bucket", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ c.proven(t)
+ putMemberEdges(t, c.fx.rel, c.ref, "", "other-data")
+ wantS4(t, "a proven member publishing a bucket never scanned", c.coverage(t))
+ })
+ t.Run("another file names the member", func(t *testing.T) {
+ // An edges file under another key whose body names the proven
+ // member must not hide behind its proof.
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ c.proven(t)
+ body := `{"v":1,"box":"` + c.ref + `","eip":"192.0.2.9","region":"eu-west-1","placement":"","hosts":{}}`
+ if _, err := c.fx.rel.Put(context.Background(), edgesFilePrefix+"old.json", []byte(body), ""); err != nil {
+ t.Fatal(err)
+ }
+ wantS4(t, "a second file naming the member", c.coverage(t))
+ })
+ t.Run("pinned as a fixed box", func(t *testing.T) {
+ c := newGroupMemberCase(t)
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ c.proven(t)
+ c.o.config.FixedBoxes[c.ref] = haFixedBox{RegionCode: "ie", InstanceID: groupTestInstance}
+ wantS4(t, "a reference the configuration pins as fixed", c.coverage(t))
+ })
+ t.Run("an identity two boxes claim", func(t *testing.T) {
+ // The member's identity is leo's instance too: identity_duplicate.
+ c := newGroupMemberCaseFor(t, "i-0123456789abcdef0")
+ c.observe(t, "i-0123456789abcdef0", time.Now().UTC(), nil)
+ f := c.o.current.Load().files
+ for _, x := range f {
+ if x.ref == c.ref && (!x.group || x.identityCode != "identity_duplicate") {
+ t.Fatalf("the case tests nothing: %+v", x)
+ }
+ }
+ wantS4(t, "a member whose identity another box also claims", c.coverage(t))
+ })
+}
+
+// TestGroupMemberLeavesHistoryUnchanged: excusing a member writes nothing:
+// the mode's region targets are what completion recorded.
+func TestGroupMemberLeavesHistoryUnchanged(t *testing.T) {
+ c := newGroupMemberCase(t)
+ before, _, err := provision.ReadHostsState(context.Background(), c.fx.rel)
+ if err != nil {
+ t.Fatal(err)
+ }
+ c.observe(t, groupTestInstance, time.Now().UTC(), nil)
+ if ref := c.coverage(t); ref != nil {
+ t.Fatalf("coverage = %+v", ref)
+ }
+ after, _, err := provision.ReadHostsState(context.Background(), c.fx.rel)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if fmt.Sprint(before.RegionTargets) != fmt.Sprint(after.RegionTargets) {
+ t.Fatalf("region targets changed: %v -> %v", before.RegionTargets, after.RegionTargets)
+ }
+}