carlos / platform Public

hosts used: group-member proof refuses pins and impostor files

Opus review r1 (READY, P3s): a box: target is excused only if every edges
file naming the member is its own (key and box_id), and never for a
reference the HA configuration pins as fixed. Tests cover a duplicate
identity, a pinned reference and an impostor file, and every refusal
subtest first asserts the proof it varies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev dfcd6a2da911232f21f8fa820105311d3c6d0bcf parent f4631a4
4 files changed, +77 −8
  • docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md +1 −1
  • internal/console/hacapacity.go +3 −0
  • internal/console/hostsused.go +10 −3
  • internal/console/hostsused_groupmember_test.go +63 −4

CI passed — run details

Intent

Attributed to this commit: 158 g CO₂e (15,330,371 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on hostname-history-group-members, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

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 bb96fe675..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,7 +56,7 @@ 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, and no other file conflicts with it (`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.
+**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)
diff --git a/internal/console/hacapacity.go b/internal/console/hacapacity.go
index 26dad0001..a0fd67e3a 100644
--- a/internal/console/hacapacity.go
+++ b/internal/console/hacapacity.go
@@ -219,6 +219,9 @@ func (o *HACapacityObservation) provenGroupMember(region, ref string) bool {
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 != ""
diff --git a/internal/console/hostsused.go b/internal/console/hostsused.go
index 5030d17b2..15133cf81 100644
--- a/internal/console/hostsused.go
+++ b/internal/console/hostsused.go
@@ -262,7 +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(region, t) })
+ now = slices.DeleteFunc(now, func(t string) bool { return s.provenGroupTarget(snap, region, t) })
}
for _, t := range now {
if !slices.Contains(recorded, t) {
@@ -283,12 +283,19 @@ func (s *Server) hostsCoverageRefusal(ctx context.Context, region string) *doorR
// 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.
-func (s *Server) provenGroupTarget(region, t string) bool {
+// 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)
}
diff --git a/internal/console/hostsused_groupmember_test.go b/internal/console/hostsused_groupmember_test.go
index f08310d61..440d9298f 100644
--- a/internal/console/hostsused_groupmember_test.go
+++ b/internal/console/hostsused_groupmember_test.go
@@ -21,6 +21,7 @@ import (
"github.com/carlosframework/platform/internal/boxid"
"github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/release"
)
const groupTestInstance = "i-0fedcba9876543210"
@@ -35,15 +36,31 @@ type groupMemberCase struct {
}
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, groupTestInstance)
- putHostsEdges(t, fx.rel, ref, "", "test-data")
+ 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
@@ -71,6 +88,15 @@ func (c *groupMemberCase) observe(t *testing.T, instance string, at time.Time, e
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(), "")
@@ -126,21 +152,54 @@ func TestUnprovenGroupMemberRefused(t *testing.T) {
if !c.o.current.Load().provenGroupMember("", c.ref) {
t.Fatal("the member was not proven at home: the case tests nothing")
}
- putHostsEdges(t, c.fx.rel, c.ref, "de", "test-data")
+ 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)
- putHostsEdges(t, c.fx.rel, c.ref, "", "other-data")
+ 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: