The reservation keeps the fingerprint of the catalog entry it was made from (versions.Source, A-76). The state sections publish-queue (max-mib 4) and acted (max-mib 1); a consumer acting once per message of the node-engine seat's running and manifest-reads-changed (why returned) by its stream sequence, the running of every subject read at the start with lastPerSubject; one queue per holder sent one at a time as the registry seat's publish with the digest and no parts, the seat and the package name read from the entry (A-73, A-76); builder_publish_queue and the new builder_publish_again, a hand act. The old form goes: build.NewPublishAgain / ModePublishAgain, versions.Acts.PublishAgain and the Again* decision, and the integration step that refused it. Builds: design 47 G §588, §369, §695, A-73, A-76 (G-16, G-18, G-20) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
66 lines
2.8 KiB
Go
66 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"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"
|
|
)
|
|
|
|
// readerOf is a kept state as the versions package's reader.
|
|
func readerOf(s stdio.KeptState) versions.Reader {
|
|
return versions.Reader{Keys: s.Keys, Get: func(key string) (json.RawMessage, bool, error) {
|
|
e, err := s.Get(key)
|
|
if err != nil || e == nil {
|
|
return nil, false, err
|
|
}
|
|
return e.Value, true, nil
|
|
}}
|
|
}
|
|
|
|
// republishTools are builder_publish_again and builder_publish_queue (design 47 G §588). The publish again is a hand act:
|
|
// it is recorded in the hand-act log first, then written to reasks for the builder, which owns the queue, to answer
|
|
// with the versions it queued.
|
|
func republishTools(queue, acted 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.PublishAgainTool, Description: versions.PublishAgainDescription,
|
|
Input: map[string]any{"type": "object", "required": []string{"why"}, "properties": map[string]any{
|
|
"module": map[string]any{"type": "string", "description": "only this module's reserved versions"},
|
|
"version": map[string]any{"type": "string", "description": "with module: only this reserved version, MAJOR.MINOR.PATCH"},
|
|
"why": map[string]any{"type": "string", "description": "why, in plain words"}}},
|
|
Run: func(args map[string]any) (any, error) {
|
|
key, value, err := build.NewRepublish(str(args, "module"), str(args, "version"), str(args, "why"), stdio.CallerOf(args), now())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if _, err := acts.Record(meshhandactsclient.Request{What: fmt.Sprintf("published reserved versions again by hand (module %q, version %q)", str(args, "module"), str(args, "version")),
|
|
Why: str(args, "why"), Cause: versions.PublishAgainTool, Verb: "publish-again"}); err != nil {
|
|
return nil, fmt.Errorf("the hand act was not recorded through mesh-hand-acts, so nothing was queued: %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, "queued": a.Queued, "answer": a.Answer}, nil
|
|
}},
|
|
{Name: versions.PublishQueueTool, Description: versions.PublishQueueDescription,
|
|
Input: map[string]any{"type": "object", "properties": map[string]any{}},
|
|
Run: func(map[string]any) (any, error) { return versions.AnswerQueue(queue, acted) }},
|
|
}
|
|
}
|