feat(system_scheduler): 添加系统级定时任务注册和管理功能#24
Conversation
Reviewer's Guide此 PR 引入了一套加固的、与操作系统集成的调度栈:将 APS 任务处理重构为“编解码器 + 执行协调器”架构;在 Windows/macOS/Linux 上通过 SystemScheduler 增加原生用户级唤醒能力;Go 更新器获得更健壮的文件锁定、原子自更新与变更应用逻辑;前端/UI/store 增强了系统级调度控制、手动启动冲突处理以及更丰富的执行历史展示;测试和 CI 也已扩展以覆盖这些行为。 原生 OS 唤醒与任务执行的时序图sequenceDiagram
actor OSScheduler
participant MWUHeadless as main.py(headless)
participant FastAPI as FastAPIApp
participant SchedulerManager
participant ExecutionCoordinator
OSScheduler->>MWUHeadless: start MWU.exe --scheduled-task <task_id>
MWUHeadless->>MWUHeadless: acquire_runtime_ownership()
MWUHeadless->>FastAPI: uvicorn.run(app)
MWUHeadless->>FastAPI: delegate_native_dispatch(task_id)
FastAPI->>FastAPI: POST /api/internal/scheduler/native-dispatch
FastAPI->>SchedulerManager: get_task(task_id)
SchedulerManager-->>FastAPI: ScheduledTask
FastAPI->>ExecutionCoordinator: submit_scheduled(task, origin="native")
ExecutionCoordinator-->>FastAPI: Admission(accepted/skip)
ExecutionCoordinator->>ExecutionCoordinator: _prepare_and_run(...)
ExecutionCoordinator-->>OSScheduler: TaskExecution result via UpdateResult / logs
文件级改动
可能关联的 Issue
Tips and commandsInteracting with Sourcery
Customizing Your Experience前往你的 dashboard:
Getting HelpOriginal review guide in EnglishReviewer's GuideThis PR introduces a hardened, OS-integrated scheduling stack: APS job handling is refactored into a codec and an execution coordinator, native user-level wakeup is added across Windows/macOS/Linux with a SystemScheduler, the Go updater gains robust file locking, atomic self-update, and change application, and the frontend/UI/store gain system-level scheduling controls, conflict handling for manual starts, and richer execution history; tests and CI are extended to cover these behaviors. Sequence diagram for native OS wakeup and task executionsequenceDiagram
actor OSScheduler
participant MWUHeadless as main.py(headless)
participant FastAPI as FastAPIApp
participant SchedulerManager
participant ExecutionCoordinator
OSScheduler->>MWUHeadless: start MWU.exe --scheduled-task <task_id>
MWUHeadless->>MWUHeadless: acquire_runtime_ownership()
MWUHeadless->>FastAPI: uvicorn.run(app)
MWUHeadless->>FastAPI: delegate_native_dispatch(task_id)
FastAPI->>FastAPI: POST /api/internal/scheduler/native-dispatch
FastAPI->>SchedulerManager: get_task(task_id)
SchedulerManager-->>FastAPI: ScheduledTask
FastAPI->>ExecutionCoordinator: submit_scheduled(task, origin="native")
ExecutionCoordinator-->>FastAPI: Admission(accepted/skip)
ExecutionCoordinator->>ExecutionCoordinator: _prepare_and_run(...)
ExecutionCoordinator-->>OSScheduler: TaskExecution result via UpdateResult / logs
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
… and UI integration - Add cross-platform kernel advisory locks (process_lock.py) with Python/Go interop - Replace PID/port race with real runtime ownership and bounded update-lock retry - Headless uses paused APScheduler, rejects disabled jobs, no double-dispatch - Normative capability matrix: implemented/verified/enabled per platform/scope/trigger - Correct Windows XML (schema-valid SYSTEM, full semantic verification), macOS (no Year, chmod 0600, argv elevation), Linux (shlex quoting, field bounds, atomic cron.d) - Transactional registration state machine: pending_register/active/orphaned/ pending_cleanup/error with compensation, recovery, and scope migration rollback - Orphan intent before APScheduler deletion; corrupt state fails closed - Updater: app-root locks before staging/self-update, atomic recoverable replacement, direct restart confirmation, install-owner restoration, CLOEXEC/sticky-dir - Frontend: capability-gated system scheduling UI in daisyUI dialog/list/RoutinesView - Extended SystemTaskStatus with authoritative observed state; no synthesized success - 315 Python tests, 46 Go tests, 289 frontend tests, all passing
- Fix SystemTaskObservation to match backend ObservedNativeState fields (scope/identifier/present/verified/details instead of registered/native_present) - Fix last_registered_at and scope to be nullable - Fix fetchAllSystemStatuses mapping to use correct field names - Remove dead dir() check and fix reason inversion in system_scheduler.py - Remove redundant test_headless_and_exit_codes.py (superseded by test_oracle_phase2_fixes.py real run_headless tests) - 312 Python tests, 46 Go tests, 289 frontend tests, all passing
7b9a531 to
46b7f38
Compare
5b3286a to
18eb36d
Compare
chore: 清理无用代码 test: 精简测试代码
refactor(updater): 简化代码
|
@sourcery-ai guide |
|
@sourcery-ai summary |
refactor: 移除复杂的锁机制和幂等操作
There was a problem hiding this comment.
Sorry @ravizhan, your pull request is larger than the review limit of 150000 diff characters
Confidence Score: 4/5Native dispatch failures can still be reported as successful process exits. HTTP rejection and retry exhaustion can return exit code zero without submitting the task. No additional distinct blocking issue qualifies for this review round.
What T-Rex did
Important Files Changed
|
style(logs): 优化日志视图的样式
This pull request introduces system-level scheduling support to the scheduler, including UI, API, and store changes, as well as new internationalization strings. Users can now register tasks as system-level, select their scope (user/system), and repair system task registrations. The UI reflects system scheduling status and provides actions for repair.
System-level scheduling support:
SystemTaskServicetoapp_state.pyand a newsystem_schedulerattribute, preparing the backend for system-level scheduling. [1] [2]front/src/services/api/modules/scheduler.ts. [1] [2]createTaskmethod now returns the created task for further processing. [1] [2] [3] [4]UI enhancements for system scheduling:
SchedulerTaskDialog.vue) to allow enabling system-level scheduling, selecting scope, and handling registration/unregistration on save. [1] [2] [3] [4] [5] [6]SchedulerTaskList.vue) to display system scheduling status with tags, including "In-Process", "Needs Repair", "System·User", and "System·System". [1] [2] [3]Internationalization (i18n) updates:
Summary by Sourcery
引入操作系统原生的调度与执行协调功能,实现无头模式下的系统级唤醒,并提供健壮的锁机制、执行追踪,以及用于处理冲突和历史记录的 UI 支持。
New Features:
ExecutionCoordinator和ExecutionStore,用于集中管理手动和计划任务执行的准入控制与持久化存储。SystemScheduler,通过无头 CLI 入口在 Windows、macOS 和 Linux 上注册、验证并收敛操作系统原生的唤醒任务。Enhancements:
SchedulerManager,使其专注于 APS 任务生命周期,将执行委托给协调器,并在任务创建、更新、暂停、恢复和删除流程中接入原生唤醒注册。Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
Introduce OS-native scheduling and execution coordination, enabling headless system-level wakeups with robust locking, execution tracking, and UI support for conflicts and history.
New Features:
Enhancements:
Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
引入操作系统原生的调度与执行协调功能,实现无头模式下的系统级唤醒,并提供健壮的锁机制、执行追踪,以及用于处理冲突和历史记录的 UI 支持。
New Features:
ExecutionCoordinator和ExecutionStore,用于集中管理手动和计划任务执行的准入控制与持久化存储。SystemScheduler,通过无头 CLI 入口在 Windows、macOS 和 Linux 上注册、验证并收敛操作系统原生的唤醒任务。Enhancements:
SchedulerManager,使其专注于 APS 任务生命周期,将执行委托给协调器,并在任务创建、更新、暂停、恢复和删除流程中接入原生唤醒注册。Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
Introduce OS-native scheduling and execution coordination, enabling headless system-level wakeups with robust locking, execution tracking, and UI support for conflicts and history.
New Features:
Enhancements:
Build:
CI:
Tests:
新功能:
改进:
测试:
Original summary in English
Summary by Sourcery
引入操作系统原生的调度与执行协调功能,实现无头模式下的系统级唤醒,并提供健壮的锁机制、执行追踪,以及用于处理冲突和历史记录的 UI 支持。
New Features:
ExecutionCoordinator和ExecutionStore,用于集中管理手动和计划任务执行的准入控制与持久化存储。SystemScheduler,通过无头 CLI 入口在 Windows、macOS 和 Linux 上注册、验证并收敛操作系统原生的唤醒任务。Enhancements:
SchedulerManager,使其专注于 APS 任务生命周期,将执行委托给协调器,并在任务创建、更新、暂停、恢复和删除流程中接入原生唤醒注册。Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
Introduce OS-native scheduling and execution coordination, enabling headless system-level wakeups with robust locking, execution tracking, and UI support for conflicts and history.
New Features:
Enhancements:
Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
引入操作系统原生的调度与执行协调功能,实现无头模式下的系统级唤醒,并提供健壮的锁机制、执行追踪,以及用于处理冲突和历史记录的 UI 支持。
New Features:
ExecutionCoordinator和ExecutionStore,用于集中管理手动和计划任务执行的准入控制与持久化存储。SystemScheduler,通过无头 CLI 入口在 Windows、macOS 和 Linux 上注册、验证并收敛操作系统原生的唤醒任务。Enhancements:
SchedulerManager,使其专注于 APS 任务生命周期,将执行委托给协调器,并在任务创建、更新、暂停、恢复和删除流程中接入原生唤醒注册。Build:
CI:
Tests:
Original summary in English
Summary by Sourcery
Introduce OS-native scheduling and execution coordination, enabling headless system-level wakeups with robust locking, execution tracking, and UI support for conflicts and history.
New Features:
Enhancements:
Build:
CI:
Tests: