The gate (node-tools/internal/approval) derives a module's marked tools and verbs, and the subjects of its marked events and restricted streams, from its served entry (the build its composed environment's fingerprint names) and the newest, unioned while they differ, and the seat definitions' verb marks, which no holder unmarks. A bundle whose marks name a tool it does not register is not loaded, its finding mark-unserved raised through the runner's held writer and cleared when a bundle serves it. The first views now start whether or not the console listens, since the gate reads the catalog half too. Builds: design 46 7-approval-mark §5, §4 (at load), §3; design 34 every-event §33; lead answer A-154 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
84 lines
2.3 KiB
Go
84 lines
2.3 KiB
Go
package firstview
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
|
catalogseat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
|
|
"github.com/novox/mesh-tools/node-tools/internal/approval"
|
|
)
|
|
|
|
// Findings is the runner's held finding writer, the one the gate writes its findings through too (design 46 7-approval-mark
|
|
// §4, §16, §19); nil when it was not made.
|
|
func (v *Views) Findings() approval.FindingWriter {
|
|
if v.deps.Findings == nil {
|
|
return nil
|
|
}
|
|
return v.deps.Findings
|
|
}
|
|
|
|
// ApprovalCatalog is the catalog half as the gate reads its marks (design 46 7-approval-mark §5): the entries the branch
|
|
// follower holds, an entry by fingerprint asked of `mesh-catalog.entry` when no branch lists it, and the seat definitions
|
|
// the seat list holds (defs).
|
|
func (v *Views) ApprovalCatalog(defs func() map[string]seatdef.Definition) approval.Catalog {
|
|
return approvalCatalog{v: v, defs: defs}
|
|
}
|
|
|
|
type approvalCatalog struct {
|
|
v *Views
|
|
defs func() map[string]seatdef.Definition
|
|
}
|
|
|
|
func (c approvalCatalog) Ready() error {
|
|
if c.v.branches == nil {
|
|
return errNotFollowed
|
|
}
|
|
return c.v.branches.Ready()
|
|
}
|
|
|
|
func (c approvalCatalog) Revision() string {
|
|
if c.v.branches == nil {
|
|
return ""
|
|
}
|
|
for _, branch := range c.v.branches.Followed() {
|
|
if cat, ok := c.v.branches.Catalog(branch); ok {
|
|
if half, ok := cat.View(); ok {
|
|
return strconv.FormatInt(half.Revision.Revision, 10)
|
|
}
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (c approvalCatalog) Served(fingerprint string) (catalogseat.CatalogEntry, bool, string) {
|
|
if c.v.branches == nil {
|
|
return catalogseat.CatalogEntry{}, false, errNotFollowed.Error()
|
|
}
|
|
e, state := c.v.branches.Resolve(context.Background(), fingerprint)
|
|
return e, state == meshcatalogclient.EntryAnswered, string(state)
|
|
}
|
|
|
|
func (c approvalCatalog) Newest(module string) (catalogseat.CatalogEntry, bool) {
|
|
if c.v.branches == nil {
|
|
return catalogseat.CatalogEntry{}, false
|
|
}
|
|
e, ok, err := c.v.branches.Entry(module)
|
|
return e, ok && err == nil
|
|
}
|
|
|
|
func (c approvalCatalog) Definitions() map[string]seatdef.Definition {
|
|
if c.defs == nil {
|
|
return nil
|
|
}
|
|
return c.defs()
|
|
}
|
|
|
|
type notFollowed struct{}
|
|
|
|
func (notFollowed) Error() string { return "the catalog half is not followed by this runner" }
|
|
|
|
var errNotFollowed error = notFollowed{}
|