Merge pull request 'A-481: catalogue Resolve keeps a templated module's archive digest' (#198) from fix/a481-composition-templates into main

This commit was merged in pull request #198.
This commit is contained in:
2026-11-18 00:54:46 +00:00
3 changed files with 22 additions and 0 deletions
+3
View File
@@ -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 = ""
+16
View File
@@ -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)
}
}
+3
View File
@@ -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:<hex>": 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.
//