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
This commit is contained in:
@@ -83,6 +83,13 @@ func claimsAtMesh(top map[string]any, seat string) bool {
|
|||||||
return false
|
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:<seat>:reach}`.
|
// ofSeatReach is a manifest's value naming a seat's reach, `${seat:<seat>:reach}`.
|
||||||
var ofSeatReach = regexp.MustCompile(`\$\{seat:[a-z0-9][a-z0-9-]*: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) {
|
if claimsAtMesh(top, storeHolderSeat) {
|
||||||
used[ReadForm+ReferenceFormSeatReach] = true
|
used[ReadForm+ReferenceFormSeatReach] = true
|
||||||
}
|
}
|
||||||
|
if runsAs, _ := top["runs-as"].(string); runsAs != "" {
|
||||||
|
used[ReadDirectoryContentsOwner] = true
|
||||||
|
}
|
||||||
for _, r := range asList(top["resources"]) {
|
for _, r := range asList(top["resources"]) {
|
||||||
if obj, ok := r.(map[string]any); ok {
|
if obj, ok := r.(map[string]any); ok {
|
||||||
if _, has := obj[IfConfigField]; has {
|
if _, has := obj[IfConfigField]; has {
|
||||||
|
|||||||
@@ -126,6 +126,9 @@ func TestOwnManifestUsesNoWordTheRunningControllerRefuses(t *testing.T) {
|
|||||||
[]string{"form:config-json"}, []string{"form:config-json"}},
|
[]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"}]}`,
|
{"a template of the config form alone", `{"module":"z","version":"1","resources":[{"id":"f","type":"file","template":"files/k"}]}`,
|
||||||
[]string{"form:config"}, nil},
|
[]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},
|
{"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
|
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) {
|
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)
|
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)
|
t.Errorf("%s: this contract lacks %v", row.why, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user