Documentation
¶
Index ¶
- Constants
- Variables
- func AdmitSource(observation SourceObservation, budget IndexBudget, usage AdmissionUsage) (SourceAdmission, AdmissionUsage, error)
- func ExtractGoSignatures(projectRoot, relPath string) (map[int]map[string]string, error)
- func ExtractGoSignaturesFromSource(source AdmittedSource) (map[int]map[string]string, error)
- func ExtractGoSignaturesWithLocals(projectRoot, relPath string, facts TypeFacts) (map[int]map[string]string, error)
- func ExtractGoSignaturesWithLocalsFromSource(source AdmittedSource, facts TypeFacts) (map[int]map[string]string, error)
- func FormatCoverageCockpitSummary(report *CoverageReport) string
- func FormatCoverageResponse(report *CoverageReport) string
- func FormatCoverageSummary(report *CoverageReport) string
- func FormatSymbolDrift(drifts []SymbolDrift) string
- func InferLocalVarTypes(fn *ast.FuncDecl, base map[string]string, facts TypeFacts) map[string]string
- func IsDatabaseIntegrityFailure(err error) bool
- func IsExcludedDir(name string) bool
- func LanguageForPath(relPath string) (string, bool)
- func NodeID(filePath, name string, startLine int) string
- func PartitionEdgeResolutions(outcomes []EdgeResolution) ([]CodeEdge, []ResolutionDiagnostic)
- func RenderRepoMap(rm *RepoMap, maxTokens int) string
- func Satisfies(typeMethods map[string]bool, iface InterfaceDef) bool
- func SliceBody(content []byte, sym CodeSymbol) ([]byte, bool)
- func TypeMethodSets(syms []CodeSymbol) map[string]map[string]bool
- func VerifyBody(content []byte, sym CodeSymbol) (body []byte, fresh bool)
- type AdmissionUsage
- type AdmittedSource
- type AmbiguousEdge
- type BindingLanguageSupport
- type ByteCount
- type CCppLang
- type CallSite
- type CodeEdge
- func ResolveConcreteMethodCallEdges(filePath string, fileSymbols []CodeSymbol, callSites []CallSite, ...) []CodeEdge
- func ResolveCrossFileCallEdges(filePath string, fileSymbols []CodeSymbol, callSites []CallSite, ...) []CodeEdge
- func ResolveEmbedsEdges(relPath string, fileSyms, pkgSyms []CodeSymbol, embeds []TypeEmbed) []CodeEdge
- func ResolveImplementsEdges(relPath string, fileSyms, pkgSyms []CodeSymbol, ...) []CodeEdge
- func ResolveInterfaceDispatchEdges(filePath string, fileSymbols []CodeSymbol, callSites []CallSite, ...) []CodeEdge
- func ResolveIntraPackageCallEdges(filePath string, fileSymbols, pkgSymbols []CodeSymbol, callSites []CallSite) []CodeEdge
- type CodeFileState
- type CodeImport
- type CodeSymbol
- type ConcernQuery
- func (q ConcernQuery) KindFilters() []string
- func (q ConcernQuery) LanguageFilters() []string
- func (q ConcernQuery) MarshalJSON() ([]byte, error)
- func (q ConcernQuery) NameFilters() []string
- func (q ConcernQuery) PathFilters() []string
- func (q ConcernQuery) Raw() string
- func (q ConcernQuery) Terms() []string
- type ConfidenceClass
- type CoverageReport
- type CoverageStatus
- type DiscoveryBudget
- type EdgeKind
- type EdgeOrigin
- type EdgeOutcomeResolver
- type EdgeResolution
- type EdgeResolver
- type EdgeStore
- func (e *EdgeStore) AllEdges(ctx context.Context) ([]CodeEdge, error)
- func (e *EdgeStore) DiagnosticsByFile(ctx context.Context, filePath string) ([]ResolutionDiagnostic, error)
- func (e *EdgeStore) EnsureSchema(ctx context.Context) error
- func (e *EdgeStore) InEdges(ctx context.Context, dstID string) ([]CodeEdge, error)
- func (e *EdgeStore) OutEdges(ctx context.Context, srcID string) ([]CodeEdge, error)
- func (e *EdgeStore) ReplaceFileEdges(ctx context.Context, filePath string, edges []CodeEdge) error
- func (e *EdgeStore) ReplaceFileResolutions(ctx context.Context, filePath string, outcomes []EdgeResolution) error
- func (e *EdgeStore) ResolutionCountsForSource(ctx context.Context, sourceID string) (ResolutionCounts, error)
- type FileBindingSupport
- type FileCount
- type FileDecisionLinkGap
- type FileGapIndexState
- type FileGapProjection
- type FileIndexDisposition
- func NewDegradedFileDisposition(reason string) (FileIndexDisposition, error)
- func NewEmptyFileDisposition() FileIndexDisposition
- func NewIndexedFileDisposition(symbols FileCount) (FileIndexDisposition, error)
- func NewSkippedFileDisposition(reason SourceSkipReason) (FileIndexDisposition, error)
- func ParsePersistedFileIndexDisposition(status string, symbolCount int64) (FileIndexDisposition, error)
- type FileIndexDispositionKind
- type FileIndexFailure
- type FileSymbols
- type GeneratedSourcePolicy
- type GoImport
- type GoLang
- func (g *GoLang) DetectModules(projectRoot string) ([]Module, error)
- func (g *GoLang) Extensions() []string
- func (g *GoLang) Language() string
- func (g *GoLang) ParseImports(source AdmittedSource, projectRoot string) ([]ImportEdge, error)
- func (g *GoLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]EdgeResolution, error)
- func (g *GoLang) ResolveAdmittedFileEdges(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]CodeEdge, error)
- func (g *GoLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
- type IgnoreChecker
- type ImportEdge
- type ImportParser
- type IndexBasisSnapshot
- type IndexBudget
- type IndexBudgetSpec
- type IndexCoverageSnapshot
- type IndexDelta
- type IndexEpochCandidate
- type IndexExclusionSnapshot
- type IndexFreshnessObservation
- type IndexRefreshMetrics
- type IndexRefreshResult
- type IndexState
- type InterfaceDef
- type JSTSLang
- func (j *JSTSLang) DetectModules(projectRoot string) ([]Module, error)
- func (j *JSTSLang) Extensions() []string
- func (j *JSTSLang) ExtractSymbolSnapshots(source AdmittedSource) ([]SymbolSnapshot, error)
- func (j *JSTSLang) ExtractSymbolSnapshotsContext(ctx gocontext.Context, source AdmittedSource) ([]SymbolSnapshot, error)
- func (j *JSTSLang) Language() string
- func (j *JSTSLang) ParseImports(source AdmittedSource, _ string) ([]ImportEdge, error)
- func (j *JSTSLang) ResolveAdmittedFileEdgeOutcomes(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]EdgeResolution, error)
- func (j *JSTSLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]EdgeResolution, error)
- func (j *JSTSLang) ResolveFileEdgeOutcomes(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]EdgeResolution, error)
- func (j *JSTSLang) ResolveFileEdgeOutcomesWithProjectSnapshot(ctx context.Context, projectRoot string, relPath string, symbols SymbolView, ...) ([]EdgeResolution, error)
- func (j *JSTSLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
- func (j *JSTSLang) SymbolLanguage(path string) string
- type LexicalTier
- type MatchField
- type MethodSig
- type Module
- type ModuleCoverage
- type ModuleDetector
- type ModuleGovernanceGap
- type ModuleImpactInfo
- type ProjectPath
- type Provenance
- type PythonLang
- func (p *PythonLang) DetectModules(projectRoot string) ([]Module, error)
- func (p *PythonLang) Extensions() []string
- func (p *PythonLang) Language() string
- func (p *PythonLang) ParseImports(source AdmittedSource, _ string) ([]ImportEdge, error)
- func (p *PythonLang) ResolveAdmittedFileEdges(ctx context.Context, _ string, source AdmittedSource, symbols SymbolView) ([]CodeEdge, error)
- func (p *PythonLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
- type Registry
- func (r *Registry) Detectors() []ModuleDetector
- func (r *Registry) ExtractAdmittedSymbolSnapshots(source AdmittedSource) ([]SymbolSnapshot, error)
- func (r *Registry) ExtractAdmittedSymbolSnapshotsContext(ctx context.Context, source AdmittedSource) ([]SymbolSnapshot, error)
- func (r *Registry) ExtractSymbolSnapshots(projectRoot string, relPath string) ([]SymbolSnapshot, error)
- func (r *Registry) ParserForFile(path string) ImportParser
- func (r *Registry) ReadAdmittedSource(projectRoot string, relPath string) (AdmittedSource, error)
- func (r *Registry) ReadSourceAdmission(projectRoot string, relPath string, budget IndexBudget, usage AdmissionUsage) (SourceAdmission, AdmissionUsage, error)
- func (r *Registry) ResolverForFile(path string) EdgeResolver
- func (r *Registry) SupportsSymbols(path string) bool
- func (r *Registry) SymbolAdapterForFile(path string) SymbolAdapter
- func (r *Registry) SymbolLanguageForFile(path string) (string, bool)
- type RepoMap
- type ResolutionCounts
- type ResolutionDiagnostic
- type ResolutionMethod
- type ResolutionReason
- type ResolutionStatus
- type ResolvedEdge
- type RustLang
- type Scanner
- func (s *Scanner) CurrentIndexState(ctx context.Context) (IndexState, error)
- func (s *Scanner) EnsureIncrementalSchema(ctx context.Context) error
- func (s *Scanner) EnsureIndexMetaSchema(ctx context.Context) error
- func (s *Scanner) GetDependents(ctx context.Context, moduleID string) ([]string, error)
- func (s *Scanner) GetModules(ctx context.Context) ([]Module, error)
- func (s *Scanner) ModulesLastScanned(ctx context.Context) time.Time
- func (s *Scanner) ObserveIndexFreshness(ctx context.Context, projectRoot string) (IndexFreshnessObservation, error)
- func (s *Scanner) RefreshIncremental(ctx context.Context, projectRoot string) (result IndexRefreshResult, resultErr error)
- func (s *Scanner) RequireDatabaseIntegrityForIndexRefresh(ctx context.Context) error
- func (s *Scanner) ResolveFileToModule(ctx context.Context, filePath string) (string, error)
- func (s *Scanner) ScanDependencies(ctx context.Context, projectRoot string) ([]ImportEdge, error)
- func (s *Scanner) ScanEdges(ctx context.Context, projectRoot string) (int, error)
- func (s *Scanner) ScanModules(ctx context.Context, projectRoot string) ([]Module, error)
- func (s *Scanner) ScanSymbols(ctx context.Context, projectRoot string) (int, error)
- func (s *Scanner) SetFingerprint(ctx context.Context, fp string) error
- func (s *Scanner) SourceFingerprint(projectRoot string) (string, error)
- func (s *Scanner) StoredFingerprint(ctx context.Context) (string, error)
- type SourceAdmission
- type SourceAdmissionKind
- type SourceClass
- type SourceLanguage
- type SourceObservation
- func NewContentObservation(path ProjectPath, language SourceLanguage, class SourceClass, content []byte) (SourceObservation, error)
- func NewMetadataObservation(path ProjectPath, language SourceLanguage, class SourceClass, ...) (SourceObservation, error)
- func ObserveSource(projectRoot string, path ProjectPath, language SourceLanguage, ...) (SourceObservation, error)
- type SourceSkipInfo
- type SourceSkipReason
- type SourceSkippedError
- type StableRangeSnapshot
- type Symbol
- type SymbolAdapter
- type SymbolAnchor
- type SymbolDiscoveryBatch
- func (b SymbolDiscoveryBatch) Budget() DiscoveryBudget
- func (b SymbolDiscoveryBatch) Candidates() []SymbolDiscoveryCandidate
- func (b SymbolDiscoveryBatch) Epoch() int64
- func (b SymbolDiscoveryBatch) Kind() SymbolDiscoveryKind
- func (b SymbolDiscoveryBatch) MarshalJSON() ([]byte, error)
- func (b SymbolDiscoveryBatch) Query() ConcernQuery
- type SymbolDiscoveryCandidate
- func (c SymbolDiscoveryCandidate) Coverage() TermCoverage
- func (c SymbolDiscoveryCandidate) Epoch() int64
- func (c SymbolDiscoveryCandidate) FieldCoverage() TermCoverage
- func (c SymbolDiscoveryCandidate) Lane() SymbolSourceLane
- func (c SymbolDiscoveryCandidate) MarshalJSON() ([]byte, error)
- func (c SymbolDiscoveryCandidate) Matches() []SymbolTermMatch
- func (c SymbolDiscoveryCandidate) Symbol() CodeSymbol
- func (c SymbolDiscoveryCandidate) Tier() LexicalTier
- type SymbolDiscoveryKind
- type SymbolDrift
- type SymbolRef
- type SymbolSnapshot
- type SymbolSourceLane
- type SymbolStore
- func (s *SymbolStore) AllSymbolRefs(ctx context.Context) ([]SymbolRef, error)
- func (s *SymbolStore) AllSymbols(ctx context.Context) ([]CodeSymbol, error)
- func (s *SymbolStore) DiscoverSymbols(ctx context.Context, query ConcernQuery, budget DiscoveryBudget, epoch int64) (SymbolDiscoveryBatch, error)
- func (s *SymbolStore) EnsureSchema(ctx context.Context) error
- func (s *SymbolStore) FileSymbolsStale(ctx context.Context, projectRoot, relPath string) (bool, error)
- func (s *SymbolStore) GetByDir(ctx context.Context, dir string) ([]CodeSymbol, error)
- func (s *SymbolStore) GetByFile(ctx context.Context, filePath string) ([]CodeSymbol, error)
- func (s *SymbolStore) GetByID(ctx context.Context, id string) (CodeSymbol, bool, error)
- func (s *SymbolStore) GetByIdentity(ctx context.Context, file, name string, startLine int) (CodeSymbol, bool, error)
- func (s *SymbolStore) GetByName(ctx context.Context, name string) ([]CodeSymbol, error)
- func (s *SymbolStore) IndexAdmittedFileSymbolsWithRegistry(ctx context.Context, source AdmittedSource, registry *Registry) error
- func (s *SymbolStore) IndexFileSymbols(ctx context.Context, projectRoot, relPath string) error
- func (s *SymbolStore) IndexFileSymbolsWithRegistry(ctx context.Context, projectRoot, relPath string, registry *Registry) error
- func (s *SymbolStore) RebuildSymbolSearchProjection(ctx context.Context, epoch int64) error
- func (s *SymbolStore) ReplaceFileSymbols(ctx context.Context, filePath string, syms []CodeSymbol) error
- func (s *SymbolStore) SearchSymbols(ctx context.Context, q string, limit int) ([]CodeSymbol, error)
- func (s *SymbolStore) SetSymbolSearchEpoch(ctx context.Context, epoch int64) error
- func (s *SymbolStore) SymbolSearchEpoch(ctx context.Context) (int64, error)
- type SymbolTermMatch
- type SymbolView
- type TermCoverage
- type TypeEmbed
- type TypeFacts
- type UnresolvedEdge
- type VueLang
- func (v *VueLang) Extensions() []string
- func (v *VueLang) ExtractSymbolSnapshots(source AdmittedSource) ([]SymbolSnapshot, error)
- func (v *VueLang) ExtractSymbolSnapshotsContext(ctx context.Context, source AdmittedSource) ([]SymbolSnapshot, error)
- func (v *VueLang) Language() string
- func (v *VueLang) ResolveAdmittedFileEdgeOutcomes(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]EdgeResolution, error)
- func (v *VueLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot(ctx context.Context, projectRoot string, source AdmittedSource, ...) ([]EdgeResolution, error)
- func (v *VueLang) ResolveFileEdgeOutcomes(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]EdgeResolution, error)
- func (v *VueLang) ResolveFileEdgeOutcomesWithProjectSnapshot(ctx context.Context, projectRoot string, relPath string, symbols SymbolView, ...) ([]EdgeResolution, error)
- func (v *VueLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
- func (v *VueLang) SymbolLanguage(string) string
- type VueParseStatus
- type WorkerCount
Constants ¶
const ( BindingSupportSymbols = "symbols_supported" BindingSupportRangeOnly = "range_only" BindingSupportUnsupportedLanguage = "unsupported_language" BindingSupportReadFailed = "read_failed" )
const ( CodeFileIndexed = "indexed" CodeFileEmpty = "empty" CodeFileDegraded = "degraded" CodeFileSkipped = "skipped" )
const ( IndexCoverageComplete = "complete" IndexCoverageBoundedWithExclusions = "bounded_with_exclusions" IndexCoverageLegacyUnknown = "legacy_unknown" )
const ( MaxConcernQueryBytes = 4096 MaxDiscoveryCandidates = 50 DiscoveryCandidates = "candidate_set" DiscoveryNoCandidates = "no_lexical_candidates" LexicalTierExactStableID = "L0_exact_stable_id" LexicalTierExactQualifiedName = "L1_exact_qualified_name" LexicalTierExactName = "L2_exact_name" LexicalTierAllTerms = "L3_all_terms" LexicalTierPartialTerms = "L4_partial_terms" LexicalTierEditDistance = "L5_edit_distance" SymbolLaneProduction = "production" SymbolLaneTest = "test" SymbolLaneGenerated = "generated" MatchFieldName = "name" MatchFieldQualifiedName = "qualified_name" MatchFieldReceiver = "receiver" MatchFieldKind = "kind" MatchFieldPath = "file_path" )
const ( VueParseIndexed = "indexed" VueParseEmpty = "empty" VueParseDegraded = "degraded" )
const CodeIndexSchemaVersion = 6
const SymbolAnchorVersion = 2
Variables ¶
var ErrDatabaseIntegrity = errors.New("project ledger database integrity failure")
ErrDatabaseIntegrity marks structural ledger damage. It is distinct from ordinary lock, cancellation, and transport failures: callers must not start expensive parser work or attempt schema repair after observing it.
var ErrSourceChanged = errors.New("source changed during bounded read")
Functions ¶
func AdmitSource ¶
func AdmitSource( observation SourceObservation, budget IndexBudget, usage AdmissionUsage, ) (SourceAdmission, AdmissionUsage, error)
AdmitSource is the pure source-admission core. It performs no filesystem, parser, database, or clock work.
func ExtractGoSignatures ¶
ExtractGoSignatures maps each func/method's start line to its receiver+param variable names → declared type name (the simple identifier; *T and pkg.T reduce to T). Uses go/ast for accurate types. This is the receiver-type inference that bounds dispatch precision: a call x.M() links through an interface only when x's DECLARED type is a known interface.
func ExtractGoSignaturesFromSource ¶
func ExtractGoSignaturesFromSource( source AdmittedSource, ) (map[int]map[string]string, error)
ExtractGoSignaturesFromSource derives declared signature variables from admitted bytes.
func ExtractGoSignaturesWithLocals ¶
func ExtractGoSignaturesWithLocals(projectRoot, relPath string, facts TypeFacts) (map[int]map[string]string, error)
ExtractGoSignaturesWithLocals additionally infers the types of LOCAL variables (`resolver := registry.ResolverForFile(path)`) via the package's TypeFacts, so interface dispatch resolves through `:=`-inferred receivers — not only the declared receiver/param ones. Same conservative discipline: an unresolvable local contributes no entry.
func ExtractGoSignaturesWithLocalsFromSource ¶
func ExtractGoSignaturesWithLocalsFromSource( source AdmittedSource, facts TypeFacts, ) (map[int]map[string]string, error)
ExtractGoSignaturesWithLocalsFromSource adds inferred locals while preserving the exact admitted parser input.
func FormatCoverageCockpitSummary ¶
func FormatCoverageCockpitSummary(report *CoverageReport) string
FormatCoverageCockpitSummary formats a one-cue coverage projection for the default status cockpit. Full coverage stays behind explicit drill-down calls.
func FormatCoverageResponse ¶
func FormatCoverageResponse(report *CoverageReport) string
FormatCoverageResponse formats the coverage report for MCP output.
func FormatCoverageSummary ¶
func FormatCoverageSummary(report *CoverageReport) string
FormatCoverageSummary formats a compact module coverage projection for default status output. The full module list remains available through FormatCoverageResponse and haft_query(action="status", full=true).
func FormatSymbolDrift ¶
func FormatSymbolDrift(drifts []SymbolDrift) string
FormatSymbolDrift renders drift report for display.
func InferLocalVarTypes ¶
func InferLocalVarTypes(fn *ast.FuncDecl, base map[string]string, facts TypeFacts) map[string]string
InferLocalVarTypes returns the variable→type map for a function body: the base (receiver + params) extended with locals whose RHS type resolves through the package's TypeFacts. Pure given (fn, base, facts).
Soundness over precision: the result is a FLAT per-function table, but Go has lexical scope, so a name can denote different types at different lines (inner- block shadowing, or a base param shadowed by a local). A flat table cannot say which type holds at a given call site — so the moment a name is bound to two DIFFERENT types, it is dropped entirely (marked ambiguous). Absent is safe; a wrong type would become a wrong dispatch edge. Only `:=` and `var` bind here; `=` cannot change a Go variable's type, so it is ignored.
func IsDatabaseIntegrityFailure ¶
IsDatabaseIntegrityFailure reports failures that prove SQLite cannot safely traverse the current ledger structure. Extended result codes are normalized to their primary code before classification.
func IsExcludedDir ¶
IsExcludedDir checks if a directory should be skipped during walking. Uses the IgnoreChecker if available, otherwise falls back to the dir name check.
func LanguageForPath ¶
func NodeID ¶
NodeID is the legacy line-based compatibility handle used by older tests and manually-constructed CodeSymbol values. Indexed symbols use SymbolAnchor v2.
func PartitionEdgeResolutions ¶
func PartitionEdgeResolutions(outcomes []EdgeResolution) ([]CodeEdge, []ResolutionDiagnostic)
PartitionEdgeResolutions is the pure admission boundary. Resolved edges flow into code traversal; every non-resolved outcome becomes an inspectable diagnostic and is inexpressible as a traversal edge.
func RenderRepoMap ¶
RenderRepoMap formats the repo map for injection into the system prompt. Shows directory tree with exported symbols, kinds, and line counts. Files sorted by modification time (recent first) for relevance. Respects a token budget (approximate: 4 chars ≈ 1 token).
func Satisfies ¶
func Satisfies(typeMethods map[string]bool, iface InterfaceDef) bool
Satisfies reports whether a concrete type's method-name set covers every method of the interface. Pure. Empty interfaces never satisfy (excluded).
func SliceBody ¶
func SliceBody(content []byte, sym CodeSymbol) ([]byte, bool)
SliceBody returns the byte-exact body of a symbol from file content. Pure; returns ok=false if the offsets don't fit the content (stale — caller must re-index before trusting source).
func TypeMethodSets ¶
func TypeMethodSets(syms []CodeSymbol) map[string]map[string]bool
TypeMethodSets groups concrete method names by receiver type, from symbols.
func VerifyBody ¶
func VerifyBody(content []byte, sym CodeSymbol) (body []byte, fresh bool)
VerifyBody slices the symbol's body from freshly-read content AND re-hashes it against the stored hash — the freshness guarantee for P3. fresh=true means the stored byte range still points at the exact same source on disk; false means the file was edited (offsets stale or content changed) and the caller must re-index before trusting the slice. Pure: the hash comparison, not a stored-hash-vs-stored-hash check, is what catches an actively-edited file.
Types ¶
type AdmissionUsage ¶
type AdmissionUsage struct {
// contains filtered or unexported fields
}
AdmissionUsage is immutable root-level source workload already observed far enough to reach a content or per-file-size disposition. Pre-classified unsupported, ignored, and excluded-generated paths do not consume it.
func EmptyAdmissionUsage ¶
func EmptyAdmissionUsage() AdmissionUsage
func (AdmissionUsage) Bytes ¶
func (u AdmissionUsage) Bytes() ByteCount
func (AdmissionUsage) Files ¶
func (u AdmissionUsage) Files() FileCount
type AdmittedSource ¶
type AdmittedSource struct {
// contains filtered or unexported fields
}
AdmittedSource is the only parser input. Its bytes and digest are private so production adapters cannot construct or mutate unaccounted parser input.
func AdmittedSourceFrom ¶
func AdmittedSourceFrom( admission SourceAdmission, ) (AdmittedSource, error)
func (AdmittedSource) ByteCount ¶
func (s AdmittedSource) ByteCount() ByteCount
func (AdmittedSource) Digest ¶
func (s AdmittedSource) Digest() string
func (AdmittedSource) Language ¶
func (s AdmittedSource) Language() SourceLanguage
func (AdmittedSource) Path ¶
func (s AdmittedSource) Path() ProjectPath
type AmbiguousEdge ¶
type AmbiguousEdge struct {
SourceID string
Kind EdgeKind
FilePath string
Line int
Reason ResolutionReason
CandidateIDs []string
Origin EdgeOrigin
ResolverVersion string
SourceSnapshotHash string
}
type BindingLanguageSupport ¶
type BindingLanguageSupport struct {
Language string `json:"language"`
Extensions []string `json:"extensions"`
SymbolExtraction bool `json:"symbol_extraction"`
RangeFallback bool `json:"range_fallback"`
}
func SupportedBindingLanguages ¶
func SupportedBindingLanguages() []BindingLanguageSupport
type ByteCount ¶
type ByteCount struct {
// contains filtered or unexported fields
}
ByteCount is a validated non-negative byte quantity.
func NewByteCount ¶
type CCppLang ¶
type CCppLang struct{}
CCppLang implements ModuleDetector and ImportParser for C/C++ projects.
func (*CCppLang) DetectModules ¶
DetectModules discovers C/C++ modules by reading compile_commands.json, falling back to directory-based heuristics with Makefile/CMakeLists.txt markers.
func (*CCppLang) Extensions ¶
func (*CCppLang) ParseImports ¶
func (c *CCppLang) ParseImports( source AdmittedSource, projectRoot string, ) ([]ImportEdge, error)
ParseImports extracts #include "..." edges from a C/C++ source file. System includes (#include <...>) are skipped since they're external.
type CallSite ¶
type CallSite struct {
Callee string
Qualifier string // "" = unqualified (intra-package candidate); non-"" = qualified (P1b)
Line int // 1-based
Shadowed bool // lexical binding hides an imported/global name at this call site
}
CallSite is one extracted call expression: the called name, an optional qualifier (the selector operand — a package alias or receiver), and the line. The enclosing caller symbol is resolved later by line containment, not here.
func ExtractCallSites ¶
ExtractCallSites walks a Go file's call expressions. Go only for P1a — other languages return nil (node extraction still works for them; edges don't yet). Pure relative to the file content; no DB.
func ExtractCallSitesFromSource ¶
func ExtractCallSitesFromSource( source AdmittedSource, ) ([]CallSite, error)
ExtractCallSitesFromSource is the tree-sitter core. It cannot receive raw filesystem bytes or silently apply its own resource policy.
type CodeEdge ¶
type CodeEdge struct {
SrcID string
DstID string
Kind EdgeKind
FilePath string
Line int
Provenance Provenance
Origin EdgeOrigin
ResolutionMethod ResolutionMethod
Confidence ConfidenceClass
ResolverVersion string
SourceSnapshotHash string
IndexEpoch int64
}
CodeEdge is a resolved directed relationship between two symbol nodes. It exists ONLY when both endpoints resolved — an unresolved call is an absent edge, never a nullable one ("partial coverage worse than none", in the type).
func ResolveConcreteMethodCallEdges ¶
func ResolveConcreteMethodCallEdges(filePath string, fileSymbols []CodeSymbol, callSites []CallSite, signatures map[int]map[string]string, facts TypeFacts, lookup func(name string) []CodeSymbol) []CodeEdge
ResolveConcreteMethodCallEdges resolves QUALIFIED calls whose receiver is a CONCRETE-typed variable or field — `store.Get(...)`, `s.scanner.ScanEdges(...)` — to the method's definition node, including cross-package (the method lives where its type is declared). This is the static counterpart to interface dispatch: the receiver type is resolved (via vars + struct-field facts), then the method node is found by (receiver, name) with the same exactly-1-or-drop guard — a bare-receiver-name collision across packages (two `Store` types) drops rather than emitting a wrong edge. Interface receivers naturally yield no match here (interfaces have no method-body nodes) and are left to dispatch.
func ResolveCrossFileCallEdges ¶
func ResolveCrossFileCallEdges(filePath string, fileSymbols []CodeSymbol, callSites []CallSite, imports []GoImport, lookup func(name string) []CodeSymbol) []CodeEdge
ResolveCrossFileCallEdges resolves QUALIFIED call sites (pkg.Func) to exported package-level functions in the imported local package. Chain: qualifier → import alias → local dir → exported func node. Same exactly-1-or-drop guard: an external import, an unknown qualifier (a receiver variable, not a package), or an unresolved name yields NO edge. lookup is the by-name node accessor (injected so the resolver stays pure relative to the store).
func ResolveEmbedsEdges ¶
func ResolveEmbedsEdges(relPath string, fileSyms, pkgSyms []CodeSymbol, embeds []TypeEmbed) []CodeEdge
ResolveEmbedsEdges emits `embeds` edges (type -> embedded type) for each embedding declared in relPath, resolving the embedded name to exactly one package-local type symbol. External or ambiguous embeds are dropped, never guessed (the no-wrong-edge invariant). Heuristic provenance: the embedding is explicit in source, but name resolution here is package-scoped without import analysis. Pure.
func ResolveImplementsEdges ¶
func ResolveImplementsEdges(relPath string, fileSyms, pkgSyms []CodeSymbol, interfaces map[string]InterfaceDef) []CodeEdge
ResolveImplementsEdges synthesizes STATIC implements edges: for each concrete type DECLARED in relPath whose method-name set covers an interface's methods, emit type -> interface (answering "what implements this interface"). Same precision class as interface_dispatch — method-NAME coverage, so a name match with a different signature is a possible false positive; hence heuristic provenance, not static. Empty interfaces never match (Satisfies excludes them). Package-scoped via pkgSyms; reuses TypeMethodSets + Satisfies. Pure.
func ResolveInterfaceDispatchEdges ¶
func ResolveInterfaceDispatchEdges( filePath string, fileSymbols []CodeSymbol, callSites []CallSite, signatures map[int]map[string]string, interfaces map[string]InterfaceDef, implSymbols []CodeSymbol, ) []CodeEdge
ResolveInterfaceDispatchEdges synthesizes interface_dispatch edges (heuristic provenance) from a call site through an interface to its concrete impls. The precision bound: it fires ONLY when the call's receiver variable has a DECLARED type (from signatures) that is a KNOWN interface declaring the called method. Where that doesn't hold, NO edge — the boundary stays "unresolved dispatch". Multiple satisfying impls produce multiple edges (the true dispatch fan, not ambiguity). Pure given its injected lookups. implSymbols MUST be scoped to a single package. Receiver names are bare (package-stripped), so a whole-repo impl lookup would collide unrelated types that happen to share a receiver name (e.g. db.Store vs artifact.Store) and emit a WRONG dispatch edge — the precision-cliff failure this scoping prevents.
func ResolveIntraPackageCallEdges ¶
func ResolveIntraPackageCallEdges(filePath string, fileSymbols, pkgSymbols []CodeSymbol, callSites []CallSite) []CodeEdge
ResolveIntraPackageCallEdges resolves UNQUALIFIED call sites in a file to package-level definitions, against the package's symbol set. The over- resolution guard is exactly-1-or-drop: a callee with zero or multiple package candidates yields NO edge (an unresolved call is honest; a fanned-out wrong edge is corrosive). Qualified calls (receiver/package selectors) are left for P1b. Pure — symbols + call sites in, edges out.
type CodeFileState ¶
type CodeImport ¶
type CodeSymbol ¶
type CodeSymbol struct {
ID string
AnchorID string
AnchorVersion int
FilePath string
Name string
QualifiedName string
SignatureHash string
Kind string
Receiver string
StartLine int
EndLine int
StartByte int
EndByte int
Hash string
Exported bool
Lang string
IndexEpoch int64
}
CodeSymbol is a persisted symbol node. AnchorID is the durable identity used by new indexes; ID remains the traversal handle and equals AnchorID for anchor v2 rows. Coordinates and Hash are mutable snapshot state, not identity.
type ConcernQuery ¶
type ConcernQuery struct {
// contains filtered or unexported fields
}
ConcernQuery is one validated weak-to-strong query conversion. The original operator text remains available while all downstream search consumes the one parsed filter/term representation.
func NewConcernQuery ¶
func NewConcernQuery(raw string) (ConcernQuery, error)
func (ConcernQuery) KindFilters ¶
func (q ConcernQuery) KindFilters() []string
func (ConcernQuery) LanguageFilters ¶
func (q ConcernQuery) LanguageFilters() []string
func (ConcernQuery) MarshalJSON ¶
func (q ConcernQuery) MarshalJSON() ([]byte, error)
func (ConcernQuery) NameFilters ¶
func (q ConcernQuery) NameFilters() []string
func (ConcernQuery) PathFilters ¶
func (q ConcernQuery) PathFilters() []string
func (ConcernQuery) Raw ¶
func (q ConcernQuery) Raw() string
func (ConcernQuery) Terms ¶
func (q ConcernQuery) Terms() []string
type ConfidenceClass ¶
type ConfidenceClass string
const ( ConfidenceExact ConfidenceClass = "exact" ConfidenceHigh ConfidenceClass = "high" ConfidenceLow ConfidenceClass = "low" )
type CoverageReport ¶
type CoverageReport struct {
TotalModules int
CoveredCount int
PartialCount int
BlindCount int
Modules []ModuleCoverage
FileGaps FileGapProjection
}
CoverageReport is the full coverage report for a project.
func ComputeCoverage ¶
ComputeCoverage calculates decision coverage for all modules. It joins codebase_modules with affected_files via path prefix matching.
func ComputeCoverageWithFileGaps ¶
func ComputeCoverageWithFileGaps( ctx context.Context, db *sql.DB, projectRoot string, requestedLimit int, ) (*CoverageReport, error)
ComputeCoverageWithFileGaps adds a bounded exact-file projection only when the existing derived code index matches the current source tree. It performs no scans and no writes; callers must run an explicit refresh to publish a new index before relying on stale or uninitialized results.
type CoverageStatus ¶
type CoverageStatus string
CoverageStatus represents how well a module is governed by decisions.
const ( CoverageCovered CoverageStatus = "covered" // ≥1 active decision covers files in this module CoveragePartial CoverageStatus = "partial" // has decisions but they're stale or low R_eff CoverageBlind CoverageStatus = "blind" // no decisions reference files in this module )
type DiscoveryBudget ¶
type DiscoveryBudget struct {
// contains filtered or unexported fields
}
DiscoveryBudget is the validated public candidate cap. The producer cap is fixed separately so a caller cannot turn a concern query into an unbounded symbol scan.
func NewDiscoveryBudget ¶
func NewDiscoveryBudget(maxCandidates int) (DiscoveryBudget, error)
func (DiscoveryBudget) MaxCandidates ¶
func (b DiscoveryBudget) MaxCandidates() int
type EdgeKind ¶
type EdgeKind string
EdgeKind enumerates the code→code relationships walked by traversal. Reference edges are deliberately NOT here — they are far more numerous and resolve far weaker, so they never enter the traversal set (per the parity decision).
const ( EdgeCall EdgeKind = "call" EdgeInterfaceDispatch EdgeKind = "interface_dispatch" EdgeImplements EdgeKind = "implements" EdgeExtends EdgeKind = "extends" EdgeEmbeds EdgeKind = "embeds" EdgeInstantiates EdgeKind = "instantiates" EdgeValueReference EdgeKind = "value_reference" EdgeTypeReference EdgeKind = "type_reference" EdgeTemplateUse EdgeKind = "template_use" // EdgeCallback is a synthesized indirect-call edge: a named function passed // as a callback argument (`register(handler)`, `emitter.on("x", handler)`) is // invoked later through dynamic dispatch the AST cannot follow directly. The // edge wires the registration site to the handler so callback-only functions // are not falsely shown as having zero callers. Always heuristic provenance. EdgeCallback EdgeKind = "callback" )
type EdgeOrigin ¶
type EdgeOrigin string
const ( EdgeOriginASTCall EdgeOrigin = "ast_call" EdgeOriginASTNew EdgeOrigin = "ast_new" EdgeOriginASTValueReference EdgeOrigin = "ast_value_reference" EdgeOriginASTTypeReference EdgeOrigin = "ast_type_reference" EdgeOriginVueTemplate EdgeOrigin = "vue_template" EdgeOriginNamedImport EdgeOrigin = "named_import" EdgeOriginNamespaceImport EdgeOrigin = "namespace_import" EdgeOriginReceiverType EdgeOrigin = "receiver_type" EdgeOriginHeritage EdgeOrigin = "heritage" EdgeOriginCallbackRegistration EdgeOrigin = "callback_registration" EdgeOriginEmitterPair EdgeOrigin = "emitter_pair" EdgeOriginLegacyStatic EdgeOrigin = "legacy_static" EdgeOriginHeuristicSynthesis EdgeOrigin = "heuristic_synthesis" )
type EdgeOutcomeResolver ¶
type EdgeOutcomeResolver interface {
ResolveFileEdgeOutcomes(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]EdgeResolution, error)
}
EdgeOutcomeResolver is the truthful resolver port. New adapters should implement this in addition to EdgeResolver so unresolved and ambiguous relations remain inspectable without entering traversal. EdgeResolver stays as a compatibility projection for existing adapters during migration.
type EdgeResolution ¶
type EdgeResolution interface {
// contains filtered or unexported methods
}
EdgeResolution is a closed outcome family: a resolver must say resolved, ambiguous, or unresolved. Only ResolvedEdge can be admitted to traversal.
type EdgeResolver ¶
type EdgeResolver interface {
Language() string
Extensions() []string
ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
}
EdgeResolver extracts the code→code edges originating in ONE file. It is the per-language PORT: the code graph is NOT Go-specific. Go is the first adapter; Python / TypeScript / Rust / … each add an EdgeResolver implementation plus a registry entry — exactly like the existing ModuleDetector / ImportParser adapters. Orchestration (scan, traversal, tools) codes against this interface, never against a language. An unresolved call/dispatch yields no edge.
type EdgeStore ¶
type EdgeStore struct {
// contains filtered or unexported fields
}
EdgeStore persists code edges. Shell over *sql.DB; the caller owns lifecycle.
func NewEdgeStore ¶
NewEdgeStore creates an edge store over an existing DB connection.
func (*EdgeStore) AllEdges ¶
AllEdges returns every code edge in one pass — the whole-graph enumeration the fused-graph ranker (graphrank, dec-20260604-3aaad199 phase 2) needs to build adjacency once instead of N per-node queries. Stable order = deterministic build.
func (*EdgeStore) DiagnosticsByFile ¶
func (*EdgeStore) EnsureSchema ¶
EnsureSchema creates the code_edges table + indexes if absent (idempotent).
func (*EdgeStore) InEdges ¶
InEdges returns edges where dstID is the target (its callers / dispatchers).
func (*EdgeStore) OutEdges ¶
OutEdges returns edges where srcID is the source (its callees / dispatch targets).
func (*EdgeStore) ReplaceFileEdges ¶
ReplaceFileEdges idempotently rebuilds the edges originating in one file (delete-by-file then insert) so re-indexing a file is exact, not additive.
func (*EdgeStore) ReplaceFileResolutions ¶
func (e *EdgeStore) ReplaceFileResolutions(ctx context.Context, filePath string, outcomes []EdgeResolution) error
ReplaceFileResolutions publishes admitted edges and non-admitted diagnostics for one source file in one transaction. A query can never observe an ambiguous/unresolved relation as a traversal edge.
func (*EdgeStore) ResolutionCountsForSource ¶
func (e *EdgeStore) ResolutionCountsForSource(ctx context.Context, sourceID string) (ResolutionCounts, error)
ResolutionCountsForSource reports admitted and non-admitted relation counts originating at one symbol. It makes graph incompleteness queryable instead of hiding it behind an empty traversal result.
type FileBindingSupport ¶
type FileBindingSupport struct {
FilePath string
Language string
Posture string
Symbols []SymbolSnapshot
Ranges []StableRangeSnapshot
Reason string
}
func InspectFileBindingSupport ¶
func InspectFileBindingSupport(projectRoot, relPath string) FileBindingSupport
type FileCount ¶
type FileCount struct {
// contains filtered or unexported fields
}
FileCount is a validated non-negative file quantity.
func NewFileCount ¶
type FileDecisionLinkGap ¶
FileDecisionLinkGap is an indexed source file inside a module that already has at least one active DecisionRecord, but has no exact active affected_files link of its own. It is an orientation cue, not proof that the file is undocumented, unconstrained, or incorrect.
type FileGapIndexState ¶
type FileGapIndexState string
FileGapIndexState reports whether the derived code index is safe to use for exact file-link gap claims. An unavailable projection is never equivalent to an empty gap set.
const ( FileGapIndexUninitialized FileGapIndexState = "uninitialized" FileGapIndexCurrent FileGapIndexState = "current" FileGapIndexStale FileGapIndexState = "stale" FileGapIndexDegraded FileGapIndexState = "degraded" FileGapIndexPartial FileGapIndexState = "partial" )
type FileGapProjection ¶
type FileGapProjection struct {
IndexState FileGapIndexState
Reason string
IndexEpoch int64
IndexBasisRef string
CoveragePosture string
IndexedFiles int
TotalGaps int
OmittedGaps int
ProjectionLimit int
Gaps []FileDecisionLinkGap
}
FileGapProjection is a bounded read-only projection over the current code index. TotalGaps counts the full result; Gaps contains at most the requested projection limit.
type FileIndexDisposition ¶
type FileIndexDisposition interface {
Kind() FileIndexDispositionKind
DetailCode() string
StatusCode() string
// contains filtered or unexported methods
}
FileIndexDisposition is the closed post-admission result for one source file. Consumers cannot represent "indexed with zero symbols" or a skipped file without an explicit admission reason.
func NewDegradedFileDisposition ¶
func NewDegradedFileDisposition( reason string, ) (FileIndexDisposition, error)
func NewEmptyFileDisposition ¶
func NewEmptyFileDisposition() FileIndexDisposition
func NewIndexedFileDisposition ¶
func NewIndexedFileDisposition( symbols FileCount, ) (FileIndexDisposition, error)
func NewSkippedFileDisposition ¶
func NewSkippedFileDisposition( reason SourceSkipReason, ) (FileIndexDisposition, error)
func ParsePersistedFileIndexDisposition ¶
func ParsePersistedFileIndexDisposition( status string, symbolCount int64, ) (FileIndexDisposition, error)
ParsePersistedFileIndexDisposition restores the strong in-memory union from the compatibility status code plus the separately persisted symbol count.
type FileIndexDispositionKind ¶
type FileIndexDispositionKind struct {
// contains filtered or unexported fields
}
FileIndexDispositionKind is the closed post-admission state discriminator.
func (FileIndexDispositionKind) String ¶
func (k FileIndexDispositionKind) String() string
type FileIndexFailure ¶
type FileIndexFailure struct {
Path string
Disposition FileIndexDisposition
}
FileIndexFailure keeps a failed candidate parse paired with its typed degraded disposition. The candidate epoch may be rejected without losing the exact per-file reason.
func NewFileIndexFailure ¶
func NewFileIndexFailure( path string, reason string, ) (FileIndexFailure, error)
func (FileIndexFailure) Error ¶
func (f FileIndexFailure) Error() string
type FileSymbols ¶
type FileSymbols struct {
Path string // relative path from project root
Language string // "go", "python", "javascript", "typescript", "rust", "c", "cpp"
Lines int // total line count
Symbols []Symbol // extracted symbols, sorted by line
ModTime int64 // modification time (unix nano) for recency sorting
}
FileSymbols holds symbols extracted from a single file.
type GeneratedSourcePolicy ¶
type GeneratedSourcePolicy struct {
// contains filtered or unexported fields
}
GeneratedSourcePolicy keeps the existing include-and-deprioritize contract explicit while allowing a bounded caller to request typed exclusion.
func ParseGeneratedSourcePolicy ¶
func ParseGeneratedSourcePolicy( raw string, ) (GeneratedSourcePolicy, error)
func (GeneratedSourcePolicy) String ¶
func (p GeneratedSourcePolicy) String() string
type GoImport ¶
GoImport is one resolved import of a Go file: the alias the source uses to qualify calls, the import path, and the LOCAL directory it maps to (relative to projectRoot) — empty for external (non-module) dependencies, which never resolve to a node.
func ExtractGoImports ¶
ExtractGoImports returns the import aliases of a Go file mapped to local directories, using the module path from go.mod. The alias is the explicit rename or, by convention, the import path's last segment (haft's packages follow dir==package, so this resolves correctly; a mismatch simply fails to resolve — an honest miss, not a wrong edge). External imports get LocalDir "".
func ExtractGoImportsFromSource ¶
func ExtractGoImportsFromSource( projectRoot string, source AdmittedSource, ) ([]GoImport, error)
ExtractGoImportsFromSource parses imports from the exact admitted bytes while retaining project-root metadata only for local-module path resolution.
type GoLang ¶
type GoLang struct{}
GoLang implements ModuleDetector and ImportParser for Go projects.
func (*GoLang) DetectModules ¶
DetectModules discovers Go packages by walking directories for .go files. Each directory containing .go files (excluding _test.go-only dirs) is a module.
func (*GoLang) Extensions ¶
func (*GoLang) ParseImports ¶
func (g *GoLang) ParseImports( source AdmittedSource, projectRoot string, ) ([]ImportEdge, error)
ParseImports extracts import edges from a Go source file using go/parser.
func (*GoLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot ¶
func (g *GoLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, snapshot *projectIndexSnapshot, ) ([]EdgeResolution, error)
func (*GoLang) ResolveAdmittedFileEdges ¶
func (g *GoLang) ResolveAdmittedFileEdges( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, ) ([]CodeEdge, error)
func (*GoLang) ResolveFileEdges ¶
func (g *GoLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
ResolveFileEdges is the Go adapter's implementation of EdgeResolver — it composes the Go-specific extraction + resolution (call-site, intra-package, cross-file qualified, interface dispatch) behind the port. The Go-specific internals live in callsites.go / dispatch.go; nothing outside this method knows the language is Go.
type IgnoreChecker ¶
type IgnoreChecker struct {
// contains filtered or unexported fields
}
IgnoreChecker determines if paths should be excluded from scanning. It respects .gitignore (local + global), .haftignore, and a minimal set of hardcoded dirs that should always be skipped (.git, .haft).
func GetIgnoreChecker ¶
func GetIgnoreChecker(projectRoot string) *IgnoreChecker
GetIgnoreChecker returns a cached IgnoreChecker for the given project root.
func NewIgnoreChecker ¶
func NewIgnoreChecker(projectRoot string) *IgnoreChecker
NewIgnoreChecker builds an IgnoreChecker for the given project root. Reads .gitignore, global git ignore files, and .haftignore.
func (*IgnoreChecker) IsIgnored ¶
func (ic *IgnoreChecker) IsIgnored(relPath string) bool
IsIgnored returns true if the relative path should be excluded.
type ImportEdge ¶
type ImportEdge struct {
SourceModule string // module that imports
TargetModule string // module being imported
SourceFile string // file containing the import
ImportPath string // raw import path as written in source
}
ImportEdge represents a dependency between two modules.
type ImportParser ¶
type ImportParser interface {
// ParseImports extracts import edges from a single source file.
// Returns edges with raw import paths. Caller resolves to modules.
ParseImports(
source AdmittedSource,
projectRoot string,
) ([]ImportEdge, error)
// Extensions returns file extensions this parser handles.
Extensions() []string
}
ImportParser extracts import/dependency edges from source files.
type IndexBasisSnapshot ¶
type IndexBasisSnapshot struct {
Epoch int64 `json:"epoch"`
CorpusDigest string `json:"corpus_digest"`
BasisDigest string `json:"basis_digest"`
Coverage IndexCoverageSnapshot `json:"coverage"`
Exclusions []IndexExclusionSnapshot `json:"exclusions,omitempty"`
}
IndexBasisSnapshot identifies the exact published graph basis used by a query. BasisDigest binds the epoch, exact corpus, coverage, and exclusions.
func (IndexBasisSnapshot) CoverageRef ¶
func (b IndexBasisSnapshot) CoverageRef() string
func (IndexBasisSnapshot) SupportsKnownAbsence ¶
func (b IndexBasisSnapshot) SupportsKnownAbsence() bool
type IndexBudget ¶
type IndexBudget struct {
// contains filtered or unexported fields
}
IndexBudget is the single source-admission resource policy.
func DefaultIndexBudget ¶
func DefaultIndexBudget() IndexBudget
func NewIndexBudget ¶
func NewIndexBudget(spec IndexBudgetSpec) (IndexBudget, error)
func (IndexBudget) GeneratedSources ¶
func (b IndexBudget) GeneratedSources() GeneratedSourcePolicy
func (IndexBudget) MaxFileBytes ¶
func (b IndexBudget) MaxFileBytes() ByteCount
func (IndexBudget) MaxFiles ¶
func (b IndexBudget) MaxFiles() FileCount
func (IndexBudget) MaxObservedBytes ¶
func (b IndexBudget) MaxObservedBytes() ByteCount
func (IndexBudget) MaxParseWorkers ¶
func (b IndexBudget) MaxParseWorkers() WorkerCount
type IndexBudgetSpec ¶
type IndexBudgetSpec struct {
MaxFileBytes ByteCount
MaxFiles FileCount
MaxObservedBytes ByteCount
MaxParseWorkers WorkerCount
GeneratedSources GeneratedSourcePolicy
}
IndexBudgetSpec is the builder input for one validated admission policy.
type IndexCoverageSnapshot ¶
type IndexCoverageSnapshot struct {
Posture string `json:"posture"`
DiscoveredFiles int64 `json:"discovered_files"`
AdmittedFiles int64 `json:"admitted_files"`
IndexedFiles int64 `json:"indexed_files"`
EmptyFiles int64 `json:"empty_files"`
SkippedFiles int64 `json:"skipped_files"`
KnownAbsenceSupported bool `json:"known_absence_supported"`
}
IndexCoverageSnapshot is the public immutable projection of one candidate's full supported-source corpus.
type IndexDelta ¶
type IndexEpochCandidate ¶
type IndexEpochCandidate struct {
// contains filtered or unexported fields
}
IndexEpochCandidate is a valid, unpublished epoch identity. It contains no database handles or mutable source maps; publication is an outer-shell transaction over this pure result and the already-built graph batches.
func BuildIndexEpochCandidate ¶
func BuildIndexEpochCandidate( epoch int64, states map[string]CodeFileState, admissions map[string]AdmittedSource, dispositions map[string]FileIndexDisposition, exclusions map[string]SourceSkipInfo, budget IndexBudget, ) (IndexEpochCandidate, error)
func (IndexEpochCandidate) Basis ¶
func (c IndexEpochCandidate) Basis() IndexBasisSnapshot
type IndexExclusionSnapshot ¶
type IndexExclusionSnapshot struct {
Path string `json:"path"`
Reason string `json:"reason"`
ObservedBytes int64 `json:"observed_bytes"`
LimitBytes int64 `json:"limit_bytes"`
Detail string `json:"detail"`
}
IndexExclusionSnapshot is the exact persisted/public projection of one known source exclusion in an epoch.
type IndexFreshnessObservation ¶
type IndexFreshnessObservation struct {
SourceFingerprint string
StoredSourceFingerprint string
ConfigFingerprint string
StoredConfigFingerprint string
CurrentSchemaVersion int
StoredSchemaVersion int
PublishedEpoch int64
Degraded bool
DegradedReason string
}
IndexFreshnessObservation is the read-only input to code-index coordination. It keeps filesystem and stored publication identity separate so the caller can make the rebuild decision in a pure policy after it owns the project rebuild lease. Missing legacy columns are represented by their zero values and therefore cannot be mistaken for a current publication.
type IndexRefreshMetrics ¶
type IndexRefreshMetrics struct {
DiscoveredFiles int
AdmittedFiles int
ObservedBytes int64
SeedFiles int
ReindexFiles int
ResolveFiles int
ResolveWorkers int
SetupDuration time.Duration
CorpusScanDuration time.Duration
DeltaDuration time.Duration
ParseDuration time.Duration
SymbolViewDuration time.Duration
ResolveDuration time.Duration
CandidateDuration time.Duration
PublicationDuration time.Duration
TotalDuration time.Duration
}
IndexRefreshMetrics makes the expensive incremental stages observable without turning runtime concurrency into persisted index identity.
type IndexRefreshResult ¶
type IndexState ¶
type IndexState struct {
Epoch int64
Degraded bool
DegradedReason string
Basis IndexBasisSnapshot
}
func (IndexState) SameCurrentBasis ¶
func (s IndexState) SameCurrentBasis(other IndexState) bool
SameCurrentBasis reports whether two observations can support one public result without mixing published or degraded currentness states.
func (IndexState) SupportsKnownAbsence ¶
func (s IndexState) SupportsKnownAbsence() bool
type InterfaceDef ¶
InterfaceDef is a Go interface and its method set, extracted structurally. Empty (marker) interfaces are excluded by the extractor — they satisfy everything and would only generate noise.
func ExtractGoInterfaces ¶
func ExtractGoInterfaces(projectRoot, relPath string) ([]InterfaceDef, error)
ExtractGoInterfaces extracts each interface type's method set from a Go file. Pure relative to file content. Go only.
func ExtractGoInterfacesFromSource ¶
func ExtractGoInterfacesFromSource( source AdmittedSource, ) ([]InterfaceDef, error)
ExtractGoInterfacesFromSource consumes only centrally admitted bytes.
type JSTSLang ¶
type JSTSLang struct{}
JSTSLang implements ModuleDetector and ImportParser for JavaScript/TypeScript.
func (*JSTSLang) DetectModules ¶
DetectModules discovers JS/TS packages by looking for package.json files. Handles monorepo workspaces.
func (*JSTSLang) Extensions ¶
func (*JSTSLang) ExtractSymbolSnapshots ¶
func (j *JSTSLang) ExtractSymbolSnapshots( source AdmittedSource, ) ([]SymbolSnapshot, error)
ExtractSymbolSnapshots implements the rich JS/TS SymbolAdapter. It produces one canonical node for each declaration: an arrow assigned to a const is a func, never both a constant wrapper and a duplicate anonymous function.
func (*JSTSLang) ExtractSymbolSnapshotsContext ¶
func (j *JSTSLang) ExtractSymbolSnapshotsContext( ctx gocontext.Context, source AdmittedSource, ) ([]SymbolSnapshot, error)
func (*JSTSLang) ParseImports ¶
func (j *JSTSLang) ParseImports( source AdmittedSource, _ string, ) ([]ImportEdge, error)
ParseImports extracts import/require edges from a JS/TS file.
func (*JSTSLang) ResolveAdmittedFileEdgeOutcomes ¶
func (j *JSTSLang) ResolveAdmittedFileEdgeOutcomes( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, ) ([]EdgeResolution, error)
func (*JSTSLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot ¶
func (j *JSTSLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, snapshot *projectIndexSnapshot, ) ([]EdgeResolution, error)
func (*JSTSLang) ResolveFileEdgeOutcomes ¶
func (j *JSTSLang) ResolveFileEdgeOutcomes(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]EdgeResolution, error)
ResolveFileEdgeOutcomes is the authority-bearing TypeScript resolver path. Resolved relations become edges; ambiguous and unresolved call sites remain diagnostics. The legacy ResolveFileEdges method is only its edge projection.
func (*JSTSLang) ResolveFileEdgeOutcomesWithProjectSnapshot ¶
func (j *JSTSLang) ResolveFileEdgeOutcomesWithProjectSnapshot( ctx context.Context, projectRoot string, relPath string, symbols SymbolView, snapshot *projectIndexSnapshot, ) ([]EdgeResolution, error)
func (*JSTSLang) ResolveFileEdges ¶
func (j *JSTSLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
ResolveFileEdges makes JSTSLang an EdgeResolver. It emits two edge families:
- `extends` / `implements` edges from the explicit JS/TS heritage clauses, resolved directory-locally (heuristic provenance — no import analysis);
- `call` edges, resolved through the project module/export model (file-local defs, default/named/namespace imports, barrels, aliases, and workspaces) with the same exactly-1-or-drop discipline (static provenance).
A base or call that does not resolve to exactly one symbol is retained as an ambiguous/unresolved diagnostic, never guessed. Instance-method calls remain unresolved until receiver facts prove their target.
func (*JSTSLang) SymbolLanguage ¶
SymbolLanguage names the concrete grammar used by a JS/TS file. JSTSLang's Language method intentionally remains "jsts" for module detection; persisted code symbols use the more precise language name.
type LexicalTier ¶
type LexicalTier struct {
// contains filtered or unexported fields
}
LexicalTier is precedence, not a probability or confidence value.
func (LexicalTier) String ¶
func (t LexicalTier) String() string
type MatchField ¶
type MatchField struct {
// contains filtered or unexported fields
}
func (MatchField) String ¶
func (f MatchField) String() string
type MethodSig ¶
type MethodSig struct {
Name string
}
MethodSig is a method's name for satisfaction matching. Matching is NAME- coverage only — no signature/arity comparison — so a same-name method with a different signature is a possible false positive, which is exactly why implements / interface_dispatch edges carry heuristic provenance. (Arity-based precision would also need the CONCRETE side's arity, which the symbol store does not extract; deferred rather than half-claimed.)
type Module ¶
type Module struct {
ID string // auto-generated from path, e.g., "mod-internal-auth"
Path string // relative path from project root
Name string // human-readable name, e.g., "auth"
Lang string // go, js, ts, python, rust, mixed, unknown
FileCount int // number of source files
}
Module represents a detected module/package in the codebase.
type ModuleCoverage ¶
type ModuleCoverage struct {
Module Module
Status CoverageStatus
DecisionCount int
DecisionIDs []string
// ImpactScore is the number of governed (Covered or Partial) modules
// that depend on this module — i.e., how many decision-covered places
// would be at risk if this module changes. Computed in ComputeCoverage
// via Scanner.GetDependents reverse-graph traversal (dec-20260527-e4b86938).
// Zero means no governed dependents (isolated utility, low priority).
ImpactScore int
}
ModuleCoverage describes the decision coverage for a single module.
type ModuleDetector ¶
type ModuleDetector interface {
// DetectModules walks the project and returns discovered modules.
DetectModules(projectRoot string) ([]Module, error)
// Language returns the language this detector handles.
Language() string
}
ModuleDetector discovers module/package boundaries in a project.
type ModuleGovernanceGap ¶
ModuleGovernanceGap reports that a module touched by a new decision has no prior active decision coverage.
func FindFirstDecisionModules ¶
func FindFirstDecisionModules(ctx context.Context, db *sql.DB, affectedFiles []string) ([]ModuleGovernanceGap, error)
FindFirstDecisionModules returns touched modules that currently have no active decision coverage. The caller can use this to warn that a decision is establishing the first explicit architectural context for a module.
type ModuleImpactInfo ¶
type ModuleImpactInfo struct {
ModuleID string
ModulePath string
DecisionIDs []string
IsBlind bool
}
ModuleImpactInfo describes a module affected by dependency propagation.
func EnrichDriftWithImpact ¶
func EnrichDriftWithImpact(ctx context.Context, db *sql.DB, driftFiles []string) ([]ModuleImpactInfo, error)
EnrichDriftWithImpact adds dependency propagation to drift reports. For each drifted file, resolves to a module, finds dependents, and looks up their decisions.
type ProjectPath ¶
type ProjectPath struct {
// contains filtered or unexported fields
}
ProjectPath is one normalized project-relative path.
func NewProjectPath ¶
func NewProjectPath(value string) (ProjectPath, error)
func (ProjectPath) String ¶
func (p ProjectPath) String() string
type Provenance ¶
type Provenance string
Provenance records how an edge was established. static = resolved directly from the AST + symbol table; heuristic = synthesized (e.g. structural interface→impl matching), which the agent can treat with appropriate caution.
const ( ProvenanceStatic Provenance = "static" ProvenanceHeuristic Provenance = "heuristic" )
type PythonLang ¶
type PythonLang struct{}
PythonLang implements ModuleDetector and ImportParser for Python projects.
func (*PythonLang) DetectModules ¶
func (p *PythonLang) DetectModules(projectRoot string) ([]Module, error)
DetectModules discovers Python packages by looking for __init__.py or pyproject.toml.
func (*PythonLang) Extensions ¶
func (p *PythonLang) Extensions() []string
func (*PythonLang) Language ¶
func (p *PythonLang) Language() string
func (*PythonLang) ParseImports ¶
func (p *PythonLang) ParseImports( source AdmittedSource, _ string, ) ([]ImportEdge, error)
ParseImports extracts import edges from a Python source file.
func (*PythonLang) ResolveAdmittedFileEdges ¶
func (p *PythonLang) ResolveAdmittedFileEdges( ctx context.Context, _ string, source AdmittedSource, symbols SymbolView, ) ([]CodeEdge, error)
func (*PythonLang) ResolveFileEdges ¶
func (p *PythonLang) ResolveFileEdges(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]CodeEdge, error)
ResolveFileEdges makes PythonLang an EdgeResolver. It emits two edge families:
- `extends` edges (subclass -> base) from class inheritance, resolved within the file's package (heuristic provenance — no import analysis on bases);
- `call` edges, resolved through import analysis (file-local defs, names imported via `from M import N`, and module-qualified `m.foo()` calls) with the same exactly-1-or-drop discipline (static provenance).
Every unresolved base or call is an absent edge, never a guessed one. Dynamic instance-method dispatch (`obj.method()` where obj is not an imported module) is deliberately dropped — it cannot be typed soundly from the AST alone.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps file extensions to language detectors, import parsers, symbol adapters, and code-graph edge resolvers. Adding a language = one adapter type plus entries here; orchestration codes against ports, never a specific language.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a registry with all supported languages.
func (*Registry) Detectors ¶
func (r *Registry) Detectors() []ModuleDetector
Detectors returns all registered module detectors.
func (*Registry) ExtractAdmittedSymbolSnapshots ¶
func (r *Registry) ExtractAdmittedSymbolSnapshots( source AdmittedSource, ) ([]SymbolSnapshot, error)
ExtractAdmittedSymbolSnapshots routes exact admitted bytes through the rich adapter or the legacy tree-sitter compatibility adapter.
func (*Registry) ExtractAdmittedSymbolSnapshotsContext ¶
func (r *Registry) ExtractAdmittedSymbolSnapshotsContext( ctx context.Context, source AdmittedSource, ) ([]SymbolSnapshot, error)
ExtractAdmittedSymbolSnapshotsContext is the cancellable scanner path. The legacy method remains for compatibility callers, while coordinated index refreshes must pass their request context through tree-sitter.
func (*Registry) ExtractSymbolSnapshots ¶
func (r *Registry) ExtractSymbolSnapshots( projectRoot string, relPath string, ) ([]SymbolSnapshot, error)
ExtractSymbolSnapshots is the temporary raw-path compatibility shell. It cannot bypass admission and never turns a skipped source into an empty file.
func (*Registry) ParserForFile ¶
func (r *Registry) ParserForFile(path string) ImportParser
ParserForFile returns the import parser for a file, or nil if unsupported.
func (*Registry) ReadAdmittedSource ¶
func (r *Registry) ReadAdmittedSource( projectRoot string, relPath string, ) (AdmittedSource, error)
ReadAdmittedSource is the compatibility shell for one-file consumers. Batch scanners pass explicit budget and usage through ReadSourceAdmission instead.
func (*Registry) ReadSourceAdmission ¶
func (r *Registry) ReadSourceAdmission( projectRoot string, relPath string, budget IndexBudget, usage AdmissionUsage, ) (SourceAdmission, AdmissionUsage, error)
ReadSourceAdmission is the single filesystem shell before symbol parsing.
func (*Registry) ResolverForFile ¶
func (r *Registry) ResolverForFile(path string) EdgeResolver
ResolverForFile returns the code-graph edge resolver for a file, or nil if no language adapter resolves edges for that extension (node extraction may still work — edges are a separate, incrementally-grown capability).
func (*Registry) SupportsSymbols ¶
SupportsSymbols reports whether the rich adapter or the legacy extractor can produce symbol snapshots for the file.
func (*Registry) SymbolAdapterForFile ¶
func (r *Registry) SymbolAdapterForFile(path string) SymbolAdapter
SymbolAdapterForFile returns the registered rich symbol adapter for a file. A nil result means the extension still uses the legacy tree-sitter queries.
type RepoMap ¶
type RepoMap struct {
Files []FileSymbols
TotalFiles int
TotalSyms int
}
RepoMap is the complete symbol map for a repository.
type ResolutionCounts ¶
type ResolutionDiagnostic ¶
type ResolutionDiagnostic struct {
SourceID string
Kind EdgeKind
FilePath string
Line int
Status ResolutionStatus
Reason ResolutionReason
CandidateIDs []string
Origin EdgeOrigin
ResolverVersion string
SourceSnapshotHash string
}
type ResolutionMethod ¶
type ResolutionMethod string
const ( ResolutionMethodExactSymbol ResolutionMethod = "exact_symbol" ResolutionMethodImportMap ResolutionMethod = "import_map" ResolutionMethodTypeFacts ResolutionMethod = "type_facts" ResolutionMethodHeuristic ResolutionMethod = "heuristic" ResolutionMethodLegacy ResolutionMethod = "legacy" )
type ResolutionReason ¶
type ResolutionReason string
const ( ResolutionReasonNoCandidate ResolutionReason = "no_candidate" ResolutionReasonMultipleCandidates ResolutionReason = "multiple_candidates" ResolutionReasonExternalDependency ResolutionReason = "external_dependency" ResolutionReasonUnsupportedForm ResolutionReason = "unsupported_form" ResolutionReasonShadowedBinding ResolutionReason = "shadowed_binding" )
type ResolutionStatus ¶
type ResolutionStatus string
const ( ResolutionResolved ResolutionStatus = "resolved" ResolutionAmbiguous ResolutionStatus = "ambiguous" ResolutionUnresolved ResolutionStatus = "unresolved" )
type ResolvedEdge ¶
type ResolvedEdge struct {
Edge CodeEdge
}
type RustLang ¶
type RustLang struct{}
RustLang implements ModuleDetector and ImportParser for Rust projects.
func (*RustLang) DetectModules ¶
DetectModules discovers Rust crates/modules by looking for Cargo.toml and mod.rs/lib.rs.
func (*RustLang) Extensions ¶
func (*RustLang) ParseImports ¶
func (r *RustLang) ParseImports( source AdmittedSource, _ string, ) ([]ImportEdge, error)
ParseImports extracts use/mod edges from a Rust source file.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner detects modules and builds the dependency graph for a project.
func (*Scanner) CurrentIndexState ¶
func (s *Scanner) CurrentIndexState(ctx context.Context) (IndexState, error)
func (*Scanner) EnsureIncrementalSchema ¶
func (*Scanner) EnsureIndexMetaSchema ¶
EnsureIndexMetaSchema creates the single-row index-meta table (idempotent).
func (*Scanner) GetDependents ¶
GetDependents returns modules that depend on the given module (1-hop).
func (*Scanner) GetModules ¶
GetModules returns all stored modules.
func (*Scanner) ModulesLastScanned ¶
ModulesLastScanned returns the time of the last module scan, or zero if never scanned.
func (*Scanner) ObserveIndexFreshness ¶
func (s *Scanner) ObserveIndexFreshness( ctx context.Context, projectRoot string, ) (IndexFreshnessObservation, error)
ObserveIndexFreshness gathers the filesystem and stored identity used by the index coordinator. It performs no schema repair and no publication. Callers must repeat this observation only after acquiring the project-scoped rebuild lease before relying on it to skip parsing.
func (*Scanner) RefreshIncremental ¶
func (*Scanner) RequireDatabaseIntegrityForIndexRefresh ¶
RequireDatabaseIntegrityForIndexRefresh performs a bounded, read-only structural check immediately before an expensive code-index rebuild. It is intentionally not part of the ordinary fresh-index read path.
func (*Scanner) ResolveFileToModule ¶
ResolveFileToModule finds the most specific module for a file path (longest prefix match).
func (*Scanner) ScanDependencies ¶
ScanDependencies parses imports across all modules and builds the dependency graph.
func (*Scanner) ScanEdges ¶
ScanEdges builds the code_edges layer for every file with a registered EdgeResolver, via the language-agnostic port (Go today; other languages add an adapter). Must run AFTER ScanSymbols — cross-file/dispatch resolution reads the full node store. Idempotent per file. Observation and resolver failures remain visible to the caller.
func (*Scanner) ScanModules ¶
ScanModules detects all modules in the project and stores them in the DB. Respects .gitignore, global git ignore, and .haftignore.
func (*Scanner) ScanSymbols ¶
ScanSymbols extracts and stores code symbols for every supported source file, populating the code_symbols node layer of the code graph. Respects the same ignore/exclusion rules as ScanModules; idempotent per file (delete-then-insert). Files excluded by the admission policy are not indexed. Observation and parse failures remain visible to the caller rather than becoming false empty files. Per-file transactions here remain the cold path; RefreshIncremental owns atomic candidate-epoch publication.
func (*Scanner) SetFingerprint ¶
SetFingerprint records the fingerprint of the tree the current index was built from, so a later query can tell whether the source has changed since.
func (*Scanner) SourceFingerprint ¶
SourceFingerprint computes a cheap fingerprint of the indexable source tree: a sha256 over sorted "relPath\x00size\x00mtime" lines for every file that ScanSymbols would index (same ignore + language filter). Stat-only — no file reads — so it is fast enough to check on each query. Any added/removed file, or a size/mtime change, flips the fingerprint; an unchanged tree reproduces it exactly. Shell (walk + stat); the hash is deterministic given the metadata.
type SourceAdmission ¶
type SourceAdmission interface {
Kind() SourceAdmissionKind
DetailCode() string
// contains filtered or unexported methods
}
SourceAdmission is the sealed pre-parser result.
type SourceAdmissionKind ¶
type SourceAdmissionKind struct {
// contains filtered or unexported fields
}
SourceAdmissionKind is the closed discriminator for source admission.
func (SourceAdmissionKind) String ¶
func (k SourceAdmissionKind) String() string
type SourceClass ¶
type SourceClass struct {
// contains filtered or unexported fields
}
SourceClass records why an observed path is or is not an ordinary supported source candidate before resource admission.
func ParseSourceClass ¶
func ParseSourceClass(raw string) (SourceClass, error)
func (SourceClass) String ¶
func (c SourceClass) String() string
type SourceLanguage ¶
type SourceLanguage struct {
// contains filtered or unexported fields
}
SourceLanguage is a validated adapter-language identity.
func NewSourceLanguage ¶
func NewSourceLanguage(value string) (SourceLanguage, error)
func (SourceLanguage) String ¶
func (l SourceLanguage) String() string
type SourceObservation ¶
type SourceObservation struct {
// contains filtered or unexported fields
}
SourceObservation is a weak filesystem observation parsed into strong path, language, classification, and bounded-content carriers.
func NewContentObservation ¶
func NewContentObservation( path ProjectPath, language SourceLanguage, class SourceClass, content []byte, ) (SourceObservation, error)
func NewMetadataObservation ¶
func NewMetadataObservation( path ProjectPath, language SourceLanguage, class SourceClass, observedBytes ByteCount, ) (SourceObservation, error)
func ObserveSource ¶
func ObserveSource( projectRoot string, path ProjectPath, language SourceLanguage, class SourceClass, budget IndexBudget, ) (SourceObservation, error)
ObserveSource is the bounded filesystem shell. It reads at most MaxFileBytes+1 bytes and returns the exact observation consumed by AdmitSource.
type SourceSkipInfo ¶
type SourceSkipInfo struct {
Path string
Reason string
ObservedBytes int64
LimitBytes int64
Detail string
}
SourceSkipInfo is the external, immutable projection of a skipped source.
func SkippedSourceInfo ¶
func SkippedSourceInfo( admission SourceAdmission, ) (SourceSkipInfo, error)
func (SourceSkipInfo) RequiresRetry ¶
func (i SourceSkipInfo) RequiresRetry() bool
RequiresRetry distinguishes an incomplete filesystem observation from a deliberate, inspectable policy exclusion.
type SourceSkipReason ¶
type SourceSkipReason struct {
// contains filtered or unexported fields
}
SourceSkipReason is a closed non-parser reason for excluding one source.
func ParseSourceSkipReason ¶
func ParseSourceSkipReason(raw string) (SourceSkipReason, error)
func (SourceSkipReason) String ¶
func (r SourceSkipReason) String() string
type SourceSkippedError ¶
type SourceSkippedError struct {
Info SourceSkipInfo
}
SourceSkippedError keeps the compatibility path explicit when a caller has not yet migrated to SourceAdmission.
func (SourceSkippedError) Error ¶
func (e SourceSkippedError) Error() string
type StableRangeSnapshot ¶
type StableRangeSnapshot struct {
FilePath string
Language string
StartLine int
EndLine int
AnchorHash string
TextHash string
NearestName string
}
func ExtractStableFileRange ¶
func ExtractStableFileRange(projectRoot, relPath string) (StableRangeSnapshot, error)
type Symbol ¶
type Symbol struct {
Name string // symbol name
Kind string // canonical kind: func, method, class, interface, type_alias, enum, constant, variable, property
Line int // 1-based line number
Exported bool // starts with uppercase (Go) or is exported
}
Symbol represents an extracted code symbol (function, type, class, etc.)
type SymbolAdapter ¶
type SymbolAdapter interface {
Extensions() []string
SymbolLanguage(path string) string
ExtractSymbolSnapshots(source AdmittedSource) ([]SymbolSnapshot, error)
}
SymbolAdapter is the per-language port for the code-graph node layer. Implementations turn one source file into the canonical SymbolSnapshot form; stores, drift detection, bindings, and repo-map rendering all consume that same form instead of maintaining their own language queries.
type SymbolAnchor ¶
type SymbolAnchor struct {
Version int
ID string
FilePath string
Language string
Kind string
QualifiedName string
SignatureHash string
}
SymbolAnchor is the durable identity of one code declaration inside a project-scoped code graph. Source coordinates and body hashes deliberately do not participate: inserting lines or editing an implementation must not mint a new node. The project database supplies the repository namespace.
func BuildSymbolAnchor ¶
func BuildSymbolAnchor(snapshot SymbolSnapshot, language string) SymbolAnchor
BuildSymbolAnchor is the pure identity core. It accepts a normalized snapshot and returns the one canonical anchor representation used by persistence.
type SymbolDiscoveryBatch ¶
type SymbolDiscoveryBatch struct {
// contains filtered or unexported fields
}
SymbolDiscoveryBatch is a closed candidate-set/no-candidate outcome. It deliberately has no selected-symbol field.
func (SymbolDiscoveryBatch) Budget ¶
func (b SymbolDiscoveryBatch) Budget() DiscoveryBudget
func (SymbolDiscoveryBatch) Candidates ¶
func (b SymbolDiscoveryBatch) Candidates() []SymbolDiscoveryCandidate
func (SymbolDiscoveryBatch) Epoch ¶
func (b SymbolDiscoveryBatch) Epoch() int64
func (SymbolDiscoveryBatch) Kind ¶
func (b SymbolDiscoveryBatch) Kind() SymbolDiscoveryKind
func (SymbolDiscoveryBatch) MarshalJSON ¶
func (b SymbolDiscoveryBatch) MarshalJSON() ([]byte, error)
func (SymbolDiscoveryBatch) Query ¶
func (b SymbolDiscoveryBatch) Query() ConcernQuery
type SymbolDiscoveryCandidate ¶
type SymbolDiscoveryCandidate struct {
// contains filtered or unexported fields
}
SymbolDiscoveryCandidate contains an existing canonical symbol plus the complete deterministic evidence that placed it in this candidate set.
func (SymbolDiscoveryCandidate) Coverage ¶
func (c SymbolDiscoveryCandidate) Coverage() TermCoverage
func (SymbolDiscoveryCandidate) Epoch ¶
func (c SymbolDiscoveryCandidate) Epoch() int64
func (SymbolDiscoveryCandidate) FieldCoverage ¶
func (c SymbolDiscoveryCandidate) FieldCoverage() TermCoverage
func (SymbolDiscoveryCandidate) Lane ¶
func (c SymbolDiscoveryCandidate) Lane() SymbolSourceLane
func (SymbolDiscoveryCandidate) MarshalJSON ¶
func (c SymbolDiscoveryCandidate) MarshalJSON() ([]byte, error)
func (SymbolDiscoveryCandidate) Matches ¶
func (c SymbolDiscoveryCandidate) Matches() []SymbolTermMatch
func (SymbolDiscoveryCandidate) Symbol ¶
func (c SymbolDiscoveryCandidate) Symbol() CodeSymbol
func (SymbolDiscoveryCandidate) Tier ¶
func (c SymbolDiscoveryCandidate) Tier() LexicalTier
type SymbolDiscoveryKind ¶
type SymbolDiscoveryKind struct {
// contains filtered or unexported fields
}
func (SymbolDiscoveryKind) String ¶
func (k SymbolDiscoveryKind) String() string
type SymbolDrift ¶
type SymbolDrift struct {
FilePath string `json:"file_path"`
SymbolName string `json:"symbol_name"`
SymbolKind string `json:"symbol_kind"`
Status string `json:"status"` // "unchanged", "modified", "added", "removed"
OldLine int `json:"old_line,omitempty"`
NewLine int `json:"new_line,omitempty"`
}
SymbolDrift describes how a single symbol changed between baseline and current.
func CompareSymbolSnapshots ¶
func CompareSymbolSnapshots(baseline []SymbolSnapshot, current []SymbolSnapshot) []SymbolDrift
CompareSymbolSnapshots compares baseline snapshots against current state.
type SymbolRef ¶
SymbolRef is a symbol's stable id paired with its file — the minimum the fused-graph ranker needs to bridge a symbol node to its file connector node (graphrank, dec-20260604-3aaad199 phase 2) without loading full symbol rows.
type SymbolSnapshot ¶
type SymbolSnapshot struct {
FilePath string `json:"file_path"`
SymbolName string `json:"symbol_name"`
SymbolKind string `json:"symbol_kind"` // func, method, class, interface, type_alias, enum, constant, variable, property
QualifiedName string `json:"qualified_name"` // Receiver.member for methods, bare name for file-scope declarations
SignatureHash string `json:"signature_hash"` // declaration signature, excluding body and source coordinates
Line int `json:"line"` // 1-based start line
EndLine int `json:"end_line"` // 1-based end line
Hash string `json:"hash"` // SHA256 of the symbol's source text
StartByte int `json:"start_byte"` // body start byte offset — for byte-exact source slicing
EndByte int `json:"end_byte"` // body end byte offset
Receiver string `json:"receiver,omitempty"` // method receiver type (Go), "" otherwise
Exported bool `json:"exported"` // first rune uppercase (Go export proxy)
}
SymbolSnapshot captures a symbol's identity and content hash at a point in time.
func ExtractSymbolSnapshots ¶
func ExtractSymbolSnapshots(projectRoot, relPath string) ([]SymbolSnapshot, error)
ExtractSymbolSnapshots extracts symbol-level hashes from a file using tree-sitter. Returns one snapshot per symbol, each with a content hash of the symbol's source text.
type SymbolSourceLane ¶
type SymbolSourceLane struct {
// contains filtered or unexported fields
}
func (SymbolSourceLane) String ¶
func (l SymbolSourceLane) String() string
type SymbolStore ¶
type SymbolStore struct {
// contains filtered or unexported fields
}
SymbolStore persists code symbols (the node layer of the code graph). It does not own the DB connection — the caller manages lifecycle.
func NewSymbolStore ¶
func NewSymbolStore(db *sql.DB) *SymbolStore
NewSymbolStore creates a symbol store over an existing DB connection.
func (*SymbolStore) AllSymbolRefs ¶
func (s *SymbolStore) AllSymbolRefs(ctx context.Context) ([]SymbolRef, error)
AllSymbolRefs enumerates every symbol's (id, anchor, file) in one pass, stably ordered. AnchorID lets the fused graph resolve durable artifact_symbol_bindings without replacing the code graph's canonical node identity.
func (*SymbolStore) AllSymbols ¶
func (s *SymbolStore) AllSymbols(ctx context.Context) ([]CodeSymbol, error)
func (*SymbolStore) DiscoverSymbols ¶
func (s *SymbolStore) DiscoverSymbols( ctx context.Context, query ConcernQuery, budget DiscoveryBudget, epoch int64, ) (SymbolDiscoveryBatch, error)
DiscoverSymbols resolves a validated concern to an evidence-bearing bounded candidate set under one exact published epoch.
func (*SymbolStore) EnsureSchema ¶
func (s *SymbolStore) EnsureSchema(ctx context.Context) error
EnsureSchema creates the code_symbols table + indexes if absent (idempotent).
func (*SymbolStore) FileSymbolsStale ¶
func (s *SymbolStore) FileSymbolsStale(ctx context.Context, projectRoot, relPath string) (bool, error)
FileSymbolsStale reports whether the file on disk no longer matches the stored symbols — by node identity + body hash. The is-stale half of the freshness primitive; pair with IndexFileSymbols to rebuild on demand before slicing.
func (*SymbolStore) GetByDir ¶
func (s *SymbolStore) GetByDir(ctx context.Context, dir string) ([]CodeSymbol, error)
GetByDir returns symbols whose file lives DIRECTLY in dir (a Go package = the files in one directory, not nested). Used to scope impl resolution to a single package so bare receiver names don't collide across packages.
func (*SymbolStore) GetByFile ¶
func (s *SymbolStore) GetByFile(ctx context.Context, filePath string) ([]CodeSymbol, error)
GetByFile returns all symbols stored for a file, ordered by start line.
func (*SymbolStore) GetByID ¶
func (s *SymbolStore) GetByID(ctx context.Context, id string) (CodeSymbol, bool, error)
GetByID returns the single node with the given surrogate id, if present. The inverse of NodeID — resolves a traversal hop back to its symbol for display.
func (*SymbolStore) GetByIdentity ¶
func (s *SymbolStore) GetByIdentity(ctx context.Context, file, name string, startLine int) (CodeSymbol, bool, error)
GetByIdentity returns the single node at (file, name, start_line), if present.
func (*SymbolStore) GetByName ¶
func (s *SymbolStore) GetByName(ctx context.Context, name string) ([]CodeSymbol, error)
GetByName returns all symbols with the given name across files (overloads incl.).
func (*SymbolStore) IndexAdmittedFileSymbolsWithRegistry ¶
func (s *SymbolStore) IndexAdmittedFileSymbolsWithRegistry( ctx context.Context, source AdmittedSource, registry *Registry, ) error
IndexAdmittedFileSymbolsWithRegistry persists symbol snapshots extracted from the exact admitted bytes that belong to the current scan.
func (*SymbolStore) IndexFileSymbols ¶
func (s *SymbolStore) IndexFileSymbols(ctx context.Context, projectRoot, relPath string) error
IndexFileSymbols extracts a file and replaces its symbol rows. The rebuild-on- demand half of the freshness primitive — calling it makes the store match disk.
func (*SymbolStore) IndexFileSymbolsWithRegistry ¶
func (s *SymbolStore) IndexFileSymbolsWithRegistry(ctx context.Context, projectRoot, relPath string, registry *Registry) error
IndexFileSymbolsWithRegistry is the scanner path: it shares the scanner's language registry so extension support, extraction, and persisted language names cannot diverge.
func (*SymbolStore) RebuildSymbolSearchProjection ¶
func (s *SymbolStore) RebuildSymbolSearchProjection( ctx context.Context, epoch int64, ) error
RebuildSymbolSearchProjection recreates the derivative entirely from the canonical symbol table without changing any symbol identity.
func (*SymbolStore) ReplaceFileSymbols ¶
func (s *SymbolStore) ReplaceFileSymbols(ctx context.Context, filePath string, syms []CodeSymbol) error
ReplaceFileSymbols idempotently rebuilds one file's symbol rows in a single transaction (delete-then-insert), so re-indexing a file is exact, not additive.
func (*SymbolStore) SearchSymbols ¶
func (s *SymbolStore) SearchSymbols(ctx context.Context, q string, limit int) ([]CodeSymbol, error)
SearchSymbols returns symbols whose name CONTAINS q (case-insensitive), deterministically ranked — exact, prefix, substring, then fuzzy — and capped. The seed-resolution fallback when the exact name is not known. When substring finds nothing it falls back to a bounded edit-distance scan so a TYPO still resolves (autenticate -> authenticate), the tier the store previously lacked. Deterministic (literal substring / edit distance + a fixed Go sort); no embeddings, no second runtime. An empty/whitespace query matches nothing (never "everything").
func (*SymbolStore) SetSymbolSearchEpoch ¶
func (s *SymbolStore) SetSymbolSearchEpoch( ctx context.Context, epoch int64, ) error
SetSymbolSearchEpoch moves every derivative row onto one published view epoch. Production publication calls the transaction-scoped equivalent.
func (*SymbolStore) SymbolSearchEpoch ¶
func (s *SymbolStore) SymbolSearchEpoch( ctx context.Context, ) (int64, error)
type SymbolTermMatch ¶
type SymbolTermMatch struct {
// contains filtered or unexported fields
}
SymbolTermMatch makes the exact lexical support inspectable.
func (SymbolTermMatch) Fields ¶
func (m SymbolTermMatch) Fields() []MatchField
func (SymbolTermMatch) MarshalJSON ¶
func (m SymbolTermMatch) MarshalJSON() ([]byte, error)
func (SymbolTermMatch) Term ¶
func (m SymbolTermMatch) Term() string
type SymbolView ¶
type SymbolView interface {
GetByFile(ctx context.Context, filePath string) ([]CodeSymbol, error)
GetByDir(ctx context.Context, dir string) ([]CodeSymbol, error)
GetByName(ctx context.Context, name string) ([]CodeSymbol, error)
}
SymbolView is the read port over the symbol-node store that an EdgeResolver needs to resolve call targets to nodes (scoped per file / package / name). *SymbolStore satisfies it — resolvers depend on this abstraction, not the concrete store (hexagonal).
type TermCoverage ¶
type TermCoverage struct {
// contains filtered or unexported fields
}
TermCoverage is an exact fraction rather than a rank-dependent float.
func (TermCoverage) Covered ¶
func (c TermCoverage) Covered() int
func (TermCoverage) MarshalJSON ¶
func (c TermCoverage) MarshalJSON() ([]byte, error)
func (TermCoverage) Total ¶
func (c TermCoverage) Total() int
type TypeEmbed ¶
TypeEmbed is a Go type and one type it embeds — an anonymous struct field or an embedded interface (Go's composition / "extends"). Both names are bare (package-stripped).
func ExtractGoEmbeds ¶
ExtractGoEmbeds reads one Go file and records each struct/interface embedding (an anonymous field, or an embedded interface) as a (Type, Embedded) pair. Shell (read + parse); pure data out. Unparseable files yield nothing.
func ExtractGoEmbedsFromSource ¶
func ExtractGoEmbedsFromSource(source AdmittedSource) []TypeEmbed
ExtractGoEmbedsFromSource derives Go embedding relations from admitted bytes.
type TypeFacts ¶
type TypeFacts struct {
FuncReturns map[string][]string // funcName -> ordered bare result types
MethodReturns map[string][]string // recvType \x00 methodName -> ordered bare result types
StructFields map[string]map[string]string // structType -> fieldName -> bare type
}
TypeFacts is the package-scoped index needed to infer the types of LOCAL variables (`x := f()`, `x := recv.field.Method()`), so interface-dispatch resolution reaches `:=`-inferred receivers, not only declared ones.
Everything here is PACKAGE-SCOPED on purpose: within one Go package, func names, (receiver, method) pairs, and (struct, field) pairs are all unique, so aggregating across the package's files is collision-free. Cross-package facts are deliberately absent — an unresolvable RHS yields NO inferred type, never a guessed one (the precision-cliff discipline that keeps dispatch edges honest).
func ExtractGoTypeFacts ¶
ExtractGoTypeFacts reads one Go file and records its func/method return types and struct field types. Shell (file read + parse); the recorded facts are pure data. Unparseable files yield empty facts, never an error that aborts a scan.
func ExtractGoTypeFactsFromSource ¶
func ExtractGoTypeFactsFromSource( source AdmittedSource, ) (TypeFacts, error)
ExtractGoTypeFactsFromSource derives package type facts from admitted bytes.
func NewTypeFacts ¶
func NewTypeFacts() TypeFacts
NewTypeFacts returns an empty, ready-to-fill TypeFacts.
type UnresolvedEdge ¶
type UnresolvedEdge struct {
SourceID string
Kind EdgeKind
FilePath string
Line int
Reason ResolutionReason
Origin EdgeOrigin
ResolverVersion string
SourceSnapshotHash string
}
type VueLang ¶
type VueLang struct{}
func (*VueLang) Extensions ¶
func (*VueLang) ExtractSymbolSnapshots ¶
func (v *VueLang) ExtractSymbolSnapshots( source AdmittedSource, ) ([]SymbolSnapshot, error)
func (*VueLang) ExtractSymbolSnapshotsContext ¶
func (v *VueLang) ExtractSymbolSnapshotsContext( ctx context.Context, source AdmittedSource, ) ([]SymbolSnapshot, error)
func (*VueLang) ResolveAdmittedFileEdgeOutcomes ¶
func (v *VueLang) ResolveAdmittedFileEdgeOutcomes( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, ) ([]EdgeResolution, error)
func (*VueLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot ¶
func (v *VueLang) ResolveAdmittedFileEdgeOutcomesWithProjectSnapshot( ctx context.Context, projectRoot string, source AdmittedSource, symbols SymbolView, snapshot *projectIndexSnapshot, ) ([]EdgeResolution, error)
func (*VueLang) ResolveFileEdgeOutcomes ¶
func (v *VueLang) ResolveFileEdgeOutcomes(ctx context.Context, projectRoot, relPath string, symbols SymbolView) ([]EdgeResolution, error)
func (*VueLang) ResolveFileEdgeOutcomesWithProjectSnapshot ¶
func (v *VueLang) ResolveFileEdgeOutcomesWithProjectSnapshot( ctx context.Context, projectRoot string, relPath string, symbols SymbolView, snapshot *projectIndexSnapshot, ) ([]EdgeResolution, error)
func (*VueLang) ResolveFileEdges ¶
func (*VueLang) SymbolLanguage ¶
type VueParseStatus ¶
func InspectVueAdmittedParse ¶
func InspectVueAdmittedParse(source AdmittedSource) VueParseStatus
func InspectVueAdmittedParseContext ¶
func InspectVueAdmittedParseContext( ctx context.Context, source AdmittedSource, ) VueParseStatus
func InspectVueParse ¶
func InspectVueParse(projectRoot, relPath string) VueParseStatus
type WorkerCount ¶
type WorkerCount struct {
// contains filtered or unexported fields
}
WorkerCount is a validated positive parser-worker quantity.
func NewWorkerCount ¶
func NewWorkerCount(value int64) (WorkerCount, error)
func (WorkerCount) Value ¶
func (c WorkerCount) Value() int64
Source Files
¶
- admission.go
- binding.go
- c_cpp.go
- callsites.go
- codeedges.go
- coverage.go
- detector.go
- dispatch.go
- freshness.go
- go.go
- go_embeds.go
- incremental.go
- index_disposition.go
- index_epoch.go
- integrity.go
- jsts.go
- python.go
- python_calls.go
- python_edges.go
- registry.go
- resolution_outcome.go
- resolver.go
- rust.go
- symbol_adapter.go
- symbol_anchor.go
- symbol_discovery.go
- symbols.go
- symhash.go
- symstore.go
- ts_calls.go
- ts_edges.go
- ts_project_model.go
- ts_references.go
- ts_resolve.go
- ts_symbols.go
- typefacts.go
- vue.go
- walker.go