Files
mesh-delivery/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go
T
jschoubben 6c2b79acf1
mesh/merge-gate head 6c2b79acf106 merged into trunk d68d7ef3d9af — fail: builds mesh-delivery-view → shanks; no bus step; a manifest the change touches fai…
mesh/repo-check head 6c2b79acf106 merged into trunk d68d7ef3d9af — pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request
Serve the indexer's read tools from the view, not the indexer (ADR 0437 4): indexer_module and indexer_modules read mesh-delivery-indexer.modules through the view's reads. Side effect: carrying the view's tools gives the tool runner read access to every bucket the view reads. (issue 1562)
2026-10-21 13:24:10 +02:00

55 lines
2.2 KiB
Go

// Command mesh-delivery-view-tools serves the read tools of the indexer's modules (novox/hq issue 1562): the runtime launches it for a
// call, it reads the indexer's modules bucket through the view's reads (mesh-delivery-indexer.modules) and writes nothing.
// The view is the other program: the indexer serves no tool (ADR 0437 §4).
package main
import (
"encoding/json"
"fmt"
"os"
stdio "git.novox.be/novox/mesh-sdk/go"
"mesh-delivery-view/internal/view"
)
// Tools are the read tools over a modules state.
func Tools(r view.Reader) []stdio.Tool {
return []stdio.Tool{
{Name: view.ModuleReadTool,
Description: "What the indexer stored for one module under modules.<module>, as stored: its fingerprint (fp, none), the " +
"new-form fingerprint (fp2) or why it has none (none2), the inputs it was computed from (inputs2), the module's " +
"directory (path) and the toolchains it was computed with. Read-only.",
Input: map[string]any{"type": "object", "required": []string{"module"}, "properties": map[string]any{
"module": map[string]any{"type": "string", "description": "the module's name"}}},
Run: func(args map[string]any) (any, error) {
name, _ := args["module"].(string)
return r.Module(name)
}},
{Name: view.ModulesReadTool,
Description: "Every module the indexer holds, each as stored under modules.<module>. With none2 true, only the modules " +
"that have no new-form fingerprint, each with the reason (none2). Read-only.",
Input: map[string]any{"type": "object", "properties": map[string]any{
"none2": map[string]any{"type": "boolean", "description": "only the modules without a new-form fingerprint"}}},
Run: func(args map[string]any) (any, error) {
only, _ := args["none2"].(bool)
mods, err := r.Modules(only)
return map[string]any{"modules": mods}, err
}},
}
}
func main() {
state := stdio.State("mesh-delivery-indexer.modules")
r := view.Reader{State: view.StateRead{Keys: state.Keys, Get: func(key string) (json.RawMessage, error) {
e, err := state.Get(key)
if err != nil || e == nil {
return nil, err
}
return e.Value, nil
}}}
if err := stdio.Serve("", Tools(r)); err != nil {
fmt.Fprintf(os.Stderr, "[mesh-delivery-view-tools] %v\n", err)
os.Exit(1)
}
}