meb

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package meb provides a MEB (Mangle Extension for Badger) storage adapter that implements the KnowledgeStore interface for the OODA loop.

This adapter bridges the MEB quad store to Manglekit's core types, providing zero-copy fact streaming and graph-scoped queries.

Index

Constants

View Source
const (
	GraphIDDefault = "default"
	GraphIDT0      = "t0"
	GraphIDT1      = "t1"
	GraphIDT2      = "t2"
	GraphIDT3      = "t3"
)

GraphID scopes queries to a specific knowledge tier/graph. Common graph IDs:

  • "t0": Immutable core axioms (Tier 0)
  • "t1": Governance/human operator rules (Tier 1)
  • "t2": Induced/learned logic (Tier 2)
  • "t3": Untrusted external input (Tier 3)
  • "playbook_v1": Specific playbook knowledge

Variables

This section is empty.

Functions

This section is empty.

Types

type KnowledgeBridge

type KnowledgeBridge struct {
	// contains filtered or unexported fields
}

KnowledgeBridge adapts MEBStore to satisfy the ports.KnowledgeStore interface. It provides graph-scoped queries and zero-copy fact streaming.

func NewKnowledgeBridge

func NewKnowledgeBridge(store interface {
	Scan(s, p, o, g string) iter.Seq2[MEBFact, error]
}, dict interface {
	GetID(key string) (uint64, error)
	GetString(id uint64) (string, error)
}, graphID string) *KnowledgeBridge

NewKnowledgeBridge creates a new MEB-backed KnowledgeStore. The store parameter must implement the MEB query interface returning MEBFact.

func (*KnowledgeBridge) GetFacts

func (b *KnowledgeBridge) GetFacts(ctx context.Context, subject, predicate, object, graphID string) ([]core.Quad, error)

GetFacts retrieves facts matching a specific pattern (subject/predicate/object). The graphID parameter scopes the search to a specific knowledge tier/graph.

func (*KnowledgeBridge) Recall

func (b *KnowledgeBridge) Recall(ctx context.Context, query string, topK int, graphID string) ([]core.Atom, error)

Recall retrieves the top-K most relevant facts for a query. Since MEB doesn't support semantic search, this implements a simple subject-prefix match. For vector similarity, use MEB's vector search separately.

The graphID parameter scopes the search to a specific knowledge tier/graph.

func (*KnowledgeBridge) StreamFacts

func (b *KnowledgeBridge) StreamFacts(ctx context.Context, subject, predicate, object, graphID string) func(func(core.Quad) bool)

StreamFacts streams facts matching a pattern using zero-copy iteration. The graphID parameter scopes the search to a specific knowledge tier/graph. This uses iter.Seq2 for memory-efficient streaming.

func (*KnowledgeBridge) ToMangleFact

func (b *KnowledgeBridge) ToMangleFact(fact MEBFact) core.Atom

ToMangleFact converts a MEB fact (Quad: S, P, O, G) to core.Fact format. This is the main entry point for mapping MEB data to Manglekit facts.

func (*KnowledgeBridge) ToMangleQuad

func (b *KnowledgeBridge) ToMangleQuad(fact MEBFact) core.Quad

ToMangleQuad converts a MEB fact to core.Quad format with Graph.

func (*KnowledgeBridge) WithGraphID

func (b *KnowledgeBridge) WithGraphID(graphID string) *KnowledgeBridge

WithGraphID returns a new bridge with the specified default graph ID.

type MEBFact

type MEBFact interface {
	GetSubject() string
	GetPredicate() string
	GetObject() any
	GetGraph() string
}

MEBFact represents the fact type from MEB store. This is a type alias to ensure proper type matching.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL