# Actions

> The named packages of labels and reports a run emits at Start or at Completion, their commands, the marker mappings of a label, and how a procedure selects them.

An **action** is a named package of paperwork a run emits: inside it, one **command** per
emission, each saying what comes out (a label or a report), when (at Start or at Completion), with
which template of the station library and, at Completion, for which verdicts. A procedure selects
whole actions, so a package written once serves every procedure that emits it, and correcting a
command is one edit instead of one per procedure. Actions live under Process > Models > model >
Setup > **Actions**. Creating them, removing them and editing an action's name, its commands and
their mappings are all gated by the same **Edit recipes & evaluations** permission, and the pages
say so ("Changing actions needs the “Edit recipes & evaluations” permission.").

## The Actions folder {#the-actions-folder}

Selecting the **Actions** row opens a page unlike the other folders of Setup: a list of the
model's actions beside the one picked in it, because an action is read against its siblings. The
list's order is the order every procedure emits the actions in, so the row verbs move an action
and never a command. The page loads the two station libraries (label templates and report
layouts) to judge readiness; when one cannot be loaded, a banner says "Global label templates
could not be loaded: …" or "Global reports could not be loaded: …".

| Column | What it shows |
| --- | --- |
| **#** | The action's place in the list. |
| **Name** | Editable in place, committed when you leave the cell. A blank name is refused with "An action needs an operational name." |
| **Commands** | How many commands, then what they emit: "0 · None yet", or "2 · Label at Start, Label and report at Completion". The tooltip lists them one per line, as `Label at Completion · <template>`. |
| **State** | **Ready**, or **Review** when the action or any of its commands is short of something. |
| Row actions | **Move action up**, **Move action down**, **Remove action** (danger ink; asks "Delete action": "This removes the action and its commands."). |

The column beside the list is headed **Action** and shows the picked action's **Name** (editable
here too), its **Commands** as read-only lines with a Ready / Review pill each ("The commands are
edited on this action's own page in the column, in this order."), and a **Needs review** banner
listing everything that is short. With no action, the list says "No actions. Add one when a
procedure of this model should emit labels or reports."; with none picked, the column says "Select
an action to read what it emits. Its commands are edited on its own page in the column."

| Command | What it does | Greyed when (situation) | Not drawn when (role) |
| --- | --- | --- | --- |
| **Action** (detail bar, folder selected; right-click **Add action**) | Adds `Action <n>` (the first number no action of the model already uses), empty, at the end of the list, and picks it in the column. | Any unit holds a run, or the runtime is stopped. | Without Edit recipes & evaluations. |
| Move up / Move down / Remove action (row actions) | Reorder or delete. | Without Manage process, under the engineering lock, or while the runtime is stopped (a press reports the reason in the action feed). | Always drawn. |

## The action's page {#the-actions-page}

Selecting an action in the tree opens it: the header with the action's name and a pill counting
its commands, the permission and library banners, an **Action** card with the **Name** field
(committed on blur; blank refused), and the **Commands** list beside the command picked in it.

| Command | What it does | Greyed when (situation) | Not drawn when (role) |
| --- | --- | --- | --- |
| **Command** (detail bar, action selected; right-click **Add command**) | Adds a command born as a **Label** at **Completion** for **OK** runs with no template yet, at the end of the list, and picks it in the column. | Any unit holds a run, or the runtime is stopped. | Without Edit recipes & evaluations. |
| **Remove action** (danger cluster; right-click; the X on the folder page's card) | Deletes the action and its commands after "Delete action". Every procedure that selected it stops emitting it. | Same. | Without Edit recipes & evaluations. |

### The Commands list {#the-commands-list}

| Column | What it shows |
| --- | --- |
| **#** | The command's place in the action, which is its emission order inside the action. |
| **Emits** | **Label** or **Report**. |
| **Trigger** | **Start** or **Completion**. |
| **Template** | One picker over two libraries: a label row offers the label templates ("(select template)"), a report row the report layouts ("(select report)"). A reference the library no longer holds keeps its place, disabled, as "Missing template · `<id>`" or "Missing report · `<id>`", so a degraded command does not read as an unconfigured one. |
| **Verdicts** | "Not used at start" for a Start command; otherwise the ticked verdicts ("OK, NOK") or "None selected". |
| **Markers** | "Not used by a report"; for a label: "No template", "Template missing", "No commands" (the template has no printer commands yet), "Unreadable", "Fixed, no markers", or "`<bound>` of `<total>` bound". |
| **State** | **Ready** or **Review**. |
| Row actions | **Move command up**, **Move command down**, **Remove command** ("Delete command": "This removes the command from the action."). |

With no command the list says "No commands. Add one when this action should emit a label or a
report."; with none picked the column says "Select a command to edit all of it in one place. Add
one from the bar above when this action should emit a label or a report."

### The command in full {#the-command-in-full}

The column opens the picked command, headed `Command <n> · <Kind> at <Trigger>`. It shows only the
fields the chosen kind owns.

| Field | What it is | Values / default | Effect (the line under the field) |
| --- | --- | --- | --- |
| **Emits** | What the command puts out. | Label / Report; Label at creation. | "Prints a tag from a command template, on the queue the Unit picks for labels at this moment." or "Publishes the run's PDF from a report in the station library." Changing the kind reseats the verdict filter on the new kind's default (Label: OK; Report: every verdict). |
| **Trigger** | At which point of a run it comes out. | Start / Completion; Completion at creation. | Label at Start: "Generated the moment the run starts, before any result exists."; label at Completion: "Generated when the run ends, for the terminal verdicts ticked below."; report at Start: "Published the moment the run starts, so the sections with nothing recorded yet are left out."; report at Completion: "Published when the run ends, for the terminal verdicts ticked below." |
| **Report** (report commands) | The layout of the station library the PDF is published with. | "(select report)" or a layout; none at creation. | "No PDF is published.", "The referenced report is not in the library.", "Publishes a PDF when a run starts." / "… when a run finishes.", with "and sends it to this command's printer queue on the Unit." when printing is on. |
| **Report printing: Print automatically** (shown once a layout resolves) | Whether the published PDF is also sent to the unit's report queue for this trigger. | Off at creation. | Legend: "The PDF is published either way, at this command's point of the run. Printing decides only whether it is also sent to a queue." On: "The PDF also goes to this command's printer queue on the Unit. Pick that queue on the Printers screen." Off: "The PDF is published to the reports folder and goes no further." |
| **Report copy: Keep it in the run** (shown once a layout resolves) | Whether the finished PDF is stored inside the run file, so a resend reissues those exact bytes after the layout is edited or deleted. | Off at creation. | Legend: "What the run keeps of the document, which is what a resend submits later." On: "Each run carries the finished PDF, a few hundred KB, and a resend submits that exact document." Off: "Each run points at the published PDF, so a later render is what a resend submits." |
| **Global template** (label commands) | The label template of the station library the command prints, whose markers it binds below. | "(select template)" or a template; none at creation. Picking one creates a mapping row for every marker the template declares that the command does not map yet. | "Choose a template: its markers are what this command fills in.", "The referenced template is no longer in the library.", "This template has no printer commands yet, so there is nothing to send.", "The markers of this template cannot be read.", "No markers: every matching run sends the same bytes. The Unit picks the printer queue.", or "`<n>` markers, each bound below to one value frozen for this run. The Unit picks the printer queue." |
| **Emit for terminal verdict** (Completion only) | Which terminal verdicts activate the command. | Four boxes: **OK**, **NOK**, **Indeterminate**, **No verdict**. A label starts on OK alone; a report starts with all four, because a procedure that judges nothing ends on no verdict and must still produce its document. | The command fires only for a run ending on a ticked verdict. A Start command has no verdict yet and reads no filter. |

A **Needs review** banner under the fields lists everything the command is short of (see
Readiness below).

The queue a printed document goes to is not a field of the command: it is resolved by the
command's kind and trigger through the unit's four printer slots, so two commands of the same
combination share the printer deliberately. See [Printers](process-printers).

### Markers {#markers}

Markers are the `{{NAME}}` fields a label template leaves for the run to fill in, so this section
is drawn for a label command and for nothing else. Its state follows the template:

| State | What the section shows |
| --- | --- |
| No template chosen | "Choose a template to map its markers." With stored mappings from an earlier template: "Stored mappings are preserved while the template is missing." and their marker names. |
| The template is gone from the library | "Template unavailable", with the same preserved list. |
| The template has no printer commands | A banner: "“`<template>`” has no printer commands yet: there is nothing to send and no marker to map until they are written or imported under Templates ▸ Labels." |
| The markers cannot be read | A banner "Markers from “`<template>`” cannot be read: `<error>`", and "Stored mappings preserved. Repair or replace the template before changing these bindings." |
| The template has no marker | "Fixed template. This template has no markers and sends the same bytes for every matching run." |
| Markers found | One row per marker, headed by the marker and a **Mapped** / **Required** pill, with the fields below. |

| Field | What it is | Values / default |
| --- | --- | --- |
| **Frozen value source** | The one run value substituted into the marker. | "(not mapped)" plus the sources of the table below. A Start command lists only the sources available at Start; a Completion command lists them all. "Metadata · Catalogue field" appears only when the model's metadata catalogue has fields, and the criterion sources only when some evaluation of the model declares a criterion. A source the current trigger cannot answer keeps its place, disabled, as "… (unavailable for this command)". Changing the source clears the field, cycle and formatting chosen for the previous one. |
| **Catalogue metadata** (Metadata source) | Which field of the model's catalogue. | "(select catalogue metadata)", "Missing field · `<id>`" for a field that is gone, then every field as "`<name>` · text / number / sequential". |
| **Criterion** (criterion sources) | Which criterion of which evaluation of the model. | "(select criterion)", "Missing criterion · `<id>`", then every criterion as "`<evaluation>` · `<criterion or Criterion n>` · `<channel>`". |
| **Cycle (0-based)** (criterion sources) | Which cycle's result. Never implied: it must be typed. | 0 up to the largest cycle count any procedure of the model runs, minus one; placeholder "required". A number outside that range is refused under the field. |
| **Value format** (date and time sources) | How the instant is written. | Station date + time (default), Station date, Station time, Station date + time, ISO 8601. |
| **Decimal places** (numeric sources, and a numeric metadata field) | A fixed number of decimals. | 0 to 9; placeholder "automatic" (the station's own preference). |
| **Clear invalid formatting** | A button drawn when a mapping carries formatting its source cannot use (decimals on a date, a date format on a number, either on a text). | Resets the offending field. |

The sources, in the order the picker lists them:

| Source | Available at Start | Kind |
| --- | --- | --- |
| Metadata · Catalogue field | Yes | Text, or a number for a numeric field |
| Model · Name, Model · Revision, Unit · Name, Unit · Code, Procedure · Name, Procedure · Code, Run · Identifier | Yes | Text |
| Run · Started at | Yes | Date and time |
| Run · State (at Start) / Run · Terminal state (at Completion) | Yes | Text |
| Run · Finished at | No | Date and time |
| Run · Duration (seconds) | No | Number |
| Run · Verdict, Run · Termination reason | No | Text |
| Criterion · Name, Channel, Limits, Severity, Outcome, Error, Affected channels | No | Text |
| Criterion · Window started at, Window closed at | No | Date and time |
| Criterion · Samples evaluated, Samples out, Samples unavailable, Samples invalid, Worst excursion | No | Number |

Under the marker rows, **Removed markers** lists the mappings stored for markers the current
template no longer declares ("`<n>` stale"; "These mappings no longer exist in the selected template
and must be removed."), each with **Remove stale marker mapping**.

### Readiness {#readiness}

The Ready / Review pills on both pages, and the rows the Validation page lists, come from one
judgement. An action with no command is short of one: "Add a command: this action emits nothing
yet." A command is short of, in the order it is repaired:

- "Select at least one completion verdict." (a Completion command with no verdict ticked)
- "Choose a report." / "The selected report no longer exists."
- "Choose a label template." / "The template was cleared or deleted; stored mappings are
  preserved." / "The selected global template no longer exists."
- "The selected template has no printer commands yet; write or import them before a run reaches
  this command."
- "Template markers cannot be read: `<error>`"
- "{{M}} needs a source." / "{{M}} is mapped more than once."
- "{{M}}: choose a source", "this source is not available at Start", "select a field of this
  model's metadata catalogue", "select a criterion from one of this model's evaluations", "set an
  explicit zero-based cycle from 0 to `<n>`", "remove decimal places from this date/time source",
  "use the default format for this numeric source", "decimal places must be between 0 and 9",
  "remove numeric/date formatting from this text source"
- "{{M}} was removed from the current template; remove its stored mapping."

A command under review still runs: nothing is dropped at emission, and a marker that cannot
resolve fails that one label as it always did. The configuration screen is where this is learned,
not the printed tag.

## How a procedure selects actions {#how-a-procedure-selects-actions}

A procedure's page carries the card **Actions this procedure emits** with a "`<n>` selected" pill
and one checkbox per action of the model, in list order. Each row shows the action's emission line
("Label at Start, Label and report at Completion", or "Emits nothing yet: this action has no
commands.") and, once selected, a **Ready** or **Review** pill. Review lists what this procedure
lacks for the action's markers, one remark per marker, because a marker resolved per run resolves
only where the procedure has the thing it names:

- "{{M}} reads a metadata field this Procedure does not prompt. Tick it in Metadata above."
- "{{M}} reads a criterion result, and this Procedure judges by no evaluation."
- "{{M}} reads a criterion this Procedure's evaluation does not declare."
- "{{M}} reads cycle `<c>`, and this Procedure runs a single cycle." / "… runs `<n>`."

The action is neither hidden nor refused: the procedure says what it lacks, and the remedy is on
the same page. With no action in the model the card says "No actions in this model yet. Add some
under the model's Actions."

### The emission order {#the-emission-order}

At a run boundary the selected actions emit in the model list's order, and inside each action in
its command order, filtered to that boundary's trigger: one answer for the whole model, never one
per procedure. Start commands run once the run has materialized (after the sequential metadata
has been reserved), and Completion commands once the terminal verdict has been sealed. Each
command is isolated: a failure publishes nothing, changes nothing about the run and never stops
the commands behind it. A report is named after the run and the action that emitted it; a later
render of the same command replaces that command's document and nothing else. What each emission
records in the run, and how it is reissued from Histories, is on
[Emitting labels and reports](process-emission).

## What an action does not do {#what-an-action-does-not-do}

- It emits nothing on its own. A procedure has to select it, and a run of that procedure has to
  reach the boundary.
- It does not check the procedure. Whether a procedure prompts the field or judges by the
  evaluation a marker names is stated on the procedure's page, beside the selection.
- It does not pick the printer. The queue is the unit's, by kind and trigger, on
  [Printers](process-printers).
- It does not edit templates. Label commands and report layouts are written under
  [Templates](process-templates); the action only names them.
- It does not confirm physical printing. Queue acceptance is what a label or a printed report
  records, never proof that paper came out.
