Class: CommandTower::Workflows::ClientCompatibility::EvaluateWorkflow

Inherits:
ApplicationWorkflow show all
Defined in:
app/workflows/command_tower/workflows/client_compatibility/evaluate_workflow.rb

Overview

Orchestrates one HTTP request's client-version-compatibility check. Maps the pure Services::ClientCompatibility::Evaluate projection to a WorkflowResult, and is the only layer (along with the boundary) allowed to place recommendation metadata onto CommandTower::Current — Evaluate itself never touches Current (authority §10, §13).

Constant Summary collapse

APP_VERSION_HEADER =
"X-App-Version"
PLATFORM_HEADER =
"X-Client-Platform"

Constants inherited from ApplicationWorkflow

ApplicationWorkflow::ALLOWED_RETRY_STRATEGIES, ApplicationWorkflow::InvalidTransactionResult, ApplicationWorkflow::TransactionFailure

Instance Method Summary collapse

Methods inherited from ApplicationWorkflow

call, call_from_job, continuation_max_attempts, declared_retry_strategy, mark_impersonation_activity!, retry_strategy, validate_retry_strategy!

Methods included from Impersonation::ActivityDeclaration

included

Methods included from Logging::LifecycleDeclaration

included

Methods included from Execution::ContextAccess

#audit, #execution_context, #log_debug, #log_error, #log_info, #log_warn, #publish_event

Methods included from Transactional

#fail_transaction!, #transaction

Instance Method Details

#call(request:, controller_class:, action_name:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/workflows/command_tower/workflows/client_compatibility/evaluate_workflow.rb', line 17

def call(request:, controller_class:, action_name:)
  decision = CommandTower::Services::ClientCompatibility::Evaluate.call(
    app_version_header: request.headers[APP_VERSION_HEADER],
    platform_header: request.headers[PLATFORM_HEADER],
    controller_class: controller_class,
    action_name: action_name
  )

  mode = CommandTower.config.registry.client_compatibility.mode
  enforced = mode == :enforce
  blocked = enforced && decision.incompatible?

  log_decision(decision, mode:, enforced:, blocked:)
  stash_recommendation!(decision)

  if blocked
    return failure(
      errors: [CommandTower::Errors::ClientUpdateRequiredError.new(details: details_for(decision))],
      http_status: :upgrade_required
    )
  end

  success(payload: { decision: decision })
end