Skip to content

fix: close scope gaps — FTS/quarantine tests, health check wiring (#882/#830) - #903

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/scope-gaps-batch-2
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/scope-gaps-batch-2

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Regression tests for quarantine and FTS commit ordering. Wire periodic health checks into daemon loop.

- #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]>
Copilot AI review requested due to automatic review settings May 7, 2026 10:13
@Sinity
Sinity merged commit dc22e1e into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/scope-gaps-batch-2 branch May 7, 2026 10:13
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 44 seconds before requesting another review.

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

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e2c88fe1-70b5-4bb8-9c50-d34bca8b574b

📥 Commits

Reviewing files that changed from the base of the PR and between 3befca6 and bc6a015.

📒 Files selected for processing (2)
  • polylogue/daemon/cli.py
  • tests/unit/storage/test_backend.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/scope-gaps-batch-2

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.

@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: 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".

Comment thread tests/unit/storage/test_backend.py Resolved
Comment thread tests/unit/storage/test_backend.py Resolved

Copilot AI 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.

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.

Comment on lines +1526 to +1551
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,
)
Comment on lines +1563 to +1568
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(?,?,?)",
Comment on lines +1584 to +1586
# 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}"
Comment thread polylogue/daemon/cli.py
send_notifications,
)

health = check_health(tiers=(HealthTier.FAST, HealthTier.MEDIUM))
Comment thread polylogue/daemon/cli.py
Comment on lines +216 to +223
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":
Comment thread polylogue/daemon/cli.py


async def _periodic_health_check() -> None:
"""Run FAST health checks every 5 minutes with structured alert logging."""
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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.
Sinity added a commit that referenced this pull request May 7, 2026
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.
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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.
Sinity added a commit that referenced this pull request May 7, 2026
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.
Sinity added a commit that referenced this pull request May 7, 2026
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
@Sinity

Sinity commented Sep 30, 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.

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

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

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.

2 participants