{"modulePath":"github.com/Rogercode97/scouter","version":"v1.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package engine\n\n## Constants\n\n```go\nconst MaxFragmentSize = 100 * 1024\n```\nMaxFragmentSize is the limit for a surgical read (100KB)\n\n```go\nconst MaxParseSize = 5 * 1024 * 1024\n```\nMaxParseSize is the limit for indexing a file (5MB)\n\n## Variables\n\n```go\nvar BlockedDirs = map[string]bool{\n\t\"vendor\":       true,\n\t\"node_modules\": true,\n\t\".git\":         true,\n\t\"dist\":         true,\n\t\"build\":        true,\n}\n```\n\n```go\nvar ErrEmptySource = errors.New(\"source file is empty\")\n```\nErrEmptySource indicates the resolved file contains no data.\n\n```go\nvar ErrInterruptedCommit = errors.New(\"ledger: an interrupted commit must be resolved before committing again\")\n```\nErrInterruptedCommit is returned when a commit is attempted while the journal still records an interrupted commit. The operator resolves it first, with Rollback or RollForward.\n\n```go\nvar PPool = \u0026parserPool{\n\tpools: make(map[*gotreesitter.Language]*sync.Pool),\n}\n```\n\n```go\nvar SupportedExts = map[string]bool{\n\t\".go\":   true,\n\t\".ts\":   true,\n\t\".tsx\":  true,\n\t\".js\":   true,\n\t\".py\":   true,\n\t\".java\": true,\n\t\".rs\":   true,\n}\n```\n\n## Functions\n\n```go\nfunc AnalyzeInterfaceImplementations(prog *ssa.Program) map[string][]string\n```\nAnalyzeInterfaceImplementations finds all concrete implementations of interfaces.\n\n```go\nfunc AnonymizeNode(node *gotreesitter.Node, source []byte, lang *gotreesitter.Language, includeBody bool) string\n```\nAnonymizeNode traverses the tree from the given node and returns an anonymized S-Expression. It masks identifiers and literals to preserve only the structural logic. When includeBody is false, function/method bodies are skipped (signature-only hash). When includeBody is true, bodies are included (full logic hash).\n\n```go\nfunc ApplyPipeline(ctx context.Context, f *filter.Filter, input string, resolver filter.SourceResolver) (string, error)\n```\nApplyPipeline executes filter actions sequentially.\n\n```go\nfunc BatchLoadPackages(dir string) (map[string]*ParsedPackageData, error)\n```\n\n```go\nfunc EncodeZON(slice interface{}) (string, error)\n```\nEncodeZON implements a minimal ZON (Zero Overhead Notation) table encoder. It converts slices of structs into a token-efficient tabular format for LLMs, saving 35-70% of tokens compared to JSON.\n\n```go\nfunc EncodeZONImpact(res *types.ImpactResult) string\n```\n\n```go\nfunc EncodeZONLSPHover(hover *lsp.Hover) (string, error)\n```\n\n```go\nfunc EncodeZONLSPLocation(locs []lsp.Location) (string, error)\n```\n\n```go\nfunc EncodeZONNeighborhood(filePath string, imports []string, exports []store.Symbol, calls []store.Call) string\n```\nEncodeZONNeighborhood formats a 1-hop structural neighborhood (imports, exports, calls) into ZON format.\n\n```go\nfunc EncodeZONPredict(tests []types.TestTarget) string\n```\n\n```go\nfunc EncodeZONVerify(diff *ChronosDiff) string\n```\n\n```go\nfunc ExtractImports(ctx context.Context, filePath string) ([]string, error)\n```\n\n```go\nfunc GetLogicHash(node *gotreesitter.Node, source []byte, lang *gotreesitter.Language) string\n```\nGetLogicHash generates a SHA-256 hash including the function body for detecting internal logic changes.\n\n```go\nfunc GetParser(lang *gotreesitter.Language) *gotreesitter.Parser\n```\n\n```go\nfunc GetStructuralHash(node *gotreesitter.Node, source []byte, lang *gotreesitter.Language) string\n```\nGetStructuralHash generates a SHA-256 hash of the anonymized structural representation (signature only).\n\n```go\nfunc ParseFile(ctx context.Context, filePath string, lspMgr *lsp.Manager) ([]types.ASTPointer, []types.ASTCall, []types.DataFlow, error)\n```\nParseFile analyzes a file using the AST engine to index its structure and call graph. It is now a wrapper around StreamSymbols for backward compatibility.\n\n```go\nfunc ParseGoMod(ctx context.Context, filePath string) ([]types.Dependency, error)\n```\nParseGoMod reads a go.mod file and extracts its dependencies.\n\n```go\nfunc ParsePackageJSON(ctx context.Context, filePath string) ([]types.Dependency, error)\n```\nParsePackageJSON reads a package.json file and extracts its dependencies.\n\n```go\nfunc Passthrough(ctx context.Context, command string, args []string) (int, error)\n```\nPassthrough runs a command with inherited stdio (no capture).\n\n```go\nfunc PutParser(lang *gotreesitter.Language, parser *gotreesitter.Parser)\n```\n\n```go\nfunc ReadFragment(ctx context.Context, filePath string, r types.Range) (string, error)\n```\nReadFragment reads a specific code fragment from a file within the given range.\n\n```go\nfunc SSACallGraph(ctx context.Context, dir string) ([]types.ASTCall, error)\n```\nSSACallGraph generates a high-precision call graph using SSA and CHA.\n\n```go\nfunc StreamSymbols(ctx context.Context, filePath string) (iter.Seq[types.ASTPointer], iter.Seq[types.ASTCall], iter.Seq[types.DataFlow], error)\n```\nStreamSymbols analyzes a file and returns iterators for symbols, calls and data flows. Optimized for Go 1.25 to avoid large slice allocations.\n\n```go\nfunc StreamSymbolsFromAST(ctx context.Context, fset *token.FileSet, astFile *ast.File, pkg *packages.Package) (iter.Seq[types.ASTPointer], iter.Seq[types.ASTCall], iter.Seq[types.DataFlow], error)\n```\n\n```go\nfunc StreamWithTreeSitter(ctx context.Context, filePath string) (iter.Seq[types.ASTPointer], iter.Seq[types.ASTCall], iter.Seq[types.DataFlow], error)\n```\n\n```go\nfunc StructuralRefactor(ctx context.Context, filePath, pattern, template, ext string) (string, error)\n```\n\n## Types\n\n```go\ntype ASTRuleEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nASTRuleEngine executes architectural rules using ast-grep.\n\n```go\nfunc NewASTRuleEngine(rulesDir string) *ASTRuleEngine\n```\nNewASTRuleEngine creates a new engine pointing to the rules directory.\n\n```go\nfunc (e *ASTRuleEngine) Audit(ctx context.Context, targetPath string) ([]types.ASTRuleMatch, error)\n```\nAudit runs all rules in the rules directory against a specific file or directory.\n\n```go\nfunc (e *ASTRuleEngine) GetRules() ([]string, error)\n```\nGetRules returns a list of available rule files.\n\n```go\ntype AnalysisEngine struct {\n\tProjectRoot string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAnalysisEngine(store AnalysisStore) *AnalysisEngine\n```\n\n```go\nfunc (a *AnalysisEngine) BuildTypeUniverse() (map[string]*types.Package, error)\n```\n\n```go\nfunc (a *AnalysisEngine) GetCriticalSymbols(ctx context.Context, limit int) ([]store.CriticalSymbol, error)\n```\n\n```go\nfunc (a *AnalysisEngine) GetNeighborhood(ctx context.Context, filePath string) (string, error)\n```\n\n```go\nfunc (a *AnalysisEngine) ResolveCentrality(ctx context.Context) error\n```\n\n```go\nfunc (a *AnalysisEngine) ResolveInterfaces(ctx context.Context) error\n```\n\n```go\nfunc (a *AnalysisEngine) ResolvePagerank(ctx context.Context, opts ...PagerankOption) error\n```\n\n```go\ntype AnalysisStore interface {\n\tstore.SymbolRegistry\n\tstore.StructuralGraph\n\tstore.DiagnosticStore\n\tstore.TransactionManager\n}\n```\nAnalysisStore defines the data requirements for the AnalysisEngine.\n\n```go\ntype AnalyzeOption func(*AnalyzeOptions)\n```\n\n```go\nfunc WithSSA(targetPkg, varName string) AnalyzeOption\n```\n\n```go\ntype AnalyzeOptions struct {\n\tUseSSA       bool\n\tSSATargetPkg string\n\tSSAVarName   string\n}\n```\n\n```go\ntype BFSPropagationStrategy struct {\n\tImpactEngine ImpactAnalyzer\n\t// contains filtered or unexported fields\n}\n```\nBFSPropagationStrategy implements PropagationStrategy using BFS traversal.\n\n```go\nfunc NewBFSPropagationStrategy(s GraphStore, ie ImpactAnalyzer) *BFSPropagationStrategy\n```\nNewBFSPropagationStrategy creates a new breadth-first propagation strategy.\n\n```go\nfunc (s *BFSPropagationStrategy) Discover(ctx context.Context, startSymbol string, maxDepth int) iter.Seq2[PropagationTask, error]\n```\n\n```go\ntype BuildValidator struct{}\n```\nBuildValidator ensures the project still builds after changes.\n\n```go\nfunc (v *BuildValidator) Validate(ctx context.Context, ledger *Ledger) (ValidationResult, error)\n```\n\n```go\ntype CentralityValidator struct {\n\t// contains filtered or unexported fields\n}\n```\nCentralityValidator detects architectural regressions via centrality spikes.\n\n```go\nfunc NewCentralityValidator(a *AnalysisEngine) *CentralityValidator\n```\n\n```go\nfunc (v *CentralityValidator) Validate(ctx context.Context, ledger *Ledger) (ValidationResult, error)\n```\n\n```go\ntype ChronosDiff struct {\n\tMissingSymbols []string // Symbols that existed before but were deleted\n\tMangledSymbols []string // Symbols whose structural hash changed (broken syntax/logic)\n\tAddedSymbols   []string // New symbols added\n\tUnchanged      int      // Number of symbols that remained perfectly intact\n}\n```\nChronosDiff represents the structural differences found after an edit.\n\n```go\ntype ChronosEngine struct{}\n```\n\n```go\nfunc NewChronosEngine() *ChronosEngine\n```\n\n```go\nfunc (e *ChronosEngine) CompareSnapshot(ctx context.Context, snapshot *ChronosSnapshot, currentFilePath string) (*ChronosDiff, error)\n```\nCompareSnapshot verifies a file against a previously taken snapshot.\n\n```go\nfunc (e *ChronosEngine) SemanticDiff(ctx context.Context, target string) (string, error)\n```\n\n```go\nfunc (e *ChronosEngine) TakeSnapshot(ctx context.Context, filePath string) (*ChronosSnapshot, error)\n```\nTakeSnapshot reads a file and captures its structural AST hashes.\n\n```go\ntype ChronosSnapshot struct {\n\tID        string\n\tFilePath  string\n\tSymbols   map[string]types.ASTPointer // Key: Symbol Name\n\tTimestamp time.Time\n}\n```\nChronosSnapshot represents a point-in-time structural map of a file.\n\n```go\ntype ChurnEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nChurnEngine analyzes the git history to identify tectonic plates (co-changing files).\n\n```go\nfunc NewChurnEngine(s ChurnStore) *ChurnEngine\n```\n\n```go\nfunc (e *ChurnEngine) AnalyzeChurn(ctx context.Context, repoPath string, commitLimit int) error\n```\nAnalyzeChurn calculates the co-change metrics and updates the store.\n\n```go\ntype ChurnStore interface {\n\tstore.SymbolRegistry\n\tstore.TransactionManager\n}\n```\nChurnStore defines the data requirements for the ChurnEngine.\n\n```go\ntype CommitPhase string\n```\nCommitPhase is the state of the mission recorded in the journal.\n\n```go\nconst (\n\t// PhaseStaged means the changes are staged and no commit was attempted.\n\tPhaseStaged CommitPhase = \"staged\"\n\t// PhaseCommitting means a commit started and did not reach its end. Only\n\t// the journal can describe the resulting tree.\n\tPhaseCommitting CommitPhase = \"committing\"\n)\n```\n\n```go\ntype CompactionEngine struct {\n\tLedger *Ledger\n\t// contains filtered or unexported fields\n}\n```\nCompactionEngine handles context hygiene and latent memory anchoring.\n\n```go\nfunc NewCompactionEngine(s store.Store, l *Ledger) *CompactionEngine\n```\n\n```go\nfunc (e *CompactionEngine) CompactSession(ctx context.Context, truthKernel string) (*types.CompactionResult, error)\n```\nCompactSession persists a boundary and provides the resumption prompt.\n\n```go\nfunc (e *CompactionEngine) CreateBoundary(ctx context.Context, truthKernel string) (*SovereignBoundary, error)\n```\nCreateBoundary generates a dense checkpoint of the current engine state.\n\n```go\nfunc (e *CompactionEngine) PruneHistory(toolResults []string) []string\n```\nPruneHistory reduces the token weight of tool results while preserving signal.\n\n```go\ntype ContextEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nContextEngine synthesizes single-shot architectural context packets for AI agents.\n\n```go\nfunc NewContextEngine(s ContextStore) *ContextEngine\n```\n\n```go\nfunc (e *ContextEngine) BuildFileContext(ctx context.Context, filePath string) (*types.FileContextResult, error)\n```\nBuildFileContext returns an ultra-compact single-call context packet for a given file.\n\n```go\ntype ContextStore interface {\n\tGraphStore\n}\n```\n\n```go\ntype DiagnosticContext struct {\n\tFailingFile  string\n\tErrorLog     string\n\tOriginalCode string\n\tPrompt       string\n\tTarget       *types.ASTPointer\n}\n```\nDiagnosticContext contains everything needed to propose a fix.\n\n```go\ntype DiagnosticEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nDiagnosticEngine is the read-only diagnosis entry point.\n\nDoctor contract (ported from Engram's DOCTOR.md): diagnosis never mutates. Diagnose, DiagnoseHUD, AssessRisk and ExtractRCA perform no writes: no Ledger staging, no memory observation, no store mutation, no cursor or index change. Mutation lives behind explicit entry points only: HealerEngine.Fix stages a fix in the Ledger (STAGED, never applied), and applying a staged fix requires an explicit commit/rollback decision. A diagnostic report therefore never implies a tree change.\n\n```go\nfunc NewDiagnosticEngine(\n\ts store.DiagnosticStore,\n\ta *AnalysisEngine,\n\ti *ImpactEngine,\n\tl *lsp.Manager,\n\tsearch *SearchEngine,\n) *DiagnosticEngine\n```\n\n```go\nfunc (e *DiagnosticEngine) AssessRisk(ctx context.Context, symbol, path string) (*RiskAssessment, error)\n```\nAssessRisk provides a unified risk assessment.\n\n```go\nfunc (e *DiagnosticEngine) BuildHealerContext(ctx context.Context, target *types.ASTPointer, failingFile, errorLog string, allMatches [][]string, originalCode string) string\n```\n\n```go\nfunc (e *DiagnosticEngine) Diagnose(ctx context.Context, errorLog string) (*DiagnosticReport, error)\n```\nDiagnose parses logs and enriches the failure context.\n\n```go\nfunc (e *DiagnosticEngine) DiagnoseHUD(ctx context.Context, errorLog string) (*DiagnosticHUD, error)\n```\nDiagnoseHUD ejecuta la visión de diagnóstico combinando Git, AST, Impacto y FTS. Retorna la representación del HUD en formato ZON.\n\n```go\nfunc (e *DiagnosticEngine) ExtractRCA(errorLog string) (string, int, [][]string, error)\n```\n\n```go\ntype DiagnosticHUD struct {\n\tFailingSymbol      string\n\tLastCommit         string\n\tRiskLevel          string\n\tRiskScore          float64\n\tBlastRadius        int\n\tSimilarPatternPath string\n}\n```\nDiagnosticHUD representa la visión térmica/estructural del motor de diagnóstico.\n\n```go\ntype DiagnosticProvider interface {\n\tDiagnose(ctx context.Context, errorLog string) (*DiagnosticReport, error)\n\tAssessRisk(ctx context.Context, symbol, path string) (*RiskAssessment, error)\n\tExtractRCA(errorLog string) (string, int, [][]string, error)\n\tBuildHealerContext(ctx context.Context, target *types.ASTPointer, failingFile, errorLog string, allMatches [][]string, originalCode string) string\n}\n```\n\n```go\ntype DiagnosticReport struct {\n\tFailingSymbol string\n\tFailingFile   string\n\tLine          int\n\tErrorLog      string\n\tContext       string\n\tRisk          *types.ImpactResult\n\tInsights      []string // Historical insights from Engram\n}\n```\nDiagnosticReport represents the \"Technical Truth\" kernel of a failure.\n\n```go\ntype Embedder interface {\n\tGenerateEmbedding(ctx context.Context, text string) ([]float32, error)\n}\n```\n\n```go\ntype Enricher struct {\n\t// contains filtered or unexported fields\n}\n```\nEnricher coordinates semantic enrichment of the call graph using LSP.\n\n```go\nfunc NewEnricher(s EnricherStore, lp LSPProvider) *Enricher\n```\n\n```go\nfunc (e *Enricher) Enrich(ctx context.Context) error\n```\nEnrich methods with implementation data from LSP.\n\n```go\ntype EnricherStore interface {\n\tstore.SymbolRegistry\n\tstore.StructuralGraph\n\tstore.TransactionManager\n}\n```\nEnricherStore defines the data requirements for the Enricher.\n\n```go\ntype EvolutionEngine struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewEvolutionEngine(store store.Store, ledger *Ledger, ripple *RippleEngine) *EvolutionEngine\n```\n\n```go\nfunc (e *EvolutionEngine) CommitLedger(ctx context.Context) (string, error)\n```\n\n```go\nfunc (e *EvolutionEngine) GetLedgerDiff(ctx context.Context) (string, error)\n```\n\n```go\nfunc (e *EvolutionEngine) GetLedgerSummary(ctx context.Context) string\n```\n\n```go\nfunc (e *EvolutionEngine) Propagate(ctx context.Context, symbol, transformation string, messenger Messenger) (string, error)\n```\n\n```go\nfunc (e *EvolutionEngine) ProposeEvolution(ctx context.Context, proposal string, force bool, messenger Messenger) (string, error)\n```\n\n```go\nfunc (e *EvolutionEngine) RollbackLedger(ctx context.Context) (string, error)\n```\n\n```go\nfunc (e *EvolutionEngine) StageMutation(ctx context.Context, filePath, newContent string) error\n```\n\n```go\nfunc (e *EvolutionEngine) StagedLedger() *Ledger\n```\nStagedLedger returns the canonical ledger this engine stages into. Callers inspect it directly instead of re-reading the staging file.\n\n```go\ntype FixCandidate struct {\n\tID       int\n\tCode     string\n\tFullCode string\n\tValid    bool\n\tScore    float64\n}\n```\nFixCandidate represents a potential fix.\n\n```go\ntype GraphStore interface {\n\tstore.SymbolRegistry\n\tstore.StructuralGraph\n}\n```\nGraphStore defines the core read-only graph traversal capabilities.\n\n```go\ntype HealerEngine struct {\n\tLedger *Ledger\n\n\t// Bridge to MCP sampling\n\tDoFixRequest func(ctx context.Context, prompt string) (string, error)\n\n\tSearch *SearchEngine\n\n\tDiagnostic DiagnosticProvider\n\t// contains filtered or unexported fields\n}\n```\nHealerEngine manages the autonomous RCA -\u003e Fix -\u003e Verify loop using the Shinigami Protocol.\n\n```go\nfunc NewHealerEngine(s TransactionalStore, l *lsp.Manager, a *AnalysisEngine, i *ImpactEngine, search *SearchEngine, mem memory.MemoryProvider, diag DiagnosticProvider) *HealerEngine\n```\n\n```go\nfunc (e *HealerEngine) Fix(ctx context.Context, errorLog string) (*types.HealResult, error)\n```\nFix attempts to repair a test failure using the Shinigami Protocol (Solver-Verifier).\n\nMutation boundary: Fix STAGES the winning candidate in the Ledger and records one memory observation. It never applies, commits, or rolls back: the staged fix takes effect only through an explicit commit/rollback decision on the Ledger. Callers that only need a diagnosis must use DiagnosticEngine and never reach this entry point.\n\n```go\nfunc (e *HealerEngine) Index(ctx context.Context, path string) error\n```\nIndex parses and persists a file. (Internal helper for HealerEngine)\n\n```go\nfunc (e *HealerEngine) SetFixRequestHook(hook func(ctx context.Context, prompt string) (string, error))\n```\nSetFixRequestHook allows setting the hook for LLM fix requests.\n\n```go\ntype HealthEngine struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewHealthEngine(store TestResultStore) *HealthEngine\n```\n\n```go\nfunc (h *HealthEngine) Ingest(ctx context.Context, r io.Reader) error\n```\n\n```go\ntype ImpactAnalyzer interface {\n\tGetDeterministicCallers(ctx context.Context, symbolName string) ([]store.Call, error)\n}\n```\nImpactAnalyzer abstracts the capabilities of the ImpactEngine required by other engines.\n\n```go\ntype ImpactEngine struct {\n\tLSPManager *lsp.Manager\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewImpactEngine(s GraphStore, lm *lsp.Manager, mem memory.MemoryProvider) *ImpactEngine\n```\n\n```go\nfunc (e *ImpactEngine) Analyze(ctx context.Context, symbol string, path string, maxDepth int, opts ...AnalyzeOption) (*types.ImpactResult, error)\n```\nAnalyze performs a deep impact analysis for a given symbol.\n\n```go\nfunc (e *ImpactEngine) GetDeterministicCallers(ctx context.Context, symbolName string) ([]store.Call, error)\n```\n\n```go\nfunc (e *ImpactEngine) IdentifyCriticalContext(ctx context.Context, diff string) ([]types.ImpactEntity, error)\n```\nIdentifyCriticalContext finds high-risk symbols affected by the current diff.\n\n```go\nfunc (e *ImpactEngine) PredictTests(ctx context.Context, diff string) ([]types.TestTarget, error)\n```\nPredictTests identifies tests affected by changes described in the diff string.\n\n```go\ntype IndexerConfig struct {\n\tStore    store.Store\n\tSemantic Embedder\n\tAnalyzer *AnalysisEngine\n\tSearch   *SearchEngine\n\tASTRules *ASTRuleEngine\n\tChurn    *ChurnEngine\n\tLogger   *slog.Logger\n}\n```\n\n```go\ntype IndexerPipeline struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewIndexerPipeline(cfg IndexerConfig) *IndexerPipeline\n```\n\n```go\nfunc (ip *IndexerPipeline) Index(ctx context.Context, path string) error\n```\n\n```go\ntype LLMSolver struct {\n\tDoFixRequest func(ctx context.Context, prompt string) (string, error)\n}\n```\n\n```go\nfunc (s *LLMSolver) Generate(ctx context.Context, diag *DiagnosticContext) (\u003c-chan FixCandidate, error)\n```\n\n```go\ntype LSPProvider interface {\n\tGetClient(ctx context.Context, filePath string) (lsp.LSPClient, error)\n}\n```\nLSPProvider defines the requirement for retrieving an LSP client.\n\n```go\ntype LSPValidator struct {\n\tProjectRoot string\n}\n```\nLSPValidator uses go/packages with Overlays to perform zero-disk verification of interface implementations across the entire workspace.\n\n```go\nfunc NewLSPValidator(root string) *LSPValidator\n```\n\n```go\nfunc (v *LSPValidator) Validate(ctx context.Context, ledger *Ledger) (ValidationResult, error)\n```\n\n```go\ntype LSPVerifier struct{}\n```\n\n```go\nfunc (v *LSPVerifier) Evaluate(ctx context.Context, diag *DiagnosticContext, c *FixCandidate) (bool, error)\n```\n\n```go\ntype LanguageConfig struct {\n\tLanguage    *gotreesitter.Language\n\tQuery       *gotreesitter.Query\n\tCallQuery   *gotreesitter.Query\n\tImportQuery *gotreesitter.Query\n\tFlowQuery   *gotreesitter.Query\n}\n```\n\n```go\ntype Ledger struct {\n\tStaged    map[string]Patch `json:\"staged\"`\n\tStats     MissionStats     `json:\"stats\"`\n\tKiLimit   int64            `json:\"ki_limit\"`\n\tTurnLimit int              `json:\"turn_limit\"`\n\tProject   string           `json:\"project\"`\n\tPhase     CommitPhase      `json:\"phase,omitempty\"`\n\tApplied   []string         `json:\"applied,omitempty\"`\n\tPending   []string         `json:\"pending,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\nLedger holds staged changes and mission metrics.\n\n```go\nfunc NewLedger() *Ledger\n```\n\n```go\nfunc (l *Ledger) AffectedFiles() []string\n```\nAffectedFiles is an alias for StagedFiles.\n\n```go\nfunc (l *Ledger) CommitStaged(ctx context.Context) error\n```\nCommitStaged applies all staged changes to the filesystem using a two-phase commit.\n\nEach file is replaced atomically, but the batch is not atomic across files: the files are applied one at a time, in sorted path order. The journal therefore records the commit before the filesystem is touched, and keeps the list of files already replaced, so an interrupted commit can be resolved afterwards with Rollback or RollForward.\n\n```go\nfunc (l *Ledger) GetStaged() []Patch\n```\nGetStaged returns all pending patches.\n\n```go\nfunc (l *Ledger) HasInterruptedCommit() bool\n```\nHasInterruptedCommit reports whether the journal records a commit that started and did not finish.\n\n```go\nfunc (l *Ledger) IncrementTurn()\n```\nIncrementTurn advances the mission turn counter.\n\n```go\nfunc (l *Ledger) InterruptedAppliedFiles() []string\n```\nInterruptedAppliedFiles returns the files the interrupted commit had already replaced.\n\n```go\nfunc (l *Ledger) InterruptedPendingFiles() []string\n```\nInterruptedPendingFiles returns the files the interrupted commit had not replaced yet.\n\n```go\nfunc (l *Ledger) Load() error\n```\nLoad restores the ledger state from disk.\n\n```go\nfunc (l *Ledger) RollForward(ctx context.Context) error\n```\nRollForward completes an interrupted commit by applying the files it had not replaced yet. It is the explicit counterpart of Rollback: the operator decides which side of the interruption the tree ends on.\n\n```go\nfunc (l *Ledger) Rollback(ctx context.Context) error\n```\nRollback clears the staged changes.\n\nWhen the journal records an interrupted commit, the files that commit already replaced are restored first, so the tree returns to the state it had before the commit. A file whose content changed after the interruption is never overwritten: the rollback fails instead of destroying work that the journal does not know about.\n\n```go\nfunc (l *Ledger) Save() error\n```\nSave persists the current ledger state to disk.\n\n```go\nfunc (l *Ledger) SetBudget(kiLimit int64, turnLimit int)\n```\nSetBudget sets the limits for the current mission.\n\n```go\nfunc (l *Ledger) SetLedgerPath(path string)\n```\nSetLedgerPath updates the persistence path and attempts to load it.\n\n```go\nfunc (l *Ledger) Stage(path string, patch Patch) error\n```\nStage adds a patch to the ledger and saves to disk.\n\n```go\nfunc (l *Ledger) StagedFiles() []string\n```\nStagedFiles returns the list of paths in the ledger.\n\n```go\nfunc (l *Ledger) Summary() string\n```\nSummary returns a human-readable mission report.\n\n```go\nfunc (l *Ledger) Unstage(path string)\n```\nUnstage removes a patch from the ledger.\n\n```go\ntype LineProvenance struct {\n\tLine           int\n\tCommit         string\n\tAuthor         string\n\tEngineeringEra string\n}\n```\nLineProvenance tracks the origin of a specific line.\n\n```go\nfunc GetFileProvenance(ctx context.Context, repoPath, filePath string) ([]LineProvenance, error)\n```\nGetFileProvenance performs a deep blame analysis using go-git to reconstruct the evolutionary narrative of a file.\n\n```go\ntype Linker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLinker(logger *slog.Logger) *Linker\n```\n\n```go\nfunc (l *Linker) LinkInterfaces(ctx context.Context, repo store.Store, lspMgr *lsp.Manager) error\n```\nLinkInterfaces performs semantic linking between interfaces and their implementations using the LSP 'textDocument/implementation' request.\n\n```go\ntype LocalFileResolver struct{}\n```\nLocalFileResolver implements filter.SourceResolver for local filesystem reads.\n\n```go\nfunc (r *LocalFileResolver) ResolveSource(ctx context.Context, file string, line int) (string, error)\n```\nResolveSource fetches a context window around a specific line in a file. It returns a 5-line window (2 before, 2 after the target line).\n\n```go\ntype MCPTransformer struct {\n\tDoTransform func(ctx context.Context, file, symbol, transformation string) (string, error)\n\t// contains filtered or unexported fields\n}\n```\nMCPTransformer implements Transformer using MCP Sampling.\n\n```go\nfunc NewMCPTransformer(s GraphStore, bridge func(context.Context, string, string, string) (string, error)) *MCPTransformer\n```\n\n```go\nfunc (t *MCPTransformer) Transform(ctx context.Context, file, symbol, transformation string) (string, error)\n```\n\n```go\ntype Messenger interface {\n\tAsk(ctx context.Context, systemPrompt, message string) (string, error)\n}\n```\nMessenger provides a callback for asking questions to an oracle (LLM/User)\n\n```go\ntype MissionStats struct {\n\tStartTime  time.Time `json:\"start_time\"`\n\tTotalKi    int64     `json:\"total_ki\"`   // Token usage (approximated)\n\tTurnCount  int       `json:\"turn_count\"` // Number of iterations\n\tFilesCount int       `json:\"files_count\"`\n}\n```\nMissionStats tracks the resource consumption of the current operation.\n\n```go\ntype PagerankOption func(*PagerankOptions)\n```\n\n```go\nfunc WithTaskSeeds(seeds []string) PagerankOption\n```\n\n```go\ntype PagerankOptions struct {\n\tTaskSeeds []string\n}\n```\n\n```go\ntype ParsedPackageData struct {\n\tFile *ast.File\n\tFset *token.FileSet\n\tPkg  *packages.Package\n}\n```\n\n```go\ntype Patch struct {\n\tFilePath   string      `json:\"file_path\"`\n\tOriginal   string      `json:\"original,omitempty\"`\n\tNewContent string      `json:\"new_content\"`\n\tDiff       string      `json:\"diff,omitempty\"`\n\tMode       os.FileMode `json:\"mode,omitempty\"`\n\tIsNew      bool        `json:\"is_new,omitempty\"`\n}\n```\nPatch represents a pending file modification.\n\n```go\ntype Pipeline struct {\n\tRegistry   *filter.Registry\n\tTracker    *telemetry.Tracker\n\tLSPManager *lsp.Manager\n\n\tTeeConfig    tee.Config\n\tVerbose      int\n\tGainLevel    int // 0: compact, 1: signal (SNR), 2: raw\n\tUltraCompact bool\n\tEnrich       bool\n\t// contains filtered or unexported fields\n}\n```\nPipeline orchestrates command execution, filtering, tracking, and tee.\n\n```go\nfunc (p *Pipeline) PassiveHealthIngest(ctx context.Context, output string)\n```\nPassiveHealthIngest parses test results from stdout and updates the risk map.\n\n```go\nfunc (p *Pipeline) Passthrough(ctx context.Context, command string, args []string) int\n```\nPassthrough runs a command directly without filtering.\n\n```go\nfunc (p *Pipeline) Run(ctx context.Context, command string, args []string) int\n```\nRun executes a command through the full pipeline.\n\n```go\nfunc (p *Pipeline) ShadowIndex(ctx context.Context)\n```\nShadowIndex re-indexes files modified by the current execution.\n\n```go\ntype PropagationStrategy interface {\n\tDiscover(ctx context.Context, startSymbol string, depth int) iter.Seq2[PropagationTask, error]\n}\n```\nPropagationStrategy defines the traversal logic for symbol discovery.\n\n```go\ntype PropagationTask struct {\n\tSymbolName     string // Local name for matching (e.g., \"Greet\")\n\tImpactedSymbol string // FQN of the impacted symbol (e.g., \"tests.S1.Greet\")\n\tFilePath       string\n\tAction         string\n}\n```\nPropagationTask represents a single unit of work in the ripple propagation.\n\n```go\ntype Result struct {\n\tStdout   string\n\tStderr   string\n\tExitCode int\n\tDuration time.Duration\n}\n```\nResult holds the output of a command execution.\n\n```go\nfunc Execute(ctx context.Context, command string, args []string) (*Result, error)\n```\nExecute runs a command, capturing stdout and stderr concurrently via goroutines.\n\n```go\ntype RippleEngine struct {\n\tTransformer  Transformer\n\tImpactEngine ImpactAnalyzer\n\tStrategy     PropagationStrategy\n\tValidators   []Validator\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewRippleEngine(s GraphStore, t Transformer, ie ImpactAnalyzer) *RippleEngine\n```\n\n```go\nfunc (e *RippleEngine) Propagate(ctx context.Context, symbolName string, transformation string, maxDepth int) (*Ledger, error)\n```\nPropagate traces the blast radius of a symbol and applies the transformation to all affected files.\n\n```go\ntype RiskAssessment struct {\n\tSymbol     string\n\tPath       string\n\tRiskScore  float64\n\tCentrality int\n\tCallers    int\n\tRiskLevel  string\n}\n```\nRiskAssessment consolidates centrality and blast radius metrics.\n\n```go\ntype SearchEngine struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSearchEngine(s store.SymbolRegistry, m memory.MemoryProvider, sem Embedder) *SearchEngine\n```\n\n```go\nfunc (e *SearchEngine) FindLogicalTwins(ctx context.Context, symbolName, path string) ([]types.Symbol, error)\n```\n\n```go\nfunc (e *SearchEngine) HybridSearch(ctx context.Context, query string, limit, offset int, pathPrefix string) (*types.HybridSearchResult, error)\n```\nHybridSearch executes parallel lookups in the AST, FTS, and Engram databases.\n\n```go\nfunc (e *SearchEngine) IndexSymbol(docID string, data map[string]interface{}) error\n```\n\n```go\ntype SemanticEngine struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSemanticEngine() (*SemanticEngine, error)\n```\n\n```go\nfunc (s *SemanticEngine) GenerateEmbedding(ctx context.Context, text string) ([]float32, error)\n```\n\n```go\nfunc (s *SemanticEngine) Init(ctx context.Context, modelPath string) error\n```\n\n```go\ntype ShinigamiPipeline struct {\n\t// contains filtered or unexported fields\n}\n```\nShinigamiPipeline orchestrates the Solver and Verifier.\n\n```go\nfunc NewShinigamiPipeline(s Solver, v Verifier) *ShinigamiPipeline\n```\n\n```go\nfunc (p *ShinigamiPipeline) Run(ctx context.Context, diag *DiagnosticContext) (*FixCandidate, error)\n```\n\n```go\ntype Solver interface {\n\tGenerate(ctx context.Context, diag *DiagnosticContext) (\u003c-chan FixCandidate, error)\n}\n```\nSolver is the generative interface (LLM/AI).\n\n```go\ntype SovereignBoundary struct {\n\tID          string           `json:\"boundary_id\"`\n\tTruthKernel string           `json:\"truth_kernel\"` // Dense summary of discoveries\n\tStagingArea map[string]Patch `json:\"staging_area\"` // Current Ledger state\n\tBudget      MissionStats     `json:\"budget\"`       // Ki/Turns consumption\n\tTimestamp   string           `json:\"timestamp\"`\n}\n```\nSovereignBoundary represents a technical checkpoint in the conversation.\n\n```go\ntype StructuralMatch struct {\n\tPath      string            `json:\"path\"`\n\tRange     types.Range       `json:\"range\"`\n\tStartLine int               `json:\"start_line\"`\n\tEndLine   int               `json:\"end_line\"`\n\tContent   string            `json:\"content\"`\n\tCaptures  map[string]string `json:\"captures\"`\n}\n```\n\n```go\nfunc StructuralSearch(ctx context.Context, rootPath, pattern, ext string) ([]StructuralMatch, error)\n```\n\n```go\nfunc StructuralSearchWithRule(ctx context.Context, rootPath string, rule types.StructuralRule, ext string) ([]StructuralMatch, error)\n```\n\n```go\ntype StructuralTransformer struct {\n\tPattern string\n}\n```\nStructuralTransformer implements Transformer using structural search and replace.\n\n```go\nfunc (t *StructuralTransformer) Transform(ctx context.Context, file, symbol, transformation string) (string, error)\n```\n\n```go\ntype TestResultStore interface {\n\tSaveTestResult(ctx context.Context, res *types.TestResult) error\n}\n```\n\n```go\ntype TestValidator struct {\n\tSpecificTests []string\n}\n```\nTestValidator ensures relevant tests still pass.\n\n```go\nfunc (v *TestValidator) Validate(ctx context.Context, ledger *Ledger) (ValidationResult, error)\n```\n\n```go\ntype TransactionalStore interface {\n\tGraphStore\n\tstore.DiagnosticStore\n\tstore.TransactionManager\n}\n```\nTransactionalStore defines the complete contract required by HealerEngine.\n\n```go\ntype Transformer interface {\n\tTransform(ctx context.Context, file string, symbolName string, transformation string) (string, error)\n}\n```\nTransformer defines how to modify a file based on a symbolic change.\n\n```go\ntype ValidationResult struct {\n\tValid   bool\n\tMessage string\n\tDetails map[string]any\n}\n```\nValidationResult carries the outcome of a validation stage.\n\n```go\ntype Validator interface {\n\tValidate(ctx context.Context, ledger *Ledger) (ValidationResult, error)\n}\n```\nValidator defines the interface for verifying the integrity of staged changes.\n\n```go\ntype Verifier interface {\n\tEvaluate(ctx context.Context, diag *DiagnosticContext, c *FixCandidate) (bool, error)\n}\n```\nVerifier evaluates a candidate's validity (LSP/AST).\n\n","path":"github.com/Rogercode97/scouter/internal/engine","name":"engine","synopsis":"","isRedistributable":true}
