Files
mesh-delivery/modules/mesh-delivery-indexer/internal/index/predefined.go
T
jschoubben e81ef8bb63 Read a manifest whose config value falls back to a predefined key, so claude-code, dunst and xterm get a new-form fingerprint (issue 1751, ADR 0348 §7)
The indexer holds no published list of predefined keys; each key a value names is taken as the value declares it.
No fingerprint input comes from the list: the gate and the controller still judge the value.
2026-10-22 18:11:21 +02:00

45 lines
1.7 KiB
Go

package index
import (
"encoding/json"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
// readManifest reads a manifest as the catalogue's parser does, for the inputs of its fingerprint (issue 1751). A config
// value falling back to a predefined key (novox/hq ADR 0348 §7) is judged against the list the mesh published when the
// process holds one; the indexer holds none, since the list is read where a manifest is judged (the merge gate, from the
// tree's root) and by the controller, so each key a value names is taken as the value declares it: of its type, trusted
// when it is. What the list adds is the judging of the value, which the gate and the controller do; no input of a
// fingerprint comes from it. Everything else the parser refuses is refused here too.
func readManifest(raw []byte) (catalogue.Manifest, error) {
list := catalogue.PublishedPredefined()
if list == nil {
list = fallbacksOf(raw)
}
return catalogue.ParseManifestWith(raw, list)
}
// fallbacksOf is the list of the predefined keys the manifest's config values fall back to, each as the value declares
// it. A manifest that is not JSON gives an empty list, and the parser says what is wrong with it.
func fallbacksOf(raw []byte) catalogue.PredefinedList {
var m struct {
Config map[string]struct {
Type string `json:"type"`
Description string `json:"description"`
Predefined string `json:"predefined"`
Trusted bool `json:"trusted"`
} `json:"config"`
}
list := catalogue.PredefinedList{}
if json.Unmarshal(raw, &m) != nil {
return list
}
for _, d := range m.Config {
if d.Predefined != "" {
list[d.Predefined] = catalogue.PredefinedKey{Type: d.Type, Description: d.Description, Trusted: d.Trusted}
}
}
return list
}