Concept · workflows
A workflow is a written job. Its steps name operations Penumbra declares, and it is checked for free and priced by a plan. Saving or publishing it runs nothing; a signed-in person starts a run of a published version.
Use when
You design a job as steps, check a draft, save or publish it, or price a version for a person. You also start a run, follow it or stop it.
Looking for something else?
A one-time extraction or crawl, which you run directly (card Extraction). Reading or changing Files and the Graph (cards file and workspace). Who must approve a change (card Approval).
For
A person describes a job in one sentence. A workflow writes that job as a JSON document. It holds a purpose, the inputs it takes, a trigger and the steps. Each step names one operation, gives it its inputs, and says what to do when it ends in each way it can.
You design the document against the catalog (
penumbra workflows catalog). You
check it, which costs nothing. You save it as a draft, publish a draft as a
numbered version, and plan a version to see what it should cost. A draft may
have problems. Only a publish refuses them. None of these acts runs a step or
spends a credit. A run does: the person starts a run of a published version with
its inputs, and each step then charges as its own operation charges.
The words a person sees:
A step that can end in a way the document does not handle is a problem to fix,
and the document says which way. A workflow can limit its spending per run with
guards.max_credits_per_run. A person sees that as the spending limit per run.
Use when
- A person asks you to turn a job they repeat into steps.
- You must find out why a draft is not ready to publish.
- You must tell a person what a published version should cost, and which steps have no figure.
Not this
- A one-time extraction or crawl: run it directly (card Extraction).
- Reading or changing Files or the Graph by hand (cards file and workspace).
- Deciding who may approve a delete, a publish or a spend (card Approval).
Rules
workflow.1A step names only an operation that declares its outcomes. Enforced:checkandpublishrefuse any other step withunknown_module,unknown_operationoroutcomes_undeclared. Your job: readpenumbra workflows catalogfirst, and use only the steps it lists (problem workflow-step-unavailable).workflow.2Every way a step can end needs a route. A success continues, a step with no effect skips what depends on it, a refusal stops, and a failure stops without a retry. A partial result has no default. Enforced: a step that can end partial and has no route inon.partialis the problemunhandled_outcome. Your job: ask the person whether what landed is enough, then route it (problem workflow-unhandled-outcome).workflow.3A step reads only the workflow’s inputs and the steps before it. A value is a literal,${inputs.name},${steps.id.outputs.path},${item}inside amap, or${size(reference)}. Enforced:checkrefuses a later step, an unknown input, a missing input and a value of the wrong type, and names each instep.fieldform.workflow.4A check costs nothing and stores nothing, and a draft may have problems. Enforced:penumbra workflows checklists every problem and exits with code 3 while there is one.createandupdatesave the draft and list its problems. Your job: check the file until it is clean before you publish.workflow.5A workflow id is a lowercase letter followed by lowercase letters, digits, dots, colons, dashes or underscores, at most 128 characters. Enforced: the document’sworkflow_idmust be the id it is saved under. The idscatalog,checkandrunsare reserved, and a taken id is refused withworkflow_id_taken(409).workflow.6A draft changes at the revision you read. Enforced: an update at any other revision is refused withworkflow_revision_conflict(409), and the refusal gives the current revision. Your job: runpenumbra workflows show <workflow>, apply your change to that draft, and update with a new--request-id.workflow.7A publish makes the next numbered version, and a version never changes. Enforced: the version’s number becomes the document’sworkflow_version, so the digest of a published version can differ from the digestcheckprinted. A draft that is already the newest version answers that version. A draft with a problem is refused withworkflow_invalid(422), and the refusal lists each problem. Your job: change a workflow by updating the draft and publishing again.workflow.8A plan shows what each step should cost and runs nothing. Enforced: only an extraction start with a literal scope, Shape and level gets a figure. Any other paid step has no figure, and its basis beginsnot_estimated. A step that costs nothing has the basisno_cost. Your job: read every basis. Tell the person which paid steps have no figure, and never present the total of a run as its whole cost.workflow.9Each plan has a digest and is kept. Enforced: a plan is kept by its digest on the version and never replaced. The same version with the same inputs gives the same digest. Your job: plan again after a Shape or a collection changes, and give the person the new figures (problem workflow-plan-changed).workflow.10Reading takes less authority than changing. Enforced: a project member reads, and a key needsworkflows.readorworkflows.write. A project editor, admin or owner changes, and a key needsworkflows.write. A person below editor is refused withworkflow_change_requires_editorand a key without the scope withworkflow_change_requires_scope(403). Access limited to a View is refused withview_operation_unavailable.workflow.11Saving, publishing and planning run no step and send nothing outward. Enforced: no step runs, no credit is spent, and the approval floor holds none of these acts. Your job: tell the person that a published version does nothing until a person starts a run.workflow.12A person starts a run, and only a person. Enforced:penumbra workflows run <workflow>needs a signed-in person who is a project editor, admin or owner. A key, an assistant connection and the in-app Assistant are refused withworkflow_run_requires_person(403). The run acts for that person, with the permissions its steps need and no more. A workflow with no published version is refused withworkflow_not_published(409). Inputs that do not fit the workflow’s inputs are refused with a diagnostic for each field (422). Your job: ask the person to start the run, give them the command and the inputs it needs, and never start one with a key.workflow.13A run is followed by its id. Enforced: a start answers the run’s id, with the statuspendinguntil Penumbra starts it. The commandpenumbra workflows runs get <run>shows the status and what the run has charged. For each step it shows every attempt with how it ended, what it charged and what it produced. The same--request-idstarts a run once. Your job: report a run by its status and its charge, and say which attempts failed or were refused and why.workflow.14A run stops when it is asked to. Enforced:penumbra workflows runs cancel <run>needs a project editor, admin or owner (or a key withworkflows.write). A step already sent finishes, nothing new starts, and a run that has already ended is refused withworkflow_run_finished(409). Your job: say that cancelling does not undo a step that finished.
Failure signs
checkprintsunhandled_outcome: problem workflow-unhandled-outcome.- A step is refused as
unknown_operationoroutcomes_undeclared: problem workflow-step-unavailable. - Two plans of one version give different digests, or a plan is refused with
artifact_mismatch: problem workflow-plan-changed. - A save is refused with
workflow_id_taken: rule workflow.5. - An update is refused with
workflow_revision_conflict: rule workflow.6. - A key is refused with a 403: rule workflow.10.
- A start is refused with
workflow_not_published: problem workflow-not-published. - A start is refused with
workflow_run_requires_person: rule workflow.12.