Documentation
¶
Index ¶
- func MarshalTargets(names []string) string
- func OpenDB(dbURL string) (*gorm.DB, error)
- type AuditEvent
- type AuditFilter
- type AuditStore
- type AuditSummary
- type ContentCache
- func (cc *ContentCache) Count() (int64, error)
- func (cc *ContentCache) DeleteOrphanedContent(activeRepos []string) error
- func (cc *ContentCache) ListDocs(repoName string) ([]DocRecord, error)
- func (cc *ContentCache) NeedsUpdate(repoName, path, sha string) bool
- func (cc *ContentCache) Search(query, repoName, fileType string) ([]ContentMatch, error)
- func (cc *ContentCache) SearchMode() string
- func (cc *ContentCache) Upsert(repoName, path, sha, content, fileType string) error
- type ContentMatch
- type DBAuditStore
- type DocRecord
- type Entity
- type IntegrationEdge
- type IntegrationMap
- type KnowledgeGraph
- type MemoryService
- func (srv *MemoryService) AddObservations(obs []Observation) ([]Observation, error)
- func (srv *MemoryService) CreateEntities(entities []Entity) ([]Entity, error)
- func (srv *MemoryService) CreateRelations(relations []Relation) ([]Relation, error)
- func (srv *MemoryService) DeleteEntities(names []string) error
- func (srv *MemoryService) DeleteObservations(deletions []Observation) error
- func (srv *MemoryService) DeleteRelations(relations []Relation) error
- func (srv *MemoryService) EntityCount() (int64, error)
- func (srv *MemoryService) EntityTypeCounts() (map[string]int64, error)
- func (srv *MemoryService) FindPath(from, to string, maxDepth int) ([]PathEdge, error)
- func (srv *MemoryService) GetIntegrationMap(ctx context.Context, service string, depth int) (IntegrationMap, error)
- func (srv *MemoryService) ListEntities(entityType string) (KnowledgeGraph, error)
- func (srv *MemoryService) ListRelations(relationType, fromEntity string) ([]Relation, error)
- func (srv *MemoryService) OpenNodes(names []string) (KnowledgeGraph, error)
- func (srv *MemoryService) OpenNodesFiltered(names []string, includeArchived bool) (KnowledgeGraph, error)
- func (srv *MemoryService) ReadGraph() (KnowledgeGraph, error)
- func (srv *MemoryService) SearchNodes(query string) (KnowledgeGraph, error)
- func (srv *MemoryService) SearchNodesFiltered(query string, includeArchived bool) (KnowledgeGraph, error)
- func (srv *MemoryService) TraverseGraph(entity, relationType, direction string, maxDepth int) ([]TraverseNode, error)
- func (srv *MemoryService) UpdateEntity(oldName, newName, newType string) error
- type Observation
- type PathEdge
- type Relation
- type TraverseNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalTargets ¶
MarshalTargets serialises a slice of entity/relation names to a JSON string.
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
}
AuditEvent is the GORM model persisted to the audit_events table.
type AuditFilter ¶
type AuditFilter struct {
Agent string
Tool string
Operation string
Outcome string
Since time.Time
Limit int
}
AuditFilter constrains Query results.
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)
}
AuditStore is the port used by GraphAuditLogger and the MCP tools.
type AuditSummary ¶
type AuditSummary struct {
TotalMutations int
ByAgent map[string]int
ByOperation map[string]int
ErrorRate float64
RiskyEvents []AuditEvent
}
AuditSummary is returned by AuditStore.Summary.
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 DBAuditStore ¶
type DBAuditStore struct {
// contains filtered or unexported fields
}
DBAuditStore is the SQLite/Postgres implementation of AuditStore.
func NewAuditStore ¶
func NewAuditStore(db *gorm.DB) (*DBAuditStore, error)
NewAuditStore creates the audit_events table (if absent) and returns a store.
func (*DBAuditStore) Query ¶
func (s *DBAuditStore) Query(_ context.Context, f AuditFilter) ([]AuditEvent, int64, error)
Query retrieves audit events matching the filter. Returns the page and total count.
func (*DBAuditStore) Summary ¶
func (s *DBAuditStore) Summary(_ context.Context, window time.Duration) (AuditSummary, error)
Summary returns anomaly-focused metrics over the given rolling window.
func (*DBAuditStore) Write ¶
func (s *DBAuditStore) Write(_ context.Context, e AuditEvent) error
Write persists one audit event. A UUIDv7 primary key is generated here so ORDER BY id gives chronological order without an extra index.
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
}
IntegrationEdge is a single integration relationship entry in an IntegrationMap.
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"
}
IntegrationMap aggregates all integration relationships for a service.
type KnowledgeGraph ¶
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, error)
func (*MemoryService) UpdateEntity ¶
func (srv *MemoryService) UpdateEntity(oldName, newName, newType string) error
type Observation ¶
type PathEdge ¶
type PathEdge struct {
From string `json:"from"`
RelationType string `json:"relationType"`
To string `json:"to"`
}
PathEdge is a single directed edge on the path between two entities. The edge reflects the actual stored direction regardless of traversal direction.
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.