diff --git a/internal/compose/composed.go b/internal/compose/composed.go index 15017c4d..7ae3253b 100644 --- a/internal/compose/composed.go +++ b/internal/compose/composed.go @@ -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) }