Automations and workflows

Plain-text prompts and processes sent to replaceable AI destinations

A Celorga workflow is a maintained, reusable process. Each workflow is an ordinary Org file under the visible top-level workflows/ directory. The file is the source of truth: it can be opened in Celorga, another editor, a terminal, or Git without depending on private application state.

The Mac app and runtime adapters provide tooling around the file. They can create prompt automations, list and validate workflows, collect inputs, start runs, activate or pause schedules, delete definitions, and show execution history. Those controls must update or act from the canonical workflow file rather than creating a second GUI-owned definition.

Workflow, run, and runtime

  • A workflow describes how a class of work should happen: inputs, context rules, instructions, steps, outputs, validation, approvals, and triggers.

  • A logical work item groups recurring executions without conflating scheduler ticks.

  • An attempt run records one concrete execution of one workflow version, including its trigger, attempt number, context, state, artifacts, approvals, validation, events, and outcome.

  • An agent profile is the stable Celorga worker identity or responsibility attached to the work.

  • An AI destination is the configured execution endpoint, such as local Codex, Claude Code, OpenClaw, or a direct model provider. It is not the agent identity.

  • A runtime adapter sends work to that destination and normalizes its result into the same history. The workflow and run formats do not depend on one provider.

Repeating a prompt is useful, but it does not by itself create a workflow. A workflow earns its durable form by making the process inspectable, editable, versionable, reviewable, and reliable across executions.

File ownership

The default corpus layout separates authored process from execution state:

workflows/                 authored workflow files
.celorga/runs/                generated durable run records
.celorga/                     runtime bindings, correlation state, and derived control data

Older early-alpha installations may keep workflows in a workflows/ folder inside the hidden state directory. Celorga continues to read that location, prefers a visible workflows/ file when both contain the same workflow ID, and provides celorga workflow migrate to move non-conflicting legacy files. New and newly saved workflows use workflows/.

One workflow per file is the default. A note or project heading may link to or invoke a workflow, while independent files keep workflow identity, version history, review, and distribution straightforward.

Creating an automation

Open Agent Work → Automations in the Mac app and choose New Automation. Give it a name and prompt, select any enabled AI destination, optionally pin an exact model and reasoning effort, optionally attach an agent profile, and either leave it manual or add an interval or cron schedule. Celorga writes the result as a normal file under workflows/. Edit Source opens that canonical file in the ordinary Celorga editor.

The minimal CLI form is:

celorga workflow create weekly-product-update \
  --title "Weekly product update" \
  --prompt "Prepare a cited update from this week's product notes." \
  --destination-ref builtin.claude \
  --model opus \
  --schedule "0 9 * * 1" \
  --timezone America/Los_Angeles \
  --dir ~/notes

The readable :AI_DESTINATION_REF: property is a symbolic reference to configured app state. Optional :MODEL: and :REASONING_EFFORT: properties pin the exact runtime choices for every manual or scheduled attempt. Leave either field absent to use that destination's configured/default value. Credentials and machine-local connection details never enter the workflow file. If the destination is missing, disabled, or cannot honor a requested reasoning level, the attempt fails visibly instead of being rerouted or silently dropping the request.

Creating and maintaining a fuller workflow

A completed one-off run can become a draft workflow:

celorga workflow save RUN_ID --id weekly-review --dir ~/notes

The saved file is a proposal, not an automatic publication or rerun. Review the concrete context copied from the original run, replace one-off values with inputs where appropriate, and inspect outputs, validation, and approval boundaries before activation.

The Mac Agent Work → Automations surface also lists fuller reusable workflows and opens the selected file in the normal Org document editor. Structured controls such as Run Now, Validate, Schedule, Activate, Pause, and View History are conveniences over the file and shared CLI.

Useful lifecycle commands include:

celorga workflow list --dir ~/notes --json
celorga workflow validate weekly-review --dir ~/notes
celorga workflow run weekly-review --dir ~/notes --json
celorga workflow due --dir ~/notes --json
celorga workflow activate weekly-review --dir ~/notes
celorga workflow pause weekly-review --dir ~/notes
celorga workflow schedule weekly-review --cron "0 9 * * 1" \
  --timezone America/Los_Angeles --model gpt-5.6-sol \
  --reasoning-effort high --dir ~/notes
celorga workflow delete weekly-review --dir ~/notes
celorga workflow delete weekly-review --dir ~/notes --apply
celorga workflow migrate --dir ~/notes

Draft, active, and paused describe operational intent. Editing the file remains possible in every state. A workflow should be validated and reviewed before an edited version becomes responsible for consequential or scheduled work.

The first workflow delete command previews the exact workflow files that would be removed; --apply performs the deletion. The Mac app exposes the same action behind a confirmation dialog. Deleting an automation removes its definition and prevents future Celorga schedule checks, but preserves every existing run and its review history. It does not cancel an attempt that has already been dispatched.

Celorga scheduling and destination dispatch

Celorga owns the portable scheduling loop. While the Mac app is running, it checks active automations once a minute and again after launch or app activation. If the Mac was asleep or Celorga was closed, it catches up only the latest missed occurrence instead of replaying every tick.

For each due occurrence Celorga:

  1. Creates a durable numbered run from the exact workflow revision before contacting an AI destination.

  2. Records the schedule, planned time, destination reference, agent profile, and stable logical-work ID, then carries the file-owned model and reasoning effort into dispatch.

  3. Refuses to overlap a queued, running, or approval-waiting attempt for the same automation.

  4. Opens a destination thread and sends the resolved prompt through the same destination-neutral path used by AI Chat.

  5. Retains the reply, result, errors, artifacts, approvals, duration, and destination thread in the shared run history.

Failed, completed, canceled, and blocked attempts do not block a later scheduled occurrence. A blocked attempt is parked on a person: it stays open for review and Reply & Resume while the next occurrence starts a fresh attempt. To make a schedule wait until its blocked attempt is resumed, completed, or canceled, run celorga workflow schedule ID --cron EXPR --when-blocked wait; this writes whenBlocked: "wait" on the schedule trigger, later schedule edits keep it, and --when-blocked continue restores the default. Queued, running, and approval-waiting attempts also do not block a later occurrence by default: each occurrence starts its own attempt, so several instances can run at once and an attempt that hangs without ever completing or failing cannot stall the schedule. To run a single instance at a time, run celorga workflow schedule ID --cron EXPR --when-running wait; this writes whenRunning: "wait", later occurrences are skipped while an earlier attempt is queued, running, or awaiting approval, and --when-running continue restores the default. The Schedule sheet in the app exposes the same choice as Skip while a previous run is still active. The failed occurrence stays in history and is not dispatched again on every scheduler check. The scheduler keeps the latest failure visible until a newer attempt supersedes it; celorga workflow due --json reports these warnings separately in failures without removing eligible work from due.

An explicit destination must be enabled on the host selected by automationHostRef. A destination configured on a laptop may be absent from the headless server that owns its schedule. Dispatch failures identify the missing destination and executing host so the workflow binding can be repaired. Celorga preserves the explicit destination rather than falling back to another runtime.

Codex, Claude Code, OpenClaw, and enabled custom or direct-provider destinations all use this path. Manual Run Now uses the same durable preparation and dispatch without waiting for the clock. Pausing the automation stops new attempts; it does not erase its source or history.

Automation threads use the workflow's exact model and reasoningEffort when present. Otherwise they use the configured destination model and runtime reasoning default. They do not inherit overrides from interactive chats. Ordinary new chats continue to remember those choices. A runtime that rejects a pinned value fails that attempt visibly; Celorga does not retry a file-configured automation with different defaults.

This first version requires Celorga to be running. A small background helper or provider-native scheduler can be added later without changing the workflow file or splitting its run history.

Scheduled TODO starts

An assigned TODO can start at the time Org already records for it. Celorga never decides to start work on its own, so a heading opts in explicitly:

,* TODO Draft the launch checklist
SCHEDULED: <2026-11-05 Thu 09:00>
:PROPERTIES:
:ID: 0d6c1e1a-1111-4a1a-8a1a-000000000001
:AGENT_REF: research-assistant
:AGENT_START: scheduled
:END:

celorga todo assign --file FILE --line N --assignee NAME --agent-ref ID --start scheduled --apply writes :AGENT_START: scheduled beside the assignment. A heading starts when all of these hold:

  • it is a TODO that is not done or canceled,

  • it has :AGENT_START: scheduled and an :AGENT_REF:,

  • its SCHEDULED: timestamp has a time of day, and that time has passed (in the host's local time zone), and

  • it has an :ID:.

A heading that opts in but lacks an ID, an AGENT_REF, or a time of day is not started; workflow due reports it under scheduledTodoStarts.notStartable with the reason instead of guessing.

Each occurrence starts at most once. Its idempotency key is scheduled-start:ID:OCCURRENCE, and the run ID is derived from that key, so a second start of the same occurrence, from the same or another host, is refused when the run file already exists. For a repeating timestamp such as <2026-11-01 Sun 07:30 +1d>, Celorga starts only the latest occurrence at or before now, matching how schedules catch up only the latest missed occurrence. Nothing starts while the heading's :ORG2_RUN_ID: run, or an earlier scheduled start for the same ID, is still queued, running, waiting for approval, or blocked.

celorga workflow due --dir ~/notes --json              # scheduledTodoStarts.due / skipped / notStartable
celorga workflow start-todo --id ID --dir ~/notes      # preview
celorga workflow start-todo --id ID --dir ~/notes --apply

workflow start-todo --apply does what Start work does: it creates and starts a durable run that cites the heading, adds :ORG2_RUN_ID: to the heading, and moves a TODO or NEXT keyword to in progress. Its JSON includes the Start work prompt. The Mac app or headless server that owns automations (automationHostRef) runs it on every scheduler check and sends the task to the heading's AI chat thread on the default run destination (Settings → AI Chat → Agent Work → Run new agent work with). Without an enabled destination, it reports the problem and starts nothing.

Event-triggered workflows

An automation can also start when something happens in the corpus or on GitHub. Celorga is the workspace agents work in, not an agent: triggers are deterministic detectors that record signals, and a model never decides whether an attempt starts.

  • A todo-state trigger fires when a heading enters one of its TODO keywords, such as NEXT. Optional filters require a tag (inherited from ancestor headings), a corpus-relative path glob (notes/**, projects/*.org), or a property (AGENT_REF or AGENT_REF=writer). The keywords must exist in the file's or corpus's TODO sequence. Headings pair with their previous version by :ID: first, then by outline path and title, so retitling a heading with an ID does not fire again. The attempt receives each heading's file, line, ID, title, and previous and new state, and cites it as run context.

  • A pull-request trigger watches one owner/name repository for opened, commit (the head changed), review, comment, merged, or closed activity, optionally limited to one pull request number or author. Celorga reads activity through your existing gh login; it never stores a token. Install the GitHub CLI and run gh auth login first.

  • coalesce (for example 5m, at most 24h) combines signals that arrive within that window of the first one into a single attempt that lists every combined signal. Without it, each detector pass that finds activity starts its own attempt.

celorga workflow trigger-set delegate-next --trigger next --type todo-state \
  --state NEXT --property AGENT_REF --path "notes/**" --coalesce 2m --dir ~/notes
celorga workflow trigger-set review-follow-up --trigger reviews --type pull-request \
  --repo acme/widgets --pr-event review --pr-event comment --coalesce 5m --dir ~/notes
celorga workflow observe --dir ~/notes            # preview TODO-state signals
celorga workflow poll --source github --dir ~/notes  # preview pull-request signals
celorga workflow due --dir ~/notes --json
celorga workflow trigger-remove review-follow-up --trigger reviews --dir ~/notes

workflow observe compares each changed Org file with a snapshot under the corpus state directory and workflow poll keeps a per-trigger cursor there. Both preview by default; --apply records signals in the workflow file and advances the snapshot or cursor. The first pass of a new or re-activated trigger records a baseline and fires nothing, so existing NEXT headings or old pull-request activity do not start attempts. workflow due --json then lists each ready signal window with triggerType and signalIds, keeps open windows in pending, and reports which detectors are needed in eventSources. workflow run ID --trigger TRIGGER --scheduled-for TIME creates the attempt with the combined signals in attempt.signals, adds them to the prompt, and prunes them from the workflow file.

While the Mac app or headless server owns automations, it runs workflow observe on every scheduler check and as soon as an Org file changes, and runs workflow poll --source github every two minutes when an active automation has a pull-request trigger. A missing or signed-out gh appears under the scheduler status in Automations and is rechecked every 15 minutes.

OpenClaw lifecycle integration

The optional OpenClaw lifecycle plugin adds deeper OpenClaw lifecycle integration:

  1. For a manual execution, the plugin instantiates the workflow into a durable Celorga run before the agent begins.

  2. The plugin sends OpenClaw a workflow marker and a request to read the canonical workflow and run records.

  3. OpenClaw lifecycle events update that same run instead of creating a duplicate generic run. Available provider, model, token, and elapsed-time metadata is preserved on the run, and successful terminal turns record a concise outcome summary.

  4. When execution requests approval or clarification, the turn may end while the durable run remains open. Approving in the Mac app continues the existing workflow in its correlated OpenClaw chat session; a pending approval or blocked run is never treated as successful completion.

  5. Outputs, validation, steps, and approvals remain visible in Agent Work as the agent records them through the shared CLI.

Run celorga doctor --dir CORPUS --json before reconciliation or execution when a long-running workspace may contain stale or hand-edited state. The read-only report identifies contradictory run/approval state, duplicate provider identities, missing workflow definitions, conflicting attempt numbers, overlapping active attempts, unmanaged OpenClaw cron series, and broken or duplicate headline projections. It exits nonzero for hard contradictions but never rewrites the canonical records automatically.

Lifecycle mutations use atomic revision-checked writes. A client that holds a run across requests should read run show ID --with-revision --json and return that token through --if-revision; even without the explicit flag, one CLI invocation protects the revision it loaded. A concurrent mutation or ambiguous direct edit therefore produces a conflict for the caller to refresh and reconcile, not a last-writer-wins overwrite.

High-volume account-oriented workflows should keep global selection state in celorga ledger accounts rather than in the workflow prompt or one append-only task heading. Resolve every available name, email, domain, and provider identity before creating an account. A workflow can query ledger list LEDGER --eligible --json, link the exact run approval through an idempotent account event, and record the provider receipt after the approved action completes. The workflow remains the recipe, each run remains one attempt, and the ledger remains durable cross-attempt subject history.

Opening a PDF output from Agent Work uses the system's default PDF application (Preview by default on macOS). Text outputs continue to open in the Celorga workspace, with raw source editing available when needed.

OpenClaw cron reconciliation remains available as an optional runtime-native clock:

  1. Explicitly syncing workflows reconciles enabled generic schedule triggers into OpenClaw cron.

  2. The cron payload identifies the workflow, version, and trigger; it does not maintain a separate copy of the process.

  3. Each eligible execution creates a distinct numbered attempt under the workflow's stable logical-work ID. run list --json includes a logicalWork roll-up without erasing per-attempt evidence.

  4. A schedule may declare --gate-event and/or --gate-path. workflow signal records event/fresh-work evidence, and the lifecycle adapter safely skips a tick when no matching signal is newer than the prior attempt.

  5. Pausing the workflow disables its managed OpenClaw job at the next reconciliation.

OpenClaw job IDs and correlation mappings are adapter state. They are not part of the portable workflow definition. This boundary prevents scheduler details from leaking into authored corpus files and allows another runtime adapter to execute the same process later.

The plugin has one explicit corpusDir write target. Requests from the Mac app carry the selected portable corpus ID, and the adapter refuses to act when that identity does not match its configured corpus. Read-only mounted agenda and search views do not silently become agent write access.

Do not enable both Celorga scheduling and a provider-native clock for the same automation. Provider-native scheduling is an execution adapter, not a second canonical definition; Celorga remains authoritative for the prompt, desired schedule, review boundaries, and durable work record.

Safety and review

A workflow declares capabilities and a risk class. Expected outputs should land in reviewable locations such as views/ or compiled/, and consequential or external actions should carry an explicit approval requirement. An external-action or high-impact approval must expose the exact recipient, content, command, and attachments through an inspectable artifact, approval note, or live runtime detail; a fingerprint is integrity evidence, not review material. Once requested, Celorga fingerprints that exact material and preserves the same native approval ID/fingerprint through CLI, Mac, mobile decision transport, and OpenClaw. A mismatched --fingerprint is rejected. The Mac Agent Work surface retrieves linked OpenClaw exec details when they remain available and disables Approve when no reviewable material can be shown. Activating a schedule never weakens those boundaries.

Keep runtime credentials outside workflow files. A workflow may name a capability or symbolic runtime policy, but provider tokens, Gateway credentials, machine-local job IDs, and private scheduler state belong in runtime configuration.

Current limits

This is an early automation surface. The canonical file carries readable Org authoring fields plus a versioned machine-state block for the complete portable definition. The visible title, description, instructions, destination reference, model, reasoning effort, version, risk, and lifecycle state are authoritative when edited in source; a later structured save normalizes those values back into the complete definition. Source mode remains the complete editing escape hatch while structured assistance for inputs, steps, outputs, validation, and approvals becomes deeper. Scheduled work requires the selected desktop app or headless server process to be running. Celorga does not yet delegate clock ownership to Codex or Claude Code native schedulers.

Running without the desktop app

The headless server reuses these workflow and run records. Assign automationHostRef with preview-first celorga server assign --dir CORPUS --host-ref HOST. Updated desktop schedulers skip a corpus owned by another host. Scheduled attempt creation locks each workflow separately and refuses an already dispatched occurrence. Independently synchronized copies require one explicitly chosen owner; they do not support automatic distributed failover.

Headset approval replies on iPhone

Enable walkie-talkie approvals in iPhone Settings, grant Microphone and Speech Recognition access, and join the approvals channel. Celorga reads one exact pending run approval on a connected headset. A spoken yes or no can request a decision from the paired Mac once the prompt finishes, or at any point during a long prompt: press Talk or the headset button while it is being read, and Celorga stops reading and listens for your reply to that prompt. If playback or capture fails, nothing is decided.

Audio prompts are limited to requests from the last ten minutes. The phone checks the original request time after verifying a push and again before playback, so a delayed notification or restored channel cannot read an old backlog. Requests with missing or unreadable times are held for review in Approvals. Older pending requests stay available there without being decided or dismissed by the audio filter.

While joined, approval prompts can interrupt a podcast or music through the system Push to Talk audio session. Quiet mode and snooze hold prompts, and phone or FaceTime calls retain system priority. Finishing a prompt releases the receive session so other audio can resume.

Prompts play only on a headset by default. To hear them without one, turn on Settings → Audio approvals → Play on iPhone speaker. With it on and no headset connected, prompts play out loud on the phone's loudspeaker; a connected Bluetooth headset is still preferred and waited for while it takes over the route. Quiet mode, snooze, and calls hold prompts as before.

In Settings → Audio approvals → Voice, choose an installed voice or use Automatic to select the highest-quality voice for your language and region. Automatic prefers Premium, then Enhanced, then Standard within that region, falling back to another region of the same language when necessary. Download additional Enhanced or Premium voices through iPhone Settings by searching for Voices, then return to Celorga. Speech is generated on the phone. If a chosen voice is removed, Celorga uses Automatic while preserving the preference for a later download.

In Approvals → Reply and decision history, inspect the recognized words, their interpretation, and the Mac-confirmed result or failure. The latest 50 spoken attempts persist on the phone for the selected Mac, including unsuccessful attempts. Recorded decisions returned by the Mac include their actor and reason, so a canceled test can be distinguished from a spoken rejection. Older paired hosts continue to support the queue but do not supply canonical decision history.

Explicit automation failure receipts

An automation may return a standalone ORG2_RUN_OUTCOME: failed line when admission or execution fails. The scheduler records a failed attempt instead of mistaking a delivered response for completed work, including when a remote host-local lifecycle update has not synchronized yet. A conflicting completed receipt never overrides failure. Native run lifecycle commands remain the canonical outcome record; existing terminal states and approvals are preserved.

Syncthing .sync-conflict- workflow copies are retained as recovery evidence but ignored by live workflow inventory. They cannot override the canonical workflow version or scheduling state because of filename ordering.