<?php

declare(strict_types=1);

namespace Drupal\flowdrop_interrupt\Message;

use Drupal\flowdrop_interrupt\Enum\InterruptType;

/**
 * Operator- or parent-initiated signal targeting a running pipeline.
 *
 * Inward signals (Cancel, Pause) don't originate from a node — they're
 * pushed at a pipeline from outside the execution graph. The polling
 * subscriber finds them by `targetPipelineId` and feeds them back into the
 * orchestrator. See PipelineSignalPollSubscriber.
 *
 * Two call sites today:
 *  - {@see \Drupal\flowdrop_interrupt\Controller\PipelineSignalController}
 *    — HTTP endpoint hit by the playground "Cancel" button.
 *  - `WorkflowExecutionService::cancelExecution()` — cascade signal when a
 *    parent workflow's cancel propagates to a sub-pipeline.
 *
 * The handler stamps `direction = Inward`, `targetPipelineId`,
 * `initiatorUid`, and `reason` on the persisted entity.
 *
 * @api
 */
final class InwardSignalMessage extends AbstractInterruptMessage {

  public function __construct(
    InterruptType $type,
    string $message,
    public readonly string $targetPipelineId,
    public readonly ?int $initiatorUid = NULL,
    public readonly ?string $reason = NULL,
  ) {
    parent::__construct($type, $message);
  }

}
