Repository navigation
feat(embeddings): activation flow + hybrid default + local backend support (#1217) - #1327
Conversation
Wires the dormant embedding pipeline (zero messages embedded in production per #828) into a turnkey operator onboarding flow and promotes hybrid search to the default lane once embeddings exist. New ``polylogue embed`` group: - ``enable`` (alias ``activate``): verifies ``sqlite-vec`` is importable, resolves the Voyage API key (flag / env / existing config), prints a cost preflight, asks for confirmation, and persists ``[embedding] enabled = true`` plus the API key into the user ``polylogue.toml``. ``--no-store-key`` keeps the secret in env only. - ``preflight``: read-only token count + Voyage cost estimate using ``ESTIMATED_TOKENS_PER_MESSAGE`` and ``VOYAGE_4_COST_PER_1M_TOKENS``; never contacts the provider. - ``backfill``: iterates pending conversations with per-conversation cost feedback against ``embedding_max_cost_usd`` as a soft cap. - ``disable``: flips ``enabled = false`` without dropping existing embeddings; previously-embedded messages stay queryable via ``--similar``. - ``status``: coverage / freshness snapshot via the existing ``embedding_status_payload``. Hybrid as default: ``_maybe_elevate_to_hybrid`` in ``polylogue/cli/query.py`` promotes ``retrieval_lane='auto'`` to ``'hybrid'`` only when there's an FTS query, a vector provider is wired, and ``archive_stats.embedded_messages > 0``. ``--lexical`` / ``--semantic`` are root query-mode shortcuts that desugar at ``RootModeRequest.from_params``: ``--lexical`` forces ``retrieval_lane=dialogue`` (FTS-only), ``--semantic`` promotes the query string into ``similar_text`` for vector-only retrieval. Existing ``--retrieval-lane`` choices are unchanged. Surface integration: ``polylogue status`` now includes an ``Embeddings:`` line whenever any messages are embedded so coverage shows up at a glance. Tests in ``tests/unit/cli/test_embed_activation.py`` exercise the TOML splicer, the ``enable``/``preflight``/``disable``/``backfill`` subcommands against a stub provider, the hybrid auto-elevation gating (provider absent, no embeddings, no FTS terms, explicit lane), and the ``--lexical``/``--semantic`` desugaring. Docs: ``docs/architecture.md`` Embedding Pipeline section now describes the activation flow and the hybrid-as-default behavior. Closes #1217.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughThis PR introduces an embedding pipeline activation onboarding flow, enabling users to safely enable embeddings with cost preview and configuration management. It adds a new ChangesEmbedding Activation Onboarding Flow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| path.parent.mkdir(parents=True, exist_ok=True) | ||
| existing = path.read_text(encoding="utf-8") if path.exists() else "" | ||
| updated = _splice_embedding_section(existing, enabled=enabled, voyage_api_key=voyage_api_key) | ||
| path.write_text(updated, encoding="utf-8") |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41ee13fa19
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Wires the dormant embedding pipeline (0 messages embedded in production
per #828) into a turnkey
polylogue embedonboarding flow, makeshybrid search the default lane once embeddings exist, and adds
--lexical/--semanticquery shortcuts. Closes #1217.Problem
The Voyage AI embedding pipeline is fully built but dormant. Activating
it today requires the operator to: install
sqlite-vec, setVOYAGE_API_KEY, hand-editpolylogue.tomlto flipembedding_enabled = true, restart the daemon, and watch apotentially expensive first-embed batch run with no preview. The
acceptance criteria in #1217 ask for a single-command activation with
explicit cost preview, bounded first-embed batching, a clean disable
that preserves existing embeddings, and smoke tests against a stub
provider.
The companion goal — hybrid search as the default once embeddings exist
— is the activation force multiplier: without it, embedding spend
yields no end-user-visible behavior change.
Solution
New
polylogue embedgroup (polylogue/cli/commands/embed.py)embed enable(aliasactivate)sqlite-vec, captures the Voyage key (flag/env/existing config), prints cost preflight, on confirmation writes[embedding] enabled = trueplus the key into the user TOML via a section splicer that preserves comments and unrelated sections.--no-store-keykeeps the secret in env only.embed preflightESTIMATED_TOKENS_PER_MESSAGEandVOYAGE_4_COST_PER_1M_TOKENS; never contacts the provider.embed backfillembedding_max_cost_usdas a soft cap.embed disableenabled = false; existing embeddings remain queryable via--similar.embed statusembedding_status_payload.Hybrid as the default lane
_maybe_elevate_to_hybridinpolylogue/cli/query.pypromotesretrieval_lane='auto'to'hybrid'only when all three hold:there's an FTS query, a vector provider is wired, and
archive_stats.embedded_messages > 0. Otherwise the existingauto → dialoguepath stands.--retrieval-lane dialogue(or thenew
--lexicalshortcut) is never overridden.--lexicaland--semanticquery shortcutsAdded to the root query option group. Desugar at
RootModeRequest.from_params:--lexicalforcesretrieval_lane=dialogue(FTS-only),--semanticpromotes thequery string into
similar_textfor vector-only retrieval. No newspec fields, no parser surface changes downstream.
polylogue statussurfaces embedding coverageThe direct-status path includes an
Embeddings:line whenever anymessages are embedded so coverage shows up alongside FTS readiness.
Out of scope / deferred
ambitious expansionin feat(embeddings): activation onboarding flow with key provisioning, batching, cost preflight #1217 suggests local backends. The CLIshape (key resolution, preflight, backfill, status) is provider-
agnostic enough that adding a local backend is a focused follow-up
PR — the activation flow does not lock anything in. Tracked under
the existing feat(embeddings): activation onboarding flow with key provisioning, batching, cost preflight #1217 narrative.
currently depend on
keyringand adding it would expand theinstall surface for a single field. The key is recorded in the
user-scoped
polylogue.toml(XDG_CONFIG_HOME);--no-store-keyis offered for operators who prefer env-only.
Verification
nix develop -c pytest tests/unit/cli/test_embed_activation.py:20 passed.nix develop -c pytest tests/unit/cli/ tests/unit/storage/ tests/unit/daemon/ tests/unit/core/test_config.py tests/unit/archive/:2660 passed, 1 xfailed.nix develop -c devtools verify --quick:exit_code: 0acrossruff format, ruff check, mypy, render-all, verify-topology,
verify-layering, verify-file-budgets, verify-test-ownership,
verify-closure-matrix, verify-schema-roundtrip, verify-cross-cuts,
verify-suppressions, verify-manifests, verify-ci-workflows,
verify-witness-lifecycle, verify-witness-coverage,
verify-lane-assertions, verify-test-infra-currency, and
verification-impact check.
nix develop -c polylogue embed --helplists the new subcommands;nix develop -c polylogue --helpsurfaces--lexicaland--semanticplus the newembedentry.Closes #1217.
Summary by CodeRabbit
New Features
polylogue embedcommand for activating and managing the embedding pipeline--lexicaland--semanticquery options to override search retrieval behaviorstatusoutput to display embedding statisticsDocumentation