mesh/delivery-group group feat/774-l3-reland rejected: composed together: the checker's verdict at the members' heads (b48c90fea31f): integration: mesh-self-ch…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: integration: mesh-self-check/cmd/mesh-self-check.TestTheSelfCheckWholeRunsOnTheBus: the run answered {Run:doctor-1793351737-1 At:20…
One commit with exactly the tree of the reviewed head35b4509c0a, on main12c2574c9d, so two compiled programs added and removed on the branch leave no trace in history (issue 1577).
80 lines
3.6 KiB
Go
80 lines
3.6 KiB
Go
package main
|
|
|
|
// The tools of the switch (novox/hq ADR 0565 §4, §15): compare, take-over and hand-back, served as the seat's verbs
|
|
// and as the module's own tools beside them, the read of `declared` and resync.
|
|
|
|
import (
|
|
"strings"
|
|
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
)
|
|
|
|
// The switch's tools.
|
|
const (
|
|
CompareTool = "config_compare"
|
|
TakeOverTool = "config_take_over"
|
|
HandBackTool = "config_hand_back"
|
|
DeclaredTool = "config_declared"
|
|
ResyncTool = "config_resync"
|
|
)
|
|
|
|
// SeatVerbs are the seat's verbs, as the manifest claims them.
|
|
var SeatVerbs = []string{Verb, CompareVerb, TakeOverVerb, HandBackVerb}
|
|
|
|
func switchTools(c *Config) []stdio.Tool {
|
|
own := ownSwitchTools(c)
|
|
byName := map[string]stdio.Tool{}
|
|
for _, t := range own {
|
|
byName[t.Name] = t
|
|
}
|
|
for verb, tool := range map[string]string{CompareVerb: CompareTool, TakeOverVerb: TakeOverTool, HandBackVerb: HandBackTool} {
|
|
t := byName[tool]
|
|
t.Name = Seat + "." + verb
|
|
own = append(own, t)
|
|
}
|
|
return own
|
|
}
|
|
|
|
func ownSwitchTools(c *Config) []stdio.Tool {
|
|
why := map[string]any{"type": "object", "properties": map[string]any{
|
|
"why": map[string]any{"type": "string", "description": "why, in a sentence"}}, "required": []string{"why"}}
|
|
whyOf := func(a map[string]any) string { s, _ := a["why"].(string); return strings.TrimSpace(s) }
|
|
return []stdio.Tool{
|
|
{Name: CompareTool,
|
|
Description: "Every difference between config's own sources and the controller's records (novox/hq ADR 0565 §4): " +
|
|
"each placed module's declarations (declared against the mirror declared-config), the list of predefined " +
|
|
"keys (the indexer's against the mirror's), each open pull request's config (the indexer's candidate " +
|
|
"against the controller's pull-declares), and every placed module's value on every node resolved both " +
|
|
"ways; each with its reason. The take-over is refused while any stands.",
|
|
Run: func(map[string]any) (any, error) { return c.Compare() }},
|
|
{Name: TakeOverTool,
|
|
Description: "Ask the operator's Approve, under mesh-config's own name, to switch config to its own sources: " +
|
|
"the indexer's list of predefined keys and pull request config, refusing the controller's pull-declares. " +
|
|
"Refused while compare shows a difference; on Approve switched if nothing differs then.",
|
|
Input: why,
|
|
Run: func(a map[string]any) (any, error) {
|
|
return c.TakeOver(Call{Why: whyOf(a), Caller: stdio.CallerOf(a)})
|
|
}},
|
|
{Name: HandBackTool,
|
|
Description: "Return config to the controller's records (its mirrors declared-config and predefined, and " +
|
|
"pull-declares) until the controller hands its lease away; gone after it. Recorded as a hand act.",
|
|
Input: why,
|
|
Run: func(a map[string]any) (any, error) {
|
|
return c.HandBack(Call{Why: whyOf(a), Caller: stdio.CallerOf(a)})
|
|
}},
|
|
{Name: DeclaredTool,
|
|
Description: "Each placed module's declarations as config keeps them (its state declared): the manifest and " +
|
|
"commit they come from and how many keys, or one module whole; and which source holds now.",
|
|
Input: map[string]any{"type": "object", "properties": map[string]any{
|
|
"module": map[string]any{"type": "string", "description": "one module, whole"}}},
|
|
Run: func(a map[string]any) (any, error) {
|
|
m, _ := a["module"].(string)
|
|
return c.Declared(strings.TrimSpace(m))
|
|
}},
|
|
{Name: ResyncTool,
|
|
Description: "Read every source again and write what differs: the published list of predefined keys, the " +
|
|
"resolved values, declared, and after the take-over the indexer's config candidates.",
|
|
Run: func(map[string]any) (any, error) { return c.Resync() }},
|
|
}
|
|
}
|