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,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { SettlementId, SubmissionId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
3
- import { X as ToolCallPrepared, z as SettlementOutcome } from "../Records-BAutSSnJ.mjs";
3
+ import { X as ToolCallPrepared, z as SettlementOutcome } from "../Records-DR1xtbXY.mjs";
4
4
  import { ChildReservationId, WaitingChild, submissionSettlementId } from "./SubmissionLedger.mjs";
5
5
  import { Effect, Schema } from "effect";
6
6
  //#region src/durable/Recovery.ts
@@ -51,8 +51,8 @@ var OpenToolCallEvidence = class extends Schema.Class("@effect-agent/thread/Open
51
51
  }) {};
52
52
  /**
53
53
  * A committed tool-declaring response with ZERO prepared and ZERO settled records for its Turn:
54
- * the provably-safe durability §15 window — no prepared records means no handler ran, so the
55
- * declared batch resumes without model re-invocation and without Unknown.
54
+ * the durability §15 batch-resume window. Mutation preparation has not committed; readonly
55
+ * handlers may already have run. The worker checks each unfinished operation before execution.
56
56
  */
57
57
  var DeclaredPendingBatchEvidence = class extends Schema.Class("@effect-agent/thread/DeclaredPendingBatchEvidence")({
58
58
  turn: ToolCallPrepared.fields.turn,
@@ -199,7 +199,7 @@ var MarkUnknown = class extends Schema.TaggedClass("@effect-agent/thread/MarkUnk
199
199
  openToolCallIds: Schema.Array(ToolCallId)
200
200
  }) {};
201
201
  /** A committed tool-declaring response has zero prepared and zero settled records: a worker
202
- * resumes the declared batch — no model re-invocation, no Unknown (durability §15). S2 also
202
+ * checks unfinished contracts and resumes the declared batch without model re-invocation. S2 also
203
203
  * routes an open delegation call WITHOUT establishment evidence here (spec §13 row 1): the
204
204
  * declared batch re-executes and the idempotent establishment converges on one child. */
205
205
  var ResumePendingToolBatch = class extends Schema.TaggedClass("@effect-agent/thread/ResumePendingToolBatch")("ResumePendingToolBatch", {
@@ -212,11 +212,11 @@ var AwaitApprovalDecision = class extends Schema.TaggedClass("@effect-agent/thre
212
212
  /** Every pending approval has a durable decision: a worker resumes the declared batch via the
213
213
  * batch-resume seam, appending the canonical `ToolApprovalDecided` records first. */
214
214
  var ResumeSuspended = class extends Schema.TaggedClass("@effect-agent/thread/ResumeSuspended")("ResumeSuspended", { submissionId: SubmissionId }) {};
215
- /** Unknown Outcomes lack covering resolutions: the lane stays blocked awaiting the authorized
215
+ /** Unknown Outcomes lack covering resolutions: this Submission stays parked awaiting the authorized
216
216
  * DUR-017 resolution path; the obligation stays visible, nothing replays. */
217
217
  var AwaitUnknownResolution = class extends Schema.TaggedClass("@effect-agent/thread/AwaitUnknownResolution")("AwaitUnknownResolution", { submissionId: SubmissionId }) {};
218
- /** Durable resolution intents cover every open call: apply them canonically
219
- * (`ToolCallResolved` + `ToolCallSettled` for recovered results) and reopen the lane. */
218
+ /** Durable resolution intents cover every open call: wake the original Submission when its
219
+ * required retry contract is supported. Canonical outcomes are applied by the next claim. */
220
220
  var ApplyUnknownResolutions = class extends Schema.TaggedClass("@effect-agent/thread/ApplyUnknownResolutions")("ApplyUnknownResolutions", { submissionId: SubmissionId }) {};
221
221
  /** `joining` without a canonical `input:{sid}` record: revert to `ready` — the input was never
222
222
  * consumed and will be delivered exactly once later (DUR-016). */
@@ -634,8 +634,8 @@ const classifyDelegationAbort = (submissionId, views) => {
634
634
  * ApplyJoinAccounting → CompleteChildAdmission → RepairSubagentStartLink →
635
635
  * AwaitChildAdmissionResolution → ResumePendingToolBatch (idempotent handler re-entry) →
636
636
  * EnsureWaitingForChild → ResumeWaitingParent → ReleaseOrphanChildReservation.
637
- * 10. declared-but-unprepared tool batch → ResumePendingToolBatch — no handler ran (no prepared
638
- * records), so the batch resumes with no model re-invocation and no Unknown (§15).
637
+ * 10. declared-but-unprepared tool batch → ResumePendingToolBatch — the worker checks original
638
+ * operation contracts; missing preparation proves no mutation dispatch, not readonly nonexecution (§15).
639
639
  * 11. `admitted` → a parent-linked Submission whose Thread lacks the canonical lineage
640
640
  * record defers (AwaitParentEstablishment: the parent's idempotent establishment
641
641
  * completes it); otherwise
@@ -1 +1 @@
1
- {"version":3,"file":"Recovery.mjs","names":[],"sources":["../../src/durable/Recovery.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\n\nimport { ThreadId, SettlementId, SubmissionId, ToolCallId } from \"../core/Identifiers.ts\";\nimport { SettlementOutcome, ToolCallPrepared } from \"./Records.ts\";\nimport {\n ChildReservationId,\n submissionSettlementId,\n WaitingChild,\n type ChildAttachmentSnapshot,\n type ChildBudgetReservationSnapshot,\n type RecoverySnapshot,\n} from \"./SubmissionLedger.ts\";\n\n/** One canonical `ToolCallPrepared` without a settling or resolving canonical record (DUR-009). */\nexport class OpenToolCallEvidence extends Schema.Class<OpenToolCallEvidence>(\n \"@effect-agent/thread/OpenToolCallEvidence\",\n)({\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n turn: ToolCallPrepared.fields.turn,\n}) {}\n\n/**\n * A committed tool-declaring response with ZERO prepared and ZERO settled records for its Turn:\n * the provably-safe durability §15 window — no prepared records means no handler ran, so the\n * declared batch resumes without model re-invocation and without Unknown.\n */\nexport class DeclaredPendingBatchEvidence extends Schema.Class<DeclaredPendingBatchEvidence>(\n \"@effect-agent/thread/DeclaredPendingBatchEvidence\",\n)({\n turn: ToolCallPrepared.fields.turn,\n callCount: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** One canonical `ToolApprovalRequested` without a canonical `ToolApprovalDecided`. */\nexport class PendingApprovalEvidence extends Schema.Class<PendingApprovalEvidence>(\n \"@effect-agent/thread/PendingApprovalEvidence\",\n)({\n toolCallId: ToolCallId,\n turn: ToolCallPrepared.fields.turn,\n}) {}\n\n/**\n * The authoritative tri-state admission answer recorded as pure classifier evidence (SUB-031):\n * the recovery pass queries `resolveAdmission` with the deterministic child idempotency key for\n * a requested-but-unstarted delegation call and records the result here. Absence of this field\n * means the lookup was not performed — the classifier treats that exactly like `indeterminate`\n * (fail-closed: only a proven `not-admitted` ever permits an admission attempt).\n */\nexport const DelegationAdmissionEvidence = Schema.Literals([\n \"not-admitted\",\n \"admitted\",\n \"indeterminate\",\n]);\n\nexport type DelegationAdmissionEvidence = typeof DelegationAdmissionEvidence.Type;\n\n/**\n * One prepared-without-outcome parent Tool Call that IS a delegation (plan §4.1), separated from\n * `openToolCalls` because its establishment protocol is idempotent by construction and must\n * NEVER be marked Unknown (spec §13 vs. DUR-009). Delegation detection is durable and\n * fail-closed: canonical preparation records carry the definition-owned execution kind;\n * child reservations and request records must agree with that classification. Names never\n * authorize replay, including in the pre-reservation window. The\n * `requested`/`started`/`joined` flags come from the parent-log canonical records; the child\n * identity fields are present exactly when those records (or the reservation attachment) carry\n * them.\n */\nexport class OpenDelegationCallEvidence extends Schema.Class<OpenDelegationCallEvidence>(\n \"@effect-agent/thread/OpenDelegationCallEvidence\",\n)({\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n turn: ToolCallPrepared.fields.turn,\n /** The canonical `SubagentRequested` record exists for this call. */\n requested: Schema.Boolean,\n /** The canonical `SubagentStarted` record exists for this call. */\n started: Schema.Boolean,\n /** The canonical `SubagentJoined` record exists for this call. */\n joined: Schema.Boolean,\n childThreadId: Schema.optionalKey(ThreadId),\n childSubmissionId: Schema.optionalKey(SubmissionId),\n admission: Schema.optionalKey(DelegationAdmissionEvidence),\n}) {}\n\n/**\n * Canonical-log facts about one Submission, read strongly consistently alongside the ledger\n * `RecoverySnapshot` (STORE-003). Canonical history wins over every ledger marker (DUR-015), so\n * the classifier consults these facts before trusting ledger state — with one deliberate Phase 5\n * inversion: a RECORDED terminal outcome now beats open tool calls, because a canonical\n * settlement is never revisited (DUR-002/DUR-015); the P4 rule that unknown-beats-settlement is\n * gone.\n *\n * `openToolCalls` is the DUR-009 seam: every `ToolCallPrepared` without a matching\n * `ToolCallSettled` or `ToolCallResolved`. S2 separates `openDelegationCalls` from it (plan\n * §4.1): a delegation's prepared-without-outcome state is provably replay-safe, so those calls\n * route through the Subagent recovery rows and never through `MarkUnknown`. Names and\n * operational reservation rows cannot upgrade ordinary classification. `joinedInputCovered`\n * implements the plan §2.5 prompt-coverage rule for the joined side: a joined input is covered\n * iff a later `ModelResponseRecorded` of the host Run exists after the `input:{sid}` record.\n * `hostSettlementOutcome` is the joined-side view of the host's canonical `SubmissionSettled`\n * record, present exactly when that record exists.\n */\nexport class RecoveryEvidence extends Schema.Class<RecoveryEvidence>(\n \"@effect-agent/thread/RecoveryEvidence\",\n)({\n /** The Thread exists in the ThreadStore. */\n threadMaterialized: Schema.Boolean,\n /** The deterministic canonical `UserInputRecorded` record (`input:{sid}`) is committed. */\n inputRecorded: Schema.Boolean,\n /**\n * The committed canonical `SubmissionSettled` outcome (`settlement:{sid}`). Present exactly\n * when the canonical settlement record exists, so the flag and the outcome cannot diverge.\n */\n recordedSettlementOutcome: Schema.optionalKey(SettlementOutcome),\n /** The deterministic canonical `AbortRequested` record (`abort:{sid}`) is committed. */\n abortRecorded: Schema.Boolean,\n /** Prepared ordinary Tool Calls without a canonical settled/resolved outcome (DUR-009). */\n openToolCalls: Schema.Array(OpenToolCallEvidence),\n /**\n * Delegation Tool Calls with an open parent-side obligation (plan §4.1), removed from\n * `openToolCalls`. Wire-required; construction alone defaults it so pre-S2 evidence\n * assemblers stay valid while the classifier's fail-closed detection still protects them.\n */\n openDelegationCalls: Schema.Array(OpenDelegationCallEvidence).pipe(\n Schema.withConstructorDefault(Effect.succeed([])),\n ),\n /** Only persisted orchestration classification authorizes idempotent host-operation replay. */\n openWorkerCalls: Schema.optionalKey(Schema.Array(OpenToolCallEvidence)),\n /** A declared-but-unprepared tool batch: response canonical, zero prepared, zero settled. */\n declaredPendingBatch: Schema.optionalKey(DeclaredPendingBatchEvidence),\n /** Canonically requested approvals without a canonical decision. */\n approvalsPending: Schema.Array(PendingApprovalEvidence),\n /** Joined-side prompt coverage (plan §2.5); `true` whenever the Submission is not joined. */\n joinedInputCovered: Schema.Boolean,\n /** Joined-side view of the host's canonical settlement record, when it exists. */\n hostSettlementOutcome: Schema.optionalKey(SettlementOutcome),\n /**\n * The Thread carries its canonical `SubagentLineageRecorded` record. Only\n * consulted for a parent-linked Submission: a child whose lineage is not yet canonical defers\n * its own materialization/readiness repair to the parent's idempotent establishment\n * (`AwaitParentEstablishment`). Defaults to `false` so an assembler that does not compute it\n * stays fail-closed: deferring is safe because the parent's establishment completes the child;\n * running a Turn before lineage is recorded would violate the child establishment ordering.\n */\n subagentLineageRecorded: Schema.Boolean.pipe(\n Schema.withConstructorDefault(Effect.succeed(false)),\n ),\n}) {}\n\n/** Ledger admission committed but the Thread is not durable: finish materialization,\n * append `ThreadCreated`, and mark readiness (crash between admit and materialize). */\nexport class CompleteMaterialization extends Schema.TaggedClass<CompleteMaterialization>(\n \"@effect-agent/thread/CompleteMaterialization\",\n)(\"CompleteMaterialization\", { submissionId: SubmissionId }) {}\n\n/** Thread durable but the readiness marker is missing: idempotent `markReady`. */\nexport class RepairReadiness extends Schema.TaggedClass<RepairReadiness>(\n \"@effect-agent/thread/RepairReadiness\",\n)(\"RepairReadiness\", { submissionId: SubmissionId }) {}\n\n/** No canonical input yet: append the deterministic `UserInputRecorded` record and mark it. */\nexport class ApplyInput extends Schema.TaggedClass<ApplyInput>(\"@effect-agent/thread/ApplyInput\")(\n \"ApplyInput\",\n { submissionId: SubmissionId },\n) {}\n\n/** Canonical input exists but the ledger marker was lost: repair the marker only (DUR-015). */\nexport class RepairInputMarker extends Schema.TaggedClass<RepairInputMarker>(\n \"@effect-agent/thread/RepairInputMarker\",\n)(\"RepairInputMarker\", { submissionId: SubmissionId }) {}\n\n/** Input applied and no terminal work reserved: a worker resumes the Run from the last committed\n * Turn boundary (D6; the model may be re-invoked, duplicate cost is observable — the resuming\n * worker appends `ModelResponseInterrupted` when superseding a prior owner, durability §9). */\nexport class ResumeFromTurnBoundary extends Schema.TaggedClass<ResumeFromTurnBoundary>(\n \"@effect-agent/thread/ResumeFromTurnBoundary\",\n)(\"ResumeFromTurnBoundary\", { submissionId: SubmissionId }) {}\n\n/** A settlement is reserved but not canonical: append the EXACT reserved record, then finalize. */\nexport class AppendReservedSettlement extends Schema.TaggedClass<AppendReservedSettlement>(\n \"@effect-agent/thread/AppendReservedSettlement\",\n)(\"AppendReservedSettlement\", {\n submissionId: SubmissionId,\n settlementId: SettlementId,\n outcome: SettlementOutcome,\n}) {}\n\n/** The canonical settlement record exists: rebuild/finalize the ledger from history and never\n * rewrite history from the cached ledger status (DUR-011, DUR-015). */\nexport class FinalizeLedgerFromHistory extends Schema.TaggedClass<FinalizeLedgerFromHistory>(\n \"@effect-agent/thread/FinalizeLedgerFromHistory\",\n)(\"FinalizeLedgerFromHistory\", {\n submissionId: SubmissionId,\n settlementId: SettlementId,\n outcome: SettlementOutcome,\n}) {}\n\n/** A durable abort intent exists, no terminal outcome is reserved, and no attached-child\n * obligation remains open: settle aborted (DUR-012). The executor first appends\n * `ToolCallUnknown` audit records for any open ordinary calls — abort settles the obligation but\n * never asserts external rollback (durability §13). */\nexport class SettleAborted extends Schema.TaggedClass<SettleAborted>(\n \"@effect-agent/thread/SettleAborted\",\n)(\"SettleAborted\", { submissionId: SubmissionId }) {}\n\n/** Prepared ordinary Tool Calls have no canonical outcome: the executor reconciles each open\n * call (recovered result / never-started / safe-retry) and marks the remainder Unknown — never\n * an automatic replay (DUR-009/DUR-017). Delegation calls are excluded: their establishment is\n * idempotent by construction and routes through the Subagent rows instead (plan §4.3). */\nexport class MarkUnknown extends Schema.TaggedClass<MarkUnknown>(\n \"@effect-agent/thread/MarkUnknown\",\n)(\"MarkUnknown\", {\n submissionId: SubmissionId,\n reason: Schema.String,\n openToolCallIds: Schema.Array(ToolCallId),\n}) {}\n\n/** A committed tool-declaring response has zero prepared and zero settled records: a worker\n * resumes the declared batch — no model re-invocation, no Unknown (durability §15). S2 also\n * routes an open delegation call WITHOUT establishment evidence here (spec §13 row 1): the\n * declared batch re-executes and the idempotent establishment converges on one child. */\nexport class ResumePendingToolBatch extends Schema.TaggedClass<ResumePendingToolBatch>(\n \"@effect-agent/thread/ResumePendingToolBatch\",\n)(\"ResumePendingToolBatch\", {\n submissionId: SubmissionId,\n turn: DeclaredPendingBatchEvidence.fields.turn,\n}) {}\n\n/** Canonically requested approvals lack decisions: the lane waits durably (the executor repairs\n * the ledger suspension from history when the suspend transition itself was lost). */\nexport class AwaitApprovalDecision extends Schema.TaggedClass<AwaitApprovalDecision>(\n \"@effect-agent/thread/AwaitApprovalDecision\",\n)(\"AwaitApprovalDecision\", { submissionId: SubmissionId }) {}\n\n/** Every pending approval has a durable decision: a worker resumes the declared batch via the\n * batch-resume seam, appending the canonical `ToolApprovalDecided` records first. */\nexport class ResumeSuspended extends Schema.TaggedClass<ResumeSuspended>(\n \"@effect-agent/thread/ResumeSuspended\",\n)(\"ResumeSuspended\", { submissionId: SubmissionId }) {}\n\n/** Unknown Outcomes lack covering resolutions: the lane stays blocked awaiting the authorized\n * DUR-017 resolution path; the obligation stays visible, nothing replays. */\nexport class AwaitUnknownResolution extends Schema.TaggedClass<AwaitUnknownResolution>(\n \"@effect-agent/thread/AwaitUnknownResolution\",\n)(\"AwaitUnknownResolution\", { submissionId: SubmissionId }) {}\n\n/** Durable resolution intents cover every open call: apply them canonically\n * (`ToolCallResolved` + `ToolCallSettled` for recovered results) and reopen the lane. */\nexport class ApplyUnknownResolutions extends Schema.TaggedClass<ApplyUnknownResolutions>(\n \"@effect-agent/thread/ApplyUnknownResolutions\",\n)(\"ApplyUnknownResolutions\", { submissionId: SubmissionId }) {}\n\n/** `joining` without a canonical `input:{sid}` record: revert to `ready` — the input was never\n * consumed and will be delivered exactly once later (DUR-016). */\nexport class RevertJoining extends Schema.TaggedClass<RevertJoining>(\n \"@effect-agent/thread/RevertJoining\",\n)(\"RevertJoining\", { submissionId: SubmissionId }) {}\n\n/** The canonical input exists but the `joined` marker was lost: repair the marker only, exactly\n * like `RepairInputMarker` (DUR-015/DUR-016); the input reattaches, never duplicates. */\nexport class RepairJoinMarker extends Schema.TaggedClass<RepairJoinMarker>(\n \"@effect-agent/thread/RepairJoinMarker\",\n)(\"RepairJoinMarker\", { submissionId: SubmissionId }) {}\n\n/** The host Run settled canonically: settle this joined Submission with the host outcome\n * (each joined Submission is owed its own settlement, DUR-002). */\nexport class SettleJoinedWithHost extends Schema.TaggedClass<SettleJoinedWithHost>(\n \"@effect-agent/thread/SettleJoinedWithHost\",\n)(\"SettleJoinedWithHost\", {\n submissionId: SubmissionId,\n outcome: SettlementOutcome,\n}) {}\n\n/** The Submission is `joined` and its host Run is still live: nothing to repair — the input\n * reattaches through the host's resume and the Submission settles with the host. */\nexport class AwaitHostSettlement extends Schema.TaggedClass<AwaitHostSettlement>(\n \"@effect-agent/thread/AwaitHostSettlement\",\n)(\"AwaitHostSettlement\", {\n submissionId: SubmissionId,\n hostSubmissionId: Schema.optionalKey(SubmissionId),\n}) {}\n\n/** A canonical `SubagentRequested` exists and the authoritative admission lookup proved\n * `notAdmitted`: idempotently admit the intended child from the canonical request payload — it\n * carries the encoded child input (D3), the intended child identity, and every digest — then\n * materialize the child Thread, append its immutable lineage, and mark it ready. No live\n * delegation handler is required (spec §13, SUB-016/SUB-031). */\nexport class CompleteChildAdmission extends Schema.TaggedClass<CompleteChildAdmission>(\n \"@effect-agent/thread/CompleteChildAdmission\",\n)(\"CompleteChildAdmission\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** A canonical `SubagentRequested` exists but the authoritative admission lookup answered\n * `indeterminate` — or was not (yet) performed: wait and retry the authoritative owner directly.\n * Absence from a projection is never proof of absence and a second admission NEVER occurs\n * (spec §12, SUB-031). */\nexport class AwaitChildAdmissionResolution extends Schema.TaggedClass<AwaitChildAdmissionResolution>(\n \"@effect-agent/thread/AwaitChildAdmissionResolution\",\n)(\"AwaitChildAdmissionResolution\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** The child Submission is admitted but the parent's `SubagentStarted` link is missing (or its\n * reservation attachment was lost): resolve the SAME child by its deterministic idempotency key\n * and append the exact deterministic start record, then attach the child to its reservation —\n * the same Receipt on every replay (spec §13, SUB-016/SUB-017). */\nexport class RepairSubagentStartLink extends Schema.TaggedClass<RepairSubagentStartLink>(\n \"@effect-agent/thread/RepairSubagentStartLink\",\n)(\"RepairSubagentStartLink\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** Children are established and at least one is nonterminal while the parent lane is NOT\n * durably suspended: restore the `waitingForChild` suspension so the lane holds no worker\n * permit while each child runs on its own lane. Recovery reattaches the one existing child and\n * NEVER spawns a replacement (spec §13, SUB-018/SUB-030). */\nexport class EnsureWaitingForChild extends Schema.TaggedClass<EnsureWaitingForChild>(\n \"@effect-agent/thread/EnsureWaitingForChild\",\n)(\"EnsureWaitingForChild\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** The parent is durably suspended `WaitingForChild` and at least one listed child is not yet\n * provably settled: the lane stays dormant and consumes no permit; the child's Settlement wakes\n * it durably (spec §12 step 10). An unresolved ordinary Tool inside a child keeps the parent\n * here honestly — the obligation stays visible and aged, nothing is fabricated (SUB-021). */\nexport class AwaitChildSettlement extends Schema.TaggedClass<AwaitChildSettlement>(\n \"@effect-agent/thread/AwaitChildSettlement\",\n)(\"AwaitChildSettlement\", { submissionId: SubmissionId }) {}\n\n/** Every relevant child is provably settled but the parent has not joined (legacy data, or a\n * canonical settlement whose idempotent wake still needs replay): record/replay the durable wake\n * so a claiming worker resumes the declared batch and joins each child's canonical Settlement —\n * the join itself needs the parent Binding and is deferred to that worker (spec §13). */\nexport class ResumeWaitingParent extends Schema.TaggedClass<ResumeWaitingParent>(\n \"@effect-agent/thread/ResumeWaitingParent\",\n)(\"ResumeWaitingParent\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** The canonical `SubagentJoined` record exists but the reservation release is incomplete:\n * replay `beginChildBudgetRelease` with the accounting decision FROM the canonical record, then\n * apply `releaseChildBudget` — budget stays unavailable until repair, never available twice\n * (spec §12 join step 6, DUR-015). */\nexport class ApplyJoinAccounting extends Schema.TaggedClass<ApplyJoinAccounting>(\n \"@effect-agent/thread/ApplyJoinAccounting\",\n)(\"ApplyJoinAccounting\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n reservationId: ChildReservationId,\n}) {}\n\n/** Parent abort is canonical while attached children are nonterminal: idempotently issue each\n * child's durable abort command and keep the parent waiting for the joins —\n * request-abort-and-join is the ONLY close behavior; the replayed command returns the recorded\n * child intent unchanged, so the intent row IS the propagation marker (spec §13.1, SUB-022,\n * DUR-012). */\nexport class PropagateChildAbort extends Schema.TaggedClass<PropagateChildAbort>(\n \"@effect-agent/thread/PropagateChildAbort\",\n)(\"PropagateChildAbort\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** A child budget reservation can no longer bind a child — its request is absent with no\n * resumable batch, or the parent is aborting and the child provably never admitted: freeze the\n * deterministic zero-consumed accounting decision and release the unused allocation exactly\n * once (spec §13/§14: \"releases the reservation exactly once\"). */\nexport class ReleaseOrphanChildReservation extends Schema.TaggedClass<ReleaseOrphanChildReservation>(\n \"@effect-agent/thread/ReleaseOrphanChildReservation\",\n)(\"ReleaseOrphanChildReservation\", {\n submissionId: SubmissionId,\n reservationIds: Schema.NonEmptyArray(ChildReservationId),\n}) {}\n\n/**\n * A parent-linked `admitted` Submission whose Thread lacks the canonical\n * `SubagentLineageRecorded` record: the child lane DEFERS its own materialization/readiness\n * repair — the parent's idempotent establishment (admit → materialize → lineage → ready)\n * completes it, so a child never runs a Turn before its lineage record is canonical.\n * This preserves the child establishment ordering. It is ordering/liveness hygiene, not a\n * safety repair — the join already fails closed without lineage (SUB-019).\n */\nexport class AwaitParentEstablishment extends Schema.TaggedClass<AwaitParentEstablishment>(\n \"@effect-agent/thread/AwaitParentEstablishment\",\n)(\"AwaitParentEstablishment\", {\n submissionId: SubmissionId,\n parentSubmissionId: SubmissionId,\n parentToolCallId: ToolCallId,\n}) {}\n\n/** The Submission is settled; nothing is owed. */\nexport class NoAction extends Schema.TaggedClass<NoAction>(\"@effect-agent/thread/NoAction\")(\n \"NoAction\",\n { submissionId: SubmissionId },\n) {}\n\n/** The executable recovery decision table's output alphabet (plan §Recovery classifier). */\nexport const RecoveryDecision = Schema.Union([\n CompleteMaterialization,\n RepairReadiness,\n ApplyInput,\n RepairInputMarker,\n ResumeFromTurnBoundary,\n AppendReservedSettlement,\n FinalizeLedgerFromHistory,\n SettleAborted,\n MarkUnknown,\n ResumePendingToolBatch,\n AwaitApprovalDecision,\n ResumeSuspended,\n AwaitUnknownResolution,\n ApplyUnknownResolutions,\n RevertJoining,\n RepairJoinMarker,\n SettleJoinedWithHost,\n AwaitHostSettlement,\n CompleteChildAdmission,\n AwaitChildAdmissionResolution,\n RepairSubagentStartLink,\n EnsureWaitingForChild,\n AwaitChildSettlement,\n ResumeWaitingParent,\n ApplyJoinAccounting,\n PropagateChildAbort,\n ReleaseOrphanChildReservation,\n AwaitParentEstablishment,\n NoAction,\n]);\n\nexport type RecoveryDecision = typeof RecoveryDecision.Type;\n\n/**\n * The classifier's merged per-call view of one delegation Tool Call: canonical parent-log flags\n * from the evidence, the reservation row, and the child attachment from the ledger snapshot.\n */\ninterface DelegationCallView {\n readonly toolCallId: ToolCallId;\n turn: number | undefined;\n /** A prepared-without-outcome record exists, so the declared batch is worker-resumable. */\n open: boolean;\n requested: boolean;\n started: boolean;\n joined: boolean;\n admission: DelegationAdmissionEvidence | undefined;\n childSubmissionId: SubmissionId | undefined;\n reservation: ChildBudgetReservationSnapshot | undefined;\n attachment: ChildAttachmentSnapshot | undefined;\n}\n\n/** The attachment proves the child's canonical Settlement exists. */\nconst isTerminalAttachment = (attachment: ChildAttachmentSnapshot): boolean =>\n attachment.childState === \"settled\" || attachment.childOutcome !== undefined;\n\n/**\n * Merge every durable delegation-detection source into per-call views (plan §4.1): the\n * explicitly classified `openDelegationCalls`, reservation rows and child attachments.\n * Reservations may need cleanup, but never upgrade an ordinary call into a replayable delegation.\n */\nconst delegationViewsOf = (\n snapshot: RecoverySnapshot,\n evidence: RecoveryEvidence,\n): Array<DelegationCallView> => {\n const views = new Map<ToolCallId, DelegationCallView>();\n\n const ensure = (toolCallId: ToolCallId): DelegationCallView => {\n const existing = views.get(toolCallId);\n\n if (existing !== undefined) return existing;\n\n const created: DelegationCallView = {\n toolCallId,\n turn: undefined,\n open: false,\n requested: false,\n started: false,\n joined: false,\n admission: undefined,\n childSubmissionId: undefined,\n reservation: undefined,\n attachment: undefined,\n };\n\n views.set(toolCallId, created);\n\n return created;\n };\n\n for (const call of evidence.openDelegationCalls) {\n const view = ensure(call.toolCallId);\n\n view.turn = call.turn;\n view.open = true;\n view.requested = call.requested;\n view.started = call.started;\n view.joined = call.joined;\n view.admission = call.admission;\n view.childSubmissionId = call.childSubmissionId;\n }\n for (const reservation of snapshot.childReservations) {\n let view = views.get(reservation.parentToolCallId);\n\n if (view === undefined) {\n view = ensure(reservation.parentToolCallId);\n }\n view.reservation = reservation;\n if (view.childSubmissionId === undefined && reservation.childSubmissionId !== undefined) {\n view.childSubmissionId = reservation.childSubmissionId;\n }\n }\n for (const attachment of snapshot.childAttachments) {\n const view = ensure(attachment.toolCallId);\n\n view.attachment = attachment;\n if (view.childSubmissionId === undefined) {\n view.childSubmissionId = attachment.childSubmissionId;\n }\n }\n\n return [...views.values()];\n};\n\nconst waitingChildOf = (view: DelegationCallView, childSubmissionId: SubmissionId): WaitingChild =>\n WaitingChild.make({ toolCallId: view.toolCallId, childSubmissionId });\n\nconst nonEmpty = <A>(values: ReadonlyArray<A>): readonly [A, ...Array<A>] | undefined => {\n const [first, ...rest] = values;\n\n return first === undefined ? undefined : [first, ...rest];\n};\n\n/**\n * The reservation's frozen accounting decision has not been applied: whether frozen by a\n * canonical join or by an orphan zero-consumed decision, `releasePending` always finishes\n * through the idempotent `releaseChildBudget` replay — never through a second freeze, whose\n * divergent accounting would conflict (`ChildReservationConflict`).\n */\nconst releasePendingReservation = (\n view: DelegationCallView,\n): ChildBudgetReservationSnapshot | undefined =>\n view.reservation !== undefined && view.reservation.status === \"releasePending\"\n ? view.reservation\n : undefined;\n\n/** The reservation still holds unfrozen allocation (`reserved`). */\nconst reservedReservation = (\n view: DelegationCallView,\n): ChildBudgetReservationSnapshot | undefined =>\n view.reservation !== undefined && view.reservation.status === \"reserved\"\n ? view.reservation\n : undefined;\n\n/**\n * The spec §13 Subagent rows for a live (non-suspended) parent WITHOUT a durable abort intent,\n * in most-repairing-first order. Returns `undefined` when no delegation obligation is open so\n * the ordinary rows apply.\n */\nconst classifyDelegationRepairs = (\n submissionId: SubmissionId,\n views: ReadonlyArray<DelegationCallView>,\n): RecoveryDecision | undefined => {\n const applyJoins: Array<DelegationCallView> = [];\n const completeAdmissions: Array<DelegationCallView> = [];\n const repairStartLinks: Array<DelegationCallView> = [];\n const awaitAdmissions: Array<DelegationCallView> = [];\n const resumeBatches: Array<DelegationCallView> = [];\n const waiting: Array<WaitingChild> = [];\n const terminalUnjoined: Array<WaitingChild> = [];\n const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];\n\n for (const view of views) {\n if (view.reservation !== undefined && view.reservation.status === \"released\") {\n // The reservation lifecycle is complete: release happens only after the canonical join\n // (or a provably-childless orphan decision), so no parent-side budget or waiting\n // obligation remains on this call.\n continue;\n }\n if (releasePendingReservation(view) !== undefined) {\n // Row: budget release incomplete with the accounting decision already frozen → finish\n // the idempotent release; a second freeze would conflict.\n applyJoins.push(view);\n continue;\n }\n if (view.joined) {\n // Row: parent join canonical, budget release incomplete → apply the canonical accounting.\n if (reservedReservation(view) !== undefined) applyJoins.push(view);\n continue;\n }\n if (view.started && view.childSubmissionId !== undefined) {\n // Rows: started + child nonterminal → waiting; child terminal + join missing → wake.\n const child = waitingChildOf(view, view.childSubmissionId);\n\n if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {\n terminalUnjoined.push(child);\n } else {\n waiting.push(child);\n }\n continue;\n }\n if (view.started || view.childSubmissionId !== undefined || view.admission === \"admitted\") {\n // Row: child admitted, parent start record missing (or the start/attachment link is\n // incomplete) → resolve the same child by key and append the exact link.\n repairStartLinks.push(view);\n continue;\n }\n if (view.requested) {\n // Rows: requested + notAdmitted → admit exactly one child; indeterminate (or unqueried,\n // fail-closed) → wait/retry the authoritative owner, never a second admission.\n if (view.admission === \"not-admitted\") completeAdmissions.push(view);\n else awaitAdmissions.push(view);\n continue;\n }\n if (view.open) {\n // Row: no reservation and no request (or reservation without a request on a live parent)\n // → the declared batch re-executes; establishment is idempotent by construction.\n resumeBatches.push(view);\n continue;\n }\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) {\n // Row: reservation exists, request absent, no resumable batch → release exactly once.\n orphanReservations.push(reservation);\n }\n }\n\n const applyJoin = applyJoins[0];\n\n if (applyJoin?.reservation !== undefined) {\n return ApplyJoinAccounting.make({\n submissionId,\n toolCallId: applyJoin.toolCallId,\n reservationId: applyJoin.reservation.reservationId,\n });\n }\n const completeAdmission = completeAdmissions[0];\n\n if (completeAdmission !== undefined) {\n return CompleteChildAdmission.make({ submissionId, toolCallId: completeAdmission.toolCallId });\n }\n const repairStartLink = repairStartLinks[0];\n\n if (repairStartLink !== undefined) {\n return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });\n }\n const awaitAdmission = awaitAdmissions[0];\n\n if (awaitAdmission !== undefined) {\n return AwaitChildAdmissionResolution.make({\n submissionId,\n toolCallId: awaitAdmission.toolCallId,\n });\n }\n const resumeBatch = resumeBatches[0];\n\n if (resumeBatch?.turn !== undefined) {\n return ResumePendingToolBatch.make({ submissionId, turn: resumeBatch.turn });\n }\n const waitingChildren = nonEmpty([...waiting, ...terminalUnjoined]);\n\n if (waiting.length > 0 && waitingChildren !== undefined) {\n return EnsureWaitingForChild.make({ submissionId, children: waitingChildren });\n }\n const settledChildren = nonEmpty(terminalUnjoined);\n\n if (settledChildren !== undefined) {\n return ResumeWaitingParent.make({ submissionId, children: settledChildren });\n }\n const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));\n\n if (orphans !== undefined) {\n return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });\n }\n\n return undefined;\n};\n\n/**\n * The spec §13/§13.1 Subagent rows under a canonical parent abort intent: request-abort-and-join\n * is the only close behavior, so a nonterminal attached child converts `SettleAborted` into\n * `PropagateChildAbort`, terminal-but-unjoined children are joined first, incomplete releases\n * are applied, provably childless reservations release exactly once, and only a parent with no\n * open child obligation settles aborted. Returns `undefined` for exactly that last case.\n */\nconst classifyDelegationAbort = (\n submissionId: SubmissionId,\n views: ReadonlyArray<DelegationCallView>,\n): RecoveryDecision | undefined => {\n const awaitAdmissions: Array<DelegationCallView> = [];\n const repairStartLinks: Array<DelegationCallView> = [];\n const nonterminal: Array<WaitingChild> = [];\n const terminalUnjoined: Array<WaitingChild> = [];\n const applyJoins: Array<DelegationCallView> = [];\n const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];\n\n for (const view of views) {\n if (view.reservation !== undefined && view.reservation.status === \"released\") {\n // Fully closed (release only follows the canonical join or a provably-childless orphan\n // decision): nothing left to abort, join, or release for this call.\n continue;\n }\n if (releasePendingReservation(view) !== undefined) {\n // The accounting decision is already frozen: finish the idempotent release; a second\n // (zero-consumed) freeze would conflict with the frozen decision.\n applyJoins.push(view);\n continue;\n }\n if (view.joined) {\n if (reservedReservation(view) !== undefined) applyJoins.push(view);\n continue;\n }\n if (view.childSubmissionId !== undefined) {\n if (!view.started) {\n // The child exists but the canonical start link is missing: repair it first so the\n // abort command targets a canonically linked child.\n repairStartLinks.push(view);\n continue;\n }\n const child = waitingChildOf(view, view.childSubmissionId);\n\n if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {\n terminalUnjoined.push(child);\n } else {\n nonterminal.push(child);\n }\n continue;\n }\n if (view.started || view.admission === \"admitted\") {\n repairStartLinks.push(view);\n continue;\n }\n if (view.requested) {\n if (view.admission === \"not-admitted\") {\n // Provably childless request under abort: never admit a child merely to abort it;\n // release the unused reservation exactly once.\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) orphanReservations.push(reservation);\n } else {\n // Indeterminate or unqueried: a child may exist — never release, settle, or re-admit\n // until the authoritative owner answers (SUB-031).\n awaitAdmissions.push(view);\n }\n continue;\n }\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) orphanReservations.push(reservation);\n // An open delegation call with no reservation carries no child obligation: establishment\n // never started, so the ordinary aborted settlement (with its unknown-audit for open\n // calls) is honest.\n }\n\n const awaitAdmission = awaitAdmissions[0];\n\n if (awaitAdmission !== undefined) {\n return AwaitChildAdmissionResolution.make({\n submissionId,\n toolCallId: awaitAdmission.toolCallId,\n });\n }\n const repairStartLink = repairStartLinks[0];\n\n if (repairStartLink !== undefined) {\n return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });\n }\n const abortChildren = nonEmpty(nonterminal);\n\n if (abortChildren !== undefined) {\n return PropagateChildAbort.make({ submissionId, children: abortChildren });\n }\n const settledChildren = nonEmpty(terminalUnjoined);\n\n if (settledChildren !== undefined) {\n return ResumeWaitingParent.make({ submissionId, children: settledChildren });\n }\n const applyJoin = applyJoins[0];\n\n if (applyJoin?.reservation !== undefined) {\n return ApplyJoinAccounting.make({\n submissionId,\n toolCallId: applyJoin.toolCallId,\n reservationId: applyJoin.reservation.reservationId,\n });\n }\n const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));\n\n if (orphans !== undefined) {\n return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });\n }\n\n return undefined;\n};\n\n/**\n * Pure recovery classifier (durability §14, DUR-013): a finite persisted snapshot plus canonical\n * evidence deterministically selects exactly one decision. Precedence, most-settled first\n * (plan §4.2/§4.3 — note the deliberate P5 reorder: canonical settlement and reservation beat\n * open tool calls, because a recorded terminal outcome is never revisited, DUR-002/DUR-015; and\n * the three S2 edits: the abort row propagates to nonterminal attached children, delegation\n * calls never mark Unknown, and the suspended row branches on the suspension reason):\n *\n * 1. `settled` → NoAction — terminal outcomes are never revisited (DUR-002).\n * 2. canonical settlement record → FinalizeLedgerFromHistory — history beats every ledger\n * marker (DUR-015), including a missing or divergent reservation AND open tool calls.\n * 3. reservation → FinalizeLedgerFromHistory when finalized, else AppendReservedSettlement —\n * the reserved record is the single exact outcome owed (DUR-011); it also beats a pending\n * abort intent (DUR-012).\n * 4. joined-side states (DUR-016): `joining` without canonical input → RevertJoining; `joining`\n * with canonical input → RepairJoinMarker (marker lost); `joined` + host settled →\n * SettleJoinedWithHost; `joined` + host live → AwaitHostSettlement (deferred).\n * 5. abort intent → the S2 abort rows (spec §13.1 request-abort-and-join): an unproven child\n * admission waits, an admitted-but-unlinked child repairs its start link, a nonterminal\n * attached child gets PropagateChildAbort — the parent does NOT settle — terminal children\n * are joined, incomplete releases applied, provably childless reservations released; ONLY a\n * parent with no open child obligation reaches SettleAborted, where open ordinary calls\n * become `ToolCallUnknown` audit records, never a rollback claim (§13). SettleAborted is\n * position-blind by design (P7 §7(c)): an aborted, never-claimed `ready` Submission earns it\n * ANYWHERE in the queue — the executor settles it immediately without waiting for it to head\n * the lane, because settlement order of never-run work is not execution order (DUR-004\n * bounds execution order; DUR-012 permits settling inactive accepted work without an\n * Attempt).\n * 6. ordinary open tool calls (state not yet `unknown`) → MarkUnknown — reconcile-then-mark,\n * never an automatic replay (DUR-009). Delegation calls are EXCLUDED (plan §4.3's most\n * important edit): their prepared-without-outcome state is provably replay-safe and routes\n * through rows 5/8/9 instead. A lane already `unknown` is in the DUR-017 resolution regime\n * (row 7) and is not re-marked.\n * 7. state `unknown` → ApplyUnknownResolutions when durable intents cover every open ordinary\n * call, else AwaitUnknownResolution.\n * 8. state `suspended` branches on the stored reason: `WaitingForChild` → ResumeWaitingParent\n * when every listed child is provably settled (replay the idempotent wake), else\n * AwaitChildSettlement (SUB-030); `ApprovalPending` keeps the P5 behavior — undecided\n * canonical approval requests → AwaitApprovalDecision (repairing a lost suspend transition\n * from history), every request decided → ResumeSuspended.\n * 9. the S2 establishment/join rows for a live parent (spec §13, most-repairing first):\n * ApplyJoinAccounting → CompleteChildAdmission → RepairSubagentStartLink →\n * AwaitChildAdmissionResolution → ResumePendingToolBatch (idempotent handler re-entry) →\n * EnsureWaitingForChild → ResumeWaitingParent → ReleaseOrphanChildReservation.\n * 10. declared-but-unprepared tool batch → ResumePendingToolBatch — no handler ran (no prepared\n * records), so the batch resumes with no model re-invocation and no Unknown (§15).\n * 11. `admitted` → a parent-linked Submission whose Thread lacks the canonical lineage\n * record defers (AwaitParentEstablishment: the parent's idempotent establishment\n * completes it); otherwise\n * CompleteMaterialization / RepairReadiness by Thread durability.\n * 12. otherwise → ApplyInput / RepairInputMarker / ResumeFromTurnBoundary by canonical input\n * evidence, with the ledger marker repaired from history, never the reverse.\n *\n * A CHILD Submission (one whose snapshot carries `parentLinkage`) classifies through exactly\n * the same rows as any Submission — child recovery proceeds under its own ownership token and\n * epoch (spec §13, SUB-020); nothing here consults the parent's lane.\n *\n * Ownership leases are deliberately ignored here: the executor's fenced claim is the only\n * authority over liveness, and a stale Attempt is fenced by producer epoch regardless (DUR-006).\n */\nexport const classifyRecovery = (\n snapshot: RecoverySnapshot,\n evidence: RecoveryEvidence,\n): RecoveryDecision => {\n const submissionId = snapshot.submission.submissionId;\n const state = snapshot.submission.state;\n\n if (state === \"settled\") {\n return NoAction.make({ submissionId });\n }\n if (evidence.recordedSettlementOutcome !== undefined) {\n return FinalizeLedgerFromHistory.make({\n submissionId,\n settlementId: snapshot.reservation?.settlementId ?? submissionSettlementId(submissionId),\n outcome: evidence.recordedSettlementOutcome,\n });\n }\n if (snapshot.reservation !== undefined) {\n if (snapshot.reservation.finalized) {\n return FinalizeLedgerFromHistory.make({\n submissionId,\n settlementId: snapshot.reservation.settlementId,\n outcome: snapshot.reservation.outcome,\n });\n }\n\n return AppendReservedSettlement.make({\n submissionId,\n settlementId: snapshot.reservation.settlementId,\n outcome: snapshot.reservation.outcome,\n });\n }\n if (state === \"joining\") {\n return evidence.inputRecorded\n ? RepairJoinMarker.make({ submissionId })\n : RevertJoining.make({ submissionId });\n }\n if (state === \"joined\") {\n if (evidence.hostSettlementOutcome !== undefined) {\n return SettleJoinedWithHost.make({\n submissionId,\n outcome: evidence.hostSettlementOutcome,\n });\n }\n\n return AwaitHostSettlement.make({\n submissionId,\n ...(snapshot.hostSubmissionId === undefined\n ? {}\n : { hostSubmissionId: snapshot.hostSubmissionId }),\n });\n }\n const delegationViews = delegationViewsOf(snapshot, evidence);\n\n if (snapshot.abortIntent !== undefined) {\n return (\n classifyDelegationAbort(submissionId, delegationViews) ?? SettleAborted.make({ submissionId })\n );\n }\n\n const delegationCallIds = new Set<string>(\n evidence.openDelegationCalls.map((call) => call.toolCallId),\n );\n\n const ordinaryOpenCalls = evidence.openToolCalls.filter(\n (call) => !delegationCallIds.has(call.toolCallId),\n );\n\n if (state !== \"unknown\" && ordinaryOpenCalls.length > 0) {\n return MarkUnknown.make({\n submissionId,\n reason: \"An ordinary Tool call may have executed without a canonical outcome\",\n openToolCallIds: ordinaryOpenCalls.map((call) => call.toolCallId),\n });\n }\n if (state === \"unknown\") {\n const resolved = new Set(\n snapshot.unknownResolutions.map((resolution) => resolution.toolCallId),\n );\n\n const covered = ordinaryOpenCalls.every((call) => resolved.has(call.toolCallId));\n\n return covered\n ? ApplyUnknownResolutions.make({ submissionId })\n : AwaitUnknownResolution.make({ submissionId });\n }\n const decided = new Set(snapshot.approvalDecisions.map((decision) => decision.toolCallId));\n\n const undecidedApprovals = evidence.approvalsPending.filter(\n (pending) => !decided.has(pending.toolCallId),\n );\n\n if (state === \"suspended\") {\n const reason = snapshot.suspension?.reason;\n\n if (reason !== undefined && reason._tag === \"WaitingForChild\") {\n const terminalChildIds = new Set(\n snapshot.childAttachments\n .filter(isTerminalAttachment)\n .map((attachment) => attachment.childSubmissionId),\n );\n\n return reason.children.every((child) => terminalChildIds.has(child.childSubmissionId))\n ? ResumeWaitingParent.make({ submissionId, children: reason.children })\n : AwaitChildSettlement.make({ submissionId });\n }\n\n return undecidedApprovals.length === 0\n ? ResumeSuspended.make({ submissionId })\n : AwaitApprovalDecision.make({ submissionId });\n }\n if (undecidedApprovals.length > 0) {\n return AwaitApprovalDecision.make({ submissionId });\n }\n const delegationDecision = classifyDelegationRepairs(submissionId, delegationViews);\n\n if (delegationDecision !== undefined) {\n return delegationDecision;\n }\n if (evidence.declaredPendingBatch !== undefined) {\n return ResumePendingToolBatch.make({\n submissionId,\n turn: evidence.declaredPendingBatch.turn,\n });\n }\n const workerCall = evidence.openWorkerCalls?.[0];\n\n if (workerCall !== undefined) {\n return ResumePendingToolBatch.make({ submissionId, turn: workerCall.turn });\n }\n if (state === \"admitted\") {\n // A parent-linked child never self-repairs readiness before its immutable\n // lineage record is canonical — the parent's establishment appends lineage BEFORE\n // markReady, so the parent completes the child idempotently.\n const linkage = snapshot.submission.parentLinkage ?? snapshot.parentLinkage;\n\n if (linkage !== undefined && !evidence.subagentLineageRecorded) {\n return AwaitParentEstablishment.make({\n submissionId,\n parentSubmissionId: linkage.parentSubmissionId,\n parentToolCallId: linkage.parentToolCallId,\n });\n }\n\n return evidence.threadMaterialized\n ? RepairReadiness.make({ submissionId })\n : CompleteMaterialization.make({ submissionId });\n }\n if (!evidence.inputRecorded) {\n return ApplyInput.make({ submissionId });\n }\n if (snapshot.inputApplied === undefined) {\n return RepairInputMarker.make({ submissionId });\n }\n\n return ResumeFromTurnBoundary.make({ submissionId });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,uBAAb,cAA0C,OAAO,MAC/C,2CACF,CAAC,CAAC;CACA,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,MAAM,iBAAiB,OAAO;AAChC,CAAC,CAAC,CAAC,CAAC;;;;;;AAOJ,IAAa,+BAAb,cAAkD,OAAO,MACvD,mDACF,CAAC,CAAC;CACA,MAAM,iBAAiB,OAAO;CAC9B,WAAW,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,0BAAb,cAA6C,OAAO,MAClD,8CACF,CAAC,CAAC;CACA,YAAY;CACZ,MAAM,iBAAiB,OAAO;AAChC,CAAC,CAAC,CAAC,CAAC;;;;;;;;AASJ,MAAa,8BAA8B,OAAO,SAAS;CACzD;CACA;CACA;AACF,CAAC;;;;;;;;;;;;AAeD,IAAa,6BAAb,cAAgD,OAAO,MACrD,iDACF,CAAC,CAAC;CACA,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,MAAM,iBAAiB,OAAO;;CAE9B,WAAW,OAAO;;CAElB,S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\";\n\nimport { ThreadId, SettlementId, SubmissionId, ToolCallId } from \"../core/Identifiers.ts\";\nimport { SettlementOutcome, ToolCallPrepared } from \"./Records.ts\";\nimport {\n ChildReservationId,\n submissionSettlementId,\n WaitingChild,\n type ChildAttachmentSnapshot,\n type ChildBudgetReservationSnapshot,\n type RecoverySnapshot,\n} from \"./SubmissionLedger.ts\";\n\n/** One canonical `ToolCallPrepared` without a settling or resolving canonical record (DUR-009). */\nexport class OpenToolCallEvidence extends Schema.Class<OpenToolCallEvidence>(\n \"@effect-agent/thread/OpenToolCallEvidence\",\n)({\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n turn: ToolCallPrepared.fields.turn,\n}) {}\n\n/**\n * A committed tool-declaring response with ZERO prepared and ZERO settled records for its Turn:\n * the durability §15 batch-resume window. Mutation preparation has not committed; readonly\n * handlers may already have run. The worker checks each unfinished operation before execution.\n */\nexport class DeclaredPendingBatchEvidence extends Schema.Class<DeclaredPendingBatchEvidence>(\n \"@effect-agent/thread/DeclaredPendingBatchEvidence\",\n)({\n turn: ToolCallPrepared.fields.turn,\n callCount: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** One canonical `ToolApprovalRequested` without a canonical `ToolApprovalDecided`. */\nexport class PendingApprovalEvidence extends Schema.Class<PendingApprovalEvidence>(\n \"@effect-agent/thread/PendingApprovalEvidence\",\n)({\n toolCallId: ToolCallId,\n turn: ToolCallPrepared.fields.turn,\n}) {}\n\n/**\n * The authoritative tri-state admission answer recorded as pure classifier evidence (SUB-031):\n * the recovery pass queries `resolveAdmission` with the deterministic child idempotency key for\n * a requested-but-unstarted delegation call and records the result here. Absence of this field\n * means the lookup was not performed — the classifier treats that exactly like `indeterminate`\n * (fail-closed: only a proven `not-admitted` ever permits an admission attempt).\n */\nexport const DelegationAdmissionEvidence = Schema.Literals([\n \"not-admitted\",\n \"admitted\",\n \"indeterminate\",\n]);\n\nexport type DelegationAdmissionEvidence = typeof DelegationAdmissionEvidence.Type;\n\n/**\n * One prepared-without-outcome parent Tool Call that IS a delegation (plan §4.1), separated from\n * `openToolCalls` because its establishment protocol is idempotent by construction and must\n * NEVER be marked Unknown (spec §13 vs. DUR-009). Delegation detection is durable and\n * fail-closed: canonical preparation records carry the definition-owned execution kind;\n * child reservations and request records must agree with that classification. Names never\n * authorize replay, including in the pre-reservation window. The\n * `requested`/`started`/`joined` flags come from the parent-log canonical records; the child\n * identity fields are present exactly when those records (or the reservation attachment) carry\n * them.\n */\nexport class OpenDelegationCallEvidence extends Schema.Class<OpenDelegationCallEvidence>(\n \"@effect-agent/thread/OpenDelegationCallEvidence\",\n)({\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n turn: ToolCallPrepared.fields.turn,\n /** The canonical `SubagentRequested` record exists for this call. */\n requested: Schema.Boolean,\n /** The canonical `SubagentStarted` record exists for this call. */\n started: Schema.Boolean,\n /** The canonical `SubagentJoined` record exists for this call. */\n joined: Schema.Boolean,\n childThreadId: Schema.optionalKey(ThreadId),\n childSubmissionId: Schema.optionalKey(SubmissionId),\n admission: Schema.optionalKey(DelegationAdmissionEvidence),\n}) {}\n\n/**\n * Canonical-log facts about one Submission, read strongly consistently alongside the ledger\n * `RecoverySnapshot` (STORE-003). Canonical history wins over every ledger marker (DUR-015), so\n * the classifier consults these facts before trusting ledger state — with one deliberate Phase 5\n * inversion: a RECORDED terminal outcome now beats open tool calls, because a canonical\n * settlement is never revisited (DUR-002/DUR-015); the P4 rule that unknown-beats-settlement is\n * gone.\n *\n * `openToolCalls` is the DUR-009 seam: every `ToolCallPrepared` without a matching\n * `ToolCallSettled` or `ToolCallResolved`. S2 separates `openDelegationCalls` from it (plan\n * §4.1): a delegation's prepared-without-outcome state is provably replay-safe, so those calls\n * route through the Subagent recovery rows and never through `MarkUnknown`. Names and\n * operational reservation rows cannot upgrade ordinary classification. `joinedInputCovered`\n * implements the plan §2.5 prompt-coverage rule for the joined side: a joined input is covered\n * iff a later `ModelResponseRecorded` of the host Run exists after the `input:{sid}` record.\n * `hostSettlementOutcome` is the joined-side view of the host's canonical `SubmissionSettled`\n * record, present exactly when that record exists.\n */\nexport class RecoveryEvidence extends Schema.Class<RecoveryEvidence>(\n \"@effect-agent/thread/RecoveryEvidence\",\n)({\n /** The Thread exists in the ThreadStore. */\n threadMaterialized: Schema.Boolean,\n /** The deterministic canonical `UserInputRecorded` record (`input:{sid}`) is committed. */\n inputRecorded: Schema.Boolean,\n /**\n * The committed canonical `SubmissionSettled` outcome (`settlement:{sid}`). Present exactly\n * when the canonical settlement record exists, so the flag and the outcome cannot diverge.\n */\n recordedSettlementOutcome: Schema.optionalKey(SettlementOutcome),\n /** The deterministic canonical `AbortRequested` record (`abort:{sid}`) is committed. */\n abortRecorded: Schema.Boolean,\n /** Prepared ordinary Tool Calls without a canonical settled/resolved outcome (DUR-009). */\n openToolCalls: Schema.Array(OpenToolCallEvidence),\n /**\n * Delegation Tool Calls with an open parent-side obligation (plan §4.1), removed from\n * `openToolCalls`. Wire-required; construction alone defaults it so pre-S2 evidence\n * assemblers stay valid while the classifier's fail-closed detection still protects them.\n */\n openDelegationCalls: Schema.Array(OpenDelegationCallEvidence).pipe(\n Schema.withConstructorDefault(Effect.succeed([])),\n ),\n /** Only persisted orchestration classification authorizes idempotent host-operation replay. */\n openWorkerCalls: Schema.optionalKey(Schema.Array(OpenToolCallEvidence)),\n /** A declared-but-unprepared tool batch: response canonical, zero prepared, zero settled. */\n declaredPendingBatch: Schema.optionalKey(DeclaredPendingBatchEvidence),\n /** Canonically requested approvals without a canonical decision. */\n approvalsPending: Schema.Array(PendingApprovalEvidence),\n /** Joined-side prompt coverage (plan §2.5); `true` whenever the Submission is not joined. */\n joinedInputCovered: Schema.Boolean,\n /** Joined-side view of the host's canonical settlement record, when it exists. */\n hostSettlementOutcome: Schema.optionalKey(SettlementOutcome),\n /**\n * The Thread carries its canonical `SubagentLineageRecorded` record. Only\n * consulted for a parent-linked Submission: a child whose lineage is not yet canonical defers\n * its own materialization/readiness repair to the parent's idempotent establishment\n * (`AwaitParentEstablishment`). Defaults to `false` so an assembler that does not compute it\n * stays fail-closed: deferring is safe because the parent's establishment completes the child;\n * running a Turn before lineage is recorded would violate the child establishment ordering.\n */\n subagentLineageRecorded: Schema.Boolean.pipe(\n Schema.withConstructorDefault(Effect.succeed(false)),\n ),\n}) {}\n\n/** Ledger admission committed but the Thread is not durable: finish materialization,\n * append `ThreadCreated`, and mark readiness (crash between admit and materialize). */\nexport class CompleteMaterialization extends Schema.TaggedClass<CompleteMaterialization>(\n \"@effect-agent/thread/CompleteMaterialization\",\n)(\"CompleteMaterialization\", { submissionId: SubmissionId }) {}\n\n/** Thread durable but the readiness marker is missing: idempotent `markReady`. */\nexport class RepairReadiness extends Schema.TaggedClass<RepairReadiness>(\n \"@effect-agent/thread/RepairReadiness\",\n)(\"RepairReadiness\", { submissionId: SubmissionId }) {}\n\n/** No canonical input yet: append the deterministic `UserInputRecorded` record and mark it. */\nexport class ApplyInput extends Schema.TaggedClass<ApplyInput>(\"@effect-agent/thread/ApplyInput\")(\n \"ApplyInput\",\n { submissionId: SubmissionId },\n) {}\n\n/** Canonical input exists but the ledger marker was lost: repair the marker only (DUR-015). */\nexport class RepairInputMarker extends Schema.TaggedClass<RepairInputMarker>(\n \"@effect-agent/thread/RepairInputMarker\",\n)(\"RepairInputMarker\", { submissionId: SubmissionId }) {}\n\n/** Input applied and no terminal work reserved: a worker resumes the Run from the last committed\n * Turn boundary (D6; the model may be re-invoked, duplicate cost is observable — the resuming\n * worker appends `ModelResponseInterrupted` when superseding a prior owner, durability §9). */\nexport class ResumeFromTurnBoundary extends Schema.TaggedClass<ResumeFromTurnBoundary>(\n \"@effect-agent/thread/ResumeFromTurnBoundary\",\n)(\"ResumeFromTurnBoundary\", { submissionId: SubmissionId }) {}\n\n/** A settlement is reserved but not canonical: append the EXACT reserved record, then finalize. */\nexport class AppendReservedSettlement extends Schema.TaggedClass<AppendReservedSettlement>(\n \"@effect-agent/thread/AppendReservedSettlement\",\n)(\"AppendReservedSettlement\", {\n submissionId: SubmissionId,\n settlementId: SettlementId,\n outcome: SettlementOutcome,\n}) {}\n\n/** The canonical settlement record exists: rebuild/finalize the ledger from history and never\n * rewrite history from the cached ledger status (DUR-011, DUR-015). */\nexport class FinalizeLedgerFromHistory extends Schema.TaggedClass<FinalizeLedgerFromHistory>(\n \"@effect-agent/thread/FinalizeLedgerFromHistory\",\n)(\"FinalizeLedgerFromHistory\", {\n submissionId: SubmissionId,\n settlementId: SettlementId,\n outcome: SettlementOutcome,\n}) {}\n\n/** A durable abort intent exists, no terminal outcome is reserved, and no attached-child\n * obligation remains open: settle aborted (DUR-012). The executor first appends\n * `ToolCallUnknown` audit records for any open ordinary calls — abort settles the obligation but\n * never asserts external rollback (durability §13). */\nexport class SettleAborted extends Schema.TaggedClass<SettleAborted>(\n \"@effect-agent/thread/SettleAborted\",\n)(\"SettleAborted\", { submissionId: SubmissionId }) {}\n\n/** Prepared ordinary Tool Calls have no canonical outcome: the executor reconciles each open\n * call (recovered result / never-started / safe-retry) and marks the remainder Unknown — never\n * an automatic replay (DUR-009/DUR-017). Delegation calls are excluded: their establishment is\n * idempotent by construction and routes through the Subagent rows instead (plan §4.3). */\nexport class MarkUnknown extends Schema.TaggedClass<MarkUnknown>(\n \"@effect-agent/thread/MarkUnknown\",\n)(\"MarkUnknown\", {\n submissionId: SubmissionId,\n reason: Schema.String,\n openToolCallIds: Schema.Array(ToolCallId),\n}) {}\n\n/** A committed tool-declaring response has zero prepared and zero settled records: a worker\n * checks unfinished contracts and resumes the declared batch without model re-invocation. S2 also\n * routes an open delegation call WITHOUT establishment evidence here (spec §13 row 1): the\n * declared batch re-executes and the idempotent establishment converges on one child. */\nexport class ResumePendingToolBatch extends Schema.TaggedClass<ResumePendingToolBatch>(\n \"@effect-agent/thread/ResumePendingToolBatch\",\n)(\"ResumePendingToolBatch\", {\n submissionId: SubmissionId,\n turn: DeclaredPendingBatchEvidence.fields.turn,\n}) {}\n\n/** Canonically requested approvals lack decisions: the lane waits durably (the executor repairs\n * the ledger suspension from history when the suspend transition itself was lost). */\nexport class AwaitApprovalDecision extends Schema.TaggedClass<AwaitApprovalDecision>(\n \"@effect-agent/thread/AwaitApprovalDecision\",\n)(\"AwaitApprovalDecision\", { submissionId: SubmissionId }) {}\n\n/** Every pending approval has a durable decision: a worker resumes the declared batch via the\n * batch-resume seam, appending the canonical `ToolApprovalDecided` records first. */\nexport class ResumeSuspended extends Schema.TaggedClass<ResumeSuspended>(\n \"@effect-agent/thread/ResumeSuspended\",\n)(\"ResumeSuspended\", { submissionId: SubmissionId }) {}\n\n/** Unknown Outcomes lack covering resolutions: this Submission stays parked awaiting the authorized\n * DUR-017 resolution path; the obligation stays visible, nothing replays. */\nexport class AwaitUnknownResolution extends Schema.TaggedClass<AwaitUnknownResolution>(\n \"@effect-agent/thread/AwaitUnknownResolution\",\n)(\"AwaitUnknownResolution\", { submissionId: SubmissionId }) {}\n\n/** Durable resolution intents cover every open call: wake the original Submission when its\n * required retry contract is supported. Canonical outcomes are applied by the next claim. */\nexport class ApplyUnknownResolutions extends Schema.TaggedClass<ApplyUnknownResolutions>(\n \"@effect-agent/thread/ApplyUnknownResolutions\",\n)(\"ApplyUnknownResolutions\", { submissionId: SubmissionId }) {}\n\n/** `joining` without a canonical `input:{sid}` record: revert to `ready` — the input was never\n * consumed and will be delivered exactly once later (DUR-016). */\nexport class RevertJoining extends Schema.TaggedClass<RevertJoining>(\n \"@effect-agent/thread/RevertJoining\",\n)(\"RevertJoining\", { submissionId: SubmissionId }) {}\n\n/** The canonical input exists but the `joined` marker was lost: repair the marker only, exactly\n * like `RepairInputMarker` (DUR-015/DUR-016); the input reattaches, never duplicates. */\nexport class RepairJoinMarker extends Schema.TaggedClass<RepairJoinMarker>(\n \"@effect-agent/thread/RepairJoinMarker\",\n)(\"RepairJoinMarker\", { submissionId: SubmissionId }) {}\n\n/** The host Run settled canonically: settle this joined Submission with the host outcome\n * (each joined Submission is owed its own settlement, DUR-002). */\nexport class SettleJoinedWithHost extends Schema.TaggedClass<SettleJoinedWithHost>(\n \"@effect-agent/thread/SettleJoinedWithHost\",\n)(\"SettleJoinedWithHost\", {\n submissionId: SubmissionId,\n outcome: SettlementOutcome,\n}) {}\n\n/** The Submission is `joined` and its host Run is still live: nothing to repair — the input\n * reattaches through the host's resume and the Submission settles with the host. */\nexport class AwaitHostSettlement extends Schema.TaggedClass<AwaitHostSettlement>(\n \"@effect-agent/thread/AwaitHostSettlement\",\n)(\"AwaitHostSettlement\", {\n submissionId: SubmissionId,\n hostSubmissionId: Schema.optionalKey(SubmissionId),\n}) {}\n\n/** A canonical `SubagentRequested` exists and the authoritative admission lookup proved\n * `notAdmitted`: idempotently admit the intended child from the canonical request payload — it\n * carries the encoded child input (D3), the intended child identity, and every digest — then\n * materialize the child Thread, append its immutable lineage, and mark it ready. No live\n * delegation handler is required (spec §13, SUB-016/SUB-031). */\nexport class CompleteChildAdmission extends Schema.TaggedClass<CompleteChildAdmission>(\n \"@effect-agent/thread/CompleteChildAdmission\",\n)(\"CompleteChildAdmission\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** A canonical `SubagentRequested` exists but the authoritative admission lookup answered\n * `indeterminate` — or was not (yet) performed: wait and retry the authoritative owner directly.\n * Absence from a projection is never proof of absence and a second admission NEVER occurs\n * (spec §12, SUB-031). */\nexport class AwaitChildAdmissionResolution extends Schema.TaggedClass<AwaitChildAdmissionResolution>(\n \"@effect-agent/thread/AwaitChildAdmissionResolution\",\n)(\"AwaitChildAdmissionResolution\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** The child Submission is admitted but the parent's `SubagentStarted` link is missing (or its\n * reservation attachment was lost): resolve the SAME child by its deterministic idempotency key\n * and append the exact deterministic start record, then attach the child to its reservation —\n * the same Receipt on every replay (spec §13, SUB-016/SUB-017). */\nexport class RepairSubagentStartLink extends Schema.TaggedClass<RepairSubagentStartLink>(\n \"@effect-agent/thread/RepairSubagentStartLink\",\n)(\"RepairSubagentStartLink\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n}) {}\n\n/** Children are established and at least one is nonterminal while the parent lane is NOT\n * durably suspended: restore the `waitingForChild` suspension so the lane holds no worker\n * permit while each child runs on its own lane. Recovery reattaches the one existing child and\n * NEVER spawns a replacement (spec §13, SUB-018/SUB-030). */\nexport class EnsureWaitingForChild extends Schema.TaggedClass<EnsureWaitingForChild>(\n \"@effect-agent/thread/EnsureWaitingForChild\",\n)(\"EnsureWaitingForChild\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** The parent is durably suspended `WaitingForChild` and at least one listed child is not yet\n * provably settled: the lane stays dormant and consumes no permit; the child's Settlement wakes\n * it durably (spec §12 step 10). An unresolved ordinary Tool inside a child keeps the parent\n * here honestly — the obligation stays visible and aged, nothing is fabricated (SUB-021). */\nexport class AwaitChildSettlement extends Schema.TaggedClass<AwaitChildSettlement>(\n \"@effect-agent/thread/AwaitChildSettlement\",\n)(\"AwaitChildSettlement\", { submissionId: SubmissionId }) {}\n\n/** Every relevant child is provably settled but the parent has not joined (legacy data, or a\n * canonical settlement whose idempotent wake still needs replay): record/replay the durable wake\n * so a claiming worker resumes the declared batch and joins each child's canonical Settlement —\n * the join itself needs the parent Binding and is deferred to that worker (spec §13). */\nexport class ResumeWaitingParent extends Schema.TaggedClass<ResumeWaitingParent>(\n \"@effect-agent/thread/ResumeWaitingParent\",\n)(\"ResumeWaitingParent\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** The canonical `SubagentJoined` record exists but the reservation release is incomplete:\n * replay `beginChildBudgetRelease` with the accounting decision FROM the canonical record, then\n * apply `releaseChildBudget` — budget stays unavailable until repair, never available twice\n * (spec §12 join step 6, DUR-015). */\nexport class ApplyJoinAccounting extends Schema.TaggedClass<ApplyJoinAccounting>(\n \"@effect-agent/thread/ApplyJoinAccounting\",\n)(\"ApplyJoinAccounting\", {\n submissionId: SubmissionId,\n toolCallId: ToolCallId,\n reservationId: ChildReservationId,\n}) {}\n\n/** Parent abort is canonical while attached children are nonterminal: idempotently issue each\n * child's durable abort command and keep the parent waiting for the joins —\n * request-abort-and-join is the ONLY close behavior; the replayed command returns the recorded\n * child intent unchanged, so the intent row IS the propagation marker (spec §13.1, SUB-022,\n * DUR-012). */\nexport class PropagateChildAbort extends Schema.TaggedClass<PropagateChildAbort>(\n \"@effect-agent/thread/PropagateChildAbort\",\n)(\"PropagateChildAbort\", {\n submissionId: SubmissionId,\n children: Schema.NonEmptyArray(WaitingChild),\n}) {}\n\n/** A child budget reservation can no longer bind a child — its request is absent with no\n * resumable batch, or the parent is aborting and the child provably never admitted: freeze the\n * deterministic zero-consumed accounting decision and release the unused allocation exactly\n * once (spec §13/§14: \"releases the reservation exactly once\"). */\nexport class ReleaseOrphanChildReservation extends Schema.TaggedClass<ReleaseOrphanChildReservation>(\n \"@effect-agent/thread/ReleaseOrphanChildReservation\",\n)(\"ReleaseOrphanChildReservation\", {\n submissionId: SubmissionId,\n reservationIds: Schema.NonEmptyArray(ChildReservationId),\n}) {}\n\n/**\n * A parent-linked `admitted` Submission whose Thread lacks the canonical\n * `SubagentLineageRecorded` record: the child lane DEFERS its own materialization/readiness\n * repair — the parent's idempotent establishment (admit → materialize → lineage → ready)\n * completes it, so a child never runs a Turn before its lineage record is canonical.\n * This preserves the child establishment ordering. It is ordering/liveness hygiene, not a\n * safety repair — the join already fails closed without lineage (SUB-019).\n */\nexport class AwaitParentEstablishment extends Schema.TaggedClass<AwaitParentEstablishment>(\n \"@effect-agent/thread/AwaitParentEstablishment\",\n)(\"AwaitParentEstablishment\", {\n submissionId: SubmissionId,\n parentSubmissionId: SubmissionId,\n parentToolCallId: ToolCallId,\n}) {}\n\n/** The Submission is settled; nothing is owed. */\nexport class NoAction extends Schema.TaggedClass<NoAction>(\"@effect-agent/thread/NoAction\")(\n \"NoAction\",\n { submissionId: SubmissionId },\n) {}\n\n/** The executable recovery decision table's output alphabet (plan §Recovery classifier). */\nexport const RecoveryDecision = Schema.Union([\n CompleteMaterialization,\n RepairReadiness,\n ApplyInput,\n RepairInputMarker,\n ResumeFromTurnBoundary,\n AppendReservedSettlement,\n FinalizeLedgerFromHistory,\n SettleAborted,\n MarkUnknown,\n ResumePendingToolBatch,\n AwaitApprovalDecision,\n ResumeSuspended,\n AwaitUnknownResolution,\n ApplyUnknownResolutions,\n RevertJoining,\n RepairJoinMarker,\n SettleJoinedWithHost,\n AwaitHostSettlement,\n CompleteChildAdmission,\n AwaitChildAdmissionResolution,\n RepairSubagentStartLink,\n EnsureWaitingForChild,\n AwaitChildSettlement,\n ResumeWaitingParent,\n ApplyJoinAccounting,\n PropagateChildAbort,\n ReleaseOrphanChildReservation,\n AwaitParentEstablishment,\n NoAction,\n]);\n\nexport type RecoveryDecision = typeof RecoveryDecision.Type;\n\n/**\n * The classifier's merged per-call view of one delegation Tool Call: canonical parent-log flags\n * from the evidence, the reservation row, and the child attachment from the ledger snapshot.\n */\ninterface DelegationCallView {\n readonly toolCallId: ToolCallId;\n turn: number | undefined;\n /** A prepared-without-outcome record exists, so the declared batch is worker-resumable. */\n open: boolean;\n requested: boolean;\n started: boolean;\n joined: boolean;\n admission: DelegationAdmissionEvidence | undefined;\n childSubmissionId: SubmissionId | undefined;\n reservation: ChildBudgetReservationSnapshot | undefined;\n attachment: ChildAttachmentSnapshot | undefined;\n}\n\n/** The attachment proves the child's canonical Settlement exists. */\nconst isTerminalAttachment = (attachment: ChildAttachmentSnapshot): boolean =>\n attachment.childState === \"settled\" || attachment.childOutcome !== undefined;\n\n/**\n * Merge every durable delegation-detection source into per-call views (plan §4.1): the\n * explicitly classified `openDelegationCalls`, reservation rows and child attachments.\n * Reservations may need cleanup, but never upgrade an ordinary call into a replayable delegation.\n */\nconst delegationViewsOf = (\n snapshot: RecoverySnapshot,\n evidence: RecoveryEvidence,\n): Array<DelegationCallView> => {\n const views = new Map<ToolCallId, DelegationCallView>();\n\n const ensure = (toolCallId: ToolCallId): DelegationCallView => {\n const existing = views.get(toolCallId);\n\n if (existing !== undefined) return existing;\n\n const created: DelegationCallView = {\n toolCallId,\n turn: undefined,\n open: false,\n requested: false,\n started: false,\n joined: false,\n admission: undefined,\n childSubmissionId: undefined,\n reservation: undefined,\n attachment: undefined,\n };\n\n views.set(toolCallId, created);\n\n return created;\n };\n\n for (const call of evidence.openDelegationCalls) {\n const view = ensure(call.toolCallId);\n\n view.turn = call.turn;\n view.open = true;\n view.requested = call.requested;\n view.started = call.started;\n view.joined = call.joined;\n view.admission = call.admission;\n view.childSubmissionId = call.childSubmissionId;\n }\n for (const reservation of snapshot.childReservations) {\n let view = views.get(reservation.parentToolCallId);\n\n if (view === undefined) {\n view = ensure(reservation.parentToolCallId);\n }\n view.reservation = reservation;\n if (view.childSubmissionId === undefined && reservation.childSubmissionId !== undefined) {\n view.childSubmissionId = reservation.childSubmissionId;\n }\n }\n for (const attachment of snapshot.childAttachments) {\n const view = ensure(attachment.toolCallId);\n\n view.attachment = attachment;\n if (view.childSubmissionId === undefined) {\n view.childSubmissionId = attachment.childSubmissionId;\n }\n }\n\n return [...views.values()];\n};\n\nconst waitingChildOf = (view: DelegationCallView, childSubmissionId: SubmissionId): WaitingChild =>\n WaitingChild.make({ toolCallId: view.toolCallId, childSubmissionId });\n\nconst nonEmpty = <A>(values: ReadonlyArray<A>): readonly [A, ...Array<A>] | undefined => {\n const [first, ...rest] = values;\n\n return first === undefined ? undefined : [first, ...rest];\n};\n\n/**\n * The reservation's frozen accounting decision has not been applied: whether frozen by a\n * canonical join or by an orphan zero-consumed decision, `releasePending` always finishes\n * through the idempotent `releaseChildBudget` replay — never through a second freeze, whose\n * divergent accounting would conflict (`ChildReservationConflict`).\n */\nconst releasePendingReservation = (\n view: DelegationCallView,\n): ChildBudgetReservationSnapshot | undefined =>\n view.reservation !== undefined && view.reservation.status === \"releasePending\"\n ? view.reservation\n : undefined;\n\n/** The reservation still holds unfrozen allocation (`reserved`). */\nconst reservedReservation = (\n view: DelegationCallView,\n): ChildBudgetReservationSnapshot | undefined =>\n view.reservation !== undefined && view.reservation.status === \"reserved\"\n ? view.reservation\n : undefined;\n\n/**\n * The spec §13 Subagent rows for a live (non-suspended) parent WITHOUT a durable abort intent,\n * in most-repairing-first order. Returns `undefined` when no delegation obligation is open so\n * the ordinary rows apply.\n */\nconst classifyDelegationRepairs = (\n submissionId: SubmissionId,\n views: ReadonlyArray<DelegationCallView>,\n): RecoveryDecision | undefined => {\n const applyJoins: Array<DelegationCallView> = [];\n const completeAdmissions: Array<DelegationCallView> = [];\n const repairStartLinks: Array<DelegationCallView> = [];\n const awaitAdmissions: Array<DelegationCallView> = [];\n const resumeBatches: Array<DelegationCallView> = [];\n const waiting: Array<WaitingChild> = [];\n const terminalUnjoined: Array<WaitingChild> = [];\n const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];\n\n for (const view of views) {\n if (view.reservation !== undefined && view.reservation.status === \"released\") {\n // The reservation lifecycle is complete: release happens only after the canonical join\n // (or a provably-childless orphan decision), so no parent-side budget or waiting\n // obligation remains on this call.\n continue;\n }\n if (releasePendingReservation(view) !== undefined) {\n // Row: budget release incomplete with the accounting decision already frozen → finish\n // the idempotent release; a second freeze would conflict.\n applyJoins.push(view);\n continue;\n }\n if (view.joined) {\n // Row: parent join canonical, budget release incomplete → apply the canonical accounting.\n if (reservedReservation(view) !== undefined) applyJoins.push(view);\n continue;\n }\n if (view.started && view.childSubmissionId !== undefined) {\n // Rows: started + child nonterminal → waiting; child terminal + join missing → wake.\n const child = waitingChildOf(view, view.childSubmissionId);\n\n if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {\n terminalUnjoined.push(child);\n } else {\n waiting.push(child);\n }\n continue;\n }\n if (view.started || view.childSubmissionId !== undefined || view.admission === \"admitted\") {\n // Row: child admitted, parent start record missing (or the start/attachment link is\n // incomplete) → resolve the same child by key and append the exact link.\n repairStartLinks.push(view);\n continue;\n }\n if (view.requested) {\n // Rows: requested + notAdmitted → admit exactly one child; indeterminate (or unqueried,\n // fail-closed) → wait/retry the authoritative owner, never a second admission.\n if (view.admission === \"not-admitted\") completeAdmissions.push(view);\n else awaitAdmissions.push(view);\n continue;\n }\n if (view.open) {\n // Row: no reservation and no request (or reservation without a request on a live parent)\n // → the declared batch re-executes; establishment is idempotent by construction.\n resumeBatches.push(view);\n continue;\n }\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) {\n // Row: reservation exists, request absent, no resumable batch → release exactly once.\n orphanReservations.push(reservation);\n }\n }\n\n const applyJoin = applyJoins[0];\n\n if (applyJoin?.reservation !== undefined) {\n return ApplyJoinAccounting.make({\n submissionId,\n toolCallId: applyJoin.toolCallId,\n reservationId: applyJoin.reservation.reservationId,\n });\n }\n const completeAdmission = completeAdmissions[0];\n\n if (completeAdmission !== undefined) {\n return CompleteChildAdmission.make({ submissionId, toolCallId: completeAdmission.toolCallId });\n }\n const repairStartLink = repairStartLinks[0];\n\n if (repairStartLink !== undefined) {\n return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });\n }\n const awaitAdmission = awaitAdmissions[0];\n\n if (awaitAdmission !== undefined) {\n return AwaitChildAdmissionResolution.make({\n submissionId,\n toolCallId: awaitAdmission.toolCallId,\n });\n }\n const resumeBatch = resumeBatches[0];\n\n if (resumeBatch?.turn !== undefined) {\n return ResumePendingToolBatch.make({ submissionId, turn: resumeBatch.turn });\n }\n const waitingChildren = nonEmpty([...waiting, ...terminalUnjoined]);\n\n if (waiting.length > 0 && waitingChildren !== undefined) {\n return EnsureWaitingForChild.make({ submissionId, children: waitingChildren });\n }\n const settledChildren = nonEmpty(terminalUnjoined);\n\n if (settledChildren !== undefined) {\n return ResumeWaitingParent.make({ submissionId, children: settledChildren });\n }\n const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));\n\n if (orphans !== undefined) {\n return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });\n }\n\n return undefined;\n};\n\n/**\n * The spec §13/§13.1 Subagent rows under a canonical parent abort intent: request-abort-and-join\n * is the only close behavior, so a nonterminal attached child converts `SettleAborted` into\n * `PropagateChildAbort`, terminal-but-unjoined children are joined first, incomplete releases\n * are applied, provably childless reservations release exactly once, and only a parent with no\n * open child obligation settles aborted. Returns `undefined` for exactly that last case.\n */\nconst classifyDelegationAbort = (\n submissionId: SubmissionId,\n views: ReadonlyArray<DelegationCallView>,\n): RecoveryDecision | undefined => {\n const awaitAdmissions: Array<DelegationCallView> = [];\n const repairStartLinks: Array<DelegationCallView> = [];\n const nonterminal: Array<WaitingChild> = [];\n const terminalUnjoined: Array<WaitingChild> = [];\n const applyJoins: Array<DelegationCallView> = [];\n const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];\n\n for (const view of views) {\n if (view.reservation !== undefined && view.reservation.status === \"released\") {\n // Fully closed (release only follows the canonical join or a provably-childless orphan\n // decision): nothing left to abort, join, or release for this call.\n continue;\n }\n if (releasePendingReservation(view) !== undefined) {\n // The accounting decision is already frozen: finish the idempotent release; a second\n // (zero-consumed) freeze would conflict with the frozen decision.\n applyJoins.push(view);\n continue;\n }\n if (view.joined) {\n if (reservedReservation(view) !== undefined) applyJoins.push(view);\n continue;\n }\n if (view.childSubmissionId !== undefined) {\n if (!view.started) {\n // The child exists but the canonical start link is missing: repair it first so the\n // abort command targets a canonically linked child.\n repairStartLinks.push(view);\n continue;\n }\n const child = waitingChildOf(view, view.childSubmissionId);\n\n if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {\n terminalUnjoined.push(child);\n } else {\n nonterminal.push(child);\n }\n continue;\n }\n if (view.started || view.admission === \"admitted\") {\n repairStartLinks.push(view);\n continue;\n }\n if (view.requested) {\n if (view.admission === \"not-admitted\") {\n // Provably childless request under abort: never admit a child merely to abort it;\n // release the unused reservation exactly once.\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) orphanReservations.push(reservation);\n } else {\n // Indeterminate or unqueried: a child may exist — never release, settle, or re-admit\n // until the authoritative owner answers (SUB-031).\n awaitAdmissions.push(view);\n }\n continue;\n }\n const reservation = reservedReservation(view);\n\n if (reservation !== undefined) orphanReservations.push(reservation);\n // An open delegation call with no reservation carries no child obligation: establishment\n // never started, so the ordinary aborted settlement (with its unknown-audit for open\n // calls) is honest.\n }\n\n const awaitAdmission = awaitAdmissions[0];\n\n if (awaitAdmission !== undefined) {\n return AwaitChildAdmissionResolution.make({\n submissionId,\n toolCallId: awaitAdmission.toolCallId,\n });\n }\n const repairStartLink = repairStartLinks[0];\n\n if (repairStartLink !== undefined) {\n return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });\n }\n const abortChildren = nonEmpty(nonterminal);\n\n if (abortChildren !== undefined) {\n return PropagateChildAbort.make({ submissionId, children: abortChildren });\n }\n const settledChildren = nonEmpty(terminalUnjoined);\n\n if (settledChildren !== undefined) {\n return ResumeWaitingParent.make({ submissionId, children: settledChildren });\n }\n const applyJoin = applyJoins[0];\n\n if (applyJoin?.reservation !== undefined) {\n return ApplyJoinAccounting.make({\n submissionId,\n toolCallId: applyJoin.toolCallId,\n reservationId: applyJoin.reservation.reservationId,\n });\n }\n const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));\n\n if (orphans !== undefined) {\n return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });\n }\n\n return undefined;\n};\n\n/**\n * Pure recovery classifier (durability §14, DUR-013): a finite persisted snapshot plus canonical\n * evidence deterministically selects exactly one decision. Precedence, most-settled first\n * (plan §4.2/§4.3 — note the deliberate P5 reorder: canonical settlement and reservation beat\n * open tool calls, because a recorded terminal outcome is never revisited, DUR-002/DUR-015; and\n * the three S2 edits: the abort row propagates to nonterminal attached children, delegation\n * calls never mark Unknown, and the suspended row branches on the suspension reason):\n *\n * 1. `settled` → NoAction — terminal outcomes are never revisited (DUR-002).\n * 2. canonical settlement record → FinalizeLedgerFromHistory — history beats every ledger\n * marker (DUR-015), including a missing or divergent reservation AND open tool calls.\n * 3. reservation → FinalizeLedgerFromHistory when finalized, else AppendReservedSettlement —\n * the reserved record is the single exact outcome owed (DUR-011); it also beats a pending\n * abort intent (DUR-012).\n * 4. joined-side states (DUR-016): `joining` without canonical input → RevertJoining; `joining`\n * with canonical input → RepairJoinMarker (marker lost); `joined` + host settled →\n * SettleJoinedWithHost; `joined` + host live → AwaitHostSettlement (deferred).\n * 5. abort intent → the S2 abort rows (spec §13.1 request-abort-and-join): an unproven child\n * admission waits, an admitted-but-unlinked child repairs its start link, a nonterminal\n * attached child gets PropagateChildAbort — the parent does NOT settle — terminal children\n * are joined, incomplete releases applied, provably childless reservations released; ONLY a\n * parent with no open child obligation reaches SettleAborted, where open ordinary calls\n * become `ToolCallUnknown` audit records, never a rollback claim (§13). SettleAborted is\n * position-blind by design (P7 §7(c)): an aborted, never-claimed `ready` Submission earns it\n * ANYWHERE in the queue — the executor settles it immediately without waiting for it to head\n * the lane, because settlement order of never-run work is not execution order (DUR-004\n * bounds execution order; DUR-012 permits settling inactive accepted work without an\n * Attempt).\n * 6. ordinary open tool calls (state not yet `unknown`) → MarkUnknown — reconcile-then-mark,\n * never an automatic replay (DUR-009). Delegation calls are EXCLUDED (plan §4.3's most\n * important edit): their prepared-without-outcome state is provably replay-safe and routes\n * through rows 5/8/9 instead. A lane already `unknown` is in the DUR-017 resolution regime\n * (row 7) and is not re-marked.\n * 7. state `unknown` → ApplyUnknownResolutions when durable intents cover every open ordinary\n * call, else AwaitUnknownResolution.\n * 8. state `suspended` branches on the stored reason: `WaitingForChild` → ResumeWaitingParent\n * when every listed child is provably settled (replay the idempotent wake), else\n * AwaitChildSettlement (SUB-030); `ApprovalPending` keeps the P5 behavior — undecided\n * canonical approval requests → AwaitApprovalDecision (repairing a lost suspend transition\n * from history), every request decided → ResumeSuspended.\n * 9. the S2 establishment/join rows for a live parent (spec §13, most-repairing first):\n * ApplyJoinAccounting → CompleteChildAdmission → RepairSubagentStartLink →\n * AwaitChildAdmissionResolution → ResumePendingToolBatch (idempotent handler re-entry) →\n * EnsureWaitingForChild → ResumeWaitingParent → ReleaseOrphanChildReservation.\n * 10. declared-but-unprepared tool batch → ResumePendingToolBatch — the worker checks original\n * operation contracts; missing preparation proves no mutation dispatch, not readonly nonexecution (§15).\n * 11. `admitted` → a parent-linked Submission whose Thread lacks the canonical lineage\n * record defers (AwaitParentEstablishment: the parent's idempotent establishment\n * completes it); otherwise\n * CompleteMaterialization / RepairReadiness by Thread durability.\n * 12. otherwise → ApplyInput / RepairInputMarker / ResumeFromTurnBoundary by canonical input\n * evidence, with the ledger marker repaired from history, never the reverse.\n *\n * A CHILD Submission (one whose snapshot carries `parentLinkage`) classifies through exactly\n * the same rows as any Submission — child recovery proceeds under its own ownership token and\n * epoch (spec §13, SUB-020); nothing here consults the parent's lane.\n *\n * Ownership leases are deliberately ignored here: the executor's fenced claim is the only\n * authority over liveness, and a stale Attempt is fenced by producer epoch regardless (DUR-006).\n */\nexport const classifyRecovery = (\n snapshot: RecoverySnapshot,\n evidence: RecoveryEvidence,\n): RecoveryDecision => {\n const submissionId = snapshot.submission.submissionId;\n const state = snapshot.submission.state;\n\n if (state === \"settled\") {\n return NoAction.make({ submissionId });\n }\n if (evidence.recordedSettlementOutcome !== undefined) {\n return FinalizeLedgerFromHistory.make({\n submissionId,\n settlementId: snapshot.reservation?.settlementId ?? submissionSettlementId(submissionId),\n outcome: evidence.recordedSettlementOutcome,\n });\n }\n if (snapshot.reservation !== undefined) {\n if (snapshot.reservation.finalized) {\n return FinalizeLedgerFromHistory.make({\n submissionId,\n settlementId: snapshot.reservation.settlementId,\n outcome: snapshot.reservation.outcome,\n });\n }\n\n return AppendReservedSettlement.make({\n submissionId,\n settlementId: snapshot.reservation.settlementId,\n outcome: snapshot.reservation.outcome,\n });\n }\n if (state === \"joining\") {\n return evidence.inputRecorded\n ? RepairJoinMarker.make({ submissionId })\n : RevertJoining.make({ submissionId });\n }\n if (state === \"joined\") {\n if (evidence.hostSettlementOutcome !== undefined) {\n return SettleJoinedWithHost.make({\n submissionId,\n outcome: evidence.hostSettlementOutcome,\n });\n }\n\n return AwaitHostSettlement.make({\n submissionId,\n ...(snapshot.hostSubmissionId === undefined\n ? {}\n : { hostSubmissionId: snapshot.hostSubmissionId }),\n });\n }\n const delegationViews = delegationViewsOf(snapshot, evidence);\n\n if (snapshot.abortIntent !== undefined) {\n return (\n classifyDelegationAbort(submissionId, delegationViews) ?? SettleAborted.make({ submissionId })\n );\n }\n\n const delegationCallIds = new Set<string>(\n evidence.openDelegationCalls.map((call) => call.toolCallId),\n );\n\n const ordinaryOpenCalls = evidence.openToolCalls.filter(\n (call) => !delegationCallIds.has(call.toolCallId),\n );\n\n if (state !== \"unknown\" && ordinaryOpenCalls.length > 0) {\n return MarkUnknown.make({\n submissionId,\n reason: \"An ordinary Tool call may have executed without a canonical outcome\",\n openToolCallIds: ordinaryOpenCalls.map((call) => call.toolCallId),\n });\n }\n if (state === \"unknown\") {\n const resolved = new Set(\n snapshot.unknownResolutions.map((resolution) => resolution.toolCallId),\n );\n\n const covered = ordinaryOpenCalls.every((call) => resolved.has(call.toolCallId));\n\n return covered\n ? ApplyUnknownResolutions.make({ submissionId })\n : AwaitUnknownResolution.make({ submissionId });\n }\n const decided = new Set(snapshot.approvalDecisions.map((decision) => decision.toolCallId));\n\n const undecidedApprovals = evidence.approvalsPending.filter(\n (pending) => !decided.has(pending.toolCallId),\n );\n\n if (state === \"suspended\") {\n const reason = snapshot.suspension?.reason;\n\n if (reason !== undefined && reason._tag === \"WaitingForChild\") {\n const terminalChildIds = new Set(\n snapshot.childAttachments\n .filter(isTerminalAttachment)\n .map((attachment) => attachment.childSubmissionId),\n );\n\n return reason.children.every((child) => terminalChildIds.has(child.childSubmissionId))\n ? ResumeWaitingParent.make({ submissionId, children: reason.children })\n : AwaitChildSettlement.make({ submissionId });\n }\n\n return undecidedApprovals.length === 0\n ? ResumeSuspended.make({ submissionId })\n : AwaitApprovalDecision.make({ submissionId });\n }\n if (undecidedApprovals.length > 0) {\n return AwaitApprovalDecision.make({ submissionId });\n }\n const delegationDecision = classifyDelegationRepairs(submissionId, delegationViews);\n\n if (delegationDecision !== undefined) {\n return delegationDecision;\n }\n if (evidence.declaredPendingBatch !== undefined) {\n return ResumePendingToolBatch.make({\n submissionId,\n turn: evidence.declaredPendingBatch.turn,\n });\n }\n const workerCall = evidence.openWorkerCalls?.[0];\n\n if (workerCall !== undefined) {\n return ResumePendingToolBatch.make({ submissionId, turn: workerCall.turn });\n }\n if (state === \"admitted\") {\n // A parent-linked child never self-repairs readiness before its immutable\n // lineage record is canonical — the parent's establishment appends lineage BEFORE\n // markReady, so the parent completes the child idempotently.\n const linkage = snapshot.submission.parentLinkage ?? snapshot.parentLinkage;\n\n if (linkage !== undefined && !evidence.subagentLineageRecorded) {\n return AwaitParentEstablishment.make({\n submissionId,\n parentSubmissionId: linkage.parentSubmissionId,\n parentToolCallId: linkage.parentToolCallId,\n });\n }\n\n return evidence.threadMaterialized\n ? RepairReadiness.make({ submissionId })\n : CompleteMaterialization.make({ submissionId });\n }\n if (!evidence.inputRecorded) {\n return ApplyInput.make({ submissionId });\n }\n if (snapshot.inputApplied === undefined) {\n return RepairInputMarker.make({ submissionId });\n }\n\n return ResumeFromTurnBoundary.make({ submissionId });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,uBAAb,cAA0C,OAAO,MAC/C,2CACF,CAAC,CAAC;CACA,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,MAAM,iBAAiB,OAAO;AAChC,CAAC,CAAC,CAAC,CAAC;;;;;;AAOJ,IAAa,+BAAb,cAAkD,OAAO,MACvD,mDACF,CAAC,CAAC;CACA,MAAM,iBAAiB,OAAO;CAC9B,WAAW,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,0BAAb,cAA6C,OAAO,MA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wB,KAAK,EAAE,aAAa,CAAC;CACnD;CACA,IAAI,CAAC,SAAS,eACZ,OAAO,WAAW,KAAK,EAAE,aAAa,CAAC;CAEzC,IAAI,SAAS,iBAAiB,KAAA,GAC5B,OAAO,kBAAkB,KAAK,EAAE,aAAa,CAAC;CAGhD,OAAO,uBAAuB,KAAK,EAAE,aAAa,CAAC;AACrD"}
@@ -1,2 +1,2 @@
1
- import { $n as toolCallUnknownRecordId, An as projectRunJournalStream, Bn as subagentLineageBatchId, Cn as compactionBatchId, Dn as modelResponseInterruptedRecordId, En as modelResponseInterruptedBatchId, Fn as runIdForSubmission, Gn as subagentStartedRecordId, Hn as subagentRequestedBatchId, In as runStartedBatchId, Jn as toolCallPreparedRecordId, Kn as toolApprovalDecisionRecordId, Ln as runStartedRecordId, Mn as runCompletedRecordId, Nn as runDurationBatchId, On as modelResponseRecordId, Pn as runDurationRecordId, Qn as toolCallSettledRecordId, Rn as subagentJoinBatchId, Sn as childThreadIdFor, Tn as markUnknownBatchId, Un as subagentRequestedRecordId, Vn as subagentLineageRecordId, Wn as subagentStartedBatchId, Xn as toolCallResolvedRecordId, Yn as toolCallResolutionBatchId, Zn as toolCallResultBatchId, _n as RunJournalUsage, ar as turnIdForRun, bn as approvalDecisionBatchId, cr as turnResponseBatchId, er as toolStepSettledBatchId, gn as RunJournalProjection, hn as RunJournalError, ir as turnCanonicalBatch, jn as promptFromCanonicalRecords, kn as projectRunJournal, lr as turnResultsBatch, mn as JournalBoundary, nr as turnApprovalsBatchId, or as turnPreparedBatchId, qn as toolApprovalRequestRecordId, rr as turnBatchId, sr as turnResponseBatch, tr as toolStepSettledRecordId, ur as turnResultsBatchId, wn as compactionRecordId, xn as childIdempotencyKeyFor, yn as TurnCommitInput, zn as subagentJoinedRecordId } from "../Records-CV49DgQK.mjs";
2
- export { JournalBoundary, RunJournalError, RunJournalProjection, RunJournalUsage, TurnCommitInput, approvalDecisionBatchId, childIdempotencyKeyFor, childThreadIdFor, compactionBatchId, compactionRecordId, markUnknownBatchId, modelResponseInterruptedBatchId, modelResponseInterruptedRecordId, modelResponseRecordId, projectRunJournal, projectRunJournalStream, promptFromCanonicalRecords, runCompletedRecordId, runDurationBatchId, runDurationRecordId, runIdForSubmission, runStartedBatchId, runStartedRecordId, subagentJoinBatchId, subagentJoinedRecordId, subagentLineageBatchId, subagentLineageRecordId, subagentRequestedBatchId, subagentRequestedRecordId, subagentStartedBatchId, subagentStartedRecordId, toolApprovalDecisionRecordId, toolApprovalRequestRecordId, toolCallPreparedRecordId, toolCallResolutionBatchId, toolCallResolvedRecordId, toolCallResultBatchId, toolCallSettledRecordId, toolCallUnknownRecordId, toolStepSettledBatchId, toolStepSettledRecordId, turnApprovalsBatchId, turnBatchId, turnCanonicalBatch, turnIdForRun, turnPreparedBatchId, turnResponseBatch, turnResponseBatchId, turnResultsBatch, turnResultsBatchId };
1
+ import { $n as toolCallResolvedRecordId, An as modelResponseRecordId, Bn as runStartedRecordId, Cn as childIdempotencyKeyFor, Dn as markUnknownBatchId, En as compactionRecordId, Fn as runCompletionDigest, Gn as subagentRequestedBatchId, Hn as subagentJoinedRecordId, In as runDurationBatchId, Jn as subagentStartedRecordId, Kn as subagentRequestedRecordId, Ln as runDurationRecordId, Mn as projectRunJournalStream, Nn as promptFromCanonicalRecords, On as modelResponseInterruptedBatchId, Pn as runCompletedRecordId, Qn as toolCallResolutionBatchId, Rn as runIdForSubmission, Sn as approvalDecisionBatchId, Tn as compactionBatchId, Un as subagentLineageBatchId, Vn as subagentJoinBatchId, Wn as subagentLineageRecordId, Xn as toolApprovalRequestRecordId, Yn as toolApprovalDecisionRecordId, Zn as toolCallPreparedRecordId, _n as RunJournalError, ar as turnApprovalsBatchId, cr as turnIdForRun, dr as turnResponseBatchId, er as toolCallResultBatchId, fr as turnResultsBatch, gn as JournalBoundary, ir as toolStepSettledRecordId, jn as projectRunJournal, kn as modelResponseInterruptedRecordId, lr as turnPreparedBatchId, nr as toolCallUnknownRecordId, or as turnBatchId, pr as turnResultsBatchId, qn as subagentStartedBatchId, rr as toolStepSettledBatchId, sr as turnCanonicalBatch, tr as toolCallSettledRecordId, ur as turnResponseBatch, vn as RunJournalProjection, wn as childThreadIdFor, xn as TurnCommitInput, yn as RunJournalUsage, zn as runStartedBatchId } from "../Records-BIiRLqlz.mjs";
2
+ export { JournalBoundary, RunJournalError, RunJournalProjection, RunJournalUsage, TurnCommitInput, approvalDecisionBatchId, childIdempotencyKeyFor, childThreadIdFor, compactionBatchId, compactionRecordId, markUnknownBatchId, modelResponseInterruptedBatchId, modelResponseInterruptedRecordId, modelResponseRecordId, projectRunJournal, projectRunJournalStream, promptFromCanonicalRecords, runCompletedRecordId, runCompletionDigest, runDurationBatchId, runDurationRecordId, runIdForSubmission, runStartedBatchId, runStartedRecordId, subagentJoinBatchId, subagentJoinedRecordId, subagentLineageBatchId, subagentLineageRecordId, subagentRequestedBatchId, subagentRequestedRecordId, subagentStartedBatchId, subagentStartedRecordId, toolApprovalDecisionRecordId, toolApprovalRequestRecordId, toolCallPreparedRecordId, toolCallResolutionBatchId, toolCallResolvedRecordId, toolCallResultBatchId, toolCallSettledRecordId, toolCallUnknownRecordId, toolStepSettledBatchId, toolStepSettledRecordId, turnApprovalsBatchId, turnBatchId, turnCanonicalBatch, turnIdForRun, turnPreparedBatchId, turnResponseBatch, turnResponseBatchId, turnResultsBatch, turnResultsBatchId };
@@ -1,2 +1,2 @@
1
- import { A as toolApprovalRequestRecordId, B as turnBatchId, C as subagentLineageBatchId, D as subagentStartedBatchId, E as subagentRequestedRecordId, F as toolCallSettledRecordId, G as turnResponseBatchId, H as turnIdForRun, I as toolCallUnknownRecordId, K as turnResultsBatch, L as toolStepSettledBatchId, M as toolCallResolutionBatchId, N as toolCallResolvedRecordId, O as subagentStartedRecordId, P as toolCallResultBatchId, R as toolStepSettledRecordId, S as subagentJoinedRecordId, T as subagentRequestedBatchId, U as turnPreparedBatchId, V as turnCanonicalBatch, W as turnResponseBatch, _ as runDurationRecordId, a as childThreadIdFor, b as runStartedRecordId, c as markUnknownBatchId, d as modelResponseRecordId, f as projectRunJournal, g as runDurationBatchId, h as runCompletedRecordId, i as childIdempotencyKeyFor, j as toolCallPreparedRecordId, k as toolApprovalDecisionRecordId, l as modelResponseInterruptedBatchId, m as promptFromCanonicalRecords, o as compactionBatchId, p as projectRunJournalStream, q as turnResultsBatchId, r as approvalDecisionBatchId, s as compactionRecordId, t as RunJournalError, u as modelResponseInterruptedRecordId, v as runIdForSubmission, w as subagentLineageRecordId, x as subagentJoinBatchId, y as runStartedBatchId, z as turnApprovalsBatchId } from "../RunJournal-DRRRZmG7.mjs";
2
- export { RunJournalError, approvalDecisionBatchId, childIdempotencyKeyFor, childThreadIdFor, compactionBatchId, compactionRecordId, markUnknownBatchId, modelResponseInterruptedBatchId, modelResponseInterruptedRecordId, modelResponseRecordId, projectRunJournal, projectRunJournalStream, promptFromCanonicalRecords, runCompletedRecordId, runDurationBatchId, runDurationRecordId, runIdForSubmission, runStartedBatchId, runStartedRecordId, subagentJoinBatchId, subagentJoinedRecordId, subagentLineageBatchId, subagentLineageRecordId, subagentRequestedBatchId, subagentRequestedRecordId, subagentStartedBatchId, subagentStartedRecordId, toolApprovalDecisionRecordId, toolApprovalRequestRecordId, toolCallPreparedRecordId, toolCallResolutionBatchId, toolCallResolvedRecordId, toolCallResultBatchId, toolCallSettledRecordId, toolCallUnknownRecordId, toolStepSettledBatchId, toolStepSettledRecordId, turnApprovalsBatchId, turnBatchId, turnCanonicalBatch, turnIdForRun, turnPreparedBatchId, turnResponseBatch, turnResponseBatchId, turnResultsBatch, turnResultsBatchId };
1
+ import { A as toolApprovalDecisionRecordId, B as turnApprovalsBatchId, C as subagentJoinedRecordId, D as subagentRequestedRecordId, E as subagentRequestedBatchId, F as toolCallResultBatchId, G as turnResponseBatch, H as turnCanonicalBatch, I as toolCallSettledRecordId, J as turnResultsBatchId, K as turnResponseBatchId, L as toolCallUnknownRecordId, M as toolCallPreparedRecordId, N as toolCallResolutionBatchId, O as subagentStartedBatchId, P as toolCallResolvedRecordId, R as toolStepSettledBatchId, S as subagentJoinBatchId, T as subagentLineageRecordId, U as turnIdForRun, V as turnBatchId, W as turnPreparedBatchId, _ as runDurationBatchId, a as childThreadIdFor, b as runStartedBatchId, c as markUnknownBatchId, d as modelResponseRecordId, f as projectRunJournal, g as runCompletionDigest, h as runCompletedRecordId, i as childIdempotencyKeyFor, j as toolApprovalRequestRecordId, k as subagentStartedRecordId, l as modelResponseInterruptedBatchId, m as promptFromCanonicalRecords, o as compactionBatchId, p as projectRunJournalStream, q as turnResultsBatch, r as approvalDecisionBatchId, s as compactionRecordId, t as RunJournalError, u as modelResponseInterruptedRecordId, v as runDurationRecordId, w as subagentLineageBatchId, x as runStartedRecordId, y as runIdForSubmission, z as toolStepSettledRecordId } from "../RunJournal-DNs3PM4K.mjs";
2
+ export { RunJournalError, approvalDecisionBatchId, childIdempotencyKeyFor, childThreadIdFor, compactionBatchId, compactionRecordId, markUnknownBatchId, modelResponseInterruptedBatchId, modelResponseInterruptedRecordId, modelResponseRecordId, projectRunJournal, projectRunJournalStream, promptFromCanonicalRecords, runCompletedRecordId, runCompletionDigest, runDurationBatchId, runDurationRecordId, runIdForSubmission, runStartedBatchId, runStartedRecordId, subagentJoinBatchId, subagentJoinedRecordId, subagentLineageBatchId, subagentLineageRecordId, subagentRequestedBatchId, subagentRequestedRecordId, subagentStartedBatchId, subagentStartedRecordId, toolApprovalDecisionRecordId, toolApprovalRequestRecordId, toolCallPreparedRecordId, toolCallResolutionBatchId, toolCallResolvedRecordId, toolCallResultBatchId, toolCallSettledRecordId, toolCallUnknownRecordId, toolStepSettledBatchId, toolStepSettledRecordId, turnApprovalsBatchId, turnBatchId, turnCanonicalBatch, turnIdForRun, turnPreparedBatchId, turnResponseBatch, turnResponseBatchId, turnResultsBatch, turnResultsBatchId };
@@ -1,2 +1,2 @@
1
- import { A as ScheduleSnapshotPage, B as ScheduledInputAdmission, C as ScheduleRecord, D as ScheduleScope, E as ScheduleRetryReason, F as ScheduleTimingRequest, G as defaultSchedulingLimits, H as ScheduledInputRefused, I as ScheduleValidationError, L as ScheduleWake, M as ScheduleStore, N as ScheduleStoreFailure, O as ScheduleSkippedRange, P as ScheduleTiming, S as SchedulePending, T as ScheduleRetry, U as ScheduledInputRetryable, V as ScheduledInputFailure, W as SchedulingLimits, _ as ScheduleNotFound, a as ScheduleChange, b as SchedulePage, c as ScheduleDestination, d as ScheduleFailpointError, f as ScheduleId, g as ScheduleManagementOperation, h as ScheduleManagementAuthorization, i as ScheduleCapacityError, j as ScheduleStorageError, k as ScheduleSnapshot, l as ScheduleDueCursor, m as ScheduleKey, n as ScheduleAuthorizationError, o as ScheduleConfiguration, p as ScheduleInstant, r as ScheduleAuthorizer, s as ScheduleConflict, t as ScheduleAuthorizationDecision, u as ScheduleFailpoint, v as ScheduleOccurrenceAuthorization, w as ScheduleRefusal, x as SchedulePageRequest, y as ScheduleOwner, z as ScheduledEnvelope } from "../Schedule-DePbGfgd.mjs";
1
+ import { A as ScheduleSnapshotPage, B as ScheduledInputAdmission, C as ScheduleRecord, D as ScheduleScope, E as ScheduleRetryReason, F as ScheduleTimingRequest, G as defaultSchedulingLimits, H as ScheduledInputRefused, I as ScheduleValidationError, L as ScheduleWake, M as ScheduleStore, N as ScheduleStoreFailure, O as ScheduleSkippedRange, P as ScheduleTiming, S as SchedulePending, T as ScheduleRetry, U as ScheduledInputRetryable, V as ScheduledInputFailure, W as SchedulingLimits, _ as ScheduleNotFound, a as ScheduleChange, b as SchedulePage, c as ScheduleDestination, d as ScheduleFailpointError, f as ScheduleId, g as ScheduleManagementOperation, h as ScheduleManagementAuthorization, i as ScheduleCapacityError, j as ScheduleStorageError, k as ScheduleSnapshot, l as ScheduleDueCursor, m as ScheduleKey, n as ScheduleAuthorizationError, o as ScheduleConfiguration, p as ScheduleInstant, r as ScheduleAuthorizer, s as ScheduleConflict, t as ScheduleAuthorizationDecision, u as ScheduleFailpoint, v as ScheduleOccurrenceAuthorization, w as ScheduleRefusal, x as SchedulePageRequest, y as ScheduleOwner, z as ScheduledEnvelope } from "../Schedule-BNFlluAl.mjs";
2
2
  export { ScheduleAuthorizationDecision, ScheduleAuthorizationError, ScheduleAuthorizer, ScheduleCapacityError, ScheduleChange, ScheduleConfiguration, ScheduleConflict, ScheduleDestination, ScheduleDueCursor, ScheduleFailpoint, ScheduleFailpointError, ScheduleId, ScheduleInstant, ScheduleKey, ScheduleManagementAuthorization, ScheduleManagementOperation, ScheduleNotFound, ScheduleOccurrenceAuthorization, ScheduleOwner, SchedulePage, SchedulePageRequest, SchedulePending, ScheduleRecord, ScheduleRefusal, ScheduleRetry, ScheduleRetryReason, ScheduleScope, ScheduleSkippedRange, ScheduleSnapshot, ScheduleSnapshotPage, ScheduleStorageError, ScheduleStore, ScheduleStoreFailure, ScheduleTiming, ScheduleTimingRequest, ScheduleValidationError, ScheduleWake, ScheduledEnvelope, ScheduledInputAdmission, ScheduledInputFailure, ScheduledInputRefused, ScheduledInputRetryable, SchedulingLimits, defaultSchedulingLimits };
@@ -1,7 +1,7 @@
1
1
  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
- import { T as PersistedJson, h as Digest, p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
4
+ import { T as PersistedJson, h as Digest, p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
5
5
  import { AdmissionFence, AdmissionGroup } from "./SubmissionLedger.mjs";
6
6
  import { Context, Effect, Schema } from "effect";
7
7
  //#region src/durable/Schedule.ts
@@ -1,4 +1,4 @@
1
- import { M as ScheduleStore, N as ScheduleStoreFailure } from "../Schedule-DePbGfgd.mjs";
1
+ import { M as ScheduleStore, N as ScheduleStoreFailure } from "../Schedule-BNFlluAl.mjs";
2
2
  import { Effect, Schema } from "effect";
3
3
  //#region src/durable/ScheduleStoreConformance.d.ts
4
4
  declare const ScheduleStoreConformanceViolation_base: Schema.Class<ScheduleStoreConformanceViolation, Schema.TaggedStruct<"ScheduleStoreConformanceViolation", {
@@ -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 { ScheduleCapacityError, ScheduleId, ScheduleStore } from "./Schedule.mjs";
5
5
  import { Effect, Result, Schema } from "effect";
6
6
  //#region src/durable/ScheduleStoreConformance.ts
@@ -1,4 +1,4 @@
1
- import { C as ScheduleRecord, a as ScheduleChange, m as ScheduleKey, s as ScheduleConflict, y as ScheduleOwner } from "../Schedule-DePbGfgd.mjs";
1
+ import { C as ScheduleRecord, a as ScheduleChange, m as ScheduleKey, s as ScheduleConflict, y as ScheduleOwner } from "../Schedule-BNFlluAl.mjs";
2
2
  import { Result } from "effect";
3
3
  declare namespace ScheduleTransition_d_exports {
4
4
  export { applyScheduleChange, compareScheduleKeys, compareScheduleNames, scheduleDeadline, scheduleKeyOf, scheduleKeyString, scheduleOwnerKey, scheduleUsesCapacity };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { T as PersistedJson, p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
2
+ import { T as PersistedJson, p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
3
3
  import { AdmissionFence } from "./SubmissionLedger.mjs";
4
4
  import { ScheduleConflict } from "./Schedule.mjs";
5
5
  import { Result, Schema } from "effect";
@@ -1,6 +1,6 @@
1
1
  import { r as Principal } from "../Receipt-BAHyigAF.mjs";
2
- import { Ki as AdmissionFence, Ot as DurableSubmitAgent, h as DefinitionDigests } from "../Records-CV49DgQK.mjs";
3
- import { A as ScheduleSnapshotPage, B as ScheduledInputAdmission, C as ScheduleRecord, D as ScheduleScope, F as ScheduleTimingRequest, I as ScheduleValidationError, L as ScheduleWake, M as ScheduleStore, N as ScheduleStoreFailure, W as SchedulingLimits, c as ScheduleDestination, f as ScheduleId, j as ScheduleStorageError, k as ScheduleSnapshot, m as ScheduleKey, n as ScheduleAuthorizationError, r as ScheduleAuthorizer, y as ScheduleOwner } from "../Schedule-DePbGfgd.mjs";
2
+ import { At as DurableSubmitAgent, Gi as AdmissionFence, h as DefinitionDigests } from "../Records-BIiRLqlz.mjs";
3
+ import { A as ScheduleSnapshotPage, B as ScheduledInputAdmission, C as ScheduleRecord, D as ScheduleScope, F as ScheduleTimingRequest, I as ScheduleValidationError, L as ScheduleWake, M as ScheduleStore, N as ScheduleStoreFailure, W as SchedulingLimits, c as ScheduleDestination, f as ScheduleId, j as ScheduleStorageError, k as ScheduleSnapshot, m as ScheduleKey, n as ScheduleAuthorizationError, r as ScheduleAuthorizer, y as ScheduleOwner } from "../Schedule-BNFlluAl.mjs";
4
4
  import { Context, Crypto, Effect, Layer, Schema } from "effect";
5
5
  declare namespace Scheduling_d_exports {
6
6
  export { ScheduleCreateOptions, ScheduleDriver, ScheduleListOptions, ScheduleManagementFailure, ScheduleProcessFailure, ScheduleUpdateOptions, ScheduleWakeNoop, Scheduling };
@@ -1,2 +1,2 @@
1
- import { n as ScheduleWakeNoop, r as Scheduling, t as ScheduleDriver } from "../Scheduling-C3QpYn0W.mjs";
1
+ import { n as ScheduleWakeNoop, r as Scheduling, t as ScheduleDriver } from "../Scheduling-HFH0pST1.mjs";
2
2
  export { ScheduleDriver, ScheduleWakeNoop, Scheduling };
@@ -1,5 +1,5 @@
1
- import { d as ScheduleFailpointError } from "../Schedule-DePbGfgd.mjs";
2
- import { g as SubscriptionFailpointError } from "../Subscription-BR_8Cxh3.mjs";
1
+ import { d as ScheduleFailpointError } from "../Schedule-BNFlluAl.mjs";
2
+ import { g as SubscriptionFailpointError } from "../Subscription-BCQ3L9Zp.mjs";
3
3
  import { Effect, Schema } from "effect";
4
4
  import * as SqlClient from "effect/unstable/sql/SqlClient";
5
5
  //#region src/durable/SqlStorageV2Upgrade.d.ts
@@ -1,4 +1,4 @@
1
- import { p as DefinitionDigests } from "../Records-BAutSSnJ.mjs";
1
+ import { p as DefinitionDigests } from "../Records-DR1xtbXY.mjs";
2
2
  import { digestJson } from "./Digest.mjs";
3
3
  import { ScheduleConfiguration, ScheduleFailpoint, ScheduleInstant, ScheduleRecord, ScheduleRetry, ScheduledEnvelope } from "./Schedule.mjs";
4
4
  import { PreparedInput, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionFailpoint, SubscriptionRecord, subscriptionDeliveryKeyString } from "./Subscription.mjs";
@@ -1,5 +1,5 @@
1
- import { _ as Digest } from "../Records-CV49DgQK.mjs";
2
- import { C as SubscriptionScanCursors, O as SubscriptionStoreFailure, S as SubscriptionRetentionPolicy, _ as SubscriptionKey, b as SubscriptionRecord, d as SubscriptionDelivery, f as SubscriptionDeliveryKey, g as SubscriptionFailpointError, 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 { _ as Digest } from "../Records-BIiRLqlz.mjs";
2
+ import { C as SubscriptionScanCursors, O as SubscriptionStoreFailure, S as SubscriptionRetentionPolicy, _ as SubscriptionKey, b as SubscriptionRecord, d as SubscriptionDelivery, f as SubscriptionDeliveryKey, g as SubscriptionFailpointError, l as SubscriptionChange, m as SubscriptionError, n as DeliveryChange, o as SourcePartition, t as AcceptedEvent, v as SubscriptionLimits } from "../Subscription-BCQ3L9Zp.mjs";
3
3
  import { Context, Effect } from "effect";
4
4
  import * as SqlClientService from "effect/unstable/sql/SqlClient";
5
5
  //#region src/durable/SqlSubscriptionStore.d.ts
@@ -1,4 +1,4 @@
1
- import { h as Digest } from "../Records-BAutSSnJ.mjs";
1
+ import { h as Digest } from "../Records-DR1xtbXY.mjs";
2
2
  import { AcceptedEvent, DeliveryChange, SubscriptionChange, SubscriptionDelivery, SubscriptionDeliveryKey, SubscriptionError, SubscriptionFailpoint, SubscriptionKey, SubscriptionLimits, SubscriptionName, SubscriptionRecord, SubscriptionRetentionPolicy, SubscriptionScanCursors, SubscriptionStore, subscriptionDeliveryKeyString } from "./Subscription.mjs";
3
3
  import { applySubscriptionChange, applySubscriptionDeliveryChange, sameAcceptedEventIdentity, sameSourcePartition, subscriptionCanSelect, subscriptionDeliveryCanSelect, validateEventRetention } from "./SubscriptionTransition.mjs";
4
4
  import { Clock, Context, Effect, Result, Schema } from "effect";
@@ -1,3 +1,3 @@
1
1
  import { i as QueueSequence, n as JoinedToHost, r as Principal, t as IdempotencyKey } from "../Receipt-BAHyigAF.mjs";
2
- import { $a as SubmissionLookup, $i as AdmissionResult, Aa as OwnershipToken, Ba as ResolutionCompletedWithResult, Ca as MarkInputAppliedRequest, Da as OwnershipLost, Ea as MarkUnknownRequest, Fa as ReleaseOwnershipRequest, Ga as SettlementConflict, Gi as AdmissionConflict, Ha as ResolutionSafeToRetry, Hi as AbortIntent, Ia as RenewOwnershipRequest, Ja as SettlementReservationSnapshot, Ji as AdmissionIndeterminate, Ka as SettlementFinalization, Ki as AdmissionFence, La as ReservedChildBudget, Ma as RecoverySnapshot, Na as RecoverySnapshotRequest, Oa as OwnershipRenewal, Pa as ReleaseChildBudgetRequest, Qi as AdmissionResolution, Ra as ReservedSettlement, Sa as LedgerError, Ta as MarkReadyRequest, Ua as RevertJoiningRequest, Ui as AbortIntentRequest, Va as ResolutionNeverHappened, Vi as AbortCommand, Wa as Settlement, Wi as AdmissionAdmitted, Xa as SubmissionLedger, Xi as AdmissionPolicyError, Ya as SubmissionAdmissionFence, Yi as AdmissionNotAdmitted, Za as SubmissionLedgerFailure, Zi as AdmissionRequest, _a as DEFAULT_OWNERSHIP_LEASE_DURATION, _o as submissionInputBatchId, aa as BeginChildBudgetReleaseRequest, ao as SuspensionOutcome, ba as JoiningClaim, bo as submissionSettlementId, ca as ChildBudgetReservationSnapshot, co as UnknownResolution, da as ChildReservationStatus, do as UnknownResolutionIntent, ea as ApprovalConflict, eo as SubmissionLookupById, fa as ChildSettledNotification, fo as WaitingChild, ga as ClaimRequest, go as submissionAbortRecordId, ha as ClaimJoiningRequest, ho as submissionAbortBatchId, ia as AttachChildToReservationRequest, io as SuspendRequest, ja as ParentLinkage, ka as OwnershipSnapshot, la as ChildReservationConflict, lo as UnknownResolutionCommand, ma as Claim, mo as settlementFailureFromRecord, na as ApprovalDecisionIntent, no as SubmissionSnapshot, oa as ChildAttachmentSnapshot, oo as SuspensionReason, pa as ChildSettledOutcome, po as WaitingForChildSuspension, qa as SettlementReservation, qi as AdmissionGroup, ra as ApprovalPendingSuspension, ro as SubmissionState, sa as ChildBudgetReservationRequest, so as SuspensionSnapshot, ta as ApprovalDecisionCommand, to as SubmissionLookupByKey, ua as ChildReservationId, uo as UnknownResolutionConflict, va as InputAppliedMarker, vo as submissionInputRecordId, wa as MarkJoinedRequest, xa as LedgerCapabilities, xo as submissionSettlementRecordId, ya as JoinSnapshot, yo as submissionSettlementBatchId, za as ResolutionAbortSubmission } from "../Records-CV49DgQK.mjs";
2
+ import { $a as SubmissionLookupById, $i as ApprovalConflict, Aa as ParentLinkage, Ba as ResolutionNeverHappened, Bi as AbortCommand, Ca as MarkJoinedRequest, Da as OwnershipRenewal, Ea as OwnershipLost, Fa as RenewOwnershipRequest, Ga as SettlementFinalization, Gi as AdmissionFence, Ha as RevertJoiningRequest, Hi as AbortIntentRequest, Ia as ReservedChildBudget, Ja as SubmissionAdmissionFence, Ji as AdmissionNotAdmitted, Ka as SettlementReservation, Ki as AdmissionGroup, La as ReservedSettlement, Ma as RecoverySnapshotRequest, Na as ReleaseChildBudgetRequest, Oa as OwnershipSnapshot, Pa as ReleaseOwnershipRequest, Qa as SubmissionLookup, Qi as AdmissionResult, Ra as ResolutionAbortSubmission, Sa as MarkInputAppliedRequest, Ta as MarkUnknownRequest, Ua as Settlement, Ui as AdmissionAdmitted, Va as ResolutionSafeToRetry, Vi as AbortIntent, Wa as SettlementConflict, Wi as AdmissionConflict, Xa as SubmissionLedgerFailure, Xi as AdmissionRequest, Ya as SubmissionLedger, Yi as AdmissionPolicyError, Zi as AdmissionResolution, _a as InputAppliedMarker, _o as submissionInputRecordId, aa as ChildAttachmentSnapshot, ao as SuspensionReason, ba as LedgerCapabilities, bo as submissionSettlementRecordId, ca as ChildReservationConflict, co as UnknownResolutionCommand, da as ChildSettledNotification, do as WaitingChild, ea as ApprovalDecisionCommand, eo as SubmissionLookupByKey, fa as ChildSettledOutcome, fo as WaitingForChildSuspension, ga as DEFAULT_OWNERSHIP_LEASE_DURATION, go as submissionInputBatchId, ha as ClaimRequest, ho as submissionAbortRecordId, ia as BeginChildBudgetReleaseRequest, io as SuspensionOutcome, ja as RecoverySnapshot, ka as OwnershipToken, la as ChildReservationId, lo as UnknownResolutionConflict, ma as ClaimJoiningRequest, mo as submissionAbortBatchId, na as ApprovalPendingSuspension, no as SubmissionState, oa as ChildBudgetReservationRequest, oo as SuspensionSnapshot, pa as Claim, po as settlementFailureFromRecord, qa as SettlementReservationSnapshot, qi as AdmissionIndeterminate, ra as AttachChildToReservationRequest, ro as SuspendRequest, sa as ChildBudgetReservationSnapshot, so as UnknownResolution, ta as ApprovalDecisionIntent, to as SubmissionSnapshot, ua as ChildReservationStatus, uo as UnknownResolutionIntent, va as JoinSnapshot, vo as submissionSettlementBatchId, wa as MarkReadyRequest, xa as LedgerError, ya as JoiningClaim, yo as submissionSettlementId, za as ResolutionCompletedWithResult } from "../Records-BIiRLqlz.mjs";
3
3
  export { AbortCommand, AbortIntent, AbortIntentRequest, AdmissionAdmitted, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionIndeterminate, AdmissionNotAdmitted, AdmissionPolicyError, AdmissionRequest, AdmissionResolution, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationId, ChildReservationStatus, ChildSettledNotification, ChildSettledOutcome, Claim, ClaimJoiningRequest, ClaimRequest, DEFAULT_OWNERSHIP_LEASE_DURATION, IdempotencyKey, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, OwnershipToken, ParentLinkage, Principal, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, ResolutionAbortSubmission, ResolutionCompletedWithResult, ResolutionNeverHappened, ResolutionSafeToRetry, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionAdmissionFence, SubmissionLedger, SubmissionLedgerFailure, SubmissionLookup, SubmissionLookupById, SubmissionLookupByKey, SubmissionSnapshot, SubmissionState, SuspendRequest, SuspensionOutcome, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WaitingChild, WaitingForChildSuspension, settlementFailureFromRecord, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId };
@@ -3,7 +3,7 @@ import { AgentId, AttemptId, ReceiptId, SettlementId, SubmissionId, ThreadId, To
3
3
  import { IdempotencyKey, JoinedToHost, Principal, QueueSequence } from "../core/Receipt.mjs";
4
4
  import { RunUsageSummary } from "../core/Usage.mjs";
5
5
  import { l as InputMessage } from "../MessagingHost-CWi_PP3g.mjs";
6
- import { D as ProducerId, E as ProducerEpoch, J as ToolApprovalDecided, O as RecordEnvelope, Q as ToolCallResolved, R as SettlementFailureDiagnostic, T as PersistedJson, et as ToolCallUnknown, h as Digest, i as BatchId, k as RecordId, m as DeploymentId, p as DefinitionDigests, r as ApprovalDecision, rt as WorkerAdmission, t as AbortRequested, u as CanonicalSequence, z as SettlementOutcome } from "../Records-BAutSSnJ.mjs";
6
+ import { D as ProducerId, E as ProducerEpoch, J as ToolApprovalDecided, O as RecordEnvelope, Q as ToolCallResolved, R as SettlementFailureDiagnostic, T as PersistedJson, at as WorkerAdmission, et as ToolCallUnknown, h as Digest, i as BatchId, k as RecordId, m as DeploymentId, p as DefinitionDigests, r as ApprovalDecision, t as AbortRequested, u as CanonicalSequence, z as SettlementOutcome } from "../Records-DR1xtbXY.mjs";
7
7
  import { Context, Duration, Effect, Schema } from "effect";
8
8
  //#region src/durable/SubmissionLedger.ts
9
9
  var SubmissionLedger_exports = /* @__PURE__ */ __exportAll({
@@ -117,12 +117,12 @@ const OwnershipToken = identifier("OwnershipToken");
117
117
  * host Run's outcome.
118
118
  * - `suspended` — durably waiting for explicit approval decisions; the ownership period has
119
119
  * ended and the lane consumes no worker permit while the obligation stays owed.
120
- * - `unknown` — at least one ordinary Tool Call has a durable Unknown Outcome; the lane is
121
- * blocked until an authorized resolution covers every open call or a durable abort intent
122
- * authorizes cleanup and aborted settlement without Tool replay (DUR-012/DUR-017).
120
+ * - `unknown` — at least one Tool Call has a durable Unknown Outcome; this Submission is
121
+ * parked until an authorized resolution covers every open call or a durable abort intent
122
+ * authorizes cleanup without Tool replay. Later eligible input may run (DUR-012/DUR-017).
123
123
  *
124
- * `claim` never grants a `joining`, `joined`, or `suspended` head. An `unknown` head is
125
- * claimable only with a durable abort intent, under the ordinary lease and fencing rules.
124
+ * `claim` never grants or bypasses a `joining`, `joined`, or `suspended` head. It skips unknown
125
+ * work without an abort intent. Any live ownership in the Thread prevents another claim.
126
126
  */
127
127
  const SubmissionState = Schema.Literals([
128
128
  "admitted",
@@ -574,7 +574,7 @@ var ApprovalDecisionIntent = class extends Schema.Class("@effect-agent/thread/Ap
574
574
  }) {};
575
575
  /**
576
576
  * Durable Unknown marking for one Submission's open ordinary Tool Calls (DUR-009): state →
577
- * `unknown`, the lane blocks, ownership-free (recovery may mark without a claim). Idempotent.
577
+ * `unknown`, parking that Submission without changing ownership or the Thread epoch. Idempotent.
578
578
  */
579
579
  var MarkUnknownRequest = class extends Schema.Class("@effect-agent/thread/MarkUnknownRequest")({
580
580
  submissionId: SubmissionId,
@@ -773,10 +773,10 @@ var LedgerError = class extends Schema.TaggedError()("LedgerError", {
773
773
  * Marking an already-ready (or later-state) Submission is a no-op.
774
774
  * - `lookup` — read one Submission by identity or scoped idempotency key; strongly consistent
775
775
  * with prior ledger writes.
776
- * - `claim` — FIFO-head claim rule: claims ONLY the lowest unsettled `queueSequence` of the
777
- * requested Thread lane (DUR-004/DUR-005), regardless of that head's nonterminal state,
778
- * and returns `Option.none` when the lane has no unsettled work or the head's lease is still
779
- * live under another owner. A successful claim atomically bumps the Thread's producer
776
+ * - `claim` — claims the lowest unsettled `queueSequence` after skipping only unknown rows
777
+ * without abort intent. Approval, joining and child-wait barriers remain ordered. Returns
778
+ * `Option.none` when no eligible work exists or ANY lease in the Thread is live, including
779
+ * a lease belonging to the same producer. A successful claim atomically bumps the Thread's producer
780
780
  * epoch — fencing every stale Attempt out of canonical appends (DUR-006) — mints a fresh
781
781
  * `attemptId` and `ownershipToken`, and starts the ownership lease (D5: adapters default to
782
782
  * `DEFAULT_OWNERSHIP_LEASE_DURATION`, configurable). An expired lease makes the head
@@ -859,8 +859,9 @@ var LedgerError = class extends Schema.TaggedError()("LedgerError", {
859
859
  * with `ChildReservationConflict`. "A crash before release leaves budget unavailable until
860
860
  * repair, never available twice" (spec §12).
861
861
  * - `markUnknown` — idempotent, ownership-free (canonical evidence authorizes it): state →
862
- * `unknown`, the lane blocks and stops consuming worker permits while the accepted settlement
863
- * obligation stays visible (DUR-009/DUR-017). Fails with `SettlementConflict` once settled.
862
+ * `unknown`, parking the Submission while its accepted settlement obligation stays visible.
863
+ * Existing ownership must release or expire before another claim (DUR-009/DUR-017).
864
+ * Fails with `SettlementConflict` once settled.
864
865
  * - `recordUnknownResolution` — durable, idempotent per `(submissionId, toolCallId)`; a
865
866
  * divergent re-resolution fails with `UnknownResolutionConflict`. Transitions
866
867
  * `unknown → input-applied` once no open call remains, waking the lane. Fails with