I7: the indexer judges no manifest. The judge pass, its verdicts and unjudged states, the events manifest-accepted and manifest-refused, the tools verdicts, indexer_verdicts, indexer_judge and indexer_say_accepted, and the take-in's wait for the verdicts state go; indexer_bus_state answers from the modules state at its mark. The seed writes validate required in every policy. oldsections stays (H-A-79). I6, the half that follows C-R: the gate's pinned, freed, heads-replaced and pins-stated are no longer heard. A pipeline-started pins the revision it names under pipeline.<branch>.<source>, its pipeline-ended frees it, each on a durable of its own stream; kept revisions are judged against the pins the state holds, never a count (made and pins-stated go). A take-in pins its revision once, for its one pipeline. indexer_pin_drop (§765) is still to do. The entry's pull goes (§763). The tests of the old take-in (pending, behind, pushed) go with it, ahead of I8. The unit suite is green except manifest_test's check that the watchman's and the grants part's invokes of the indexer's verdicts tools are served: their removal is the contracts developer's (H-A-79). Builds: design 47 H §743, §745, §749, §763, §764 (the indexer); H-A-48, H-A-49, H-A-79 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
87 lines
3.2 KiB
Go
87 lines
3.2 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"git.novox.be/novox/mesh-sdk/go/views"
|
|
)
|
|
|
|
// BusStateTool is the indexer's tool the bus module's keeper takes its first view from (design 25 § 12.2; DLV-I11):
|
|
// every trunk module whose accepted manifest asks for bus state, then each manifest-accepted after its revision.
|
|
const BusStateTool = "indexer_bus_state"
|
|
|
|
// BusStateModule is one module of BusStateAnswer: the digest of its trunk's manifest, the modules state's revision of its
|
|
// value, and its bus-state entries whole. No manifest is judged at the take-in (design 47 H §743, §745).
|
|
type BusStateModule struct {
|
|
Module string `json:"module"`
|
|
Digest string `json:"digest"`
|
|
Revision uint64 `json:"revision"`
|
|
BusState []catalogue.BusStateEntry `json:"bus-state"`
|
|
}
|
|
|
|
// BusStateAnswer is indexer_bus_state's answer: Revision is the modules state's mark, read before anything else, so every
|
|
// change of modules above it is a change after this answer (ADR 0615 §4); Modules in module order.
|
|
type BusStateAnswer struct {
|
|
Revision uint64 `json:"revision"`
|
|
Modules []BusStateModule `json:"modules"`
|
|
}
|
|
|
|
// BusStateOf answers indexer_bus_state from the indexer's own states: its trunk modules and the manifests it keeps, and
|
|
// the marks the views family says them up to. A module whose manifest asks for no bus state is left out; a value that
|
|
// cannot be read is an error, never a module silently left out.
|
|
func BusStateOf(modules, manifests, marks views.Source) (BusStateAnswer, error) {
|
|
out := BusStateAnswer{Modules: []BusStateModule{}}
|
|
if marks != nil {
|
|
if e, ok, err := marks.Get(ModulesState); err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the mark of %s cannot be read: %w", ModulesState, err)
|
|
} else if ok {
|
|
m, err := views.DecodeMark(e.Value)
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the mark of %s: %w", ModulesState, err)
|
|
}
|
|
out.Revision = m.Revision
|
|
}
|
|
}
|
|
names, err := modules.Keys()
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the modules state cannot be listed: %w", err)
|
|
}
|
|
slices.Sort(names)
|
|
for _, name := range names {
|
|
e, ok, err := modules.Get(name)
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("modules.%s cannot be read: %w", name, err)
|
|
}
|
|
if !ok {
|
|
continue
|
|
}
|
|
mod, err := meshcatalogclient.DecodeModule(e.Value)
|
|
if err != nil || mod.Manifest == "" {
|
|
continue // no manifest held for it
|
|
}
|
|
me, ok, err := manifests.Get(mod.Manifest)
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the manifest of %s cannot be read: %w", name, err)
|
|
}
|
|
if !ok {
|
|
continue
|
|
}
|
|
kept, err := meshcatalogclient.DecodeManifest(me.Value)
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the manifest of %s: %w", name, err)
|
|
}
|
|
m, err := catalogue.Decode([]byte(kept.Manifest))
|
|
if err != nil {
|
|
return BusStateAnswer{}, fmt.Errorf("the manifest of %s does not read: %w", name, err)
|
|
}
|
|
if len(m.BusState) == 0 {
|
|
continue
|
|
}
|
|
out.Modules = append(out.Modules, BusStateModule{Module: name, Digest: mod.Manifest, Revision: e.Revision, BusState: m.BusState})
|
|
}
|
|
return out, nil
|
|
}
|