grouproll: drain list only from a marked, well-formed floor row
Astra r3 F3.1/F3.2, cut ruled by 8a3d302. The floor row gains "population": "all-files-v1". drainPeers refuses a row without that marker (floor_legacy): an older tool's live list skipped quiet boxes, so a resumed transaction is ended, never drained, and the floor is not re- run or migrated. It also refuses a live that is absent, null, not an array, or has a bad or duplicate reference (floor_population); an empty list is only an actual empty array or one holding just the member. Witness: the old row (no marker, a six-hour-old adi left out), a cut right after the durable floor event, then resume: refused, no drain session intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/grouproll/depart.go+16 −3internal/grouproll/depart_test.go+112 −0internal/grouproll/floor.go+7 −1internal/grouproll/text.go+2 −0internal/grouproll/text_test.go+4 −4
Intent
<task-notification> <task-id>bpoq7vjsj</task-id> <tool-use-id>toolu_01BmRBWi6ZEQDcS8DfcuRZDK</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a99cbe46-f458-4f72-8b8a-294aae9cdf21/tasks/bpoq7vjsj.output</output-file> <status>completed</status> <summary>Background command "Run held suite and the Go guard" completed (exit code 0)</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="c539b1a6-0845-4eb6-9345-ae8597416f93"> Agent manager 8a3d302: ruled cut, no step-back. The core population fix is confirmed closed, and F3.1 is a legacy-journal migration edge whose fix is to refuse up front. Build exactly (a) refuse to drain from a floor row without the new provenance marker (a legacy row is closed or cancelled by the operator, never resumed into a drain), and (b) the journal's peer list must be a present array of valid refs, else refuse. Tests for both, including a legacy row written by the old verb and resumed by the new one. No 4th Astra round: get a Fable 5.2 spot-check of just those two hunks plus their tests via the claude CLI (claude -p --model claude-fable-5-2, read-only, the diff and the R3 findings in the prompt). If Fable finds no P1 and CI is green (re-run the #359 job), merge under the standing approval and send me the SHA. If Fable finds a P1, stop and tell me. </paseo-system>
diff --git a/internal/grouproll/depart.go b/internal/grouproll/depart.go| index d6e11179c..9536191cf 100644 |
| --- a/internal/grouproll/depart.go |
| +++ b/internal/grouproll/depart.go |
| @@ -343,14 +343,27 @@ func (e *Engine) drainPeers() ([]string, error) { |
| if !ok || row["rule"] != "drain" { |
| return nil, refuse("record") |
| } |
| + // A row without this build's marker is an older tool's (Astra r3 |
| + // F3.1): its live list skipped quiet boxes. It is never the population; |
| + // the transaction is closed, not resumed into a drain. |
| + if row["population"] != floorPopulation { |
| + return nil, refuse("floor_legacy") |
| + } |
| + // live must be a present array of valid, distinct references (F3.2): |
| + // missing evidence never means "no peers". |
| + live, ok := row["live"].([]any) |
| + if !ok { |
| + return nil, refuse("floor_population") |
| + } |
| self, _ := e.hIdentity()["box_ref"].(string) |
| - live, _ := row["live"].([]any) |
| peers := []string{} |
| + seen := map[string]bool{} |
| for _, v := range live { |
| s, ok := v.(string) |
| - if !ok { |
| - return nil, refuse("record") |
| + if !ok || !boxRef.MatchString(s) || seen[s] { |
| + return nil, refuse("floor_population") |
| } |
| + seen[s] = true |
| if s != self { |
| peers = append(peers, s) |
| } |
diff --git a/internal/grouproll/depart_test.go b/internal/grouproll/depart_test.go| index 3cb52d4e6..48f52e1f2 100644 |
| --- a/internal/grouproll/depart_test.go |
| +++ b/internal/grouproll/depart_test.go |
| @@ -7,6 +7,7 @@ import ( |
| "fmt" |
| "math" |
| "reflect" |
| + "slices" |
| "sort" |
| "strings" |
| "testing" |
| @@ -1200,6 +1201,117 @@ func TestDepartDrainNamesTheFloorPopulation(t *testing.T) { |
| } |
| } |
| +// drainPeersFrom journals one floor row and builds the drain list from it, |
| +// as a resumed transaction would. |
| +func drainPeersFrom(t *testing.T, row map[string]any) ([]string, error) { |
| + t.Helper() |
| + h := newHeldHarness(t, 2, nil) |
| + e := h.journaled() |
| + e.header = Row{"iid": fakeIID, "identity": map[string]any{"box_ref": ref(fakeIID)}} |
| + if _, err := e.event("floor", row); err != nil { |
| + t.Fatal(err) |
| + } |
| + return e.drainPeers() |
| +} |
| + |
| +func markedFloor(live any, present bool) map[string]any { |
| + row := map[string]any{"rule": "drain", "reasons": []any{}, "population": floorPopulation, |
| + "ha_floor": "v0.35.0", "releases": map[string]any{}} |
| + if present { |
| + row["live"] = live |
| + } |
| + return row |
| +} |
| + |
| +// Astra r3 F3.2: the floor row's live list must be a present JSON array of |
| +// valid, distinct box references. Absent, null or another type, a bad |
| +// element and a duplicate each refuse; they never mean "no peers". The |
| +// empty list is an actual empty array, or one holding only the member. |
| +func TestDrainPeersNeedAStrictLiveList(t *testing.T) { |
| + for name, c := range map[string]struct { |
| + live any |
| + present bool |
| + }{ |
| + "absent": {nil, false}, "null": {nil, true}, "string": {"adi", true}, "bool": {true, true}, |
| + "object": {map[string]any{"adi": true}, true}, "number": {int64(1), true}, |
| + "bad element": {[]any{"adi", "a b"}, true}, "non-string element": {[]any{"adi", int64(1)}, true}, |
| + "duplicate": {[]any{"adi", "adi"}, true}, "dash first": {[]any{"-adi"}, true}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + peers, err := drainPeersFrom(t, markedFloor(c.live, c.present)) |
| + if refusalKey(err) != "floor_population" || peers != nil { |
| + t.Fatalf("peers %v, %v; want floor_population", peers, err) |
| + } |
| + }) |
| + } |
| + for name, live := range map[string][]any{"empty": {}, "only the member": {ref(fakeIID)}} { |
| + if peers, err := drainPeersFrom(t, markedFloor(live, true)); err != nil || peers == nil || len(peers) != 0 { |
| + t.Fatalf("%s: peers %#v, %v; want an empty list", name, peers, err) |
| + } |
| + } |
| + peers, err := drainPeersFrom(t, markedFloor([]any{"adi", ref(fakeIID), ref(fakePeer)}, true)) |
| + if err != nil || !slices.Equal(peers, []string{"adi", ref(fakePeer)}) { |
| + t.Fatalf("a marked row: %v, %v", peers, err) |
| + } |
| +} |
| + |
| +// Astra r3 F3.1: a floor row without this build's population marker was |
| +// written by an older tool, whose live list kept only fresh files. It is |
| +// never the drain's population: drainPeers refuses it, whatever its live |
| +// list says. |
| +func TestDrainPeersRefuseALegacyFloor(t *testing.T) { |
| + for name, pop := range map[string]any{"absent": nil, "other": "fresh-files", "number": int64(1)} { |
| + row := markedFloor([]any{"adi", ref(fakePeer)}, true) |
| + if pop == nil { |
| + delete(row, "population") |
| + } else { |
| + row["population"] = pop |
| + } |
| + if peers, err := drainPeersFrom(t, row); refusalKey(err) != "floor_legacy" || peers != nil { |
| + t.Fatalf("%s: peers %v, %v; want floor_legacy", name, peers, err) |
| + } |
| + } |
| +} |
| + |
| +// Astra r3 F3.1, end to end: the old verb writes its floor row (no |
| +// population marker, and a live list that skipped adi, whose file is six |
| +// hours old), then the process dies right after that durable row. The new |
| +// verb resumes the transaction: it refuses before any drain request, and |
| +// the journal holds no drain session intent. |
| +func TestDepartResumeOfALegacyFloorRefusesBeforeTheDrain(t *testing.T) { |
| + h := newHeldHarness(t, 2, nil) |
| + h.f.fixed["adi"] = fixedEdges{haTake: int64(1), haHandover: int64(1), age: 6 * time.Hour} |
| + // The old Floor's row, exactly its keys: origin/main kept only files |
| + // at most 15 minutes old, so adi is not in live. |
| + h.beforeEvent = func(kind string, data map[string]any) { |
| + if kind == "floor" { |
| + delete(data, "population") |
| + data["live"] = []any{ref(fakeIID), ref(fakePeer)} |
| + } |
| + } |
| + h.afterEvent = func(kind string, _ Row) { |
| + if kind == "floor" { |
| + panic(fakeDeath{"after the floor"}) |
| + } |
| + } |
| + if !expectDeath(t, func() { h.depart("replace", heldTx) }) { |
| + t.Fatal("no death after the floor row") |
| + } |
| + h.beforeEvent, h.afterEvent = nil, nil |
| + err := h.resume() |
| + if refusalKey(err) != "floor_legacy" { |
| + t.Fatalf("resume: %v, want floor_legacy", err) |
| + } |
| + for _, r := range h.txJournal(heldTx).Rows() { |
| + if a, ok := r["args"].(map[string]any); ok && r["kind"] == "intent" && a["verb"] == "drain" { |
| + t.Fatalf("a drain session intent: %v", r) |
| + } |
| + } |
| + if floor, _ := h.txJournal(heldTx).Last("floor", nil); floor["population"] != nil || containsValue(floor["live"], "adi") { |
| + t.Fatalf("the legacy floor row was rewritten: %v", floor) |
| + } |
| +} |
| + |
| // RemoveTests and RemoveMinimumTests. |
| func removeHarness(t *testing.T, pools map[string]any) *harness { |
diff --git a/internal/grouproll/floor.go b/internal/grouproll/floor.go| index 9ca07c463..e06d4f13f 100644 |
| --- a/internal/grouproll/floor.go |
| +++ b/internal/grouproll/floor.go |
| @@ -18,6 +18,12 @@ var ( |
| defaultReleasePlatform = "linux-arm64" |
| ) |
| +// floorPopulation marks a floor row whose live list is this build's |
| +// population: every edges file in the listing, whatever its age (Astra r3 |
| +// F3.1). An older tool's row has no marker and kept only fresh files, so |
| +// drainPeers never builds a drain list from it. |
| +const floorPopulation = "all-files-v1" |
| + |
| // Floor is the script's Operator.floor (held-floor-sha-map; region HA |
| // spec §25.9, group roll verb spec §9): which rule a departure or a roll |
| // takes. "drain" when every box with an edges file publishes |
| @@ -181,7 +187,7 @@ func (e *Engine) Floor(ctx context.Context, kind, version string) (rule string, |
| if len(reasons) > 0 { |
| rule = "dr4" |
| } |
| - if _, err := e.event("floor", map[string]any{"rule": rule, "reasons": reasons, "live": live, |
| + if _, err := e.event("floor", map[string]any{"rule": rule, "reasons": reasons, "live": live, "population": floorPopulation, |
| "ha_floor": haFloor, "releases": releases}); err != nil { |
| return "", err |
| } |
diff --git a/internal/grouproll/text.go b/internal/grouproll/text.go| index 055ba55ce..c9a1b8e54 100644 |
| --- a/internal/grouproll/text.go |
| +++ b/internal/grouproll/text.go |
| @@ -94,6 +94,8 @@ var text = map[string]string{ |
| "floor_box": "Box {box} does not publish ha_handover: 1", |
| "floor_fixed_missing": "Fixed box {box} is in fixed_boxes but has no edges file", |
| "floor_fixed_boxes": "The config must list the deployment's fixed boxes in fixed_boxes, or set no_fixed_boxes to true if it has none", |
| + "floor_legacy": "This transaction's floor was recorded by an older tool that did not count every edges file, so it cannot be resumed into a drain. Do not resume it: end it with abandon, return, cancel-drain or close-lost, whichever applies", |
| + "floor_population": "This transaction's floor row has no valid list of the boxes it counted, so the drain cannot name them. Do not resume it: end it with abandon, return, cancel-drain or close-lost, whichever applies", |
| "drain_peers_many": "The floor counted {count} other boxes, more than the {max} one drain request can name", |
| "floor_fixed_both": "The config lists fixed_boxes and also sets no_fixed_boxes to true. Keep only one", |
| "floor_unreadable": "The edges file {key} cannot be read", |
diff --git a/internal/grouproll/text_test.go b/internal/grouproll/text_test.go| index 067c27c0a..e82abd1c3 100644 |
| --- a/internal/grouproll/text_test.go |
| +++ b/internal/grouproll/text_test.go |
| @@ -13,10 +13,10 @@ var placeholderPattern = regexp.MustCompile(`\{([a-z_]+)\}`) |
| // Text cannot fill, or leaves a brace behind, fails here. |
| func TestTextRendersEveryKey(t *testing.T) { |
| // 139 approved, plus floor_fixed_missing, floor_fixed_boxes, |
| - // floor_fixed_both and drain_peers_many (held floor capability, |
| - // 2026-11-10), not yet copy-reviewed. |
| - if len(text) != 143 { |
| - t.Fatalf("text has %d keys, want the 139 approved plus 4", len(text)) |
| + // floor_fixed_both, drain_peers_many, floor_legacy and floor_population |
| + // (held floor capability, 2026-11-10), not yet copy-reviewed. |
| + if len(text) != 145 { |
| + t.Fatalf("text has %d keys, want the 139 approved plus 6", len(text)) |
| } |
| for key, raw := range text { |
| var args []string |