B9 publish-kept-call: a publish's kept call that has waited five minutes raises call-unanswered about its ask id, and its answer clears it

Builds: design 47 H2 H-A-613 (4), H-A-620 (3), H-A-625 (3)
This commit is contained in:
2026-11-25 17:49:49 +01:00
parent 87e7912220
commit 88bdd4bd33
3 changed files with 56 additions and 4 deletions
@@ -259,7 +259,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf)
pq := &publishQueue{js: js, logf: logger.Printf, binding: publishesOf(cred.Module)}
republish := &versions.Republisher{Reserved: reserved.r, Put: pq.put,
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk),
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk, publishUnanswered(ctx, found)),
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
Holders: holders, // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a)
Started: time.Now()} // a build ended from now on is of the live class (H-A-290 (1))
@@ -8,9 +8,11 @@ import (
"fmt"
"time"
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-sdk/go/busretry"
"git.novox.be/novox/mesh-sdk/go/process"
"mesh-delivery-builder/internal/versions"
@@ -47,9 +49,15 @@ func publishAskID(p versions.Publish) string {
// artifact store, addressed by digest. The four seats' publish take one wire form; an answer that lacks parts, or a fault of
// the call, is the holder's refusal, said in its words (not stored when the holder lacks the bytes). The publish is a kept
// call carrying its ask id (design 47 H2 §775), made again through transport faults at the kept-call pace within ctx's bound.
func sendVia(call keptCaller) func(ctx context.Context, p versions.Publish) error {
//
// said is told when the call has waited five minutes unanswered and once at its answer (busretry.WaitSaid; design 47 H2 H-A-613 (4),
// H-A-620 (3): call-unanswered written after five minutes, ADR 0668 §3); nil is told nothing.
func sendVia(call keptCaller, said func(p versions.Publish, w busretry.Waited)) func(ctx context.Context, p versions.Publish) error {
return func(ctx context.Context, p versions.Publish) error {
ask := process.KeptAsk{ID: publishAskID(p)}
if said != nil {
ask.Hook = func(w busretry.Waited) { said(p, w) }
}
if d, ok := ctx.Deadline(); ok {
ask.Bound = time.Until(d)
}
@@ -101,3 +109,18 @@ func callWithin(ctx context.Context, call toolCaller, key string, body any) (jso
func publishBody(p versions.Publish) gopackageregistry.PublishInput {
return gopackageregistry.PublishInput{Commit: p.Commit, Digest: p.Digest, Fingerprint: p.Fingerprint, Kind: p.Kind, Name: p.Name, Transfer: p.Transfer, Version: p.Version}
}
// publishUnanswered is what a publish's kept call tells when it has waited five minutes and at its answer (design 47 H2 H-A-613 (4),
// H-A-620 (3); ADR 0668 §3): the finding call-unanswered about the publish's ask id is raised at the first and cleared at the second.
func publishUnanswered(ctx context.Context, f *findings) func(versions.Publish, busretry.Waited) {
return func(p versions.Publish, w busretry.Waited) {
id := publishAskID(p)
if w.Answered {
f.clear(ctx, meshconditionsclient.KindCallUnanswered, meshconditionsclient.ScopeCall, id)
return
}
o := callUnanswered(id, "seat:"+p.Seat+"."+versions.VerbPublish+" of "+p.Name+" "+p.Version, "", w.Last, "builder."+meshconditionsclient.KindCallUnanswered, w.Since)
o.needs = "the call is made again by itself until the holder answers; builder_publish_queue shows the item."
f.raise(ctx, o)
}
}
@@ -15,6 +15,9 @@ import (
"git.novox.be/novox/mesh-sdk/go/process"
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-sdk/go/busretry"
"mesh-delivery-builder/internal/build"
"mesh-delivery-builder/internal/versions"
)
@@ -54,7 +57,7 @@ func TestRepublishSend(t *testing.T) {
send := sendVia(func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) {
asked, id = key, ask.ID
return json.RawMessage(c.answer), c.err
})
}, nil)
err := send(context.Background(), p)
// design 47 H2 §775: the publish carries its ask id, the same for the same publish
if asked != "seat:oci-artifact-registry.publish" || id != publishAskID(p) || strings.Contains(id, ".") || (c.want == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), c.want)) {
@@ -73,7 +76,7 @@ func TestRepublishSend(t *testing.T) {
}
for name, call := range map[string]func(context.Context) error{
"the publish": func(ctx context.Context) error {
return sendVia(func(_ process.KeptAsk, k string, b any) (json.RawMessage, error) { return slow(k, b) })(ctx, p)
return sendVia(func(_ process.KeptAsk, k string, b any) (json.RawMessage, error) { return slow(k, b) }, nil)(ctx, p)
},
"the entry": func(ctx context.Context) error { _, err := entryVia(slow)(ctx, "fp"); return err },
} {
@@ -89,3 +92,29 @@ func TestRepublishSend(t *testing.T) {
}
func versionsNow() time.Time { return time.Unix(1, 0) }
// Design 47 H2 H-A-613 (4), H-A-620 (3): a publish's kept call that has waited five minutes raises call-unanswered about its ask id,
// and its answer clears it; the call carries the hook that says so.
func TestAPublishWaitedFiveMinutesIsCallUnanswered(t *testing.T) {
p := versions.Publish{Seat: versions.SeatArtifacts, Kind: "bundle", Name: "m/prog", Version: "0.1.3", Digest: "sha256:aa"}
st := &memFindings{vals: map[string][]byte{}}
f := &findings{module: builds.BuilderModule, w: st, logf: t.Logf, now: func() time.Time { return time.Unix(0, 0) }}
said := publishUnanswered(context.Background(), f)
var hook func(busretry.Waited)
_ = sendVia(func(ask process.KeptAsk, _ string, _ any) (json.RawMessage, error) {
hook = ask.Hook
return json.RawMessage(`{"held":true}`), nil
}, said)(context.Background(), p)
if hook == nil {
t.Fatal("the publish's kept call carries no hook")
}
key := meshconditionsclient.Key(meshconditionsclient.ScopeCall, publishAskID(p), meshconditionsclient.KindCallUnanswered)
hook(busretry.Waited{Since: time.Unix(0, 0), Last: "no responders"})
if got, err := decodeFinding(st.vals[key]); err != nil || got.Kind != meshconditionsclient.KindCallUnanswered || !strings.Contains(got.Summary, "m/prog 0.1.3") {
t.Fatalf("the call waited: finding %+v, %v", got, err)
}
hook(busretry.Waited{Answered: true})
if st.vals[key] != nil {
t.Error("the call answered: the finding stands")
}
}