diff --git a/go/catalogue/manifest.go b/go/catalogue/manifest.go index c9e2ccc..897d053 100644 --- a/go/catalogue/manifest.go +++ b/go/catalogue/manifest.go @@ -479,8 +479,8 @@ type Manifest struct { // §8): filled from the long form's `shares`, or from the stored form's `requires-shares`; never written by hand. RequireShares map[string][]BucketShare `json:"-"` // BusState is what the module keeps on the bus, each entry asked for in `requires` in its typed long form - // (BusStateEntry, novox/hq ADR 0595 §1), whose name is also in Requires. Stored beside `requires` - // (BusStateField), which stays a plain list of names. + // (BusStateEntry, novox/hq ADR 0595 §1); its local name is never in Requires, which names provisions. Stored + // beside `requires` (BusStateField), which stays a plain list of names. BusState []BusStateEntry `json:"bus-state,omitempty"` // Emits are the events this module publishes, named **locally**: `order.placed`, not a subject diff --git a/go/catalogue/optional_requirements.go b/go/catalogue/optional_requirements.go index a4d0c61..dcfd4c7 100644 --- a/go/catalogue/optional_requirements.go +++ b/go/catalogue/optional_requirements.go @@ -26,14 +26,15 @@ type requiresRead struct { names []string optional map[string]bool shares map[string][]BucketShare - // busState are the entries asking for bus state (BusStateEntry), each also named in names; aside the paths of the - // keys they had that this package does not know, set aside (ADR 0578 §3). + // busState are the entries asking for bus state (BusStateEntry), never named in names, which name provisions; aside + // the paths of the keys they had that this package does not know, set aside (ADR 0578 §3). busState []BusStateEntry aside []string } // readRequires reads `requires` in its forms — a bare name, {name, optional}, or a bus-state entry (BusStateEntry, -// novox/hq ADR 0595 §1) — into the names, which of them are optional, and the bus-state entries. +// novox/hq ADR 0595 §1) — into the names of the provisions, which of them are optional, and the bus-state entries, +// whose local names stay off the names: a local name is no provision, and nothing provides it. func readRequires(raw json.RawMessage) (requiresRead, error) { var entries []json.RawMessage if err := json.Unmarshal(raw, &entries); err != nil { @@ -55,7 +56,6 @@ func readRequires(raw json.RawMessage) (requiresRead, error) { if err != nil { return requiresRead{}, fmt.Errorf("requires[%d]: a bus-state entry is {name, storage, template, options, configuration, types} (novox/hq ADR 0595 §1): %w", i, err) } - names = append(names, entry.Name) busState = append(busState, entry) for _, path := range unknown { aside = append(aside, fmt.Sprintf("requires[%d]%s", i, path)) diff --git a/go/catalogue/optional_requirements_test.go b/go/catalogue/optional_requirements_test.go index d0e7e32..d6d9cb3 100644 --- a/go/catalogue/optional_requirements_test.go +++ b/go/catalogue/optional_requirements_test.go @@ -65,17 +65,18 @@ func TestARequirementsLongForm(t *testing.T) { busState []BusStateEntry aside []string }{ - // 1966/AC1: a plain name and a bus-state entry: Requires names both, BusState holds the one entry whole. + // 1966/AC1: a plain name and a bus-state entry: Requires names the plain one only, since it names provisions, + // and BusState holds the entry whole. {"a plain name and a bus-state entry", `["postgres-database", {"name":"records","storage":"ledger","template":"ledger","options":{"max-mib":1024}}]`, - "postgres-database records", []BusStateEntry{records}, nil}, + "postgres-database", []BusStateEntry{records}, nil}, // 1966/AC2: an unknown key is set aside and named, never refused; the entry decodes. {"a bus-state entry with a key it does not know", `[ {"name":"records","storage":"ledger","template":"ledger","colour":"red","options":{"max-mib":1024}}]`, - "records", []BusStateEntry{records}, []string{"requires[0].colour"}}, + "", []BusStateEntry{records}, []string{"requires[0].colour"}}, // 1966/AC3: a ledger type with each of the four effects round-trips through JSON unchanged. {"a ledger with its type", `[{"name":"records","storage":"ledger","template":"ledger","options":{"max-mib":1024}, - "types":[` + string(typeJSON) + `]}]`, "records", []BusStateEntry{ledger}, nil}, + "types":[` + string(typeJSON) + `]}]`, "", []BusStateEntry{ledger}, nil}, } { got, err := decodeForTest([]byte(`{"module":"x","version":"1","requires":` + c.requires + `}`)) if err != nil {