DLV-I10: indexer_config_readers; and indexer_read_findings with its views event
indexer_config_readers {module} answers {readers: [{module, key, kind,
readers}]} for every value key and own secret any kept manifest of the
module ever declared: the module where its trunk's manifest declares it,
each open pull request whose head declares it, none for a key no longer
read (design 32 *A value no longer read*). It reads one watched copy of
the modules, manifests and config-candidates states. Nodes is left out:
the indexer cannot say which nodes' builds read a key. The indexer's
findings are said on its views family and read by indexer_read_findings,
for the condition keeper (the lead's ruling).
Issue 1966.
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -194,7 +194,7 @@ func heldCounts(s stdio.KeptState) func() (index.OldSectionsCount, error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := stdio.Serve("", append(Tools(askTakeIn(stdio.State(index.TakeInsState), 25*time.Second), time.Now, stdio.State(index.VerdictsState), heldCounts(stdio.State(index.OldSectionsState))), append(catalogTools(), viewTools(os.Getenv, keptSource, time.Now)...)...)); err != nil {
|
||||
if err := stdio.Serve("", append(Tools(askTakeIn(stdio.State(index.TakeInsState), 25*time.Second), time.Now, stdio.State(index.VerdictsState), heldCounts(stdio.State(index.OldSectionsState))), append(append(catalogTools(), viewTools(os.Getenv, keptSource, time.Now)...), configReadersTool(stdio.NewWatchedStates()))...)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[mesh-delivery-indexer-tools] %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
@@ -30,3 +32,52 @@ func viewTools(getenv func(string) string, state func(string) views.Source, now
|
||||
|
||||
// keptSource is one of the indexer's states as its runtime reads it.
|
||||
func keptSource(name string) views.Source { return views.KeptSource{State: stdio.State(name)} }
|
||||
|
||||
// configReadersTool is indexer_config_readers (design 32 *A value no longer read*; DLV-I10): read from one watched copy
|
||||
// of the indexer's modules, manifests and config-candidates states, so an ask on each manifest-accepted reads no state
|
||||
// whole again.
|
||||
func configReadersTool(watched *stdio.WatchedStates) stdio.Tool {
|
||||
return stdio.Tool{Name: index.ConfigReadersTool,
|
||||
Description: "Who reads a module's config keys now (design 32): every value key and own secret any manifest of the module " +
|
||||
"the indexer keeps ever declared, each with its readers — the module itself where its trunk's manifest declares it, and " +
|
||||
"each open pull request (owner/repository#number) whose head declares it. A key with no reader is no longer read by any " +
|
||||
"trunk or pull request, which mesh-config retires; which nodes still run a build reading it is not the indexer's to say.",
|
||||
Input: map[string]any{"type": "object", "required": []string{"module"}, "properties": map[string]any{
|
||||
"module": map[string]any{"type": "string", "description": "the module whose config keys are asked"}}},
|
||||
Run: func(args map[string]any) (any, error) {
|
||||
module, _ := args["module"].(string)
|
||||
if module == "" {
|
||||
return nil, fmt.Errorf("%s names the module", index.ConfigReadersTool)
|
||||
}
|
||||
trunk := map[string]delivery.Module{}
|
||||
mods, err := watched.Values("modules")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the modules state cannot be read: %w", err)
|
||||
}
|
||||
for k, v := range mods {
|
||||
if m, err := delivery.DecodeModule(v); err == nil {
|
||||
trunk[k] = m
|
||||
}
|
||||
}
|
||||
kept := map[string]delivery.Manifest{}
|
||||
raws, err := watched.Values("manifests")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the manifests state cannot be read: %w", err)
|
||||
}
|
||||
for k, v := range raws {
|
||||
if m, err := delivery.DecodeManifest(v); err == nil {
|
||||
kept[k] = m
|
||||
}
|
||||
}
|
||||
var pulls []delivery.ConfigCandidate
|
||||
if cands, err := watched.Values(delivery.IndexerConfigCandidatesState); err == nil {
|
||||
for _, v := range cands {
|
||||
var c delivery.ConfigCandidate
|
||||
if json.Unmarshal(v, &c) == nil {
|
||||
pulls = append(pulls, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return map[string]any{"readers": index.ConfigReaders(module, trunk, kept, pulls)}, nil
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
map[string]readyOf{"manifests": boundNow(manifests), "modules": boundNow(modules), "candidates": boundNow(candidates),
|
||||
index.VerdictsState: awaited(verdicts), delivery.IndexerPredefinedState: awaited(predefined),
|
||||
delivery.IndexerConfigCandidatesState: awaited(configCandidates), delivery.PackagesState: awaited(packages),
|
||||
graphState: awaited(graph), index.HeardState: awaited(heard.b), "taken": awaited(taken)}, errs, logger.Printf)
|
||||
graphState: awaited(graph), index.HeardState: awaited(heard.b), "taken": awaited(taken), "findings": awaited(findings)}, errs, logger.Printf)
|
||||
cc, err := process.HearEvents(cons, func(m jetstream.Msg) { handle(ctx, m, ix, heard, logger); ix.KickFill(ctx) }, logger.Printf)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user