Skip to content

Conversation

@weilicious
Copy link
Collaborator

@weilicious weilicious commented Dec 1, 2025

This pull request refactors task cancellation logic throughout the codebase to use a more general "active/inactive" status instead of the previous "canceled" status. The main effect is to allow tasks to be toggled between active and inactive states, improving clarity and flexibility in task management. The changes also update related APIs, logging, notifications, and tests to reflect this new approach.

Task status and API refactor:

  • Replaced the concept of "canceled" tasks with "inactive" tasks across the codebase, including in status enums, API request/response types, and logging. The CancelTaskByUser method is replaced with SetTaskActiveByUser, and CancelTask with DeactivateTask. [1] [2] [3] [4]
  • Updated task statistics and counting logic to use the "inactive" status instead of "canceled". This affects wallet/task stats and related test assertions. [1] [2] [3] [4] [5]
  • Modified task deletion logic to check for the new "running" status instead of "executing" and updated related status names throughout. [1] [2]

Operator notification and event handling:

  • Updated operator notification logic and event overload handling to use DeactivateTask and the corresponding message type, replacing the previous "cancel" semantics. [1] [2] [3] [4] [5]

Testing updates:

  • Refactored and expanded tests to cover the new activate/deactivate functionality, including idempotency, state transitions, and correct notification message types. [1] [2]

These changes modernize the task lifecycle management, making it more expressive and easier to extend in the future.


Note

Switches task cancellation to reversible active/inactive, introducing SetTaskActive RPC and DeactivateTask message, updating statuses, storage, engine/operator logic, and tests.

  • Protocol (protobuf):
    • Add TaskStatus.Inactive; rename ExecutingRunning.
    • Replace CancelTaskResp/CancelTask with SetTaskActiveReq/Resp and rpc SetTaskActive.
    • Change MessageOp_CancelTaskMessageOp_DeactivateTask.
  • Engine/Aggregator:
    • Implement SetTaskActiveByUser (activate/deactivate with idempotency and guards); add DeactivateTask for alerts.
    • Replace RPC handler to SetTaskActive and adjust overload handling (deactivate on alert).
    • Delete-guard updated to block when Running.
  • Operator:
    • Handle DeactivateTask (remove checks); update worker loop and processing.
  • Storage/Stats:
    • Map new status prefixes (i for inactive, x for running); stats/counts use Inactive instead of Canceled.
  • Queue/Cleanup:
    • Status lists updated (active/completed/failed/inactive/running).
  • Tests/Integration:
    • Update/expand unit and integration tests for activate/deactivate, idempotency, notifications; adjust REST/moralis mocks; rename expectations.
  • Docs:
    • Add docs/ACTIVE_INACTIVE_TASK_STATUS_MIGRATION.md outlining breaking changes.
  • Scripts:
    • Improve scripts/gh_job_logs.sh CLI (positional JOB_ID, help).

Written by Cursor Bugbot for commit 85b1997. Configure here.

@chrisli30 chrisli30 requested a review from Copilot December 1, 2025 21:03
@chrisli30 chrisli30 changed the title Wei add active deactive feat: switch cancel task to active/inactive tasks; add SetTaskActive; Dec 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a major architectural change replacing the irreversible "Canceled" task status with a reversible "Active/Inactive" toggle mechanism. This enables users to temporarily turn tasks off and reactivate them later without losing task definitions or history.

Key Changes:

  • Replaces TaskStatus_Canceled (enum value 3) with TaskStatus_Inactive (enum value 5) and renames TaskStatus_Executing to TaskStatus_Running (enum value 4)
  • Introduces new SetTaskActive RPC replacing the removed CancelTask RPC, allowing explicit activation/deactivation control
  • Updates operator control messages from MessageOp_CancelTask to MessageOp_DeactivateTask for immediate operator notification

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
storage/schema/task.go Updates storage key mapping: "l" (canceled) → "i" (inactive), "executing" comment → "running"
protobuf/node.proto Renames MessageOp_CancelTask to MessageOp_DeactivateTask and updates comment references
protobuf/node.pb.go Generated code reflecting MessageOp enum changes
protobuf/avs_grpc.pb.go Generated gRPC code: replaces CancelTask method with SetTaskActive
protobuf/avs.proto Defines new SetTaskActiveReq/Resp messages, removes CancelTaskResp, updates TaskStatus enum
protobuf/avs.pb.go Generated code for new activation/deactivation messages and updated enums
operator/worker_loop_test.go Updates test to use DeactivateTask operation
operator/worker_loop.go Updates message processing to handle DeactivateTask instead of CancelTask
operator/process_message.go Updates operator message handling for deactivation
model/user.go Renames SmartWalletTaskStat.Canceled field to Inactive
model/task.go Renames SetCanceled() method to SetInactive(), removes CompletedAt timestamp update
integration_test/orphaned_task_reclamation_test.go Updates event trigger Topics structure from nested to flat array
integration_test/operator_reconnection_test.go Updates Topics structure and node naming
integration_test/activation_deactivation_sync_test.go New integration test verifying activation/deactivation synchronization flow
docs/ACTIVE_INACTIVE_TASK_STATUS_MIGRATION.md Comprehensive migration documentation covering protocol changes, implementation, and rollout plan
core/taskengine/stats_test.go Updates test assertions for Inactive field
core/taskengine/stats.go Updates stats tracking to count Inactive tasks instead of Canceled
core/taskengine/operator_notification_test.go Updates tests to verify DeactivateTask notifications and new response fields
core/taskengine/engine.go Implements SetTaskActiveByUser replacing CancelTaskByUser, adds activation/deactivation logic with idempotency
core/apqueue/cleanup.go Updates orphaned job cleanup to check for Inactive and Running statuses
aggregator/rpc_server.go Replaces CancelTask RPC handler with SetTaskActive, updates overload handling to use deactivation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@chrisli30 chrisli30 merged commit 01eaa31 into staging Dec 1, 2025
18 checks passed
@chrisli30 chrisli30 deleted the wei-add_active_deactive branch December 1, 2025 22:09
chrisli30 pushed a commit that referenced this pull request Dec 20, 2025
…#433)

* chore: add plan for implementing active status

* fix: switch to active/inactive tasks; add SetTaskActive; update operator/storage/tests

* fix: active/inactive tasks; add SetTaskActive; update operator, storage, tests; integration fixes

* fix: test failures caused by mock server
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.

3 participants