Let ssh-client use the SDK's forgekey, and let the checks accept a module's own .ssh (issues 1480, 1484), part 2 of 17

This commit is contained in:
2026-10-20 20:44:30 +00:00
parent 1e1def4d32
commit bf8f47ce66
9 changed files with 98 additions and 35 deletions
@@ -15,6 +15,7 @@ import (
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/forgekey"
)
func main() {
@@ -141,7 +142,7 @@ func flag(args map[string]any, key string, def bool) bool {
return def
}
// startKeeper runs the forge key's keeper (keykeeper.go) when the runtime launched this process for a node:
// startKeeper runs the forge key's keeper (go/forgekey) when the runtime launched this process for a node:
// outside a launch — a build, a check — there is no state to put the entry in.
func startKeeper() {
node := strings.TrimSpace(os.Getenv("MESH_NODE"))
@@ -151,22 +152,27 @@ func startKeeper() {
return
}
go keepSwept(c)
k := &KeyKeeper{Home: c.Home, Node: node, Account: u.Username, Run: ExecRunner, State: keysState{}, Now: time.Now}
k := keeperFor(c.Home, node, u.Username, forgekey.ExecRunner, keysState{})
k.Keep(context.Background(), func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[ssh-client] "+f+"\n", a...) })
}
// keepSwept sweeps ~/.ssh (sweep.go) now and every KeyRound.
// keeperFor is the machine's account's keeper: go/forgekey's, of kind machine (ADR 0400 §1, ADR 0466 §2), whose key
// file is ~/.ssh/mesh_ed25519 and whose entry lies at <node>.<account> in the keys state.
func keeperFor(home, node, account string, run forgekey.Runner, state forgekey.KeyPutter) *forgekey.KeyKeeper {
return &forgekey.KeyKeeper{Home: home, Node: node, Account: account, Kind: forgekey.KindMachine, Run: run, State: state, Now: time.Now}
}
// keepSwept sweeps ~/.ssh (sweep.go) now and every forgekey.KeyRound.
func keepSwept(c *Client) {
say := func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[ssh-client] "+f+"\n", a...) }
for {
c.SweepOnce(time.Now(), say)
time.Sleep(KeyRound)
time.Sleep(forgekey.KeyRound)
}
}
type keysState struct{}
func (keysState) Put(key string, value any) error {
_, err := stdio.State("keys").Put(key, value)
return err
func (keysState) Put(key string, value any) (uint64, error) {
return stdio.State("keys").Put(key, value)
}