Repository navigation
feat: add bounded embedding preflight - #1531
Conversation
Problem: semantic embedding catch-up can already be bounded by conversation or message count, but the preflight path still estimated the entire backlog and the selector grouped over every message before returning small windows. On the live archive, a ten-conversation preflight could time out before showing the operator a safe first batch. What changed: add bounded preflight options, make backfill confirmation preview the same bounded window it will execute, and have pending-window selection use conversation_stats when available so small windows avoid whole-archive message aggregation. Verification: pytest -q tests/unit/cli/test_embed_activation.py::TestPreflightCommand tests/unit/cli/test_embed_activation.py::TestBackfillCommand::test_backfill_passes_bounded_window_options tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_conversations tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_messages tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_conversation_stats_when_available --tb=short; ruff format --check polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py; ruff check polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py; python -m mypy polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py; POLYLOGUE_FORCE_PLAIN=1 timeout 30 polylogue embed preflight --max-conversations 10; devtools verify --quick
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 50 minutes and 29 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. 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 PR extends embedding CLI preflight and backfill commands to accept optional window limits (--max-conversations, --max-messages), scoping pending conversation/message counts to a bounded subset instead of full backlog. PreflightReport now carries windowing metadata; pending counting branches to use select_pending_conversation_window when limits are provided; and that SQL query conditionally uses precomputed conversation_stats table for message counts when available. ChangesWindowed Pending Conversation Limiting
🎯 3 (Moderate) | ⏱️ ~25 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89597007d7
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@polylogue/cli/commands/embed.py`:
- Line 74: The CLI is importing a substrate internal function
select_pending_conversation_window from
polylogue.storage.embeddings.materialization; change the CLI to call a public
API entrypoint instead—add or expose a wrapper in polylogue.api
(api/__init__.py) that calls select_pending_conversation_window (or equivalent
materialization logic) and then update polylogue/cli/commands/embed.py to import
from polylogue.api and call that public function (e.g., a newly exported
select_pending_conversation_window or named wrapper) so the CLI only depends on
the public api surface.
🪄 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: bf4630db-ac78-4c29-8b47-e0220eea6c05
📒 Files selected for processing (5)
docs/verification-catalog.mdpolylogue/cli/commands/embed.pypolylogue/storage/embeddings/materialization.pytests/unit/cli/test_embed_activation.pytests/unit/storage/test_embedding_contracts.py
Problem: the bounded embedding selector used conversation_stats for every bounded window. Those stats can lag direct message writes, which makes --max-messages and bounded cost preflight underestimate the real selected batch. What changed: keep conversation_stats for conversation-count windows, but force live message counts whenever max_messages is present. Add a regression with stale stats proving the message cap follows actual message rows. Verification: pytest -q tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_conversation_stats_when_available tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_live_counts_for_message_bound tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_messages tests/unit/cli/test_embed_activation.py::TestPreflightCommand::test_preflight_passes_bounded_window_options --tb=short; ruff format --check polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py; ruff check polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py; python -m mypy polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py
|
Addressed the review finding in eedd014. is now used only when is absent; message-bounded windows use live message counts so the cap and cost estimate are not understated by stale stats. Added with deliberately stale stats. Focused checks and pre-push { |
Problem: embed preflight imported the storage materialization helper directly from the CLI callback, crossing the CLI/substrate boundary even though this is an operator-facing public workflow. What changed: expose select_pending_embedding_conversation_window from polylogue.api and have the CLI call that public API wrapper for bounded preflight windows. Verification: pytest -q tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_live_counts_for_message_bound tests/unit/cli/test_embed_activation.py::TestPreflightCommand tests/unit/cli/test_embed_activation.py::TestBackfillCommand::test_backfill_passes_bounded_window_options --tb=short; ruff format --check polylogue/api/__init__.py polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py tests/unit/cli/test_embed_activation.py; ruff check polylogue/api/__init__.py polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py tests/unit/cli/test_embed_activation.py; python -m mypy polylogue/api/__init__.py polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/storage/test_embedding_contracts.py tests/unit/cli/test_embed_activation.py
|
Review fixes pushed.
Verification after the fixes:
|
## Summary `polylogue embed status` now prints explicit bounded next actions for semantic-search activation and first catch-up. `docs/search.md` documents the same activation flow, including the distinction between fast conversation-count windows and hard live-count message windows. ## Problem After #1531/#1532, the mechanics for bounded embedding catch-up and daemon progress existed, but the operator still had to infer the safe first commands from status fields and docs spread across search/architecture. On the live archive this matters: embeddings are disabled, the key is present, and there are 7,951 pending conversations, so the next step must be obvious and bounded. ## Solution Embedding status now prints: - activation command when config is disabled, - bounded preflight command, - bounded backfill command, - daemon-enabled wording when the daemon stage is already enabled. Search docs now include the activation/catch-up sequence and explicitly state that `--max-messages` uses live counts because it is a hard cap, while `--max-conversations` may use materialized stats for speed. ## Verification - `pytest -q tests/unit/cli/test_embed_status_fast.py --tb=short` — 8 passed. - `ruff format --check polylogue/cli/shared/embed_stats.py tests/unit/cli/test_embed_status_fast.py` — passed. - `ruff check polylogue/cli/shared/embed_stats.py tests/unit/cli/test_embed_status_fast.py` — passed. - `python -m mypy polylogue/cli/shared/embed_stats.py tests/unit/cli/test_embed_status_fast.py` — passed. - `POLYLOGUE_FORCE_PLAIN=1 timeout 20 polylogue embed status` — live read-only smoke showed the new activation/preflight/backfill lines against the real archive. - `devtools render-all --check` — passed after refreshing the docs site cache. - `devtools verify --quick` — passed. Ref #1503
|
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
Adds bounded
polylogue embed preflightwindows and makesembed backfillpreview the exact bounded batch it is about to run. The pending conversation selector now usesconversation_statswhen available, so small operator windows do not first aggregate every message in the archive.Problem
Semantic embedding catch-up is intentionally bounded by
--max-conversationsand--max-messages, but preflight still estimated the full backlog. Worse, the pending-window query grouped acrossmessagesbefore returning a small window; on the live archive,polylogue embed preflight --max-conversations 10could time out instead of showing a safe first batch.Solution
embed preflightaccepts the same conversation/message window options as backfill. Backfill passes those options into the confirmation preflight so the operator sees the real planned window.select_pending_conversation_windownow readsconversation_stats.message_countwhen present, falling back to per-conversation counts only when stats are absent, and keeps SQL fragments within the storage SQL-audit contract.Verification
pytest -q tests/unit/cli/test_embed_activation.py::TestPreflightCommand tests/unit/cli/test_embed_activation.py::TestBackfillCommand::test_backfill_passes_bounded_window_options tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_conversations tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_messages tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_conversation_stats_when_available --tb=short— 6 passed.pytest -q tests/unit/storage/test_no_string_interpolated_sql.py::test_no_unaudited_string_interpolated_sql tests/unit/storage/test_embedding_contracts.py::test_pending_window_uses_conversation_stats_when_available tests/unit/storage/test_embedding_contracts.py::test_pending_window_honors_max_messages --tb=short— 3 passed.ruff format --check polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py— passed.ruff check polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py— passed.python -m mypy polylogue/cli/commands/embed.py polylogue/storage/embeddings/materialization.py tests/unit/cli/test_embed_activation.py tests/unit/storage/test_embedding_contracts.py— passed.POLYLOGUE_FORCE_PLAIN=1 timeout 30 polylogue embed preflight --max-conversations 10— returned a 10-conversation, 2,034-message live archive estimate.devtools verify --quick— passed.devtools verify— passed: 9,450 passed, 2 xfailed under pytest-testmon.Ref #1503
Summary by CodeRabbit
New Features
--max-conversationsand--max-messagesoptions to theembed preflightcommand for bounded window analysisPerformance
Documentation