A-4 record: a run on the operator's approval answers its approval and is recorded in the hand-act log

A call run on its warrant answers {answer, approval}, the tool's own answer and the line
naming the approval, as a process holder's gated-ended says it. The runner then calls
mesh-hand-acts.warranted, each try a kept call open while the ask lacks recorded, and on
its answer writes recorded; past the kept call's bound it is asked again when the hand-act
seat's holder is heard again and at each start, for every acted, unrecorded ask within its
48 hours. Two bound keys per run in the runner's key-ttl state bound raise call-unanswered
at five minutes and say an unrecorded run an hour before its key's end; the answer clears
the finding.

Builds: design 46 7-approval-mark §16, §13 (the log line an hour before 48 hours); lead answers A-157, A-158

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 05:18:42 +01:00
parent 0fdec2bd60
commit 3640447711
9 changed files with 385 additions and 9 deletions
+48
View File
@@ -3,6 +3,11 @@ package main
import (
"encoding/json"
"errors"
"log"
"time"
handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts"
"git.novox.be/novox/mesh-sdk/go/busretry"
stdio "git.novox.be/novox/mesh-sdk/go"
@@ -99,3 +104,46 @@ func routerRecord(conn *bus.Conn) func(module, id string) (*stdio.StateEntry, er
return &stdio.StateEntry{Key: e.Key, Value: e.Value, Revision: e.Revision, At: e.At}, nil
}
}
// boundState is the runner's key-ttl state bound (lead answers A-157, A-158).
type boundState struct {
conn *bus.Conn
module string
}
// BoundState is the runner's state its bound keys live in.
const BoundState = "bound"
func (b boundState) CreateTTL(key string, value any, ttl time.Duration) error {
raw, err := json.Marshal(value)
if err != nil {
return err
}
_, err = b.conn.StateCreateTTL(b.module, BoundState, key, raw, ttl)
return err
}
func (b boundState) Delete(key string) error { return b.conn.StateDelete(b.module, BoundState, key) }
func (b boundState) Watch(pattern string, expired func(key string)) (func(), error) {
return b.conn.StateWatch(b.module, BoundState, pattern, func(c bus.StateChange) error {
if c.Op == "expire" {
expired(c.Key)
}
return nil
})
}
// warranted asks mesh-hand-acts.warranted for one acted ask, each try a kept call open while open says so (design 46
// 7-approval-mark §16; lead answer A-157).
func warranted(conn *bus.Conn) func(asker, ask string, open func() (bool, error)) error {
return func(asker, ask string, open func() (bool, error)) error {
_, err := busretry.DoKept("mesh-hand-acts.warranted of "+asker+"."+ask,
busretry.Open{Key: asker + "." + ask, Open: func(string) (bool, error) { return open() }, Logf: log.Printf},
func() (bus.Answered, error) {
return conn.Ask("seat:"+handacts.Seat+"."+handacts.VerbWarranted, handacts.WarrantedInput{Asker: asker, Ask: ask},
"mesh.seat."+handacts.Seat+".tool."+handacts.VerbWarranted)
}, nil)
return err
}
}
+11 -1
View File
@@ -25,7 +25,9 @@ import (
"syscall"
"time"
handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts"
"github.com/novox/mesh-tools/node-tools/internal/alive"
"github.com/novox/mesh-tools/node-tools/internal/approval"
"github.com/novox/mesh-tools/node-tools/internal/bus"
"github.com/novox/mesh-tools/node-tools/internal/console"
@@ -77,8 +79,16 @@ func main() {
defer stopViews()
gate := approval.New(approval.Deps{Node: conn.Node(), Runner: cred.Module, Catalog: source.ApprovalCatalog(definitionsOf(seatList)), Wait: source.WaitCatalog,
Findings: source.Findings(), Logf: log.Printf, State: approvalsState{conn: conn, module: cred.Module},
Publish: publishAsk(conn), Record: routerRecord(conn)})
Publish: publishAsk(conn), Record: routerRecord(conn), Warranted: warranted(conn), Bounds: boundState{conn: conn, module: cred.Module}})
opts = append(opts, runtime.WithGate(gate))
// A run still unrecorded is asked again at each start and when the hand-act seat's holder is heard again (lead answer A-157).
if stopBounds, err := gate.WatchBounds(); err != nil {
log.Printf("[mesh-tools] the gate's bound keys are not watched (%v): an unanswered hand-act is said in the log only", err)
} else {
defer stopBounds()
}
source.OnSeatHolder(handacts.Seat, gate.Recover)
go gate.Recover()
stop, err := runtime.Run(conn, served, envs, log.Printf, opts...)
if err != nil {
log.Fatalf("node-tools: %v", err)