carlos / platform Public

status: regional display names (DisplayName, Box.Name, FleetBox.Name)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9e72dcd413d4b75bff378217163905de9f2312f3 parent eabe437
5 files changed, +327 −7
  • internal/status/contract_test.go +8 −4
  • internal/status/displayname.go +154 −0
  • internal/status/displayname_test.go +152 −0
  • internal/status/fleet.go +2 −0
  • internal/status/snapshot.go +11 −3
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go
index 011e17935..9dc1a8256 100644
--- a/internal/status/contract_test.go
+++ b/internal/status/contract_test.go
@@ -79,7 +79,7 @@ var allowedBoxKeys = map[string][]string{
// Safe on the identical structural ground: BuildFleet's field-by-field
// copy never names "metrics", so no hostname here can reach FleetBox or
// fleet.json regardless of what this map holds.
- "": {"generated_at", "label", "region", "routes", "load", "capacity", "replication", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries", "metrics"},
+ "": {"generated_at", "label", "name", "region", "routes", "load", "capacity", "replication", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries", "metrics"},
"routes": {"static", "resident", "hibernating", "awake", "asleep"},
"replication": {"healthy", "lag_seconds"},
"metrics": {"mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates"},
@@ -117,7 +117,7 @@ var allowedBoxKeys = map[string][]string{
// allowedBoxKeys: every new field is a deliberate publication decision.
var allowedFleetKeys = map[string][]string{
"": {"generated_at", "boxes", "instances", "capacity", "apps", "apps_unlisted", "services", "replication", "adoption_running", "expired_canaries"},
- "boxes[]": {"label", "region", "load", "stale", "routes", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries"},
+ "boxes[]": {"label", "name", "region", "load", "stale", "routes", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries"},
"boxes[].routes": {"static", "resident", "hibernating", "awake", "asleep"},
"instances": {"total", "static", "resident", "hibernating", "awake", "asleep"},
"capacity": {"level"},
@@ -388,6 +388,9 @@ func fixtureProbes() status.Probes {
// explicitly added to allowedBoxKeys to pass this test — that's the guard.
func TestBoxSchemaAllowlisted(t *testing.T) {
b := status.CollectBox(fixtureRoutes(), fixtureProbes(), time.Now())
+ // The host stamps Name after CollectBox (statusTick); set it here so
+ // the key is exercised, not merely allowed.
+ b.Name = "seamus-minding-ie"
j, err := json.Marshal(b)
if err != nil {
t.Fatalf("marshal Box: %v", err)
@@ -403,8 +406,9 @@ func TestFleetSchemaAllowlisted(t *testing.T) {
now := time.Now()
// Write a box so BuildFleet has something to merge.
- if err := status.WriteBox(context.Background(), s,
- status.CollectBox(fixtureRoutes(), fixtureProbes(), now)); err != nil {
+ named := status.CollectBox(fixtureRoutes(), fixtureProbes(), now)
+ named.Name = "seamus-minding-ie"
+ if err := status.WriteBox(context.Background(), s, named); err != nil {
t.Fatalf("WriteBox: %v", err)
}
diff --git a/internal/status/displayname.go b/internal/status/displayname.go
new file mode 100644
index 000000000..27a363eac
--- /dev/null
+++ b/internal/status/displayname.go
@@ -0,0 +1,154 @@
+package status
+
+import (
+ "crypto/sha256"
+ "encoding/binary"
+)
+
+// DisplayName is a box's regional display name, "name-verb-region" — the
+// shape of seamus-minding-ie (spec 2026-10-25-regional-box-names-design.md).
+// It is for people to read on the status page and the console, and nothing
+// may key on it: object keys, enrollment, the roster, invitations, layout
+// intents and every feed's Box field use the identity label, always.
+//
+// It is derived from label, the identity label the report is published
+// under (the hashed pseudonym, a group box's g- reference). That label is
+// already public, so the name tells a reader nothing the page didn't, and a
+// group box, which has no hashed pseudonym, is covered by the same rule.
+// The hash carries its own domain prefix so the indexes don't echo Label's:
+// without it, a hashed-label box under an unthemed region would just get
+// its own label back with a suffix.
+//
+// Two boxes in one region can share a display name (1 in 1,600 for a pair).
+// That is cosmetic: the label is shown beside it.
+//
+// region is an operator-set code; "" (or anything ValidNameRegion refuses)
+// means no display name, and so does an empty label. A code with no themed
+// lists uses Label's own lists plus the suffix.
+func DisplayName(label, region string) string {
+ if label == "" || !ValidNameRegion(region) {
+ return ""
+ }
+ names, verbs := labelNames, labelActions
+ if theme, ok := nameThemes[region]; ok {
+ names, verbs = theme.names, theme.verbs
+ }
+ n, v := nameIndexes(label)
+ return names[n] + "-" + verbs[v] + "-" + region
+}
+
+// ValidNameRegion reports whether code is a display-name region code: 2 to
+// 8 lowercase ASCII letters, which covers every CARLOS placement code and
+// can never contain "-", the name's separator. Callers trim first; this
+// does not.
+func ValidNameRegion(code string) bool {
+ if len(code) < 2 || len(code) > 8 {
+ return false
+ }
+ for i := 0; i < len(code); i++ {
+ if code[i] < 'a' || code[i] > 'z' {
+ return false
+ }
+ }
+ return true
+}
+
+// nameIndexes is the name and verb index for label, each a uint32 % 40 of
+// its own 4-byte chunk, the same bias reasoning as Label's.
+func nameIndexes(label string) (name, verb uint32) {
+ sum := sha256.Sum256([]byte("carlos-box-name/v1\x00" + label))
+ return binary.BigEndian.Uint32(sum[0:4]) % 40, binary.BigEndian.Uint32(sum[4:8]) % 40
+}
+
+// nameTheme is one region's word lists: first names people there actually
+// have, and gerunds that read as both a host's job and something people do
+// there. Fixed-size, like labelNames, so the space stays auditable at a
+// glance. The lists passed a copy review
+// (docs/superpowers/specs/COPY-FINDINGS-REGIONAL-BOX-NAMES.md).
+type nameTheme struct {
+ names, verbs [40]string
+}
+
+// nameThemes holds the themed regions. Adding one is an entry here and
+// nothing else.
+var nameThemes = map[string]nameTheme{
+ "ie": {
+ names: [40]string{
+ "seamus", "siobhan", "niamh", "aoife", "ciaran", "padraig", "maeve",
+ "sinead", "eoin", "orla", "declan", "grainne", "cian", "roisin", "fionn",
+ "saoirse", "colm", "brid", "oisin", "aisling", "darragh", "caoimhe",
+ "ronan", "deirdre", "cathal", "una", "tadhg", "eimear", "donal",
+ "clodagh", "fiachra", "muireann", "lorcan", "sorcha", "eamon", "nuala",
+ "diarmuid", "ailbhe", "cormac", "mairead",
+ },
+ verbs: [40]string{
+ "minding", "herding", "shepherding", "droving", "ploughing", "thatching",
+ "baling", "foddering", "ferrying", "footing", "milking", "churning",
+ "stacking", "carting", "rambling", "welcoming", "pouring", "brewing",
+ "distilling", "baking", "knitting", "weaving", "walling", "fencing",
+ "hurling", "busking", "fiddling", "storytelling", "angling", "trawling",
+ "rowing", "shopkeeping", "gathering", "haymaking", "turfcutting",
+ "harvesting", "penning", "shearing", "grazing", "lambing",
+ },
+ },
+ "uk": {
+ names: [40]string{
+ "martin", "nigel", "gareth", "gemma", "ian", "claire", "derek", "colin",
+ "julie", "trevor", "alison", "graham", "keith", "wendy", "barry",
+ "sharon", "gavin", "kirsty", "neil", "lorraine", "stuart", "hayley",
+ "darren", "joanne", "craig", "nicola", "malcolm", "fiona", "rhys",
+ "bethan", "alastair", "morag", "hamish", "ellie", "hugh", "rosie",
+ "alfie", "imogen", "tom", "dave",
+ },
+ verbs: [40]string{
+ "queueing", "brewing", "narrowboating", "punting", "lockkeeping",
+ "signalling", "shunting", "portering", "marshalling", "trainspotting",
+ "bellringing", "allotmenting", "rambling", "pottering", "fettling",
+ "mending", "darning", "letterboxing", "hedgelaying", "wassailing",
+ "carolling", "twitching", "bowling", "batting", "quizzing", "caravanning",
+ "baking", "pickling", "jamming", "hoovering", "tidying", "stewarding",
+ "rowing", "fellrunning", "morrisdancing", "busking", "tinkering",
+ "crocheting", "beachcombing", "gardening",
+ },
+ },
+ "us": {
+ names: [40]string{
+ "hank", "betty", "earl", "peggy", "chuck", "dolores", "andrew", "tammy",
+ "dwayne", "shelby", "cody", "travis", "wade", "loretta", "dale", "bonnie",
+ "gus", "rhonda", "bud", "patsy", "mike", "jennifer", "chris", "ashley",
+ "brian", "amanda", "kevin", "heather", "jason", "melissa", "josh",
+ "brittany", "tyler", "kayla", "jake", "megan", "dylan", "madison", "cole",
+ "savannah",
+ },
+ verbs: [40]string{
+ "tailgating", "grilling", "barbecuing", "wrangling", "ranching",
+ "lassoing", "corralling", "trucking", "hauling", "railroading",
+ "carpooling", "roadtripping", "bussing", "carhopping", "potlucking",
+ "babysitting", "lifeguarding", "ushering", "bellhopping", "dispatching",
+ "shuttling", "logging", "homesteading", "prospecting", "panning",
+ "canning", "whittling", "squaredancing", "linedancing", "bowling",
+ "pitching", "umpiring", "coaching", "flyfishing", "rafting", "camping",
+ "surfing", "skateboarding", "carving", "guiding",
+ },
+ },
+ "au": {
+ names: [40]string{
+ "bruce", "sheila", "shane", "kylie", "brett", "tracey", "wayne",
+ "narelle", "craig", "leanne", "scott", "kerry", "glenn", "raelene",
+ "troy", "bronwyn", "mick", "nathan", "chloe", "lachlan", "matilda",
+ "isla", "kane", "jacinta", "hamish", "angus", "tahlia", "cooper", "ruby",
+ "brodie", "belinda", "dean", "darcy", "mitchell", "harley", "tegan",
+ "clancy", "lily", "mackenzie", "ella",
+ },
+ verbs: [40]string{
+ "mustering", "droving", "shearing", "jackarooing", "boundaryriding",
+ "fencing", "lifesaving", "patrolling", "announcing", "barbecuing",
+ "roadbuilding", "ferrying", "surfing", "bodyboarding", "snorkelling",
+ "sailing", "paddling", "crabbing", "rockpooling", "fossicking",
+ "prospecting", "bushwalking", "camping", "caravanning", "stargazing",
+ "beachcombing", "skimboarding", "guiding", "bowling", "brewing",
+ "pouring", "busking", "yachting", "rowing", "diving", "birdwatching",
+ "swimming", "fishing", "kayaking", "gardening",
+ },
+ },
+}
diff --git a/internal/status/displayname_test.go b/internal/status/displayname_test.go
new file mode 100644
index 000000000..7c83f6462
--- /dev/null
+++ b/internal/status/displayname_test.go
@@ -0,0 +1,152 @@
+package status
+
+import (
+ "context"
+ "encoding/json"
+ "regexp"
+ "sort"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// TestNameIndexesGolden pins the display name's hash independently of the
+// word lists: the expected indexes were computed outside Go from
+// sha256("carlos-box-name/v1\x00" + label), so a change to the domain
+// prefix, the byte ranges or the modulus fails here even if every list
+// still lines up.
+func TestNameIndexesGolden(t *testing.T) {
+ for _, c := range []struct {
+ label string
+ n, v uint32
+ }{
+ {"dennis-stenciling", 21, 19},
+ {"ada-stargazing", 17, 16},
+ {"g-0123456789abcdef0123", 39, 12},
+ } {
+ n, v := nameIndexes(c.label)
+ if n != c.n || v != c.v {
+ t.Errorf("%s: (%d,%d), want (%d,%d)", c.label, n, v, c.n, c.v)
+ }
+ }
+}
+
+var displayNameShape = regexp.MustCompile(`^[a-z]+-[a-z]+-[a-z]{2,8}$`)
+
+func TestDisplayNameThemed(t *testing.T) {
+ for _, code := range []string{"ie", "uk", "us", "au"} {
+ theme := nameThemes[code]
+ want := theme.names[21] + "-" + theme.verbs[19] + "-" + code
+ got := DisplayName("dennis-stenciling", code)
+ if got != want {
+ t.Errorf("%s: DisplayName = %q, want %q", code, got, want)
+ }
+ if !displayNameShape.MatchString(got) {
+ t.Errorf("%s: %q does not have the name-verb-region shape", code, got)
+ }
+ if again := DisplayName("dennis-stenciling", code); again != got {
+ t.Errorf("%s: not stable: %q then %q", code, got, again)
+ }
+ }
+}
+
+func TestDisplayNameUnthemed(t *testing.T) {
+ want := labelNames[17] + "-" + labelActions[16] + "-de"
+ if got := DisplayName("ada-stargazing", "de"); got != want {
+ t.Errorf("DisplayName(ada-stargazing, de) = %q, want %q", got, want)
+ }
+}
+
+func TestDisplayNameRefuses(t *testing.T) {
+ for _, region := range []string{"", "IE", "u-k", "i", "abcdefghi", "ie "} {
+ if got := DisplayName("dennis-stenciling", region); got != "" {
+ t.Errorf("region %q: DisplayName = %q, want none", region, got)
+ }
+ }
+ if got := DisplayName("", "ie"); got != "" {
+ t.Errorf("empty label: DisplayName = %q, want none", got)
+ }
+}
+
+func TestNameListsHygiene(t *testing.T) {
+ word := regexp.MustCompile(`^[a-z]+$`)
+ check := func(what string, list [40]string) {
+ seen := map[string]bool{}
+ for _, w := range list {
+ if !word.MatchString(w) {
+ t.Errorf("%s: %q is not lowercase ASCII letters", what, w)
+ }
+ if seen[w] {
+ t.Errorf("%s: %q appears twice", what, w)
+ }
+ seen[w] = true
+ }
+ }
+ check("labelNames", labelNames)
+ check("labelActions", labelActions)
+ var codes []string
+ for code, theme := range nameThemes {
+ codes = append(codes, code)
+ check(code+" names", theme.names)
+ check(code+" verbs", theme.verbs)
+ }
+ sort.Strings(codes)
+ if got, want := codes, []string{"au", "ie", "uk", "us"}; len(got) != len(want) || got[0] != want[0] || got[1] != want[1] || got[2] != want[2] || got[3] != want[3] {
+ t.Errorf("themed regions = %v, want %v", got, want)
+ }
+}
+
+// TestBuildFleetCopiesName: a named report's name reaches fleet.json, and a
+// report from a release that never wrote one (the old shape) still loads
+// and publishes no name key at all.
+func TestBuildFleetCopiesName(t *testing.T) {
+ ctx := context.Background()
+ s := release.NewDirStore(t.TempDir())
+ now := time.Now()
+ named := Box{GeneratedAt: now, Label: "dennis-stenciling", Name: "seamus-minding-ie"}
+ if err := WriteBox(ctx, s, named); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := s.Put(ctx, "status/boxes/ada-stargazing.json",
+ []byte(`{"generated_at":"`+now.UTC().Format(time.RFC3339)+`","label":"ada-stargazing","routes":{}}`), ""); err != nil {
+ t.Fatal(err)
+ }
+ f, err := BuildFleet(ctx, s, nil, now, SnapshotPeriod)
+ if err != nil {
+ t.Fatal(err)
+ }
+ got := map[string]string{}
+ for _, b := range f.Boxes {
+ got[b.Label] = b.Name
+ }
+ if got["dennis-stenciling"] != "seamus-minding-ie" || got["ada-stargazing"] != "" || len(got) != 2 {
+ t.Fatalf("fleet names = %v", got)
+ }
+ j, err := json.Marshal(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var wire struct {
+ Boxes []map[string]json.RawMessage `json:"boxes"`
+ }
+ if err := json.Unmarshal(j, &wire); err != nil {
+ t.Fatal(err)
+ }
+ for _, b := range wire.Boxes {
+ _, has := b["name"]
+ if label := string(b["label"]); label == `"ada-stargazing"` && has {
+ t.Errorf("an unnamed box published a name key: %s", j)
+ }
+ }
+}
+
+// TestCollectBoxIgnoresNameRegion: naming happens in the host once the
+// label is final (fleet and group overrides applied), never in CollectBox,
+// whose label may still be about to change.
+func TestCollectBoxIgnoresNameRegion(t *testing.T) {
+ b := CollectBox(nil, Probes{MachineID: "m", NameRegion: "ie"}, time.Now())
+ if b.Name != "" {
+ t.Errorf("CollectBox set Name %q", b.Name)
+ }
+}
diff --git a/internal/status/fleet.go b/internal/status/fleet.go
index dc0d51031..03b2afaea 100644
--- a/internal/status/fleet.go
+++ b/internal/status/fleet.go
@@ -30,6 +30,7 @@ type FleetApp struct {
// against.
type FleetBox struct {
Label string `json:"label"`
+ Name string `json:"name,omitempty"` // Box.Name, display only
Region string `json:"region,omitempty"`
Load *string `json:"load"`
Stale bool `json:"stale"`
@@ -171,6 +172,7 @@ func BuildFleet(ctx context.Context, s release.Store, routes []registry.Route, n
stale[i] = BoxStale(b, now, period)
f.Boxes = append(f.Boxes, FleetBox{
Label: b.Label,
+ Name: b.Name,
Region: b.Region,
Load: b.Load,
Stale: stale[i],
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 4dd9ef44a..b68a3e4fa 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -57,7 +57,11 @@ type Probes struct {
// or "" for hardware no cloud owns. It is the console architecture
// page's join key — see BoxMetrics.InstanceID.
InstanceID string
- Region string // operator-set, coarse; "" omits the field
+ Region string // operator-set, coarse; "" omits the field
+ // NameRegion is the validated STATUS_NAME_REGION code, or "". Never
+ // serialized, and CollectBox ignores it: the host derives Box.Name from
+ // it after the label is final (fleet and group overrides applied).
+ NameRegion string
MemFrac *float64 // 0..1 memory utilization
DiskFrac *float64 // 0..1 proximity to the disk floor
Listening func(sock string) *bool // kernel socket table read; nil fn = unknown
@@ -721,8 +725,12 @@ type Replication struct {
// the package doc) and excluded from FleetBox by construction (fleet.go's
// BuildFleet copies fields one at a time and never names either).
type Box struct {
- GeneratedAt time.Time `json:"generated_at"`
- Label string `json:"label"`
+ GeneratedAt time.Time `json:"generated_at"`
+ Label string `json:"label"`
+ // Name is the regional display name (DisplayName), stamped by the
+ // host once Label is final; "" omits the key. Display only: nothing
+ // keys on it.
+ Name string `json:"name,omitempty"`
Region string `json:"region,omitempty"`
Routes RouteCounts `json:"routes"`
Load *string `json:"load"` // comfortable|busy|critical