The builder keeps one key per module and MAJOR.MINOR in its state reserved, written by compare-and-set when a trunk build is claimed; nothing is reserved, and the build says wait-held, before the catalog says versions-filled; the key goes on version-released; a built reservation unpublished past ten minutes is the finding version-unreleased; builder_reserved, builder_reserved_drop (hand act, recorded) and the seat mesh-builds' verb reserved. Builds: design 47 G §369, §372, §52, §85 (reserved) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
63 lines
3.2 KiB
Go
63 lines
3.2 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
|
|
"mesh-delivery-builder/internal/build"
|
|
"mesh-delivery-builder/internal/versions"
|
|
)
|
|
|
|
// reservedTools are builder_reserved, builder_reserved_drop and the seat mesh-builds' verb reserved (design 47 G section
|
|
// 369), served as tools of the bundle. The drop is a hand act: it is recorded in the hand-act log first, then written to
|
|
// reasks for the builder, which owns the reservations, to answer.
|
|
func reservedTools(rr versions.Reader, ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
|
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
|
return []stdio.Tool{
|
|
{Name: versions.ReservedTool, Description: versions.ReservedDescription,
|
|
Input: map[string]any{"type": "object", "properties": map[string]any{
|
|
"module": map[string]any{"type": "string", "description": "only this module's reservations"}}},
|
|
Run: func(args map[string]any) (any, error) { return versions.AnswerReserved(rr, str(args, "module")) }},
|
|
{Name: versions.ReservedVerb, Description: "The seat mesh-builds' verb reserved: a module's reserved version with each artifact's digest once built " +
|
|
"(design 47 G section 369), for a registry holder deciding whether to publish. Read-only.",
|
|
Input: map[string]any{"type": "object", "required": []string{"module"}, "properties": map[string]any{
|
|
"module": map[string]any{"type": "string", "description": "the module"},
|
|
"version": map[string]any{"type": "string", "description": "the version, when asked for a particular one"}}},
|
|
Run: func(args map[string]any) (any, error) {
|
|
return versions.AnswerReservedVerb(rr, str(args, "module"), str(args, "version"))
|
|
}},
|
|
{Name: versions.ReservedDropTool, Description: versions.ReservedDropDescription,
|
|
Input: map[string]any{"type": "object", "required": []string{"module", "series", "why"}, "properties": map[string]any{
|
|
"module": map[string]any{"type": "string", "description": "the module"},
|
|
"series": map[string]any{"type": "string", "description": "its MAJOR.MINOR"},
|
|
"why": map[string]any{"type": "string", "description": "why, in plain words"}}},
|
|
Run: func(args map[string]any) (any, error) {
|
|
key, value, err := build.NewReservedDrop(str(args, "module"), str(args, "series"), str(args, "why"), stdio.CallerOf(args), now())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if _, err := acts.Record(meshhandactsclient.Request{What: fmt.Sprintf("dropped the reservation of %s %s by hand", str(args, "module"), str(args, "series")),
|
|
Why: str(args, "why"), Cause: versions.ReservedDropTool, Verb: "reserved-drop"}); err != nil {
|
|
return nil, fmt.Errorf("the hand act was not recorded through mesh-hand-acts, so nothing was dropped: %w", err)
|
|
}
|
|
raw, err := ask(key, value)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
a, err := build.DecodeReAsk(raw)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if a.Refused {
|
|
return nil, errors.New(a.Answer)
|
|
}
|
|
return map[string]any{"key": key, "answer": a.Answer}, nil
|
|
}},
|
|
}
|
|
}
|