[Feat] [Automations] Event-Driven Trigger Type with document.entered_folder#1449
Conversation
A standalone, domain-agnostic pub/sub seam: an EventBus that owns its subscriber registry and streams Event values from producers to listeners in process. Boundary-crossing (Celery/DB/workers) is left to subscribers, keeping the bus single-responsibility. Includes the immutable Event value object and full unit coverage.
…ered_folder events
|
@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Summary
EventBus(app/event_bus/) with a typedEventCatalog— decoupled from Celery (SRP)document.entered_folderas the first built-in event type, published via SQLAlchemyafter_commithooks (ORM-level CDC, no external daemon)eventtrigger type for automations, mirroring thescheduletrigger pattern (source → selector → inputs → dispatch)bulk_move_documentsto use ORM objects so session hooks fire correctly on bulk moveseventtrigger typeTest plan
uv run pytest tests/unit/High-level PR Summary
This PR introduces an event-driven automation trigger system centered around the
document.entered_folderevent. It adds a new in-processEventBuswith a typedEventCatalogthat decouples domain events from Celery, publishesdocument.entered_folderevents via SQLAlchemyafter_commithooks when documents move into folders, and implements a neweventtrigger type for automations that matches events using a JSON filter grammar. The PR also refactors the existing automation dispatch logic to use a unifiedlaunch_runentry point, fixesbulk_move_documentsto fire ORM session hooks properly, and updates the frontend to accept theeventtrigger type while fixing numeric type coercion in the JSON editor.⏱️ Estimated Review Time: 30-90 minutes
💡 Review Order Suggestion
.gitignoresurfsense_backend/alembic/versions/147_add_event_to_automation_trigger_type.pysurfsense_backend/app/event_bus/event.pysurfsense_backend/app/event_bus/catalog.pysurfsense_backend/app/event_bus/bus.pysurfsense_backend/app/event_bus/__init__.pysurfsense_backend/app/event_bus/events/__init__.pysurfsense_backend/app/event_bus/events/document_entered_folder.pysurfsense_backend/app/session_events.pysurfsense_backend/app/automations/persistence/enums/trigger_type.pysurfsense_backend/app/automations/triggers/builtin/event/params.pysurfsense_backend/app/automations/triggers/builtin/event/filter.pysurfsense_backend/app/automations/triggers/builtin/event/match.pysurfsense_backend/app/automations/triggers/builtin/event/inputs.pysurfsense_backend/app/automations/triggers/builtin/event/definition.pysurfsense_backend/app/automations/triggers/builtin/event/source.pysurfsense_backend/app/automations/triggers/builtin/event/selector.pysurfsense_backend/app/automations/triggers/builtin/event/__init__.pysurfsense_backend/app/automations/triggers/__init__.pysurfsense_backend/app/automations/triggers/builtin/__init__.pysurfsense_backend/app/automations/dispatch/resolve.pysurfsense_backend/app/automations/dispatch/inputs.pysurfsense_backend/app/automations/dispatch/launch.pysurfsense_backend/app/automations/dispatch/__init__.pysurfsense_backend/app/automations/triggers/builtin/schedule/inputs.pysurfsense_backend/app/automations/triggers/builtin/schedule/source.pysurfsense_backend/app/automations/triggers/builtin/schedule/selector.pysurfsense_backend/app/automations/triggers/builtin/schedule/__init__.pysurfsense_backend/app/automations/actions/builtin/__init__.pysurfsense_backend/app/automations/actions/__init__.pysurfsense_backend/app/routes/folders_routes.pysurfsense_backend/app/app.pysurfsense_backend/app/celery_app.pysurfsense_backend/app/automations/services/automation.pysurfsense_backend/app/automations/services/trigger.pysurfsense_web/contracts/types/automation.types.tssurfsense_web/components/json-view.tsxsurfsense_backend/tests/unit/event_bus/conftest.pysurfsense_backend/tests/unit/event_bus/test_event.pysurfsense_backend/tests/unit/event_bus/test_catalog.pysurfsense_backend/tests/unit/event_bus/test_bus.pysurfsense_backend/tests/unit/event_bus/test_document_entered_folder.pysurfsense_backend/tests/unit/event_bus/test_entered_folder_predicate.pysurfsense_backend/tests/unit/automations/triggers/builtin/event/test_params.pysurfsense_backend/tests/unit/automations/triggers/builtin/event/test_filter.pysurfsense_backend/tests/unit/automations/triggers/builtin/event/test_match.pysurfsense_backend/tests/unit/automations/triggers/builtin/event/test_inputs.pysurfsense_backend/tests/unit/automations/triggers/builtin/event/test_definition.pysurfsense_backend/tests/unit/automations/dispatch/test_inputs.pysurfsense_backend/tests/unit/automations/test_persistence_enums.py