@reventlessdev/reventless-core 3.0.0-alpha.320 → 3.0.0-alpha.321

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 3.0.0-alpha.321 (2026-10-30)
7
+
8
+ ### Features
9
+
10
+ * **outbound:** a work item with personal data is stored like an event ([5588bbe](https://github.com/ReventlessDev/reventless-core/commit/5588bbeaccc5032800d02871243c70147c669ebd))
11
+
12
+
6
13
  # 3.0.0-alpha.320 (2026-10-30)
7
14
 
8
15
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-core",
3
- "version": "3.0.0-alpha.320",
3
+ "version": "3.0.0-alpha.321",
4
4
  "description": "Core package for Reventless framework",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -29,16 +29,16 @@
29
29
  "sury": "11.0.0",
30
30
  "uuid": "^13.0.0",
31
31
  "@reventlessdev/rescript-effect": "1.0.0-alpha.1",
32
+ "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.24",
32
33
  "@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
33
34
  "@reventlessdev/rescript-node": "2.0.0-alpha.24",
34
35
  "@reventlessdev/rescript-jest": "1.0.0-alpha.13",
35
- "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.24",
36
- "@reventlessdev/rescript-ssh2": "2.0.0-alpha.25",
37
36
  "@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
38
- "@reventlessdev/reventless-infra": "3.0.0-alpha.217",
39
- "@reventlessdev/reventless-spec": "3.0.0-alpha.188",
37
+ "@reventlessdev/rescript-ssh2": "2.0.0-alpha.25",
40
38
  "@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
41
- "@reventlessdev/reventless-interop": "3.0.0-alpha.42"
39
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.218",
40
+ "@reventlessdev/reventless-interop": "3.0.0-alpha.42",
41
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.189"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rescript": "12.3.1",
@@ -189,7 +189,7 @@ module Make = (
189
189
  Effect.promise(
190
190
  async () => {
191
191
  // Phase 1: collect outbound items
192
- Callback.phase1(eventsArr)
192
+ await Callback.phase1(eventsArr, ~capabilities=Capabilities.capabilities())
193
193
  // Sync the post-phase-1 TODO state so consumers awaiting the
194
194
  // originating publishEvent observe Pending rows immediately.
195
195
  await syncToQueryDb(queryDbOps)
@@ -108,7 +108,7 @@ function Make(RuntimeEnvironment) {
108
108
  return [];
109
109
  }
110
110
  })), events => Stream$1.fromIterable(events))), eventsArr => Effect.promise(async () => {
111
- Callback.phase1(eventsArr);
111
+ await Callback.phase1(eventsArr, Capabilities.capabilities());
112
112
  await syncToQueryDb(queryDbOps);
113
113
  Stdlib_Promise.$$catch(Callback.phase2(publishJsonsFn, Capabilities.capabilities()).then(() => syncToQueryDb(queryDbOps)), exn => {
114
114
  let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
@@ -79,7 +79,10 @@ the AWS entry point kept passing bare events and nothing complained, because its
79
79
  hand-written copy was internally consistent. The mismatch surfaced only at
80
80
  runtime, as `undefined` destructured from a tuple that was never a tuple.
81
81
  */
82
- type phase1<'event> = array<(string, 'event)> => unit
82
+ type phase1<'event> = (
83
+ array<(string, 'event)>,
84
+ ~capabilities: Reventless.Capabilities.t,
85
+ ) => promise<unit>
83
86
 
84
87
  /** Phase 2: translate all pending items, optionally publishing commands.
85
88
 
@@ -109,7 +112,8 @@ module type T = {
109
112
 
110
113
  /** Phase 1: update TODO list from a batch of `(sourceId, event)` pairs
111
114
  (collect only, no resolve). `sourceId` is the envelope id of the entity the
112
- event was published for. */
115
+ event was published for. `~capabilities` supplies the key a personal item's
116
+ row id is fingerprinted with. */
113
117
  let phase1: phase1<Spec.consumedEvent>
114
118
 
115
119
  /** Phase 2: translate all pending items, optionally publishing commands via publishJsons. */
@@ -201,25 +205,82 @@ module Make = (
201
205
  )->Effect.runSync
202
206
  }
203
207
 
204
- let phase1 = (events: array<(string, Spec.consumedEvent)>) => {
205
- events->Array.forEach(((sourceId, event)) => {
208
+ // A work item that carries personal data is stored the way an event is: its
209
+ // marked fields sealed, and its row keyed by a fingerprint of the key `collect`
210
+ // chose, which may hold the address the work is about. A table key can be
211
+ // neither encrypted nor erased.
212
+ let personalFields = Reventless.Pii.recordFields(Spec.outboundItemSchema)
213
+ let fingerprintPurpose = `outboundWorkItem:${Spec.name}`
214
+ let warnedUnkeyed = ref(false)
215
+
216
+ /** The id a row is stored under, or `None` when it cannot be stored safely. */
217
+ let storedKey = (key, ~capabilities: Reventless.Capabilities.t): option<string> =>
218
+ if personalFields == [] {
219
+ Some(key)
220
+ } else {
221
+ switch capabilities.secrets.fingerprint(~purpose=fingerprintPurpose, key) {
222
+ | Ok(fingerprint) => Some(fingerprint)
223
+ | Error(Unavailable(why)) =>
224
+ if Reventless.Pii.Provider.isRequired() {
225
+ EffectLogger.logError(
226
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
227
+ `a work item was not stored: its row id cannot be fingerprinted (${why})`,
228
+ )->Effect.runSync
229
+ None
230
+ } else {
231
+ if !warnedUnkeyed.contents {
232
+ warnedUnkeyed := true
233
+ EffectLogger.logWarn(
234
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
235
+ `work items carrying personal data are keyed in the clear: no key to fingerprint them with (${why})`,
236
+ )->Effect.runSync
237
+ }
238
+ Some(key)
239
+ }
240
+ }
241
+ }
242
+
243
+ let phase1 = async (
244
+ events: array<(string, Spec.consumedEvent)>,
245
+ ~capabilities: Reventless.Capabilities.t,
246
+ ) =>
247
+ for i in 0 to events->Array.length - 1 {
248
+ let (sourceId, event) = events->Array.getUnsafe(i)
206
249
  // Collect new outbound items
207
- Translation.collect(event, ~sourceId)->Array.forEach(((id, item)) => {
208
- switch todoItems->Dict.get(id) {
209
- | Some(_) => () // Already exists -- skip (idempotent)
210
- | None =>
211
- let row: todoRow = {
212
- item: item->Reventless.Util_Sury.toJson(Spec.outboundItemSchema),
213
- status: Pending,
214
- createdAt: now(),
215
- retryCount: 0,
216
- maxRetries: Spec.maxRetries,
250
+ let collected = Translation.collect(event, ~sourceId)
251
+ for j in 0 to collected->Array.length - 1 {
252
+ let (key, item) = collected->Array.getUnsafe(j)
253
+ switch storedKey(key, ~capabilities) {
254
+ | None => ()
255
+ | Some(id) if todoItems->Dict.get(id)->Option.isSome => () // idempotent
256
+ | Some(id) =>
257
+ let json = item->Reventless.Util_Sury.toJson(Spec.outboundItemSchema)
258
+ let stored = switch json {
259
+ | Object(data) if personalFields != [] =>
260
+ (
261
+ await Reventless.Pii.sealRecord(Spec.outboundItemSchema, data)
262
+ )->Result.map(d => JSON.Object(d))
263
+ | other => Ok(other)
264
+ }
265
+ switch stored {
266
+ | Error(e) =>
267
+ EffectLogger.logError(
268
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
269
+ `a work item was not stored: ${e->Reventless.Pii.errorMessage}`,
270
+ )->Effect.runSync
271
+ | Ok(stored) =>
272
+ let row: todoRow = {
273
+ item: stored,
274
+ status: Pending,
275
+ createdAt: now(),
276
+ retryCount: 0,
277
+ maxRetries: Spec.maxRetries,
278
+ }
279
+ todoItems->Dict.set(id, row)
217
280
  }
218
- todoItems->Dict.set(id, row)
219
281
  }
220
- })
221
- })
222
- }
282
+ }
283
+ }
223
284
 
224
285
  let phase2 = async (
225
286
  publishJsons: ReventlessInfra.CommandTopic.publishJsons,
@@ -253,15 +314,50 @@ module Make = (
253
314
  let _ = await pending->Array.reduce(Promise.resolve(), async (prev, (id, row)) => {
254
315
  let _ = await prev
255
316
 
256
- let item = try row.item->Reventless.Util_Sury.fromJson(Spec.outboundItemSchema)->Some catch {
257
- | exn =>
258
- let errMsg =
259
- exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
317
+ // Opened first: a personal field is sealed in the row, and one whose
318
+ // subject was erased since leaves nothing to send.
319
+ let opened = switch row.item {
320
+ | Object(data) if personalFields != [] =>
321
+ switch await Reventless.Pii.openRecord(Spec.outboundItemSchema, data) {
322
+ | Ok(data) =>
323
+ switch Reventless.Pii.goneField(Spec.outboundItemSchema, data) {
324
+ | Some(field) => Error(#Gone(field))
325
+ | None => Ok(JSON.Object(data))
326
+ }
327
+ | Error(e) => Error(#Unopened(e->Reventless.Pii.errorMessage))
328
+ }
329
+ | other => Ok(other)
330
+ }
331
+ let item = switch opened {
332
+ | Error(#Gone(field)) =>
333
+ EffectLogger.logInfo(
334
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
335
+ `${id}: its ${field} was erased; nothing to do`,
336
+ )->Effect.runSync
337
+ todoItems->Dict.set(id, {...row, status: Completed, completedAt: now()})
338
+ None
339
+ | Error(#Unopened(why)) =>
260
340
  EffectLogger.logError(
261
341
  ~comp=`OutboundTranslationSlice(${Spec.name})`,
262
- `failed to decode outboundItem: ${errMsg}`,
342
+ `${id}: its work item does not open: ${why}`,
263
343
  )->Effect.runSync
344
+ let updated = row->afterFailedAttempt(~lastError=why)
345
+ todoItems->Dict.set(id, updated)
346
+ if updated.status == Abandoned {
347
+ newlyAbandoned->Array.push(id)
348
+ }
264
349
  None
350
+ | Ok(itemJson) =>
351
+ try itemJson->Reventless.Util_Sury.fromJson(Spec.outboundItemSchema)->Some catch {
352
+ | exn =>
353
+ let errMsg =
354
+ exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
355
+ EffectLogger.logError(
356
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
357
+ `failed to decode outboundItem: ${errMsg}`,
358
+ )->Effect.runSync
359
+ None
360
+ }
265
361
  }
266
362
 
267
363
  switch item {
@@ -4,7 +4,10 @@ import * as Sury from "sury";
4
4
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
5
5
  import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
6
6
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
7
+ import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
7
8
  import * as Effect from "effect/Effect";
9
+ import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
10
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
8
11
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
9
12
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
10
13
  import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
@@ -82,27 +85,63 @@ function Make(Spec) {
82
85
  return Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `retries exhausted for ` + id + `, and the abandonment command could not be published: ` + errMsg));
83
86
  }
84
87
  };
85
- let phase1 = events => {
86
- events.forEach(param => {
87
- Translation.collect(param[1], param[0]).forEach(param => {
88
- let id = param[0];
89
- let match = todoItems[id];
90
- if (match !== undefined) {
91
- return;
88
+ let personalFields = Pii$Reventless.recordFields(Spec.outboundItemSchema);
89
+ let fingerprintPurpose = `outboundWorkItem:` + Spec.name;
90
+ let warnedUnkeyed = {
91
+ contents: false
92
+ };
93
+ let storedKey = (key, capabilities) => {
94
+ if (Primitive_object.equal(personalFields, [])) {
95
+ return key;
96
+ }
97
+ let fingerprint = capabilities.secrets.fingerprint(fingerprintPurpose, key);
98
+ if (fingerprint.TAG === "Ok") {
99
+ return fingerprint._0;
100
+ }
101
+ let why = fingerprint._0._0;
102
+ if (Pii$Reventless.Provider.isRequired()) {
103
+ Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `a work item was not stored: its row id cannot be fingerprinted (` + why + `)`));
104
+ return;
105
+ } else {
106
+ if (!warnedUnkeyed.contents) {
107
+ warnedUnkeyed.contents = true;
108
+ Effect.runSync(EffectLogger$ReventlessCore.logWarn(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `work items carrying personal data are keyed in the clear: no key to fingerprint them with (` + why + `)`));
109
+ }
110
+ return key;
111
+ }
112
+ };
113
+ let phase1 = async (events, capabilities) => {
114
+ for (let i = 0, i_finish = events.length; i < i_finish; ++i) {
115
+ let match = events[i];
116
+ let collected = Translation.collect(match[1], match[0]);
117
+ for (let j = 0, j_finish = collected.length; j < j_finish; ++j) {
118
+ let match$1 = collected[j];
119
+ let id = storedKey(match$1[0], capabilities);
120
+ if (id !== undefined && !Stdlib_Option.isSome(todoItems[id])) {
121
+ let json = Util_Sury$Reventless.toJson(match$1[1], Spec.outboundItemSchema);
122
+ let stored;
123
+ stored = typeof json === "object" && json !== null && !Array.isArray(json) && Primitive_object.notequal(personalFields, []) ? Stdlib_Result.map(await Pii$Reventless.sealRecord(Spec.outboundItemSchema, json), d => (d)) : ({
124
+ TAG: "Ok",
125
+ _0: json
126
+ });
127
+ if (stored.TAG === "Ok") {
128
+ let row_item = stored._0;
129
+ let row_createdAt = new Date().toISOString();
130
+ let row_maxRetries = Spec.maxRetries;
131
+ let row = {
132
+ item: row_item,
133
+ status: "Pending",
134
+ createdAt: row_createdAt,
135
+ retryCount: 0,
136
+ maxRetries: row_maxRetries
137
+ };
138
+ todoItems[id] = row;
139
+ } else {
140
+ Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `a work item was not stored: ` + Pii$Reventless.errorMessage(stored._0)));
141
+ }
92
142
  }
93
- let row_item = Util_Sury$Reventless.toJson(param[1], Spec.outboundItemSchema);
94
- let row_createdAt = new Date().toISOString();
95
- let row_maxRetries = Spec.maxRetries;
96
- let row = {
97
- item: row_item,
98
- status: "Pending",
99
- createdAt: row_createdAt,
100
- retryCount: 0,
101
- maxRetries: row_maxRetries
102
- };
103
- todoItems[id] = row;
104
- });
105
- });
143
+ }
144
+ }
106
145
  };
107
146
  let phase2 = async (publishJsons, capabilities) => {
108
147
  let newlyAbandoned = [];
@@ -131,22 +170,75 @@ function Make(Spec) {
131
170
  let row = param[1];
132
171
  let id = param[0];
133
172
  await prev;
173
+ let data = row.item;
174
+ let opened;
175
+ if (typeof data === "object" && data !== null && !Array.isArray(data) && Primitive_object.notequal(personalFields, [])) {
176
+ let data$1 = await Pii$Reventless.openRecord(Spec.outboundItemSchema, data);
177
+ if (data$1.TAG === "Ok") {
178
+ let data$2 = data$1._0;
179
+ let field = Pii$Reventless.goneField(Spec.outboundItemSchema, data$2);
180
+ opened = field !== undefined ? ({
181
+ TAG: "Error",
182
+ _0: {
183
+ NAME: "Gone",
184
+ VAL: field
185
+ }
186
+ }) : ({
187
+ TAG: "Ok",
188
+ _0: data$2
189
+ });
190
+ } else {
191
+ opened = {
192
+ TAG: "Error",
193
+ _0: {
194
+ NAME: "Unopened",
195
+ VAL: Pii$Reventless.errorMessage(data$1._0)
196
+ }
197
+ };
198
+ }
199
+ } else {
200
+ opened = {
201
+ TAG: "Ok",
202
+ _0: data
203
+ };
204
+ }
134
205
  let item;
135
- try {
136
- item = Primitive_option.some(Util_Sury$Reventless.fromJson(row.item, Spec.outboundItemSchema));
137
- } catch (raw_exn) {
138
- let exn = Primitive_exceptions.internalToException(raw_exn);
139
- let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
140
- Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to decode outboundItem: ` + errMsg));
141
- item = undefined;
206
+ if (opened.TAG === "Ok") {
207
+ try {
208
+ item = Primitive_option.some(Util_Sury$Reventless.fromJson(opened._0, Spec.outboundItemSchema));
209
+ } catch (raw_exn) {
210
+ let exn = Primitive_exceptions.internalToException(raw_exn);
211
+ let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
212
+ Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to decode outboundItem: ` + errMsg));
213
+ item = undefined;
214
+ }
215
+ } else {
216
+ let match = opened._0;
217
+ if (match.NAME === "Gone") {
218
+ Effect.runSync(EffectLogger$ReventlessCore.logInfo(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, id + `: its ` + match.VAL + ` was erased; nothing to do`));
219
+ let newrecord = {...row};
220
+ newrecord.completedAt = new Date().toISOString();
221
+ newrecord.status = "Completed";
222
+ todoItems[id] = newrecord;
223
+ item = undefined;
224
+ } else {
225
+ let why = match.VAL;
226
+ Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, id + `: its work item does not open: ` + why));
227
+ let updated = afterFailedAttempt(row, why);
228
+ todoItems[id] = updated;
229
+ if (updated.status === "Abandoned") {
230
+ newlyAbandoned.push(id);
231
+ }
232
+ item = undefined;
233
+ }
142
234
  }
143
235
  if (item === undefined) {
144
236
  return;
145
237
  }
146
- let newrecord = {...row};
147
- newrecord.processedAt = new Date().toISOString();
148
- newrecord.status = "Processing";
149
- todoItems[id] = newrecord;
238
+ let newrecord$1 = {...row};
239
+ newrecord$1.processedAt = new Date().toISOString();
240
+ newrecord$1.status = "Processing";
241
+ todoItems[id] = newrecord$1;
150
242
  let result;
151
243
  try {
152
244
  result = await Translation.translate(id, Primitive_option.valFromOption(item), capabilities);
@@ -159,11 +251,11 @@ function Make(Spec) {
159
251
  };
160
252
  }
161
253
  if (result.TAG === "Ok") {
162
- let match = result._0;
163
- if (match !== undefined) {
254
+ let match$1 = result._0;
255
+ if (match$1 !== undefined) {
164
256
  let commandJson;
165
257
  try {
166
- commandJson = Util_Sury$Reventless.toJson(match[1], Spec.inboundCommandSchema);
258
+ commandJson = Util_Sury$Reventless.toJson(match$1[1], Spec.inboundCommandSchema);
167
259
  } catch (raw_exn$2) {
168
260
  let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
169
261
  let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
@@ -172,7 +264,7 @@ function Make(Spec) {
172
264
  }
173
265
  if (commandJson !== undefined) {
174
266
  try {
175
- let msg_id = match[0];
267
+ let msg_id = match$1[0];
176
268
  let msg_meta = makeMeta();
177
269
  let msg$1 = {
178
270
  id: msg_id,
@@ -180,18 +272,18 @@ function Make(Spec) {
180
272
  commandJson: commandJson
181
273
  };
182
274
  await publishJsons([msg$1]);
183
- let newrecord$1 = {...row};
184
- newrecord$1.completedAt = new Date().toISOString();
185
- newrecord$1.status = "Completed";
186
- todoItems[id] = newrecord$1;
275
+ let newrecord$2 = {...row};
276
+ newrecord$2.completedAt = new Date().toISOString();
277
+ newrecord$2.status = "Completed";
278
+ todoItems[id] = newrecord$2;
187
279
  return;
188
280
  } catch (raw_exn$3) {
189
281
  let exn$3 = Primitive_exceptions.internalToException(raw_exn$3);
190
282
  let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$3), Stdlib_JsExn.message), "unknown");
191
283
  Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to publish command: ` + errMsg$2));
192
- let updated = afterFailedAttempt(row, errMsg$2);
193
- todoItems[id] = updated;
194
- if (updated.status === "Abandoned") {
284
+ let updated$1 = afterFailedAttempt(row, errMsg$2);
285
+ todoItems[id] = updated$1;
286
+ if (updated$1.status === "Abandoned") {
195
287
  newlyAbandoned.push(id);
196
288
  return;
197
289
  } else {
@@ -199,9 +291,9 @@ function Make(Spec) {
199
291
  }
200
292
  }
201
293
  } else {
202
- let updated$1 = afterFailedAttempt(row, undefined);
203
- todoItems[id] = updated$1;
204
- if (updated$1.status === "Abandoned") {
294
+ let updated$2 = afterFailedAttempt(row, undefined);
295
+ todoItems[id] = updated$2;
296
+ if (updated$2.status === "Abandoned") {
205
297
  newlyAbandoned.push(id);
206
298
  return;
207
299
  } else {
@@ -209,16 +301,16 @@ function Make(Spec) {
209
301
  }
210
302
  }
211
303
  } else {
212
- let newrecord$2 = {...row};
213
- newrecord$2.completedAt = new Date().toISOString();
214
- newrecord$2.status = "Completed";
215
- todoItems[id] = newrecord$2;
304
+ let newrecord$3 = {...row};
305
+ newrecord$3.completedAt = new Date().toISOString();
306
+ newrecord$3.status = "Completed";
307
+ todoItems[id] = newrecord$3;
216
308
  return;
217
309
  }
218
310
  } else {
219
- let updated$2 = afterFailedAttempt(row, result._0);
220
- todoItems[id] = updated$2;
221
- if (updated$2.status === "Abandoned") {
311
+ let updated$3 = afterFailedAttempt(row, result._0);
312
+ todoItems[id] = updated$3;
313
+ if (updated$3.status === "Abandoned") {
222
314
  newlyAbandoned.push(id);
223
315
  return;
224
316
  } else {