G findings: the writers name the ask's subject from the contract; the readers take the writer whole

WriterConfig.Asked is the generated mesh-conditions contract's SubjectFindingsAsked (A-17), a reader's Findings is the
module's writer itself (A-22, A-26), and mesh-build-go's single manifest ask writes and clears its first-view-unanswered
finding through the writer with the contract's Finding (A-28). mesh-config and mesh-vault's own followers (A-28) are not
yet moved onto a views.Reader: they do not compile at mesh-sdk 24f876a.

Builds: design 47 G §687, §689, A-17, A-22, A-26, A-28

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 22:03:09 +01:00
parent 95f29d6c54
commit 06ebd7e8cf
14 changed files with 59 additions and 33 deletions
@@ -30,6 +30,7 @@ import (
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
"git.novox.be/novox/mesh-delivery/sdk/composer"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/keys"
"git.novox.be/novox/mesh-sdk/go/views"
)
@@ -37,6 +38,9 @@ import (
// module invokes it, module.json invokes). A manifest by its digest never changes and a compose ask is rare, so the
// module asks for the one key it needs when it needs it, and keeps no picture of the indexer's whole state (ADR 0615).
// indexerModule is the module that holds the seat mesh-catalog, whose manifests state a compose ask reads.
// findingsModule is the module whose findings these are.
const findingsModule = "mesh-build-go"
const indexerModule = "mesh-delivery-indexer"
const ManifestsTool = indexerModule + ".indexer_read_manifests"
@@ -88,31 +92,48 @@ func askManifest(key string) (json.RawMessage, error) {
// manifestFindings is where askManifest writes its finding: the module's writer once main has started it (design 47 G §689,
// A-16); outside a launch by the runtime, which has no node and no state, nothing is written.
var manifestFindings views.FindingWriter = noFindings{}
var manifestFindings findingWriter = noFindings{}
// findingWriter is the module's writer (views.Writer) as askManifestVia writes and clears through it.
type findingWriter interface {
Write(ctx context.Context, finding seat.Finding) error
Clear(ctx context.Context, scope, id, kind, why string) error
}
type noFindings struct{}
func (noFindings) Put(views.Finding) error { return nil }
func (noFindings) Delete(views.Finding) error { return nil }
func (noFindings) Write(context.Context, seat.Finding) error { return nil }
func (noFindings) Clear(context.Context, string, string, string, string) error { return nil }
// unansweredManifest is the finding of an ask the indexer did not answer, laid out as mesh-sdk lays out a views reader's
// first-view-unanswered (design 47 G §687, A-28): the id is the view's name, escaped as a key's name is.
func unansweredManifest(err string, asked, at time.Time) seat.Finding {
id := keys.EscapeName(findingsModule + "." + indexerModule + ".manifests")
return seat.Finding{Kind: views.UnansweredKind, Scope: "module", ID: id, Severity: seat.FindingSeverityWarning, Source: "views",
Subject: seat.Subject{Scope: "module", ID: findingsModule, Machine: os.Getenv("MESH_NODE")},
Summary: fmt.Sprintf("%s has no first view of %s's manifests: %s has not answered since %s (%s)", findingsModule, indexerModule, ManifestsTool,
asked.Format(time.RFC3339), strings.TrimSpace(err)),
Headline: fmt.Sprintf("%s waits for %s", findingsModule, indexerModule), At: at.UTC()}
}
// newFindingsWriter is this module's finding writer: it states the finding of askManifest and observes none of its own.
func newFindingsWriter() (*views.Writer[seat.Finding, seat.FindingCleared, seat.FindingsStated, seat.FindingsAskedEvent], error) {
return views.NewStdioWriter(views.WriterConfig[seat.Finding, seat.FindingCleared, seat.FindingsStated, seat.FindingsAskedEvent]{
Module: "mesh-build-go", State: stdio.State("findings"),
Asked: seat.SubjectFindingsAsked, Module: findingsModule, State: stdio.State("findings"),
Observe: func(context.Context) (views.Observed[seat.Finding], error) {
return views.Observed[seat.Finding]{}, nil
}})
}
func askManifestVia(ask func(string, any) (json.RawMessage, error), findings views.FindingWriter, now func() time.Time, key string) (json.RawMessage, error) {
st := views.Status{Owner: indexerModule, Tool: ManifestsTool, State: "manifests", Asked: now().UTC()}
func askManifestVia(ask func(string, any) (json.RawMessage, error), findings findingWriter, now func() time.Time, key string) (json.RawMessage, error) {
asked := now().UTC()
raw, err := ask(ManifestsTool, map[string]any{"key": key})
f := unansweredManifest("", asked, now())
if err != nil {
st.Error = err.Error()
_ = findings.Put(views.UnansweredFinding("mesh-build-go", st, now()))
_ = findings.Write(context.Background(), unansweredManifest(err.Error(), asked, now()))
return nil, err
}
_ = findings.Delete(views.UnansweredFinding("mesh-build-go", st, now()))
_ = findings.Clear(context.Background(), f.Scope, f.ID, f.Kind, "the indexer answered")
var a struct {
Found bool `json:"found"`
Value json.RawMessage `json:"value"`
@@ -11,12 +11,12 @@ import (
"testing"
"time"
seat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
catalogclient "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
meshcat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
"git.novox.be/novox/mesh-delivery/sdk/composer"
"git.novox.be/novox/mesh-sdk/go/forgekey"
"git.novox.be/novox/mesh-sdk/go/views"
)
// nodeEngineComposer is the composer command of the node-engine's repository, whose Go module is at its root (ADR 0593 §7):
@@ -187,8 +187,14 @@ func TestAnIndexerThatDoesNotAnswerIsAFinding(t *testing.T) {
type mapFindings map[string][]byte
func (m mapFindings) Put(f views.Finding) error { m[f.ID+"."+f.Kind] = []byte(f.Summary); return nil }
func (m mapFindings) Delete(f views.Finding) error { delete(m, f.ID+"."+f.Kind); return nil }
func (m mapFindings) Write(_ context.Context, f seat.Finding) error {
m[f.ID+"."+f.Kind] = []byte(f.Summary)
return nil
}
func (m mapFindings) Clear(_ context.Context, _, id, kind, _ string) error {
delete(m, id+"."+kind)
return nil
}
// ADR 0593 §7 (C9): a compose ask naming the node-engine's repository builds its composer command in the Go module at the
// repository's root, under a key of that repository, commit and package, and runs the program over the request with its
@@ -17,7 +17,6 @@ import (
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busstate"
"git.novox.be/novox/mesh-sdk/go/views"
)
// The directories the module's manifest places outside its home (ADR 0466 §1): the workspaces, and the Go module
@@ -77,7 +76,7 @@ func main() {
logf("the finding writer: %v", err)
os.Exit(1)
}
manifestFindings = views.WriterFindings{Writer: findings}
manifestFindings = findings
// the runtime answers the writer's subscription only once Serve has its channel
go func() {
<-stdio.Served()