grouproll: journal finite floats; ha_take 1.0 is a DR-4 reason
The format 2 encoder writes an integral number as an integer and any other finite number in Go's shortest form; NaN and Inf still refuse. The permit encoder stays integers-only for byte parity with Python. The floor reads ha_take's raw token, so 1.0, 1e0 and true are floor_box reasons as in the script. Classify grouprollaws' read-only Bucket opener.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/grouproll/box.go+5 −1internal/grouproll/floor.go+2 −0internal/grouproll/floor_test.go+30 −15internal/grouproll/journal.go+54 −16internal/grouproll/journal_test.go+56 −3internal/grouproll/status.go+2 −1internal/release/openers_test.go+1 −0
CI failed — run details
Intent
<task-notification> <task-id>a030cd856fcf6708b</task-id> <tool-use-id>toolu_01Lj51BNHRDdRVt1xSFiyuhw</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/a030cd856fcf6708b.output</output-file> <status>completed</status> <summary>Agent "Implement Task 8: floor + SHA map" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS. Commit 06848c36 "grouproll: the held-requests floor from signed release pointers" is on group-roll-verb, not pushed. **Tests:** - The new tests pass (`TestReleaseForArtifact*`, `TestFloor*`, `TestRollRelease`). The pointer read matches the tool column on all 29 cases. - `go test ./internal/grouproll/... ./internal/grouprollaws/...`, the root `TestRegionHA` tests, `go vet` and the darwin and windows builds are clean. - Fixtures are in `internal/release/testdata/`, byte-identical to e17a74d3. **API:** - `release.ReleaseForArtifact(ctx, store, pub, channels, platform, sha) (string, error)`. It returns `*PointerError` (the fault plus the pointer's key and channel), `ErrUnknownArtifact`, or `*AmbiguousArtifactError`. - `(*Engine).Floor(ctx, kind, version string) (string, error)`. - For Task 7: `(*Engine).rollRelease(ctx, sha, prepared string) (string, error)`, which does the mapping and the `release_mismatch` check. Floor already calls it for a roll. **Concerns:** 1. The four escaped-timestamp cases are not on held-floor-sha-map; R2 asked for them but they were never added. I generate them in the Go test, signed with the golden key. Go rejects all four, and so does the verb. 2. `go test ./internal/release` fails on `TestS3StoreOpenersClassified`. It flags Task 5's `grouprollaws/objects.go`, a file I did not change. 3. A non-integer number in an edges file (for example `ha_take: 1.0`) cannot be written to the integer-only journal. The verb then refuses the transaction as an unreadable edges file, where the script would choose DR-4. 4. Go commands only ran with the sandbox off, because `~/.cache/go-build` is read-only inside it. GOCACHE stayed at its default. 5. `git commit` printed a `packed-refs.lock` error from another process, but the commit landed. I left the lock alone. Report: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-group-roll-verb/.superpowers/sdd/2026-11-09-group-roll-verb/task-8-report.md`</result> <usage><subagent_tokens>252006</subagent_tokens><tool_uses>80</tool_uses><duration_ms>1480392</duration_ms></usage> </task-notification>
Attributed to this commit: 24.5 g CO₂e (3,184,038 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on group-roll-verb, 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/internal/grouproll/box.go b/internal/grouproll/box.go| index 8524dad8c..7ce31b2ef 100644 |
| --- a/internal/grouproll/box.go |
| +++ b/internal/grouproll/box.go |
| @@ -167,7 +167,7 @@ func shellQuote(s string) string { |
| // (a surrogate pair above U+FFFF). It takes the values the strict decoder |
| // produces and refuses floats, as the journal encoder does. |
| func pythonEncoded(v any) ([]byte, error) { |
| - n, err := normalize(v) |
| + n, err := integersOnly(v) |
| if err != nil { |
| return nil, err |
| } |
| @@ -189,6 +189,10 @@ func writePythonSep(b *strings.Builder, v any, item, key string) error { |
| b.WriteString(strconv.FormatBool(x)) |
| case int64: |
| b.WriteString(strconv.FormatInt(x, 10)) |
| + case json.Number: |
| + // Only normalize's finite non-integral form reaches here; the |
| + // permit encoder (integersOnly) never passes one. |
| + b.WriteString(string(x)) |
| case string: |
| return writePythonString(b, x) |
| case []any: |
diff --git a/internal/grouproll/floor.go b/internal/grouproll/floor.go| index eacf572bd..8d1ee85b8 100644 |
| --- a/internal/grouproll/floor.go |
| +++ b/internal/grouproll/floor.go |
| @@ -79,6 +79,8 @@ func (e *Engine) Floor(ctx context.Context, kind, version string) (rule string, |
| continue |
| } |
| live = append(live, m[1]) |
| + // type(take) is int and take == 1: the decoder keeps 1.0 and 1e0 |
| + // as json.Number and true as bool, so only the integer 1 counts. |
| if take, ok := edges["ha_take"].(int64); !ok || take != 1 { |
| reasons = append(reasons, Text("floor_box", "box", m[1])) |
| } |
diff --git a/internal/grouproll/floor_test.go b/internal/grouproll/floor_test.go| index c6b345fa4..5c2db3ab4 100644 |
| --- a/internal/grouproll/floor_test.go |
| +++ b/internal/grouproll/floor_test.go |
| @@ -253,23 +253,38 @@ func TestFloorMemberWithoutHATake(t *testing.T) { |
| h.refused(t, h.floor("replace", ""), Text("floor_box", "box", ref(fakePeer))) |
| } |
| +// The script's test is `type(take) is int and take == 1`: only the JSON |
| +// integer 1 is the floor value. 1.0 and 1e0 are floats to json.loads, and |
| +// True is a bool, so each is a DR-4 reason, never a refusal; the edges_key |
| +// row journals 1.0 and 1e0 as 1 (the journal's float ruling) while the |
| +// floor reads the raw token the decoder kept as a json.Number. |
| func TestFloorMemberWithOtherHATake(t *testing.T) { |
| - for _, take := range []any{int64(0), int64(2), true, "1", nil} { |
| - h := newFloorHarness(t, false) |
| - h.f.haTake[ref(fakeIID)] = take |
| - r := h.floor("replace", "") |
| - if r.err != nil { |
| - t.Fatalf("take %#v: %v; output %q", take, r.err, h.out.String()) |
| - } |
| - h.refused(t, r, Text("floor_box", "box", ref(fakeIID))) |
| + for _, c := range []struct { |
| + take any |
| + raw string |
| + }{ |
| + {int64(1), "1"}, {json.Number("1.0"), "1.0"}, {json.Number("1e0"), "1e0"}, {true, "true"}, |
| + {"1", `"1"`}, {int64(2), "2"}, {int64(0), "0"}, {nil, ""}, |
| + } { |
| + t.Run(c.raw, func(t *testing.T) { |
| + h := newFloorHarness(t, false) |
| + h.f.haTake[ref(fakeIID)] = c.take |
| + r := h.floor("replace", "") |
| + if c.raw == "1" { |
| + h.drained(t, r) |
| + return |
| + } |
| + h.refused(t, r, Text("floor_box", "box", ref(fakeIID))) |
| + if c.raw == "1.0" || c.raw == "1e0" { |
| + for _, row := range r.e.j.Rows() { |
| + res, _ := row["result"].(map[string]any) |
| + if row["kind"] == "response" && res["box"] == ref(fakeIID) && res["ha_take"] != int64(1) { |
| + t.Fatalf("journaled ha_take = %#v, want 1", res["ha_take"]) |
| + } |
| + } |
| + } |
| + }) |
| } |
| - // 1.0 is not the integer 1 to the script either, but a format 2 |
| - // journal holds integers only (spec V3): the edges_key response row |
| - // cannot be written, so the file is unreadable and the floor refuses |
| - // instead of choosing DR-4. Never a drain. |
| - h := newFloorHarness(t, false) |
| - h.f.haTake[ref(fakeIID)] = json.Number("1.0") |
| - h.floorError(t, h.floor("replace", ""), Text("floor_unreadable", "key", "control/edges/"+ref(fakeIID)+".json")) |
| } |
| func TestFloorFixedForwarderWithoutHATake(t *testing.T) { |
diff --git a/internal/grouproll/journal.go b/internal/grouproll/journal.go| index f590bef96..e40dc905f 100644 |
| --- a/internal/grouproll/journal.go |
| +++ b/internal/grouproll/journal.go |
| @@ -46,8 +46,8 @@ const journalCap = 64 * 1024 * 1024 |
| var zeroHash = strings.Repeat("0", 64) |
| -// Row is one journal row as decoded: nil, bool, string, int64, []any and |
| -// map[string]any values only. |
| +// Row is one journal row as decoded: nil, bool, string, int64, json.Number |
| +// (a finite non-integral number), []any and map[string]any values only. |
| type Row map[string]any |
| // Journal is one open transaction journal or plan log. |
| @@ -59,8 +59,10 @@ type Journal struct { |
| } |
| // encodeRow is the canonical format 2 encoding: object keys sorted, no |
| -// insignificant space, no HTML escaping, integers only. A float, a |
| -// non-integer number or a value that does not encode as JSON is refused. |
| +// insignificant space, no HTML escaping. An integral number is written as |
| +// an integer (1.0 as 1), any other finite number in Go's shortest |
| +// round-trip form (0.5); NaN, the infinities and a value that does not |
| +// encode as JSON are refused. Times are integer milliseconds by type. |
| func encodeRow(v map[string]any) ([]byte, error) { |
| n, err := normalize(v) |
| if err != nil { |
| @@ -79,8 +81,29 @@ func encodeNormal(v any) ([]byte, error) { |
| return bytes.TrimSuffix(b.Bytes(), []byte("\n")), nil |
| } |
| -// normalize returns v as the decoder hands values back, refusing floats. |
| -func normalize(v any) (any, error) { |
| +// normalize returns v as the decoder hands values back, for the journal |
| +// and for comparisons: a finite number that is integral (1.0, 1e0) is an |
| +// int64; any other finite number is a json.Number in Go's shortest |
| +// round-trip form (strconv 'g', -1); NaN and the infinities are refused. |
| +func normalize(v any) (any, error) { return normalizeValue(v, true) } |
| + |
| +// integersOnly is normalize refusing every non-integer number, for the |
| +// encoders that must match Python's json.dumps byte for byte (which |
| +// writes 1.0 as 1.0, not 1). |
| +func integersOnly(v any) (any, error) { return normalizeValue(v, false) } |
| + |
| +// canonicalFloat is a finite number's journal form. |
| +func canonicalFloat(f float64) (any, error) { |
| + if math.IsNaN(f) || math.IsInf(f, 0) { |
| + return nil, fmt.Errorf("grouproll: journal numbers are finite, not %v", f) |
| + } |
| + if f == math.Trunc(f) && f >= -(1<<63) && f < 1<<63 { |
| + return int64(f), nil |
| + } |
| + return json.Number(strconv.FormatFloat(f, 'g', -1, 64)), nil |
| +} |
| + |
| +func normalizeValue(v any, floats bool) (any, error) { |
| switch x := v.(type) { |
| case nil, bool, string, int64: |
| return x, nil |
| @@ -108,20 +131,35 @@ func normalize(v any) (any, error) { |
| return nil, fmt.Errorf("grouproll: integer %d out of range", x) |
| } |
| return int64(x), nil |
| - case float32, float64: |
| - return nil, fmt.Errorf("grouproll: journal values are integers, not %v", x) |
| + case float32: |
| + if !floats { |
| + return nil, fmt.Errorf("grouproll: values are integers, not %v", x) |
| + } |
| + return canonicalFloat(float64(x)) |
| + case float64: |
| + if !floats { |
| + return nil, fmt.Errorf("grouproll: values are integers, not %v", x) |
| + } |
| + return canonicalFloat(x) |
| case json.Number: |
| - i, ok := integer(string(x)) |
| - if !ok { |
| - return nil, fmt.Errorf("grouproll: journal values are integers, not %s", x) |
| + if i, ok := integer(string(x)); ok { |
| + return i, nil |
| + } |
| + if !floats { |
| + return nil, fmt.Errorf("grouproll: values are integers, not %s", x) |
| + } |
| + f, err := strconv.ParseFloat(string(x), 64) |
| + if err != nil { |
| + // Out of float64's range (1e400): not finite. |
| + return nil, fmt.Errorf("grouproll: journal numbers are finite, not %s", x) |
| } |
| - return i, nil |
| + return canonicalFloat(f) |
| case Row: |
| - return normalize(map[string]any(x)) |
| + return normalizeValue(map[string]any(x), floats) |
| case map[string]any: |
| out := make(map[string]any, len(x)) |
| for k, e := range x { |
| - n, err := normalize(e) |
| + n, err := normalizeValue(e, floats) |
| if err != nil { |
| return nil, err |
| } |
| @@ -131,7 +169,7 @@ func normalize(v any) (any, error) { |
| case []any: |
| out := make([]any, len(x)) |
| for i, e := range x { |
| - n, err := normalize(e) |
| + n, err := normalizeValue(e, floats) |
| if err != nil { |
| return nil, err |
| } |
| @@ -158,7 +196,7 @@ func normalize(v any) (any, error) { |
| if err != nil { |
| return nil, err |
| } |
| - return normalize(d) |
| + return normalizeValue(d, floats) |
| } |
| // integer parses s as a JSON integer literal within int64. |
diff --git a/internal/grouproll/journal_test.go b/internal/grouproll/journal_test.go| index 8d509f6b1..7f33f0832 100644 |
| --- a/internal/grouproll/journal_test.go |
| +++ b/internal/grouproll/journal_test.go |
| @@ -6,6 +6,8 @@ import ( |
| "bytes" |
| "crypto/sha256" |
| "encoding/hex" |
| + "encoding/json" |
| + "math" |
| "os" |
| "path/filepath" |
| "reflect" |
| @@ -75,6 +77,52 @@ func TestJournalFormat2Golden(t *testing.T) { |
| } |
| } |
| +// TestJournalFloats: a finite number is journaled (the controller's |
| +// ruling on V3, 2026-11-10). An integral one is written as an integer, so |
| +// a drain report's "v":1.0 reads back as 1; a non-integral one in Go's |
| +// shortest round-trip form. Both reload and verify. Times stay integer ms |
| +// by type. |
| +func TestJournalFloats(t *testing.T) { |
| + j, path := newJournal(t) |
| + if _, err := j.Add("begin", map[string]any{"transaction": "t"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + report, err := decodeStrict([]byte(`{"v":1.0,"e":1e0,"half":0.5,"tenth":0.10,"big":1e21}`)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + row, err := j.Add("response", map[string]any{"result": report, "f": 2.0, "g": 0.25}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := os.ReadFile(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + line := strings.Split(strings.TrimSpace(string(raw)), "\n")[1] |
| + if !strings.Contains(line, `"f":2,"g":0.25,`) || |
| + !strings.Contains(line, `"result":{"big":1e+21,"e":1,"half":0.5,"tenth":0.1,"v":1}`) { |
| + t.Fatalf("row bytes: %s", line) |
| + } |
| + if v := row["result"].(map[string]any)["v"]; v != int64(1) { |
| + t.Fatalf("v = %#v, want int64 1", v) |
| + } |
| + j.Close() |
| + r, err := openJournal(path, currentOwner(), false, true) |
| + if err != nil { |
| + t.Fatalf("reopen: %v", err) |
| + } |
| + defer r.Close() |
| + if !reflect.DeepEqual(r.Rows(), j.Rows()) { |
| + t.Fatalf("reloaded rows differ:\n%#v\n%#v", r.Rows(), j.Rows()) |
| + } |
| + // The permit encoder still matches Python byte for byte, so it still |
| + // refuses a non-integer (TestPythonEncoded); the journal does not. |
| + if _, err := pythonEncoded(map[string]any{"x": 1.0}); err == nil { |
| + t.Fatal("pythonEncoded took a float") |
| + } |
| +} |
| + |
| func TestJournalAddAndLast(t *testing.T) { |
| j, _ := newJournal(t) |
| if _, err := j.Add("intent", map[string]any{"op": "x"}); refusalKey(err) != "record" { |
| @@ -100,8 +148,14 @@ func TestJournalAddAndLast(t *testing.T) { |
| if _, ok := j.Last("done", nil); ok { |
| t.Fatal("Last found done") |
| } |
| - if _, err := j.Add("intent", map[string]any{"at": 1.5}); refusalKey(err) != "record" { |
| - t.Fatalf("float: %v", err) |
| + if _, err := j.Add("intent", map[string]any{"at": math.NaN()}); refusalKey(err) != "record" { |
| + t.Fatalf("NaN: %v", err) |
| + } |
| + if _, err := j.Add("intent", map[string]any{"at": math.Inf(1)}); refusalKey(err) != "record" { |
| + t.Fatalf("Inf: %v", err) |
| + } |
| + if _, err := j.Add("intent", map[string]any{"at": json.Number("1e400")}); refusalKey(err) != "record" { |
| + t.Fatalf("1e400: %v", err) |
| } |
| if _, err := j.Add("intent", map[string]any{"seq": 9}); refusalKey(err) != "record" { |
| t.Fatalf("reserved field: %v", err) |
| @@ -151,7 +205,6 @@ func TestJournalRefusesDamage(t *testing.T) { |
| "no final newline": good[:len(good)-1], |
| "duplicate key": bytes.Replace(good, []byte(`{"format":2,`), []byte(`{"format":2,"format":2,`), 1), |
| "NaN": bytes.Replace(good, []byte(`"op":"x"`), []byte(`"op":NaN`), 1), |
| - "float": bytes.Replace(good, []byte(`"op":"x"`), []byte(`"op":1.5`), 1), |
| "bad previous": chained(t, []map[string]any{begin, with(intent, "previous", strings.Repeat("1", 64))}), |
| "bad hash": bytes.Replace(good, []byte(`"op":"x"`), []byte(`"op":"y"`), 1), |
| "seq gap": chained(t, []map[string]any{begin, with(intent, "seq", int64(2))}), |
diff --git a/internal/grouproll/status.go b/internal/grouproll/status.go| index 2f98b102e..f9ba07302 100644 |
| --- a/internal/grouproll/status.go |
| +++ b/internal/grouproll/status.go |
| @@ -69,7 +69,8 @@ func Status(stateDir string, c Config, tx string, w io.Writer) error { |
| } |
| // pythonDumps is json.dumps(v, sort_keys=True): Python's default ", " and |
| -// ": " separators and ensure_ascii. |
| +// ": " separators and ensure_ascii. A saved non-integral number prints in |
| +// its journal form (0.5); an integral one was saved as an integer. |
| func pythonDumps(v any) (string, error) { |
| n, err := normalize(v) |
| if err != nil { |
diff --git a/internal/release/openers_test.go b/internal/release/openers_test.go| index ce66b85c6..4ed824f89 100644 |
| --- a/internal/release/openers_test.go |
| +++ b/internal/release/openers_test.go |
| @@ -54,6 +54,7 @@ var otherBucketOpeners = map[string]openerEntry{ |
| "internal/lease/execution_store.go:ExecutionStore": {"execution/build state: the hibernate and claim data bucket, keyed by host prefix", 1}, |
| "internal/lease/endpoint.go:NewFilesStore": {"per-instance files store: the data/hibernate bucket, a host's published files under its hibernate prefix (files/0/), not the deployment bucket", 1}, |
| "internal/status/dryrun.go:DryRun": {"status dry run: a throwaway scratch directory, not a deployment", 1}, |
| + "internal/grouprollaws/objects.go:Bucket": {"carlos system group's read-only operator store (edges files, locks, router pointers in the deployment and data buckets) over the region's own endpoint, never a configured one; its Put and Delete refuse, so no change-index bump is needed", 1}, |
| } |
| // deploymentManualSites are stores over the deployment (CARLOS_DEPLOYMENT_DIR |