Repository navigation
fix(daemon): make embedding convergence opt in (#845) - #863
Conversation
Problem: daemon catch-up treated VOYAGE_API_KEY as enough to run the embed convergence stage, so ordinary live convergence could block on provider API work during startup or catch-up. What changed: default convergence now runs FTS and insights only; the embed stage is included only when POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS is explicitly enabled with VOYAGE_API_KEY. Query errors and docs now describe the opt-in contract. Verification: devtools verify Ref #845
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe pull request makes daemon-side embedding explicitly opt-in by introducing a new environment variable ChangesDaemon Embedding Opt-in
Estimated code review effort🎯 2 (Simple) | ⏱️ ~18 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/daemon.md`:
- Around line 189-193: Update the daemon docs to clarify that the embedding
opt-in flag POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS accepts multiple truthy values
(e.g., 1, true, yes) rather than only "=1"; mention that when VOYAGE_API_KEY is
set and POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS is enabled (1/true/yes) the daemon
will generate embeddings stored in the message_embeddings vec0 virtual table and
used by the --similar search and the hybrid retrieval lane, and note that
embedding convergence remains opt-in so ordinary daemon catch-up does not call
provider APIs.
In `@polylogue/cli/query.py`:
- Around line 382-385: The error message in the similar-text branch (the if
checking plan.selection.similar_text and vector_provider is None in
polylogue/cli/query.py) is too prescriptive; change the click.echo to report
that vector provider initialization failed (generic failure), then append a
suggested remediation mentioning common causes such as missing VOYAGE_API_KEY or
disabled daemon embedding convergence. Keep the message concise, neutral about
cause, and preserve that it is printed to stderr.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a0efc67a-f068-4533-ae8a-7ac68d06c05c
📒 Files selected for processing (7)
docs/architecture.mddocs/configuration.mddocs/daemon.mdpolylogue/cli/query.pypolylogue/daemon/convergence_stages.pytests/unit/cli/test_query_exec.pytests/unit/daemon/test_convergence_stages.py
There was a problem hiding this comment.
Pull request overview
This PR makes daemon embedding convergence an explicit opt-in, so default live convergence doesn’t block on external embedding provider calls unless the operator enables it.
Changes:
- Gate the default daemon convergence stage list so
embedis included only whenVOYAGE_API_KEYis set andPOLYLOGUE_DAEMON_ENABLE_EMBEDDINGSis truthy. - Update CLI error messaging for
--similarand adjust unit tests to reflect the new opt-in contract. - Refresh daemon/configuration/architecture docs to describe embedding convergence as opt-in.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
polylogue/daemon/convergence_stages.py |
Makes embed stage inclusion conditional on an explicit opt-in env var plus VOYAGE_API_KEY. |
tests/unit/daemon/test_convergence_stages.py |
Adds coverage for default stage selection with/without embedding opt-in; updates embed-stage test setup. |
polylogue/cli/query.py |
Updates --similar error guidance to refer to enabling daemon embedding convergence. |
tests/unit/cli/test_query_exec.py |
Updates assertions to match the new --similar error wording. |
docs/daemon.md |
Documents embedding convergence as opt-in to avoid provider calls during ordinary catch-up. |
docs/configuration.md |
Adds POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS and clarifies when VOYAGE_API_KEY is consulted for indexing. |
docs/architecture.md |
Updates embedding pipeline description to reflect opt-in daemon integration behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if plan.selection.similar_text and vector_provider is None: | ||
| click.echo( | ||
| "Error: --similar requires vector search support. Configure VOYAGE_API_KEY and daemon-managed embeddings first.", | ||
| "Error: --similar requires vector search support. Configure VOYAGE_API_KEY and enable daemon embedding convergence first.", | ||
| err=True, | ||
| ) |
| if archive_stats.embedded_messages <= 0: | ||
| click.echo( | ||
| "Error: --similar requires existing embeddings. Build embeddings through the daemon before querying.", | ||
| "Error: --similar requires existing embeddings. Enable daemon embedding convergence and let embeddings build before querying.", |
| When `VOYAGE_API_KEY` is set and `POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS=1`, the | ||
| daemon can generate vector embeddings for message content. Embeddings are stored | ||
| in the `message_embeddings` vec0 virtual table and used by the `--similar` | ||
| search and `hybrid` retrieval lane. Embedding convergence is opt-in so ordinary | ||
| daemon catch-up does not make provider API calls. |
| - **Integration**: Daemon-side post-ingest embedding is opt-in with | ||
| `POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS=1`; default live convergence does not call | ||
| the embedding provider during catch-up ([#828](https://github.com/Sinity/polylogue/issues/828)). |
Problem: PR review noted that the new daemon embedding flag accepts more than one truthy value and that --similar setup failures should not imply a single root cause. What changed: daemon docs now list the accepted opt-in values, and the --similar error explains that vector provider initialization may have failed or be disabled while still pointing at VOYAGE_API_KEY and daemon embedding convergence. Verification: devtools verify Ref #845
Problem: follow-up review noted that the similar-search remediation and architecture docs should name the exact daemon embedding opt-in flag and accepted values. What changed: similar-search errors now mention POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS=1/true/yes directly, tests assert that wording, and the architecture reference matches the accepted truthy values. Verification: devtools verify Ref #845
Live daemon verification showed `polylogued` stuck in the embed convergence stage during catch-up because the stage was enabled solely by the presence of `VOYAGE_API_KEY`. Ordinary daemon convergence depended on external embedding throughput and obscured the actual ingest / read-model convergence performance work in #845. `make_default_convergence_stages()` now includes the `embed` stage only when both `VOYAGE_API_KEY` is present AND `POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS` is `1`/`true`/`yes`. Default daemon catch-up runs FTS repair and insights refresh only, so daemon startup and convergence do not block on provider API calls unless the operator explicitly opts in. Query error text and the architecture / configuration / daemon docs describe the opt-in contract; unit tests pin the default stage list with and without the opt-in. Refs #845
Single-file follow-up to PR #863. The embedding convergence stage was checking `os.environ` directly for the opt-in flag, duplicating the lookup the rest of the daemon already gets from `PolylogueConfig`. Routes the check through the typed config in `polylogue/daemon/convergence_stages.py` so changes to the embedding flag (TOML, env, or programmatic) take effect uniformly. Refs #828
Live daemon verification showed `polylogued` stuck in the embed convergence stage during catch-up because the stage was enabled solely by the presence of `VOYAGE_API_KEY`. Ordinary daemon convergence depended on external embedding throughput and obscured the actual ingest / read-model convergence performance work in #845. `make_default_convergence_stages()` now includes the `embed` stage only when both `VOYAGE_API_KEY` is present AND `POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS` is `1`/`true`/`yes`. Default daemon catch-up runs FTS repair and insights refresh only, so daemon startup and convergence do not block on provider API calls unless the operator explicitly opts in. Query error text and the architecture / configuration / daemon docs describe the opt-in contract; unit tests pin the default stage list with and without the opt-in. Refs #845
Single-file follow-up to PR #863. The embedding convergence stage was checking `os.environ` directly for the opt-in flag, duplicating the lookup the rest of the daemon already gets from `PolylogueConfig`. Routes the check through the typed config in `polylogue/daemon/convergence_stages.py` so changes to the embedding flag (TOML, env, or programmatic) take effect uniformly. Refs #828
Summary
Daemon convergence now treats vector embedding rebuilds as an explicit opt-in stage instead of enabling them whenever
VOYAGE_API_KEYexists. Default live catch-up runs FTS repair and insights refresh only, so daemon startup and convergence do not block on provider API calls unless the operator asks for embedding convergence.Problem
Live daemon verification showed
polyloguedstuck in the embed convergence stage during catch-up because the stage was enabled solely byVOYAGE_API_KEY. That made ordinary daemon convergence depend on external embedding throughput and obscured the actual ingest/read-model convergence performance work in #845.Solution
make_default_convergence_stages()now includes theembedstage only when bothVOYAGE_API_KEYis present andPOLYLOGUE_DAEMON_ENABLE_EMBEDDINGSis set to1,true, oryes. Query error text and daemon/configuration/architecture docs now describe that explicit opt-in contract, and unit tests pin the default stage list with and without the opt-in.Ref #845
Verification
ruff format --check polylogue/daemon/convergence_stages.py polylogue/cli/query.py tests/unit/daemon/test_convergence_stages.py tests/unit/cli/test_query_exec.py && ruff check polylogue/daemon/convergence_stages.py polylogue/cli/query.py tests/unit/daemon/test_convergence_stages.py tests/unit/cli/test_query_exec.py— passed.mypy --strict polylogue/daemon/convergence_stages.py polylogue/cli/query.py tests/unit/daemon/test_convergence_stages.py tests/unit/cli/test_query_exec.py—Success: no issues found in 4 source files.pytest tests/unit/daemon/test_convergence_stages.py tests/unit/cli/test_query_exec.py -q—75 passed in 13.36s.devtools render-all --check— all generated surfaces in sync.devtools verify—verify: all checks passed.Summary by CodeRabbit
Documentation
Chores