effect-agent 0.1.0-beta.134 → 0.1.0-beta.135

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 (51) hide show
  1. package/dist/{Admin-CUja0lmO.d.mts → Admin-DKqg6zQa.d.mts} +38 -4
  2. package/dist/{DurableAgentRuntime-DH2baLGe.mjs → DurableAgentRuntime-DgzI83ng.mjs} +47 -9
  3. package/dist/DurableAgentRuntime-DgzI83ng.mjs.map +1 -0
  4. package/dist/{EventSource-DoiZF3xv.d.mts → EventSource-P4hq8Opp.d.mts} +2 -2
  5. package/dist/{PreparedInputAdmission-B1bzyIuV.d.mts → PreparedInputAdmission-ChcWS1xV.d.mts} +3 -3
  6. package/dist/{Subscription-m_yNfNeN.d.mts → Subscription-jOOrT8Js.d.mts} +2 -2
  7. package/dist/{SubscriptionInput-ON3-b8Sl.d.mts → SubscriptionInput-CPyqenXR.d.mts} +2 -2
  8. package/dist/durable/Admin.d.mts +1 -1
  9. package/dist/durable/AgentRegistration.d.mts +1 -1
  10. package/dist/durable/Certification.d.mts +1 -1
  11. package/dist/durable/CommittedActivity.d.mts +1 -1
  12. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  13. package/dist/durable/DurableAgentRuntime.mjs +1 -1
  14. package/dist/durable/EventSource.d.mts +1 -1
  15. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  16. package/dist/durable/MessageDelivery.d.mts +3 -3
  17. package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -1
  18. package/dist/durable/PersistentHistory.d.mts +1 -1
  19. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  20. package/dist/durable/Recovery.d.mts +1 -1
  21. package/dist/durable/RunJournal.d.mts +1 -1
  22. package/dist/durable/Scheduling.d.mts +1 -1
  23. package/dist/durable/SqlStorageV2Upgrade.d.mts +1 -1
  24. package/dist/durable/SqlSubscriptionStore.d.mts +1 -1
  25. package/dist/durable/SqlThreadNativeReads.d.mts +1 -1
  26. package/dist/durable/SubmissionLedger.d.mts +2 -2
  27. package/dist/durable/SubmissionLedger.mjs +29 -2
  28. package/dist/durable/SubmissionLedger.mjs.map +1 -1
  29. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  30. package/dist/durable/SubmissionLedgerConformance.mjs +68 -1
  31. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -1
  32. package/dist/durable/SubmissionStatus.d.mts +1 -1
  33. package/dist/durable/Subscription.d.mts +1 -1
  34. package/dist/durable/SubscriptionInput.d.mts +1 -1
  35. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  36. package/dist/durable/SubscriptionTools.d.mts +2 -2
  37. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  38. package/dist/durable/Subscriptions.d.mts +5 -5
  39. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  40. package/dist/durable/ThreadInvariants.d.mts +1 -1
  41. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  42. package/dist/durable/ThreadStore.d.mts +1 -1
  43. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  44. package/dist/durable/WorkerHost.d.mts +1 -1
  45. package/dist/index.d.mts +5 -5
  46. package/dist/index.mjs +1 -1
  47. package/package.json +1 -1
  48. package/src/durable/DurableAgentRuntime.ts +94 -10
  49. package/src/durable/SubmissionLedger.ts +32 -0
  50. package/src/durable/SubmissionLedgerConformance.ts +120 -0
  51. package/dist/DurableAgentRuntime-DH2baLGe.mjs.map +0 -1
@@ -45,6 +45,7 @@ import {
45
45
  ChildSettledNotification,
46
46
  ClaimJoiningRequest,
47
47
  ClaimRequest,
48
+ ClaimHandoff,
48
49
  IdempotencyKey,
49
50
  JoinedToHost,
50
51
  LedgerError,
@@ -4770,6 +4771,124 @@ const assignmentSettlement = conformanceCase(
4770
4771
  }),
4771
4772
  );
4772
4773
 
4774
+ // Native turn-boundary yielding retained the active FIFO head:
4775
+ // https://github.com/danieljvdm/effect-agent/commit/2259fc05eec3bfac2a92a8d055953f3482e54735
4776
+ const cooperativeHandoff = conformanceCase(
4777
+ "hands off complete Turns without bypassing ownership, ordering, cancellation or approval",
4778
+ ({ ensure, expectSome }) =>
4779
+ Effect.gen(function* () {
4780
+ const ledger = yield* SubmissionLedger;
4781
+
4782
+ for (const scenario of [
4783
+ "ready",
4784
+ "live",
4785
+ "stale",
4786
+ "abort",
4787
+ "approval",
4788
+ "gap",
4789
+ "ready-prefix",
4790
+ "unapplied",
4791
+ "foreign",
4792
+ ] as const) {
4793
+ const threadId = decodeThreadId(`ledger-handoff-${scenario}`);
4794
+ const first = yield* admitReady(threadId, "first", { work: "old" });
4795
+ const claim = yield* expectSome("original claim", yield* claimLane(threadId, PRODUCER_A));
4796
+
4797
+ if (scenario !== "unapplied")
4798
+ yield* ledger.markInputApplied(
4799
+ MarkInputAppliedRequest.make({
4800
+ submissionId: first.submissionId,
4801
+ ownershipToken: claim.ownershipToken,
4802
+ recordId: submissionInputRecordId(first.submissionId),
4803
+ sequence: decodeSequence(1),
4804
+ }),
4805
+ );
4806
+ if (scenario === "gap")
4807
+ yield* ledger.admit(yield* admissionRequest(threadId, "gap", { work: "not-ready" }));
4808
+ if (scenario === "ready-prefix") yield* admitReady(threadId, "prefix", { work: "earlier" });
4809
+ const next = yield* admitReady(threadId, "next", { work: "human" });
4810
+
4811
+ const handoff = ClaimHandoff.make({
4812
+ producerEpoch: claim.producerEpoch,
4813
+ deferredSubmissionIds: [first.submissionId],
4814
+ submissionId: scenario === "foreign" ? decodeSubmissionId("foreign") : next.submissionId,
4815
+ });
4816
+
4817
+ if (scenario === "approval") {
4818
+ yield* ledger.suspend(
4819
+ SuspendRequest.make({
4820
+ submissionId: first.submissionId,
4821
+ ownershipToken: claim.ownershipToken,
4822
+ reason: ApprovalPendingSuspension.make({
4823
+ toolCallIds: [decodeToolCallId("purchase")],
4824
+ }),
4825
+ }),
4826
+ );
4827
+ } else if (scenario !== "live") {
4828
+ yield* ledger.releaseOwnership(
4829
+ ReleaseOwnershipRequest.make({
4830
+ submissionId: first.submissionId,
4831
+ ownershipToken: claim.ownershipToken,
4832
+ }),
4833
+ );
4834
+ }
4835
+ if (scenario === "abort")
4836
+ yield* ledger.requestAbort(
4837
+ AbortCommand.make({
4838
+ submissionId: first.submissionId,
4839
+ author: "human",
4840
+ reason: "stop",
4841
+ }),
4842
+ );
4843
+ if (scenario === "stale") {
4844
+ const intervening = yield* expectSome(
4845
+ "intervening claim",
4846
+ yield* claimLane(threadId, PRODUCER_B),
4847
+ );
4848
+
4849
+ yield* ledger.releaseOwnership(
4850
+ ReleaseOwnershipRequest.make({
4851
+ submissionId: first.submissionId,
4852
+ ownershipToken: intervening.ownershipToken,
4853
+ }),
4854
+ );
4855
+ }
4856
+
4857
+ const selected = yield* ledger.claim(
4858
+ ClaimRequest.make({ threadId, producerId: PRODUCER_B, handoff }),
4859
+ );
4860
+
4861
+ if (scenario !== "ready") {
4862
+ yield* ensure(Option.isNone(selected), `Handoff must preserve the ${scenario} boundary`);
4863
+ continue;
4864
+ }
4865
+ const nextClaim = yield* expectSome("ordered handoff claim", selected);
4866
+
4867
+ yield* ensure(
4868
+ nextClaim.submissionId === next.submissionId &&
4869
+ nextClaim.producerEpoch > claim.producerEpoch,
4870
+ "Handoff must claim the next Submission with a new epoch",
4871
+ );
4872
+ yield* settleClaimed(next, nextClaim.ownershipToken);
4873
+
4874
+ const resumed = yield* expectSome(
4875
+ "original Run resumes",
4876
+ yield* claimLane(threadId, PRODUCER_A),
4877
+ );
4878
+
4879
+ yield* ensure(
4880
+ resumed.submissionId === first.submissionId,
4881
+ "The deferred Submission must retain its original obligation",
4882
+ );
4883
+ yield* ensure(
4884
+ (yield* recoverySnapshot(first.submissionId)).submission.receiptId === first.receiptId &&
4885
+ (yield* recoverySnapshot(next.submissionId)).submission.receiptId === next.receiptId,
4886
+ "Handoff must preserve both receipt identities",
4887
+ );
4888
+ }
4889
+ }),
4890
+ );
4891
+
4773
4892
  /**
4774
4893
  * The shared, adapter-parameterized SubmissionLedger contract suite (STORE-010). Every durable
4775
4894
  * ledger adapter test suite must execute each case against its own ledger provisioning, inside
@@ -4788,6 +4907,7 @@ export const submissionLedgerConformanceCases: ReadonlyArray<SubmissionLedgerCon
4788
4907
  admissionTupleBoundaries,
4789
4908
  concurrentAdmissionFifo,
4790
4909
  fifoHeadClaim,
4910
+ cooperativeHandoff,
4791
4911
  leaseExpiryReclaim,
4792
4912
  releaseMakesHeadClaimable,
4793
4913
  inputAppliedIdempotency,