diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index 9aef082ca..ac5ad003e 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -6097,24 +6097,38 @@ func WorkQueueConsumedElsewhereProblems(shelf catalogue.Shelf) []string { // WorkQueueStreamProblems refuses a work-queue stream (novox/hq ADR 0436 §6) that is not read by exactly // one process of its own module: named by none, it queues forever unconsumed; named by two, each would take -// half of what the other needed, silently. +// half of what the other needed, silently. A module with exactly one process, that process declaring no bus, +// runs that process on the module's own account, so its work-queue streams are read by that one process +// without naming them (design 47 H2 H-A-464); two processes, or one with a bus, name the reader in bus.queues. func WorkQueueStreamProblems(m catalogue.Manifest) []string { var problems []string named := map[string]int{} - for _, b := range m.ProcessBuses() { + buses := m.ProcessBuses() + for _, b := range buses { for _, q := range b.Queues { named[q]++ } } + processes := 0 + for _, r := range m.Resources { + if fmt.Sprint(r["type"]) == "process" { + processes++ + } + } + onAccount := processes == 1 && len(buses) == 0 for _, s := range m.Streams { if s.Retention != catalogue.StreamRetentionWorkQueue { continue } switch named[s.Name] { case 0: + if onAccount { + continue + } problems = append(problems, fmt.Sprintf( "%s's work-queue stream %q: no process names it in bus.queues; a work-queue stream is read by "+ - "exactly one process (novox/hq ADR 0436 §6)", m.Module, s.Name)) + "exactly one process (novox/hq ADR 0436 §6), named in bus.queues unless the module has one "+ + "process declaring no bus (design 47 H2 H-A-464)", m.Module, s.Name)) case 1: default: problems = append(problems, fmt.Sprintf( diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index 433413f0a..4610f9f92 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -3317,6 +3317,34 @@ func caseAWorkQueueStreamIsReadByExactlyOneProcessOfItsModule(t *testing.T) { !strings.Contains(got, "no process names it") { t.Errorf("an unnamed work-queue stream: %q", got) } + // H-A-464: a module whose one process declares no bus runs it on the module's account, its reader by that shape; + // two processes without a bus, or one process whose bus does not name the stream, still name the reader. + busless := func(processes int) catalogue.Manifest { + m := mailSenderManifestWithQueue("") + m.Resources = m.Resources[:1] + for i := 0; i < processes; i++ { + m.Resources = append(m.Resources, map[string]any{"id": fmt.Sprintf("send%d", i), "type": "process", + "run": []any{"./mesh-mail", "send"}, "user": "mesh-mail-send"}) + } + return m + } + for _, row := range []struct { + name string + m catalogue.Manifest + want string + }{ + {"one process declaring no bus", busless(1), ""}, + {"two processes declaring no bus", busless(2), "no process names it"}, + {"one process whose bus does not name the stream", mailSenderManifestWithQueue(""), "no process names it"}, + } { + got := strings.Join(WorkQueueStreamProblems(row.m), "; ") + switch { + case row.want == "" && got != "": + t.Errorf("%s is refused: %s", row.name, got) + case row.want != "" && (!strings.Contains(got, row.want) || !strings.Contains(got, "mail-sends")): + t.Errorf("%s: problems %q, want one naming mail-sends saying %q", row.name, got, row.want) + } + } two := mailSenderManifestWithQueue("mail-sends") two.Resources = append(two.Resources, map[string]any{"id": "resend", "type": "process", "run": []any{"./mesh-mail", "send"}, "user": "mesh-mail-send",