effect-agent 0.1.0-beta.97 → 0.1.0-beta.99

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 (143) hide show
  1. package/dist/{AgentRuntime-B64362Id.d.mts → AgentRuntime-BMzrJos6.d.mts} +2 -2
  2. package/dist/{AgentRuntime-Cdvqw7l_.mjs → AgentRuntime-BWOnNc0d.mjs} +78 -42
  3. package/dist/AgentRuntime-BWOnNc0d.mjs.map +1 -0
  4. package/dist/{DurableAgentRuntime-DbUvZHDZ.mjs → DurableAgentRuntime-BE_OjQjz.mjs} +471 -252
  5. package/dist/DurableAgentRuntime-BE_OjQjz.mjs.map +1 -0
  6. package/dist/{DurableFailpoint-DQJet828.d.mts → DurableFailpoint-mx3-nsxU.d.mts} +3 -3
  7. package/dist/{EventSource-D6PAAEyK.d.mts → EventSource-BZ73J0s5.d.mts} +3 -3
  8. package/dist/{PreparedInputAdmission-omMbwd--.d.mts → PreparedInputAdmission-BkeI-Xvr.d.mts} +4 -4
  9. package/dist/{Records-CV49DgQK.d.mts → Records-BIiRLqlz.d.mts} +92 -128
  10. package/dist/{Records-BAutSSnJ.mjs → Records-DR1xtbXY.mjs} +35 -8
  11. package/dist/Records-DR1xtbXY.mjs.map +1 -0
  12. package/dist/{RunJournal-DRRRZmG7.mjs → RunJournal-DNs3PM4K.mjs} +80 -23
  13. package/dist/RunJournal-DNs3PM4K.mjs.map +1 -0
  14. package/dist/{RunOptions-Clj8cLsp.d.mts → RunOptions-Bruk54SE.d.mts} +13 -4
  15. package/dist/{Schedule-DePbGfgd.d.mts → Schedule-BNFlluAl.d.mts} +2 -2
  16. package/dist/{Scheduling-C3QpYn0W.mjs → Scheduling-HFH0pST1.mjs} +2 -2
  17. package/dist/{Scheduling-C3QpYn0W.mjs.map → Scheduling-HFH0pST1.mjs.map} +1 -1
  18. package/dist/{Subagent-Cbfzylz1.mjs → Subagent-C2s8PFrd.mjs} +2 -2
  19. package/dist/{Subagent-Cbfzylz1.mjs.map → Subagent-C2s8PFrd.mjs.map} +1 -1
  20. package/dist/{Subagent-Bm1dRecN.d.mts → Subagent-m7ywTCe4.d.mts} +3 -3
  21. package/dist/{Subscription-BR_8Cxh3.d.mts → Subscription-BCQ3L9Zp.d.mts} +3 -3
  22. package/dist/{SubscriptionInput-B95sQbuk.d.mts → SubscriptionInput-Cqu4_RW3.d.mts} +3 -3
  23. package/dist/{ToolReconciler-DQVaJfpE.d.mts → ToolReconciler-BmVRAHKs.d.mts} +8 -4
  24. package/dist/agent-registration-cXpB8cBU.mjs +199 -0
  25. package/dist/agent-registration-cXpB8cBU.mjs.map +1 -0
  26. package/dist/capabilities/Commands.d.mts +1 -1
  27. package/dist/capabilities/RunHooks.d.mts +1 -1
  28. package/dist/capabilities/Subagent.d.mts +1 -1
  29. package/dist/capabilities/Subagent.mjs +1 -1
  30. package/dist/durable/ActivityStore.d.mts +1 -1
  31. package/dist/durable/ActivityStore.mjs +1 -1
  32. package/dist/durable/Admin.d.mts +1 -1
  33. package/dist/durable/Admin.mjs +12 -10
  34. package/dist/durable/Admin.mjs.map +1 -1
  35. package/dist/durable/AgentRegistration.d.mts +2 -2
  36. package/dist/durable/AgentRegistration.mjs +4 -8
  37. package/dist/durable/AgentRegistration.mjs.map +1 -1
  38. package/dist/durable/Certification.d.mts +2 -2
  39. package/dist/durable/CommittedActivity.d.mts +1 -1
  40. package/dist/durable/CommittedActivity.mjs +1 -1
  41. package/dist/durable/Digest.d.mts +1 -1
  42. package/dist/durable/Digest.mjs +1 -1
  43. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  44. package/dist/durable/DurableAgentRuntime.mjs +1 -1
  45. package/dist/durable/DurableFailpoint.d.mts +1 -1
  46. package/dist/durable/DurableFailpoint.mjs +2 -0
  47. package/dist/durable/DurableFailpoint.mjs.map +1 -1
  48. package/dist/durable/DurableFailpointTestControl.d.mts +1 -1
  49. package/dist/durable/EventSource.d.mts +1 -1
  50. package/dist/durable/EventSource.mjs +1 -1
  51. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  52. package/dist/durable/GitHubWorkflowSource.mjs +1 -1
  53. package/dist/durable/MessageDelivery.d.mts +3 -3
  54. package/dist/durable/MessageDelivery.mjs +1 -1
  55. package/dist/durable/MessageDeliveryStoreConformance.d.mts +39 -39
  56. package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
  57. package/dist/durable/PersistentHistory.d.mts +1 -1
  58. package/dist/durable/PersistentHistory.mjs +2 -2
  59. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  60. package/dist/durable/Records.d.mts +2 -2
  61. package/dist/durable/Records.mjs +2 -2
  62. package/dist/durable/Recovery.d.mts +1 -1
  63. package/dist/durable/Recovery.mjs +9 -9
  64. package/dist/durable/Recovery.mjs.map +1 -1
  65. package/dist/durable/RunJournal.d.mts +2 -2
  66. package/dist/durable/RunJournal.mjs +2 -2
  67. package/dist/durable/Schedule.d.mts +1 -1
  68. package/dist/durable/Schedule.mjs +1 -1
  69. package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
  70. package/dist/durable/ScheduleStoreConformance.mjs +1 -1
  71. package/dist/durable/ScheduleTransition.d.mts +1 -1
  72. package/dist/durable/ScheduleTransition.mjs +1 -1
  73. package/dist/durable/Scheduling.d.mts +2 -2
  74. package/dist/durable/Scheduling.mjs +1 -1
  75. package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
  76. package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
  77. package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
  78. package/dist/durable/SqlSubscriptionStore.mjs +1 -1
  79. package/dist/durable/SubmissionLedger.d.mts +1 -1
  80. package/dist/durable/SubmissionLedger.mjs +14 -13
  81. package/dist/durable/SubmissionLedger.mjs.map +1 -1
  82. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  83. package/dist/durable/SubmissionLedgerConformance.mjs +9 -2
  84. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -1
  85. package/dist/durable/SubmissionStatus.d.mts +1 -1
  86. package/dist/durable/Subscription.d.mts +1 -1
  87. package/dist/durable/Subscription.mjs +1 -1
  88. package/dist/durable/SubscriptionInput.d.mts +1 -1
  89. package/dist/durable/SubscriptionInput.mjs +2 -2
  90. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  91. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  92. package/dist/durable/SubscriptionTools.d.mts +3 -3
  93. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  94. package/dist/durable/SubscriptionTransition.mjs +1 -1
  95. package/dist/durable/Subscriptions.d.mts +5 -5
  96. package/dist/durable/Subscriptions.mjs +1 -1
  97. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  98. package/dist/durable/ThreadContextHistory.mjs +1 -1
  99. package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
  100. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  101. package/dist/durable/ThreadInvariants.d.mts +4 -2
  102. package/dist/durable/ThreadInvariants.mjs +49 -3
  103. package/dist/durable/ThreadInvariants.mjs.map +1 -1
  104. package/dist/durable/ThreadProjection.d.mts +1 -1
  105. package/dist/durable/ThreadProjection.mjs +1 -1
  106. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  107. package/dist/durable/ThreadStore.d.mts +1 -1
  108. package/dist/durable/ThreadStore.mjs +1 -1
  109. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  110. package/dist/durable/ThreadStoreConformance.mjs +1 -1
  111. package/dist/durable/ToolReconciler.d.mts +1 -1
  112. package/dist/durable/ToolReconciler.mjs +9 -5
  113. package/dist/durable/ToolReconciler.mjs.map +1 -1
  114. package/dist/durable/WorkerHost.d.mts +1 -1
  115. package/dist/engine/AgentRuntime.d.mts +1 -1
  116. package/dist/engine/AgentRuntime.mjs +1 -1
  117. package/dist/engine/RunOptions.d.mts +1 -1
  118. package/dist/engine/RunOptions.mjs.map +1 -1
  119. package/dist/index.d.mts +11 -11
  120. package/dist/index.mjs +6 -6
  121. package/package.json +1 -1
  122. package/src/durable/Admin.ts +20 -11
  123. package/src/durable/AgentRegistration.ts +1 -5
  124. package/src/durable/DurableAgentRuntime.ts +947 -464
  125. package/src/durable/DurableFailpoint.ts +2 -0
  126. package/src/durable/Records.ts +30 -5
  127. package/src/durable/Recovery.ts +8 -8
  128. package/src/durable/RunJournal.ts +128 -51
  129. package/src/durable/SubmissionLedger.ts +13 -12
  130. package/src/durable/SubmissionLedgerConformance.ts +13 -2
  131. package/src/durable/ThreadInvariants.ts +70 -5
  132. package/src/durable/ToolReconciler.ts +7 -3
  133. package/src/durable/internal/agent-registration.ts +65 -414
  134. package/src/durable/internal/messaging-host.ts +0 -2
  135. package/src/durable/internal/worker-host.ts +34 -96
  136. package/src/engine/RunOptions.ts +13 -3
  137. package/src/engine/internal/agent-runtime.ts +160 -106
  138. package/dist/AgentRuntime-Cdvqw7l_.mjs.map +0 -1
  139. package/dist/DurableAgentRuntime-DbUvZHDZ.mjs.map +0 -1
  140. package/dist/Records-BAutSSnJ.mjs.map +0 -1
  141. package/dist/RunJournal-DRRRZmG7.mjs.map +0 -1
  142. package/dist/agent-registration-CXGDwvJH.mjs +0 -379
  143. package/dist/agent-registration-CXGDwvJH.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import { dn as SettledSubmission, fn as SubmissionStatus, un as PendingSubmission } from "../Records-CV49DgQK.mjs";
1
+ import { fn as PendingSubmission, mn as SubmissionStatus, pn as SettledSubmission } from "../Records-BIiRLqlz.mjs";
2
2
  export { PendingSubmission, SettledSubmission, SubmissionStatus };
@@ -1,2 +1,2 @@
1
- import { A as defaultSubscriptionLimits, C as SubscriptionScanCursors, D as SubscriptionStore, E as SubscriptionSourceError, M as subscriptionKeyString, O as SubscriptionStoreFailure, S as SubscriptionRetentionPolicy, T as SubscriptionSnapshot, _ as SubscriptionKey, a as PreparedInput, b as SubscriptionRecord, c as SubscriptionAuthorizer, d as SubscriptionDelivery, f as SubscriptionDeliveryKey, g as SubscriptionFailpointError, h as SubscriptionFailpoint, i as EventSourceVersion, j as subscriptionDeliveryKeyString, l as SubscriptionChange, m as SubscriptionError, n as DeliveryChange, o as SourcePartition, p as SubscriptionDeliverySnapshot, r as EventAcknowledgement, s as SourceRecovery, t as AcceptedEvent, u as SubscriptionConfiguration, v as SubscriptionLimits, w as SubscriptionScope, x as SubscriptionRefusal, y as SubscriptionName } from "../Subscription-BR_8Cxh3.mjs";
1
+ import { A as defaultSubscriptionLimits, C as SubscriptionScanCursors, D as SubscriptionStore, E as SubscriptionSourceError, M as subscriptionKeyString, O as SubscriptionStoreFailure, S as SubscriptionRetentionPolicy, T as SubscriptionSnapshot, _ as SubscriptionKey, a as PreparedInput, b as SubscriptionRecord, c as SubscriptionAuthorizer, d as SubscriptionDelivery, f as SubscriptionDeliveryKey, g as SubscriptionFailpointError, h as SubscriptionFailpoint, i as EventSourceVersion, j as subscriptionDeliveryKeyString, l as SubscriptionChange, m as SubscriptionError, n as DeliveryChange, o as SourcePartition, p as SubscriptionDeliverySnapshot, r as EventAcknowledgement, s as SourceRecovery, t as AcceptedEvent, u as SubscriptionConfiguration, v as SubscriptionLimits, w as SubscriptionScope, x as SubscriptionRefusal, y as SubscriptionName } from "../Subscription-BCQ3L9Zp.mjs";
2
2
  export { AcceptedEvent, DeliveryChange, EventAcknowledgement, EventSourceVersion, PreparedInput, SourcePartition, SourceRecovery, SubscriptionAuthorizer, SubscriptionChange, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionDeliveryKey, SubscriptionDeliverySnapshot, SubscriptionError, SubscriptionFailpoint, SubscriptionFailpointError, SubscriptionKey, SubscriptionLimits, SubscriptionName, SubscriptionRecord, SubscriptionRefusal, SubscriptionRetentionPolicy, SubscriptionScanCursors, SubscriptionScope, SubscriptionSnapshot, SubscriptionSourceError, SubscriptionStore, SubscriptionStoreFailure, defaultSubscriptionLimits, subscriptionDeliveryKeyString, subscriptionKeyString };
@@ -2,7 +2,7 @@ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { AgentId, ThreadId } from "../core/Identifiers.mjs";
3
3
  import { IdempotencyKey, Principal, Receipt } from "../core/Receipt.mjs";
4
4
  import { l as InputMessage } from "../MessagingHost-CWi_PP3g.mjs";
5
- import { T as PersistedJson, h as Digest, p as DefinitionDigests, rt as WorkerAdmission } from "../Records-BAutSSnJ.mjs";
5
+ import { T as PersistedJson, at as WorkerAdmission, h as Digest, p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
6
6
  import { AdmissionFence, AdmissionGroup } from "./SubmissionLedger.mjs";
7
7
  import { ScheduleAuthorizationDecision, ScheduleDestination, ScheduleInstant, ScheduleRetry } from "./Schedule.mjs";
8
8
  import { Context, Effect, Schema } from "effect";
@@ -1,2 +1,2 @@
1
- import { a as resolveSubscriptionInput, i as makeSubscriptionInputBinding, n as SubscriptionInputBindings, t as SubscriptionInputBinding } from "../SubscriptionInput-B95sQbuk.mjs";
1
+ import { a as resolveSubscriptionInput, i as makeSubscriptionInputBinding, n as SubscriptionInputBindings, t as SubscriptionInputBinding } from "../SubscriptionInput-Cqu4_RW3.mjs";
2
2
  export { SubscriptionInputBinding, SubscriptionInputBindings, makeSubscriptionInputBinding, resolveSubscriptionInput };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { T as PersistedJson } from "../Records-BAutSSnJ.mjs";
3
- import { c as definitionDigestsEqual } from "../agent-registration-CXGDwvJH.mjs";
2
+ import { T as PersistedJson } from "../Records-DR1xtbXY.mjs";
3
+ import { a as definitionDigestsEqual } from "../agent-registration-cXpB8cBU.mjs";
4
4
  import { SubscriptionError, SubscriptionSourceError } from "./Subscription.mjs";
5
5
  import { Context, Effect, Schema } from "effect";
6
6
  //#region src/durable/SubscriptionInput.ts
@@ -1,4 +1,4 @@
1
- import { D as SubscriptionStore, O as SubscriptionStoreFailure, o as SourcePartition } from "../Subscription-BR_8Cxh3.mjs";
1
+ import { D as SubscriptionStore, O as SubscriptionStoreFailure, o as SourcePartition } from "../Subscription-BCQ3L9Zp.mjs";
2
2
  import { Effect, Schema } from "effect";
3
3
  //#region src/durable/SubscriptionStoreConformance.d.ts
4
4
  declare const SubscriptionStoreConformanceViolation_base: Schema.Class<SubscriptionStoreConformanceViolation, Schema.TaggedStruct<"SubscriptionStoreConformanceViolation", {
@@ -1,6 +1,6 @@
1
1
  import { AgentId, ReceiptId, SubmissionId, ThreadId } from "../core/Identifiers.mjs";
2
2
  import { IdempotencyKey, Principal, QueueSequence, Receipt } from "../core/Receipt.mjs";
3
- import { h as Digest, p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
3
+ import { h as Digest, p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
4
4
  import { SubscriptionStore, defaultSubscriptionLimits } from "./Subscription.mjs";
5
5
  import { Clock, Effect, Result, Schema } from "effect";
6
6
  import { TestClock } from "effect/testing";
@@ -1,9 +1,9 @@
1
1
  import { t as AgentId, u as ThreadId } from "../Identifiers-CN2s30fF.mjs";
2
2
  import { r as Principal } from "../Receipt-BAHyigAF.mjs";
3
3
  import { t as DurableStep } from "../DurableStep-Cry_iol4.mjs";
4
- import { h as DefinitionDigests } from "../Records-CV49DgQK.mjs";
5
- import { c as ScheduleDestination } from "../Schedule-DePbGfgd.mjs";
6
- import { E as SubscriptionSourceError, g as SubscriptionFailpointError, i as EventSourceVersion, m as SubscriptionError, w as SubscriptionScope } from "../Subscription-BR_8Cxh3.mjs";
4
+ import { h as DefinitionDigests } from "../Records-BIiRLqlz.mjs";
5
+ import { c as ScheduleDestination } from "../Schedule-BNFlluAl.mjs";
6
+ import { E as SubscriptionSourceError, g as SubscriptionFailpointError, i as EventSourceVersion, m as SubscriptionError, w as SubscriptionScope } from "../Subscription-BCQ3L9Zp.mjs";
7
7
  import { Subscriptions } from "./Subscriptions.mjs";
8
8
  import { Tool, Toolkit } from "effect/unstable/ai";
9
9
  import { Crypto, Layer, Schema } from "effect";
@@ -1,4 +1,4 @@
1
- import { b as SubscriptionRecord, d as SubscriptionDelivery, l as SubscriptionChange, m as SubscriptionError, n as DeliveryChange, o as SourcePartition, t as AcceptedEvent, v as SubscriptionLimits } from "../Subscription-BR_8Cxh3.mjs";
1
+ import { b as SubscriptionRecord, d as SubscriptionDelivery, l as SubscriptionChange, m as SubscriptionError, n as DeliveryChange, o as SourcePartition, t as AcceptedEvent, v as SubscriptionLimits } from "../Subscription-BCQ3L9Zp.mjs";
2
2
  import { Result } from "effect";
3
3
  declare namespace SubscriptionTransition_d_exports {
4
4
  export { applySubscriptionChange, applySubscriptionDeliveryChange, sameAcceptedEventIdentity, sameSourcePartition, sameSubscriptionDelivery, subscriptionCanSelect, subscriptionDeliveryCanSelect, subscriptionMatchesEvent, validateEventRetention };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Receipt } from "../core/Receipt.mjs";
3
- import { p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
3
+ import { p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
4
4
  import { AdmissionFence } from "./SubmissionLedger.mjs";
5
5
  import { SubscriptionConfiguration, SubscriptionDelivery, SubscriptionError } from "./Subscription.mjs";
6
6
  import { Result, Schema } from "effect";
@@ -1,9 +1,9 @@
1
1
  import { r as Principal } from "../Receipt-BAHyigAF.mjs";
2
- import { Ki as AdmissionFence, O as PersistedJson } from "../Records-CV49DgQK.mjs";
3
- import { D as SubscriptionStore, E as SubscriptionSourceError, O as SubscriptionStoreFailure, T as SubscriptionSnapshot, _ as SubscriptionKey, c as SubscriptionAuthorizer, f as SubscriptionDeliveryKey, i as EventSourceVersion, m as SubscriptionError, p as SubscriptionDeliverySnapshot, r as EventAcknowledgement, u as SubscriptionConfiguration, v as SubscriptionLimits, w as SubscriptionScope } from "../Subscription-BR_8Cxh3.mjs";
4
- import { r as EventSources } from "../EventSource-D6PAAEyK.mjs";
5
- import { t as PreparedInputAdmission } from "../PreparedInputAdmission-omMbwd--.mjs";
6
- import { n as SubscriptionInputBindings } from "../SubscriptionInput-B95sQbuk.mjs";
2
+ import { Gi as AdmissionFence, O as PersistedJson } from "../Records-BIiRLqlz.mjs";
3
+ import { D as SubscriptionStore, E as SubscriptionSourceError, O as SubscriptionStoreFailure, T as SubscriptionSnapshot, _ as SubscriptionKey, c as SubscriptionAuthorizer, f as SubscriptionDeliveryKey, i as EventSourceVersion, m as SubscriptionError, p as SubscriptionDeliverySnapshot, r as EventAcknowledgement, u as SubscriptionConfiguration, v as SubscriptionLimits, w as SubscriptionScope } from "../Subscription-BCQ3L9Zp.mjs";
4
+ import { r as EventSources } from "../EventSource-BZ73J0s5.mjs";
5
+ import { t as PreparedInputAdmission } from "../PreparedInputAdmission-BkeI-Xvr.mjs";
6
+ import { n as SubscriptionInputBindings } from "../SubscriptionInput-Cqu4_RW3.mjs";
7
7
  import { Context, Crypto, Effect, Layer } from "effect";
8
8
  declare namespace Subscriptions_d_exports {
9
9
  export { SubscribeOptions, SubscriptionDriver, SubscriptionFailure, SubscriptionIntake, Subscriptions };
@@ -2,7 +2,7 @@ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ThreadId } from "../core/Identifiers.mjs";
3
3
  import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
4
4
  import { IdempotencyKey } from "../core/Receipt.mjs";
5
- import { p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
5
+ import { p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
6
6
  import { digestJson } from "./Digest.mjs";
7
7
  import { PreparedInputAdmission, admitPreparedInput } from "./PreparedInputAdmission.mjs";
8
8
  import { AcceptedEvent, PreparedInput, SubscriptionAuthorizer, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionError, SubscriptionFailpoint, SubscriptionKey, SubscriptionLimits, SubscriptionScope, SubscriptionSourceError, SubscriptionStore, defaultSubscriptionLimits, subscriptionDeliveryKeyString } from "./Subscription.mjs";
@@ -1,5 +1,5 @@
1
1
  import { ContextHistory, ContextHistoryError } from "../engine/ContextHistory.mjs";
2
- import { in as ThreadStore } from "../Records-CV49DgQK.mjs";
2
+ import { on as ThreadStore } from "../Records-BIiRLqlz.mjs";
3
3
  import { Layer, Schema } from "effect";
4
4
  declare namespace ThreadContextHistory_d_exports {
5
5
  export { ThreadContextHistoryOptions, layer };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ContextHistory, ContextHistoryError, ContextHistoryHit, ContextHistoryPage, ContextHistoryRead, ContextHistorySearch } from "../engine/ContextHistory.mjs";
3
- import { c as CanonicalRecordEnvelope, u as CanonicalSequence } from "../Records-BAutSSnJ.mjs";
3
+ import { c as CanonicalRecordEnvelope, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
4
4
  import { ThreadRead, ThreadStore, ThreadTail, ThreadTailRequest } from "./ThreadStore.mjs";
5
5
  import { ContextHistoryEvidence, matchText, normalizeQuery, project, windowIdFor } from "./ThreadContextHistoryProjection.mjs";
6
6
  import { Effect, Layer, Schema, Stream } from "effect";
@@ -1,5 +1,5 @@
1
1
  import { ContextHistoryError } from "../engine/ContextHistory.mjs";
2
- import { l as CanonicalRecordEnvelope } from "../Records-CV49DgQK.mjs";
2
+ import { l as CanonicalRecordEnvelope } from "../Records-BIiRLqlz.mjs";
3
3
  import { Effect, Schema } from "effect";
4
4
  declare namespace ThreadContextHistoryProjection_d_exports {
5
5
  export { ContextHistoryBoundary, ContextHistoryEvidence, ContextHistoryProjection, matchText, normalizeQuery, normalizeText, project, windowIdFor };
@@ -2,7 +2,7 @@ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { RunId } from "../core/Identifiers.mjs";
3
3
  import { f as contextWindowId } from "../compaction-C2OTceKw.mjs";
4
4
  import { ContextHistoryError, ContextHistorySearch } from "../engine/ContextHistory.mjs";
5
- import { T as PersistedJson, k as RecordId, u as CanonicalSequence } from "../Records-BAutSSnJ.mjs";
5
+ import { T as PersistedJson, k as RecordId, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
6
6
  import { Prompt } from "effect/unstable/ai";
7
7
  import { Effect, Schema } from "effect";
8
8
  //#region src/durable/ThreadContextHistoryProjection.ts
@@ -1,4 +1,4 @@
1
- import { A as ProducerId, Yt as ThreadCheckpoint, Zt as ThreadExport, a as BatchId, no as SubmissionSnapshot, vr as IntegrityReport } from "../Records-CV49DgQK.mjs";
1
+ import { $t as ThreadExport, A as ProducerId, Zt as ThreadCheckpoint, a as BatchId, to as SubmissionSnapshot, xr as IntegrityReport } from "../Records-BIiRLqlz.mjs";
2
2
  import { Crypto, Effect } from "effect";
3
3
  declare namespace ThreadInvariants_d_exports {
4
4
  export { ThreadInvariantInput, verifyThreadInvariants };
@@ -52,7 +52,9 @@ interface ThreadInvariantInput {
52
52
  * 4. `digest-chain` — the tail digest recomputes from `EMPTY_TAIL_DIGEST` through every batch
53
53
  * (requires the per-batch producer directory; skipped honestly otherwise).
54
54
  * 5. `fifo-input-order` / `fifo-settlement-order` — canonical input and settlement records
55
- * follow the admitted queue order (DUR-004). Aborted settlements of never-run work (no
55
+ * follow the admitted queue order (DUR-004), except a later input may settle before a Run
56
+ * with canonically unresolved unknown calls when that input became active. Resolving those
57
+ * calls later does not revoke the later Run's ownership. Aborted settlements of never-run work (no
56
58
  * canonical `input:{sid}` record) are exempt from the settlement comparison: P7 §7(c)
57
59
  * settles them immediately without waiting for the head, and DUR-004 bounds execution
58
60
  * order, which never-run work has none of.
@@ -1,8 +1,9 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { c as CanonicalRecordEnvelope, o as CanonicalBatch } from "../Records-BAutSSnJ.mjs";
2
+ import { c as CanonicalRecordEnvelope, o as CanonicalBatch } from "../Records-DR1xtbXY.mjs";
3
3
  import { submissionInputRecordId, submissionSettlementRecordId } from "./SubmissionLedger.mjs";
4
4
  import { IntegrityCheck, IntegrityReport } from "./Admin.mjs";
5
5
  import { EMPTY_TAIL_DIGEST, digestCanonicalBatch } from "./Digest.mjs";
6
+ import { y as runIdForSubmission } from "../RunJournal-DNs3PM4K.mjs";
6
7
  import { Effect, Schema } from "effect";
7
8
  //#region src/durable/ThreadInvariants.ts
8
9
  var ThreadInvariants_exports = /* @__PURE__ */ __exportAll({ verifyThreadInvariants: () => verifyThreadInvariants });
@@ -46,7 +47,9 @@ const batchRunsOf = (records) => {
46
47
  * 4. `digest-chain` — the tail digest recomputes from `EMPTY_TAIL_DIGEST` through every batch
47
48
  * (requires the per-batch producer directory; skipped honestly otherwise).
48
49
  * 5. `fifo-input-order` / `fifo-settlement-order` — canonical input and settlement records
49
- * follow the admitted queue order (DUR-004). Aborted settlements of never-run work (no
50
+ * follow the admitted queue order (DUR-004), except a later input may settle before a Run
51
+ * with canonically unresolved unknown calls when that input became active. Resolving those
52
+ * calls later does not revoke the later Run's ownership. Aborted settlements of never-run work (no
50
53
  * canonical `input:{sid}` record) are exempt from the settlement comparison: P7 §7(c)
51
54
  * settles them immediately without waiting for the head, and DUR-004 bounds execution
52
55
  * order, which never-run work has none of.
@@ -137,8 +140,39 @@ const verifyThreadInvariants = Effect.fn("Thread.verifyThreadInvariants")(functi
137
140
  {
138
141
  const recordIdSet = new Set(recordIds);
139
142
  const abortedNeverRun = /* @__PURE__ */ new Set();
143
+ const settlementByRun = new Map(ordered.map((row) => [runIdForSubmission(row.submissionId), submissionSettlementRecordId(row.submissionId)]));
144
+ const inputSettlements = new Map(ordered.map((row) => [submissionInputRecordId(row.submissionId), submissionSettlementRecordId(row.submissionId)]));
145
+ const unknownCalls = /* @__PURE__ */ new Map();
146
+ const abortsOrTerminals = /* @__PURE__ */ new Set();
147
+ const bypassedSettlements = /* @__PURE__ */ new Map();
140
148
  for (const envelope of records) {
141
149
  const payload = envelope.record.payload;
150
+ if (payload._tag === "ToolCallUnknown" && !abortsOrTerminals.has(payload.runId)) {
151
+ const calls = unknownCalls.get(payload.runId) ?? /* @__PURE__ */ new Set();
152
+ calls.add(payload.toolCallId);
153
+ unknownCalls.set(payload.runId, calls);
154
+ } else if (payload._tag === "ToolCallResolved" || payload._tag === "ToolCallSettled") {
155
+ const calls = unknownCalls.get(payload.runId);
156
+ calls?.delete(payload.toolCallId);
157
+ if (calls?.size === 0) unknownCalls.delete(payload.runId);
158
+ } else if (payload._tag === "AbortRequested" || payload._tag === "SubmissionSettled") {
159
+ const runId = runIdForSubmission(payload.submissionId);
160
+ abortsOrTerminals.add(runId);
161
+ unknownCalls.delete(runId);
162
+ } else if (payload._tag === "RunCompleted" || payload._tag === "RunFailed") {
163
+ abortsOrTerminals.add(payload.runId);
164
+ unknownCalls.delete(payload.runId);
165
+ } else if (payload._tag === "UserInputRecorded") {
166
+ const settlementId = inputSettlements.get(envelope.record.recordId);
167
+ if (settlementId !== void 0) {
168
+ const bypassed = /* @__PURE__ */ new Set();
169
+ for (const runId of unknownCalls.keys()) {
170
+ const earlier = settlementByRun.get(runId);
171
+ if (earlier !== void 0) bypassed.add(earlier);
172
+ }
173
+ bypassedSettlements.set(settlementId, bypassed);
174
+ }
175
+ }
142
176
  if (payload._tag === "SubmissionSettled" && payload.outcome === "aborted" && !recordIdSet.has(submissionInputRecordId(payload.submissionId))) abortedNeverRun.add(payload.submissionId);
143
177
  }
144
178
  const expectedSettlements = ordered.filter((row) => !abortedNeverRun.has(row.submissionId)).map((row) => submissionSettlementRecordId(row.submissionId));
@@ -146,7 +180,19 @@ const verifyThreadInvariants = Effect.fn("Thread.verifyThreadInvariants")(functi
146
180
  const settlementOrder = recordIds.filter((recordId) => expectedSet.has(recordId));
147
181
  const presentSettlements = new Set(settlementOrder);
148
182
  const expectedPresent = expectedSettlements.filter((expected) => presentSettlements.has(expected));
149
- const matches = settlementOrder.length === expectedPresent.length && settlementOrder.every((recordId, index) => recordId === expectedPresent[index]);
183
+ const remaining = new Set(expectedPresent);
184
+ let matches = settlementOrder.length === expectedPresent.length;
185
+ for (const recordId of settlementOrder) {
186
+ for (const earlier of remaining) {
187
+ if (earlier === recordId) break;
188
+ if (!bypassedSettlements.get(recordId)?.has(earlier)) {
189
+ matches = false;
190
+ break;
191
+ }
192
+ }
193
+ if (!matches) break;
194
+ remaining.delete(recordId);
195
+ }
150
196
  checks.push(matches ? check("fifo-settlement-order", "passed") : check("fifo-settlement-order", "failed", `canonical settlement order [${settlementOrder.join(", ")}] violates queue order`));
151
197
  }
152
198
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadInvariants.mjs","names":[],"sources":["../../src/durable/ThreadInvariants.ts"],"sourcesContent":["import type { Crypto } from \"effect\";\nimport { Effect, Schema } from \"effect\";\n\nimport { IntegrityCheck, IntegrityReport, type IntegrityCheckName } from \"./Admin.ts\";\nimport { digestCanonicalBatch, EMPTY_TAIL_DIGEST } from \"./Digest.ts\";\nimport {\n CanonicalBatch,\n CanonicalRecordEnvelope,\n type BatchId,\n type ProducerId,\n type RecordEnvelope,\n} from \"./Records.ts\";\nimport {\n submissionInputRecordId,\n submissionSettlementRecordId,\n type SubmissionSnapshot,\n} from \"./SubmissionLedger.ts\";\nimport type { ThreadCheckpoint, ThreadExport } from \"./ThreadStore.ts\";\n\n/**\n * The production thread invariant checker, shared by the durable coordinator, admin\n * verification, and development harnesses. Keeping it independent of certification and\n * conformance modules prevents ordinary runtime imports from loading test-only dependencies.\n *\n * `verifyThreadInvariants` — hoisted from the DC eviction harness's `assertConvergence`\n * so the admin `verify` operation, the adapter certification tiers (WP2), and the chaos/soak\n * properties (WP4) all assert one set of claims.\n */\n\n/**\n * Input of one invariant verification, assembled entirely from port reads (or from a captured\n * copy under test):\n *\n * - `export` — the Thread's canonical export (`ThreadStore.export`).\n * - `submissions` — every known Submission row of the lane (ledger scan + lookups). Order is\n * irrelevant; the checker sorts by `queueSequence`.\n * - `batchProducers` — OPTIONAL per-batch producer identity directory. The digest chain hashes\n * each batch's Schema-encoded `CanonicalBatch` — including its `producerId`, which the\n * `ThreadStore` port deliberately does not export — so full chain recomputation needs\n * this directory (capture it at append time, or from adapter-private storage). Without it the\n * `digest-chain` and `checkpoint-binding` checks report `skipped` with the honest reason;\n * adapter-level `verifyOnOpen` remains the storage-side full audit.\n * - `checkpoint` — the stored checkpoint to bind against the recomputed chain, when one exists.\n * - `checkpointsSupported` — whether the caller inspected a supporting adapter. Without this\n * evidence or a supplied checkpoint, checkpoint verification is skipped.\n * - `requireAllSettled` — convergence mode (certification Tier 2, chaos, soak): additionally\n * require every known Submission to be settled.\n */\nexport interface ThreadInvariantInput {\n readonly export: ThreadExport;\n readonly submissions: ReadonlyArray<SubmissionSnapshot>;\n readonly batchProducers?: ReadonlyMap<BatchId, ProducerId> | undefined;\n readonly checkpoint?: ThreadCheckpoint | undefined;\n /** Set only after checking the adapter's optional checkpoint capability. */\n readonly checkpointsSupported?: boolean | undefined;\n readonly requireAllSettled?: boolean | undefined;\n}\n\nconst encodeEnvelope = Schema.encodeEffect(CanonicalRecordEnvelope);\nconst decodeEnvelope = Schema.decodeUnknownEffect(CanonicalRecordEnvelope);\n\nconst check = (\n name: IntegrityCheckName,\n status: \"passed\" | \"failed\" | \"skipped\",\n detail?: string,\n): IntegrityCheck =>\n IntegrityCheck.make({\n name,\n status,\n ...(detail === undefined ? {} : { detail: detail.slice(0, 4_096) }),\n });\n\ninterface BatchRun {\n readonly batchId: BatchId;\n readonly records: Array<RecordEnvelope>;\n readonly lastSequence: number;\n}\n\n/** Group the export's records into their atomic append runs (batches append contiguously). */\nconst batchRunsOf = (records: ReadonlyArray<CanonicalRecordEnvelope>): Array<BatchRun> => {\n const runs: Array<BatchRun> = [];\n\n for (const envelope of records) {\n const current = runs.at(-1);\n\n if (current !== undefined && current.batchId === envelope.batchId) {\n current.records.push(envelope.record);\n runs[runs.length - 1] = { ...current, lastSequence: envelope.sequence };\n continue;\n }\n runs.push({\n batchId: envelope.batchId,\n records: [envelope.record],\n lastSequence: envelope.sequence,\n });\n }\n\n return runs;\n};\n\n/**\n * The shared thread invariant checker (plan §1/§3): the DC harness `assertConvergence`\n * claims, verbatim, as typed per-check results over a canonical export plus the lane's ledger\n * rows — read-only, never a repair:\n *\n * 1. `schema-round-trip` — every envelope re-encodes and re-decodes through its canonical\n * Schema (a corrupted copy fails typed instead of decoding incorrectly).\n * 2. `record-identity` — no canonical record identity appears twice (DUR-007 dedupe held).\n * 3. `sequence-contiguity` — gap-free sequences from 1 through the exported tail.\n * 4. `digest-chain` — the tail digest recomputes from `EMPTY_TAIL_DIGEST` through every batch\n * (requires the per-batch producer directory; skipped honestly otherwise).\n * 5. `fifo-input-order` / `fifo-settlement-order` — canonical input and settlement records\n * follow the admitted queue order (DUR-004). Aborted settlements of never-run work (no\n * canonical `input:{sid}` record) are exempt from the settlement comparison: P7 §7(c)\n * settles them immediately without waiting for the head, and DUR-004 bounds execution\n * order, which never-run work has none of.\n * 6. `terminal-uniqueness` — at most one canonical terminal record per Submission, exactly one\n * for every settled ledger row (DUR-002).\n * 7. `ledger-canonical-agreement` — a settled ledger row has a canonical settlement record and\n * the outcomes agree; canonical history remains the authority (DUR-015).\n * 8. `checkpoint-binding` — a stored checkpoint's digest matches the recomputed chain at its\n * sequence (needs the chain; bounds are checked regardless).\n * 9. `all-settled` — convergence mode only: every known Submission settled.\n *\n * Requires only `Crypto.Crypto` (digest recomputation); it performs no port access, so the\n * admin operation, certification runners, and chaos properties feed it whatever copies they\n * hold.\n */\nexport const verifyThreadInvariants = Effect.fn(\"Thread.verifyThreadInvariants\")(function* (\n input: ThreadInvariantInput,\n): Effect.fn.Return<IntegrityReport, never, Crypto.Crypto> {\n const exported = input.export;\n const records = exported.records;\n const checks: Array<IntegrityCheck> = [];\n\n // 1. schema-round-trip\n {\n let failure: string | undefined;\n\n for (const envelope of records) {\n const roundTrip = yield* encodeEnvelope(envelope).pipe(\n Effect.flatMap(decodeEnvelope),\n Effect.exit,\n );\n\n if (roundTrip._tag === \"Failure\") {\n failure = `record ${envelope.record.recordId} does not round-trip its Schema`;\n break;\n }\n }\n checks.push(\n failure === undefined\n ? check(\"schema-round-trip\", \"passed\")\n : check(\"schema-round-trip\", \"failed\", failure),\n );\n }\n\n // 2. record-identity\n {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n\n for (const envelope of records) {\n if (seen.has(envelope.record.recordId)) duplicates.add(envelope.record.recordId);\n seen.add(envelope.record.recordId);\n }\n checks.push(\n duplicates.size === 0\n ? check(\"record-identity\", \"passed\")\n : check(\n \"record-identity\",\n \"failed\",\n `duplicated canonical record identities: ${[...duplicates].join(\", \")}`,\n ),\n );\n }\n\n // 3. sequence-contiguity\n {\n let contiguityFailure: string | undefined;\n\n for (const [index, envelope] of records.entries()) {\n if (envelope.sequence !== index + 1) {\n contiguityFailure = `sequence ${envelope.sequence} at position ${index} (expected ${index + 1})`;\n break;\n }\n }\n if (contiguityFailure === undefined && records.length !== exported.tailSequence) {\n contiguityFailure = `exported tail sequence ${exported.tailSequence} disagrees with ${records.length} records`;\n }\n checks.push(\n contiguityFailure === undefined\n ? check(\"sequence-contiguity\", \"passed\")\n : check(\"sequence-contiguity\", \"failed\", contiguityFailure),\n );\n }\n\n // 4. digest-chain (+ collect per-sequence chain digests for checkpoint binding)\n const chainDigestAtSequence = new Map<number, string>();\n\n if (input.batchProducers === undefined) {\n checks.push(\n check(\n \"digest-chain\",\n \"skipped\",\n \"the ThreadStore port does not export per-batch producer identity; supply batchProducers (captured at append time) to recompute the chain — adapter-level verifyOnOpen performs the storage-side audit\",\n ),\n );\n } else {\n let chain = EMPTY_TAIL_DIGEST;\n let chainFailure: string | undefined;\n\n for (const run of batchRunsOf(records)) {\n const producerId = input.batchProducers.get(run.batchId);\n\n if (producerId === undefined) {\n chainFailure = `no producer identity supplied for batch ${run.batchId}`;\n break;\n }\n const [first, ...rest] = run.records;\n\n if (first === undefined) {\n chainFailure = `batch ${run.batchId} grouped zero records`;\n break;\n }\n\n const digest = yield* digestCanonicalBatch(\n chain,\n CanonicalBatch.make({ batchId: run.batchId, producerId, records: [first, ...rest] }),\n ).pipe(Effect.exit);\n\n if (digest._tag === \"Failure\") {\n chainFailure = `batch ${run.batchId} could not be re-digested`;\n break;\n }\n chain = digest.value;\n chainDigestAtSequence.set(run.lastSequence, chain);\n }\n if (chainFailure === undefined && chain !== exported.tailDigest) {\n chainFailure = `recomputed tail digest ${chain} disagrees with exported tail digest ${exported.tailDigest}`;\n }\n checks.push(\n chainFailure === undefined\n ? check(\"digest-chain\", \"passed\")\n : check(\"digest-chain\", \"failed\", chainFailure),\n );\n }\n\n // Shared FIFO/terminal machinery\n const ordered = [...input.submissions].sort(\n (left, right) => left.queueSequence - right.queueSequence,\n );\n\n const recordIds = records.map((envelope) => envelope.record.recordId);\n\n // 5a. fifo-input-order\n {\n const expectedInputs = ordered.map((row) => submissionInputRecordId(row.submissionId));\n const expectedSet = new Set<string>(expectedInputs);\n const inputOrder = recordIds.filter((recordId) => expectedSet.has(recordId));\n const presentInputs = new Set(inputOrder);\n const expectedPresent = expectedInputs.filter((expected) => presentInputs.has(expected));\n\n const matches =\n inputOrder.length === expectedPresent.length &&\n inputOrder.every((recordId, index) => recordId === expectedPresent[index]);\n\n checks.push(\n matches\n ? check(\"fifo-input-order\", \"passed\")\n : check(\n \"fifo-input-order\",\n \"failed\",\n `canonical input order [${inputOrder.join(\", \")}] violates queue order`,\n ),\n );\n }\n\n // 5b. fifo-settlement-order — P7 §7(c) exemption: an ABORTED settlement for never-run work\n // (no canonical `input:{sid}` record) settles immediately by design, without waiting to\n // head the lane, so it is excluded from the FIFO comparison. DUR-004 bounds EXECUTION\n // order; the exempted rows provably never executed.\n {\n const recordIdSet = new Set<string>(recordIds);\n const abortedNeverRun = new Set<string>();\n\n for (const envelope of records) {\n const payload = envelope.record.payload;\n\n if (\n payload._tag === \"SubmissionSettled\" &&\n payload.outcome === \"aborted\" &&\n !recordIdSet.has(submissionInputRecordId(payload.submissionId))\n ) {\n abortedNeverRun.add(payload.submissionId);\n }\n }\n\n const expectedSettlements = ordered\n .filter((row) => !abortedNeverRun.has(row.submissionId))\n .map((row) => submissionSettlementRecordId(row.submissionId));\n\n const expectedSet = new Set<string>(expectedSettlements);\n const settlementOrder = recordIds.filter((recordId) => expectedSet.has(recordId));\n\n const presentSettlements = new Set(settlementOrder);\n\n const expectedPresent = expectedSettlements.filter((expected) =>\n presentSettlements.has(expected),\n );\n\n const matches =\n settlementOrder.length === expectedPresent.length &&\n settlementOrder.every((recordId, index) => recordId === expectedPresent[index]);\n\n checks.push(\n matches\n ? check(\"fifo-settlement-order\", \"passed\")\n : check(\n \"fifo-settlement-order\",\n \"failed\",\n `canonical settlement order [${settlementOrder.join(\", \")}] violates queue order`,\n ),\n );\n }\n\n // 6 + 7. terminal-uniqueness and ledger-canonical-agreement\n {\n const settlementsBySubmission = new Map<string, Array<CanonicalRecordEnvelope>>();\n\n for (const envelope of records) {\n if (envelope.record.payload._tag !== \"SubmissionSettled\") continue;\n const submissionId = envelope.record.payload.submissionId;\n const existing = settlementsBySubmission.get(submissionId) ?? [];\n\n existing.push(envelope);\n settlementsBySubmission.set(submissionId, existing);\n }\n let uniquenessFailure: string | undefined;\n let agreementFailure: string | undefined;\n\n for (const [submissionId, settlements] of settlementsBySubmission) {\n if (settlements.length > 1) {\n uniquenessFailure = `submission ${submissionId} has ${settlements.length} canonical terminal records`;\n }\n }\n for (const row of ordered) {\n const settlements = settlementsBySubmission.get(row.submissionId) ?? [];\n const canonical = settlements[0]?.record.payload;\n\n if (row.state === \"settled\") {\n if (settlements.length !== 1) {\n uniquenessFailure ??= `settled submission ${row.submissionId} has ${settlements.length} canonical terminal records (expected exactly 1)`;\n }\n if (\n canonical !== undefined &&\n canonical._tag === \"SubmissionSettled\" &&\n row.settledOutcome !== undefined &&\n canonical.outcome !== row.settledOutcome\n ) {\n agreementFailure = `submission ${row.submissionId}: ledger outcome ${row.settledOutcome} disagrees with canonical outcome ${canonical.outcome}`;\n }\n if (settlements.length === 0) {\n agreementFailure ??= `settled submission ${row.submissionId} has no canonical settlement record (DUR-015: history is the authority)`;\n }\n }\n }\n checks.push(\n uniquenessFailure === undefined\n ? check(\"terminal-uniqueness\", \"passed\")\n : check(\"terminal-uniqueness\", \"failed\", uniquenessFailure),\n );\n checks.push(\n agreementFailure === undefined\n ? check(\"ledger-canonical-agreement\", \"passed\")\n : check(\"ledger-canonical-agreement\", \"failed\", agreementFailure),\n );\n }\n\n // 8. checkpoint-binding\n if (input.checkpoint === undefined && input.checkpointsSupported !== true) {\n checks.push(check(\"checkpoint-binding\", \"skipped\", \"checkpoint support was not supplied\"));\n } else if (input.checkpoint === undefined) {\n checks.push(check(\"checkpoint-binding\", \"passed\", \"no stored checkpoint\"));\n } else if (input.checkpoint.throughSequence > exported.tailSequence) {\n checks.push(\n check(\n \"checkpoint-binding\",\n \"failed\",\n `checkpoint through-sequence ${input.checkpoint.throughSequence} is ahead of the tail ${exported.tailSequence}`,\n ),\n );\n } else if (input.batchProducers === undefined) {\n checks.push(\n check(\n \"checkpoint-binding\",\n \"skipped\",\n \"digest binding needs the recomputed chain; supply batchProducers (the adapter rejects mismatched checkpoints on save/load regardless)\",\n ),\n );\n } else {\n const bound = chainDigestAtSequence.get(input.checkpoint.throughSequence);\n\n checks.push(\n bound === input.checkpoint.tailDigest\n ? check(\"checkpoint-binding\", \"passed\")\n : check(\n \"checkpoint-binding\",\n \"failed\",\n `checkpoint digest ${input.checkpoint.tailDigest} does not match the recomputed chain at sequence ${input.checkpoint.throughSequence}`,\n ),\n );\n }\n\n // 9. all-settled (convergence mode)\n if (input.requireAllSettled === true) {\n const nonterminal = ordered.filter((row) => row.state !== \"settled\");\n\n checks.push(\n nonterminal.length === 0 && ordered.length > 0\n ? check(\"all-settled\", \"passed\")\n : check(\n \"all-settled\",\n \"failed\",\n ordered.length === 0\n ? \"no Submissions are known to the lane\"\n : `nonterminal submissions: ${nonterminal\n .map((row) => `${row.submissionId}(${row.state})`)\n .join(\", \")}`,\n ),\n );\n }\n\n return IntegrityReport.make({\n threadId: exported.threadId,\n tailSequence: exported.tailSequence,\n recordCount: records.length,\n submissionCount: ordered.length,\n checks,\n ok: checks.every((result) => result.status !== \"failed\"),\n });\n});\n"],"mappings":";;;;;;;;AA0DA,MAAM,iBAAiB,OAAO,aAAa,uBAAuB;AAClE,MAAM,iBAAiB,OAAO,oBAAoB,uBAAuB;AAEzE,MAAM,SACJ,MACA,QACA,WAEA,eAAe,KAAK;CAClB;CACA;CACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,MAAM,GAAG,IAAK,EAAE;AACnE,CAAC;;AASH,MAAM,eAAe,YAAqE;CACxF,MAAM,OAAwB,CAAC;CAE/B,KAAK,MAAM,YAAY,SAAS;EAC9B,MAAM,UAAU,KAAK,GAAG,EAAE;EAE1B,IAAI,YAAY,KAAA,KAAa,QAAQ,YAAY,SAAS,SAAS;GACjE,QAAQ,QAAQ,KAAK,SAAS,MAAM;GACpC,KAAK,KAAK,SAAS,KAAK;IAAE,GAAG;IAAS,cAAc,SAAS;GAAS;GACtE;EACF;EACA,KAAK,KAAK;GACR,SAAS,SAAS;GAClB,SAAS,CAAC,SAAS,MAAM;GACzB,cAAc,SAAS;EACzB,CAAC;CACH;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,yBAAyB,OAAO,GAAG,+BAA+B,CAAC,CAAC,WAC/E,OACyD;CACzD,MAAM,WAAW,MAAM;CACvB,MAAM,UAAU,SAAS;CACzB,MAAM,SAAgC,CAAC;CAGvC;EACE,IAAI;EAEJ,KAAK,MAAM,YAAY,SAMrB,KAAI,OALqB,eAAe,QAAQ,CAAC,CAAC,KAChD,OAAO,QAAQ,cAAc,GAC7B,OAAO,IACT,EAAA,CAEc,SAAS,WAAW;GAChC,UAAU,UAAU,SAAS,OAAO,SAAS;GAC7C;EACF;EAEF,OAAO,KACL,YAAY,KAAA,IACR,MAAM,qBAAqB,QAAQ,IACnC,MAAM,qBAAqB,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AS;EAEnE,OAAO,KACL,YAAY,WAAW,KAAK,QAAQ,SAAS,IACzC,MAAM,eAAe,QAAQ,IAC7B,MACE,eACA,UACA,QAAQ,WAAW,IACf,yCACA,4BAA4B,YACzB,KAAK,QAAQ,GAAG,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,CAAC,CACjD,KAAK,IAAI,GAClB,CACN;CACF;CAEA,OAAO,gBAAgB,KAAK;EAC1B,UAAU,SAAS;EACnB,cAAc,SAAS;EACvB,aAAa,QAAQ;EACrB,iBAAiB,QAAQ;EACzB;EACA,IAAI,OAAO,OAAO,WAAW,OAAO,WAAW,QAAQ;CACzD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"ThreadInvariants.mjs","names":[],"sources":["../../src/durable/ThreadInvariants.ts"],"sourcesContent":["import type { Crypto } from \"effect\";\nimport { Effect, Schema } from \"effect\";\n\nimport { IntegrityCheck, IntegrityReport, type IntegrityCheckName } from \"./Admin.ts\";\nimport { digestCanonicalBatch, EMPTY_TAIL_DIGEST } from \"./Digest.ts\";\nimport {\n CanonicalBatch,\n CanonicalRecordEnvelope,\n type BatchId,\n type ProducerId,\n type RecordEnvelope,\n} from \"./Records.ts\";\nimport { runIdForSubmission } from \"./RunJournal.ts\";\nimport {\n submissionInputRecordId,\n submissionSettlementRecordId,\n type SubmissionSnapshot,\n} from \"./SubmissionLedger.ts\";\nimport type { ThreadCheckpoint, ThreadExport } from \"./ThreadStore.ts\";\n\n/**\n * The production thread invariant checker, shared by the durable coordinator, admin\n * verification, and development harnesses. Keeping it independent of certification and\n * conformance modules prevents ordinary runtime imports from loading test-only dependencies.\n *\n * `verifyThreadInvariants` — hoisted from the DC eviction harness's `assertConvergence`\n * so the admin `verify` operation, the adapter certification tiers (WP2), and the chaos/soak\n * properties (WP4) all assert one set of claims.\n */\n\n/**\n * Input of one invariant verification, assembled entirely from port reads (or from a captured\n * copy under test):\n *\n * - `export` — the Thread's canonical export (`ThreadStore.export`).\n * - `submissions` — every known Submission row of the lane (ledger scan + lookups). Order is\n * irrelevant; the checker sorts by `queueSequence`.\n * - `batchProducers` — OPTIONAL per-batch producer identity directory. The digest chain hashes\n * each batch's Schema-encoded `CanonicalBatch` — including its `producerId`, which the\n * `ThreadStore` port deliberately does not export — so full chain recomputation needs\n * this directory (capture it at append time, or from adapter-private storage). Without it the\n * `digest-chain` and `checkpoint-binding` checks report `skipped` with the honest reason;\n * adapter-level `verifyOnOpen` remains the storage-side full audit.\n * - `checkpoint` — the stored checkpoint to bind against the recomputed chain, when one exists.\n * - `checkpointsSupported` — whether the caller inspected a supporting adapter. Without this\n * evidence or a supplied checkpoint, checkpoint verification is skipped.\n * - `requireAllSettled` — convergence mode (certification Tier 2, chaos, soak): additionally\n * require every known Submission to be settled.\n */\nexport interface ThreadInvariantInput {\n readonly export: ThreadExport;\n readonly submissions: ReadonlyArray<SubmissionSnapshot>;\n readonly batchProducers?: ReadonlyMap<BatchId, ProducerId> | undefined;\n readonly checkpoint?: ThreadCheckpoint | undefined;\n /** Set only after checking the adapter's optional checkpoint capability. */\n readonly checkpointsSupported?: boolean | undefined;\n readonly requireAllSettled?: boolean | undefined;\n}\n\nconst encodeEnvelope = Schema.encodeEffect(CanonicalRecordEnvelope);\nconst decodeEnvelope = Schema.decodeUnknownEffect(CanonicalRecordEnvelope);\n\nconst check = (\n name: IntegrityCheckName,\n status: \"passed\" | \"failed\" | \"skipped\",\n detail?: string,\n): IntegrityCheck =>\n IntegrityCheck.make({\n name,\n status,\n ...(detail === undefined ? {} : { detail: detail.slice(0, 4_096) }),\n });\n\ninterface BatchRun {\n readonly batchId: BatchId;\n readonly records: Array<RecordEnvelope>;\n readonly lastSequence: number;\n}\n\n/** Group the export's records into their atomic append runs (batches append contiguously). */\nconst batchRunsOf = (records: ReadonlyArray<CanonicalRecordEnvelope>): Array<BatchRun> => {\n const runs: Array<BatchRun> = [];\n\n for (const envelope of records) {\n const current = runs.at(-1);\n\n if (current !== undefined && current.batchId === envelope.batchId) {\n current.records.push(envelope.record);\n runs[runs.length - 1] = { ...current, lastSequence: envelope.sequence };\n continue;\n }\n runs.push({\n batchId: envelope.batchId,\n records: [envelope.record],\n lastSequence: envelope.sequence,\n });\n }\n\n return runs;\n};\n\n/**\n * The shared thread invariant checker (plan §1/§3): the DC harness `assertConvergence`\n * claims, verbatim, as typed per-check results over a canonical export plus the lane's ledger\n * rows — read-only, never a repair:\n *\n * 1. `schema-round-trip` — every envelope re-encodes and re-decodes through its canonical\n * Schema (a corrupted copy fails typed instead of decoding incorrectly).\n * 2. `record-identity` — no canonical record identity appears twice (DUR-007 dedupe held).\n * 3. `sequence-contiguity` — gap-free sequences from 1 through the exported tail.\n * 4. `digest-chain` — the tail digest recomputes from `EMPTY_TAIL_DIGEST` through every batch\n * (requires the per-batch producer directory; skipped honestly otherwise).\n * 5. `fifo-input-order` / `fifo-settlement-order` — canonical input and settlement records\n * follow the admitted queue order (DUR-004), except a later input may settle before a Run\n * with canonically unresolved unknown calls when that input became active. Resolving those\n * calls later does not revoke the later Run's ownership. Aborted settlements of never-run work (no\n * canonical `input:{sid}` record) are exempt from the settlement comparison: P7 §7(c)\n * settles them immediately without waiting for the head, and DUR-004 bounds execution\n * order, which never-run work has none of.\n * 6. `terminal-uniqueness` — at most one canonical terminal record per Submission, exactly one\n * for every settled ledger row (DUR-002).\n * 7. `ledger-canonical-agreement` — a settled ledger row has a canonical settlement record and\n * the outcomes agree; canonical history remains the authority (DUR-015).\n * 8. `checkpoint-binding` — a stored checkpoint's digest matches the recomputed chain at its\n * sequence (needs the chain; bounds are checked regardless).\n * 9. `all-settled` — convergence mode only: every known Submission settled.\n *\n * Requires only `Crypto.Crypto` (digest recomputation); it performs no port access, so the\n * admin operation, certification runners, and chaos properties feed it whatever copies they\n * hold.\n */\nexport const verifyThreadInvariants = Effect.fn(\"Thread.verifyThreadInvariants\")(function* (\n input: ThreadInvariantInput,\n): Effect.fn.Return<IntegrityReport, never, Crypto.Crypto> {\n const exported = input.export;\n const records = exported.records;\n const checks: Array<IntegrityCheck> = [];\n\n // 1. schema-round-trip\n {\n let failure: string | undefined;\n\n for (const envelope of records) {\n const roundTrip = yield* encodeEnvelope(envelope).pipe(\n Effect.flatMap(decodeEnvelope),\n Effect.exit,\n );\n\n if (roundTrip._tag === \"Failure\") {\n failure = `record ${envelope.record.recordId} does not round-trip its Schema`;\n break;\n }\n }\n checks.push(\n failure === undefined\n ? check(\"schema-round-trip\", \"passed\")\n : check(\"schema-round-trip\", \"failed\", failure),\n );\n }\n\n // 2. record-identity\n {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n\n for (const envelope of records) {\n if (seen.has(envelope.record.recordId)) duplicates.add(envelope.record.recordId);\n seen.add(envelope.record.recordId);\n }\n checks.push(\n duplicates.size === 0\n ? check(\"record-identity\", \"passed\")\n : check(\n \"record-identity\",\n \"failed\",\n `duplicated canonical record identities: ${[...duplicates].join(\", \")}`,\n ),\n );\n }\n\n // 3. sequence-contiguity\n {\n let contiguityFailure: string | undefined;\n\n for (const [index, envelope] of records.entries()) {\n if (envelope.sequence !== index + 1) {\n contiguityFailure = `sequence ${envelope.sequence} at position ${index} (expected ${index + 1})`;\n break;\n }\n }\n if (contiguityFailure === undefined && records.length !== exported.tailSequence) {\n contiguityFailure = `exported tail sequence ${exported.tailSequence} disagrees with ${records.length} records`;\n }\n checks.push(\n contiguityFailure === undefined\n ? check(\"sequence-contiguity\", \"passed\")\n : check(\"sequence-contiguity\", \"failed\", contiguityFailure),\n );\n }\n\n // 4. digest-chain (+ collect per-sequence chain digests for checkpoint binding)\n const chainDigestAtSequence = new Map<number, string>();\n\n if (input.batchProducers === undefined) {\n checks.push(\n check(\n \"digest-chain\",\n \"skipped\",\n \"the ThreadStore port does not export per-batch producer identity; supply batchProducers (captured at append time) to recompute the chain — adapter-level verifyOnOpen performs the storage-side audit\",\n ),\n );\n } else {\n let chain = EMPTY_TAIL_DIGEST;\n let chainFailure: string | undefined;\n\n for (const run of batchRunsOf(records)) {\n const producerId = input.batchProducers.get(run.batchId);\n\n if (producerId === undefined) {\n chainFailure = `no producer identity supplied for batch ${run.batchId}`;\n break;\n }\n const [first, ...rest] = run.records;\n\n if (first === undefined) {\n chainFailure = `batch ${run.batchId} grouped zero records`;\n break;\n }\n\n const digest = yield* digestCanonicalBatch(\n chain,\n CanonicalBatch.make({ batchId: run.batchId, producerId, records: [first, ...rest] }),\n ).pipe(Effect.exit);\n\n if (digest._tag === \"Failure\") {\n chainFailure = `batch ${run.batchId} could not be re-digested`;\n break;\n }\n chain = digest.value;\n chainDigestAtSequence.set(run.lastSequence, chain);\n }\n if (chainFailure === undefined && chain !== exported.tailDigest) {\n chainFailure = `recomputed tail digest ${chain} disagrees with exported tail digest ${exported.tailDigest}`;\n }\n checks.push(\n chainFailure === undefined\n ? check(\"digest-chain\", \"passed\")\n : check(\"digest-chain\", \"failed\", chainFailure),\n );\n }\n\n // Shared FIFO/terminal machinery\n const ordered = [...input.submissions].sort(\n (left, right) => left.queueSequence - right.queueSequence,\n );\n\n const recordIds = records.map((envelope) => envelope.record.recordId);\n\n // 5a. fifo-input-order\n {\n const expectedInputs = ordered.map((row) => submissionInputRecordId(row.submissionId));\n const expectedSet = new Set<string>(expectedInputs);\n const inputOrder = recordIds.filter((recordId) => expectedSet.has(recordId));\n const presentInputs = new Set(inputOrder);\n const expectedPresent = expectedInputs.filter((expected) => presentInputs.has(expected));\n\n const matches =\n inputOrder.length === expectedPresent.length &&\n inputOrder.every((recordId, index) => recordId === expectedPresent[index]);\n\n checks.push(\n matches\n ? check(\"fifo-input-order\", \"passed\")\n : check(\n \"fifo-input-order\",\n \"failed\",\n `canonical input order [${inputOrder.join(\", \")}] violates queue order`,\n ),\n );\n }\n\n // 5b. fifo-settlement-order — P7 §7(c) exemption: an ABORTED settlement for never-run work\n // (no canonical `input:{sid}` record) settles immediately by design, without waiting to\n // head the lane, so it is excluded from the FIFO comparison. DUR-004 bounds EXECUTION\n // order; the exempted rows provably never executed. Unknown work can also be bypassed,\n // but only the inputs that became active while it was parked may settle ahead of it.\n {\n const recordIdSet = new Set<string>(recordIds);\n const abortedNeverRun = new Set<string>();\n\n const settlementByRun = new Map<string, string>(\n ordered.map((row) => [\n runIdForSubmission(row.submissionId),\n submissionSettlementRecordId(row.submissionId),\n ]),\n );\n\n const inputSettlements = new Map(\n ordered.map((row) => [\n submissionInputRecordId(row.submissionId),\n submissionSettlementRecordId(row.submissionId),\n ]),\n );\n\n const unknownCalls = new Map<string, Set<string>>();\n const abortsOrTerminals = new Set<string>();\n const bypassedSettlements = new Map<string, Set<string>>();\n\n for (const envelope of records) {\n const payload = envelope.record.payload;\n\n if (payload._tag === \"ToolCallUnknown\" && !abortsOrTerminals.has(payload.runId)) {\n const calls = unknownCalls.get(payload.runId) ?? new Set<string>();\n\n calls.add(payload.toolCallId);\n unknownCalls.set(payload.runId, calls);\n } else if (payload._tag === \"ToolCallResolved\" || payload._tag === \"ToolCallSettled\") {\n const calls = unknownCalls.get(payload.runId);\n\n calls?.delete(payload.toolCallId);\n if (calls?.size === 0) unknownCalls.delete(payload.runId);\n } else if (payload._tag === \"AbortRequested\" || payload._tag === \"SubmissionSettled\") {\n const runId = runIdForSubmission(payload.submissionId);\n\n abortsOrTerminals.add(runId);\n unknownCalls.delete(runId);\n } else if (payload._tag === \"RunCompleted\" || payload._tag === \"RunFailed\") {\n abortsOrTerminals.add(payload.runId);\n unknownCalls.delete(payload.runId);\n } else if (payload._tag === \"UserInputRecorded\") {\n const settlementId = inputSettlements.get(envelope.record.recordId);\n\n if (settlementId !== undefined) {\n const bypassed = new Set<string>();\n\n for (const runId of unknownCalls.keys()) {\n const earlier = settlementByRun.get(runId);\n\n if (earlier !== undefined) bypassed.add(earlier);\n }\n bypassedSettlements.set(settlementId, bypassed);\n }\n }\n if (\n payload._tag === \"SubmissionSettled\" &&\n payload.outcome === \"aborted\" &&\n !recordIdSet.has(submissionInputRecordId(payload.submissionId))\n ) {\n abortedNeverRun.add(payload.submissionId);\n }\n }\n\n const expectedSettlements = ordered\n .filter((row) => !abortedNeverRun.has(row.submissionId))\n .map((row) => submissionSettlementRecordId(row.submissionId));\n\n const expectedSet = new Set<string>(expectedSettlements);\n const settlementOrder = recordIds.filter((recordId) => expectedSet.has(recordId));\n\n const presentSettlements = new Set(settlementOrder);\n\n const expectedPresent = expectedSettlements.filter((expected) =>\n presentSettlements.has(expected),\n );\n\n const remaining = new Set(expectedPresent);\n let matches = settlementOrder.length === expectedPresent.length;\n\n for (const recordId of settlementOrder) {\n for (const earlier of remaining) {\n if (earlier === recordId) break;\n if (!bypassedSettlements.get(recordId)?.has(earlier)) {\n matches = false;\n break;\n }\n }\n if (!matches) break;\n remaining.delete(recordId);\n }\n\n checks.push(\n matches\n ? check(\"fifo-settlement-order\", \"passed\")\n : check(\n \"fifo-settlement-order\",\n \"failed\",\n `canonical settlement order [${settlementOrder.join(\", \")}] violates queue order`,\n ),\n );\n }\n\n // 6 + 7. terminal-uniqueness and ledger-canonical-agreement\n {\n const settlementsBySubmission = new Map<string, Array<CanonicalRecordEnvelope>>();\n\n for (const envelope of records) {\n if (envelope.record.payload._tag !== \"SubmissionSettled\") continue;\n const submissionId = envelope.record.payload.submissionId;\n const existing = settlementsBySubmission.get(submissionId) ?? [];\n\n existing.push(envelope);\n settlementsBySubmission.set(submissionId, existing);\n }\n let uniquenessFailure: string | undefined;\n let agreementFailure: string | undefined;\n\n for (const [submissionId, settlements] of settlementsBySubmission) {\n if (settlements.length > 1) {\n uniquenessFailure = `submission ${submissionId} has ${settlements.length} canonical terminal records`;\n }\n }\n for (const row of ordered) {\n const settlements = settlementsBySubmission.get(row.submissionId) ?? [];\n const canonical = settlements[0]?.record.payload;\n\n if (row.state === \"settled\") {\n if (settlements.length !== 1) {\n uniquenessFailure ??= `settled submission ${row.submissionId} has ${settlements.length} canonical terminal records (expected exactly 1)`;\n }\n if (\n canonical !== undefined &&\n canonical._tag === \"SubmissionSettled\" &&\n row.settledOutcome !== undefined &&\n canonical.outcome !== row.settledOutcome\n ) {\n agreementFailure = `submission ${row.submissionId}: ledger outcome ${row.settledOutcome} disagrees with canonical outcome ${canonical.outcome}`;\n }\n if (settlements.length === 0) {\n agreementFailure ??= `settled submission ${row.submissionId} has no canonical settlement record (DUR-015: history is the authority)`;\n }\n }\n }\n checks.push(\n uniquenessFailure === undefined\n ? check(\"terminal-uniqueness\", \"passed\")\n : check(\"terminal-uniqueness\", \"failed\", uniquenessFailure),\n );\n checks.push(\n agreementFailure === undefined\n ? check(\"ledger-canonical-agreement\", \"passed\")\n : check(\"ledger-canonical-agreement\", \"failed\", agreementFailure),\n );\n }\n\n // 8. checkpoint-binding\n if (input.checkpoint === undefined && input.checkpointsSupported !== true) {\n checks.push(check(\"checkpoint-binding\", \"skipped\", \"checkpoint support was not supplied\"));\n } else if (input.checkpoint === undefined) {\n checks.push(check(\"checkpoint-binding\", \"passed\", \"no stored checkpoint\"));\n } else if (input.checkpoint.throughSequence > exported.tailSequence) {\n checks.push(\n check(\n \"checkpoint-binding\",\n \"failed\",\n `checkpoint through-sequence ${input.checkpoint.throughSequence} is ahead of the tail ${exported.tailSequence}`,\n ),\n );\n } else if (input.batchProducers === undefined) {\n checks.push(\n check(\n \"checkpoint-binding\",\n \"skipped\",\n \"digest binding needs the recomputed chain; supply batchProducers (the adapter rejects mismatched checkpoints on save/load regardless)\",\n ),\n );\n } else {\n const bound = chainDigestAtSequence.get(input.checkpoint.throughSequence);\n\n checks.push(\n bound === input.checkpoint.tailDigest\n ? check(\"checkpoint-binding\", \"passed\")\n : check(\n \"checkpoint-binding\",\n \"failed\",\n `checkpoint digest ${input.checkpoint.tailDigest} does not match the recomputed chain at sequence ${input.checkpoint.throughSequence}`,\n ),\n );\n }\n\n // 9. all-settled (convergence mode)\n if (input.requireAllSettled === true) {\n const nonterminal = ordered.filter((row) => row.state !== \"settled\");\n\n checks.push(\n nonterminal.length === 0 && ordered.length > 0\n ? check(\"all-settled\", \"passed\")\n : check(\n \"all-settled\",\n \"failed\",\n ordered.length === 0\n ? \"no Submissions are known to the lane\"\n : `nonterminal submissions: ${nonterminal\n .map((row) => `${row.submissionId}(${row.state})`)\n .join(\", \")}`,\n ),\n );\n }\n\n return IntegrityReport.make({\n threadId: exported.threadId,\n tailSequence: exported.tailSequence,\n recordCount: records.length,\n submissionCount: ordered.length,\n checks,\n ok: checks.every((result) => result.status !== \"failed\"),\n });\n});\n"],"mappings":";;;;;;;;;AA2DA,MAAM,iBAAiB,OAAO,aAAa,uBAAuB;AAClE,MAAM,iBAAiB,OAAO,oBAAoB,uBAAuB;AAEzE,MAAM,SACJ,MACA,QACA,WAEA,eAAe,KAAK;CAClB;CACA;CACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,MAAM,GAAG,IAAK,EAAE;AACnE,CAAC;;AASH,MAAM,eAAe,YAAqE;CACxF,MAAM,OAAwB,CAAC;CAE/B,KAAK,MAAM,YAAY,SAAS;EAC9B,MAAM,UAAU,KAAK,GAAG,EAAE;EAE1B,IAAI,YAAY,KAAA,KAAa,QAAQ,YAAY,SAAS,SAAS;GACjE,QAAQ,QAAQ,KAAK,SAAS,MAAM;GACpC,KAAK,KAAK,SAAS,KAAK;IAAE,GAAG;IAAS,cAAc,SAAS;GAAS;GACtE;EACF;EACA,KAAK,KAAK;GACR,SAAS,SAAS;GAClB,SAAS,CAAC,SAAS,MAAM;GACzB,cAAc,SAAS;EACzB,CAAC;CACH;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,yBAAyB,OAAO,GAAG,+BAA+B,CAAC,CAAC,WAC/E,OACyD;CACzD,MAAM,WAAW,MAAM;CACvB,MAAM,UAAU,SAAS;CACzB,MAAM,SAAgC,CAAC;CAGvC;EACE,IAAI;EAEJ,KAAK,MAAM,YAAY,SAMrB,KAAI,OALqB,eAAe,QAAQ,CAAC,CAAC,KAChD,OAAO,QAAQ,cAAc,GAC7B,OAAO,IACT,EAAA,CAEc,SAAS,WAAW;GAChC,U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,MAAM,WAAW,kBAAkB,SAAS,cACrD,OAAO,KACL,MACE,sBACA,UACA,+BAA+B,MAAM,WAAW,gBAAgB,wBAAwB,SAAS,cACnG,CACF;MACK,IAAI,MAAM,mBAAmB,KAAA,GAClC,OAAO,KACL,MACE,sBACA,WACA,uIACF,CACF;MACK;EACL,MAAM,QAAQ,sBAAsB,IAAI,MAAM,WAAW,eAAe;EAExE,OAAO,KACL,UAAU,MAAM,WAAW,aACvB,MAAM,sBAAsB,QAAQ,IACpC,MACE,sBACA,UACA,qBAAqB,MAAM,WAAW,WAAW,mDAAmD,MAAM,WAAW,iBACvH,CACN;CACF;CAGA,IAAI,MAAM,sBAAsB,MAAM;EACpC,MAAM,cAAc,QAAQ,QAAQ,QAAQ,IAAI,UAAU,SAAS;EAEnE,OAAO,KACL,YAAY,WAAW,KAAK,QAAQ,SAAS,IACzC,MAAM,eAAe,QAAQ,IAC7B,MACE,eACA,UACA,QAAQ,WAAW,IACf,yCACA,4BAA4B,YACzB,KAAK,QAAQ,GAAG,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,CAAC,CACjD,KAAK,IAAI,GAClB,CACN;CACF;CAEA,OAAO,gBAAgB,KAAK;EAC1B,UAAU,SAAS;EACnB,cAAc,SAAS;EACvB,aAAa,QAAQ;EACrB,iBAAiB,QAAQ;EACzB;EACA,IAAI,OAAO,OAAO,WAAW,OAAO,WAAW,QAAQ;CACzD,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { u as ThreadId } from "../Identifiers-CN2s30fF.mjs";
2
- import { G as SubagentRequested, J as SubmissionSettledRecord, K as SubagentStarted, Q as ToolApprovalRequested, U as SubagentJoined, W as SubagentLineageRecorded, Z as ToolApprovalDecided, _ as Digest, l as CanonicalRecordEnvelope, q as SubmissionSettled, rt as ToolCallUnknown, t as AbortRequested } from "../Records-CV49DgQK.mjs";
2
+ import { G as SubagentRequested, J as SubmissionSettledRecord, K as SubagentStarted, Q as ToolApprovalRequested, U as SubagentJoined, W as SubagentLineageRecorded, Z as ToolApprovalDecided, _ as Digest, l as CanonicalRecordEnvelope, q as SubmissionSettled, rt as ToolCallUnknown, t as AbortRequested } from "../Records-BIiRLqlz.mjs";
3
3
  import { Schema } from "effect";
4
4
  declare namespace ThreadProjection_d_exports {
5
5
  export { ApprovalRecord, OpenToolCallState, SubagentInvocationState, ThreadProjection, initialThreadProjection, reduceThreadRecord, replayThread, replayThreadFromCheckpoint };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { RunId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
3
- import { B as SubagentJoined, G as SubmissionSettledRecord, H as SubagentRequested, J as ToolApprovalDecided, T as PersistedJson, U as SubagentStarted, V as SubagentLineageRecorded, X as ToolCallPrepared, Y as ToolApprovalRequested, et as ToolCallUnknown, h as Digest, t as AbortRequested, u as CanonicalSequence } from "../Records-BAutSSnJ.mjs";
3
+ import { B as SubagentJoined, G as SubmissionSettledRecord, H as SubagentRequested, J as ToolApprovalDecided, T as PersistedJson, U as SubagentStarted, V as SubagentLineageRecorded, X as ToolCallPrepared, Y as ToolApprovalRequested, et as ToolCallUnknown, h as Digest, t as AbortRequested, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
4
4
  import { EMPTY_TAIL_DIGEST } from "./Digest.mjs";
5
5
  import { Schema } from "effect";
6
6
  //#region src/durable/ThreadProjection.ts
@@ -1,4 +1,4 @@
1
- import { Vt as AppendResult, Wt as FencedAppendRequest } from "../Records-CV49DgQK.mjs";
1
+ import { Kt as FencedAppendRequest, Ut as AppendResult } from "../Records-BIiRLqlz.mjs";
2
2
  import { Context, Effect, Layer, Option, Schema } from "effect";
3
3
  declare namespace ThreadProjectionMaintenance_d_exports {
4
4
  export { ThreadProjectionError, ThreadProjectionMaintenance, ThreadProjectionMaintenanceService, drainDue };
@@ -1,2 +1,2 @@
1
- import { $t as ThreadMaterialization, Bt as AppendConflict, Gt as LoadCheckpointRequest, Ht as CheckpointRejected, Jt as SaveRecoveryCheckpointRequest, Kt as MAX_THREAD_EXPORT_RECORDS, Qt as ThreadExportRequest, Ut as FenceRejected, Vt as AppendResult, Wt as FencedAppendRequest, Xt as ThreadCheckpoints, Yt as ThreadCheckpoint, Zt as ThreadExport, an as ThreadStoreError, cn as ThreadTail, en as ThreadNotMaterialized, in as ThreadStore, ln as ThreadTailRequest, nn as ThreadRead, on as ThreadStoreFailure, qt as SaveCheckpointRequest, rn as ThreadRecoveryCheckpoints, tn as ThreadObservation } from "../Records-CV49DgQK.mjs";
1
+ import { $t as ThreadExport, Gt as FenceRejected, Ht as AppendConflict, Jt as MAX_THREAD_EXPORT_RECORDS, Kt as FencedAppendRequest, Qt as ThreadCheckpoints, Ut as AppendResult, Wt as CheckpointRejected, Xt as SaveRecoveryCheckpointRequest, Yt as SaveCheckpointRequest, Zt as ThreadCheckpoint, an as ThreadRecoveryCheckpoints, cn as ThreadStoreFailure, dn as ThreadTailRequest, en as ThreadExportRequest, in as ThreadRead, nn as ThreadNotMaterialized, on as ThreadStore, qt as LoadCheckpointRequest, rn as ThreadObservation, sn as ThreadStoreError, tn as ThreadMaterialization, un as ThreadTail } from "../Records-BIiRLqlz.mjs";
2
2
  export { AppendConflict, AppendResult, CheckpointRejected, FenceRejected, FencedAppendRequest, LoadCheckpointRequest, MAX_THREAD_EXPORT_RECORDS, SaveCheckpointRequest, SaveRecoveryCheckpointRequest, ThreadCheckpoint, ThreadCheckpoints, ThreadExport, ThreadExportRequest, ThreadMaterialization, ThreadNotMaterialized, ThreadObservation, ThreadRead, ThreadRecoveryCheckpoints, ThreadStore, ThreadStoreError, ThreadStoreFailure, ThreadTail, ThreadTailRequest };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ThreadId } from "../core/Identifiers.mjs";
3
- import { C as ObservationOffset, E as ProducerEpoch, T as PersistedJson, c as CanonicalRecordEnvelope, h as Digest, i as BatchId, o as CanonicalBatch, u as CanonicalSequence } from "../Records-BAutSSnJ.mjs";
3
+ import { C as ObservationOffset, E as ProducerEpoch, T as PersistedJson, c as CanonicalRecordEnvelope, h as Digest, i as BatchId, o as CanonicalBatch, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
4
4
  import { Context, Schema } from "effect";
5
5
  //#region src/durable/ThreadStore.ts
6
6
  var ThreadStore_exports = /* @__PURE__ */ __exportAll({
@@ -1,4 +1,4 @@
1
- import { Ht as CheckpointRejected, in as ThreadStore, on as ThreadStoreFailure } from "../Records-CV49DgQK.mjs";
1
+ import { Wt as CheckpointRejected, cn as ThreadStoreFailure, on as ThreadStore } from "../Records-BIiRLqlz.mjs";
2
2
  import { Effect, Schema } from "effect";
3
3
  //#region src/durable/ThreadStoreConformance.d.ts
4
4
  declare const ThreadStoreConformanceViolation_base: Schema.Class<ThreadStoreConformanceViolation, Schema.TaggedStruct<"ThreadStoreConformanceViolation", {
@@ -1,5 +1,5 @@
1
1
  import { RunId, SubmissionId, ThreadId } from "../core/Identifiers.mjs";
2
- import { D as ProducerId, E as ProducerEpoch, O as RecordEnvelope, i as BatchId, k as RecordId, m as DeploymentId, nt as UserInputRecorded, o as CanonicalBatch, u as CanonicalSequence } from "../Records-BAutSSnJ.mjs";
2
+ import { D as ProducerId, E as ProducerEpoch, O as RecordEnvelope, i as BatchId, it as UserInputRecorded, k as RecordId, m as DeploymentId, o as CanonicalBatch, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
3
3
  import { EMPTY_TAIL_DIGEST } from "./Digest.mjs";
4
4
  import { AppendConflict, CheckpointRejected, FenceRejected, FencedAppendRequest, LoadCheckpointRequest, SaveCheckpointRequest, ThreadCheckpoint, ThreadExportRequest, ThreadMaterialization, ThreadNotMaterialized, ThreadObservation, ThreadRead, ThreadStore, ThreadTailRequest } from "./ThreadStore.mjs";
5
5
  import { DateTime, Effect, Option, Schema, Stream } from "effect";
@@ -1,2 +1,2 @@
1
- import { a as ReconciliationSafeToRetry, c as ToolReconcilerError, i as ReconciliationNeverStarted, n as ReconciliationCompleted, o as ReconciliationUncertain, r as ReconciliationDecision, s as ToolReconciler, t as PreparedToolCallEvidence } from "../ToolReconciler-DQVaJfpE.mjs";
1
+ import { a as ReconciliationSafeToRetry, c as ToolReconcilerError, i as ReconciliationNeverStarted, n as ReconciliationCompleted, o as ReconciliationUncertain, r as ReconciliationDecision, s as ToolReconciler, t as PreparedToolCallEvidence } from "../ToolReconciler-BmVRAHKs.mjs";
2
2
  export { PreparedToolCallEvidence, ReconciliationCompleted, ReconciliationDecision, ReconciliationNeverStarted, ReconciliationSafeToRetry, ReconciliationUncertain, ToolReconciler, ToolReconcilerError };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { RunId, SubmissionId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
3
- import { T as PersistedJson, X as ToolCallPrepared, h as Digest } from "../Records-BAutSSnJ.mjs";
3
+ import { T as PersistedJson, X as ToolCallPrepared, h as Digest } from "../Records-DR1xtbXY.mjs";
4
4
  import { Context, Effect, Layer, Schema } from "effect";
5
5
  //#region src/durable/ToolReconciler.ts
6
6
  var ToolReconciler_exports = /* @__PURE__ */ __exportAll({
@@ -27,9 +27,12 @@ var PreparedToolCallEvidence = class extends Schema.Class("@effect-agent/thread/
27
27
  toolCallId: ToolCallId,
28
28
  toolName: ToolCallPrepared.fields.toolName,
29
29
  parameters: PersistedJson,
30
- parametersDigest: Digest
30
+ parametersDigest: Digest,
31
+ executionKind: ToolCallPrepared.fields.executionKind,
32
+ executionClass: ToolCallPrepared.fields.executionClass,
33
+ replay: ToolCallPrepared.fields.replay
31
34
  }) {};
32
- /** Proof that the external execution never started: the call may re-execute on resume. */
35
+ /** Proof of nonexecution: resume the original operation or report it unavailable. */
33
36
  var ReconciliationNeverStarted = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationNeverStarted")("NeverStarted", {}) {};
34
37
  /**
35
38
  * Proof that the external execution completed: `result` is the recovered supplier truth, which
@@ -39,7 +42,7 @@ var ReconciliationCompleted = class extends Schema.TaggedClass("@effect-agent/th
39
42
  result: PersistedJson,
40
43
  isFailure: Schema.Boolean
41
44
  }) {};
42
- /** The call is safe to repeat under a stable external idempotency contract. */
45
+ /** Only the original operation, identity and parameters may repeat under supported semantics. */
43
46
  var ReconciliationSafeToRetry = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationSafeToRetry")("SafeToRetry", {}) {};
44
47
  /** No proof either way: the outcome is Unknown and requires authorized resolution (DUR-017). */
45
48
  var ReconciliationUncertain = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationUncertain")("Uncertain", { reason: Schema.String }) {};
@@ -47,7 +50,8 @@ var ReconciliationUncertain = class extends Schema.TaggedClass("@effect-agent/th
47
50
  * What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call
48
51
  * (durability §10): execution never started, execution completed with a recoverable result,
49
52
  * execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine
50
- * never manufactures an error result and continues.
53
+ * never invents an external result. Proven nonexecution can close a retired operation with
54
+ * an explicit not-executed result; uncertainty stays parked.
51
55
  */
52
56
  const ReconciliationDecision = Schema.Union([
53
57
  ReconciliationNeverStarted,
@@ -1 +1 @@
1
- {"version":3,"file":"ToolReconciler.mjs","names":[],"sources":["../../src/durable/ToolReconciler.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { ThreadId, RunId, SubmissionId, ToolCallId } from \"../core/Identifiers.ts\";\nimport { Digest, PersistedJson, ToolCallPrepared } from \"./Records.ts\";\n\n/**\n * Everything a reconciliation policy can consult about one prepared-but-unsettled ordinary Tool\n * Call (durability §10): deterministic identities for supplier-side lookup plus the exact\n * Schema-encoded parameters and their digest. Built from the canonical `ToolCallPrepared` record\n * and the owning Submission's identities — never from in-memory Attempt state.\n */\nexport class PreparedToolCallEvidence extends Schema.Class<PreparedToolCallEvidence>(\n \"@effect-agent/thread/PreparedToolCallEvidence\",\n)({\n threadId: ThreadId,\n submissionId: SubmissionId,\n runId: RunId,\n turn: ToolCallPrepared.fields.turn,\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n parameters: PersistedJson,\n parametersDigest: Digest,\n}) {}\n\n/** Proof that the external execution never started: the call may re-execute on resume. */\nexport class ReconciliationNeverStarted extends Schema.TaggedClass<ReconciliationNeverStarted>(\n \"@effect-agent/thread/ReconciliationNeverStarted\",\n)(\"NeverStarted\", {}) {}\n\n/**\n * Proof that the external execution completed: `result` is the recovered supplier truth, which\n * becomes canonical (`ToolCallSettled` + `ToolCallResolved`) WITHOUT executing anything.\n */\nexport class ReconciliationCompleted extends Schema.TaggedClass<ReconciliationCompleted>(\n \"@effect-agent/thread/ReconciliationCompleted\",\n)(\"CompletedWithResult\", {\n result: PersistedJson,\n isFailure: Schema.Boolean,\n}) {}\n\n/** The call is safe to repeat under a stable external idempotency contract. */\nexport class ReconciliationSafeToRetry extends Schema.TaggedClass<ReconciliationSafeToRetry>(\n \"@effect-agent/thread/ReconciliationSafeToRetry\",\n)(\"SafeToRetry\", {}) {}\n\n/** No proof either way: the outcome is Unknown and requires authorized resolution (DUR-017). */\nexport class ReconciliationUncertain extends Schema.TaggedClass<ReconciliationUncertain>(\n \"@effect-agent/thread/ReconciliationUncertain\",\n)(\"Uncertain\", {\n reason: Schema.String,\n}) {}\n\n/**\n * What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call\n * (durability §10): execution never started, execution completed with a recoverable result,\n * execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine\n * never manufactures an error result and continues.\n */\nexport const ReconciliationDecision = Schema.Union([\n ReconciliationNeverStarted,\n ReconciliationCompleted,\n ReconciliationSafeToRetry,\n ReconciliationUncertain,\n]);\n\nexport type ReconciliationDecision = typeof ReconciliationDecision.Type;\n\n/** The reconciliation policy itself failed (supplier unreachable, corrupt lookup, ...). The\n * caller treats this as no proof: the call stays open and the pass may retry. */\nexport class ToolReconcilerError extends Schema.TaggedError<ToolReconcilerError>()(\n \"ToolReconcilerError\",\n {\n toolCallId: ToolCallId,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * Application-registered reconciliation policy consulted by recovery for every open ordinary\n * Tool Call before an Unknown Outcome is recorded (durability §10, DUR-009). A decision is a\n * claim about EXTERNAL truth — typically an idempotency-keyed supplier lookup — never a guess\n * from canonical state alone.\n *\n * `ToolReconciler.uncertain` is the fail-closed default (AGENTS rule 11): with no registered\n * policy, every open call stays Unknown and routes to the authorized DUR-017 resolution path.\n */\nexport class ToolReconciler extends Context.Service<\n ToolReconciler,\n {\n readonly reconcile: (\n evidence: PreparedToolCallEvidence,\n ) => Effect.Effect<ReconciliationDecision, ToolReconcilerError>;\n }\n>()(\"@effect-agent/thread/ToolReconciler\") {\n /** Fail-closed default: no proof is ever asserted, every open call stays Unknown. */\n static readonly uncertain: Layer.Layer<ToolReconciler> = Layer.succeed(this)({\n reconcile: () =>\n Effect.succeed(\n ReconciliationUncertain.make({\n reason: \"No reconciliation policy is registered; the outcome stays unknown\",\n }),\n ),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,IAAa,2BAAb,cAA8C,OAAO,MACnD,+CACF,CAAC,CAAC;CACA,UAAU;CACV,cAAc;CACd,OAAO;CACP,MAAM,iBAAiB,OAAO;CAC9B,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,YAAY;CACZ,kBAAkB;AACpB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,6BAAb,cAAgD,OAAO,YACrD,iDACF,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;AAMvB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,uBAAuB;CACvB,QAAQ;CACR,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,4BAAb,cAA+C,OAAO,YACpD,gDACF,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGtB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,aAAa,EACb,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;;;;;;;AAQJ,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;AACF,CAAC;;;AAMD,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,YAAY;CACZ,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;;;AAWH,IAAa,iBAAb,cAAoC,QAAQ,QAO1C,CAAC,CAAC,qCAAqC,CAAC,CAAC;;CAEzC,OAAgB,YAAyC,MAAM,QAAQ,IAAI,CAAC,CAAC,EAC3E,iBACE,OAAO,QACL,wBAAwB,KAAK,EAC3B,QAAQ,oEACV,CAAC,CACH,EACJ,CAAC;AACH"}
1
+ {"version":3,"file":"ToolReconciler.mjs","names":[],"sources":["../../src/durable/ToolReconciler.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { ThreadId, RunId, SubmissionId, ToolCallId } from \"../core/Identifiers.ts\";\nimport { Digest, PersistedJson, ToolCallPrepared } from \"./Records.ts\";\n\n/**\n * Everything a reconciliation policy can consult about one prepared-but-unsettled ordinary Tool\n * Call (durability §10): deterministic identities for supplier-side lookup plus the exact\n * Schema-encoded parameters and their digest. Built from the canonical `ToolCallPrepared` record\n * and the owning Submission's identities — never from in-memory Attempt state.\n */\nexport class PreparedToolCallEvidence extends Schema.Class<PreparedToolCallEvidence>(\n \"@effect-agent/thread/PreparedToolCallEvidence\",\n)({\n threadId: ThreadId,\n submissionId: SubmissionId,\n runId: RunId,\n turn: ToolCallPrepared.fields.turn,\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n parameters: PersistedJson,\n parametersDigest: Digest,\n executionKind: ToolCallPrepared.fields.executionKind,\n executionClass: ToolCallPrepared.fields.executionClass,\n replay: ToolCallPrepared.fields.replay,\n}) {}\n\n/** Proof of nonexecution: resume the original operation or report it unavailable. */\nexport class ReconciliationNeverStarted extends Schema.TaggedClass<ReconciliationNeverStarted>(\n \"@effect-agent/thread/ReconciliationNeverStarted\",\n)(\"NeverStarted\", {}) {}\n\n/**\n * Proof that the external execution completed: `result` is the recovered supplier truth, which\n * becomes canonical (`ToolCallSettled` + `ToolCallResolved`) WITHOUT executing anything.\n */\nexport class ReconciliationCompleted extends Schema.TaggedClass<ReconciliationCompleted>(\n \"@effect-agent/thread/ReconciliationCompleted\",\n)(\"CompletedWithResult\", {\n result: PersistedJson,\n isFailure: Schema.Boolean,\n}) {}\n\n/** Only the original operation, identity and parameters may repeat under supported semantics. */\nexport class ReconciliationSafeToRetry extends Schema.TaggedClass<ReconciliationSafeToRetry>(\n \"@effect-agent/thread/ReconciliationSafeToRetry\",\n)(\"SafeToRetry\", {}) {}\n\n/** No proof either way: the outcome is Unknown and requires authorized resolution (DUR-017). */\nexport class ReconciliationUncertain extends Schema.TaggedClass<ReconciliationUncertain>(\n \"@effect-agent/thread/ReconciliationUncertain\",\n)(\"Uncertain\", {\n reason: Schema.String,\n}) {}\n\n/**\n * What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call\n * (durability §10): execution never started, execution completed with a recoverable result,\n * execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine\n * never invents an external result. Proven nonexecution can close a retired operation with\n * an explicit not-executed result; uncertainty stays parked.\n */\nexport const ReconciliationDecision = Schema.Union([\n ReconciliationNeverStarted,\n ReconciliationCompleted,\n ReconciliationSafeToRetry,\n ReconciliationUncertain,\n]);\n\nexport type ReconciliationDecision = typeof ReconciliationDecision.Type;\n\n/** The reconciliation policy itself failed (supplier unreachable, corrupt lookup, ...). The\n * caller treats this as no proof: the call stays open and the pass may retry. */\nexport class ToolReconcilerError extends Schema.TaggedError<ToolReconcilerError>()(\n \"ToolReconcilerError\",\n {\n toolCallId: ToolCallId,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * Application-registered reconciliation policy consulted by recovery for every open ordinary\n * Tool Call before an Unknown Outcome is recorded (durability §10, DUR-009). A decision is a\n * claim about EXTERNAL truth — typically an idempotency-keyed supplier lookup — never a guess\n * from canonical state alone.\n *\n * `ToolReconciler.uncertain` is the fail-closed default (AGENTS rule 11): with no registered\n * policy, every open call stays Unknown and routes to the authorized DUR-017 resolution path.\n */\nexport class ToolReconciler extends Context.Service<\n ToolReconciler,\n {\n readonly reconcile: (\n evidence: PreparedToolCallEvidence,\n ) => Effect.Effect<ReconciliationDecision, ToolReconcilerError>;\n }\n>()(\"@effect-agent/thread/ToolReconciler\") {\n /** Fail-closed default: no proof is ever asserted, every open call stays Unknown. */\n static readonly uncertain: Layer.Layer<ToolReconciler> = Layer.succeed(this)({\n reconcile: () =>\n Effect.succeed(\n ReconciliationUncertain.make({\n reason: \"No reconciliation policy is registered; the outcome stays unknown\",\n }),\n ),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,IAAa,2BAAb,cAA8C,OAAO,MACnD,+CACF,CAAC,CAAC;CACA,UAAU;CACV,cAAc;CACd,OAAO;CACP,MAAM,iBAAiB,OAAO;CAC9B,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,YAAY;CACZ,kBAAkB;CAClB,eAAe,iBAAiB,OAAO;CACvC,gBAAgB,iBAAiB,OAAO;CACxC,QAAQ,iBAAiB,OAAO;AAClC,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,6BAAb,cAAgD,OAAO,YACrD,iDACF,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;AAMvB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,uBAAuB;CACvB,QAAQ;CACR,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,4BAAb,cAA+C,OAAO,YACpD,gDACF,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGtB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,aAAa,EACb,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;;;;;;;;AASJ,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;AACF,CAAC;;;AAMD,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,YAAY;CACZ,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;;;AAWH,IAAa,iBAAb,cAAoC,QAAQ,QAO1C,CAAC,CAAC,qCAAqC,CAAC,CAAC;;CAEzC,OAAgB,YAAyC,MAAM,QAAQ,IAAI,CAAC,CAAC,EAC3E,iBACE,OAAO,QACL,wBAAwB,KAAK,EAC3B,QAAQ,oEACV,CAAC,CACH,EACJ,CAAC;AACH"}
@@ -4,7 +4,7 @@ import { r as Principal } from "../Receipt-BAHyigAF.mjs";
4
4
  import { t as AgentPolicy } from "../AgentPolicy-BqDoSXO6.mjs";
5
5
  import { r as AnyDefinition } from "../Agent-CM6JubNX.mjs";
6
6
  import { a as WorkerError, c as WorkerRef, u as WorkerSource } from "../Worker--j87JI__.mjs";
7
- import { O as PersistedJson, _ as Digest, h as DefinitionDigests, lt as WorkerOrigin, no as SubmissionSnapshot } from "../Records-CV49DgQK.mjs";
7
+ import { O as PersistedJson, _ as Digest, dt as WorkerOrigin, h as DefinitionDigests, to as SubmissionSnapshot } from "../Records-BIiRLqlz.mjs";
8
8
  import { Context, Effect, Option, Schema } from "effect";
9
9
  declare namespace WorkerHost_d_exports {
10
10
  export { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizationRequest, WorkerHostAuthorizer, WorkerHostConfig, WorkerHostLimits, WorkerPolicyResolver, WorkerPolicySource, WorkerPolicyTarget };
@@ -1,2 +1,2 @@
1
- import { A as start, C as decodeFinalOutput, D as renderInputPrompt, E as projectCompletionOutput, F as withTerminalDefectEvent, M as stream, N as streamUnknown, O as run, P as streamWithUsageAccountingUnknown, S as ToolCallWaiting, T as projectCompletionFromToolOutput, _ as SubagentDurability, a as AgentResultSchema, b as SubagentDurabilityError, c as AgentSpawner, d as DetachedRun, f as EngineProvidedToolServices, g as SpawnedChildRun, h as SpawnRunOptions, i as AgentResult, j as startUnknown, k as runUnknown, l as AgentSpawnerParent, m as SpawnDelegation, n as AgentChildPending, o as AgentRuntimeFailure, p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements, u as AgentSpawnerService, v as SubagentDurabilityDurable, w as encodeRunDisposition, x as SubagentDurabilityService, y as SubagentDurabilityEphemeral } from "../AgentRuntime-B64362Id.mjs";
1
+ import { A as start, C as decodeFinalOutput, D as renderInputPrompt, E as projectCompletionOutput, F as withTerminalDefectEvent, M as stream, N as streamUnknown, O as run, P as streamWithUsageAccountingUnknown, S as ToolCallWaiting, T as projectCompletionFromToolOutput, _ as SubagentDurability, a as AgentResultSchema, b as SubagentDurabilityError, c as AgentSpawner, d as DetachedRun, f as EngineProvidedToolServices, g as SpawnedChildRun, h as SpawnRunOptions, i as AgentResult, j as startUnknown, k as runUnknown, l as AgentSpawnerParent, m as SpawnDelegation, n as AgentChildPending, o as AgentRuntimeFailure, p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements, u as AgentSpawnerService, v as SubagentDurabilityDurable, w as encodeRunDisposition, x as SubagentDurabilityService, y as SubagentDurabilityEphemeral } from "../AgentRuntime-BMzrJos6.mjs";
2
2
  export { AgentChildPending, type AgentCompletionProjectionRequirements, type AgentResult, AgentResultSchema, type AgentRuntimeFailure, type AgentRuntimeRequirements, AgentSpawner, type AgentSpawnerParent, type AgentSpawnerService, type DetachedRun, type EngineProvidedToolServices, type RuntimeBinding, type SpawnDelegation, type SpawnRunOptions, type SpawnedChildRun, SubagentDurability, type SubagentDurabilityDurable, type SubagentDurabilityEphemeral, SubagentDurabilityError, type SubagentDurabilityService, ToolCallWaiting, decodeFinalOutput, encodeRunDisposition, projectCompletionFromToolOutput, projectCompletionOutput, renderInputPrompt, run, runUnknown, start, startUnknown, stream, streamUnknown, streamWithUsageAccountingUnknown, withTerminalDefectEvent };
@@ -1,2 +1,2 @@
1
- import { _ as stream, a as SubagentDurability, b as withTerminalDefectEvent, c as decodeFinalOutput, d as projectCompletionOutput, f as renderInputPrompt, g as startUnknown, h as start, i as AgentSpawner, l as encodeRunDisposition, m as runUnknown, n as AgentChildPending, o as SubagentDurabilityError, p as run, r as AgentResultSchema, s as ToolCallWaiting, u as projectCompletionFromToolOutput, v as streamUnknown, y as streamWithUsageAccountingUnknown } from "../AgentRuntime-Cdvqw7l_.mjs";
1
+ import { _ as stream, a as SubagentDurability, b as withTerminalDefectEvent, c as decodeFinalOutput, d as projectCompletionOutput, f as renderInputPrompt, g as startUnknown, h as start, i as AgentSpawner, l as encodeRunDisposition, m as runUnknown, n as AgentChildPending, o as SubagentDurabilityError, p as run, r as AgentResultSchema, s as ToolCallWaiting, u as projectCompletionFromToolOutput, v as streamUnknown, y as streamWithUsageAccountingUnknown } from "../AgentRuntime-BWOnNc0d.mjs";
2
2
  export { AgentChildPending, AgentResultSchema, AgentSpawner, SubagentDurability, SubagentDurabilityError, ToolCallWaiting, decodeFinalOutput, encodeRunDisposition, projectCompletionFromToolOutput, projectCompletionOutput, renderInputPrompt, run, runUnknown, start, startUnknown, stream, streamUnknown, streamWithUsageAccountingUnknown, withTerminalDefectEvent };
@@ -1,2 +1,2 @@
1
- import { $ as RunTurnResponseCommit, A as RunInputCommand, B as RunSubagentChildIdentity, C as RunContextPreparationPassthrough, D as RunCostEstimateValue, E as RunCostEstimateRequest, G as RunToolAuthorization, H as RunSubagentEstablishRequest, I as RunResumeUsage, J as RunToolAuthorizationRequest, K as RunToolAuthorizationDecision, L as RunResumeUsageSchema, M as RunOptions, N as RunOptionsError, O as RunCostEstimator, P as RunOptionsRequirements, Q as RunTransientContextHook, R as RunSchedulingHook, S as RunContextPreparationError, T as RunCostEstimate, U as RunSubagentHook, V as RunSubagentDigests, W as RunSubagentJoinRequest, X as RunToolFailureObserver, Y as RunToolCallDescriptor, Z as RunToolScheduling, _ as RunBudgetHook, a as ChildEstablishWaiting, at as RunUsageDelta, b as RunContextHook, c as ModelToolFailure, d as ProgrammaticPreflightFailure, et as RunTurnResume, f as ProgrammaticToolFailure, g as RunApprovalRequest, h as RunApprovalHook, i as ChildEstablishStatus, it as RunTurnUsage, j as RunInputHook, k as RunDurabilityHook, l as ModelUsageAccounting, m as RunApprovalDecision, n as ChildEstablishDenied, nt as RunTurnResumeSettledCall, o as CommandDrainPolicy, ot as ToolFailureObservation, p as ResolvedModelCall, q as RunToolAuthorizationHook, r as ChildEstablishSettled, rt as RunTurnResumeSettledCallSchema, s as CurrentToolFailureObserver, st as toolFailureObserverLayer, t as AgentUpdateAcceptance, tt as RunTurnResumeCall, u as PreparedRunContext, v as RunBufferLimits, w as RunContextRequest, x as RunContextPreparation, y as RunCompactionCommit, z as RunSchedulingOverride } from "../RunOptions-Clj8cLsp.mjs";
1
+ import { $ as RunTurnResponseCommit, A as RunInputCommand, B as RunSubagentChildIdentity, C as RunContextPreparationPassthrough, D as RunCostEstimateValue, E as RunCostEstimateRequest, G as RunToolAuthorization, H as RunSubagentEstablishRequest, I as RunResumeUsage, J as RunToolAuthorizationRequest, K as RunToolAuthorizationDecision, L as RunResumeUsageSchema, M as RunOptions, N as RunOptionsError, O as RunCostEstimator, P as RunOptionsRequirements, Q as RunTransientContextHook, R as RunSchedulingHook, S as RunContextPreparationError, T as RunCostEstimate, U as RunSubagentHook, V as RunSubagentDigests, W as RunSubagentJoinRequest, X as RunToolFailureObserver, Y as RunToolCallDescriptor, Z as RunToolScheduling, _ as RunBudgetHook, a as ChildEstablishWaiting, at as RunUsageDelta, b as RunContextHook, c as ModelToolFailure, d as ProgrammaticPreflightFailure, et as RunTurnResume, f as ProgrammaticToolFailure, g as RunApprovalRequest, h as RunApprovalHook, i as ChildEstablishStatus, it as RunTurnUsage, j as RunInputHook, k as RunDurabilityHook, l as ModelUsageAccounting, m as RunApprovalDecision, n as ChildEstablishDenied, nt as RunTurnResumeSettledCall, o as CommandDrainPolicy, ot as ToolFailureObservation, p as ResolvedModelCall, q as RunToolAuthorizationHook, r as ChildEstablishSettled, rt as RunTurnResumeSettledCallSchema, s as CurrentToolFailureObserver, st as toolFailureObserverLayer, t as AgentUpdateAcceptance, tt as RunTurnResumeCall, u as PreparedRunContext, v as RunBufferLimits, w as RunContextRequest, x as RunContextPreparation, y as RunCompactionCommit, z as RunSchedulingOverride } from "../RunOptions-Bruk54SE.mjs";
2
2
  export { AgentUpdateAcceptance, ChildEstablishDenied, ChildEstablishSettled, ChildEstablishStatus, ChildEstablishWaiting, CommandDrainPolicy, CurrentToolFailureObserver, ModelToolFailure, ModelUsageAccounting, PreparedRunContext, ProgrammaticPreflightFailure, ProgrammaticToolFailure, ResolvedModelCall, RunApprovalDecision, RunApprovalHook, RunApprovalRequest, RunBudgetHook, RunBufferLimits, RunCompactionCommit, RunContextHook, RunContextPreparation, RunContextPreparationError, RunContextPreparationPassthrough, RunContextRequest, RunCostEstimate, RunCostEstimateRequest, RunCostEstimateValue, RunCostEstimator, RunDurabilityHook, RunInputCommand, RunInputHook, RunOptions, RunOptionsError, RunOptionsRequirements, RunResumeUsage, RunResumeUsageSchema, RunSchedulingHook, RunSchedulingOverride, RunSubagentChildIdentity, RunSubagentDigests, RunSubagentEstablishRequest, RunSubagentHook, RunSubagentJoinRequest, RunToolAuthorization, RunToolAuthorizationDecision, RunToolAuthorizationHook, RunToolAuthorizationRequest, RunToolCallDescriptor, RunToolFailureObserver, RunToolScheduling, RunTransientContextHook, RunTurnResponseCommit, RunTurnResume, RunTurnResumeCall, RunTurnResumeSettledCall, RunTurnResumeSettledCallSchema, RunTurnUsage, RunUsageDelta, ToolFailureObservation, toolFailureObserverLayer };