@effect-agent/storage-sqlite 0.1.0-beta.14 → 0.1.0-beta.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.
package/dist/index.mjs CHANGED
@@ -2715,7 +2715,8 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
2715
2715
  const outcome = yield* inWriteTransaction(operation, Effect.gen(function* () {
2716
2716
  const parent = yield* requireSubmission(operation, validated.parentSubmissionId);
2717
2717
  const child = yield* readSubmission(operation, validated.childSubmissionId);
2718
- if (Option.isNone(child) || child.value.state !== "settled") return yield* LedgerError.make({
2718
+ const childReservation = yield* readReservation(operation, validated.childSubmissionId);
2719
+ if (!(Option.isSome(child) && (child.value.state === "settled" || child.value.state === "terminalizing" && Option.isSome(childReservation)))) return yield* LedgerError.make({
2719
2720
  operation,
2720
2721
  message: `Child submission ${validated.childSubmissionId} has no recorded settlement.`
2721
2722
  });
@@ -2725,7 +2726,8 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
2725
2726
  if (!reason.children.some((entry) => entry.childSubmissionId === validated.childSubmissionId)) return "not-waiting";
2726
2727
  for (const entry of reason.children) {
2727
2728
  const listed = yield* readSubmission(operation, entry.childSubmissionId);
2728
- if (Option.isNone(listed) || listed.value.state !== "settled") return "still-waiting";
2729
+ const reservation = yield* readReservation(operation, entry.childSubmissionId);
2730
+ if (!(Option.isSome(listed) && (listed.value.state === "settled" || listed.value.state === "terminalizing" && Option.isSome(reservation)))) return "still-waiting";
2729
2731
  }
2730
2732
  yield* sql`
2731
2733
  UPDATE effect_agent_submissions