A bus-state entry stays off Requires, which names provisions (issue 1966 S1)

A local name such as records is no provision: on Requires it would send
the placement looking for a provider nothing offers (the lead's ruling on
issue 1966 B1). BusState alone holds the typed entries.
This commit is contained in:
2026-11-03 13:26:27 +01:00
parent 6ec6cad968
commit d3e10f68c5
3 changed files with 11 additions and 10 deletions
+2 -2
View File
@@ -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
+4 -4
View File
@@ -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))
+5 -4
View File
@@ -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 {