The node-engine composes nothing of a package artifact (H-A-466)
A package is a build input published to a registry, never placed on a machine, and no registry seat the engine reads numbers it: asking its digest failed the whole build, so a module declaring a package (the indexer, the forge bridge) was wanted and held. The engine now leaves package artifacts out of what it resolves (lookUp), holds (partsMissing), builds (buildOf) and takes in (takein.Manifest, takein.Built, and the manifest handed to Resolve), and so does the candidate compose, which shares partsOf. Builds: design 47 H2 H-A-466
This commit is contained in:
@@ -780,7 +780,7 @@ func referenceOf(module, artifact, digest string) string {
|
||||
}
|
||||
|
||||
// buildOf is the build a want names, made from the entry the composer holds and the parts of the want (the builder's done key is
|
||||
// not read, §421, §628): done, with each artifact of the entry at the digest its part names and the reference made from it. Nil
|
||||
// not read, §421, §628): done, with each placed artifact of the entry (no package, H-A-466) at the digest its part names and the reference made from it. Nil
|
||||
// where the entry is not held, the want names another fingerprint, or a part is missing. The shadow's wants for the modules a
|
||||
// candidate adds carry the parts the candidate gives (A-316).
|
||||
func (c *Composer) buildOf(module, fp string) *builds.BuilderBuild {
|
||||
@@ -804,6 +804,9 @@ func (c *Composer) buildOf(module, fp string) *builds.BuilderBuild {
|
||||
c.mu.Unlock()
|
||||
b := builds.BuilderBuild{State: builds.BuildDone, Manifest: digest}
|
||||
for _, a := range k.entry.Artifacts {
|
||||
if !placed(a.Kind) {
|
||||
continue // a package is no part of what the node composes (H-A-466)
|
||||
}
|
||||
_, name, _ := strings.Cut(a.Ref, ":")
|
||||
digest := parts[a.Ref]
|
||||
b.Artifacts = append(b.Artifacts, builds.BuiltArtifact{Name: name, Kind: a.Kind, Digest: digest,
|
||||
|
||||
@@ -1120,10 +1120,13 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
catalogEntries := map[string]meshcatalog.CatalogEntry{fp: entryOfManifest("lemurs", fp, lemurs), kfp: entryOfManifest("keeper", kfp, keeper)}
|
||||
// A module with an artifact: its build is made from its entry and the parts the candidate gives (design 47 G §628, A-316).
|
||||
artFp := meshcatalogclient.SourcePrefix2 + strings.Repeat("7", 64)
|
||||
artManifest := `{"module":"art","version":"1","capabilities":["systemd"],"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]},` +
|
||||
artManifest := `{"module":"art","version":"1","capabilities":["systemd"],"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"},` +
|
||||
`{"name":"artapi","kind":"package","language":"go","from":"api"}]},` +
|
||||
`"resources":[{"id":"service","type":"service","unit":"art.service","state":"running","boot":"enabled"}]}`
|
||||
artEntry := entryOfManifest("art", artFp, artManifest)
|
||||
artEntry.Artifacts = []meshcatalog.Artifact{{Kind: "archive", Language: "none", Ref: "art:files"}}
|
||||
// Its package is a build input, never placed (H-A-466): the candidate's version resolves no digest of it and holds nothing for it.
|
||||
artEntry.Artifacts = []meshcatalog.Artifact{{Kind: "archive", Language: "none", Ref: "art:files"},
|
||||
{Kind: "package", Language: "go", Ref: "art:artapi", Package: &meshcatalog.ArtifactPackage{Name: "git.example/art/api"}}}
|
||||
catalogEntries[artFp] = artEntry
|
||||
// art's files archive at version 1, which the candidate "art-with" names (the candidate's version, never a digest).
|
||||
senv.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) {
|
||||
|
||||
@@ -73,6 +73,11 @@ func seatOfKind(kind string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// placed is whether the node places an artifact of kind on a machine, and so resolves, holds and takes it in (design 47 H, the
|
||||
// lead's answer H-A-466): a package is a build input published to a registry (catalogue.ArtifactPackage), never placed, and a
|
||||
// want names no digest for it.
|
||||
func placed(kind string) bool { return kind != catalogue.ArtifactPackage }
|
||||
|
||||
// registryName is the name an artifact of module is numbered under: `<module>/<artifact>`, or a package's name in its
|
||||
// ecosystem as the entry gives it.
|
||||
func registryName(module string, a meshcatalog.Artifact) string {
|
||||
@@ -100,7 +105,7 @@ func (c *Composer) partsOf(module string, e meshcatalog.CatalogEntry, w meshwant
|
||||
func partsMissing(e meshcatalog.CatalogEntry, parts map[string]string) string {
|
||||
var out []string
|
||||
for _, a := range e.Artifacts {
|
||||
if parts[a.Ref] == "" {
|
||||
if placed(a.Kind) && parts[a.Ref] == "" {
|
||||
out = append(out, a.Ref)
|
||||
}
|
||||
}
|
||||
@@ -182,7 +187,7 @@ func (c *Composer) dropForgottenLocked(module string) {
|
||||
}
|
||||
}
|
||||
|
||||
// lookUp asks each artifact's digest at w's version of the seat of its kind. Every failure is said, naming the module, the version
|
||||
// lookUp asks each placed artifact's digest at w's version of the seat of its kind. Every failure is said, naming the module, the version
|
||||
// and the seat; any failure resolves nothing of the build.
|
||||
func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants.WantsByWantNodeModuleValue) (map[string]string, string) {
|
||||
parts := map[string]string{}
|
||||
@@ -195,6 +200,9 @@ func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants
|
||||
}
|
||||
var manifest *catalogue.Manifest
|
||||
for _, a := range e.Artifacts {
|
||||
if !placed(a.Kind) {
|
||||
continue // no digest is asked of a package (H-A-466)
|
||||
}
|
||||
_, artifact, _ := strings.Cut(a.Ref, ":")
|
||||
if a.Kind == catalogue.ArtifactUpstream {
|
||||
if manifest == nil {
|
||||
|
||||
@@ -14,6 +14,9 @@ import (
|
||||
|
||||
"github.com/novox/mesh-host/internal/agent"
|
||||
"github.com/novox/mesh-host/internal/nodegrant"
|
||||
"github.com/novox/mesh-host/internal/takein"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
@@ -36,15 +39,26 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
}}}
|
||||
entry := meshcatalog.CatalogEntry{Module: "mail", Fp: fp, Manifest: manifest, Artifacts: []meshcatalog.Artifact{
|
||||
{Ref: "mail:server", Kind: "upstream"}, {Ref: "mail:files", Kind: "archive"}, {Ref: "mail:web", Kind: "image"}}}
|
||||
// H-A-466: a build with a bundle and a package resolves the bundle's digest alone; no digest is asked of the package, a build
|
||||
// input never placed, and nothing is held for it.
|
||||
fpPkg := meshcatalogclient.SourcePrefix2 + strings.Repeat("b", 64)
|
||||
withPackage := meshcatalog.CatalogEntry{Module: "mail", Fp: fpPkg, Manifest: map[string]any{"module": "mail", "version": "1",
|
||||
"build": map[string]any{"artifacts": []any{
|
||||
map[string]any{"name": "tools", "kind": "bundle", "language": "go", "from": "tools"},
|
||||
map[string]any{"name": "mailapi", "kind": "package", "language": "go", "from": "api"},
|
||||
}}}, Artifacts: []meshcatalog.Artifact{{Ref: "mail:tools", Kind: "bundle", Language: "go"},
|
||||
{Ref: "mail:mailapi", Kind: "package", Language: "go", Package: &meshcatalog.ArtifactPackage{Name: "git.example/mail/api"}}}}
|
||||
// The seats hold mail/files and mail/web; versions newest first.
|
||||
held := map[string]string{
|
||||
"oci-artifact-registry.mail/files": `{"name":"mail/files","versions":[{"name":"mail/files","kind":"archive","digest":"` + d("2") + `","version":"1.3.0"},{"name":"mail/files","kind":"archive","digest":"` + d("1") + `","version":"1.2.3"}]}`,
|
||||
"container-image-registry.mail/web": `{"name":"mail/web","versions":[{"name":"mail/web","kind":"image","digest":"` + d("3") + `","version":"1.2.3"}]}`,
|
||||
"container-image-registry.mail/other": `{"name":"mail/other","versions":[]}`,
|
||||
"oci-artifact-registry.mail/tools": `{"name":"mail/tools","versions":[{"name":"mail/tools","kind":"bundle","digest":"` + d("4") + `","version":"1.2.3"}]}`,
|
||||
}
|
||||
for name, row := range map[string]struct {
|
||||
want meshwants.WantsByWantNodeModuleValue
|
||||
down string // a seat whose call fails
|
||||
entry *meshcatalog.CatalogEntry // the build's entry, the one above when nil
|
||||
down string // a seat whose call fails
|
||||
parts map[string]string
|
||||
missing string // a word the reason holds
|
||||
said []string
|
||||
@@ -55,6 +69,8 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
missing: "2.0.0", said: []string{"mail at version 2.0.0", "oci-artifact-registry", "container-image-registry"}},
|
||||
"a seat that does not answer": {want: meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: "1.2.3", Self: true}, down: "container-image-registry",
|
||||
missing: "mail:web", said: []string{"mail at version 1.2.3: the seat container-image-registry"}},
|
||||
"a package artifact": {want: meshwants.WantsByWantNodeModuleValue{Fp: fpPkg, Version: "1.2.3", Self: true}, entry: &withPackage,
|
||||
parts: map[string]string{"mail:tools": d("4")}},
|
||||
} {
|
||||
var mu sync.Mutex
|
||||
var said []string
|
||||
@@ -77,11 +93,15 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) {
|
||||
return nil, errors.New("not asked")
|
||||
})
|
||||
entry := entry
|
||||
if row.entry != nil {
|
||||
entry = *row.entry
|
||||
}
|
||||
c := New(env)
|
||||
c.wants["mail"] = row.want
|
||||
c.keptEnt[fp] = keptEntry{entry: entry}
|
||||
c.keptEnt[entry.Fp] = keptEntry{entry: entry}
|
||||
parts, missing := c.partsOf("mail", entry, row.want)
|
||||
b := c.buildOf("mail", fp)
|
||||
b := c.buildOf("mail", entry.Fp)
|
||||
if row.missing != "" {
|
||||
if parts != nil || b != nil || !strings.Contains(missing, row.missing) {
|
||||
t.Errorf("%s: parts %v, build %v, missing %q: want the module held whole, naming %s", name, parts, b, missing, row.missing)
|
||||
@@ -97,16 +117,28 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
if missing != "" || len(parts) != len(row.parts) {
|
||||
t.Fatalf("%s: parts %v, missing %q", name, parts, missing)
|
||||
t.Fatalf("%s: parts %v, missing %q (said %q)", name, parts, missing, said)
|
||||
}
|
||||
if held := c.entryHolds()["mail"]; held != "" {
|
||||
t.Errorf("%s: the module is held: %s", name, held)
|
||||
}
|
||||
for ref, digest := range row.parts {
|
||||
if parts[ref] != digest {
|
||||
t.Errorf("%s: %s at %s, want %s", name, ref, parts[ref], digest)
|
||||
}
|
||||
}
|
||||
if b == nil || len(b.Artifacts) != 3 {
|
||||
if b == nil || len(b.Artifacts) != len(row.parts) {
|
||||
t.Fatalf("%s: build %+v", name, b)
|
||||
}
|
||||
// The take-in of the build's manifest passes: no package is counted as missing or waited on (H-A-466).
|
||||
raw, _ := json.Marshal(entry.Manifest)
|
||||
m, err := catalogue.Decode(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
if _, err := takein.Manifest(context.Background(), m, *b, nil); err != nil {
|
||||
t.Errorf("%s: the take-in refused the build: %v", name, err)
|
||||
}
|
||||
for _, a := range b.Artifacts {
|
||||
if a.Digest != row.parts["mail:"+a.Name] || a.Reference != referenceOf("mail", a.Name, a.Digest) {
|
||||
t.Errorf("%s: artifact %+v", name, a)
|
||||
|
||||
@@ -44,6 +44,9 @@ func Manifest(ctx context.Context, m catalogue.Manifest, b builds.BuilderBuild,
|
||||
// package not yet built again for the trunk.
|
||||
var missing []string
|
||||
for _, a := range b.Artifacts {
|
||||
if a.Kind == catalogue.ArtifactPackage {
|
||||
continue // a package is taken in by no node (H-A-466)
|
||||
}
|
||||
if strings.TrimSpace(a.Reference) == "" {
|
||||
missing = append(missing, a.Name)
|
||||
}
|
||||
@@ -56,14 +59,32 @@ func Manifest(ctx context.Context, m catalogue.Manifest, b builds.BuilderBuild,
|
||||
if err != nil {
|
||||
return catalogue.Manifest{}, err
|
||||
}
|
||||
resolved, err := m.Resolve(built)
|
||||
resolved, err := placedOnly(m).Resolve(built)
|
||||
if err != nil {
|
||||
return catalogue.Manifest{}, fmt.Errorf("takein: the build of %s does not resolve: %w", m.Module, err)
|
||||
}
|
||||
return resolved, nil
|
||||
}
|
||||
|
||||
// Built is each of a done key's artifacts as catalogue.Manifest.Resolve reads it: its recorded reference and digest, a
|
||||
// placedOnly is m with the package artifacts it declares left out (design 47 H, the lead's answer H-A-466): a package is a
|
||||
// build input published to a registry, never placed on a machine (catalogue.ArtifactPackage), so a node takes none in, and
|
||||
// Resolve counts none as a declared artifact the build did not produce.
|
||||
func placedOnly(m catalogue.Manifest) catalogue.Manifest {
|
||||
if m.Build == nil {
|
||||
return m
|
||||
}
|
||||
build := *m.Build
|
||||
build.Artifacts = nil
|
||||
for _, a := range m.Build.Artifacts {
|
||||
if a.Kind != catalogue.ArtifactPackage {
|
||||
build.Artifacts = append(build.Artifacts, a)
|
||||
}
|
||||
}
|
||||
m.Build = &build
|
||||
return m
|
||||
}
|
||||
|
||||
// Built is each of a done key's placed artifacts (no package, H-A-466) as catalogue.Manifest.Resolve reads it: its recorded reference and digest, a
|
||||
// TypeScript bundle's launchers by the build modules' one rule (catalogue.Launchers), and, for the archive a module packs
|
||||
// its templates into, each template's text read back from that archive.
|
||||
func Built(ctx context.Context, m catalogue.Manifest, artifacts []builds.BuiltArtifact, archive Archive) ([]catalogue.Built, error) {
|
||||
@@ -84,6 +105,9 @@ func Built(ctx context.Context, m catalogue.Manifest, artifacts []builds.BuiltAr
|
||||
if kind == "" {
|
||||
kind = d.Kind
|
||||
}
|
||||
if kind == catalogue.ArtifactPackage {
|
||||
continue
|
||||
}
|
||||
b := catalogue.Built{Name: a.Name, Kind: kind, Reference: registryforms.Forms.Recorded(a.Reference), Digest: a.Digest}
|
||||
if launchers := catalogue.Launchers(d.Language, d.Entrypoints); len(launchers) > 0 {
|
||||
b.Launchers = launchers
|
||||
|
||||
Reference in New Issue
Block a user