cmdx 1.7.5 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.cursor/prompts/docs.md +3 -3
- data/.cursor/prompts/llms.md +1 -3
- data/.cursor/prompts/rspec.md +1 -1
- data/.irbrc +14 -2
- data/CHANGELOG.md +62 -29
- data/LLM.md +203 -78
- data/README.md +23 -85
- data/docs/.DS_Store +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/favicon.svg +1 -0
- data/docs/attributes/coercions.md +19 -29
- data/docs/attributes/defaults.md +3 -16
- data/docs/attributes/definitions.md +29 -39
- data/docs/attributes/naming.md +3 -13
- data/docs/attributes/transformations.md +63 -0
- data/docs/attributes/validations.md +23 -40
- data/docs/basics/chain.md +14 -23
- data/docs/basics/context.md +13 -22
- data/docs/basics/execution.md +8 -26
- data/docs/basics/setup.md +8 -19
- data/docs/callbacks.md +19 -32
- data/docs/deprecation.md +8 -25
- data/docs/getting_started.md +101 -77
- data/docs/index.md +120 -0
- data/docs/internationalization.md +6 -18
- data/docs/interruptions/exceptions.md +10 -16
- data/docs/interruptions/faults.md +8 -25
- data/docs/interruptions/halt.md +31 -25
- data/docs/logging.md +7 -17
- data/docs/middlewares.md +13 -29
- data/docs/outcomes/result.md +21 -38
- data/docs/outcomes/states.md +8 -22
- data/docs/outcomes/statuses.md +10 -21
- data/docs/stylesheets/extra.css +42 -0
- data/docs/tips_and_tricks.md +7 -46
- data/docs/workflows.md +23 -38
- data/examples/active_record_query_tagging.md +46 -0
- data/examples/paper_trail_whatdunnit.md +39 -0
- data/lib/cmdx/attribute.rb +9 -2
- data/lib/cmdx/attribute_value.rb +31 -10
- data/lib/cmdx/callback_registry.rb +12 -2
- data/lib/cmdx/coercions/hash.rb +6 -1
- data/lib/cmdx/configuration.rb +10 -2
- data/lib/cmdx/deprecator.rb +3 -3
- data/lib/cmdx/errors.rb +1 -1
- data/lib/cmdx/executor.rb +97 -9
- data/lib/cmdx/log_formatters/logstash.rb +4 -4
- data/lib/cmdx/pipeline.rb +4 -4
- data/lib/cmdx/railtie.rb +9 -0
- data/lib/cmdx/result.rb +10 -1
- data/lib/cmdx/task.rb +12 -7
- data/lib/cmdx/version.rb +1 -1
- data/lib/cmdx.rb +1 -0
- data/lib/generators/cmdx/templates/install.rb +9 -0
- data/lib/locales/af.yml +2 -2
- data/lib/locales/ar.yml +2 -2
- data/lib/locales/az.yml +2 -2
- data/lib/locales/be.yml +2 -2
- data/lib/locales/bg.yml +2 -2
- data/lib/locales/bn.yml +2 -2
- data/lib/locales/bs.yml +2 -2
- data/lib/locales/ca.yml +2 -2
- data/lib/locales/cnr.yml +2 -2
- data/lib/locales/cs.yml +2 -2
- data/lib/locales/cy.yml +2 -2
- data/lib/locales/da.yml +2 -2
- data/lib/locales/de.yml +2 -2
- data/lib/locales/dz.yml +2 -2
- data/lib/locales/el.yml +2 -2
- data/lib/locales/en.yml +2 -2
- data/lib/locales/eo.yml +2 -2
- data/lib/locales/es.yml +2 -2
- data/lib/locales/et.yml +2 -2
- data/lib/locales/eu.yml +2 -2
- data/lib/locales/fa.yml +2 -2
- data/lib/locales/fi.yml +2 -2
- data/lib/locales/fr.yml +2 -2
- data/lib/locales/fy.yml +2 -2
- data/lib/locales/gd.yml +2 -2
- data/lib/locales/gl.yml +2 -2
- data/lib/locales/he.yml +2 -2
- data/lib/locales/hi.yml +2 -2
- data/lib/locales/hr.yml +2 -2
- data/lib/locales/hu.yml +2 -2
- data/lib/locales/hy.yml +2 -2
- data/lib/locales/id.yml +2 -2
- data/lib/locales/is.yml +2 -2
- data/lib/locales/it.yml +2 -2
- data/lib/locales/ja.yml +2 -2
- data/lib/locales/ka.yml +2 -2
- data/lib/locales/kk.yml +2 -2
- data/lib/locales/km.yml +2 -2
- data/lib/locales/kn.yml +2 -2
- data/lib/locales/ko.yml +2 -2
- data/lib/locales/lb.yml +2 -2
- data/lib/locales/lo.yml +2 -2
- data/lib/locales/lt.yml +2 -2
- data/lib/locales/lv.yml +2 -2
- data/lib/locales/mg.yml +2 -2
- data/lib/locales/mk.yml +2 -2
- data/lib/locales/ml.yml +2 -2
- data/lib/locales/mn.yml +2 -2
- data/lib/locales/mr-IN.yml +2 -2
- data/lib/locales/ms.yml +2 -2
- data/lib/locales/nb.yml +2 -2
- data/lib/locales/ne.yml +2 -2
- data/lib/locales/nl.yml +2 -2
- data/lib/locales/nn.yml +2 -2
- data/lib/locales/oc.yml +2 -2
- data/lib/locales/or.yml +2 -2
- data/lib/locales/pa.yml +2 -2
- data/lib/locales/pl.yml +2 -2
- data/lib/locales/pt.yml +2 -2
- data/lib/locales/rm.yml +2 -2
- data/lib/locales/ro.yml +2 -2
- data/lib/locales/ru.yml +2 -2
- data/lib/locales/sc.yml +2 -2
- data/lib/locales/sk.yml +2 -2
- data/lib/locales/sl.yml +2 -2
- data/lib/locales/sq.yml +2 -2
- data/lib/locales/sr.yml +2 -2
- data/lib/locales/st.yml +2 -2
- data/lib/locales/sv.yml +2 -2
- data/lib/locales/sw.yml +2 -2
- data/lib/locales/ta.yml +2 -2
- data/lib/locales/te.yml +2 -2
- data/lib/locales/th.yml +2 -2
- data/lib/locales/tl.yml +2 -2
- data/lib/locales/tr.yml +2 -2
- data/lib/locales/tt.yml +2 -2
- data/lib/locales/ug.yml +2 -2
- data/lib/locales/uk.yml +2 -2
- data/lib/locales/ur.yml +2 -2
- data/lib/locales/uz.yml +2 -2
- data/lib/locales/vi.yml +2 -2
- data/lib/locales/wo.yml +2 -2
- data/lib/locales/zh-CN.yml +2 -2
- data/lib/locales/zh-HK.yml +2 -2
- data/lib/locales/zh-TW.yml +2 -2
- data/lib/locales/zh-YUE.yml +2 -2
- data/mkdocs.yml +122 -0
- data/src/cmdx-dark-logo.png +0 -0
- data/src/cmdx-favicon.svg +1 -0
- data/src/cmdx-light-logo.png +0 -0
- data/src/cmdx-logo.svg +1 -0
- metadata +15 -4
- data/lib/cmdx/freezer.rb +0 -51
- data/src/cmdx-logo.png +0 -0
    
        data/docs/basics/chain.md
    CHANGED
    
    | @@ -1,20 +1,14 @@ | |
| 1 1 | 
             
            # Basics - Chain
         | 
| 2 2 |  | 
| 3 | 
            -
            Chains automatically  | 
| 4 | 
            -
             | 
| 5 | 
            -
            ## Table of Contents
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            - [Management](#management)
         | 
| 8 | 
            -
            - [Links](#links)
         | 
| 9 | 
            -
            - [Inheritance](#inheritance)
         | 
| 10 | 
            -
            - [Structure](#structure)
         | 
| 3 | 
            +
            Chains automatically track related task executions within a thread. Think of them as execution traces that help you understand what happened and in what order.
         | 
| 11 4 |  | 
| 12 5 | 
             
            ## Management
         | 
| 13 6 |  | 
| 14 | 
            -
            Each thread maintains its own chain  | 
| 7 | 
            +
            Each thread maintains its own isolated chain using thread-local storage.
         | 
| 15 8 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 9 | 
            +
            !!! warning
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                Chains are thread-local. Don't share chain references across threads—it causes race conditions.
         | 
| 18 12 |  | 
| 19 13 | 
             
            ```ruby
         | 
| 20 14 | 
             
            # Thread A
         | 
| @@ -36,10 +30,11 @@ CMDx::Chain.clear    #=> Clears current thread's chain | |
| 36 30 |  | 
| 37 31 | 
             
            ## Links
         | 
| 38 32 |  | 
| 39 | 
            -
             | 
| 33 | 
            +
            Tasks automatically create or join the current thread's chain:
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            !!! warning "Important"
         | 
| 40 36 |  | 
| 41 | 
            -
             | 
| 42 | 
            -
            > Chain creation is automatic and transparent. You don't need to manually manage chain lifecycle.
         | 
| 37 | 
            +
                Chain management is automatic—no manual lifecycle handling needed.
         | 
| 43 38 |  | 
| 44 39 | 
             
            ```ruby
         | 
| 45 40 | 
             
            class ImportDataset < CMDx::Task
         | 
| @@ -62,7 +57,7 @@ end | |
| 62 57 |  | 
| 63 58 | 
             
            ## Inheritance
         | 
| 64 59 |  | 
| 65 | 
            -
             | 
| 60 | 
            +
            Subtasks automatically inherit the current thread's chain, building a unified execution trail:
         | 
| 66 61 |  | 
| 67 62 | 
             
            ```ruby
         | 
| 68 63 | 
             
            class ImportDataset < CMDx::Task
         | 
| @@ -87,10 +82,11 @@ chain.results.map { |r| r.task.class } | |
| 87 82 |  | 
| 88 83 | 
             
            ## Structure
         | 
| 89 84 |  | 
| 90 | 
            -
            Chains  | 
| 85 | 
            +
            Chains expose comprehensive execution information:
         | 
| 91 86 |  | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 87 | 
            +
            !!! warning "Important"
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                Chain state reflects the first (outermost) task result. Subtasks maintain their own states.
         | 
| 94 90 |  | 
| 95 91 | 
             
            ```ruby
         | 
| 96 92 | 
             
            result = ImportDataset.execute(dataset_id: 456)
         | 
| @@ -110,8 +106,3 @@ chain.results.each_with_index do |result, index| | |
| 110 106 | 
             
              puts "#{index}: #{result.task.class} - #{result.status}"
         | 
| 111 107 | 
             
            end
         | 
| 112 108 | 
             
            ```
         | 
| 113 | 
            -
             | 
| 114 | 
            -
            ---
         | 
| 115 | 
            -
             | 
| 116 | 
            -
            - **Prev:** [Basics - Context](context.md)
         | 
| 117 | 
            -
            - **Next:** [Interruptions - Halt](../interruptions/halt.md)
         | 
    
        data/docs/basics/context.md
    CHANGED
    
    | @@ -1,17 +1,10 @@ | |
| 1 1 | 
             
            # Basics - Context
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
            ## Table of Contents
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            - [Assigning Data](#assigning-data)
         | 
| 8 | 
            -
            - [Accessing Data](#accessing-data)
         | 
| 9 | 
            -
            - [Modifying Context](#modifying-context)
         | 
| 10 | 
            -
            - [Data Sharing](#data-sharing)
         | 
| 3 | 
            +
            Context is your data container for inputs, intermediate values, and outputs. It makes sharing data between tasks effortless.
         | 
| 11 4 |  | 
| 12 5 | 
             
            ## Assigning Data
         | 
| 13 6 |  | 
| 14 | 
            -
            Context  | 
| 7 | 
            +
            Context automatically captures all task inputs, normalizing keys to symbols:
         | 
| 15 8 |  | 
| 16 9 | 
             
            ```ruby
         | 
| 17 10 | 
             
            # Direct execution
         | 
| @@ -21,12 +14,13 @@ CalculateShipping.execute(weight: 2.5, destination: "CA") | |
| 21 14 | 
             
            CalculateShipping.new(weight: 2.5, "destination" => "CA")
         | 
| 22 15 | 
             
            ```
         | 
| 23 16 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 17 | 
            +
            !!! warning "Important"
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                String keys convert to symbols automatically. Prefer symbols for consistency.
         | 
| 26 20 |  | 
| 27 21 | 
             
            ## Accessing Data
         | 
| 28 22 |  | 
| 29 | 
            -
             | 
| 23 | 
            +
            Access context data using method notation, hash keys, or safe accessors:
         | 
| 30 24 |  | 
| 31 25 | 
             
            ```ruby
         | 
| 32 26 | 
             
            class CalculateShipping < CMDx::Task
         | 
| @@ -49,8 +43,9 @@ class CalculateShipping < CMDx::Task | |
| 49 43 | 
             
            end
         | 
| 50 44 | 
             
            ```
         | 
| 51 45 |  | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 46 | 
            +
            !!! warning "Important"
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                Undefined attributes return `nil` instead of raising errors—perfect for optional data.
         | 
| 54 49 |  | 
| 55 50 | 
             
            ## Modifying Context
         | 
| 56 51 |  | 
| @@ -91,12 +86,13 @@ class CalculateShipping < CMDx::Task | |
| 91 86 | 
             
            end
         | 
| 92 87 | 
             
            ```
         | 
| 93 88 |  | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 89 | 
            +
            !!! tip
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                Use context for both input values and intermediate results. This creates natural data flow through your task execution pipeline.
         | 
| 96 92 |  | 
| 97 93 | 
             
            ## Data Sharing
         | 
| 98 94 |  | 
| 99 | 
            -
             | 
| 95 | 
            +
            Share context across tasks for seamless data flow:
         | 
| 100 96 |  | 
| 101 97 | 
             
            ```ruby
         | 
| 102 98 | 
             
            # During execution
         | 
| @@ -123,8 +119,3 @@ result = CalculateShipping.execute(destination: "New York, NY") | |
| 123 119 |  | 
| 124 120 | 
             
            CreateShippingLabel.execute(result)
         | 
| 125 121 | 
             
            ```
         | 
| 126 | 
            -
             | 
| 127 | 
            -
            ---
         | 
| 128 | 
            -
             | 
| 129 | 
            -
            - **Prev:** [Basics - Execution](execution.md)
         | 
| 130 | 
            -
            - **Next:** [Basics - Chain](chain.md)
         | 
    
        data/docs/basics/execution.md
    CHANGED
    
    | @@ -1,19 +1,10 @@ | |
| 1 1 | 
             
            # Basics - Execution
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            CMDx offers two execution methods with different error handling approaches. Choose based on your needs: safe result handling or exception-based control flow.
         | 
| 4 4 |  | 
| 5 | 
            -
            ##  | 
| 5 | 
            +
            ## Execution Methods
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
            - [Non-bang Execution](#non-bang-execution)
         | 
| 9 | 
            -
            - [Bang Execution](#bang-execution)
         | 
| 10 | 
            -
            - [Direct Instantiation](#direct-instantiation)
         | 
| 11 | 
            -
            - [Result Details](#result-details)
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            ## Methods Overview
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            Tasks are single-use objects. Once executed, they are frozen and cannot be executed again.
         | 
| 16 | 
            -
            Create a new instance for subsequent executions.
         | 
| 7 | 
            +
            Both methods return results, but handle failures differently:
         | 
| 17 8 |  | 
| 18 9 | 
             
            | Method | Returns | Exceptions | Use Case |
         | 
| 19 10 | 
             
            |--------|---------|------------|----------|
         | 
| @@ -22,10 +13,7 @@ Create a new instance for subsequent executions. | |
| 22 13 |  | 
| 23 14 | 
             
            ## Non-bang Execution
         | 
| 24 15 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
            This is the preferred method for most use cases.
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            Any unhandled exceptions will be caught and returned as a task failure.
         | 
| 16 | 
            +
            Always returns a `CMDx::Result`, never raises exceptions. Perfect for most use cases.
         | 
| 29 17 |  | 
| 30 18 | 
             
            ```ruby
         | 
| 31 19 | 
             
            result = CreateAccount.execute(email: "user@example.com")
         | 
| @@ -43,17 +31,16 @@ result.status           #=> "success" | |
| 43 31 |  | 
| 44 32 | 
             
            ## Bang Execution
         | 
| 45 33 |  | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
            It raises any unhandled non-fault exceptions caused during execution.
         | 
| 34 | 
            +
            Raises `CMDx::Fault` exceptions on failure or skip. Returns results only on success.
         | 
| 49 35 |  | 
| 50 36 | 
             
            | Exception | Raised When |
         | 
| 51 37 | 
             
            |-----------|-------------|
         | 
| 52 38 | 
             
            | `CMDx::FailFault` | Task execution fails |
         | 
| 53 39 | 
             
            | `CMDx::SkipFault` | Task execution is skipped |
         | 
| 54 40 |  | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 41 | 
            +
            !!! warning "Important"
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                Behavior depends on `task_breakpoints` or `workflow_breakpoints` config. Default: only failures raise exceptions.
         | 
| 57 44 |  | 
| 58 45 | 
             
            ```ruby
         | 
| 59 46 | 
             
            begin
         | 
| @@ -107,8 +94,3 @@ result.chain        #=> Task execution chain | |
| 107 94 | 
             
            result.context      #=> Context with all task data
         | 
| 108 95 | 
             
            result.metadata     #=> Hash with execution metadata
         | 
| 109 96 | 
             
            ```
         | 
| 110 | 
            -
             | 
| 111 | 
            -
            ---
         | 
| 112 | 
            -
             | 
| 113 | 
            -
            - **Prev:** [Basics - Setup](setup.md)
         | 
| 114 | 
            -
            - **Next:** [Basics - Context](context.md)
         | 
    
        data/docs/basics/setup.md
    CHANGED
    
    | @@ -1,16 +1,10 @@ | |
| 1 1 | 
             
            # Basics - Setup
         | 
| 2 2 |  | 
| 3 | 
            -
            Tasks are the  | 
| 4 | 
            -
             | 
| 5 | 
            -
            ## Table of Contents
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            - [Structure](#structure)
         | 
| 8 | 
            -
            - [Inheritance](#inheritance)
         | 
| 9 | 
            -
            - [Lifecycle](#lifecycle)
         | 
| 3 | 
            +
            Tasks are the heart of CMDx—self-contained units of business logic with built-in validation, error handling, and execution tracking.
         | 
| 10 4 |  | 
| 11 5 | 
             
            ## Structure
         | 
| 12 6 |  | 
| 13 | 
            -
            Tasks inherit from `CMDx::Task` and  | 
| 7 | 
            +
            Tasks need only two things: inherit from `CMDx::Task` and define a `work` method:
         | 
| 14 8 |  | 
| 15 9 | 
             
            ```ruby
         | 
| 16 10 | 
             
            class ValidateDocument < CMDx::Task
         | 
| @@ -20,7 +14,7 @@ class ValidateDocument < CMDx::Task | |
| 20 14 | 
             
            end
         | 
| 21 15 | 
             
            ```
         | 
| 22 16 |  | 
| 23 | 
            -
             | 
| 17 | 
            +
            Without a `work` method, execution raises `CMDx::UndefinedMethodError`.
         | 
| 24 18 |  | 
| 25 19 | 
             
            ```ruby
         | 
| 26 20 | 
             
            class IncompleteTask < CMDx::Task
         | 
| @@ -32,8 +26,7 @@ IncompleteTask.execute #=> raises CMDx::UndefinedMethodError | |
| 32 26 |  | 
| 33 27 | 
             
            ## Inheritance
         | 
| 34 28 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
            Create a base class to share common configuration across tasks:
         | 
| 29 | 
            +
            Share configuration across tasks using inheritance:
         | 
| 37 30 |  | 
| 38 31 | 
             
            ```ruby
         | 
| 39 32 | 
             
            class ApplicationTask < CMDx::Task
         | 
| @@ -59,10 +52,11 @@ end | |
| 59 52 |  | 
| 60 53 | 
             
            ## Lifecycle
         | 
| 61 54 |  | 
| 62 | 
            -
            Tasks follow a predictable  | 
| 55 | 
            +
            Tasks follow a predictable execution pattern:
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            !!! danger "Caution"
         | 
| 63 58 |  | 
| 64 | 
            -
             | 
| 65 | 
            -
            > Tasks are single-use objects. Once executed, they are frozen and cannot be executed again.
         | 
| 59 | 
            +
                Tasks are single-use objects. Once executed, they're frozen and immutable.
         | 
| 66 60 |  | 
| 67 61 | 
             
            | Stage | State | Status | Description |
         | 
| 68 62 | 
             
            |-------|-------|--------|-------------|
         | 
| @@ -71,8 +65,3 @@ Tasks follow a predictable call pattern with specific states and statuses: | |
| 71 65 | 
             
            | **Execution** | `executing` | `success`/`failed`/`skipped` | `work` method runs |
         | 
| 72 66 | 
             
            | **Completion** | `executed` | `success`/`failed`/`skipped` | Result finalized |
         | 
| 73 67 | 
             
            | **Freezing** | `executed` | `success`/`failed`/`skipped` | Task becomes immutable |
         | 
| 74 | 
            -
             | 
| 75 | 
            -
            ---
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            - **Prev:** [Getting Started](../getting_started.md)
         | 
| 78 | 
            -
            - **Next:** [Basics - Execution](execution.md)
         | 
    
        data/docs/callbacks.md
    CHANGED
    
    | @@ -1,36 +1,27 @@ | |
| 1 1 | 
             
            # Callbacks
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            Run custom logic at specific points during task execution. Callbacks have full access to task context and results, making them perfect for logging, notifications, cleanup, and more.
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 5 | 
            +
            See [Global Configuration](getting_started.md#callbacks) for framework-wide callback setup.
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
            > Callbacks execute in the order they are declared within each hook type. Multiple callbacks of the same type execute in declaration order (FIFO: first in, first out).
         | 
| 7 | 
            +
            !!! warning "Important"
         | 
| 9 8 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
            - [Available Callbacks](#available-callbacks)
         | 
| 13 | 
            -
            - [Declarations](#declarations)
         | 
| 14 | 
            -
              - [Symbol References](#symbol-references)
         | 
| 15 | 
            -
              - [Proc or Lambda](#proc-or-lambda)
         | 
| 16 | 
            -
              - [Class or Module](#class-or-module)
         | 
| 17 | 
            -
              - [Conditional Execution](#conditional-execution)
         | 
| 18 | 
            -
            - [Callback Removal](#callback-removal)
         | 
| 9 | 
            +
                Callbacks execute in declaration order (FIFO). Multiple callbacks of the same type run sequentially.
         | 
| 19 10 |  | 
| 20 11 | 
             
            ## Available Callbacks
         | 
| 21 12 |  | 
| 22 | 
            -
            Callbacks execute in  | 
| 13 | 
            +
            Callbacks execute in a predictable lifecycle order:
         | 
| 23 14 |  | 
| 24 15 | 
             
            ```ruby
         | 
| 25 16 | 
             
            1. before_validation           # Pre-validation setup
         | 
| 26 | 
            -
            2. before_execution            #  | 
| 17 | 
            +
            2. before_execution            # Prepare for execution
         | 
| 27 18 |  | 
| 28 | 
            -
            # --- Task#work  | 
| 19 | 
            +
            # --- Task#work executes ---
         | 
| 29 20 |  | 
| 30 | 
            -
            3. on_[complete|interrupted]   #  | 
| 31 | 
            -
            4. on_executed                 #  | 
| 32 | 
            -
            5. on_[success|skipped|failed] #  | 
| 33 | 
            -
            6. on_[good|bad]               #  | 
| 21 | 
            +
            3. on_[complete|interrupted]   # State-based (execution lifecycle)
         | 
| 22 | 
            +
            4. on_executed                 # Always runs after work completes
         | 
| 23 | 
            +
            5. on_[success|skipped|failed] # Status-based (business outcome)
         | 
| 24 | 
            +
            6. on_[good|bad]               # Outcome-based (success/skip vs fail)
         | 
| 34 25 | 
             
            ```
         | 
| 35 26 |  | 
| 36 27 | 
             
            ## Declarations
         | 
| @@ -73,7 +64,7 @@ Use anonymous functions for inline callback logic: | |
| 73 64 | 
             
            ```ruby
         | 
| 74 65 | 
             
            class ProcessBooking < CMDx::Task
         | 
| 75 66 | 
             
              # Proc
         | 
| 76 | 
            -
              on_interrupted proc {  | 
| 67 | 
            +
              on_interrupted proc { ReservationSystem.pause! }
         | 
| 77 68 |  | 
| 78 69 | 
             
              # Lambda
         | 
| 79 70 | 
             
              on_complete -> { ReservationSystem.resume! }
         | 
| @@ -120,10 +111,10 @@ class ProcessBooking < CMDx::Task | |
| 120 111 | 
             
              before_execution :notify_guest, if: :messaging_enabled?, unless: :messaging_blocked?
         | 
| 121 112 |  | 
| 122 113 | 
             
              # Proc
         | 
| 123 | 
            -
              on_failure :increment_failure, if: -> | 
| 114 | 
            +
              on_failure :increment_failure, if: -> { Rails.env.production? && self.class.name.include?("Legacy") }
         | 
| 124 115 |  | 
| 125 116 | 
             
              # Lambda
         | 
| 126 | 
            -
              on_success :ping_housekeeping, if: proc {  | 
| 117 | 
            +
              on_success :ping_housekeeping, if: proc { context.rooms_need_cleaning? }
         | 
| 127 118 |  | 
| 128 119 | 
             
              # Class or Module
         | 
| 129 120 | 
             
              on_complete :send_confirmation, unless: MessagingPermissionCheck
         | 
| @@ -138,7 +129,7 @@ class ProcessBooking < CMDx::Task | |
| 138 129 | 
             
              private
         | 
| 139 130 |  | 
| 140 131 | 
             
              def messaging_enabled?
         | 
| 141 | 
            -
                context.guest.messaging_preference | 
| 132 | 
            +
                context.guest.messaging_preference == true
         | 
| 142 133 | 
             
              end
         | 
| 143 134 |  | 
| 144 135 | 
             
              def messaging_blocked?
         | 
| @@ -149,10 +140,11 @@ end | |
| 149 140 |  | 
| 150 141 | 
             
            ## Callback Removal
         | 
| 151 142 |  | 
| 152 | 
            -
            Remove callbacks  | 
| 143 | 
            +
            Remove unwanted callbacks dynamically:
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            !!! warning "Important"
         | 
| 153 146 |  | 
| 154 | 
            -
             | 
| 155 | 
            -
            > Only one removal operation is allowed per `deregister` call. Multiple removals require separate calls.
         | 
| 147 | 
            +
                Each `deregister` call removes one callback. Use multiple calls for batch removals.
         | 
| 156 148 |  | 
| 157 149 | 
             
            ```ruby
         | 
| 158 150 | 
             
            class ProcessBooking < CMDx::Task
         | 
| @@ -163,8 +155,3 @@ class ProcessBooking < CMDx::Task | |
| 163 155 | 
             
              deregister :callback, :on_complete, BookingConfirmationCallback
         | 
| 164 156 | 
             
            end
         | 
| 165 157 | 
             
            ```
         | 
| 166 | 
            -
             | 
| 167 | 
            -
            ---
         | 
| 168 | 
            -
             | 
| 169 | 
            -
            - **Prev:** [Attributes - Defaults](attributes/defaults.md)
         | 
| 170 | 
            -
            - **Next:** [Middlewares](middlewares.md)
         | 
    
        data/docs/deprecation.md
    CHANGED
    
    | @@ -1,28 +1,16 @@ | |
| 1 1 | 
             
            # Task Deprecation
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
            ## Table of Contents
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            - [Modes](#modes)
         | 
| 8 | 
            -
              - [Raise](#raise)
         | 
| 9 | 
            -
              - [Log](#log)
         | 
| 10 | 
            -
              - [Warn](#warn)
         | 
| 11 | 
            -
            - [Declarations](#declarations)
         | 
| 12 | 
            -
              - [Symbol or String](#symbol-or-string)
         | 
| 13 | 
            -
              - [Boolean or Nil](#boolean-or-nil)
         | 
| 14 | 
            -
              - [Method](#method)
         | 
| 15 | 
            -
              - [Proc or Lambda](#proc-or-lambda)
         | 
| 16 | 
            -
              - [Class or Module](#class-or-module)
         | 
| 3 | 
            +
            Manage legacy tasks gracefully with built-in deprecation support. Choose how to handle deprecated tasks—log warnings for awareness, issue Ruby warnings for development, or prevent execution entirely.
         | 
| 17 4 |  | 
| 18 5 | 
             
            ## Modes
         | 
| 19 6 |  | 
| 20 7 | 
             
            ### Raise
         | 
| 21 8 |  | 
| 22 | 
            -
             | 
| 9 | 
            +
            Prevent task execution completely. Perfect for tasks that must no longer run.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            !!! warning
         | 
| 23 12 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
            > Use `:raise` mode carefully in production environments as it will break existing workflows immediately.
         | 
| 13 | 
            +
                Use `:raise` mode carefully—it will break existing workflows immediately.
         | 
| 26 14 |  | 
| 27 15 | 
             
            ```ruby
         | 
| 28 16 | 
             
            class ProcessObsoleteAPI < CMDx::Task
         | 
| @@ -39,7 +27,7 @@ result = ProcessObsoleteAPI.execute | |
| 39 27 |  | 
| 40 28 | 
             
            ### Log
         | 
| 41 29 |  | 
| 42 | 
            -
             | 
| 30 | 
            +
            Allow execution while tracking deprecation in logs. Ideal for gradual migrations.
         | 
| 43 31 |  | 
| 44 32 | 
             
            ```ruby
         | 
| 45 33 | 
             
            class ProcessLegacyFormat < CMDx::Task
         | 
| @@ -62,7 +50,7 @@ result.successful? #=> true | |
| 62 50 |  | 
| 63 51 | 
             
            ### Warn
         | 
| 64 52 |  | 
| 65 | 
            -
             | 
| 53 | 
            +
            Issue Ruby warnings visible during development and testing. Keeps production logs clean while alerting developers.
         | 
| 66 54 |  | 
| 67 55 | 
             
            ```ruby
         | 
| 68 56 | 
             
            class ProcessOldData < CMDx::Task
         | 
| @@ -77,7 +65,7 @@ result = ProcessOldData.execute | |
| 77 65 | 
             
            result.successful? #=> true
         | 
| 78 66 |  | 
| 79 67 | 
             
            # Ruby warning appears in stderr:
         | 
| 80 | 
            -
            # [ProcessOldData] DEPRECATED: migrate to replacement or discontinue use
         | 
| 68 | 
            +
            # [ProcessOldData] DEPRECATED: migrate to a replacement or discontinue use
         | 
| 81 69 | 
             
            ```
         | 
| 82 70 |  | 
| 83 71 | 
             
            ## Declarations
         | 
| @@ -155,8 +143,3 @@ class OutdatedConnector < CMDx::Task | |
| 155 143 | 
             
              settings(deprecated: OutdatedTaskDeprecator.new)
         | 
| 156 144 | 
             
            end
         | 
| 157 145 | 
             
            ```
         | 
| 158 | 
            -
             | 
| 159 | 
            -
            ---
         | 
| 160 | 
            -
             | 
| 161 | 
            -
            - **Prev:** [Internationalization (i18n)](internationalization.md)
         | 
| 162 | 
            -
            - **Next:** [Workflows](workflows.md)
         |