AAnvio
Reference ArchiveSource Docs

Automation Engine

The Automation Engine executes recurring and event-driven workflows without manual intervention. All automations are **configuration-driven** and stored in the filesystem by default.

3 min read

This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.

Original path: docs/27-automation-engine.md

The Automation Engine executes recurring and event-driven workflows without manual intervention. All automations are configuration-driven and stored in the filesystem by default.

Trigger Types

TypeExampleConfig Key
Scheduled (Cron)Every day at 08:00schedule: "0 8 * * *"
EventOn every commiton: git.commit
WorkflowAfter blueprint completeson: workflow.completed
GoalWhen goal reaches 100%on: goal.completed

File Layout

workspace/automations/
  daily-summary.yaml
  weekly-review.yaml
  on-commit-review.yaml

workspace/automations/_state/
  daily-summary.last-run    # Persisted scheduler state
  cron.lock                 # Leader election (optional, multi-instance)

Automation Schema

apiVersion: anvio.io/v1
kind: Automation
metadata:
  slug: daily-summary
  enabled: true
spec:
  description: Summarize notifications every morning
  trigger:
    type: cron
    schedule: "0 8 * * *"
    timezone: Asia/Jakarta
  action:
    type: blueprint
    blueprint: daily-summary
    inputs:
      userId: local-user
  retry:
    maxAttempts: 3
    backoff: exponential
  onFailure:
    notify: true
    hook: workspace/hooks/on-automation-failed.sh

Event Trigger Example

apiVersion: anvio.io/v1
kind: Automation
metadata:
  slug: on-commit-review
spec:
  trigger:
    type: event
    event: git.commit
    filter:
      branch: main
  action:
    type: agent
    agent: code-reviewer
    input: "Review the latest commit"

Goal Trigger Example

spec:
  trigger:
    type: goal
    event: goal.completed
    goalSlug: project-refactor
  action:
    type: blueprint
    blueprint: release-preparation

Architecture

Rendering diagram…

Sequence: Scheduled Run

Rendering diagram…

Cron Scheduler

Native cron scheduling with restart-safe persistence.

Features

  • Standard cron expressions (0 8 * * *, 0 9 * * MON)
  • Timezone-aware (spec.trigger.timezone)
  • State persisted to workspace/automations/_state/
  • Survives process restarts — missed runs optionally catch up (configurable)

Cron Schema Extension

trigger:
  type: cron
  schedule: "0 9 * * MON"
  timezone: UTC
  catchUp: false          # skip missed runs after long downtime
  maxCatchUp: 1           # max catch-up executions

Implementation Notes

  • Level 1: in-process node-cron or lightweight scheduler in packages/automation
  • Level 3: optional distributed lock via Redis for multi-worker deployments
  • Cron definitions live in automation YAML — no code changes to add schedules

CLI

anvio cron list
anvio cron add daily-summary --schedule "0 8 * * *"
anvio cron remove daily-summary
anvio cron next-runs --limit 5

Failure Handling

PolicyBehavior
retry.maxAttemptsRetry with backoff
onFailure.notifySend notification via channel hub
onFailure.hookExecute local script

Extension Guide

Status (2026-10-25): items below that mention a plugin or plugin manifest describe design intent. Anvio has no plugin system (ROADMAP T-058); extending this subsystem today means changing the package code.

  1. Register custom trigger types via plugin manifest
  2. Register custom action types (type: webhook, type: mcp-tool)
  3. Add automations by dropping YAML in workspace/automations/

Operational Runbook

ScenarioAction
Disable automationSet metadata.enabled: false
Debug missed runCheck automations/_state/\{slug\}.last-run
Force runanvio automation run daily-summary --force
View logsanvio logs --automation daily-summary

Package Boundaries

  • Schema: packages/core/src/schemas/automation.schema.ts
  • Engine: packages/automation/src/automation-engine.ts
  • Cron: packages/automation/src/cron-scheduler.ts
  • State: packages/automation/src/filesystem-state-store.ts
Edit on GitHub

Last updated on

On this page