carlos / platform Public

group verb: TemplateData XML from the start tag, pointer body, edge tests

Fable r1 P3s: the launchTemplateData start tag's attributes are compared
too; bufferedBody is a pointer so bodies stay comparable; tests for a
self-closing userData, one with attributes, an absent one, the XML
prolog. Census re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude pushed by paul@keymail.dev d3938119198beb2377f65638f191241fad148220 parent 7d52ec6
6 files changed, +31 −12
  • docs/superpowers/notes/census-proposal-group-observation-carry.md +1 −1
  • internal/grouprollaws/group.go +5 −3
  • internal/grouprollaws/group_test.go +17 −1
  • internal/grouprollaws/transport.go +4 −3
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv +3 −3

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-group-observation-carry.md b/docs/superpowers/notes/census-proposal-group-observation-carry.md
index 796393f9a..f4d3d26fa 100644
--- a/docs/superpowers/notes/census-proposal-group-observation-carry.md
+++ b/docs/superpowers/notes/census-proposal-group-observation-carry.md
@@ -18,6 +18,6 @@ Recorded dispositions, which each change must still satisfy:
- `internal/grouproll/plan.go` `Engine.Plan`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads provider-observation.json from the operator's own 0700 state directory;rev3=census-ruling-group-verb-followups;basis=a missing or unreadable provider-observation.json is refused as observation instead of passing the read error through (same file, same read)
- `internal/grouprollaws/transport.go` `boundBody.HandleDeserialize`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap
-Seal: `40c8459580c3e62a53637e9989f1616e5735ce78796ec6ea1b22655a5eb4ad63` → `55cbab59f71de378573e93a87d00ae6aba819f87786a2ead08d743051b936a01`.
+Seal: `40c8459580c3e62a53637e9989f1616e5735ce78796ec6ea1b22655a5eb4ad63` → `9f1b2a7e7e9fcee366606e9536a7497ec9d74422b7b0797f4e69b91b9807bb54`.
Overlay: `internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/grouprollaws/group.go b/internal/grouprollaws/group.go
index 45e06fe0c..62ca5c3fa 100644
--- a/internal/grouprollaws/group.go
+++ b/internal/grouprollaws/group.go
@@ -714,7 +714,7 @@ func captureBody(dst *[]byte) middleware.DeserializeMiddleware {
return out, md, err
}
if r, ok := out.RawResponse.(*smithyhttp.Response); ok && r != nil && r.Response != nil {
- if b, ok := r.Body.(bufferedBody); ok {
+ if b, ok := r.Body.(*bufferedBody); ok {
*dst = b.data
}
}
@@ -749,7 +749,9 @@ func launchDataXML(body []byte) (string, bool) {
path = append(path, t.Name.Local)
if depth == 0 && strings.Join(path, "/") == "DescribeLaunchTemplateVersionsResponse/launchTemplateVersionSet/item/launchTemplateData" {
found++
- depth, start = 1, dec.InputOffset()
+ // From the start tag itself, so its attributes count too
+ // (Fable P3-2).
+ depth, start = 1, before
continue
}
if depth > 0 {
@@ -772,7 +774,7 @@ func launchDataXML(body []byte) (string, bool) {
udStart = -1
}
if depth == 0 {
- end = before
+ end = dec.InputOffset()
}
}
}
diff --git a/internal/grouprollaws/group_test.go b/internal/grouprollaws/group_test.go
index 1ecd6a874..dd569c76a 100644
--- a/internal/grouprollaws/group_test.go
+++ b/internal/grouprollaws/group_test.go
@@ -619,7 +619,7 @@ func TestTemplateDataUnknownField(t *testing.T) {
return d
}
base := must("7", `<imageId>ami-0123</imageId><userData>QQ==</userData><futureSetting></futureSetting>`)
- if got := base["LaunchTemplateDataXML"]; got != `<imageId>ami-0123</imageId><futureSetting></futureSetting>` {
+ if got := base["LaunchTemplateDataXML"]; got != `<launchTemplateData><imageId>ami-0123</imageId><futureSetting></futureSetting></launchTemplateData>` {
t.Fatalf("exact bytes %q", got)
}
if same := must("8", `<imageId>ami-0123</imageId><userData>Qg==</userData><futureSetting></futureSetting>`); !reflect.DeepEqual(base, same) {
@@ -636,6 +636,22 @@ func TestTemplateDataUnknownField(t *testing.T) {
t.Errorf("%s: no difference seen: %v", name, d["LaunchTemplateDataXML"])
}
}
+ // A self-closing userData, or one with attributes, is cut like any
+ // other; a version whose user data is absent equals one that has it.
+ for name, data := range map[string]string{
+ "self-closing": `<imageId>ami-0123</imageId><userData/><futureSetting></futureSetting>`,
+ "with attributes": `<imageId>ami-0123</imageId><userData kind="x">QQ==</userData><futureSetting></futureSetting>`,
+ "absent": `<imageId>ami-0123</imageId><futureSetting></futureSetting>`,
+ } {
+ if d := must("9", data); !reflect.DeepEqual(base["LaunchTemplateDataXML"], d["LaunchTemplateDataXML"]) {
+ t.Errorf("%s: %q", name, d["LaunchTemplateDataXML"])
+ }
+ }
+ // The real answer starts with an XML prolog; the element is the same.
+ withProlog := `<?xml version="1.0" encoding="UTF-8"?>` + "\n" + resp("7", `<imageId>ami-0123</imageId><userData>QQ==</userData><futureSetting></futureSetting>`)
+ if got, ok := launchDataXML([]byte(withProlog)); !ok || got != base["LaunchTemplateDataXML"] {
+ t.Errorf("prolog: %q, %v", got, ok)
+ }
for name, data := range map[string]string{
"two userData": `<imageId>ami-0123</imageId><userData>QQ==</userData><userData>QQ==</userData>`,
} {
diff --git a/internal/grouprollaws/transport.go b/internal/grouprollaws/transport.go
index 3e0ff3134..667f7e35a 100644
--- a/internal/grouprollaws/transport.go
+++ b/internal/grouprollaws/transport.go
@@ -100,12 +100,13 @@ func (boundBody) HandleDeserialize(ctx context.Context, in middleware.Deserializ
if err != nil {
return out, md, err
}
- resp.Body = bufferedBody{Reader: bytes.NewReader(data), data: data}
+ resp.Body = &bufferedBody{Reader: bytes.NewReader(data), data: data}
resp.ContentLength = int64(len(data))
return out, md, nil
}
-// bufferedBody is the whole bounded answer: the operation's deserializer
+// bufferedBody is the whole bounded answer (a pointer, so bodies stay
+// comparable; Fable P3-3): the operation's deserializer
// reads it, and a middleware outside boundBody can take its bytes without
// another read (TemplateData's captureBody).
type bufferedBody struct {
@@ -113,7 +114,7 @@ type bufferedBody struct {
data []byte
}
-func (bufferedBody) Close() error { return nil }
+func (*bufferedBody) Close() error { return nil }
type boundedBody struct {
rc io.ReadCloser
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index e8b82d4dd..8211f3ef9 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -169,4 +169,4 @@ plan14-root-reads-group-capacity-damping.tsv 0c649af234a7b89a75479e59e705307e329
plan14-root-reads-group-verb-followups.tsv 9c74b9876a13a3a3802860fe44406898c8bcbfd3bd22e8172a59a02674c3b4af
plan14-root-reads-group-read-transport-retry.tsv 9c74b9876a13a3a3802860fe44406898c8bcbfd3bd22e8172a59a02674c3b4af
plan14-root-reads-linked-deployments-slice1.tsv 40c8459580c3e62a53637e9989f1616e5735ce78796ec6ea1b22655a5eb4ad63
-plan14-root-reads-group-observation-carry.tsv 55cbab59f71de378573e93a87d00ae6aba819f87786a2ead08d743051b936a01
+plan14-root-reads-group-observation-carry.tsv 9f1b2a7e7e9fcee366606e9536a7497ec9d74422b7b0797f4e69b91b9807bb54
diff --git a/internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv b/internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv
index 2bcecc5f1..daf9dc07c 100644
--- a/internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv
+++ b/internal/provision/testdata/plan14-root-reads-group-observation-carry.tsv
@@ -2,9 +2,9 @@
# 3 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
@legacy e6723f485e963b2299144956c0e14997fd81558fded6f664a9838d4abb2cc7ae internal/grouproll/engine.go Engine.preflight legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads provider-observation.json from the operator's own 0700 state directory;rev3=census-ruling-group-observation-carry;basis=the same provider-observation.json read; when it names another version of the same launch template, the two versions are read from the provider (template_data, a DescribeLaunchTemplateVersions read through the adapter) and compared without user data; no new file read, nothing written file:Read@713 34851c542471ef3c75b164bd80bb63d060902ed74c438a8202af5b20684b8c48
@legacy 0732aca0e25ff830a56a0ad177aa86507e3cf14d94db509e26514a90f92aa1cf internal/grouproll/plan.go Engine.Plan legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads provider-observation.json from the operator's own 0700 state directory;rev3=census-ruling-group-verb-followups;basis=a missing or unreadable provider-observation.json is refused as observation instead of passing the read error through (same file, same read);rev3=census-ruling-group-observation-carry;basis=the same observation read and the same carry-over rule as preflight (two template_data provider reads); no new file read, nothing written file:Read@2300 e31735a42c7a49724f503b59406ced05c5e6d39038d8135b34c0ae463b36b415
-@legacy e088fa6b63cb030eedd9d2c356659dccccbe64eca464ec6625fa8b75c287cfaf internal/grouprollaws/transport.go boundBody.HandleDeserialize legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap;rev3=census-ruling-group-observation-carry;basis=the same bounded read of the AWS answer; the buffered bytes are kept on a typed body (bufferedBody) so TemplateData can compare the raw launchTemplateData without a second read; no new read file:ReadAll@436 22970b4b6bdf5bd90b25183ee33b702ebfea6070781aa4bac9cd5f461fd17280
+@legacy e4be70749edd7ee592f3d45d442141733639e2e105602702b4beb2b599481a4c internal/grouprollaws/transport.go boundBody.HandleDeserialize legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap;rev3=census-ruling-group-observation-carry;basis=the same bounded read of the AWS answer; the buffered bytes are kept on a typed body (bufferedBody) so TemplateData can compare the raw launchTemplateData without a second read; no new read file:ReadAll@436 8a54d323a71cbc8b179e367d700747b2c4102e13c1322d5afa27ed15cbf54601
internal/grouproll/engine.go Engine.preflight legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads provider-observation.json from the operator's own 0700 state directory;rev3=census-ruling-group-observation-carry;basis=the same provider-observation.json read; when it names another version of the same launch template, the two versions are read from the provider (template_data, a DescribeLaunchTemplateVersions read through the adapter) and compared without user data; no new file read, nothing written file:Read@713 34851c542471ef3c75b164bd80bb63d060902ed74c438a8202af5b20684b8c48
internal/grouproll/plan.go Engine.Plan legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads provider-observation.json from the operator's own 0700 state directory;rev3=census-ruling-group-verb-followups;basis=a missing or unreadable provider-observation.json is refused as observation instead of passing the read error through (same file, same read);rev3=census-ruling-group-observation-carry;basis=the same observation read and the same carry-over rule as preflight (two template_data provider reads); no new file read, nothing written file:Read@2300 e31735a42c7a49724f503b59406ced05c5e6d39038d8135b34c0ae463b36b415
-internal/grouprollaws/transport.go boundBody.HandleDeserialize legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap;rev3=census-ruling-group-observation-carry;basis=the same bounded read of the AWS answer; the buffered bytes are kept on a typed body (bufferedBody) so TemplateData can compare the raw launchTemplateData without a second read; no new read file:ReadAll@436 22970b4b6bdf5bd90b25183ee33b702ebfea6070781aa4bac9cd5f461fd17280
+internal/grouprollaws/transport.go boundBody.HandleDeserialize legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=reads an AWS API answer body under the 4 MiB cap;rev3=census-ruling-group-observation-carry;basis=the same bounded read of the AWS answer; the buffered bytes are kept on a typed body (bufferedBody) so TemplateData can compare the raw launchTemplateData without a second read; no new read file:ReadAll@436 8a54d323a71cbc8b179e367d700747b2c4102e13c1322d5afa27ed15cbf54601
@coverage internal/grouproll d0decee68f572b1fc022493d7721f5efdba74ddfe9b1438f78cf3aee716405c0
-@coverage internal/grouprollaws 13dc8722bbb49a68f075daaaa704ac6166236351d875f4b6dbd0cfb0c89f6b17
+@coverage internal/grouprollaws 287bd94344295b8618f577f0d5dd4bee809d99cb7342b53c6cc1e955e66ae01d