diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index 7045cdec..5b95d8e2 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -290,8 +290,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // (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]{ 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): the tool runner's writer states its kinds over the same state - Kinds: index.FindingKinds}) + // 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 { return fmt.Errorf("the indexer's finding writer cannot be made: %w", err) } diff --git a/modules/mesh-delivery-indexer/internal/index/finding_kinds_test.go b/modules/mesh-delivery-indexer/internal/index/finding_kinds_test.go index 31310d7f..1a6c9114 100644 --- a/modules/mesh-delivery-indexer/internal/index/finding_kinds_test.go +++ b/modules/mesh-delivery-indexer/internal/index/finding_kinds_test.go @@ -12,13 +12,16 @@ import ( "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, G §580: every finding kind the daemon's code raises or clears is one its writer owns +// 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, and the Kind of a Finding literal. A +// 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. @@ -26,6 +29,18 @@ 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{} @@ -125,6 +140,20 @@ func TestFindingKindsHoldEveryKindTheCodeRaises(t *testing.T) { 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 { @@ -138,7 +167,7 @@ func TestFindingKindsHoldEveryKindTheCodeRaises(t *testing.T) { return true }) } - for _, k := range []string{PinMissingKind, OutOfStepKind, PackagesNotPublishedKind} { + 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) } @@ -148,4 +177,10 @@ func TestFindingKindsHoldEveryKindTheCodeRaises(t *testing.T) { 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 _, k := range RetiredFindingKinds { + if at, ok := raised[k]; ok || slices.Contains(declared, k) { + t.Errorf("the retired kind %q is still declared or raised (%s)", k, at) + } + } } diff --git a/modules/mesh-delivery-indexer/internal/index/findings.go b/modules/mesh-delivery-indexer/internal/index/findings.go index 25df6af3..773a2966 100644 --- a/modules/mesh-delivery-indexer/internal/index/findings.go +++ b/modules/mesh-delivery-indexer/internal/index/findings.go @@ -4,7 +4,9 @@ import ( "context" 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" + "git.novox.be/novox/mesh-sdk/go/views" ) // FindingsState is the indexer's state of its findings (design 47 G §383, §687). @@ -12,11 +14,21 @@ const ( 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): the tool runner's writer over the same state `findings` owns its own, and a views reader's (views.ViewKinds) are -// always the writer's besides. TestFindingKindsHoldEveryKindTheCodeRaises holds the code to this list. +// 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, mcc.KindCallUnanswered} + 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. +var RetiredFindingKinds = []string{"merge-untaken"} // 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 diff --git a/modules/mesh-delivery-indexer/internal/index/seed.go b/modules/mesh-delivery-indexer/internal/index/seed.go index c4f38aa7..317ebc48 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed.go +++ b/modules/mesh-delivery-indexer/internal/index/seed.go @@ -124,7 +124,7 @@ func (r *Registry) ProposeSeed(ctx context.Context, modules []SeedModule, again return "", err } 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 } diff --git a/modules/mesh-delivery-indexer/internal/index/seed_steps.go b/modules/mesh-delivery-indexer/internal/index/seed_steps.go index 9667902c..9a6391dd 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed_steps.go +++ b/modules/mesh-delivery-indexer/internal/index/seed_steps.go @@ -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 // 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 -// its artifact unanswered, which holds the seed; its call-unanswered finding (scope call, id .steps) is written once +// its artifact unanswered, which holds the seed; its indexer-call-unanswered finding (scope call, id .steps) is written once // 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) { if ix.Revisions == nil { @@ -202,7 +202,7 @@ func artifactName(ref string) string { 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) { if ix.Findings == nil { return @@ -223,11 +223,11 @@ func (ix *Indexer) stepsFindings(ctx context.Context, answered map[string]bool, } for _, seat := range slices.Sorted(slices.Values(raise)) { 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)), "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]), - "indexer."+mcc.KindCallUnanswered) + "indexer."+CallUnansweredKind) if err := ix.Findings.Write(ctx, f); err != nil { 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 { 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) } } diff --git a/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go b/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go index 6824bb67..a2107598 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go +++ b/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go @@ -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, // 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 .steps), cleared when it answers. +// minutes, is the finding indexer-call-unanswered (scope call, id .steps), cleared when it answers. func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) { ctx := context.Background() 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 { 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) } goUp = true diff --git a/modules/mesh-delivery-indexer/internal/index/tag_floor.go b/modules/mesh-delivery-indexer/internal/index/tag_floor.go index b7e69553..33f454d8 100644 --- a/modules/mesh-delivery-indexer/internal/index/tag_floor.go +++ b/modules/mesh-delivery-indexer/internal/index/tag_floor.go @@ -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 // 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). 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 // 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 -// 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. func (ix *Indexer) FillFloor(ctx context.Context, module string, src FloorSources) error { 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)) } -// 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) { now := ix.now() since := ix.unansweredSince(ctx, floorSinceKey(module), first) @@ -206,11 +206,11 @@ func (ix *Indexer) floorUnanswered(ctx context.Context, module string, first tim return } 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), "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), - "indexer."+mcc.KindCallUnanswered) + "indexer."+CallUnansweredKind) if err := ix.Findings.Write(ctx, f); err != nil { 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) { ix.answered(ctx, floorSinceKey(module)) 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) } } diff --git a/modules/mesh-delivery-indexer/internal/index/versions_fill.go b/modules/mesh-delivery-indexer/internal/index/versions_fill.go index a19e1274..9b4cc2ad 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions_fill.go +++ b/modules/mesh-delivery-indexer/internal/index/versions_fill.go @@ -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 // 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 { if ix.Versions == nil || ix.Heard == nil { 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) 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) } } @@ -184,18 +184,18 @@ func (ix *Indexer) FillVersions(ctx context.Context, ask VersionsAsker) error { 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) { now := ix.now() since := ix.unansweredSince(ctx, versionsFillSince, now) if ix.Findings == nil || now.Sub(since) < mcc.CallUnansweredAfter { 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)), "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), - "indexer."+mcc.KindCallUnanswered) + "indexer."+CallUnansweredKind) if err := ix.Findings.Write(ctx, f); err != nil { ix.logf("versions fill: the finding %s is not written: %v", BuilderVersionsCall, err) } diff --git a/modules/mesh-delivery-indexer/internal/index/versions_test.go b/modules/mesh-delivery-indexer/internal/index/versions_test.go index 399d8791..b4c56076 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions_test.go +++ b/modules/mesh-delivery-indexer/internal/index/versions_test.go @@ -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 // 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) { ctx := context.Background() 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 // 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) { ctx := context.Background() 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 // failure (FloorModules never picks the module again to clear it). func TestTheFloorFindingClearsOnEveryExitOfTheFill(t *testing.T) {