Skip to content

fix(daemon): make embedding convergence opt in (#845) - #863

Merged
Sinity merged 3 commits into
masterfrom
feature/fix/daemon-embed-opt-in
May 6, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/fix/daemon-embed-opt-in

Conversation

@Sinity

@Sinity Sinity commented May 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Daemon convergence now treats vector embedding rebuilds as an explicit opt-in stage instead of enabling them whenever VOYAGE_API_KEY exists. 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 polylogued stuck in the embed convergence stage during catch-up because the stage was enabled solely by VOYAGE_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 the embed stage only when both VOYAGE_API_KEY is present and POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS is set to 1, true, or yes. 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

    • Updated architecture, configuration, and daemon documentation to clarify that daemon-side embeddings are now opt-in, requiring explicit environment variable configuration to enable vector search functionality.
  • Chores

    • Updated error messages to provide clearer guidance on enabling daemon embeddings when using similarity search features.
    • Updated tests to validate the new opt-in embedding behavior.

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
Copilot AI review requested due to automatic review settings May 6, 2026 22:50
@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 20 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a603f9b-ccae-467b-9992-020f0e98890d

📥 Commits

Reviewing files that changed from the base of the PR and between d307cb7 and 0768506.

📒 Files selected for processing (4)
  • docs/architecture.md
  • docs/daemon.md
  • polylogue/cli/query.py
  • tests/unit/cli/test_query_exec.py
📝 Walkthrough

Walkthrough

The pull request makes daemon-side embedding explicitly opt-in by introducing a new environment variable POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS. When unset or falsy, the convergence pipeline excludes the embed stage entirely. Documentation, error messages, and tests are updated to reflect this configuration requirement.

Changes

Daemon Embedding Opt-in

Layer / File(s) Summary
Configuration Documentation
docs/configuration.md, docs/daemon.md, docs/architecture.md
POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS environment variable is documented as the opt-in control for daemon embedding. Clarified that VOYAGE_API_KEY is only read when embedding convergence is explicitly enabled, and that embeddings generation is fully built but dormant by default.
Core Stage Selection
polylogue/daemon/convergence_stages.py
Default convergence stage builder now conditionally includes the embed stage only when POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS is truthy and VOYAGE_API_KEY is present. The _embedding_env_enabled() function updated to require both flags.
User-Facing Error Messages
polylogue/cli/query.py
Error text for --similar queries updated to reference "enable daemon embedding convergence" instead of prior phrasing, directing users to the new opt-in requirement.
Tests & Test Environment
tests/unit/daemon/test_convergence_stages.py, tests/unit/cli/test_query_exec.py
New tests verify stage composition changes based on POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS. Existing embed-stage test now explicitly sets the env flag. Query execution test assertions updated to match new error message text.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~18 minutes

Possibly related PRs

  • Sinity/polylogue#831: Introduced the convergence stages framework that this PR extends to make the embed stage conditional.
  • Sinity/polylogue#791: Integrated embed stage into daemon pipeline execution; this PR makes that integration optional.

Poem

🐰 A daemon once embedded with care,
Now waits for a flag to declare—
"Opt-in, please do say!
Before I'd embed away,"
The rabbit hops with newfound flair! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making embedding convergence opt-in for the daemon, which aligns with the changeset's core objective.
Description check ✅ Passed The description follows the template structure with all required sections completed: Summary, Problem, Solution, Verification, and Changelog consideration noted.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/daemon-embed-opt-in

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fbf1197 and d307cb7.

📒 Files selected for processing (7)
  • docs/architecture.md
  • docs/configuration.md
  • docs/daemon.md
  • polylogue/cli/query.py
  • polylogue/daemon/convergence_stages.py
  • tests/unit/cli/test_query_exec.py
  • tests/unit/daemon/test_convergence_stages.py

Comment thread docs/daemon.md Resolved
Comment thread polylogue/cli/query.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 embed is included only when VOYAGE_API_KEY is set and POLYLOGUE_DAEMON_ENABLE_EMBEDDINGS is truthy.
  • Update CLI error messaging for --similar and 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.

Comment thread polylogue/cli/query.py
Comment on lines 382 to 386
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,
)
Comment thread polylogue/cli/query.py Outdated
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.",
Comment thread docs/daemon.md Outdated
Comment on lines +189 to +193
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.
Comment thread docs/architecture.md Outdated
Comment on lines +160 to +162
- **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)).
Sinity added 2 commits May 7, 2026 01:07
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
@Sinity
Sinity merged commit 09b5e90 into master May 6, 2026
2 checks passed
@Sinity
Sinity deleted the feature/fix/daemon-embed-opt-in branch May 6, 2026 23:21
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants