From cbd4da3a116cfc2d5c383f74771082d6c8c42507 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 11 Nov 2026 21:49:54 +0100 Subject: [PATCH] =?UTF-8?q?GATE=20=C2=A7613:=20deliveries,=20groups,=20owe?= =?UTF-8?q?d=20and=20conditions=20are=20template=20state=20entries=20under?= =?UTF-8?q?=20the=20same=20names,=20taking=20the=20buckets=20they=20had?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit merges and source stay in the old state section; pulls and asks wait for the removal of the merge states. Builds: design 47 G §613, A-8, A-20 (G-17, G-20) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- .../cmd/mesh-delivery-gate/keeps_test.go | 48 ++++++++++++++++++- modules/mesh-delivery-gate/module.json | 32 +++++++++---- 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go index e3ef8b05e..4694f8f7c 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "slices" + "strings" "testing" ) @@ -30,7 +31,12 @@ func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T t.Fatal(err) } var m struct { - State []json.RawMessage `json:"state"` + State []json.RawMessage `json:"state"` + Requires []struct { + Name string `json:"name"` + Storage string `json:"storage"` + Template string `json:"template"` + } `json:"requires"` } if err := json.Unmarshal(raw, &m); err != nil { t.Fatal(err) @@ -47,6 +53,12 @@ func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T } declared = append(declared, name) } + // The kept data of the template `state` are asked for in `requires`, under their local names (design 47 G §613). + for _, r := range m.Requires { + if r.Storage == "key-value" && r.Template == "state" { + declared = append(declared, r.Name) + } + } announced := []string{} for _, s := range Kept { announced = append(announced, s.Name) @@ -62,3 +74,37 @@ func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T } } } + +// Design 47 G §613 (A-20): deliveries, groups, owed and conditions are `requires` entries of the template `state` under +// their local names, taking the buckets they already had; merges and source stay in the old `state` section. +func TestTheFourStatesMoveToTheTemplateAndTwoStayOld(t *testing.T) { + raw, err := os.ReadFile(filepath.Join("..", "..", "module.json")) + if err != nil { + t.Fatal(err) + } + var m struct { + State []json.RawMessage `json:"state"` + Requires []struct{ Name, Storage, Template string } + } + if err := json.Unmarshal(raw, &m); err != nil { + t.Fatal(err) + } + moved := map[string]bool{} + for _, r := range m.Requires { + if r.Storage == "key-value" && r.Template == "state" { + moved[r.Name] = true + } + } + old := string(raw[strings.Index(string(raw), `"state": [`):]) + old = old[:strings.Index(old, "]")] + for _, n := range []string{"deliveries", "groups", "owed", "conditions"} { + if !moved[n] || strings.Contains(old, `"`+n+`"`) { + t.Errorf("%s: template state %v, old section lists it %v", n, moved[n], strings.Contains(old, `"`+n+`"`)) + } + } + for _, n := range []string{"merges", "source"} { + if moved[n] || !strings.Contains(old, `"`+n+`"`) { + t.Errorf("%s stays in the old section", n) + } + } +} diff --git a/modules/mesh-delivery-gate/module.json b/modules/mesh-delivery-gate/module.json index b015d3760..62651668b 100644 --- a/modules/mesh-delivery-gate/module.json +++ b/modules/mesh-delivery-gate/module.json @@ -278,6 +278,29 @@ ] } ] + }, + { + "name": "deliveries", + "storage": "key-value", + "template": "state" + }, + { + "name": "groups", + "storage": "key-value", + "template": "state" + }, + { + "name": "owed", + "storage": "key-value", + "template": "state", + "options": { + "history": 5 + } + }, + { + "name": "conditions", + "storage": "key-value", + "template": "state" } ], "packages": { @@ -296,8 +319,6 @@ "mesh-delivery-view.view_reach" ], "state": [ - "deliveries", - "groups", "pulls", { "name": "asks", @@ -307,15 +328,10 @@ "name": "merges", "history": 10 }, - { - "name": "owed", - "history": 5 - }, { "name": "source", "history": 64 - }, - "conditions" + } ], "capabilities": [ "ledger-calls",