bus5 B5 (A-107): the keeper's process answers mesh-broker's snapshot verbs itself through AnswerSeat

snapshot-get, snapshot-restore, snapshot-restore-cancel and snapshot-remove are answered by
the keeper's process with the proved caller; it publishes snapshot-get's chunks and hears
their acks on its own subscription, and acts at once with no hand-over through requests
(the record of a running restore is written before it runs). The tools bundle keeps its
tools, nats_snapshots among them. The protected refusal and the whole test's case (send,
restore in place, removal) stay.

Builds: design 47 G A-107 (G-20-lead-answers), §681

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-11 23:56:06 +01:00
parent a9dfe77b1d
commit 44cb7ad449
8 changed files with 378 additions and 254 deletions
+27 -8
View File
@@ -97,6 +97,33 @@ func (r Request) Act() occ.Act {
return occ.Act{"verb": r.Verb, "module": r.Module, "local": r.Local}
}
// AnswerSnapshot answers one call of the seat mesh-broker's snapshot-restore, snapshot-restore-cancel or snapshot-remove at once, as
// the keeper's process answers it (design 47 G §681, A-107): r names the verb, its arguments and the proved caller, and comes back
// ended with its Outcome (accepted, busy, verified or error), ActID and Error. Nothing is handed through the state requests but the
// record of a restore that runs, which its end and a restart's cut-off read.
func (k *Keeper) AnswerSnapshot(r Request) Request {
if r.At.IsZero() {
r.At = k.now()
}
var outcome string
var err error
switch r.Verb {
case VerbSnapshotRestore:
outcome, err = k.startRestore(&r)
case VerbSnapshotRestoreCancel:
outcome, err = k.cancelRestore(&r)
case VerbSnapshotRemove:
outcome, err = k.removeSnapshots(&r)
default:
outcome, err = "error", fmt.Errorf("%q is no snapshot verb", r.Verb)
}
r.Done, r.Outcome = k.now(), outcome
if err != nil {
r.Error = err.Error()
}
return r
}
// ErrNoWarrant is a request that waits for the operator's word: kept, acted on once the warrant is held.
var ErrNoWarrant = errors.New("the operator has not answered yet")
@@ -154,14 +181,6 @@ func (k *Keeper) act(r *Request) (string, error) {
}
return fmt.Sprintf("the first view answered at revision %d", s.Revision), nil
}
switch r.Verb {
case VerbSnapshotRestore:
return k.startRestore(r)
case VerbSnapshotRestoreCancel:
return k.cancelRestore(r)
case VerbSnapshotRemove:
return k.removeSnapshots(r)
}
if !k.Viewed() {
return "", fmt.Errorf("%w: the keeper holds no first view yet, so it acts on nothing", ErrNoWarrant)
}