One page for each automation alert and each action on Script Jobs and Reconciliation. These pages are for the people
who hold ops.executor (Script Jobs, the alerts) and reconcile.manage (Reconciliation). Each section says what you
see, what it means, what to do, and when to hand it on.
Where things are:
- Setup › Developer › Script Jobs lists the scripts that failed or are retrying after a save, with Service Levels beside them.
- Setup › Business Settings › Reconciliation lists stored totals that differ from their source records.
- Setup › System Settings › Automation Reliability holds the switches, the alert threshold and the service-level targets.
The Two Alerts
Both alerts arrive as notifications for everyone who holds ops.executor. Each sends at most one notice an hour per
script or per service level. Both are off until they are set.
"<script> failed N times in the past hour"
This alert is on when Alert After (Failed Jobs per Hour) is above 0. Open Script Jobs and filter by the script. Every failed job carries a class, a plain message and What to do. Then follow the class's runbook below.
If several scripts alert in the same hour with the class Temporary, the cause is the database or the workers, not the scripts. Go to Queue Wait Missed.
"Script jobs are slow", "<queue> has a job waiting", "A reconciliation difference has stood"
This alert is on when Alert On Missed Service Levels is on. The section for each missed level is under Service Levels.
Failure Classes
Limit Reached
A governor limit stopped the script. No retry can get past it, so with Stop Retrying Hopeless Script Jobs on, the job fails at once.
- Cascade depth (the PO approval incident): a chain of automatic saves went past depth 3. A depth-3 script may only
read. An after-save job blocked this way is not retried at the same depth (it could never pass). Instead it is queued
again once as a new job at depth 0, and its timeline shows deferred. So a chain such as bill → order → project →
group total gets through. A chain that hits the limit again after that restart fails at once, with no retries, whether
or not Stop Retrying Hopeless Script Jobs is on. That usually means a loop. Replay is refused, because the job keeps
the depth it was queued at. To fix it:
- Break the chain. Give the after-save scripts a
watchso that each runs only when its own fields change, or turn the chain into one process of Run Script steps (the Automations help covers both). - Save the record again. That queues a fresh job at depth 0.
- Break the chain. Give the after-save scripts a
- Rows per query: the script asked for more than 500 rows at once. Change the script to page through the rows, or
use
api.records.aggregateor a rollup field. Never raise the limit. Then Replay. - A per-run budget or memory: split the work or read less per run, then Replay.
Run npm run scripts:inventory -w kernel (on the server, node dist/cli/script-inventory.js). Its flags (rows>500,
self-write-unwatched) show the other scripts heading the same way.
Script Error
The code itself is wrong. Examples are a ReferenceError such as lib is not defined, a call its kind of script may
not make, or setting a status when creating a record.
lib is not defined: the script reads a library it does not import. On the inventory this shows aslib-without-imports, or asimport-missingwhen the library is switched off or gone. Add the import, or switch the library on.- "The script sets the record's status itself": leave
statusout when the script creates the record (it starts in its flow's first stage), then run a transition to move it on.
Fix the script, test it with Test Run in the studio, then Replay the failed jobs. Hand the job to the script's author when the fix is in the code.
No Access
The user the script runs as may not do what the script does: read the record, write in that company, or use a service call. Retrying as the same user cannot help.
- If the script must do what its writer may not (the stock approval a project's creation makes), set Run As to a service user that holds the access. Check that the service user is active and has the record's company.
- If the user should have the access, grant it (Setup › Access), then Replay.
Data Problem
The records refuse the write. Examples are a duplicate number, a missing record, or a value that fails validation.
- A missing record (the bank GL link incident: the script links a bank line to a ledger account that does not exist in that company): create or restore the record, or correct the link, then Replay.
- A duplicate number: fix or remove the existing record or number, then Replay.
Hand data problems to the record's owner (Accounts, Projects). The message names the record and the field.
Temporary
The database aborted or timed out the transaction. Examples are a write conflict, an aborted transaction, or the script's time limit. These jobs are retried automatically, after a short wait (1 s, 2 s, 4 s… up to 30 s). A single one needs no action.
A write conflict usually never reaches the job at all: the job's unit of work runs again at once, inside the same
attempt. The script's run log then shows a run with status Retried (the error names the write conflict), followed
by the run that counts. A Retried run is not a failure and lost nothing, and the daily run metrics count it as
retried, not error. (Before this status, these runs read as an error on attempt 1 with no later attempt, which looked
like a lost update.)
- If one script keeps failing as Temporary, it does too much in one run. Treat it like Limit Reached: split it.
- If many scripts fail as Temporary in the same hour, check the database and the workers (Queue Wait Missed).
Unclassified, Not Classified Yet
- Unclassified: no rule matched the error. It is retried as before. Read the error and the script's run log (Scripts › the script › Runs). If it recurs, ask the platform team for a classifier rule.
- Not Classified Yet: it failed before classification. Classify Older Failures classifies those jobs from their kept errors and changes nothing else.
Actions on Script Jobs
| Action | When | What it does |
|---|---|---|
| Replay | The cause is fixed | Queues the failed job again, with fresh attempts. It is refused for a cascade-depth failure: save the record again instead. |
| Stop Retrying | A retrying job will not succeed | Marks it failed now, so it stops using workers. It stays listed. |
| Classify Older Failures | Jobs show Not Classified Yet | Classifies failed jobs from their errors. Statuses are untouched. |
Before replaying many jobs of one script, replay one and wait for it to complete. A replay runs the script on the record as it is now, not as it was when the job failed.
Service Levels
Script Jobs measures the service levels when the page loads. The targets are in Automation Reliability.
Script Jobs Done Within (99% Within 2 Minutes)
This is the share of the past hour's script jobs that were done within the target time after the save queued them, retries included. No Data means no jobs completed in the hour.
When it is missed:
- Look at Longest Wait first. If jobs are waiting to start, the workers are behind (Queue Wait Missed).
- Otherwise jobs are slow to run. Look for Temporary failures (retries make jobs late) and for the scripts with the most rows on the inventory.
Queue Wait Missed
The script, rollup or automation queue has a job waiting longer than the target (10 minutes) to start.
- Check that the workers are running:
GET /api/internal/executor/healthlists the executors and each queue's waiting jobs and stale leases;docker compose ps workeron the server.
- A stale lease is a job held by a worker that died. It is taken back once its lease runs out, with no action needed.
- If the workers run but the queue grows, the database is slow. Check its load, then add workers.
- The rollup queue folds repeated saves of the same record, so a long rollup queue is many different records: a large import or a bulk update. It drains on its own. Leave it unless it keeps growing after the import ends.
A Reconciliation Difference Has Stood
A difference on Reconciliation has been open longer than the target (24 hours: one working day). Stale Sales Utilisation was this kind of incident: a stored total that no rollup kept, so it fell behind its sources.
- Open Reconciliation and filter by the figure in the notice.
- Check Again. If the difference is gone, a late job has caught up.
- If it stays:
- compare Stored and From Sources, and open the record;
- if the sources are right, Repair it. This needs Allow Repair. It writes the recomputed total, runs no script, and the audit log names you;
- if the difference is known and accepted, Ignore it. It comes back if its numbers change.
- If the same figure keeps drifting, a script still writes it. Open the figure's Scripts, switch off the ones that write the field, and Declare as Rollup so the kernel keeps the total.
Commands
All four commands are run on the server (docker compose exec kernel node dist/cli/<file>.js …), or in a checkout
with npm run <name> -w kernel -- ….
| Command | What it is for |
|---|---|
jobs:export-failed --out f.jsonl |
Every failed job to a file, with its SHA-256 checksum and a summary. Run it before failed jobs expire (30 days). --failed-before 30 --delete archives them. |
scripts:inventory --out f.csv |
One row per script, the scripts with the most failures first, with flags (rows>500, lib-without-imports, import-missing, self-write-unwatched, create-sets-status, script-gone). |
jobs:report --out baseline.csv |
Failures by script, class, error pattern and day, from the queue or from an export file (--from f.jsonl). --compare baseline.csv shows before and after, as failures per day. |
automation:cleanup |
Switched-off scripts that are ready to remove, the switches and the failed-job retention. --apply removes those scripts. --restore <key> brings a removed script back, switched off. |
Recompute Rollups
A write made straight in the database (a migration, a repair script) bypasses the hooks that keep rollup and mirror fields up to date. For example, payments marked posted leave an order's paid figure stale. A recompute works every rollup and mirror field of a record out again from its source records, and writes only what differs:
- API (metadata writers holding every company):
POST /api/admin/rollups/<model>/recomputewith{ "ids": ["…"] }(at most 5,000), or with no body for every record of the model. It answers 202 with{ enqueued }; theinbox_rollupsjobs do the work. - Scripts (after-save jobs, scheduled and step scripts):
api.rollups.recompute(model, ids)queues the recompute of up to 500 records a run, once the run commits. Only records the script can read are queued; the others come back innotFound.
A recompute waiting for a record takes in the next one for it, so repeating a sweep doesn't pile up jobs.
Game Day
Rehearse these runbooks in a development environment, never in production. The automated rehearsal is
npx tsx tools/test-run.ts test/scripts/game-day.test.ts (from kernel/). By hand:
- A write conflict. Open a project in two browser windows. Start an edit in one window and save in the other. At the same moment, save an order whose script writes that project. The job waits and completes, and no job fails. Check Script Jobs: nothing is listed.
- A slow database. In development, give a test script a short time limit and a loop that runs past it, or slow the database down (for example, a lock held on the collection). Save a record. The job fails as Temporary, is retried, and then fails. Script jobs are slow shows as Missed. Follow the Temporary runbook: remove the cause, Replay, and check that the record is written once.
- Write down how long each step took and what the runbook did not say. Add the missing steps to this page.
Hand-Over
Escalate in this order:
- The script's author: Script Error, or a script that keeps hitting Limit Reached.
- The record's owner: Accounts for ledgers and banks, Projects for projects and orders, for Data Problem.
- The administrators: No Access (roles, service users).
- The platform team: workers or the database (a missed queue wait), and Unclassified failures that recur.