Skip to main content
This section covers the automation and durable goal systems in Palyra. It explains the relationship between high-level Objectives, the underlying Routines engine, and the Cron scheduling system used for periodic execution.

System Architecture

The automation system is built on a layered architecture where user-facing “Objectives” are backed by technical “Routines”.
  • Objectives: High-level entities representing long-term goals or recurring checks (e.g., “Monitor server health”).
  • Routines: The execution engine that handles triggers, delivery configuration, and quiet hours.
  • Cron: The specific implementation of schedule-based triggers within the routine system.

Entity Relationship Diagram

The following diagram shows how high-level concepts map to internal code structures. “Natural Language Space to Code Entity Space” Sources: crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#18-25, apps/web/src/console/sections/OverviewSection.tsx#64-78

Objectives

Objectives represent durable stateful goals. They are managed via the palyra objectives command group crates/palyra-cli/src/args/mod.rs#138.

Objective Types (ObjectiveKindArg)

Defined in crates/palyra-cli/src/args/objectives.rs#150-155:
  1. Objective: A standard goal-oriented task.
  2. Heartbeat: A recurring check-in or status monitor.
  3. Standing Order: Persistent instructions applied to specific contexts.
  4. Program: A complex, multi-step automated workflow.

Objective Lifecycle Actions

Objectives transition through several states (ObjectiveStateArg): Draft, Active, Paused, Cancelled, and Archived crates/palyra-cli/src/args/objectives.rs#170-176. Key lifecycle commands implemented in run_objectives_async: Sources: crates/palyra-cli/src/args/objectives.rs#150-189, crates/palyra-cli/src/commands/objectives.rs#12-143

Routines & Scheduling

Routines are the unified automation surface for schedules and event triggers crates/palyra-cli/src/args/mod.rs#139.

Schedule Configuration

Routines support multiple schedule types defined in ObjectiveScheduleTypeArg crates/palyra-cli/src/args/objectives.rs#212-217:
  • Cron: Standard crontab expressions.
  • Every: Interval-based execution (e.g., every 5 minutes).
  • At: One-time execution at a specific timestamp.

Routine Features

FeatureImplementationDescription
Natural Languagenatural_language_scheduleParses phrases like “every Friday at noon” into cron expressions crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#72.
Quiet HoursRoutineQuietHoursPrevents execution during specific time windows (e.g., 10 PM to 6 AM) crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#96-100.
Approval ModeRoutineApprovalModeDefines if a run requires human intervention (None, Required, Always) crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#104.
DeliveryRoutineDeliveryConfigConfigures where the output is sent (e.g., a specific Discord channel) crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#92-94.
Sources: crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#53-107, crates/palyra-cli/src/args/objectives.rs#212-227

Cron Commands

The palyra cron command group provides a schedule-only interface that interacts with the routines compatibility layer crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#17.

Data Flow: Schedule to Execution

The following diagram traces a scheduled task from configuration to the daemon’s internal CronJobRecord. “Cron Execution Flow” Sources: crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#154-215, crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#9-25

Key Parameters

Sources: crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#12-25, apps/web/src/console/sections/CronSection.tsx#35-55

Implementation Details

Console Handlers

The logic for managing these entities resides in crates/palyra-daemon/src/transport/http/handlers/console/routines.rs.

Web Console Integration

The Web UI provides specialized sections for these systems: Sources: crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#1-153, apps/web/src/console/sections/OverviewSection.tsx#100-206