mesh/delivery-group group feat/sdk1 rejected: composed together: the checker's verdict at the members' heads (428d048dd50a): unit: git.novox.be/novox/mesh-sdk/…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: unit: git.novox.be/novox/mesh-sdk/go/process.TestStatePutWritesAKeyWhole: a Put through a short blackout: 0, mesh-mail's state send…
Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
// SeatPath is one path a seat's holder owns: absolute, literal, on the machine where the holder runs.
|
|
type SeatPath struct {
|
|
Path string `json:"path"`
|
|
// StepsBackFor is a node seat whose holder owns the path instead, on a machine where that seat is held
|
|
// (novox/hq ADR 0287, ADR 0247): this seat's holder still declares the path, and its declaration is not
|
|
// composed there. Only the mesh's own seats step back, each by a record.
|
|
StepsBackFor string `json:"steps-back-for,omitempty"`
|
|
}
|
|
|
|
// declaredPaths is every machine path a module declares it owns: a resource's literal path, and a file
|
|
// the mesh renders for it outside the operator's home. An access is not here — reading is not owning.
|
|
//
|
|
// **Cleaned, because the machine writes the cleaned path**: /etc//hosts, /etc/./hosts, /etc/../etc/hosts and
|
|
// /etc/hosts/ are all /etc/hosts to it, and a seat's path is clean by its own rule, so a declaration compared
|
|
// as written would pass for a path nobody named.
|
|
func declaredPaths(m Manifest) map[string]bool {
|
|
out := map[string]bool{}
|
|
if m.OwnsPaths != nil {
|
|
// Carried: what its manifest declares, never what runs of it (issue 1126, seed-8: f1-circuits, snake and txt-game
|
|
// on ace owned their /var/lib paths on the node and none on the controller).
|
|
for _, p := range m.OwnsPaths {
|
|
out[p] = true
|
|
}
|
|
return out
|
|
}
|
|
for _, r := range m.Resources {
|
|
if p, ok := r["path"].(string); ok && strings.HasPrefix(p, "/") {
|
|
out[path.Clean(p)] = true
|
|
}
|
|
}
|
|
for _, f := range m.Facts {
|
|
if !f.Home && strings.HasPrefix(f.Path, "/") {
|
|
out[path.Clean(f.Path)] = true
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// missingPaths is each path a seat names that a module does not declare, in the seat's order.
|
|
func missingPaths(m Manifest, paths []SeatPath) []string {
|
|
if len(paths) == 0 {
|
|
return nil
|
|
}
|
|
has := declaredPaths(m)
|
|
var missing []string
|
|
for _, p := range paths {
|
|
if !has[p.Path] {
|
|
missing = append(missing, p.Path)
|
|
}
|
|
}
|
|
return missing
|
|
}
|