H-A-146: the bound before a failed resolution is asked again is the setting resolve-again-minutes

A failed resolution of a want's version, or one forgotten after a failed fetch, stood a minute written into
the code; by principle 11 a bound is a setting with a default. The manifest declares resolve-again-minutes
(1 to 60, default 1) and its file, the engine reads it at its start and hands it to the composer's Env.

Builds: design 47 H H-A-146 (hq 26f5505e), principle 11
This commit is contained in:
2026-11-20 20:54:32 +01:00
parent 79a0dbf41d
commit 7d5faee346
8 changed files with 87 additions and 15 deletions
+3
View File
@@ -73,6 +73,9 @@ type Env struct {
// EntryAsks is the setting `entry-asks`: how often an entry whose ask failed in transport is asked again before it is
// unanswered; meshcatalogclient.DefaultEntryAsks when 0 (design 47 H, H-A-60).
EntryAsks int
// ResolveAgain is the setting `resolve-again-minutes`: how long a failed resolution of a want's version stands before the
// seats' verb versions is asked again; DefaultResolveAgain when 0 (design 47 H, H-A-146; principle 11).
ResolveAgain time.Duration
// Watch follows one bucket's keys matching pattern, as the agent's watches do.
Watch func(ctx context.Context, bucket, pattern string) (<-chan agent.Update, error)
// Get reads one key's latest value; nil and no error when there is none.
+15 -6
View File
@@ -25,8 +25,17 @@ import (
// manifest's `from` pins. A want that names parts (a build no version is known of) is read by its parts as before. A lookup that
// fails is said in the journal, naming the module, the version and the seat, and the module is held whole: never composed partly.
// resolveAgain is how long a failed lookup stands before it is asked again; a pass is asked then.
const resolveAgain = time.Minute
// DefaultResolveAgain is how long a failed lookup stands before it is asked again when the setting `resolve-again-minutes` gives
// nothing (Env.ResolveAgain 0); a pass is asked then (H-A-146 "after a bound"; principle 11: a bound is a setting with a default).
const DefaultResolveAgain = time.Minute
// resolveAgain is how long a failed lookup stands before it is asked again: the setting, or DefaultResolveAgain.
func (c *Composer) resolveAgain() time.Duration {
if c.env.ResolveAgain > 0 {
return c.env.ResolveAgain
}
return DefaultResolveAgain
}
// versionsVerb is the verb a lookup asks.
const versionsVerb = "versions"
@@ -107,7 +116,7 @@ func (c *Composer) resolve(module string, e meshcatalog.CatalogEntry, w meshwant
c.mu.Lock()
r, ok := c.resolved[key]
c.mu.Unlock()
if ok && (r.failed == "" || now.Sub(r.at) < resolveAgain) {
if ok && (r.failed == "" || now.Sub(r.at) < c.resolveAgain()) {
return r.parts, r.failed
}
parts, failed := c.lookUp(module, e, w)
@@ -124,7 +133,7 @@ func (c *Composer) resolve(module string, e meshcatalog.CatalogEntry, w meshwant
c.resolved[key] = versionParts{parts: parts, failed: failed, at: now}
c.mu.Unlock()
if failed != "" {
time.AfterFunc(resolveAgain, c.askRehand)
time.AfterFunc(c.resolveAgain(), c.askRehand)
return nil, failed
}
return parts, ""
@@ -146,7 +155,7 @@ func (c *Composer) forgetFetched(digest, why string) {
continue
}
line := fmt.Sprintf("resolution of %s %s forgotten: %s", k.module, k.version, why)
c.resolved[k] = versionParts{failed: line + "; the seats' verb versions is asked again at its next want, at the next compose or in " + resolveAgain.String(),
c.resolved[k] = versionParts{failed: line + "; the seats' verb versions is asked again at its next want, at the next compose or in " + c.resolveAgain().String(),
at: now, forgotten: true}
lines = append(lines, line)
}
@@ -156,7 +165,7 @@ func (c *Composer) forgetFetched(digest, why string) {
c.env.Say(line)
}
if len(lines) > 0 {
time.AfterFunc(resolveAgain, c.askRehand)
time.AfterFunc(c.resolveAgain(), c.askRehand)
}
}
+15 -8
View File
@@ -149,12 +149,13 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
Artifacts: []meshcatalog.Artifact{{Ref: "mail:files", Kind: "archive"}}}
want := meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: "1.2.3", Self: true}
for name, row := range map[string]struct {
answer string // the digest versions answers
fetch error // the store's answer to the fetch
then string // what follows the fetch: "" (a pass within the bound), want, compose, bound
asked bool // versions is asked again
forgets bool // the journal says it forgot
failed bool // the fetch fails though nothing is forgotten
answer string // the digest versions answers
fetch error // the store's answer to the fetch
then string // what follows the fetch: "" (a pass within the bound), want, compose, bound
asked bool // versions is asked again
forgets bool // the journal says it forgot
failed bool // the fetch fails though nothing is forgotten
again time.Duration // the setting resolve-again-minutes; 0 is its default
}{
"a fetch that succeeded keeps its resolution": {answer: good, then: "bound"},
"a 404, the next pass within the bound": {answer: wrong, fetch: notFound{}, forgets: true},
@@ -162,13 +163,17 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
"a 404, then a compose by hand": {answer: wrong, fetch: notFound{}, then: "compose", asked: true, forgets: true},
"a 404, then the bound while it is held": {answer: wrong, fetch: notFound{}, then: "bound", asked: true, forgets: true},
"bytes that are not of the digest": {answer: wrong, then: "want", asked: true, forgets: true},
// Principle 11: the bound is the setting resolve-again-minutes, one minute by default.
"a 404, a minute within a setting of five": {answer: wrong, fetch: notFound{}, then: "minute", forgets: true, again: 5 * time.Minute},
"a 404, then the setting's bound of five": {answer: wrong, fetch: notFound{}, then: "bound", asked: true, forgets: true, again: 5 * time.Minute},
// H-A-150: a fetch nothing answered for keeps its resolution, and the module is not held for it.
"a bus that did not answer keeps it": {answer: good, fetch: errors.New("nats: timeout"), failed: true},
"a store away keeps it": {answer: good, fetch: storeAway{}, failed: true},
} {
now := time.Date(2026, 11, 20, 16, 0, 0, 0, time.UTC)
var said []string
env := Env{Node: "desk", Say: func(line string) { said = append(said, line) }, Now: func() time.Time { return now }}
env := Env{Node: "desk", Say: func(line string) { said = append(said, line) }, Now: func() time.Time { return now },
ResolveAgain: row.again}
calls := 0
env.Registry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
calls++
@@ -196,7 +201,9 @@ func aResolutionWhoseFetchFailedIsForgotten(t *testing.T) {
cancel()
c.ComposeNow(ended)
case "bound":
now = now.Add(resolveAgain)
now = now.Add(max(row.again, DefaultResolveAgain))
case "minute":
now = now.Add(time.Minute)
}
before := calls
again, missing := c.partsOf("mail", entry, want)