selfcompose: the one place says its source at every caller, reads the have's build, answers HoldsData; the tool composition reads it outside the agent's lock (A-484, A-482)
Builds: design 47 G A-484, A-484a, A-482
This commit is contained in:
@@ -182,7 +182,9 @@ type Composer struct {
|
||||
inOwn map[string]bool
|
||||
// haveRuns is, by module, whether this node's have of it names a build in the phase running or held: a module that
|
||||
// keeps running what it runs, though no running event says it (design 47 G A-482).
|
||||
haveRuns map[string]bool
|
||||
haveRuns map[string]bool
|
||||
// haveFp is, by module, the build that have names, where haveRuns says it runs: one of the builds the one place reads (A-482, A-484).
|
||||
haveFp map[string]string
|
||||
modules map[string]meshcatalog.ModulesByModuleValue
|
||||
told map[string]bool // lines said once each (sayOnceEach)
|
||||
values map[string]map[string]any // by module, this node's
|
||||
@@ -428,7 +430,7 @@ func New(env Env) *Composer {
|
||||
|
||||
func newComposer(env Env) *Composer {
|
||||
return &Composer{env: env, wants: map[string]meshwants.WantsByWantNodeModuleValue{}, assignments: map[string]meshmoduleassigner.Assignments{}, assignmentKeys: meshmoduleassignerclient.NewKeys(),
|
||||
records: map[string]nodeengine.NodeRecord{}, inOwn: map[string]bool{}, haveRuns: map[string]bool{}, modules: map[string]meshcatalog.ModulesByModuleValue{}, values: map[string]map[string]any{},
|
||||
records: map[string]nodeengine.NodeRecord{}, inOwn: map[string]bool{}, haveRuns: map[string]bool{}, haveFp: map[string]string{}, modules: map[string]meshcatalog.ModulesByModuleValue{}, values: map[string]map[string]any{},
|
||||
manifests: map[string][]byte{}, archives: map[string][]byte{}, handed: map[string]string{}, notTaken: map[string]string{}, unmadeSaid: map[string]string{}, rehand: make(chan struct{}, 1), sealedOwn: map[string]ownSealed{},
|
||||
pkgs: map[string]compositions.Composed{}, asked: make(chan chan Pass, 8)}
|
||||
}
|
||||
@@ -867,9 +869,10 @@ func (c *Composer) takeModuleHave(u agent.Update) bool {
|
||||
if err != nil || isNode || node != c.env.Node {
|
||||
return false
|
||||
}
|
||||
in, runs := false, false
|
||||
in, runs, haveFp := false, false, ""
|
||||
if !u.Deleted {
|
||||
if h, err := nodeengineclient.DecodeHave(u.Value); err == nil {
|
||||
haveFp = h.Fp
|
||||
runs = (h.Phase == nodeengineclient.PhaseRunning || h.Phase == nodeengineclient.PhaseHeld) && h.Fp != ""
|
||||
// A have that names nothing it runs, failed (the node could not compose a module it never ran: NotComposed), is
|
||||
// no module run inside the node's own composition: taken as one, it was composed from its manifest past its
|
||||
@@ -888,8 +891,10 @@ func (c *Composer) takeModuleHave(u agent.Update) bool {
|
||||
changed := c.haveRuns[module] != runs
|
||||
if runs {
|
||||
c.haveRuns[module] = true
|
||||
c.haveFp[module] = haveFp
|
||||
} else {
|
||||
delete(c.haveRuns, module)
|
||||
delete(c.haveFp, module)
|
||||
}
|
||||
if c.inOwn[module] == in {
|
||||
return changed
|
||||
@@ -1414,25 +1419,15 @@ func (c *Composer) Policy(ctx context.Context, module string) string {
|
||||
return policy
|
||||
}
|
||||
|
||||
// HoldsData says whether a module's manifest declares data (catalogue.Manifest.DataItems), as a composition's Data says
|
||||
// it, and whether the manifest could be read: the agent's Data for what runs of a module from the kept declaration
|
||||
// HoldsData says whether the manifest of the build a module runs here declares data (catalogue.Manifest.DataItems), as a
|
||||
// composition's Data says it, and whether that manifest could be read, from the one place (A-484): the agent's Data for what runs of a module from the kept declaration
|
||||
// (agent.Env.HoldsData, issue 924).
|
||||
func (c *Composer) HoldsData(ctx context.Context, module string) (data, known bool) {
|
||||
c.mu.Lock()
|
||||
m, ok := c.modules[module]
|
||||
c.mu.Unlock()
|
||||
if !ok || m.Manifest == "" {
|
||||
func (c *Composer) HoldsData(_ context.Context, module string) (data, known bool) {
|
||||
a := c.runningManifest(c.env.Node, module, "")
|
||||
if !a.Known {
|
||||
return false, false
|
||||
}
|
||||
raw, err := reader{c: c}.Manifest(ctx, m.Manifest)
|
||||
if err != nil {
|
||||
return false, false
|
||||
}
|
||||
parsed, held, err := c.taken(module, m, raw)
|
||||
if err != nil || held != "" {
|
||||
return false, false
|
||||
}
|
||||
return len(parsed.DataItems()) > 0, true
|
||||
return len(a.Manifest.DataItems()) > 0, true
|
||||
}
|
||||
|
||||
// taken is a module's manifest as this engine reads it (novox/hq ADR 0578 §3): decoded leniently, judging nothing, with
|
||||
|
||||
Reference in New Issue
Block a user