The checker read any touched contracts module's definitions, skipped the check that a definition names its own directory's seat, and copied the indexer's tree reading. sdk/seatdefs now holds the reading and the rule of which contracts module may define a seat; the indexer's keeping, its revision seats and the checker's head seats all use it. Two heads defining one seat fail the judging unless one hands it over to its domain's module. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
53 lines
2.3 KiB
Go
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
|
|
}
|