package approval import ( "context" "sort" condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-sdk/go/views" catalogseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" gate "git.novox.be/novox/mesh-sdk/go/approval" "git.novox.be/novox/mesh-sdk/go/seatdef" ) // fakeCatalog is a catalog half as a fixture: entries by fingerprint, the newest by module, the seat definitions. type fakeCatalog struct { ready error revision string byFp map[string]catalogseat.CatalogEntry newest map[string]catalogseat.CatalogEntry defs map[string]seatdef.Definition } func (c *fakeCatalog) Ready() error { return c.ready } func (c *fakeCatalog) Revision() string { return c.revision } func (c *fakeCatalog) Served(fp string) (gate.Entry, bool, string) { e, ok := c.byFp[fp] return Entry(e), ok, "not-found" } func (c *fakeCatalog) Newest(m string) (gate.Entry, bool) { e, ok := c.newest[m] return Entry(e), ok } func (c *fakeCatalog) Definitions() map[string]seatdef.Definition { return c.defs } func (c *fakeCatalog) Entries() []gate.Entry { var out []gate.Entry for _, e := range c.newest { out = append(out, Entry(e)) } return out } func entry(fp string, serves []string, manifest map[string]any) catalogseat.CatalogEntry { return catalogseat.CatalogEntry{Module: "shell", Fp: fp, Serves: serves, Manifest: manifest} } // findings is the runner's held writer as a fixture: each finding raised now, by id. type findings struct { raised map[string]string // pends are the keys pending in the held writer's statement; pended every key ever pended. pends map[string]views.PendingKey pended []string } func (f *findings) Pend(p views.PendingKey) { if f.pends == nil { f.pends = map[string]views.PendingKey{} } f.pends[p.Key] = p f.pended = append(f.pended, p.Key) } func (f *findings) Judged(key string) { delete(f.pends, key) } func (f *findings) Write(_ context.Context, x condseat.Finding) error { if f.raised == nil { f.raised = map[string]string{} } f.raised[x.ID] = x.Kind return nil } func (f *findings) Clear(_ context.Context, _, id, _, _ string) error { delete(f.raised, id) return nil } func keysOf(set map[string]string) []string { var out []string for k := range set { out = append(out, k) } sort.Strings(out) return out }