carlos / platform Public

console, cli: labelled_first for a competing label (M2 review P3-4)

The writer's ErrFleetBoxNotFirst answers why_not labelled_first, Label
naming the winner; labelled stays the early answer for a record tied
before the read. The CLI prints C34 for labelled_first and C20 or C07
for labelled, so the choice no longer depends on serving_box. Additive
wire change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ffcb5d59550b3e58d6d4328b5cf7896e0e2cd7cc parent c5483d6
4 files changed, +45 −34
  • instances_cli.go +10 −10
  • instances_cli_label_test.go +7 −1
  • internal/console/instancelabel.go +25 −20
  • internal/console/instancelabel_test.go +3 −3

Intent

Attributed to this commit: 13.4 g CO₂e (1,694,780 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fleet-record-labels-m2, 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/instances_cli.go b/instances_cli.go
index 8565f590d..1d71bc429 100644
--- a/instances_cli.go
+++ b/instances_cli.go
@@ -1477,14 +1477,13 @@ func renderInstanceLabel(w io.Writer, app, host string, write bool, via []string
fmt.Fprintf(w, labelTied+"\n", host, a.Label)
return nil
}
- if a.WhyNot == labelWhyLabelled {
- // The door answers labelled both for a record tied before it was
- // read (an early answer, with no evidence) and for a competing
- // label that won the write (judged, so it carries the evidence).
- switch {
- case write && a.ServingBox != "":
- return fmt.Errorf(labelCompetingWrite, host, a.Label)
- case a.Box != "" && a.Box != a.Label:
+ switch a.WhyNot {
+ case labelWhyLabelledFirst:
+ // A competing label won the write (C34); Label names it.
+ return fmt.Errorf(labelCompetingWrite, host, a.Label)
+ case labelWhyLabelled:
+ // The record was tied before the door read it.
+ if a.Box != "" && a.Box != a.Label {
return fmt.Errorf(labelAlreadyTied, host, a.Label)
}
fmt.Fprintf(w, labelNothingToDo+"\n", host, a.Label)
@@ -1531,8 +1530,9 @@ func renderInstanceLabel(w io.Writer, app, host string, write bool, via []string
// The door's why_not codes (internal/console/instancelabel.go), mirrored.
const (
- labelWhyLabelled = "labelled"
- labelWhyUnmovPfx = "unmovable:"
+ labelWhyLabelled = "labelled"
+ labelWhyLabelledFirst = "labelled_first"
+ labelWhyUnmovPfx = "unmovable:"
)
// labelEarlyRefusal is a code the door can answer from the record alone,
diff --git a/instances_cli_label_test.go b/instances_cli_label_test.go
index e3248b407..5b4d196fe 100644
--- a/instances_cli_label_test.go
+++ b/instances_cli_label_test.go
@@ -236,8 +236,14 @@ func TestInstancesLabelRefusalExitsNonZero(t *testing.T) {
{"not_fleet", withEarly("not_fleet", map[string]any{"fleet": ""}), nil, "shop.example.com is not on a fleet"},
{"labelled before the read", withEarly("labelled", map[string]any{"label": "box-2"}), write,
"shop.example.com is already tied to box-2. to move it, drain that box with carlos fleets drain"},
- {"labelled by a competing write", refused("labelled", map[string]any{"label": "box-2"}), write,
+ {"labelled by a competing write", refused("labelled_first", map[string]any{"label": "box-2"}), write,
"another change tied shop.example.com to box-2 first. nothing more changed"},
+ {"labelled_first naming the same box", refused("labelled_first", map[string]any{"label": "box-1"}), write,
+ "another change tied shop.example.com to box-1 first. nothing more changed"},
+ // M2 review P3-4: labelled is C20 whatever serving_box says; only
+ // labelled_first is C34.
+ {"labelled with evidence", refused("labelled", map[string]any{"label": "box-2"}), write,
+ "shop.example.com is already tied to box-2. to move it, drain that box with carlos fleets drain"},
{"assigned", withEarly("assigned", nil), nil, "shop.example.com runs as copies, so placement chooses its boxes"},
{"move", withEarly("move", nil), nil, "shop.example.com has a move in progress. finish it before tying it to a box"},
{"import", withEarly("import", nil), nil, "shop.example.com has an import in progress. finish it before tying it to a box"},
diff --git a/internal/console/instancelabel.go b/internal/console/instancelabel.go
index 38c9c9bfa..00de62983 100644
--- a/internal/console/instancelabel.go
+++ b/internal/console/instancelabel.go
@@ -78,25 +78,30 @@ type instanceLabelAnswer struct {
// The door's why_not codes, each one copy key in the CLI (plan T5/T7).
const (
- labelWhyNotFleet = "not_fleet"
- labelWhyLabelled = "labelled"
- labelWhyAssigned = "assigned"
- labelWhyMove = "move"
- labelWhyImport = "import"
- labelWhyCoordinated = "coordinated"
- labelWhyNotActive = "not_active"
- labelWhyDraining = "draining"
- labelWhyStale = "stale"
- labelWhyRuntime = "runtime"
- labelWhyFloor = "floor"
- labelWhyNotServing = "not_serving"
- labelWhyDisagree = "disagree"
- labelWhyNoEvidence = "no_evidence"
- labelWhyUnmovable = "unmovable:" // + static, addr, always_on, unit, ha or demo
- labelWhySidecars = "sidecars"
- labelWhyIncomplete = "incomplete"
- labelWhyChanged = "changed"
- labelWhyMarkFailed = "mark_failed"
+ labelWhyNotFleet = "not_fleet"
+ labelWhyLabelled = "labelled"
+ // labelWhyLabelledFirst is the writer's ErrFleetBoxNotFirst: a
+ // competing label won the write (C34), and Label names it. labelled
+ // stays the early answer for a record tied before it was read (M2
+ // review P3-4).
+ labelWhyLabelledFirst = "labelled_first"
+ labelWhyAssigned = "assigned"
+ labelWhyMove = "move"
+ labelWhyImport = "import"
+ labelWhyCoordinated = "coordinated"
+ labelWhyNotActive = "not_active"
+ labelWhyDraining = "draining"
+ labelWhyStale = "stale"
+ labelWhyRuntime = "runtime"
+ labelWhyFloor = "floor"
+ labelWhyNotServing = "not_serving"
+ labelWhyDisagree = "disagree"
+ labelWhyNoEvidence = "no_evidence"
+ labelWhyUnmovable = "unmovable:" // + static, addr, always_on, unit, ha or demo
+ labelWhySidecars = "sidecars"
+ labelWhyIncomplete = "incomplete"
+ labelWhyChanged = "changed"
+ labelWhyMarkFailed = "mark_failed"
)
// labelOwnerPurpose completes apiOwnerAccountFor's 403: "only an account
@@ -250,7 +255,7 @@ func (s *Server) handleAPIInstanceLabel(w http.ResponseWriter, r *http.Request)
out, err := provision.SetRecordFirstFleetBox(ctx, s.cfg.Releases, acct.Sqid, app, host, want, ans.Box, time.Now())
switch {
case errors.Is(err, provision.ErrFleetBoxNotFirst):
- refuseLabel(&ans, labelWhyLabelled) // C34: another change tied it first
+ refuseLabel(&ans, labelWhyLabelledFirst) // C34: another change tied it first
if out != nil {
ans.Label = out.FleetBox
}
diff --git a/internal/console/instancelabel_test.go b/internal/console/instancelabel_test.go
index 904db5b3b..06f24ad24 100644
--- a/internal/console/instancelabel_test.go
+++ b/internal/console/instancelabel_test.go
@@ -621,7 +621,7 @@ func labelPostAsync(fx *consoleFixture, token, box string) (instanceLabelAnswer,
// Two owners' requests both read the unlabelled record before either takes
// the fleet's lock (a barrier holds each after its read until both have
// read). One label is written; the other request is refused by the writer
-// and names the label that won (C34).
+// with labelled_first and names the label that won (C34; M2 review P3-4).
func TestLabelDoorConcurrentLabels(t *testing.T) {
fx, token, reg, created := labelWorld(t, "code-ld-concurrent", "pi-1", "pi-2")
servingEvidence(t, fx, reg, created, "pi-1")
@@ -665,12 +665,12 @@ func TestLabelDoorConcurrentLabels(t *testing.T) {
switch {
case a.Applied && a.Label == "pi-1":
applied++
- case !a.Applied && a.WhyNot == "labelled" && a.Label == "pi-1":
+ case !a.Applied && a.WhyNot == "labelled_first" && a.Label == "pi-1":
lost++
}
}
if applied != 1 || lost != 1 {
- t.Fatalf("answers %+v; want one applied and one labelled naming pi-1", answers)
+ t.Fatalf("answers %+v; want one applied and one labelled_first naming pi-1", answers)
}
if r := shopRec(t, fx, labelHost); r.FleetBox != "pi-1" || !r.FleetBoxMoved {
t.Fatalf("record %+v; want labelled pi-1", r)