MH-0: an entry whose ask failed is asked again, at most entry-asks times, then unanswered

The node-engine consumes the entries client's asking again (H-A-60, H-A-110): the setting entry-asks (default 5; module.json
config and file resource, read at the engine's start) goes to Entries.Asks; Entries.AskAgain is called at each link's start and
on each catalog-revision the composer hears (the shadow's cache too); the finding entry-unanswered joins the engine's finding
kinds, written with a journal line when an entry ends unanswered and cleared when it is answered or no longer wanted; the
shadow's wait and the have's hold end on it instead of waiting without bound.

Builds: design 47 H, H-A-60, H-A-110

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 04:25:00 +01:00
parent e4d098c4b9
commit 39e16689fa
12 changed files with 286 additions and 5 deletions
+13 -2
View File
@@ -627,6 +627,11 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus
say("the finding that the catalog half holds no entry of " + fp + " cannot be kept: " + err.Error())
}
},
entryUnanswered: func(fp string, asks int, unanswered bool) {
if err := seatwait.SayEntryUnanswered(run, findings, node, findings.observer(), fp, asks, unanswered, time.Now); err != nil {
say("the finding that the entry of " + fp + " is unanswered cannot be kept: " + err.Error())
}
},
seatList: seats,
seatListFailed: err != nil,
running: func() []compositions.Composed {
@@ -690,10 +695,14 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus
// nothing and keeps running what it runs; a assignment it cannot watch stops the agent, said, and it begins again.
composer := selfComposer(session, node, hooks, say)
composer.AlsoEntryAgain = shadow.EntryAgain
composer.AlsoEntriesAskAgain = shadow.EntriesAskAgain
composer.OnEngine = session.Own.Set // the first composing names the engine's own module on a first start (§527, §634)
machinesNow.Store(composer) // the machines a failing network part points at, by the assignments (issue 774)
composerNow.Store(composer) // what the verb compose asks a pass of, this run's alone
session.SetManifestOf(composer.ManifestOf) // the event running names the manifest of the build that runs
// The link is open: each entry whose ask failed in transport is asked again (design 47 H, H-A-60).
composer.EntriesAskAgain(run)
shadow.EntriesAskAgain(run)
go followRunning(run, session, composer, say)
go followBuildEnds(run, session, composer, say)
apply.UseEngineModule(composer.EngineModule) // the guard of the engine's own trees fixes no name (§527)
@@ -1132,7 +1141,9 @@ type composerHooks struct {
kept func(kept map[string][]string)
// entryNotFound is selfcompose.Env's EntryNotFound.
entryNotFound func(fp string, notFound bool)
held func(module string) (compositions.Seals, []string, error)
// entryUnanswered is selfcompose.Env's EntryUnanswered.
entryUnanswered func(fp string, asks int, unanswered bool)
held func(module string) (compositions.Seals, []string, error)
// vaultAuthority and certify are selfcompose.Env's VaultAuthority and Certify.
vaultAuthority func() string
certify func(ctx context.Context) error
@@ -1191,7 +1202,7 @@ func composerEnv(session *link.Session, node string, say func(string), hooks com
Hear: session.Hear,
// And a moved module's templates archive, in the artifact store, as every archive is fetched (issue 1126).
Fetch: apply.Fetch,
Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound,
Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound, EntryUnanswered: hooks.entryUnanswered, EntryAsks: entryAsks(),
VaultAuthority: hooks.vaultAuthority, Certify: hooks.certify}
if hooks.seatList != nil {
env.SeatList, env.SeatListChanged = hooks.seatList.reader, hooks.seatList.changed
@@ -79,6 +79,9 @@ type itBed struct {
// holder re-serves (issue 1966).
seatAway atomic.Bool
findings nats.KeyValue
// entryFails makes the stand-in answer the verb entry with a refusal in words the holder never gives for an unknown fingerprint:
// the ask fails to reach the holder's answer, as one on a bus that drops it does (design 47 H, H-A-60).
entryFails atomic.Bool
// entries are the entries the stand-in of the seat mesh-catalog answers its verb entry from, by fingerprint (design 47 G §421).
entries map[string]meshcatalog.CatalogEntry
}
@@ -117,6 +120,10 @@ func (b *itBed) standInEntry() {
b.mu.Lock()
e, ok := b.entries[in.Fingerprint]
b.mu.Unlock()
if b.entryFails.Load() {
_ = m.Respond([]byte(`{"error":"the holder cannot answer now"}`))
return
}
if !ok {
_ = m.Respond([]byte(`{"error":"no entry of fingerprint ` + in.Fingerprint + ` is kept"}`))
return
@@ -334,6 +341,42 @@ func TestNatsANodeTheAssignmentsNameComposesAndAppliesItsOwn(t *testing.T) {
t.Errorf("composed and applied under a grant without the served key: %q", b.file("web"))
}
})
// Design 47 H, H-A-60 and H-A-110: an entry whose ask failed is asked again on each catalog-revision, at most entry-asks times; the
// shadow's wait on it and the have's end `unanswered`, loudly (the journal and the finding entry-unanswered), instead of waiting
// without bound; asked again by hand once the holder answers, the node composes.
t.Run("an entry whose ask failed is asked again on each catalog-revision and ends unanswered", func(t *testing.T) {
// The golden grant does not list the subscription to catalog-revision, which the manifest consumes: laid over it here.
granted := nodegrant.For(itNode, "it2.mailer.domain")
granted.Subscribe = append(granted.Subscribe, meshcatalog.SubjectCatalogRevisionAll)
b := newItBedAs(t, granted)
b.entryFails.Store(true)
stop, st := h8(t, b, false)
defer stop()
revision := func() bool {
if err := b.conn.Publish(meshcatalog.SubjectCatalogRevision("main"), []byte(`{}`)); err != nil {
t.Fatal(err)
}
h := b.have("web")
return h.Phase == nec.PhaseHeld && strings.HasPrefix(h.Detail, agent.EntryAsked) && strings.Contains(h.Detail, "is unanswered")
}
within(t, 20*time.Second, "web's entry did not end unanswered after the asks the setting allows", revision)
within(t, 5*time.Second, "the journal does not say the entry is unanswered", func() bool {
b.mu.Lock()
defer b.mu.Unlock()
return strings.Contains(strings.Join(b.said, "\n"), "is unanswered")
})
if b.file("web") != "" {
t.Fatal("composed with an entry nobody answered")
}
b.entryFails.Store(false)
if err := composerNow.Load().EntryAgain(context.Background(), st.fp); err != nil {
t.Fatal(err)
}
if _, err := st.resolved.Put(itNode+".web.greeting", []byte(`{"value":"bonjour","source":"module"}`)); err != nil {
t.Fatal(err)
}
within(t, 5*time.Second, "the node did not compose once the entry was asked again and answered", func() bool { return b.file("web") == "greeting=bonjour\n" })
})
b := newItBedAs(t, nodegrant.For(itNode, "it2.mailer.domain"))
stop, st := h8(t, b, true)
defer stop()
+20
View File
@@ -56,6 +56,26 @@ func TestTheEnginesOwnNameIsReadFromItsAppliedRecordOrItsFirstComposing(t *testi
}
}
// Design 47 H, H-A-60: how often an entry whose ask failed is asked again is the file the manifest's `entry-asks` feeds, five when it
// holds nothing usable.
func TestTheEntryAsksAreTheManifestsSetting(t *testing.T) {
was := entryAsksFile
defer func() { entryAsksFile = was }()
for content, want := range map[string]int{"2\n": 2, "": 5, "0": 5, "x": 5} {
entryAsksFile = filepath.Join(t.TempDir(), "w")
if err := os.WriteFile(entryAsksFile, []byte(content), 0o644); err != nil {
t.Fatal(err)
}
if got := entryAsks(); got != want {
t.Errorf("the file %q gives %v, want %v", content, got, want)
}
}
entryAsksFile = filepath.Join(t.TempDir(), "missing")
if got := entryAsks(); got != 5 {
t.Errorf("no file gives %v", got)
}
}
// §633: the engine's bound for the first seat list is the file the manifest's `view-waits-minutes` feeds, five minutes
// when it holds nothing usable.
func TestTheViewWaitsBoundIsTheManifestsSetting(t *testing.T) {
+20 -1
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
"os"
"strconv"
"strings"
@@ -124,7 +125,7 @@ func newFindingsOfTheNode(session *link.Session, node, module string, say func(s
Module: module,
Node: node,
State: link.FindingsState{Session: session},
Kinds: append([]string{seatwait.Kind, seatwait.HeldKind, seatwait.EntryNotFoundKind}, seatwait.NodeKinds...),
Kinds: append([]string{seatwait.Kind, seatwait.HeldKind, seatwait.EntryNotFoundKind, seatwait.EntryUnansweredKind}, seatwait.NodeKinds...),
Asked: condseat.SubjectFindingsAsked,
Logf: func(format string, args ...any) { say(fmt.Sprintf(format, args...)) },
Publish: session.PublishEvent,
@@ -279,3 +280,21 @@ func viewWaitsBound() time.Duration {
}
return time.Duration(n) * time.Minute
}
// entryAsksFile is the file the manifest declares with the content ${config:entry-asks} (design 47 H, H-A-60), read at the
// engine's start as recoveryWaitFile is.
var entryAsksFile = "/var/lib/mesh-host/entry-asks"
// entryAsks is how often an entry whose ask failed in transport is asked again before it is unanswered: the file's number, the
// design's five (meshcatalogclient.DefaultEntryAsks) when the file is missing, empty or not a positive number.
func entryAsks() int {
raw, err := os.ReadFile(entryAsksFile)
if err != nil {
return meshcatalogclient.DefaultEntryAsks
}
n, err := strconv.Atoi(strings.TrimSpace(string(raw)))
if err != nil || n <= 0 {
return meshcatalogclient.DefaultEntryAsks
}
return n
}