phronomy 0.37.0 → 0.38.0

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 (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -0
  3. data/README.md +24 -2
  4. data/SECURITY.md +1 -1
  5. data/docs/architecture/agent-approval-recovery.md +320 -0
  6. data/docs/architecture/agent-child-approval-recovery.md +387 -0
  7. data/docs/architecture/agent-child-execution-recovery.md +425 -0
  8. data/docs/architecture/agent-dispatch-recovery.md +308 -0
  9. data/docs/architecture/agent-terminal-persistence-evidence.md +360 -0
  10. data/docs/architecture/agent-terminal-recovery.md +298 -0
  11. data/docs/architecture/agent-terminal-submission-recovery.md +275 -0
  12. data/docs/architecture/agent-tool-child-lifetime.md +29 -0
  13. data/docs/architecture/agent-transition-ownership.md +24 -0
  14. data/docs/architecture/backend-groups.md +6 -0
  15. data/docs/architecture/detached-outcome-proof-projection.md +576 -0
  16. data/docs/architecture/execution-abstraction-review.md +5 -0
  17. data/docs/architecture/handoff-dispatch-recovery.md +205 -0
  18. data/docs/architecture/handoff-initial-terminal-application.md +321 -0
  19. data/docs/architecture/initial-preparation-recovery.md +308 -0
  20. data/docs/architecture/multi-agent-handoff.md +17 -0
  21. data/docs/architecture/native-outcome-preparation.md +715 -0
  22. data/docs/architecture/native-parent-dispatch-recovery.md +460 -0
  23. data/docs/architecture/native-parent-outcome-recovery.md +644 -0
  24. data/docs/architecture/parent-child-terminal-acknowledgement.md +297 -0
  25. data/docs/architecture/r8-unit12.md +6 -3
  26. data/docs/architecture/r8-unit4.md +11 -2
  27. data/docs/architecture/recovery-physical-attempt.md +88 -0
  28. data/docs/architecture/recovery-submission-custody.md +247 -0
  29. data/docs/architecture/retained-attempts.md +229 -0
  30. data/docs/architecture/retained-outcome-materialization.md +636 -0
  31. data/docs/architecture/retained-outcome-publication.md +506 -0
  32. data/docs/architecture/storage-execution-boundaries.md +1 -1
  33. data/docs/architecture/structured-output-and-scope.md +15 -0
  34. data/docs/architecture/synchronous-participant-application.md +397 -0
  35. data/docs/architecture/synchronous-participant-contract.md +195 -0
  36. data/docs/architecture/team-admission-rejection.md +91 -0
  37. data/docs/architecture/team-cancellation-delivery.md +245 -0
  38. data/docs/architecture/team-child-retirement.md +104 -0
  39. data/docs/architecture/tracing.md +26 -0
  40. data/docs/architecture/workflow-terminal-ownership-design.md +25 -9
  41. data/docs/architecture/workflow-terminal-reconciliation.md +221 -0
  42. data/docs/architecture.md +16 -9
  43. data/docs/decisions/025-process-local-agent-ownership-and-runtime-admission.md +8 -0
  44. data/docs/features.md +3 -3
  45. data/docs/mcp-client.md +138 -5
  46. data/docs/migrations/orchestrator-subagent-dispatch.md +89 -0
  47. data/docs/migrations/vector-async-clients.md +18 -3
  48. data/docs/persistence-backends.md +30 -4
  49. data/docs/runtime-and-concurrency.md +235 -11
  50. data/lib/phronomy/agent/admission.rb +37 -17
  51. data/lib/phronomy/agent/api/agent.rb +25 -0
  52. data/lib/phronomy/agent/approval_recovery.rb +30 -0
  53. data/lib/phronomy/agent/approval_recovery_api.rb +61 -0
  54. data/lib/phronomy/agent/approval_recovery_error.rb +39 -0
  55. data/lib/phronomy/agent/approval_recovery_result.rb +94 -0
  56. data/lib/phronomy/agent/async_event_api.rb +22 -5
  57. data/lib/phronomy/agent/base.rb +76 -48
  58. data/lib/phronomy/agent/context_preparation.rb +10 -8
  59. data/lib/phronomy/agent/dispatch_recovery.rb +29 -0
  60. data/lib/phronomy/agent/dispatch_recovery_api.rb +84 -0
  61. data/lib/phronomy/agent/dispatch_recovery_error.rb +36 -0
  62. data/lib/phronomy/agent/dispatch_recovery_result.rb +93 -0
  63. data/lib/phronomy/agent/execution/agent_invocation.rb +11 -3
  64. data/lib/phronomy/agent/execution/approval_continuation_plan.rb +131 -0
  65. data/lib/phronomy/agent/execution/approval_parent_evidence.rb +116 -0
  66. data/lib/phronomy/agent/execution/approval_persistence_evidence.rb +111 -0
  67. data/lib/phronomy/agent/execution/approval_recovery_operation.rb +496 -0
  68. data/lib/phronomy/agent/execution/approval_resume_commit.rb +174 -10
  69. data/lib/phronomy/agent/execution/dispatch_continuation_delivery.rb +96 -0
  70. data/lib/phronomy/agent/execution/dispatch_persistence_evidence.rb +147 -0
  71. data/lib/phronomy/agent/execution/dispatch_preparation.rb +63 -7
  72. data/lib/phronomy/agent/execution/dispatch_recovery_operation.rb +495 -0
  73. data/lib/phronomy/agent/execution/execution_coordinator.rb +724 -158
  74. data/lib/phronomy/agent/execution/execution_outcome_committer.rb +312 -39
  75. data/lib/phronomy/agent/execution/execution_registry.rb +508 -13
  76. data/lib/phronomy/agent/execution/initial_persistence_evidence.rb +269 -0
  77. data/lib/phronomy/agent/execution/initial_preparation.rb +132 -40
  78. data/lib/phronomy/agent/execution/initial_preparation_recovery_operation.rb +513 -0
  79. data/lib/phronomy/agent/execution/invocation_transitions.rb +3 -0
  80. data/lib/phronomy/agent/execution/outcome_planning.rb +108 -0
  81. data/lib/phronomy/agent/execution/outcome_preparation.rb +81 -0
  82. data/lib/phronomy/agent/execution/outcome_recovery_operation.rb +609 -0
  83. data/lib/phronomy/agent/execution/outcome_text_projection.rb +73 -0
  84. data/lib/phronomy/agent/execution/outcome_write_plan.rb +48 -0
  85. data/lib/phronomy/agent/execution/runtime_record_encoder.rb +7 -4
  86. data/lib/phronomy/agent/execution/terminal_persistence_evidence.rb +280 -0
  87. data/lib/phronomy/agent/execution/terminal_recovery_operation.rb +38 -0
  88. data/lib/phronomy/agent/execution_change.rb +138 -26
  89. data/lib/phronomy/agent/execution_environment.rb +29 -0
  90. data/lib/phronomy/agent/execution_rejected_error.rb +34 -0
  91. data/lib/phronomy/agent/initial_preparation_recovery.rb +32 -0
  92. data/lib/phronomy/agent/initial_preparation_recovery_api.rb +85 -0
  93. data/lib/phronomy/agent/initial_preparation_recovery_error.rb +41 -0
  94. data/lib/phronomy/agent/initial_preparation_recovery_result.rb +115 -0
  95. data/lib/phronomy/agent/lifecycle/hosted_approval_context.rb +86 -0
  96. data/lib/phronomy/agent/lifecycle/hosted_invocation.rb +42 -10
  97. data/lib/phronomy/agent/lifecycle/identity_write.rb +101 -0
  98. data/lib/phronomy/agent/lifecycle/lifetime_api.rb +28 -0
  99. data/lib/phronomy/agent/lifecycle/ownership_registry.rb +136 -70
  100. data/lib/phronomy/agent/lifecycle/scope.rb +3 -3
  101. data/lib/phronomy/agent/outcome_recovery.rb +47 -0
  102. data/lib/phronomy/agent/outcome_recovery_api.rb +114 -0
  103. data/lib/phronomy/agent/outcome_recovery_error.rb +36 -0
  104. data/lib/phronomy/agent/outcome_recovery_result.rb +92 -0
  105. data/lib/phronomy/agent/output_contract.rb +16 -6
  106. data/lib/phronomy/agent/persistence/identity_receipt_repository.rb +61 -0
  107. data/lib/phronomy/agent/persistence/records.rb +2 -0
  108. data/lib/phronomy/agent/persistence/storage_schema.rb +2 -0
  109. data/lib/phronomy/agent/recovery/invocation_restorer.rb +8 -5
  110. data/lib/phronomy/agent/recovery/recovery_coordinator/continuation.rb +6 -4
  111. data/lib/phronomy/agent/recovery/recovery_coordinator/installation.rb +21 -43
  112. data/lib/phronomy/agent/recovery/recovery_coordinator.rb +19 -6
  113. data/lib/phronomy/agent/runtime_binding/engine_environment.rb +12 -0
  114. data/lib/phronomy/agent/state_writer.rb +4 -3
  115. data/lib/phronomy/agent/store.rb +7 -1
  116. data/lib/phronomy/agent/terminal_recovery.rb +41 -0
  117. data/lib/phronomy/agent/terminal_recovery_api.rb +101 -0
  118. data/lib/phronomy/agent/terminal_recovery_error.rb +36 -0
  119. data/lib/phronomy/agent/terminal_recovery_result.rb +67 -0
  120. data/lib/phronomy/agent/tool_execution/tool_approval_request.rb +25 -1
  121. data/lib/phronomy/common/values/serializable.rb +37 -4
  122. data/lib/phronomy/engine/concurrency/offload_pool.rb +32 -4
  123. data/lib/phronomy/engine/concurrency/pool_registry.rb +6 -0
  124. data/lib/phronomy/engine/event_loop.rb +161 -11
  125. data/lib/phronomy/engine/execution_binding.rb +4 -2
  126. data/lib/phronomy/engine/execution_receiver_binding.rb +5 -0
  127. data/lib/phronomy/engine/runtime/shutdown_result.rb +21 -0
  128. data/lib/phronomy/engine/runtime/timer_queue.rb +7 -2
  129. data/lib/phronomy/engine/runtime.rb +119 -15
  130. data/lib/phronomy/execution/attempt_completion.rb +91 -0
  131. data/lib/phronomy/execution/concurrency/cancellation_token.rb +7 -2
  132. data/lib/phronomy/execution/concurrency/physical_completion_task.rb +7 -2
  133. data/lib/phronomy/execution/execution.rb +17 -2
  134. data/lib/phronomy/execution/execution_receiver.rb +27 -0
  135. data/lib/phronomy/execution/execution_retirement.rb +30 -0
  136. data/lib/phronomy/execution/invocation_controls.rb +2 -2
  137. data/lib/phronomy/execution/retained_attempts.rb +179 -0
  138. data/lib/phronomy/execution/stopped_terminal_custody.rb +99 -0
  139. data/lib/phronomy/llm_adapter/response.rb +7 -1
  140. data/lib/phronomy/multi_agent/admission_registry.rb +6 -0
  141. data/lib/phronomy/multi_agent/durable_subagent_coordinator.rb +175 -39
  142. data/lib/phronomy/multi_agent/handoff_dispatch_evidence.rb +176 -0
  143. data/lib/phronomy/multi_agent/handoff_finalization_error.rb +33 -0
  144. data/lib/phronomy/multi_agent/handoff_history_release.rb +80 -0
  145. data/lib/phronomy/multi_agent/handoff_participant.rb +31 -6
  146. data/lib/phronomy/multi_agent/handoff_runner.rb +195 -21
  147. data/lib/phronomy/multi_agent/handoff_terminal_finalization.rb +176 -0
  148. data/lib/phronomy/multi_agent/native_approval_evidence.rb +26 -0
  149. data/lib/phronomy/multi_agent/native_child_authority.rb +135 -0
  150. data/lib/phronomy/multi_agent/native_dispatch_evidence.rb +43 -0
  151. data/lib/phronomy/multi_agent/native_outcome_evidence.rb +46 -0
  152. data/lib/phronomy/multi_agent/native_persistence_plan.rb +93 -0
  153. data/lib/phronomy/multi_agent/orchestrator.rb +28 -52
  154. data/lib/phronomy/multi_agent/reserved_child_admission.rb +90 -1
  155. data/lib/phronomy/multi_agent/store.rb +5 -34
  156. data/lib/phronomy/multi_agent/subagent_history_release.rb +88 -0
  157. data/lib/phronomy/multi_agent/team_cancellation_delivery_error.rb +21 -0
  158. data/lib/phronomy/multi_agent/team_cancellation_request.rb +134 -0
  159. data/lib/phronomy/multi_agent/team_coordinator.rb +174 -27
  160. data/lib/phronomy/persistence_composition/stores.rb +10 -3
  161. data/lib/phronomy/runtime_composition/execution_defaults.rb +18 -0
  162. data/lib/phronomy/storage/backends/in_memory.rb +3 -1
  163. data/lib/phronomy/storage/resource.rb +10 -1
  164. data/lib/phronomy/tools/agent.rb +7 -1
  165. data/lib/phronomy/tools/mcp.rb +210 -91
  166. data/lib/phronomy/tools/mcp_http_close_response.rb +23 -0
  167. data/lib/phronomy/tools/mcp_transport_registry.rb +210 -0
  168. data/lib/phronomy/tools/vector_search.rb +28 -5
  169. data/lib/phronomy/tracing/automatic.rb +8 -1
  170. data/lib/phronomy/version.rb +1 -1
  171. data/lib/phronomy/workflow/execution/workflow.rb +34 -0
  172. data/lib/phronomy/workflow/execution/workflow_execution_environment.rb +1 -0
  173. data/lib/phronomy/workflow/execution/workflow_execution_registry.rb +106 -7
  174. data/lib/phronomy/workflow/execution/workflow_runner.rb +53 -108
  175. data/lib/phronomy/workflow/execution/workflow_terminal_operation.rb +489 -0
  176. data/lib/phronomy/workflow/execution/workflow_terminal_persistence.rb +81 -0
  177. data/lib/phronomy/workflow/execution/workflow_terminal_recovery.rb +38 -0
  178. data/lib/phronomy/workflow/execution/workflow_terminal_recovery_error.rb +34 -0
  179. data/lib/phronomy/workflow/execution/workflow_terminal_recovery_result.rb +56 -0
  180. data/lib/phronomy/workflow/runtime_binding/workflow_engine_environment.rb +10 -1
  181. data/lib/phronomy/workflow/runtime_binding/workflow_task_session.rb +3 -1
  182. data/lib/phronomy/workflow/runtime_binding/workflow_terminal_policy.rb +2 -1
  183. data/scripts/api_snapshot.rb +46 -1
  184. data/sig/_private/phronomy/multi_agent/team_cancellation_request.rbs +19 -0
  185. data/sig/phronomy/agent/approval_recovery.rbs +54 -0
  186. data/sig/phronomy/agent/dispatch_recovery.rbs +49 -0
  187. data/sig/phronomy/agent/execution_contract.rbs +4 -1
  188. data/sig/phronomy/agent/execution_environment.rbs +2 -0
  189. data/sig/phronomy/agent/initial_preparation_recovery.rbs +48 -0
  190. data/sig/phronomy/agent/outcome_recovery.rbs +51 -0
  191. data/sig/phronomy/agent/store.rbs +1 -0
  192. data/sig/phronomy/agent/terminal_persistence_evidence.rbs +111 -0
  193. data/sig/phronomy/agent/terminal_recovery.rbs +46 -0
  194. data/sig/phronomy/agent.rbs +36 -0
  195. data/sig/phronomy/engine/concurrency/timer_bindings.rbs +2 -0
  196. data/sig/phronomy/engine/execution_binding.rbs +2 -1
  197. data/sig/phronomy/engine/execution_receiver.rbs +4 -0
  198. data/sig/phronomy/engine/observability.rbs +22 -1
  199. data/sig/phronomy/execution/execution.rbs +16 -1
  200. data/sig/phronomy/execution/execution_receiver.rbs +12 -0
  201. data/sig/phronomy/execution/execution_retirement.rbs +18 -0
  202. data/sig/phronomy/execution/stopped_terminal_custody.rbs +19 -0
  203. data/sig/phronomy/handoff.rbs +1 -0
  204. data/sig/phronomy/multi_agent/handoff_finalization_error.rbs +18 -0
  205. data/sig/phronomy/multi_agent/store.rbs +1 -1
  206. data/sig/phronomy/multi_agent/team_cancellation_delivery_error.rbs +9 -0
  207. data/sig/phronomy/persistence_composition.rbs +2 -1
  208. data/sig/phronomy/storage/contracts.rbs +2 -1
  209. data/sig/phronomy/tools/mcp.rbs +27 -0
  210. data/sig/phronomy/workflow.rbs +42 -0
  211. metadata +104 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea854d0434bfc24dd1bb49dc2420ead34b2a1ba1e0b5f9749e96cb91b0bc9108
4
- data.tar.gz: 5fe68a72f9a4f7856f82ef564a0326b2d121d420bc7fa80b81d268430768b8a4
3
+ metadata.gz: e598d11b85a284c81c07f0354afd38d14dfed928d3cae1a828b97690afc35af5
4
+ data.tar.gz: de34972482feb6d1e3c9acb4e8a0373b01b66469eef9db2d81ccf6e3d8cc415d
5
5
  SHA512:
6
- metadata.gz: 1aa266e0d0fd39a069f955c314b58c35d9ac9976a6273d2705477e273501a938dbf06dd217802f25ae869ef5527527d837e851197582d43593d8d2fab1920700
7
- data.tar.gz: 5cdc5a5e88ece7863c51055aa28f647603171a801a9206b3422b09ace4aa5c423a0347668e2fee0d8615ee3e22c97b6180ad581b866e57033ec1375f61be12ff
6
+ metadata.gz: 7123677d3efd5dff66b1207e2f51b9705ad9697d4ee45e153cd08d9784c05edd98f0725da849e6d84f4830273ab1ebb616453488ad03df27c38a8c4f8a808fee
7
+ data.tar.gz: 5e77fd850e3794fe2f16bf20d677deeea2126660d0a22a935cfc21598493e4bd96d03dd6044743130bffd94749594b58a4bfbd741bccded29d3db8397d9c017b
data/CHANGELOG.md CHANGED
@@ -12,6 +12,93 @@ Release history for 0.14.0 and earlier is archived in
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [0.38.0] - 2026-12-02
16
+
17
+ ### Added
18
+
19
+ - Add explicit recovery for retained Agent terminal, dispatch, approval, initial
20
+ preparation and native outcome operations, and for Workflow terminal saves.
21
+ Reconciliation observes the original operation; guarded retries use captured
22
+ writes rather than replaying completed application work.
23
+ - Add in-process stopped-terminal custody and Runtime shutdown reconciliation
24
+ for supported ownership transfers and deferred cleanup. These APIs do not
25
+ provide general process-crash recovery.
26
+ - Add MCP cleanup handles and designated transfer receipts to retain unresolved
27
+ transport ownership across interrupted or failed close operations.
28
+ - Add the optional Agent identity receipt resource and reconciliation API for
29
+ unconfirmed create and purge commits. Add guarded Handoff resume and terminal
30
+ routing, and synchronous participant approval preparation.
31
+ - Recover a transient native child or extension read without repeating completed
32
+ Agent or Tool work. An explicit retry can finish the first outcome selection.
33
+ After a failed plain-text conversion, the original owner can accept verified
34
+ text for the same execution revision and reuse its encoded records.
35
+ - Transfer a confirmed terminal disposition from a stopped standalone Agent
36
+ or Workflow to an in-process recipient. A read failure, active worker or
37
+ competing recipient leaves the operation with its existing owner.
38
+
39
+ ### Changed
40
+
41
+ - Reserved Agent starts expose `Agent::ExecutionRejectedError`, with the reserved
42
+ Agent/execution IDs and original cause, for validation failures detected before
43
+ durable admission is attempted. Ordinary invocation errors and uncertain
44
+ admission, recovery and observation failures keep their existing contracts.
45
+
46
+ ### Fixed
47
+
48
+ - Settle Agent creation, hydration and purge reservations when the caller is
49
+ interrupted. Retry a hydration interrupted during its initial reads, and keep
50
+ the identity reserved when recovery submission may already have occurred.
51
+
52
+ - Retain explicit Team cancellation requests and wake the existing synchronous
53
+ Team host while it waits for a child. Record cancellation before signalling
54
+ children without submitting another worker job. Unconfirmed persistence
55
+ raises `MultiAgent::TeamCancellationDeliveryError` with exact Team/run IDs;
56
+ retain the request for explicit `resume` or `cancel`, including across the
57
+ original observer's return and Runtime shutdown accounting.
58
+ - Give fresh Agent Tool children their own execution wiring instead of forwarding
59
+ the parent's reserved ID, admission, coordination participants and observers.
60
+ Preserve application context, cancellation and shared deadline controls.
61
+ - Keep rejected execution registration and its terminal delivery isolated from
62
+ an existing owner with the same ID. Session startup failure after a successful
63
+ installation uses normal owned terminal cleanup; an unregistered start never
64
+ releases the other owner's state or drains its completion waiters.
65
+ - Retire the loaded coordinator and worker Agents of confirmed terminal Team
66
+ runs after their observed physical work finishes, without delaying the saved
67
+ Team result or deleting durable history. Drop terminal coordinator class
68
+ entries while preserving active and recovery-required runs.
69
+ - Report failed Team child retirement with its identities and retain the live
70
+ owner. Terminal `resume` can retry release without replaying business work;
71
+ read-only `result` does not initiate cleanup.
72
+ - Isolate logger failures while reporting cancellation, physical-completion and
73
+ timer callback errors. Later callbacks still run, queued cancellation remains
74
+ effective, and timer accounting and Runtime delivery continue.
75
+ - Validate and snapshot Team `durable_context` before accepting a new run. An
76
+ invalid value no longer creates an active Team execution.
77
+ - Finish an accepted Team run when its child start is definitively rejected and
78
+ a guarded public observation confirms the reserved execution is absent. Save
79
+ the Team failure and release its active-run slot in the same transaction;
80
+ preserve recovery when a competing child exists or observation/commit is
81
+ uncertain. This also handles invalid input retained by earlier versions.
82
+
83
+ ### Compatibility
84
+
85
+ - The optional Agent identity receipt resource stores one control record per
86
+ Agent ID. Enable it for an existing Store only after all writers can update
87
+ it; the built-in in-memory Store enables it by default. Stores without the
88
+ resource retain the existing narrower recovery behavior.
89
+ - Team cancellation-delivery failures are now observable operation errors,
90
+ separate from saved business cancellation. A new turn cannot bypass an older
91
+ unresolved intent on the same Team. Existing call signatures and saved record
92
+ formats remain unchanged. See [cancellation delivery](docs/architecture/team-cancellation-delivery.md).
93
+ - The new reserved-start error and Team failure behavior change the public error
94
+ contract. Call signatures and saved record formats are unchanged. No child
95
+ execution is fabricated, and no new execution or coordination layer is added.
96
+ See [Team admission rejection](docs/architecture/team-admission-rejection.md).
97
+ - Calling an Orchestrator-generated subagent Tool without a reserved parent
98
+ invocation now fails before child creation. Standalone callers can use
99
+ `Tools::Agent.from_agent` for output or `Orchestrator#subagent` for an
100
+ identity-bearing result. [Migration examples](docs/migrations/orchestrator-subagent-dispatch.md)
101
+
15
102
  ## [0.37.0] - 2026-11-21
16
103
 
17
104
  ### Changed
data/README.md CHANGED
@@ -37,7 +37,7 @@ tracking `main` directly.
37
37
 
38
38
  See [Features and Application Programming Interface (API) stability](docs/features.md) for the full feature matrix.
39
39
 
40
- The following table describes the application APIs available in v0.37.0.
40
+ The following table describes application API availability and stability for v0.38.0.
41
41
  The public persistence resource catalogs are available starting with v0.35.0.
42
42
  The sharing, Tool composition and Context budgeting operations remain
43
43
  Experimental; their introduction version is shown below.
@@ -57,26 +57,48 @@ the current saved representation.
57
57
  | API | Stability | Contract |
58
58
  |---|---|---|
59
59
  | `PersistenceComposition.resources` and `.agent_resources` | Beta (since v0.35.0) | Supply canonical frozen resource catalogs to an application-selected backend for `.build(backend:)` or `.agent(backend:)`, without creating a backend, stores or Runtime. [Backend catalog](docs/persistence-backends.md#supplying-a-backend-catalog) |
60
+ | `PersistenceComposition.identity_receipt_resource` | Since v0.38.0 | Supply the optional Agent identity receipt resource for reconciling uncertain create or purge commits. Enable it only after all Store writers can update it. [Identity recovery](docs/runtime-and-concurrency.md#process-local-agent-identity-ownership-and-admission) |
60
61
  | `Persistence::Migration::InitialFormatMigration` | Removed (v0.34.0) | The pre-S3 conversion API is retired without a replacement. Current domain codecs and the separate Unit4 snapshot migration remain. [Legacy-format cleanup](docs/migrations/legacy-format-removal.md) |
61
62
  | `Context::ContextPolicyInput#input_token_limit / #with_input_token_limit` and protected `ContextPolicy#estimate_tokens` | Experimental (since v0.33.0) | Inspect and constrain selection budgets and estimate candidate content through Context-owned operations. [Policy budgeting](docs/context-policy-budgeting.md) |
62
63
  | `Agent::Base.with_tools(definitions, id:, version:)` | Experimental (since v0.33.0) | Derive an Agent class with a complete replacement Tool map and explicit definition identity while preserving Phronomy authoring settings and filters. Orchestrator derivation also preserves native subagent registrations for retained child Tools, including their aliases. [Tool composition](docs/shared-state-sharing.md#deriving-an-agent-with-a-complete-tool-set) |
63
64
  | `MultiAgent::SharedState.sharing(provider, id:, version:)`, `SharedState::Binding` and `SharedState::MemberLifecycleError` | Experimental (since v0.33.0) | Sequential coordination releases its terminal member Agents in both default and custom modes; an optional invocation-scoped provider supplies application-owned data and Tools. [Sharing and member lifetime contract](docs/shared-state-sharing.md) |
64
65
  | `Tool::Base#approval_display(arguments:, facts:)` | Beta (since v0.33.0) | The Tool selects the arguments and derived facts a person can see in an approval request. [Approval display](docs/runtime-and-concurrency.md#tool-approval-display) |
66
+ | `Agent::ExecutionChange#prepare_approval_in(scope)` and `commit_in(..., fail_unavailable_approval:)` | Beta (since v0.38.0) | An opting-in synchronous participant checks the original display before committing an approval, a durable coordination wait, or an explicit preparation failure. [Participant contract](docs/architecture/synchronous-participant-contract.md#prepare-an-approval-before-choosing-its-outcome) |
65
67
  | `Runtime#shutdown` result predicates `cleanup_complete?` and `clean?` | Beta | Check resource release with `cleanup_complete?`; `clean?` additionally requires a graceful shutdown. The obsolete `success?` alias is removed in v0.34.0. [Cleanup migration](docs/migrations/cleanup-audit.md#runtime-cleanup-completion) |
68
+ | `Agent#supply_outcome_text`, `OutcomeRecovery#output_text_required?` and `#expected_execution_revision` | Since v0.38.0 | Bind an independently verified plain-text result to its original execution and revision after the native text conversion fails. Reconcile the original operation before a guarded retry. [Retained outcome preparation](docs/architecture/retained-outcome-materialization.md) |
69
+ | `Agent::TerminalRecovery#new_stopped_recipient`, `Agent::OutcomeRecovery#new_stopped_recipient`, `WorkflowTerminalRecovery#new_stopped_recipient` and `StoppedTerminalCustody#reconcile` / `#retry_save` | Since v0.38.0 | A designated in-process recipient accepts a verified terminal disposition after the original dispatcher and workers stop. Native Agent outcomes support read-only transfer of a verified terminal result. A standalone Agent can explicitly retry its exact captured save. Keep the recipient across retries. [Shutdown management](docs/runtime-and-concurrency.md) |
70
+ | `Runtime#reconcile_shutdown` and `Runtime::ShutdownManagementResult` | Since v0.38.0 | Check outstanding cleanup on the original Runtime after shutdown. The report identifies blockers and participant errors and retains the original shutdown result. [Shutdown management](docs/runtime-and-concurrency.md) |
71
+ | `Tools::Mcp.cleanup_handles`, `#cleanup_handle`, `CleanupHandle`, `CleanupTransfer` and `CleanupError` | Since v0.38.0 | Inspect pending transports, finish a queued close, or transfer a failed close to the designated recipient with `accept!`. [MCP cleanup](docs/mcp-client.md#management-after-a-failed-close) |
72
+ | `MultiAgent::Store#forget_subagents(require_import: true)` | Since v0.38.0 | Require matching durable child-result import before deleting subagent history. [History removal](docs/runtime-and-concurrency.md) |
66
73
  | `Phronomy::EventLoopReentrancyError` | Beta | Raised when a synchronous operation would block the EventLoop control thread. The obsolete `SchedulerReentrancyError` subclass is removed in v0.34.0. [Cleanup migration](docs/migrations/cleanup-audit.md#eventloop-reentrancy-errors) |
67
74
  | `Phronomy::LLMAdapter::LMStudio` | Beta | Explicit known-output-error identification and bounded opt-in retry; [policy and evidence limits](docs/architecture/lm-studio-output-failures.md) |
68
75
  | Agent `output_schema:`, `schema_delivery:`, `Agent::OutputError` and `OutputParser::JsonSchemaParser` | Beta | Agent returns validated immutable JSON or an explicit output failure; [contract and migration](docs/architecture/structured-output-and-scope.md) |
69
76
  | Agent `start_reserved_async`, `resume_async` and `resume` | Beta (behavior changed in v0.37.0) | Return the confirmed execution result, including `status: :failed` and saved `OutputError` diagnostics. Errors in starting, resuming or observing the execution remain operation failures; [exact execution results](docs/architecture/structured-output-and-scope.md#exact-execution-results) |
77
+ | `Agent::ExecutionRejectedError` and Team rejection handling | Beta (since v0.38.0) | Distinguish reserved-start validation rejection from uncertain execution outcomes. Team validates durable input before admission and records a confirmed child-start rejection as its own failure after a guarded absence check; [rejection contract](docs/architecture/team-admission-rejection.md) |
78
+ | `MultiAgent::TeamCoordinator#invoke / #stream / #resume / #result` | Beta | Terminal runs retire internally owned child Agents after physical work completes; saved outcomes remain authoritative. `result` stays read-only and terminal `resume` can retry failed retirement. Automatic retirement is available since v0.38.0; [child lifetime](docs/architecture/team-child-retirement.md) |
79
+ | `MultiAgent::TeamCancellationDeliveryError` | Beta (since v0.38.0) | Exact Team/run identities for unresolved token-originated cancellation delivery. Retained intent can be retried with the same run's `resume` or `cancel`; [control delivery and lifetime](docs/architecture/team-cancellation-delivery.md). |
80
+ | Agent `pending_terminal_recovery(execution_id:)`, `reconcile_terminal[_async](recovery:)`, `retry_terminal[_async](recovery:)`, `Agent::TerminalRecovery`, `Agent::TerminalRecoveryResult` and `Agent::TerminalRecoveryError` | Since v0.38.0 | Observe retained terminal saves on the original running or draining Runtime. Reconciliation performs no persistence writes; explicit retry saves captured records without replaying application work. Saved outcome, owner application and release remain separate. The original-owner APIs require a running or draining Runtime; the separate stopped-recipient operation is described above. [Recovery contract](docs/architecture/agent-terminal-recovery.md) |
81
+ | Agent `.reconcile_identity(agent_id, persistence:)` | Since v0.38.0 | Re-read an unconfirmed Agent create or purge on its original Store and running Runtime. Release or restore local ownership only after matching the original durable evidence. [Runtime and concurrency](docs/runtime-and-concurrency.md) |
82
+ | Agent `retry_terminal_submission[_async](recovery:)` and `Agent::TerminalRecoveryResult#submission_state` | Since v0.38.0 | Explicitly resubmit terminal work only after the execution mechanism proves it was not admitted. Validation and encoding may run for the first time; provider/Tool work is not repeated. Captured-write retry stays separate. [Submission recovery](docs/architecture/agent-terminal-submission-recovery.md) |
83
+ | Agent `pending_outcome_recovery(execution_id:)`, `reconcile_outcome[_async](recovery:)`, `retry_outcome[_async](recovery:)`, `retry_outcome_submission[_async](recovery:)`, `Agent::OutcomeRecovery`, `Agent::OutcomeRecoveryResult` and `Agent::OutcomeRecoveryError` | Since v0.38.0 | Recover a native parent's captured final, coordination-wait or approval-wait save through its original owner. Readback and explicit captured-write retry remain separate; `saved_outcome` identifies the saved kind. Releasing recovery custody does not finish a waiting job. Existing terminal recovery remains actual-final only; no process-loss takeover. [Native outcome contract](docs/architecture/native-parent-outcome-recovery.md) |
84
+ | Agent `pending_approval_recovery(execution_id:)`, `reconcile_approval[_async](recovery:)`, `Agent::ApprovalRecovery`, `Agent::ApprovalRecoveryResult` and `Agent::ApprovalRecoveryError` | Since v0.38.0 | Read retained supported standalone, child/restored and native-parent approval decisions on the original running or draining Runtime without retrying approval writes. Confirmed pre-state restores the same wait; confirmed post-state can start the authorized continuation with a fresh execution observation. Native decisions require fresh child authority. Approval worker completion does not mean execution completion; no stopped-owner or process-crash recovery. [Approval recovery](docs/architecture/agent-approval-recovery.md), [native decisions](docs/architecture/native-parent-outcome-recovery.md#recover-the-native-parents-own-approval-decision) |
85
+ | Agent `pending_dispatch_recovery(execution_id:)`, `reconcile_dispatch[_async](recovery:)`, `retry_dispatch[_async](recovery:)`, `Agent::DispatchRecovery`, `Agent::DispatchRecoveryResult` and `Agent::DispatchRecoveryError` | Since v0.38.0 | Reconcile retained pre-dispatch preparation through the original live Agent. Explicit retry writes only the captured persistence proposal; preparation and external work are not replayed. Saved permission, continuation handoff and physical completion remain separate; includes bounded [native parent dispatch](docs/architecture/native-parent-dispatch-recovery.md) with fresh child-authority checks. No stopped-owner or process-crash recovery. [Dispatch recovery](docs/architecture/agent-dispatch-recovery.md) |
86
+ | Agent `pending_initial_preparation_recovery`, `reconcile_initial_preparation[_async](recovery:)`, `retry_initial_preparation[_async](recovery:)`, `Agent::InitialPreparationRecovery`, `Agent::InitialPreparationRecoveryResult` and `Agent::InitialPreparationRecoveryError` | Since v0.38.0 | Recover admission, the first manifest or preparation failure through one original initial owner. Confirmed admission may start preparation once; explicit retry repeats captured writes only. Original controls survive observer failure, and same-execution observation is separate from custody release. Standalone and framework reservations are supported; opaque admission uncertainty and stopped-owner recovery remain outside this contract. [Initial preparation recovery](docs/architecture/initial-preparation-recovery.md) |
87
+ | `MultiAgent::HandoffRunner#resume(execution_id, config: {})` | Since v0.38.0 | Continue the exact recorded Handoff chain after explicit Agent dispatch recovery. Terminal history returns durable execution fields plus `agent` without starting another turn; unresolved retained dispatch requires the original Agent recovery API. Ordinary `invoke` remains turn entry. [Handoff recovery](docs/architecture/handoff-dispatch-recovery.md) |
88
+ | Handoff initial Target terminal finalization and `MultiAgent::HandoffFinalizationError` | Since v0.38.0 | Explicit `invoke`, `resume` or `cancel` completes current pending routing for an exact failed, cancelled or blocked Target after original Source/Target custody is released. Saved failure stays failure; `result` remains read-only. A finalization error preserves the saved outcome and routing error; a later explicit call retries only guarded routing work. [Complete application](docs/architecture/handoff-initial-terminal-application.md) |
70
89
  | Agent `transcript_messages` / `transcript_messages_async` | Beta | Read immutable conversation Message values with the same restoration rules as execution results; [reading conversation state](docs/getting-started.md) |
71
90
  | `Phronomy::GeneratorVerifier`, its approval/lifetime operations and immutable `Result` with output-failure diagnostics | Beta | [Generation and structured-output contract](docs/architecture/structured-output-and-scope.md) |
72
91
  | `Agent.open_scope`, `Agent::Scope`, `Agent::Base#unload_async / #unload!`, `AgentUnloadedError` and `Agent::ScopeCleanupError` | Beta | Runtime-bound ownership and safe release of idle Agent incarnations without changing saved history or closing the Store; [contract](docs/architecture/dx05-agent-scope.md) |
73
92
  | `Agent::Base#start_hosted`, `Agent::HostedInvocation`, `Agent::ApprovalWait` and `Agent::Store#standalone_approval_wait` | Beta | Added in v0.32.0. Detach an exclusively owned standalone Agent at its first committed approval wait, then restore the same execution in another process; delivery claims and worker fencing remain application responsibilities; [contract](docs/runtime-and-concurrency.md#hosting-a-standalone-agent-through-approval) |
74
93
  | `Agent::HostedInvocation#detach!(execution_id:, approval_request_id:)` | Beta | Added in v0.32.0. Release an exclusively owned Orchestrator and its single direct subagent at the child's approval wait. A second worker can resume both saved executions while the first worker handles other requests. [Contract](docs/runtime-and-concurrency.md#hosting-an-orchestrator-through-a-child-approval) |
75
94
  | `MultiAgent::Orchestrator#approve_hosted_child` | Beta | Added in v0.32.0. Answer the current approval on a restored direct child. The returned handle can release the pair again if that child requests another approval during the same execution. [Contract](docs/runtime-and-concurrency.md#hosting-an-orchestrator-through-a-child-approval) |
76
- | `MultiAgent::Orchestrator#unload_with_completed_child!` | Beta | Added in v0.32.0. Release local owners after a direct child result has been imported and the parent has finished. The saved executions, transcripts and coordination history remain available. [Contract](docs/runtime-and-concurrency.md#releasing-a-completed-orchestrator-and-child) |
95
+ | `Agent::ApprovalRecoveryResult#hosted_invocation` and child/restored approval recovery | Since v0.38.0 | Reconcile the original decision on a direct correlated child or restored wait. A recovered hosted continuation can return an independent handle for its next approval detach; original failed observations remain closed. [Child approval recovery](docs/architecture/agent-child-approval-recovery.md) |
96
+ | `MultiAgent::Orchestrator#unload_with_completed_child!` | Beta | Added in v0.32.0. Release local owners after a direct child result has been imported and the parent has finished. Since v0.38.0, a separate acknowledgement by the terminal parent can also establish child custody. The saved executions, transcripts and coordination history remain available. [Contract](docs/runtime-and-concurrency.md#releasing-a-completed-orchestrator-and-child) |
77
97
  | `MultiAgent::Orchestrator::ChildCleanupError` | Beta (since v0.36.0) | Retains exact child owners and causes when direct dispatch cannot safely release children whose results are not returned. Ordinary successful results keep their existing Agent reuse contract. [Direct-child lifetime](docs/async-composition.md#direct-orchestrator-children) |
98
+ | `Tools::Agent.from_agent` and generated Tool `call_async` | Beta | Fresh children inherit application context and cancellation/deadline controls while owning their own execution wiring. Parent-binding isolation is available since v0.38.0; arguments and result formats are unchanged. [Child invocation context](docs/architecture/agent-tool-child-lifetime.md#child-invocation-context) |
78
99
  | `Tools::Agent::CleanupError` | Beta | Added in v0.31.0. Preserves the child, result and failure causes when safe release fails; retry `child_agent.unload_async` for release only; [contract](docs/architecture/agent-tool-child-lifetime.md) |
79
100
  | `Workflow#send_saved_event` | Beta | Added in v0.32.0. Deliver an event to a specific revision of a persisted Workflow wait; [contract](docs/runtime-and-concurrency.md#delivering-an-event-to-a-saved-workflow-wait) |
101
+ | `Workflow#pending_terminal_recovery / #reconcile_terminal_async / #reconcile_terminal` and `WorkflowTerminalRecoveryError` | Beta (since v0.38.0) | Explicit observation of retained terminal saves through the original running or draining Runtime; persistence, owner application and release remain separate. The original-owner APIs require a running or draining Runtime; see the separate stopped-recipient operation above. [Recovery contract](docs/architecture/workflow-terminal-reconciliation.md) |
80
102
  | `Workflow::Builder#task_state` and `WorkflowTaskResumeError` | Beta | State-entry-scoped Task completion, live cancellation and explicit restart rejection; [contract](docs/architecture/dx05-workflow-task-state.md) |
81
103
  | `Phronomy::Integrations::OrderedEventDelivery` | Beta | Optional ordered delivery with bounded admission and explicit drain lifetime; [usage](docs/ordered-event-delivery.md) |
82
104
  | `Phronomy::Error#code` and error constructor `code:` | Beta | Optional reason codes and bounded causes retained in saved failure diagnostics; [meaning and compatibility](docs/architecture/error-api-review.md) |
data/SECURITY.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  | Version | Supported |
6
6
  |---------|-----------|
7
- | 0.37.0 (latest release) | ✅ |
7
+ | 0.38.0 (latest release) | ✅ |
8
8
  | Older versions | ❌ — please upgrade |
9
9
 
10
10
  Only the latest released version of `phronomy` receives security patches. If you
@@ -0,0 +1,320 @@
1
+ # Original-owner Agent approval recovery
2
+
3
+ G3a recovers one uncertain approval decision on the original live standalone Agent. The Agent owns the decision's meaning, its suspended wait, cancellation binding and continuation. Persistence proves what was saved; the Runtime serializes original-owner application and accounts for physical work. A caller's observation can fail without releasing any of those responsibilities.
4
+
5
+ For example, a report-reading Tool waits for a human decision. The decision transaction commits, but its response is lost. The stored execution has the decision while the live Agent still appears suspended. Repeating `approve` can duplicate intent, and loading another Agent does not repair the original live owner. An explicit recovery observation instead checks the exact saved state and completes that owner's transition.
6
+
7
+ Baseline: G3b-4 `b2f7c349215085983cfcc89097df9cdbaddef24d`. This document describes the G3a implementation candidate. Contract concept v55 and foundation v48 remain the canonical architectural boundaries. The delivery evidence identifies the final candidate and validation results.
8
+
9
+ G3d extends this operation to supported correlated child and restored waits. The hosted continuation has an optional independent handle and additional parent-authority checks; see [child and restored approval recovery](agent-child-approval-recovery.md). The original G3a examples and baseline below remain historical evidence.
10
+
11
+ G3h extends the same public decision operation to a supported [native parent's own Tool approval](native-parent-outcome-recovery.md#recover-the-native-parents-own-approval-decision). It retains the complete decision proof and freshly checks native child authority before restoring the wait or applying the decision. Known committed history remains confirmed when current authority blocks continuation. Saving the preceding approval wait uses the distinct `OutcomeRecovery` contract; no approval-write retry is introduced.
12
+
13
+ ## Keep the decision, owner transition and caller observation separate
14
+
15
+ An approval transaction and its reply are different facts. The retained operation captures immutable before/after evidence, the exact request and decision, original Store identity, and the original owner. It exposes `ApprovalRecoveryError` only while retaining the uncertain obligation. A later observation does not reopen the failed approval TaskResult.
16
+
17
+ For example, `approve_async` can fail with `ApprovalRecoveryError` while the original `invoke_async` observation remains attached to the execution. If reconciliation confirms the committed decision, the original invocation and a new execution observation may both receive the eventual result; the failed approval observation remains failed.
18
+
19
+ | Layer | Owns | Does not establish by itself |
20
+ | --- | --- | --- |
21
+ | Caller observation | Waiting, timeout and a result/error received by one caller | Transaction outcome, job cancellation or owner release |
22
+ | Approval persistence proof | The exact captured pre-state or post-state under the original Store's guard | Live application or continuation admission |
23
+ | Original Agent owner | Restoring the wait or applying the decision and retaining exact continuation sessions | Provider/Tool success merely because sessions were admitted |
24
+ | Runtime physical accounting | Completion of the tracked approval save/read workers and admitted sessions | Durable decision outcome from worker return alone |
25
+
26
+ The proof compares the root, execution, relevant journal evidence, journal head, retention evidence and cancellation evidence. A confirmed post-state additionally verifies the exact decision content bytes. Matching an execution revision alone is insufficient. Changed or conflicting evidence remains unresolved; an unavailable read does not become a guessed rollback.
27
+
28
+ For example, the correct request identifier with a different saved approval value must not authorize the retained continuation. Likewise, a changed cancellation marker prevents treating the old captured pre-state as current.
29
+
30
+ ## Observe recovery through the original Agent
31
+
32
+ The capability is a process-local reference to one retained operation. Public identities support diagnostics; they do not reconstruct authority. Reconciliation reads approval persistence without retrying its writes. Applying confirmed post-state may start the first execution of the authorized Tool/provider continuation, so the operation is not generally free of business effects.
33
+
34
+ For example, a committed `approved: true` decision can release the previously waiting Tool to run once. A committed `approved: false` decision resumes the rejection path. Neither branch asks the application to repeat the decision merely because the response was lost.
35
+
36
+ | Method or value | Contract |
37
+ | --- | --- |
38
+ | `pending_approval_recovery(execution_id:)` | Local lookup on this exact Agent incarnation's existing registry; no persistence access, Runtime creation or coordinator creation. Requires a nonempty String. |
39
+ | `reconcile_approval_async(recovery:)` | Fresh `TaskResult<ApprovalRecoveryResult>` for explicit readback and original-owner application. |
40
+ | `reconcile_approval(recovery:)` | Blocking host-thread equivalent. The EventLoop reentrancy guard runs before starting an observation. |
41
+ | `ApprovalRecovery` | Frozen, privately constructed capability with `agent_id`, `execution_id`, `approval_request_id`, `recovery_id` and `approved` readers. |
42
+ | `ApprovalRecoveryError` | Retained responsibility with code `agent.approval_recovery`; `original_error` preserves the initial failure and `cause` the immediate failure. It is not a business-failure verdict. |
43
+
44
+ The capability's private operation, exact issued reference and owning Agent object must all match. Another Agent with the same durable identifier, a copied capability, or copied diagnostic strings does not grant recovery rights. No separate approval retry API is added.
45
+
46
+ For example, after an observer ends before receiving the recovery error, the application can retain its original Agent and execution identity, then use `pending_approval_recovery(execution_id:)` to find the still-owned obligation. Once that obligation resolves, pending lookup returns nil; an already held capability can still produce its final receipt.
47
+
48
+ ## Interpret the receipt without confusing recovery with job completion
49
+
50
+ The immutable receipt separates persistence outcome, original-owner application, continuation progress and physical approval-worker completion. Resolving approval recovery leaves the same Agent job owned: it either waits again or continues execution.
51
+
52
+ For example, a receipt can be `confirmed_post` while application is still pending after a delivery failure. A later receipt may become `applied`/`resumed` while the approved Tool is still running. Both receipts preserve the same decision fact; neither claims that Tool work succeeded.
53
+
54
+ | Reader | Meaning |
55
+ | --- | --- |
56
+ | `recovery` and diagnostic identities, including `approved` | The same captured approval decision and process-local authority. |
57
+ | `outcome` | `confirmed_pre`, `confirmed_post`, `unresolved` or `unavailable`. |
58
+ | `application_state` | `pending` or `applied` by the original owner. |
59
+ | `continuation_state` | `pending`, `restored` or `resumed`. Restored records restoration of the same original wait; resumed records admission or terminal handoff of the retained continuation. These are historical handoff facts, not the job's current status. |
60
+ | `physical_complete?` | Whether the approval save and recovery read workers have stopped. This excludes the resumed Tool/provider work and whole Agent job. |
61
+ | `resolved?` | Physical approval completion plus applied state and restored/resumed continuation. |
62
+ | `revision` | Exact confirmed execution revision: original suspended revision for pre-state, saved approval revision for post-state; otherwise nil. |
63
+ | `execution_task` | Fresh independent observation of resumed execution, available only for confirmed post-state with applied/resumed continuation. |
64
+ | `error` | Recovery/read/application error, separate from the resumed execution's own result or error. |
65
+
66
+ Confirmed pre-state restores the same request, invocation, suspended cancellation binding and admission. It neither rewrites the decision nor releases the job. Restoring that binding can immediately honor an already captured cancellation, so a restored receipt does not prove that the job is still awaiting approval. Check the original invocation's current outcome and current approval state before offering another explicit decision. Confirmed post-state applies the captured decision and continues the same invocation, retaining exact parent/child session identities across partial registration.
67
+
68
+ For example, if the first Tool child was admitted and registration of a later child failed, recovery must not recreate or restart the first child. It resumes only missing registrations whose non-admission is known. Missing sessions observed later are not proof that earlier business effects never ran.
69
+
70
+ `resumed` includes an admitted continuation that subsequently fails or is cancelled; its execution observation reports the actual outcome. Repeated resolved receipts provide independent execution TaskResults. A timeout while waiting on one does not cancel the authorized work, and closing one observer does not settle the private canonical continuation task.
71
+
72
+ For example, a caller may time out while an approved report read is still running, then observe the same retained continuation through a later receipt. The Tool count must remain one, even though the application obtains two distinct execution observations.
73
+
74
+ ## Keep normal application behavior equivalent
75
+
76
+ The complete normal application below is unchanged between the G3b-4 baseline and G3a candidate. Its deterministic adapter performs no network request; Runtime admission, the approval wait, transaction, Tool invocation and final result are real. The additional record reads are measurement scaffolding, not application recovery policy.
77
+
78
+ For example, the shared fixture asks for one approved report read, executes the Tool once, and returns `report ready`. To run either version, concatenate the shared setup, exactly one normal-function listing, and the shared driver. The source listings are checked byte-for-byte against the executed delivery helpers.
79
+
80
+ ### Shared fixture setup
81
+
82
+ <!-- example: shared-setup -->
83
+ ```ruby
84
+ # frozen_string_literal: true
85
+
86
+ require "phronomy"
87
+ require "json"
88
+ require "timeout"
89
+
90
+ class G3aReportTool < Phronomy::Tool::Base
91
+ tool_name "read_approved_report"
92
+ description "Read the report after the exact human decision"
93
+ requires_approval true
94
+ class << self
95
+ attr_accessor :calls
96
+ end
97
+
98
+ def execute
99
+ self.class.calls += 1
100
+ "approved report"
101
+ end
102
+ end
103
+
104
+ class G3aReportAgent < Phronomy::Agent::Base
105
+ agent_definition id: "approval-report", version: 1
106
+ model "offline-model"
107
+ tools G3aReportTool => nil
108
+ end
109
+
110
+ class G3aReportAdapter < Phronomy::LLMAdapter::Base
111
+ attr_reader :calls
112
+
113
+ def initialize
114
+ @calls = 0
115
+ end
116
+
117
+ def perform_complete(_request, cancellation_token:)
118
+ cancellation_token&.raise_if_cancelled!
119
+ @calls += 1
120
+ if @calls == 1
121
+ Phronomy::LLMAdapter::Response.new(tool_calls: [
122
+ Phronomy::Tool::CallRequest.new(id: "report-read", name: "read_approved_report", arguments: {})
123
+ ], finish_reason: :tool_calls)
124
+ else
125
+ Phronomy::LLMAdapter::Response.new(content: "report ready", finish_reason: :stop)
126
+ end
127
+ end
128
+ end
129
+ ```
130
+
131
+ ### Before: G3b-4 baseline
132
+
133
+ This function contains the complete ordinary request, decision, observation and measurement flow.
134
+
135
+ <!-- example: normal-before -->
136
+ ```ruby
137
+ # The application selects one exact approval request and makes one decision.
138
+ # The fixture adapter does not use a network; Runtime and persistence are real.
139
+ def run_approval_report
140
+ G3aReportTool.calls = 0
141
+ adapter = G3aReportAdapter.new
142
+ Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
143
+ store = Phronomy::PersistenceComposition.in_memory.agent
144
+ approvals = Queue.new
145
+ agent = G3aReportAgent.create(agent_id: "approval-report", persistence: store,
146
+ on_event: ->(event) { approvals << event.payload.fetch(:request) if event.type == :approval_required })
147
+ invocation = agent.invoke_async("Read the report")
148
+ request = Timeout.timeout(5) { approvals.pop }
149
+ decision = agent.approve_async(request.execution_id, approval_request_id: request.id, approved: true)
150
+ result = decision.wait_result(timeout: 5)
151
+ original_result = invocation.wait_result(timeout: 5)
152
+ execution = store.executions.load(request.execution_id)
153
+ decisions = store.journals.read(agent.agent_id).select { |record| record.kind == :approval_decided }
154
+ {
155
+ output: result.fetch(:output), original_output: original_result.fetch(:output),
156
+ execution_status: execution.status, execution_revision: execution.execution_revision,
157
+ agent_revision: agent.agent_root.agent_revision, root_status: agent.agent_root.lifecycle_status,
158
+ provider_calls: adapter.calls, tool_calls: G3aReportTool.calls,
159
+ decisions: decisions.map { |record| store.contents.fetch_json(record.content_ref).fetch("approved") },
160
+ decision_logical_complete: decision.done?, decision_physical_complete: decision.physical_complete?,
161
+ invocation_logical_complete: invocation.done?, invocation_physical_complete: invocation.physical_complete?
162
+ }
163
+ end
164
+ ```
165
+
166
+ ### After: G3a candidate
167
+
168
+ The application function is identical. Successful approval still returns the execution result through the decision observation and original invocation.
169
+
170
+ <!-- example: normal-after -->
171
+ ```ruby
172
+ # The application selects one exact approval request and makes one decision.
173
+ # The fixture adapter does not use a network; Runtime and persistence are real.
174
+ def run_approval_report
175
+ G3aReportTool.calls = 0
176
+ adapter = G3aReportAdapter.new
177
+ Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
178
+ store = Phronomy::PersistenceComposition.in_memory.agent
179
+ approvals = Queue.new
180
+ agent = G3aReportAgent.create(agent_id: "approval-report", persistence: store,
181
+ on_event: ->(event) { approvals << event.payload.fetch(:request) if event.type == :approval_required })
182
+ invocation = agent.invoke_async("Read the report")
183
+ request = Timeout.timeout(5) { approvals.pop }
184
+ decision = agent.approve_async(request.execution_id, approval_request_id: request.id, approved: true)
185
+ result = decision.wait_result(timeout: 5)
186
+ original_result = invocation.wait_result(timeout: 5)
187
+ execution = store.executions.load(request.execution_id)
188
+ decisions = store.journals.read(agent.agent_id).select { |record| record.kind == :approval_decided }
189
+ {
190
+ output: result.fetch(:output), original_output: original_result.fetch(:output),
191
+ execution_status: execution.status, execution_revision: execution.execution_revision,
192
+ agent_revision: agent.agent_root.agent_revision, root_status: agent.agent_root.lifecycle_status,
193
+ provider_calls: adapter.calls, tool_calls: G3aReportTool.calls,
194
+ decisions: decisions.map { |record| store.contents.fetch_json(record.content_ref).fetch("approved") },
195
+ decision_logical_complete: decision.done?, decision_physical_complete: decision.physical_complete?,
196
+ invocation_logical_complete: invocation.done?, invocation_physical_complete: invocation.physical_complete?
197
+ }
198
+ end
199
+ ```
200
+
201
+ ### Shared measurement driver
202
+
203
+ Set `G3A_NORMAL_REPORT` and `G3A_NORMAL_SOURCE` to output paths, then run the assembled file using the tested checkout's bundled Ruby dependencies. The source report identifies the loaded implementation; the functional report excludes random execution identifiers and timestamps.
204
+
205
+ <!-- example: normal-driver -->
206
+ ```ruby
207
+ if $PROGRAM_NAME == __FILE__
208
+ begin
209
+ report = run_approval_report
210
+ raise "Unexpected result" unless report[:output] == "report ready" && report[:original_output] == "report ready"
211
+ raise "Unexpected business replay" unless report[:provider_calls] == 2 && report[:tool_calls] == 1
212
+ raise "Unexpected approval decision count" unless report[:decisions] == [true]
213
+ File.write(ENV.fetch("G3A_NORMAL_REPORT"), JSON.pretty_generate(report) + "\n")
214
+ File.write(ENV.fetch("G3A_NORMAL_SOURCE"), JSON.pretty_generate({
215
+ application: method(:run_approval_report).source_location,
216
+ approval_commit: Phronomy::Agent::ApprovalResumeCommit.instance_method(:commit).source_location,
217
+ gem: Gem.loaded_specs.fetch("phronomy").full_gem_path
218
+ }) + "\n")
219
+ ensure
220
+ Phronomy.reset_runtime!
221
+ end
222
+ end
223
+ ```
224
+
225
+ The baseline and candidate functional JSON reports are exactly equal. This comparison establishes the measured successful path; it does not claim fault-path equivalence or equivalence for every provider/backend.
226
+
227
+ For example, both reports contain the following complete observation, including separate decision/invocation logical and physical completion:
228
+
229
+ ```json
230
+ {
231
+ "output": "report ready",
232
+ "original_output": "report ready",
233
+ "execution_status": "completed",
234
+ "execution_revision": 6,
235
+ "agent_revision": 4,
236
+ "root_status": "idle",
237
+ "provider_calls": 2,
238
+ "tool_calls": 1,
239
+ "decisions": [
240
+ true
241
+ ],
242
+ "decision_logical_complete": true,
243
+ "decision_physical_complete": true,
244
+ "invocation_logical_complete": true,
245
+ "invocation_physical_complete": true
246
+ }
247
+ ```
248
+
249
+ ## Add explicit handling only for the uncertain decision path
250
+
251
+ The following complete helper makes one decision and, only after `ApprovalRecoveryError`, performs one explicit reconciliation. It returns a restoration receipt tied to the original request, a resumed execution observation, or retained pending recovery. It does not loop, automatically write another decision, transfer ownership or manufacture a replacement Agent.
252
+
253
+ For example, a rolled-back decision returns `approval_restored` with the original request and historical restoration receipt. The original invocation may already report cancellation because recovery honored captured cancellation; the application must inspect that outcome before presenting another approval. A committed decision returns `resumed` with an execution TaskResult. If readback is unavailable, the caller retains the Agent and capability and chooses when to observe again.
254
+
255
+ <!-- example: recovery-handler -->
256
+ ```ruby
257
+ # frozen_string_literal: true
258
+
259
+ require "phronomy"
260
+
261
+ # The caller owns the Agent, original invocation and unresolved references.
262
+ # Recovery may start the already authorized Tool for its first execution.
263
+ # A restored receipt records a completed handoff, not the job's current status.
264
+ # Check the original invocation before offering a new human decision; this
265
+ # function never automatically submits another approval write.
266
+ def decide_with_recovery(agent:, request:, approved: true)
267
+ result = agent.approve(request.execution_id, approval_request_id: request.id, approved: approved)
268
+ {state: :completed, result: result}.freeze
269
+ rescue Phronomy::Agent::ApprovalRecoveryError => failure
270
+ recovery = failure.recovery
271
+ receipt = agent.reconcile_approval(recovery: recovery)
272
+ if receipt.resolved? && receipt.continuation_state == :restored
273
+ {state: :approval_restored, request: request, recovery: recovery, receipt: receipt}.freeze
274
+ elsif receipt.resolved? && receipt.continuation_state == :resumed
275
+ {state: :resumed, execution_task: receipt.execution_task, recovery: recovery, receipt: receipt}.freeze
276
+ else
277
+ {state: :recovery_pending, recovery: recovery, receipt: receipt}.freeze
278
+ end
279
+ end
280
+ ```
281
+
282
+ The helper's `completed` tag means the ordinary decision observation returned its result; the application must inspect that result as usual, including a rejection result's `rejected: true`. `resumed` means an observation exists for continued work, not that work succeeded. The caller remains responsible for retaining the original Agent, the original invocation handle and any unresolved recovery reference.
283
+
284
+ For example, after `resumed`, waiting on `execution_task` can return a completed/failed saved execution or raise an operation/observation error according to the existing exact-result contract. After `recovery_pending`, the application can call `reconcile_approval` again with the same capability when observation is appropriate. It must not blindly call the decision helper again while the original transition remains unresolved.
285
+
286
+ | Trigger | Baseline behavior observed in review | G3a behavior |
287
+ | --- | --- | --- |
288
+ | Ordinary successful decision | One saved decision, one Tool execution and final result | Same application and equal functional report |
289
+ | Decision commits, reply is lost | Saved state advances while the original live wait/admission remains inconsistent | Retained error/capability; explicit proof can apply the saved decision and start its continuation once |
290
+ | Decision transaction rolls back | Original wait can remain blocked behind a recovery-required admission with cancellation unbound | Explicit confirmed pre-state restores the same wait and cancellation binding without another decision write |
291
+ | Proof unavailable or conflicting | No reliable classification from the original failure alone | `unavailable` or `unresolved`; responsibility stays retained |
292
+ | Original owner has stopped | A different Runtime cannot safely repair the old owner's local transition | Unavailable receipt and incomplete cleanup; no fabricated successful release |
293
+
294
+ ## Preserve the bounded implementation scope
295
+
296
+ G3a covers an installed standalone Agent's original live invocation at its approval wait. Hosted/detached Agents, participant or reserved execution, execution extensions, parent-owned waits and cross-process recovery retain their existing separate contracts. It does not add general approval rehydration or a generic distributed retry protocol.
297
+
298
+ For example, an approval owned by an Orchestrator/Team participant must continue through that domain's existing coordination path. A saved request identifier is not permission for this original-owner capability API to take over a detached execution.
299
+
300
+ Recovery can finish on the original running or draining Runtime. A stopped owner cannot be replaced through these methods, and unresolved responsibility prevents complete cleanup. Positive mechanism evidence that the initial save was never admitted can restore the ordinary wait and preserve the ordinary error; a missing handle or generic submission exception does not establish that evidence.
301
+
302
+ For example, shutdown while an uncertain save/read still has physical work cannot report successful release merely because its waiting TaskResult ended. Conversely, restoring a wait does not release the Agent job: its ordinary cancellation and shutdown obligations continue, and an already captured cancellation can immediately move that job to terminal handling.
303
+
304
+ The backend must establish that the prior transaction has settled and authoritative readback is ordered after it, with the Store's guard and atomicity guarantees intact. Local worker quiescence, a matching revision or an in-memory test does not prove these properties for every remote database. There is no claim of exactly-once external effects after a process crash.
305
+
306
+ For example, a database whose late commit can occur after an unguarded read cannot safely classify that read as a final pre-state. Its adapter must provide the required ordering and exclusion before this recovery contract applies.
307
+
308
+ ## Validate the protocol and the actual application separately
309
+
310
+ The finite [approval recovery model](../../spec/models/approval_decision_recovery/README.md) checks stated safety/liveness properties under explicit premises. Real Runtime fault-injection tests check whether implementation follows those rules. Neither substitutes for backend conformance or an actual application comparison.
311
+
312
+ For example, model checks can reject release before physical completion or replay of an admitted child. Integration tests must still inject commit-response loss, rollback, read failure, cancellation, partial session admission and owner shutdown through the real Agent/Runtime path.
313
+
314
+ The delivery's documented-application tests execute the exact helper above on ordinary success, confirmed pre-state, committed positive/negative decisions, unavailable readback and stopped-owner cases. A gated real Tool also checks that physical approval completion can precede job completion and that later receipts return fresh execution observations without another Tool call. The normal reports come from executing the identical complete application on both framework versions, not from rewriting expected JSON.
315
+
316
+ As of 2026-11-28, approval recovery uses the C13 `RetainedAttempts` manager and `AttemptCompletion` evidence record alongside Agent outcome/dispatch recovery and Workflow terminal recovery. Explicit reservation, observation membership, submission evidence and completion handling are shared. Approval still owns proof interpretation, original wait restoration, partial continuation and responsibility transfer. See [shared retained-attempt management](retained-attempts.md) for the current lock and model correspondence.
317
+
318
+ The original approval-stage review identified approximately 72 duplicated nonblank, noncomment lines per owner, including an approximately 48-line watch/refresh core. That historical finding motivated the first Agent-only extraction; it is not a remaining future task or a size measurement of the current implementation. Its measured cost is preserved in [the extraction history](recovery-physical-attempt.md).
319
+
320
+ For example, extracting a helper that always releases Agent admission after successful proof would be correct for some terminal paths and wrong for this restored approval wait. Any later common abstraction must preserve that distinction while reducing actual duplicate implementation and test burden.