Skip to content

feat: record daemon embedding progress - #1532

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/daemon-embedding-progress
May 25, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/daemon-embedding-progress

Conversation

@Sinity

@Sinity Sinity commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Daemon embedding convergence now records the same durable embedding_catchup_runs progress ledger as manual polylogue 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_sync now selects the pending daemon batch up front, starts an embedding_catchup_runs row 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_info now includes the latest catch-up run when present, and polylogued status plain 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

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
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

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 @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 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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 77a378b2-bff2-4a57-8774-f5e309fb2e4d

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2b86d and c910fec.

📒 Files selected for processing (4)
  • polylogue/daemon/convergence_stages.py
  • polylogue/daemon/embedding_readiness.py
  • polylogue/daemon/status.py
  • tests/unit/daemon/test_embedding_convergence_progress.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/daemon-embedding-progress

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.

@Sinity
Sinity merged commit f727678 into master May 25, 2026
6 checks passed
@Sinity
Sinity deleted the feature/feat/daemon-embedding-progress branch May 25, 2026 01:40

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines 895 to 900
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Sinity added a commit that referenced this pull request May 25, 2026
## 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
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.

1 participant