Skip to content

feat(notifications): wire on_ai_processed / on_task_failed trigger events - #67

Open
1012839419a-alt wants to merge 1 commit into
2233admin:mainfrom
1012839419a-alt:feat/notification-trigger-events
Open

feat(notifications): wire on_ai_processed / on_task_failed trigger events#67
1012839419a-alt wants to merge 1 commit into
2233admin:mainfrom
1012839419a-alt:feat/notification-trigger-events

Conversation

@1012839419a-alt

Copy link
Copy Markdown
Contributor

Summary

WIRING_GAP_LEDGER W2: the model comment promised trigger_event of on_new_record | on_ai_processed | on_task_failed but the schema Literal only allowed on_new_record and dispatch_notifications() had no producer for any other value — a rule saved with another string was rejected at the schema layer, but the promised events stayed impossible.

Changes

  • schemas/notification: Literal now accepts all three values (Create + Update); arbitrary strings still rejected (422)
  • notifier_dispatch: dispatch_notifications() gains failure_payload — with no collected records and a failure payload, a synthetic (never-persisted) record carries error/error_type into the normal rule-match/send pipeline, so on_task_failed fires without any collected items
  • pipeline: step 5 fires on_ai_processed when AI enrichment ran (ai_count>0) after the existing on_new_record dispatch; both permanent collect-failure paths call a new best-effort _notify_task_failed() helper (error + error_type + task_id), guarded by enable_notifications and never masking the original failure

Test Plan

  • schema accepts 3 values / rejects arbitrary (Create + Update)
  • dispatch event-scoped rule matching for on_ai_processed (on_new_record rule does NOT fire)
  • on_task_failed synthetic payload with error fields
  • pipeline wiring: failure fires _notify_task_failed with error/error_type; AI run fires both events

42 passed on affected suites; ruff errors unchanged vs baseline (19).

…ents

WIRING_GAP_LEDGER W2: the model comment promised trigger_event of
on_new_record | on_ai_processed | on_task_failed but the schema Literal
only allowed on_new_record and dispatch_notifications() had no producer for
any other value (a rule saved with another string was rejected at the
schema layer — loudly, but the promised events stayed impossible).

- schemas/notification: Literal now accepts all three values (Create +
  Update); arbitrary strings still rejected (422)
- notifier_dispatch: dispatch_notifications() gains failure_payload — with
  no collected records and a failure payload, a synthetic (never-persisted)
  record carries error/error_type into the normal rule-match/send pipeline,
  so on_task_failed fires without any collected items
- pipeline: step 5 fires on_ai_processed when AI enrichment ran (ai_count>0)
  after the existing on_new_record dispatch; both permanent collect-failure
  paths call a new best-effort _notify_task_failed() helper (error +
  error_type + task_id), guarded by enable_notifications and never masking
  the original failure

Tests: schema accepts 3 values / rejects arbitrary (Create+Update),
dispatch event-scoped rule matching for on_ai_processed, on_task_failed
synthetic payload with error fields, pipeline wiring (failure fires
_notify_task_failed with error/error_type; AI run fires both events). 42
passed on affected suites; ruff errors unchanged vs baseline (19).
@repowise-bot

repowise-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Health of changed files: 5.1 → 5.6 (+0.5)
🚨 Change risk: high, riskier than 69% of this repo's commits.

📋 At a glance
2 files changed health · 5 hotspots touched · 2 new findings introduced · 5 files with recent fix history.

Files & modules (2)
  • backend (3 files)
    • backend/pipeline/notifier_dispatch.py
    • backend/pipeline/pipeline.py
    • backend/schemas/notification.py
  • tests (3 files)
    • .../pipeline/test_notifier_dispatch.py
    • .../pipeline/test_pipeline_errors.py
    • tests/unit/test_schemas_notification.py

✅ Health gate: passed

📌 Before you merge

  • Run .../pipeline/test_notifier_dispatch_errors.py, .../pipeline/test_legacy_db_sink.py, .../pipeline/test_pipeline.py, .../pipeline/test_pipeline_affinity.py: they import the changed files

🎯 Blast radius (symbols whose signature this PR changed, and who calls them)

  • dispatch_notifications in backend/pipeline/notifier_dispatch.py signature changed. Called by 4 symbols outside this PR: .../pipeline/test_notifier_dispatch_errors.py::test_dispatch_aggregate_counts_partial_failure, .../pipeline/test_notifier_dispatch_errors.py::test_dispatch_notifier_send_exception_logged, .../pipeline/test_notifier_dispatch_errors.py::test_dispatch_pending_rows_committed_before_sends_start (+1 more)
🔎 More signals (2)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (3 with dependents)"]
    f_backend_pipeline_notifier_dispatch_py["backend/pipeline/notifier_dispatch.py 🔥"]:::changed
    f_backend_pipeline_pipeline_py["backend/pipeline/pipeline.py 🔥"]:::changed
    f_backend_schemas_notification_py["backend/schemas/notification.py 🔥"]:::changed
  end
  f_backend_worker_tasks_py["backend/worker/tasks.py"]
  f_backend_pipeline_notifier_dispatch_py --> f_backend_worker_tasks_py
  f_backend_workflow_webhook_delivery_py["backend/workflow/webhook_delivery.py"]
  f_backend_pipeline_notifier_dispatch_py --> f_backend_workflow_webhook_delivery_py
  f_backend_api_v1___init___py[".../v1/__init__.py"]
  f_backend_pipeline_pipeline_py --> f_backend_api_v1___init___py
  f_backend_channels_rss_channel_py["backend/channels/rss_channel.py"]
  f_backend_pipeline_pipeline_py --> f_backend_channels_rss_channel_py
  f_backend_channels_skill_channel_py["backend/channels/skill_channel.py"]
  f_backend_pipeline_pipeline_py --> f_backend_channels_skill_channel_py
  f_backend_config_py["backend/config.py"]
  f_backend_pipeline_pipeline_py --> f_backend_config_py
  f_backend_api_v1_notifications_py[".../v1/notifications.py"]
  f_backend_schemas_notification_py --> f_backend_api_v1_notifications_py
  more(["+3 more dependents"])
  PR --> more
  t_tests_unit_pipeline_test_notifier_dispatch_errors_py(["✅ .../pipeline/test_notifier_dispatch_errors.py"]):::guard
  t_tests_unit_pipeline_test_notifier_dispatch_errors_py -.-> f_backend_pipeline_notifier_dispatch_py
  t_tests_unit_pipeline_test_legacy_db_sink_py(["✅ .../pipeline/test_legacy_db_sink.py"]):::guard
  t_tests_unit_pipeline_test_legacy_db_sink_py -.-> f_backend_pipeline_pipeline_py
  classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Solid arrows: code that imports the changed files (10 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (5)

  • backend/pipeline/pipeline.py: 18 commits/90d, 14 dependents · primary owner: Curry (64%)
  • .../pipeline/test_pipeline_errors.py: 3 commits/90d, 1 dependents · primary owner: xujinghua (51%)
  • .../pipeline/test_notifier_dispatch.py: 2 commits/90d, 1 dependents · primary owner: xujinghua (69%)
2 more
  • backend/schemas/notification.py: 4 commits/90d, 2 dependents · primary owner: xujinghua (53%)
  • backend/pipeline/notifier_dispatch.py: 4 commits/90d, 5 dependents · primary owner: Curry (81%)

👀 Suggested reviewers @2233admin


📊 See the full report for this PR
Your repo map with this PR's blast radius lit up, every caller of the contracts it changes, and health before and after. No sign-in. · ⭐ Star Repowise · 📥 Install bot · Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot · Updated 2026-08-07 12:11 UTC

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@1012839419a-alt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c9731648-dde5-4efc-ad39-82c1208efde9

📥 Commits

Reviewing files that changed from the base of the PR and between 94ab53d and 360612e.

📒 Files selected for processing (6)
  • backend/pipeline/notifier_dispatch.py
  • backend/pipeline/pipeline.py
  • backend/schemas/notification.py
  • tests/unit/pipeline/test_notifier_dispatch.py
  • tests/unit/pipeline/test_pipeline_errors.py
  • tests/unit/test_schemas_notification.py

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.

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