feat(brain): runtime embedding config + incremental per-symbol embedding - #501
Merged
Conversation
- Add BrainConfig to .cora.yaml with brain.embedding mode (auto|hashing|pretrained) - Refactor embed dispatch from compile-time to runtime via resolve_backend() - Migration v7: add embed_fingerprint column to symbols table - Incremental embedding: only re-embed symbols whose name+signature changed - Wire resolve_backend() in cora index, cora brain, cora watch commands Closes #499
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add runtime embedding backend selection via
.cora.yamlconfig and incremental per-symbol embedding to skip unchanged symbols during re-index.Why
Previously, embedding backend was selected at compile time only (
#[cfg(feature = "pretrained-embed")]). Users could not switch between hashing 256d and pretrained 768d without recompiling. Additionally,embed_project()re-embedded all symbols on every index run, even when only 1 file changed — wasting CPU on large projects.Closes #499
How
BrainConfig (
src/config/schema.rs):brain.embeddingfield in.cora.yamlwith values:auto(default),hashing,pretrainedautowith a warningBrainEmbeddingModeenum withDisplay+FromStrimplsRuntime dispatch (
src/embed/mod.rs):Backendenum (Hashing | Pretrained) withdims()andprovider_name()resolve_backend()reads config string, caches viaOnceLockembed_code_dispatch()checksACTIVE_BACKENDat runtime, falls back to compile-time default if unsetbrain.embedding=pretrainedwithout feature flag → warning + hashingIncremental embedding (
src/index/brain.rs):embed_fingerprint TEXTcolumn tosymbolstableembed_project()computesDefaultHasherfingerprint fromname + signatureWiring (
src/main.rs,src/commands/watch.rs):cora index,cora brain,cora watchall callresolve_backend()before embeddingTesting
cargo test --features tree-sitterpasses (881 + 16 + 6 = 903 tests, 0 failures)cargo fmt --all -- --checkpassescargo clippy --all-targets --features tree-sitter -- -D warningspassescargo build --release --features tree-sitterpasses (hashing-only mode)cargo build --release --features tree-sitter,pretrained-embedpasses (dual mode)cora indexon uteke (1106 symbols, 147 files)cora brain "memory recall"returns 8 results with correct FTS5 + vector signals ✅Related Issues
Closes #499
Checklist
feat/brain-runtime-config-499)develop