From 2ef966ca171bc235e8a0f6b0e2809af2d3e75e49 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 12:23:58 +0100 Subject: [PATCH] A manifest of its own account needs an engine that gives directory contents A module moved to runs-as reads what it wrote before only once its node-engine gives a directory's contents the directory's new owner. ManifestNeeds now names the reader capability directory-contents-owner for every manifest declaring runs-as, so the module graph orders such a module's move after that engine runs on its node; the node-engine states it itself. Builds: design 47 H2 H-A-554 (1), H-A-556 --- go/catalogue/manifest_reads.go | 10 ++++++++++ go/catalogue/own_manifest_test.go | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/go/catalogue/manifest_reads.go b/go/catalogue/manifest_reads.go index ebc27b7d..e6dc9b34 100644 --- a/go/catalogue/manifest_reads.go +++ b/go/catalogue/manifest_reads.go @@ -83,6 +83,13 @@ func claimsAtMesh(top map[string]any, seat string) bool { return false } +// ReadDirectoryContentsOwner is the reader capability of a node-engine that, when a directory's owner changes, gives its +// contents the new owner too (novox/hq design 47 H2, H-A-545 (2), H-A-550, H-A-556): an engine before it changes the +// directory alone, and a module moved to an account of its own then cannot read what it wrote before. A manifest that +// declares runs-as needs it (ManifestNeeds), so the module graph orders such a module's move after that engine runs on +// its node (ADR 0614 ยง4). The engine states it itself; this contract does not (ManifestReads). +const ReadDirectoryContentsOwner = "directory-contents-owner" + // ofSeatReach is a manifest's value naming a seat's reach, `${seat::reach}`. var ofSeatReach = regexp.MustCompile(`\$\{seat:[a-z0-9][a-z0-9-]*:reach\}`) @@ -179,6 +186,9 @@ func ManifestNeeds(raw []byte) ([]string, error) { if claimsAtMesh(top, storeHolderSeat) { used[ReadForm+ReferenceFormSeatReach] = true } + if runsAs, _ := top["runs-as"].(string); runsAs != "" { + used[ReadDirectoryContentsOwner] = true + } for _, r := range asList(top["resources"]) { if obj, ok := r.(map[string]any); ok { if _, has := obj[IfConfigField]; has { diff --git a/go/catalogue/own_manifest_test.go b/go/catalogue/own_manifest_test.go index b08babff..ceffe063 100644 --- a/go/catalogue/own_manifest_test.go +++ b/go/catalogue/own_manifest_test.go @@ -126,6 +126,9 @@ func TestOwnManifestUsesNoWordTheRunningControllerRefuses(t *testing.T) { []string{"form:config-json"}, []string{"form:config-json"}}, {"a template of the config form alone", `{"module":"z","version":"1","resources":[{"id":"f","type":"file","template":"files/k"}]}`, []string{"form:config"}, nil}, + // A module of its own account needs an engine that gives a directory's contents its new owner (H-A-556). + {"a module of its own account", `{"module":"g","version":"1","runs-as":"g"}`, + []string{"directory-contents-owner", "word:runs-as"}, []string{"directory-contents-owner"}}, {"a word this contract does not know", `{"module":"u","version":"1","newer-word":{"inside":1}}`, []string{"word:module"}, nil}, } { templates := map[string]map[string]string{ // the templates' text a row's module names @@ -164,7 +167,8 @@ func TestOwnManifestUsesNoWordTheRunningControllerRefuses(t *testing.T) { if got := MissingManifestReads(needs, nil); !slices.Equal(got, row.missing) { t.Errorf("%s: an engine stating nothing lacks %v, want %v", row.why, got, row.missing) } - if got := MissingManifestReads(needs, reads); len(got) != 0 { + // The node-engine states directory-contents-owner itself, beside this contract's reads (H-A-556). + if got := MissingManifestReads(needs, append(slices.Clone(reads), ReadDirectoryContentsOwner)); len(got) != 0 { t.Errorf("%s: this contract lacks %v", row.why, got) } } -- 2.54.0