Carry the catalogue's predefined list on the bridge's merged message, so the indexer keeps it without the controller's mirror (issue 1953 L5-D1, ADR 0565 §2)

This commit is contained in:
2026-10-29 22:21:12 +01:00
parent 2e5cc4f166
commit 2d2aa7ba9b
2 changed files with 47 additions and 0 deletions
+19
View File
@@ -33,6 +33,22 @@ func TestForgeMergedCarriesManifestsAndLocks(t *testing.T) {
if got.Manifests["a"] != oddManifest || !SameForge(got, withV(f)) {
t.Errorf("the message changed on the way: %q", got.Manifests["a"])
}
// ADR 0565 §2 (issue 1953 D1): a merged message carries the predefined list exact, or says the merge holds none; a
// pull message carries neither.
f.Predefined = []byte(`{"domain":{"type":"string"}}`)
if data, err := EncodeForge(f); err != nil {
t.Fatal(err)
} else if got, err := DecodeForge(data); err != nil || string(got.Predefined) != `{"domain":{"type":"string"}}` {
t.Errorf("the predefined list read back as %s, %v", got.Predefined, err)
}
f.Predefined, f.PredefinedRead = nil, true
if _, err := EncodeForge(f); err != nil {
t.Errorf("a merge holding no predefined list: %v", err)
}
pull := Forge{Kind: ForgePull, Repository: "novox/mesh-sdk", Number: 1, Head: "h", Action: PullOpened, PredefinedRead: true}
if _, err := EncodeForge(pull); err == nil || !strings.Contains(err.Error(), "only a merged message") {
t.Errorf("a pull message carrying the predefined list: %v", err)
}
}
func withV(f Forge) Forge { f.V = Version; return f }
@@ -50,6 +66,9 @@ func TestForgeMergedRefusesBadInputs(t *testing.T) {
// No repository holds placement (ADR 0567 §11): a message carrying placement files is refused, on a merge or a pull.
"placement files": {func(f *Forge) { f.RetiredPlacements = []byte(`{"anchor":"{}"}`) }, "mesh-placement"},
"placements read": {func(f *Forge) { f.RetiredRead = true }, "mesh-placement"},
// ADR 0565 §2 (issue 1953 D1): the predefined list is one JSON object, said present or absent, never both.
"predefined not an object": {func(f *Forge) { f.Predefined = []byte(`["domain"]`) }, "one JSON object"},
"predefined both": {func(f *Forge) { f.Predefined = []byte(`{}`); f.PredefinedRead = true }, "says the merge holds none"},
} {
f := mergedWithInputs()
tc.mut(&f)