Skip to content

fix(daemon): stop schema-blocked background work - #1466

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/schema-block-background
May 24, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/schema-block-background

Conversation

@Sinity

@Sinity Sinity commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Stops schema-blocked daemon startup from launching any DB-opening background work. The daemon can still expose degraded browser/API surfaces, but a critical schema preflight now blocks the watcher, periodic archive tasks, and the post-ingest converger.

Problem

After deploying #1465, the live service correctly refused live ingest because the archive metadata reported schema v12 against runtime v8, but it still started the convergence engine and periodic loops. On the real archive, read_bytes rose by about 1.17 GB in 5 seconds even though the watcher was blocked. That defeats the schema preflight's purpose and can keep the host under IO pressure.

Solution

  • Keep run_daemon_services from creating WAL, heartbeat, convergence-debt, health, DB optimize, or status-snapshot tasks when watcher_blocked is true.
  • Keep the post-ingest DaemonConverger unconstructed under the same schema-blocked state.
  • Add a regression test proving the schema-blocked browser/API path closes cleanly without starting DB background work.

Ref #1447

Verification

  • pytest -q tests/unit/daemon/test_daemon_cli.py -q -> 18 passed
  • ruff check polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py -> All checks passed!
  • mypy polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py -> Success: no issues found in 2 source files
  • devtools verify --quick -> exit_code: 0, total_duration_s: 35.03
  • pre-push devtools verify --quick -> exit_code: 0, total_duration_s: 33.62

Problem: a critical schema preflight blocked live ingest but still allowed the daemon to start periodic DB loops and the post-ingest converger. On the live archive that produced heavy physical reads even though the watcher refused to start.\n\nWhat changed: schema-blocked startup now keeps the degraded HTTP/browser surfaces observable while skipping all DB-opening background tasks and converger construction. A daemon CLI regression test pins the exact schema-blocked path.\n\nVerification: pytest -q tests/unit/daemon/test_daemon_cli.py -q; ruff check polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py; mypy polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py; devtools verify --quick.\n\nRef #1447
@coderabbitai

coderabbitai Bot commented May 24, 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 currently allows 1 review/hour. Refill in 9 minutes and 53 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: 9d5f22a8-2bc2-4b9d-8ac5-e48a2c74488a

📥 Commits

Reviewing files that changed from the base of the PR and between 7da2749 and a100086.

📒 Files selected for processing (2)
  • polylogue/daemon/cli.py
  • tests/unit/daemon/test_daemon_cli.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/schema-block-background

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 fd93d0d into master May 24, 2026
6 checks passed
@Sinity
Sinity deleted the feature/fix/schema-block-background branch May 24, 2026 02:42

@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: a100086807

ℹ️ 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/cli.py Resolved
Sinity added a commit that referenced this pull request May 24, 2026
Summary: Failed live-ingest paths now retry through live_cursor backoff instead of being immediately requeued from batch metrics. The daemon can still converge source files, but a failing catch-up group no longer turns into a half-second disk hot loop.

Problem: After the #1466 deploy, polylogued reached real catch-up and processed the large Codex chunks, then repeatedly logged batching 305 changed files and requeued 305 failed files. Live IO samples reached roughly 23 GB of reads and IO PSI full avg10 was roughly 24%, while live_cursor had zero failed rows. Retry state was bypassing the durable cursor/backoff mechanism.

Solution: Added failed cursor record listing, replaced direct metrics failed_paths requeueing with cursor-owned retry scheduling, scheduled due failures back into pending work, and added a delayed wake-up for the next retry timestamp. Tests assert backed-off failures are not immediately requeued and only due failures re-enter pending work.

Verification:
- pytest -q tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py -> 65 passed
- ruff check polylogue/sources/live/watcher.py polylogue/sources/live/cursor.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py -> pass
- mypy polylogue/sources/live/watcher.py polylogue/sources/live/cursor.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py -> pass
- devtools verify --quick -> exit_code 0, total_duration_s 37.93
- pre-push devtools verify --quick -> exit_code 0, total_duration_s 35.40
- GitHub checks: Analyze (python), CodeQL, GitGuardian, build (runtime), build (distroless) -> pass

Ref #1447
@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.

  • 62.F032 / P1: fixed-already at the checked revision: Lifecycle heartbeat, health checking and schema-preflight rechecking are started independently of archive intake at polylogue/daemon/cli.py:2525-2530. The blocked watch-only branch therefore still has supervised ongoing services instead of an empty maintenance gather.

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