Announce the controller's states, keep every module's word, and grant a read only where its owner announced the state readable; the copied list of the controller's mirrors goes (issue 1790, D1-D4, ADR 0495, ADR 0513 §3)
This commit is contained in:
@@ -3,6 +3,7 @@ package inventory
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.novox.be/novox/mesh-sdk/go/announce"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
@@ -16,6 +17,10 @@ import (
|
||||
// apart for the reason that package keeps its own types: a permission must be a function of what a
|
||||
// module declared, and a query that decided anything would be a second place authority came from.
|
||||
|
||||
// Announcements reads the last announcement of each module (novox/hq ADR 0495, issue 1790), set by the controller that
|
||||
// reaches the bus; nil, nothing is read and every read is granted from `reads`.
|
||||
var Announcements func(ctx context.Context) (map[string]announce.States, error)
|
||||
|
||||
// BusRecords is every fact the composer needs about who may reach the bus.
|
||||
//
|
||||
// **A module's authority comes from the manifest, not from the assignment.** The assignment says
|
||||
@@ -110,6 +115,29 @@ func (i *Inventory) BusRecords(ctx context.Context) (broker.Records, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// **Who may read a state is what its owner announced** (novox/hq ADR 0495 clause 3, issue 1790): a read the owner's
|
||||
// announcement does not make readable is granted nothing, and said; an owner that announced nothing yet is read as
|
||||
// before. Announcements that cannot be read are said, and every read is granted as before: the bus's users are
|
||||
// composed either way.
|
||||
if Announcements != nil {
|
||||
announced, err := Announcements(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("the states the modules announced cannot be read, so every read is granted from `reads` as before: %v\n", err)
|
||||
} else {
|
||||
out.Announced = announced
|
||||
for node, ds := range out.Assigned {
|
||||
for k := range ds {
|
||||
granted, refused := broker.ReadsAnnounced(ds[k].Reads, announced)
|
||||
ds[k].Reads, ds[k].ReadsRefused = granted, refused
|
||||
for _, r := range refused {
|
||||
fmt.Printf("%s on %s reads %s, which its owner does not announce readable: not granted\n",
|
||||
ds[k].Module, node, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enrolling, err := i.NodesWithALiveToken(ctx)
|
||||
if err != nil {
|
||||
return broker.Records{}, err
|
||||
|
||||
Reference in New Issue
Block a user