Skip to content

Commit 61f2a99

Browse files
docs(skills): teach the mail option formatter for a notice's select label and the active-member rule for a user target
The automation skill's notify section says an option label in a notice is written in the mail template as the option formatter, which prints each recipient's language, never label() in templateData (evaluated once per run, before fan-out); its assignment-rules section says a user target holds the row only while an active member of its organization. Eval 15 grades the notice case. The queues-and-assignment-rules docs page gains the organization-authored sys_assignment_rule rules beside the declared ones: evaluated first, by sort_order then name, first match wins, a failed read routes nothing, and the active-member rule. Paid inside SKILL.md by deleting the CRM Automation Blueprint section and two restatements; the token ceiling re-locked at the measurement. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxujehvWJcGRXMYv7f
1 parent 677d542 commit 61f2a99

5 files changed

Lines changed: 51 additions & 14 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the automation skill teaches the mail `option` formatter for a notice's select label, and that a user target owns a row only while an active member
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Two lines in `objectstack-automation/SKILL.md`, each following a platform change that landed before it. In the `notify` section: an option label in a notice is written in the mail `template` as `{{ stage | option:opportunity.stage }}`, which prints the label in each recipient's language and is mail-only (refused in an inline `title` / `message`) — never `label()` in `templateData`, which is evaluated once per run, before recipients fan out. In "Assignment rules": `assignTo: { type: 'user', value: '<id>' }` names an owner who holds the row only while an active member of its organization, else the row is written ownerless. Eval 15 of `evals/flows-triggers-approvals.json` grades the notice case. The docs page `automation/queues-and-assignment-rules` gains the organization-authored `sys_assignment_rule` rules beside the declared ones: evaluated first, by `sort_order` then name, first match wins, a failed read of the organization's rules routes nothing, and the active-member rule for a `user` target. Paid inside the skill by deleting the CRM Automation Blueprint section (the `src/flows` layout objectstack-platform's bootstrap reference carries) and two restatements.

‎content/docs/automation/queues-and-assignment-rules.mdx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export default defineStack({
9393

9494
The rule writes `owner_id` (when it chose a member) and `queue` (for a queue target), nothing else. The row's audit columns still record who inserted it; the owner the rule chose is ownership, not attribution.
9595

96+
**A `user` target owns the row only while an active member.** `assignTo: { type: 'user', value: '<id>' }` is honoured when that user has a `sys_member` row in the record's organization and no ban in force — asked again at every insert, not only when the rule was written. A target who has left or is banned when a row arrives leaves it ownerless (`queue` unset), logged once at `warn`; the insert is never refused. Point the rule at a current member, or at a queue.
97+
98+
An organization authors its own assignment rules too. A `sys_assignment_rule` record (Setup → Assignment Rules, for holders of `manage_platform_settings`) is one rule with one entry: `object_name`, an optional `criteria`, `recipient_type` (`queue` or `user`) with `recipient_id`, and for a queue target an optional `strategy` with its `load`; `active: false` switches it off without deleting it. Like `sys_queue`, it shares **one namespace, by name** with the declared rules: a record may not take a declared rule's name, and one found under that name is not evaluated — the declared rule answers for it, logged once. Unlike a `sys_queue` record, which resolves after the declared queues, **the organization's rules are evaluated first** — ascending by `sort_order`, then by `name` — and the stack's `assignmentRules`, in registry order, are the fallback, so an organization routes ahead of an installed app's rule, which it cannot switch off for itself alone (the activation ledger has no organization column). The first match across both sources wins. When the organization's rules cannot be read, its new rows are written as they stood and routed by **no** rule — not by the declared fallback its own rules would have overtaken — logged at `warn`.
99+
100+
The record is validated on save, one `VALIDATION_FAILED` naming every field at fault: a `name` that is not snake_case or that a declared rule holds; an `object_name` that is not registered or carries no `queue` column; the shape a declared entry refuses (a `strategy` on a user target, `least_loaded` without `load`); a `criteria` or `load` the engine cannot compile; a `user` target who is not an active member of the organization. A later patch of only the label, description, order or active flag is not re-judged, so a rule whose target has lapsed can still be switched off or renamed.
101+
96102
### 3. `load` is required with `least_loaded`
97103

98104
`least_loaded` counts each member's **open** rows of the object, and only you know what "open" means for it — `status != "closed"` for cases, `is_converted == false` for leads. So `load` is **required** with `least_loaded` and has no default: a default such as "every row" would count closed work and quietly make the busiest historical owner look the most loaded. `load` on any other strategy is refused, because nothing reads it.
@@ -153,6 +159,7 @@ A queue routes **records** to people. It is not an address for **messages**: a f
153159
- The object is `ownership: 'user'`, and declares no field of its own named `queue`.
154160
- The stack loads `@objectstack/plugin-sharing`; otherwise `queues` / `assignmentRules` refuse the boot.
155161
- A declared queue's members are positions; organizations add users, teams and units through `sys_queue_member`.
162+
- An organization's own `sys_assignment_rule` records are tried before the stack's rules, lowest `sort_order` first; a `user` target is an active member of the organization.
156163
- Every `least_loaded` entry has a `load` your filter compiler can lower; no other entry has one.
157164
- Code that claims a record sends `{ owner_id: <self> }` by id and handles `409` as "someone else took it".
158165
- Alerts about new work address a team or a position, not the queue.

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,14 @@ export const CEILINGS = new Map([
490490
// request signing, which the built-in providers serve (recipe 6 and the
491491
// `signed` kind in references/integration-recipes.md). Re-locked AT the
492492
// measurement, headroom 0 tokens.
493-
['skills/objectstack-automation/SKILL.md', 6449],
493+
// 6449 -> 6448 (cards #30731 + #30826): the notify section's option-label
494+
// line and the user-target active-member clause, paid by deleting the CRM
495+
// Automation Blueprint section (the `src/flows` layout lives in
496+
// objectstack-platform's bootstrap reference), the "When to Use" restatement
497+
// of the assignment-rules heading and the scaffolded-project validate line
498+
// (objectstack-formula's Verify section). Re-locked AT the measurement,
499+
// headroom 0 tokens.
500+
['skills/objectstack-automation/SKILL.md', 6448],
494501
// 13783 -> 13892 (2026-08-31 app-repo-principles raise, see the block above).
495502
// The invariant-vs-transition-gate choice, placed in the field-conditional-rule
496503
// bullet list where the tool is actually picked. Both wrong picks are silent:

‎skills/objectstack-automation/SKILL.md‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ metadata:
2323
## When to Use This Skill
2424

2525
Flows (auto-launched, screen, scheduled), state machines and approvals,
26-
record-change triggers, scheduled automation, vendor integrations and their
27-
callbacks, and **assignment rules** that route a new record to a queue or a person.
26+
record-change triggers, vendor integrations and their callbacks, and
27+
**assignment rules**.
2828

2929
> **Predicates and conditions are CEL** — every `condition` / `guard` /
3030
> `entryCondition` / filter `value` is an **Expression** envelope: a plain CEL
@@ -127,6 +127,11 @@ error. **RAW** keys are read as written: a
127127
} }
128128
```
129129

130+
An option label in a notice: `{{ stage | option:opportunity.stage }}` in the mail
131+
`template` (each recipient's language; mail-only, refused in inline `title` /
132+
`message`) — never `label()` in `templateData`, evaluated once per run, before
133+
fan-out.
134+
130135
### Flow Variables
131136

132137
`variables` is an **array** of `{ name, type, isInput, isOutput }` entries —
@@ -315,7 +320,8 @@ export const caseIntake = defineAssignmentRule({
315320
```
316321

317322
`strategy` is for a queue target only; `assignTo: { type: 'user', value: '<id>' }`
318-
names one owner. Queues are declared in `queues` (objectstack-data); an approval
323+
names one owner, who holds the row only while an active member of its organization
324+
(else ownerless). Queues are declared in `queues` (objectstack-data); an approval
319325
for the same people is `approvers: [{ type: 'queue', value: 'support_intake' }]`
320326
([Approver Types](./references/state-machines-and-approvals.md#approver-types)).
321327
⛔ Never a `beforeInsert` hook that picks an owner, nor a round-robin counter field.
@@ -421,14 +427,6 @@ reason to write code.
421427

422428
---
423429

424-
## CRM Automation Blueprint
425-
426-
Lifecycle first, as Flow / Approval metadata: `src/flows/*.flow.ts` with explicit
427-
`variables`, `nodes` + `edges`, exported from `src/flows/index.ts` into
428-
`defineStack({ flows })`.
429-
430-
---
431-
432430
## Verify your work
433431

434432
A bare ref (`status == 'open'`) resolves (fields are flattened into scope), so
@@ -440,8 +438,6 @@ os validate # CEL/predicate validation + schema
440438
# or: os build # the same gates, plus emits dist/
441439
```
442440

443-
In a scaffolded project: `npm run validate`.
444-
445441
---
446442

447443
## References

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,23 @@
260260
"actionUrl:"
261261
]
262262
}
263+
},
264+
{
265+
"id": 15,
266+
"prompt": "Email the opportunity owner and the sales manager when an opportunity has sat in one stage for 30 days; the subject must show the `stage` as its label, in each recipient's own language.",
267+
"expected_output": "The notify node names a mail `template` (never inline `title` / `message`, which are one text for every recipient), and the template's subject prints the stage with the mail formatter `{{ stage | option:opportunity.stage }}` — the argument a bare `object.field`, no quotes — so the renderer prints that recipient's label from the field's option list in the recipient's locale. Not `label()` in `templateData`: the map is evaluated once per run, before recipients fan out, so it cannot differ per recipient; and `option` is mail-only, refused in an inline `title` / `message`. The stage value itself reaches the template as stored (`stage` in `templateData`).",
268+
"files": [],
269+
"assertions": {
270+
"must_contain": [
271+
"option:opportunity.stage",
272+
"template",
273+
"once per run"
274+
],
275+
"must_not_contain": [
276+
"source: 'label(",
277+
"| label"
278+
]
279+
}
263280
}
264281
]
265282
}

0 commit comments

Comments
 (0)