Skip to content

Commit e606eff

Browse files
docs(skills): teach the approval escalation clock (escalation.clock, escalation.calendar) (#35963)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D4n2wzAmmp4Z6W5jsqtM2qx)_ Fixes #35931 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用 AI 写审批流程的作者,现在会被教到「审批超时可以按工作日历只算工作时间」,而不是旧的「平台没有工作日历」。 - 为什么做:属于「工作日历」这条线;超时按工作时间计算的功能已经上线,随包发布的技能文档还在教相反的说法。 - 出错会怎样:只改文档和一条评测用例,不改运行行为;写错了的后果是 AI 给出错误的配置建议,可直接撤回本次合并。 - 要你做什么:无(另有一处「平台目录仍写工作日历未提供」的遗留,见验收说明,需另行安排)。 ## What changes - `skills/objectstack-automation/references/state-machines-and-approvals.md`, the `escalation` row of the node-config table, rewritten in place from the merged contract (`ApprovalEscalationSchema` in `packages/spec/src/automation/approval.zod.ts`, `slaDeadline` in `packages/plugins/plugin-approvals/src/approval-service.ts`, the lint in `packages/lint/src/validate-approval-approvers.ts`, the inbox label in `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx`). It now states: - both clocks and the default: `clock: 'wall_clock'` (default) counts nights, weekends and holidays; `'working_time'` counts `timeoutHours` as working hours on a working calendar (`sys_work_calendar`, maintained per organization in Setup); - the resolution order: the `calendar` code, else the organization's default, else refused, never wall-clock; - the cannot-answer hold: the request does not escalate, its row carries `sla_due_refusal` instead of `sla_due_at`, the inbox shows why, and each sweep retries; - the lint rule: `calendar` without `clock: 'working_time'` is the error `approval-escalation-calendar-without-working-time`. - The sentence "the platform ships no business-hours calendar" is gone. - Paid for inside the same file's ceiling by deletions (the ceiling row is untouched): the "Analog" column of the expression-roots table (other vendors' names for the three roots), the rationale sentence after "`record` and bare field names are NOT available" (the fix, `current.x` or `trigger.x`, stays), the pointer to a showcase flow in the framework repo (an installed app has no such repo), "the author declares keys, approvers only fill values" (the next sentences state the refusal of an undeclared key), "(do not mix them up)", and the `sys_user_position` parenthetical on `escalateTo`, which the Approver Types table's `position` row already carries. - `skills/objectstack-data/references/data-hooks.md`: the note on a hook-stamped deadline says "wall-clock hours" instead of "calendar hours", names the constant `*_WALL_CLOCK_HOURS`, and points at `escalation.clock: 'working_time'` for an approval deadline. Same line count. - `.changeset/35931-escalation-clock-skill.md`: `'@objectstack/skills': patch`. ## Evals One case added, id 25 in `skills/objectstack-automation/evals/flows-triggers-approvals.json`: an approval step that must hand over after 8 business hours on the calendar `cn_plant`. It requires `clock: 'working_time'` and `calendar: 'cn_plant'` and refuses a hand-rolled `3_600_000` deadline. The old row would have answered that the platform has no working calendar, so the case separates the two texts. `skills/objectstack-project/evals/project-process.json` case 8 is unchanged; see Acceptance notes. ## Verification Head `d34c403632`. Read first: the `escalation` row (the one hunk that teaches new behaviour), then the five deletions in the same file. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints `state-machines-and-approvals.md is 5932 tokens (ceiling 5936; headroom 4)` and `data-hooks.md is 10120 tokens (ceiling 10122; headroom 2)` and exits 0. Readings, before to after: | File | Lines | Bytes | Tokens / ceiling | |:--|:--|:--|:--| | `state-machines-and-approvals.md` | 389 to 385 | 23710 to 23726 | 5928 to 5932 / 5936 | | `data-hooks.md` | 884 to 884 | 40467 to 40478 | 10117 to 10120 / 10122 | | `flows-triggers-approvals.json` (eval, not ratcheted) | 440 to 450 | 26920 to 28309 | 6730 to 7078 | Whole catalog: authored 197404 to 197411 tokens (ceiling sum 202541 unchanged), shipped tree 288105 to 288460 tokens, of which 348 are the eval fixture; the sum of all `SKILL.md` files is 4944 lines before and after. Net added lines for the PR, changeset included: 33 added, 19 deleted, net 14 (budget 25). Gates on this head, local: the `dispatch-gates --commands` list derived 49 commands; 45 exited 0, among them `check-skills-token-ratchet` and its self-test, `check:skill-refs`, `check:skill-served-sections`, `check:skill-identifier-liveness`, `check:skill-links`, `check:skill-compatibility`, `check:doc-authoring`, `check:nul-bytes`, `check-empty-changeset`, `check-adr-0087-registration` and `check:doc-formula-expressions` (after building its closure under the verify lock, `VERDICT command-exit 0`). NOT MEASURED: `check:dts-closure`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`, `check:sourcemap-no-sources-content`; each exited 3 asking for a full build, each reads built package output, and this diff changes no package, so they are left to CI. `overlap-check`: `VERDICT clean exit 0`. ## Acceptance notes - **The project eval and the platform catalog are left as they are, and the catalog is now stale.** `skills/objectstack-project/references/platform-catalog.md` still lists working calendars under "Planned: carded, not shipped" as "not available", and project eval case 8 expects exactly that answer. The page is generated from `PLANNED_ROWS` in `packages/spec/scripts/lib/platform-catalog.ts`; `sys_work_calendar` and `sys_work_calendar_exception` are in the platform object registry and in Setup, and the approval clock reads them, but no catalog row names them. Changing the eval alone would make it contradict the page it is graded against, and moving the row is a generator edit with its own test and byte ceiling, which this card's diff does not carry. The three formula functions ADR-0157 D4 names are not in the formula stdlib on this head, so what the eval's "make the SLA formula read them" should now expect is not settled by what merged. Reported to the seat as a finding. - **`data-hooks.md` renames the advised constant** from `*_CALENDAR_HOURS` to `*_WALL_CLOCK_HOURS`. The arithmetic the note teaches is unchanged and still true. The old name is the one the merged spec declined as a clock value because, with a working calendar in the platform, "calendar hours" reads as hours on that calendar. An app that followed the earlier advice has a constant whose name is now ambiguous; nothing refuses it. - The row names `sla_due_refusal` and `sla_due_at` as fields of the request row; the three refusal codes are not listed, to stay inside the ceiling. - No ablation or reverse verification: the diff changes prose, one eval fixture and a changeset, no tested behaviour. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0a3dd40 commit e606eff

4 files changed

Lines changed: 33 additions & 19 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
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.

‎skills/objectstack-automation/evals/flows-triggers-approvals.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,16 @@
435435
"isActive"
436436
]
437437
}
438+
},
439+
{
440+
"id": 25,
441+
"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?",
442+
"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`).",
443+
"files": [],
444+
"assertions": {
445+
"must_contain": ["clock: 'working_time'", "calendar: 'cn_plant'"],
446+
"must_not_contain": ["3_600_000"]
447+
}
438448
}
439449
]
440450
}

‎skills/objectstack-automation/references/state-machines-and-approvals.md‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ Three pieces author it:
164164
> so the branch cannot run; `flow-approval-revise-target-not-service-owned`), a
165165
> `revise` edge whose window never loops back (a dead end `registerFlow` accepts
166166
> but that leaves the submitter nowhere to resubmit), and a resubmit edge left
167-
> **without** `type: 'back'`. Resubmit is never a
168-
> record-save. See the `showcase_budget_approval` flow in the showcase app in
169-
> the framework repo for the canonical shape.
167+
> **without** `type: 'back'`. Resubmit is never a record-save.
170168
171169
### Recording a decision
172170

@@ -180,8 +178,8 @@ matching branch — you never resume the flow by hand, and you *cannot*: the
180178
parked on one (including via a `subflow` pause) and changes nothing.
181179

182180
A decision may also carry **structured outputs** (`{ outputs: { … } }` in the
183-
decide body) when the node declares the keys in `decisionOutputs` — the author
184-
declares keys, approvers only fill values. Accepted outputs resume the run as
181+
decide body) when the node declares the keys in `decisionOutputs`. Accepted
182+
outputs resume the run as
185183
`<nodeId>.<key>` flow variables, so a LATER node reads them as
186184
`vars.<nodeId>.<key>` (Dynamic approvers ② below). A decision carrying an
187185
undeclared key is rejected; `decision` / `requestId` are reserved. A declaration marked
@@ -244,16 +242,14 @@ environment-wide (`ambiguous-in-environment`).
244242
An `expression` approver computes WHO approves at the moment the node is
245243
entered. Its CEL source sees exactly **three roots** — nothing else:
246244

247-
| Root | Meaning | Analog |
248-
|:-----|:--------|:-------|
249-
| `current.*` | The record's **live** state at node entry — fields written by earlier steps/approvers are visible | ServiceNow `current` |
250-
| `trigger.*` | The **submit-time snapshot** (what flow conditions call `record`) | ServiceNow Flow Designer `trigger.record`, Power Automate `triggerBody()` |
251-
| `vars.*` | Flow variables — node outputs (`vars.<nodeId>.<key>`), `get_record` results, `vars.previous` (the pre-update row) | BPMN process variables |
245+
| Root | Meaning |
246+
|:-----|:--------|
247+
| `current.*` | The record's **live** state at node entry — fields written by earlier steps/approvers are visible |
248+
| `trigger.*` | The **submit-time snapshot** (what flow conditions call `record`) |
249+
| `vars.*` | Flow variables — node outputs (`vars.<nodeId>.<key>`), `get_record` results, `vars.previous` (the pre-update row) |
252250

253-
**`record` and bare field names are NOT available and fail the node loudly.**
254-
Everywhere else on this platform `record` means "the record at event time" — at an
255-
approval node that phrase is ambiguous between two different times, so you must
256-
say which one: `current.x` or `trigger.x`.
251+
**`record` and bare field names are NOT available and fail the node loudly:**
252+
say which time you mean, `current.x` or `trigger.x`.
257253

258254
Result contract: a user-id string, a CSV string, or an array of ids. An **empty**
259255
result (present-but-empty field/variable) triggers `onEmptyApprovers`. A
@@ -325,7 +321,7 @@ export const DynamicApprovalFlow = defineFlow({
325321
});
326322
```
327323

328-
Time-word cheat sheet across surfaces (do not mix them up):
324+
Time-word cheat sheet across surfaces:
329325

330326
| Surface | Event-time record | Pre-event record | Live record |
331327
|:--------|:------------------|:-----------------|:------------|
@@ -347,7 +343,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data**
347343
| `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) |
348344
| `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` |
349345
| `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* |
350-
| `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) |
346+
| `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) |
351347
| `maxRevisions` | Send-backs per run before auto-reject (ADR-0044) |
352348

353349
### Branching, side-effects & rejection

‎skills/objectstack-data/references/data-hooks.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ The body runs in an isolated QuickJS VM, **not** Node:
347347
same wrapper: `job-body-does-not-compile`, from the three commands. A regex
348348
pattern the checking engine refuses is a warning: the runtime may accept it.
349349

350-
> **A deadline stamped from an hours table is calendar hours** — nights, weekends and
351-
> holidays count. Name it `*_CALENDAR_HOURS` (`SLA_CALENDAR_HOURS`, or its camelCase)
352-
> and add elapsed milliseconds (`hours * 3_600_000`); never label it "business hours".
350+
> **A deadline stamped from an hours table is wall-clock hours** — nights, weekends and
351+
> holidays count. Name it `*_WALL_CLOCK_HOURS`, add `hours * 3_600_000` ms, never label it
352+
> "business hours"; an approval's `escalation.clock: 'working_time'` counts working hours.
353353
354354
### ⚠️ Gotcha 1 — `ctx.result` is a *partial* record on afterUpdate
355355

0 commit comments

Comments
 (0)