A command opens each store once, not once per machine

Working out what a machine should be reaches the identity context for its
certificate and the licence context for its model access. Both were opened —
and waited on — inside functions called for every node in a push. Two machines
hid it. Fifty would be fifty connect-and-wait cycles for data that does not
change while the push runs.

So a command holds what it has open, and passes it. Each context is opened on
first use rather than up front, because most commands need one and paying to
reach three would be the same waste from the other side.

The contexts stay separate, which is the point: this is one struct holding
three connections to three databases, not one connection to a shared one. No
context reaches another's store, and each still holds only its own credential
(novox/hq ADR 0008).

A pure move again — the gate is green before and after, and no test changed.
This commit is contained in:
2026-08-31 13:35:39 +02:00
parent 8623613704
commit 6eeb10f066
11 changed files with 177 additions and 91 deletions
+6 -4
View File
@@ -24,11 +24,12 @@ func nodeCommand(ctx context.Context, args []string) error {
if len(args) == 0 {
return errors.New("node add <name>, node list, or node show <name>")
}
inv, err := openInventory(ctx)
open, err := openStores(ctx)
if err != nil {
return err
}
defer inv.Close()
defer open.Close()
inv := open.inventory
switch args[0] {
case "show":
@@ -89,11 +90,12 @@ func tokenCommand(ctx context.Context, args []string) error {
"machine the mesh already has a record for, the second is one it has never seen")
}
inv, err := openInventory(ctx)
open, err := openStores(ctx)
if err != nil {
return err
}
defer inv.Close()
defer open.Close()
inv := open.inventory
name := *existing
if *fresh != "" {