Documentation
¶
Overview ¶
Package store manages the brain's own SQLite database. It stores semantic summaries, cached violation explanations, SDLC state, decision history, and learned co-occurrence patterns. This is separate from Synapses' SQLite database.
Index ¶
- type ADR
- type ContextPattern
- type DecisionLogEntry
- type InsightCacheEntry
- type SDLCConfigRow
- type Store
- func (s *Store) AllADRs() ([]ADR, error)
- func (s *Store) AllPatterns() ([]ContextPattern, error)
- func (s *Store) Close() error
- func (s *Store) GetADR(id string) (ADR, error)
- func (s *Store) GetADRsForFile(filePath string, limit int) ([]ADR, error)
- func (s *Store) GetDecisionLog(entityName string, limit int) ([]DecisionLogEntry, error)
- func (s *Store) GetInsightCache(nodeID, phase string) (entry InsightCacheEntry, found bool)
- func (s *Store) GetPatternsForTriggers(triggers []string, limit int) []ContextPattern
- func (s *Store) GetSDLCConfig() SDLCConfigRow
- func (s *Store) GetSummaries(projectID string, nodeIDs []string) map[string]string
- func (s *Store) GetSummariesByName(names []string) map[string]string
- func (s *Store) GetSummary(projectID, nodeID string) string
- func (s *Store) GetViolationExplanation(ruleID, sourceFile string) (explanation, fix string, found bool)
- func (s *Store) LogDecision(agentID, phase, entityName, action string, relatedEntities []string, ...) error
- func (s *Store) Reset() error
- func (s *Store) UpsertADR(adr ADR) error
- func (s *Store) UpsertInsightCache(nodeID, phase, insight string, concerns []string) error
- func (s *Store) UpsertPattern(trigger, coChange, reason string) error
- func (s *Store) UpsertSDLCConfig(phase, qualityMode, updatedBy string) error
- func (s *Store) UpsertSummary(projectID, nodeID, nodeName, summary string, tags []string) error
- func (s *Store) UpsertViolationExplanation(ruleID, sourceFile, explanation, fix string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADR ¶
type ADR struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"` // proposed | accepted | deprecated | superseded
ContextText string `json:"context,omitempty"`
Decision string `json:"decision"`
Consequences string `json:"consequences,omitempty"`
LinkedFiles []string `json:"linked_files,omitempty"` // file path glob patterns
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
ADR represents an Architectural Decision Record stored in brain.sqlite.
type ContextPattern ¶
type ContextPattern struct {
Trigger string
CoChange string
Reason string
Confidence float64
CoCount int
}
ContextPattern is a learned co-occurrence rule.
type DecisionLogEntry ¶
type DecisionLogEntry struct {
ID string
AgentID string
Phase string
EntityName string
Action string
RelatedEntities []string
Outcome string
Notes string
CreatedAt string
}
DecisionLogEntry is a row from decision_log.
type InsightCacheEntry ¶
InsightCacheEntry is a stored LLM-generated insight for a (node_id, phase) pair.
type SDLCConfigRow ¶
SDLCConfigRow is the stored project SDLC state.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the brain's persistent SQLite store.
func Open ¶
Open opens (or creates) the brain SQLite database at the given path. Parent directories are created if they do not exist. Old data is pruned at startup (decision_log >30d, stale patterns >14d).
func (*Store) AllPatterns ¶
func (s *Store) AllPatterns() ([]ContextPattern, error)
AllPatterns returns all patterns ordered by confidence for CLI display.
func (*Store) GetADRsForFile ¶
GetADRsForFile returns accepted ADRs whose linked_files patterns match the given file path. At most `limit` ADRs are returned; pass 0 for no limit.
func (*Store) GetDecisionLog ¶
func (s *Store) GetDecisionLog(entityName string, limit int) ([]DecisionLogEntry, error)
GetDecisionLog returns up to limit decision log entries, optionally filtered by entityName (empty string = all), ordered by created_at DESC.
func (*Store) GetInsightCache ¶
func (s *Store) GetInsightCache(nodeID, phase string) (entry InsightCacheEntry, found bool)
GetInsightCache returns the cached insight for a (nodeID, phase) pair. Returns ("", nil, false) if not cached or if the entry was pruned (>6h old).
func (*Store) GetPatternsForTriggers ¶
func (s *Store) GetPatternsForTriggers(triggers []string, limit int) []ContextPattern
GetPatternsForTriggers returns the top patterns for any of the given trigger names. Results are ordered by confidence descending, capped at limit.
func (*Store) GetSDLCConfig ¶
func (s *Store) GetSDLCConfig() SDLCConfigRow
GetSDLCConfig returns the current project SDLC config. Returns defaults if no config row exists.
func (*Store) GetSummaries ¶
GetSummaries returns summaries for all given node IDs keyed by node ID. Missing nodes are omitted from the result map.
func (*Store) GetSummariesByName ¶
GetSummariesByName returns summaries keyed by node_name for the given names. This is used by the contextbuilder to look up dep summaries by entity name.
func (*Store) GetSummary ¶
GetSummary returns the stored summary for a node, or "" if not found. Falls back to the empty-projectID (legacy) row if no project-scoped row exists.
func (*Store) GetViolationExplanation ¶
func (s *Store) GetViolationExplanation(ruleID, sourceFile string) (explanation, fix string, found bool)
GetViolationExplanation returns the cached explanation for a rule+file pair. Returns ("", "", false) if not cached.
func (*Store) LogDecision ¶
func (s *Store) LogDecision(agentID, phase, entityName, action string, relatedEntities []string, outcome, notes string) error
LogDecision inserts a new decision log entry.
func (*Store) UpsertInsightCache ¶
UpsertInsightCache stores a (nodeID, phase) → insight mapping. Existing entries are replaced (insight content may have improved).
func (*Store) UpsertPattern ¶
UpsertPattern adds or increments a co-occurrence pattern. coCount and totalCount are incremented; confidence is recomputed.
func (*Store) UpsertSDLCConfig ¶
UpsertSDLCConfig saves the SDLC config row.
func (*Store) UpsertSummary ¶
UpsertSummary stores or updates the semantic summary and tags for a node. If the node already exists (re-ingest), the insight cache is invalidated for all phases — the old insight may no longer match the updated code. projectID scopes the summary; use "" for legacy/unscoped entries.
func (*Store) UpsertViolationExplanation ¶
UpsertViolationExplanation caches a plain-English explanation for a rule+file pair.