I8: every take-in computes with main's import set, a watched branch's too
The recompute takes each module's set from the state imports (a branch's copy of another set gives way to it), with main's import form while main's value holds that set, so the form costs no rebuild; a branch's take-in reads the state through an overlay and drops none of it. Builds: design 47 H2 H-A-519, H-A-529, H-A-532 DMC-6
This commit is contained in:
@@ -165,8 +165,11 @@ type Indexer struct {
|
||||
fillAgain atomic.Bool // a kick arrived while it ran
|
||||
underSeats bool // a dry run inside judge.WithSeats: its judge passes do not hold the seat list (verdicts.go)
|
||||
isDry bool // a dry run (dryrun.go): its packages are a working copy over the live state, and it drops no kept package key (packages.go)
|
||||
judgeMu sync.Mutex // one judge pass at a time (verdicts.go)
|
||||
keepMu sync.Mutex // one catalog graph revision kept at a time (keepEntries)
|
||||
// trunkModules is, in a dry run, the live modules state under its view: main's values, whose import form a branch takes
|
||||
// with main's import set (importset.go, H-A-532 DMC-6); nil reads Modules.
|
||||
trunkModules Store
|
||||
judgeMu sync.Mutex // one judge pass at a time (verdicts.go)
|
||||
keepMu sync.Mutex // one catalog graph revision kept at a time (keepEntries)
|
||||
// Pins is the state pins (pins.go); nil keeps none. PinsPending says how many messages the indexer's durable consumer of the
|
||||
// events stream has not been given: a revision is removed only while none is pending (§579).
|
||||
Pins Store
|
||||
|
||||
@@ -71,6 +71,12 @@ func (ix *Indexer) dry(branch, call string) *dryRun {
|
||||
x.Taken, d.taken = over(ix.Taken)
|
||||
x.Predefined, d.predefined = over(ix.Predefined)
|
||||
x.OldSections, d.oldSections = over(ix.OldSections)
|
||||
// Every branch's take-in reads main's import sets (design 47 H2 H-A-519, H-A-532 DMC-6), and writes none of them.
|
||||
x.Imports, _ = over(ix.Imports)
|
||||
x.trunkModules = ix.Modules
|
||||
if ix.trunkModules != nil {
|
||||
x.trunkModules = ix.trunkModules
|
||||
}
|
||||
ix.mu.Lock()
|
||||
x.source = sourceNow{rev: ix.source.rev, heads: maps.Clone(ix.source.heads)}
|
||||
x.toolchains = map[string]map[string]nodebuildgo.Toolchain{}
|
||||
|
||||
@@ -102,6 +102,35 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T
|
||||
set.Imports[0].Package != meshSDK || set.Imports[0].Digest != digestIn(pub, meshSDK) || set.Imports[1].Digest != digestIn(pub, meshSDK+"/announce") || set.Imports[1].Digest == "" {
|
||||
t.Fatalf("imports.avahi = %+v, %v, %v; want the set at %s with each package's published digest %v", set, found, err, before.Fp2, pub.Packages)
|
||||
}
|
||||
// H-A-519, H-A-532 DMC-6: a take-in computes with main's import set, a watched branch's too: a branch's copy holding
|
||||
// another set (buildstep alone, which would write its own import form) computes to main's fingerprint, and a branch's
|
||||
// take-in drops no set of main's.
|
||||
branch := ix.dry("feature", "c")
|
||||
stale := after
|
||||
staleIn := *after.Inputs2
|
||||
staleIn.Imports, staleIn.ImportForm = []string{meshSDK + "/buildstep"}, ""
|
||||
stale.Inputs2 = &staleIn
|
||||
if err := write(ctx, branch.ix.Modules, "avahi", func([]byte, bool) ([]byte, bool, error) {
|
||||
b, err := meshcatalogclient.EncodeModule(stale)
|
||||
return b, false, err
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := branch.ix.Recompute(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, _, _, _ := branch.ix.Modules.Get(ctx, "avahi"); v == nil {
|
||||
t.Fatal("the branch holds no avahi")
|
||||
} else if m, _ := meshcatalogclient.DecodeModule(v); m.Fp2 != before.Fp2 {
|
||||
t.Fatalf("the branch's avahi computes to %q, want main's %q with main's set and its import form", m.Fp2, before.Fp2)
|
||||
}
|
||||
if err := branch.ix.dropImportSet(ctx, "avahi"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, found, _ := ix.ImportSetOf(ctx, "avahi"); !found {
|
||||
t.Fatal("a branch's take-in dropped main's import set")
|
||||
}
|
||||
branch.end(ctx)
|
||||
// H-A-527: indexer_imports reads it for one module, and says so of a module with none.
|
||||
tool := ImportsReadTool(ix.Imports)
|
||||
if got, err := tool.Run(map[string]any{"module": "avahi"}); err != nil || got.(map[string]any)["kept"] != true || got.(map[string]any)["set"].(ImportSet).Fingerprint != before.Fp2 {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"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"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
@@ -136,3 +137,56 @@ func ImportsReadTool(st Store) stdio.Tool {
|
||||
return map[string]any{"module": module, "kept": true, "set": set}, nil
|
||||
}}
|
||||
}
|
||||
|
||||
// withReportedImports is cur with the import set the state imports keeps for key, the set main's last build reported,
|
||||
// which every take-in computes with, a watched branch's too (design 47 H2 H-A-519, H-A-532 DMC-6); a value holding
|
||||
// another set takes it with main's import form while main's value holds that set (so the form costs no rebuild of its
|
||||
// own, H-A-529), else with none, so its next computation writes the import form. cur is left as it is when the state
|
||||
// keeps no set for key, or it holds no inputs.
|
||||
func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) meshcatalog.ModulesByModuleValue {
|
||||
if cur.Inputs2 == nil {
|
||||
return cur
|
||||
}
|
||||
set, found, err := ix.ImportSetOf(ctx, key)
|
||||
if err != nil {
|
||||
ix.logf("%s.%s cannot be read, so %s keeps the import set its value holds: %v", ImportsState, key, key, err)
|
||||
return cur
|
||||
}
|
||||
if !found {
|
||||
return cur
|
||||
}
|
||||
imports := make([]string, 0, len(set.Imports))
|
||||
for _, p := range set.Imports {
|
||||
imports = append(imports, p.Package)
|
||||
}
|
||||
if slices.Equal(cur.Inputs2.Imports, imports) {
|
||||
return cur
|
||||
}
|
||||
in := *cur.Inputs2
|
||||
in.Imports, in.ImportForm = imports, ix.trunkImportForm(ctx, key, imports)
|
||||
if len(imports) == 0 {
|
||||
in.Imports = nil
|
||||
}
|
||||
cur.Inputs2 = &in
|
||||
return cur
|
||||
}
|
||||
|
||||
// trunkImportForm is the import form main's modules value of key holds with imports, "" when it holds another set.
|
||||
func (ix *Indexer) trunkImportForm(ctx context.Context, key string, imports []string) string {
|
||||
st := ix.trunkModules
|
||||
if st == nil {
|
||||
st = ix.Modules
|
||||
}
|
||||
if st == nil {
|
||||
return ""
|
||||
}
|
||||
v, _, found, err := st.Get(ctx, key)
|
||||
if err != nil || !found {
|
||||
return ""
|
||||
}
|
||||
m, err := meshcatalogclient.DecodeModule(v)
|
||||
if err != nil || m.Inputs2 == nil || !slices.Equal(m.Inputs2.Imports, imports) {
|
||||
return ""
|
||||
}
|
||||
return m.Inputs2.ImportForm
|
||||
}
|
||||
|
||||
@@ -221,6 +221,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
||||
cur, stale[key] = again, true
|
||||
held[key] = cur
|
||||
}
|
||||
cur = ix.withReportedImports(ctx, key, cur)
|
||||
all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before}
|
||||
}
|
||||
tools := ix.agreed()
|
||||
|
||||
Reference in New Issue
Block a user