Merge pull request 'Design 47 H1: the indexer declares the finding kinds it raises; its unanswered calls get a kind of its own (H-A-247)' (#308) from fix/47-H1-indexer-finding-kinds into main
This commit was merged in pull request #308.
This commit is contained in:
@@ -289,7 +289,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
// The indexer's findings are the seat mesh-conditions' generated finding, written through mesh-sdk's held finding writer
|
// The indexer's findings are the seat mesh-conditions' generated finding, written through mesh-sdk's held finding writer
|
||||||
// (design 47 G §689, A-29): it holds what is written before the state is bound, and starts once the state is.
|
// (design 47 G §689, A-29): it holds what is written before the state is bound, and starts once the state is.
|
||||||
writer, err := views.NewHeldWriter(views.WriterConfig[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]{
|
writer, err := views.NewHeldWriter(views.WriterConfig[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]{
|
||||||
Module: cred.Module, State: calls.State(index.FindingsState), Node: cred.Node, Asked: mcseat.SubjectFindingsAsked, JS: js, Conn: conn, Logf: logger.Printf})
|
Module: cred.Module, State: calls.State(index.FindingsState), Node: cred.Node, Asked: mcseat.SubjectFindingsAsked, JS: js, Conn: conn, Logf: logger.Printf,
|
||||||
|
// its own kinds only (G §580, H-A-242, H-A-247): the tool runner's writer states its kinds over the same state
|
||||||
|
Kinds: index.FindingKinds, Retired: index.RetiredFindingKinds})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("the indexer's finding writer cannot be made: %w", err)
|
return fmt.Errorf("the indexer's finding writer cannot be made: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,206 @@
|
|||||||
|
package index
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go/ast"
|
||||||
|
"go/parser"
|
||||||
|
"go/token"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||||
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient/heard"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/views"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Design 47 H H-A-240, H-A-242, H-A-247, G §580: every finding kind the daemon's code raises or clears is one its writer owns
|
||||||
|
// (FindingKinds, and a views reader's views.ViewKinds), so the writer never refuses a kind of the indexer's own. The test
|
||||||
|
// reads the daemon's code (this package and cmd/mesh-delivery-indexer) for every place a kind is given to the writer: the
|
||||||
|
// kind argument of observed, finding, clearFinding, clearHeld and a writer's Clear, the Kind of a Finding literal, and the
|
||||||
|
// kinds of an SDK part handed the writer (partKinds). mcc.KindCallUnanswered stays readable, so a return to the tool runner's
|
||||||
|
// kind fails the test. A
|
||||||
|
// kind there is a string, a constant of the package or a constant named in imported below; any other form fails the test,
|
||||||
|
// naming its place, but for the pass-through parameter `kind`, a held finding's `.Kind` and the kind cut from a key a views
|
||||||
|
// reader names, which carry a kind given elsewhere.
|
||||||
|
func TestFindingKindsHoldEveryKindTheCodeRaises(t *testing.T) {
|
||||||
|
imported := map[string]string{"mcc.KindCallUnanswered": mcc.KindCallUnanswered, "views.ViewWaitsKind": views.ViewWaitsKind}
|
||||||
|
// kindArg is the place of the kind among a raising call's arguments.
|
||||||
|
kindArg := map[string]int{"observed": 2, "finding": 2, "clearFinding": 3, "clearHeld": 4, "Clear": 3}
|
||||||
|
// partKinds are the kinds each SDK part raises through the writer it is handed (H-A-247 (1)); handed says a literal's field
|
||||||
|
// gives it the writer.
|
||||||
|
partKinds := map[string][]string{"views.ProcessReader": {views.EventUnhandledKind}, "views.Emitter": {views.UnsaidKind, views.TooLargeKind},
|
||||||
|
"heard.Writer": {heard.Kind}}
|
||||||
|
handed := func(e ast.Expr) bool {
|
||||||
|
kv, ok := e.(*ast.KeyValueExpr)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
id, ok := kv.Key.(*ast.Ident)
|
||||||
|
return ok && (id.Name == "Findings" || id.Name == "Put")
|
||||||
|
}
|
||||||
|
fset := token.NewFileSet()
|
||||||
|
var files []*ast.File
|
||||||
|
consts := map[string]string{}
|
||||||
|
for _, dir := range []string{".", filepath.Join("..", "..", "cmd", "mesh-delivery-indexer")} {
|
||||||
|
entries, err := os.ReadDir(dir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, e := range entries {
|
||||||
|
if !strings.HasSuffix(e.Name(), ".go") || strings.HasSuffix(e.Name(), "_test.go") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f, err := parser.ParseFile(fset, filepath.Join(dir, e.Name()), nil, 0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
files = append(files, f)
|
||||||
|
if dir != "." {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, d := range f.Decls {
|
||||||
|
g, ok := d.(*ast.GenDecl)
|
||||||
|
if !ok || g.Tok != token.CONST {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, s := range g.Specs {
|
||||||
|
v := s.(*ast.ValueSpec)
|
||||||
|
for i, n := range v.Names {
|
||||||
|
if i < len(v.Values) {
|
||||||
|
if l, ok := v.Values[i].(*ast.BasicLit); ok && l.Kind == token.STRING {
|
||||||
|
consts[n.Name], _ = strconv.Unquote(l.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declared := append(slices.Clone(FindingKinds), views.ViewKinds...)
|
||||||
|
raised := map[string]string{} // kind -> a place it is raised
|
||||||
|
kindOf := func(e ast.Expr) (string, bool) {
|
||||||
|
switch x := e.(type) {
|
||||||
|
case *ast.BasicLit:
|
||||||
|
s, err := strconv.Unquote(x.Value)
|
||||||
|
return s, err == nil
|
||||||
|
case *ast.Ident:
|
||||||
|
if x.Name == "kind" {
|
||||||
|
return "", true // a pass-through parameter: its callers give the kind
|
||||||
|
}
|
||||||
|
s, ok := consts[x.Name]
|
||||||
|
if !ok {
|
||||||
|
s, ok = imported["index."+x.Name]
|
||||||
|
}
|
||||||
|
return s, ok
|
||||||
|
case *ast.SliceExpr:
|
||||||
|
return "", true // the kind of a key a views reader names: its own kinds (views.ViewKinds)
|
||||||
|
case *ast.SelectorExpr:
|
||||||
|
if x.Sel.Name == "Kind" {
|
||||||
|
return "", true // a held finding's kind, given when it was raised
|
||||||
|
}
|
||||||
|
if p, ok := x.X.(*ast.Ident); ok {
|
||||||
|
if p.Name == "index" {
|
||||||
|
s, ok := consts[x.Sel.Name]
|
||||||
|
return s, ok
|
||||||
|
}
|
||||||
|
s, ok := imported[p.Name+"."+x.Sel.Name]
|
||||||
|
return s, ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
note := func(e ast.Expr) {
|
||||||
|
k, ok := kindOf(e)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("%s: a finding kind the test cannot read; give it as a constant (or name it in imported)", fset.Position(e.Pos()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if k != "" {
|
||||||
|
raised[k] = fset.Position(e.Pos()).String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range files {
|
||||||
|
ast.Inspect(f, func(n ast.Node) bool {
|
||||||
|
switch x := n.(type) {
|
||||||
|
case *ast.CallExpr:
|
||||||
|
var name string
|
||||||
|
switch fn := x.Fun.(type) {
|
||||||
|
case *ast.Ident:
|
||||||
|
name = fn.Name
|
||||||
|
case *ast.SelectorExpr:
|
||||||
|
name = fn.Sel.Name
|
||||||
|
}
|
||||||
|
if i, ok := kindArg[name]; ok && len(x.Args) > i {
|
||||||
|
if name == "Clear" && len(x.Args) != 5 {
|
||||||
|
return true // not a finding writer's Clear(ctx, scope, id, kind, why)
|
||||||
|
}
|
||||||
|
note(x.Args[i])
|
||||||
|
}
|
||||||
|
case *ast.CompositeLit:
|
||||||
|
// an SDK part handed the writer raises its own kinds through it (H-A-247 (1))
|
||||||
|
if s, ok := x.Type.(*ast.SelectorExpr); ok && slices.ContainsFunc(x.Elts, handed) {
|
||||||
|
if p, ok := s.X.(*ast.Ident); ok && p.Name != "index" { // the indexer's own code is read above
|
||||||
|
part := p.Name + "." + s.Sel.Name
|
||||||
|
if kinds, ok := partKinds[part]; ok {
|
||||||
|
for _, k := range kinds {
|
||||||
|
raised[k] = fset.Position(x.Pos()).String() + " (" + part + ")"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
t.Errorf("%s: %s is handed the finding writer, and the test does not know its kinds: name them in partKinds",
|
||||||
|
fset.Position(x.Pos()), part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if s, ok := x.Type.(*ast.SelectorExpr); ok && s.Sel.Name == "Finding" {
|
||||||
|
for _, el := range x.Elts {
|
||||||
|
if kv, ok := el.(*ast.KeyValueExpr); ok {
|
||||||
|
if id, ok := kv.Key.(*ast.Ident); ok && id.Name == "Kind" {
|
||||||
|
note(kv.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, k := range []string{PinMissingKind, OutOfStepKind, PackagesNotPublishedKind, CallUnansweredKind, views.EventUnhandledKind, heard.Kind} {
|
||||||
|
if _, ok := raised[k]; !ok {
|
||||||
|
t.Errorf("the test no longer finds the kind %s the code raises: it reads the code wrongly", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k, at := range raised {
|
||||||
|
if !slices.Contains(declared, k) {
|
||||||
|
t.Errorf("%s: the code raises the finding kind %q, which the writer's list FindingKinds does not declare", at, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// a retired kind is one no code raises and the writer does not own (H-A-247 (3))
|
||||||
|
for _, r := range RetiredFindingKinds {
|
||||||
|
if at, ok := raised[r.Kind]; ok || slices.Contains(declared, r.Kind) {
|
||||||
|
t.Errorf("the retired kind %q is still declared or raised (%s)", r.Kind, at)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// H-A-249: the retired call-unanswered names the ids the indexer's unanswered calls are written under, as in a key
|
||||||
|
covers := func(scope, id string) bool {
|
||||||
|
for _, r := range RetiredFindingKinds {
|
||||||
|
if r.Kind == mcc.KindCallUnanswered && (r.Scope == "" || r.Scope == scope) && (slices.Contains(r.IDs, id) ||
|
||||||
|
slices.ContainsFunc(r.Prefixes, func(p string) bool { return strings.HasPrefix(id, p) })) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, id := range []string{keyID("node-build-go." + StepsVerb), keyID("node-build-image." + StepsVerb), keyID(floorKey("mesh-tools")),
|
||||||
|
keyID(BuilderVersionsCall)} {
|
||||||
|
if !covers(mcc.ScopeCall, id) {
|
||||||
|
t.Errorf("the retired call-unanswered does not cover the indexer's id %s", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// the approval gate's findings: scope machine, id <node>=2e<ask>
|
||||||
|
if covers("machine", "novox=2eask-1") || covers("machine", "node-build-go.steps") || covers(mcc.ScopeCall, "novox=2eask-1") {
|
||||||
|
t.Error("the retired call-unanswered covers an id of the tool runner's")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||||
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient/heard"
|
||||||
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/views"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FindingsState is the indexer's state of its findings (design 47 G §383, §687).
|
// FindingsState is the indexer's state of its findings (design 47 G §383, §687).
|
||||||
@@ -12,6 +14,26 @@ const (
|
|||||||
FindingsState = "findings"
|
FindingsState = "findings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CallUnansweredKind is the indexer's finding of a call nobody answered within its bound (scope call, its id the call): a kind
|
||||||
|
// of its own, since the tool runner's writer over the same state owns call-unanswered (design 47 H H-A-247 (2)).
|
||||||
|
const CallUnansweredKind = "indexer-call-unanswered"
|
||||||
|
|
||||||
|
// FindingKinds are the finding kinds the indexer's daemon raises, the kinds its writer owns (design 47 G §580, H H-A-240,
|
||||||
|
// H-A-242, H-A-247): its own, the process reader's event-unhandled and the family-not-heard of the heard writer it is handed
|
||||||
|
// (H-A-247 (1)); a views reader's and the emitter's (views.ViewKinds) are always the writer's besides. The tool runner's
|
||||||
|
// writer over the same state `findings` owns its own. TestFindingKindsHoldEveryKindTheCodeRaises holds the code to this list.
|
||||||
|
var FindingKinds = []string{PinMissingKind, OutOfStepKind, PackagesNotPublishedKind, HistoryFillingKind, SeedWaitsKind,
|
||||||
|
SeedLeftOutKind, SeatDefinitionUnparsedKind, SeatDefinedTwiceKind, SeatOutsideItsDomainKind, CallUnansweredKind,
|
||||||
|
views.EventUnhandledKind, heard.Kind}
|
||||||
|
|
||||||
|
// RetiredFindingKinds are kinds no code of the indexer raises any more, which its writer clears once at its start (H-A-247
|
||||||
|
// (3)): merge-untaken went with H-A-82; call-unanswered became indexer-call-unanswered (H-A-247 (2)), and since the tool
|
||||||
|
// runner's writer owns call-unanswered in the same state, only the ids the indexer wrote under it, in scope call, are cleared (H-A-249):
|
||||||
|
// the seed's <build seat>.steps (every build seat is named node-build-<kind>), the floor's mesh-catalog.versions-floor.<module>
|
||||||
|
// and the versions fill's mesh-delivery-builder.builder_versions.
|
||||||
|
var RetiredFindingKinds = []views.RetiredKind{{Kind: "merge-untaken"}, {Kind: mcc.KindCallUnanswered, Scope: mcc.ScopeCall,
|
||||||
|
IDs: []string{keyID(BuilderVersionsCall)}, Prefixes: []string{"node-build-", keyID(FloorCall) + "."}}}
|
||||||
|
|
||||||
// FindingWriter is the indexer's finding writer, mesh-sdk's held writer of the seat mesh-conditions' generated finding (design
|
// FindingWriter is the indexer's finding writer, mesh-sdk's held writer of the seat mesh-conditions' generated finding (design
|
||||||
// 47 G A-29, A-38): Write raises a finding, Clear clears one, Held answers the findings it holds, so the indexer reads what
|
// 47 G A-29, A-38): Write raises a finding, Clear clears one, Held answers the findings it holds, so the indexer reads what
|
||||||
// stands from the writer.
|
// stands from the writer.
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func (r *Registry) ProposeSeed(ctx context.Context, modules []SeedModule, again
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if len(seed.Unanswered) > 0 {
|
if len(seed.Unanswered) > 0 {
|
||||||
return "", fmt.Errorf("the build seats %v have not answered steps: the seed waits for them (call-unanswered after five minutes)", seed.Unanswered)
|
return "", fmt.Errorf("the build seats %v have not answered steps: the seed waits for them (indexer-call-unanswered after five minutes)", seed.Unanswered)
|
||||||
}
|
}
|
||||||
regs, left = seed.Registrations, seed.Left
|
regs, left = seed.Registrations, seed.Left
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func buildSeatOf(defs map[string]seatdef.Definition, a meshcatalog.Artifact) (st
|
|||||||
// SeedModulesFrom reads the modules the newest trunk revision holds for the seed (design 47 G §704, §8): for each artifact of
|
// SeedModulesFrom reads the modules the newest trunk revision holds for the seed (design 47 G §704, §8): for each artifact of
|
||||||
// each module the seat list's build seat answers steps with {module, artifact, fingerprint, fetch} from the module's trunk
|
// each module the seat list's build seat answers steps with {module, artifact, fingerprint, fetch} from the module's trunk
|
||||||
// entry, the fetch its repository, commit, directory and the artifact's named paths. A seat that does not answer leaves
|
// entry, the fetch its repository, commit, directory and the artifact's named paths. A seat that does not answer leaves
|
||||||
// its artifact unanswered, which holds the seed; its call-unanswered finding (scope call, id <seat>.steps) is written once
|
// its artifact unanswered, which holds the seed; its indexer-call-unanswered finding (scope call, id <seat>.steps) is written once
|
||||||
// it is unanswered five minutes and cleared when it answers.
|
// it is unanswered five minutes and cleared when it answers.
|
||||||
func (ix *Indexer) SeedModulesFrom(ctx context.Context, defs map[string]seatdef.Definition, steps StepsCaller) ([]SeedModule, error) {
|
func (ix *Indexer) SeedModulesFrom(ctx context.Context, defs map[string]seatdef.Definition, steps StepsCaller) ([]SeedModule, error) {
|
||||||
if ix.Revisions == nil {
|
if ix.Revisions == nil {
|
||||||
@@ -202,7 +202,7 @@ func artifactName(ref string) string {
|
|||||||
return ref
|
return ref
|
||||||
}
|
}
|
||||||
|
|
||||||
// stepsFindings writes call-unanswered for each seat unanswered for five minutes and clears it for each that answered.
|
// stepsFindings writes indexer-call-unanswered for each seat unanswered for five minutes and clears it for each that answered.
|
||||||
func (ix *Indexer) stepsFindings(ctx context.Context, answered map[string]bool, unanswered map[string]error) {
|
func (ix *Indexer) stepsFindings(ctx context.Context, answered map[string]bool, unanswered map[string]error) {
|
||||||
if ix.Findings == nil {
|
if ix.Findings == nil {
|
||||||
return
|
return
|
||||||
@@ -223,11 +223,11 @@ func (ix *Indexer) stepsFindings(ctx context.Context, answered map[string]bool,
|
|||||||
}
|
}
|
||||||
for _, seat := range slices.Sorted(slices.Values(raise)) {
|
for _, seat := range slices.Sorted(slices.Values(raise)) {
|
||||||
id := seat + "." + StepsVerb
|
id := seat + "." + StepsVerb
|
||||||
f := ix.observed(mcc.ScopeCall, id, mcc.KindCallUnanswered,
|
f := ix.observed(mcc.ScopeCall, id, CallUnansweredKind,
|
||||||
fmt.Sprintf("the call %s is unanswered since %s", id, since[seat].UTC().Format(time.RFC3339)),
|
fmt.Sprintf("the call %s is unanswered since %s", id, since[seat].UTC().Format(time.RFC3339)),
|
||||||
"A call whose answer is kept is not answered",
|
"A call whose answer is kept is not answered",
|
||||||
fmt.Sprintf("The seed asks %s of every artifact its build seat builds; it is not answered since %s (%v), so the first registrations wait for it.", id, since[seat].UTC().Format(time.RFC3339), unanswered[seat]),
|
fmt.Sprintf("The seed asks %s of every artifact its build seat builds; it is not answered since %s (%v), so the first registrations wait for it.", id, since[seat].UTC().Format(time.RFC3339), unanswered[seat]),
|
||||||
"indexer."+mcc.KindCallUnanswered)
|
"indexer."+CallUnansweredKind)
|
||||||
if err := ix.Findings.Write(ctx, f); err != nil {
|
if err := ix.Findings.Write(ctx, f); err != nil {
|
||||||
ix.logf("seed: the finding %s is not written: %v", id, err)
|
ix.logf("seed: the finding %s is not written: %v", id, err)
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ func (ix *Indexer) stepsFindings(ctx context.Context, answered map[string]bool,
|
|||||||
if _, bad := unanswered[seat]; bad {
|
if _, bad := unanswered[seat]; bad {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := ix.clearFinding(ctx, mcc.ScopeCall, seat+"."+StepsVerb, mcc.KindCallUnanswered, "the seat answers steps"); err != nil {
|
if err := ix.clearFinding(ctx, mcc.ScopeCall, seat+"."+StepsVerb, CallUnansweredKind, "the seat answers steps"); err != nil {
|
||||||
ix.logf("seed: the finding %s.%s is not cleared: %v", seat, StepsVerb, err)
|
ix.logf("seed: the finding %s.%s is not cleared: %v", seat, StepsVerb, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
// Design 47 G §704: the seed asks `steps` of the build seat whose `build` rule matches each artifact, with {module,
|
// Design 47 G §704: the seed asks `steps` of the build seat whose `build` rule matches each artifact, with {module,
|
||||||
// artifact, fingerprint, fetch} from the newest trunk entry; a seat that does not answer holds the seed and, after five
|
// artifact, fingerprint, fetch} from the newest trunk entry; a seat that does not answer holds the seed and, after five
|
||||||
// minutes, is the finding call-unanswered (scope call, id <seat>.steps), cleared when it answers.
|
// minutes, is the finding indexer-call-unanswered (scope call, id <seat>.steps), cleared when it answers.
|
||||||
func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) {
|
func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
now := time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC)
|
now := time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC)
|
||||||
@@ -85,7 +85,7 @@ func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) {
|
|||||||
if _, err := ix.SeedModulesFrom(ctx, defs, call); err != nil {
|
if _, err := ix.SeedModulesFrom(ctx, defs, call); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if h := w.Held(); len(h) != 1 || h[0].Scope != mcc.ScopeCall || h[0].ID != "node-build-go.steps" || h[0].Kind != mcc.KindCallUnanswered {
|
if h := w.Held(); len(h) != 1 || h[0].Scope != mcc.ScopeCall || h[0].ID != "node-build-go.steps" || h[0].Kind != CallUnansweredKind {
|
||||||
t.Fatalf("the findings after five minutes: %+v", h)
|
t.Fatalf("the findings after five minutes: %+v", h)
|
||||||
}
|
}
|
||||||
goUp = true
|
goUp = true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
// filled per module whenever the indexer starts and at each catalog revision kept, not once (A-490d, A-490f): the key
|
// filled per module whenever the indexer starts and at each catalog revision kept, not once (A-490d, A-490f): the key
|
||||||
// versions-filled closes only the builder's half of the fill.
|
// versions-filled closes only the builder's half of the fill.
|
||||||
|
|
||||||
// FloorCall is the id of the finding call-unanswered when a floor read (the forge's tags or a package holder's versions) is
|
// FloorCall is the id of the finding indexer-call-unanswered when a floor read (the forge's tags or a package holder's versions) is
|
||||||
// unanswered five minutes after the first (A-490h).
|
// unanswered five minutes after the first (A-490h).
|
||||||
const FloorCall = "mesh-catalog.versions-floor"
|
const FloorCall = "mesh-catalog.versions-floor"
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ func (ix *Indexer) FloorModules(ctx context.Context) ([]string, error) {
|
|||||||
// FillFloor fills one module's floor, the highest version among its packages' tags and holders' versions (A-490g). Its reads are
|
// FillFloor fills one module's floor, the highest version among its packages' tags and holders' versions (A-490g). Its reads are
|
||||||
// kept calls made through mesh-sdk's form, which asks again through every transport fault; a read it gives up on (its own
|
// kept calls made through mesh-sdk's form, which asks again through every transport fault; a read it gives up on (its own
|
||||||
// pause spent) is asked again at once, never given up, so the read has no bound (A-490i). The first unanswered try starts the
|
// pause spent) is asked again at once, never given up, so the read has no bound (A-490i). The first unanswered try starts the
|
||||||
// module's clock: five minutes later the finding call-unanswered is written, and cleared when a read answers. A read the
|
// module's clock: five minutes later the finding indexer-call-unanswered is written, and cleared when a read answers. A read the
|
||||||
// callee answered with a failure ends the fill, left for the next start or revision. One fill of a module runs at a time.
|
// callee answered with a failure ends the fill, left for the next start or revision. One fill of a module runs at a time.
|
||||||
func (ix *Indexer) FillFloor(ctx context.Context, module string, src FloorSources) error {
|
func (ix *Indexer) FillFloor(ctx context.Context, module string, src FloorSources) error {
|
||||||
if _, running := ix.floors.LoadOrStore(module, true); running {
|
if _, running := ix.floors.LoadOrStore(module, true); running {
|
||||||
@@ -198,7 +198,7 @@ func FloorSinceKey(module string) string { return floorSinceKey(module) }
|
|||||||
|
|
||||||
func floorSinceKey(module string) string { return "call-since." + keys.EscapeName(floorKey(module)) }
|
func floorSinceKey(module string) string { return "call-since." + keys.EscapeName(floorKey(module)) }
|
||||||
|
|
||||||
// floorUnanswered writes call-unanswered once the module's floor read is unanswered five minutes (the time kept in the own state).
|
// floorUnanswered writes indexer-call-unanswered once the module's floor read is unanswered five minutes (the time kept in the own state).
|
||||||
func (ix *Indexer) floorUnanswered(ctx context.Context, module string, first time.Time, cause error) {
|
func (ix *Indexer) floorUnanswered(ctx context.Context, module string, first time.Time, cause error) {
|
||||||
now := ix.now()
|
now := ix.now()
|
||||||
since := ix.unansweredSince(ctx, floorSinceKey(module), first)
|
since := ix.unansweredSince(ctx, floorSinceKey(module), first)
|
||||||
@@ -206,11 +206,11 @@ func (ix *Indexer) floorUnanswered(ctx context.Context, module string, first tim
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
at := since.UTC().Format(time.RFC3339)
|
at := since.UTC().Format(time.RFC3339)
|
||||||
f := ix.observed(mcc.ScopeCall, floorKey(module), mcc.KindCallUnanswered,
|
f := ix.observed(mcc.ScopeCall, floorKey(module), CallUnansweredKind,
|
||||||
fmt.Sprintf("the floor of %s's versions is unanswered since %s", module, at),
|
fmt.Sprintf("the floor of %s's versions is unanswered since %s", module, at),
|
||||||
"A call whose answer is kept is not answered",
|
"A call whose answer is kept is not answered",
|
||||||
fmt.Sprintf("The floor of %s's versions reads the forge's tags and the package holders' versions; a read is not answered since %s (%v), so it has no version.", module, at, cause),
|
fmt.Sprintf("The floor of %s's versions reads the forge's tags and the package holders' versions; a read is not answered since %s (%v), so it has no version.", module, at, cause),
|
||||||
"indexer."+mcc.KindCallUnanswered)
|
"indexer."+CallUnansweredKind)
|
||||||
if err := ix.Findings.Write(ctx, f); err != nil {
|
if err := ix.Findings.Write(ctx, f); err != nil {
|
||||||
ix.logf("floor: the finding %s is not written: %v", floorKey(module), err)
|
ix.logf("floor: the finding %s is not written: %v", floorKey(module), err)
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ func (ix *Indexer) floorUnanswered(ctx context.Context, module string, first tim
|
|||||||
func (ix *Indexer) floorAnswered(ctx context.Context, module string) {
|
func (ix *Indexer) floorAnswered(ctx context.Context, module string) {
|
||||||
ix.answered(ctx, floorSinceKey(module))
|
ix.answered(ctx, floorSinceKey(module))
|
||||||
if ix.Findings != nil {
|
if ix.Findings != nil {
|
||||||
if err := ix.clearFinding(ctx, mcc.ScopeCall, floorKey(module), mcc.KindCallUnanswered, "the floor's reads answer"); err != nil {
|
if err := ix.clearFinding(ctx, mcc.ScopeCall, floorKey(module), CallUnansweredKind, "the floor's reads answer"); err != nil {
|
||||||
ix.logf("floor: the finding %s is not cleared: %v", floorKey(module), err)
|
ix.logf("floor: the finding %s is not cleared: %v", floorKey(module), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ func versionNameOf(module string, a meshcatalog.Artifact) string {
|
|||||||
|
|
||||||
// FillVersions fills the state versions once from builder_versions and says versions-filled (§372). A fill already made
|
// FillVersions fills the state versions once from builder_versions and says versions-filled (§372). A fill already made
|
||||||
// is not made again; a builder_versions that does not answer holds the fill and, after five minutes, is the finding
|
// is not made again; a builder_versions that does not answer holds the fill and, after five minutes, is the finding
|
||||||
// call-unanswered (scope call, id mesh-delivery-builder.builder_versions), cleared when it answers.
|
// indexer-call-unanswered (scope call, id mesh-delivery-builder.builder_versions), cleared when it answers.
|
||||||
func (ix *Indexer) FillVersions(ctx context.Context, ask VersionsAsker) error {
|
func (ix *Indexer) FillVersions(ctx context.Context, ask VersionsAsker) error {
|
||||||
if ix.Versions == nil || ix.Heard == nil {
|
if ix.Versions == nil || ix.Heard == nil {
|
||||||
return errors.New("the state versions is not kept here")
|
return errors.New("the state versions is not kept here")
|
||||||
@@ -127,7 +127,7 @@ func (ix *Indexer) FillVersions(ctx context.Context, ask VersionsAsker) error {
|
|||||||
}
|
}
|
||||||
ix.answered(ctx, versionsFillSince)
|
ix.answered(ctx, versionsFillSince)
|
||||||
if ix.Findings != nil {
|
if ix.Findings != nil {
|
||||||
if err := ix.clearFinding(ctx, mcc.ScopeCall, BuilderVersionsCall, mcc.KindCallUnanswered, "builder_versions answers"); err != nil {
|
if err := ix.clearFinding(ctx, mcc.ScopeCall, BuilderVersionsCall, CallUnansweredKind, "builder_versions answers"); err != nil {
|
||||||
ix.logf("versions fill: the finding %s is not cleared: %v", BuilderVersionsCall, err)
|
ix.logf("versions fill: the finding %s is not cleared: %v", BuilderVersionsCall, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,18 +184,18 @@ func (ix *Indexer) FillVersions(ctx context.Context, ask VersionsAsker) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// fillUnanswered writes call-unanswered once builder_versions is unanswered five minutes (the time kept in the own state).
|
// fillUnanswered writes indexer-call-unanswered once builder_versions is unanswered five minutes (the time kept in the own state).
|
||||||
func (ix *Indexer) fillUnanswered(ctx context.Context, cause error) {
|
func (ix *Indexer) fillUnanswered(ctx context.Context, cause error) {
|
||||||
now := ix.now()
|
now := ix.now()
|
||||||
since := ix.unansweredSince(ctx, versionsFillSince, now)
|
since := ix.unansweredSince(ctx, versionsFillSince, now)
|
||||||
if ix.Findings == nil || now.Sub(since) < mcc.CallUnansweredAfter {
|
if ix.Findings == nil || now.Sub(since) < mcc.CallUnansweredAfter {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f := ix.observed(mcc.ScopeCall, BuilderVersionsCall, mcc.KindCallUnanswered,
|
f := ix.observed(mcc.ScopeCall, BuilderVersionsCall, CallUnansweredKind,
|
||||||
fmt.Sprintf("the call %s is unanswered since %s", BuilderVersionsCall, since.UTC().Format(time.RFC3339)),
|
fmt.Sprintf("the call %s is unanswered since %s", BuilderVersionsCall, since.UTC().Format(time.RFC3339)),
|
||||||
"A call whose answer is kept is not answered",
|
"A call whose answer is kept is not answered",
|
||||||
fmt.Sprintf("The first fill of the catalog's versions asks %s of every artifact; it is not answered since %s (%v), so no version is released and the builder reserves nothing.", BuilderVersionsCall, since.UTC().Format(time.RFC3339), cause),
|
fmt.Sprintf("The first fill of the catalog's versions asks %s of every artifact; it is not answered since %s (%v), so no version is released and the builder reserves nothing.", BuilderVersionsCall, since.UTC().Format(time.RFC3339), cause),
|
||||||
"indexer."+mcc.KindCallUnanswered)
|
"indexer."+CallUnansweredKind)
|
||||||
if err := ix.Findings.Write(ctx, f); err != nil {
|
if err := ix.Findings.Write(ctx, f); err != nil {
|
||||||
ix.logf("versions fill: the finding %s is not written: %v", BuilderVersionsCall, err)
|
ix.logf("versions fill: the finding %s is not written: %v", BuilderVersionsCall, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func TestAVersionIsReleasedOnceEveryArtifactIsPublished(t *testing.T) {
|
|||||||
|
|
||||||
// Design 47 G §372, A-350: the first fill records, once, each module's highest version the builder gave a number, numbered or
|
// Design 47 G §372, A-350: the first fill records, once, each module's highest version the builder gave a number, numbered or
|
||||||
// published, over its artifacts as released and says versions-filled once; a builder_versions that does not answer holds it and, after five minutes, is the finding
|
// published, over its artifacts as released and says versions-filled once; a builder_versions that does not answer holds it and, after five minutes, is the finding
|
||||||
// call-unanswered; a fill made is not made again.
|
// indexer-call-unanswered; a fill made is not made again.
|
||||||
func TestTheFirstFillOfTheVersionsComesFromTheBuildersNumbers(t *testing.T) {
|
func TestTheFirstFillOfTheVersionsComesFromTheBuildersNumbers(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
now := time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC)
|
now := time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC)
|
||||||
@@ -501,7 +501,7 @@ func TestAnInputIsDeletedAtTheStepEndedOfItsAsk(t *testing.T) {
|
|||||||
|
|
||||||
// Design 47 G §412 as A-490c, A-490d and A-490e amend it: a module the versions hold none of is filled from the highest tag of its
|
// Design 47 G §412 as A-490c, A-490d and A-490e amend it: a module the versions hold none of is filled from the highest tag of its
|
||||||
// Go package in the repository it was taken in from, per module and not once; a forge that does not answer fills nothing and
|
// Go package in the repository it was taken in from, per module and not once; a forge that does not answer fills nothing and
|
||||||
// raises call-unanswered after five minutes.
|
// raises indexer-call-unanswered after five minutes.
|
||||||
func TestTheTagFloorFillsAModuleWithNoVersionFromItsGoTags(t *testing.T) {
|
func TestTheTagFloorFillsAModuleWithNoVersionFromItsGoTags(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
now := time.Date(2026, 11, 19, 17, 0, 0, 0, time.UTC)
|
now := time.Date(2026, 11, 19, 17, 0, 0, 0, time.UTC)
|
||||||
@@ -623,7 +623,7 @@ func TestAFloorEntryIsReplacedByThePublishHeardAtItsVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADR 0668 §3, design 47 G A-490i: the finding call-unanswered of a module's floor clears, with its call-since key, on every way the
|
// ADR 0668 §3, design 47 G A-490i: the finding indexer-call-unanswered of a module's floor clears, with its call-since key, on every way the
|
||||||
// fill ends but the end of its context: a release gave the module a version, the module left the trunk, or the callee answered with a
|
// fill ends but the end of its context: a release gave the module a version, the module left the trunk, or the callee answered with a
|
||||||
// failure (FloorModules never picks the module again to clear it).
|
// failure (FloorModules never picks the module again to clear it).
|
||||||
func TestTheFloorFindingClearsOnEveryExitOfTheFill(t *testing.T) {
|
func TestTheFloorFindingClearsOnEveryExitOfTheFill(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user