node-engine: a held tool runner keeps its running program, so a module of its own account is not held for want of a runtime that runs (ADR 0259 §8)
This commit is contained in:
@@ -489,6 +489,49 @@ func Stub(m catalogue.Manifest) catalogue.Manifest {
|
||||
// run). What it provides, requires, listens on and grants is its manifest's. A module whose resources runs holds none
|
||||
// of is its Stub, as before.
|
||||
func Carried(m catalogue.Manifest, module string, runs *engcomp.Composed) catalogue.Manifest {
|
||||
stub := carried(m, module, runs)
|
||||
if catalogue.IsToolRunner(m) && (len(stub.Bundles) != 1 || stub.Bundles[0].Binary == "") {
|
||||
if b, ok := runningProgram(module, runs); ok {
|
||||
stub.Bundles = []catalogue.Bundle{b}
|
||||
}
|
||||
}
|
||||
return stub
|
||||
}
|
||||
|
||||
// runningProgram is the program bundle of the tool runner as it runs on the node: its process's source, digest and binary.
|
||||
// A held tool runner keeps it, so a module of its own account is run by the same program the node runs (novox/hq ADR 0259
|
||||
// §8) and is not held for want of a runtime that runs (lead-47 2026-11-16: novox's tool runner was held for a build the
|
||||
// catalog half held no entry of, and held the new indexer with it).
|
||||
func runningProgram(module string, runs *engcomp.Composed) (catalogue.Bundle, bool) {
|
||||
if runs == nil {
|
||||
return catalogue.Bundle{}, false
|
||||
}
|
||||
for _, raw := range runs.Resources {
|
||||
var r struct {
|
||||
ID string `json:"id"`
|
||||
Module string `json:"module"`
|
||||
Type string `json:"type"`
|
||||
Source string `json:"source"`
|
||||
Digest string `json:"digest"`
|
||||
Run []string `json:"run"`
|
||||
}
|
||||
if json.Unmarshal(raw, &r) != nil || r.Type != "process" || r.Source == "" || r.Digest == "" || len(r.Run) == 0 {
|
||||
continue
|
||||
}
|
||||
owner := r.Module
|
||||
if owner == "" {
|
||||
owner, _ = declaration.ModuleGuess(r.ID)
|
||||
}
|
||||
binary, ok := strings.CutPrefix(r.Run[0], "./")
|
||||
if owner != module || !ok || binary == "" || strings.Contains(binary, "/") {
|
||||
continue
|
||||
}
|
||||
return catalogue.Bundle{Name: "program", Source: registryforms.Forms.Recorded(r.Source), Digest: r.Digest, Binary: binary}, true
|
||||
}
|
||||
return catalogue.Bundle{}, false
|
||||
}
|
||||
|
||||
func carried(m catalogue.Manifest, module string, runs *engcomp.Composed) catalogue.Manifest {
|
||||
if runs == nil {
|
||||
return Stub(m)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user