@systemfsoftware/agent 0.0.0-bootstrap.0 → 0.1.0-beta.192
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/LICENSE +21 -0
- package/dist/ActivityStore-CEy3oY41.mjs +90 -0
- package/dist/ActivityStore-CEy3oY41.mjs.map +1 -0
- package/dist/ActivityStore-CPXWRHGz.d.mts +91 -0
- package/dist/Admin-BcQDrWKY.mjs +329 -0
- package/dist/Admin-BcQDrWKY.mjs.map +1 -0
- package/dist/Admin-BfolLkHj.d.mts +5678 -0
- package/dist/Agent-Bn3zMhDH.mjs +60 -0
- package/dist/Agent-Bn3zMhDH.mjs.map +1 -0
- package/dist/Agent-DSVEpq4e.d.mts +219 -0
- package/dist/AgentError-RkUaetX8.d.mts +128 -0
- package/dist/AgentError-yFdnS9bl.mjs +141 -0
- package/dist/AgentError-yFdnS9bl.mjs.map +1 -0
- package/dist/AgentPolicy-CI7LRBQa.mjs +116 -0
- package/dist/AgentPolicy-CI7LRBQa.mjs.map +1 -0
- package/dist/AgentPolicy-D-GmZQex.d.mts +128 -0
- package/dist/AgentRegistration-Dg53p6du.mjs +14 -0
- package/dist/AgentRegistration-Dg53p6du.mjs.map +1 -0
- package/dist/AgentRuntime-CoGy_5dm.d.mts +751 -0
- package/dist/AgentRuntime-CzP4I4RB.mjs +5249 -0
- package/dist/AgentRuntime-CzP4I4RB.mjs.map +1 -0
- package/dist/AgentUpdates-7xT0It_R.d.mts +54 -0
- package/dist/AgentUpdates-BS_6gR5K.mjs +66 -0
- package/dist/AgentUpdates-BS_6gR5K.mjs.map +1 -0
- package/dist/BrowserUse-C9vict2M.d.mts +196 -0
- package/dist/BrowserUse-DjEyFDLZ.mjs +156 -0
- package/dist/BrowserUse-DjEyFDLZ.mjs.map +1 -0
- package/dist/Budget-CXh_ChFJ.d.mts +112 -0
- package/dist/Budget-j1UkthgY.mjs +351 -0
- package/dist/Budget-j1UkthgY.mjs.map +1 -0
- package/dist/CodeExecutor-B_Vt1Ghy.mjs +281 -0
- package/dist/CodeExecutor-B_Vt1Ghy.mjs.map +1 -0
- package/dist/CodeExecutor-D5-Rda75.d.mts +198 -0
- package/dist/CodeMode-B7JvfKAD.d.mts +159 -0
- package/dist/CodeMode-BI7WhUkr.mjs +555 -0
- package/dist/CodeMode-BI7WhUkr.mjs.map +1 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs +146 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs.map +1 -0
- package/dist/CommittedActivity-LWOKXqdi.d.mts +62 -0
- package/dist/Compaction-C0hWAmOG.mjs +15 -0
- package/dist/Compaction-C0hWAmOG.mjs.map +1 -0
- package/dist/Compaction-e5cNeFmY.d.mts +5 -0
- package/dist/ContextCompactor-Chm9BLrD.d.mts +165 -0
- package/dist/ContextCompactor-DV4NOQvg.mjs +134 -0
- package/dist/ContextCompactor-DV4NOQvg.mjs.map +1 -0
- package/dist/ContextHistory-C80rW5M7.mjs +76 -0
- package/dist/ContextHistory-C80rW5M7.mjs.map +1 -0
- package/dist/ContextHistory-akQ1Td7a.d.mts +65 -0
- package/dist/ContextTools-917r7gpv.d.mts +186 -0
- package/dist/ContextTools-p8JDPo-W.mjs +88 -0
- package/dist/ContextTools-p8JDPo-W.mjs.map +1 -0
- package/dist/ContextWindow-BJZI4MMt.d.mts +61 -0
- package/dist/ContextWindow-kbFcs1IF.mjs +63 -0
- package/dist/ContextWindow-kbFcs1IF.mjs.map +1 -0
- package/dist/Digest-BDToAbaX.d.mts +25 -0
- package/dist/Digest-CU6IWj-2.mjs +106 -0
- package/dist/Digest-CU6IWj-2.mjs.map +1 -0
- package/dist/DurableAgentRuntime-BHXo8GPJ.mjs +8432 -0
- package/dist/DurableAgentRuntime-BHXo8GPJ.mjs.map +1 -0
- package/dist/DurableFailpoint-BD5nowNl.mjs +98 -0
- package/dist/DurableFailpoint-BD5nowNl.mjs.map +1 -0
- package/dist/DurableFailpoint-Cqi5tyof.d.mts +42 -0
- package/dist/DurableStep-CzVIho7y.mjs +54 -0
- package/dist/DurableStep-CzVIho7y.mjs.map +1 -0
- package/dist/DurableStep-cI_Ho_rU.d.mts +109 -0
- package/dist/EventSource-BwZVkEQi.mjs +66 -0
- package/dist/EventSource-BwZVkEQi.mjs.map +1 -0
- package/dist/EventSource-C0TCBeIf.d.mts +52 -0
- package/dist/FailureDiagnostic-DdHV2eFs.mjs +304 -0
- package/dist/FailureDiagnostic-DdHV2eFs.mjs.map +1 -0
- package/dist/FailureDiagnostic-DpzYNI8f.d.mts +232 -0
- package/dist/IdGenerator-BCzwV0ZI.mjs +29 -0
- package/dist/IdGenerator-BCzwV0ZI.mjs.map +1 -0
- package/dist/IdGenerator-BY8NH74o.d.mts +26 -0
- package/dist/Identifiers-LWd4837I.mjs +41 -0
- package/dist/Identifiers-LWd4837I.mjs.map +1 -0
- package/dist/Identifiers-qafW4EP0.d.mts +38 -0
- package/dist/InMemory-BrTm6XEO.mjs +57 -0
- package/dist/InMemory-BrTm6XEO.mjs.map +1 -0
- package/dist/InMemory-C3qXFT5k.d.mts +46 -0
- package/dist/InMemory.d.mts +2 -0
- package/dist/InMemory.mjs +1 -0
- package/dist/InteractiveBrowser-B-hlNJy5.mjs +237 -0
- package/dist/InteractiveBrowser-B-hlNJy5.mjs.map +1 -0
- package/dist/InteractiveBrowser-nnML0r7w.d.mts +258 -0
- package/dist/LifecyclePublication-BDc_ug5v.mjs +204 -0
- package/dist/LifecyclePublication-BDc_ug5v.mjs.map +1 -0
- package/dist/Memory-CT5bDZqi.d.mts +57 -0
- package/dist/Memory-Dl9ecPpm.mjs +204 -0
- package/dist/Memory-Dl9ecPpm.mjs.map +1 -0
- package/dist/MemoryNamespace-BtnlH_E6.d.mts +35 -0
- package/dist/MemoryNamespace-DZSpjLj9.mjs +116 -0
- package/dist/MemoryNamespace-DZSpjLj9.mjs.map +1 -0
- package/dist/MemoryNotes-4CRzkPBD.d.mts +425 -0
- package/dist/MemoryNotes-i41TsH11.mjs +132 -0
- package/dist/MemoryNotes-i41TsH11.mjs.map +1 -0
- package/dist/MemoryReference-Dd3KSMa7.d.mts +77 -0
- package/dist/MemoryReference-RFU0HQJG.mjs +108 -0
- package/dist/MemoryReference-RFU0HQJG.mjs.map +1 -0
- package/dist/MemoryRevalidation--aAh_Pfq.mjs +136 -0
- package/dist/MemoryRevalidation--aAh_Pfq.mjs.map +1 -0
- package/dist/MemoryRevalidation-FsJ8E61W.d.mts +64 -0
- package/dist/MemoryStore-Bg5RunTk.d.mts +187 -0
- package/dist/MemoryStore-E0J99hb2.mjs +245 -0
- package/dist/MemoryStore-E0J99hb2.mjs.map +1 -0
- package/dist/MessageDelivery-BE2Yf3FC.mjs +615 -0
- package/dist/MessageDelivery-BE2Yf3FC.mjs.map +1 -0
- package/dist/MessageDelivery-Dh6GZBt_.d.mts +1129 -0
- package/dist/Messaging-BqWHYf93.d.mts +216 -0
- package/dist/Messaging-DgSiv4f4.mjs +154 -0
- package/dist/Messaging-DgSiv4f4.mjs.map +1 -0
- package/dist/Messaging-DhM-APnP.d.mts +1074 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs +117 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs.map +1 -0
- package/dist/MessagingHost-CubWeYKN.d.mts +80 -0
- package/dist/OperationAuthorizer-VSiHCC2S.mjs +72 -0
- package/dist/OperationAuthorizer-VSiHCC2S.mjs.map +1 -0
- package/dist/OperationAuthorizer-y-F-Ox_Q.d.mts +62 -0
- package/dist/Output-DQ8mWcgf.mjs +7 -0
- package/dist/Output-DQ8mWcgf.mjs.map +1 -0
- package/dist/Output-SbOdlBFL.d.mts +22 -0
- package/dist/PageCapture-BfRURUOA.mjs +275 -0
- package/dist/PageCapture-BfRURUOA.mjs.map +1 -0
- package/dist/PageCapture-C_mE72Sd.d.mts +216 -0
- package/dist/PageScreenshot-BJTASs4o.mjs +53 -0
- package/dist/PageScreenshot-BJTASs4o.mjs.map +1 -0
- package/dist/PageScreenshot-CaoaH7mc.d.mts +48 -0
- package/dist/PersistentHistory-BrtZ0g2j.d.mts +14 -0
- package/dist/PersistentHistory-CTAVhHKH.mjs +147 -0
- package/dist/PersistentHistory-CTAVhHKH.mjs.map +1 -0
- package/dist/PreparedInputAdmission-Ci18uY4s.d.mts +973 -0
- package/dist/PreparedInputAdmission-adqVJJa6.mjs +95 -0
- package/dist/PreparedInputAdmission-adqVJJa6.mjs.map +1 -0
- package/dist/ProvisionalText-BcKpPYKQ.d.mts +70 -0
- package/dist/ProvisionalText-DXddTK4c.mjs +47 -0
- package/dist/ProvisionalText-DXddTK4c.mjs.map +1 -0
- package/dist/Receipt-B-FlCaNH.mjs +35 -0
- package/dist/Receipt-B-FlCaNH.mjs.map +1 -0
- package/dist/Receipt-B4feBxMY.d.mts +31 -0
- package/dist/RecordFormat-DoNh-AFe.mjs +79 -0
- package/dist/RecordFormat-DoNh-AFe.mjs.map +1 -0
- package/dist/RecordFormat-ZMus8Dx8.d.mts +52 -0
- package/dist/Records-C645aQks.mjs +1145 -0
- package/dist/Records-C645aQks.mjs.map +1 -0
- package/dist/Records-C9I1nCL9.d.mts +1423 -0
- package/dist/Recovery-zWy_kmZq.mjs +736 -0
- package/dist/Recovery-zWy_kmZq.mjs.map +1 -0
- package/dist/Redaction-C0zLBAn6.d.mts +28 -0
- package/dist/Redaction-CtyCBMEj.mjs +116 -0
- package/dist/Redaction-CtyCBMEj.mjs.map +1 -0
- package/dist/RememberingStore-BO-OnCgP.mjs +23 -0
- package/dist/RememberingStore-BO-OnCgP.mjs.map +1 -0
- package/dist/RememberingStore-DgqXmILx.d.mts +14 -0
- package/dist/RunContinuation-BVAHoYlN.d.mts +127 -0
- package/dist/RunContinuation-Bpfp087i.mjs +1060 -0
- package/dist/RunContinuation-Bpfp087i.mjs.map +1 -0
- package/dist/RunEvent-CwgDzXcH.d.mts +465 -0
- package/dist/RunEvent-DJxENnJi.mjs +345 -0
- package/dist/RunEvent-DJxENnJi.mjs.map +1 -0
- package/dist/RunEventSink-B8uM8bw2.mjs +22 -0
- package/dist/RunEventSink-B8uM8bw2.mjs.map +1 -0
- package/dist/RunEventSink-f-T4jbNB.d.mts +105 -0
- package/dist/RunHooks-Bob22Bcj.d.mts +40 -0
- package/dist/RunHooks-DWuLBVdU.mjs +60 -0
- package/dist/RunHooks-DWuLBVdU.mjs.map +1 -0
- package/dist/RunJournal-C_1eqQdr.mjs +1107 -0
- package/dist/RunJournal-C_1eqQdr.mjs.map +1 -0
- package/dist/RunOptions-BVSa3BO2.d.mts +560 -0
- package/dist/RunOptions-COEUCrx4.mjs +61 -0
- package/dist/RunOptions-COEUCrx4.mjs.map +1 -0
- package/dist/RunPolicyUsage-B-JXRZYO.mjs +25 -0
- package/dist/RunPolicyUsage-B-JXRZYO.mjs.map +1 -0
- package/dist/RunPolicyUsage-jvJo0vJp.d.mts +21 -0
- package/dist/RunStorage-CsQQ0Y5u.mjs +304 -0
- package/dist/RunStorage-CsQQ0Y5u.mjs.map +1 -0
- package/dist/Sandbox-37vXP0BV.d.mts +24 -0
- package/dist/Sandbox-Bze6pHYc.mjs +30 -0
- package/dist/Sandbox-Bze6pHYc.mjs.map +1 -0
- package/dist/Schedule-BY0lzbij.mjs +336 -0
- package/dist/Schedule-BY0lzbij.mjs.map +1 -0
- package/dist/ScheduleTransition-CjVP48I8.d.mts +22 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs +180 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs.map +1 -0
- package/dist/Scheduling-BpJN9E1j.mjs +699 -0
- package/dist/Scheduling-BpJN9E1j.mjs.map +1 -0
- package/dist/Scheduling-DYTM29s9.d.mts +57 -0
- package/dist/SemanticMemory-BRV0cuWg.mjs +300 -0
- package/dist/SemanticMemory-BRV0cuWg.mjs.map +1 -0
- package/dist/SemanticMemory-rgWlhW87.d.mts +431 -0
- package/dist/SemanticMemoryIndex-D7yNEWpt.d.mts +826 -0
- package/dist/SemanticMemoryIndex-godQDjNx.mjs +186 -0
- package/dist/SemanticMemoryIndex-godQDjNx.mjs.map +1 -0
- package/dist/SemanticMemoryRevalidation-Bm3_pfsI.d.mts +44 -0
- package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs +179 -0
- package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs.map +1 -0
- package/dist/Subagent-CSIRUgUo.mjs +1315 -0
- package/dist/Subagent-CSIRUgUo.mjs.map +1 -0
- package/dist/Subagent-CXEI5YZ8.d.mts +2368 -0
- package/dist/SubagentContract-B7vQPueI.d.mts +176 -0
- package/dist/SubagentContract-C-7AxTm_.mjs +187 -0
- package/dist/SubagentContract-C-7AxTm_.mjs.map +1 -0
- package/dist/SubagentHost-BEnICu7g.mjs +70 -0
- package/dist/SubagentHost-BEnICu7g.mjs.map +1 -0
- package/dist/SubagentHost-CKhz1vbH.d.mts +167 -0
- package/dist/SubagentReservations-BYNAHPpm.mjs +465 -0
- package/dist/SubagentReservations-BYNAHPpm.mjs.map +1 -0
- package/dist/SubagentReservations-WrmIVzO5.d.mts +185 -0
- package/dist/SubmissionLedger-WG0beEyt.mjs +921 -0
- package/dist/SubmissionLedger-WG0beEyt.mjs.map +1 -0
- package/dist/SubmissionStatus-CPZsOM5a.mjs +17 -0
- package/dist/SubmissionStatus-CPZsOM5a.mjs.map +1 -0
- package/dist/Subscription-BhQbmUD-.mjs +340 -0
- package/dist/Subscription-BhQbmUD-.mjs.map +1 -0
- package/dist/Subscription-CC--_OnU.d.mts +815 -0
- package/dist/SubscriptionInput-BEeB0Cj8.d.mts +42 -0
- package/dist/SubscriptionInput-Xcd4JjEs.mjs +53 -0
- package/dist/SubscriptionInput-Xcd4JjEs.mjs.map +1 -0
- package/dist/SubscriptionTransition-CWt9UVH0.d.mts +23 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs +154 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs.map +1 -0
- package/dist/Subscriptions-4K_qu_2f.mjs +638 -0
- package/dist/Subscriptions-4K_qu_2f.mjs.map +1 -0
- package/dist/Subscriptions-BF3aSf8X.d.mts +75 -0
- package/dist/Thread-B8JApGHa.mjs +283 -0
- package/dist/Thread-B8JApGHa.mjs.map +1 -0
- package/dist/Thread-BnAtkJl4.d.mts +116 -0
- package/dist/ThreadArchiveRange-1PMdjpdJ.mjs +64 -0
- package/dist/ThreadArchiveRange-1PMdjpdJ.mjs.map +1 -0
- package/dist/ThreadContextHistory-BSStMOLX.mjs +211 -0
- package/dist/ThreadContextHistory-BSStMOLX.mjs.map +1 -0
- package/dist/ThreadContextHistory-lTZ8Ftq1.d.mts +33 -0
- package/dist/ThreadContextHistoryProjection-Cp7_RR6V.d.mts +59 -0
- package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs +149 -0
- package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs.map +1 -0
- package/dist/ThreadHistory-BkyGfv5E.d.mts +76 -0
- package/dist/ThreadHistory-Blt_W31N.mjs +69 -0
- package/dist/ThreadHistory-Blt_W31N.mjs.map +1 -0
- package/dist/ThreadImport-C8Tqiezd.mjs +491 -0
- package/dist/ThreadImport-C8Tqiezd.mjs.map +1 -0
- package/dist/ThreadImport-DaSmrlRi.d.mts +843 -0
- package/dist/ThreadInvariants-DyPhMeo-.d.mts +23 -0
- package/dist/ThreadInvariants-fniroLRY.mjs +154 -0
- package/dist/ThreadInvariants-fniroLRY.mjs.map +1 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs +37 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs.map +1 -0
- package/dist/ThreadProjectionMaintenance-DjUy7kCa.d.mts +51 -0
- package/dist/ThreadStore-BMUAp5Ta.mjs +937 -0
- package/dist/ThreadStore-BMUAp5Ta.mjs.map +1 -0
- package/dist/ThreadTransfer-B3NkyO_y.mjs +154 -0
- package/dist/ThreadTransfer-B3NkyO_y.mjs.map +1 -0
- package/dist/ThreadTransfer-BM02cbOo.d.mts +63 -0
- package/dist/ThreadWork-C-xa2Boi.mjs +484 -0
- package/dist/ThreadWork-C-xa2Boi.mjs.map +1 -0
- package/dist/ToolBroker-DkoVyx6T.mjs +42 -0
- package/dist/ToolBroker-DkoVyx6T.mjs.map +1 -0
- package/dist/ToolBroker-Dy2xM6ht.d.mts +134 -0
- package/dist/ToolDiscovery-DHySvLQd.mjs +211 -0
- package/dist/ToolDiscovery-DHySvLQd.mjs.map +1 -0
- package/dist/ToolDiscovery-VjamzX3q.d.mts +119 -0
- package/dist/ToolExposure-Cn7xETn5.d.mts +6 -0
- package/dist/ToolExposure-D7id9Gt5.d.mts +37 -0
- package/dist/ToolExposure-DCvQWFIa.mjs +9 -0
- package/dist/ToolExposure-DCvQWFIa.mjs.map +1 -0
- package/dist/ToolExposure-DNME8BkG.d.mts +44 -0
- package/dist/ToolExposure-DPnq8Won.mjs +30 -0
- package/dist/ToolExposure-DPnq8Won.mjs.map +1 -0
- package/dist/ToolExposure-DaGaF5tj.mjs +20 -0
- package/dist/ToolExposure-DaGaF5tj.mjs.map +1 -0
- package/dist/ToolExposure.d.mts +4 -0
- package/dist/ToolExposure.mjs +4 -0
- package/dist/ToolReconciler-6bb7xlip.d.mts +81 -0
- package/dist/ToolReconciler-DJQd3SZA.mjs +87 -0
- package/dist/ToolReconciler-DJQd3SZA.mjs.map +1 -0
- package/dist/ToolResult-By5KAje4.d.mts +79 -0
- package/dist/ToolResult-DwZxjlHw.mjs +160 -0
- package/dist/ToolResult-DwZxjlHw.mjs.map +1 -0
- package/dist/ToolResultStorage-BmoRewhh.mjs +46 -0
- package/dist/ToolResultStorage-BmoRewhh.mjs.map +1 -0
- package/dist/ToolResultStorage-Bp5fm0do.d.mts +49 -0
- package/dist/ToolResults-C4-HsMCp.d.mts +33 -0
- package/dist/ToolResults-nCgBlTp2.mjs +45 -0
- package/dist/ToolResults-nCgBlTp2.mjs.map +1 -0
- package/dist/Usage-B0xgME5f.mjs +340 -0
- package/dist/Usage-B0xgME5f.mjs.map +1 -0
- package/dist/Usage-Bc-jXe_9.d.mts +128 -0
- package/dist/WakeScheduler-DVYj66C-.mjs +74 -0
- package/dist/WakeScheduler-DVYj66C-.mjs.map +1 -0
- package/dist/WakeScheduler-SFqj67Sk.d.mts +74 -0
- package/dist/WebCapture-CA4ZarW2.mjs +64 -0
- package/dist/WebCapture-CA4ZarW2.mjs.map +1 -0
- package/dist/WebCapture-pzIeUJ5W.d.mts +49 -0
- package/dist/WebSearch-CD0V--qh.d.mts +18 -0
- package/dist/WebSearch-DnbOzRL_.mjs +30 -0
- package/dist/WebSearch-DnbOzRL_.mjs.map +1 -0
- package/dist/Worker-CQu8Qp1j.mjs +267 -0
- package/dist/Worker-CQu8Qp1j.mjs.map +1 -0
- package/dist/Worker-xxucY_0b.d.mts +468 -0
- package/dist/WorkerAdmission-BhFjx86s.mjs +162 -0
- package/dist/WorkerAdmission-BhFjx86s.mjs.map +1 -0
- package/dist/WorkerAdmission-BnRuXLWF.d.mts +171 -0
- package/dist/WorkerHost-DtYzi54D.d.mts +150 -0
- package/dist/WorkerHost-DuQug9Bq.mjs +73 -0
- package/dist/WorkerHost-DuQug9Bq.mjs.map +1 -0
- package/dist/agent-registration-CNs2twrr.mjs +262 -0
- package/dist/agent-registration-CNs2twrr.mjs.map +1 -0
- package/dist/capabilities/BrowserUse.d.mts +2 -0
- package/dist/capabilities/BrowserUse.mjs +1 -0
- package/dist/capabilities/Budget.d.mts +2 -0
- package/dist/capabilities/Budget.mjs +1 -0
- package/dist/capabilities/CodeMode.d.mts +2 -0
- package/dist/capabilities/CodeMode.mjs +1 -0
- package/dist/capabilities/ContextTools.d.mts +2 -0
- package/dist/capabilities/ContextTools.mjs +1 -0
- package/dist/capabilities/MemoryNotes.d.mts +2 -0
- package/dist/capabilities/MemoryNotes.mjs +1 -0
- package/dist/capabilities/Messaging.d.mts +3 -0
- package/dist/capabilities/Messaging.mjs +4 -0
- package/dist/capabilities/Redaction.d.mts +2 -0
- package/dist/capabilities/Redaction.mjs +1 -0
- package/dist/capabilities/RunHooks.d.mts +2 -0
- package/dist/capabilities/RunHooks.mjs +1 -0
- package/dist/capabilities/SemanticMemory.d.mts +2 -0
- package/dist/capabilities/SemanticMemory.mjs +1 -0
- package/dist/capabilities/Subagent.d.mts +4 -0
- package/dist/capabilities/Subagent.mjs +6 -0
- package/dist/capabilities/SubagentReservations.d.mts +2 -0
- package/dist/capabilities/SubagentReservations.mjs +1 -0
- package/dist/capabilities/ToolDiscovery.d.mts +2 -0
- package/dist/capabilities/ToolDiscovery.mjs +1 -0
- package/dist/capabilities/ToolResults.d.mts +2 -0
- package/dist/capabilities/ToolResults.mjs +1 -0
- package/dist/capabilities/WebCapture.d.mts +2 -0
- package/dist/capabilities/WebCapture.mjs +1 -0
- package/dist/capabilities/WebSearch.d.mts +2 -0
- package/dist/capabilities/WebSearch.mjs +1 -0
- package/dist/compaction-C3hXuO4Z.mjs +539 -0
- package/dist/compaction-C3hXuO4Z.mjs.map +1 -0
- package/dist/completion-B_WDnSg-.d.mts +11 -0
- package/dist/core/Agent.d.mts +2 -0
- package/dist/core/Agent.mjs +1 -0
- package/dist/core/AgentError.d.mts +2 -0
- package/dist/core/AgentError.mjs +1 -0
- package/dist/core/AgentPolicy.d.mts +2 -0
- package/dist/core/AgentPolicy.mjs +1 -0
- package/dist/core/AgentUpdates.d.mts +2 -0
- package/dist/core/AgentUpdates.mjs +1 -0
- package/dist/core/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +1 -0
- package/dist/core/IdGenerator.d.mts +2 -0
- package/dist/core/IdGenerator.mjs +1 -0
- package/dist/core/Identifiers.d.mts +2 -0
- package/dist/core/Identifiers.mjs +1 -0
- package/dist/core/Memory.d.mts +2 -0
- package/dist/core/Memory.mjs +1 -0
- package/dist/core/MemoryNamespace.d.mts +2 -0
- package/dist/core/MemoryNamespace.mjs +1 -0
- package/dist/core/MemoryReference.d.mts +2 -0
- package/dist/core/MemoryReference.mjs +1 -0
- package/dist/core/MemoryRevalidation.d.mts +2 -0
- package/dist/core/MemoryRevalidation.mjs +1 -0
- package/dist/core/MemoryStore.d.mts +2 -0
- package/dist/core/MemoryStore.mjs +1 -0
- package/dist/core/ProvisionalText.d.mts +2 -0
- package/dist/core/ProvisionalText.mjs +1 -0
- package/dist/core/Receipt.d.mts +2 -0
- package/dist/core/Receipt.mjs +1 -0
- package/dist/core/RememberingStore.d.mts +2 -0
- package/dist/core/RememberingStore.mjs +1 -0
- package/dist/core/RunEvent.d.mts +3 -0
- package/dist/core/RunEvent.mjs +1 -0
- package/dist/core/RunPolicyUsage.d.mts +2 -0
- package/dist/core/RunPolicyUsage.mjs +1 -0
- package/dist/core/SemanticMemoryIndex.d.mts +2 -0
- package/dist/core/SemanticMemoryIndex.mjs +1 -0
- package/dist/core/SemanticMemoryRevalidation.d.mts +2 -0
- package/dist/core/SemanticMemoryRevalidation.mjs +1 -0
- package/dist/core/SubagentContract.d.mts +2 -0
- package/dist/core/SubagentContract.mjs +1 -0
- package/dist/core/Thread.d.mts +2 -0
- package/dist/core/Thread.mjs +1 -0
- package/dist/core/ToolResult.d.mts +2 -0
- package/dist/core/ToolResult.mjs +1 -0
- package/dist/core/ToolResultStorage.d.mts +2 -0
- package/dist/core/ToolResultStorage.mjs +1 -0
- package/dist/core/Usage.d.mts +2 -0
- package/dist/core/Usage.mjs +1 -0
- package/dist/core/Worker.d.mts +3 -0
- package/dist/core/Worker.mjs +3 -0
- package/dist/durable/ActivityStore.d.mts +2 -0
- package/dist/durable/ActivityStore.mjs +1 -0
- package/dist/durable/Admin.d.mts +2 -0
- package/dist/durable/Admin.mjs +1 -0
- package/dist/durable/AgentRegistration.d.mts +3 -0
- package/dist/durable/AgentRegistration.mjs +2 -0
- package/dist/durable/CommittedActivity.d.mts +2 -0
- package/dist/durable/CommittedActivity.mjs +1 -0
- package/dist/durable/Digest.d.mts +2 -0
- package/dist/durable/Digest.mjs +3 -0
- package/dist/durable/DurableAgentRuntime.d.mts +3 -0
- package/dist/durable/DurableAgentRuntime.mjs +4 -0
- package/dist/durable/DurableFailpoint.d.mts +2 -0
- package/dist/durable/DurableFailpoint.mjs +1 -0
- package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
- package/dist/durable/DurableFailpointTestControl.mjs +21 -0
- package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
- package/dist/durable/EventSource.d.mts +2 -0
- package/dist/durable/EventSource.mjs +1 -0
- package/dist/durable/LifecyclePublication.d.mts +2 -0
- package/dist/durable/LifecyclePublication.mjs +1 -0
- package/dist/durable/MessageDelivery.d.mts +2 -0
- package/dist/durable/MessageDelivery.mjs +1 -0
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +401 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs +273 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
- package/dist/durable/OperationAuthorizer.d.mts +2 -0
- package/dist/durable/OperationAuthorizer.mjs +1 -0
- package/dist/durable/PersistentHistory.d.mts +2 -0
- package/dist/durable/PersistentHistory.mjs +1 -0
- package/dist/durable/PreparedInputAdmission.d.mts +2 -0
- package/dist/durable/PreparedInputAdmission.mjs +1 -0
- package/dist/durable/RecordFormat.d.mts +2 -0
- package/dist/durable/RecordFormat.mjs +1 -0
- package/dist/durable/Records.d.mts +2 -0
- package/dist/durable/Records.mjs +1 -0
- package/dist/durable/Recovery.d.mts +2 -0
- package/dist/durable/Recovery.mjs +1 -0
- package/dist/durable/RunContinuation.d.mts +4 -0
- package/dist/durable/RunContinuation.mjs +4 -0
- package/dist/durable/RunJournal.d.mts +2 -0
- package/dist/durable/RunJournal.mjs +1 -0
- package/dist/durable/RunStorage.d.mts +2 -0
- package/dist/durable/RunStorage.mjs +1 -0
- package/dist/durable/Schedule.d.mts +2 -0
- package/dist/durable/Schedule.mjs +1 -0
- package/dist/durable/ScheduleStoreConformance.d.mts +16 -0
- package/dist/durable/ScheduleStoreConformance.mjs +421 -0
- package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
- package/dist/durable/ScheduleTransition.d.mts +2 -0
- package/dist/durable/ScheduleTransition.mjs +1 -0
- package/dist/durable/Scheduling.d.mts +2 -0
- package/dist/durable/Scheduling.mjs +1 -0
- package/dist/durable/SettlementPublisher.d.mts +2 -0
- package/dist/durable/SettlementPublisher.mjs +99 -0
- package/dist/durable/SettlementPublisher.mjs.map +1 -0
- package/dist/durable/SqlMemoryStore.d.mts +729 -0
- package/dist/durable/SqlMemoryStore.mjs +626 -0
- package/dist/durable/SqlMemoryStore.mjs.map +1 -0
- package/dist/durable/SqlStorageOwner.d.mts +18 -0
- package/dist/durable/SqlStorageOwner.mjs +6 -0
- package/dist/durable/SqlStorageOwner.mjs.map +1 -0
- package/dist/durable/SubmissionLedger.d.mts +3 -0
- package/dist/durable/SubmissionLedger.mjs +3 -0
- package/dist/durable/SubmissionLedgerConformance.d.mts +31 -0
- package/dist/durable/SubmissionLedgerConformance.mjs +2090 -0
- package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
- package/dist/durable/SubmissionStatus.d.mts +2 -0
- package/dist/durable/SubmissionStatus.mjs +1 -0
- package/dist/durable/Subscription.d.mts +2 -0
- package/dist/durable/Subscription.mjs +1 -0
- package/dist/durable/SubscriptionInput.d.mts +2 -0
- package/dist/durable/SubscriptionInput.mjs +1 -0
- package/dist/durable/SubscriptionStoreConformance.d.mts +15 -0
- package/dist/durable/SubscriptionStoreConformance.mjs +816 -0
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
- package/dist/durable/SubscriptionTransition.d.mts +2 -0
- package/dist/durable/SubscriptionTransition.mjs +1 -0
- package/dist/durable/Subscriptions.d.mts +2 -0
- package/dist/durable/Subscriptions.mjs +1 -0
- package/dist/durable/ThreadArchiveRange.d.mts +2 -0
- package/dist/durable/ThreadArchiveRange.mjs +1 -0
- package/dist/durable/ThreadContextHistory.d.mts +2 -0
- package/dist/durable/ThreadContextHistory.mjs +1 -0
- package/dist/durable/ThreadContextHistoryProjection.d.mts +2 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -0
- package/dist/durable/ThreadImport.d.mts +2 -0
- package/dist/durable/ThreadImport.mjs +1 -0
- package/dist/durable/ThreadInvariants.d.mts +2 -0
- package/dist/durable/ThreadInvariants.mjs +1 -0
- package/dist/durable/ThreadProjectionMaintenance.d.mts +2 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs +1 -0
- package/dist/durable/ThreadReader.d.mts +2 -0
- package/dist/durable/ThreadReader.mjs +1 -0
- package/dist/durable/ThreadStore.d.mts +3 -0
- package/dist/durable/ThreadStore.mjs +3 -0
- package/dist/durable/ThreadStoreConformance.d.mts +53 -0
- package/dist/durable/ThreadStoreConformance.mjs +402 -0
- package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
- package/dist/durable/ThreadTransfer.d.mts +2 -0
- package/dist/durable/ThreadTransfer.mjs +1 -0
- package/dist/durable/ThreadWork.d.mts +2 -0
- package/dist/durable/ThreadWork.mjs +1 -0
- package/dist/durable/ToolReconciler.d.mts +2 -0
- package/dist/durable/ToolReconciler.mjs +1 -0
- package/dist/durable/WakeScheduler.d.mts +2 -0
- package/dist/durable/WakeScheduler.mjs +1 -0
- package/dist/durable/WorkerAdmission.d.mts +2 -0
- package/dist/durable/WorkerAdmission.mjs +1 -0
- package/dist/durable/WorkerHost.d.mts +2 -0
- package/dist/durable/WorkerHost.mjs +1 -0
- package/dist/engine/AgentRuntime.d.mts +2 -0
- package/dist/engine/AgentRuntime.mjs +1 -0
- package/dist/engine/Compaction.d.mts +4 -0
- package/dist/engine/Compaction.mjs +2 -0
- package/dist/engine/ContextCompactor.d.mts +2 -0
- package/dist/engine/ContextCompactor.mjs +1 -0
- package/dist/engine/ContextHistory.d.mts +2 -0
- package/dist/engine/ContextHistory.mjs +1 -0
- package/dist/engine/ContextWindow.d.mts +2 -0
- package/dist/engine/ContextWindow.mjs +1 -0
- package/dist/engine/DurableStep.d.mts +2 -0
- package/dist/engine/DurableStep.mjs +3 -0
- package/dist/engine/MessagingHost.d.mts +2 -0
- package/dist/engine/MessagingHost.mjs +1 -0
- package/dist/engine/Output.d.mts +3 -0
- package/dist/engine/Output.mjs +2 -0
- package/dist/engine/RunEventSink.d.mts +2 -0
- package/dist/engine/RunEventSink.mjs +1 -0
- package/dist/engine/RunOptions.d.mts +2 -0
- package/dist/engine/RunOptions.mjs +1 -0
- package/dist/engine/SubagentHost.d.mts +2 -0
- package/dist/engine/SubagentHost.mjs +1 -0
- package/dist/engine/ThreadHistory.d.mts +2 -0
- package/dist/engine/ThreadHistory.mjs +1 -0
- package/dist/engine/ToolBroker.d.mts +2 -0
- package/dist/engine/ToolBroker.mjs +1 -0
- package/dist/index.d.mts +90 -0
- package/dist/index.mjs +101 -0
- package/dist/output-contract-CYA4oBhe.mjs +128 -0
- package/dist/output-contract-CYA4oBhe.mjs.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-context-reader-CHox63hg.d.mts +17 -0
- package/dist/sandbox/CodeExecutor.d.mts +2 -0
- package/dist/sandbox/CodeExecutor.mjs +1 -0
- package/dist/sandbox/InteractiveBrowser.d.mts +2 -0
- package/dist/sandbox/InteractiveBrowser.mjs +1 -0
- package/dist/sandbox/PageCapture.d.mts +2 -0
- package/dist/sandbox/PageCapture.mjs +1 -0
- package/dist/sandbox/PageScreenshot.d.mts +2 -0
- package/dist/sandbox/PageScreenshot.mjs +1 -0
- package/dist/sandbox/Sandbox.d.mts +2 -0
- package/dist/sandbox/Sandbox.mjs +1 -0
- package/dist/subagent-policy-xRJhrc0a.mjs +133 -0
- package/dist/subagent-policy-xRJhrc0a.mjs.map +1 -0
- package/dist/tool-execution-Cl7v8fXU.mjs +16 -0
- package/dist/tool-execution-Cl7v8fXU.mjs.map +1 -0
- package/dist/tool-operations-CauPonM8.mjs +84 -0
- package/dist/tool-operations-CauPonM8.mjs.map +1 -0
- package/dist/utf8-Bl0ZhhGe.mjs +27 -0
- package/dist/utf8-Bl0ZhhGe.mjs.map +1 -0
- package/package.json +489 -5
- package/src/InMemory.ts +79 -0
- package/src/ToolExposure.ts +2 -0
- package/src/capabilities/BrowserUse.ts +212 -0
- package/src/capabilities/Budget.ts +544 -0
- package/src/capabilities/CodeMode.ts +1129 -0
- package/src/capabilities/ContextTools.ts +131 -0
- package/src/capabilities/MemoryNotes.ts +177 -0
- package/src/capabilities/Messaging.ts +260 -0
- package/src/capabilities/Redaction.ts +163 -0
- package/src/capabilities/RunHooks.ts +116 -0
- package/src/capabilities/SemanticMemory.ts +402 -0
- package/src/capabilities/Subagent.ts +2343 -0
- package/src/capabilities/SubagentReservations.ts +807 -0
- package/src/capabilities/ToolDiscovery.ts +291 -0
- package/src/capabilities/ToolResults.ts +50 -0
- package/src/capabilities/WebCapture.ts +64 -0
- package/src/capabilities/WebSearch.ts +45 -0
- package/src/capabilities/internal/subagent-background.ts +1137 -0
- package/src/capabilities/internal/subagent-contract.ts +92 -0
- package/src/capabilities/internal/subagent-policy.ts +205 -0
- package/src/capabilities/internal/subagent-reporting.ts +152 -0
- package/src/core/Agent.ts +528 -0
- package/src/core/AgentError.ts +189 -0
- package/src/core/AgentPolicy.ts +194 -0
- package/src/core/AgentUpdates.ts +104 -0
- package/src/core/FailureDiagnostic.ts +392 -0
- package/src/core/IdGenerator.ts +42 -0
- package/src/core/Identifiers.ts +64 -0
- package/src/core/Memory.ts +283 -0
- package/src/core/MemoryNamespace.ts +202 -0
- package/src/core/MemoryReference.ts +120 -0
- package/src/core/MemoryRevalidation.ts +151 -0
- package/src/core/MemoryStore.ts +371 -0
- package/src/core/Messaging.ts +72 -0
- package/src/core/ProvisionalText.ts +53 -0
- package/src/core/Receipt.ts +42 -0
- package/src/core/RememberingStore.ts +22 -0
- package/src/core/RunEvent.ts +345 -0
- package/src/core/RunPolicyUsage.ts +19 -0
- package/src/core/SemanticMemoryIndex.ts +259 -0
- package/src/core/SemanticMemoryRevalidation.ts +220 -0
- package/src/core/SubagentContract.ts +263 -0
- package/src/core/Thread.ts +447 -0
- package/src/core/ToolExposure.ts +75 -0
- package/src/core/ToolResult.ts +204 -0
- package/src/core/ToolResultStorage.ts +56 -0
- package/src/core/Usage.ts +562 -0
- package/src/core/Worker.ts +236 -0
- package/src/core/internal/agent-updates.ts +42 -0
- package/src/core/internal/completion.ts +33 -0
- package/src/core/internal/json.ts +17 -0
- package/src/core/internal/memory-document.ts +39 -0
- package/src/core/internal/message-status.ts +60 -0
- package/src/core/internal/strict-schema.ts +14 -0
- package/src/core/internal/tool-execution.ts +33 -0
- package/src/core/internal/utf8.ts +32 -0
- package/src/durable/ActivityStore.ts +131 -0
- package/src/durable/Admin.ts +504 -0
- package/src/durable/AgentRegistration.ts +16 -0
- package/src/durable/CommittedActivity.ts +262 -0
- package/src/durable/Digest.ts +57 -0
- package/src/durable/DurableAgentRuntime.ts +12758 -0
- package/src/durable/DurableFailpoint.ts +108 -0
- package/src/durable/DurableFailpointTestControl.ts +39 -0
- package/src/durable/EventSource.ts +179 -0
- package/src/durable/LifecyclePublication.ts +343 -0
- package/src/durable/MessageDelivery.ts +949 -0
- package/src/durable/MessageDeliveryStoreConformance.ts +407 -0
- package/src/durable/OperationAuthorizer.ts +89 -0
- package/src/durable/PersistentHistory.ts +322 -0
- package/src/durable/PreparedInputAdmission.ts +128 -0
- package/src/durable/RecordFormat.ts +113 -0
- package/src/durable/Records.ts +1396 -0
- package/src/durable/Recovery.ts +1022 -0
- package/src/durable/RunContinuation.ts +1946 -0
- package/src/durable/RunJournal.ts +1926 -0
- package/src/durable/RunStorage.ts +533 -0
- package/src/durable/Schedule.ts +445 -0
- package/src/durable/ScheduleStoreConformance.ts +642 -0
- package/src/durable/ScheduleTransition.ts +267 -0
- package/src/durable/Scheduling.ts +1031 -0
- package/src/durable/SettlementPublisher.ts +172 -0
- package/src/durable/SqlMemoryStore.ts +1042 -0
- package/src/durable/SqlStorageOwner.ts +25 -0
- package/src/durable/SubmissionLedger.ts +1247 -0
- package/src/durable/SubmissionLedgerConformance.ts +4695 -0
- package/src/durable/SubmissionStatus.ts +14 -0
- package/src/durable/Subscription.ts +527 -0
- package/src/durable/SubscriptionInput.ts +145 -0
- package/src/durable/SubscriptionStoreConformance.ts +1275 -0
- package/src/durable/SubscriptionTransition.ts +330 -0
- package/src/durable/Subscriptions.ts +1245 -0
- package/src/durable/ThreadArchiveRange.ts +91 -0
- package/src/durable/ThreadContextHistory.ts +338 -0
- package/src/durable/ThreadContextHistoryProjection.ts +219 -0
- package/src/durable/ThreadImport.ts +1199 -0
- package/src/durable/ThreadInvariants.ts +312 -0
- package/src/durable/ThreadProjectionMaintenance.ts +72 -0
- package/src/durable/ThreadReader.ts +21 -0
- package/src/durable/ThreadStore.ts +1258 -0
- package/src/durable/ThreadStoreConformance.ts +877 -0
- package/src/durable/ThreadTransfer.ts +263 -0
- package/src/durable/ThreadWork.ts +713 -0
- package/src/durable/ToolReconciler.ts +112 -0
- package/src/durable/WakeScheduler.ts +125 -0
- package/src/durable/WorkerAdmission.ts +98 -0
- package/src/durable/WorkerHost.ts +204 -0
- package/src/durable/internal/StorageOwner.ts +181 -0
- package/src/durable/internal/agent-registration.ts +713 -0
- package/src/durable/internal/agent-updates.ts +338 -0
- package/src/durable/internal/canonical-json.ts +110 -0
- package/src/durable/internal/evidence.ts +29 -0
- package/src/durable/internal/foreign-diagnostic.ts +48 -0
- package/src/durable/internal/history-prompt.ts +87 -0
- package/src/durable/internal/initial-context.ts +215 -0
- package/src/durable/internal/journal-metadata.ts +188 -0
- package/src/durable/internal/message-status.ts +18 -0
- package/src/durable/internal/messaging-host.ts +615 -0
- package/src/durable/internal/prompt-footprint.ts +47 -0
- package/src/durable/internal/prompt-history-cache.ts +604 -0
- package/src/durable/internal/record-encoding.ts +258 -0
- package/src/durable/internal/record-ownership.ts +68 -0
- package/src/durable/internal/run-context-reader.ts +51 -0
- package/src/durable/internal/run-context.ts +211 -0
- package/src/durable/internal/schedule-time.ts +304 -0
- package/src/durable/internal/thread-import-reader.ts +85 -0
- package/src/durable/internal/thread-initialization.ts +181 -0
- package/src/durable/internal/thread-transfer-source.ts +7 -0
- package/src/durable/internal/tool-operations.ts +138 -0
- package/src/durable/internal/transfer-dependencies.ts +40 -0
- package/src/durable/internal/usage-totals.ts +36 -0
- package/src/durable/internal/worker-host.ts +4041 -0
- package/src/durable/internal/worker-runtime.ts +10 -0
- package/src/engine/AgentRuntime.ts +100 -0
- package/src/engine/Compaction.ts +11 -0
- package/src/engine/ContextCompactor.ts +302 -0
- package/src/engine/ContextHistory.ts +75 -0
- package/src/engine/ContextWindow.ts +81 -0
- package/src/engine/DurableStep.ts +115 -0
- package/src/engine/MessagingHost.ts +118 -0
- package/src/engine/Output.ts +2 -0
- package/src/engine/RunEventSink.ts +124 -0
- package/src/engine/RunOptions.ts +664 -0
- package/src/engine/SubagentHost.ts +231 -0
- package/src/engine/ThreadHistory.ts +125 -0
- package/src/engine/ToolBroker.ts +159 -0
- package/src/engine/ToolExposure.ts +49 -0
- package/src/engine/internal/agent-runtime.ts +11137 -0
- package/src/engine/internal/bounded-value.ts +312 -0
- package/src/engine/internal/compaction.ts +673 -0
- package/src/engine/internal/error-diagnostic.ts +39 -0
- package/src/engine/internal/image-tokens.ts +61 -0
- package/src/engine/internal/interpreter-options.ts +569 -0
- package/src/engine/internal/output-contract.ts +226 -0
- package/src/engine/internal/primitive-delta.ts +103 -0
- package/src/engine/internal/provider-result-staging.ts +211 -0
- package/src/engine/internal/provisional-text.ts +107 -0
- package/src/engine/internal/tool-derivative.ts +47 -0
- package/src/engine/internal/tool-exposure.ts +228 -0
- package/src/engine/internal/tool-telemetry.ts +488 -0
- package/src/index.ts +100 -0
- package/src/sandbox/CodeExecutor.ts +352 -0
- package/src/sandbox/InteractiveBrowser.ts +343 -0
- package/src/sandbox/PageCapture.ts +391 -0
- package/src/sandbox/PageScreenshot.ts +83 -0
- package/src/sandbox/Sandbox.ts +29 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1275 @@
|
|
|
1
|
+
import * as Clock from 'effect/Clock'
|
|
2
|
+
import * as Effect from 'effect/Effect'
|
|
3
|
+
import * as Result from 'effect/Result'
|
|
4
|
+
import * as Schema from 'effect/Schema'
|
|
5
|
+
import * as TestClock from 'effect/testing/TestClock'
|
|
6
|
+
|
|
7
|
+
import { AgentId, ReceiptId, SubmissionId, ThreadId } from '../core/Identifiers'
|
|
8
|
+
import { Receipt } from './DurableAgentRuntime'
|
|
9
|
+
import { DefinitionDigests, Digest } from './Records'
|
|
10
|
+
import { IdempotencyKey, Principal, QueueSequence } from './SubmissionLedger'
|
|
11
|
+
import {
|
|
12
|
+
type AcceptedEvent,
|
|
13
|
+
defaultSubscriptionLimits,
|
|
14
|
+
type SourcePartition,
|
|
15
|
+
type SubscriptionDelivery,
|
|
16
|
+
type SubscriptionRecord,
|
|
17
|
+
SubscriptionStore,
|
|
18
|
+
type SubscriptionStoreFailure,
|
|
19
|
+
} from './Subscription'
|
|
20
|
+
|
|
21
|
+
export class SubscriptionStoreConformanceViolation extends Schema.TaggedError<SubscriptionStoreConformanceViolation>()(
|
|
22
|
+
'SubscriptionStoreConformanceViolation',
|
|
23
|
+
{ caseName: Schema.String, message: Schema.String },
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
export interface SubscriptionStoreConformanceCase {
|
|
27
|
+
readonly name: string
|
|
28
|
+
readonly run: Effect.Effect<
|
|
29
|
+
void,
|
|
30
|
+
SubscriptionStoreFailure | SubscriptionStoreConformanceViolation,
|
|
31
|
+
SubscriptionStore
|
|
32
|
+
>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const subscriptionConformancePartition: SourcePartition = {
|
|
36
|
+
tenantId: 'subscription-conformance',
|
|
37
|
+
address: 'source-address',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const principal = Schema.decodeSync(Principal)('subscription-conformance-principal')
|
|
41
|
+
const agentId = Schema.decodeSync(AgentId)('subscription-conformance-agent')
|
|
42
|
+
const threadId = Schema.decodeSync(ThreadId)('subscription-conformance-thread')
|
|
43
|
+
const digest = (character: string) => Schema.decodeSync(Digest)(character.repeat(64))
|
|
44
|
+
|
|
45
|
+
const definitions = DefinitionDigests.make({
|
|
46
|
+
agent: digest('a'),
|
|
47
|
+
model: digest('b'),
|
|
48
|
+
tools: digest('c'),
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const record = (
|
|
52
|
+
name: string,
|
|
53
|
+
mode: 'once' | 'continuous' = 'once',
|
|
54
|
+
ownerId = 'owner',
|
|
55
|
+
): SubscriptionRecord => ({
|
|
56
|
+
schemaVersion: 1,
|
|
57
|
+
key: { partition: subscriptionConformancePartition, ownerId, subscriptionId: name },
|
|
58
|
+
creationFingerprint: digest(name.charCodeAt(0) % 2 === 0 ? 'd' : 'e'),
|
|
59
|
+
createdBy: principal,
|
|
60
|
+
createdAtMillis: 1,
|
|
61
|
+
ordinal: 0,
|
|
62
|
+
configurationRevision: 1,
|
|
63
|
+
configurationFingerprint: digest(name.charCodeAt(0) % 2 === 0 ? 'd' : 'e'),
|
|
64
|
+
creationConfiguration: {
|
|
65
|
+
source: { name: 'trusted', version: '1' },
|
|
66
|
+
matchingKey: 'match',
|
|
67
|
+
parameters: { name },
|
|
68
|
+
context: { name },
|
|
69
|
+
mode,
|
|
70
|
+
expiresAtMillis: 100_000,
|
|
71
|
+
destination: { _tag: 'ExistingThread', threadId },
|
|
72
|
+
deliveryPrincipal: principal,
|
|
73
|
+
agentId,
|
|
74
|
+
definitions,
|
|
75
|
+
},
|
|
76
|
+
configuration: {
|
|
77
|
+
source: { name: 'trusted', version: '1' },
|
|
78
|
+
matchingKey: 'match',
|
|
79
|
+
parameters: { name },
|
|
80
|
+
context: { name },
|
|
81
|
+
mode,
|
|
82
|
+
expiresAtMillis: 100_000,
|
|
83
|
+
destination: { _tag: 'ExistingThread', threadId },
|
|
84
|
+
deliveryPrincipal: principal,
|
|
85
|
+
agentId,
|
|
86
|
+
definitions,
|
|
87
|
+
},
|
|
88
|
+
state: 'active',
|
|
89
|
+
recovery: null,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const event = (name: string, payloadDigest = digest('f')): AcceptedEvent => ({
|
|
93
|
+
schemaVersion: 1,
|
|
94
|
+
partition: subscriptionConformancePartition,
|
|
95
|
+
eventId: name,
|
|
96
|
+
source: { name: 'trusted', version: '1' },
|
|
97
|
+
matchingKey: 'match',
|
|
98
|
+
payload: { name },
|
|
99
|
+
payloadDigest,
|
|
100
|
+
acceptedAtMillis: 10,
|
|
101
|
+
cutoff: 0,
|
|
102
|
+
cursor: 0,
|
|
103
|
+
routingComplete: false,
|
|
104
|
+
routingFailure: null,
|
|
105
|
+
nextAttemptAtMillis: 10,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const delivery = (
|
|
109
|
+
subscription: SubscriptionRecord,
|
|
110
|
+
accepted: AcceptedEvent,
|
|
111
|
+
suffix = '0',
|
|
112
|
+
): SubscriptionDelivery => {
|
|
113
|
+
const deliveryId = digest(suffix === '0' ? '1' : '2')
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
schemaVersion: 1,
|
|
117
|
+
key: { subscription: subscription.key, eventId: accepted.eventId },
|
|
118
|
+
deliveryId,
|
|
119
|
+
source: accepted.source,
|
|
120
|
+
subscriptionFingerprint: subscription.configurationFingerprint,
|
|
121
|
+
configurationRevision: subscription.configurationRevision,
|
|
122
|
+
configuration: subscription.configuration,
|
|
123
|
+
eventDigest: accepted.payloadDigest,
|
|
124
|
+
threadId,
|
|
125
|
+
admissionKey: Schema.decodeSync(IdempotencyKey)(`subscription:${deliveryId}`),
|
|
126
|
+
selectedAtMillis: suffix === '0' ? 20 : 21,
|
|
127
|
+
state: 'selected',
|
|
128
|
+
envelope: null,
|
|
129
|
+
envelopeDigest: null,
|
|
130
|
+
retry: {
|
|
131
|
+
generation: 0,
|
|
132
|
+
attempts: 0,
|
|
133
|
+
automaticAttempts: 0,
|
|
134
|
+
parked: false,
|
|
135
|
+
nextAttemptAtMillis: 20,
|
|
136
|
+
lastAttemptAtMillis: null,
|
|
137
|
+
lastFailure: null,
|
|
138
|
+
},
|
|
139
|
+
receipt: null,
|
|
140
|
+
refusal: null,
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const preparedInput = (selected: SubscriptionDelivery) => ({
|
|
145
|
+
schemaVersion: 1 as const,
|
|
146
|
+
threadId: selected.threadId,
|
|
147
|
+
deliveryPrincipal: principal,
|
|
148
|
+
agentId,
|
|
149
|
+
definitions,
|
|
150
|
+
input: { event: selected.key.eventId },
|
|
151
|
+
inputDigest: digest('3'),
|
|
152
|
+
admissionKey: selected.admissionKey,
|
|
153
|
+
authorization: { policyId: 'policy', decisionId: 'decision' },
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const receipt = Receipt.make({
|
|
157
|
+
receiptId: Schema.decodeSync(ReceiptId)('subscription-conformance-receipt'),
|
|
158
|
+
submissionId: Schema.decodeSync(SubmissionId)('subscription-conformance-submission'),
|
|
159
|
+
threadId,
|
|
160
|
+
queueSequence: Schema.decodeSync(QueueSequence)(1),
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const conformanceCase = (
|
|
164
|
+
name: string,
|
|
165
|
+
body: (
|
|
166
|
+
ensure: (
|
|
167
|
+
condition: boolean,
|
|
168
|
+
message: string,
|
|
169
|
+
) => Effect.Effect<void, SubscriptionStoreConformanceViolation>,
|
|
170
|
+
) => Effect.Effect<
|
|
171
|
+
void,
|
|
172
|
+
SubscriptionStoreFailure | SubscriptionStoreConformanceViolation,
|
|
173
|
+
SubscriptionStore
|
|
174
|
+
>,
|
|
175
|
+
): SubscriptionStoreConformanceCase => ({
|
|
176
|
+
name,
|
|
177
|
+
run: body((condition, message) =>
|
|
178
|
+
condition
|
|
179
|
+
? Effect.void
|
|
180
|
+
: Effect.fail(SubscriptionStoreConformanceViolation.make({ caseName: name, message }))
|
|
181
|
+
),
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const historicalOccurrenceReplay = conformanceCase(
|
|
185
|
+
'preserves unknown occurrence time on replay and fences known times',
|
|
186
|
+
(ensure) =>
|
|
187
|
+
Effect.gen(function*() {
|
|
188
|
+
const store = yield* SubscriptionStore
|
|
189
|
+
const original = yield* store.accept(event('legacy-occurrence'), defaultSubscriptionLimits)
|
|
190
|
+
|
|
191
|
+
const replay = yield* store.accept(
|
|
192
|
+
{ ...original, occurredAtMillis: 1 },
|
|
193
|
+
defaultSubscriptionLimits,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
yield* ensure(
|
|
197
|
+
replay.occurredAtMillis === undefined &&
|
|
198
|
+
replay.acceptedAtMillis === original.acceptedAtMillis &&
|
|
199
|
+
replay.cutoff === original.cutoff,
|
|
200
|
+
'replay invented historical occurrence or moved acceptance',
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
const known = yield* store.accept(
|
|
204
|
+
{ ...event('known-occurrence'), occurredAtMillis: 1 },
|
|
205
|
+
defaultSubscriptionLimits,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
const changed = yield* store
|
|
209
|
+
.accept({ ...known, occurredAtMillis: 2 }, defaultSubscriptionLimits)
|
|
210
|
+
.pipe(Effect.result)
|
|
211
|
+
|
|
212
|
+
yield* ensure(Result.isFailure(changed), 'known occurrence time changed on replay')
|
|
213
|
+
|
|
214
|
+
const omitted = yield* store
|
|
215
|
+
.accept(event('known-occurrence'), defaultSubscriptionLimits)
|
|
216
|
+
.pipe(Effect.result)
|
|
217
|
+
|
|
218
|
+
yield* ensure(Result.isFailure(omitted), 'known occurrence time was erased on replay')
|
|
219
|
+
}),
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
const cutoffAndIntake = conformanceCase(
|
|
223
|
+
'orders eligibility cutoffs and preserves duplicate intake',
|
|
224
|
+
(ensure) =>
|
|
225
|
+
Effect.gen(function*() {
|
|
226
|
+
const store = yield* SubscriptionStore
|
|
227
|
+
const before = yield* store.register(record('before'), defaultSubscriptionLimits)
|
|
228
|
+
const accepted = yield* store.accept(event('cutoff'), defaultSubscriptionLimits)
|
|
229
|
+
const after = yield* store.register(record('after'), defaultSubscriptionLimits)
|
|
230
|
+
|
|
231
|
+
yield* ensure(
|
|
232
|
+
before.ordinal < accepted.cutoff && after.ordinal > accepted.cutoff,
|
|
233
|
+
'sequence did not order registration and intake',
|
|
234
|
+
)
|
|
235
|
+
const candidates = yield* store.candidates(accepted, 10)
|
|
236
|
+
|
|
237
|
+
yield* ensure(
|
|
238
|
+
candidates.length === 1 && candidates[0].key.subscriptionId === 'before',
|
|
239
|
+
'cutoff admitted a later registration',
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
const replayed = yield* store.accept(
|
|
243
|
+
{ ...event('cutoff'), acceptedAtMillis: 99 },
|
|
244
|
+
defaultSubscriptionLimits,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
yield* ensure(
|
|
248
|
+
replayed.cutoff === accepted.cutoff &&
|
|
249
|
+
replayed.acceptedAtMillis === accepted.acceptedAtMillis,
|
|
250
|
+
'duplicate intake did not return retained progress',
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
const conflict = yield* Effect.result(
|
|
254
|
+
store.accept(event('cutoff', digest('9')), defaultSubscriptionLimits),
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
yield* ensure(
|
|
258
|
+
Result.isFailure(conflict) &&
|
|
259
|
+
conflict.failure._tag === 'SubscriptionError' &&
|
|
260
|
+
conflict.failure.reason === 'conflict',
|
|
261
|
+
'conflicting event identity was accepted',
|
|
262
|
+
)
|
|
263
|
+
}),
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
const onceAndCapacity = conformanceCase(
|
|
267
|
+
'consumes once atomically and rejects capacity before progress',
|
|
268
|
+
(ensure) =>
|
|
269
|
+
Effect.gen(function*() {
|
|
270
|
+
const store = yield* SubscriptionStore
|
|
271
|
+
const once = yield* store.register(record('once'), defaultSubscriptionLimits)
|
|
272
|
+
const first = yield* store.accept(event('first'), defaultSubscriptionLimits)
|
|
273
|
+
const second = yield* store.accept(event('second'), defaultSubscriptionLimits)
|
|
274
|
+
|
|
275
|
+
const duplicate = yield* store
|
|
276
|
+
.select(
|
|
277
|
+
first,
|
|
278
|
+
[delivery(once, first), delivery(once, first)],
|
|
279
|
+
once.ordinal,
|
|
280
|
+
true,
|
|
281
|
+
20,
|
|
282
|
+
defaultSubscriptionLimits,
|
|
283
|
+
)
|
|
284
|
+
.pipe(Effect.result)
|
|
285
|
+
|
|
286
|
+
yield* ensure(
|
|
287
|
+
Result.isFailure(duplicate) &&
|
|
288
|
+
duplicate.failure._tag === 'SubscriptionError' &&
|
|
289
|
+
duplicate.failure.reason === 'validation',
|
|
290
|
+
'duplicate batch keys must not charge capacity twice for one retained delivery',
|
|
291
|
+
)
|
|
292
|
+
yield* ensure(
|
|
293
|
+
(yield* store.get(once.key))?.state === 'active' &&
|
|
294
|
+
(yield* store.event(first.eventId))?.cursor === 0,
|
|
295
|
+
'duplicate batch rejection consumed once or advanced routing',
|
|
296
|
+
)
|
|
297
|
+
yield* store.select(
|
|
298
|
+
first,
|
|
299
|
+
[delivery(once, first)],
|
|
300
|
+
once.ordinal,
|
|
301
|
+
true,
|
|
302
|
+
20,
|
|
303
|
+
defaultSubscriptionLimits,
|
|
304
|
+
)
|
|
305
|
+
yield* store.select(
|
|
306
|
+
second,
|
|
307
|
+
[delivery(once, second)],
|
|
308
|
+
once.ordinal,
|
|
309
|
+
true,
|
|
310
|
+
20,
|
|
311
|
+
defaultSubscriptionLimits,
|
|
312
|
+
)
|
|
313
|
+
yield* ensure(
|
|
314
|
+
(yield* store.get(once.key))?.state === 'consumed',
|
|
315
|
+
'once registration remained active',
|
|
316
|
+
)
|
|
317
|
+
yield* ensure(
|
|
318
|
+
(yield* store.delivery({ subscription: once.key, eventId: first.eventId })) !== null,
|
|
319
|
+
'winning delivery was lost',
|
|
320
|
+
)
|
|
321
|
+
yield* ensure(
|
|
322
|
+
(yield* store.delivery({ subscription: once.key, eventId: second.eventId })) === null,
|
|
323
|
+
'second event consumed once registration again',
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
const left = yield* store.register(
|
|
327
|
+
record('left', 'continuous', 'capacity'),
|
|
328
|
+
defaultSubscriptionLimits,
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
const right = yield* store.register(
|
|
332
|
+
record('right', 'continuous', 'capacity'),
|
|
333
|
+
defaultSubscriptionLimits,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
const bounded = yield* store.accept(event('bounded'), defaultSubscriptionLimits)
|
|
337
|
+
const limits = { ...defaultSubscriptionLimits, maxDeliveries: 2, maxDeliveriesPerOwner: 1 }
|
|
338
|
+
|
|
339
|
+
const failure = yield* Effect.result(
|
|
340
|
+
store.select(
|
|
341
|
+
bounded,
|
|
342
|
+
[delivery(left, bounded), delivery(right, bounded, '1')],
|
|
343
|
+
right.ordinal,
|
|
344
|
+
true,
|
|
345
|
+
20,
|
|
346
|
+
limits,
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
yield* ensure(
|
|
351
|
+
Result.isFailure(failure) &&
|
|
352
|
+
failure.failure._tag === 'SubscriptionError' &&
|
|
353
|
+
failure.failure.reason === 'capacity',
|
|
354
|
+
'delivery quota did not reject batch',
|
|
355
|
+
)
|
|
356
|
+
yield* ensure(
|
|
357
|
+
(yield* store.event(bounded.eventId))?.cursor === 0,
|
|
358
|
+
'capacity failure advanced event cursor',
|
|
359
|
+
)
|
|
360
|
+
}),
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
const preparationLifecycle = conformanceCase(
|
|
364
|
+
'refuses cancelled selection and preserves prepared work',
|
|
365
|
+
(ensure) =>
|
|
366
|
+
Effect.gen(function*() {
|
|
367
|
+
const store = yield* SubscriptionStore
|
|
368
|
+
const cancelled = yield* store.register(record('cancelled'), defaultSubscriptionLimits)
|
|
369
|
+
|
|
370
|
+
const cancelledEvent = yield* store.accept(
|
|
371
|
+
event('cancelled-event'),
|
|
372
|
+
defaultSubscriptionLimits,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
const cancelledDelivery = delivery(cancelled, cancelledEvent)
|
|
376
|
+
|
|
377
|
+
yield* store.select(
|
|
378
|
+
cancelledEvent,
|
|
379
|
+
[cancelledDelivery],
|
|
380
|
+
cancelled.ordinal,
|
|
381
|
+
true,
|
|
382
|
+
20,
|
|
383
|
+
defaultSubscriptionLimits,
|
|
384
|
+
)
|
|
385
|
+
yield* store.cancel(cancelled.key)
|
|
386
|
+
|
|
387
|
+
const refused = yield* store.changeDelivery(
|
|
388
|
+
cancelledDelivery.key,
|
|
389
|
+
cancelledDelivery.deliveryId,
|
|
390
|
+
{
|
|
391
|
+
_tag: 'Prepare',
|
|
392
|
+
envelope: preparedInput(cancelledDelivery),
|
|
393
|
+
envelopeDigest: digest('4'),
|
|
394
|
+
nowMillis: 30,
|
|
395
|
+
},
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
yield* ensure(
|
|
399
|
+
refused.state === 'refused' && refused.refusal?.code === 'cancelled',
|
|
400
|
+
'cancelled selection prepared',
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
const durable = yield* store.register(record('durable'), defaultSubscriptionLimits)
|
|
404
|
+
const durableEvent = yield* store.accept(event('durable-event'), defaultSubscriptionLimits)
|
|
405
|
+
const selected = delivery(durable, durableEvent)
|
|
406
|
+
|
|
407
|
+
yield* store.select(
|
|
408
|
+
durableEvent,
|
|
409
|
+
[selected],
|
|
410
|
+
durable.ordinal,
|
|
411
|
+
true,
|
|
412
|
+
20,
|
|
413
|
+
defaultSubscriptionLimits,
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
const prepared = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
417
|
+
_tag: 'Prepare',
|
|
418
|
+
envelope: preparedInput(selected),
|
|
419
|
+
envelopeDigest: digest('5'),
|
|
420
|
+
nowMillis: 30,
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
const retry = {
|
|
424
|
+
generation: 0,
|
|
425
|
+
automaticAttempts: 0,
|
|
426
|
+
parked: false,
|
|
427
|
+
attempts: 2,
|
|
428
|
+
nextAttemptAtMillis: 60,
|
|
429
|
+
lastAttemptAtMillis: 35,
|
|
430
|
+
lastFailure: 'transport' as const,
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
434
|
+
_tag: 'Retry',
|
|
435
|
+
retry,
|
|
436
|
+
nowMillis: 35,
|
|
437
|
+
})
|
|
438
|
+
for (
|
|
439
|
+
const staleRetry of [
|
|
440
|
+
{ ...retry, attempts: 1, nextAttemptAtMillis: 70 },
|
|
441
|
+
{ ...retry, nextAttemptAtMillis: 70 },
|
|
442
|
+
{ ...retry, attempts: 3, nextAttemptAtMillis: 50 },
|
|
443
|
+
]
|
|
444
|
+
) {
|
|
445
|
+
const retained = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
446
|
+
_tag: 'Retry',
|
|
447
|
+
retry: staleRetry,
|
|
448
|
+
nowMillis: 36,
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
yield* ensure(
|
|
452
|
+
retained.retry.attempts === 2 && retained.retry.nextAttemptAtMillis === 60,
|
|
453
|
+
'stale retry overwrote newer retry state',
|
|
454
|
+
)
|
|
455
|
+
}
|
|
456
|
+
yield* store.cancel(durable.key)
|
|
457
|
+
|
|
458
|
+
const completed = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
459
|
+
_tag: 'Complete',
|
|
460
|
+
receipt,
|
|
461
|
+
nowMillis: 40,
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
yield* ensure(
|
|
465
|
+
prepared.state === 'prepared' && completed.state === 'delivered',
|
|
466
|
+
'prepared work did not survive cancellation',
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
const stale = yield* Effect.result(
|
|
470
|
+
store.changeDelivery(selected.key, digest('8'), {
|
|
471
|
+
_tag: 'Complete',
|
|
472
|
+
receipt,
|
|
473
|
+
nowMillis: 41,
|
|
474
|
+
}),
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
yield* ensure(
|
|
478
|
+
Result.isFailure(stale) &&
|
|
479
|
+
stale.failure._tag === 'SubscriptionError' &&
|
|
480
|
+
stale.failure.code === 'stale-delivery',
|
|
481
|
+
'stale outcome was not fenced',
|
|
482
|
+
)
|
|
483
|
+
}),
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
const catchUpAndCursors = conformanceCase(
|
|
487
|
+
'limits catch-up to one watch and persists recovery cursors',
|
|
488
|
+
(ensure) =>
|
|
489
|
+
Effect.gen(function*() {
|
|
490
|
+
const store = yield* SubscriptionStore
|
|
491
|
+
const accepted = yield* store.accept(event('observed'), defaultSubscriptionLimits)
|
|
492
|
+
const watch = yield* store.register(record('watch'), defaultSubscriptionLimits)
|
|
493
|
+
const selected = delivery(watch, accepted)
|
|
494
|
+
|
|
495
|
+
yield* store.catchUp(accepted, selected, 20, defaultSubscriptionLimits)
|
|
496
|
+
yield* store.catchUp(
|
|
497
|
+
accepted,
|
|
498
|
+
{ ...selected, selectedAtMillis: 999, retry: { ...selected.retry, attempts: 2 } },
|
|
499
|
+
30,
|
|
500
|
+
defaultSubscriptionLimits,
|
|
501
|
+
)
|
|
502
|
+
yield* ensure(
|
|
503
|
+
(yield* store.get(watch.key))?.state === 'consumed',
|
|
504
|
+
'catch-up did not consume watch',
|
|
505
|
+
)
|
|
506
|
+
yield* store.advanceScanCursors({ events: 'e', deliveries: 'd', recovery: 7 })
|
|
507
|
+
const cursors = yield* store.readScanCursors
|
|
508
|
+
|
|
509
|
+
yield* ensure(
|
|
510
|
+
cursors.events === 'e' && cursors.deliveries === 'd' && cursors.recovery === 7,
|
|
511
|
+
'scan cursors were not durable',
|
|
512
|
+
)
|
|
513
|
+
yield* ensure(
|
|
514
|
+
(yield* store.nextDeadline) === 0,
|
|
515
|
+
'nonzero scan cursor did not keep recovery armed',
|
|
516
|
+
)
|
|
517
|
+
}),
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
const replayUnderTighterLimits = conformanceCase(
|
|
521
|
+
'preserves retained identities when limits tighten',
|
|
522
|
+
(ensure) =>
|
|
523
|
+
Effect.gen(function*() {
|
|
524
|
+
const store = yield* SubscriptionStore
|
|
525
|
+
const created = yield* store.register(record('retained'), defaultSubscriptionLimits)
|
|
526
|
+
const accepted = yield* store.accept(event('retained'), defaultSubscriptionLimits)
|
|
527
|
+
|
|
528
|
+
const limits = {
|
|
529
|
+
...defaultSubscriptionLimits,
|
|
530
|
+
maxRegistrations: 1,
|
|
531
|
+
maxEvents: 1,
|
|
532
|
+
maxPayloadBytes: 1,
|
|
533
|
+
maxContextBytes: 1,
|
|
534
|
+
maxLifetimeMillis: 1,
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const replayed = yield* store.register(record('retained'), limits)
|
|
538
|
+
const repeated = yield* store.accept(event('retained'), limits)
|
|
539
|
+
|
|
540
|
+
yield* ensure(replayed.ordinal === created.ordinal, 'registration replay lost identity')
|
|
541
|
+
yield* ensure(repeated.cutoff === accepted.cutoff, 'intake replay lost cutoff')
|
|
542
|
+
const newRegistration = yield* Effect.result(store.register(record('new'), limits))
|
|
543
|
+
const newEvent = yield* Effect.result(store.accept(event('new'), limits))
|
|
544
|
+
|
|
545
|
+
yield* ensure(Result.isFailure(newRegistration), 'new registration ignored tightened limits')
|
|
546
|
+
yield* ensure(Result.isFailure(newEvent), 'new intake ignored tightened limits')
|
|
547
|
+
}),
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
const revisionsAndRetention = conformanceCase(
|
|
551
|
+
'preserves historical selection, CAS revisions, and unsettled evidence during retention',
|
|
552
|
+
(ensure) =>
|
|
553
|
+
Effect.gen(function*() {
|
|
554
|
+
const store = yield* SubscriptionStore
|
|
555
|
+
const now = yield* Clock.currentTimeMillis
|
|
556
|
+
const policy = { replayHorizonMillis: 10_000, completedRetentionMillis: 0, maxTombstones: 8 }
|
|
557
|
+
const limits = { ...defaultSubscriptionLimits, retention: policy }
|
|
558
|
+
const indefinite = record('revision', 'continuous')
|
|
559
|
+
|
|
560
|
+
const original = yield* store.register(
|
|
561
|
+
{
|
|
562
|
+
...indefinite,
|
|
563
|
+
configuration: { ...indefinite.configuration, expiresAtMillis: null },
|
|
564
|
+
},
|
|
565
|
+
limits,
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
yield* ensure(
|
|
569
|
+
original.configuration.expiresAtMillis === null,
|
|
570
|
+
'UntilCancelled must remain explicit',
|
|
571
|
+
)
|
|
572
|
+
yield* ensure(
|
|
573
|
+
(yield* store.nextDeadline) === null,
|
|
574
|
+
'UntilCancelled cannot create an expiry wake',
|
|
575
|
+
)
|
|
576
|
+
|
|
577
|
+
const accepted = yield* store.accept(
|
|
578
|
+
{ ...event('retained'), occurredAtMillis: now, acceptedAtMillis: now },
|
|
579
|
+
limits,
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
const selected = {
|
|
583
|
+
...delivery(original, accepted),
|
|
584
|
+
configuration: original.configuration,
|
|
585
|
+
configurationRevision: 1,
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
yield* store.select(
|
|
589
|
+
accepted,
|
|
590
|
+
[selected],
|
|
591
|
+
original.ordinal,
|
|
592
|
+
true,
|
|
593
|
+
now + limits.maxLifetimeMillis + 1,
|
|
594
|
+
limits,
|
|
595
|
+
)
|
|
596
|
+
yield* ensure(
|
|
597
|
+
(yield* store.delivery(selected.key)) !== null,
|
|
598
|
+
'UntilCancelled cannot expire at the ordinary maximum lifetime',
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
const updated = yield* store.change(original.key, 1, {
|
|
602
|
+
_tag: 'Update',
|
|
603
|
+
configuration: { ...original.configuration, context: { edited: true } },
|
|
604
|
+
configurationFingerprint: digest('9'),
|
|
605
|
+
recovery: null,
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
yield* ensure(
|
|
609
|
+
updated.configurationRevision === 2 && updated.creationConfiguration !== undefined,
|
|
610
|
+
'Update must preserve creation evidence and advance revision',
|
|
611
|
+
)
|
|
612
|
+
const stale = yield* store.change(original.key, 1, { _tag: 'Pause' }).pipe(Effect.result)
|
|
613
|
+
|
|
614
|
+
yield* ensure(Result.isFailure(stale), 'Stale management must conflict')
|
|
615
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
616
|
+
_tag: 'Prepare',
|
|
617
|
+
envelope: preparedInput(selected),
|
|
618
|
+
envelopeDigest: digest('4'),
|
|
619
|
+
nowMillis: now,
|
|
620
|
+
})
|
|
621
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
622
|
+
_tag: 'Complete',
|
|
623
|
+
receipt,
|
|
624
|
+
nowMillis: now,
|
|
625
|
+
})
|
|
626
|
+
yield* store.compact(now, policy, 8)
|
|
627
|
+
yield* ensure(
|
|
628
|
+
(yield* store.delivery(selected.key)) !== null,
|
|
629
|
+
'Admission is not settlement; delivery evidence must remain',
|
|
630
|
+
)
|
|
631
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
632
|
+
_tag: 'ObserveSettlement',
|
|
633
|
+
receipt,
|
|
634
|
+
settled: true,
|
|
635
|
+
nowMillis: now,
|
|
636
|
+
nextAttemptAtMillis: now,
|
|
637
|
+
})
|
|
638
|
+
const recovering = yield* store.register(record('recovering-retention', 'once'), limits)
|
|
639
|
+
|
|
640
|
+
yield* store.deferRecovery(recovering.key, recovering.configurationRevision, {
|
|
641
|
+
attempts: 1,
|
|
642
|
+
nextAttemptAtMillis: null,
|
|
643
|
+
lastFailure: 'source-unavailable',
|
|
644
|
+
})
|
|
645
|
+
yield* store.compact(now, policy, 8)
|
|
646
|
+
yield* ensure(
|
|
647
|
+
(yield* store.delivery(selected.key)) !== null,
|
|
648
|
+
'Permanent recovery evidence must protect retained source facts',
|
|
649
|
+
)
|
|
650
|
+
yield* store.deferRecovery(recovering.key, recovering.configurationRevision, null)
|
|
651
|
+
yield* store.compact(now, policy, 8)
|
|
652
|
+
yield* ensure(
|
|
653
|
+
(yield* store.delivery(selected.key)) === null,
|
|
654
|
+
'Settled delivery must release retained capacity',
|
|
655
|
+
)
|
|
656
|
+
yield* ensure(
|
|
657
|
+
(yield* store.event(accepted.eventId))?.tombstone === true,
|
|
658
|
+
'Deduplication tombstone must outlive completed payload',
|
|
659
|
+
)
|
|
660
|
+
const replay = yield* store.accept(accepted, limits)
|
|
661
|
+
|
|
662
|
+
yield* ensure(
|
|
663
|
+
Result.isFailure(
|
|
664
|
+
yield* store
|
|
665
|
+
.accept({ ...accepted, occurredAtMillis: now + 1 }, limits)
|
|
666
|
+
.pipe(Effect.result),
|
|
667
|
+
),
|
|
668
|
+
'An event identity cannot replace its retained source timestamp',
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
yield* ensure(
|
|
672
|
+
Result.isFailure(
|
|
673
|
+
yield* store.compact(now, { ...policy, replayHorizonMillis: 1 }, 8).pipe(Effect.result),
|
|
674
|
+
),
|
|
675
|
+
'Compaction cannot change the persisted replay horizon',
|
|
676
|
+
)
|
|
677
|
+
yield* ensure(
|
|
678
|
+
Result.isFailure(
|
|
679
|
+
yield* store
|
|
680
|
+
.accept(event('without-policy'), defaultSubscriptionLimits)
|
|
681
|
+
.pipe(Effect.result),
|
|
682
|
+
),
|
|
683
|
+
'Fresh intake cannot disable established retention',
|
|
684
|
+
)
|
|
685
|
+
yield* ensure(
|
|
686
|
+
replay.cutoff === accepted.cutoff && replay.tombstone === true,
|
|
687
|
+
'Duplicate intake cannot reopen routing after compaction',
|
|
688
|
+
)
|
|
689
|
+
}),
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
const sustainedRetention = conformanceCase(
|
|
693
|
+
'reuses event, delivery and tombstone quotas across replay horizons',
|
|
694
|
+
(ensure) =>
|
|
695
|
+
Effect.gen(function*() {
|
|
696
|
+
const store = yield* SubscriptionStore
|
|
697
|
+
const policy = { replayHorizonMillis: 100, completedRetentionMillis: 0, maxTombstones: 8 }
|
|
698
|
+
|
|
699
|
+
const limits = {
|
|
700
|
+
...defaultSubscriptionLimits,
|
|
701
|
+
maxEvents: 4,
|
|
702
|
+
maxDeliveries: 4,
|
|
703
|
+
maxDeliveriesPerOwner: 4,
|
|
704
|
+
retention: policy,
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const registration = yield* store.register(record('sustained', 'continuous'), limits)
|
|
708
|
+
|
|
709
|
+
// 32 events reuse four live slots and eight tombstone slots across six replay
|
|
710
|
+
// horizons, including the lexical 9→10 boundary. The full driver's >1,000-event
|
|
711
|
+
// regression remains in storage-memory/test/subscriptions.test.ts; bounded cursor
|
|
712
|
+
// traversal is exercised separately by retentionFairness on every adapter.
|
|
713
|
+
for (let index = 0; index < 32; index++) {
|
|
714
|
+
const now = yield* Clock.currentTimeMillis
|
|
715
|
+
|
|
716
|
+
const accepted = yield* store.accept(
|
|
717
|
+
{ ...event(`retained-${index}`), occurredAtMillis: now, acceptedAtMillis: now },
|
|
718
|
+
limits,
|
|
719
|
+
)
|
|
720
|
+
|
|
721
|
+
const deliveryId = yield* Schema.decodeEffect(Digest)(
|
|
722
|
+
index.toString(16).padStart(64, '0'),
|
|
723
|
+
).pipe(Effect.orDie)
|
|
724
|
+
|
|
725
|
+
const selected = {
|
|
726
|
+
...delivery(registration, accepted),
|
|
727
|
+
deliveryId,
|
|
728
|
+
admissionKey: yield* Schema.decodeEffect(IdempotencyKey)(
|
|
729
|
+
`subscription:${deliveryId}`,
|
|
730
|
+
).pipe(Effect.orDie),
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
yield* store.select(accepted, [selected], registration.ordinal, true, now, limits)
|
|
734
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
735
|
+
_tag: 'Prepare',
|
|
736
|
+
envelope: preparedInput(selected),
|
|
737
|
+
envelopeDigest: digest('4'),
|
|
738
|
+
nowMillis: now,
|
|
739
|
+
})
|
|
740
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
741
|
+
_tag: 'Complete',
|
|
742
|
+
receipt,
|
|
743
|
+
nowMillis: now,
|
|
744
|
+
})
|
|
745
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
746
|
+
_tag: 'ObserveSettlement',
|
|
747
|
+
receipt,
|
|
748
|
+
settled: true,
|
|
749
|
+
nowMillis: now,
|
|
750
|
+
nextAttemptAtMillis: now,
|
|
751
|
+
})
|
|
752
|
+
yield* store.compact(now, policy, 8)
|
|
753
|
+
yield* ensure(
|
|
754
|
+
(yield* store.delivery(selected.key)) === null,
|
|
755
|
+
'Settled delivery must release its quota on every cycle',
|
|
756
|
+
)
|
|
757
|
+
yield* ensure(
|
|
758
|
+
(yield* store.accept(accepted, limits)).tombstone === true,
|
|
759
|
+
'Duplicate acknowledgement must preserve its tombstone',
|
|
760
|
+
)
|
|
761
|
+
yield* TestClock.adjust(20)
|
|
762
|
+
}
|
|
763
|
+
yield* ensure(
|
|
764
|
+
(yield* store.event('retained-0')) === null,
|
|
765
|
+
'Expired identity must be reclaimed',
|
|
766
|
+
)
|
|
767
|
+
|
|
768
|
+
const expired = yield* store
|
|
769
|
+
.accept({ ...event('retained-0'), occurredAtMillis: 0 }, limits)
|
|
770
|
+
.pipe(Effect.result)
|
|
771
|
+
|
|
772
|
+
yield* ensure(
|
|
773
|
+
Result.isFailure(expired) &&
|
|
774
|
+
expired.failure._tag === 'SubscriptionError' &&
|
|
775
|
+
expired.failure.code === 'event-replay-horizon',
|
|
776
|
+
'Reclaimed identity must not be admitted after its replay horizon',
|
|
777
|
+
)
|
|
778
|
+
}),
|
|
779
|
+
)
|
|
780
|
+
|
|
781
|
+
const lifetimeCapacity = conformanceCase(
|
|
782
|
+
'reuses subscription capacity without retention and preserves live host guards and replay',
|
|
783
|
+
(ensure) =>
|
|
784
|
+
Effect.gen(function*() {
|
|
785
|
+
const store = yield* SubscriptionStore
|
|
786
|
+
|
|
787
|
+
const limits = {
|
|
788
|
+
...defaultSubscriptionLimits,
|
|
789
|
+
maxRegistrations: 1,
|
|
790
|
+
maxRegistrationsPerOwner: 1,
|
|
791
|
+
maxEvents: 1,
|
|
792
|
+
maxDeliveries: 1,
|
|
793
|
+
maxDeliveriesPerOwner: 1,
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
const retained: Array<{
|
|
797
|
+
registration: SubscriptionRecord
|
|
798
|
+
accepted: AcceptedEvent
|
|
799
|
+
completed: SubscriptionDelivery
|
|
800
|
+
}> = []
|
|
801
|
+
|
|
802
|
+
for (let index = 0; index < 4; index++) {
|
|
803
|
+
const registration = yield* store.register(record(`lifetime-${index}`), limits)
|
|
804
|
+
const accepted = yield* store.accept(event(`lifetime-${index}`), limits)
|
|
805
|
+
|
|
806
|
+
const deliveryId = yield* Schema.decodeEffect(Digest)(
|
|
807
|
+
index.toString(16).padStart(64, '0'),
|
|
808
|
+
).pipe(Effect.orDie)
|
|
809
|
+
|
|
810
|
+
const selected = {
|
|
811
|
+
...delivery(registration, accepted),
|
|
812
|
+
deliveryId,
|
|
813
|
+
admissionKey: yield* Schema.decodeEffect(IdempotencyKey)(
|
|
814
|
+
`subscription:${deliveryId}`,
|
|
815
|
+
).pipe(Effect.orDie),
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (index === 3) {
|
|
819
|
+
yield* store.select(accepted, [], 0, true, 20, limits)
|
|
820
|
+
yield* store.catchUp(accepted, selected, 20, limits)
|
|
821
|
+
} else {
|
|
822
|
+
yield* store.select(accepted, [selected], registration.ordinal, true, 20, limits)
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (index % 2 === 0) {
|
|
826
|
+
yield* store.changeDelivery(selected.key, deliveryId, {
|
|
827
|
+
_tag: 'Prepare',
|
|
828
|
+
envelope: preparedInput(selected),
|
|
829
|
+
envelopeDigest: digest('4'),
|
|
830
|
+
nowMillis: 20,
|
|
831
|
+
})
|
|
832
|
+
yield* store.changeDelivery(selected.key, deliveryId, {
|
|
833
|
+
_tag: 'Complete',
|
|
834
|
+
receipt,
|
|
835
|
+
nowMillis: 21,
|
|
836
|
+
})
|
|
837
|
+
} else {
|
|
838
|
+
yield* store.changeDelivery(selected.key, deliveryId, {
|
|
839
|
+
_tag: 'Refuse',
|
|
840
|
+
refusal: { phase: 'preparation', code: 'refused' },
|
|
841
|
+
nowMillis: 21,
|
|
842
|
+
})
|
|
843
|
+
}
|
|
844
|
+
const completed = yield* store.delivery(selected.key)
|
|
845
|
+
|
|
846
|
+
if (completed === null) {
|
|
847
|
+
return yield* ensure(false, 'completion discarded exact delivery evidence')
|
|
848
|
+
}
|
|
849
|
+
retained.push({ registration, accepted, completed })
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
for (const { registration, accepted, completed } of retained) {
|
|
853
|
+
const replay = yield* store.register(registration, limits)
|
|
854
|
+
const intakeReplay = yield* store.accept(accepted, limits)
|
|
855
|
+
|
|
856
|
+
yield* ensure(
|
|
857
|
+
replay.state === 'consumed' && replay.ordinal === registration.ordinal,
|
|
858
|
+
'creation replay changed or resurrected a consumed registration',
|
|
859
|
+
)
|
|
860
|
+
yield* ensure(
|
|
861
|
+
intakeReplay.routingComplete &&
|
|
862
|
+
intakeReplay.cutoff === accepted.cutoff &&
|
|
863
|
+
JSON.stringify(intakeReplay.payload) === JSON.stringify(accepted.payload),
|
|
864
|
+
'retained event replay lost its payload/cutoff or reopened routing',
|
|
865
|
+
)
|
|
866
|
+
if (completed.state === 'delivered') {
|
|
867
|
+
yield* store.changeDelivery(completed.key, completed.deliveryId, {
|
|
868
|
+
_tag: 'Complete',
|
|
869
|
+
receipt,
|
|
870
|
+
nowMillis: 99,
|
|
871
|
+
})
|
|
872
|
+
}
|
|
873
|
+
yield* ensure(
|
|
874
|
+
JSON.stringify(yield* store.delivery(completed.key)) === JSON.stringify(completed),
|
|
875
|
+
'terminal replay changed prepared input, receipt, refusal or completion time',
|
|
876
|
+
)
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
const assertHostGuard = Effect.fnUntraced(function*<A>(
|
|
880
|
+
effect: Effect.Effect<A, SubscriptionStoreFailure>,
|
|
881
|
+
code: string,
|
|
882
|
+
) {
|
|
883
|
+
const result = yield* Effect.result(effect)
|
|
884
|
+
|
|
885
|
+
yield* ensure(
|
|
886
|
+
Result.isFailure(result) &&
|
|
887
|
+
result.failure._tag === 'SubscriptionError' &&
|
|
888
|
+
result.failure.reason === 'capacity' &&
|
|
889
|
+
result.failure.code === code,
|
|
890
|
+
`host ${code} guard ignored live work`,
|
|
891
|
+
)
|
|
892
|
+
})
|
|
893
|
+
|
|
894
|
+
const active = yield* store.register(record('host-active'), limits)
|
|
895
|
+
const activeEvent = yield* store.accept(event('host-active'), limits)
|
|
896
|
+
|
|
897
|
+
yield* assertHostGuard(
|
|
898
|
+
store.register(record('host-excess', 'once', 'other-owner'), limits),
|
|
899
|
+
'registrations',
|
|
900
|
+
)
|
|
901
|
+
yield* assertHostGuard(store.accept(event('host-excess'), limits), 'events')
|
|
902
|
+
yield* store.select(
|
|
903
|
+
activeEvent,
|
|
904
|
+
[delivery(active, activeEvent)],
|
|
905
|
+
active.ordinal,
|
|
906
|
+
true,
|
|
907
|
+
20,
|
|
908
|
+
limits,
|
|
909
|
+
)
|
|
910
|
+
|
|
911
|
+
const nextRegistration = yield* store.register(
|
|
912
|
+
record('host-excess', 'once', 'other-owner'),
|
|
913
|
+
limits,
|
|
914
|
+
)
|
|
915
|
+
|
|
916
|
+
const nextEvent = yield* store.accept(event('host-excess'), limits)
|
|
917
|
+
|
|
918
|
+
yield* assertHostGuard(
|
|
919
|
+
store.select(
|
|
920
|
+
nextEvent,
|
|
921
|
+
[delivery(nextRegistration, nextEvent)],
|
|
922
|
+
nextRegistration.ordinal,
|
|
923
|
+
true,
|
|
924
|
+
20,
|
|
925
|
+
limits,
|
|
926
|
+
),
|
|
927
|
+
'deliveries',
|
|
928
|
+
)
|
|
929
|
+
yield* ensure(
|
|
930
|
+
(yield* store.event(nextEvent.eventId))?.cursor === 0 &&
|
|
931
|
+
(yield* store.get(nextRegistration.key))?.state === 'active',
|
|
932
|
+
'host capacity rejection changed routing or registration evidence',
|
|
933
|
+
)
|
|
934
|
+
}),
|
|
935
|
+
)
|
|
936
|
+
|
|
937
|
+
const capacityReactivation = conformanceCase(
|
|
938
|
+
'reserves live capacity across expiry, pause and settlement observation',
|
|
939
|
+
(ensure) =>
|
|
940
|
+
Effect.gen(function*() {
|
|
941
|
+
const store = yield* SubscriptionStore
|
|
942
|
+
|
|
943
|
+
const limits = {
|
|
944
|
+
...defaultSubscriptionLimits,
|
|
945
|
+
maxRegistrations: 32,
|
|
946
|
+
maxRegistrationsPerOwner: 1,
|
|
947
|
+
maxEvents: 32,
|
|
948
|
+
maxDeliveries: 32,
|
|
949
|
+
maxDeliveriesPerOwner: 1,
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const expectCapacity = Effect.fnUntraced(function*<A>(
|
|
953
|
+
effect: Effect.Effect<A, SubscriptionStoreFailure>,
|
|
954
|
+
) {
|
|
955
|
+
const result = yield* Effect.result(effect)
|
|
956
|
+
|
|
957
|
+
yield* ensure(
|
|
958
|
+
Result.isFailure(result) &&
|
|
959
|
+
result.failure._tag === 'SubscriptionError' &&
|
|
960
|
+
result.failure.reason === 'capacity',
|
|
961
|
+
'live work did not reserve capacity',
|
|
962
|
+
)
|
|
963
|
+
})
|
|
964
|
+
|
|
965
|
+
const expiring = record('expiring')
|
|
966
|
+
|
|
967
|
+
yield* store.register(
|
|
968
|
+
{ ...expiring, configuration: { ...expiring.configuration, expiresAtMillis: 1 } },
|
|
969
|
+
limits,
|
|
970
|
+
)
|
|
971
|
+
yield* TestClock.setTime(2)
|
|
972
|
+
const current = yield* store.register(record('current', 'continuous'), limits)
|
|
973
|
+
const paused = yield* store.change(current.key, 1, { _tag: 'Pause' }, limits)
|
|
974
|
+
|
|
975
|
+
yield* expectCapacity(store.register(record('excess'), limits))
|
|
976
|
+
|
|
977
|
+
const revive = {
|
|
978
|
+
_tag: 'Update' as const,
|
|
979
|
+
configuration: expiring.configuration,
|
|
980
|
+
configurationFingerprint: expiring.configurationFingerprint,
|
|
981
|
+
recovery: null,
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
yield* expectCapacity(store.change(expiring.key, 1, revive, limits))
|
|
985
|
+
yield* ensure(
|
|
986
|
+
(yield* store.get(expiring.key))?.configurationRevision === 1,
|
|
987
|
+
'rejected revival changed registration evidence',
|
|
988
|
+
)
|
|
989
|
+
yield* store.cancel(current.key, paused.configurationRevision)
|
|
990
|
+
const registration = yield* store.change(expiring.key, 1, revive, limits)
|
|
991
|
+
const accepted = yield* store.accept(event('observed'), limits)
|
|
992
|
+
|
|
993
|
+
yield* expectCapacity(store.accept(event('unrouted-excess'), { ...limits, maxEvents: 1 }))
|
|
994
|
+
const selected = { ...delivery(registration, accepted), observeSettlement: true }
|
|
995
|
+
|
|
996
|
+
yield* store.select(accepted, [selected], registration.ordinal, true, 20, limits)
|
|
997
|
+
const nextRegistration = yield* store.register(record('next'), limits)
|
|
998
|
+
const nextEvent = yield* store.accept(event('next-event'), limits)
|
|
999
|
+
const next = delivery(nextRegistration, nextEvent, '1')
|
|
1000
|
+
|
|
1001
|
+
const selectNext = store.select(
|
|
1002
|
+
nextEvent,
|
|
1003
|
+
[next],
|
|
1004
|
+
nextRegistration.ordinal,
|
|
1005
|
+
true,
|
|
1006
|
+
20,
|
|
1007
|
+
limits,
|
|
1008
|
+
)
|
|
1009
|
+
|
|
1010
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1011
|
+
_tag: 'Retry',
|
|
1012
|
+
retry: { ...selected.retry, attempts: 1, automaticAttempts: 1, parked: true },
|
|
1013
|
+
nowMillis: 20,
|
|
1014
|
+
})
|
|
1015
|
+
yield* expectCapacity(selectNext)
|
|
1016
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1017
|
+
_tag: 'Prepare',
|
|
1018
|
+
envelope: preparedInput(selected),
|
|
1019
|
+
envelopeDigest: digest('4'),
|
|
1020
|
+
nowMillis: 20,
|
|
1021
|
+
})
|
|
1022
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1023
|
+
_tag: 'Complete',
|
|
1024
|
+
receipt,
|
|
1025
|
+
nowMillis: 21,
|
|
1026
|
+
})
|
|
1027
|
+
yield* expectCapacity(selectNext)
|
|
1028
|
+
yield* ensure(
|
|
1029
|
+
(yield* store.event(nextEvent.eventId))?.cursor === 0 &&
|
|
1030
|
+
(yield* store.get(nextRegistration.key))?.state === 'active',
|
|
1031
|
+
'capacity rejection consumed a registration or advanced routing',
|
|
1032
|
+
)
|
|
1033
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1034
|
+
_tag: 'ObserveSettlement',
|
|
1035
|
+
receipt,
|
|
1036
|
+
settled: true,
|
|
1037
|
+
nowMillis: 22,
|
|
1038
|
+
nextAttemptAtMillis: 22,
|
|
1039
|
+
})
|
|
1040
|
+
yield* selectNext
|
|
1041
|
+
yield* store.changeDelivery(next.key, next.deliveryId, {
|
|
1042
|
+
_tag: 'Prepare',
|
|
1043
|
+
envelope: preparedInput(next),
|
|
1044
|
+
envelopeDigest: digest('4'),
|
|
1045
|
+
nowMillis: 22,
|
|
1046
|
+
})
|
|
1047
|
+
yield* store.changeDelivery(next.key, next.deliveryId, {
|
|
1048
|
+
_tag: 'Complete',
|
|
1049
|
+
receipt,
|
|
1050
|
+
nowMillis: 23,
|
|
1051
|
+
})
|
|
1052
|
+
const blocker = yield* store.register(record('blocker'), limits)
|
|
1053
|
+
const blockerEvent = yield* store.accept(event('blocker'), limits)
|
|
1054
|
+
const blockerDelivery = delivery(blocker, blockerEvent)
|
|
1055
|
+
|
|
1056
|
+
yield* store.select(blockerEvent, [blockerDelivery], blocker.ordinal, true, 24, limits)
|
|
1057
|
+
yield* expectCapacity(
|
|
1058
|
+
store.changeDelivery(
|
|
1059
|
+
next.key,
|
|
1060
|
+
next.deliveryId,
|
|
1061
|
+
{
|
|
1062
|
+
_tag: 'ObserveSettlement',
|
|
1063
|
+
receipt,
|
|
1064
|
+
settled: false,
|
|
1065
|
+
nowMillis: 24,
|
|
1066
|
+
nextAttemptAtMillis: 25,
|
|
1067
|
+
},
|
|
1068
|
+
limits,
|
|
1069
|
+
),
|
|
1070
|
+
)
|
|
1071
|
+
yield* ensure(
|
|
1072
|
+
(yield* store.delivery(next.key))?.observeSettlement !== true,
|
|
1073
|
+
'rejected observation reactivation changed delivery evidence',
|
|
1074
|
+
)
|
|
1075
|
+
}),
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
const recoveryRevisionFence = conformanceCase(
|
|
1079
|
+
'fences source recovery across pause, resume and configuration replacement',
|
|
1080
|
+
(ensure) =>
|
|
1081
|
+
Effect.gen(function*() {
|
|
1082
|
+
const store = yield* SubscriptionStore
|
|
1083
|
+
|
|
1084
|
+
const initial = yield* store.register(
|
|
1085
|
+
{
|
|
1086
|
+
...record('recovery-revisions'),
|
|
1087
|
+
recovery: { attempts: 0, nextAttemptAtMillis: 10, lastFailure: null },
|
|
1088
|
+
},
|
|
1089
|
+
defaultSubscriptionLimits,
|
|
1090
|
+
)
|
|
1091
|
+
|
|
1092
|
+
const paused = yield* store.change(initial.key, 1, { _tag: 'Pause' })
|
|
1093
|
+
|
|
1094
|
+
yield* store.deferRecovery(initial.key, 1, null)
|
|
1095
|
+
yield* ensure(
|
|
1096
|
+
(yield* store.get(initial.key))?.recovery?.nextAttemptAtMillis === 10,
|
|
1097
|
+
'late provider completion erased paused recovery',
|
|
1098
|
+
)
|
|
1099
|
+
|
|
1100
|
+
const resumed = yield* store.change(initial.key, paused.configurationRevision, {
|
|
1101
|
+
_tag: 'Resume',
|
|
1102
|
+
})
|
|
1103
|
+
|
|
1104
|
+
yield* ensure(
|
|
1105
|
+
resumed.recovery?.nextAttemptAtMillis === 10,
|
|
1106
|
+
'resume lost the recovery obligation',
|
|
1107
|
+
)
|
|
1108
|
+
|
|
1109
|
+
const updated = yield* store.change(initial.key, resumed.configurationRevision, {
|
|
1110
|
+
_tag: 'Update',
|
|
1111
|
+
configuration: { ...initial.configuration, source: { name: 'replacement', version: '2' } },
|
|
1112
|
+
configurationFingerprint: digest('9'),
|
|
1113
|
+
recovery: { attempts: 0, nextAttemptAtMillis: 50, lastFailure: null },
|
|
1114
|
+
})
|
|
1115
|
+
|
|
1116
|
+
yield* store.deferRecovery(initial.key, resumed.configurationRevision, {
|
|
1117
|
+
attempts: 9,
|
|
1118
|
+
nextAttemptAtMillis: null,
|
|
1119
|
+
lastFailure: 'obsolete-source',
|
|
1120
|
+
})
|
|
1121
|
+
const retained = yield* store.get(initial.key)
|
|
1122
|
+
|
|
1123
|
+
yield* ensure(
|
|
1124
|
+
retained?.recovery?.nextAttemptAtMillis === 50 &&
|
|
1125
|
+
retained.configurationRevision === updated.configurationRevision,
|
|
1126
|
+
'obsolete provider completion overwrote replacement recovery',
|
|
1127
|
+
)
|
|
1128
|
+
yield* ensure(
|
|
1129
|
+
retained?.creationFingerprint === initial.creationFingerprint &&
|
|
1130
|
+
retained.creationConfiguration.source.name === initial.configuration.source.name,
|
|
1131
|
+
'revision rewrote creation identity',
|
|
1132
|
+
)
|
|
1133
|
+
}),
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
const retryGenerationFence = conformanceCase(
|
|
1137
|
+
'rearms only one delivery generation and retains late receipt authority',
|
|
1138
|
+
(ensure) =>
|
|
1139
|
+
Effect.gen(function*() {
|
|
1140
|
+
const store = yield* SubscriptionStore
|
|
1141
|
+
|
|
1142
|
+
const subscription = yield* store.register(
|
|
1143
|
+
record('retry-generation', 'continuous'),
|
|
1144
|
+
defaultSubscriptionLimits,
|
|
1145
|
+
)
|
|
1146
|
+
|
|
1147
|
+
const accepted = yield* store.accept(event('retry-generation'), defaultSubscriptionLimits)
|
|
1148
|
+
const selected = { ...delivery(subscription, accepted), observeSettlement: true }
|
|
1149
|
+
|
|
1150
|
+
yield* store.select(
|
|
1151
|
+
accepted,
|
|
1152
|
+
[selected],
|
|
1153
|
+
subscription.ordinal,
|
|
1154
|
+
true,
|
|
1155
|
+
20,
|
|
1156
|
+
defaultSubscriptionLimits,
|
|
1157
|
+
)
|
|
1158
|
+
yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1159
|
+
_tag: 'Prepare',
|
|
1160
|
+
envelope: preparedInput(selected),
|
|
1161
|
+
envelopeDigest: digest('4'),
|
|
1162
|
+
nowMillis: 30,
|
|
1163
|
+
})
|
|
1164
|
+
|
|
1165
|
+
const parked = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1166
|
+
_tag: 'Retry',
|
|
1167
|
+
nowMillis: 40,
|
|
1168
|
+
retry: {
|
|
1169
|
+
...selected.retry,
|
|
1170
|
+
attempts: 8,
|
|
1171
|
+
automaticAttempts: 8,
|
|
1172
|
+
parked: true,
|
|
1173
|
+
nextAttemptAtMillis: 50,
|
|
1174
|
+
lastAttemptAtMillis: 40,
|
|
1175
|
+
lastFailure: 'ambiguous',
|
|
1176
|
+
},
|
|
1177
|
+
})
|
|
1178
|
+
|
|
1179
|
+
yield* ensure(
|
|
1180
|
+
(yield* store.pendingDeliveries(100, '', 10)).length === 0,
|
|
1181
|
+
'parked admission remained due for settlement observation',
|
|
1182
|
+
)
|
|
1183
|
+
yield* ensure(
|
|
1184
|
+
(yield* store.nextDeadline) === null,
|
|
1185
|
+
'parked admission retained a busy-loop deadline',
|
|
1186
|
+
)
|
|
1187
|
+
|
|
1188
|
+
const recovered = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1189
|
+
_tag: 'Recover',
|
|
1190
|
+
expectedGeneration: parked.retry.generation,
|
|
1191
|
+
nowMillis: 50,
|
|
1192
|
+
})
|
|
1193
|
+
|
|
1194
|
+
const stale = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1195
|
+
_tag: 'Retry',
|
|
1196
|
+
nowMillis: 60,
|
|
1197
|
+
retry: { ...parked.retry, attempts: 9, nextAttemptAtMillis: 70 },
|
|
1198
|
+
})
|
|
1199
|
+
|
|
1200
|
+
yield* ensure(
|
|
1201
|
+
!stale.retry.parked && stale.retry.generation === recovered.retry.generation,
|
|
1202
|
+
'stale retry undid recovery',
|
|
1203
|
+
)
|
|
1204
|
+
|
|
1205
|
+
const completed = yield* store.changeDelivery(selected.key, selected.deliveryId, {
|
|
1206
|
+
_tag: 'Complete',
|
|
1207
|
+
receipt,
|
|
1208
|
+
nowMillis: 70,
|
|
1209
|
+
})
|
|
1210
|
+
|
|
1211
|
+
yield* ensure(
|
|
1212
|
+
completed.receipt?.receiptId === receipt.receiptId &&
|
|
1213
|
+
completed.envelopeDigest === digest('4'),
|
|
1214
|
+
'late receipt or immutable envelope was lost',
|
|
1215
|
+
)
|
|
1216
|
+
}),
|
|
1217
|
+
)
|
|
1218
|
+
|
|
1219
|
+
const retentionFairness = conformanceCase(
|
|
1220
|
+
'advances bounded maintenance beyond protected oldest events',
|
|
1221
|
+
(ensure) =>
|
|
1222
|
+
Effect.gen(function*() {
|
|
1223
|
+
const store = yield* SubscriptionStore
|
|
1224
|
+
const policy = { replayHorizonMillis: 1_000, completedRetentionMillis: 0, maxTombstones: 8 }
|
|
1225
|
+
const limits = { ...defaultSubscriptionLimits, retention: policy }
|
|
1226
|
+
|
|
1227
|
+
for (let index = 0; index < 6; index++) {
|
|
1228
|
+
const accepted = yield* store.accept(
|
|
1229
|
+
{ ...event(`protected-${index}`), occurredAtMillis: 0, acceptedAtMillis: 0 },
|
|
1230
|
+
limits,
|
|
1231
|
+
)
|
|
1232
|
+
|
|
1233
|
+
if (index === 5) yield* store.select(accepted, [], 0, true, 0, limits)
|
|
1234
|
+
}
|
|
1235
|
+
yield* TestClock.setTime(10)
|
|
1236
|
+
for (let pass = 0; pass < 8; pass++) yield* store.compact(10, policy, 1)
|
|
1237
|
+
yield* ensure(
|
|
1238
|
+
(yield* store.event('protected-5'))?.tombstone === true,
|
|
1239
|
+
'protected first pages starved a reclaimable event',
|
|
1240
|
+
)
|
|
1241
|
+
yield* ensure(
|
|
1242
|
+
(yield* store.event('protected-0'))?.tombstone !== true,
|
|
1243
|
+
'unfinished event was reclaimed',
|
|
1244
|
+
)
|
|
1245
|
+
yield* TestClock.setTime(1_001)
|
|
1246
|
+
for (let pass = 0; pass < 8; pass++) yield* store.compact(1_001, policy, 1)
|
|
1247
|
+
yield* ensure(
|
|
1248
|
+
(yield* store.event('protected-5')) === null,
|
|
1249
|
+
'idle maintenance did not expire tombstone',
|
|
1250
|
+
)
|
|
1251
|
+
|
|
1252
|
+
const rejected = yield* store
|
|
1253
|
+
.accept({ ...event('protected-5'), occurredAtMillis: 0 }, limits)
|
|
1254
|
+
.pipe(Effect.result)
|
|
1255
|
+
|
|
1256
|
+
// The caller cannot manufacture a recent occurrence to resurrect a pruned identity.
|
|
1257
|
+
yield* ensure(Result.isFailure(rejected), 'retention state became inconsistent')
|
|
1258
|
+
}),
|
|
1259
|
+
)
|
|
1260
|
+
|
|
1261
|
+
export const subscriptionStoreConformanceCases: ReadonlyArray<SubscriptionStoreConformanceCase> = [
|
|
1262
|
+
historicalOccurrenceReplay,
|
|
1263
|
+
recoveryRevisionFence,
|
|
1264
|
+
retryGenerationFence,
|
|
1265
|
+
retentionFairness,
|
|
1266
|
+
sustainedRetention,
|
|
1267
|
+
lifetimeCapacity,
|
|
1268
|
+
capacityReactivation,
|
|
1269
|
+
revisionsAndRetention,
|
|
1270
|
+
cutoffAndIntake,
|
|
1271
|
+
onceAndCapacity,
|
|
1272
|
+
preparationLifecycle,
|
|
1273
|
+
catchUpAndCursors,
|
|
1274
|
+
replayUnderTighterLimits,
|
|
1275
|
+
]
|