# Create, run, and monitor automation

**Flow key:** `automation-create-run-monitor`

## Outcome

An authorized user defines a versioned trigger-condition-action workflow, previews it, activates it, and observes idempotent execution, failure handling, and safe shutdown.

## Actors

- Automation author/admin
- Workflow engine
- Target services
- Observers/operators

## Preconditions and entry points

- Synthetic events and records cover match/no-match, duplicates, ordering, failure, and permissions.
- Rate, recursion, retry, authority, and version policies are known.

## Required test data

Use synthetic, isolated, resettable data. Never use real credentials, payment instruments, private customer records, or production notifications.

| Data | Canonical valid seed | Critical variations |
|---|---|---|
| Trigger | new synthetic lead event | duplicate, late, out of order, malformed, other tenant |
| Condition | status `Qualified` and score >= 80 | null, boundary 79/80/81, Unicode text, unknown enum |
| Action | assign owner and send test notification | unauthorized target, rate-limited integration, partial failure |
| Workflow | `CARBON Lead Router v1` disabled | draft edit, active old version, cloned, cyclic |
| Load | one event | batch boundary, burst, backlog, replay |

## Canonical steps

Treat this as the ordinary successful path inferred from common product behavior. Adapt it to observed labels, business rules, APIs, and implementation evidence; do not invent a requirement.

| Step | User or system action | Expected evidence |
|---:|---|---|
| 1 | Create a draft workflow. | Trigger, condition, action, authority, retry, limits, and version are explicit. |
| 2 | Validate and preview against synthetic match/no-match events. | Proposed decisions and actions are inspectable without mutation. |
| 3 | Activate/publish. | One immutable active version and audit entry exist. |
| 4 | Deliver a matching event. | One run evaluates the correct version and commits intended idempotent actions. |
| 5 | Deliver duplicate/failing events and monitor. | Retries, deduplication, failure branches, alerts, and manual recovery are truthful. |
| 6 | Pause, edit, publish new version, replay safely, and disable. | Queued/running/versioned work follows explicit semantics with no orphaned actions. |

## Alternate paths

- Scheduled workflow
- Event-driven rule
- Approval-gated action
- Multi-step workflow
- Dry run/replay

## Failure and recovery paths

- Event duplicated/out of order
- Role changes before execution
- Action commits before timeout
- Workflow loops
- Worker crash or backlog during disable

## Completion oracle

- The stated outcome is true in visible UI and authoritative persisted state.
- Exactly one intended business result and no unintended side effect occurred.
- Identity, tenant, authorization, money/data, lifecycle, notifications, integrations, analytics, and audit agree where applicable.
- Refresh, retry, back/forward, and a second authorized read do not reveal a contradictory result.
- Any partial, delayed, canceled, failed, or unknown outcome is labeled truthfully and has a safe recovery path.

## Evidence to capture

- Entry context, actor, tenant, role, feature flags, locale, time zone, and initial identifiers/state.
- Step-level screenshots or DOM state plus request/response, correlation, job, event, and stable business IDs where available.
- Before/after authoritative records, versions, totals, permissions, lifecycle states, and downstream side effects.
- Notifications, audit events, integration deliveries, retries, deduplication, latency, and recovery evidence.
- Untested branches, unsafe-to-run cases, product decisions, and evidence tier.

## Product decisions to resolve

- Exact eligibility, required data, authorization, and validation rules.
- Which steps are synchronous, asynchronous, optional, skippable, reversible, or irreversible.
- Idempotency, concurrency, timeout, retry, cancellation, and compensation semantics.
- Retention, privacy, notification, audit, performance, accessibility, and localization commitments.

## Related CARBON items

- [workflow graph](../../items/automation/workflow-graph.md)
- [trigger](../../items/automation/trigger.md)
- [condition and rule expression](../../items/automation/condition-and-rule-expression.md)
- [automated action](../../items/automation/automated-action.md)
- [audit](../../items/automation/audit.md)

[Back to AI and automation flows](index.md)
