Repository navigation
feat: record daemon embedding progress - #1532
Conversation
Problem: manual embedding backfill persisted catch-up progress, but daemon embedding convergence ran bounded batches without creating catch-up ledger rows. Operators could see metrics for manual runs, but daemon-driven embedding work remained opaque. What changed: daemon embedding batches now start, update, and finalize embedding_catchup_runs entries with planned counts, progress, skipped/error rows, embedded messages, estimated cost, and stop reasons. Daemon embedding readiness carries the latest catch-up run, and plain status output renders the latest run summary. Verification: pytest -q tests/unit/daemon/test_embedding_convergence_progress.py tests/unit/daemon/test_metrics_endpoint.py::TestFormatMetricsReadsArchiveState::test_embedding_backlog_and_latest_catchup_state --tb=short; ruff format --check polylogue/daemon/convergence_stages.py polylogue/daemon/embedding_readiness.py polylogue/daemon/status.py tests/unit/daemon/test_embedding_convergence_progress.py; ruff check polylogue/daemon/convergence_stages.py polylogue/daemon/embedding_readiness.py polylogue/daemon/status.py tests/unit/daemon/test_embedding_convergence_progress.py; python -m mypy polylogue/daemon/convergence_stages.py polylogue/daemon/embedding_readiness.py polylogue/daemon/status.py tests/unit/daemon/test_embedding_convergence_progress.py
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 32 minutes and 14 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)
✨ 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: c910fec4bc
ℹ️ 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".
| logger.info("embed: %d done, %d errors, est. cost $%.4f", embedded, errors, cumulative_cost) | ||
| if stop_reason is not None: | ||
| finish_embedding_catchup_run(db_path, run_id, status="stopped", stop_reason=stop_reason) | ||
| else: | ||
| finish_embedding_catchup_run(db_path, run_id, status="completed", stop_reason=None) | ||
| return errors == 0 |
There was a problem hiding this comment.
Finalize catch-up run when embed loop errors
Ensure the catch-up run is closed in an exception path: finish_embedding_catchup_run(...) is only called after the loop succeeds, so any unexpected exception inside the loop (for example from record_embedding_catchup_progress during a transient SQLite write failure) exits early and leaves the row in running forever. That corrupts daemon observability because status/metrics will continue reporting an in-flight run that has already aborted.
Useful? React with 👍 / 👎.
## 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
Summary
Daemon embedding convergence now records the same durable
embedding_catchup_runsprogress ledger as manualpolylogue embed backfill. Daemon status also carries and renders the latest embedding catch-up run, so operator surfaces can explain daemon-driven embedding work without relying only on Prometheus metrics.Problem
#1523 made manual embedding backfill resumability visible, and #1524 exposed that ledger in metrics. The daemon embed stage still ran bounded batches without starting/updating/finalizing a catch-up run. That made daemon-driven semantic-search catch-up opaque: a live daemon could be doing embedding work, but
embed status,/metrics, and daemon status had no shared run record to explain the current or latest daemon batch.Solution
_embed_conversations_syncnow selects the pending daemon batch up front, starts anembedding_catchup_runsrow with planned conversation/message counts, records per-conversation embedded/skipped/error progress, and finalizes the run as completed, stopped, or failed with a stop reason. The legacy unit-test seam where the helper is called against an empty touched DB remains supported by treating the provided IDs as the pending window.embedding_readiness_infonow includes the latest catch-up run when present, andpolylogued statusplain output shows the latest embedding catch-up status/progress inline with the embedding readiness section.Verification
pytest -q tests/unit/daemon/test_embedding_readiness.py::test_embed_loop_counts_errors_and_returns_false tests/unit/daemon/test_embedding_readiness.py::test_embed_loop_halts_when_cost_cap_exceeded tests/unit/daemon/test_embedding_readiness.py::test_embed_loop_no_cost_cap_processes_all tests/unit/daemon/test_embedding_convergence_progress.py tests/unit/daemon/test_metrics_endpoint.py::TestFormatMetricsReadsArchiveState::test_embedding_backlog_and_latest_catchup_state --tb=short— 7 passed.pytest -q tests/unit/ui/test_tui.py::test_search_flow --tb=short— passed when rerun individually after the first broad run exposed a transient UI failure.pytest -q tests/unit/storage/test_scale.py::TestPerformanceBudget::test_get_many_performance_budget --tb=short— passed when rerun individually after the first broad run exposed a transient setup/perf failure.ruff check polylogue/daemon/convergence_stages.py polylogue/daemon/embedding_readiness.py polylogue/daemon/status.py tests/unit/daemon/test_embedding_convergence_progress.py tests/unit/daemon/test_embedding_readiness.py— passed.python -m mypy polylogue/daemon/convergence_stages.py polylogue/daemon/embedding_readiness.py polylogue/daemon/status.py tests/unit/daemon/test_embedding_convergence_progress.py tests/unit/daemon/test_embedding_readiness.py— passed.devtools verify --quick— passed.devtools verify— passed: 9,454 passed, 2 xfailed under pytest-testmon.Ref #1503