Skip to content

Record lots and measured amounts in batch records

eaxScadaHow-to guideStarterProEnterpriseView as Markdown

Migrated page, not yet verified against the current code. Treat values, paths and examples as indicative until this notice is removed.

Every batch record (EBR) links each material to the lot that was really used, and shows an actual amount only when a tag on the plant measured it with Good quality. Nothing in the record is made up: no lot, no amount, no tolerance verdict, no unit, no batch ID that another batch already has.

  • A Process_Supervisor, Lead_Engineer or Administrator edits recipes and launches batches. A custom role needs a level of 60 or more, and no feature rule that denies it the right (see Who may change recipes and run batches).
  • For each measured ingredient, a tag that holds the amount dosed for this dose: a scale’s net weight, or a flow totaliser reset at the start of the dose.

Open the recipe in Recipes. The ingredients (bill of materials) grid has three columns for this:

Column Field What it does
Lot tracked lot_tracked Ticked (the default, also for every recipe saved before): a batch needs this material’s lot. Untick it for a material without lots, such as process water.
Lot pattern lot_number_pattern Optional. Every lot entered must match it whole.
Actual tag actual_tag Optional. The tag that measures the amount dosed. Empty: the batch records the amount as not measured.

Double-click a cell to edit it, then save the recipe. A recipe whose lot pattern is not valid is refused when you save it, naming the ingredient.

A lot pattern is a regular expression matched against the whole lot, where # stands for one digit:

Pattern Accepts Refuses
WTR-#### WTR-0042 WTR-42, wtr-0042, WTR-0042A
[A-Z]{2}-\d+ AB-7, CD-12345 A-7
LOT\#-## LOT#-01 LOT1-01

\# is a # itself. Lots are at most 128 characters.

The patterns older versions wrote on their own, never chosen by a user, count as no pattern: LOT-#### (the default of every new ingredient) and WTR-####, SGR-####, CIT-####, FLV-####, WFI-####, NACL-#### (the former example recipes). They are removed when you save the recipe. New ingredients get no pattern.

  1. Choose Launch Batch on the approved recipe.
  2. Batch ID is optional. Leave it empty and the server assigns a unique one, such as BATCH-PRD-20261101-142233-7F3A2C (product code, date, time, random part). An ID another batch already has is refused.
  3. Under Material lots, enter the lot of every lot-tracked material. A material that is not lot tracked shows “not lot tracked” and takes no lot.
  4. Choose Initialize Batch. The batch is created in the IDLE state; start it from the batch view.

The batch is refused, and nothing is created, when a lot-tracked material has no lot, a lot does not match its pattern, or a lot is entered for a material that is not lot tracked. The message names every material at fault.

When a phase completes, the server reads the actual tag of each ingredient that phase doses, with its quality:

Reading Actual amount Verdict Status shown
Good, from the plant, inside the band the value in tolerance IN TOLERANCE
Good, from the plant, outside the band the value out of tolerance (the phase is logged OUT_OF_SPEC) OUT OF TOLERANCE
Good, and the recipe gives no band the value none MEASURED, NO BAND
Bad, Uncertain or overridden, a missing tag, not a number none: the value read is kept with its quality and the reason none the quality read
From a simulated source none: the value read is kept none SIMULATED, NOT MEASURED
No actual tag, or no phase doses the ingredient none none NOT MEASURED

The band is the recipe’s minimum and maximum, scaled to the batch size like the target. Before its phase completes an ingredient is pending.

The batch views show Actual amount, Measured by (tag and quality), Tolerance band, Lot number and Phase completed for each ingredient.

Older versions wrote the target as the actual amount, and “in tolerance”, as soon as the phase began, with nothing measured. The Studio shows such ingredients as not measured (“Recorded before measured amounts”). The stored record is not changed.

An integration that reads batches through GET /api/batches must:

  • treat an ingredient without a measurement field as not measured;
  • accept null in actual_amount and in_tolerance (no measured amount, no verdict).

The other fields of an ingredient: measurement (PENDING, NOT_MEASURED, GOOD, BAD, UNCERTAIN, SIMULATED), min_amount and max_amount (the scaled band), measurement_tag, measurement_quality, measured_value (the value read when it is not an amount), measurement_note (why there is no verdict), not_lot_tracked, and dosed_at (when the phase completed).

Each batch record (EBR) is checked against its own hash chain and against the audit trail every time it is opened. This section says what is recorded, what the check compares, what each result means and what it does not cover.

Each batch record is a chain of entries: the batch as created (with the recipe as run), each state change, each phase log entry, each material record and each signature. Each entry’s SHA-256 hash covers the batch ID, the entry’s place in the chain, its kind, its time, who made it, its content and the hash of the entry before it. Changing any entry changes its hash and breaks every link after it.

The chain is kept in its own file next to the batch, in the recipe store’s batches folder (b<batch key>.chain.jsonl). Each line is appended and synced to disk. The batch file and the phase log file stay the views the API serves. The chain is the record they are checked against.

Entry kind What it holds
BATCH_CREATED The batch as created, with the copy of the recipe it runs.
STATE A state change (START, HOLD, a phase entered…). A phase’s state entry is on disk before the phase writes its setpoints.
PHASE_LOG A phase log entry.
MATERIAL A material record: lot, measured amount, tolerance verdict.
SIGNATURE A release signature or a post-release note.
COVERAGE_START The start of the chain of a batch recorded by an earlier version: the batch, its phase logs and its materials as they were found (Batch records from earlier versions).
REVERTED A step refused after its entries were written (its view could not be written). The entries stay in the chain: the record shows the step and its refusal.

Each entry’s hash is also written to the audit trail when the entry is written: the audit record of the step names the step’s last entry, with its place and hash, in its version_ref field (ebr/<batch id>/<seq>/<entry hash>). Runner steps that had no audit record of their own (a phase entered, a phase completed, a wait note) now write BATCH_EBR_ENTRY (user SYSTEM). A batch record that was edited, cut short, deleted or replaced by an older copy no longer matches the audit trail, and its EBR reports the first entry that fails.

Each step that changes a batch record is done in this order. The batch’s chain cannot move on in between.

  1. The audit record of the step is written, naming the step’s last chain entry. If it cannot be written, the step is refused with 503 AUDIT_NOT_WRITTEN, and nothing changes.
  2. The chain entries are appended and synced. If they cannot be written, the step is refused with 503 EBR_NOT_WRITTEN, nothing changes, and a <ACTION>_FAILED audit record names the entries that were never written.
  3. The views: the batch file and the phase log. If they cannot be written, the step is refused, and a REVERTED entry records the refusal in the chain.
  4. The acknowledgement: the answer, the live update, the notification.

A phase writes its setpoints only after its entry is on disk. If the server stops after step 2 and a view lags its chain by exactly the last step, that view is completed from the chain at the next start. The completion is recorded as BATCH_EBR_VIEW_COMPLETED. Any other difference is never repaired: it is reported as a failure.

When the record cannot be written: EBR_NOT_WRITTEN

Section titled “When the record cannot be written: EBR_NOT_WRITTEN”

A step whose chain entry cannot be written gets the same answer as BATCH_NOT_WRITTEN, with the integrity record named: 503, "code": "EBR_NOT_WRITTEN", and the status that says what happened (The answers of batch actions):

status What happened Shown in the Studio
refused Batch creation, START, RESUME, RESTART, RESET, a prompt acknowledgement or a signature was refused. Nothing changed and no setpoint was written. “Not done: the integrity record could not be written; nothing changed”
applied A PAUSE, HOLD, STOP or ABORT took effect. Its entry is kept in memory and written again until it is on disk. “Done, but the integrity record could not be written yet; it is written again”
held A phase step could not be recorded. The batch is on HOLD and no setpoint is written until a RESTART, which needs its own record written. “The batch was held: its integrity record could not be written”
  • PAUSE, HOLD, STOP and ABORT always take effect. Refusing them could keep a batch running.
  • The batch then takes no further step until its record is written. While an entry of a batch is kept in memory, every forward step and every signature of that batch is refused. ALM-SYS-BATCH-RECORD stays active.
  • An entry written later is marked late, with the time of its step. The EBR counts these entries in late_entries.
  • What is kept in memory is lost if the server stops first (see Known limits).

The audit trail comes first for batch steps, as for every other recorded action:

  • A forward command (creation, START, RESUME, RESTART, RESET, a prompt acknowledgement) and a signature are refused with 503 AUDIT_NOT_WRITTEN. Nothing changes.
  • A running batch is held at its next step. The runner cannot record its next phase entry or phase completion, so it puts the batch on HOLD before any setpoint is written (BATCH_HELD_NOT_WRITTEN, ALM-SYS-BATCH-RECORD). The completion of the last phase goes ahead, because it takes the batch to rest.
  • Stops are never blocked. PAUSE, HOLD, STOP and ABORT take effect. Their audit record is saved to disk, and written again every 2 seconds, as BATCH_EBR_ENTRY, marked late, naming the step’s entry.
  • Until those records are written, the batch’s check reports not_checked (audit_records_pending), not a failure and never valid. The records are saved to disk before the step answers and written once the trail is back, also after a restart (Known limits).

Every GET /api/batches/{id}/ebr runs the full check each time it is called, within a cap of 2 s (see The 2 s cap):

  1. It reads the chain. It checks that each entry follows the one before it without a gap, that each entry links to the hash before it, and that each hash recomputes.
  2. It replays the chain and compares the result with the batch, phase logs, materials and signatures that the API serves. The first difference is the failing entry.
  3. It reads the batch’s audit records. It confirms that each entry an audit record names is in the chain with that hash, that the batch’s creation is named, and that the chain’s last entry is named.
  4. It checks each signature (see Signatures bound to the record).

The result is the integrity object of the EBR:

"integrity": {
"status": "invalid",
"reason": "Integrity check failed at entry 37 (MATERIAL, view_differs): ...",
"reason_code": "view_differs",
"entries": 412,
"checked_at": "2026-11-19T10:00:00Z",
"covered_from": 1,
"first_failing": {
"seq": 37, "kind": "MATERIAL", "at": "...", "reason": "view_differs", "reason_code": "view_differs",
"field": "actual_amount", "expected": "...", "actual": "...",
"audit_record": {"sequence": 1042, "action": "BATCH_EBR_ENTRY", "at": "...", "user": "SYSTEM", "version_ref": "ebr/..."},
"row": {"grid": "materials", "index": 2}
},
"signatures": [{"index": 0, "status": "bound", "kind": "release", "signs_seq": 410, "signs_hash": "...", "covers": "entry"}],
"late_entries": 0,
"pending_entries": 0,
"tip_seq": 412,
"tip_hash": "..."
}
  • reason is the server’s full English sentence.
  • reason_code is a stable code, for translation and for integrations.
  • first_failing is present only for invalid. seq 0 means that the stored record holds something no entry records (field names it).
  • audit_record names the audit trail record that the chain does not match (not_in_ledger, behind_ledger).
  • row is the grid row in the EBR (phase_log, materials or signatures, with the log ID for the phase log).

Only valid means verified. No other status is shown or exported as verified.

status reason_code Meaning
valid verified Every hash and link checks, the stored views match the chain, every entry is in the audit trail from the batch’s creation on, and no signature is legacy. Shown as Integrity verified (N entries, checked at …) (emerald).
invalid the failing entry’s reason (table below) The record fails. first_failing names the first entry that fails. Shown as Integrity check failed: entry #N (kind), reason (rose), and the failing row is marked in its grid.
partial coverage_linked The batch was recorded by an earlier version and its chain started at a later step (COVERAGE_START). What was recorded before is shown as it was found, not verified. Every entry since is in the audit trail.
partial coverage_no_audit_trail As coverage_linked, on a server without an audit trail: not anchored as well.
partial linked_from_entry The chain checks. Its first entries were recorded before the link to the audit trail existed and are checked by their chain only. covered_from names the first linked entry.
partial legacy_signatures Everything checks, but the record holds legacy signatures, which cover the signer, role, reason and time, not the record’s content.
not_covered recorded_before_chain “Recorded before eaxScada <version>: this batch record has no integrity chain.” The version is the one that first wrote an integrity chain on this server.
not_anchored no_audit_trail The chain checks, but this server has no audit trail, so a removed, cut-short or replaced batch record is not detected (Free, builds without the audit trail).
not_anchored not_linked The chain checks, but no audit record names an entry of this batch: it was recorded without the link.
not_anchored audit_trail_read_only The chain checks. Later entries were written while the audit trail was read only (it takes no records in this edition, for example Free after a paid period).
not_checked chain_unreadable The chain file could not be read.
not_checked audit_trail_unreadable The audit trail could not be read: the link is not checked. It is never reported as “valid without the audit trail”.
not_checked entries_pending Entries of this batch are kept in memory, not on disk yet.
not_checked audit_records_pending Not checked: audit records pending. Audit records of this batch could not be written when the audit trail was down. They are kept on disk and written again until the trail takes them, also after a server restart. The batch’s link to the audit trail is checked once they are. Until then the record is never shown as verified. The check also gives audit_records_pending, the number of records waiting.

An unknown status, or none, reads Integrity not verified in the Studio.

first_failing.reason Meaning
entry_hash The entry’s hash does not recompute: the entry was changed.
prev_hash The entry’s link to the entry before it is broken: an entry was removed, inserted or reordered.
missing_entry An entry is missing: the chain is shorter than the batch file says, or the chain file is gone.
view_differs The stored batch, phase log, material or signature differs from its entry (field, expected, actual).
unreadable A chain line is not an entry.
invalid_entry An entry whose hash checks cannot be part of a record (an unknown kind, unreadable content, a second creation, a material out of place).
not_in_ledger The chain holds an entry the audit trail does not confirm: its hash differs from the one recorded (the chain was edited and its hashes recomputed), or entries follow the last one an audit record names.
behind_ledger The audit trail names entries the chain no longer holds: the record was cut short, removed or replaced by an older copy. A removed chain is reported this way, never as not_covered.
signature A signature fails its check (field is the signature’s reason code).
after_release Record content was added after the release signature, which closes the record.

What to do with a failed record: restore the batch folder from a backup taken after the failing entry’s time, or treat the record as altered. The audit trail shows the original actions.

GET /api/batches/{id}/ebr waits at most 2 s for its check. A check that runs longer does not hold the answer:

  • A check of the record as it is now exists. The answer carries its result with integrity.cached: true and its checked_at.
  • None covers the record as it is now (it changed since the last check, or was never checked). The answer is not_checked with reason_code check_running and stale: true. It is never valid.
  • Signing is refused until the check completes: EBR_NOT_CHECKED. Open the record again in a moment. A signature runs its own full check, with no cap.
  • The check goes on in the background, and its result is cached for the next answer.

Each check of a batch is kept in memory with a stamp of what it read: the chain’s tip and hash, the entries not yet written, the chain file’s size and time, the batch, phase log and signature views, and the audit trail’s mode and the batch’s audit records still to be written. The runner’s elapsed time and percent are not part of it. A restart starts the cache empty.

  • A cached status is served only for the record as it is now. When the record changed since the check, the status is not_checked with reason_code changed_since_check and the time of the old check. A batch not checked since the server started is not_checked with never_checked. Only a check that covers the record as it is now reads valid.
  • Running batches are checked at start: every batch that has not ended is checked once when the server starts.
  • The status is refreshed after every step of a batch (a state change, a phase entry, a late write, a replicated entry), 200 ms after it and one batch at a time. The EBR, a signature and the check of every batch refresh it too.

GET /api/batches returns this status per batch, without running a check:

Field Meaning
integrity_status valid, invalid, partial, not_covered, not_anchored or not_checked (Statuses)
integrity_checked_at Time of the check the status comes from
integrity_reason_code The reason code, including never_checked and changed_since_check
integrity_reason The server’s full English sentence
integrity_stale true when the record changed since the check
integrity_entries Entries the check covered
integrity_failing_seq The failing entry’s seq, for invalid
  • The batch list: the EBR view has a batch records list (data grid) beside the record, with an Integrity column that can be filtered, sorted and exported to CSV. Only a check that covers the record as it is now reads Verified. A record that changed since its check reads not checked, with the reason changed_since_check. A batch not checked since the server started reads never_checked. Every other state is marked in its row (rose for a failed check, amber otherwise) with its reason and what to do. One chip above the list filters to them. A row, or Open, opens that batch’s EBR. The header’s selector stays as the compact picker. Below 1280 px the list goes above the record.
  • The badge in the EBR header shows the status and its reason in the Studio language. The server’s full reason is in its tooltip. The state is given in text and in the aria-label, never by color alone.
  • The failing entry is marked in its grid row (phase log, materials or signatures): a warning marker with a rose accent. Clicking it opens the card with the expected and actual values. One chip above the grids, “1 integrity fault”, filters to that row.
  • The signatures grid has a Covers column: “Record as of entry N”, “Record as found (not covered)”, “As found: not verified”, “Legacy: signer and time only”, or why it fails (“Fails: signed another state”, “Fails: the signature does not recompute”, “Fails: its meaning is not its kind’s”, “Fails: unknown signature version”). It also has a Meaning column.
  • Exports: the CSV export starts with the integrity status, the time it was checked, the number of entries, the tip’s place and hash, the first failing entry and the reason. The JSON export carries integrity. Both carry each signature’s kind, meaning, signs_seq, signs_hash and Covers.

POST /api/batches/verify checks every stored batch record in the background. It also lists the batches that the audit trail records as created but that the store no longer holds. Only an Administrator may run it or read it (403 for any other user).

  • POST answers 202 with the check as started. Its start is recorded first (BATCH_EBR_VERIFY_ALL). If that record cannot be written, nothing starts (503 AUDIT_NOT_WRITTEN). While a check runs, another POST answers 409 {"status": "running", "code": "VERIFY_RUNNING", "check": ...}. When the check ends, its result is recorded as BATCH_EBR_VERIFY_ALL_DONE, with a summary.
  • GET (or HEAD) returns the last result, or the one running. It answers 404 {"status": "none"} when no check has run since the server started. The result is kept in memory only.
  • The result: running, started_by, started_at, finished_at, total (batches to check), checked (batches checked so far, counted as it goes), counts (batches per status), failing (each batch whose status is not valid, with batch_id, status, reason, reason_code, entries, checked_at and first_failing), missing and anchored.
  • Missing batches: each batch the audit trail records as created (BATCH_CREATED, minus the creations refused) that is not in the store is listed in missing, with its BATCH_CREATED audit record and the reason “Recorded in the audit trail (…), missing from the store: the batch record was removed.”
  • anchored is false when the server has no audit trail, so a missing batch cannot be detected. When the audit trail cannot be read, anchored is also false, and error says why.

The check runs one batch at a time, so the runner and batch commands continue between two batches. Each result is also cached for the batch list. The result stays in memory and in the audit trail (BATCH_EBR_VERIFY_ALL_DONE): after a restart, run the check again.

In the Studio, administrators use Verify all batch records in the EBR view (disabled, with the reason, for other users). The dialog starts the check, shows its progress (checked of total), then its findings in a grid: the records that are not valid and the batches missing from the store. A refusal (for example AUDIT_NOT_WRITTEN or a check already running) is said in the dialog and never shown as a result.

A release signature covers the record as it stood when it was signed. It signs the batch, the chain entry it signs and that entry’s hash, together with the signer, role, meaning, reason and time:

signing digest = SHA-256("eaxscada-ebr-sign/1", batch ID, signed entry's place, signed entry's hash,
signer, role, meaning, reason, time)

Each field has its length in front of it, as in the chain. The signed entry is the chain’s last entry when the signer confirms. That entry’s hash covers the whole record up to that point. The digest is stored with the signature (signing_digest, and signature_hash, which has the same value), in the signature’s SIGNATURE chain entry, and in the signature field of its audit record (BATCH_EBR_SIGN_RELEASE, or BATCH_EBR_POST_RELEASE_NOTE for a note).

The check recomputes each signature’s digest, confirms that the entry it signs exists in this batch’s chain with that hash, and confirms that the signature’s meaning is the one of its kind. A signature copied to another batch, or a record changed after it was signed, fails the check, and so does the record.

Kind Meaning recorded, word for word
release “Release: I have reviewed this batch record as it stands and approve the batch for release.”
post_release_note “Post-release note: I add this note to the released batch record; it does not change the record.”
  • The dialog signs the record on screen. The Studio signs the batch whose EBR is shown, never the batch that happens to be active. When the dialog opens, it reads that EBR again and names the batch. An answer for another batch signs nothing. A record that cannot be read is cleared from the screen and cannot be signed.
  • The dialog shows what is signed: “Batch <id>, record as of entry <seq> (<time>), <first 12 hex digits of the entry’s hash>”, or, for a batch recorded before its chain, “Batch <id>, record as found (recorded before its integrity chain), content <12 hex digits>”. The meaning is shown word for word.
  • The signer is the signed-in user, shown read-only. The password field is empty, and the reason (the note, for a post-release note) is required.
  • The sign button reads Sign Batch Release, or Add post-release note once the record is released. When the server already reports a refusal, the button is disabled and the refusal is shown next to it, with its code.

The EBR’s signing object says what a signature would sign now: kind (release, post_release_note, or empty when none is possible), meaning, signs_seq, signs_hash, signs_at, chained, released, and refusal_code with refusal when a signature would be refused. POST /api/batches/{id}/sign must send kind, plus the signs_seq and signs_hash the dialog showed. Without them it answers 400 "code": "EBR_SIGNS_REQUIRED".

These refusals answer 409 {"status": "refused", "code": ...}. Nothing is signed. The refusal is recorded in the audit trail as BATCH_EBR_SIGN_RELEASE_REFUSED or BATCH_EBR_POST_RELEASE_NOTE_REFUSED, with the code.

Code When In the answer
EBR_CHANGED The record moved on since the dialog showed it. Review it and sign again. tip_seq, tip_hash: the record as it is now.
EBR_INVALID The record fails its check. Nothing is signed over a record that fails. first_failing
EBR_NOT_CHECKED The record’s check could not run (the audit trail is unreadable, entries are not written yet). Nothing is signed unchecked.
EBR_RELEASED A release of a record that is already released. Add a signed post-release note instead.
BATCH_NOT_ENDED A release of a batch that has not ended (COMPLETED, STOPPED or ABORTED).
EBR_NOT_RELEASED A post-release note on a record that is not released.
SIGN_KIND A signature kind that does not exist.

A signature whose record cannot be written is refused with 503 AUDIT_NOT_WRITTEN or 503 EBR_NOT_WRITTEN (refused). A wrong password answers as on every signature route (A refused signature is not an ended session).

A record that is partial or not_covered can be signed. A signature over a batch recorded before its chain is bound to that record’s content as it was found when it was signed (signs_seq 0, Covers “Record as found (not covered)”). The record stays not_covered: a signature never starts its chain.

  • A batch is released once it has ended, and only once.
  • After the release, every command on the batch is refused with 409 EBR_RELEASED and recorded (BATCH_COMMAND_<command>_REFUSED). Any other change to the record is refused the same way.
  • The only addition allowed is a signed post-release note (kind post_release_note; the reason is the note). It is a new SIGNATURE entry that does not change the record.
  • Record content found in the chain after the release signature fails the check (after_release).
  • A release signature from an earlier version (a legacy signature) does not close the record.

Nothing is rewritten, and nothing is hashed silently at the upgrade.

  • A batch without a chain is not_covered: “Recorded before eaxScada <version>: this batch record has no integrity chain.” It is never reported as verified.
  • A batch that has not finished, or that takes any forward step (START, RESET, RESUME, RESTART, a prompt acknowledgement, a runner step), gets a COVERAGE_START entry at that step, recorded first as BATCH_EBR_COVERAGE_START. The entry holds the batch, its phase logs and its materials as they were found. From then on, the record is partial: “Covered from entry 1 (<time>): what was recorded before is shown as it was found, not verified.” A forward step is refused if the coverage cannot be started, so a batch recorded before its chain never runs again without one. Content as found is never presented as verified content.
  • A finished batch stays not_covered for good, including when it is signed or only takes steps toward rest. There is no “adopt” or “re-seal” action, because hashing old content now would only certify whatever the files hold today.
  • Legacy signatures never count toward valid. A signature without a version, made by an earlier version, covers the signer, role, reason and time, not the record’s content (Covers “Legacy: signer and time only”). A record that holds one is at best partial (legacy_signatures). It is not invalid either: it is reported as it is. A signature that was in the record when its coverage started reads “As found: not verified”.

Recipe approvals bound to content and revision

Section titled “Recipe approvals bound to content and revision”

A recipe approval signs the recipe revision the signer saw:

content hash = SHA-256("eaxscada-recipe-content/1", recipe ID, revision, the recipe's content)
signing digest = SHA-256("eaxscada-recipe-sign/1", recipe ID, version, revision, content hash,
signer, role, meaning, reason, time)

The content is the recipe without its status, signatures and update stamp, so an approval does not change what it approves. The meaning recorded is “Approval: I have reviewed this recipe revision and approve it for production.”

  • The approval dialog shows the recipe ID, version, revision and meaning, and sends the revision it showed. POST /api/recipes/{id}/approve answers:

    • 400 "code": "RECIPE_REVISION_REQUIRED" without revision;
    • 409 "code": "RECIPE_CHANGED", with current_rev, when the recipe changed since the dialog showed it. The refusal is recorded as RECIPE_ESIGN_APPROVE_REFUSED. Review the recipe and approve again.
  • GET /api/recipes carries, per recipe:

    • approval_checks: one per signature, with index, status (bound, legacy or invalid), revision, version and reason_code (digest, meaning, version, or recipe_changed for an approval of another revision);

    • approval_meaning.

    • approval_invalid: true when the recipe is approved but its approval does not hold. It comes from the same check that refuses a run or download. With it, approval_invalid_code (latest_invalid or not_covered), approval_invalid_index (the latest signature), approval_invalid_reason_code and approval_invalid_reason say why. It is never stored: a save ignores it.

    The recipe list is a data grid (filters, sorting, CSV export, Open). A recipe whose approval does not hold is marked in its row: a marker, a rose status and the reason in its card. The Studio takes it from approval_invalid and no longer works it out from approval_checks.

    The recipe approvals grid shows Meaning and Covers: “This revision (<rev>)”, “Not this revision: signed revision <rev>”, “Legacy: signer and time only” or “Fails: the signature does not match”.

  • SAFETY: an approved recipe whose approval does not hold is not run. Its approval does not hold when its latest approval fails, or when it was approved with a bound signature and no bound approval covers its content now (it changed behind its approval). Then a batch launch and a setpoint download are refused with 409 RECIPE_APPROVAL_INVALID, recorded as BATCH_CREATED_REFUSED or RECIPE_DOWNLOAD_REFUSED, and no setpoint is written. In the Studio, the recipe’s header and its card read Approval does not hold in rose, and Launch and Download Setpoints are disabled with the reason. Approve the recipe again.

  • A recipe approved only with legacy signatures (made by an earlier version, covering the signer, role, reason and time, not the content) runs as before.

  • A batch already created keeps running the copy of the recipe it was created from (A batch runs the recipe it was created from).

Recipes and batches exist in every edition, Free included. The chain and the content-bound signatures are built and checked in every edition. The link to the audit trail, which detects a removed, cut-short or replaced record, needs the audit trail, which Starter, Pro and Enterprise have.

Free Starter Pro Enterprise Build without the audit trail
Batch chain written and checked yes yes yes yes yes
Content-bound signatures and approvals yes yes yes yes yes
Audit trail link (rollback, deletion, recomputed chain) no yes yes yes no
Best status reachable not_anchored valid valid valid not_anchored

In Free and in builds without the audit trail, the chain is checked, but a removed or replaced record cannot be detected: the EBR reports not anchored, never verified.

On a redundant pair, the primary is the only node that writes batch records. It sends each step’s chain entries to the other nodes on the cluster stream EAX_HA_EBR, one message per step. The standby never takes the batch views it receives: it rebuilds the batch, its phase log and its signatures from its own chain.

  • Entries replicate synchronously. For each step, the primary writes the audit record and the chain entry here (synced to disk), puts the entry on the stream, and waits for the cluster’s acknowledgement. Only then does it write the views and answer.
  • A step is acknowledged only once another running SCADA node holds its audit record. The step’s audit record anchors its chain entries. Before the entries go on EAX_HA_EBR, the primary asks on ha.sync.audit.have whether another node holds its audit records up to the step’s. The standby takes what it lacks from the primary and confirms. If that is not confirmed within 4 s, the step is handled as if the stream had not taken it: a forward step is refused (503 EBR_NOT_WRITTEN, REVERTED), and a step toward rest applies and is sent again until it is confirmed. If no other SCADA node runs, steps go on as before. A step can take up to about 1.5 s longer when the standby lags.
  • After a failover, every acknowledged entry is anchored on the new primary. Its record reads valid once it has caught up. Before this release, an acknowledged entry could stay not_anchored on the new primary until the old primary came back, or forever if it never did.
  • A running but unhealthy standby blocks forward batch steps. A standby whose audit trail is down, for example, cannot hold the records and answers “not held”. This is deliberate: record integrity comes before availability. See When a forward step is refused because of the standby.
  • With more than two SCADA nodes, the first node to answer confirms. A newly elected node that is not that one may lack the anchors until it fetches them from the node that holds them (its audit catch-up runs at once after a gap and every 30 s). Until then its EBR can read not_anchored for those entries. Open it again a moment later.
  • A forward step or a signature that the cluster does not acknowledge is refused with 503 "code": "EBR_NOT_WRITTEN", "status": "refused". Nothing changes: no setpoint is written. The entry stays in the chain followed by a REVERTED entry that undoes it, and both are sent again, in order, until the cluster takes them.
  • Stops still apply. PAUSE, HOLD, STOP and ABORT take effect when the cluster does not acknowledge them (503 EBR_NOT_WRITTEN, "status": "applied"). Their entries are sent late, again until the cluster takes them. Until then, the batch takes no forward step and no signature.
  • The standby accepts only entries that link to its own chain. Each entry must be the next one of its chain (place, prev_hash, and an entry_hash the standby computes again). An entry that does not link stops the replication of that batch on that node. It is reported, never repaired: in System Health, HA section, and in GET /api/ha/status under buckets, EAX_HA_EBR reads “batch <id> not replicated here: <reason>”.
  • A node that is not the primary refuses every batch step with 409 {"status": "refused", "code": "EBR_NOT_PRIMARY"}: batch creation, START, RESUME, RESTART, RESET, a prompt acknowledgement, a signature, and also PAUSE, HOLD, STOP and ABORT. A standby drives nothing: send the command to the primary. The refusal is recorded in the audit trail.
  • After a failover, the new primary catches up before it runs forward steps. It puts its term marker on the stream, applies every entry up to that marker, rebuilds its views, and sends the stream any entries of its own that the stream lacks. Until then it takes steps toward rest only (a forward step answers 409 EBR_NOT_PRIMARY), and its runner does not step a batch. Entries sent by a replaced primary with an older term after the marker are refused by every node.
  • Entries that were recorded but never replicated are reported as missing. The audit trail replicates on its own. When it names an entry that another node recorded and that never reached this node before the failover, the check reports invalid, behind_ledger: “Integrity check failed at entry N: entry N is recorded in the audit trail on node <node> and is missing here (it did not reach this node before the failover)”. The entry is never invented.
  • Phase logs and signatures now survive a failover. Before this release, the standby received only the batch’s state, without its phase log, signatures or chain, so they were lost when it took over.

Limits on a redundant pair:

  • A STOP on a primary that has not caught up can fork the batch on that node. A step toward rest is taken before the catch-up ends. If entries of the same batch from the previous primary are still on their way, the two records differ from that entry on. The replication of that batch stops on that node, and the HA status reports it (“the record forked”). The audit trail holds both nodes’ records.
  • A step taken while no other SCADA node was running is anchored on a later primary only once the old primary’s records reach it. With no standby running there is nothing to confirm, and the step goes on. A node that starts later takes those records by its audit catch-up from the old primary; if the old primary fails before that, the entries read not_anchored on the new primary until the old primary comes back.
  • A node that runs but does not answer the confirmation is reported, not waited for. If no node answers on ha.sync.audit.have while another SCADA node was seen running in the last 65 s (an older version during an upgrade, for example), the step goes on as on a lone primary. The primary logs a warning, HA audit confirmation: a SCADA node seen running does not answer, and raises ALM-SYS-HA-AUDIT-UNCONFIRMED. It clears with the next step another node confirms, or when the server is no longer the primary. A standby stopped on purpose less than 65 s before a step can raise it too.
  • Batches that ended before the upgrade are reported missing after a failover. Their chain entries were written on the node that ran them, before this replication existed, and were never sent to the other node. When that other node takes over, the audit trail names entries it does not hold, and their EBR reports behind_ledger “missing here”. Batches still running at the upgrade are sent to the stream by the primary.

When the audit trail is down, a step toward rest keeps its audit record to write it late (When the audit trail is down). On a redundant pair these kept records are no longer local to the primary:

  • The primary sends a batch’s kept records to the other nodes on EAX_HA_EBR (subject ebr.late.<batch key>, fenced by term like the entries) and waits for the stream’s acknowledgement.
  • A standby holds them. It adds them to its own b<id>.lateaudit.jsonl, synced, before it reads on in the stream. On the standby the batch reads not_checked (audit_records_pending) until the records are written. A standby never writes them, and never removes one because of another node’s message.
  • After a failover, the new primary writes them once. It writes them when it has caught up for its term, after checking its own audit trail for each one. The batch then reads valid on the new primary. Before this release, it read not_anchored there.
  • Only one node writes kept records: the primary caught up for its term, or a server without HA. Every node drops a kept record that its own audit trail already holds (same batch, action and version_ref, whoever wrote it). A kept BATCH_EBR_ENTRY is also dropped when the trail already holds a later record of the batch that is not a refusal and names the same entry or a later one, for example when the step’s own record was committed but its answer was lost.
  • A node that has run in a cluster waits up to 60 s at start for its replication before it writes kept records as a server without HA. In that time it writes none, because it cannot know yet whether another node wrote them.
  • When the cluster does not take the kept records, they are sent again after 10 s, until they are taken. The primary waits on the cluster for them at most once per 10 s. Its log has “batch’s kept audit records not taken by the cluster: sent again until they are”. If the primary fails before they are taken, the new primary does not have them, and the batch reads there as it did before this release.

For QA reviewers: an audit trail can hold the same late record twice. If the old primary writes a late record and fails before that audit record reaches any other node, the new primary still holds the record from the stream, finds no copy in its own trail, and writes it too. Once the old primary’s record reaches the cluster, the trail holds two records with the same action and version_ref, from two nodes. This is accepted and expected: both name the same entry, and the batch record still checks valid. It is not a sign of tampering or of a step taken twice; only one step took place.

When a forward step is refused because of the standby

Section titled “When a forward step is refused because of the standby”

A forward step (batch creation, START, RESUME, RESTART, a prompt acknowledgement, a signature) answers 503 EBR_NOT_WRITTEN, "status": "refused", and the server log of the primary has “batch record entries not taken by the cluster” with the error “the audit records of this node up to N are not confirmed on another node”. Nothing changed: no setpoint was written. PAUSE, HOLD, STOP and ABORT still take effect.

  1. Put the batch in a safe state if the process needs it: HOLD or PAUSE apply even now.
  2. Open System Health on the standby. Look for ALM-SYS-AUDIT-DOWN, ALM-SYS-AUDIT-DISK or an HA error: a standby whose audit trail is down cannot hold the records.
  3. Repair the standby (free space on its audit volume, fix its audit folder, restart it), or stop it. A stopped standby is no longer asked: the primary runs alone and forward steps go on (each one then waits for the standby’s catch-up when it comes back).
  4. Send the refused step again. It is not repeated by itself.

Never stop the standby only to get a batch going without first checking why it does not confirm: until it is back and caught up, a failure of the primary leaves the steps taken meanwhile unanchored on the standby.

  • A full administrator of the host is not in scope. The check does not protect against someone who can rewrite the batch files, the audit trail and the security store together. Limit write access to the data folder to the service account (21 CFR Part 11 §11.10(d)).
  • A late audit record is kept on disk, per node. While the audit trail is down, a batch step’s audit record (or the BATCH_EBR_ENTRY naming its entry) is saved to data/recipes/batches/b<id>.lateaudit.jsonl before the step answers. It is written once the trail is back, also after a server restart, and never twice (an audit record with the same action and version_ref is not written again). The file exists only while records are pending. On a redundant pair the primary also sends these records to the other nodes, so a new primary writes them after a failover (Late audit records on a redundant pair). Do not delete it: the server backup holds it with the chain files.
  • Chain entries that could not be written are kept on disk. A PAUSE, HOLD, STOP or ABORT (or a step already done on the plant) takes effect even when its chain entries cannot be appended to the chain. The entries are saved to data/recipes/batches/b<id>.chainpending.jsonl, synced, before the step answers, and written again until the chain holds them; then the file is removed. After a restart they are written at once, marked late, and the record checks valid. Before this release they were kept in memory only, and a restart before they were written made the record read invalid with missing_entry, which looks like an altered record. Do not delete the file: the server backup holds it with the chain files.
  • A chain-pending journal that does not follow the chain is never applied. If its entries do not link to the chain (another entry at a place, a link or a hash that does not check, a place below 1) or it cannot be read, the server leaves the file in place, logs “batch record pending journal does not follow the chain: not applied, left in place” (or “unreadable”), and the check reports the record as its chain is. Keep the file and the server log for the investigation.
  • The batch list can show the last result for an audit-trail edit. An edit of the audit trail that comes with no batch step does not change the record’s stamp, so the list shows the last result until the next check. Opening the record, signing it, or Verify all batch records always runs the full check.
  • An export cannot be checked again offline. The exports carry the integrity result and the signatures, not the chain entries.

Five rights control recipes and batches:

Right Allows
recipe.edit create, save and delete a recipe (also the recipes a starter template adds)
recipe.approve approve a recipe (e-signature)
recipe.download download a recipe’s setpoints to the plant
batch.run create a batch; START, RESUME, RESTART and RESET it; acknowledge its operator prompts
batch.sign sign a batch record’s release (e-signature)
  • Who holds them. Every role of level 60 or more: Process_Supervisor, Lead_Engineer and Administrator among the built-in roles. A custom role holds them by its level, the same way. No built-in role’s access changed with these rights.
  • DENY rules take a right away. In Security > Permissions, a feature rule (target type feature) can name one right (batch.run) or a group (recipe.*, batch.*). A DENY rule also matches with the catch-all * (feature:*) or a prefix ending in * (batch*, recipe*). A DENY rule that matches refuses the action (403) for every role, group or user it applies to, whatever their level. For example, DENY recipe.download on the group of the night shift supervisors lets them edit recipes but not send them to the plant.
  • The Administrator too: a matching DENY rule refuses these rights to a user with the Administrator role as well, as it does the shift log and Analytics and Reports rights. The Administrator keeps security administration, so can always remove the rule. Without a matching DENY the Administrator holds every right, as before; the default rules hold no feature DENY.
  • Rules that cannot be read refuse: when the server cannot read the permission rules, the recipe and batch rights are refused to everyone, the Administrator included, with “permissions could not be read; <right> refused” and a WARN in the log. A store with no rules is not such a failure: the defaults apply.
  • ALLOW rules do not lower the level. A role below level 60 does not get these rights from an ALLOW rule.
  • Toward rest needs no right. PAUSE, HOLD, STOP and ABORT only need a signed-in user: refusing them could keep a batch running.
  • The AI co-pilot never downloads a recipe or runs a batch, whatever roles its account has.

These actions are recorded in the audit trail before they take effect. When the record cannot be written, the action is refused with 503 AUDIT_NOT_WRITTEN (“… the audit trail could not be written”) and nothing changes:

Action Recorded as With the trail down
Batch creation, START, RESUME, RESTART, RESET the batch command nothing created, the batch state does not change
Recipe approval, batch release signature the signature nothing signed
Recipe download, signed or not RECIPE_DOWNLOAD, before the first setpoint no setpoint written
Recipe save RECIPE_SAVED, with the stored and the new revision nothing saved
Recipe delete RECIPE_DELETED nothing deleted
Operator-prompt acknowledgement BATCH_PROMPT_ACK, with the prompt, the user, the next phase and the comment nothing acknowledged, the next phase’s setpoints are not written
  • A recipe’s “updated by” is the signed-in user who saved it, and a recipe added by a starter template is saved as the user who applied the template (with its own RECIPE_SAVED record).
  • Batch creation, batch commands and prompt acknowledgements are recorded under the user’s highest role.
  • When a change fails after its record was written, a <ACTION>_FAILED record follows.
  • PAUSE, HOLD, STOP and ABORT always act, and report the missing record. A batch completion and a hold at runtime stop are logged when their record is missing.
  • In the Studio, saving or creating a recipe shows the server’s answer: a refusal shows its code and message. A recipe changed elsewhere in the meantime offers a reload.

An integration that creates batches, sends batch commands or saves recipes gets 503 AUDIT_NOT_WRITTEN when the trail cannot be written (earlier releases answered 400), and 403 when the user lacks the right. Treat 503 as “nothing changed, retry once the trail is back”. See the audit trail on disk.

A batch’s state and its log entries are written to the recipe store (data/recipes) before a command is answered, and before a phase writes its setpoints. Nothing is answered OK that is not on disk.

  • A command that runs a batch is refused when its record cannot be written: batch creation, START, RESUME, RESTART, RESET and a prompt acknowledgement. Nothing changes and no setpoint is written.
  • PAUSE, HOLD, STOP and ABORT always take effect, as do a hold at runtime stop and a batch’s completion. Their record is kept in memory and written again every few seconds until it is on disk. It is lost if the server stops first.
  • A phase step whose record cannot be written holds the batch. No further setpoint is written until a RESTART, which needs its own record written. When the hold came before the phase’s setpoints were written, the RESTART writes them.
  • The batch log is in the order things happened: a START is logged before the first phase’s ENTER (START, then ENTER), as the command comes before its setpoints.

POST /api/batches, POST /api/batches/{id}/command and POST /api/batches/{id}/prompt answer:

Answer status What happened Shown in the Studio
503, "code": "BATCH_NOT_WRITTEN" refused The action was refused: its record could not be written. Nothing changed. “Not done: the batch record could not be written; nothing changed”
503, "code": "BATCH_NOT_WRITTEN" applied A PAUSE, HOLD, STOP or ABORT took effect, but its record is not written yet: it is written again until it is. “Done, but the batch record could not be written yet; it is written again”
503, "code": "BATCH_NOT_WRITTEN" held The action started a phase step whose record could not be written: the batch is on HOLD, no setpoint is written until a RESTART. “The batch was held: its record could not be written”
409, "code": "BATCH_NOT_RUNNING" refused A prompt acknowledgement on a batch that is PAUSED or HELD. Nothing was acknowledged and the batch is not stepped; the prompt still waits. “Resume or restart the batch first”

When it is the batch’s integrity record (its chain entry) that could not be written, the answer is the same with "code": "EBR_NOT_WRITTEN" (When the record cannot be written). POST /api/batches/{id}/sign answers 503 EBR_NOT_WRITTEN refused the same way.

A 503 BATCH_NOT_WRITTEN or EBR_NOT_WRITTEN answer also has applied and held (true or false), the server’s error, and, for a command or a prompt acknowledgement, batch: the batch as it stands. The Studio shows that batch in the batch monitor. None of these answers is shown as a success, and a refused prompt acknowledgement keeps the comment you typed.

An integration must read the status: only applied means the command took effect. Never retry an applied PAUSE, HOLD, STOP or ABORT as if it had not happened.

ALM-SYS-BATCH-RECORD (High), “Batch record not written - batch held or record waiting”, is active while the state or a log entry of a batch is kept in memory but not written. The server log names the batches and the error. Free space on the disk of data/recipes, or fix the folder’s permissions. The alarm clears when everything is written. See System alarm ALM-SYS-BATCH-RECORD.

A batch runs the recipe it was created from

Section titled “A batch runs the recipe it was created from”

A batch keeps a copy of the master recipe as it was when the batch was created, with its revision (recipe_revision). The batch runs those phases, and editing the master recipe no longer changes a batch already created or running. A remote START, RESUME or RESTART is checked against the recipe the batch runs.

The EBR shows the recipe as run. GET /api/batches/{id}/ebr carries:

Field Value
recipe_source as_run: master_recipe is the recipe the batch was created from and ran. current_not_recorded: the batch was created before this version, which kept no copy; master_recipe is the master recipe as it is now, which may differ from the version run.
recipe_note For current_not_recorded: “Recipe as of now (the version run was not recorded).”
recipe_revision The revision of the recipe the batch runs (empty for an older batch).

In the Studio, the EBR’s summary reads Recipe as run, revision …, or, for an older batch, Recipe as of now (the version run was not recorded) in amber. An older batch also runs the master recipe as it is now, as before.

  • The batch’s EBR lists each material with the lot you entered, or “not lot tracked”.
  • After a phase with a measured ingredient completes, its row shows the amount, Measured by the actual tag (Good) and IN TOLERANCE or OUT OF TOLERANCE.
  • On Starter, Pro or Enterprise, the EBR of a batch created on this version reads Integrity verified (N entries, checked at …). In Free, or in a build without the audit trail, it reads Not anchored.
  • The sign dialog names the batch whose record is on screen and the entry it signs.
Symptom Cause Fix
“no lot number given for ingredient …” A lot-tracked material has no lot. Enter its lot, or untick Lot tracked in the recipe if the material has none.
“lot … does not match the pattern …” The lot is not of the form the recipe asks. Check the lot, or correct the recipe’s Lot pattern.
“… is not lot tracked; … remove the lot entered” A lot was sent for a material that is not lot tracked. Remove it.
“batch id … is already in use” Another batch has that ID. Leave the field empty or use a new ID.
Every amount says NOT MEASURED The ingredients have no actual tag. Set Actual tag in the recipe.
403: “… needs recipe.download …” or “the rule … denies …” The user’s role is below level 60, or a feature rule denies the right. Give the user a role of level 60 or more, or narrow the DENY rule in Security > Permissions.
503 AUDIT_NOT_WRITTEN The audit trail could not be written (disk full, audit folder not writable). Nothing changed. Fix the audit folder, then try again.
“Not done: the batch record could not be written; nothing changed” (503 BATCH_NOT_WRITTEN, refused) The recipe store could not write the batch (disk full, data/recipes not writable). Nothing changed. Free space or fix the folder’s permissions, wait for ALM-SYS-BATCH-RECORD to clear, then try again.
“The batch was held: its record could not be written” A phase step could not be recorded; the batch is on HOLD. Fix the store, then RESTART the batch.
“Resume or restart the batch first” (409 BATCH_NOT_RUNNING) The batch is PAUSED or HELD: its prompt is not acknowledged. RESUME or RESTART the batch, then acknowledge the prompt.
“Not done: the integrity record could not be written; nothing changed” (503 EBR_NOT_WRITTEN) The batch’s chain file could not be written, or an earlier entry of the batch still waits to be written. Free space or fix the permissions of data/recipes, wait for ALM-SYS-BATCH-RECORD to clear, then try again.
503 EBR_NOT_WRITTEN on a redundant pair, the primary’s log says the audit records “are not confirmed on another node” The standby runs but cannot hold the step’s audit record within 4 s (its audit trail is down, or it lags too far). See When a forward step is refused because of the standby.
ALM-SYS-HA-AUDIT-UNCONFIRMED Another SCADA node runs but does not answer the confirmation (an older version, for example); steps go on unconfirmed. Finish the upgrade so both nodes run the same version. The alarm clears with the next confirmed step.
The EBR reads Integrity check failed An entry, a view or a signature does not match its chain or the audit trail. Open the marked row’s card. Restore the batch folder from a backup taken after the failing entry’s time, or treat the record as altered. Read Known limits first.
409 EBR_CHANGED when signing The record moved on since the dialog opened. Review the record as it is now and sign again.
409 BATCH_NOT_ENDED when signing The batch is still running, held or paused. Release it once it is COMPLETED, STOPPED or ABORTED.
409 EBR_RELEASED on a batch command The batch is released: its record is closed. Add a signed post-release note if something must be added.
409 RECIPE_APPROVAL_INVALID, recipe reads Approval does not hold The recipe’s content no longer matches its approval. Review the recipe and approve it again.
409 RECIPE_CHANGED when approving The recipe changed since the dialog showed it. Reload the recipe, review it and approve again.
An amount shows the quality instead of a value The actual tag was Bad, Uncertain or overridden when the phase completed. Check the device and the tag’s quality; the value read is kept in the record.