From 3bb2c4e7f4e4bc9bfeee295efe0f3b8b819e8e99 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 23:43:08 +0100 Subject: [PATCH] catalogue: Resolve keeps the digest of a templated module's archive as TemplatesDigest (A-481, A-481a) Builds: design 47 G A-481, A-481a --- go/catalogue/build.go | 3 +++ go/catalogue/build_test.go | 16 ++++++++++++++++ go/catalogue/manifest.go | 3 +++ 3 files changed, 22 insertions(+) diff --git a/go/catalogue/build.go b/go/catalogue/build.go index 48858460..e769f526 100644 --- a/go/catalogue/build.go +++ b/go/catalogue/build.go @@ -64,6 +64,7 @@ func (m Manifest) Resolve(built []Built) (Manifest, error) { // **Each template's text, as the build read it back from its templates archive** (novox/hq ADR 0349 ยง2): into // the file's content, so what the mesh holds and composes is what the same text inline would be. var handed *Handed + templatesDigest := "" if m.Templated() { name := TemplatesArtifact(m) texts := by[name].Texts @@ -90,12 +91,14 @@ func (m Manifest) Resolve(built []Built) (Manifest, error) { // And, for a moved module, where its templates are and which one each file and item is filled from // (handed.go): read while its resources and items still name their templates. handed = handedBy(m, by[name]) + templatesDigest = by[name].Digest m.Resources = filled m.Items = items } out := m out.Handed = handed + out.TemplatesDigest = templatesDigest out.Build = nil // Read with the build, like Build: the manifest the mesh holds carries each file's text (issue 731). out.Templates = "" diff --git a/go/catalogue/build_test.go b/go/catalogue/build_test.go index aa9be4cc..10e07838 100644 --- a/go/catalogue/build_test.go +++ b/go/catalogue/build_test.go @@ -120,3 +120,19 @@ func TestAResourceNamingAPackageIsRefused(t *testing.T) { t.Fatal("a resource backed by a package was accepted; a package is not a resource") } } + +// A templated module's resolved manifest keeps the digest of the archive its files were rendered from, handed or not +// (design 47 G A-481, A-481a); a module with no templates keeps none. +func TestResolveKeepsTheDigestOfTheTemplatesArchive(t *testing.T) { + m := Manifest{Module: "tidy", Build: &Build{Artifacts: []Artifact{{Name: "files", Kind: ArtifactArchive, From: "files"}}}, Resources: []map[string]any{ + {"id": "tidy:conf", "type": "file", "path": "/etc/tidy.conf", TemplateField: "files/tidy.conf"}}} + digest := "sha256:" + strings.Repeat("c", 64) + got, err := m.Resolve([]Built{{Name: "files", Kind: ArtifactArchive, Digest: digest, + Reference: ArtifactStoreScheme + "tidy/files/blobs/" + digest, Texts: map[string]string{"tidy.conf": "x"}}}) + if err != nil || got.TemplatesDigest != digest { + t.Fatalf("templates digest %q, %v; want %s", got.TemplatesDigest, err, digest) + } + if plain, err := buildable().Resolve(wasBuilt()); err != nil || plain.TemplatesDigest != "" { + t.Fatalf("a module with no templates keeps no templates digest: %q, %v", plain.TemplatesDigest, err) + } +} diff --git a/go/catalogue/manifest.go b/go/catalogue/manifest.go index f737f9f1..e4444846 100644 --- a/go/catalogue/manifest.go +++ b/go/catalogue/manifest.go @@ -749,6 +749,9 @@ type Manifest struct { // Handed is what its build kept for that (handed.go): written by Resolve, never in a repository. Moved bool `json:"moved,omitempty"` Handed *Handed `json:"handed,omitempty"` + // TemplatesDigest is the digest of the archive a templated module's files were rendered from, "sha256:": written + // by Resolve, never in a repository; the composition names it (design 47 G A-481, A-481a). + TemplatesDigest string `json:"templates-digest,omitempty"` // Binds is where this module wants to be told about something it requires, per requirement. // -- 2.54.0