store

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodePolicyStaleReview         = "policy.stale_review"
	CodePolicySupersedeReferenced = "policy.superseded_referenced"
	CodePolicyDuplicate           = "policy.duplicate"
	CodePolicyNonCanonical        = "policy.non_canonical"
	CodePolicyConflicting         = "policy.conflicting"
)

Policy/process drift finding codes.

View Source
const (
	CodeResearchStaleAssessment          = "research.stale_assessment"
	CodeResearchUnverifiedEvidence       = "research.unverified_evidence"
	CodeResearchCompetingInterpretations = "research.competing_interpretations"
	CodeResearchSupersededClaim          = "research.superseded_claim"
	CodeResearchImpactedDeliverable      = "research.impacted_deliverable"
)

Research/assessment drift finding codes.

View Source
const (
	CodeCodeMissingSymbol      = "code.missing_symbol"
	CodeCodeUndocumentedExport = "code.undocumented_export"
	CodeCodeUnanchoredFeature  = "code.unanchored_feature"
)

Docs-code drift finding codes.

View Source
const (
	MaxEntityAliases     = 200
	MaxMentionContextLen = 500
	MaxEntitiesPerDoc    = 500
)
View Source
const (
	CodeStaleByGit = "doc.stale_by_git"
)

Git-history drift finding codes.

View Source
const SchemaSQL = `` /* 12317-byte string literal not displayed */

SchemaSQL is the complete current schema. Every statement uses CREATE ... IF NOT EXISTS so bootstrapSchema is idempotent — safe to call on every Open() whether the DB is brand new or already initialised.

Node kinds: document, heading, definition, tag (plus code_file when the code_doc pack is enabled). Edge kinds: contains, references, wikilinks_to, related_to, similar_to, tagged, embeds, links_external. related_to is a recognized reference edge — graph traversal, search ranking, and the drift audits all query it alongside references/wikilinks_to/embeds — but the current parser/resolver never EMITS one: a frontmatter related_to: field resolves into wikilinks_to. So normal indexing produces zero related_to edges; they exist only if inserted directly.

Variables

This section is empty.

Functions

func IsGovernanceEmpty added in v0.2.0

func IsGovernanceEmpty(r *GovernanceRecord) bool

IsGovernanceEmpty reports whether a GovernanceRecord has any non-empty fields.

func IsResearchEmpty added in v0.2.0

func IsResearchEmpty(r *ResearchRecord) bool

IsResearchEmpty reports whether a ResearchRecord has any non-empty fields.

func ReadSectionContent

func ReadSectionContent(filePath string, startLine, endLine int, projectRoot string, maxBytes int) (string, error)

ReadSectionContent reads the content of a section from its source file. filePath is relative to projectRoot. startLine and endLine are 1-based. If the result exceeds maxBytes, it is truncated with a marker.

Types

type AISummary added in v0.2.2

type AISummary struct {
	NodeID      string
	Summary     string
	ModelID     string
	AgentID     string
	RunID       string
	ContentHash string
	UpdatedAt   int64
}

AISummary stores the agent-authored summary for a document and the content hash it was derived from.

type AgentEnrichment added in v0.2.2

type AgentEnrichment struct {
	DocID       string
	Summary     string
	Provider    string
	ModelID     string
	AgentID     string
	ContentHash string
	Metadata    []MetadataTuple
}

AgentEnrichment is the write payload for agent-inferred metadata. Metadata sources are forced to agent_inferred so the audit trail is explicit.

type AgentEnrichmentRun added in v0.2.2

type AgentEnrichmentRun struct {
	RunID        string
	NodeID       string
	Provider     string
	ModelID      string
	AgentID      string
	ContentHash  string
	SummaryHash  string
	MetadataHash string
	CreatedAt    int64
}

AgentEnrichmentRun records one external model processing event. Runs are an append-only provenance ledger; the active summary/metadata remains a single current view to avoid mixing model outputs in normal retrieval.

type DomainPackStats added in v0.2.0

type DomainPackStats struct {
	TotalPacks    int
	EnabledPacks  int
	TotalFields   int
	BuiltInPacks  int
	OptionalPacks int
}

DomainPackStats reports the loaded pack surface for status output.

type DriftAuditOpts added in v0.2.0

type DriftAuditOpts struct {
	// SimilarityMin is the minimum similar_to edge score for duplicate and
	// conflict detection. Default 0.75. Must be in (0, 1].
	SimilarityMin float64
	// Limit caps the total findings returned across all finding types.
	// Default 100.
	Limit int
	// AsOf is the reference date for stale-review and overdue checks.
	// Default time.Now().UTC().
	AsOf time.Time
	// UnverifiedAfterDays is the age threshold in days for the
	// research.unverified_evidence check. A research document whose
	// last_verified date is older than AsOf minus this many days is flagged.
	// Default 180.
	UnverifiedAfterDays int
	// StaleByGitAfterDays is the age threshold in days for the doc.stale_by_git
	// check. A document whose git last_commit_at is older than AsOf minus this
	// many days is flagged. Default 365. Has no effect when file_history is
	// empty (non-git corpus or --no-history).
	StaleByGitAfterDays int
}

DriftAuditOpts configures a drift audit query. Zero value is safe to use; defaults are applied inside GetDriftFindings before any sub-query runs.

type DriftAuditStats added in v0.2.0

type DriftAuditStats struct {
	TotalFindings int
	BySeverity    map[string]int
	ByCode        map[string]int
}

DriftAuditStats summarizes findings by code for docgraph_status and drift_audit format.

func SummarizeDriftFindings added in v0.2.0

func SummarizeDriftFindings(findings []DriftFinding) DriftAuditStats

SummarizeDriftFindings produces a summary for status and format output.

type DriftFinding added in v0.2.0

type DriftFinding struct {
	Code          string // stable dotted code, e.g. "policy.stale_review"
	NodeID        string
	FilePath      string
	RelatedNodeID string // "" when not applicable
	RelatedPath   string // "" when not applicable
	Severity      string // "error" | "warning" | "info"
	Message       string
	Evidence      string // brief supporting detail
	Remediation   string // actionable fix; "" when none applies
}

DriftFinding is an advisory finding produced by a drift audit query. Code values use dotted namespace prefixes (e.g. "policy.*", "research.*") so future packs can extend the namespace without collision. Messages are human-facing and may change; Code values are stable API.

type Edge

type Edge struct {
	Source   string
	Target   string
	Kind     string
	Metadata string
	Line     int
}

type Embedding added in v0.2.0

type Embedding struct {
	DocID       string
	ModelID     string
	Dim         int
	Vector      []float64
	ContentHash string
	UpdatedAt   int64
}

type EmbeddingModelStat added in v0.2.0

type EmbeddingModelStat struct {
	ModelID string
	Total   int
	Stale   int
}

type EnrichmentCandidate added in v0.2.2

type EnrichmentCandidate struct {
	DocID          string
	FilePath       string
	Name           string
	StartLine      int
	EndLine        int
	BodyExcerpt    string
	ContentHash    string
	HasFrontmatter bool
}

EnrichmentCandidate is a document that can be sent to an agent for inferred summary and metadata generation. It only includes documents that lack frontmatter, because human-authored metadata remains the authoritative path.

type EnrichmentStats added in v0.2.2

type EnrichmentStats struct {
	EligibleDocs int
	EnrichedDocs int
	StaleDocs    int
}

EnrichmentStats reports the state of agent-driven metadata enrichment.

type Entity added in v0.2.0

type Entity struct {
	ID                      string
	EntityType              string // pack vocab value or "" for generic
	CanonicalName           string
	CanonicalNameNormalized string            // lowercase trimmed; used for UNIQUE dedup
	Aliases                 []string          // JSON array, capped at MaxEntityAliases entries
	Properties              map[string]string // JSON object, pack-defined
	PackID                  string            // "" = generic
	UpdatedAt               int64
}

Entity is a canonical entity or source node. UUID PK is never changed on upsert so FK references in entity_mentions stay stable.

type EntitySearchOptions added in v0.2.0

type EntitySearchOptions struct {
	EntityType string
	EntityID   string
}

EntitySearchOptions carries entity/source graph filter constraints. Empty fields are ignored so existing callers keep their default behavior.

type FileHistory added in v0.2.0

type FileHistory struct {
	Path          string
	CommitCount   int
	FirstCommitAt int64
	LastCommitAt  int64
	AuthorCount   int
	LastAuthor    string
	LastSubject   string
}

type FileInfo

type FileInfo struct {
	Path           string
	ContentHash    string
	Size           int64
	ModifiedAt     int64
	IndexedAt      int64
	NodeCount      int
	HasFrontmatter bool
	Errors         string
}

type GovernanceRecord added in v0.2.0

type GovernanceRecord struct {
	NodeID          string
	Status          string
	Owner           string
	Approver        string
	Department      string
	EffectiveDate   string
	ReviewDue       string
	Supersedes      string
	SupersededBy    string
	Sensitivity     string
	AllowedAudience string
	CanonicalSource string
	UpdatedAt       int64
}

GovernanceRecord is the typed projection of governance fields for a document node.

type GovernanceSearchOptions added in v0.2.0

type GovernanceSearchOptions struct {
	Status          string
	Sensitivity     string
	CanonicalSource string
	AllowedAudience string
	AsOfDate        string
}

GovernanceSearchOptions carries governance retrieval constraints. Empty fields are ignored so existing callers keep their default behavior while newer tools can opt into policy-aware filtering without adding a top-level MCP tool.

type Mention added in v0.2.0

type Mention struct {
	EntityID    string
	NodeID      string
	FilePath    string
	Line        int
	Context     string // ≤ MaxMentionContextLen chars
	MentionType string // "reference" | "definition" | "wikilink"
	UpdatedAt   int64
}

Mention records one document/section reference to an entity.

type MetadataQualityIssue added in v0.2.0

type MetadataQualityIssue struct {
	Code        string
	Severity    string
	Message     string
	Penalty     int
	Remediation string // actionable fix; "" when none applies
}

MetadataQualityIssue describes one advisory quality finding for a document. Codes are stable machine-readable anchors for future audit packs; messages are human-facing summaries and may evolve without changing the code.

type MetadataQualityRecord added in v0.2.0

type MetadataQualityRecord struct {
	NodeID             string
	Score              int
	Level              string
	Issues             []MetadataQualityIssue
	IncomingReferences int
	OutgoingReferences int
	AsOf               string
}

MetadataQualityRecord is an advisory score derived from explicit metadata and graph structure. The score is not an authority decision; it highlights review gaps that governance or research audit packs can inspect later.

type MetadataQualityStats added in v0.2.0

type MetadataQualityStats struct {
	TotalDocs    int
	AverageScore float64
	GoodDocs     int
	WarningDocs  int
	PoorDocs     int
	IssueCounts  map[string]int
}

MetadataQualityStats summarizes advisory quality across document nodes.

type MetadataStats added in v0.2.0

type MetadataStats struct {
	TotalDocs        int
	DocsWithMetadata int
	DocsWithResearch int
}

MetadataStats reports aggregate metadata index state for docgraph_status.

type MetadataTuple added in v0.2.0

type MetadataTuple struct {
	Key        string
	Value      string
	ValueType  string
	Source     string
	Confidence *float64
}

MetadataTuple is a normalized key/value pair extracted from a document. source must be one of the application-level validSources values. value_type must be one of: "string", "number", "date", "bool", "list", "ref". list values are JSON-encoded arrays. Confidence is only set for skill_advisory/derived.

type Node

type Node struct {
	ID            string
	Kind          string
	Name          string
	QualifiedName string
	FilePath      string
	// ProjectName is runtime-only workspace context. It is not persisted in SQLite.
	ProjectName string
	StartLine   int
	EndLine     int
	Level       int
	Metadata    string
	BodyExcerpt string
	UpdatedAt   int64
}

type PendingDoc added in v0.2.0

type PendingDoc struct {
	DocID       string
	FilePath    string
	Name        string
	StartLine   int
	EndLine     int
	BodyExcerpt string
	ContentHash string
}

PendingDoc is a document that lacks an up-to-date embedding for a model.

type ResearchRecord added in v0.2.0

type ResearchRecord struct {
	NodeID         string
	ClaimID        string
	Evidence       string
	SourceType     string
	Confidence     string
	EventDate      string
	AssessmentDate string
	LastVerified   string
	ValidUntil     string
	AnalystStatus  string
	Client         string
	DeliverableID  string
	UpdatedAt      int64
}

ResearchRecord is the typed projection of research provenance fields for a document node.

type ResearchSearchOptions added in v0.2.0

type ResearchSearchOptions struct {
	ClaimID       string
	SourceType    string
	Confidence    string
	AnalystStatus string
}

ResearchSearchOptions carries research provenance constraints. These fields intentionally mirror the typed projection columns so future domain packs can map their own fields into the same retrieval policy layer.

type SearchIntent added in v0.2.0

type SearchIntent string

SearchIntent records the local routing decision used by SearchWithOptions. The intent is advisory: it selects candidate modules and boosts, but it does not change the stable public Search(query, kind, limit) contract.

const (
	SearchIntentTopic   SearchIntent = "topic"
	SearchIntentExact   SearchIntent = "exact"
	SearchIntentSection SearchIntent = "section"
)

type SearchOptions added in v0.2.0

type SearchOptions struct {
	Query string
	Kind  string
	Limit int
	// IncludeCode opts code_doc-pack results back in. Default false:
	// docgraph_search returns documentation only, so an enabled code_doc pack
	// does not flood doc queries with .go internals. The filter excludes any
	// node whose file is a code_file — the file-level code_file node AND its
	// kind="heading" children (test funcs, doc comments) — since kind alone
	// cannot tell a code heading from a markdown heading. It is a no-op when
	// the pack is off. Passing Kind == "code_file" implies IncludeCode (see
	// newSearchRequest), otherwise that filter would null out the request.
	IncludeCode bool
	Intent      SearchIntent
	Governance  GovernanceSearchOptions
	Research    ResearchSearchOptions
	Entity      EntitySearchOptions
	// ProjectFilter scopes workspace fan-out to a single project (directory name).
	// Empty means query all projects. No-op in single-store mode.
	ProjectFilter string
}

SearchOptions keeps search quality upgrades extensible without adding new MCP tools. Governance, research, and entity filters are additive optional constraints.

func (SearchOptions) HasMetadataFilters added in v0.2.0

func (opts SearchOptions) HasMetadataFilters() bool

HasMetadataFilters reports whether SearchWithOptions must enforce typed governance/research metadata constraints in addition to relevance ranking. Entity filters are handled separately by collectEntityFilteredCandidates and must NOT set this flag — they use a different collection path.

type SearchResult

type SearchResult struct {
	Node Node
	Rank float64
}

type SectionChunk added in v0.2.0

type SectionChunk struct {
	NodeID      string
	FilePath    string
	StartLine   int
	EndLine     int
	ContentHash string // file-level SHA-256 at index time
	SectionHash string // SHA-256 of section text; drift/diff primitive
	HeadingPath string // breadcrumb "Parent > Child"; "" for document nodes
	Text        string // bounded section content (≤ 10KB)
}

SectionChunk is an indexed snapshot of a section's content captured at index time. It backs reads and diffs without live file I/O, eliminating the TOCTOU race on line ranges.

start_line and end_line are -1 for non-line-based sources.

type Stats

type Stats struct {
	FileCount       int
	NodeCount       int
	EdgeCount       int
	UnresolvedCount int
	DBSizeBytes     int64
	NodesByKind     map[string]int
	EdgesByKind     map[string]int
}

type Store

type Store struct {
	Entity   *entityStore // entity graph: entities + entity_mentions
	Searcher *searchStore // search/retrieval: FTS, LIKE, ranking, metadata filters
	Fts      *ftsStore    // FTS5 index lifecycle: empty-probes, triggers, rebuild
	// contains filtered or unexported fields
}

func Open

func Open(dbPath string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteAllUnresolvedRefs

func (s *Store) DeleteAllUnresolvedRefs() error

func (*Store) DeleteDocumentMetadataByFile added in v0.2.0

func (s *Store) DeleteDocumentMetadataByFile(filePath string) error

DeleteDocumentMetadataByFile removes normalized metadata and typed projections for nodes belonging to the given file path. Called before re-indexing a file to ensure a clean slate.

func (*Store) DeleteEdgesByKind

func (s *Store) DeleteEdgesByKind(kind string) error

func (*Store) DeleteEmbeddingsByModel added in v0.2.0

func (s *Store) DeleteEmbeddingsByModel(modelID string) (int64, error)

func (*Store) DeleteEntityData added in v0.2.0

func (s *Store) DeleteEntityData(filePath string) error

DeleteEntityData removes all entity mentions for filePath, then prunes orphans.

func (*Store) DeleteFileData

func (s *Store) DeleteFileData(filePath string) error

func (*Store) DeleteFilesByNodeKind added in v0.2.0

func (s *Store) DeleteFilesByNodeKind(kind string) (int, error)

DeleteFilesByNodeKind removes all files whose document node has the given kind. This is used when disabling opt-in indexed surfaces, such as code_doc, so stale nodes and section chunks do not remain searchable after the pack is turned off.

func (*Store) DeleteNeuralSimilarityEdgesByModel added in v0.2.0

func (s *Store) DeleteNeuralSimilarityEdgesByModel(modelID string) (int64, error)

func (*Store) DeleteNeuralSimilarityEdgesForDoc added in v0.2.0

func (s *Store) DeleteNeuralSimilarityEdgesForDoc(docID string) error

func (*Store) DeleteSectionChunksByFile added in v0.2.0

func (s *Store) DeleteSectionChunksByFile(filePath string) error

DeleteSectionChunksByFile removes all chunks for a file path (called before reindexing a file).

func (*Store) DeleteSimilarityEdgesForDocs added in v0.2.0

func (s *Store) DeleteSimilarityEdgesForDocs(nodeIDs []string) error

DeleteSimilarityEdgesForDocs removes similar_to edges where source or target is in nodeIDs. Used by incremental similarity to clear stale edges before recomputing only the affected pairs.

func (*Store) FindNodeByName

func (s *Store) FindNodeByName(name string) (*Node, error)

func (*Store) FindNodeByPath

func (s *Store) FindNodeByPath(path string) (*Node, error)

func (*Store) GetAISummary added in v0.2.2

func (s *Store) GetAISummary(nodeID string) (*AISummary, error)

GetAISummary returns an agent-authored summary for a document, when present.

func (*Store) GetAgentEnrichmentRuns added in v0.2.2

func (s *Store) GetAgentEnrichmentRuns(nodeID string) ([]AgentEnrichmentRun, error)

GetAgentEnrichmentRuns returns the append-only processing history for a document. Normal retrieval uses only agent_enrichment_current; this method is for audit surfaces and tests that need model lineage.

func (*Store) GetAllDocumentIDs

func (s *Store) GetAllDocumentIDs() ([]string, error)

func (*Store) GetAllDocumentNodes

func (s *Store) GetAllDocumentNodes() ([]Node, error)

func (*Store) GetAllTags added in v0.2.0

func (s *Store) GetAllTags() ([]TagCount, error)

GetAllTags returns all tag names with the count of documents that use them, ordered by count descending then name ascending.

func (*Store) GetChildHeadings

func (s *Store) GetChildHeadings(docFilePath string) ([]Node, error)

func (*Store) GetDocumentMetadata added in v0.2.0

func (s *Store) GetDocumentMetadata(nodeID string) ([]MetadataTuple, error)

GetDocumentMetadata returns all metadata tuples for a node (all sources coexist).

func (*Store) GetDocumentsByTag added in v0.2.0

func (s *Store) GetDocumentsByTag(tagName string) ([]Node, error)

GetDocumentsByTag returns all document nodes that are tagged with the given tag name (case-insensitive). Results are ordered by file path.

func (*Store) GetDomainPackStats added in v0.2.0

func (s *Store) GetDomainPackStats() (DomainPackStats, error)

GetDomainPackStats returns aggregate pack counts.

func (*Store) GetDomainPacks added in v0.2.0

func (s *Store) GetDomainPacks() ([]domainpacks.Pack, error)

GetDomainPacks returns all persisted pack definitions with fields attached.

func (*Store) GetDriftFindings added in v0.2.0

func (s *Store) GetDriftFindings(opts DriftAuditOpts) ([]DriftFinding, error)

GetDriftFindings runs the policy/process drift audit and returns advisory findings. Computation is on-demand; no schema migration is required. The findings are not authoritative — they highlight candidates for human review.

func (*Store) GetEdgesBySource

func (s *Store) GetEdgesBySource(sourceID string) ([]Edge, error)

func (*Store) GetEmbedding added in v0.2.0

func (s *Store) GetEmbedding(docID, modelID string) (*Embedding, error)

func (*Store) GetEmbeddingModelStats added in v0.2.0

func (s *Store) GetEmbeddingModelStats() ([]EmbeddingModelStat, error)

func (*Store) GetEmbeddingsByModel added in v0.2.0

func (s *Store) GetEmbeddingsByModel(modelID string) ([]Embedding, error)

func (*Store) GetEnrichmentStats added in v0.2.2

func (s *Store) GetEnrichmentStats() (EnrichmentStats, error)

GetEnrichmentStats returns aggregate counts for docgraph_status.

func (*Store) GetFileHash

func (s *Store) GetFileHash(path string) (string, error)

func (*Store) GetFileHistory added in v0.2.0

func (s *Store) GetFileHistory(path string) (*FileHistory, error)

func (*Store) GetFiles

func (s *Store) GetFiles(pathFilter string) ([]FileInfo, error)

func (*Store) GetGovernanceMetadata added in v0.2.0

func (s *Store) GetGovernanceMetadata(nodeID string) (*GovernanceRecord, error)

GetGovernanceMetadata returns the typed governance projection for a node. Returns nil, nil when no governance data exists.

func (*Store) GetIncomingEdges

func (s *Store) GetIncomingEdges(nodeID string) ([]Edge, error)

func (*Store) GetIncomingEdgesBatch added in v0.3.0

func (s *Store) GetIncomingEdgesBatch(nodeIDs []string) (map[string][]Edge, error)

GetIncomingEdgesBatch returns incoming edges for many nodeIDs in one call. Returns map[nodeID][]Edge where each slice is in SQL result-row order. Invariant: the impact BFS queues only document-node IDs; each document maps to exactly one file_path. If that invariant ever breaks, doc-branch results would be silently merged for nodes sharing a file_path.

func (*Store) GetMetadataQuality added in v0.2.0

func (s *Store) GetMetadataQuality(nodeID string, asOf time.Time) (*MetadataQualityRecord, error)

GetMetadataQuality evaluates one document or section against metadata quality signals. Section IDs are resolved to their owning document so callers can use this from search, node, context, or future audit workflows.

func (*Store) GetMetadataQualityStats added in v0.2.0

func (s *Store) GetMetadataQualityStats(asOf time.Time) (MetadataQualityStats, error)

GetMetadataQualityStats evaluates all document nodes for docgraph_status.

func (*Store) GetMetadataStats added in v0.2.0

func (s *Store) GetMetadataStats() (MetadataStats, error)

GetMetadataStats returns counts used by docgraph_status.

func (*Store) GetNodeByID

func (s *Store) GetNodeByID(id string) (*Node, error)

func (*Store) GetNodesByFile

func (s *Store) GetNodesByFile(filePath string) ([]Node, error)

func (*Store) GetNodesByIDs added in v0.3.0

func (s *Store) GetNodesByIDs(ids []string) (map[string]*Node, error)

GetNodesByIDs loads nodes for many IDs in one query. Missing IDs are absent from the map.

func (*Store) GetOutgoingEdges

func (s *Store) GetOutgoingEdges(nodeID string) ([]Edge, error)

func (*Store) GetPendingEmbeddings added in v0.2.0

func (s *Store) GetPendingEmbeddings(modelID string, limit int) ([]PendingDoc, error)

GetPendingEmbeddings returns documents that have no embedding for modelID, or whose stored content_hash differs from the current files.content_hash.

func (*Store) GetPendingEnrichments added in v0.2.2

func (s *Store) GetPendingEnrichments(limit int) ([]EnrichmentCandidate, error)

GetPendingEnrichments returns frontmatter-less documents whose inferred summary is missing or stale for the current file content hash.

func (*Store) GetProjectMeta added in v0.2.0

func (s *Store) GetProjectMeta(key string) (string, bool, error)

func (*Store) GetResearchMetadata added in v0.2.0

func (s *Store) GetResearchMetadata(nodeID string) (*ResearchRecord, error)

GetResearchMetadata returns the typed research provenance projection for a node. Returns nil, nil when no research data exists.

func (Store) GetSectionChunk added in v0.2.0

func (b Store) GetSectionChunk(nodeID string) (*SectionChunk, bool, error)

GetSectionChunk retrieves the indexed snapshot for a node. Returns (nil, false, nil) if not found. Lives on baseDB (not *Store): it is a shared content read that searchStore needs directly, and it stays promoted to *Store via the embedded *baseDB so existing st.GetSectionChunk callers are unaffected.

func (*Store) GetSimilarEdgesForDoc added in v0.2.0

func (s *Store) GetSimilarEdgesForDoc(docID string) ([]Edge, error)

GetSimilarEdgesForDoc returns all similar_to edges where source or target equals docID.

func (*Store) GetStats

func (s *Store) GetStats() (Stats, error)

func (*Store) GetTopLevelDirs added in v0.3.0

func (s *Store) GetTopLevelDirs() ([]string, error)

GetTopLevelDirs returns the deduplicated, sorted list of first path segments found in the files table. Files stored at the repo root (no slash in the path) yield an empty segment and are excluded. The result is suitable for surfacing as "known indexed directories" when a path-filtered query returns zero results.

func (*Store) GetUnresolvedRefs

func (s *Store) GetUnresolvedRefs() ([]UnresolvedRef, error)

func (*Store) InsertDocumentMetadata added in v0.2.0

func (s *Store) InsertDocumentMetadata(nodeID string, tuples []MetadataTuple) error

InsertDocumentMetadata upserts normalized metadata tuples for a document node. It is an audit-trail insert: all (node_id, key, source) triples coexist as separate rows. Authority ordering is NOT enforced here — it is applied at projection time in UpsertGovernanceMetadata. Source enum is validated; invalid values return an error. Cap: at most 200 tuples (defence-in-depth; parser is the primary enforcement point).

func (*Store) InsertEdges

func (s *Store) InsertEdges(edges []Edge) error

func (*Store) InsertEntities added in v0.2.0

func (s *Store) InsertEntities(entities []Entity) error

InsertEntities upserts entities by (entity_type, canonical_name_normalized).

func (*Store) InsertEntityMentions added in v0.2.0

func (s *Store) InsertEntityMentions(mentions []Mention) error

InsertEntityMentions inserts mentions, ignoring duplicates on (entity_id, node_id, line).

func (*Store) InsertNodes

func (s *Store) InsertNodes(nodes []Node) error

func (*Store) InsertUnresolvedRefs

func (s *Store) InsertUnresolvedRefs(refs []UnresolvedRef) error

func (*Store) IsPackEnabled added in v0.2.0

func (s *Store) IsPackEnabled(packID string) (bool, error)

IsPackEnabled reports whether the domain pack with the given ID is enabled in SQLite. Returns false (not an error) if the pack does not yet exist in the table.

func (*Store) LockIndex added in v0.3.2

func (s *Store) LockIndex()

LockIndex acquires the index mutex, serialising index/reindex on this store.

func (*Store) NodesIsEmpty added in v0.3.0

func (s *Store) NodesIsEmpty() (bool, error)

NodesIsEmpty reports whether the nodes base table has no rows — i.e. this index run started against a fresh/cold DB. Callers use it to skip the eager per-file stale-row delete block on a cold-start, where every DELETE matches 0 rows and is a true no-op (no rows → no FK cascade → no AFTER DELETE trigger). See the call site for why an empty nodes table implies the delete targets are empty too. EXISTS short-circuits on the first row, so it stays O(1) on a populated DB.

func (*Store) PruneOrphanEntities added in v0.2.0

func (s *Store) PruneOrphanEntities() error

PruneOrphanEntities deletes entities with no remaining entity_mentions rows.

func (*Store) RefreshMetadataProjections added in v0.2.2

func (s *Store) RefreshMetadataProjections(nodeID string) error

RefreshMetadataProjections recomputes typed metadata from all persisted document_metadata rows. This is required for agent writes because inferred metadata arrives after indexing and must not overwrite higher-authority rows.

func (*Store) SetPackEnabled added in v0.2.0

func (s *Store) SetPackEnabled(packID string, enabled bool) error

SetPackEnabled updates the persisted enabled state for a domain pack. The pack must already be registered in domain_packs; Store.Open syncs process-registered packs before callers can reach this method.

func (*Store) SyncDomainPacks added in v0.2.0

func (s *Store) SyncDomainPacks(packs []domainpacks.Pack) error

SyncDomainPacks persists process-registered pack definitions into SQLite. Existing enabled flags are preserved so a future CLI can disable a pack without that choice being overwritten on every process start.

func (*Store) UnlockIndex added in v0.3.2

func (s *Store) UnlockIndex()

UnlockIndex releases the index mutex acquired by LockIndex.

func (*Store) UpsertAgentEnrichment added in v0.2.2

func (s *Store) UpsertAgentEnrichment(e AgentEnrichment) error

UpsertAgentEnrichment stores a summary and normalized metadata inferred by an external agent. content_hash is checked before every write so stale agent output cannot be applied after the source document changes.

func (*Store) UpsertEmbedding added in v0.2.0

func (s *Store) UpsertEmbedding(e Embedding) error

func (*Store) UpsertFile

func (s *Store) UpsertFile(f FileInfo) error

func (*Store) UpsertFileHistory added in v0.2.0

func (s *Store) UpsertFileHistory(h FileHistory) error

func (*Store) UpsertGovernanceMetadata added in v0.2.0

func (s *Store) UpsertGovernanceMetadata(nodeID string, tuples []MetadataTuple) error

UpsertGovernanceMetadata projects governance keys from tuples into governance_metadata, applying authority ordering: highest-priority source per key wins; on ties, newer updated_at. Called after InsertDocumentMetadata during indexing.

func (*Store) UpsertProjectMeta added in v0.2.0

func (s *Store) UpsertProjectMeta(key, value string) error

func (*Store) UpsertResearchMetadata added in v0.2.0

func (s *Store) UpsertResearchMetadata(nodeID string, tuples []MetadataTuple) error

UpsertResearchMetadata projects research provenance keys from tuples into research_metadata, applying the same source authority ordering as governance metadata.

func (*Store) UpsertSectionChunks added in v0.2.0

func (s *Store) UpsertSectionChunks(chunks []SectionChunk) error

UpsertSectionChunks inserts or replaces all chunks in a single transaction.

type TagCount added in v0.2.0

type TagCount struct {
	Name  string
	Count int
}

type UnresolvedRef

type UnresolvedRef struct {
	FromNodeID    string
	ReferenceText string
	ReferenceKind string
	Line          int
	Col           int
	FilePath      string
}

Jump to

Keyboard shortcuts

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