No client names the holder of the seat mesh-provisioner: each reader keeps its own constant, held to its manifest (ADR 0625 section 4, issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 19:36:21 +01:00
parent d630635229
commit 625d627794
21 changed files with 186 additions and 29 deletions
@@ -100,7 +100,7 @@ func main() {
}
cfg.Log = say
svc := NewService(cfg)
p := svc.Provider(provider.StateBus(Module))
p := svc.Provider(provider.StateBus(Module, provisionerModule))
ctx := context.Background()
// A pass answers every consumer; one at a time, and one per change of a machine's key.
var passing sync.Mutex
@@ -132,3 +132,7 @@ func main() {
os.Exit(1)
}
}
// provisionerModule is the holder of the seat mesh-provisioner, named from this module's manifest (its `reads` of plans and
// provisions; TestTheProvisionerIsTheManifests).
const provisionerModule = "mesh-provisioner"
@@ -0,0 +1,28 @@
package main
import (
"encoding/json"
"os"
"slices"
"testing"
)
// The module holding the seat mesh-provisioner, which this provider reads the plans and provisions of, is the one its manifest's
// `reads` name: no client names a holder (novox/hq ADR 0625 §4).
func TestTheProvisionerIsTheManifests(t *testing.T) {
raw, err := os.ReadFile("../../module.json")
if err != nil {
t.Fatal(err)
}
var m struct {
Reads []string `json:"reads"`
}
if err := json.Unmarshal(raw, &m); err != nil {
t.Fatal(err)
}
for _, state := range []string{"plans", "provisions"} {
if !slices.Contains(m.Reads, provisionerModule+"."+state) {
t.Errorf("the provider reads %s.%s, its manifest's reads are %v", provisionerModule, state, m.Reads)
}
}
}
@@ -125,7 +125,7 @@ func (s *Service) Provider(bus provider.Bus) *provider.Provider {
vb := &valuesBus{Bus: bus, s: s, written: map[string][]byte{}}
s.bound = vb
return provider.New(provider.Options{
Node: s.cfg.Node, Module: Module,
Node: s.cfg.Node, Module: Module, Provisioner: provisionerModule,
Offers: map[string]provider.Offer{ProvisionName: {Credential: provider.NoCredential}},
Bus: vb,
Make: s.Make, Gone: s.Gone,
@@ -110,19 +110,19 @@ func (b *fakeBus) bindClient(node string) {
// bindPlan makes module on node bind gitea's forge-account as the seat mesh-provisioner keeps it: its plan, and the
// provision key asked of gitea on novox (novox/hq ADR 0570 clauses 1 to 3).
func (b *fakeBus) bindPlan(node, module, as string) {
b.set(meshprovisionerclient.PlansBucket, node+"."+module, []byte(fmt.Sprintf(
b.set(meshprovisionerclient.PlansBucketOf(provisionerModule), node+"."+module, []byte(fmt.Sprintf(
`{"v":1,"node":%q,"module":%q,"plan":{"provisions":[{"provision":"forge-account","provider":"novox","provider-module":"gitea","as":%q}]}}`,
node, module, as)))
b.set(meshprovisionerclient.ProvisionsBucket, node+"."+module+".forge-account", provisionKey(node, module, meshprovisionerclient.Asked, nil))
b.set(meshprovisionerclient.ProvisionsBucketOf(provisionerModule), node+"."+module+".forge-account", provisionKey(node, module, meshprovisionerclient.Asked, nil))
}
// retire is the operator's yes to the retiring of module's forge-account on node: its plan gone, its key retiring
// with the warrant (ADR 0570 clause 5), the only way the provider lets an entry go.
func (b *fakeBus) retire(node, module string) {
b.mu.Lock()
delete(b.buckets[meshprovisionerclient.PlansBucket], node+"."+module)
delete(b.buckets[meshprovisionerclient.PlansBucketOf(provisionerModule)], node+"."+module)
b.mu.Unlock()
b.set(meshprovisionerclient.ProvisionsBucket, node+"."+module+".forge-account", provisionKey(node, module, meshprovisionerclient.Retiring,
b.set(meshprovisionerclient.ProvisionsBucketOf(provisionerModule), node+"."+module+".forge-account", provisionKey(node, module, meshprovisionerclient.Retiring,
&meshprovisionerclient.Warrant{Ask: "ask-1", Option: "yes", By: "operator", At: time.Date(2026, 10, 29, 12, 0, 0, 0, time.UTC)}))
}