The composer strips every manifest-only process key, serves beside bus
The composer stripped a process's bus before the declaration but not its serves, so the node-engine's strict declaration read refused every module whose process declares serves (the builder, the bus module's keeper, mesh-recovery): "a process does not use serves, and it is set". The keys are now one set, built from the SDK's constants, so a later manifest-only key joins it in one place; the bus test gains a row for serves. Builds: design 47 H2 H-A-469
This commit is contained in:
@@ -42,6 +42,11 @@ func renderingMachinePort(r mcat.Rendering, module string, wanted int) int {
|
||||
return wanted
|
||||
}
|
||||
|
||||
// manifestOnlyProcessKeys is every key a process resource declares in its manifest that the composer strips before the
|
||||
// declaration (design 47 H2 H-A-469): the node-engine's strict declaration read knows none of them, and refuses a process
|
||||
// that carries one. A later manifest-only process key the SDK names joins here, and nowhere else.
|
||||
var manifestOnlyProcessKeys = []string{mcat.ProcessBusField, mcat.ProcessServesField}
|
||||
|
||||
// Declaration is everything the resolved modules put on the node, with settings applied.
|
||||
//
|
||||
// Resource identities are prefixed with the module they came from. Two modules may reasonably
|
||||
@@ -940,10 +945,12 @@ func resolutionCompose(r mcat.Resolution, with mcat.Rendering, h Holding, filter
|
||||
delete(copied, mcat.SecretsInEnvironment)
|
||||
delete(copied, mcat.NamesOnPurpose)
|
||||
delete(copied, mcat.TrustedField)
|
||||
// A process's bus stays controller-side (novox/hq ADR 0436 §1): never composed onto the
|
||||
// node-engine's process resource, whose wire declaration is mesh-host's own, vendored, with a
|
||||
// strict decoder that refuses an unknown key.
|
||||
delete(copied, mcat.ProcessBusField)
|
||||
// A process's manifest-only keys stay controller-side (novox/hq ADR 0436 §1; design 47 H2
|
||||
// H-A-469): never composed onto the node-engine's process resource, whose strict decoder
|
||||
// refuses an unknown key.
|
||||
for _, key := range manifestOnlyProcessKeys {
|
||||
delete(copied, key)
|
||||
}
|
||||
// **An operator's value, from the assignment** (novox/hq ADR 0112, ADR 0155): what a
|
||||
// definition may not carry because it is true of one installation only. Filled from
|
||||
// the same layers a mergeable file takes, and refused when no layer set it.
|
||||
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
// shape (ADR 0436 §7, §8), copied from mesh-catalog/modules/mesh-mail/module.json and extended as settled by
|
||||
// the lead: process id "send" is the manifest's own `id` (internal/catalogue/runtime.go:72-74 is the model for
|
||||
// a process id); the account file uses the controller's real JSON tags (modules.go:1041-1056 issueWith).
|
||||
func mailSenderProcessManifest(t *testing.T, bus string) string {
|
||||
func mailSenderProcessManifest(t *testing.T, key, value string) string {
|
||||
t.Helper()
|
||||
process := `{"id":"send","type":"process","run":["./mesh-mail","send"],"user":"mesh-mail-send"`
|
||||
if bus != "" {
|
||||
process += `,"bus":` + bus
|
||||
if value != "" {
|
||||
process += `,"` + key + `":` + value
|
||||
}
|
||||
process += `}`
|
||||
// The stream itself is plain here, not retention work-queue: 1179 checks only that a process names a
|
||||
@@ -32,45 +32,53 @@ const mailSenderBus = `{"emits":["mail.send.sent","mail.send.failed"],"queues":[
|
||||
`"state":["sends"],"asks":true,"invokes":["seat:operator-channel.tell"]}`
|
||||
|
||||
// 1179/AC5: a process declaring bus is composed with no bus key on the wire, and is otherwise byte for byte
|
||||
// what main composes for the same process without bus.
|
||||
// what main composes for the same process without bus. Design 47 H2 H-A-469: the same for every manifest-only
|
||||
// process key, its serves among them (the strict declaration read refused every process declaring serves).
|
||||
func TestAProcessesBusNeverReachesTheWire(t *testing.T) {
|
||||
withBus, err := decodeForTest([]byte(mailSenderProcessManifest(t, mailSenderBus)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
withoutBus, err := decodeForTest([]byte(mailSenderProcessManifest(t, "")))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
with := mcat.Rendering{Needed: map[string]map[string]string{}}
|
||||
outWith, err := Declaration(mcat.Resolution{Node: "novox", Modules: []mcat.Manifest{withBus}}, with)
|
||||
if err != nil {
|
||||
t.Fatalf("composing with bus: %v", err)
|
||||
}
|
||||
outWithout, err := Declaration(mcat.Resolution{Node: "novox", Modules: []mcat.Manifest{withoutBus}}, with)
|
||||
if err != nil {
|
||||
t.Fatalf("composing without bus: %v", err)
|
||||
}
|
||||
var withProcess, withoutProcess map[string]any
|
||||
for _, r := range outWith {
|
||||
if r["id"] == "mesh-mail.send" {
|
||||
withProcess = r
|
||||
}
|
||||
}
|
||||
for _, r := range outWithout {
|
||||
if r["id"] == "mesh-mail.send" {
|
||||
withoutProcess = r
|
||||
}
|
||||
}
|
||||
if withProcess == nil || withoutProcess == nil {
|
||||
t.Fatalf("the process was not composed at all: with=%v without=%v", withProcess, withoutProcess)
|
||||
}
|
||||
if _, has := withProcess["bus"]; has {
|
||||
t.Fatalf("the process resource carried a bus key onto the wire: %v", withProcess)
|
||||
}
|
||||
delete(withProcess, "bus")
|
||||
if !mapsEqual(withProcess, withoutProcess) {
|
||||
t.Fatalf("with bus declared, the process composed differently: %+v\nwant: %+v", withProcess, withoutProcess)
|
||||
for _, row := range []struct{ key, value string }{
|
||||
{mcat.ProcessBusField, mailSenderBus},
|
||||
{mcat.ProcessServesField, `["seat:mesh-mail.send"]`},
|
||||
} {
|
||||
t.Run(row.key, func(t *testing.T) {
|
||||
withKey, err := decodeForTest([]byte(mailSenderProcessManifest(t, row.key, row.value)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
withoutKey, err := decodeForTest([]byte(mailSenderProcessManifest(t, row.key, "")))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
with := mcat.Rendering{Needed: map[string]map[string]string{}}
|
||||
outWith, err := Declaration(mcat.Resolution{Node: "novox", Modules: []mcat.Manifest{withKey}}, with)
|
||||
if err != nil {
|
||||
t.Fatalf("composing with %s: %v", row.key, err)
|
||||
}
|
||||
outWithout, err := Declaration(mcat.Resolution{Node: "novox", Modules: []mcat.Manifest{withoutKey}}, with)
|
||||
if err != nil {
|
||||
t.Fatalf("composing without %s: %v", row.key, err)
|
||||
}
|
||||
var withProcess, withoutProcess map[string]any
|
||||
for _, r := range outWith {
|
||||
if r["id"] == "mesh-mail.send" {
|
||||
withProcess = r
|
||||
}
|
||||
}
|
||||
for _, r := range outWithout {
|
||||
if r["id"] == "mesh-mail.send" {
|
||||
withoutProcess = r
|
||||
}
|
||||
}
|
||||
if withProcess == nil || withoutProcess == nil {
|
||||
t.Fatalf("the process was not composed at all: with=%v without=%v", withProcess, withoutProcess)
|
||||
}
|
||||
if _, has := withProcess[row.key]; has {
|
||||
t.Fatalf("the process resource carried a %s key onto the wire: %v", row.key, withProcess)
|
||||
}
|
||||
if !mapsEqual(withProcess, withoutProcess) {
|
||||
t.Fatalf("with %s declared, the process composed differently: %+v\nwant: %+v", row.key, withProcess,
|
||||
withoutProcess)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user