Repository navigation
fix: close scope gaps — FTS/quarantine tests, health check wiring (#882/#830) - #903
Conversation
- #882: add quarantine and FTS commit-ordering regression tests - #830: wire periodic health checks into daemon maintenance loop with structured notification logging for non-OK alerts Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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: bc6a015bdc
ℹ️ 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.
Pull request overview
Adds regression coverage around raw-ingest quarantine semantics and FTS trigger/commit ordering, and wires periodic daemon health checks into the long-running maintenance loop.
Changes:
- Add unit tests intended to cover quarantine behavior on validation failure and FTS trigger restoration timing.
- Introduce a periodic daemon health-check task and include it in the daemon’s maintenance task set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/unit/storage/test_backend.py | Adds new regression tests for raw-ingest quarantine logic and FTS trigger/commit behavior. |
| polylogue/daemon/cli.py | Adds a periodic health check coroutine and schedules it alongside other daemon maintenance tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raw_id="raw-1", | ||
| parsed=False, | ||
| parse_error=None, | ||
| parsed_at=None, | ||
| validation_status=ValidationStatus.FAILED, | ||
| ) | ||
| assert state.quarantined is True | ||
|
|
||
| # Parse error also quarantines | ||
| state_with_parse = RawIngestArtifactState( | ||
| raw_id="raw-2", | ||
| parsed=False, | ||
| parse_error="something broke", | ||
| parsed_at=None, | ||
| validation_status=None, | ||
| ) | ||
| assert state_with_parse.quarantined is True | ||
|
|
||
| # Successfully parsed + validated is NOT quarantined | ||
| state_clean = RawIngestArtifactState( | ||
| raw_id="raw-3", | ||
| parsed=True, | ||
| parse_error=None, | ||
| parsed_at="2026-01-01T00:00:00Z", | ||
| validation_status=ValidationStatus.PASSED, | ||
| ) |
| from polylogue.storage.sqlite.schema_ddl_archive import ARCHIVE_STORAGE_DDL | ||
|
|
||
| db = tmp_path / "fts_commit.db" | ||
| conn = sqlite3.connect(str(db)) | ||
| conn.executescript(ARCHIVE_STORAGE_DDL) | ||
| conn.execute("INSERT INTO conversations(conversation_id, provider_name, provider_conversation_id) VALUES(?,?,?)", |
| # After commit, FTS should be populated for both messages | ||
| count = conn.execute("SELECT COUNT(*) FROM messages_fts").fetchone()[0] | ||
| assert count == 2, f"Expected 2 FTS entries, got {count}" |
| send_notifications, | ||
| ) | ||
|
|
||
| health = check_health(tiers=(HealthTier.FAST, HealthTier.MEDIUM)) |
| from polylogue.daemon.health import HealthTier, check_health | ||
| from polylogue.daemon.notifications import ( | ||
| LogNotificationBackend, | ||
| send_notifications, | ||
| ) | ||
|
|
||
| health = check_health(tiers=(HealthTier.FAST, HealthTier.MEDIUM)) | ||
| if health.overall_status != "ok": |
|
|
||
|
|
||
| async def _periodic_health_check() -> None: | ||
| """Run FAST health checks every 5 minutes with structured alert logging.""" |
First production-grade hardening slice for #830 on top of the existing daemon/status substrate. Three new modules and modifications to status and CLI; PR #920 / #903 land the remaining checks and config wiring on top of this. - `polylogue/daemon/health.py`: `HealthTier` enum (FAST / MEDIUM / EXPENSIVE), `HealthAlert` typed model with severity and consecutive-failure tracking, `DaemonHealth` aggregation, and `check_health()` runner. Fast checks cover liveness/disk/WAL; medium covers FTS readiness, raw failure counts, and stale ingest attempts; expensive runs PRAGMA integrity_check. - `polylogue/daemon/backup.py`: `backup_archive()` using `VACUUM INTO` with a file-copy fallback; `--check` dry-run; optional blob-store backup via `--include-blobs`. - `polylogue/daemon/notifications.py`: `NotificationBackend` protocol with `LogNotificationBackend` routing alerts through the structured logger by severity. - `polylogue/daemon/status.py`: `DaemonStatus` gains `health: DaemonHealth`, populated by `build_daemon_status()` and exposed in the JSON payload and text formatter. - `polylogue/daemon/cli.py`: `polylogued health` subcommand with tier selection (`--tier`, `--expensive`), JSON output, and deterministic exit codes (1 on error/critical). - `polylogue/cli/commands/backup.py` + registration: `polylogue backup` with `--output-dir`, `--check`, `--include-blobs`. Closes #830 on the substrate axis; remaining health-check additions land in PR #920. Refs #830
Two follow-ups merged together. - #882 (FTS / quarantine): regression tests in `tests/unit/storage/test_backend.py` pinning the FTS trigger-restore-before-commit ordering and the `quarantined` property's coverage of `validation_status=FAILED` so the original PR #882 fixes cannot silently regress. - #830 (tiered health): `polylogue/daemon/cli.py` wires the periodic health-check loop into the daemon main loop and schedules notifications when a check transitions to a worse severity. Refs #830, #882
Direct, no-PR. Local repair in `tests/unit/storage/test_backend.py`: the wave that landed PRs #882/#903/#911 left two FK-test cases referencing helper names that had been renamed in the same wave, so `devtools verify` failed at the test stage even though every individual PR's CI was green. Realigns the helper names; pure test-file repair, no production code change.
Direct, no-PR. `tests/unit/storage/test_backend.py` accumulated regression cases from the FK / quarantine / FTS / blob waves (PRs #879/#881/#882/#903/#911) and exceeded its previous LOC budget. Bumps `docs/plans/file-size-budgets.yaml` to 1750 so `devtools verify-file-budgets` passes; the tests stay grouped in one place rather than splitting along an arbitrary cut.
Completes #830 on top of the health/backup substrate from PRs #898 / #903: four new health checks across the FAST/MEDIUM/ EXPENSIVE tiers, config-driven notification backend selection, and operator vs. daemon maintenance documentation. - `polylogue/daemon/health.py`: - FAST: `_check_source_availability_fast()` verifies each watch root from `default_sources()` exists and is readable. - MEDIUM: `_check_insight_freshness_medium()` flags >10% gap between session-profile coverage and total conversations. - MEDIUM: `_check_repeated_stage_failures_medium()` reads `live_ingest_attempt` for recent failure rates and samples the latest error. - EXPENSIVE: `_check_blob_integrity_expensive()` runs a bounded `BlobStore.verify_all(max_failures=5)` content check. - EXPENSIVE: `_check_embedding_coverage_expensive()` reports coverage and failure count when embeddings are enabled. - `polylogue/daemon/notifications.py` + `config.py`: backend factory `_resolve_backend(backend_name)` (currently log-only), resolved from `PolylogueConfig` so tier set, interval, and backend can be set via TOML or the matching env vars. - `polylogue/daemon/cli.py`: `_periodic_health_check()` reads config to pick the tier set and backend. - `docs/daemon.md`: separates daemon-owned and operator-owned maintenance tasks. Refs #830
First production-grade hardening slice for #830 on top of the existing daemon/status substrate. Three new modules and modifications to status and CLI; PR #920 / #903 land the remaining checks and config wiring on top of this. - `polylogue/daemon/health.py`: `HealthTier` enum (FAST / MEDIUM / EXPENSIVE), `HealthAlert` typed model with severity and consecutive-failure tracking, `DaemonHealth` aggregation, and `check_health()` runner. Fast checks cover liveness/disk/WAL; medium covers FTS readiness, raw failure counts, and stale ingest attempts; expensive runs PRAGMA integrity_check. - `polylogue/daemon/backup.py`: `backup_archive()` using `VACUUM INTO` with a file-copy fallback; `--check` dry-run; optional blob-store backup via `--include-blobs`. - `polylogue/daemon/notifications.py`: `NotificationBackend` protocol with `LogNotificationBackend` routing alerts through the structured logger by severity. - `polylogue/daemon/status.py`: `DaemonStatus` gains `health: DaemonHealth`, populated by `build_daemon_status()` and exposed in the JSON payload and text formatter. - `polylogue/daemon/cli.py`: `polylogued health` subcommand with tier selection (`--tier`, `--expensive`), JSON output, and deterministic exit codes (1 on error/critical). - `polylogue/cli/commands/backup.py` + registration: `polylogue backup` with `--output-dir`, `--check`, `--include-blobs`. Closes #830 on the substrate axis; remaining health-check additions land in PR #920. Refs #830
Two follow-ups merged together. - #882 (FTS / quarantine): regression tests in `tests/unit/storage/test_backend.py` pinning the FTS trigger-restore-before-commit ordering and the `quarantined` property's coverage of `validation_status=FAILED` so the original PR #882 fixes cannot silently regress. - #830 (tiered health): `polylogue/daemon/cli.py` wires the periodic health-check loop into the daemon main loop and schedules notifications when a check transitions to a worse severity. Refs #830, #882
Direct, no-PR. Local repair in `tests/unit/storage/test_backend.py`: the wave that landed PRs #882/#903/#911 left two FK-test cases referencing helper names that had been renamed in the same wave, so `devtools verify` failed at the test stage even though every individual PR's CI was green. Realigns the helper names; pure test-file repair, no production code change.
Direct, no-PR. `tests/unit/storage/test_backend.py` accumulated regression cases from the FK / quarantine / FTS / blob waves (PRs #879/#881/#882/#903/#911) and exceeded its previous LOC budget. Bumps `docs/plans/file-size-budgets.yaml` to 1750 so `devtools verify-file-budgets` passes; the tests stay grouped in one place rather than splitting along an arbitrary cut.
Completes #830 on top of the health/backup substrate from PRs #898 / #903: four new health checks across the FAST/MEDIUM/ EXPENSIVE tiers, config-driven notification backend selection, and operator vs. daemon maintenance documentation. - `polylogue/daemon/health.py`: - FAST: `_check_source_availability_fast()` verifies each watch root from `default_sources()` exists and is readable. - MEDIUM: `_check_insight_freshness_medium()` flags >10% gap between session-profile coverage and total conversations. - MEDIUM: `_check_repeated_stage_failures_medium()` reads `live_ingest_attempt` for recent failure rates and samples the latest error. - EXPENSIVE: `_check_blob_integrity_expensive()` runs a bounded `BlobStore.verify_all(max_failures=5)` content check. - EXPENSIVE: `_check_embedding_coverage_expensive()` reports coverage and failure count when embeddings are enabled. - `polylogue/daemon/notifications.py` + `config.py`: backend factory `_resolve_backend(backend_name)` (currently log-only), resolved from `PolylogueConfig` so tier set, interval, and backend can be set via TOML or the matching env vars. - `polylogue/daemon/cli.py`: `_periodic_health_check()` reads config to pick the tier set and backend. - `docs/daemon.md`: separates daemon-owned and operator-owned maintenance tasks. Refs #830
|
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. |
|
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. |
Regression tests for quarantine and FTS commit ordering. Wire periodic health checks into daemon loop.