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:
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
catalogclient "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
||||
catalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
@@ -155,22 +155,21 @@ func (m *memStore) assign(t *testing.T, node, module string) {
|
||||
m.place(t, node, module, true)
|
||||
}
|
||||
|
||||
// unassign takes a module off a node's placement.
|
||||
// unassign takes a module off a node's assignments.
|
||||
func (m *memStore) unassign(t *testing.T, node, module string) {
|
||||
t.Helper()
|
||||
m.place(t, node, module, false)
|
||||
}
|
||||
|
||||
// place writes a node's placement as the seat writes it: its node key and module keys (research 072 row 37), and for
|
||||
// ace in the form before, `placement.ace`, which a reader still takes while the change is delivered.
|
||||
// place writes a node's assignments as the seat writes it: its node key and module keys (research 072 row 37).
|
||||
func (m *memStore) place(t *testing.T, node, module string, on bool) {
|
||||
t.Helper()
|
||||
keys := map[string][]byte{}
|
||||
for _, k := range m.keysOf(PlacementRead) {
|
||||
e, _ := m.Get(PlacementRead, k)
|
||||
for _, k := range m.keysOf(AssignmentsRead) {
|
||||
e, _ := m.Get(AssignmentsRead, k)
|
||||
keys[k] = e.Value
|
||||
}
|
||||
all, err := assignerclient.PlacementsOf(keys)
|
||||
all, err := assignerclient.AssignmentsOf(keys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -186,25 +185,17 @@ func (m *memStore) place(t *testing.T, node, module string, on bool) {
|
||||
kept = append(kept, meshseat.PlacedModule{Module: module})
|
||||
}
|
||||
p.Modules = kept
|
||||
for _, k := range m.keysOf(PlacementRead) {
|
||||
for _, k := range m.keysOf(AssignmentsRead) {
|
||||
if n, _, _, err := assignerclient.ParseKey(k); err == nil && n == node {
|
||||
_ = m.Delete(PlacementRead, k)
|
||||
_ = m.Delete(AssignmentsRead, k)
|
||||
}
|
||||
}
|
||||
if node == "ace" {
|
||||
raw, err := assignerclient.EncodePlacement(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = m.Put(PlacementRead, "placement.ace", json.RawMessage(raw))
|
||||
return
|
||||
}
|
||||
values, err := assignerclient.PlacementValues(p)
|
||||
values, err := assignerclient.AssignmentsValues(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for k, raw := range values {
|
||||
if err := m.Put(PlacementRead, k, json.RawMessage(raw)); err != nil {
|
||||
if err := m.Put(AssignmentsRead, k, json.RawMessage(raw)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -592,7 +583,7 @@ func TestAListDroppingAKeyThatHoldsAValueIsWithheldUntilItIsCleared(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
// **A placement, a declaration or its removal moves the resolved values**, written only where they moved, and
|
||||
// **An assignment, a declaration or its removal moves the resolved values**, written only where they moved, and
|
||||
// said as config-changed; a pass over unchanged sources writes nothing.
|
||||
func TestAnAssignmentMovesTheResolvedValuesAndAQuietPassWritesNothing(t *testing.T) {
|
||||
c, m := aMesh(t)
|
||||
|
||||
@@ -148,7 +148,7 @@ type Published struct {
|
||||
Commit string `json:"commit"`
|
||||
}
|
||||
|
||||
// Assignment is a module placed on a node, as the seat mesh-module-assigner's key `placement.<node>` names it.
|
||||
// Assignment is a module placed on a node, as the seat mesh-module-assigner's key `<node>.node` names it.
|
||||
type Assignment struct {
|
||||
Node string `json:"node"`
|
||||
Module string `json:"module"`
|
||||
|
||||
@@ -39,8 +39,8 @@ func TestEveryStateAndActHasItsTool(t *testing.T) {
|
||||
via := map[string]string{
|
||||
ValuesState: "config list", ResolvedState: "config list", PredefinedState: "config list",
|
||||
ProposalsState: "config proposals", PullsState: "config list", KeptState: "config list", HistoryLog: "config history",
|
||||
DeclaredState: DeclaredTool,
|
||||
PlacementRead: "config list", WantsRead: "config list", BuildsRead: "config list", ModulesRead: DeclaredTool,
|
||||
DeclaredState: DeclaredTool,
|
||||
AssignmentsRead: "config list", WantsRead: "config list", BuildsRead: "config list", ModulesRead: DeclaredTool,
|
||||
ManifestsRead: DeclaredTool, IndexerPredefinedRead: "config list", CandidatesRead: ResyncTool,
|
||||
"a resolution": ResyncTool, "the indexer's candidates taken": ResyncTool,
|
||||
// design 32: each new state with the tool that reads it, each act with the tool that starts it.
|
||||
|
||||
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
// What mesh-config reads of the delivery owners' state, through their tools and views families (novox/hq ADR 0615 §1,
|
||||
// §4 to §6, ADR 0596): never a bucket of theirs. For each of the six states it follows (the indexer's modules, manifests,
|
||||
// predefined and config-candidates, the assigner's placement and wants) it asks the owner's read tool for the whole
|
||||
// predefined and config-candidates, the assigner's assignments and wants) it asks the owner's read tool for the whole
|
||||
// state at its start, keeps the picture from the owner's `views.<state>` events, and asks again only on a gap. Started
|
||||
// while an owner is down it keeps asking, and past two minutes writes a finding naming the owner and the tool.
|
||||
//
|
||||
@@ -27,12 +27,12 @@ import (
|
||||
|
||||
// The tools of the owners that mesh-config asks, by the state they read.
|
||||
const (
|
||||
IndexerModulesTool = "indexer_read_modules"
|
||||
IndexerManifestsTool = "indexer_read_manifests"
|
||||
IndexerPredefTool = "indexer_read_predefined"
|
||||
IndexerCandidatesTool = "indexer_read_config_candidates"
|
||||
AssignerPlacementTool = "assigner_read_placement"
|
||||
AssignerWantsTool = "assigner_read_wants"
|
||||
IndexerModulesTool = "indexer_read_modules"
|
||||
IndexerManifestsTool = "indexer_read_manifests"
|
||||
IndexerPredefTool = "indexer_read_predefined"
|
||||
IndexerCandidatesTool = "indexer_read_config_candidates"
|
||||
AssignerAssignmentsTool = "assigner_read_assignments"
|
||||
AssignerWantsTool = "assigner_read_wants"
|
||||
|
||||
FirstViewsTool = "config_first_views"
|
||||
FirstViewAgainTool = "config_first_view_again"
|
||||
@@ -45,7 +45,7 @@ var followed = []struct{ Read, Owner, State, Tool string }{
|
||||
{ManifestsRead, indexerModule, "manifests", IndexerManifestsTool},
|
||||
{IndexerPredefinedRead, indexerModule, catalog.StatePredefined, IndexerPredefTool},
|
||||
{CandidatesRead, indexerModule, catalog.StateConfigCandidates, IndexerCandidatesTool},
|
||||
{PlacementRead, assignerModule, "placement", AssignerPlacementTool},
|
||||
{AssignmentsRead, assignerModule, "assignments", AssignerAssignmentsTool},
|
||||
{WantsRead, assignerModule, "wants", AssignerWantsTool},
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func viewTools(c *Config, o func() *ownerViews) []stdio.Tool {
|
||||
return []stdio.Tool{
|
||||
{Name: FirstViewsTool,
|
||||
Description: "mesh-config's first views of the delivery owners' state: for each of the indexer's modules, manifests, " +
|
||||
"predefined and config-candidates and the assigner's placement and wants, the tool it asks, the revision its " +
|
||||
"predefined and config-candidates and the assigner's assignments and wants, the tool it asks, the revision its " +
|
||||
"picture holds, when it asked and was answered, how many asks (and by hand), and whether its condition is raised.",
|
||||
Run: func(map[string]any) (any, error) {
|
||||
ov := o()
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
meshwants "git.novox.be/novox/mesh-contracts/placement/go/seats/meshwants"
|
||||
meshwants "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
)
|
||||
|
||||
// The holders whose states this module reads, one constant each (a reader names its holder once; ADR 0634 §4).
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
catalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"sort"
|
||||
@@ -23,10 +23,10 @@ const (
|
||||
PredefinedState = "predefined"
|
||||
ProposalsState = "proposals"
|
||||
|
||||
// PlacementRead is the seat mesh-module-assigner's state, held by the assigner (novox/hq ADR 0567 §1, §8): each
|
||||
// node's key `placement.<node>` with the modules placed there. It is the one source of which module runs where
|
||||
// AssignmentsRead is the seat mesh-module-assigner's state, held by the assigner (novox/hq ADR 0567 §1, §8): each
|
||||
// node's key `<node>.node` with the modules placed there. It is the one source of which module runs where
|
||||
// (issue 1953): the controller's assignments are no longer read.
|
||||
PlacementRead = (assignerModule + "." + meshseat.StatePlacement)
|
||||
AssignmentsRead = (assignerModule + "." + meshseat.StateAssignments)
|
||||
// WantsRead is the assigner's wants, `want.<node>.<module>`: the build each node is to run (ADR 0539 §1).
|
||||
WantsRead = assignerModule + ".wants"
|
||||
// BuildsRead is the builder's builds, `<module>.<fingerprint hex>`: each build's manifest digest (ADR 0525).
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
catalogclient "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"sort"
|
||||
@@ -20,8 +20,8 @@ func (c *Config) sources() (Sources, error) {
|
||||
s := Sources{Declared: map[string]ModuleDeclarations{}, OnNode: map[string]ModuleDeclarations{},
|
||||
Predefined: map[string]Published{}, Values: map[string]Value{}, Renames: map[string]Rename{}}
|
||||
var problems []string
|
||||
if err := c.readPlacement(&s); err != nil {
|
||||
return s, fmt.Errorf("the seat mesh-module-assigner's placement cannot be read: %w", err)
|
||||
if err := c.readAssignments(&s); err != nil {
|
||||
return s, fmt.Errorf("the seat mesh-module-assigner's assignments cannot be read: %w", err)
|
||||
}
|
||||
if err := c.readDeclarations(&s); err != nil {
|
||||
return s, fmt.Errorf("the modules' declarations cannot be read: %w", err)
|
||||
@@ -64,28 +64,27 @@ func (c *Config) sources() (Sources, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// readPlacement is every module the seat mesh-module-assigner places on a node (ADR 0567 §1, §9), from the state's keys in
|
||||
// either form: a node key and its module keys, or the form before, `placement.<node>` (assignerclient.PlacementsOf;
|
||||
// research 072 row 37). By node in name order, each node's modules in the order its placement names them.
|
||||
func (c *Config) readPlacement(s *Sources) error {
|
||||
// readAssignments is every module the seat mesh-module-assigner places on a node (ADR 0567 §1, §9), from the state's keys, a
|
||||
// node key and its module keys (assignerclient.AssignmentsOf; research 072 row 37). By node in name order, each node's modules in the order its assignments names them.
|
||||
func (c *Config) readAssignments(s *Sources) error {
|
||||
keys := map[string][]byte{}
|
||||
if err := c.each(PlacementRead, func(key string, raw []byte) error {
|
||||
if err := c.each(AssignmentsRead, func(key string, raw []byte) error {
|
||||
keys[key] = raw
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
placements, err := assignerclient.PlacementsOf(keys)
|
||||
assignments, err := assignerclient.AssignmentsOf(keys)
|
||||
if err != nil {
|
||||
return fmt.Errorf("the placement is not read whole: %w", err)
|
||||
return fmt.Errorf("the assignments is not read whole: %w", err)
|
||||
}
|
||||
nodes := make([]string, 0, len(placements))
|
||||
for node := range placements {
|
||||
nodes := make([]string, 0, len(assignments))
|
||||
for node := range assignments {
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
sort.Strings(nodes)
|
||||
for _, node := range nodes {
|
||||
for _, module := range assignerclient.Assigned(placements[node]) {
|
||||
for _, module := range assignerclient.Assigned(assignments[node]) {
|
||||
s.Assignments = append(s.Assignments, Assignment{Node: node, Module: module})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
engineclient "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
assignerclient "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
meshseat "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
catalogclient "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
||||
catalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
@@ -591,7 +591,7 @@ func (p *player) buildIn(node, module, fp, raw string) {
|
||||
|
||||
func (p *player) placed(node string, modules ...string) {
|
||||
p.t.Helper()
|
||||
pl := meshseat.Placement{V: 1, Node: node}
|
||||
pl := meshseat.Assignments{V: 1, Node: node}
|
||||
for _, m := range modules {
|
||||
pl.Modules = append(pl.Modules, meshseat.PlacedModule{Module: m})
|
||||
}
|
||||
@@ -602,7 +602,7 @@ func (p *player) placed(node string, modules ...string) {
|
||||
p.t.Fatal(err)
|
||||
}
|
||||
for _, w := range writes {
|
||||
p.put("mesh-delivery-assigner.placement", w.Key, json.RawMessage(w.Value))
|
||||
p.put("mesh-delivery-assigner.assignments", w.Key, json.RawMessage(w.Value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ func TestConfigWholeRenamesAndRetiresAgainstTheBus(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
buckets := []string{"mesh-delivery-assigner_placement", "mesh-delivery-assigner_wants", "mesh-delivery-builder_builds",
|
||||
buckets := []string{"mesh-delivery-assigner_assignments", "mesh-delivery-assigner_wants", "mesh-delivery-builder_builds",
|
||||
"mesh-delivery-indexer_modules", "mesh-delivery-indexer_manifests", "mesh-delivery-indexer_predefined",
|
||||
"mesh-delivery-indexer_config-candidates"}
|
||||
for _, s := range []string{ValuesState, ResolvedState, PredefinedState, ProposalsState, PullsState, KeptState, DeclaredState,
|
||||
|
||||
Reference in New Issue
Block a user