test: hold the approved fleet record label copy in the code
TestFleetRecordLabelsApprovedCopyApplied checks every approved C key's exact text with checkRunApplied, in each file that carries its marker, and requires C40 and C41, restoring the applied-text coverage SR-4-C95/C96 had. The marker test accepts the approved marker, and the label and checkpoint tests assert Luna's text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+205
−19
approved_fleet_record_labels_copy_test.go+183 −0approved_stateless_replicas_copy_test.go+2 −2instances_cli_label_test.go+9 −9instances_label_copy_keys_test.go+9 −6internal/activator/pendingwake_linux_test.go+2 −2
CI failed — run details
Intent
Attributed to this commit: 25.5 g CO₂e (3,171,386 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/approved_fleet_record_labels_copy_test.go b/approved_fleet_record_labels_copy_test.go| new file mode 100644 |
| index 000000000..9f9a684e7 |
| --- /dev/null |
| +++ b/approved_fleet_record_labels_copy_test.go |
| @@ -0,0 +1,183 @@ |
| +package main |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + "regexp" |
| + "sort" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// The fleet record labels deck (#1008 option B). Luna reviewed it on |
| +// 2026-11-14 by Paul's delegation, so every C key is approved and its text |
| +// must be in the code. The docs.* entries wait for Paul's own review and |
| +// are not checked here. |
| +const fleetRecordLabelsCopyDeck = "docs/drafts/fleet-record-labels/strings.json" |
| + |
| +const fleetRecordLabelsApproved = "approved (Luna, by Paul's delegation)" |
| + |
| +// fleetRecordLabelsNotInDeck is every C key the deck leaves out on purpose: |
| +// C46, the console's copy of C31's reasons, held word for word to C31 by |
| +// TestInstancesLabelConsoleReasonsMatchTheCLI. |
| +var fleetRecordLabelsNotInDeck = []string{"C46"} |
| + |
| +// fleetRecordLabelsMustCover are keys whose applied-text coverage this test |
| +// exists to keep: C40 and C41 replaced the guard's refusals SR-4-C96 and |
| +// SR-4-C95, which left the stateless replicas built list. |
| +var fleetRecordLabelsMustCover = []string{"C40", "C41"} |
| + |
| +type fleetRecordLabelsEntry struct { |
| + ID string `json:"id"` |
| + Text string `json:"text"` |
| + Status string `json:"status"` |
| +} |
| + |
| +func fleetRecordLabelsDeck(t *testing.T) []fleetRecordLabelsEntry { |
| + t.Helper() |
| + raw, err := os.ReadFile(fleetRecordLabelsCopyDeck) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var deck []fleetRecordLabelsEntry |
| + if err := json.Unmarshal(raw, &deck); err != nil { |
| + t.Fatal(err) |
| + } |
| + return deck |
| +} |
| + |
| +// fleetRecordLabelsLogPrefix is the prefix the code puts before a box log |
| +// line's deck text (the deck's notes say "the log adds ..."). The check |
| +// holds the whole line, prefix and text, so the text cannot drift. |
| +var fleetRecordLabelsLogPrefix = map[string]string{ |
| + "C44": "activator: ", |
| + "C45": "activator: ERROR: ", |
| +} |
| + |
| +// fleetRecordLabelsKey is an entry's C key: C38.door and C31.unit are forms |
| +// of C38 and C31, marked under the bare key. |
| +var fleetRecordLabelsKey = regexp.MustCompile(`^(C[0-9]{2})(\.[a-z_]+)?$`) |
| + |
| +// fleetRecordLabelsRows returns the deck's C entries, each with the files |
| +// that carry its key's marker. It fails the test if a C key is missing from |
| +// the deck, named twice, or not approved. |
| +func fleetRecordLabelsRows(t *testing.T) (entries []fleetRecordLabelsEntry, files map[string][]string) { |
| + t.Helper() |
| + marks := instancesLabelCopyMarks(t, ".") |
| + files = map[string][]string{} |
| + seen := map[string]bool{} |
| + for _, e := range fleetRecordLabelsDeck(t) { |
| + m := fleetRecordLabelsKey.FindStringSubmatch(e.ID) |
| + if m == nil { |
| + if !strings.HasPrefix(e.ID, "docs.") { |
| + t.Errorf("%s: not a C key or a docs entry", e.ID) |
| + } |
| + continue |
| + } |
| + if seen[e.ID] { |
| + t.Errorf("%s is in the deck twice", e.ID) |
| + } |
| + seen[e.ID], seen[m[1]] = true, true |
| + if e.Status != fleetRecordLabelsApproved { |
| + t.Errorf("%s: status %q, want %q", e.ID, e.Status, fleetRecordLabelsApproved) |
| + } |
| + if p, ok := fleetRecordLabelsLogPrefix[e.ID]; ok { |
| + e.Text = p + e.Text |
| + } |
| + entries = append(entries, e) |
| + if _, done := files[m[1]]; done { |
| + continue |
| + } |
| + set := map[string]bool{} |
| + for _, line := range marks[m[1]] { |
| + path, _, _ := strings.Cut(line, ":") |
| + set[path] = true |
| + } |
| + for p := range set { |
| + files[m[1]] = append(files[m[1]], p) |
| + } |
| + sort.Strings(files[m[1]]) |
| + if len(files[m[1]]) == 0 { |
| + t.Errorf("%s: no marker in the code", m[1]) |
| + } |
| + } |
| + for _, k := range instancesLabelCopyKeys { |
| + left := false |
| + for _, n := range fleetRecordLabelsNotInDeck { |
| + left = left || n == k |
| + } |
| + if !left && !seen[k] { |
| + t.Errorf("%s has no entry in %s", k, fleetRecordLabelsCopyDeck) |
| + } |
| + } |
| + return entries, files |
| +} |
| + |
| +// TestFleetRecordLabelsApprovedCopyApplied holds the approved text in the |
| +// code with the shared applied-text check (checkRunApplied): every C entry's |
| +// exact text is spoken by a string expression in a file that carries its |
| +// key's marker, and every such file speaks one of its key's entries, so a |
| +// marker cannot sit on text that drifted. |
| +func TestFleetRecordLabelsApprovedCopyApplied(t *testing.T) { |
| + entries, files := fleetRecordLabelsRows(t) |
| + byFile := map[string]bool{} // key + "\x00" + file, spoken there |
| + covered := map[string]bool{} |
| + var problems []string |
| + for _, e := range entries { |
| + key := fleetRecordLabelsKey.FindStringSubmatch(e.ID)[1] |
| + var misses []string |
| + for _, f := range files[key] { |
| + got := checkRunApplied([]copyRow{{ID: e.ID, File: f, Text: e.Text, Status: "approved"}}, ".") |
| + if len(got) == 0 { |
| + byFile[key+"\x00"+f] = true |
| + covered[e.ID] = true |
| + } |
| + misses = append(misses, got...) |
| + } |
| + if !covered[e.ID] { |
| + problems = append(problems, misses...) |
| + } |
| + } |
| + for key, fs := range files { |
| + for _, f := range fs { |
| + if !byFile[key+"\x00"+f] { |
| + problems = append(problems, key+": "+f+" carries the marker but speaks none of its approved text") |
| + } |
| + } |
| + } |
| + for _, k := range fleetRecordLabelsMustCover { |
| + if !covered[k] { |
| + problems = append(problems, k+": no applied-text coverage") |
| + } |
| + } |
| + sort.Strings(problems) |
| + reportAll(t, problems) |
| +} |
| + |
| +// Every C key carries the approved marker, not the draft one, once the |
| +// deck says it is approved. |
| +func TestFleetRecordLabelsApprovedMarkers(t *testing.T) { |
| + draft := regexp.MustCompile(`draft for copy review \(C[0-9]{2}\)`) |
| + for key, lines := range instancesLabelCopyMarks(t, ".") { |
| + for _, line := range lines { |
| + path, _, _ := strings.Cut(line, ":") |
| + raw, err := os.ReadFile(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if draft.Match(raw) { |
| + t.Errorf("%s: %s still has a draft marker", key, path) |
| + } |
| + } |
| + } |
| +} |
| + |
| +func TestFleetRecordLabelsCopyHasNoEmDash(t *testing.T) { |
| + raw, err := os.ReadFile(fleetRecordLabelsCopyDeck) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if strings.Contains(string(raw), "—") { |
| + t.Fatal("copy deck contains an em dash") |
| + } |
| +} |
diff --git a/approved_stateless_replicas_copy_test.go b/approved_stateless_replicas_copy_test.go| index 893cf75d5..d62dfd28a 100644 |
| --- a/approved_stateless_replicas_copy_test.go |
| +++ b/approved_stateless_replicas_copy_test.go |
| @@ -13,8 +13,8 @@ var statelessReplicaBuiltCopy = []string{"SR-2-C11", "SR-2-C01", "SR-2-C02", "SR |
| // SR-4-C95 and SR-4-C96 left the built list when fleet record labels |
| // replaced their text with C41 and C40, which point at carlos instances |
| -// label; those drafts are held by TestInstancesLabelCopyKeysPresent until |
| -// Paul's copy review. |
| +// label. Luna approved C40 and C41 by Paul's delegation (2026-11-14), and |
| +// TestFleetRecordLabelsApprovedCopyApplied holds their applied text. |
| func statelessReplicaCopyRows(t *testing.T) []copyRow { |
| t.Helper() |
diff --git a/instances_cli_label_test.go b/instances_cli_label_test.go| index 204d6631b..10a691bfd 100644 |
| --- a/instances_cli_label_test.go |
| +++ b/instances_cli_label_test.go |
| @@ -127,12 +127,12 @@ func TestInstancesLabelDryRunByDefault(t *testing.T) { |
| } |
| for _, want := range []string{ |
| "shop.example.com is not tied to a box of fleet pi", |
| - "last binding reported: box-1 (", |
| + "last report from box-1 (", |
| "the hub sends its requests to box-1", |
| "these agree: box-1 looks like the box serving it", |
| labelC13, |
| "box-1 can take it\n" + |
| - "if the report is wrong, tying it moves it: it stops on the box that runs it and starts on box-1 from its last saved copy\n" + |
| + "if the report is wrong, tying it moves the instance. it stops on the serving box and starts on box-1 from its last saved copy\n" + |
| "to tie it, run:\n" + |
| " carlos instances label --account bab --app shop shop.example.com --box box-1\n" + |
| labelC16 + "\n", |
| @@ -240,15 +240,15 @@ func TestInstancesLabelRefusalExitsNonZero(t *testing.T) { |
| {"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"}, |
| {"coordinated", refused("coordinated", map[string]any{"coordinator_box": "box-2"}), nil, |
| - "shop.example.com is coordinated by box-2 right now. try again in a few minutes"}, |
| + "shop.example.com is being handled by box-2 right now. try again in a few minutes"}, |
| {"not_active", refused("not_active", nil), nil, "box-1 is not an active box of fleet pi"}, |
| {"draining", refused("draining", nil), nil, "box-1 is draining. it cannot take an instance"}, |
| {"stale", refused("stale", nil), nil, "box-1 has not reported in recently"}, |
| {"runtime", refused("runtime", nil), nil, "box-1 cannot run this app's runtime yet"}, |
| {"floor: a box", refused("floor", map[string]any{"floor_box": "box-2", "floor_release": "v0.34.0", "floor": "v9.9.9"}), nil, |
| - "box-2 runs v0.34.0. tying instances to boxes needs v9.9.9 or later on the console and on every box of fleet pi"}, |
| + "box-2 runs v0.34.0. tying instances to boxes needs v9.9.9 or later on the console and every active box of fleet pi"}, |
| {"floor: the console", refused("floor", map[string]any{"floor_box": "console", "floor_release": "v0.34.0", "floor": "v9.9.9"}), nil, |
| - "the console runs v0.34.0. tying instances to boxes needs v9.9.9 or later on the console and on every box of fleet pi"}, |
| + "the console runs v0.34.0. tying instances to boxes needs v9.9.9 or later on the console and every active box of fleet pi"}, |
| {"not_serving", refused("not_serving", map[string]any{"box": "box-2"}), []string{"--box", "box-2"}, |
| "box-2 is not the box serving it now. only that box can be named for now"}, |
| {"disagree", refused("disagree", map[string]any{"hub_box": "box-2", "agree": false, "serving_box": "", "box": ""}), nil, |
| @@ -264,9 +264,9 @@ func TestInstancesLabelRefusalExitsNonZero(t *testing.T) { |
| {"unmovable:ha", refused("unmovable:ha", nil), nil, "shop.example.com cannot be tied to one box: it is a high availability instance"}, |
| {"unmovable:demo", refused("unmovable:demo", nil), nil, "shop.example.com cannot be tied to one box: it is a demo"}, |
| {"sidecars", refused("sidecars", nil), nil, "fleet pi has sidecars, so its instances cannot be tied to boxes yet"}, |
| - {"incomplete", refused("incomplete", nil), nil, "could not read the instance and its fleet, so it was not tied. try again"}, |
| + {"incomplete", refused("incomplete", nil), nil, "could not read the instance or its fleet, so it was not tied. try again"}, |
| {"changed", refused("changed", nil), write, "shop.example.com changed while it was being tied, so it was not tied. try again"}, |
| - {"mark_failed", refused("mark_failed", nil), write, "could not mark box-1 for this instance, so it was not tied. try again"}, |
| + {"mark_failed", refused("mark_failed", nil), write, "could not record that box-1 holds this instance, so it was not tied. try again"}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| stub := newLabelStub(t, http.StatusOK, labelAnswerJSON(t, tc.over)) |
| @@ -402,7 +402,7 @@ func TestInstancesLabelUnknownOutcome(t *testing.T) { |
| } |
| t.Run("a dry run's 502 is the console's own text", func(t *testing.T) { |
| - stub := newLabelStub(t, http.StatusBadGateway, `{"error":"could not read the instance and its fleet, so it was not tied. try again"}`) |
| + stub := newLabelStub(t, http.StatusBadGateway, `{"error":"could not read the instance or its fleet, so it was not tied. try again"}`) |
| out, ok := runLabelCLI(t, stub.ts.URL, "--app", "shop", "--account", "bab", "shop.example.com") |
| if ok || strings.Contains(out, labelC38) || !strings.Contains(out, "could not read the instance") { |
| t.Fatalf("want the console's text and a non-zero exit, got ok=%v:\n%s", ok, out) |
| @@ -497,7 +497,7 @@ func TestInstancesLabelNoEvidenceSaysItOnce(t *testing.T) { |
| over map[string]any |
| line string |
| }{ |
| - {map[string]any{"binding": nil}, "no box has reported a binding for it since it was created"}, |
| + {map[string]any{"binding": nil}, "no box has reported running it since it was created"}, |
| {map[string]any{"hub_box": ""}, "the hub has no box for it yet"}, |
| } { |
| over := map[string]any{"why_not": "no_evidence", "eligible": false, "agree": false, "serving_box": "", "box": ""} |
diff --git a/instances_label_copy_keys_test.go b/instances_label_copy_keys_test.go| index 3f83586ca..225ea50fe 100644 |
| --- a/instances_label_copy_keys_test.go |
| +++ b/instances_label_copy_keys_test.go |
| @@ -1,7 +1,9 @@ |
| // The fleet record labels copy keys (spec §9, and the keys the T7 UX pass |
| -// added) are held in the code by their markers until Paul's copy review: |
| -// every key must have at least one `// draft for copy review (Cnn)` in a Go |
| -// source file, so a string cannot lose its place in the deck unnoticed. |
| +// added) are held in the code by their markers: every key must have at least |
| +// one `// draft for copy review (Cnn)` or, once reviewed, |
| +// `// approved copy (Cnn), Luna review by Paul's delegation 2026-11-14` in a |
| +// Go source file, so a string cannot lose its place in the deck unnoticed. |
| +// The approved text itself is held by TestFleetRecordLabelsApprovedCopyApplied. |
| package main |
| import ( |
| @@ -24,7 +26,7 @@ var instancesLabelCopyKeys = func() []string { |
| return keys |
| }() |
| -var instancesLabelCopyMarker = regexp.MustCompile(`draft for copy review \((C[0-9]{2})\)`) |
| +var instancesLabelCopyMarker = regexp.MustCompile(`(?:draft for copy review \((C[0-9]{2})\)|approved copy \((C[0-9]{2})\), Luna review by Paul's delegation 2026-11-14)`) |
| // instancesLabelCopyMarks maps each key to the marked lines under root's Go |
| // sources, test files excluded. |
| @@ -57,7 +59,8 @@ func instancesLabelCopyMarks(t *testing.T, root string) map[string][]string { |
| if strings.HasPrefix(strings.TrimSpace(line), "//") && i+1 < len(lines) { |
| text = lines[i+1] |
| } |
| - marks[m[1]] = append(marks[m[1]], fmt.Sprintf("%s:%d: %s", path, i+1, strings.TrimSpace(text))) |
| + key := m[1] + m[2] // one of the two forms matched |
| + marks[key] = append(marks[key], fmt.Sprintf("%s:%d: %s", path, i+1, strings.TrimSpace(text))) |
| } |
| } |
| return nil |
| @@ -77,7 +80,7 @@ func TestInstancesLabelCopyKeysPresent(t *testing.T) { |
| } |
| } |
| if len(missing) > 0 { |
| - t.Fatalf("copy keys with no `draft for copy review (Cnn)` marker in the tree: %s", strings.Join(missing, ", ")) |
| + t.Fatalf("copy keys with no `draft for copy review (Cnn)` or `approved copy (Cnn), ...` marker in the tree: %s", strings.Join(missing, ", ")) |
| } |
| for key, lines := range marks { |
| for _, line := range lines { |
diff --git a/internal/activator/pendingwake_linux_test.go b/internal/activator/pendingwake_linux_test.go| index 51dd43b73..195551997 100644 |
| --- a/internal/activator/pendingwake_linux_test.go |
| +++ b/internal/activator/pendingwake_linux_test.go |
| @@ -1699,7 +1699,7 @@ func TestFleetStopWithLostLeaseFinishesUncleanWithoutRelease(t *testing.T) { |
| t.Fatalf("the stop finished clean (%+v); want replicaClosed false", outcome) |
| } |
| logged := r.log.String() |
| - if !strings.Contains(logged, "activator: ERROR: "+r.rt.Host+": its final checkpoint failed, so its lease is not released and frees at its expiry") { |
| + if !strings.Contains(logged, "activator: ERROR: "+r.rt.Host+": its final checkpoint failed. its lease stays held until it expires") { |
| t.Fatalf("no ERROR naming %s:\n%s", r.rt.Host, logged) |
| } |
| if strings.Contains(logged, c44Line) { |
| @@ -1709,7 +1709,7 @@ func TestFleetStopWithLostLeaseFinishesUncleanWithoutRelease(t *testing.T) { |
| // c45Text is the body of C45, the ERROR an abandoned fleet checkpoint |
| // logs, whatever its prefix. |
| -const c45Text = "its final checkpoint failed, so its lease is not released and frees at its expiry" |
| +const c45Text = "its final checkpoint failed. its lease stays held until it expires" |
| // holdCheckpointReturn holds the next fleet checkpoint's handling once its |
| // CloseProven has returned (Service.checkpointReturned): returned receives |