Files
mesh-delivery/modules/mesh-delivery-indexer/internal/index/seatsof.go
T
jschoubben 043e3fb979 Read seat definitions once: the indexer's reading becomes a module the checker requires (issue 1921)
The checking program's seat list parsed the definition format a second time beside the
indexer's judge. The indexer's reading moves whole into its own sibling module seatfiles
(a domain path, as takein), with ResolveRaw keeping every field as written for a request's
seats; the judge and the take-in read through it, and the checker's rules only find the
definitions and say why one is left out (the lead's ruling on D3, ADR 0634 §1).

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
2026-11-06 22:39:31 +01:00

53 lines
2.3 KiB
Go

package index
// The seat definitions a revision carries (novox/hq ADR 0633 §1, ADR 0635 §3, ADR 0636 §4): when a take-in works out which
// indexer a revision names, or a group try's candidate is made, the manifests are judged against the seats of that revision
// on top of the seat list the indexer holds, since the manifest the revision names may serve or invoke what the revision's
// definitions add (a verb of a seat, an event). The revision's merges are not taken in yet, and a try has no pull request,
// so their definitions are not on the bus: they are read from the merges' trees as the indexer reads a merge's (readDefinitions
// of seatdefs.go, the same resolution of the parts and the same rule of which module may define a seat), never by a reader
// of their own.
import (
"context"
"maps"
"slices"
"git.novox.be/novox/mesh-delivery/sdk/seatdefs"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/seatdef"
)
// revisionSeats are the seats of the definitions the ready merges carry, read at their merge commits, the newest merge
// of a repository governing; none where the indexer has no forge reader. A read the forge does not answer is an error
// (the take-in is tried again); a definition that does not parse is said and left out, as the indexer that keeps it
// would say it unparsed.
func (ix *Indexer) revisionSeats(ctx context.Context, ready []PendingEntry) ([]catalogue.Seat, error) {
if ix.ReadFile == nil || ix.Files == nil {
return nil, nil
}
defs := map[string]seatdef.Definition{}
for _, e := range ready {
if e.Covered || e.Forge.Merge == "" {
continue
}
for _, c := range contractsModules(e.Forge.Manifests) {
got, unparsed, err := ix.readDefinitions(ctx, e.Forge.Repository, e.Forge.Merge, c)
if err != nil {
return nil, err
}
for seat, why := range unparsed {
ix.logf("the revision's definition of %s (%s) does not parse and is left out: %s", seat, c.Module, why)
}
for seat, d := range got {
if why := seatdefs.Refusal(c.Module, d); why != "" {
ix.logf("the revision's definition of %s is left out: %s", seat, why) // as keepTrunk refuses it (ADR 0636 §5)
continue
}
defs[seat] = d
}
}
}
return catalogue.SeatsFromDefinitions(slices.Collect(maps.Values(defs))), nil
}