Skip to content

Commit ecb737a

Browse files
committed
docs(automation): the notify click-through default names the before-create run that has no record id yet
Four texts said a run started by a record change other than a delete links its notification to that record. A before-create run is such a change and has no record id until the driver issues one at the write, after the hook, so the notification links nowhere unless the caller wrote the id. The spec describes and docblock, the notify node's docblock, descriptions and null failure text, the Flows guide and the automation skill's example now say so, and two pins hold the before-create cases. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibwUogojquWFFVyz422
1 parent 6ff27b3 commit ecb737a

6 files changed

Lines changed: 74 additions & 20 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/service-automation': patch
4+
'@objectstack/skills': patch
5+
---
6+
7+
docs(automation): the notify click-through default says a before-create run links to its record only when the caller wrote the id
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
A `notify` node that writes none of `sourceObject`, `sourceId` and `actionUrl` links to the run's trigger record when the run has one. Four texts enumerated that run as "a record change other than a delete", which includes a before-create run (`record-before-create`, or the insert leg of `record-before-write`). On that run the record is the write's input, and the driver issues the id at the write, after the hook, so the input carries an id only when the caller wrote one; with no id the notification links nowhere. The runtime is unchanged. The texts now say "a record change other than a delete or a before-create", and that a before-create run links only when the caller wrote the id:
13+
14+
- the `NotifyConfigSchema` docblock and the `sourceObject` / `sourceId` descriptions in `@objectstack/spec`, and the reference page generated from them;
15+
- the `notify` node's docblock and config descriptions in `@objectstack/service-automation`, which is the wording source;
16+
- the Flows guide and the automation skill's `notify` example.
17+
18+
The same texts said that a `sourceId` evaluating to `null` "leaves the key unset". It is a written key: the node then writes a half pair, which is dropped rather than defaulted to the trigger record. The node's failure text, the guide and the schema say so.
19+
20+
A test pins that a notify on a `beforeInsert` run whose record carries no id writes no `source_object` / `source_id`, and that one whose caller wrote the id links to it. No key, shape, default or refinement changes.

‎content/docs/automation/flows.mdx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,17 @@ nothing. The template handed a whole token holding a list, written as a list
348348
entry (`['{owners}']`), on as **one** recipient joined with commas (`'u1,u2'`),
349349
which reached nobody. Guard a recipient field that may be unset —
350350
`has(record.assignee) ? record.assignee : null` — so it is dropped rather than
351-
failing the run. `sourceId` takes a string or an envelope evaluating to one:
352-
`null` leaves the key unset. A node that writes none of `sourceObject`,
353-
`sourceId` and `actionUrl` links to the run's trigger record when it has one —
354-
a record change other than a delete, a time-relative sweep's row, an action
351+
failing the run. `sourceId` takes a string or an envelope evaluating to one;
352+
`null` is a written `sourceId` that resolves to nothing, so the pair is dropped,
353+
not defaulted. A node that writes none of `sourceObject`, `sourceId` and
354+
`actionUrl` links to the run's trigger record when it has one — a record change
355+
other than a delete or a before-create, a time-relative sweep's row, an action
355356
started on a record — so a record-triggered `notify` opens its record without a
356357
pair. An explicit pair or `actionUrl` wins; a half-specified pair is dropped,
357358
never defaulted; a run with no trigger record (a schedule tick, an inbound API
358-
post, a manual start with no record) links nowhere.
359+
post, a manual start with no record) links nowhere. A before-create run's record
360+
has no id until the driver issues one at the write, after the hook, so it links
361+
only when the caller wrote the id.
359362
The node's `sourceObject`, `actorId` and `payload` are
360363
**literals**, read as written: no flow computed one, so nothing is evaluated
361364
there — write the value itself (`sourceObject: 'crm_case'`). A `{…}` token

‎packages/services/service-automation/src/builtin/notify-node.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,29 @@ describe('notify click-through defaults to the trigger record', () => {
475475

476476
expect(messaging.emitted[0].source).toBeUndefined();
477477
});
478+
479+
// A before-create run's record is the write's input: the driver issues the
480+
// id at the write, after the hook, so the input carries one only when the
481+
// caller wrote it. With no id there is no trigger record to link.
482+
it('writes no source on a before-create run whose record has no id yet', async () => {
483+
engine.registerFlow('notify_flow', notifyFlow({ recipients: ['user_1'], title: 'Ticket incoming' }));
484+
485+
const result = await engine.execute(
486+
'notify_flow',
487+
{ record: { name: 'Pump' }, object: 'repair_ticket', event: 'beforeInsert' } as any,
488+
);
489+
490+
expect(result.success).toBe(true);
491+
expect(messaging.emitted).toHaveLength(1);
492+
expect(messaging.emitted[0].source).toBeUndefined();
493+
expect(messaging.emitted[0].payload.url).toBeUndefined();
494+
});
495+
496+
it('links a before-create run whose caller wrote the id', async () => {
497+
engine.registerFlow('notify_flow', notifyFlow({ recipients: ['user_1'], title: 'Ticket incoming' }));
498+
499+
await engine.execute('notify_flow', recordRun('beforeInsert'));
500+
501+
expect(messaging.emitted[0].source).toEqual({ object: 'repair_ticket', id: 't_7' });
502+
});
478503
});

‎packages/services/service-automation/src/builtin/notify-node.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,14 @@ const DELETE_EVENTS: ReadonlySet<string> = new Set(['beforeDelete', 'afterDelete
171171
* explicit `actionUrl`, and a half-written pair (still dropped, as before) are
172172
* the author's word and are kept as written.
173173
*
174-
* Only when the run has a trigger record (`triggerRecordOf`): a record-change
175-
* run, a time-relative sweep's row, an action started on a record. A schedule
176-
* tick, an inbound API post and a manual start with no record have none and
177-
* link nowhere, as before. A delete event's record is gone once the write
178-
* lands, so it is not linked: the inbox never renders a dead link.
174+
* Only when the run has a trigger record (`triggerRecordOf`): a record change
175+
* other than a delete or a before-create, a time-relative sweep's row, an
176+
* action started on a record. A schedule tick, an inbound API post and a
177+
* manual start with no record have none and link nowhere, as before. A delete
178+
* event's record is gone once the write lands, so it is not linked: the inbox
179+
* never renders a dead link. A before-create run's record is the write's
180+
* input, which carries an id only when the caller wrote one — the driver
181+
* issues the id at the write, after the hook — so it links only then.
179182
*/
180183
function defaultClickThroughOf(
181184
cfg: Pick<NotifyConfigParsed, 'sourceObject' | 'sourceId' | 'actionUrl'>,
@@ -706,7 +709,7 @@ function resolveStringSlot(
706709
ok: false,
707710
error:
708711
`notify: ${key} evaluated to ${evaluatedKindOf(evaluated)}, not a string — write a value expression that `
709-
+ 'evaluates to the record id, or to `null` to leave it unset — source: '
712+
+ 'evaluates to the record id, or to `null`, a written sourceId that resolves to nothing, so the pair is dropped rather than defaulted — source: '
710713
+ `\`${sourceOf(raw)}\``,
711714
};
712715
}
@@ -882,11 +885,11 @@ export function registerNotifyNode(engine: AutomationEngine, ctx: PluginContext)
882885
// literals, read as written.
883886
sourceObject: {
884887
type: 'string',
885-
description: 'Object name of the record the notification links to (writes sys_notification.source_object) — read as written: a single-brace {token} is not resolved here and is refused, as is a CEL value envelope; write the value. Only takes effect together with sourceId — a half-specified click-through target is dropped at execute time, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete, a time-relative sweep, an action on a record) links to that record.',
888+
description: 'Object name of the record the notification links to (writes sys_notification.source_object) — read as written: a single-brace {token} is not resolved here and is refused, as is a CEL value envelope; write the value. Only takes effect together with sourceId — a half-specified click-through target is dropped at execute time, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete or a before-create, a time-relative sweep, an action on a record) links to that record; a before-create run\'s record has no id until the driver issues one at the write, so it links only when the caller wrote the id.',
886889
},
887890
sourceId: {
888891
type: 'string',
889-
description: 'Record id the notification links to (writes sys_notification.source_id) — a string, or a CEL value envelope evaluated per run to one, such as { dialect: \'cel\', source: \'record.id\' }; a single-brace {token} is refused. Only takes effect together with sourceObject — a half-specified click-through target is dropped at execute time, so the inbox never renders a dead link. The inbox synthesizes a `/{object}/{id}` deep-link from these. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete, a time-relative sweep, an action on a record) links to that record.',
892+
description: 'Record id the notification links to (writes sys_notification.source_id) — a string, or a CEL value envelope evaluated per run to one, such as { dialect: \'cel\', source: \'record.id\' }; a single-brace {token} is refused. Only takes effect together with sourceObject — a half-specified click-through target is dropped at execute time, so the inbox never renders a dead link. The inbox synthesizes a `/{object}/{id}` deep-link from these. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete or a before-create, a time-relative sweep, an action on a record) links to that record; a before-create run\'s record has no id until the driver issues one at the write, so it links only when the caller wrote the id.',
890893
},
891894
actorId: {
892895
type: 'string',

‎packages/spec/src/automation/io-node-config.zod.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,13 @@ function notifyLiteralRefusals(cfg: {
645645
* tolerates (drops) the half-specified shape rather than rejecting it.
646646
* - Click-through default: a node that writes none of `sourceObject`,
647647
* `sourceId` and `actionUrl` links to the run's trigger record, when the
648-
* run has one — a record change other than a delete, a time-relative
649-
* sweep's row, an action started on a record. A schedule tick, an inbound
650-
* API post and a manual start with no record have none and link nowhere;
651-
* a delete's record is gone once the write lands, so it is not linked. An
648+
* run has one — a record change other than a delete or a before-create, a
649+
* time-relative sweep's row, an action started on a record. A schedule
650+
* tick, an inbound API post and a manual start with no record have none
651+
* and link nowhere; a delete's record is gone once the write lands, so it
652+
* is not linked; a before-create run's record has no id until the driver
653+
* issues one at the write, after the hook, so it links only when the
654+
* caller wrote the id. An
652655
* explicit pair or an explicit `actionUrl` is the author's word and wins,
653656
* and a half-written pair is still dropped, never defaulted. The executor
654657
* owns the default (`defaultClickThroughOf` in service-automation's
@@ -760,7 +763,7 @@ export const NotifyConfigSchema = lazySchema(() => strictObject({
760763
* (see "click-through default" above).
761764
*/
762765
sourceObject: notifyLiteralStringSchema('sourceObject').optional()
763-
.describe('Object name of the record the notification links to (writes sys_notification.source_object) — a literal, read as written: a single-brace `{token}` is not resolved here and is refused, as is a CEL value envelope; write the value. Only takes effect together with sourceId — a half-specified click-through target is dropped at execute time, not defaulted, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete, a time-relative sweep, an action on a record) links to that record, and a run with no trigger record links nowhere; an explicit pair or an actionUrl is kept as written.'),
766+
.describe('Object name of the record the notification links to (writes sys_notification.source_object) — a literal, read as written: a single-brace `{token}` is not resolved here and is refused, as is a CEL value envelope; write the value. Only takes effect together with sourceId — a half-specified click-through target is dropped at execute time, not defaulted, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete or a before-create, a time-relative sweep, an action on a record) links to that record, and a run with no trigger record links nowhere — a before-create run\'s record has no id until the driver issues one at the write, so it links only when the caller wrote the id; an explicit pair or an actionUrl is kept as written.'),
764767
/**
765768
* Click-through target record id — only effective together with
766769
* `sourceObject`; a half-written pair is dropped, never defaulted. A `value`
@@ -769,7 +772,7 @@ export const NotifyConfigSchema = lazySchema(() => strictObject({
769772
* record (see "click-through default" above).
770773
*/
771774
sourceId: NotifySourceIdSlotSchema.optional()
772-
.describe('Record id the notification links to (writes sys_notification.source_id) — a string, or a CEL value envelope `{ dialect: \'cel\', source }` evaluated per run to one (`record.id`); a `{…}` template token is refused. Only takes effect together with sourceObject — a half-specified click-through target is dropped at execute time, not defaulted, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete, a time-relative sweep, an action on a record) links to that record, and a run with no trigger record links nowhere; an explicit pair or an actionUrl is kept as written.'),
775+
.describe('Record id the notification links to (writes sys_notification.source_id) — a string, or a CEL value envelope `{ dialect: \'cel\', source }` evaluated per run to one (`record.id`); a `{…}` template token is refused. Only takes effect together with sourceObject — a half-specified click-through target is dropped at execute time, not defaulted, so the inbox never renders a dead link. When sourceObject, sourceId and actionUrl are all left out, a run started by a record (a record change other than a delete or a before-create, a time-relative sweep, an action on a record) links to that record, and a run with no trigger record links nowhere — a before-create run\'s record has no id until the driver issues one at the write, so it links only when the caller wrote the id; an explicit pair or an actionUrl is kept as written.'),
773776
/** User id that caused the event. A literal, read as written (#19939, "notify literals" above). */
774777
actorId: notifyLiteralStringSchema('actorId').optional()
775778
.describe('User id that caused the event (writes sys_notification.actor_id) — a literal, read as written: a single-brace `{token}` is not resolved here and is refused, as is a CEL value envelope; write the value'),

‎skills/objectstack-automation/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ error. **RAW** keys are read as written: a
122122
severity: 'warning', // RAW; CLOSED enum info|warning|critical
123123
channels: ['inbox'], // RAW; default inbox
124124
sourceObject: 'task', // link: PAIR, else dropped; none of the 3 ⇒ the
125-
sourceId: { dialect: 'cel', source: 'record.id' }, // trigger record (not on delete), if any
125+
sourceId: { dialect: 'cel', source: 'record.id' }, // trigger record (not on delete/before-create), if any
126126
actionUrl: '/tasks/{{ record.id }}', // overrides the pair
127127
} }
128128
```

0 commit comments

Comments
 (0)