memory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportGraph added in v0.1.0

func ExportGraph(kg KnowledgeGraph, format, title string) ([]byte, error)

func MarshalTargets

func MarshalTargets(names []string) string

func OpenDB

func OpenDB(dbURL string) (*gorm.DB, error)

Types

type AuditEvent

type AuditEvent struct {
	ID string `gorm:"primaryKey"`

	CreatedAt time.Time `gorm:"autoCreateTime"`

	Agent string

	Tool string

	Operation string

	Targets string // JSON array of entity/relation names

	Count int

	Outcome string // "ok" | "error"

	ErrorMsg string
}

type AuditFilter

type AuditFilter struct {
	Agent string

	Tool string

	Operation string

	Outcome string

	Since time.Time

	Limit int
}

type AuditStore

type AuditStore interface {
	Write(ctx context.Context, e AuditEvent) error

	Query(ctx context.Context, f AuditFilter) ([]AuditEvent, int64, error)

	Summary(ctx context.Context, window time.Duration) (AuditSummary, error)
}

type AuditSummary

type AuditSummary struct {
	TotalMutations int

	ByAgent map[string]int

	ByOperation map[string]int

	ErrorRate float64

	RiskyEvents []AuditEvent
}

type ContentCache

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

func NewContentCache

func NewContentCache(db *gorm.DB, enabled bool, maxSize int) *ContentCache

func (*ContentCache) Count

func (cc *ContentCache) Count() (int64, error)

func (*ContentCache) DeleteOrphanedContent

func (cc *ContentCache) DeleteOrphanedContent(activeRepos []string) error

func (*ContentCache) ListDocs

func (cc *ContentCache) ListDocs(repoName string) ([]DocRecord, error)

func (*ContentCache) NeedsUpdate

func (cc *ContentCache) NeedsUpdate(repoName, path, sha string) bool

func (*ContentCache) Search

func (cc *ContentCache) Search(query, repoName, fileType string) ([]ContentMatch, error)

func (*ContentCache) SearchMode

func (cc *ContentCache) SearchMode() string

func (*ContentCache) Upsert

func (cc *ContentCache) Upsert(repoName, path, sha, content, fileType string) error

type ContentMatch

type ContentMatch struct {
	RepoName string `json:"repo_name"`

	Path string `json:"path"`

	FileType string `json:"file_type,omitempty"`

	Snippet string `json:"snippet"`
}

type DBAuditStore

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

func NewAuditStore

func NewAuditStore(db *gorm.DB) (*DBAuditStore, error)

func (*DBAuditStore) Query

func (*DBAuditStore) Summary

func (s *DBAuditStore) Summary(_ context.Context, window time.Duration) (AuditSummary, error)

func (*DBAuditStore) Write

func (s *DBAuditStore) Write(_ context.Context, e AuditEvent) error

type DocRecord

type DocRecord struct {
	RepoName string

	Path string

	DocID string // "<RepoName>#<Path>"

	Content string
}

type Entity

type Entity struct {
	Name string `json:"name"`

	EntityType string `json:"entityType"`

	Observations []string `json:"observations"`
}

type IntegrationEdge

type IntegrationEdge struct {
	Target string `json:"target"`

	Schema string `json:"schema,omitempty"` // event-topic schema name

	Version string `json:"version,omitempty"` // api version

	Paths int `json:"paths,omitempty"` // api path count

	Confidence string `json:"confidence"` // "authoritative" | "inferred"

	SourceRepo string `json:"source_repo,omitempty"` // originating repo

}

type IntegrationMap

type IntegrationMap struct {
	Service string `json:"service"`

	Publishes []IntegrationEdge `json:"publishes"`

	Subscribes []IntegrationEdge `json:"subscribes"`

	ExposesAPI []IntegrationEdge `json:"exposes_api"`

	ProvidesGRPC []IntegrationEdge `json:"provides_grpc"`

	GRPCDeps []IntegrationEdge `json:"grpc_deps"`

	Calls []IntegrationEdge `json:"calls"`

	Coverage string `json:"graph_coverage"` // "full" | "partial" | "inferred" | "none"

}

type KnowledgeGraph

type KnowledgeGraph struct {
	Entities []Entity `json:"entities"`

	Relations []Relation `json:"relations"`
}

type MemoryService

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

func NewMemoryService

func NewMemoryService(db *gorm.DB) *MemoryService

func (*MemoryService) AddObservations

func (srv *MemoryService) AddObservations(obs []Observation) ([]Observation, error)

func (*MemoryService) CreateEntities

func (srv *MemoryService) CreateEntities(entities []Entity) ([]Entity, error)

func (*MemoryService) CreateRelations

func (srv *MemoryService) CreateRelations(relations []Relation) ([]Relation, error)

func (*MemoryService) DeleteEntities

func (srv *MemoryService) DeleteEntities(names []string) error

func (*MemoryService) DeleteObservations

func (srv *MemoryService) DeleteObservations(deletions []Observation) error

func (*MemoryService) DeleteRelations

func (srv *MemoryService) DeleteRelations(relations []Relation) error

func (*MemoryService) EntityCount

func (srv *MemoryService) EntityCount() (int64, error)

func (*MemoryService) EntityTypeCounts

func (srv *MemoryService) EntityTypeCounts() (map[string]int64, error)

func (*MemoryService) FindPath

func (srv *MemoryService) FindPath(from, to string, maxDepth int) ([]PathEdge, error)

func (*MemoryService) GetIntegrationMap

func (srv *MemoryService) GetIntegrationMap(ctx context.Context, service string, depth int) (IntegrationMap, error)

func (*MemoryService) ListEntities

func (srv *MemoryService) ListEntities(entityType string) (KnowledgeGraph, error)

func (*MemoryService) ListRelations

func (srv *MemoryService) ListRelations(relationType, fromEntity string) ([]Relation, error)

func (*MemoryService) OpenNodes

func (srv *MemoryService) OpenNodes(names []string) (KnowledgeGraph, error)

func (*MemoryService) OpenNodesFiltered

func (srv *MemoryService) OpenNodesFiltered(names []string, includeArchived bool) (KnowledgeGraph, error)

func (*MemoryService) ReadGraph

func (srv *MemoryService) ReadGraph() (KnowledgeGraph, error)

func (*MemoryService) SearchNodes

func (srv *MemoryService) SearchNodes(query string) (KnowledgeGraph, error)

func (*MemoryService) SearchNodesFiltered

func (srv *MemoryService) SearchNodesFiltered(query string, includeArchived bool) (KnowledgeGraph, error)

func (*MemoryService) TraverseGraph

func (srv *MemoryService) TraverseGraph(entity, relationType, direction string, maxDepth int) ([]TraverseNode, []TraverseEdge, error)

func (*MemoryService) UpdateEntity

func (srv *MemoryService) UpdateEntity(oldName, newName, newType string) error

type Observation

type Observation struct {
	EntityName string `json:"entityName"`

	Contents []string `json:"contents"`

	Observations []string `json:"observations,omitempty"` // For deletion

}

type PathEdge

type PathEdge struct {
	From         string `json:"from"`
	RelationType string `json:"relationType"`
	To           string `json:"to"`
	Confidence   string `json:"confidence,omitempty"`
}

PathEdge is a single directed edge on the path between two entities. The edge reflects the actual stored direction regardless of traversal direction.

type Relation

type Relation struct {
	From string `json:"from"`

	To string `json:"to"`

	RelationType string `json:"relationType"`

	Confidence string `json:"confidence,omitempty"`
}

type TraverseEdge added in v0.1.0

type TraverseEdge struct {
	From         string `json:"from"`
	To           string `json:"to"`
	RelationType string `json:"relationType"`
	Confidence   string `json:"confidence,omitempty"`
}

TraverseEdge is a directed edge discovered during graph traversal.

type TraverseNode

type TraverseNode struct {
	Name         string   `json:"name"`
	EntityType   string   `json:"entityType"`
	Observations []string `json:"observations"`
	Distance     int      `json:"distance"`
	Path         []string `json:"path"` // entity names from start (exclusive) to this node (inclusive)
}

TraverseNode is a node reached during graph traversal, enriched with distance from the start entity and the path of entity names leading to it.

Jump to

Keyboard shortcuts

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