---
id: STATE-PFM-INT-015
title: Automation rule lifecycle
object: DOM-PFM-INT-006
product_area: platform
module: integrations
revision: 1
status: draft
design_intent: confirmed
implementation_evidence: observed
origin: docs/proposals/application-processes-and-workflow-actions/14-decisions.md D-10 (Andrew 2026-10-17)
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
states:
  - name: draft
    meaning: An unpublished rule has editable content and raises no work.
  - name: enabled
    meaning: The current publication can raise work when its event occurs.
  - name: disabled
    meaning: A published rule remains saved while new event work is paused.
  - name: retired
    meaning: The rule remains for history and cannot be used for new work.
  - name: deleted
    meaning: A never-published rule and its draft were removed.
transitions:
  - from: draft
    to: draft
    trigger: Save unpublished content
    guard: The read version matches and the rule remains editable
    side_effects:
      - Update the first draft’s content.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: draft
    to: enabled
    trigger: Publish the first version
    guard: 'Registered event, condition facts, valid actions and publisher authority checks pass'
    side_effects:
      - Freeze content and publication attribution
      - Record permissions and select the current version.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: enabled
    to: enabled
    trigger: Publish a replacement version
    guard: A new draft exists and ordinary publication checks pass
    side_effects:
      - Freeze the replacement and move the current publication.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: enabled
    to: disabled
    trigger: Pause published automation
    guard: The rule remains enabled
    side_effects:
      - Exclude the rule from subsequent event reads.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: disabled
    to: enabled
    trigger: Restore paused automation
    guard: The rule remains disabled
    side_effects:
      - Use its current publication for subsequent events.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: disabled
    to: disabled
    trigger: Publish while paused
    guard: A draft exists and ordinary publication checks pass
    side_effects:
      - Update the current publication without enabling the rule.
    who: Automation administrator
    provenance: inferred
    source: 'services-platform:modules/workflow-actions/services/automation/publish-automation-rule.ts'
    note: Publishing changes standing to enabled only when the rule was still a draft.
  - from: draft
    to: retired
    trigger: Retire unpublished automation
    guard: The rule is not already retired
    side_effects:
      - Keep the rule as a retired record.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: enabled
    to: retired
    trigger: Retire usable automation
    guard: The rule is not already retired
    side_effects:
      - Keep the rule and version references used by host runs.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: disabled
    to: retired
    trigger: Retire paused automation
    guard: The rule is not already retired
    side_effects:
      - Keep the rule and version references used by host runs.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
  - from: draft
    to: deleted
    trigger: Delete never-published automation
    guard: The rule has no publication history
    side_effects:
      - Remove its retained draft and rule record.
    who: Automation administrator
    provenance: observed
    source: 'services-platform:modules/workflow-actions/services/persistence/automation-rules.ts'
invalid:
  - from: draft
    to: disabled
    why: Publication is the path from unpublished configuration to usable automation.
  - from: retired
    to: enabled
    why: Retired rules cannot be enabled again.
  - from: enabled
    to: deleted
    why: Deletion is limited to never-published rules; published ones are retired instead.
concurrency: >-
  Publication locks both rule and draft. Database checks permit one draft and protect published content from
  changes. Hosts read applicable publications at event time; disabling a rule does not cancel runs already
  raised.
invariants:
  - INV-DOM-PFM-INT-006-07
  - INV-DOM-PFM-INT-006-08
  - INV-DOM-PFM-INT-006-09
evidence:
  - >-
    services-platform at ad3f6a65: modules/workflow-actions/db/automation-rules.table.ts,
    automation-rule-versions.table.ts; services/automation/*; docs/workflow-actions/automation-rules.md
---

# Automation rule lifecycle

## The Lifecycle

```mermaid
stateDiagram-v2
  state "draft" as s0
  state "enabled" as s1
  state "disabled" as s2
  state "retired" as s3
  state "deleted" as s4
  s0 --> s0: Save unpublished content
  s0 --> s1: Publish the first version
  s1 --> s1: Publish a replacement version
  s1 --> s2: Pause published automation
  s2 --> s1: Restore paused automation
  s2 --> s2: Publish while paused
  s0 --> s3: Retire unpublished automation
  s1 --> s3: Retire usable automation
  s2 --> s3: Retire paused automation
  s0 --> s4: Delete never-published automation
```

## Transitions Explained

Publication freezes the draft and selects it for later events. Subsequent edits create another draft without changing the current publication. Administrators pause or restore new event work, retire rules for history and delete only never-published configuration.

## What Cannot Happen

Publication is the path from unpublished configuration to usable automation. Retired rules cannot be enabled again. Deletion is limited to never-published rules; published ones are retired instead.

## Concurrency and Timing

Publication locks both rule and draft. Database checks permit one draft and protect published content from changes. Hosts read applicable publications at event time; disabling a rule does not cancel runs already raised.
