Skip to content

refactor(api): isolate trigger schedule runtime - #45941

Merged
hjlarry merged 4 commits into
mainfrom
hjlarry/trigger-schedule-runtime
Nov 10, 2026
Merged

hjlarry merged 4 commits into
mainfrom
hjlarry/trigger-schedule-runtime

Conversation

@hjlarry

@hjlarry hjlarry commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move schedule publication synchronization, due-plan polling, and workflow dispatch into injected trigger schedule services and a repository.
  • Keep publication changes in the workflow publisher's transaction and preserve database claims while publishing due plans, preventing concurrent pollers from dispatching the same plan. A transactional outbox could remove the broker call from the claim transaction in a future change.
  • Replace legacy schedule tests with coverage for publication, polling, execution, ownership, and concurrent claims.

This PR is stacked on #45912 and should be reviewed against that branch.

Screenshots

@github-actions github-actions Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Nov 10, 2026
@hjlarry
hjlarry added this pull request to stack #45942 November 10, 2026 01:31
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-10 06:09:30.510093475 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-10 06:09:18.474057605 +0000
@@ -996,16 +996,6 @@
    --> tests/e2e_tests/containers/services/test_model_provider_service.py:147:24
 ERROR Argument `str` is not assignable to parameter `model_type` with type `ModelType | SQLCoreOperations[ModelType]` in function `models.provider.ProviderModelSetting.__init__` [bad-argument-type]
    --> tests/e2e_tests/containers/services/test_model_provider_service.py:184:24
-ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_schedule_service.py:30:20
-ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_schedule_service.py:32:58
-ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
-   --> tests/e2e_tests/containers/services/test_schedule_service.py:319:26
-ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
-   --> tests/e2e_tests/containers/services/test_schedule_service.py:353:26
-ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
-   --> tests/e2e_tests/containers/services/test_schedule_service.py:382:22
 ERROR Argument `Literal['chat']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:45:14
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
@@ -1589,9 +1579,9 @@
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/trigger/conftest.py:66:19
 ERROR Argument `dict[str, str | dict[str, str | dict[str, str]]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `core.trigger.debug.event_selectors.TriggerDebugEventPoller.__init__` [bad-argument-type]
-   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:293:21
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:245:21
 ERROR Argument `dict[str, Any]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
-   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:588:49
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:424:49
 ERROR Class member `StaticRepo.get_form` overrides parent class `HumanInputFormRepository` in an inconsistent manner [bad-override]
    --> tests/e2e_tests/contracts/core/workflow/graph_engine/test_parallel_human_input_join_resume.py:137:9
 ERROR Argument `_TestFileReferenceFactory` is not assignable to parameter `file_reference_factory` with type `DifyFileReferenceFactory | None` in function `core.workflow.nodes.human_input.callback.DifyHITLCallback.__init__` [bad-argument-type]

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 84.82% 84.85% +0.02%
Strict coverage 84.48% 84.51% +0.02%
Typed symbols 89,177 89,229 +52
Untyped symbols 16,019 15,999 -20
Modules 4446 4450 +4

@hjlarry
hjlarry marked this pull request as ready for review November 10, 2026 01:34
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.80220% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.10%. Comparing base (9fbd9dc) to head (a690a03).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...dlers/sync_workflow_schedule_when_app_published.py 78.57% 2 Missing and 1 partial ⚠️
api/services/trigger/schedule_service.py 98.38% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #45941   +/-   ##
=======================================
  Coverage   90.09%   90.10%           
=======================================
  Files        6271     6274    +3     
  Lines      392030   392018   -12     
  Branches    78449    78434   -15     
=======================================
+ Hits       353201   353212   +11     
+ Misses      32738    32721   -17     
+ Partials     6091     6085    -6     
Flag Coverage Δ
api 89.94% <97.25%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from hjlarry/trigger-webhook-runtime to main November 10, 2026 05:14
@hjlarry
hjlarry force-pushed the hjlarry/trigger-schedule-runtime branch from b307993 to 75e73a9 Compare November 10, 2026 05:14
@hjlarry
hjlarry enabled stacked auto-merge November 10, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants