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
@@ -0,0 +1,506 @@
1
+ # Publish retained outcomes from captured persistence facts
2
+
3
+ Agent owns the observation of an accepted execution result. Persistence owns the encoded facts accepted by the save, and MultiAgent owns the native relationships associated with that execution. A recovered result must agree with the captured persistence facts even when the original application objects later change or become unusable. G3j repairs this publication boundary within the existing owners.
4
+
5
+ For example, a report service saves `Report completed`, loses the save response, and then changes the original output String. A recovered report must still say `Report completed`. If the report instead failed and its original exception can no longer produce a diagnostic, the already captured failure must remain observable.
6
+
7
+ This document compares applied G3i `a6c026aaa02b069a330662d67e906c9b6204f6d0` with the G3j candidate. Contract concept v55 and foundation v48 define the responsibility boundaries. The preceding [native preparation account](native-outcome-preparation.md) and [native recovery protocol](native-parent-outcome-recovery.md) remain the public protocol references. G3j adds no public API, durable owner, participant callback or preparation-retry permission. Candidate validation evidence accompanies the delivered change; this document does not certify arbitrary production backends.
8
+
9
+ ## Captured facts and publication responsibility
10
+
11
+ The original outcome worker already captures the content and record values required for an exact save. That worker now also derives a detached terminal observation from those captured bytes. The EventLoop publishes that observation after the existing owner and persistence checks, without reading the Store or invoking the original output or exception again.
12
+
13
+ For example, a saved plain report uses captured text content, a structured report uses captured JSON plus its captured raw output, and a failed report uses the exact captured error JSON. An output-contract failure keeps its schema digest, reason, violations and raw output because those fields belong to its saved diagnostic.
14
+
15
+ | Value or responsibility | Authoritative source | Boundary |
16
+ | --- | --- | --- |
17
+ | Completed result | Captured content addressed by `result_ref`, decoded using the recorded result format. | A later mutation or application conversion cannot replace the saved result. |
18
+ | Structured raw output | Captured text addressed by `raw_output_ref`. | Parsing and validation are not repeated during publication. |
19
+ | Failed result | Captured JSON addressed by `error_ref`. | Keep the complete `OutputError` or ordinary business diagnostic; do not call `message`, `cause` or `diagnostic` again. |
20
+ | Local execution application | Existing semantic outcome and owner checks. | Domain transitions, journal application and original exception delivery retain their existing responsibilities. |
21
+ | Save confirmation and retry | Exact captured pre/post comparison, physical settlement, Store identity and current native authority. | An observation cache neither proves a write committed nor grants permission to retry it. |
22
+ | Native waits | Existing coordination-wait or approval-wait representation. | A captured wait remains unfinished work and does not acquire a terminal observation. |
23
+
24
+ `TerminalPersistenceEvidence` derives the terminal `ExecutionObservation` while the original worker prepares complete evidence. Its private captured-content adapter reads only retained `ContentWrite` bytes through the existing content decoding rules. `OutcomeRecoveryOperation#remember_post` selects that prepared observation; the inherited terminal recovery path shares this rule. Missing captured content fails evidence construction instead of falling back to a live application object. The original semantic outcome remains available for ordinary delivery and local state application. This does not move standalone physical writes before or after their existing evidence boundary; native preparation retains its G3i ordering.
25
+
26
+ This is a correction to a narrower G3i guarantee: retaining detached proof input avoided repeated proof construction callbacks, but did not ensure that later owner publication used the same detached facts. The coordinator application path does not itself rebuild a business diagnostic; the repeated access was in owner observation construction.
27
+
28
+ ## Application scenario and behavioral contract
29
+
30
+ The report application owns whether to permit a persistence-only retry and how long to retain unresolved responsibility. The framework owns faithful observation of the saved result and must not require the application to reconstruct its own diagnostic or guess whether business work should run again.
31
+
32
+ For example, the parent receives `Prepare one report`, makes one offline Provider call, and returns a filtered text report or the original business error. A declared reviewer selects the native coordinator, but this bounded example does not dispatch that reviewer or execute a Tool. The fault fixture changes the caller-owned output or disables the original error accessor after complete evidence capture, then optionally loses a rolled-back or committed save response.
33
+
34
+ | Aspect | Contract shared by both application versions |
35
+ | --- | --- |
36
+ | Input and ordinary output | One request produces `Report completed`, or one `G3jReportError` with code `report.source_unavailable`. |
37
+ | Errors | Ordinary failure preserves the original business exception object. An ambiguous save creates the existing `OutcomeRecoveryError`; later observation cannot reopen the original failed task. |
38
+ | Ordering and concurrency | One admitted execution and one Provider call. Reconciliation follows the original failed observation; explicit captured-write retry follows confirmed pre-state only. |
39
+ | Persistence | Actual in-memory Persistence and Runtime. The fixture intercepts the real outer transaction; it does not replace exact readback or replay logic. |
40
+ | Ownership and cleanup | Release only after a confirmed saved outcome is applied. Otherwise retain the same service and exact recovery capability; incomplete cleanup is reported explicitly. |
41
+ | Cancellation | Observation timeout and shutdown do not supply cancellation authority or prove physical completion. No new cancellation behavior is proposed. |
42
+ | External effects | The Provider is offline and counted. No Tool, child admission or external side effect occurs in this application comparison. |
43
+ | Retry policy | `retry_confirmed_pre: false` holds the exact pre-state; `true` explicitly permits only captured persistence writes. |
44
+
45
+ The ordinary domain is equivalent: both columns below use the same application source and preserve the same business contract. Fault observations intentionally differ as follows.
46
+
47
+ | Condition | Before: applied G3i | After: G3j candidate |
48
+ | --- | --- | --- |
49
+ | No injected fault | Normal success or original business error; one Provider call and ordinary release. | Same ordinary behavior and application function. |
50
+ | Original output changes after capture, then an eligible save is reconciled or retried | The stored report can retain the original text while the recovery receipt reports the changed String. | Recovery result and Store observation both use the captured text. |
51
+ | Original exception accessor becomes unavailable after capture | A saved failed execution can remain unavailable and retained because publication reads the live exception again. | The captured diagnostic supports publication and release without another diagnostic read. |
52
+ | Exact pre-state and application declines retry | Owner remains retained; no business or persistence replay is authorized. | Same explicit hold policy. |
53
+ | Incomplete preparation before captured facts exist | No supported generic replay or terminalization follows merely from retention. | Still unresolved; this change is not a generic preparation recovery API. |
54
+
55
+ ## Shared setup and ordinary execution comparison
56
+
57
+ The same application definitions and observation helpers supply both ordinary execution functions. The offline Provider makes unexpected replay visible, while the mutable output and custom exception expose the distinction between application objects and captured facts.
58
+
59
+ For example, `build_report_service(failure: false)` installs a native-configured report parent with an output filter returning a caller-owned String. With `failure: true`, the same parent receives the exact custom business exception. Both normal functions below are complete and identical.
60
+
61
+ Copy the shared setup, common observation helpers, one column of the ordinary function, one column of the recovery function, the complete fixture and the driver into one Ruby file in that order. Every dependency is shown. Run each case in a fresh Ruby process with the chosen checkout in the bundle, because the fixture instruments that process. These are application adaptations using existing public APIs, not excerpts from a separate application repository.
62
+
63
+ <!-- g3j-code:shared-setup -->
64
+ ```ruby
65
+ require "phronomy"
66
+ require "json"
67
+
68
+ class G3jReportError < Phronomy::Error
69
+ attr_accessor :reject_reads
70
+ attr_reader :reads
71
+
72
+ def initialize
73
+ @reads = 0
74
+ super("The report source is unavailable", code: "report.source_unavailable")
75
+ end
76
+
77
+ def message
78
+ @reads += 1
79
+ raise IOError, "Original report diagnostic is no longer available" if reject_reads
80
+ super
81
+ end
82
+ end
83
+
84
+ class G3jReportWorker < Phronomy::Agent::Base
85
+ agent_definition id: "retained-report-worker", version: 1
86
+ model "offline-model"
87
+ end
88
+
89
+ class G3jReportParent < Phronomy::MultiAgent::Orchestrator
90
+ agent_definition id: "retained-report-parent", version: 1
91
+ model "offline-model"
92
+ subagent :reviewer, G3jReportWorker
93
+ end
94
+
95
+ class G3jReportAdapter < Phronomy::LLMAdapter::Base
96
+ attr_reader :calls
97
+
98
+ def initialize(error: nil)
99
+ @error, @calls = error, 0
100
+ end
101
+
102
+ def perform_complete(_request, cancellation_token:)
103
+ cancellation_token&.raise_if_cancelled!
104
+ @calls += 1
105
+ raise "Unexpected repeated Provider work" if @calls > 1
106
+ raise @error if @error
107
+ Phronomy::LLMAdapter::Response.new(content: "Report source text", finish_reason: :stop)
108
+ end
109
+ end
110
+
111
+ def build_report_service(failure: false)
112
+ error = failure ? G3jReportError.new : nil
113
+ adapter = G3jReportAdapter.new(error: error)
114
+ Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
115
+ stores = Phronomy::PersistenceComposition.in_memory
116
+ parent = G3jReportParent.create(agent_id: "retained-report-parent", persistence: stores.agent,
117
+ coordination_store: stores.multi_agent)
118
+ output = +"Report completed"
119
+ parent.add_output_filter(->(_text) { output }) unless failure
120
+ {adapter: adapter, stores: stores, parent: parent, output: output, error: error,
121
+ execution_id: "retained-report-execution"}
122
+ end
123
+ ```
124
+
125
+
126
+ <!-- g3j-code:common-observation -->
127
+ ```ruby
128
+ def stored_report(service)
129
+ parent = service.fetch(:parent)
130
+ fact = service.fetch(:stores).agent.observe_execution(agent_id: parent.agent_id,
131
+ execution_id: service.fetch(:execution_id))
132
+ {status: fact.status, result: fact.result, raw_output: fact.raw_output, error: fact.error}
133
+ end
134
+
135
+ def report_receipt(receipt)
136
+ execution = receipt.execution
137
+ {outcome: receipt.outcome, application_state: receipt.application_state,
138
+ ownership_state: receipt.ownership_state, saved_outcome: receipt.saved_outcome,
139
+ execution: execution && {status: execution.status, result: execution.result,
140
+ raw_output: execution.raw_output, error: execution.error}}
141
+ end
142
+
143
+ def release_report(service)
144
+ service.fetch(:parent).unload!
145
+ end
146
+
147
+ def start_report(service)
148
+ parent = service.fetch(:parent)
149
+ reservation = Phronomy::Agent::ReservedExecution.new(agent_id: parent.agent_id,
150
+ execution_id: service.fetch(:execution_id))
151
+ parent.start_hosted(reservation: reservation, input: "Prepare one report")
152
+ end
153
+ ```
154
+
155
+
156
+ <table>
157
+ <thead><tr><th>Before: applied G3i</th><th>After: G3j candidate</th></tr></thead>
158
+ <tbody><tr>
159
+ <td><pre><code><!-- g3j-code:normal-function:before -->def run_report(failure: false)
160
+ service = build_report_service(failure: failure)
161
+ original = start_report(service)
162
+ original_error = nil
163
+ begin
164
+ original.wait_result(timeout: 8)
165
+ rescue G3jReportError =&gt; error
166
+ original_error = error
167
+ end
168
+ {state: :ordinary, stored: stored_report(service),
169
+ original_business_error_preserved: failure ? original_error.equal?(service.fetch(:error)) : nil,
170
+ provider_calls: service.fetch(:adapter).calls, released: release_report(service)}
171
+ end
172
+ </code></pre></td>
173
+ <td><pre><code><!-- g3j-code:normal-function:after -->def run_report(failure: false)
174
+ service = build_report_service(failure: failure)
175
+ original = start_report(service)
176
+ original_error = nil
177
+ begin
178
+ original.wait_result(timeout: 8)
179
+ rescue G3jReportError =&gt; error
180
+ original_error = error
181
+ end
182
+ {state: :ordinary, stored: stored_report(service),
183
+ original_business_error_preserved: failure ? original_error.equal?(service.fetch(:error)) : nil,
184
+ provider_calls: service.fetch(:adapter).calls, released: release_report(service)}
185
+ end
186
+ </code></pre></td>
187
+ </tr></tbody>
188
+ </table>
189
+
190
+
191
+ ## Explicit recovery comparison
192
+
193
+ Recovery policy remains visible in the application: observe the retained owner, permit a captured-write retry only from confirmed pre-state when requested, and keep unresolved responsibility alive. G3j changes the reliability of the returned facts without adding an application branch or asking the application to cache a parallel error representation.
194
+
195
+ For example, the report service reconciles a lost response and retries only when `retry_confirmed_pre` is true. A second reconciliation must return the same saved facts after release, and a second wait on the original task must return the same failure object. Both functions below make that policy explicit.
196
+
197
+ <table>
198
+ <thead><tr><th>Before: applied G3i</th><th>After: G3j candidate</th></tr></thead>
199
+ <tbody><tr>
200
+ <td><pre><code><!-- g3j-code:recovery-function:before --># The application explicitly permits a persistence-only retry from an exact
201
+ # pre-state. It never repeats the report to infer whether its save succeeded.
202
+ def run_report_with_recovery(fault:, retry_confirmed_pre: false, failure: false)
203
+ service = build_report_service(failure: failure)
204
+ fault.call(service)
205
+ parent = service.fetch(:parent)
206
+ original = start_report(service)
207
+ original_failure = nil
208
+ ordinary_error = nil
209
+ begin
210
+ original.wait_result(timeout: 8)
211
+ rescue Phronomy::Agent::OutcomeRecoveryError =&gt; error
212
+ original_failure = error
213
+ rescue G3jReportError =&gt; error
214
+ ordinary_error = error
215
+ end
216
+
217
+ unless original_failure
218
+ return {state: :ordinary, stored: stored_report(service),
219
+ original_business_error_preserved: failure ? ordinary_error.equal?(service.fetch(:error)) : nil,
220
+ provider_calls: service.fetch(:adapter).calls, released: release_report(service)}
221
+ end
222
+
223
+ recovery = original_failure.recovery
224
+ raise "Unexpected retained owner" unless parent.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
225
+ first = parent.reconcile_outcome(recovery: recovery)
226
+ if first.outcome == :confirmed_pre &amp;&amp; retry_confirmed_pre
227
+ first = parent.retry_outcome(recovery: recovery)
228
+ end
229
+ # A second observation must preserve the same stored facts, including after
230
+ # release. A closed original task must not be reopened by either observation.
231
+ second = parent.reconcile_outcome(recovery: recovery)
232
+ begin
233
+ original.wait_result(timeout: 8)
234
+ raise "Original failed observation reopened"
235
+ rescue Phronomy::Agent::OutcomeRecoveryError =&gt; error
236
+ raise "Original observation changed" unless error.equal?(original_failure)
237
+ end
238
+ released = first.ownership_state == :released
239
+ release_report(service) if released
240
+ {state: released ? :recovered : :retained, stored: stored_report(service),
241
+ observations: [report_receipt(first), report_receipt(second)],
242
+ provider_calls: service.fetch(:adapter).calls, released: released,
243
+ original_observation_closed: true,
244
+ retained_service: released ? nil : service, retained_recovery: released ? nil : recovery}
245
+ end
246
+ </code></pre></td>
247
+ <td><pre><code><!-- g3j-code:recovery-function:after --># The application explicitly permits a persistence-only retry from an exact
248
+ # pre-state. It never repeats the report to infer whether its save succeeded.
249
+ def run_report_with_recovery(fault:, retry_confirmed_pre: false, failure: false)
250
+ service = build_report_service(failure: failure)
251
+ fault.call(service)
252
+ parent = service.fetch(:parent)
253
+ original = start_report(service)
254
+ original_failure = nil
255
+ ordinary_error = nil
256
+ begin
257
+ original.wait_result(timeout: 8)
258
+ rescue Phronomy::Agent::OutcomeRecoveryError =&gt; error
259
+ original_failure = error
260
+ rescue G3jReportError =&gt; error
261
+ ordinary_error = error
262
+ end
263
+
264
+ unless original_failure
265
+ return {state: :ordinary, stored: stored_report(service),
266
+ original_business_error_preserved: failure ? ordinary_error.equal?(service.fetch(:error)) : nil,
267
+ provider_calls: service.fetch(:adapter).calls, released: release_report(service)}
268
+ end
269
+
270
+ recovery = original_failure.recovery
271
+ raise "Unexpected retained owner" unless parent.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
272
+ first = parent.reconcile_outcome(recovery: recovery)
273
+ if first.outcome == :confirmed_pre &amp;&amp; retry_confirmed_pre
274
+ first = parent.retry_outcome(recovery: recovery)
275
+ end
276
+ # A second observation must preserve the same stored facts, including after
277
+ # release. A closed original task must not be reopened by either observation.
278
+ second = parent.reconcile_outcome(recovery: recovery)
279
+ begin
280
+ original.wait_result(timeout: 8)
281
+ raise "Original failed observation reopened"
282
+ rescue Phronomy::Agent::OutcomeRecoveryError =&gt; error
283
+ raise "Original observation changed" unless error.equal?(original_failure)
284
+ end
285
+ released = first.ownership_state == :released
286
+ release_report(service) if released
287
+ {state: released ? :recovered : :retained, stored: stored_report(service),
288
+ observations: [report_receipt(first), report_receipt(second)],
289
+ provider_calls: service.fetch(:adapter).calls, released: released,
290
+ original_observation_closed: true,
291
+ retained_service: released ? nil : service, retained_recovery: released ? nil : recovery}
292
+ end
293
+ </code></pre></td>
294
+ </tr></tbody>
295
+ </table>
296
+
297
+
298
+ The application does not become shorter. Its benefit is that its existing recovery policy can trust the saved result without keeping a second authoritative output or reconstructing a generic diagnostic. The application still decides retry, observes new recovery results, retains unresolved owners and performs ordinary cleanup. A wrapper that automatically retries or invents a terminal failure would hide those responsibilities and is not added.
299
+
300
+ ## Complete fault fixture and driver
301
+
302
+ The fixture creates only the environmental failures needed to compare publication. It leaves the real Runtime, coordinator, persistence transaction, evidence comparison and captured-write retry in place, and it measures Provider, committer and encoder execution separately.
303
+
304
+ For example, `mode: :pre` executes the transaction and raises inside its scope so the original save rolls back; `mode: :post` raises only after the real transaction returns, so the save has committed. Each mode also loses the immediate readback once. A diagnostic mutation happens immediately after complete evidence capture, before publication can consult the original error again.
305
+
306
+ <!-- g3j-code:fault-fixture -->
307
+ ```ruby
308
+ # This test fixture changes caller-owned values after complete capture and
309
+ # injects a transaction response loss. It does not replace persistence logic.
310
+ module G3jReportFault
311
+ class << self
312
+ attr_accessor :current
313
+
314
+ def selected?(command)
315
+ current && command.execution_id == current.fetch(:execution_id)
316
+ end
317
+
318
+ def context
319
+ Thread.current[:g3j_report_outcome]
320
+ end
321
+
322
+ def after_capture(evidence)
323
+ fault = current
324
+ return unless fault && evidence.execution_id == fault.fetch(:execution_id)
325
+ fault[:captures] += 1
326
+ raise "Outcome captured twice" if fault[:captures] > 1
327
+ fault[:captured_result] = evidence.outcome.result&.slice(:output, :raw_output)
328
+ fault[:captured_error] = evidence.outcome.error_diagnostic
329
+ if fault[:mutation] == :output
330
+ fault.fetch(:service).fetch(:output).replace("Changed after capture")
331
+ elsif fault[:mutation] == :diagnostic
332
+ error = fault.fetch(:service).fetch(:error)
333
+ fault[:diagnostic_reads_at_capture] = error.reads
334
+ error.reject_reads = true
335
+ end
336
+ end
337
+
338
+ def report
339
+ return {enabled: false} unless current
340
+ error = current.fetch(:service)[:error]
341
+ {enabled: true, mode: current[:mode], mutation: current[:mutation],
342
+ captures: current[:captures], failures: current[:failures],
343
+ committer_calls: current[:committer_calls], encoder_calls: current[:encoder_calls],
344
+ captured_result: current[:captured_result], captured_error: current[:captured_error],
345
+ diagnostic_reads_after_capture: error && current[:diagnostic_reads_at_capture] &&
346
+ error.reads - current[:diagnostic_reads_at_capture]}
347
+ end
348
+ end
349
+ end
350
+
351
+ module G3jCommitScope
352
+ def commit_outcome(command, **options)
353
+ previous = Thread.current[:g3j_report_outcome]
354
+ selected = G3jReportFault.selected?(command)
355
+ Thread.current[:g3j_report_outcome] = selected ? G3jReportFault.current : nil
356
+ G3jReportFault.current[:committer_calls] += 1 if selected
357
+ super
358
+ ensure
359
+ Thread.current[:g3j_report_outcome] = previous
360
+ end
361
+ end
362
+
363
+ module G3jCapturedEvidence
364
+ def capture_evidence(evidence)
365
+ super
366
+ G3jReportFault.after_capture(evidence)
367
+ end
368
+ end
369
+
370
+ module G3jEncodingCount
371
+ def encode(*args, **options)
372
+ G3jReportFault.context[:encoder_calls] += 1 if G3jReportFault.context
373
+ super
374
+ end
375
+ end
376
+
377
+ module G3jTransactionResponse
378
+ def atomic(*args, &transaction)
379
+ fault = G3jReportFault.context
380
+ return super unless fault && fault[:mode] != :none
381
+ if fault[:readback_loss]
382
+ fault[:readback_loss] = false
383
+ raise IOError, "Immediate report save readback unavailable"
384
+ end
385
+ return super unless fault[:armed]
386
+ fault[:armed] = false
387
+ fault[:failures] += 1
388
+ if fault[:mode] == :pre
389
+ super(*args) do |scope|
390
+ transaction.call(scope)
391
+ fault[:readback_loss] = true
392
+ raise IOError, "Report save rolled back and response lost"
393
+ end
394
+ else
395
+ super(*args, &transaction)
396
+ fault[:readback_loss] = true
397
+ raise IOError, "Report save committed and response lost"
398
+ end
399
+ end
400
+ end
401
+
402
+ Phronomy::Agent::ExecutionOutcomeCommitter.prepend(G3jCommitScope)
403
+ Phronomy::Agent::OutcomeRecoveryOperation.prepend(G3jCapturedEvidence)
404
+ Phronomy::Agent::RuntimeRecordEncoder.singleton_class.prepend(G3jEncodingCount)
405
+
406
+ def report_fault(mutation:, mode:)
407
+ raise ArgumentError, "Unknown mutation" unless %i[none output diagnostic].include?(mutation)
408
+ raise ArgumentError, "Unknown response loss" unless %i[none pre post].include?(mode)
409
+ lambda do |service|
410
+ service.fetch(:stores).agent.coordinator.singleton_class.prepend(G3jTransactionResponse)
411
+ G3jReportFault.current = {service: service, execution_id: service.fetch(:execution_id),
412
+ mutation: mutation, mode: mode, armed: true, readback_loss: false,
413
+ captures: 0, failures: 0, committer_calls: 0, encoder_calls: 0}
414
+ end
415
+ end
416
+ ```
417
+
418
+
419
+ <!-- g3j-code:shared-driver -->
420
+ ```ruby
421
+ # Pending results retain the live owner and exact recovery capability. A real
422
+ # service must keep these values until resolution. This process only reports
423
+ # the retained state and the incomplete cleanup; it provides no restart path.
424
+ def run_report_example(normal: false, failure: false, mutation: :none, mode: :none,
425
+ retry_confirmed_pre: false)
426
+ begin
427
+ report = if normal
428
+ run_report(failure: failure)
429
+ else
430
+ run_report_with_recovery(fault: report_fault(mutation: mutation, mode: mode),
431
+ retry_confirmed_pre: retry_confirmed_pre, failure: failure)
432
+ end
433
+ report = report.reject { |key, _value| %i[retained_service retained_recovery].include?(key) }
434
+ ensure
435
+ Phronomy::Runtime.instance.shutdown(timeout: 0.03, cancel_grace: 0.2)
436
+ begin
437
+ Phronomy.reset_runtime!
438
+ cleanup_incomplete = false
439
+ rescue Phronomy::RuntimeShutdownError
440
+ cleanup_incomplete = true
441
+ end
442
+ end
443
+ report.merge(cleanup_incomplete: cleanup_incomplete, fixture: G3jReportFault.report)
444
+ end
445
+
446
+ if $PROGRAM_NAME == __FILE__
447
+ puts JSON.pretty_generate(run_report_example(normal: ENV["G3J_NORMAL"] == "true",
448
+ failure: ENV["G3J_FAILURE"] == "true", mutation: ENV.fetch("G3J_MUTATION", "none").to_sym,
449
+ mode: ENV.fetch("G3J_MODE", "none").to_sym,
450
+ retry_confirmed_pre: ENV["G3J_RETRY_CAPTURED_OUTCOME"] == "true"))
451
+ end
452
+ ```
453
+
454
+
455
+ The driver reports retained ownership and incomplete cleanup rather than treating process exit as successful resolution. Its bounded shutdown is test cleanup, not a supported recovery across stopped Runtime or process restart. A long-running application must keep the returned service and recovery capability alive while the result is retained.
456
+
457
+ Example invocations select one case per process:
458
+
459
+ ```sh
460
+ G3J_NORMAL=true bundle exec ruby retained_report_application.rb
461
+ G3J_NORMAL=true G3J_FAILURE=true bundle exec ruby retained_report_application.rb
462
+ G3J_MUTATION=output G3J_MODE=post bundle exec ruby retained_report_application.rb
463
+ G3J_MUTATION=output G3J_MODE=pre G3J_RETRY_CAPTURED_OUTCOME=true bundle exec ruby retained_report_application.rb
464
+ G3J_FAILURE=true G3J_MUTATION=diagnostic G3J_MODE=post bundle exec ruby retained_report_application.rb
465
+ G3J_FAILURE=true G3J_MUTATION=diagnostic G3J_MODE=pre bundle exec ruby retained_report_application.rb
466
+ ```
467
+
468
+ ## Public contract and symmetry decisions
469
+
470
+ The shared Agent owner publishes the same captured representation for standalone terminal recovery and native terminal-outcome recovery. Comparable operations retain their own domain meanings: recovery observation does not become an approval decision, a business retry or a new durable owner.
471
+
472
+ For example, native `reconcile_outcome` and standalone `reconcile_terminal` both need the saved failure to remain readable when its original exception is no longer available. An approval wait still needs its own subsequent decision, and a positively refused worker submission still needs the separate submission-retry operation.
473
+
474
+ | Peer operation or value | Naming, values and lifecycle | Decision |
475
+ | --- | --- | --- |
476
+ | `reconcile_outcome` / `reconcile_outcome_async` | Same required exact `recovery:`; synchronous receipt or fresh `TaskResult`; read-only persistence observation. | Adopt captured publication through the existing owner. No retry flag or new default. |
477
+ | `retry_outcome` / `retry_outcome_async` | Same exact recovery capability and result family; explicit permission for eligible captured writes. | Preserve authority, physical-settlement and exact pre-state checks. |
478
+ | Standalone terminal recovery | Existing terminal-only operation family shares the recovery owner implementation. | Adopt the same captured terminal observation, rather than a separate diagnostic cache. |
479
+ | `Store#observe_execution` | Result format, raw output and full diagnostic describe saved execution facts. | Align recovery representation with the same captured content. Independently changing cancellation request facts retain their existing contract. |
480
+ | Ordinary invoke or stream delivery | Original result/error delivery follows its existing execution path. | Preserve original business exception identity and stream semantics; this comparison exercises hosted invocation, not Provider streaming. |
481
+ | Approval recovery and native waits | Decision and continuation semantics differ from terminal results. | Keep existing kind and lifetime; do not add terminal facts to a wait. |
482
+ | First-submission retry | Positive non-admission evidence is required. | Do not treat a diagnostic-publication failure as worker refusal. |
483
+ | New generic preparation retry or termination | No complete replay or disposition authority follows from mere retention. | Defer; not required to repair publication after complete capture. |
484
+
485
+ Synchronous recovery continues to reject EventLoop reentrancy. Observer timeout or cancellation closes an observation according to its existing contract; it does not end a backend transaction, authorize overlapping work or transfer the live owner. No public migration is required, but application tests that relied on a mutated recovery value must adopt the saved-value contract.
486
+
487
+ ## Acceptance, model coverage and remaining limits
488
+
489
+ Acceptance separates persistence truth, local application, observation publication and physical ownership. Exact readback alone cannot prove that an application receives the right facts, so the change requires direct comparison of recovery observations with stored representations and checks that original business work is not repeated.
490
+
491
+ For example, a pre-state retry must preserve captured text after the application mutates its String, while a post-state reconciliation must publish a captured failure without re-reading its original exception. In both cases, the original failed task stays failed and the Provider and encoder counters stay at one.
492
+
493
+ | Recorded validation | Result | Interpretation |
494
+ | --- | --- | --- |
495
+ | Isolated G3i custom-diagnostic characterization | One example, zero failures; all 407 library source files match the exact baseline Git content. | Reproduces the defect: a durable failed result remains unavailable and retained when publication reads the original diagnostic again. |
496
+ | Same application matrix on baseline and candidate | Nine baseline cases and nine candidate cases match their declared expectations. | Ordinary success/failure reports are identical. Candidate recovery facts match stored output/diagnostics, with zero diagnostic reads after capture; explicit pre-state holds remain retained. |
497
+ | Source reconstructed from this document | All eight blocks match the executed source; complete before/after Ruby syntax passes; 18 direct runs match the matrix reports and selected source hashes. | Repeats the same nine cases on two versions to verify the published source, rather than adding 18 independent scenarios. |
498
+ | Existing finite model family | All 153 configurations match their declared outcomes: 73 positive properties, 55 deliberate mutations, 15 witnesses and ten missing-premise cases. | Expected negative cases demonstrate the need for a rule or environmental premise; they are not unfixed violations in the correct protocol. |
499
+
500
+ The acceptance scope includes mutable plain and structured results, structured raw output, full output-contract diagnostic fields, unavailable custom business diagnostics, standalone and native terminal owners, delayed or retried publication, exact pre/post cases, ordinary exception identity and explicit retry holds. Missing captured content must remain a precise preparation failure. The application fixture above covers its declared plain-result and business-error scenarios; independent implementation tests carry structured output, actual child obligations and other lifecycle paths. A green fixture is not a claim that every external service or backend has been audited.
501
+
502
+ The existing [native parent outcome recovery model](../../spec/models/native_parent_outcome_recovery/README.md) is extended rather than replaced. The publication abstraction distinguishes the captured fact, mutable live source and published observation. Fourteen new configurations add four safety checks, three conditional progress checks, four safety mutations, one progress mutation and two reachability witnesses; the preceding 139 configurations keep their scenarios and selected properties. `ExactPublishedPayload` requires the published fact to equal the confirmed captured value, and `NoPublicationReconversion` excludes another original diagnostic conversion. Diagnostic unavailability must not block otherwise eligible publication in pre-state, post-state or deferred-proof cases. Existing physical settlement, exact owner, retained responsibility and original-observer invariants remain required.
503
+
504
+ The new publication cases bound one captured terminal result, one later source change, two payload identities and at most two forbidden conversion attempts in the deliberate mutant. The inherited limits include one representative child, three management attempts and two observers; the 14 new cases select no child-authority drift. Raw-output mutation is an overapproximation because the concrete response content is copied and frozen. Payload-token equality is not a refinement proof of JSON decoding, complete `OutputError` fields or arbitrary Ruby conversion. The five existing entity/preparation diagrams keep their topology, and the old 139 configurations did not establish the absence of the newly represented publication defects.
505
+
506
+ A failure before complete evidence exists remains residual group 1. Existing factual resolution is limited to precise durable LLM or Tool subjects; ordinary failure encoding can itself repeat the failing conversion. Neither cancellation intent nor retaining a live owner proves that unresolved child obligations or external effects have been discharged. A future non-replaying termination requires its own disposition, audit representation and positive authority. G3j does not close that work, stopped-Runtime recovery or production-backend acceptance.
@@ -18,7 +18,7 @@ reconciliation belongs to `ExecutionChange#perform_once`.
18
18
  |---|---|---|
19
19
  | `agent/execution/execution_coordinator.rb` | Provider dispatch preparation | Agent environment; ProviderDispatchPreparationReady |
20
20
  | same | Tool dispatch preparation | Agent environment; ToolDispatchPreparationReady |
21
- | same | Initial invocation preparation | Agent environment; InitialPreparationReady |
21
+ | same | Initial invocation preparation | Agent environment; InitialPreparationRecoveryOperation::Ready |
22
22
  | same | Recovery of initial preparation | Agent environment; InitialPreparationRecoveryReady |
23
23
  | same | Approval resume commit | Agent environment; ResumeCommitReady and admission handling |
24
24
  | same | Terminal outcome commit | Agent environment; TerminalCommitReady and commit/readback policy |
@@ -135,6 +135,15 @@ also compares delivery. Resume/approval restore the saved choice, and a reserved
135
135
  ID cannot be reused with a different schema or delivery. Generic config/provider
136
136
  schema overrides are rejected.
137
137
 
138
+ The invocation keeps its immutable output contract after admission. A restored
139
+ invocation receives the contract loaded from its saved schema before it resumes.
140
+ At final validation the worker checks the content reference, digest and delivery
141
+ against the execution record and validates the output once. A schema-store
142
+ outage after the last Provider or Tool call therefore cannot turn a valid result
143
+ into a stored business failure. When a worker has to restore a missing contract,
144
+ a read or integrity failure leaves the execution pending. An actual invalid
145
+ output still produces its durable OutputError.
146
+
138
147
  Structured success stores JSON result plus raw_output_ref and result_format=json.
139
148
  Old records without output_contract remain facts from a free-text execution; no
140
149
  schema is added retroactively. Existing output_contract version 1 is read as
@@ -183,6 +192,12 @@ ownership or reservation, and an unresolved execution requiring recovery or
183
192
  approval wiring. Such errors do not manufacture a failed execution record.
184
193
  The ordinary Agent event listener and its existing error policy are unchanged.
185
194
 
195
+ Reserved-start validation has a narrower explicit failure contract:
196
+ `Agent::ExecutionRejectedError` identifies a request rejected before attempting
197
+ durable admission. It does not assert that another caller has not started the
198
+ same reserved execution. Team checks that identity under its admission guard
199
+ before finalizing its own run; see [Team admission rejection](team-admission-rejection.md).
200
+
186
201
  Applications that need the saved failure raised explicitly can use the existing
187
202
  observation conversion after receiving the result:
188
203