Skip to content

Commit 83b5ec5

Browse files
docs(skills): objectstack-automation teaches the emailField recipient, flow requiredPermissions, excludeSubmitter and the screen file field
Four audit rows the package taught nowhere, each in the fewest lines an AI author needs: - `notify.recipients` has a fourth form, `{ emailField }` — an `email`-typed field of the trigger record, for a person who is not a user; the node then names `channels: 'email'` alone. A CEL envelope must yield user ids, and an address no user holds fails the node at run time (the trap SKILL.md's "id, list, or envelope" line set). - flow-level `requiredPermissions` — who may START a flow, checked at every door that starts it by name; not a `current_user.positions` check inside it. - `excludeSubmitter` in the approval config table — segregation of duties; refused beside `onEmptyApprovers: 'auto_approve'`. - the screen field typed `file` — the run resumes with the `sys_file` id, which a later record write claims. Three eval prompts, one per teaching. Paid down first: the CRM Blueprint's approval row that restated the approvals reference, and Best Practices 1 and 4 that restated the Branching section; the measured remainder raises the three token-ratchet rows, quoting the maintainer's ruling. Claude-Session: https://claude.ai/code/session_01JQwxbXsLdroTYaf1DRqVUG Co-authored-by: Claude <noreply@anthropic.com>
1 parent 756220c commit 83b5ec5

4 files changed

Lines changed: 72 additions & 13 deletions

File tree

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,17 @@ export const CEILINGS = new Map([
381381
// row this PR itself lowered by 7,006, and the entry stays 448 lines).
382382
// 5785 -> 5780: A2′ — the release-stamp line left the count (see
383383
// STAMP_LINE_REPIN); the file's count fell by the same 5, headroom unchanged.
384-
['skills/objectstack-automation/SKILL.md', 5780],
384+
// 5780 -> 6004 (card #26298, audit #26184 rows A1/A3/A4): three teachings an
385+
// author had no row for — the fourth `notify` recipient form `{ emailField }`
386+
// (an envelope over an address no user holds now fails the node), flow-level
387+
// `requiredPermissions` (who may START a flow), and the screen field typed
388+
// `file` (the run resumes with the `sys_file` id). Paid down first: the CRM
389+
// Blueprint's approval row restated the approvals reference's config table
390+
// and branching section and was cut to a pointer (~17 tokens). Landed 5771 ->
391+
// 6004: +233 net, 9 absorbed by headroom, ceiling +224. Maintainer ruling
392+
// 2026-10-27 on the skills-lane decision card 「skills 修复卡的教学和 eval 都撞
393+
// token 天花板,怎么付?」, verbatim and untranslated: 「A:先削重复,余额按实测提高」.
394+
['skills/objectstack-automation/SKILL.md', 6004],
385395
// 13783 -> 13892 (2026-08-31 app-repo-principles raise, see the block above).
386396
// The invariant-vs-transition-gate choice, placed in the field-conditional-rule
387397
// bullet list where the tool is actually picked. Both wrong picks are silent:
@@ -650,7 +660,13 @@ export const CEILINGS = new Map([
650660
// `evals/**` stays priced.
651661
['skills/objectstack-ai/evals/skills-tools-knowledge.json', 1074],
652662
['skills/objectstack-api/evals/endpoints-auth-routes.json', 1042],
653-
['skills/objectstack-automation/evals/flows-triggers-approvals.json', 1255],
663+
// 1255 -> 1823 (card #26298): three eval prompts, one per new teaching — the
664+
// applicant email over `{ emailField }`, `requiredPermissions` + `excludeSubmitter`
665+
// on one approval, the screen `file` field written by a later `create_record`.
666+
// +568 tokens, nothing in the file to delete, zero headroom, ceiling +568.
667+
// Same maintainer ruling as the SKILL.md row above (2026-10-27, verbatim and
668+
// untranslated): 「A:先削重复,余额按实测提高」.
669+
['skills/objectstack-automation/evals/flows-triggers-approvals.json', 1823],
654670
['skills/objectstack-data/evals/hooks-security-seeds-datasources.json', 894],
655671
['skills/objectstack-data/evals/objects-fields-relationships.json', 946],
656672
['skills/objectstack-formula/evals/cel-predicates-formulas.json', 1046],
@@ -672,7 +688,14 @@ export const CEILINGS = new Map([
672688
// because a split that arrives with budget is a raise wearing a new path.
673689
// The package deltas are the pointer lines and the four new file titles only.
674690
['skills/objectstack-automation/references/examples-flows.md', 1436],
675-
['skills/objectstack-automation/references/state-machines-and-approvals.md', 5569],
691+
// 5569 -> 5587 (card #26298, audit #26184 row A2): the approval config table
692+
// gains `excludeSubmitter` (refused beside `onEmptyApprovers: 'auto_approve'`),
693+
// +105 tokens. Paid down first: Best Practices 1 and 4 restated the Branching
694+
// section's "Conditional step" and "Roll back on reject" / "Hard reject"
695+
// bullets and were deleted (~73 tokens). Landed 5555 -> 5587: +32 net, 14
696+
// absorbed by headroom, ceiling +18. Same maintainer ruling as the SKILL.md
697+
// row above (2026-10-27, verbatim and untranslated): 「A:先削重复,余额按实测提高」.
698+
['skills/objectstack-automation/references/state-machines-and-approvals.md', 5587],
676699
['skills/objectstack-data/references/examples-objects.md', 1779],
677700
['skills/objectstack-data/references/lint-rules.md', 970],
678701
['skills/objectstack-data/references/seeds.md', 1299],

‎skills/objectstack-automation/SKILL.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Flows are built from **20 built-in node types** (plugins register more via
8888
| `notify` | Send a notification through the messaging service (inbox channel by default) |
8989
| `connector_action` | Invoke a pre-built integration connector |
9090
| `script` | Call a **registered** function named by `config.function` (see *Valid-but-silently-wrong* #3) |
91-
| `screen` | Display a UI form to the user (screen flows only) |
91+
| `screen` | Display a UI form to the user (screen flows only). `config.fields[]`: `{ name, label, type, required, options, defaultValue }`, `type` an open widget hint; `'file'` renders the upload widget and resumes with the `sys_file` id bound to `name` — a later `create_record` / `update_record` writes it into a `file` field, which claims the file: collect first, write after the last screen |
9292

9393
#### Human Decision
9494

@@ -104,7 +104,9 @@ undeclared key is a named parse error. **RAW** keys are read as written: a
104104

105105
```ts
106106
{ id: 'tell_owner', type: 'notify', label: 'Notify Owner', config: {
107-
recipients: { dialect: 'cel', source: 'record.assignee' }, // REQUIRED — id, list, or envelope; a CSV is ONE id
107+
recipients: { dialect: 'cel', source: 'record.assignee' }, // REQUIRED — id, list, or envelope; a CSV is ONE id.
108+
// 4th form `{ emailField: 'applicant_email' }`: an `email` field of the trigger record, for a non-user —
109+
// then `channels: 'email'` alone. An envelope must yield USER ids: an address no user holds fails the node
108110
title: 'Done: {{ record.title }}', // inline; XOR `template` (RAW, localizable)
109111
message: 'Closed {{ record.closed_at | date:long }}', // body; only with inline `title`
110112
topic: 'task', // RAW; default 'notify'
@@ -182,6 +184,13 @@ variables: [
182184
> organization predicate reads and writes across every tenant. The tenant column
183185
> is platform-injected — filter on it, never re-declare it per object.
184186
187+
> **Who may START a flow: `requiredPermissions: ['…']` on the flow** (ADR-0066
188+
> D4) — every door that starts it by name (trigger route, action of type `flow`,
189+
> declared endpoint) refuses a non-system caller missing any named capability
190+
> with `403 PERMISSION_DENIED`; an action starting it inherits the list, a
191+
> `subflow` node is not a door. Gate an elevated `screen` / `api` flow here, never
192+
> on `current_user.positions` inside it.
193+
185194
> **A hook elevates itself with `runAs`, never with `sudo`.** An object hook
186195
> (objectstack-data) declares its own `runAs: 'system' | 'user' | 'inherit'` —
187196
> default `'inherit'`, the context of the write that fired it — scoping that
@@ -399,7 +408,7 @@ in this CRM-style structure:
399408
| Automation Type | Typical Location | Pattern |
400409
|:--|:--|:--|
401410
| Screen flow | `src/flows/*.flow.ts` | Use explicit `variables`, node graph (`nodes` + `edges`), and decision branches |
402-
| Approval flow | `src/flows/*.flow.ts` | A flow with `approval` node(s); set `approvers` / `behavior` / `lockRecord` / `approvalStatusField` in node `config`, branch on `approve` / `reject` edges |
411+
| Approval flow | `src/flows/*.flow.ts` | A flow with `approval` node(s) — config and branching in the approvals reference |
403412
| Flow registry | `src/flows/index.ts` | Export `allFlows: Flow[]` and register centrally in `defineStack({ flows })` |
404413

405414
---

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@
5050
"must_contain": ["function:", "outputVariable", "type: 'fault'", "timeoutMs", "update_record", "dialect: 'cel'"],
5151
"must_not_contain": ["label: 'error'", "query_record", "{recalc"]
5252
}
53+
},
54+
{
55+
"id": 6,
56+
"prompt": "When a `job_application` is approved, email the applicant. Applicants are not users; the address is in the record's `applicant_email` field.",
57+
"expected_output": "`notify` with `recipients: { emailField: 'applicant_email' }` (the fourth recipient form: an `email`-typed field of the trigger record) and `channels: 'email'` alone — never a CEL envelope over `record.applicant_email`, which must yield user ids and fails the node for an address no user holds.",
58+
"files": [],
59+
"assertions": {
60+
"must_contain": ["notify", "emailField", "applicant_email", "'email'"],
61+
"must_not_contain": ["source: 'record.applicant_email'", "channels: ['inbox']"]
62+
}
63+
},
64+
{
65+
"id": 7,
66+
"prompt": "An expense approval only holders of the `expense.approve_request` capability may start; route to the `finance_manager` position, and the submitter must never approve their own expense.",
67+
"expected_output": "Flow-level `requiredPermissions: ['expense.approve_request']` (checked at every door that starts the flow, not a `current_user.positions` check inside it); the `approval` node sets `excludeSubmitter: true`, and its `onEmptyApprovers` is anything but `auto_approve`, which is refused beside it.",
68+
"files": [],
69+
"assertions": {
70+
"must_contain": ["requiredPermissions", "excludeSubmitter: true", "type: 'position'"],
71+
"must_not_contain": ["onEmptyApprovers: 'auto_approve'", "current_user.positions"]
72+
}
73+
},
74+
{
75+
"id": 8,
76+
"prompt": "A screen flow: the user uploads the signed contract PDF on the last step, then the flow creates the `contract` record with the file in its `signed_copy` field.",
77+
"expected_output": "A `screen` field `{ name: 'signed_copy', type: 'file', required: true }`; the screen resumes with the uploaded `sys_file` id bound to `signed_copy`, and a `create_record` after the last screen writes `fields: { signed_copy: { dialect: 'cel', source: 'signed_copy' } }`, which claims the file for the record.",
78+
"files": [],
79+
"assertions": {
80+
"must_contain": ["type: 'screen'", "type: 'file'", "create_record", "signed_copy"],
81+
"must_not_contain": ["type: 'upload'", "type: 'attachment'"]
82+
}
5383
}
5484
]
5585
}

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data**
347347
| `lockRecord` | Lock the triggering record from edits while pending. Default `true` |
348348
| `approvalStatusField` | Business-object field to mirror `pending`/`approved`/`rejected`/`recalled` onto (should be readonly) |
349349
| `onEmptyApprovers` | What an EMPTY resolved slate does: `admin_rescue` (default — request opens, only a privileged admin can act via Reassign; 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) |
350+
| `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` |
350351
| `decisionOutputs` | Decision outputs a decision may carry (author declares, approvers fill values). Entries are bare keys (free-text input) **or typed declarations** `{ key, label?, type: 'text'\|'user'\|'department'\|'position'\|'team', multiple?, required? }` — a typed entry renders the matching record picker in the decision dialog (`multiple` collects an id array). Accepted outputs resume the run as `<nodeId>.<key>` variables; undeclared keys reject the decision; `decision`/`requestId` reserved |
351352
| `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) |
352353
| `maxRevisions` | ADR-0044 — max **send-backs-for-revision** per run before auto-reject. Default `3`; `0` disables send-back. Only meaningful when the node has a `revise` out-edge |
@@ -369,15 +370,11 @@ These are wired on the **graph**, not in node config:
369370

370371
### Approval Best Practices
371372

372-
1. **Gate entry on the edge** (`condition` into the Approval node) so the flow
373-
only pauses for records that actually need sign-off.
374-
2. **Set `approvalStatusField`** to mirror status onto the row — views and
373+
1. **Set `approvalStatusField`** to mirror status onto the row — views and
375374
formulas can then filter on it without joining `sys_approval_request`.
376-
3. **Keep `lockRecord: true`** unless you have a strong reason to allow
375+
2. **Keep `lockRecord: true`** unless you have a strong reason to allow
377376
edits while pending — otherwise approvers chase a moving target.
378-
4. **Model rejection as a visible branch** — a back-edge to revise, or an `end`
379-
node to terminate. The path is on the diagram, not hidden in config.
380-
5. **Notify the submitter from downstream nodes** wired to the `approve` /
377+
3. **Notify the submitter from downstream nodes** wired to the `approve` /
381378
`reject` edges. Opening already tells each resolved approver
382379
(`approval.requested`); ⛔ no `notify` node for the opening: it tells
383380
them twice.

0 commit comments

Comments
 (0)