diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go index 4d2b8d89..c905eac1 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go @@ -91,19 +91,14 @@ func Tools(ask asker, now func() time.Time, counts func() (index.OldSectionsCoun }}, {Name: index.SeatDefinitionsAgainTool, Description: "Read a contracts module's seat definitions again now (design 26): its trunk's, at the commit the indexer " + - "holds the module at, or with pull and head a pull request's head (read with the head's own manifest, so its " + - "generated-from as the head has it), and keep them in the seat-definitions state as a merge or a pull request's " + - "push would (seat-definition-changed said where a digest moved; the trunk's seat-definition-unparsed and " + + "holds the module at, and keep them in the seat-definitions state as a take-in would (seat-definition-changed said where a digest moved; the trunk's seat-definition-unparsed and " + "seat-defined-twice findings written or cleared). For a read the forge did not answer. A hand act, " + "recorded through mesh-hand-acts before it is asked. indexer_seat_definition reads the result.", Input: map[string]any{"type": "object", "required": []string{"module", "why"}, "properties": map[string]any{ "module": map[string]any{"type": "string", "description": "the contracts module, such as mesh-contracts"}, - "pull": map[string]any{"type": "integer", "description": "a pull request's number, with head"}, - "head": map[string]any{"type": "string", "description": "the pull request's head commit, with pull"}, "why": map[string]any{"type": "string", "description": "why it is read again now, in plain words"}}}, Run: func(args map[string]any) (any, error) { - pull, _ := args["pull"].(float64) - key, value, err := index.NewSeatDefinitionsAgain(str(args, "module"), int(pull), str(args, "head"), str(args, "why"), stdio.CallerOf(args), now()) + key, value, err := index.NewSeatDefinitionsAgain(str(args, "module"), str(args, "why"), stdio.CallerOf(args), now()) if err != nil { return nil, err } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go index 94a05dee..e1a041ac 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go @@ -139,23 +139,17 @@ func packageUsersTool(state func(string) views.Source) stdio.Tool { }} } -// seatDefinitionTool is indexer_seat_definition (design 26; DLV-I19): one seat's definition, the trunk's unless a pull -// request is named, saying which it answered, at the mark the views family said the state up to. +// seatDefinitionTool is indexer_seat_definition (design 26; DLV-I19): one seat's trunk definition, at the mark the views +// family said the state up to. func seatDefinitionTool(state func(string) views.Source) stdio.Tool { return stdio.Tool{Name: index.SeatDefinitionTool, - Description: "One seat's definition as the indexer keeps it (design 26): the trunk's, which is the seat's contract, unless a " + - "pull request is named (repository and pull), whose head's is answered with the trunk's beside it; answered says " + - "which. An entry with unparsed holds why the pull request's definition does not parse. The revision is the one " + - "the indexer's views family said the state up to; seat-definition-changed says each change after it.", + Description: "One seat's definition as the indexer keeps it (design 26): the trunk's, which is the seat's contract. The " + + "revision is the one the indexer's views family said the state up to; seat-definition-changed says each change after it.", Input: map[string]any{"type": "object", "required": []string{"seat"}, "properties": map[string]any{ - "seat": map[string]any{"type": "string", "description": "the seat, such as go-package-registry"}, - "repository": map[string]any{"type": "string", "description": "a pull request's repository (owner/name), with pull"}, - "pull": map[string]any{"type": "integer", "description": "a pull request's number, with repository"}}}, + "seat": map[string]any{"type": "string", "description": "the seat, such as go-package-registry"}}}, Run: func(args map[string]any) (any, error) { seat, _ := args["seat"].(string) - repository, _ := args["repository"].(string) - pull, _ := args["pull"].(float64) - return index.SeatDefinitionOf(state(index.SeatDefinitionsState), state(views.MarksState), seat, repository, int(pull)) + return index.SeatDefinitionOf(state(index.SeatDefinitionsState), state(views.MarksState), seat) }} } @@ -164,10 +158,10 @@ func outOfStepTool(own string, state func(string) views.Source) stdio.Tool { return stdio.Tool{Name: index.OutOfStepTool, Description: "The generated types out of step with their seat definitions (design 26): each trunk contracts module whose " + "finding generated-types-out-of-step stands (its last trunk build's test step named the files; cleared only by a clean " + - "build of the same module), then each open pull request whose check's verdict named out-of-step files.", + "build of the same module).", Input: map[string]any{"type": "object", "properties": map[string]any{}}, Run: func(map[string]any) (any, error) { - rows, err := index.OutOfStepOf(own, state(index.SeatDefinitionsState), state(index.FindingsState)) + rows, err := index.OutOfStepOf(own, state(index.FindingsState)) if err != nil { return nil, err } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go index f27fc75e..609e1b42 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go @@ -15,7 +15,7 @@ import ( type takerIn interface { TakeIn(ctx context.Context, module string) index.TakenIn TakeInRepository(ctx context.Context, repository string) index.TakenIn - SeatDefinitionsAgain(ctx context.Context, module string, pull int, head string) index.TakenIn + SeatDefinitionsAgain(ctx context.Context, module string) index.TakenIn FingerprintsAgain(ctx context.Context, module string) index.TakenIn RecomputeByHand(ctx context.Context, by, why string) index.TakenIn DropCandidateGraph(ctx context.Context, group, heads, by, why string) index.TakenIn @@ -78,7 +78,7 @@ func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream asked, r = "take-in of a repository", ix.TakeInRepository(ctx, a.Repository) a.Module = a.Repository } else if a.SeatDefinitions { - asked, r = "reading of its seat definitions again", ix.SeatDefinitionsAgain(ctx, a.Module, a.Pull, a.Head) + asked, r = "reading of its seat definitions again", ix.SeatDefinitionsAgain(ctx, a.Module) } else { r = ix.TakeIn(ctx, a.Module) } diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_test.go index cbe98ec9..3b05c598 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_test.go @@ -76,10 +76,10 @@ func catalogVerbsAnswerFromTheStates(t *testing.T) { } return g, nil }, - // The verb seat-definitions answers from the seat definitions state: the trunk's git, a pull request's git beside it. + // The verb seat-definitions answers from the seat definitions state: the trunk's git, never a key an earlier form left. SeatDefinitions: memSource{ "git.trunk": {Value: []byte(`{"seat":"git","source":"trunk","digest":"d1","definition":{"seat":"git"}}`)}, - SeatDefinitionKey("git", SourcePull, "r", 1): {Value: []byte(`{"seat":"git","source":"pull","digest":"d2"}`)}, + "git.pull.r.1": {Value: []byte(`{"seat":"git","source":"pull","digest":"d2"}`)}, }, } answer := func(v any, err error) []byte { diff --git a/modules/mesh-delivery-indexer/internal/index/control_records_test.go b/modules/mesh-delivery-indexer/internal/index/control_records_test.go index 18796889..580a4bcc 100644 --- a/modules/mesh-delivery-indexer/internal/index/control_records_test.go +++ b/modules/mesh-delivery-indexer/internal/index/control_records_test.go @@ -362,6 +362,16 @@ func TestTheControlRecords(t *testing.T) { if err != nil || !strings.Contains(string(raw), `"seat":"wants","source":"trunk","digest":"`) || strings.Contains(string(raw), "pull") || strings.Contains(string(raw), "_out-of-step") { t.Errorf("the verb with no seat = %s, %v", raw, err) } + // Design 47 H §764 (H-A-48): no pull request's definition is kept or answered; the again-ask names the trunk alone. + if key, value, err := NewSeatDefinitionsAgain("mesh-contracts", "the forge did not answer", "person.op", time.Now()); err != nil || + key != "seat-definitions.mesh-contracts" || strings.Contains(string(value), `"pull"`) || strings.Contains(string(value), `"head"`) { + t.Errorf("the again-ask = %s %s, %v; want the trunk's alone", key, value, err) + } + old := src() + old["wants.pull.novox_mesh-contracts.81"] = &views.Entry{Value: []byte(`{"seat":"wants","source":"pull","digest":"d2"}`)} + if a, err := SeatDefinitionOf(old, nil, "wants"); err != nil || a.Answered != SourceTrunk || a.Entry == nil || a.Entry.Source != SourceTrunk { + t.Errorf("indexer_seat_definition = %+v, %v; want the trunk's entry", a, err) + } one, err := SeatDefinitionsOf(src(), nil, "vault") raw, _ = json.Marshal(one) if err != nil || !strings.Contains(string(raw), `"found":true`) || !strings.Contains(string(raw), `"definition"`) { diff --git a/modules/mesh-delivery-indexer/internal/index/seatdefs.go b/modules/mesh-delivery-indexer/internal/index/seatdefs.go index e71095d4..e688f279 100644 --- a/modules/mesh-delivery-indexer/internal/index/seatdefs.go +++ b/modules/mesh-delivery-indexer/internal/index/seatdefs.go @@ -2,10 +2,9 @@ package index // The seat definitions on the bus (novox/hq ADR 0608 §2-§4, design 26 *A seat's definition*; DLV-I17-I20). The indexer // reads every seat definition of a contracts module (a module whose package artifact names `generated-from`) at each -// trunk merge and each pull request's head the forge bridge says changed it, through the forge's get-file tool, parses -// it with the format's one reader (mesh-sdk seatdef), and keeps it in its own state `seat-definitions`, keyed by seat -// and source, as its only writer. Only the trunk's entry is the seat's contract; a pull request's entries go when it -// closes or merges. A trunk definition that does not parse keeps the trunk's entry and writes the finding +// take-in of its repository, through the forge's get-file tool, parses it with the format's one reader (mesh-sdk +// seatdef), and keeps it in its own state `seat-definitions`, keyed by seat, as its only writer: the trunk's entry is the +// seat's contract, and no pull request's is kept (design 47 H §764, H-A-48). A trunk definition that does not parse keeps the trunk's entry and writes the finding // seat-definition-unparsed; a trunk defining a seat another repository's trunk already defines is refused with the // finding seat-defined-twice naming both (a seat has one definition); a seat of the mesh's own contracts is taken only // from its domain's contracts module, and a move there is a handover (ADR 0636 §5, domain.go); generated types out of step on a trunk, said by @@ -21,9 +20,7 @@ import ( "errors" "fmt" "maps" - "path" "slices" - "strconv" "strings" "time" @@ -33,7 +30,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/seatdefs" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" - "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/seatdef" "git.novox.be/novox/mesh-sdk/go/views" ) @@ -60,22 +56,20 @@ const ( SeatDefinitionsAgainTool = "indexer_seat_definitions_again" OutOfStepTool = "indexer_out_of_step" - // SourceTrunk and SourcePull are a definition's two sources. + // SourceTrunk is a definition's source: the trunk's alone (no pull request's, design 47 H §764). SourceTrunk = "trunk" - SourcePull = "pull" ) -// outOfStepPrefix begins the key of a pull request's out-of-step files in the state: no seat name holds '_'. +// outOfStepPrefix began the key of a pull request's out-of-step files, which no take-in writes any more; a reader of the +// state still leaves such a key aside. const outOfStepPrefix = "_out-of-step." // SeatDefinitionEntry is one value of the state: a seat's definition from one source, resolved with the parts it -// includes. Unparsed is why a pull request's head's definition did not parse (it then holds no definition); a trunk's -// that does not parse is never written over the entry that stands. +// includes. A trunk's definition that does not parse is never written over the entry that stands. type SeatDefinitionEntry struct { Seat string `json:"seat"` Source string `json:"source"` Repository string `json:"repository"` - Pull int `json:"pull,omitempty"` Module string `json:"module"` Directory string `json:"directory"` Commit string `json:"commit"` @@ -91,34 +85,12 @@ type SeatDefinitionChanged struct { Seat string `json:"seat"` Source string `json:"source"` Repository string `json:"repository"` - Pull int `json:"pull,omitempty"` Digest string `json:"digest"` } -// OutOfStep is a pull request's generated files out of step with their definitions, as its check's verdict said them. -type OutOfStep struct { - Repository string `json:"repository"` - Pull int `json:"pull"` - Head string `json:"head"` - Files []string `json:"files"` - At time.Time `json:"at"` -} - -// SeatDefinitionKey is a seat's key for a source: `.trunk`, or `.pull..`. -func SeatDefinitionKey(seat, source, repository string, pull int) string { - if source == SourceTrunk { - return seat + "." + SourceTrunk - } - return seat + "." + pullSuffix(repository, pull) -} - -func pullSuffix(repository string, pull int) string { - return SourcePull + "." + keys.EscapeName(repository) + "." + strconv.Itoa(pull) -} - -// OutOfStepKey is the key of a pull request's out-of-step files. -func OutOfStepKey(repository string, pull int) string { - return outOfStepPrefix + keys.EscapeName(repository) + "." + strconv.Itoa(pull) +// SeatDefinitionKey is a seat's key: `.trunk`. +func SeatDefinitionKey(seat string) string { + return seat + "." + SourceTrunk } // errForgeRead is a read the forge did not answer (never a file it does not hold): the message is left for redelivery. @@ -162,21 +134,17 @@ func (ix *Indexer) ApplySeatDefinitions(ctx context.Context, f whole) error { } // NewSeatDefinitionsAgain is the value indexer_seat_definitions_again writes: its key in the takeins state and the value. -// A pull request is named by its number and head together, or neither (the trunk's). -func NewSeatDefinitionsAgain(module string, pull int, head, why, by string, at time.Time) (string, []byte, error) { - key, data, err := NewTakeIn(module, why, by, at) +// It reads the trunk's definitions alone (design 47 H §764: no pull request's is kept). +func NewSeatDefinitionsAgain(module, why, by string, at time.Time) (string, []byte, error) { + module = strings.TrimSpace(module) + if module == "" { + return "", nil, errors.New("name the contracts module (module)") + } + key, err := meshcatalogclient.ModulesKey(module) if err != nil { return "", nil, err } - if (pull > 0) != (head != "") { - return "", nil, errors.New("name a pull request by its number and its head together (pull, head), or neither for the trunk") - } - var a TakeInAsk - if err := json.Unmarshal(data, &a); err != nil { - return "", nil, err - } - a.SeatDefinitions, a.Pull, a.Head = true, pull, head - data, err = json.Marshal(a) + data, err := json.Marshal(TakeInAsk{V: 1, Module: module, SeatDefinitions: true, Why: strings.TrimSpace(why), By: by, At: at.UTC()}) return seatDefinitionsPrefix + key, data, err } @@ -184,9 +152,8 @@ func NewSeatDefinitionsAgain(module string, pull int, head, why, by string, at t const seatDefinitionsPrefix = "seat-definitions." // SeatDefinitionsAgain reads a contracts module's seat definitions again now (indexer_seat_definitions_again): its -// trunk's at the commit the modules state holds it at, or a pull request's at the head given, with the head's own manifest -// (its generated-from as the head has it). -func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string, pull int, head string) TakenIn { +// trunk's at the commit the modules state holds it at. +func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string) TakenIn { out := TakenIn{Module: module} if ix.SeatDefinitions == nil || ix.ReadFile == nil || ix.Modules == nil { out.Answer = "the indexer holds no seat-definitions state or forge reader yet" @@ -217,35 +184,13 @@ func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string, pull dir = meshcatalogclient.RootPath } whose := "its trunk's" - if pull > 0 { - // A pull request is read with its head's own manifest, so a change of generated-from is read as the head has it. - file := "module.json" - if dir != meshcatalogclient.RootPath { - file = path.Join(dir, file) - } - raw, err := ix.ReadFile(ctx, m.Repository, head, file) - switch { - case err != nil: - out.Answer = fmt.Sprintf("%s at %.12s cannot be read: %v", file, head, err) - return out - case raw == nil: - out.Answer = fmt.Sprintf("%s#%d's head %.12s holds no %s", m.Repository, pull, head, file) - return out - } - manifest, whose = string(raw), fmt.Sprintf("%s#%d's head's", m.Repository, pull) - } cs := contractsModules(map[string]string{dir: manifest}) if len(cs) == 0 { out.Answer = module + " is no contracts module: no package artifact of " + whose + " manifest names generated-from" return out } out.Repository, out.Commit, out.Path = m.Repository, m.Commit, m.Path - if pull > 0 { - err, out.Commit = ix.keepPull(ctx, m.Repository, pull, head, cs[0]), head - } else { - err = ix.keepTrunk(ctx, m.Repository, m.Commit, cs[0]) - } - if err != nil { + if err = ix.keepTrunk(ctx, m.Repository, m.Commit, cs[0]); err != nil { out.Answer = "read again, not kept: " + err.Error() return out } @@ -351,45 +296,6 @@ func (ix *Indexer) keepTrunk(ctx context.Context, repository, commit string, c c return errors.Join(errs...) } -// keepPull writes a pull request's head definitions of a contracts module: each that parses, and each that does not -// with its words (its check fails on it; the trunk's entry stays). -func (ix *Indexer) keepPull(ctx context.Context, repository string, pull int, head string, c contractsModule) error { - defs, unparsed, err := ix.readDefinitions(ctx, repository, head, c) - if errors.Is(err, errForgeRead) { - return err - } - if err != nil { - unparsed = map[string]string{"": err.Error()} - } - base := SeatDefinitionEntry{Source: SourcePull, Repository: repository, Pull: pull, Module: c.Module, Directory: c.Dir, Commit: head} - var errs []error - for seat, d := range defs { - if why := seatdefs.Refusal(c.Module, d); why != "" { - unparsed[seat] = why // its check fails on it, as on a definition that does not parse - continue - } - e := base - e.Seat = seat - _, err := ix.putDefinition(ctx, e, d) - errs = append(errs, err) - } - for seat, why := range unparsed { - e := base - e.Seat, e.Unparsed, e.At = seat, why, ix.now().UTC() - if seat == "" { - e.Seat = c.Module // the module's index did not parse: no seat is known, the entry is named by the module - } - data, err := json.Marshal(e) - if err == nil { - err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat, SourcePull, repository, pull), func([]byte, bool) ([]byte, bool, error) { - return data, false, nil - }) - } - errs = append(errs, err) - } - return errors.Join(errs...) -} - // putDefinition writes one parsed definition at its key, said when its digest moved. A trunk's definition of a seat // another repository's (or module's) trunk already defines is refused, written nowhere: a seat has one definition, unless // the definer is the seat's domain's module taking it over from another module of the mesh's own (a handover, domain.go). @@ -401,7 +307,7 @@ func (ix *Indexer) putDefinition(ctx context.Context, e SeatDefinitionEntry, d s } e.Definition, e.Digest, e.At = raw, digest, ix.now().UTC() moved, holder := false, "" - err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat, e.Source, e.Repository, e.Pull), func(value []byte, found bool) ([]byte, bool, error) { + err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat), func(value []byte, found bool) ([]byte, bool, error) { var cur SeatDefinitionEntry known := found && json.Unmarshal(value, &cur) == nil moved, holder = false, "" @@ -417,7 +323,7 @@ func (ix *Indexer) putDefinition(ctx context.Context, e SeatDefinitionEntry, d s return data, false, err }) if err == nil && moved { - ix.sayChanged(ctx, SeatDefinitionChanged{Seat: e.Seat, Source: e.Source, Repository: e.Repository, Pull: e.Pull, Digest: digest}) + ix.sayChanged(ctx, SeatDefinitionChanged{Seat: e.Seat, Source: e.Source, Repository: e.Repository, Digest: digest}) } return holder, err } @@ -452,26 +358,6 @@ func (ix *Indexer) outsideFinding(ctx context.Context, module string, outside ma "Move the definition there; the next merge of "+module+" without it clears this.") } -// dropPull removes a pull request's entries and its out-of-step files. -func (ix *Indexer) dropPull(ctx context.Context, repository string, pull int) error { - keys, err := ix.SeatDefinitions.Keys(ctx) - if err != nil { - return err - } - suffix, oos := "."+pullSuffix(repository, pull), OutOfStepKey(repository, pull) - var errs []error - for _, key := range keys { - if !strings.HasSuffix(key, suffix) && key != oos { - continue - } - errs = append(errs, write(ctx, ix.SeatDefinitions, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil })) - if seat, ok := strings.CutSuffix(key, suffix); ok { - ix.sayChanged(ctx, SeatDefinitionChanged{Seat: seat, Source: SourcePull, Repository: repository, Pull: pull}) - } - } - return errors.Join(errs...) -} - func (ix *Indexer) sayChanged(ctx context.Context, c SeatDefinitionChanged) { if ix.SaySeatDefinition == nil || c.Source != SourceTrunk { return @@ -536,7 +422,7 @@ func (ix *Indexer) ApplyOutOfStepBuild(ctx context.Context, value []byte) { return } if !trunkLike[e.Ref] { - return // a pull request's build: its check's verdict says its files + return // no other branch's build writes the finding } switch { case len(e.OutOfStep) > 0: @@ -552,37 +438,18 @@ func (ix *Indexer) ApplyOutOfStepBuild(ctx context.Context, value []byte) { } } -// ApplyVerdict keeps a pull request's out-of-step files from its check's verdict (the checker's event verdict): a -// verdict naming files writes them, one naming none (a clean verdict) removes them. -func (ix *Indexer) ApplyVerdict(ctx context.Context, repository string, pull int, head string, files []string) error { - if ix.SeatDefinitions == nil || repository == "" || pull <= 0 { - return nil - } - return write(ctx, ix.SeatDefinitions, OutOfStepKey(repository, pull), func(_ []byte, found bool) ([]byte, bool, error) { - if len(files) == 0 { - return nil, found, nil - } - fs := slices.Clone(files) - slices.Sort(fs) - data, err := json.Marshal(OutOfStep{Repository: repository, Pull: pull, Head: head, Files: fs, At: ix.now().UTC()}) - return data, false, err - }) -} - // SeatDefinitionAnswer is indexer_seat_definition's answer: which source it answered, and the entry. type SeatDefinitionAnswer struct { Seat string `json:"seat"` Answered string `json:"answered"` Found bool `json:"found"` Entry *SeatDefinitionEntry `json:"entry,omitempty"` - Trunk *SeatDefinitionEntry `json:"trunk,omitempty"` Revision uint64 `json:"revision"` } -// SeatDefinitionOf answers indexer_seat_definition from the state: the trunk's entry, unless a pull request (repository -// and number) is named, whose entry is answered with the trunk's beside it; Answered says which. A pull request holding -// no entry for the seat answers the trunk's, saying so. The revision is the views mark the state was said up to. -func SeatDefinitionOf(defs, marks views.Source, seat, repository string, pull int) (SeatDefinitionAnswer, error) { +// SeatDefinitionOf answers indexer_seat_definition from the state: the trunk's entry (no pull request's is kept, design 47 +// H §764). The revision is the views mark the state was said up to. +func SeatDefinitionOf(defs, marks views.Source, seat string) (SeatDefinitionAnswer, error) { if seat == "" { return SeatDefinitionAnswer{}, fmt.Errorf("%s names the seat", SeatDefinitionTool) } @@ -601,22 +468,11 @@ func SeatDefinitionOf(defs, marks views.Source, seat, repository string, pull in return &e, nil } out := SeatDefinitionAnswer{Seat: seat, Answered: SourceTrunk, Revision: markOf(marks)} - trunk, err := get(SeatDefinitionKey(seat, SourceTrunk, "", 0)) + trunk, err := get(SeatDefinitionKey(seat)) if err != nil { return out, err } out.Entry, out.Found = trunk, trunk != nil - if pull > 0 { - p, err := get(SeatDefinitionKey(seat, SourcePull, repository, pull)) - if err != nil { - return out, err - } - if p != nil { - out.Answered, out.Entry, out.Trunk, out.Found = fmt.Sprintf("%s#%d", repository, pull), p, trunk, true - } else { - out.Answered = SourceTrunk + fmt.Sprintf(" (%s#%d holds no definition of %s)", repository, pull, seat) - } - } return out, nil } @@ -636,19 +492,16 @@ func markOf(marks views.Source) uint64 { return m.Revision } -// OutOfStepRow is one row of indexer_out_of_step: a trunk's contracts module (from its finding) or a pull request. +// OutOfStepRow is one row of indexer_out_of_step: a trunk's contracts module, from its finding. type OutOfStepRow struct { - Source string `json:"source"` - Module string `json:"module,omitempty"` - Pull string `json:"pull,omitempty"` - Head string `json:"head,omitempty"` - Files []string `json:"files,omitempty"` - Summary string `json:"summary,omitempty"` + Source string `json:"source"` + Module string `json:"module,omitempty"` + Summary string `json:"summary,omitempty"` } // OutOfStepOf answers indexer_out_of_step: every trunk contracts module whose finding generated-types-out-of-step -// stands, then every pull request whose check's verdict named out-of-step files. -func OutOfStepOf(own string, defs, findings views.Source) ([]OutOfStepRow, error) { +// stands. +func OutOfStepOf(own string, findings views.Source) ([]OutOfStepRow, error) { out := []OutOfStepRow{} fkeys, err := findings.Keys() if err != nil { @@ -666,25 +519,6 @@ func OutOfStepOf(own string, defs, findings views.Source) ([]OutOfStepRow, error } out = append(out, OutOfStepRow{Source: SourceTrunk, Module: strings.TrimPrefix(f.Subject.ID, own+".out-of-step."), Summary: f.Summary}) } - keys, err := defs.Keys() - if err != nil { - return nil, fmt.Errorf("the %s state cannot be listed: %w", SeatDefinitionsState, err) - } - slices.Sort(keys) - for _, key := range keys { - if !strings.HasPrefix(key, outOfStepPrefix) { - continue - } - v, ok, err := defs.Get(key) - if err != nil || !ok || v == nil { - continue - } - var o OutOfStep - if json.Unmarshal(v.Value, &o) != nil { - continue - } - out = append(out, OutOfStepRow{Source: SourcePull, Pull: fmt.Sprintf("%s#%d", o.Repository, o.Pull), Head: o.Head, Files: o.Files}) - } return out, nil } @@ -704,10 +538,10 @@ type SeatDefinition struct { // SeatDefinitionsOf answers the verb seat-definitions of the seat mesh-catalog (ADR 0636 §4) from the state: with no // seat, every trunk seat with its digest, by seat; with a seat, that seat's trunk definition (found false when the trunk -// holds none). Never a pull request's: a running part acts on what is merged. +// holds none). func SeatDefinitionsOf(defs, marks views.Source, seat string) (any, error) { if seat != "" { - a, err := SeatDefinitionOf(defs, marks, seat, "", 0) + a, err := SeatDefinitionOf(defs, marks, seat) if err != nil { return nil, err } diff --git a/modules/mesh-delivery-indexer/internal/index/takein.go b/modules/mesh-delivery-indexer/internal/index/takein.go index 3d35b93b..fb701ba5 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein.go +++ b/modules/mesh-delivery-indexer/internal/index/takein.go @@ -34,11 +34,9 @@ type TakeInAsk struct { // CatchUp asks the head the gate's source names for every repository to be taken in (CatchUp): the catch-up tool, // indexer_take_in called with no module and no repository, as the node agent calls it after a restore. CatchUp bool `json:"catch-up,omitempty"` - // SeatDefinitions asks a contracts module's seat definitions to be read again now (indexer_seat_definitions_again, - // DLV-I19): its trunk's, or with Pull and Head a pull request's head. - SeatDefinitions bool `json:"seat-definitions,omitempty"` - Pull int `json:"pull,omitempty"` - Head string `json:"head,omitempty"` + // SeatDefinitions asks a contracts module's trunk seat definitions to be read again now (indexer_seat_definitions_again, + // DLV-I19). + SeatDefinitions bool `json:"seat-definitions,omitempty"` // Pending asks the wait under this take-in key to be taken in by hand (indexer_take_in_pending), or with Drop the // one pending merge under it to be dropped (indexer_drop_pending), instead of a module (pending.go, ADR 0633 §5). Pending string `json:"pending,omitempty"`