Skip to content

feat: expose embedding catch-up metrics - #1524

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

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

Conversation

@Sinity

@Sinity Sinity commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Expose semantic-embedding backlog and latest catch-up progress through the daemon /metrics Prometheus surface, so operational dashboards can see whether semantic search is ready, catching up, or stalled without running polylogue embed status manually.

Problem

#1503 is about making semantic embeddings operational on live archives. #1523 added a durable catch-up ledger and CLI status visibility, but daemon observability still missed the embedding backlog and latest run state. That meant normal ops tooling could not see the semantic-search readiness gap.

Solution

  • Add bounded /metrics series for embedding conversation totals, embedded/pending/failed counts, embedded message count, and coverage percentage.
  • Add latest embedding_catchup_runs metrics for run status, rebuild mode, planned/processed/embedded/skipped/failed conversations, planned/embedded messages, and estimated cost.
  • Keep scrapes bounded by deliberately not calculating exact pending-message counts on every Prometheus scrape.
  • Tolerate fresh and partial embedding table sets without 5xx or query failures.
  • Extend the metrics endpoint contract tests and internals docs.

Ref #1503

Verification

  • pytest -q tests/unit/daemon/test_metrics_endpoint.py --tb=short — 15 passed.
  • ruff format --check polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py — passed.
  • ruff check polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py — passed.
  • python -m mypy polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py — passed.
  • timeout 10 python ... format_metrics(get_config().db_path) against live archive — completed; reported 7,951 pending embedding conversations, 0 embedded, no catch-up run.
  • devtools verify --quick — passed.
  • devtools verify — passed: 9448 passed, 2 xfailed via pytest-testmon.
  • Pre-push devtools verify --quick — passed.

Problem: semantic-search catch-up state was visible through CLI status, but daemon dashboards and scrapers could not see embedding backlog or the latest persisted catch-up run.

What changed: add Prometheus series for embedding conversation backlog, embedded message count, coverage percentage, and latest embedding_catchup_runs progress. Keep scrapes bounded by avoiding exact pending-message counts, tolerate partial embedding tables, and update the metrics contract tests and internals docs.

Verification: pytest -q tests/unit/daemon/test_metrics_endpoint.py --tb=short; ruff format --check polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py; ruff check polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py; python -m mypy polylogue/daemon/metrics.py tests/unit/daemon/test_metrics_endpoint.py; timeout 10 python metrics smoke against live archive; devtools verify --quick; devtools verify.

Ref #1503
@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 38 minutes and 3 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: c90406f7-9975-45d0-a484-fd3d708cbd57

📥 Commits

Reviewing files that changed from the base of the PR and between b6b4737 and 09c14bb.

📒 Files selected for processing (4)
  • AGENTS.md
  • docs/internals.md
  • polylogue/daemon/metrics.py
  • tests/unit/daemon/test_metrics_endpoint.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/embedding-metrics-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 f42f053 into master May 25, 2026
7 checks passed
@Sinity
Sinity deleted the feature/feat/embedding-metrics-progress branch May 25, 2026 00:33

@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: 09c14bbc39

ℹ️ 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 thread polylogue/daemon/metrics.py Resolved
Sinity added a commit that referenced this pull request May 25, 2026
## 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
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 63.F118 / P2: refuted at the checked revision: The requested fallback explicitly supports a partially initialized or legacy embedding_catchup_runs column set. AGENTS.md:192-194 rejects compatibility branches for prior archive shapes; restoring that old-schema read is outside the fresh-format contract rather than an accepted metrics requirement.

Only the rows listed above are dispositioned. Held findings remain open.

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