RG1: the registry takes a publish ask once by its id

A publish carrying an ask id is kept in the state taken for ask-taken-bound
(10m): a repeat while the act runs joins it, a repeat after it ended answers
the act's state read afresh (the transfer's lacking parts, a held version
ended, a transfer gone refused), never publishing twice.

Builds: design 47 H2 §775, §820; H-A-359, H-A-381
This commit is contained in:
2026-11-22 00:05:58 +01:00
parent d545299a71
commit babcd1bb31
7 changed files with 217 additions and 6 deletions
@@ -244,7 +244,7 @@ func arg[T any](args map[string]any) (T, error) {
func str(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
// tools are distribution's tools over v.
func tools(v *holder.Verbs, windows kept[holder.Window]) []stdio.Tool {
func tools(v *holder.Verbs, windows kept[holder.Window], taken *asks) []stdio.Tool {
obj := func(props map[string]any, req ...string) map[string]any {
return map[string]any{"type": "object", "required": req, "properties": props}
}
@@ -262,7 +262,9 @@ func tools(v *holder.Verbs, windows kept[holder.Window]) []stdio.Tool {
caller := stdio.CallerOf(args)
start := time.Now()
logf("%s.publish received from %s: %s %s (%s, %d parts)", seat, caller, in.Name, in.Version, in.Kind, len(in.Parts))
a, err := v.Publish(seat, caller, publishOf(in))
r := publishOf(in)
a, err := taken.once(seat, stdio.AskIDOf(args), func() (holder.PublishAnswer, error) { return v.Publish(seat, caller, r) },
func() (holder.PublishAnswer, error) { return v.Repeat(seat, caller, r) })
if err == nil {
// The window's learning asks the delivery view (up to 60 s, past the runner's 30 s call bound),
// so it never holds the answer.
@@ -503,7 +505,13 @@ func main() {
logf("transfer %s had no part for %s: dropped with its parts", id, holder.TransferIdle)
})
windows := kept[holder.Window]{state: "windows", key: func(w holder.Window) string { return w.Name }}
if err := stdio.Serve("", tools(v, windows)); err != nil {
bound, err := stdio.SettingDuration(askTakenBound, askTakenDefault)
if err != nil {
logf("the setting %s: %v", askTakenBound, err)
os.Exit(1)
}
taken := &asks{take: stdio.State(stdio.TakenState).TakeOnce, bound: bound}
if err := stdio.Serve("", tools(v, windows, taken)); err != nil {
logf("%v", err)
os.Exit(1)
}