@elaraai/e3-ui 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/src/{data.d.ts → bind/data.d.ts} +7 -0
  2. package/dist/src/bind/data.d.ts.map +1 -0
  3. package/dist/src/{data.js → bind/data.js} +7 -0
  4. package/dist/src/bind/data.js.map +1 -0
  5. package/dist/src/bind/func.d.ts.map +1 -0
  6. package/dist/src/bind/func.js.map +1 -0
  7. package/dist/src/bind/record.d.ts +275 -0
  8. package/dist/src/bind/record.d.ts.map +1 -0
  9. package/dist/src/bind/record.js +239 -0
  10. package/dist/src/bind/record.js.map +1 -0
  11. package/dist/src/decision/bind.d.ts +1 -1
  12. package/dist/src/decision/bind.d.ts.map +1 -1
  13. package/dist/src/decision/bind.js +1 -1
  14. package/dist/src/decision/bind.js.map +1 -1
  15. package/dist/src/{diff.d.ts → diff/index.d.ts} +3 -3
  16. package/dist/src/diff/index.d.ts.map +1 -0
  17. package/dist/src/{diff.js → diff/index.js} +3 -3
  18. package/dist/src/diff/index.js.map +1 -0
  19. package/dist/src/experiment/index.d.ts +3 -3
  20. package/dist/src/experiment/index.d.ts.map +1 -1
  21. package/dist/src/experiment/index.js +2 -2
  22. package/dist/src/experiment/index.js.map +1 -1
  23. package/dist/src/index.d.ts +7 -6
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/index.js +7 -6
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/internal.d.ts +7 -6
  28. package/dist/src/internal.d.ts.map +1 -1
  29. package/dist/src/internal.js +7 -6
  30. package/dist/src/internal.js.map +1 -1
  31. package/dist/src/{ontology.d.ts → ontology/index.d.ts} +3 -3
  32. package/dist/src/ontology/index.d.ts.map +1 -0
  33. package/dist/src/{ontology.js → ontology/index.js} +3 -3
  34. package/dist/src/ontology/index.js.map +1 -0
  35. package/dist/src/runtime/diff.d.ts +1 -1
  36. package/dist/src/runtime/diff.d.ts.map +1 -1
  37. package/dist/src/runtime/diff.js +1 -1
  38. package/dist/src/runtime/diff.js.map +1 -1
  39. package/dist/src/runtime/ontology.d.ts +1 -1
  40. package/dist/src/runtime/ontology.d.ts.map +1 -1
  41. package/dist/src/runtime/ontology.js +1 -1
  42. package/dist/src/runtime/ontology.js.map +1 -1
  43. package/dist/src/ui.js +3 -3
  44. package/dist/src/ui.js.map +1 -1
  45. package/dist/src/utils/derive.d.ts +29 -0
  46. package/dist/src/utils/derive.d.ts.map +1 -0
  47. package/dist/src/utils/derive.js +57 -0
  48. package/dist/src/utils/derive.js.map +1 -0
  49. package/dist/src/{manifest.d.ts → utils/manifest.d.ts} +9 -14
  50. package/dist/src/utils/manifest.d.ts.map +1 -0
  51. package/dist/src/utils/manifest.js +37 -0
  52. package/dist/src/utils/manifest.js.map +1 -0
  53. package/dist/test/bind/data/data.examples.d.ts.map +1 -0
  54. package/dist/test/bind/data/data.examples.js.map +1 -0
  55. package/dist/test/bind/func/func.examples.d.ts.map +1 -0
  56. package/dist/test/bind/func/func.examples.js.map +1 -0
  57. package/dist/test/bind/record/record.examples.d.ts +13 -0
  58. package/dist/test/bind/record/record.examples.d.ts.map +1 -0
  59. package/dist/test/bind/record/record.examples.js +73 -0
  60. package/dist/test/bind/record/record.examples.js.map +1 -0
  61. package/dist/test/experiment/experiment.examples.d.ts +141 -0
  62. package/dist/test/experiment/experiment.examples.d.ts.map +1 -1
  63. package/dist/test/experiment/experiment.examples.js +38 -0
  64. package/dist/test/experiment/experiment.examples.js.map +1 -1
  65. package/package.json +7 -7
  66. package/dist/src/data.d.ts.map +0 -1
  67. package/dist/src/data.js.map +0 -1
  68. package/dist/src/derive.d.ts +0 -34
  69. package/dist/src/derive.d.ts.map +0 -1
  70. package/dist/src/derive.js +0 -86
  71. package/dist/src/derive.js.map +0 -1
  72. package/dist/src/diff.d.ts.map +0 -1
  73. package/dist/src/diff.js.map +0 -1
  74. package/dist/src/func.d.ts.map +0 -1
  75. package/dist/src/func.js.map +0 -1
  76. package/dist/src/manifest.d.ts.map +0 -1
  77. package/dist/src/manifest.js +0 -53
  78. package/dist/src/manifest.js.map +0 -1
  79. package/dist/src/ontology.d.ts.map +0 -1
  80. package/dist/src/ontology.js.map +0 -1
  81. package/dist/test/data/data.examples.d.ts.map +0 -1
  82. package/dist/test/data/data.examples.js.map +0 -1
  83. package/dist/test/func/func.examples.d.ts.map +0 -1
  84. package/dist/test/func/func.examples.js.map +0 -1
  85. /package/dist/src/{func.d.ts → bind/func.d.ts} +0 -0
  86. /package/dist/src/{func.js → bind/func.js} +0 -0
  87. /package/dist/test/{data → bind/data}/data.examples.d.ts +0 -0
  88. /package/dist/test/{data → bind/data}/data.examples.js +0 -0
  89. /package/dist/test/{func → bind/func}/func.examples.d.ts +0 -0
  90. /package/dist/test/{func → bind/func}/func.examples.js +0 -0
@@ -66,6 +66,11 @@ export type DiffBindingType = typeof DiffBindingType;
66
66
  * @property writeAndStart - Like `write`, but kicks the workspace dataflow
67
67
  * so downstream tasks recompute. Only meaningful when `mode = "direct"`
68
68
  * and `patch` is absent — in other modes it falls back to `write`.
69
+ * @property start - Launch the workspace dataflow on its own, without
70
+ * writing first, so downstream tasks recompute against the current
71
+ * datasets. The standalone half of `writeAndStart`; queued behind any
72
+ * pending writes, so `write(v)` then `start()` propagates the new value.
73
+ * Always returns null.
69
74
  * @property source - Read the raw source value with no overlay applied.
70
75
  * @property pending - True when there is an in-flight change waiting to be
71
76
  * committed. Always false in `mode = "direct"` without a `patch` dataset.
@@ -82,6 +87,7 @@ export declare const DataBindHandleType: <T extends EastType | string>(t: T) =>
82
87
  readonly read: FunctionType<[], T>;
83
88
  readonly write: FunctionType<[T], NullType>;
84
89
  readonly writeAndStart: FunctionType<[T], NullType>;
90
+ readonly start: FunctionType<[], NullType>;
85
91
  readonly source: FunctionType<[], T>;
86
92
  readonly pending: FunctionType<[], BooleanType>;
87
93
  readonly commit: FunctionType<[], NullType>;
@@ -143,6 +149,7 @@ export declare const bindPlatformFn: import("@elaraai/east").GenericPlatformDefi
143
149
  readonly read: FunctionType<[], "T">;
144
150
  readonly write: FunctionType<["T"], NullType>;
145
151
  readonly writeAndStart: FunctionType<["T"], NullType>;
152
+ readonly start: FunctionType<[], NullType>;
146
153
  readonly source: FunctionType<[], "T">;
147
154
  readonly pending: FunctionType<[], BooleanType>;
148
155
  readonly commit: FunctionType<[], NullType>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/bind/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAEH,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EAIV,KAAK,QAAQ,EACb,KAAK,QAAQ,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;EAG3B,CAAC;AACH,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC;AAEvD,uDAAuD;AACvD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;EAI1B,CAAC;AACH,8CAA8C;AAC9C,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,QAAQ,GAAG,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYlE,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAMhG;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkB1B,CAAC;AAMF;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC5B,2DAA2D;IAC3D,IAAI,CAAC,EAAG,mBAAmB,CAAC;IAC5B;0EACsE;IACtE,KAAK,CAAC,EAAE,UAAU,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,iBAAS,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAChC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACnC,OAAO,CAAC,EAAE,eAAe,GAC1B,UAAU,CAAC,CAAC,CAAC,CAYf;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI;;CAEP,CAAC"}
@@ -59,6 +59,11 @@ export const DiffBindingType = StructType({
59
59
  * @property writeAndStart - Like `write`, but kicks the workspace dataflow
60
60
  * so downstream tasks recompute. Only meaningful when `mode = "direct"`
61
61
  * and `patch` is absent — in other modes it falls back to `write`.
62
+ * @property start - Launch the workspace dataflow on its own, without
63
+ * writing first, so downstream tasks recompute against the current
64
+ * datasets. The standalone half of `writeAndStart`; queued behind any
65
+ * pending writes, so `write(v)` then `start()` propagates the new value.
66
+ * Always returns null.
62
67
  * @property source - Read the raw source value with no overlay applied.
63
68
  * @property pending - True when there is an in-flight change waiting to be
64
69
  * committed. Always false in `mode = "direct"` without a `patch` dataset.
@@ -75,6 +80,7 @@ export const DataBindHandleType = (t) => StructType({
75
80
  read: FunctionType([], t),
76
81
  write: FunctionType([t], NullType),
77
82
  writeAndStart: FunctionType([t], NullType),
83
+ start: FunctionType([], NullType),
78
84
  source: FunctionType([], t),
79
85
  pending: FunctionType([], BooleanType),
80
86
  commit: FunctionType([], NullType),
@@ -96,6 +102,7 @@ export const bindPlatformFn = East.genericPlatform("data_bind", ["T"], [TreePath
96
102
  read: FunctionType([], "T"),
97
103
  write: FunctionType(["T"], NullType),
98
104
  writeAndStart: FunctionType(["T"], NullType),
105
+ start: FunctionType([], NullType),
99
106
  source: FunctionType([], "T"),
100
107
  pending: FunctionType([], BooleanType),
101
108
  commit: FunctionType([], NullType),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../../src/bind/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,OAAO,GAGV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGpE,+EAA+E;AAC/E,oEAAoE;AACpE,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;IACxC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACnB,CAAC,CAAC;AAOH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACtC,MAAM,EAAE,YAAY;IACpB,KAAK,EAAG,UAAU,CAAC,YAAY,CAAC;IAChC,IAAI,EAAI,gBAAgB;CAC3B,CAAC,CAAC;AAIH,+EAA+E;AAC/E,4CAA4C;AAC5C,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAA8B,CAAI,EAAE,EAAE,CAAC,UAAU,CAAC;IAChF,IAAI,EAAW,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,KAAK,EAAU,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;IAC1C,a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;;;;;;;;;;;;;;;;;GAiDG;AACH,SAAS,YAAY,CACjB,EAA+B;IAE/B,MAAM,UAAU,GAAG,kBAAkB,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IACzE,mEAAmE;IACnE,sEAAsE;IACtE,0DAA0D;IAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,OAAO,kBAAkB,CAAC,CAAC,UAAU,CAAC,EAAE,SAAS,CAA8B,CAAC;AACpF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,IAAI,EAAE,YAAY;CACZ,CAAC"}
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Reactive record binding for e3 UI tasks — read an `e3.record`'s current
7
+ * state and apply its typed mutations from East UI code.
8
+ *
9
+ * `Record.bind` is the record-shaped sibling of `Data.bind` / `Func.bind`,
10
+ * adapting the TanStack query/mutation split to East's reactive,
11
+ * fire-and-forget model: `read` / `status` / `history` observe the record (the
12
+ * read side, served from the shared dataset cache), while `mutate.<name>(…)`
13
+ * launches a typed mutation fire-and-forget (the write side), with
14
+ * `mutate.pending` / `status` / `error` / `cancel` tracking the shared,
15
+ * latest-wins mutation lifecycle. A record's mutations serialize server-side
16
+ * under compare-and-swap, so one shared channel per record is the honest model.
17
+ *
18
+ * @packageDocumentation
19
+ */
20
+ import { ArrayType, BooleanType, FunctionType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, type EastType, type ExprType } from '@elaraai/east';
21
+ import { DatasetStatusType, RecordCommitInfoType } from '@elaraai/e3-types';
22
+ import type { RecordDef, MutationDef } from '@elaraai/e3';
23
+ /**
24
+ * Shared mutate-lifecycle tag for a bound record. One launch channel per
25
+ * record (mutations serialize via CAS), latest-wins.
26
+ *
27
+ * @remarks
28
+ * Client-defined. `idle` means no mutation has been launched through this
29
+ * binding; `cancelled` means the client stopped waiting (via `cancel()` or a
30
+ * superseding mutation) — the server's CAS reducer still ran to completion.
31
+ *
32
+ * @property idle - No mutation launched
33
+ * @property running - A mutation is in flight
34
+ * @property committed - The most recent mutation committed a new commit
35
+ * @property failed - The most recent mutation failed (see `error`)
36
+ * @property cancelled - The client stopped waiting for the most recent mutation
37
+ */
38
+ export declare const RecordMutateStatusType: VariantType<{
39
+ readonly idle: NullType;
40
+ readonly running: NullType;
41
+ readonly committed: NullType;
42
+ readonly failed: NullType;
43
+ readonly cancelled: NullType;
44
+ }>;
45
+ /** Type representing the {@link RecordMutateStatusType} structure. */
46
+ export type RecordMutateStatusType = typeof RecordMutateStatusType;
47
+ /**
48
+ * Failure detail for a bound mutation, mirroring the server's
49
+ * `MutationResult` non-committed outcome arms plus client-side transport
50
+ * errors — the record-side analogue of `FuncError`.
51
+ *
52
+ * @property kind - Which way the mutation failed:
53
+ * `invalid` (lookup/arity/signature), `failed` (reducer exited non-zero),
54
+ * `too_large` (new state exceeded the server limit), `timed_out` (reducer
55
+ * deadline hit), `conflict` (the compare-and-swap lost the race), `transport`
56
+ * (HTTP/decode failure — never reached the server).
57
+ * @property message - One-line human-readable summary, always present
58
+ * @property stderr - Captured reducer stderr (empty unless the reducer ran)
59
+ */
60
+ export declare const RecordErrorType: StructType<{
61
+ readonly kind: VariantType<{
62
+ readonly invalid: StructType<{
63
+ readonly message: StringType;
64
+ }>;
65
+ readonly failed: StructType<{
66
+ readonly exitCode: IntegerType;
67
+ }>;
68
+ readonly too_large: StructType<{
69
+ readonly bytes: IntegerType;
70
+ readonly limit: IntegerType;
71
+ }>;
72
+ readonly timed_out: StructType<{
73
+ readonly ms: IntegerType;
74
+ }>;
75
+ readonly conflict: StructType<{
76
+ readonly attempts: IntegerType;
77
+ }>;
78
+ readonly transport: StructType<{
79
+ readonly message: StringType;
80
+ }>;
81
+ }>;
82
+ readonly message: StringType;
83
+ readonly stderr: StringType;
84
+ }>;
85
+ /** Type representing the {@link RecordErrorType} structure. */
86
+ export type RecordErrorType = typeof RecordErrorType;
87
+ /**
88
+ * Descriptor for a record binding — carried on the handle's `binding` field
89
+ * for inspector surfaces.
90
+ *
91
+ * @property name - The bound record's name in the deployed package
92
+ * @property mutations - The mutation names this binding exposes
93
+ */
94
+ export declare const RecordBindingType: StructType<{
95
+ readonly name: StringType;
96
+ readonly mutations: ArrayType<StringType>;
97
+ }>;
98
+ /** Type representing the {@link RecordBindingType} structure. */
99
+ export type RecordBindingType = typeof RecordBindingType;
100
+ /**
101
+ * The struct returned by every {@link Record.bind} call. The read side
102
+ * (`read` / `status` / `history`) is served reactively from the shared dataset
103
+ * cache; the write side lives under `mutate` — one closure per mutation plus
104
+ * the shared lifecycle accessors.
105
+ *
106
+ * @remarks
107
+ * The handle's shape IS the signature: the runtime recovers the state type
108
+ * from `read`'s output and each mutation's name + arg types from the `mutate`
109
+ * sub-struct's fields, so there are no duplicate signature arguments to drift.
110
+ *
111
+ * @typeParam T - The record's East state type.
112
+ * @typeParam M - Map of mutation name to its extra positional arg types.
113
+ * @param stateType - The record's state East type.
114
+ * @param mutations - Map of mutation name to its arg types.
115
+ * @returns The handle StructType for that record + mutation set.
116
+ *
117
+ * @property read - The record's current committed state. Reactive — re-fires
118
+ * when a mutation commits (the dataset cache refreshes the record's bytes).
119
+ * @property status - Per-dataset freshness signal — see {@link DatasetStatusType}.
120
+ * @property history - The commit chain, newest first; `none` until the first
121
+ * load completes, then the cached chain (refreshed after each commit).
122
+ * @property mutate - The write surface: one fire-and-forget closure per
123
+ * mutation (typed from its def), plus the shared `pending` / `status` /
124
+ * `error` / `cancel`.
125
+ * @property start - Launch the workspace dataflow without mutating, so tasks
126
+ * that consume this record recompute against its latest committed state.
127
+ * The standalone "Run" affordance — a mutation refreshes the record's own
128
+ * bytes but does not propagate downstream until a dataflow run; call this
129
+ * (e.g. from a Run button) to drive that run. Always returns null.
130
+ * @property binding - Descriptor for this binding — see {@link RecordBindingType}.
131
+ */
132
+ export declare const RecordBindHandleType: <T extends EastType, M extends Record<string, EastType[]>>(stateType: T, mutations: M) => StructType<{
133
+ readonly read: FunctionType<[], T>;
134
+ readonly status: FunctionType<[], VariantType<{
135
+ readonly unset: NullType;
136
+ readonly stale: NullType;
137
+ readonly 'up-to-date': NullType;
138
+ }>>;
139
+ readonly history: FunctionType<[], OptionType<ArrayType<StructType<{
140
+ readonly hash: StringType;
141
+ readonly parent: OptionType<StringType>;
142
+ readonly state: StringType;
143
+ readonly mutation: StringType;
144
+ readonly actor: StringType;
145
+ readonly at: import("@elaraai/east").DateTimeType;
146
+ }>>>>;
147
+ readonly mutate: StructType<Record<string, EastType>>;
148
+ readonly start: FunctionType<[], NullType>;
149
+ readonly binding: StructType<{
150
+ readonly name: StringType;
151
+ readonly mutations: ArrayType<StringType>;
152
+ }>;
153
+ }>;
154
+ /**
155
+ * Map of each mutation's name (literal) to its extra positional arg types,
156
+ * recovered structurally from a tuple of {@link MutationDef}s.
157
+ */
158
+ type MutationsArgMap<Muts extends readonly MutationDef<string, EastType, EastType[]>[]> = {
159
+ [M in Muts[number] as M['name']]: M extends MutationDef<string, EastType, infer A> ? [...A] : never;
160
+ };
161
+ /**
162
+ * The precise East struct type of a record handle — written as a mapped type
163
+ * (rather than inferred from {@link RecordBindHandleType}'s runtime loop, which
164
+ * TS widens) so each `mutate.<name>` closure keeps its arg types.
165
+ */
166
+ type RecordHandle<T extends EastType, M extends Record<string, EastType[]>> = StructType<{
167
+ read: FunctionType<[], T>;
168
+ status: FunctionType<[], typeof DatasetStatusType>;
169
+ history: FunctionType<[], OptionType<ArrayType<typeof RecordCommitInfoType>>>;
170
+ mutate: StructType<{
171
+ pending: FunctionType<[], typeof BooleanType>;
172
+ status: FunctionType<[], RecordMutateStatusType>;
173
+ error: FunctionType<[], OptionType<RecordErrorType>>;
174
+ cancel: FunctionType<[], typeof NullType>;
175
+ } & {
176
+ [K in keyof M]: FunctionType<M[K], typeof NullType>;
177
+ }>;
178
+ start: FunctionType<[], typeof NullType>;
179
+ binding: RecordBindingType;
180
+ }>;
181
+ /**
182
+ * The TypeScript type of a {@link Record.bind} handle bound to a record of
183
+ * state type `T` with mutations `Muts` — i.e. the return of
184
+ * `Record.bind(record, [...mutations])`.
185
+ *
186
+ * @remarks
187
+ * The mutation names + arg types live structurally in the `mutate` field's
188
+ * closure signatures (recovered from the {@link MutationDef} tuple), not a
189
+ * phantom TS brand, so they survive `$.let` / `$.const` and ordinary
190
+ * expression plumbing.
191
+ *
192
+ * @typeParam T - The record's East state type.
193
+ * @typeParam Muts - The bound mutation defs (their names + arg types).
194
+ */
195
+ export type BoundRecord<T extends EastType, Muts extends readonly MutationDef<string, T, EastType[]>[]> = ExprType<RecordHandle<T, MutationsArgMap<Muts>>>;
196
+ /**
197
+ * The underlying `Record.bind` platform-function definition. End-users should
198
+ * call {@link Record.bind} (the typed factory in this module); runtime
199
+ * implementations register against this raw definition via
200
+ * `recordBindPlatformFn.implement(...)`.
201
+ *
202
+ * @remarks
203
+ * Generic over `H`, the fully-instantiated handle struct — its shape IS the
204
+ * signature (the runtime recovers the state type from `read` and the mutation
205
+ * names + arg types from `mutate`). The single literal argument is the record
206
+ * name; the record's dataset path is reconstructed runtime-side, and mutation
207
+ * names are validated against the deployed record signature.
208
+ */
209
+ export declare const recordBindPlatformFn: import("@elaraai/east").GenericPlatformDefinition<readonly ["H"], readonly [StringType], "H">;
210
+ /**
211
+ * Bind an `e3.record` and its mutations to a reactive read/mutate handle.
212
+ *
213
+ * Takes the {@link RecordDef} returned by `e3.record` plus the array of its
214
+ * {@link MutationDef}s — the state type comes from the record, and each
215
+ * mutation's name and arg types come from its def, the same way `Func.bind`
216
+ * takes a function's signature from its `FunctionDef`. The binding is correct
217
+ * by construction: it cannot drift from the deployed record's mutations.
218
+ *
219
+ * @typeParam T - The record's state East type (from the def).
220
+ * @typeParam Muts - The mutation defs to expose (names + arg types from defs).
221
+ * @param record - The `e3.record` definition to bind.
222
+ * @param mutations - The mutations to expose on `handle.mutate`.
223
+ * @returns A handle struct described by {@link RecordBindHandleType} —
224
+ * `read` / `status` / `history` / `mutate.{<name>,pending,status,error,cancel}`
225
+ * / `binding`.
226
+ *
227
+ * @remarks
228
+ * The launch/observe split is the same shape `Func.bind` uses for `call`:
229
+ * `mutate.<name>` never blocks, and everything you'd want back arrives through
230
+ * `read` / `mutate.status` / `mutate.error` on the next reactive render. A
231
+ * committed mutation auto-refreshes `read()` (the record's dataset bytes are
232
+ * re-fetched) — no manual invalidation. All handles bound to the same record
233
+ * in the same workspace share one mutation channel.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * import { East, IntegerType, NullType } from "@elaraai/east";
238
+ * import { Button, Reactive, Stat, UIComponentType, VStack } from "@elaraai/east-ui";
239
+ * import { Record } from "@elaraai/e3-ui";
240
+ * import e3 from "@elaraai/e3";
241
+ *
242
+ * const counter = e3.record("counter", IntegerType, 0n);
243
+ * const increment = e3.mutation("increment", counter,
244
+ * East.function([IntegerType, IntegerType], IntegerType, ($, state, by) => state.add(by)));
245
+ *
246
+ * const counterUi = East.function([], UIComponentType, _$ =>
247
+ * Reactive.Root(East.function([], UIComponentType, $ => {
248
+ * const r = $.let(Record.bind(counter, [increment]));
249
+ * const bump = $.const(East.function([], NullType, $ => { $(r.mutate.increment(1n)); }));
250
+ * return VStack.Root([
251
+ * Stat.Root({ label: "Counter", value: East.print(r.read()) }),
252
+ * Button.Root("Increment", { onClick: bump, loading: r.mutate.pending() }),
253
+ * ], { gap: "3" });
254
+ * })));
255
+ * ```
256
+ */
257
+ declare function bindRecord<T extends EastType, Muts extends readonly MutationDef<string, T, EastType[]>[]>(record: RecordDef<T>, mutations: [...Muts]): BoundRecord<T, Muts>;
258
+ /**
259
+ * The Record namespace — reactive record (read + mutate + history) binding for
260
+ * e3 UI tasks.
261
+ *
262
+ * @remarks
263
+ * `Record.bind` binds an `e3.record` and its mutations to a handle: `read` /
264
+ * `status` / `history` observe the record's current state (served from the
265
+ * shared dataset cache), and `mutate.<name>` applies a typed mutation
266
+ * fire-and-forget under compare-and-swap, refreshing `read()` on commit.
267
+ *
268
+ * Use inside `Reactive.Root` for reactive re-rendering as the record and the
269
+ * mutation lifecycle change.
270
+ */
271
+ export declare const Record: {
272
+ readonly bind: typeof bindRecord;
273
+ };
274
+ export {};
275
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/bind/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEH,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,QAAQ,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB;;;;;;EAMjC,CAAC;AAEH,sEAAsE;AACtE,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;EAW1B,CAAC;AAEH,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AAEH,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC;AAMzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,o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C,CAAC,CAAC,CAAC,EAAE,OAAO,QAAQ,CAAC;KAAE,CAC9D,CAAC;IACF,KAAK,EAAI,YAAY,CAAC,EAAE,EAAE,OAAO,QAAQ,CAAC,CAAC;IAC3C,OAAO,EAAE,iBAAiB,CAAC;CAC9B,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,CACnB,CAAC,SAAS,QAAQ,EAClB,IAAI,SAAS,SAAS,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAC1D,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAMrD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,+FAMhC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,iBAAS,UAAU,CACf,CAAC,SAAS,QAAQ,EAClB,IAAI,SAAS,SAAS,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAE1D,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACpB,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,GACrB,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAgBtB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM;;CAET,CAAC"}
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Reactive record binding for e3 UI tasks — read an `e3.record`'s current
7
+ * state and apply its typed mutations from East UI code.
8
+ *
9
+ * `Record.bind` is the record-shaped sibling of `Data.bind` / `Func.bind`,
10
+ * adapting the TanStack query/mutation split to East's reactive,
11
+ * fire-and-forget model: `read` / `status` / `history` observe the record (the
12
+ * read side, served from the shared dataset cache), while `mutate.<name>(…)`
13
+ * launches a typed mutation fire-and-forget (the write side), with
14
+ * `mutate.pending` / `status` / `error` / `cancel` tracking the shared,
15
+ * latest-wins mutation lifecycle. A record's mutations serialize server-side
16
+ * under compare-and-swap, so one shared channel per record is the honest model.
17
+ *
18
+ * @packageDocumentation
19
+ */
20
+ import { East, ArrayType, BooleanType, FunctionType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, } from '@elaraai/east';
21
+ import { DatasetStatusType, RecordCommitInfoType } from '@elaraai/e3-types';
22
+ // ============================================================================
23
+ // Status + error + descriptor types
24
+ // ============================================================================
25
+ /**
26
+ * Shared mutate-lifecycle tag for a bound record. One launch channel per
27
+ * record (mutations serialize via CAS), latest-wins.
28
+ *
29
+ * @remarks
30
+ * Client-defined. `idle` means no mutation has been launched through this
31
+ * binding; `cancelled` means the client stopped waiting (via `cancel()` or a
32
+ * superseding mutation) — the server's CAS reducer still ran to completion.
33
+ *
34
+ * @property idle - No mutation launched
35
+ * @property running - A mutation is in flight
36
+ * @property committed - The most recent mutation committed a new commit
37
+ * @property failed - The most recent mutation failed (see `error`)
38
+ * @property cancelled - The client stopped waiting for the most recent mutation
39
+ */
40
+ export const RecordMutateStatusType = VariantType({
41
+ idle: NullType,
42
+ running: NullType,
43
+ committed: NullType,
44
+ failed: NullType,
45
+ cancelled: NullType,
46
+ });
47
+ /**
48
+ * Failure detail for a bound mutation, mirroring the server's
49
+ * `MutationResult` non-committed outcome arms plus client-side transport
50
+ * errors — the record-side analogue of `FuncError`.
51
+ *
52
+ * @property kind - Which way the mutation failed:
53
+ * `invalid` (lookup/arity/signature), `failed` (reducer exited non-zero),
54
+ * `too_large` (new state exceeded the server limit), `timed_out` (reducer
55
+ * deadline hit), `conflict` (the compare-and-swap lost the race), `transport`
56
+ * (HTTP/decode failure — never reached the server).
57
+ * @property message - One-line human-readable summary, always present
58
+ * @property stderr - Captured reducer stderr (empty unless the reducer ran)
59
+ */
60
+ export const RecordErrorType = StructType({
61
+ kind: VariantType({
62
+ invalid: StructType({ message: StringType }),
63
+ failed: StructType({ exitCode: IntegerType }),
64
+ too_large: StructType({ bytes: IntegerType, limit: IntegerType }),
65
+ timed_out: StructType({ ms: IntegerType }),
66
+ conflict: StructType({ attempts: IntegerType }),
67
+ transport: StructType({ message: StringType }),
68
+ }),
69
+ message: StringType,
70
+ stderr: StringType,
71
+ });
72
+ /**
73
+ * Descriptor for a record binding — carried on the handle's `binding` field
74
+ * for inspector surfaces.
75
+ *
76
+ * @property name - The bound record's name in the deployed package
77
+ * @property mutations - The mutation names this binding exposes
78
+ */
79
+ export const RecordBindingType = StructType({
80
+ name: StringType,
81
+ mutations: ArrayType(StringType),
82
+ });
83
+ // ============================================================================
84
+ // Bind handle — return type of `Record.bind`.
85
+ // ============================================================================
86
+ /**
87
+ * The struct returned by every {@link Record.bind} call. The read side
88
+ * (`read` / `status` / `history`) is served reactively from the shared dataset
89
+ * cache; the write side lives under `mutate` — one closure per mutation plus
90
+ * the shared lifecycle accessors.
91
+ *
92
+ * @remarks
93
+ * The handle's shape IS the signature: the runtime recovers the state type
94
+ * from `read`'s output and each mutation's name + arg types from the `mutate`
95
+ * sub-struct's fields, so there are no duplicate signature arguments to drift.
96
+ *
97
+ * @typeParam T - The record's East state type.
98
+ * @typeParam M - Map of mutation name to its extra positional arg types.
99
+ * @param stateType - The record's state East type.
100
+ * @param mutations - Map of mutation name to its arg types.
101
+ * @returns The handle StructType for that record + mutation set.
102
+ *
103
+ * @property read - The record's current committed state. Reactive — re-fires
104
+ * when a mutation commits (the dataset cache refreshes the record's bytes).
105
+ * @property status - Per-dataset freshness signal — see {@link DatasetStatusType}.
106
+ * @property history - The commit chain, newest first; `none` until the first
107
+ * load completes, then the cached chain (refreshed after each commit).
108
+ * @property mutate - The write surface: one fire-and-forget closure per
109
+ * mutation (typed from its def), plus the shared `pending` / `status` /
110
+ * `error` / `cancel`.
111
+ * @property start - Launch the workspace dataflow without mutating, so tasks
112
+ * that consume this record recompute against its latest committed state.
113
+ * The standalone "Run" affordance — a mutation refreshes the record's own
114
+ * bytes but does not propagate downstream until a dataflow run; call this
115
+ * (e.g. from a Run button) to drive that run. Always returns null.
116
+ * @property binding - Descriptor for this binding — see {@link RecordBindingType}.
117
+ */
118
+ export const RecordBindHandleType = (stateType, mutations) => {
119
+ const mutateFields = {
120
+ pending: FunctionType([], BooleanType),
121
+ status: FunctionType([], RecordMutateStatusType),
122
+ error: FunctionType([], OptionType(RecordErrorType)),
123
+ cancel: FunctionType([], NullType),
124
+ };
125
+ for (const [name, argTypes] of Object.entries(mutations)) {
126
+ if (name in mutateFields) {
127
+ throw new Error(`Record.bind: mutation name "${name}" collides with a reserved mutate ` +
128
+ `field (pending/status/error/cancel). Rename the mutation.`);
129
+ }
130
+ mutateFields[name] = FunctionType(argTypes, NullType);
131
+ }
132
+ return StructType({
133
+ read: FunctionType([], stateType),
134
+ status: FunctionType([], DatasetStatusType),
135
+ history: FunctionType([], OptionType(ArrayType(RecordCommitInfoType))),
136
+ mutate: StructType(mutateFields),
137
+ start: FunctionType([], NullType),
138
+ binding: RecordBindingType,
139
+ });
140
+ };
141
+ // ============================================================================
142
+ // Platform function — single generic over the instantiated handle type.
143
+ // ============================================================================
144
+ /**
145
+ * The underlying `Record.bind` platform-function definition. End-users should
146
+ * call {@link Record.bind} (the typed factory in this module); runtime
147
+ * implementations register against this raw definition via
148
+ * `recordBindPlatformFn.implement(...)`.
149
+ *
150
+ * @remarks
151
+ * Generic over `H`, the fully-instantiated handle struct — its shape IS the
152
+ * signature (the runtime recovers the state type from `read` and the mutation
153
+ * names + arg types from `mutate`). The single literal argument is the record
154
+ * name; the record's dataset path is reconstructed runtime-side, and mutation
155
+ * names are validated against the deployed record signature.
156
+ */
157
+ export const recordBindPlatformFn = East.genericPlatform("record_bind", ["H"], [StringType], "H", { optional: true });
158
+ // ============================================================================
159
+ // User-facing factory.
160
+ // ============================================================================
161
+ /**
162
+ * Bind an `e3.record` and its mutations to a reactive read/mutate handle.
163
+ *
164
+ * Takes the {@link RecordDef} returned by `e3.record` plus the array of its
165
+ * {@link MutationDef}s — the state type comes from the record, and each
166
+ * mutation's name and arg types come from its def, the same way `Func.bind`
167
+ * takes a function's signature from its `FunctionDef`. The binding is correct
168
+ * by construction: it cannot drift from the deployed record's mutations.
169
+ *
170
+ * @typeParam T - The record's state East type (from the def).
171
+ * @typeParam Muts - The mutation defs to expose (names + arg types from defs).
172
+ * @param record - The `e3.record` definition to bind.
173
+ * @param mutations - The mutations to expose on `handle.mutate`.
174
+ * @returns A handle struct described by {@link RecordBindHandleType} —
175
+ * `read` / `status` / `history` / `mutate.{<name>,pending,status,error,cancel}`
176
+ * / `binding`.
177
+ *
178
+ * @remarks
179
+ * The launch/observe split is the same shape `Func.bind` uses for `call`:
180
+ * `mutate.<name>` never blocks, and everything you'd want back arrives through
181
+ * `read` / `mutate.status` / `mutate.error` on the next reactive render. A
182
+ * committed mutation auto-refreshes `read()` (the record's dataset bytes are
183
+ * re-fetched) — no manual invalidation. All handles bound to the same record
184
+ * in the same workspace share one mutation channel.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * import { East, IntegerType, NullType } from "@elaraai/east";
189
+ * import { Button, Reactive, Stat, UIComponentType, VStack } from "@elaraai/east-ui";
190
+ * import { Record } from "@elaraai/e3-ui";
191
+ * import e3 from "@elaraai/e3";
192
+ *
193
+ * const counter = e3.record("counter", IntegerType, 0n);
194
+ * const increment = e3.mutation("increment", counter,
195
+ * East.function([IntegerType, IntegerType], IntegerType, ($, state, by) => state.add(by)));
196
+ *
197
+ * const counterUi = East.function([], UIComponentType, _$ =>
198
+ * Reactive.Root(East.function([], UIComponentType, $ => {
199
+ * const r = $.let(Record.bind(counter, [increment]));
200
+ * const bump = $.const(East.function([], NullType, $ => { $(r.mutate.increment(1n)); }));
201
+ * return VStack.Root([
202
+ * Stat.Root({ label: "Counter", value: East.print(r.read()) }),
203
+ * Button.Root("Increment", { onClick: bump, loading: r.mutate.pending() }),
204
+ * ], { gap: "3" });
205
+ * })));
206
+ * ```
207
+ */
208
+ function bindRecord(record, mutations) {
209
+ const mutMap = {};
210
+ for (const m of mutations) {
211
+ if (m.record.name !== record.name) {
212
+ throw new Error(`Record.bind: mutation "${m.name}" writes record "${m.record.name}", not "${record.name}".`);
213
+ }
214
+ mutMap[m.name] = [...m.argTypes];
215
+ }
216
+ const handleType = RecordBindHandleType(record.type, mutMap);
217
+ // The record name must be a single literal Value IR node — the only shape
218
+ // manifest derivation (`derive.ts`) handles. `record.name` is a static JS
219
+ // string at IR-build time, so this holds by construction.
220
+ const nameValue = East.value(record.name, StringType);
221
+ return recordBindPlatformFn([handleType], nameValue);
222
+ }
223
+ /**
224
+ * The Record namespace — reactive record (read + mutate + history) binding for
225
+ * e3 UI tasks.
226
+ *
227
+ * @remarks
228
+ * `Record.bind` binds an `e3.record` and its mutations to a handle: `read` /
229
+ * `status` / `history` observe the record's current state (served from the
230
+ * shared dataset cache), and `mutate.<name>` applies a typed mutation
231
+ * fire-and-forget under compare-and-swap, refreshing `read()` on commit.
232
+ *
233
+ * Use inside `Reactive.Root` for reactive re-rendering as the record and the
234
+ * mutation lifecycle change.
235
+ */
236
+ export const Record = {
237
+ bind: bindRecord,
238
+ };
239
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/bind/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACH,IAAI,EACJ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,+EAA+E;AAC/E,oCAAoC;AACpC,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,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pB,SAAoB;IAEpB,MAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACX,0BAA0B,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC,IAAI,IAAI,CAC9F,CAAC;QACN,CAAC;QACD,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,UAAU,GAAG,oBAAoB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7D,0EAA0E;IAC1E,0EAA0E;IAC1E,0DAA0D;IAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACtD,OAAO,oBAAoB,CAAC,CAAC,UAAU,CAAC,EAAE,SAAS,CAAyB,CAAC;AACjF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,IAAI,EAAE,UAAU;CACV,CAAC"}
@@ -28,7 +28,7 @@
28
28
  */
29
29
  import { ArrayType, DictType, OptionType, StructType, VariantType, FunctionType, StringType, IntegerType, NullType, type EastType, type ExprType, type SubtypeExprOrValue } from '@elaraai/east';
30
30
  import { SliceStateType } from '@elaraai/east-ui/internal';
31
- import { type BoundValue } from '../data.js';
31
+ import { type BoundValue } from '../bind/data.js';
32
32
  import { DecisionType, DecisionConstraintType } from './types.js';
33
33
  /**
34
34
  * The derived commit gate for one case — a pure function of the decision's