feat(embedding): add strategy-based fallback engine with provenance#7
Merged
feat(embedding): add strategy-based fallback engine with provenance#7
Conversation
…change - add retrieval proofing benchmark fixtures and profile thresholds - add proofing runner, deterministic scoring, and report generation - add retrieval-proof CLI command and smoke CI gate - add tests and docs for local/CI proofing workflow - archive retrieval-quality-proofing change and sync main spec
- add typed embedding strategy config, validation, and deterministic resolution - add anthropic native-first fallback policy with failure-category control - add embedding provenance envelope and persist provenance on chunk embeddings - surface provenance in retrieval metadata and optional provenance logging - add migration runner support for sequential SQL migrations and provenance column - add conformance/policy/provenance tests and rollout documentation - archive embedding-parity-hardening change and sync new capability specs
PR Checks Summary
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a strategy-based, configurable embedding fallback engine with full provenance tracking for the embedding pipeline. It adds explicit strategy selection (primary provider/model + ordered fallback list), startup validation, a provenance envelope persisted to the database, and a feature-flag-gated rollout path. The system is backward-compatible, defaulting to the legacy embedding behavior unless DUBSBOT_EMBEDDING_STRATEGY_V2=1 is set.
Changes:
- New
src/context/embedding/module:strategy.ts(schema/validation),engine.ts(execution with fallback + provenance), andconfig.ts(loading + legacy default mapping). - Refactored
src/db/migrate.tsfrom single-file to glob-based ordered migration runner; addedsrc/db/migrations/0002_embedding_provenance.sqlto addprovenanceJSONB column tochunk_embeddings. - Integration into
full-index.ts(indexing path),hybrid.ts(retrieval metadata),daemon/main.ts, andcli/runtime.ts; new conformance tests intests/embedding-strategy.test.ts; rollout documentation.
Reviewed changes
Copilot reviewed 15 out of 20 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/context/embedding/strategy.ts |
Core schema (Zod), validation, cycle detection, and typed error classes |
src/context/embedding/engine.ts |
BFS fallback execution loop with provenance tracking |
src/context/embedding/config.ts |
Config loading from env, legacy default strategy construction |
src/context/indexer/full-index.ts |
Strategy V2 path for embedding during full indexing |
src/context/retrieval/hybrid.ts |
Exposes provenance fields from DB in retrieval results |
src/db/migrations/0002_embedding_provenance.sql |
Adds provenance JSONB column to chunk_embeddings |
src/db/migrate.ts |
Refactors migration runner from hardcoded single file to glob-ordered multi-file |
src/daemon/main.ts |
Calls loadEmbeddingStrategyConfig() at startup for early validation |
src/cli/runtime.ts |
Loads and exposes embeddingStrategyConfig from the runtime |
tests/embedding-strategy.test.ts |
Conformance tests for config, fallback policy, and provenance completeness |
docs/embedding-strategy-rollout.md |
Rollout and rollback procedure documentation |
README.md |
Documents new env vars and rollout guide link |
openspec/specs/*/spec.md (×2) |
Spec files for new capabilities (with placeholder Purpose sections) |
openspec/changes/archive/*/ |
Archived change proposal, design, tasks documents |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
openspec/specs/anthropic-embedding-fallback-and-provenance/spec.md
Outdated
Show resolved
Hide resolved
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.
Summary
Implements embedding parity hardening with an explicit strategy engine, controlled Anthropic fallback policy, and provenance plumbing across indexing/retrieval.
This PR also archives the OpenSpec change and syncs its capability specs into main OpenSpec specs.
What changed
version: 1.0)provenanceJSON inchunk_embeddingssrc/db/migrations/*.sqlin sorted order0002_embedding_provenance.sqldocs/embedding-strategy-rollout.mdembedding-parity-hardeningopenspec/specs/embedding-strategy-configuration/spec.mdopenspec/specs/anthropic-embedding-fallback-and-provenance/spec.mdFeature gate
Embedding strategy engine is gated by:
DUBSBOT_EMBEDDING_STRATEGY_V2=1Optional:
DUBSBOT_EMBEDDING_STRATEGY_CONFIG_JSONDUBSBOT_EMBEDDING_PROVENANCE_LOG=1Validation
pnpm checkspassed locally:pnpm testpnpm typecheckpnpm lintpnpm buildNotes
codex/feat/retrieval-quality-proofing).🥞 DubStack