carlos / platform Public

regional box labels: design draft

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev efa39ca7c836c1517303064b8cb5a1b956773a5f parent 4a9a47c
1 file changed, +333 −0
  • docs/superpowers/specs/2026-10-25-regional-box-labels-design.md +333 −0
diff --git a/docs/superpowers/specs/2026-10-25-regional-box-labels-design.md b/docs/superpowers/specs/2026-10-25-regional-box-labels-design.md
new file mode 100644
index 000000000..d5abd94ae
--- /dev/null
+++ b/docs/superpowers/specs/2026-10-25-regional-box-labels-design.md
@@ -0,0 +1,333 @@
+# Regional box labels
+
+Status: draft, awaiting Paul's approval. Branch `design-regional-box-labels`.
+
+## Intent
+
+Every box that runs `carlos agent` gets a public pseudonym from
+`status.Label(machineID)` (`internal/status/snapshot.go`): a first name and a
+gerund, `dennis-stenciling`. Both halves come from one global pair of
+40-word lists, so a name tells you nothing about where the box is.
+
+Paul wants the name to say where the box is and to sound like it belongs
+there:
+
+ seamus-ploughing-ie
+ martin-queueing-uk
+
+Three asks, all his:
+
+1. The region goes in the name, as a suffix.
+2. The first name is a typical name for that region.
+3. The verb is both a host's job (minding, carrying, serving, routing,
+ holding, watching) and a typical activity in that region.
+
+Why: an operator reading the status page, a log line or an alert can tell
+at a glance which region a box is in, and the names are more fun. Today
+that takes a lookup against `STATUS_BOX_REGION`.
+
+## Goals
+
+- `name-verb-region` labels for boxes whose operator opts in.
+- Themed word lists for every region the flagship runs today: `ie`, `uk`,
+ `us`, `au`.
+- A region code with no themed lists still gets the suffix, on top of
+ today's global lists.
+- One place resolves a box's label, so the status snapshot, the log, error
+ and analytics feeds and the metrics fallback all agree.
+
+## Non-goals
+
+- Fleet boxes. They publish under the label their operator picked
+ (`internal/host/fleetidentity.go`) and never under `status.Label`. That
+ stays exactly as it is.
+- Detecting two boxes with the same label. No such guard exists today.
+ This change makes a clash less likely (see Collisions) and adds nothing
+ more.
+- Different verbs for different kinds of box (edge, scanner, app host).
+ Only app hosts publish under this label today, and a verb per kind of box
+ would put each box's role on the public page.
+- Renaming anything that isn't `status.Label`: AWS `Name` tags, hostnames,
+ tofu resource names, the operator-picked fleet labels.
+
+## Anti-goals
+
+These would make it a failure even if it worked:
+
+- **A box renamed by an upgrade.** A box with no label region must produce
+ byte-for-byte the label it produces today. Renaming changes the status
+ object key and the feed source name, so it only ever happens when an
+ operator chose it.
+- **A machine id that can be recovered from the label.** The sha256
+ derivation stays.
+- **Names that read as a caricature of a place.** "Typical" means names
+ people there actually have, across ages, not a joke accent. The lists go
+ through copy review before they ship.
+- **Tenant names, team names or famous people.** No `tito`, `paul` or
+ `bill`. Neutral common names only.
+- **A region the status page doesn't already show.** See Privacy.
+
+## Constraints found in the code
+
+- **The label is a stable key.** It names `status/boxes/<label>.json`
+ (`snapshot.go`, `WriteBox`), it is the `Box` field on every log and error
+ record (`internal/applog/sink.go`, `internal/apperr/sink.go`), and it is a
+ path segment in analytics day files,
+ `analytics/.../<app>/<box>/days/<date>.json`
+ (`internal/analytics/day.go`, `BoxPrefix`).
+- **The status page never forgets a box.** `BuildFleet`
+ (`internal/status/fleet.go`) lists every `status/boxes/*.json` and marks
+ old ones `Stale`. It never drops them. A renamed box shows up twice, once
+ as a stale box, until someone deletes its old key.
+- **Seven call sites compute the label.** `status.Label(readMachineID())`
+ appears in `internal/host/agent.go` for the log sink, error sink, log
+ shipper, error shipper and analytics meter (around lines 244, 245, 465,
+ 468 and 531). `metricsBoxLabel` (`internal/host/metrics_loop.go`) falls
+ back to it. `CollectBox` (`snapshot.go`) stamps it on the snapshot. They
+ must all use the same region, or the same box goes by two names.
+- **There is no region code on the home box.** `CARLOS_REGION` is the
+ placement code (`us`, `uk`, `au`), but the flagship's IE box leaves it
+ unset on purpose: unset means "serves ""-scoped records". Setting
+ `CARLOS_REGION=ie` there would change placement, so the label can't
+ borrow it.
+- **`STATUS_BOX_REGION` is free text** (`"UK · London"`, `"AU · Sydney"`).
+ It's for display, and parsing a code out of it would be fragile.
+- **The platform is general-purpose.** carloku.com is one deployment. Which
+ box is in which region is deployment configuration
+ (`carloku-infrastructure`, `platform-infrastructure` for dev), never
+ platform code. The platform can ship themed lists keyed by region code,
+ as long as any deployment can use them and nothing assumes carloku's
+ regions.
+
+## Design
+
+### The input: `STATUS_LABEL_REGION`
+
+There's a new agent environment variable, `STATUS_LABEL_REGION`. It sits
+next to `STATUS_BOX_REGION` because it is a status-page setting, not a
+placement setting.
+
+- Unset or empty: the label is exactly today's `name-verb`, from the global
+ lists. Nothing changes on upgrade.
+- Set to a valid code: the label is `name-verb-<code>`.
+- Set to something invalid: log once at startup, naming the variable and
+ the value, and fall back to the unset behaviour. This follows the agent's
+ existing degrade-don't-disable rule for status identity
+ (`metricsBoxLabel`, the status loop).
+
+A valid code is 2 to 8 lowercase ASCII letters, `^[a-z]{2,8}$`. That covers
+every CARLOS placement code in use and keeps the label safe as an object key
+segment and a path segment. It must not contain `-`, the label's separator.
+If `registry` already has a placement-code validator with the same or a
+tighter grammar, the builder should use that one instead.
+
+It is an opt-in, not a default taken from `CARLOS_REGION`. Defaulting would
+rename every non-home box on upgrade (anti-goal 1) and would leave the home
+box out anyway.
+
+### Word lists
+
+Each themed region gets a name list and a verb list. Both are fixed-size Go
+arrays in `internal/status`, next to today's `labelNames` and
+`labelActions`, so the label space stays easy to audit.
+
+Rules for every list:
+
+- Exactly 40 entries. That keeps 1,600 labels per region, the same as
+ today's global space, and keeps the existing uint32 index-bias reasoning
+ unchanged.
+- Lowercase ASCII letters only, no hyphens or spaces. Irish fadas are
+ dropped (`siobhan`, `padraig`). Compound activities run together
+ (`narrowboating`, `lockkeeping`).
+- No duplicates within a list. The same word can appear in two regions,
+ because the suffix tells them apart.
+- Verbs are gerunds. Each one should work as a host's job and as something
+ people do in that region. Where a word can't manage both, the regional
+ pastime wins.
+- Local spelling: `signalling` in uk and au, `barbecuing` in us.
+
+Lookup is `themes[code]`. A code with no entry uses today's global lists
+plus the suffix (`ada-stargazing-de`). Adding a region later is one map
+entry and two arrays, with no other code change.
+
+### Derivation
+
+`Label` keeps its algorithm: `sha256(machineID)`, name index from bytes
+0-3, verb index from bytes 4-7, each `uint32 % 40`. Only the lists it
+indexes into change, plus the suffix.
+
+So the unset case has to stay identical. Today's test
+(`internal/status/status_test.go`) only checks that a label is stable, not
+what it is. Before changing anything, the builder captures today's output
+for a handful of ids as golden values, and those must pass unchanged
+afterwards.
+
+The builder decides the signature. Two obvious ones are
+`Label(machineID, region string)` with every caller updated, or a new
+`RegionalLabel` beside an unchanged `Label`. Either way there must be one
+resolver in `internal/host`, for example `boxLabel(getenv, machineID)`.
+It reads `STATUS_LABEL_REGION` once, and all seven call sites go through
+it. `metricsBoxLabel` and the exported `BoxLabel` that the relay uses fall
+back to it instead of calling `status.Label` directly.
+
+The doc comment on `Label` currently says the label "give[s] away nothing
+about the machine". It needs rewriting to say the label can now carry the
+operator-set region code, and nothing else.
+
+### Privacy
+
+Today's label is public and has to stay safe to publish.
+
+- The machine id still goes through sha256. The region code is an operator
+ setting, not something derived from the machine.
+- On the flagship, every box's `STATUS_BOX_REGION` already says its region
+ in words next to the label in `fleet.json`, so the code adds nothing new.
+- An operator who sets `STATUS_LABEL_REGION` but not `STATUS_BOX_REGION`
+ publishes a region they weren't publishing before. That's their choice,
+ and the README entry for the variable says so in plain words.
+
+### Collisions
+
+Two boxes with the same label overwrite each other's status object. With
+the suffix, boxes in different regions can never clash. Within a region
+the space is 1,600 labels, the same as today's whole fleet. That's no worse
+for any region and better overall. Nothing more is in scope.
+
+### Rollout (operator steps, per box)
+
+A label change is a rename, so it happens one box at a time and on purpose:
+
+1. Set `STATUS_LABEL_REGION=<code>` in the box's `host.env`. For the
+ flagship this goes through `scripts/bootstrap-box.sh` in
+ `carloku-infrastructure`, which gains an argument the same way
+ `STATUS_BOX_REGION` did. It's a separate change in that repo, plus the
+ dev root in `platform-infrastructure`. Don't hand-edit user_data: a
+ user_data change restarts the instance.
+2. Restart the agent through the normal path (`update-platform-binary.sh`
+ or `carlos system apply`, whichever the release in use calls for).
+3. Wait for `status/boxes/<new>.json` to appear, then delete
+ `status/boxes/<old>.json` so the status page stops showing a stale
+ twin. The old label is the box's current one, which is in `fleet.json`
+ before the change.
+4. Roll order stays dev boxes, dev console, check, flagship boxes,
+ flagship console. The console doesn't compute labels, so the console
+ steps are only the usual check.
+
+What the rename leaves behind, by design:
+
+- Log and error records before the switch carry the old `Box` value, and
+ records after it carry the new one.
+- Analytics for the day of the switch is split across two box
+ directories. That's fine: `ReadRange` (`internal/analytics/read.go`)
+ already lists every box directory for an app and merges them per day,
+ summing counters and unioning visitor sketches, because instances move
+ between boxes anyway.
+
+The agent doesn't delete the old status key itself. That would need a
+`DeleteObject` grant the box role may not have, and an id-less label
+clash could delete another box's live snapshot. Four flagship boxes and a
+few dev boxes is a handful of `aws s3 rm` commands. *(Claude's call.)*
+
+## Starter word lists
+
+These are a first draft for copy review (a Luna pass on Paul's house
+rules). They aren't final.
+
+### ie
+
+Names: 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: 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: 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: 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: hank, betty, earl, peggy, chuck, dolores, randy, 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: 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, quarterbacking, cheerleading, flyfishing, rafting, camping,
+surfing, skateboarding, carving, trailblazing.
+
+### au
+
+Names: bruce, sheila, shane, kylie, brett, tracey, wayne, narelle, craig,
+leanne, scott, kerry, glenn, raelene, troy, bronwyn, mick, nathan, chloe,
+lachlan, matilda, isla, kane, jacinta, jarrah, banjo, tahlia, cooper,
+ruby, brodie, belinda, dean, darcy, mitchell, harley, tegan, clancy, lily,
+mackenzie, ella.
+
+Verbs: mustering, droving, shearing, jackarooing, boundaryriding, fencing,
+lifesaving, patrolling, shouting, barbecuing, roadtraining, ferrying,
+surfing, bodyboarding, snorkelling, sailing, yabbying, crabbing,
+rockpooling, fossicking, prospecting, bushwalking, camping, caravanning,
+stargazing, beachcombing, skimboarding, tipping, bowling, brewing,
+pouring, busking, yachting, rowing, diving, birdwatching, swimming,
+fishing, kayaking, gardening.
+
+The au lists stay away from Aboriginal and Torres Strait Islander cultural
+practices on purpose. They aren't ours to make into hostnames.
+
+## Tests the builder owes
+
+- Unset `STATUS_LABEL_REGION`: `Label` output is byte-identical to the
+ golden values captured from today's code.
+- For each themed region: the label is stable for a given id, has the shape
+ `^[a-z]+-[a-z]+-<code>$`, and uses that region's lists.
+- An unthemed valid code: global lists plus the suffix.
+- An invalid code (`UK`, `u-k`, `ireland1`, a nine-letter code): falls back
+ to the unset label and logs once.
+- List hygiene, checked in a test rather than by eye: each list has 40
+ entries, all `^[a-z]+$`, none duplicated within the list.
+- One resolver, wired for real: a test drives the production wiring
+ (following the production-wired-witness rule) and shows that the snapshot
+ label, the log sink's box, the error sink's box, the analytics meter's
+ box and `metricsBoxLabel`'s fallback are the same string for a box with
+ `STATUS_LABEL_REGION` set.
+- Fleet boxes: with `CARLOS_FLEET` set, `STATUS_LABEL_REGION` has no
+ effect.
+
+## Docs the builder owes
+
+- README: a `STATUS_LABEL_REGION` entry next to `STATUS_BOX_REGION`. It
+ covers what it does, that setting it renames the box, that the code is
+ public, and the delete-the-old-key step.
+- The `Label` doc comment, as above.
+
+## Left to the builder
+
+- `Label`'s signature, and where the resolver lives in `internal/host`.
+- Whether to reuse a `registry` placement-code validator.
+- The exact log line for an invalid code. It goes through copy review with
+ the word lists.