Repository navigation
Expand file tree
/
Copy pathautomation-service.ts
More file actions
2644 lines (2571 loc) · 139 KB
/
Copy pathautomation-service.ts
File metadata and controls
2644 lines (2571 loc) · 139 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
/**
* IAutomationService - Automation Service Contract
*
* Defines the interface for flow/script execution in ObjectStack.
* Concrete implementations (Flow Engine, Script Runner, etc.)
* should implement this interface.
*
* Follows Dependency Inversion Principle - plugins depend on this interface,
* not on concrete automation engine implementations.
*
* Aligned with CoreServiceName 'automation' in core-services.zod.ts.
*/
import type { FlowParsed } from '../automation/flow.zod';
import type { ExecutionLog, ExecutionStatus, FlowRunSummary } from '../automation/execution.zod';
import type { ActionDescriptor } from '../automation/node-executor.zod';
import type { ConnectorDescriptor, ConnectorState } from '../integration/connector-descriptor';
import type { ConversionNotice, ConversionTodoNotice } from '../conversions/types';
import type { ExecutionContext } from '../kernel/execution-context.zod';
import type { JobRunTrigger } from './job-service';
import type { FlowRegistration } from '../api/protocol.zod';
import type { FlowInnerRefusal, RecordUpdateStart } from '../api/automation-api.zod';
import type { DroppedFieldsEvent } from '../data/data-engine.zod';
import type { FieldError } from '../api/errors.zod';
/**
* The write a record-triggered run was dispatched inside (#28251) — see
* {@link AutomationContext.saveNotice}.
*/
export interface SaveNoticeChannel {
/**
* Hand the rendered notice to the triggering write. Refuses (throws a
* `TypeError`) a message that is not a non-empty string; a later call
* replaces an earlier one.
*/
set(message: string): void;
/** The writer's locale (BCP-47), when the write's session carries one. */
readonly locale?: string;
}
/**
* Context passed to a flow/script execution
*/
export interface AutomationContext {
/** Record that triggered the automation (if applicable) */
record?: Record<string, unknown>;
/**
* `true` exactly when the dispatcher's caller-scope load of the subject row
* did NOT deliver it — so {@link record} is the stamped `{ id }` stub the
* dispatcher puts in place of the row, not the row (#14244; the flow face of
* the handler-face signal `ctx.recordLoadDenied` of commit f19475c0a). Absent — never
* `false` — otherwise, including for a record-less start that attempted no
* load, so a consumer reads `recordLoadDenied === true`.
*
* Who sets it: the runtime's action dispatch, both doors — REST
* `POST /api/v1/actions/...` and the MCP `run_action` bridge — through ONE
* producer, `loadActionSubjectRecord` in `@objectstack/runtime`'s
* `action-execution.ts`, whose `actionRecordLoadSignal(load)` returns
* exactly `{ recordLoadDenied?: true }` (line 1278 on `2cc46103`). This key
* IS that producer's spelling, mirrored — not a second one.
*
* What a flow guards on: a `type: 'flow'` action's dispatcher stamps the
* requested `recordId` onto `record.id` whether or not the caller could
* read the row (new-record / record-less actions depend on the stamp), so
* `record.id` is present either way and a node branching on it never
* refuses. A `runAs: 'user'` flow re-derives the caller's scope on its own
* reads and the stub resolves to nothing; a `runAs: 'system'` flow runs
* elevated AND receives the stub — this key is what such a flow guards on
* before acting on a row its invoker has not demonstrated read access to.
* It reports "the row did not resolve for this caller", not "an
* authorization error was caught": an RLS-hidden row and an id that names
* nothing both arrive as `RECORD_NOT_FOUND`, deliberately, and the key does
* not pretend to separate them.
*
* Populated on the flow face since #15168: `dispatchFlowAction` takes the
* producer's load outcome and spreads the signal into the context it hands
* `automation.execute`, on both doors, so a flow run receives this key
* exactly when a handler would. Additive — no existing key changes value.
* Callers other than the action dispatcher do NOT set this.
*/
recordLoadDenied?: true;
/**
* Prior state of the record for update triggers (the "old" row). Lets
* record-change-triggered flows gate on transitions (e.g.
* `status == "done" && previous.status != "done"`). Absent for
* create/delete events.
*/
previous?: Record<string, unknown>;
/** Object name the record belongs to */
object?: string;
/** Trigger event type (e.g. 'on_create', 'on_update') */
event?: string;
/**
* The acting user: who triggered the automation — or, on a run that an
* approval decision resumed, the decider, for the nodes after that
* decision, on both postures (`FlowSchema.runAs`;
* {@link ResumeSignal.resumedBy}).
*/
userId?: string;
/**
* Position names of the triggering identity (ADR-0090 D3; formerly
* `roles`). Forwarded by the trigger surface (REST route / record-change
* hook) so a `runAs:'user'` run enforces RLS exactly as that user — not a
* member fallback. ADR-0049 / #1888.
*/
positions?: string[];
/**
* Explicit permission-set names of the triggering identity (parity with a
* direct REST request). Forwarded alongside {@link positions}. ADR-0049 / #1888.
*/
permissions?: string[];
/**
* The posture rung of the triggering identity (ADR-0095 D2/D3), the kernel
* `ExecutionContext.posture` under its own name: what the readers keyed on
* the rung read, the compliance ledger's deployment-level rows among them
* (`PLATFORM_ADMIN` alone is served those). Forwarded alongside
* {@link positions} and {@link permissions} by the two doors that start a
* run on a person's behalf (`buildAutomationContext` and
* `dispatchFlowAction` in `@objectstack/runtime`), copied off the
* request's already-resolved execution context, so the run reads what the
* same caller's request reads. #28099.
*
* ⛔ It is the caller's own rung, as-is: never derived from the flow's
* author, never raised, and never filled in when the request carries none.
* Run setup keeps a forwarded rung beside the forwarded grants and does not
* re-derive it. When it resolves the grants itself (a context with no
* {@link permissions}: a record-change run, the segment after an approval
* decision), it drops any forwarded rung and takes the rung off that same
* resolution; grants that stay unresolved (the resolver rejects, answers
* nothing, or is not wired) leave the run with none. So a rung stands only
* beside the grants it was derived from. Absent:
* every reader of it answers as for a principal below the rung, which
* narrows and never widens. Absent on a `runAs:'system'` run's data
* context, whose `isSystem` short-circuit precedes every reader of it.
*/
posture?: ExecutionContext['posture'];
/**
* Tenant/org id of the triggering identity, carried so a `runAs:'user'` run
* stays tenant-scoped. ADR-0049 / #1888.
*/
tenantId?: string;
/**
* The acting user's unique email, the value row-level security reads as
* `current_user.email` (an owner policy such as
* `assignee == current_user.email`). The kernel `ExecutionContext.email`,
* under its own name.
*
* Who sets it: the engine's run setup, for a `runAs:'user'` run whose
* context names a user and carries no email yet. It is taken from the
* resolver a request's envelope is built through (`resolveUserAuthzGrants`
* in `@objectstack/core`, the user's `sys_user` email), so the run matches
* the same user's own request. After an approval decision it is the
* DECIDER's, resolved for them; the trigger user's never survives into the
* decider's segment. A context that already carries one keeps it verbatim,
* as a request's session email wins over the stored one. Absent on a
* `runAs:'system'` run (nothing is resolved for it), on a user-less run,
* and for a user with no stored email: every policy that reads it then
* drops out, which narrows and never widens.
*
* It reaches the data engine through `resolveRunDataContext` in
* `@objectstack/service-automation`, and rides the run's context into a
* `subflow` / `map` child and through a suspension, as {@link positions}
* and {@link permissions} do. Identity for row policies only: the flow CEL
* scope's `current_user` does not bind it.
*/
email?: string;
/**
* The language of the person who started the run (BCP-47, e.g. `zh-CN`):
* the door's already-resolved `ExecutionContext.locale`, forwarded as-is.
* It is never resolved a second time here. The request's own
* `Accept-Language` wins over the user's and the workspace's `localization`
* settings, and that precedence lives in one place, the shared
* execution-context assembler.
*
* Who sets it: the two doors that start a run on a person's behalf, from the
* request's execution context —
* - the trigger door, `buildAutomationContext` in `@objectstack/runtime`'s
* `domains/automation.ts` (`POST /api/v1/automation/:name/trigger`, the
* legacy trigger route, and a declarative `type: 'flow'` endpoint);
* - the action door, `dispatchFlowAction` in `@objectstack/runtime`'s
* `action-execution.ts` (REST `POST /api/v1/actions/...` and the MCP
* `run_action` bridge).
*
* Its readers pick a translated TEMPLATE in this locale before they render
* the `{{ }}` holes: the engine's refusing `end` node, at
* `flows.<flow>.refusals.<node_id>.message` (`flowRefusalMessageKey`,
* #22450), and the `screen` executor, at
* `flows.<flow>.screens.<node_id>.title` / `.description`
* (`flowScreenCopyKey`, #22507). With no locale, or no translation, the
* authored template renders.
*
* It lives as long as the run: it is persisted with a suspended run, so a
* resumed leg renders in the STARTER's locale whoever resumes it (a resume
* carries no locale of its own), and a `subflow` / `map` child inherits it
* with the rest of the parent's context. Absent on a run no person started:
* a record-change, schedule or webhook trigger, or code calling `execute`
* directly. Such a run renders the authored templates.
*
* Presentation, not authorization: no security middleware keys on it.
*/
locale?: string;
/**
* The write that fired this run, for its `save_notice` nodes (#28251):
* where a `save_notice` node hands its rendered message, so the create /
* update answer of that write carries it as `notice`.
*
* Who sets it: the record-change trigger (`trigger-record-change`), the one
* door that runs a flow INSIDE a write — its hook handler awaits the run
* before the write answers. It wraps the hook face of the write's own
* listener (`HookContext.notice`, bound from `onNotice` on every insert /
* update dispatch), so this is that channel, never a second one; `locale`
* is the writer's (the hook session's `locale`), the language the
* `save_notice` executor picks the translated template in.
*
* In-process only, and only for the run's first leg: a function does not
* survive a suspension, so a leg an approval or a wait resumed carries no
* channel and its `save_notice` node refuses by name — the write answered
* long before. Never inherited by a `subflow` / `map` child (a child is
* not started by the write). Absent on every other door's run, which the
* flow parse already refuses a `save_notice` node in.
*/
saveNotice?: SaveNoticeChannel;
/**
* The tenant default currency of the run's organization (ISO 4217, e.g.
* `CNY`): the `localization.currency` setting, read the way a currency
* field reads it. Seeded by the engine at run setup when the context does
* not already carry one (the automation plugin bridges the read to
* `@objectstack/core`'s `resolveLocalizationContext`), and kept for the
* run's life like {@link locale}: persisted with a suspended run, inherited
* by a `subflow` / `map` child.
*
* Its reader is the flow's text renderer: a `{{ amount | currency }}` hole
* with no argument formats in it. Absent (the organization has no default,
* or the engine is not bridged), such a hole refuses the node by name
* instead of formatting in a guessed currency.
*
* Presentation, not authorization: no security middleware keys on it.
*/
currency?: string;
/**
* Effective execution identity for the run's DATA operations, established by
* the engine from {@link FlowParsed.runAs} at run setup (ADR-0049 / #1888):
* - `'system'` runs elevated — a full-access, RLS-bypassing system principal;
* - `'user'` (default) runs as {@link userId}, so CRUD nodes' ObjectQL
* reads/writes respect that user's row-level security.
* Node executors translate this into the ObjectQL `context` they pass to the
* data engine (see `resolveRunDataContext` in @objectstack/service-automation).
* Callers do NOT set this — the engine derives it from the flow definition.
*/
runAs?: 'system' | 'user';
/**
* Machine name of the flow this run executes, stamped by the engine at run
* setup alongside {@link runAs} / {@link flowRunId} (same single
* construction point, same lifetime). Provenance, not authorization — no
* security middleware keys on it.
*
* Its consumer is audit attribution: `resolveRunDataContext` labels a
* `runAs:'system'` run's data operations `svc:flow:<flowName>` on
* `ExecutionContext.actor` (ADR-0014 D2), naming WHICH automation performed
* the write. The label is a FALLBACK, not a replacement — the audit writer
* records `session.userId ?? session.actor` on `sys_audit_log.actor` — and
* elevation never costs the run its operator: a `runAs:'system'` run
* carries the triggering user through whenever the trigger resolved one
* (#5494), so its writes still stamp `created_by` / `updated_by` and
* `sys_audit_log.user_id` with that human, exactly as the same trigger
* would under `runAs:'user'` — and after a human decision that parity
* holds with the decider: an approval decision moves the acting user to
* the decider for the nodes after it on BOTH postures (`FlowSchema.runAs`).
* A `runAs:'user'` run takes the decider's permissions with them; a
* `runAs:'system'` run keeps its elevation and only its attribution user
* moves. `runAs` declares the run's
* AUTHORIZATION posture and leaves ATTRIBUTION alone (ADR-0073 D2).
*
* The `svc:flow:` label is therefore what a genuinely USER-LESS run falls
* back to — a schedule, or a `runAs:'system'` flow fired by a write that
* itself carried no user — instead of leaving the audit row unattributed
* (#4366). There the user column stays null: ADR-0118 D1 forbids inventing
* a sentinel or pseudo-user in its place.
*
* Callers do NOT set this — the engine derives it, exactly like {@link runAs}.
*/
flowName?: string;
/**
* Id of the run this context belongs to, stamped by the engine at run setup
* alongside {@link runAs} and carried into every data node's ObjectQL
* `context` (see `resolveRunDataContext` in @objectstack/service-automation).
* It is persisted with a suspended run, so it survives a pause/resume round
* trip — including a cold resume after a process restart.
*
* Provenance, not authorization: it grants nothing and no security
* middleware keys on it. A hook uses it to recognize writes made BY a given
* run — the approvals record lock (#3456) lets the run that opened a pending
* approval write its own target record, which it otherwise cannot tell apart
* from an unrelated user's edit. A run with no resolvable principal (a
* schedule) carries this and nothing else into the data engine, so it is
* attributable without presenting an identity it does not have (#3712).
*
* Callers do NOT set this — the engine derives it, exactly like {@link runAs}.
*/
flowRunId?: string;
/**
* The administrator (a `sys_user` id) at the keyboard when the request or
* write that started this run came from an impersonation session. Every
* door that starts a run from an envelope carrying it sets it: the
* record-change trigger from the triggering hook's
* `provenance.impersonatedBy`, and the manual trigger route and a
* `type: 'flow'` action from the caller's `ExecutionContext.impersonatedBy`.
* The run's data nodes carry it onto every write as
* `ExecutionContext.impersonatedBy`, so the audit writer names the
* administrator on the run's writes as on the request that started it.
*
* ATTRIBUTION ONLY: {@link userId} stays the impersonated user, whose
* grants a `runAs:'user'` run resolves, and nothing in the authorization
* path reads this. Absent on every run a user's own write started. An
* approval decision replaces it for the decider's segment with the
* decision's own {@link ResumeSignal.impersonatedBy}: the administrator
* when the decider decided from an impersonation session, absent when the
* decider acted in their own name, never the stamp of the write that
* started the run.
*/
impersonatedBy?: string;
/** Additional contextual data */
params?: Record<string, unknown>;
/**
* Which keys of {@link params} the run's CALLER supplied as flow input —
* stated by the door that started the run, so that no consumer has to guess
* it from the bag (#19846). A key listed here carries a value the caller
* put in its own `params`; a key missing from it was seeded by the door
* itself (a column of the subject {@link record}, or the launched row's id).
* An empty array is an answer — "the caller supplied nothing" — and is not
* the same as an absent key.
*
* Who sets it: the two doors that start a flow on a caller's behalf, each
* from the caller's bag BEFORE it seeds anything —
* - the action door, `dispatchFlowAction` in `@objectstack/runtime`'s
* `action-execution.ts` (REST `POST /api/v1/actions/...` and the MCP
* `run_action` bridge);
* - the trigger door, `buildAutomationContext` in `@objectstack/runtime`'s
* `domains/automation.ts` (`POST /api/v1/automation/:name/trigger`, the
* legacy `POST /api/v1/automation/trigger/:name`, and a declarative
* `type: 'flow'` endpoint).
*
* Both doors leave out the keys they use to carry the launched row's id —
* `recordId`, the camelCase `<object>Id` alias, and on the action door the
* action's own `recordIdParam` — even when the caller's bag names them too:
* a client that mirrors the row id into `params.recordId` is addressing the
* row, not answering a question the flow asks.
*
* One producer with no caller at all states the empty list: the schedule
* trigger (`ScheduleTrigger` in `@objectstack/trigger-schedule`, #19900).
* Its `jobId`, `flowName` and `schedule` keys in {@link params} are its own
* seeds, so none of them answers a question the flow asks.
*
* Absent means the producer does not state provenance: a record-change,
* time-relative or webhook trigger, a `subflow` or `map` child run
* (those two nodes drop the parent's list from the child context, because it
* describes the PARENT's bag), or code calling `execute` directly. Its
* consumer, the `screen` node's headless verdict in
* `@objectstack/service-automation`, then falls back to inferring
* provenance from the bag, an inference whose failure direction is to pause.
*
* Provenance, not authorization — no security middleware keys on it.
* Additive: no existing key changes value, and a context without it keeps
* its prior meaning.
*/
callerParamKeys?: string[];
}
/** One input field rendered by a paused `screen` node (ADR-0019 / screen-flow runtime). */
export interface ScreenFieldSpec {
name: string;
label?: string;
/**
* Widget hint (text/select/boolean/number/date/file/…); the client maps it
* to a field widget.
*
* Nine members are value domains the server re-checks on resume
* (`validateScreenInputs`): the three numeric kinds `'number'`,
* `'currency'` and `'percent'` take a finite JSON number (a numeric
* string is refused, ⛔ not coerced; the client renders all three as a
* numeric input, which posts a number); `'file'` (#25801) takes the
* id of an uploaded `sys_file` — the client
* renders the platform upload widget and answers with the id the upload
* minted, never the expanded `{ id, name, url, … }` read form; and the
* five string kinds `'text'`, `'textarea'`, `'email'`, `'url'` and
* `'phone'` (#31491) take a JSON string (an object, number, boolean or
* array is refused, ⛔ not coerced — `42` is not read as `'42'`). Only the
* shape is checked: the format of an email, URL or phone number is not.
* A refused value leaves the run paused, so a corrected resume continues
* it.
*
* One member is not an input at all: `'record_link'` shows the
* {@link reference} record whose id {@link defaultValue} carries (served
* already evaluated) by its display name, as a link to its record page.
* The client submits nothing for it, and the server refuses any value sent
* under its name on resume, so the id is never bound to a flow variable.
*/
type?: string;
required?: boolean;
/** Closed-enum options for select-style fields. */
options?: Array<{ value: unknown; label: string }>;
defaultValue?: unknown;
placeholder?: string;
/**
* Numeric bound pair the client applies to a numeric input (#17306),
* spelled as the object field spells it (`FieldSchema.min` / `.max`).
*
* Unlike {@link visibleWhen}, these are NOT client-only: the server
* re-checks them when the run resumes (`validateScreenInputs`), so a bound
* holds against a caller that skips the dialog — with no "if the value
* happens to be a number" qualifier, because on a numeric field
* (`type: 'number'`, `'currency'` or `'percent'`) a present non-number is
* refused outright (`invalid_type`) rather than
* passing the bound it cannot be compared against. ⛔ Not coerced. The
* client still applies them so the user is stopped at the input rather
* than at Submit.
*/
min?: number;
max?: number;
/**
* Help text rendered under the input (#17306) — `FieldSchema`'s spelling.
* Distinct from {@link placeholder}, which the browser clears the moment a
* value is typed, and so cannot carry a constraint the user must keep
* reading.
*/
inlineHelpText?: string;
/**
* Object whose records a `type: 'lookup'` field picks from (#17306), or
* that a `type: 'record_link'` field's record belongs to —
* `FieldSchema.reference`'s spelling. Required on both by
* `ScreenFieldConfigSchema`.
*
* Optional HERE and required on the authoring side: `ScreenFieldConfigSchema`
* refuses a `type: 'lookup'` field that declares no `reference` (maintainer
* ruling A′, 2026-09-13), so a screen reaching a client through a parsed
* flow always carries it. This is the WIRE shape, and it stays optional for
* the reason every key on it is: it also describes a `ScreenSpec` rehydrated
* from a run SUSPENDED before the upgrade, which was stored under the old
* accept set. A client that meets one has no target to resolve a picker
* against and falls back to a plain input — the pre-#17306 behaviour, kept
* reachable on purpose rather than turned into a client-side crash.
*/
reference?: string;
/**
* Conditional-visibility predicate (ADR-0089's canonical key), evaluated by
* the CLIENT against the screen's live collected values — not by the server,
* which has no view of what the user has typed so far.
*
* Bare CEL over the screen's own field names, e.g. `createOpportunity ==
* true` shows the field only once that checkbox is ticked. Omit = always
* visible.
*
* A hidden field is not collected, so it must not be enforced as `required`
* either — a client that renders this predicate but validates over the full
* field list dead-ends the run: Submit blocks on a field the user was never
* shown, and no resume is ever issued (#3528).
*/
visibleWhen?: string;
}
/**
* The screen a paused `screen` node wants the client to render. Surfaced on a
* paused {@link AutomationResult} so a UI flow-runner can collect input and
* `resume()` the run with the values.
*/
export interface ScreenSpec {
/** The screen node's id (correlates the resume back to this pause point). */
nodeId: string;
/**
* The heading, rendered: `config.title`, or the node label when the screen
* declares none, with its `{{ }}` holes filled — in the run's language. The
* engine picks the translated template (`flowScreenCopyKey`, #22507) in
* {@link AutomationContext.locale} before it renders, so a client draws
* this as served and ⛔ never overlays a translation on it: the holes are
* already filled, and a translated template laid over them would draw them
* as literal text.
*/
title?: string;
/**
* The body text, rendered and translated exactly as {@link title} is; absent
* when the screen authors none.
*/
description?: string;
fields: ScreenFieldSpec[];
/**
* Rendering kind. `'fields'` (default) renders the flat {@link fields} list.
* `'object-form'` renders an object's full create/edit form — including any
* inline master-detail child grids (`subforms`) — so a screen-flow wizard
* can walk the user through one full object form per step (e.g. lead
* conversion: a Customer step, then an Opportunity-with-line-items step).
* The client renders the object form; on save it persists the record (and
* its children, atomically) itself, then resumes the run with the new
* record's id bound to {@link idVariable}.
*/
kind?: 'fields' | 'object-form';
/** Object whose form to render (object-form screens). */
objectName?: string;
/** Form mode for an object-form screen — defaults to `'create'`. */
mode?: 'create' | 'edit';
/** Record id to edit (object-form screens in `'edit'` mode). */
recordId?: string;
/** Prefilled field values for the object form (already interpolated). */
defaults?: Record<string, unknown>;
/**
* Flow variable that receives the saved record's id when the client resumes
* the run — so a later step can reference it (e.g. the Opportunity form
* prefilling its `account` FK with the id created by the Customer step).
*/
idVariable?: string;
/**
* Where this screen sits among the screens of its run, read by the engine
* off the flow graph at the moment it pauses (#26657). A runner labels its
* primary button from {@link ScreenProgressSpec.nextScreen} ("Next" while
* another screen can follow, "Submit" on the last) and draws a step
* counter only from {@link ScreenProgressSpec.stepCount}.
*
* Absent when the engine cannot answer at all — a server that predates
* this member; a run with no flow name, a node that is not a `screen` of
* the registered flow, or a flow with no start node (no graph to read);
* or a screen inside a child run whose own graph shows no further screen
* (the parent may still have some) — and a runner then keeps the label
* it drew before this member existed.
*/
progress?: ScreenProgressSpec;
}
/**
* The graph's answer about a paused screen's place in its run (#26657),
* served on {@link ScreenSpec.progress}. Computed by the engine — the only
* party that holds the graph — so a client ⛔ never walks the flow itself.
*
* "Another screen" means another `screen` node this run can still pause on
* and serve before it ends. A screen that never pauses (no fields and no
* `waitForInput`) does not count. A pause that serves no screen (an approval,
* a wait) may end the stretch of screens a runner draws, so a screen that can
* only be reached past one counts as possible, never as certain.
*/
export interface ScreenProgressSpec {
/**
* Whether another screen can follow this one.
*
* - `'none'` — no path out of this screen reaches another one: it is the
* last step, and a runner says "Submit".
* - `'certain'` — every way the run can go from here pauses on another
* screen first: a runner says "Next".
* - `'possible'` — some ways do and some do not, because something after
* this screen decides: a branch (a `decision`, a fault path, a loop
* back), a pause that serves no screen, or a `subflow` that may serve
* a screen of its own. The engine does not guess which way the run
* goes; a runner says "Next", since a later screen is still possible.
*/
nextScreen: 'none' | 'possible' | 'certain';
/**
* This screen's 1-based position among the screens of the run. Present
* only when every path from the flow's start to this screen pauses on the
* same number of screens before it, so the number is exact; absent when a
* branch, a loop through a screen, a parallel fan-out or a `subflow` makes
* it vary.
*/
step?: number;
/**
* How many screens the run pauses on in all, this one included. Present
* only alongside {@link step}, and only when every path through this
* screen pauses on the same number of screens after it too; a runner
* draws a step counter from it and draws none without it.
*/
stepCount?: number;
}
/**
* Result of an automation execution
*/
export interface AutomationResult {
/** Whether the automation completed successfully */
success: boolean;
/** Output data from the automation */
output?: unknown;
/** Error message if execution failed */
error?: string;
/** Execution duration in milliseconds */
durationMs?: number;
/**
* Machine-readable failure classification, set alongside `error` when the
* caller must distinguish *why* it failed rather than just report it —
* without it a refusal is indistinguishable from "no such run".
*
* Two disjoint families share this field, and the distinction is
* load-bearing rather than editorial — see the trigger-time group at the
* bottom.
*
* **Resume refusals** — {@link IAutomationService.resume} declined to
* continue a parked run:
*
* - `'PERMISSION_DENIED'` — {@link IAutomationService.resume} refused
* because the run is parked on a node whose descriptor declares
* `resumeAuthority: 'service'` — or declares no `resumeAuthority` at all,
* which resolves the same way (#3801, #5561). A transport maps it to
* **403**.
* - `'INVALID_SIGNAL'` — the resume signal tried to write variables the
* flow engine reserves for itself (a `$…` name, or one carrying a `.$`
* segment: `$runId`, `<nodeId>.$mapItemDone`, …), or named a key in
* `output` or `variables` whose name, or any dot-separated part of it,
* is `__proto__`, `constructor` or `prototype`. Nothing is applied and
* the run stays suspended. A transport maps it to **400**.
* - `'RUN_NOT_FOUND'` — no suspension exists for the run id, in the hot
* cache or the durable store. The run is unresumable *for good*: it
* already resumed, was cancelled, or paused in a process whose state was
* never persisted (#4420). A transport maps it to **404**. Callers that
* persist a decision before resuming (approvals) must treat this as a
* hard failure, not a no-op.
* - `'STORE_UNAVAILABLE'` — the durable store could not be read, so
* whether a suspension exists is UNKNOWN. Distinct from
* `'RUN_NOT_FOUND'` on purpose: a transient store outage must not be
* mistaken for a dead run. A transport maps it to **503**; the same
* resume is expected to succeed once the store recovers.
* - `'RESUME_IN_PROGRESS'` — a concurrent resume of this run is already
* running; this duplicate was refused so side effects cannot run twice.
* A transport maps it to **409**. The other resume is doing the work,
* so callers should treat it as benign.
* - `'RESUME_CHILD_PENDING'` — the run is parked on a `map` node (directly,
* or through the run a `subflow` node waits on) whose in-flight item's
* child run is still suspended, and the resume addressed the PARENT.
* Continuing it would advance the map past an item that never ran, so
* nothing moves and `error` names the child run id to resume instead; the
* map continues when that child completes (#27877). A transport maps it
* to **409**. Distinct from `'RESUME_IN_PROGRESS'` on purpose: that one is
* benign and needs nothing from the caller, this one is answered only by
* resuming a different run id.
* The same code answers the map's second refusal (#27971): the item's
* suspension is gone and its run history does not record it as
* `cancelled` (no entry, an unreadable store, or another status), so the
* map has nothing true to record for that item. Nothing moves; `error`
* names the item run and the remedy, which is cancelling the parent run
* to end the batch, or retrying once the store is readable. A cancelled
* item is not refused: the map records it and goes on.
* - `'INVALID_SCREEN_INPUT'` — the run is parked on a `screen` node and
* the submitted bag violates that screen's declared field contract: a
* `required` field the caller WAS asked for is missing, or a key the
* screen never declared was sent (#4477). A transport maps it to
* **400**. Distinct from `'INVALID_SIGNAL'`, which is about the
* engine's own `$` variable namespace rather than the author's field
* declarations. `visibleWhen` is evaluated against the submitted values
* first, so a HIDDEN field's `required` never fires — enforcing it would
* dead-end the run at a field the user was never shown (#3528).
*
* All of the above refuse before consuming the suspension: the run stays
* parked and the legitimate continuation still lands.
*
* **Trigger-time refusals** — {@link IAutomationService.execute} declined
* to start a run at all. Both are classified by the engine **before
* dispatch**, so no node ever executed, nothing was written, and there is
* no run to inspect: they carry no `status`, which is exactly what
* separates them from a run that dispatched and was rejected
* (`status: 'failed'`, #9378). A transport reads the classification; it
* must never infer one from `summary` / `durationMs` / the message text.
*
* - `'FLOW_DISABLED'` — the flow exists but is switched off
* (`toggleFlow(name, false)`), so this dispatch was refused by policy.
* A transport maps it to **409**: the request is well-formed and the
* flow is well-defined; only the flow's current *state* conflicts with
* running it, and enabling the flow makes the identical request
* succeed.
* - `'FLOW_NO_START_NODE'` — the flow's definition holds no `start` node,
* so there is nothing to dispatch. A transport maps it to **422**: the
* request was understood and the flow exists, but the stored definition
* cannot be executed — an authoring defect the caller cannot fix by
* retrying. Distinct from `'FLOW_DISABLED'` on purpose: one is a
* reversible operational state, the other a malformed definition, and
* collapsing them tells an operator to flip a switch that will not help.
* - `'FLOW_INPUT_SCHEMA_INVALID'` — a node's static `config` violates the
* `inputSchema` its own flow definition declares, so the
* definition-level guard refused to dispatch. The verdict is a pure
* function of the flow definition — re-running the guard cannot produce
* a different answer — so the refusal is NON-RETRYABLE (#10025,
* maintainer ruling 2026-08-20: Option B taken whole): the engine
* refuses once instead of burning the whole retry budget re-deriving a
* certainty into 1 + maxRetries identical failed rows. A transport maps
* it to **422**, exactly as `'FLOW_NO_START_NODE'`: the stored
* definition cannot be executed, an authoring defect retrying cannot
* fix. Distinct from it on purpose: that one says the definition has
* nothing to dispatch, this one says a node's config contradicts the
* schema the definition itself declares. This member is the ruling's
* contract half; the engine begins stamping it when #10025's services
* half (the `execute()` catch short-circuit) lands.
*
* `'FLOW_DISABLED'` / `'FLOW_NO_START_NODE'` are the remaining two rows of
* the #9378 trigger-status ruling; `'FLOW_INPUT_SCHEMA_INVALID'` joined
* the never-dispatched class under the #10025 ruling. The union stays
* closed (the #9384 ruling), so each member was added deliberately, from
* measured need — and by the spec seat — rather than minted at a call
* site.
*/
code?: 'PERMISSION_DENIED' | 'INVALID_SIGNAL' | 'RUN_NOT_FOUND' | 'STORE_UNAVAILABLE' | 'RESUME_IN_PROGRESS' | 'RESUME_CHILD_PENDING' | 'INVALID_SCREEN_INPUT' | 'FLOW_DISABLED' | 'FLOW_NO_START_NODE' | 'FLOW_INPUT_SCHEMA_INVALID';
/**
* [#37526] The field-addressed findings behind an `'INVALID_SCREEN_INPUT'`
* refusal, one entry per finding: the screen field's `name`, the
* `FieldErrorCode` it broke (ADR-0114 D2: `required`, `invalid_type`,
* `invalid_value`, `min_value`, `max_value`, `unknown_field`) and the
* engine's English line for it. Set with that code only; absent otherwise.
* One field can carry more than one entry — a value above a field's `max`
* but below its larger `min` breaks both bounds, for instance — so a runner
* groups by `field` rather than counting one entry per field. For `unknown_field`,
* `field` is the key the caller sent, not a declared screen field name.
*
* It is what lets a runner place the refusal AT the field, in its own
* language, by the label it shows, instead of reading `error`: `error`
* keeps the whole sentence, with the screen's declared field names, for
* logs and API callers. A transport serves it as `error.details.fields`,
* the slot `VALIDATION_FAILED` already uses for the same entries.
*/
fields?: FieldError[];
/**
* Lifecycle status. `'paused'` means the run suspended at a node (e.g.
* an Approval node awaiting a human decision, ADR-0019) and can be
* continued later with {@link IAutomationService.resume}. Absent or
* `'completed'`/`'failed'`/`'stranded'` ⇒ the run reached a terminal
* state.
*
* `'stranded'` names the terminally-failed-but-repairable run (#13909;
* the #13937 shape-4 ruling, maintainer 2026-09-01): a resume CONSUMED the
* suspension, a downstream node threw, and the run is recorded as failed —
* terminal exactly like `'failed'`, except that the pause a durable
* decision (an approval, a screen submission) was waiting on is gone with
* it, so the run can be re-armed only by an explicit operator verb — never
* by {@link IAutomationService.resume} (which answers `'RUN_NOT_FOUND'`:
* there is no suspension left) and never automatically. Distinct from
* `'failed'` on purpose: that one says the run ran and was rejected; this
* one says a recorded continuation stopped mid-flight and an operator has
* something to repair. This member is the ruling's contract half; the
* engine begins stamping it when #13937's services half (the re-arm verb
* and the catch-arm stamp in `resumeInternal`) lands. plugin-approvals'
* `StrandedRunState` is a report-only label over a request's run and is
* deliberately NOT promoted to this status (same ruling): it classifies
* WHY a request's run is unrecoverable, this names the run's own lifecycle
* verdict. ⛔ Its members are deliberately NOT restated here: the union is
* plugin-local — declared, and documented member by member, on the type
* itself in `plugins/plugin-approvals/src/approval-service.ts` — and
* `automation-result-status.pin.test.ts` excludes it from its pins on
* purpose, so a member list copied into this file is unpinned prose that
* goes stale the next time the plugin splits an arm.
*
* `'refused'` names the run that reached an `end` node declaring
* `outcome: 'refused'` (#14945; maintainer ruling 2026-09-05, option 2′):
* a successful evaluation that said no. Terminal exactly like
* `'completed'`, and DISTINCT from `'failed'` on purpose — nothing threw,
* the flow refused deliberately, and the authored reason is rendered
* per-record into {@link refusalMessage}. `success` stays `true` (the
* evaluation succeeded), `successMessage` is NOT set (there is nothing to
* toast), and the run is never resumed. A runner renders `refusalMessage`
* with Close only — no Submit, no completion toast. This member is the
* ruling's contract half; the engine begins stamping it when the
* services half (the `end` handling in `service-automation`) lands.
*/
status?: 'completed' | 'paused' | 'failed' | 'stranded' | 'refused';
/** Run id — set when `status` is `'paused'`, so callers can resume it. */
runId?: string;
/**
* The screen to render — set when the run paused at a `screen` node awaiting
* user input (screen-flow runtime). The client collects values for
* `screen.fields` and calls {@link IAutomationService.resume} with them as
* `signal.variables`.
*/
screen?: ScreenSpec;
/**
* Friendly terminal messages rendered from the flow definition
* (`flow.successMessage` / `flow.errorMessage`) so a screen-flow runner can
* show a meaningful toast instead of a generic "Done" / the raw error.
* `successMessage` is set on terminal success, `errorMessage` on failure.
* Each is the flow's `{{ }}` template already rendered over the run's
* variables, in the run's locale (#28054), so a runner draws it as served.
*/
successMessage?: string;
errorMessage?: string;
/**
* The producer-marked END-USER text of the refusal a node met inside the
* run, verbatim (ruling B′ on #24914, decision batch #379 item 5; #24996).
*
* The semantics are `ApiErrorSchema.userMessage`'s (`api/contract.zod.ts`)
* and nothing else: presence IS the marking — set exactly when the inner
* refusal's producer (an application hook, a platform refusal that carries
* static guidance) opted in at throw time, read through the one
* `declaredUserMessage` read; absent otherwise, so a runner keeps its own
* substitution for anything unmarked. It never replaces {@link error}: the
* diagnostic channel keeps its own wording, and a door serving this run's
* failure carries this text as its envelope's top-level `userMessage`
* beside an unchanged `message`.
*/
userMessage?: string;
/**
* The refusal a node met inside the run (a data node's read or write, or a
* `script` node's function resolution), structured —
* `{ code, message }`, `code` in its WIRE spelling (`UNIQUE_VIOLATION`
* for a unique refusal), the shape a record save of the same write
* answers with (ruling B′ on #24914; #24996).
*
* Declared once as `FlowInnerRefusalSchema` (`api/automation-api.zod.ts`),
* and every flow door's `400 FLOW_FAILED` details carry it under the same
* name (`FlowFailureDetailsSchema`). It rides BESIDE the run's failure and
* moves none of it: {@link error} keeps its wording, and {@link code} stays
* the closed union above — the inner code is nested here precisely so no
* new member is minted there. Set on a failed run only when a refusal was
* met; ⛔ never synthesised from the message text.
*/
innerRefusal?: FlowInnerRefusal;
/**
* The flow definition's authored `label`, copied verbatim the same way as
* the two messages above, so a flow runner can name the flow it is running
* (the runner header, the completion toast) in words rather than by its
* API name — and translate it against `flows.<flow>.label`, falling back
* to this string.
*
* Set on every result that describes an EVALUATION of a registered flow —
* `status: 'paused'`, a terminal success (no `status`, including the two
* skip exits), `'failed'`, `'stranded'` and `'refused'`, and a resumed
* parent whose delegated child failed. Absent on every refusal that
* carries a {@link code} (the run never dispatched, or a resume never
* continued it) and when the flow is not registered.
*
* Always the label of the flow the result's run belongs to — for a
* `subflow` chain that is the run the caller addressed (the parent), never
* the child the screen came from. `FlowSchema` requires `label`, so on
* those results it is always present and always what the author wrote —
* ⛔ never replaced by the flow's API name, which the caller already
* holds as the name it triggered.
*/
flowLabel?: string;
/**
* #14945: the rendered refusal, set when `status` is `'refused'` — the
* `end` node's `message` template interpolated against the run's
* variables, so it names the record (`Refused: Acme Corp is a confirmed
* duplicate`). Authored per-record text, not a copy of a flow-level
* string like the two above; absent on every other status. The runner
* shows it with Close only.
*/
refusalMessage?: string;
/**
* #4354: what the run did — records selected / acted on, gate skips,
* per-node status. Set on a TERMINAL result (a paused run has not finished
* doing it yet).
*
* On the result rather than only in the run log because a caller that
* invokes a flow synchronously — the `subflow` node rolling a child run up
* into its parent, a test asserting a sweep wrote something — needs the
* answer without a second round-trip through `getRun`.
*/
summary?: FlowRunSummary;
/**
* #32861: the caller-supplied field values a write step of this run did
* NOT store — each element the data engine's own
* {@link DroppedFieldsEvent} (`object`, `fields`, `reason`), as the
* `create_record` / `update_record` step received it — one event per
* `(object, reason)`, its `fields` the union in first-seen order, so a
* loop that drops `status` on thirty rows is one fact, not thirty. A
* field named means at least one write dropped it, not every write.
*
* The step reports the strip as a warning and SUCCEEDS (#3407): a
* `readonly` field the flow wrote was removed from the payload and the
* write committed without it. Before this member that fact stopped at the
* run log, so a record button whose flow wrote a read-only `status`
* answered a plain success and the person who clicked it was told
* nothing. It rides the answer so the door that started the run can tell
* them, the way a record save's `droppedFields` already does.
*
* ⛔ Not a failure, and it moves nothing else: `success`, `status` and
* `summary` read exactly as they would without it. Set on a TERMINAL
* success only (the run's own write steps, before and after any pause
* it resumed from), and only when at least one step dropped a field —
* absent, never `[]`, otherwise.
*
* Delegated writes roll up onto this answer too: a `subflow` child's run
* and each `map` item's run, whether it completed without pausing or
* paused and resumed (#33019), as {@link summary} credits them. Unlike
* `summary`, a child run that FAILED answers no drops, so where a
* `try_catch` or `fault` edge contains that failure an absent member is
* not proof the failed child dropped nothing. A `map` item whose paused
* run an operator cancelled (#27971) answers none either: the map goes
* on with the cancelled marker in the item's `results` slot, and that
* run's drops, like its totals, reach the parent nowhere.
*/
droppedFields?: DroppedFieldsEvent[];
}
/**
* Marker a SERVICE stamps on its {@link ResumeSignal} to prove the resume is
* the tail of a decision it already authorized and recorded (#3801).
*
* A run parked on a node whose descriptor declares `resumeAuthority: 'service'`
* (today: `approval`, `approval_revise`) is resumable ONLY with this marker
* present — as is a pause whose node type declares no `resumeAuthority` at all,
* fail-closed since #5561. It is a
* symbol on purpose: the generic resume route builds its signal out of a JSON
* body, and no JSON body can produce a symbol-keyed property — so the marker
* is unforgeable from outside the process, while an in-process owner
* (`ApprovalService.decide` and friends) just sets it.
*
* Registered via `Symbol.for` so duplicate copies of this package in one
* process still agree on identity.
*/
export const RESUME_AUTHORITY_SERVICE: unique symbol = Symbol.for(
'objectstack.automation.resume.service',
);
/** Signal payload used to resume a paused run (ADR-0019). */
export interface ResumeSignal {
/**
* Output to merge into flow variables under the suspended node's id
* (e.g. `{ decision: 'approved' }` → `<nodeId>.decision`). Downstream
* edges branch on it exactly as for a normally-executed node.
*/
output?: Record<string, unknown>;
/**
* Optional edge label to select which out-edge of the suspended node to
* follow (e.g. `'approve'` / `'reject'`). When omitted, traversal falls
* back to the node's conditional/unconditional edges.
*/
branchLabel?: string;
/**
* Bare flow variables to set on resume (e.g. a `screen` node's collected
* inputs: `{ new_assignee: 'ada@x' }` → variable `new_assignee`). Unlike
* {@link output} these are set under their plain names, so downstream
* `{var}` interpolation and conditions read them directly.
*/
variables?: Record<string, unknown>;
/**
* The user whose decision this resume is the tail of — the decider of an
* approval (approve or reject). On a `runAs: 'user'` run the nodes after
* the decision run as this user, with the identity and permissions the
* engine resolves for them through the same grants resolver a trigger
* user's run is seeded through (positions, permission sets, organisation
* peers), never with the trigger user's. On a `runAs: 'system'` run they
* keep the run's elevation and carry this user as their attribution user
* (`{ isSystem: true, userId }`), with no grant resolved; see
* `FlowSchema.runAs`. Absent
* when no human decided (an SLA auto-decision), and then the run keeps the
* identity it had.
*
* Honoured ONLY on a signal that also carries
* {@link RESUME_AUTHORITY_SERVICE}: the owning service names the decider it
* already authenticated and recorded. A signal built from an HTTP body
* cannot carry that marker, so a body naming a user here changes nothing.
*/
resumedBy?: string;
/**
* The administrator (a `sys_user` id) at the keyboard when the decider
* named by {@link resumedBy} decided from an impersonation session — the
* decision request's `ExecutionContext.impersonatedBy`, as the owning
* service read it off that request's session. The nodes after the
* decision carry it as the segment's
* {@link AutomationContext.impersonatedBy}, so the audit writer names the
* administrator on the decider's writes as on the decision itself; absent
* when the decider acted in their own name, and then the segment carries
* none, whatever the run's trigger carried.
*
* ATTRIBUTION ONLY: {@link resumedBy} stays the decider whose identity the
* segment runs with. Honoured ONLY together with {@link resumedBy} on a
* signal that also carries {@link RESUME_AUTHORITY_SERVICE}; a signal built
* from an HTTP body naming an administrator here changes nothing.
*/
impersonatedBy?: string;
/**
* Set by the service that OWNS the suspension to clear the resume gate on
* a `resumeAuthority: 'service'` node — or on one that declares no
* authority, which is gated the same way since #5561 (#3801). See
* {@link RESUME_AUTHORITY_SERVICE} — unforgeable from an HTTP body, and
* ignored entirely on nodes that declare `'any'`.
*/
[RESUME_AUTHORITY_SERVICE]?: true;
}
/**
* [#35928] The input of {@link IAutomationService.listRecordUpdateStarts}: one
* record of `object` as it stands (`previous`) and as the proposed update
* would leave it (`record`, the stored fields with the update's fields
* applied). The caller reads the record; the engine reads nothing.
*
* Of the writer it carries the user id and tenant only. A live save also
* binds the writer's positions, request params and expand into the run, so a
* start condition reading those is judged here without them, and the preview
* can differ from the save in either direction.
*/
export interface RecordUpdateStartsInput {
/** Machine name of the record's object. */
object: string;
/** The record as the proposed update would leave it. */
record: Record<string, unknown>;
/** The record as it stands before the update. */
previous: Record<string, unknown>;
/**
* The user who would write the update — `current_user` in a start
* condition, as the record-change trigger forwards the writer on a live
* save. Absent, `current_user` is `null`.
*/
userId?: string;
/** The writer's active organization, as the trigger forwards it (`current_user.organizationId`). */
tenantId?: string;
}
/**