Adoption mode: a node in use is adopted before it is converged (hq ADR 0100–0103) #44

Merged
jschoubben merged 33 commits from feat/adoption-mode into main 2026-09-22 19:01:51 +00:00
2 changed files with 12 additions and 10 deletions
Showing only changes of commit 41c300eae0 - Show all commits
+8 -8
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"sort"
"strings"
"github.com/novox/mesh-controller/internal/catalogue"
"github.com/novox/mesh-controller/internal/inventory"
@@ -23,8 +24,8 @@ type sendable struct {
}
// adoptionEnvelope is what an adopted node is told about its mode. Taken is every module taken on
// it that it runs; Untaken is, for every module it runs that is not taken, the ids of that module's
// files and containers — the resources the host keeps as found until the module is taken. Ids
// it that it runs; Untaken is, for every module it runs that is not taken, the ids of every one of
// that module's resources — what the host keeps as found until the module is taken (ADR 0103). Ids
// rather than a rule to split them by, because a module's name may contain a dot.
type adoptionEnvelope struct {
Taken []string `json:"taken"`
@@ -75,12 +76,11 @@ func adoptionFor(plan catalogue.Resolution, taken []string,
for _, r := range composed.Resources {
id, _ := r["id"].(string)
module, owned := composed.Owner[id]
if !owned || !runs[module] || isTaken[module] {
continue
}
switch r["type"] {
case "file", "container":
default:
// Every kind, not only files and containers (novox/hq ADR 0103): a directory, a service, a
// container mounting what was found and an action run in a held container all reach what
// the machine already has. What the mesh declares of its own is never held.
if !owned || !runs[module] || isTaken[module] ||
strings.HasPrefix(id, catalogue.AdoptionPrefix) {
continue
}
if out.Untaken == nil {
+4 -2
View File
@@ -84,8 +84,10 @@ func TestAnAdoptedDeclarationCarriesItsModeAndWhatWasTaken(t *testing.T) {
t.Fatal("an adopted node's declaration does not say it is adopted")
}
untaken := declared.Adoption.Untaken["hello-web"]
if !reflect.DeepEqual(untaken, []string{"hello-web.page", "hello-web.server"}) {
t.Fatalf("hello-web's files and containers are not named untaken: %v", declared.Adoption)
// Every kind — its directory too (novox/hq ADR 0103).
if !reflect.DeepEqual(untaken, []string{"hello-web.page", "hello-web.server",
"hello-web.served"}) {
t.Fatalf("hello-web's resources are not all named untaken: %v", declared.Adoption)
}
if len(declared.Adoption.Taken) != 0 {
t.Fatalf("nothing was taken, and the declaration says %v", declared.Adoption.Taken)