Every module follows the assigner's new places: the contracts' go/ path, mesh-wants in the delivery contracts, the state and tool assignments (issue 1966)
The legacy key form placement.<node> is gone from the client, so the readers and their fixtures lose it. The check noplacement now also refuses the assigner's retired names in a manifest. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -58,8 +58,8 @@ type adoptionKept struct {
|
||||
}
|
||||
|
||||
// heardHave is a node's latest have of the bus module, as the watch handed it, and whether it was adopted: a have heard
|
||||
// while the placement does not yet name its node as holding the bus adopts nothing then, and the have may not change
|
||||
// again for long, so it is adopted when the placement next changes (PlacementChanged), never on a timer.
|
||||
// while the assignments does not yet name its node as holding the bus adopts nothing then, and the have may not change
|
||||
// again for long, so it is adopted when the assignments next changes (AssignmentsChanged), never on a timer.
|
||||
type heardHave struct {
|
||||
raw []byte
|
||||
by string
|
||||
@@ -88,9 +88,9 @@ func (v *Vault) HaveGone(node string) {
|
||||
v.mu.Unlock()
|
||||
}
|
||||
|
||||
// PlacementChanged adopts from the kept have of the node the placement now names as holding the bus, when that have was
|
||||
// not adopted yet: the placement's change is the event that makes it adoptable.
|
||||
func (v *Vault) PlacementChanged() {
|
||||
// AssignmentsChanged adopts from the kept have of the node the assignments now names as holding the bus, when that have was
|
||||
// not adopted yet: the assignments' change is the event that makes it adoptable.
|
||||
func (v *Vault) AssignmentsChanged() {
|
||||
v.mu.Lock()
|
||||
pending := 0
|
||||
for _, h := range v.heard {
|
||||
@@ -112,9 +112,9 @@ func (v *Vault) PlacementChanged() {
|
||||
if !ok || h.adopted {
|
||||
return
|
||||
}
|
||||
by := h.by + ", taken again when the placement named " + bus + " as holding the bus"
|
||||
by := h.by + ", taken again when the assignments named " + bus + " as holding the bus"
|
||||
if _, err := v.AdoptFrom(bus, h.raw, by, false); err != nil {
|
||||
v.log("adopted nothing from %s.%s when the placement named it as holding the bus: %v", bus, BusModule, err)
|
||||
v.log("adopted nothing from %s.%s when the assignments named it as holding the bus: %v", bus, BusModule, err)
|
||||
return
|
||||
}
|
||||
v.markAdopted(bus, h.raw)
|
||||
|
||||
@@ -81,7 +81,7 @@ const ProvisionerPrefix = "provisioner."
|
||||
const AssignmentsRead = provisionerModule + "." + meshprovisionerclient.PlansState
|
||||
|
||||
// ProvisionsRead is the seat's state provisions as the manifest's `reads` names it; provisionerModule the module holding the seat
|
||||
// mesh-provisioner (TestThePlacementNamesAreTheManifests).
|
||||
// mesh-provisioner (TestTheAssignmentsNamesAreTheManifests).
|
||||
const (
|
||||
ProvisionsRead = provisionerModule + "." + meshprovisionerclient.ProvisionsState
|
||||
provisionerModule = "mesh-provisioner"
|
||||
|
||||
+38
-38
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
// The vault's reading of the seat mesh-module-assigner's placement, through its owner (novox/hq ADR 0615 §1, §4 to §6, ADR
|
||||
// 0596): the assigner's tool `assigner_read_placement` asked for the whole state at start, the owner's `views.placement`
|
||||
// The vault's reading of the seat mesh-module-assigner's assignments, through its owner (novox/hq ADR 0615 §1, §4 to §6, ADR
|
||||
// 0596): the assigner's tool `assigner_read_assignments` asked for the whole state at start, the owner's `views.assignments`
|
||||
// events after it, and the tool once more only on a gap. Started while the assigner is down it keeps asking and says so;
|
||||
// it never reads the assigner's bucket instead. (The vault's other reads, the node-engines' haves, the grants part's
|
||||
// accounts and the provisioner's plans and provisions, are not the indexer's or the assigner's state and stay as they are.)
|
||||
@@ -19,34 +19,34 @@ import (
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// PlacementTool is the assigner's ordinary read tool of its placement; PlacementViewsEvent the event of its views family.
|
||||
// AssignmentsTool is the assigner's ordinary read tool of its assignments; AssignmentsViewsEvent the event of its views family.
|
||||
const (
|
||||
// assignerModule is the holder of the seat mesh-module-assigner, named from this module's manifest (invokes its read tool,
|
||||
// consumes its views; TestThePlacementNamesAreTheManifests).
|
||||
assignerModule = "mesh-delivery-assigner"
|
||||
PlacementTool = assignerModule + ".assigner_read_placement"
|
||||
PlacementViewsEvent = assignerModule + ".views.placement"
|
||||
FirstViewsTool = "vault_first_views"
|
||||
FirstViewAgainTool = "vault_first_view_again"
|
||||
// consumes its views; TestTheAssignmentsNamesAreTheManifests).
|
||||
assignerModule = "mesh-delivery-assigner"
|
||||
AssignmentsTool = assignerModule + ".assigner_read_assignments"
|
||||
AssignmentsViewsEvent = assignerModule + ".views.assignments"
|
||||
FirstViewsTool = "vault_first_views"
|
||||
FirstViewAgainTool = "vault_first_view_again"
|
||||
)
|
||||
|
||||
// FindingsState is the vault's state of findings, which the condition keeper reads (ADR 0564): a finding names no secret.
|
||||
const FindingsState = "findings"
|
||||
|
||||
// placementView is the picture; nil until main begins it.
|
||||
var placementView *views.Follower
|
||||
// assignmentsView is the picture; nil until main begins it.
|
||||
var assignmentsView *views.Follower
|
||||
|
||||
// newPlacementView makes the follower: ask calls the tool, gone is told of a deleted key, changed of every change after
|
||||
// newAssignmentsView makes the follower: ask calls the tool, gone is told of a deleted key, changed of every change after
|
||||
// it is held (a first view's keys too).
|
||||
func newPlacementView(ask func(key string, body any) (json.RawMessage, error), gone func(key string), changed func(),
|
||||
func newAssignmentsView(ask func(key string, body any) (json.RawMessage, error), gone func(key string), changed func(),
|
||||
findings views.FindingWriter) *views.Follower {
|
||||
return &views.Follower{Owner: assignerModule, Tool: PlacementTool, State: "placement", Logf: say,
|
||||
return &views.Follower{Owner: assignerModule, Tool: AssignmentsTool, State: "assignments", Logf: say,
|
||||
Ask: func(_ context.Context, after string) (views.Answer, error) {
|
||||
body := map[string]any{"values": true}
|
||||
if after != "" {
|
||||
body["after"] = after
|
||||
}
|
||||
raw, err := ask(PlacementTool, body)
|
||||
raw, err := ask(AssignmentsTool, body)
|
||||
if err != nil {
|
||||
return views.Answer{}, err
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func newPlacementView(ask func(key string, body any) (json.RawMessage, error), g
|
||||
// Past its bound the vault's finding names the owner and the tool, and the condition keeper raises it (the
|
||||
// answer deletes it); the vault keeps asking meanwhile.
|
||||
Raise: func(s views.Status) {
|
||||
say("the vault has no first view of the assigner's placement: %s has not answered since %s (%s); it keeps asking", s.Tool,
|
||||
say("the vault has no first view of the assigner's assignments: %s has not answered since %s (%s); it keeps asking", s.Tool,
|
||||
s.Asked.Format(time.RFC3339), s.Error)
|
||||
f := views.UnansweredFinding(Seat, s, time.Now())
|
||||
if err := findings.Put(f); err != nil {
|
||||
@@ -88,24 +88,24 @@ func unwrapToolAnswer(raw json.RawMessage) []byte {
|
||||
return raw
|
||||
}
|
||||
|
||||
// beginPlacementView asks the first view until answered and hears the owner's events.
|
||||
func beginPlacementView(f *views.Follower) {
|
||||
// beginAssignmentsView asks the first view until answered and hears the owner's events.
|
||||
func beginAssignmentsView(f *views.Follower) {
|
||||
go func() {
|
||||
if err := f.Start(context.Background()); err != nil {
|
||||
say("the first view of the assigner's placement ended unanswered: %v", err)
|
||||
say("the first view of the assigner's assignments ended unanswered: %v", err)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
<-stdio.Served()
|
||||
for wait := 2 * time.Second; ; wait = min(wait*2, time.Minute) {
|
||||
err := stdio.Subscribe(PlacementViewsEvent, func(e stdio.Envelope) error {
|
||||
err := stdio.Subscribe(AssignmentsViewsEvent, func(e stdio.Envelope) error {
|
||||
ev, err := views.DecodeEvent(e.Body)
|
||||
if err != nil {
|
||||
say("%s is not a views event: %v", PlacementViewsEvent, err)
|
||||
say("%s is not a views event: %v", AssignmentsViewsEvent, err)
|
||||
return nil
|
||||
}
|
||||
if gap, why := f.Apply(ev); gap {
|
||||
say("a gap in the assigner's placement (%s): its first view is asked once more", why)
|
||||
say("a gap in the assigner's assignments (%s): its first view is asked once more", why)
|
||||
go func() { _ = f.Start(context.Background()) }()
|
||||
}
|
||||
return nil
|
||||
@@ -113,29 +113,29 @@ func beginPlacementView(f *views.Follower) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
say("does not hear %s yet (%v); asking again in %s", PlacementViewsEvent, err, wait)
|
||||
say("does not hear %s yet (%v); asking again in %s", AssignmentsViewsEvent, err, wait)
|
||||
time.Sleep(wait)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// viewPlacement is the placement reader over the picture: a key asked before the first view is answered is an error, so
|
||||
// viewAssignments is the assignments reader over the picture: a key asked before the first view is answered is an error, so
|
||||
// the caller waits (the "not yet" of the vault's other reads), never a read of the owner's bucket.
|
||||
func viewPlacement(f func() *views.Follower) PlacementReader {
|
||||
func viewAssignments(f func() *views.Follower) AssignerReader {
|
||||
ready := func() (*views.Follower, error) {
|
||||
fol := f()
|
||||
if fol == nil {
|
||||
return nil, fmt.Errorf("the vault reads the assigner's placement only when it runs as the module")
|
||||
return nil, fmt.Errorf("the vault reads the assigner's assignments only when it runs as the module")
|
||||
}
|
||||
select {
|
||||
case <-fol.Ready():
|
||||
return fol, nil
|
||||
default:
|
||||
s := fol.Status()
|
||||
return nil, fmt.Errorf("the first view of the assigner's placement is not answered yet (%s asked %d times)", s.Tool, s.Asks)
|
||||
return nil, fmt.Errorf("the first view of the assigner's assignments is not answered yet (%s asked %d times)", s.Tool, s.Asks)
|
||||
}
|
||||
}
|
||||
return PlacementReader{
|
||||
return AssignerReader{
|
||||
Keys: func() ([]string, error) {
|
||||
fol, err := ready()
|
||||
if err != nil {
|
||||
@@ -162,7 +162,7 @@ func viewPlacement(f func() *views.Follower) PlacementReader {
|
||||
}
|
||||
}
|
||||
|
||||
// leaverKey is whether a deleted key of the placement is a node's own key, `<node>.node`.
|
||||
// leaverKey is whether a deleted key of the assignments is a node's own key, `<node>.node`.
|
||||
func leaverKey(key string) (string, bool) {
|
||||
node, ok := strings.CutSuffix(key, ".node")
|
||||
return node, ok && node != ""
|
||||
@@ -172,20 +172,20 @@ func leaverKey(key string) (string, bool) {
|
||||
func viewTools(env *Env) []toolDef {
|
||||
return []toolDef{
|
||||
{Name: FirstViewsTool,
|
||||
Description: "The vault's first view of the assigner's placement: the tool it asks, the revision its picture holds, when it " +
|
||||
Description: "The vault's first view of the assigner's assignments: the tool it asks, the revision its picture holds, when it " +
|
||||
"asked and was answered, how many asks (and by hand), and whether it is waiting.",
|
||||
run: func(string, map[string]any) (any, error) {
|
||||
if placementView == nil {
|
||||
return nil, fmt.Errorf("the vault reads the assigner's placement only when it runs as the module")
|
||||
if assignmentsView == nil {
|
||||
return nil, fmt.Errorf("the vault reads the assigner's assignments only when it runs as the module")
|
||||
}
|
||||
return map[string]any{"first-views": []views.Status{placementView.Status()}}, nil
|
||||
return map[string]any{"first-views": []views.Status{assignmentsView.Status()}}, nil
|
||||
}},
|
||||
{Name: FirstViewAgainTool,
|
||||
Description: "Ask the first view of the assigner's placement once more by hand, with why, recorded in the vault's log.",
|
||||
Description: "Ask the first view of the assigner's assignments once more by hand, with why, recorded in the vault's log.",
|
||||
Input: map[string]any{"why": str("why the first view is asked again")},
|
||||
run: func(caller string, a map[string]any) (any, error) {
|
||||
if placementView == nil {
|
||||
return nil, fmt.Errorf("the vault reads the assigner's placement only when it runs as the module")
|
||||
if assignmentsView == nil {
|
||||
return nil, fmt.Errorf("the vault reads the assigner's assignments only when it runs as the module")
|
||||
}
|
||||
why := strings.TrimSpace(arg(a, "why"))
|
||||
if why == "" {
|
||||
@@ -194,8 +194,8 @@ func viewTools(env *Env) []toolDef {
|
||||
if err := fromAGrantedCaller(caller, FirstViewAgainTool); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
say("the first view of the assigner's placement is asked again by %s: %s", caller, why)
|
||||
return map[string]any{"asked-again": true}, placementView.Again(context.Background(), why)
|
||||
say("the first view of the assigner's assignments is asked again by %s: %s", caller, why)
|
||||
return map[string]any{"asked-again": true}, assignmentsView.Again(context.Background(), why)
|
||||
}},
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -13,8 +13,8 @@ import (
|
||||
|
||||
// ADR 0615 §6: the vault started while the assigner is down keeps asking, never reads its bucket, and past the bound
|
||||
// writes a finding naming the owner and the tool for the condition keeper; the answer deletes it. Before the answer a read
|
||||
// of the placement is an error.
|
||||
func TestAnUnansweredFirstViewOfThePlacementIsAFindingTheAnswerClears(t *testing.T) {
|
||||
// of the assignments is an error.
|
||||
func TestAnUnansweredFirstViewOfTheAssignmentsIsAFindingTheAnswerClears(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
up := false
|
||||
held := map[string]json.RawMessage{}
|
||||
@@ -24,15 +24,15 @@ func TestAnUnansweredFirstViewOfThePlacementIsAFindingTheAnswerClears(t *testing
|
||||
if !up {
|
||||
return nil, errors.New("nats: no responders available for request")
|
||||
}
|
||||
raw, _ := json.Marshal(views.Answer{V: 1, Owner: "mesh-delivery-assigner", State: "placement", Revision: 1, Created: time.Now(),
|
||||
raw, _ := json.Marshal(views.Answer{V: 1, Owner: "mesh-delivery-assigner", State: "assignments", Revision: 1, Created: time.Now(),
|
||||
Values: map[string]json.RawMessage{"g14.node": json.RawMessage(`{}`)}})
|
||||
return raw, nil
|
||||
}
|
||||
f := newPlacementView(ask, func(string) {}, nil, heldFindings{&mu, held})
|
||||
f := newAssignmentsView(ask, func(string) {}, nil, heldFindings{&mu, held})
|
||||
f.Bound, f.Wait = 30*time.Millisecond, 10*time.Millisecond
|
||||
reader := viewPlacement(func() *views.Follower { return f })
|
||||
reader := viewAssignments(func() *views.Follower { return f })
|
||||
if _, err := reader.Keys(); err == nil {
|
||||
t.Fatal("the placement was read before its first view")
|
||||
t.Fatal("the assignments was read before its first view")
|
||||
}
|
||||
done := make(chan error, 1)
|
||||
go func() { done <- f.Start(context.Background()) }()
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
enrollerclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshnodeenrollerclient"
|
||||
vaultclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -90,7 +90,7 @@ func newEnrolling(t *testing.T) *enrolling {
|
||||
v := newVault(t, nil)
|
||||
e := &enrolling{testVault: v, accounts: &fakeAccounts{keys: map[string]AccountHash{}}, logins: &loginsState{keys: map[string]NodeLogin{}}, acts: map[string]HandActSeen{}}
|
||||
v.Accounts, v.Logins = e.accounts, e.logins
|
||||
v.Placement = placementsOf(t, map[string][]string{"novox": {"nats"}, "g14": {"web"}, "ace": {"shop"}})
|
||||
v.Assigner = assignedNodes(t, map[string][]string{"novox": {"nats"}, "g14": {"web"}, "ace": {"shop"}})
|
||||
v.LoadedListHeard(570)
|
||||
v.TokenBase = func() (TokenBase, error) {
|
||||
return TokenBase{Broker: "tls://10.77.0.1:4222", Fingerprint: "sha256:bus"}, nil
|
||||
@@ -130,10 +130,10 @@ func TestTheVaultsEnrolmentAnswersAreMeshSDKsWireShapes(t *testing.T) {
|
||||
}
|
||||
// new1 is placed with its private-network address, as mesh-enrolment writes it before it asks for the certificate.
|
||||
values := map[string][]byte{}
|
||||
for node, p := range map[string]placing.Placement{"novox": {Node: "novox", Modules: []placing.PlacedModule{{Module: "nats"}}},
|
||||
for node, p := range map[string]placing.Assignments{"novox": {Node: "novox", Modules: []placing.PlacedModule{{Module: "nats"}}},
|
||||
"g14": {Node: "g14"}, "new1": {Node: "new1", Decided: placing.NodeDecided{Address: "10.77.0.9"}}} {
|
||||
p.V = vaultclient.Version
|
||||
kv, err := assignerclient.PlacementValues(p)
|
||||
kv, err := assignerclient.AssignmentsValues(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func TestTheVaultsEnrolmentAnswersAreMeshSDKsWireShapes(t *testing.T) {
|
||||
}
|
||||
_ = node
|
||||
}
|
||||
e.Placement = PlacementReader{Read: func(key string) ([]byte, error) { return values[key], nil },
|
||||
e.Assigner = AssignerReader{Read: func(key string) ([]byte, error) { return values[key], nil },
|
||||
Keys: func() ([]string, error) {
|
||||
var out []string
|
||||
for k := range values {
|
||||
@@ -481,9 +481,9 @@ func said(p *published, event string) int {
|
||||
return n
|
||||
}
|
||||
|
||||
// 774/S48/AC2 (novox/hq ADR 0583 §1 insight): the key of a node that leaves the placement is deleted, heard from the
|
||||
// placement's watch or found by the minute pass; one that cannot be read deletes nothing.
|
||||
func TestANodesLoginsKeyGoesWhenItLeavesThePlacement(t *testing.T) {
|
||||
// 774/S48/AC2 (novox/hq ADR 0583 §1 insight): the key of a node that leaves the assignments is deleted, heard from the
|
||||
// the assignments' watch or found by the minute pass; one that cannot be read deletes nothing.
|
||||
func TestANodesLoginsKeyGoesWhenItLeavesTheAssignments(t *testing.T) {
|
||||
e := newEnrolling(t)
|
||||
for _, n := range []string{"g14", "gone", "gone2"} {
|
||||
e.logins.keys[n] = NodeLogin{Node: n, Login: "node." + n}
|
||||
@@ -498,9 +498,9 @@ func TestANodesLoginsKeyGoesWhenItLeavesThePlacement(t *testing.T) {
|
||||
t.Errorf("the keys after a node left and a pass: %+v", e.logins.keys)
|
||||
}
|
||||
e.logins.keys["gone"] = NodeLogin{Node: "gone"}
|
||||
e.Placement = PlacementReader{}
|
||||
e.Assigner = AssignerReader{}
|
||||
e.LoginsPass()
|
||||
if _, ok := e.logins.keys["gone"]; !ok {
|
||||
t.Error("a placement that is not read deleted a key")
|
||||
t.Error("an assignment that is not read deleted a key")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func build() *Env {
|
||||
env.Vault = &Vault{Store: store, Own: own, Askers: Declared{Read: watchedPlan, Confirm: readAssignment, Store: store},
|
||||
Assignments: Mirror{Keys: assignmentKeys, Read: readAssignment}, Emit: emit, Ask: stdio.Ask,
|
||||
Now: time.Now, Log: say, Accounts: busAccounts{}, Haves: readHave, WantRead: readWant,
|
||||
HaveKeys: func() ([]string, error) { return stdio.State(HaveRead).Keys() }, Placement: placement, Signers: busSigners{},
|
||||
HaveKeys: func() ([]string, error) { return stdio.State(HaveRead).Keys() }, Assigner: seatAssignments, Signers: busSigners{},
|
||||
AskCallers: askCallers(os.Getenv("MESH_VAULT_SECRET_ASK_CALLERS")), EnrolCallers: askCallers(os.Getenv("MESH_VAULT_ENROLMENT_CALLERS")),
|
||||
RetireCallers: retireCallers(os.Getenv("MESH_VAULT_RETIRE_CALLERS")), Logins: busNodeLogins{}, ReadAct: readHandAct, TokenBase: TokenBaseFromFile(os.Getenv("MESH_VAULT_STATE")),
|
||||
Bound: Bound{
|
||||
@@ -110,21 +110,21 @@ func readHandAct(id string) (*HandActSeen, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// watchLeavers begins the picture of the placement and deletes a node's key of node-logins when its node key of the
|
||||
// placement is deleted (noderotation.go): the owner's event, never a poll. It answers whether it began; the minute pass
|
||||
// watchLeavers begins the picture of the assignments and deletes a node's key of node-logins when its node key of the
|
||||
// assignments is deleted (noderotation.go): the owner's event, never a poll. It answers whether it began; the minute pass
|
||||
// (LoginsPass) catches what it missed.
|
||||
func watchLeavers(env *Env) bool {
|
||||
if env.Vault == nil {
|
||||
return true
|
||||
}
|
||||
if placementView == nil {
|
||||
placementView = newPlacementView(stdio.Ask, func(key string) {
|
||||
if assignmentsView == nil {
|
||||
assignmentsView = newAssignmentsView(stdio.Ask, func(key string) {
|
||||
if node, ok := leaverKey(key); ok {
|
||||
env.Vault.NodeLeft(node)
|
||||
}
|
||||
}, env.Vault.PlacementChanged,
|
||||
}, env.Vault.AssignmentsChanged,
|
||||
meshconditionsclient.FindingWriter{State: stdio.State(FindingsState)})
|
||||
beginPlacementView(placementView)
|
||||
beginAssignmentsView(assignmentsView)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -235,9 +235,9 @@ func watchCredentialAsks(env *Env, kick chan<- struct{}) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// placement reads the seat mesh-module-assigner's placement through its owner's tool and events (placementview.go), never the
|
||||
// seatAssignments reads the seat mesh-module-assigner's assignments through its owner's tool and events (assignmentsview.go), never the
|
||||
// owner's bucket.
|
||||
var placement = viewPlacement(func() *views.Follower { return placementView })
|
||||
var seatAssignments = viewAssignments(func() *views.Follower { return assignmentsView })
|
||||
|
||||
// readWant is one wanted account of the grants part, read afresh (issue-account).
|
||||
func readWant(user string) ([]byte, bool, error) {
|
||||
|
||||
@@ -406,7 +406,7 @@ func (v *Vault) IssueAccount(caller, user string) (any, error) {
|
||||
return nil, fmt.Errorf("the wanted account %s could not be read: %w", user, err)
|
||||
}
|
||||
if !found {
|
||||
return nil, fmt.Errorf("the grants part holds no wanted account %s: the vault mints only what placement composes "+
|
||||
return nil, fmt.Errorf("the grants part holds no wanted account %s: the vault mints only what assignments composes "+
|
||||
"(grants_accounts lists them)", user)
|
||||
}
|
||||
w, err := grantsstate.ReadWantedAccount(user, raw)
|
||||
|
||||
@@ -65,18 +65,18 @@ type player struct {
|
||||
// ask answers a mesh/ask (a call of another module's tool); nil answers none, as a call with no responder.
|
||||
ask func(key string, body json.RawMessage) (any, error)
|
||||
|
||||
// The assigner's placement as its owner's tool and views family say it (ADR 0615): the values, and the revision of the
|
||||
// The assigner's assignments as its owner's tool and views family say it (ADR 0615): the values, and the revision of the
|
||||
// last change, kept from the bucket.
|
||||
placeMu sync.Mutex
|
||||
placeValues map[string]json.RawMessage
|
||||
placeRevision uint64
|
||||
// answeredOnce closes answered at the vault's first view of the placement.
|
||||
// answeredOnce closes answered at the vault's first view of the assignments.
|
||||
answeredOnce sync.Once
|
||||
answered chan struct{}
|
||||
|
||||
// The families the vault subscribed to, and the events said on one before it did: held, as the module's consumer on
|
||||
// the bus holds them, and handed in order once it subscribes. A runtime that refused the subscription and dropped the
|
||||
// events left the vault's picture at its first view, so a placement written after that view never reached it, and
|
||||
// events left the vault's picture at its first view, so an assignment written after that view never reached it, and
|
||||
// whether it did turned on which came first (the rotation test's flake, met twice).
|
||||
subMu sync.Mutex
|
||||
subscribed map[string]bool
|
||||
@@ -132,11 +132,11 @@ func (p *player) subscribe(pattern string) {
|
||||
|
||||
var placeCreated = time.Date(2026, 11, 4, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
// followPlacement keeps the bucket of the placement as the assigner's owner does: listed once, then each change said on
|
||||
// followAssignments keeps the bucket of the assignments as the assigner's owner does: listed once, then each change said on
|
||||
// its views family to the vault. Call it before the player serves.
|
||||
func (p *player) followPlacement() {
|
||||
func (p *player) followAssignments() {
|
||||
p.t.Helper()
|
||||
kv, err := p.js.KeyValue(p.ctx, "mesh-delivery-assigner_placement")
|
||||
kv, err := p.js.KeyValue(p.ctx, "mesh-delivery-assigner_assignments")
|
||||
if err != nil {
|
||||
p.t.Fatal(err)
|
||||
}
|
||||
@@ -164,7 +164,7 @@ func (p *player) followPlacement() {
|
||||
}
|
||||
if !current {
|
||||
p.placeRevision++
|
||||
ev := map[string]any{"v": 1, "owner": "mesh-delivery-assigner", "state": "placement", "key": e.Key(),
|
||||
ev := map[string]any{"v": 1, "owner": "mesh-delivery-assigner", "state": "assignments", "key": e.Key(),
|
||||
"revision": p.placeRevision, "created": placeCreated}
|
||||
if deleted {
|
||||
ev["deleted"] = true
|
||||
@@ -172,7 +172,7 @@ func (p *player) followPlacement() {
|
||||
ev["value"] = json.RawMessage(e.Value())
|
||||
}
|
||||
body, _ := json.Marshal(ev)
|
||||
p.event(PlacementViewsEvent, body)
|
||||
p.event(AssignmentsViewsEvent, body)
|
||||
}
|
||||
p.placeMu.Unlock()
|
||||
}
|
||||
@@ -180,18 +180,18 @@ func (p *player) followPlacement() {
|
||||
select {
|
||||
case <-listed:
|
||||
case <-time.After(10 * time.Second):
|
||||
p.t.Fatal("the placement was not listed")
|
||||
p.t.Fatal("the assignments was not listed")
|
||||
}
|
||||
}
|
||||
|
||||
// firstViewAnswered waits until the vault's first view of the placement is answered, so what the test writes after it
|
||||
// firstViewAnswered waits until the vault's first view of the assignments is answered, so what the test writes after it
|
||||
// reaches the vault only as the owner's events.
|
||||
func (p *player) firstViewAnswered() {
|
||||
p.t.Helper()
|
||||
select {
|
||||
case <-p.answered:
|
||||
case <-time.After(30 * time.Second):
|
||||
p.t.Fatal("the vault never asked its first view of the placement")
|
||||
p.t.Fatal("the vault never asked its first view of the assignments")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,9 +364,9 @@ func (p *player) handle(m wire) {
|
||||
p.placeMu.Lock()
|
||||
following := p.placeValues != nil
|
||||
p.placeMu.Unlock()
|
||||
if ask.Key == PlacementTool && following {
|
||||
if ask.Key == AssignmentsTool && following {
|
||||
p.placeMu.Lock()
|
||||
answer := map[string]any{"v": 1, "owner": "mesh-delivery-assigner", "state": "placement", "revision": p.placeRevision,
|
||||
answer := map[string]any{"v": 1, "owner": "mesh-delivery-assigner", "state": "assignments", "revision": p.placeRevision,
|
||||
"created": placeCreated, "values": p.placeValues, "at": time.Now()}
|
||||
raw, _ := json.Marshal(answer)
|
||||
p.placeMu.Unlock()
|
||||
@@ -492,7 +492,7 @@ func TestTheVaultWholeMintsOnTheBusWhoeverHoldsTheLease(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, b := range []string{"mesh-vault_bus-accounts", "mesh-grants_accounts",
|
||||
"mesh-provisioner_plans", "node-engine_have", "mesh-delivery-assigner_placement"} {
|
||||
"mesh-provisioner_plans", "node-engine_have", "mesh-delivery-assigner_assignments"} {
|
||||
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: b, History: 2}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -549,7 +549,7 @@ func TestTheVaultWholeMintsOnTheBusWhoeverHoldsTheLease(t *testing.T) {
|
||||
{ID: "act-ok", By: "novox.mesh-config", At: time.Now(), Verb: "mesh-vault.retire", Args: []string{"g14 dunst token ret-1"}},
|
||||
{ID: "act-other", By: "novox.mesh-config", At: time.Now(), Verb: "mesh-vault.retire", Args: []string{"g14 dunst other ret-1"}}}}, nil
|
||||
}
|
||||
p.followPlacement()
|
||||
p.followAssignments()
|
||||
go p.serve(stdout)
|
||||
|
||||
status := func() MintState {
|
||||
|
||||
@@ -16,7 +16,7 @@ package main
|
||||
// `node-account-confirm` is the node-engine's, dialled as the new login, which the runtime proves: the old login's hash
|
||||
// is then removed, and `rotation-done` is said once the loaded list lacks it, when the old value is dropped and the
|
||||
// rotating part of the key cleared. `abandon` drops the new login and its value before the confirmation and keeps the
|
||||
// old hash. A key whose node leaves the placement is deleted.
|
||||
// old hash. A key whose node leaves the assignments is deleted.
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -633,13 +633,13 @@ func (v *Vault) RotationState() RotationState {
|
||||
return RotationState{Rotating: append([]NodeLogin{}, running...), Queued: append([]queuedRotation{}, v.nr.queue...)}
|
||||
}
|
||||
|
||||
// LoginsPass deletes the key of every node that left the placement (ADR 0583 §1 insight). A placement that cannot be
|
||||
// LoginsPass deletes the key of every node that left the assignments (ADR 0583 §1 insight). An assignment that cannot be
|
||||
// read, or holds no node, deletes nothing.
|
||||
func (v *Vault) LoginsPass() {
|
||||
if v.Logins == nil || v.Placement.Keys == nil {
|
||||
if v.Logins == nil || v.Assigner.Keys == nil {
|
||||
return
|
||||
}
|
||||
placed, err := v.placements()
|
||||
placed, err := v.assignments()
|
||||
if err != nil || len(placed) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -654,9 +654,9 @@ func (v *Vault) LoginsPass() {
|
||||
}
|
||||
}
|
||||
|
||||
// NodeLeft is heard when a node's key of the placement is deleted: its key of node-logins goes with it.
|
||||
// NodeLeft is heard when a node's key of the assignments is deleted: its key of node-logins goes with it.
|
||||
func (v *Vault) NodeLeft(node string) {
|
||||
if v.Logins == nil || v.Placement.Read == nil {
|
||||
if v.Logins == nil || v.Assigner.Read == nil {
|
||||
return
|
||||
}
|
||||
if _, _, found, err := v.nodePlaced(node); err != nil || found {
|
||||
@@ -667,8 +667,8 @@ func (v *Vault) NodeLeft(node string) {
|
||||
|
||||
func (v *Vault) nodeLeft(node string) {
|
||||
if err := v.Logins.Delete(node); err != nil {
|
||||
v.log("%s left the placement, and its key of %s could not be deleted: %v", node, NodeLoginsState, err)
|
||||
v.log("%s left the assignments, and its key of %s could not be deleted: %v", node, NodeLoginsState, err)
|
||||
return
|
||||
}
|
||||
v.log("%s left the placement: its key of %s is deleted", node, NodeLoginsState)
|
||||
v.log("%s left the assignments: its key of %s is deleted", node, NodeLoginsState)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (v *Vault) credentialRefusal(node string, c CredentialAsked, plan *planRead
|
||||
if c.Consumer != node {
|
||||
return fmt.Sprintf("%s asks as a consumer on %s, and is not that machine", node, c.Consumer)
|
||||
}
|
||||
// The consuming module stands on the machine: read from the placement and the assignments, never assumed (one
|
||||
// The consuming module stands on the machine: read from the assignments and the assignments, never assumed (one
|
||||
// that cannot be read refuses). The assignments' mirror can be behind, so one it does not hold is confirmed directly.
|
||||
placed, err := plan.placedOn(c.ConsumerModule)
|
||||
if err != nil {
|
||||
@@ -102,7 +102,7 @@ func (v *Vault) credentialRefusal(node string, c CredentialAsked, plan *planRead
|
||||
return ""
|
||||
}
|
||||
raw, why, err := plan.read(c.ConsumerModule)
|
||||
if why != "" && v.Placement.Read == nil {
|
||||
if why != "" && v.Assigner.Read == nil {
|
||||
return why
|
||||
}
|
||||
if why == "" {
|
||||
@@ -130,18 +130,18 @@ func (v *Vault) credentialRefusal(node string, c CredentialAsked, plan *planRead
|
||||
|
||||
// planReader reads the assignments of one machine's modules for one answer of `own`, each module's once (issue 1126,
|
||||
// 2026-10-28: one read per own secret and per credential, 203 on novox, held the answer past the node-engine's bound),
|
||||
// and the machine's placement once (issue 774, 2026-10-31: read once per credential, 143 bus reads in one answer to ace).
|
||||
// and the machine's assignments once (issue 774, 2026-10-31: read once per credential, 143 bus reads in one answer to ace).
|
||||
type planReader struct {
|
||||
node string
|
||||
reader AssignmentReader
|
||||
confirm AssignmentReader
|
||||
why string
|
||||
got map[string]planRead
|
||||
// placement reads the machine's placed modules; placed and placedErr keep the one read for the answer.
|
||||
placement func() ([]string, error)
|
||||
placedRead bool
|
||||
placed []string
|
||||
placedErr error
|
||||
// assignments reads the machine's placed modules; placed and placedErr keep the one read for the answer.
|
||||
assignments func() ([]string, error)
|
||||
placedRead bool
|
||||
placed []string
|
||||
placedErr error
|
||||
}
|
||||
|
||||
type planRead struct {
|
||||
@@ -156,13 +156,13 @@ func (v *Vault) plansOf(node string) *planReader {
|
||||
confirm = standing(d.Confirm)
|
||||
}
|
||||
return &planReader{node: node, confirm: confirm, reader: read, why: why, got: map[string]planRead{},
|
||||
placement: func() ([]string, error) { return v.placedModules(node) }}
|
||||
assignments: func() ([]string, error) { return v.placedModules(node) }}
|
||||
}
|
||||
|
||||
// placedOn says module is placed on the machine by the catalogue, from the machine's placement read once for the answer.
|
||||
// placedOn says module is placed on the machine by the catalogue, from the machine's assignments read once for the answer.
|
||||
func (p *planReader) placedOn(module string) (bool, error) {
|
||||
if !p.placedRead {
|
||||
p.placed, p.placedErr = p.placement()
|
||||
p.placed, p.placedErr = p.assignments()
|
||||
p.placedRead = true
|
||||
}
|
||||
return slices.Contains(p.placed, module), p.placedErr
|
||||
@@ -170,8 +170,8 @@ func (p *planReader) placedOn(module string) (bool, error) {
|
||||
|
||||
// placedModules is the machine's placed modules, read once for the answer.
|
||||
func (p *planReader) placedModules() ([]string, error) {
|
||||
if p.placement == nil {
|
||||
return nil, errors.New("the machine's placement is not read here")
|
||||
if p.assignments == nil {
|
||||
return nil, errors.New("the machine's assignments is not read here")
|
||||
}
|
||||
p.placedOn("")
|
||||
return p.placed, p.placedErr
|
||||
@@ -458,7 +458,7 @@ func (v *Vault) HandedOf(node string) ([]HandedJudged, error) {
|
||||
if placedErr != nil {
|
||||
// Never dropped: an answer that leaves out the modules placed there, with no word of it, would read as "the others
|
||||
// are not placed" (issue 1966 review note).
|
||||
return nil, fmt.Errorf("the placement of %s could not be read, so the modules placed there are not all judged: %w", node, placedErr)
|
||||
return nil, fmt.Errorf("the assignments of %s could not be read, so the modules placed there are not all judged: %w", node, placedErr)
|
||||
}
|
||||
for _, m := range placed {
|
||||
modules[m] = true
|
||||
|
||||
@@ -146,10 +146,10 @@ func TestOwnReadsEachAssignmentOnceAndSyncsItsRecordOnce(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// Issue 774, 2026-10-31 (ace's 143 credentials went unanswered past the node-engine's 15 s while novox's asked every
|
||||
// 8 s): the machine's placement, one key, is read once per answer too, never once per credential.
|
||||
placed := placementsOf(t, map[string][]string{"anchor": {"web"}})
|
||||
placementReads := 0
|
||||
v.Placement = PlacementReader{Keys: placed.Keys, Read: func(key string) ([]byte, error) { placementReads++; return placed.Read(key) }}
|
||||
// 8 s): the machine's assignments, one key, is read once per answer too, never once per credential.
|
||||
placed := assignedNodes(t, map[string][]string{"anchor": {"web"}})
|
||||
assignmentsReads := 0
|
||||
v.Assigner = AssignerReader{Keys: placed.Keys, Read: func(key string) ([]byte, error) { assignmentsReads++; return placed.Read(key) }}
|
||||
for k := range reads {
|
||||
delete(reads, k)
|
||||
}
|
||||
@@ -168,10 +168,10 @@ func TestOwnReadsEachAssignmentOnceAndSyncsItsRecordOnce(t *testing.T) {
|
||||
if len(reads) != 2 {
|
||||
t.Errorf("the answer read %v, want each of anchor's two modules once", reads)
|
||||
}
|
||||
if placementReads != 1 {
|
||||
t.Errorf("one answer of two credentials read anchor's placement %d times, want once", placementReads)
|
||||
if assignmentsReads != 1 {
|
||||
t.Errorf("one answer of two credentials read anchor's assignments %d times, want once", assignmentsReads)
|
||||
}
|
||||
v.Placement = PlacementReader{}
|
||||
v.Assigner = AssignerReader{}
|
||||
if n := v.Store.syncs - syncs; n != 1 {
|
||||
t.Errorf("one answer synced the record %d times", n)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestOwnLeavesOutOnlyAModuleWhosePlanHandsIt(t *testing.T) {
|
||||
}
|
||||
v := newVault(t, nil)
|
||||
v.Askers = Declared{Read: plans.read, Store: v.Store}
|
||||
v.Placement = placementsOf(t, map[string][]string{"anchor": {"grafana", "web", "db"}})
|
||||
v.Assigner = assignedNodes(t, map[string][]string{"anchor": {"grafana", "web", "db"}})
|
||||
pub, _ := aSealingKey(t)
|
||||
for _, m := range []MoveOf{
|
||||
{Node: "anchor", Module: "grafana", Name: "admin", Origin: "made", Generation: "g-1", SealingKey: pub},
|
||||
@@ -315,14 +315,14 @@ func TestOwnLeavesOutOnlyAModuleWhosePlanHandsIt(t *testing.T) {
|
||||
if len(judged) != 4 {
|
||||
t.Errorf("own_handed names %v, want builder, db, grafana and web", judged)
|
||||
}
|
||||
// Review note of issue 1966: a placement that cannot be read is an error the tool answers, never a list that leaves out
|
||||
// Review note of issue 1966: an assignment that cannot be read is an error the tool answers, never a list that leaves out
|
||||
// the modules placed there while the vault keeps an own secret of others.
|
||||
v.Placement = PlacementReader{Keys: func() ([]string, error) { return nil, errors.New("the bus did not answer") },
|
||||
v.Assigner = AssignerReader{Keys: func() ([]string, error) { return nil, errors.New("the bus did not answer") },
|
||||
Read: func(string) ([]byte, error) { return nil, errors.New("the bus did not answer") }}
|
||||
if got, err := v.HandedOf("anchor"); err == nil || !strings.Contains(err.Error(), "placement of anchor could not be read") || got != nil {
|
||||
t.Errorf("an unreadable placement answered %v, %v", got, err)
|
||||
if got, err := v.HandedOf("anchor"); err == nil || !strings.Contains(err.Error(), "assignments of anchor could not be read") || got != nil {
|
||||
t.Errorf("an unreadable assignments answered %v, %v", got, err)
|
||||
}
|
||||
if _, err := toolNamed(t, definitions(&Env{Vault: v.Vault}), "own_handed").Run(map[string]any{"node": "anchor"}); err == nil {
|
||||
t.Error("own_handed answered with the placement unread")
|
||||
t.Error("own_handed answered with the assignments unread")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ type Drift struct {
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
// OwnDrift reads every node's own have key (`<node>.node`) and lists, from its latest answers to the placement
|
||||
// OwnDrift reads every node's own have key (`<node>.node`) and lists, from its latest answers to the assignments
|
||||
// candidates, every own secret whose shown bodies say another value (vaultclient.OwnValuesDiffer), with what the vault holds
|
||||
// of it and whether move-in with replace_running would take the running value now.
|
||||
func (v *Vault) OwnDrift() (Drift, error) {
|
||||
|
||||
@@ -1,89 +1,78 @@
|
||||
package main
|
||||
|
||||
// Where modules stand, from the placement (novox/hq ADR 0549 §3, §5; ADR 0561; issue 774), the seat mesh-module-assigner's
|
||||
// state held by the assigner (ADR 0567). The controller's assignments mirror goes with its lease, so the vault reads which
|
||||
// module stands on which node from the seat's placement first, and the assignments beside it while both stand: a module either names stands. The provisioner's plan,
|
||||
// which only an assignment's value carries, is read from the assignments still: its home after the lease is a subtask of
|
||||
// its own (issue 774).
|
||||
// Where modules stand, from the seat mesh-module-assigner's state assignments (novox/hq ADR 0549 §3, §5; ADR 0561;
|
||||
// issue 774), held by the assigner (ADR 0567). The controller's mirror of bindings (Vault.Assignments) goes with its lease,
|
||||
// so the vault reads which module stands on which node from the seat's assignments first, and the mirror beside it while
|
||||
// both stand: a module either names stands. The provisioner's plan, which only a binding's value carries, is read from
|
||||
// the mirror still: its home after the lease is a subtask of its own (issue 774).
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PlacementReader reads the seat's placement: every key, and one key's value (nil when there is none).
|
||||
type PlacementReader struct {
|
||||
// AssignerReader reads the seat's assignments: every key, and one key's value (nil when there is none).
|
||||
type AssignerReader struct {
|
||||
Keys func() ([]string, error)
|
||||
Read func(key string) ([]byte, error)
|
||||
}
|
||||
|
||||
// placements is every node's placement, by node, from the state's keys in either form (assignerclient.PlacementsOf; research
|
||||
// 072 row 37); none when the vault reads no placement. A node whose keys do not read whole is read as they stand.
|
||||
func (v *Vault) placements() (map[string]placing.Placement, error) {
|
||||
out := map[string]placing.Placement{}
|
||||
if v.Placement.Keys == nil || v.Placement.Read == nil {
|
||||
// assignments is every node's assignments, by node, from the state's keys (assignerclient.AssignmentsOf; research
|
||||
// 072 row 37); none when the vault reads no assignments. A node whose keys do not read whole is read as they stand.
|
||||
func (v *Vault) assignments() (map[string]placing.Assignments, error) {
|
||||
out := map[string]placing.Assignments{}
|
||||
if v.Assigner.Keys == nil || v.Assigner.Read == nil {
|
||||
return out, nil
|
||||
}
|
||||
keys, err := v.Placement.Keys()
|
||||
keys, err := v.Assigner.Keys()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the placement's keys could not be read: %w", err)
|
||||
return nil, fmt.Errorf("the mirror's keys could not be read: %w", err)
|
||||
}
|
||||
values := map[string][]byte{}
|
||||
for _, k := range keys {
|
||||
if _, _, _, err := assignerclient.ParseKey(k); err != nil {
|
||||
continue
|
||||
}
|
||||
raw, err := v.Placement.Read(k)
|
||||
raw, err := v.Assigner.Read(k)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the placement's key %s could not be read: %w", k, err)
|
||||
return nil, fmt.Errorf("the assignments' key %s could not be read: %w", k, err)
|
||||
}
|
||||
if raw != nil {
|
||||
values[k] = raw
|
||||
}
|
||||
}
|
||||
out, _ = assignerclient.PlacementsOf(values)
|
||||
out, _ = assignerclient.AssignmentsOf(values)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// nodePlaced is what node's own key of the placement says: the modules placed there and what a person decided of it,
|
||||
// read from its node key `<node>.node` alone (which names every module placed, research 072 row 37), or, for a node not
|
||||
// converted yet, from its key in the form before, `placement.<node>`. found is false when it has neither.
|
||||
// nodePlaced is what node's own key of the assignments says: the modules placed there and what a person decided of it,
|
||||
// read from its node key `<node>.node` alone (which names every module placed, research 072 row 37). found is false when
|
||||
// it has none.
|
||||
func (v *Vault) nodePlaced(node string) (modules []string, decided placing.NodeDecided, found bool, err error) {
|
||||
key, err := assignerclient.NodeKey(node)
|
||||
if err != nil {
|
||||
return nil, decided, false, err
|
||||
}
|
||||
raw, err := v.Placement.Read(key)
|
||||
raw, err := v.Assigner.Read(key)
|
||||
if err != nil {
|
||||
return nil, decided, false, err
|
||||
}
|
||||
if raw != nil {
|
||||
n, err := assignerclient.DecodeNode(raw)
|
||||
if err != nil {
|
||||
return nil, decided, false, fmt.Errorf("the placement of %s is not readable: %w", node, err)
|
||||
return nil, decided, false, fmt.Errorf("the assignments of %s are not readable: %w", node, err)
|
||||
}
|
||||
for _, r := range n.Modules {
|
||||
modules = append(modules, r.Module)
|
||||
}
|
||||
return modules, n.Decided, true, nil
|
||||
}
|
||||
legacy, err := assignerclient.LegacyKey(node)
|
||||
if err != nil {
|
||||
return nil, decided, false, err
|
||||
}
|
||||
if raw, err = v.Placement.Read(legacy); err != nil || raw == nil {
|
||||
return nil, decided, false, err
|
||||
}
|
||||
p, err := assignerclient.DecodePlacement(raw)
|
||||
if err != nil {
|
||||
return nil, decided, false, fmt.Errorf("the placement of %s is not readable: %w", node, err)
|
||||
}
|
||||
return assignerclient.Assigned(p), p.Decided, true, nil
|
||||
return nil, decided, false, nil
|
||||
}
|
||||
|
||||
// placedOn says module is placed on node by the catalogue.
|
||||
@@ -92,17 +81,17 @@ func (v *Vault) placedOn(node, module string) (bool, error) {
|
||||
return slices.Contains(placed, module), err
|
||||
}
|
||||
|
||||
// placedModules is every module the catalogue places on node, read from the node's own key of the placement
|
||||
// (nodePlaced); none when the vault reads no placement or the node has no key.
|
||||
// placedModules is every module the catalogue places on node, read from the node's own key of the assignments
|
||||
// (nodePlaced); none when the vault reads no assignments or the node has no key.
|
||||
func (v *Vault) placedModules(node string) ([]string, error) {
|
||||
if v.Placement.Read == nil {
|
||||
if v.Assigner.Read == nil {
|
||||
return nil, nil
|
||||
}
|
||||
modules, _, _, err := v.nodePlaced(node)
|
||||
return modules, err
|
||||
}
|
||||
|
||||
// standsOn says module stands on node: placed there, or assigned there while the assignments stand. A read that fails is
|
||||
// standsOn says module stands on node: placed there, or bound there while the mirror stands. A read that fails is
|
||||
// an error, never "not there".
|
||||
func (v *Vault) standsOn(node, module string) (bool, error) {
|
||||
placed, err := v.placedOn(node, module)
|
||||
@@ -111,8 +100,8 @@ func (v *Vault) standsOn(node, module string) (bool, error) {
|
||||
}
|
||||
d, ok := v.Askers.(Declared)
|
||||
if !ok || d.Read == nil {
|
||||
if v.Placement.Read == nil {
|
||||
return false, errors.New("the vault reads neither the placement nor the assignments")
|
||||
if v.Assigner.Read == nil {
|
||||
return false, errors.New("the vault reads neither the seat's assignments nor the mirror")
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
@@ -120,10 +109,10 @@ func (v *Vault) standsOn(node, module string) (bool, error) {
|
||||
return raw != nil, err
|
||||
}
|
||||
|
||||
// busNode is the node running the bus's module: from the placement, and from the assignments while no placement names
|
||||
// busNode is the node running the bus's module: from the seat's assignments, and from the mirror while no assignment names
|
||||
// one. The vault adopts from one node alone.
|
||||
func (v *Vault) busNode() (string, error) {
|
||||
placed, err := v.placements()
|
||||
placed, err := v.assignments()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -138,7 +127,7 @@ func (v *Vault) busNode() (string, error) {
|
||||
from = "assigned"
|
||||
keys, err := v.Assignments.Keys()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("the assignments' keys could not be read: %w", err)
|
||||
return "", fmt.Errorf("the mirror's keys could not be read: %w", err)
|
||||
}
|
||||
for _, k := range keys {
|
||||
if node, module, ok := strings.Cut(k, "."); ok && module == BusModule {
|
||||
@@ -146,7 +135,7 @@ func (v *Vault) busNode() (string, error) {
|
||||
}
|
||||
}
|
||||
} else if len(nodes) == 0 && len(placed) == 0 {
|
||||
return "", errors.New("the vault reads neither the placement nor the assignments, so it cannot tell which node holds the bus")
|
||||
return "", errors.New("the vault reads neither the seat's assignments nor the mirror, so it cannot tell which node holds the bus")
|
||||
}
|
||||
sort.Strings(nodes)
|
||||
switch len(nodes) {
|
||||
|
||||
@@ -7,22 +7,22 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
vaultclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
)
|
||||
|
||||
// placementsOf is the seat mesh-module-assigner's placement of each node, as the vault reads it.
|
||||
func placementsOf(t *testing.T, nodes map[string][]string) PlacementReader {
|
||||
// assignedNodes is the seat mesh-module-assigner's assignments of each node, as the vault reads it.
|
||||
func assignedNodes(t *testing.T, nodes map[string][]string) AssignerReader {
|
||||
t.Helper()
|
||||
values := map[string][]byte{}
|
||||
for node, modules := range nodes {
|
||||
p := placing.Placement{V: vaultclient.Version, Node: node}
|
||||
p := placing.Assignments{V: vaultclient.Version, Node: node}
|
||||
for _, m := range modules {
|
||||
p.Modules = append(p.Modules, placing.PlacedModule{Module: m})
|
||||
}
|
||||
// Research 072 row 37: the node key and a key per module.
|
||||
kv, err := assignerclient.PlacementValues(p)
|
||||
kv, err := assignerclient.AssignmentsValues(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ func placementsOf(t *testing.T, nodes map[string][]string) PlacementReader {
|
||||
values[k] = raw
|
||||
}
|
||||
}
|
||||
return PlacementReader{
|
||||
return AssignerReader{
|
||||
Keys: func() ([]string, error) {
|
||||
var out []string
|
||||
for k := range values {
|
||||
@@ -43,30 +43,30 @@ func placementsOf(t *testing.T, nodes map[string][]string) PlacementReader {
|
||||
}
|
||||
|
||||
// 774/AC11 (novox/hq ADR 0561, ADR 0549 §3, §5): with no assignments to read, the vault tells from the seat's
|
||||
// placement which node holds the bus and whether a consumer's module stands on its node; while both stand, a module
|
||||
// assignments which node holds the bus and whether a consumer's module stands on its node; while both stand, a module
|
||||
// either names stands.
|
||||
func TestTheVaultReadsWhereModulesStandFromPlacement(t *testing.T) {
|
||||
func TestTheVaultReadsWhereModulesStandFromAssignments(t *testing.T) {
|
||||
v := newVault(t, nil)
|
||||
v.Placement = placementsOf(t, map[string][]string{"novox": {"nats", "web"}, "ace": {"shop"}})
|
||||
v.Assigner = assignedNodes(t, map[string][]string{"novox": {"nats", "web"}, "ace": {"shop"}})
|
||||
if node, err := v.busNode(); err != nil || node != "novox" {
|
||||
t.Errorf("the bus node from placement: %q, %v", node, err)
|
||||
t.Errorf("the bus node from assignments: %q, %v", node, err)
|
||||
}
|
||||
asked := func(node, module string) CredentialAsked {
|
||||
return CredentialAsked{Role: "consumer", Provision: "postgres", Consumer: node, ConsumerModule: module, Provider: "novox"}
|
||||
}
|
||||
if why := v.credentialRefusal("ace", asked("ace", "shop"), v.plansOf("ace")); why != "" {
|
||||
t.Errorf("shop stands on ace by placement, refused: %s", why)
|
||||
t.Errorf("shop stands on ace by assignments, refused: %s", why)
|
||||
}
|
||||
if why := v.credentialRefusal("ace", asked("ace", "web"), v.plansOf("ace")); !strings.Contains(why, "is not on ace") {
|
||||
t.Errorf("web is not placed on ace, and is answered %q", why)
|
||||
}
|
||||
// While both stand, an assignment still names a module placement does not yet.
|
||||
// While both stand, an assignment still names a module assignments does not yet.
|
||||
v.Askers = Declared{Read: assignments{"ace.web": `{"node":"ace","module":"web"}`}.read, Store: v.Store}
|
||||
if why := v.credentialRefusal("ace", asked("ace", "web"), v.plansOf("ace")); why != "" {
|
||||
t.Errorf("web assigned on ace, refused: %s", why)
|
||||
}
|
||||
// Two nodes placed with the bus: the vault adopts from neither.
|
||||
v.Placement = placementsOf(t, map[string][]string{"novox": {"nats"}, "ace": {"nats"}})
|
||||
v.Assigner = assignedNodes(t, map[string][]string{"novox": {"nats"}, "ace": {"nats"}})
|
||||
if _, err := v.busNode(); err == nil || !strings.Contains(err.Error(), "2 nodes") {
|
||||
t.Errorf("two bus nodes: %v", err)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func TestTheVaultReadsWhereModulesStandFromPlacement(t *testing.T) {
|
||||
|
||||
// The assigner's tool and views family the vault names are the ones its manifest invokes and consumes; no client names a
|
||||
// holder (novox/hq ADR 0625 §4).
|
||||
func TestThePlacementNamesAreTheManifests(t *testing.T) {
|
||||
func TestTheAssignmentsNamesAreTheManifests(t *testing.T) {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -95,7 +95,7 @@ func TestThePlacementNamesAreTheManifests(t *testing.T) {
|
||||
t.Errorf("the vault reads %s, its manifest's reads are %v", r, reads.Reads)
|
||||
}
|
||||
}
|
||||
if !slices.Contains(m.Invokes, PlacementTool) || !slices.Contains(m.Consumes, PlacementViewsEvent) {
|
||||
t.Errorf("the vault asks %s and follows %s, its manifest invokes %v and consumes %v", PlacementTool, PlacementViewsEvent, m.Invokes, m.Consumes)
|
||||
if !slices.Contains(m.Invokes, AssignmentsTool) || !slices.Contains(m.Consumes, AssignmentsViewsEvent) {
|
||||
t.Errorf("the vault asks %s and follows %s, its manifest invokes %v and consumes %v", AssignmentsTool, AssignmentsViewsEvent, m.Invokes, m.Consumes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
engineclient "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
nodeseat "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
vaultclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -58,7 +58,7 @@ func TestTheVaultWholeRotatesANodesLoginWithAStandInEngine(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, b := range []string{"mesh-vault_bus-accounts", "mesh-vault_node-logins", "mesh-grants_accounts",
|
||||
"mesh-provisioner_plans", "node-engine_have", "mesh-delivery-assigner_placement"} {
|
||||
"mesh-provisioner_plans", "node-engine_have", "mesh-delivery-assigner_assignments"} {
|
||||
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: b, History: 2}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func TestTheVaultWholeRotatesANodesLoginWithAStandInEngine(t *testing.T) {
|
||||
}
|
||||
return map[string]any{"acts": []HandActSeen{{ID: "act-1", By: "person.jochen", At: time.Now(), Verb: "rotate-node", Args: []string{"g14"}}}}, nil
|
||||
}
|
||||
p.followPlacement()
|
||||
p.followAssignments()
|
||||
go p.serve(stdout)
|
||||
|
||||
oldPassword := "the-old-password-of-g14"
|
||||
@@ -160,21 +160,21 @@ func TestTheVaultWholeRotatesANodesLoginWithAStandInEngine(t *testing.T) {
|
||||
reload()
|
||||
// The bus node (novox, running nats) and the node that rotates (g14); no lease key anywhere (issue 1126: the controller
|
||||
// ended by its unassignment); g14's login adopted from
|
||||
// the loaded list, its password known to the engine. Written after the vault's first view of the placement, so they
|
||||
// the loaded list, its password known to the engine. Written after the vault's first view of the assignments, so they
|
||||
// reach it only as the owner's views events, and after the bus node's have: the vault heard that have while no node
|
||||
// held the bus, and adopts from it (learning the loaded list's revision) when the placement names novox.
|
||||
// held the bus, and adopts from it (learning the loaded list's revision) when the assignments names novox.
|
||||
p.firstViewAnswered()
|
||||
for node, modules := range map[string][]string{"novox": {"nats"}, "g14": {"web"}} {
|
||||
pl := placing.Placement{V: vaultclient.Version, Node: node}
|
||||
pl := placing.Assignments{V: vaultclient.Version, Node: node}
|
||||
for _, m := range modules {
|
||||
pl.Modules = append(pl.Modules, placing.PlacedModule{Module: m})
|
||||
}
|
||||
values, err := assignerclient.PlacementValues(pl)
|
||||
values, err := assignerclient.AssignmentsValues(pl)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for k, raw := range values {
|
||||
kv, _ := p.kv("mesh-delivery-assigner.placement")
|
||||
kv, _ := p.kv("mesh-delivery-assigner.assignments")
|
||||
if _, err := kv.Put(ctx, k, raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
// The vault signs (novox/hq ADR 0550 §2; issue 774, design 47's L3 item d). It makes an ed25519 signing key and an x509
|
||||
// authority once, keeps each as its own secret with its operator copy (ADR 0113 §22), publishes their public halves in its
|
||||
// state `signers`, and signs with them on its verb `sign`: a node's certificate for that node's node-engine alone, built
|
||||
// from bus state (the name from the node's placement, the serving key from its record), never from bytes the caller chose.
|
||||
// from bus state (the name from the node's assignments, the serving key from its record), never from bytes the caller chose.
|
||||
// Each signature is said as `signed` and kept in the record of hand-outs, never a key. The controller's key is never
|
||||
// copied here.
|
||||
|
||||
@@ -295,7 +295,7 @@ func (v *Vault) redeeming(node string) error {
|
||||
// signRedeemingCertificate signs the certificate of a machine that is joining, for the seat mesh-node-enroller at the redeem
|
||||
// (ADR 0587 §6). The machine has written no record yet, so the serving key is the one it presented at the redeem, which
|
||||
// counts only when the four keys presented have the digest node-account recorded for its account; the name is its
|
||||
// placement's, which mesh-enrolment writes before it asks.
|
||||
// the assignments', which mesh-enrolment writes before it asks.
|
||||
func (v *Vault) signRedeemingCertificate(caller, node string, keys PresentedKeys) (meshvault.SignAnswer, error) {
|
||||
if err := v.redeeming(node); err != nil {
|
||||
return meshvault.SignAnswer{}, err
|
||||
@@ -368,7 +368,7 @@ func (v *Vault) signNodeCertificate(caller, asked string) (meshvault.SignAnswer,
|
||||
return v.signCertificateFor(caller, node)
|
||||
}
|
||||
|
||||
// signCertificateFor signs node's certificate from its placement's name and its record's serving key.
|
||||
// signCertificateFor signs node's certificate from its the assignments' name and its record's serving key.
|
||||
func (v *Vault) signCertificateFor(caller, node string) (meshvault.SignAnswer, error) {
|
||||
name, err := v.internalName(node)
|
||||
if err != nil {
|
||||
@@ -401,21 +401,21 @@ func (v *Vault) signCertificateWith(caller, node, name string, serving ed25519.P
|
||||
return answer, nil
|
||||
}
|
||||
|
||||
// internalName is node's name inside the mesh: only a node with an address on the private network in its placement has
|
||||
// internalName is node's name inside the mesh: only a node with an address on the private network in its assignments has
|
||||
// one (a certificate for a name nothing resolves is one nothing can check).
|
||||
func (v *Vault) internalName(node string) (string, error) {
|
||||
if v.Placement.Read == nil {
|
||||
return "", errors.New("the vault reads no placement, so it cannot tell a node's internal name")
|
||||
if v.Assigner.Read == nil {
|
||||
return "", errors.New("the vault reads no assignments, so it cannot tell a node's internal name")
|
||||
}
|
||||
_, decided, found, err := v.nodePlaced(node)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(notYetPrefix+"the placement of %s could not be read: %w", node, err)
|
||||
return "", fmt.Errorf(notYetPrefix+"the assignments of %s could not be read: %w", node, err)
|
||||
}
|
||||
if !found {
|
||||
return "", fmt.Errorf("%s has no placement of the seat mesh-module-assigner, so it has no name inside the mesh", node)
|
||||
return "", fmt.Errorf("%s has no assignments of the seat mesh-module-assigner, so it has no name inside the mesh", node)
|
||||
}
|
||||
if decided.Address == "" {
|
||||
return "", fmt.Errorf("%s is not on the private network (its placement names no address), so it has no name inside the mesh to be certified for", node)
|
||||
return "", fmt.Errorf("%s is not on the private network (its assignments names no address), so it has no name inside the mesh to be certified for", node)
|
||||
}
|
||||
return overlay.InternalName(node), nil
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
engineclient "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
nodeseat "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
vaultclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
|
||||
"git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
placing "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -33,32 +33,29 @@ func (s *signersState) Put(key string, value []byte) error {
|
||||
|
||||
// L3 s2 to s5 (novox/hq ADR 0550 §2): the vault makes its signing key and authority once, with their operator copies and
|
||||
// no other holder; publishes their public halves only when they differ; signs a node's certificate for that node's
|
||||
// node-engine alone, from its placement's name and its record's serving key; and no answer, event or record carries a
|
||||
// node-engine alone, from its the assignments' name and its record's serving key; and no answer, event or record carries a
|
||||
// key.
|
||||
func TestTheVaultSigns(t *testing.T) {
|
||||
v := newVault(t, nil)
|
||||
state := &signersState{keys: map[string][]byte{}}
|
||||
v.Signers = state
|
||||
servingPub, _, _ := ed25519.GenerateKey(rand.Reader)
|
||||
placements := map[string]placing.Placement{
|
||||
assignments := map[string]placing.Assignments{
|
||||
"ace": {Node: "ace", Decided: placing.NodeDecided{Address: "10.77.0.3"}},
|
||||
"g14": {Node: "g14", Decided: placing.NodeDecided{Address: "10.77.0.4"}},
|
||||
"plain": {Node: "plain"},
|
||||
}
|
||||
// Research 072 row 37: ace and plain in their keys per module and node, g14 still in the form before.
|
||||
v.Placement = PlacementReader{Read: func(key string) ([]byte, error) {
|
||||
node, _, kind, err := assignerclient.ParseKey(key)
|
||||
// Research 072 row 37: every node in its keys per module and node.
|
||||
v.Assigner = AssignerReader{Read: func(key string) ([]byte, error) {
|
||||
node, _, _, err := assignerclient.ParseKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p, ok := placements[node]
|
||||
if !ok || (node == "g14") != (kind == assignerclient.LegacyKind) {
|
||||
p, ok := assignments[node]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
if kind == assignerclient.LegacyKind {
|
||||
return assignerclient.EncodePlacement(p)
|
||||
}
|
||||
values, err := assignerclient.PlacementValues(p)
|
||||
values, err := assignerclient.AssignmentsValues(p)
|
||||
return values[key], err
|
||||
}}
|
||||
records := map[string]string{"ace": base64.StdEncoding.EncodeToString(servingPub), "plain": base64.StdEncoding.EncodeToString(servingPub)}
|
||||
|
||||
@@ -319,27 +319,27 @@ func TestSecretOwnListsFingerprintsOfOwnSecretsOnly(t *testing.T) {
|
||||
if _, err := v.AdoptFrom("ace", have(), "the test", true); err == nil || !strings.Contains(err.Error(), "does not hold the bus") {
|
||||
t.Errorf("a handing from a node not holding the bus: %v", err)
|
||||
}
|
||||
// A have heard while the placement names no node holding the bus adopts nothing then; it is kept, and adopted when
|
||||
// the placement next changes to name its node, once (the placement's event, no timer).
|
||||
// A have heard while the assignments names no node holding the bus adopts nothing then; it is kept, and adopted when
|
||||
// the assignments next changes to name its node, once (the assignments' event, no timer).
|
||||
assignedKeys := v.Assignments
|
||||
v.Assignments = Mirror{Keys: func() ([]string, error) { return []string{"ace.dunst"}, nil }}
|
||||
handing["node.ace"] = h("k")
|
||||
if _, err := v.HaveHeard("novox", have(), "the watch"); err == nil || !strings.Contains(err.Error(), "no node is") {
|
||||
t.Fatalf("a have heard before the placement names the bus node: %v", err)
|
||||
t.Fatalf("a have heard before the assignments names the bus node: %v", err)
|
||||
}
|
||||
v.PlacementChanged()
|
||||
v.AssignmentsChanged()
|
||||
if acc.keys["node.ace"].Hash != h("m") {
|
||||
t.Fatalf("adopted while no node holds the bus: %+v", acc.keys["node.ace"])
|
||||
}
|
||||
v.Assignments = assignedKeys
|
||||
before := len(v.bus.events)
|
||||
v.PlacementChanged()
|
||||
v.AssignmentsChanged()
|
||||
if acc.keys["node.ace"].Hash != h("k") || eventsNamed(v, before, AccountHashedEvent) != 1 {
|
||||
t.Fatalf("the kept have is not adopted when the placement names its node: %+v", acc.keys["node.ace"])
|
||||
t.Fatalf("the kept have is not adopted when the assignments names its node: %+v", acc.keys["node.ace"])
|
||||
}
|
||||
v.PlacementChanged()
|
||||
v.AssignmentsChanged()
|
||||
if eventsNamed(v, before, AccountHashedEvent) != 1 {
|
||||
t.Errorf("the kept have was adopted again at a later placement change")
|
||||
t.Errorf("the kept have was adopted again at a later assignments change")
|
||||
}
|
||||
listed, err := own.Run(map[string]any{})
|
||||
if err != nil {
|
||||
|
||||
@@ -66,12 +66,12 @@ type Vault struct {
|
||||
// adoption is the last adoption (adopt.go), under mu.
|
||||
adoption adoptionKept
|
||||
// heard is each node's latest have of the bus module the watch handed (adopt.go), under mu: one not adopted is
|
||||
// adopted when the placement next changes.
|
||||
// adopted when the assignments next changes.
|
||||
heard map[string]heardHave
|
||||
// WantRead reads one wanted account afresh (issue-account): nil reads the wants as the watch handed them.
|
||||
WantRead func(user string) ([]byte, bool, error)
|
||||
// Placement reads the seat's placement (placed.go): where modules stand once the assignments are gone.
|
||||
Placement PlacementReader
|
||||
// Assignments reads the seat's assignments (placed.go): where modules stand once the assignments are gone.
|
||||
Assigner AssignerReader
|
||||
// minting is what the vault knows of the wanted bus accounts (mint.go).
|
||||
minting minting
|
||||
// Signers is the vault's state `signers`, where it publishes its signing halves (signing.go, ADR 0550 §2): nil writes
|
||||
|
||||
@@ -137,7 +137,7 @@ func filesUnder(t *testing.T, dir string) map[string]string {
|
||||
// (ADR 0547 clause 9), opened in accounts.go alone. It reads five buckets of others', and only reads them: the
|
||||
// seat mesh-provisioner's plans, for what each node's plan names (ADR 0570 clause 2), (askers.go, design 57 V4), the node-engines' haves, where
|
||||
// the bus node hands the loaded list's hashes sealed to the vault (adopt.go, ADR 0547 clause 9), the grants part's wanted
|
||||
// accounts (mint.go, ADR 0561 §2), and the seat's placement (placed.go), in
|
||||
// accounts (mint.go, ADR 0561 §2), and the seat's assignments (placed.go), in
|
||||
// main.go alone.
|
||||
func TestNoBucketHoldsASecret(t *testing.T) {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
@@ -155,7 +155,7 @@ func TestNoBucketHoldsASecret(t *testing.T) {
|
||||
}
|
||||
if r, _ := json.Marshal(manifest["reads"]); string(r) != `["node-engine.have","mesh-grants.accounts","mesh-provisioner.plans","mesh-provisioner.provisions"]` {
|
||||
t.Errorf("the manifest reads %s: the vault reads the seat mesh-provisioner's plans and provisions, the haves, the "+
|
||||
"grants part's wanted accounts alone (the placement is the assigner's, through its tool and events, ADR 0615), never the controller's lease (issue 1126)", r)
|
||||
"grants part's wanted accounts alone (the assignments is the assigner's, through its tool and events, ADR 0615), never the controller's lease (issue 1126)", r)
|
||||
}
|
||||
sources, _ := filepath.Glob("*.go")
|
||||
bucket := regexp.MustCompile(`stdio\.State\(|nats-io|jetstream|\bKeyValue\b`)
|
||||
|
||||
Reference in New Issue
Block a user