A2 tier-tools: assigner_written answers both lateness fields, held-by-tier names the tier and its holder, assigner_progress_drop
Builds: design 47 H2b §824 6., 7. (H-A-844)
This commit is contained in:
@@ -122,6 +122,8 @@ type passer struct {
|
||||
wake func()
|
||||
wakes wakes
|
||||
after func(time.Duration, func()) func() bool
|
||||
// tierHolds are, by pipeline, what holds its tier progress at its tier, read by the last pass (tiers.go, why.go).
|
||||
tierHolds map[string]tierHold
|
||||
// owed are the events of the seat mesh-wants the bus refused, owed in order and said again (owed.go, design 47 H §832).
|
||||
owed owedKept
|
||||
// passStall is the setting pass-stall-seconds (passstall.go; zero: its default): a pass still running after it says which phase
|
||||
@@ -292,7 +294,11 @@ func (p *passer) wants(ctx context.Context) {
|
||||
for node, fp := range out.Unversioned {
|
||||
unversioned[assign.UnversionedKey(name, node)] = unversionedWant{module: name, node: node, fp: fp}
|
||||
}
|
||||
p.sayWhy(ctx, name, m.Nodes, wantWhy{Branch: g.branch, Fp: target.Fp, Version: target.Version, Pipeline: target.Pipeline, Step: whyStep(ok)}, wantedOf, &out)
|
||||
why := wantWhy{Branch: g.branch, Fp: target.Fp, Version: target.Version, Pipeline: target.Pipeline, Step: whyStep(ok)}
|
||||
if !ok {
|
||||
why, _ = p.heldByTier(name, g.branch, why)
|
||||
}
|
||||
p.sayWhy(ctx, name, m.Nodes, why, wantedOf, &out)
|
||||
if ok {
|
||||
p.yeses(ctx, name, m, wantedOf, &out)
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ func (e *pipelineEnds) branchOf(module, placed string) string {
|
||||
|
||||
// writtenTools is the tool assigner_written: every key of the state written, with its end.
|
||||
func writtenTools(st store) []stdio.Tool {
|
||||
return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the newest version released whose pipeline passed, with its pipeline and rank; per pipeline whose wants are written tier by tier, its tier progress (tier, since, movers, and clock-from and paused-from: the time tier-bound counts from, and when a pause of the count by an ask of the operator began); with why, why each want is what it is (as assigner_why).",
|
||||
return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the newest version released whose pipeline passed, with its pipeline and rank; per pipeline whose wants are written tier by tier, its tier progress (tier, since, movers, and clock-from and paused-from: the time tier-bound counts from, and when a pause of the count by an ask of the operator began; tier-late-at, the time any tier was first found past tier-bound, and tier-late-said, the time the bus took pipeline-wanted tier-late: a key with the first and not the second holds a tier-late still to be said); with why, why each want is what it is (as assigner_why).",
|
||||
Input: schema(map[string]string{"why": "true: why each want is what it is", "module": "with why: a module's name", "node": "with why: a node's name"}, nil, "why"),
|
||||
Run: func(args map[string]any) (any, error) {
|
||||
if args["why"] == true || args["why"] == "true" {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
// progressDropTool drops one pipeline's tier progress by hand (design 47 H2b §824 7.): a key whose tier never runs (a version that
|
||||
// never comes) stands, said by `tier-late`, until a later pipeline carries its movers or a person drops it. The act is recorded in
|
||||
// the hand-act log first; the key is deleted, and the pass that finds its pipeline no longer followed clears its `tier-late`
|
||||
// from the findings bucket (H-A-722). Nothing is said on the seat `mesh-wants`: the gate's record ended failed at `tier-late`.
|
||||
const progressDropTool = "assigner_progress_drop"
|
||||
|
||||
// dropProgress deletes the tier progress of pipeline, the act first recorded through the seat mesh-hand-acts.
|
||||
func dropProgress(st seatStore, ask func(string, any) (json.RawMessage, error), pipeline, why, by string) (any, error) {
|
||||
switch {
|
||||
case pipeline == "":
|
||||
return nil, errors.New("name the pipeline whose tier progress is dropped")
|
||||
case !isTierKey(tierKey(pipeline)):
|
||||
return nil, fmt.Errorf("%q is no pipeline's key of a form the seat defines", pipeline)
|
||||
case why == "":
|
||||
return nil, errors.New("a tier progress dropped by hand says why")
|
||||
case by == "" || by == stdio.Unproven:
|
||||
return nil, errors.New("a tier progress dropped by hand names who drops it, and the runtime proved no caller")
|
||||
}
|
||||
key := tierKey(pipeline)
|
||||
raw, _, found, err := st.get(writtenState, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, fmt.Errorf("the assigner holds no tier progress under %s: assigner_written lists them", key)
|
||||
}
|
||||
taken, err := meshhandactsclient.Recorder{Ask: ask}.Record(meshhandactsclient.Request{What: progressDropTool + " " + key, Why: why + " (" + by + ")", Cause: "tier-progress-drop"})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the drop of %s is not recorded, so the progress stays: %w", key, err)
|
||||
}
|
||||
if err := st.del(writtenState, key); err != nil {
|
||||
return nil, fmt.Errorf("the tier progress %s is not dropped: %w", key, err)
|
||||
}
|
||||
return map[string]any{"key": key, "dropped": json.RawMessage(raw), "by": by, "hand-act": taken.Log}, nil
|
||||
}
|
||||
|
||||
// progressDropTools is the tool over the runtime's states.
|
||||
func progressDropTools(st seatStore, ask func(string, any) (json.RawMessage, error)) []stdio.Tool {
|
||||
return []stdio.Tool{{Name: progressDropTool, Description: "Drop one pipeline's tier progress by hand (design 47 H2b §824 7.): the key pipeline.<pipeline> of the state written " +
|
||||
"is deleted, for a progress whose tier never runs (a version that never comes) and no later pipeline carries; the finding tier-late of that pipeline is cleared by the next pass, and nothing " +
|
||||
"is said on the seat mesh-wants. Recorded as a hand act first; refused with no progress under the key.",
|
||||
Input: schema(map[string]string{"pipeline": "the pipeline's key, <branch>.<revision> or its again form", "why": "why the progress is dropped"}, []string{"pipeline", "why"}),
|
||||
Run: func(a map[string]any) (any, error) {
|
||||
return dropProgress(st, ask, arg(a, "pipeline"), arg(a, "why"), stdio.CallerOf(a))
|
||||
}}}
|
||||
}
|
||||
@@ -200,6 +200,7 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st
|
||||
}
|
||||
defer p.clearTierLate(followed)
|
||||
have, readable := p.findingKeys("the finding tier-late")
|
||||
p.tierHolds = map[string]tierHold{}
|
||||
for _, key := range ks {
|
||||
if !isTierKey(key) {
|
||||
continue
|
||||
@@ -259,6 +260,9 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st
|
||||
break
|
||||
}
|
||||
runs := len(notRunning) == 0
|
||||
if !runs {
|
||||
p.tierHolds[pipeline] = tierHold{tier: t.Tier, mover: notRunning[0].Module, late: !t.TierLateAt.IsZero(), pipeline: pipeline}
|
||||
}
|
||||
late := !runs && t.PausedFrom.IsZero() && !now.Before(clock.Add(bound))
|
||||
if !runs && !t.PausedFrom.IsZero() {
|
||||
break // paused: no lateness, and no timer armed
|
||||
|
||||
@@ -285,6 +285,47 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
||||
t.Errorf("AC-824n: the next pass, with the clear taken, writes tier 2 and carries the fields: %+v", prog)
|
||||
}
|
||||
})
|
||||
// Design 47 H2b §824 6., 7. (H-A-844): a want waiting on its tier says held-by-tier, naming the pipeline, the tier and the mover that
|
||||
// holds it; assigner_progress_drop deletes a progress whose version never comes, in the hand-act log.
|
||||
t.Run("a want waiting on its tier says held-by-tier, and a progress is dropped by hand", func(t *testing.T) {
|
||||
db, web := meshcatalogclient.SourcePrefix2+strings.Repeat("d", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("c", 64)
|
||||
pipeline := trunkBranch + ".5"
|
||||
r := newTierRig(t, db, web, pipeline)
|
||||
r.pass(31 * time.Minute)
|
||||
why, ok := r.p.heldByTier("web", trunkBranch, wantWhy{})
|
||||
if !ok || why.Step != whyHeldByTier || why.Pipeline != pipeline || why.Tier != 1 || why.Holder != "db" || !why.TierLate {
|
||||
t.Errorf("AC-824l: the why of web is %+v (%v), want held-by-tier naming %s, tier 1, db, late", why, ok, pipeline)
|
||||
}
|
||||
if _, ok := r.p.heldByTier("nothing", trunkBranch, wantWhy{}); ok {
|
||||
t.Error("AC-824l: a module with no kept end is held by a tier")
|
||||
}
|
||||
key := tierKey(pipeline)
|
||||
st := memStore{writtenState: &memKV{values: map[string][]byte{key: r.ends.vals[key]}}}
|
||||
var asked []string
|
||||
ask := func(verb string, body any) (json.RawMessage, error) {
|
||||
raw, _ := json.Marshal(body)
|
||||
asked = append(asked, string(raw))
|
||||
return json.RawMessage(`{}`), nil
|
||||
}
|
||||
if _, err := dropProgress(st, ask, pipeline, "its version never comes", "person.jochen"); err != nil || len(st[writtenState].values) != 0 || len(asked) != 1 ||
|
||||
!strings.Contains(asked[0], progressDropTool+" "+key) {
|
||||
t.Errorf("AC-824g: the drop answered %v, left %v, asked %v", err, st[writtenState].values, asked)
|
||||
}
|
||||
if _, err := dropProgress(st, ask, pipeline, "again", "person.jochen"); err == nil {
|
||||
t.Error("a progress no longer there was dropped")
|
||||
}
|
||||
// the pass that finds the pipeline no longer followed clears its tier-late
|
||||
delete(r.ends.vals, key)
|
||||
r.pass(32 * time.Minute)
|
||||
if len(r.findings) != 0 || len(r.said) != 1 {
|
||||
t.Errorf("AC-824g: findings %v, said %+v after the drop", r.findings, r.said)
|
||||
}
|
||||
prog := tierProgress{TierLateAt: r.start, TierLateSaid: r.start.Add(time.Minute)}
|
||||
raw, _ := json.Marshal(prog)
|
||||
if !strings.Contains(string(raw), `"tier-late-at"`) || !strings.Contains(string(raw), `"tier-late-said"`) {
|
||||
t.Errorf("AC-824j: the progress holds %s", raw)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// H-A-270, H-A-273, H-A-277 (1): a pipeline's tier progress holds every passed mover, versioned or not, and a tier with a mover
|
||||
|
||||
@@ -400,6 +400,7 @@ func serveTools() error {
|
||||
// What each node's engine reads, as the assigner uses it: its own state engine-reads (design 47 H-A-104).
|
||||
tools = append(tools, engineReadsTools(runtimeStore{})...)
|
||||
tools = append(tools, writtenTools(runtimeStore{})...)
|
||||
tools = append(tools, progressDropTools(runtimeStore{}, stdio.Ask)...) // a tier progress whose tier never runs (§824 7.)
|
||||
tools = append(tools, whyTools(runtimeStore{})...)
|
||||
tools = append(tools, askAgainTools(runtimeStore{}, stdio.Ask, time.Now)...)
|
||||
tools = append(tools, wantDropTools(runtimeStore{}, stdio.Ask)...)
|
||||
|
||||
@@ -29,6 +29,9 @@ const whyTool = "assigner_why"
|
||||
const (
|
||||
whyNoPipeline = "no-passed-pipeline" // no version of the module released on the branch passed its pipeline: the want written stays
|
||||
whyPassed = "passed-pipeline" // the want names the newest version released on the branch whose pipeline passed (design 47 H §750)
|
||||
// whyHeldByTier: the module's end is kept, and its pipeline's tier progress has not reached its rank; the why names the
|
||||
// pipeline, the tier that runs and the mover that holds it, and whether that tier was found late (§824 6., H-A-507, H-A-844).
|
||||
whyHeldByTier = "held-by-tier"
|
||||
)
|
||||
|
||||
// whyStep is the step that decided a want: a passed pipeline's version, or none yet.
|
||||
@@ -39,6 +42,32 @@ func whyStep(passed bool) string {
|
||||
return whyNoPipeline
|
||||
}
|
||||
|
||||
// heldByTier is the why of module's want on branch when its end is kept and its pipeline's tier progress has not reached its rank;
|
||||
// false when no end is kept (then the step is no-passed-pipeline, H-A-507) or the tier is written.
|
||||
func (p *passer) heldByTier(module, branch string, w wantWhy) (wantWhy, bool) {
|
||||
if p.ends == nil {
|
||||
return w, false
|
||||
}
|
||||
end, ok := p.ends.endOf(module, p.ends.branchOf(module, branch))
|
||||
if !ok || p.ends.tierWritten(end) {
|
||||
return w, false
|
||||
}
|
||||
w.Step, w.Pipeline, w.Fp, w.Version = whyHeldByTier, end.Pipeline, end.Fp, end.Version
|
||||
if h, ok := p.tierHolds[end.Pipeline]; ok {
|
||||
w.Tier, w.Holder, w.TierLate = h.tier, h.mover, h.late
|
||||
}
|
||||
return w, true
|
||||
}
|
||||
|
||||
// tierHold is what holds a pipeline's tier progress at its tier: the first mover of that tier not running, and whether the tier was
|
||||
// found late; kept by the pass that read it, for the whys of the wants that wait on the tier.
|
||||
type tierHold struct {
|
||||
tier int64
|
||||
mover string
|
||||
late bool
|
||||
pipeline string
|
||||
}
|
||||
|
||||
// wantWhy is one key's value.
|
||||
type wantWhy struct {
|
||||
At time.Time `json:"at"`
|
||||
@@ -48,6 +77,11 @@ type wantWhy struct {
|
||||
Version string `json:"version,omitempty"`
|
||||
Pipeline string `json:"pipeline,omitempty"`
|
||||
Step string `json:"step"`
|
||||
// Tier, Holder and TierLate say, for held-by-tier, the tier that runs, the mover that holds it and whether that tier was found
|
||||
// late (design 47 H2b §824 6.).
|
||||
Tier int64 `json:"tier,omitempty"`
|
||||
Holder string `json:"holder,omitempty"`
|
||||
TierLate bool `json:"tier-late,omitempty"`
|
||||
// Before is the want that stood before the pass, After the one the pass wrote (none: it kept Before).
|
||||
Before *mwc.Want `json:"before,omitempty"`
|
||||
After *mwc.Want `json:"after,omitempty"`
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestManifest(t *testing.T) {
|
||||
// which lists and asks again what each node's engine reads.
|
||||
if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assigner_inputs_drop", "assigner_compositions", "assigner_compositions_drop", "assignments", "seat-holders", "wants", "asks",
|
||||
"assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies",
|
||||
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before", "assigner_validate"}) {
|
||||
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_progress_drop", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before", "assigner_validate"}) {
|
||||
t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5), assigner_why (design 47 G A-439) and assigner_assignment_drop after assigner_want_drop (design 47 H2 H-A-509)", m.Tools)
|
||||
}
|
||||
if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs {
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
"assigner_seat_list_again",
|
||||
"assigner_ask_again",
|
||||
"assigner_written",
|
||||
"assigner_progress_drop",
|
||||
"assigner_why",
|
||||
"assigner_want_drop",
|
||||
"assigner_assignment_drop",
|
||||
|
||||
Reference in New Issue
Block a user