DC2d place-unfinished decodes through meshpipelinerunnerclient.PlaceUnfinished (AC-DC2d)

The process's verb and the runner_unfinished_place tool decode the input through the seat's client, which refuses one naming
neither or both of key and all, instead of each checking it by itself.

Builds: design 47 H2 H-A-644, H-A-725; AC-DC2d (DC2 step-runner-delivery-forms, the runner's side)
This commit is contained in:
2026-11-25 19:26:39 +01:00
parent a75bd951a7
commit 64b3445ee3
4 changed files with 54 additions and 16 deletions
@@ -5,6 +5,7 @@ import (
"errors"
"strings"
runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
stdio "git.novox.be/novox/mesh-sdk/go"
)
@@ -67,8 +68,10 @@ func VerbTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.
"Put the closed group of a mover kept in the state unfinished in a pipeline at once, by the seat verb place-unfinished (design 47 H2 H-A-607 (3), H-A-644, H-A-725): exactly one of key (<branch>.<module>; runner_unfinished lists them) or all (every key whose carrier neither waits nor runs), and why; one hand act per call. A group none of whose movers failed joins the head's pipeline while that waits or runs; otherwise the pipeline it left is reopened for the whole group under its own key. With key the answer names the pipeline; with all it lists placed (key, pipeline) and failed (key, words), both always present, and says so when no key was there.",
obj([]string{"why"}, map[string]any{"key": str, "all": map[string]any{"type": "boolean"}, "why": str}),
func(in seat.PlaceUnfinishedInput) string {
if (in.Key == "") == !in.All {
return "place-unfinished names the unfinished entry's key or all, exactly one"
// The seat's client decodes the input and refuses neither or both of key and all (design 47 H2 H-A-644).
raw, _ := json.Marshal(in)
if _, err := runnerclient.PlaceUnfinished(raw); err != nil {
return err.Error()
}
return whyOf(in.Why)
}),
@@ -47,7 +47,7 @@ func TestVerbTools(t *testing.T) {
// H-A-644: all places every key in one hand act; key and all together are refused.
{"unfinished place all", "runner_unfinished_place", "seat:mesh-pipeline-runner.place-unfinished", "", map[string]any{"all": true, "why": "now"},
seat.PlaceUnfinishedInput{All: true, Why: "now"}},
{"unfinished place key and all", "runner_unfinished_place", "", "exactly one", map[string]any{"key": "main.app", "all": true, "why": "now"}, nil},
{"unfinished place key and all", "runner_unfinished_place", "", "meshpipelinerunnerclient: place-unfinished names exactly one", map[string]any{"key": "main.app", "all": true, "why": "now"}, nil},
{"ask-again no why", "runner_ask_again", "", "names why", map[string]any{"pipeline": "p"}, nil},
} {
t.Run(c.name, func(t *testing.T) {
@@ -8,6 +8,7 @@ import (
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
"git.novox.be/novox/mesh-sdk/go/buscalls"
@@ -21,15 +22,27 @@ import (
// verbOf makes the handler of one verb from its function of the proved caller and the decoded input: the caller is the bus
// user the call's subject names, and a call naming none is refused (design 47 G §394, A-107).
func verbOf[In any](do func(caller string, in In) (any, error)) process.SeatHandler {
return decodedVerbOf(func(body []byte) (In, error) {
var in In
if len(body) > 0 {
if err := json.Unmarshal(body, &in); err != nil {
return in, fmt.Errorf("the arguments do not fit the verb's input: %w", err)
}
}
return in, nil
}, do)
}
// decodedVerbOf is verbOf of a verb whose input the seat's client decodes, with the refusals its contract holds it to
// (design 47 H2 H-A-644, AC-DC2d).
func decodedVerbOf[In any](decode func([]byte) (In, error), do func(caller string, in In) (any, error)) process.SeatHandler {
return func(caller string, body json.RawMessage) (any, error) {
if caller == "" {
return nil, errors.New("the call names no caller the bus proved: it is refused")
}
var in In
if len(body) > 0 {
if err := json.Unmarshal(body, &in); err != nil {
return nil, fmt.Errorf("the arguments do not fit the verb's input: %w", err)
}
in, err := decode(body)
if err != nil {
return nil, err
}
return do(caller, in)
}
@@ -47,14 +60,15 @@ func answerVerbs(conn *process.Conn, seats *seatlist.Part, v pipeline.Verbs) (fu
// the test runs' verbs test-runs and test-runs-drop (A-469g, A-470i).
func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
return map[string]process.SeatHandler{
seat.VerbRun: verbOf(func(c string, in seat.RunInput) (any, error) { return v.Run(c, in) }),
seat.VerbReview: verbOf(func(c string, in seat.ReviewInput) (any, error) { return v.Review(c, in) }),
seat.VerbRerun: verbOf(func(c string, in seat.RerunInput) (any, error) { return v.Rerun(c, in) }),
seat.VerbAccept: verbOf(func(c string, in seat.AcceptInput) (any, error) { return v.Accept(c, in) }),
seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }),
seat.VerbEndAgain: verbOf(func(c string, in seat.EndAgainInput) (any, error) { return v.EndAgain(c, in) }),
seat.VerbPlace: verbOf(func(c string, in seat.PlaceInput) (any, error) { return v.Place(c, in) }),
seat.VerbPlaceUnfinished: verbOf(func(c string, in seat.PlaceUnfinishedInput) (any, error) { return v.PlaceUnfinished(c, in) }),
seat.VerbRun: verbOf(func(c string, in seat.RunInput) (any, error) { return v.Run(c, in) }),
seat.VerbReview: verbOf(func(c string, in seat.ReviewInput) (any, error) { return v.Review(c, in) }),
seat.VerbRerun: verbOf(func(c string, in seat.RerunInput) (any, error) { return v.Rerun(c, in) }),
seat.VerbAccept: verbOf(func(c string, in seat.AcceptInput) (any, error) { return v.Accept(c, in) }),
seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }),
seat.VerbEndAgain: verbOf(func(c string, in seat.EndAgainInput) (any, error) { return v.EndAgain(c, in) }),
seat.VerbPlace: verbOf(func(c string, in seat.PlaceInput) (any, error) { return v.Place(c, in) }),
// The input is decoded by the seat's client, which refuses one naming neither or both of key and all (H-A-644).
seat.VerbPlaceUnfinished: decodedVerbOf(runnerclient.PlaceUnfinished, func(c string, in seat.PlaceUnfinishedInput) (any, error) { return v.PlaceUnfinished(c, in) }),
seat.VerbStart: verbOf(func(c string, in seat.StartInput) (any, error) { return v.Start(c, in) }),
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
// §728, A-469g: a test run's drop is answered by the process, the only writer of pipelines and test-runs.
@@ -4,12 +4,14 @@ import (
"encoding/json"
"errors"
"slices"
"strings"
"testing"
"time"
"git.novox.be/novox/mesh-sdk/go/busretry"
"git.novox.be/novox/mesh-sdk/go/seatlist"
runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
"mesh-delivery-pipeline/internal/pipeline"
@@ -46,6 +48,25 @@ func TestAVerbIsAnsweredOnlyForAProvedCallerAndItsOwnInput(t *testing.T) {
}
}
// design 47 H2 H-A-644 (AC-DC2d): place-unfinished's input is decoded by the seat's client: one naming both key and all, or
// neither, is refused with its words before the verb is asked, and `all` is read back.
func TestPlaceUnfinishedIsDecodedBytheSeatsClient(t *testing.T) {
var got seat.PlaceUnfinishedInput
h := decodedVerbOf(runnerclient.PlaceUnfinished, func(_ string, in seat.PlaceUnfinishedInput) (any, error) { got = in; return "placed", nil })
for _, body := range []string{`{"key":"main.app","all":true,"why":"x"}`, `{"why":"x"}`} {
if _, err := h("operator", json.RawMessage(body)); err == nil || !strings.Contains(err.Error(), "meshpipelinerunnerclient: place-unfinished names exactly one of key and all") || got.Why != "" {
t.Errorf("%s was answered (%v, %+v), want it refused by the client's words", body, err, got)
}
}
if out, err := h("operator", json.RawMessage(`{"all":true,"why":"x"}`)); err != nil || out != "placed" || !got.All {
t.Errorf("all = %v, %v, %+v", out, err, got)
}
// The process answers the verb through it.
if _, err := writeHandlers(pipeline.Verbs{})[seat.VerbPlaceUnfinished]("operator", json.RawMessage(`{"key":"main.app","all":true,"why":"x"}`)); err == nil || !strings.Contains(err.Error(), "meshpipelinerunnerclient") {
t.Errorf("the process answered place-unfinished naming key and all: %v, want the client's refusal", err)
}
}
// listingCatalog is the seat mesh-catalog as the reader asks it: an empty listing, so the bootstrapped definitions stand, or,
// silent, no answer at all.
type listingCatalog struct{ silent bool }