GATE §613: deliveries, groups, owed and conditions are template state entries under the same names, taking the buckets they had

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
This commit is contained in:
2026-11-11 21:49:54 +01:00
parent 11d1be3ef8
commit cbd4da3a11
2 changed files with 71 additions and 9 deletions
@@ -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)
}
}
}
+24 -8
View File
@@ -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",