From d34c403632c8180905fcf732fe525baa7f458ad3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 23:49:46 +0000 Subject: [PATCH] docs(skills): teach the approval escalation clock (escalation.clock, escalation.calendar) The approval node's escalation row states both clocks and the default, the working-calendar resolution order, what a calendar that cannot count the deadline does, and the lint rule for a calendar beside the wall clock. Paid for inside the file's token ceiling. The data-hooks note calls an hours-table deadline wall-clock hours. One eval case covers the working-time clock. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4d1ZJL93Kin2UHFXbFv --- .changeset/35931-escalation-clock-skill.md | 8 ++++++ .../evals/flows-triggers-approvals.json | 10 +++++++ .../state-machines-and-approvals.md | 28 ++++++++----------- .../objectstack-data/references/data-hooks.md | 6 ++-- 4 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 .changeset/35931-escalation-clock-skill.md diff --git a/.changeset/35931-escalation-clock-skill.md b/.changeset/35931-escalation-clock-skill.md new file mode 100644 index 00000000000..a5c14e4a911 --- /dev/null +++ b/.changeset/35931-escalation-clock-skill.md @@ -0,0 +1,8 @@ +--- +'@objectstack/skills': patch +--- + +Clause-②: no +Metadata-protocol: none + +The automation skill teaches the approval escalation clock: `escalation.clock: 'working_time'` counts `timeoutHours` as working hours on a working calendar (the `escalation.calendar` code, else the organization's default, else refused), a calendar that cannot count the deadline holds the escalation and shows why, and `calendar` without `clock: 'working_time'` is the lint error `approval-escalation-calendar-without-working-time`. The row no longer says the platform ships no business-hours calendar. The data skill's hook note calls an hours-table deadline wall-clock hours and points at the approval clock. diff --git a/skills/objectstack-automation/evals/flows-triggers-approvals.json b/skills/objectstack-automation/evals/flows-triggers-approvals.json index fcbeb2403c6..5fee84afd1d 100644 --- a/skills/objectstack-automation/evals/flows-triggers-approvals.json +++ b/skills/objectstack-automation/evals/flows-triggers-approvals.json @@ -435,6 +435,16 @@ "isActive" ] } + }, + { + "id": 25, + "prompt": "A purchase-order approval step must hand the request to `procurement_supervisor` once it has waited 8 business hours: nights, weekends and public holidays must not count. Our plants keep a working calendar with the code `cn_plant`. How do I declare that on the approval node?", + "expected_output": "Sets `escalation: { timeoutHours: 8, clock: 'working_time', calendar: 'cn_plant', action: 'reassign', escalateTo: 'procurement_supervisor' }` in the node config. `clock` must be written: its default, `'wall_clock'`, counts nights, weekends and holidays. Under `working_time` the hours count on a working calendar: the `calendar` code, else the organization's default calendar, else refused, never wall-clock time. The calendar is `sys_work_calendar` data each organization maintains in Setup, so the app declares no calendar or holiday object and no hook that stamps the deadline. While the calendar cannot count the deadline (no such calendar, or not maintained that far) the request does not escalate and the inbox shows why, until the calendar is fixed. `calendar` without `clock: 'working_time'` is a lint error (`approval-escalation-calendar-without-working-time`).", + "files": [], + "assertions": { + "must_contain": ["clock: 'working_time'", "calendar: 'cn_plant'"], + "must_not_contain": ["3_600_000"] + } } ] } diff --git a/skills/objectstack-automation/references/state-machines-and-approvals.md b/skills/objectstack-automation/references/state-machines-and-approvals.md index eb556381f14..c884d614f56 100644 --- a/skills/objectstack-automation/references/state-machines-and-approvals.md +++ b/skills/objectstack-automation/references/state-machines-and-approvals.md @@ -164,9 +164,7 @@ Three pieces author it: > so the branch cannot run; `flow-approval-revise-target-not-service-owned`), a > `revise` edge whose window never loops back (a dead end `registerFlow` accepts > but that leaves the submitter nowhere to resubmit), and a resubmit edge left -> **without** `type: 'back'`. Resubmit is never a -> record-save. See the `showcase_budget_approval` flow in the showcase app in -> the framework repo for the canonical shape. +> **without** `type: 'back'`. Resubmit is never a record-save. ### Recording a decision @@ -180,8 +178,8 @@ matching branch — you never resume the flow by hand, and you *cannot*: the parked on one (including via a `subflow` pause) and changes nothing. A decision may also carry **structured outputs** (`{ outputs: { … } }` in the -decide body) when the node declares the keys in `decisionOutputs` — the author -declares keys, approvers only fill values. Accepted outputs resume the run as +decide body) when the node declares the keys in `decisionOutputs`. Accepted +outputs resume the run as `.` flow variables, so a LATER node reads them as `vars..` (Dynamic approvers ② below). A decision carrying an undeclared key is rejected; `decision` / `requestId` are reserved. A declaration marked @@ -244,16 +242,14 @@ environment-wide (`ambiguous-in-environment`). An `expression` approver computes WHO approves at the moment the node is entered. Its CEL source sees exactly **three roots** — nothing else: -| Root | Meaning | Analog | -|:-----|:--------|:-------| -| `current.*` | The record's **live** state at node entry — fields written by earlier steps/approvers are visible | ServiceNow `current` | -| `trigger.*` | The **submit-time snapshot** (what flow conditions call `record`) | ServiceNow Flow Designer `trigger.record`, Power Automate `triggerBody()` | -| `vars.*` | Flow variables — node outputs (`vars..`), `get_record` results, `vars.previous` (the pre-update row) | BPMN process variables | +| Root | Meaning | +|:-----|:--------| +| `current.*` | The record's **live** state at node entry — fields written by earlier steps/approvers are visible | +| `trigger.*` | The **submit-time snapshot** (what flow conditions call `record`) | +| `vars.*` | Flow variables — node outputs (`vars..`), `get_record` results, `vars.previous` (the pre-update row) | -**`record` and bare field names are NOT available and fail the node loudly.** -Everywhere else on this platform `record` means "the record at event time" — at an -approval node that phrase is ambiguous between two different times, so you must -say which one: `current.x` or `trigger.x`. +**`record` and bare field names are NOT available and fail the node loudly:** +say which time you mean, `current.x` or `trigger.x`. Result contract: a user-id string, a CSV string, or an array of ids. An **empty** result (present-but-empty field/variable) triggers `onEmptyApprovers`. A @@ -325,7 +321,7 @@ export const DynamicApprovalFlow = defineFlow({ }); ``` -Time-word cheat sheet across surfaces (do not mix them up): +Time-word cheat sheet across surfaces: | Surface | Event-time record | Pre-event record | Live record | |:--------|:------------------|:-----------------|:------------| @@ -347,7 +343,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data** | `onEmptyApprovers` | What an EMPTY resolved slate does: `admin_rescue` (default — request opens on the organization's administrators; never waves through, never kills the run), `fail` (node fails — treat an empty slate as a config bug), `auto_approve` (skip the request, continue down `approve` with `output.autoApproved = true` — opt-in because it silently waves the record through), `fallback` (request opens on the sibling `fallbackApprovers` instead — same shape as `approvers`, required by this policy and refused under any other; a fallback that itself resolves to nobody degrades to `admin_rescue`). Declare it explicitly on any node with an `expression` approver (linted) | | `excludeSubmitter` | `true` drops the run's submitter (`submitter_id`) from the resolved slate, whatever approver type produced them — segregation of duties; a slate it empties takes the `onEmptyApprovers` route, never a silent pass. `onEmptyApprovers: 'auto_approve'` is **refused** beside it (it would approve exactly the request this exists to stop): use `admin_rescue`, `fail` or `fallback`. Default `false` | | `decisionOutputs` | Decision outputs a decision may carry: bare keys (free text) **or typed declarations** `{ key, label?, type: 'text'\|'user'\|'department'\|'position'\|'team', multiple?, required? }`, enforced at the decision — see *Recording a decision* | -| `escalation` | Optional per-node SLA — `{ enabled, timeoutHours, action: reassign\|auto_approve\|auto_reject\|notify, escalateTo?, notifySubmitter }`. `timeoutHours` is **calendar (wall-clock) hours** — nights, weekends and holidays count; the platform ships no business-hours calendar. `escalateTo` is a **position machine name** (expanded to its holders via `sys_user_position`, ADR-0090 D3) or a specific user id — never a membership tier. `reassign` without `escalateTo` degrades to notify (linted) | +| `escalation` | Optional per-node SLA — `{ enabled, timeoutHours, clock, calendar?, action: reassign\|auto_approve\|auto_reject\|notify, escalateTo?, notifySubmitter }`. `clock` sets how `timeoutHours` counts: `'wall_clock'` (default) counts nights, weekends and holidays; `'working_time'` counts working hours on a working calendar (`sys_work_calendar`, maintained per organization in Setup): the `calendar` code, else the organization's default, else refused — never wall-clock. While the calendar cannot count the deadline (none resolves, or not maintained that far) the request does not escalate: its row carries `sla_due_refusal` instead of `sla_due_at`, the inbox shows why, and each sweep retries. `calendar` without `clock: 'working_time'` is lint error `approval-escalation-calendar-without-working-time`. `escalateTo` is a **position machine name** (resolved like a `position` approver) or a specific user id — never a membership tier. `reassign` without `escalateTo` degrades to notify (linted) | | `maxRevisions` | Send-backs per run before auto-reject (ADR-0044) | ### Branching, side-effects & rejection diff --git a/skills/objectstack-data/references/data-hooks.md b/skills/objectstack-data/references/data-hooks.md index 22c88f9b4aa..05beb788cca 100644 --- a/skills/objectstack-data/references/data-hooks.md +++ b/skills/objectstack-data/references/data-hooks.md @@ -347,9 +347,9 @@ The body runs in an isolated QuickJS VM, **not** Node: same wrapper: `job-body-does-not-compile`, from the three commands. A regex pattern the checking engine refuses is a warning: the runtime may accept it. -> **A deadline stamped from an hours table is calendar hours** — nights, weekends and -> holidays count. Name it `*_CALENDAR_HOURS` (`SLA_CALENDAR_HOURS`, or its camelCase) -> and add elapsed milliseconds (`hours * 3_600_000`); never label it "business hours". +> **A deadline stamped from an hours table is wall-clock hours** — nights, weekends and +> holidays count. Name it `*_WALL_CLOCK_HOURS`, add `hours * 3_600_000` ms, never label it +> "business hours"; an approval's `escalation.clock: 'working_time'` counts working hours. ### ⚠️ Gotcha 1 — `ctx.result` is a *partial* record on afterUpdate