Files
mesh-sdk/go/delivery/provided.go
T
jschoubben 9904a03b51 Let the merge preview and the provided manifest decode instead of judging (ADR 0578 §3)
Issue 1585, S12 (mesh-sdk half): buildstep's named paths and delivery.ProvidedManifest read with catalogue.Decode.

Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
2026-11-01 02:18:56 +01:00

39 lines
1.7 KiB
Go

package delivery
import (
"encoding/json"
"fmt"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/overlay"
)
// The modules the mesh provides itself (issue 1126): no repository holds them, so the indexer reads none; their
// manifests come with mesh-sdk, built in code, and always win over any other. Today the private network alone
// (overlay.Name), built by nobody and run inside each node's own composition. One predicate for every part that judges
// or composes a placement: CheckPlacements, the seat's holder, the composer's input (frombus) and the grants part.
// ProvidedModules is every module the mesh provides itself, sorted.
func ProvidedModules() []string { return []string{overlay.Name} }
// ProvidedByMesh says whether the mesh provides module itself, so a placement may name it with no repository holding it.
func ProvidedByMesh(module string) bool { return module == overlay.Name }
// ProvidedManifest is a provided module's manifest, as its readers parse it, and its raw JSON; an error for a module the
// mesh does not provide or a manifest its own reader refuses.
func ProvidedManifest(module string) (catalogue.Manifest, []byte, error) {
if !ProvidedByMesh(module) {
return catalogue.Manifest{}, nil, fmt.Errorf("delivery: the mesh provides no module %s", module)
}
raw, err := json.Marshal(overlay.Manifest())
if err != nil {
return catalogue.Manifest{}, nil, err
}
// Decoded as every reader decodes a manifest (novox/hq ADR 0578 §3); its judgement is the indexer's.
m, err := catalogue.Decode(raw)
if err != nil {
return catalogue.Manifest{}, raw, fmt.Errorf("delivery: the manifest mesh-sdk provides for %s does not decode: %w", module, err)
}
return m, raw, nil
}