Nothing of the one model reads which build the indexer runs: the take-in holds nothing for the indexer a revision names and indexer_pending answers the state held alone, so FixOwnBuild, the state own-build, the ask of the node-engine's composition and its invoke go. No pull request's candidate is written any more, so what only it read goes: the member heads' packages (candidatePublished), SameCandidate, headOf and CandidatesKey; and consumerSink with the state consumers (H-A-80). The state taken stays: the view reads it. The run on request's candidate stays (H-A-105 b). The manifest test holds the state and the invoke absent. Builds: design 47 H §743 (holds nothing for the indexer), §764 (the indexer); H-A-48, H-A-80, H-A-102, H-A-105 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
86 lines
4.0 KiB
Go
86 lines
4.0 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
"maps"
|
|
"reflect"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
|
)
|
|
|
|
type dryRun struct {
|
|
ix *Indexer
|
|
modules, graph *overlayStore
|
|
candidates, taken, predefined *overlayStore
|
|
oldSections *overlayStore
|
|
}
|
|
|
|
// dry is an indexer over overlays of this one's states (overlay.go), for a run on request's candidate (runcandidates.go): what
|
|
// it computes stays in memory and nothing reaches the bus but the manifests and the packages, which clause 1 writes all the
|
|
// same. It says no event, kicks nothing in the background, and knows what this one knows of the source and the toolchains. Every field of Indexer is named here (TestDryNamesEveryField holds it so).
|
|
func (ix *Indexer) dry() *dryRun {
|
|
over := func(st Store) (Store, *overlayStore) {
|
|
if st == nil {
|
|
return nil, nil
|
|
}
|
|
o := newOverlay(st)
|
|
return o, o
|
|
}
|
|
d := &dryRun{}
|
|
x := &Indexer{Module: ix.Module, Manifests: ix.Manifests, Packages: ix.Packages, JudgeID: ix.JudgeID, Files: ix.Files, GoSum: ix.GoSum,
|
|
GoMod: ix.GoMod, Now: ix.Now, Builds: ix.Builds, Named: ix.Named, Trunk: ix.Trunk, BranchHead: ix.BranchHead, Read: ix.Read, Contains: ix.Contains,
|
|
SayTakeIn: nil,
|
|
// The registry milestone's fields: what a take-in would write on the bus stays out of a dry run, so the states of the
|
|
// requirements, findings, seat definitions, holds and their bounds are not overlaid, nothing is said, and no hold is
|
|
// weighed (Holds and Counted nil hold nothing); ReadFile only reads.
|
|
Requirements: nil, Findings: nil, SeatDefinitions: nil, ReadFile: ix.ReadFile, SaySeatDefinition: nil,
|
|
Heard: nil, underSeats: true,
|
|
// A dry run keeps no catalog graph revision (catalog_revisions.go): its revision is the take-in's to keep.
|
|
Revisions: nil, SayCatalogRevision: nil, SayFill: nil, EntryIndex: nil, NamedSets: nil, Versions: nil, SayVersionReleased: nil, SayVersionsFilled: nil, Inputs: nil, InputObjects: nil, Pins: nil, PinsPending: nil,
|
|
// A dry run writes no registration and asks no one.
|
|
Registry: nil, SeedModules: nil}
|
|
x.Logf = func(format string, args ...any) { ix.logf("take-in, computed and not written: "+format, args...) }
|
|
x.Store, d.candidates = over(ix.Store)
|
|
x.Modules, d.modules = over(ix.Modules)
|
|
x.Graph, d.graph = over(ix.Graph)
|
|
x.Taken, d.taken = over(ix.Taken)
|
|
x.Predefined, d.predefined = over(ix.Predefined)
|
|
x.OldSections, d.oldSections = over(ix.OldSections)
|
|
ix.mu.Lock()
|
|
x.source = sourceNow{rev: ix.source.rev, heads: maps.Clone(ix.source.heads)}
|
|
x.toolchains = map[string]map[string]nodebuildgo.Toolchain{}
|
|
for l, by := range ix.toolchains {
|
|
x.toolchains[l] = maps.Clone(by)
|
|
}
|
|
x.buildModules = maps.Clone(ix.buildModules) // the dry run computes with the build modules the running indexer takes
|
|
x.moving = maps.Clone(ix.moving)
|
|
x.untaken = maps.Clone(ix.untaken)
|
|
ix.mu.Unlock()
|
|
d.ix = x
|
|
return d
|
|
}
|
|
|
|
// refuseDisagreement refuses a candidate in which two pull requests give one module different manifests, as the
|
|
// candidate's own check does (mesh-sdk Candidate.check), naming both pull requests so the log says which; nothing is
|
|
// written, and the message is dropped as unreadable and said in the log (main.go handle): the next message of either pull
|
|
// request is judged again.
|
|
func (ix *Indexer) refuseDisagreement(c meshcatalog.CandidatesByGroupValue) error {
|
|
first := map[string]meshcatalog.CandidatesByGroupValuePullsItem{}
|
|
for _, p := range c.Pulls {
|
|
for module, m := range p.Fps {
|
|
before, ok := first[module]
|
|
if !ok {
|
|
first[module] = p
|
|
continue
|
|
}
|
|
if !reflect.DeepEqual(before.Fps[module], m) {
|
|
err := fmt.Errorf("%w: candidates.%s: %s#%d and %s#%d give the module %q different manifests (%s and %s), so the group is not written",
|
|
ErrUnreadable, c.Group, before.Repository, before.Number, p.Repository, p.Number, module, before.Fps[module].Manifest, m.Manifest)
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|