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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +87 -0
- data/README.md +24 -2
- data/SECURITY.md +1 -1
- data/docs/architecture/agent-approval-recovery.md +320 -0
- data/docs/architecture/agent-child-approval-recovery.md +387 -0
- data/docs/architecture/agent-child-execution-recovery.md +425 -0
- data/docs/architecture/agent-dispatch-recovery.md +308 -0
- data/docs/architecture/agent-terminal-persistence-evidence.md +360 -0
- data/docs/architecture/agent-terminal-recovery.md +298 -0
- data/docs/architecture/agent-terminal-submission-recovery.md +275 -0
- data/docs/architecture/agent-tool-child-lifetime.md +29 -0
- data/docs/architecture/agent-transition-ownership.md +24 -0
- data/docs/architecture/backend-groups.md +6 -0
- data/docs/architecture/detached-outcome-proof-projection.md +576 -0
- data/docs/architecture/execution-abstraction-review.md +5 -0
- data/docs/architecture/handoff-dispatch-recovery.md +205 -0
- data/docs/architecture/handoff-initial-terminal-application.md +321 -0
- data/docs/architecture/initial-preparation-recovery.md +308 -0
- data/docs/architecture/multi-agent-handoff.md +17 -0
- data/docs/architecture/native-outcome-preparation.md +715 -0
- data/docs/architecture/native-parent-dispatch-recovery.md +460 -0
- data/docs/architecture/native-parent-outcome-recovery.md +644 -0
- data/docs/architecture/parent-child-terminal-acknowledgement.md +297 -0
- data/docs/architecture/r8-unit12.md +6 -3
- data/docs/architecture/r8-unit4.md +11 -2
- data/docs/architecture/recovery-physical-attempt.md +88 -0
- data/docs/architecture/recovery-submission-custody.md +247 -0
- data/docs/architecture/retained-attempts.md +229 -0
- data/docs/architecture/retained-outcome-materialization.md +636 -0
- data/docs/architecture/retained-outcome-publication.md +506 -0
- data/docs/architecture/storage-execution-boundaries.md +1 -1
- data/docs/architecture/structured-output-and-scope.md +15 -0
- data/docs/architecture/synchronous-participant-application.md +397 -0
- data/docs/architecture/synchronous-participant-contract.md +195 -0
- data/docs/architecture/team-admission-rejection.md +91 -0
- data/docs/architecture/team-cancellation-delivery.md +245 -0
- data/docs/architecture/team-child-retirement.md +104 -0
- data/docs/architecture/tracing.md +26 -0
- data/docs/architecture/workflow-terminal-ownership-design.md +25 -9
- data/docs/architecture/workflow-terminal-reconciliation.md +221 -0
- data/docs/architecture.md +16 -9
- data/docs/decisions/025-process-local-agent-ownership-and-runtime-admission.md +8 -0
- data/docs/features.md +3 -3
- data/docs/mcp-client.md +138 -5
- data/docs/migrations/orchestrator-subagent-dispatch.md +89 -0
- data/docs/migrations/vector-async-clients.md +18 -3
- data/docs/persistence-backends.md +30 -4
- data/docs/runtime-and-concurrency.md +235 -11
- data/lib/phronomy/agent/admission.rb +37 -17
- data/lib/phronomy/agent/api/agent.rb +25 -0
- data/lib/phronomy/agent/approval_recovery.rb +30 -0
- data/lib/phronomy/agent/approval_recovery_api.rb +61 -0
- data/lib/phronomy/agent/approval_recovery_error.rb +39 -0
- data/lib/phronomy/agent/approval_recovery_result.rb +94 -0
- data/lib/phronomy/agent/async_event_api.rb +22 -5
- data/lib/phronomy/agent/base.rb +76 -48
- data/lib/phronomy/agent/context_preparation.rb +10 -8
- data/lib/phronomy/agent/dispatch_recovery.rb +29 -0
- data/lib/phronomy/agent/dispatch_recovery_api.rb +84 -0
- data/lib/phronomy/agent/dispatch_recovery_error.rb +36 -0
- data/lib/phronomy/agent/dispatch_recovery_result.rb +93 -0
- data/lib/phronomy/agent/execution/agent_invocation.rb +11 -3
- data/lib/phronomy/agent/execution/approval_continuation_plan.rb +131 -0
- data/lib/phronomy/agent/execution/approval_parent_evidence.rb +116 -0
- data/lib/phronomy/agent/execution/approval_persistence_evidence.rb +111 -0
- data/lib/phronomy/agent/execution/approval_recovery_operation.rb +496 -0
- data/lib/phronomy/agent/execution/approval_resume_commit.rb +174 -10
- data/lib/phronomy/agent/execution/dispatch_continuation_delivery.rb +96 -0
- data/lib/phronomy/agent/execution/dispatch_persistence_evidence.rb +147 -0
- data/lib/phronomy/agent/execution/dispatch_preparation.rb +63 -7
- data/lib/phronomy/agent/execution/dispatch_recovery_operation.rb +495 -0
- data/lib/phronomy/agent/execution/execution_coordinator.rb +724 -158
- data/lib/phronomy/agent/execution/execution_outcome_committer.rb +312 -39
- data/lib/phronomy/agent/execution/execution_registry.rb +508 -13
- data/lib/phronomy/agent/execution/initial_persistence_evidence.rb +269 -0
- data/lib/phronomy/agent/execution/initial_preparation.rb +132 -40
- data/lib/phronomy/agent/execution/initial_preparation_recovery_operation.rb +513 -0
- data/lib/phronomy/agent/execution/invocation_transitions.rb +3 -0
- data/lib/phronomy/agent/execution/outcome_planning.rb +108 -0
- data/lib/phronomy/agent/execution/outcome_preparation.rb +81 -0
- data/lib/phronomy/agent/execution/outcome_recovery_operation.rb +609 -0
- data/lib/phronomy/agent/execution/outcome_text_projection.rb +73 -0
- data/lib/phronomy/agent/execution/outcome_write_plan.rb +48 -0
- data/lib/phronomy/agent/execution/runtime_record_encoder.rb +7 -4
- data/lib/phronomy/agent/execution/terminal_persistence_evidence.rb +280 -0
- data/lib/phronomy/agent/execution/terminal_recovery_operation.rb +38 -0
- data/lib/phronomy/agent/execution_change.rb +138 -26
- data/lib/phronomy/agent/execution_environment.rb +29 -0
- data/lib/phronomy/agent/execution_rejected_error.rb +34 -0
- data/lib/phronomy/agent/initial_preparation_recovery.rb +32 -0
- data/lib/phronomy/agent/initial_preparation_recovery_api.rb +85 -0
- data/lib/phronomy/agent/initial_preparation_recovery_error.rb +41 -0
- data/lib/phronomy/agent/initial_preparation_recovery_result.rb +115 -0
- data/lib/phronomy/agent/lifecycle/hosted_approval_context.rb +86 -0
- data/lib/phronomy/agent/lifecycle/hosted_invocation.rb +42 -10
- data/lib/phronomy/agent/lifecycle/identity_write.rb +101 -0
- data/lib/phronomy/agent/lifecycle/lifetime_api.rb +28 -0
- data/lib/phronomy/agent/lifecycle/ownership_registry.rb +136 -70
- data/lib/phronomy/agent/lifecycle/scope.rb +3 -3
- data/lib/phronomy/agent/outcome_recovery.rb +47 -0
- data/lib/phronomy/agent/outcome_recovery_api.rb +114 -0
- data/lib/phronomy/agent/outcome_recovery_error.rb +36 -0
- data/lib/phronomy/agent/outcome_recovery_result.rb +92 -0
- data/lib/phronomy/agent/output_contract.rb +16 -6
- data/lib/phronomy/agent/persistence/identity_receipt_repository.rb +61 -0
- data/lib/phronomy/agent/persistence/records.rb +2 -0
- data/lib/phronomy/agent/persistence/storage_schema.rb +2 -0
- data/lib/phronomy/agent/recovery/invocation_restorer.rb +8 -5
- data/lib/phronomy/agent/recovery/recovery_coordinator/continuation.rb +6 -4
- data/lib/phronomy/agent/recovery/recovery_coordinator/installation.rb +21 -43
- data/lib/phronomy/agent/recovery/recovery_coordinator.rb +19 -6
- data/lib/phronomy/agent/runtime_binding/engine_environment.rb +12 -0
- data/lib/phronomy/agent/state_writer.rb +4 -3
- data/lib/phronomy/agent/store.rb +7 -1
- data/lib/phronomy/agent/terminal_recovery.rb +41 -0
- data/lib/phronomy/agent/terminal_recovery_api.rb +101 -0
- data/lib/phronomy/agent/terminal_recovery_error.rb +36 -0
- data/lib/phronomy/agent/terminal_recovery_result.rb +67 -0
- data/lib/phronomy/agent/tool_execution/tool_approval_request.rb +25 -1
- data/lib/phronomy/common/values/serializable.rb +37 -4
- data/lib/phronomy/engine/concurrency/offload_pool.rb +32 -4
- data/lib/phronomy/engine/concurrency/pool_registry.rb +6 -0
- data/lib/phronomy/engine/event_loop.rb +161 -11
- data/lib/phronomy/engine/execution_binding.rb +4 -2
- data/lib/phronomy/engine/execution_receiver_binding.rb +5 -0
- data/lib/phronomy/engine/runtime/shutdown_result.rb +21 -0
- data/lib/phronomy/engine/runtime/timer_queue.rb +7 -2
- data/lib/phronomy/engine/runtime.rb +119 -15
- data/lib/phronomy/execution/attempt_completion.rb +91 -0
- data/lib/phronomy/execution/concurrency/cancellation_token.rb +7 -2
- data/lib/phronomy/execution/concurrency/physical_completion_task.rb +7 -2
- data/lib/phronomy/execution/execution.rb +17 -2
- data/lib/phronomy/execution/execution_receiver.rb +27 -0
- data/lib/phronomy/execution/execution_retirement.rb +30 -0
- data/lib/phronomy/execution/invocation_controls.rb +2 -2
- data/lib/phronomy/execution/retained_attempts.rb +179 -0
- data/lib/phronomy/execution/stopped_terminal_custody.rb +99 -0
- data/lib/phronomy/llm_adapter/response.rb +7 -1
- data/lib/phronomy/multi_agent/admission_registry.rb +6 -0
- data/lib/phronomy/multi_agent/durable_subagent_coordinator.rb +175 -39
- data/lib/phronomy/multi_agent/handoff_dispatch_evidence.rb +176 -0
- data/lib/phronomy/multi_agent/handoff_finalization_error.rb +33 -0
- data/lib/phronomy/multi_agent/handoff_history_release.rb +80 -0
- data/lib/phronomy/multi_agent/handoff_participant.rb +31 -6
- data/lib/phronomy/multi_agent/handoff_runner.rb +195 -21
- data/lib/phronomy/multi_agent/handoff_terminal_finalization.rb +176 -0
- data/lib/phronomy/multi_agent/native_approval_evidence.rb +26 -0
- data/lib/phronomy/multi_agent/native_child_authority.rb +135 -0
- data/lib/phronomy/multi_agent/native_dispatch_evidence.rb +43 -0
- data/lib/phronomy/multi_agent/native_outcome_evidence.rb +46 -0
- data/lib/phronomy/multi_agent/native_persistence_plan.rb +93 -0
- data/lib/phronomy/multi_agent/orchestrator.rb +28 -52
- data/lib/phronomy/multi_agent/reserved_child_admission.rb +90 -1
- data/lib/phronomy/multi_agent/store.rb +5 -34
- data/lib/phronomy/multi_agent/subagent_history_release.rb +88 -0
- data/lib/phronomy/multi_agent/team_cancellation_delivery_error.rb +21 -0
- data/lib/phronomy/multi_agent/team_cancellation_request.rb +134 -0
- data/lib/phronomy/multi_agent/team_coordinator.rb +174 -27
- data/lib/phronomy/persistence_composition/stores.rb +10 -3
- data/lib/phronomy/runtime_composition/execution_defaults.rb +18 -0
- data/lib/phronomy/storage/backends/in_memory.rb +3 -1
- data/lib/phronomy/storage/resource.rb +10 -1
- data/lib/phronomy/tools/agent.rb +7 -1
- data/lib/phronomy/tools/mcp.rb +210 -91
- data/lib/phronomy/tools/mcp_http_close_response.rb +23 -0
- data/lib/phronomy/tools/mcp_transport_registry.rb +210 -0
- data/lib/phronomy/tools/vector_search.rb +28 -5
- data/lib/phronomy/tracing/automatic.rb +8 -1
- data/lib/phronomy/version.rb +1 -1
- data/lib/phronomy/workflow/execution/workflow.rb +34 -0
- data/lib/phronomy/workflow/execution/workflow_execution_environment.rb +1 -0
- data/lib/phronomy/workflow/execution/workflow_execution_registry.rb +106 -7
- data/lib/phronomy/workflow/execution/workflow_runner.rb +53 -108
- data/lib/phronomy/workflow/execution/workflow_terminal_operation.rb +489 -0
- data/lib/phronomy/workflow/execution/workflow_terminal_persistence.rb +81 -0
- data/lib/phronomy/workflow/execution/workflow_terminal_recovery.rb +38 -0
- data/lib/phronomy/workflow/execution/workflow_terminal_recovery_error.rb +34 -0
- data/lib/phronomy/workflow/execution/workflow_terminal_recovery_result.rb +56 -0
- data/lib/phronomy/workflow/runtime_binding/workflow_engine_environment.rb +10 -1
- data/lib/phronomy/workflow/runtime_binding/workflow_task_session.rb +3 -1
- data/lib/phronomy/workflow/runtime_binding/workflow_terminal_policy.rb +2 -1
- data/scripts/api_snapshot.rb +46 -1
- data/sig/_private/phronomy/multi_agent/team_cancellation_request.rbs +19 -0
- data/sig/phronomy/agent/approval_recovery.rbs +54 -0
- data/sig/phronomy/agent/dispatch_recovery.rbs +49 -0
- data/sig/phronomy/agent/execution_contract.rbs +4 -1
- data/sig/phronomy/agent/execution_environment.rbs +2 -0
- data/sig/phronomy/agent/initial_preparation_recovery.rbs +48 -0
- data/sig/phronomy/agent/outcome_recovery.rbs +51 -0
- data/sig/phronomy/agent/store.rbs +1 -0
- data/sig/phronomy/agent/terminal_persistence_evidence.rbs +111 -0
- data/sig/phronomy/agent/terminal_recovery.rbs +46 -0
- data/sig/phronomy/agent.rbs +36 -0
- data/sig/phronomy/engine/concurrency/timer_bindings.rbs +2 -0
- data/sig/phronomy/engine/execution_binding.rbs +2 -1
- data/sig/phronomy/engine/execution_receiver.rbs +4 -0
- data/sig/phronomy/engine/observability.rbs +22 -1
- data/sig/phronomy/execution/execution.rbs +16 -1
- data/sig/phronomy/execution/execution_receiver.rbs +12 -0
- data/sig/phronomy/execution/execution_retirement.rbs +18 -0
- data/sig/phronomy/execution/stopped_terminal_custody.rbs +19 -0
- data/sig/phronomy/handoff.rbs +1 -0
- data/sig/phronomy/multi_agent/handoff_finalization_error.rbs +18 -0
- data/sig/phronomy/multi_agent/store.rbs +1 -1
- data/sig/phronomy/multi_agent/team_cancellation_delivery_error.rbs +9 -0
- data/sig/phronomy/persistence_composition.rbs +2 -1
- data/sig/phronomy/storage/contracts.rbs +2 -1
- data/sig/phronomy/tools/mcp.rbs +27 -0
- data/sig/phronomy/workflow.rbs +42 -0
- metadata +104 -2
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# Native parent dispatch recovery
|
|
2
|
+
|
|
3
|
+
A native coordinating Agent owns its unfinished execution and the next Provider or Tool continuation. Its native participant owns child reservations, result-import decisions and the durable facts that connect those children to the parent. This increment extends original-owner dispatch recovery across that boundary while keeping those responsibilities separate.
|
|
4
|
+
|
|
5
|
+
For example, a report Orchestrator reserves a report child, or imports that child's completed report before asking its Provider for the final response. If the parent dispatch prerequisite commits but its response and immediate readback are unavailable, the original parent retains the captured operation. Recovery establishes the saved fact and checks the child's current authority before the original continuation can start.
|
|
6
|
+
|
|
7
|
+
Baseline: applied G3f commit `56e0e5bfedc5715749d9f10d1ddab11654d02db2`, tree `299dc7d7fe4996136eec5b77612a5413c98ef8d7`. This document describes the G3g implementation candidate, not its later application acceptance. Contract concept v55 and foundation v48 remain the architectural references. The [Agent dispatch contract](agent-dispatch-recovery.md) defines the existing public capability, receipt and observation semantics.
|
|
8
|
+
|
|
9
|
+
G3g was subsequently applied as `44288e1239701bf16aa67854a48c830b7295e2d4`. G3h adds [native final/wait and own approval recovery](native-parent-outcome-recovery.md). The G3g application source, baseline findings and operation-specific exclusions below remain its historical evidence; they do not claim that the later outcome work was already covered by dispatch recovery.
|
|
10
|
+
|
|
11
|
+
## Keep native decisions with the native owner
|
|
12
|
+
|
|
13
|
+
The generic Agent retains one operation and applies its eventual outcome through its original Runtime owner. The native participant supplies a detached persistence plan for its own domain. The plan contains immutable captured facts; it does not preserve a live participant callback or grant permission to run native coordination decisions again.
|
|
14
|
+
|
|
15
|
+
For example, a Tool prerequisite creates an exact child slot and the parent's retention hold. A retry saves the same captured extension content, the same allowed hold addition and the same Agent execution. It does not reserve a different child, repeat knowledge projection, reinterpret `on_error`, import a newly observed child result or call the original participant's commit method again.
|
|
16
|
+
|
|
17
|
+
| Responsibility | Owner | Captured or checked facts |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Preparation and next continuation | Original Agent and FSMSession | Captured Provider input or Tool batch; execution, operation and session identity; unused continuation right |
|
|
20
|
+
| Parent barrier proof | Agent Store and detached evidence | Complete parent root/execution/journal/content/cancellation footprint plus native parent retention evidence |
|
|
21
|
+
| Native persistence plan | Native participant | Exact captured extension bytes and bounded parent-hold addition reconstructed from the original before/after evidence |
|
|
22
|
+
| Child continuation authority | Native participant under ordered Store guards | Current root/execution and saved definition identity, exact native reservation/correlation, required hold and allowed terminal/absent state |
|
|
23
|
+
| Retry policy and unresolved capability lifetime | Application | Whether and when to request a persistence-only retry; retention of the original parent and capability |
|
|
24
|
+
| Result delivery and physical completion | Original Runtime and existing retained-operation machinery | Independent observations, worker completion and one-time continuation handoff |
|
|
25
|
+
|
|
26
|
+
The optional participant capability is private and limited to the native coordinator. Generic Agent code treats its plan as opaque and does not interpret native child slots or Handoff routing. Ordinary synchronous callbacks alone grant neither persistence replay nor fresh domain continuation. The later [synchronous participant custody contract](synchronous-participant-contract.md) retains uncertain custom-participant and Handoff operations through the existing owners even when supported replay proof is unavailable; custody and replay permission are separate.
|
|
27
|
+
|
|
28
|
+
For example, a Handoff Source transfer has routing, holds and a transfer receipt beyond a native child reservation. It requires its own domain proof and current-routing authority; the native plan cannot certify that transfer.
|
|
29
|
+
|
|
30
|
+
## Separate saved history from current continuation authority
|
|
31
|
+
|
|
32
|
+
A saved parent barrier and permission to continue it are different propositions. The complete captured parent footprint classifies the original write as pre-state, post-state or unknown. A fresh native-domain check determines whether its still-unused continuation can act on the children now. A known committed parent write remains a historical fact when a later child mutation blocks continuation.
|
|
33
|
+
|
|
34
|
+
For example, reconciliation may prove that a parent's child-import prerequisite committed. If that child has since been replaced or become active under a conflicting identity, recovery must preserve the confirmed parent history while withholding the new Provider dispatch. Changing the receipt to confirmed pre-state or writing the barrier again would misrepresent the saved history.
|
|
35
|
+
|
|
36
|
+
| Captured child relationship | Current authority required before first continuation |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| Already imported child | The exact terminal child with its native parent/slot correlation and required retained-history hold |
|
|
39
|
+
| Previously reserved, unimported child | The exact terminal child with matching authority, or both its root and execution fully absent as permitted by the saved reservation |
|
|
40
|
+
| Newly captured child slot | Both the exact child root and execution absent before admission |
|
|
41
|
+
| Active, suspended, replaced or incompletely absent child | Continuation is blocked; a partial record or matching identifier alone does not grant authority |
|
|
42
|
+
|
|
43
|
+
The current child check establishes identity, saved definition, terminal status, correlation and the required hold; it does not capture a new byte-for-byte child-result receipt. It relies on the existing immutable terminal-history contract. Unrelated holds or cancellation intent do not erase an exact terminal child history; the required native hold must still be present. Reconciliation and retry perform these checks again before the first continuation, including when post-state was remembered by an earlier attempt. A known-post retry is read-only. Conflicting or unavailable current evidence leaves the continuation unadmitted; the application retains the original capability and receives the existing receipt/error shape.
|
|
44
|
+
|
|
45
|
+
For example, a first read can establish post-state while result delivery is delayed. A second observation must still inspect the child before admitting the original Tool. Remembering post-state is useful for historical accuracy, but does not bypass the child check or authorize a second external call.
|
|
46
|
+
|
|
47
|
+
## Bound the persistence-only retry
|
|
48
|
+
|
|
49
|
+
The retry is one guarded transaction over captured parent effects. Parent and existing affected child-root guards are acquired in a stable order, the exact original pre-state is checked, and the native plan restores only its bounded immutable writes together with the captured Agent execution. The Store cannot guard an absent child root; new-child root and execution absence are checked inside that same transaction. A failed or incomplete proof cannot be repaired by repeating preparation or participant business logic.
|
|
50
|
+
|
|
51
|
+
For example, a rolled-back Tool prerequisite leaves no new child root or execution. An explicit retry can restore its captured reservation content and parent hold, save the captured dispatch execution, and verify the resulting complete post-state. If a child appeared in the meantime, that same retry is refused rather than adopting the new child.
|
|
52
|
+
|
|
53
|
+
The storage contract must provide settled prior attempts, authoritative ordered readback, atomic transactions and exclusion for all ordered guards. The model's `StableRead` premise excludes conflicting parent-proof or child-authority mutation between the guarded snapshot and continuation admission. The absence check is not a distributed reservation of an absent child identity. Transaction isolation and exclusion of unauthorized competing writers remain Store and integration obligations; a process-local lock or a stopped worker alone does not establish them for a remote backend.
|
|
54
|
+
|
|
55
|
+
For example, an old database transaction that may still commit after a reported pre-state defeats a guarded retry unless the backend first establishes its settlement. Likewise, releasing guards before external dispatch is correct only under the stated original-owner and admission protocol; the implementation does not hold database locks across Provider calls or Tool execution.
|
|
56
|
+
|
|
57
|
+
A retry does not rewrite root or journal history, reconstruct content from current mutable state, recreate a child or release child-history holds. The exact plan and complete post-state verification bound the write set. Any additional backend or external-service guarantee needs separate acceptance evidence.
|
|
58
|
+
|
|
59
|
+
For example, adding another retention reference is not permission to broaden the captured retry into a hold cleanup. History release remains the existing native lifetime policy, after exact parent/child custody and local physical-work checks.
|
|
60
|
+
|
|
61
|
+
## Preserve the ordinary report application
|
|
62
|
+
|
|
63
|
+
The application continues to create one parent, observe the child's approval, approve that exact child and receive the same report. It owns approval policy and final pair release. Dispatch recovery adds an explicit uncertain-save branch without requiring the application to parse native extensions, reconstruct child reservations or replay its report request.
|
|
64
|
+
|
|
65
|
+
For example, the tested report application uses an offline Provider adapter and a report Tool whose counter exposes repeated work. Its normal baseline and candidate executions follow the same public source and produce the same output and effects. Fault cases intentionally differ: the candidate exposes retained dispatch responsibility and can continue that original parent.
|
|
66
|
+
|
|
67
|
+
### Shared report service
|
|
68
|
+
|
|
69
|
+
The parent and child definitions, Provider adapter, Tool effect counter and approval listener form the same application on both sides. The adapter sends no network request; the Agent, Store and Runtime are real. The shared setup below requires `phronomy`, `json` and Ruby's `timeout` library.
|
|
70
|
+
|
|
71
|
+
For example, the first Provider response reserves the reviewer, the reviewer requests approval for one report read, and the final responses are `review ready` and `report ready`. The approval event supplies the exact child identity used by the application.
|
|
72
|
+
|
|
73
|
+
<!-- example: shared-setup -->
|
|
74
|
+
```ruby
|
|
75
|
+
# frozen_string_literal: true
|
|
76
|
+
|
|
77
|
+
require "phronomy"
|
|
78
|
+
require "json"
|
|
79
|
+
require "timeout"
|
|
80
|
+
|
|
81
|
+
class G3gReviewTool < Phronomy::Tool::Base
|
|
82
|
+
tool_name "review_one_report"
|
|
83
|
+
description "Read the approved report once"
|
|
84
|
+
requires_approval true
|
|
85
|
+
|
|
86
|
+
class << self
|
|
87
|
+
attr_accessor :effects
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def execute(query:)
|
|
91
|
+
self.class.effects << query
|
|
92
|
+
"reviewed #{query}"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class G3gReviewAgent < Phronomy::Agent::Base
|
|
97
|
+
agent_definition id: "child-execution-reviewer", version: 1
|
|
98
|
+
model "offline-model"
|
|
99
|
+
tools G3gReviewTool => nil
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
class G3gReportParent < Phronomy::MultiAgent::Orchestrator
|
|
103
|
+
agent_definition id: "child-execution-parent", version: 1
|
|
104
|
+
model "offline-model"
|
|
105
|
+
subagent :reviewer, G3gReviewAgent
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class G3gReportAdapter < Phronomy::LLMAdapter::Base
|
|
109
|
+
attr_reader :calls
|
|
110
|
+
|
|
111
|
+
def initialize
|
|
112
|
+
@calls = 0
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def perform_complete(_request, cancellation_token:)
|
|
116
|
+
cancellation_token&.raise_if_cancelled!
|
|
117
|
+
@calls += 1
|
|
118
|
+
name, arguments = case @calls
|
|
119
|
+
when 1 then ["dispatch_to_reviewer", {input: "Review the report"}]
|
|
120
|
+
when 2 then ["review_one_report", {query: "quarterly report"}]
|
|
121
|
+
when 3
|
|
122
|
+
return Phronomy::LLMAdapter::Response.new(content: "review ready", finish_reason: :stop)
|
|
123
|
+
when 4
|
|
124
|
+
return Phronomy::LLMAdapter::Response.new(content: "report ready", finish_reason: :stop)
|
|
125
|
+
else
|
|
126
|
+
raise "Unexpected repeated Provider work"
|
|
127
|
+
end
|
|
128
|
+
Phronomy::LLMAdapter::Response.new(tool_calls: [
|
|
129
|
+
Phronomy::Tool::CallRequest.new(id: "call-#{@calls}", name: name, arguments: arguments)
|
|
130
|
+
], finish_reason: :tool_calls)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def build_report_service
|
|
135
|
+
G3gReviewTool.effects = []
|
|
136
|
+
adapter = G3gReportAdapter.new
|
|
137
|
+
Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
|
|
138
|
+
stores = Phronomy::PersistenceComposition.in_memory
|
|
139
|
+
approvals = Queue.new
|
|
140
|
+
parent = G3gReportParent.create(agent_id: "child-execution-parent", persistence: stores.agent,
|
|
141
|
+
coordination_store: stores.multi_agent,
|
|
142
|
+
on_event: ->(event) { approvals << event.payload.fetch(:request) if event.type == :approval_required })
|
|
143
|
+
[adapter, stores, approvals, parent]
|
|
144
|
+
end
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Equivalent complete normal functions
|
|
148
|
+
|
|
149
|
+
The complete normal function is unchanged. This comparison promises equivalence for the ordinary successful path: the same request, approval policy, child effect, outputs, persisted statuses and final pair release. It does not promise equivalent handling of an injected ambiguous dispatch save.
|
|
150
|
+
|
|
151
|
+
For example, both executions read `quarterly report` once through the approved child, use four Provider responses, complete both saved executions and release the local parent/child pair. They preserve durable history under the existing retention policy.
|
|
152
|
+
|
|
153
|
+
<table>
|
|
154
|
+
<thead><tr><th>Before: applied G3f baseline</th><th>After: G3g candidate</th></tr></thead>
|
|
155
|
+
<tbody><tr><td>
|
|
156
|
+
<!-- example: normal-before -->
|
|
157
|
+
<pre><code># The public approval request supplies the exact child identity.
|
|
158
|
+
def run_report
|
|
159
|
+
adapter, stores, approvals, parent = build_report_service
|
|
160
|
+
parent_id = "child-report-execution"
|
|
161
|
+
reservation = Phronomy::Agent::ReservedExecution.new(agent_id: parent.agent_id, execution_id: parent_id)
|
|
162
|
+
original = parent.start_hosted(reservation: reservation, input: "Prepare the report")
|
|
163
|
+
request = Timeout.timeout(5) { approvals.pop }
|
|
164
|
+
begin
|
|
165
|
+
original.wait_result(timeout: 5)
|
|
166
|
+
rescue Phronomy::ExecutionRehydrationRequiredError
|
|
167
|
+
# The parent has its saved coordination wait for this approval-driven child.
|
|
168
|
+
end
|
|
169
|
+
child = Phronomy::Agent::Base.live_for_execution(request.execution_id)
|
|
170
|
+
child_result = child.approve_async(request.execution_id,
|
|
171
|
+
approval_request_id: request.id, approved: true).wait_result(timeout: 5)
|
|
172
|
+
parent_result = parent.resume(parent_id)
|
|
173
|
+
released = parent.unload_with_completed_child!(parent_id, execution_id: request.execution_id)
|
|
174
|
+
{
|
|
175
|
+
child_output: child_result.fetch(:output), parent_output: parent_result.fetch(:output),
|
|
176
|
+
tool_effects: G3gReviewTool.effects, provider_calls: adapter.calls, released: released,
|
|
177
|
+
statuses: [parent_id, request.execution_id].map { |id| stores.agent.executions.load(id).status },
|
|
178
|
+
revisions: [parent_id, request.execution_id].map { |id| stores.agent.executions.load(id).execution_revision }
|
|
179
|
+
}
|
|
180
|
+
end</code></pre>
|
|
181
|
+
</td><td>
|
|
182
|
+
<!-- example: normal-after -->
|
|
183
|
+
<pre><code># The public approval request supplies the exact child identity.
|
|
184
|
+
def run_report
|
|
185
|
+
adapter, stores, approvals, parent = build_report_service
|
|
186
|
+
parent_id = "child-report-execution"
|
|
187
|
+
reservation = Phronomy::Agent::ReservedExecution.new(agent_id: parent.agent_id, execution_id: parent_id)
|
|
188
|
+
original = parent.start_hosted(reservation: reservation, input: "Prepare the report")
|
|
189
|
+
request = Timeout.timeout(5) { approvals.pop }
|
|
190
|
+
begin
|
|
191
|
+
original.wait_result(timeout: 5)
|
|
192
|
+
rescue Phronomy::ExecutionRehydrationRequiredError
|
|
193
|
+
# The parent has its saved coordination wait for this approval-driven child.
|
|
194
|
+
end
|
|
195
|
+
child = Phronomy::Agent::Base.live_for_execution(request.execution_id)
|
|
196
|
+
child_result = child.approve_async(request.execution_id,
|
|
197
|
+
approval_request_id: request.id, approved: true).wait_result(timeout: 5)
|
|
198
|
+
parent_result = parent.resume(parent_id)
|
|
199
|
+
released = parent.unload_with_completed_child!(parent_id, execution_id: request.execution_id)
|
|
200
|
+
{
|
|
201
|
+
child_output: child_result.fetch(:output), parent_output: parent_result.fetch(:output),
|
|
202
|
+
tool_effects: G3gReviewTool.effects, provider_calls: adapter.calls, released: released,
|
|
203
|
+
statuses: [parent_id, request.execution_id].map { |id| stores.agent.executions.load(id).status },
|
|
204
|
+
revisions: [parent_id, request.execution_id].map { |id| stores.agent.executions.load(id).execution_revision }
|
|
205
|
+
}
|
|
206
|
+
end</code></pre>
|
|
207
|
+
</td></tr></tbody>
|
|
208
|
+
</table>
|
|
209
|
+
|
|
210
|
+
### Complete uncertain-save application
|
|
211
|
+
|
|
212
|
+
The fault-path adaptation handles retained dispatch responsibility on the original parent, then returns to the same report and approval policy. Its helper makes at most one reconciliation and one policy-authorized captured-write retry per observed failure. Unresolved recovery returns the parent and capability to the host; it does not loop, invoke again or release the unresolved owner.
|
|
213
|
+
|
|
214
|
+
For example, recovering the parent's Tool prerequisite leads to the original reviewer's approval request. Recovering the Provider prerequisite after the child has completed leads to the final parent report. A `recovery_pending` result is a host responsibility to retain and observe later, not a completed report.
|
|
215
|
+
|
|
216
|
+
The following complete helper and function share the service above. The injected `fault` callable is a test dependency defined below; it is not an application persistence or recovery API. This helper is exercised for captured native Provider/Tool prerequisites and does not generalize `child_approval_wait` to every rehydration-required error in an arbitrary application.
|
|
217
|
+
|
|
218
|
+
<!-- example: recovery-helper -->
|
|
219
|
+
```ruby
|
|
220
|
+
# Reconciliation reads evidence. Retrying a confirmed pre-state is a separate,
|
|
221
|
+
# explicit application policy; unresolved work keeps its original owner alive.
|
|
222
|
+
def recover_parent_dispatch(parent:, recovery:, retry_confirmed_pre: false)
|
|
223
|
+
receipt = parent.reconcile_dispatch(recovery: recovery)
|
|
224
|
+
if retry_confirmed_pre && receipt.outcome == :confirmed_pre
|
|
225
|
+
receipt = parent.retry_dispatch(recovery: recovery)
|
|
226
|
+
end
|
|
227
|
+
if receipt.resolved?
|
|
228
|
+
{state: :resumed, task: receipt.execution_task, receipt: receipt}.freeze
|
|
229
|
+
else
|
|
230
|
+
{state: :recovery_pending, parent: parent, recovery: recovery, receipt: receipt}.freeze
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# The resumed task may finish, fail, or reach this example's child approval wait.
|
|
235
|
+
# The earlier observation remains failed; it is never reused as the continuation.
|
|
236
|
+
def await_parent(parent:, task:, retry_confirmed_pre:, recoveries:)
|
|
237
|
+
{state: :completed, result: task.wait_result(timeout: 5)}
|
|
238
|
+
rescue Phronomy::ExecutionRehydrationRequiredError
|
|
239
|
+
{state: :child_approval_wait}
|
|
240
|
+
rescue Phronomy::Agent::DispatchRecoveryError => original_failure
|
|
241
|
+
pending = parent.pending_dispatch_recovery(execution_id: original_failure.recovery.execution_id)
|
|
242
|
+
raise "The exact parent recovery owner was not retained" unless pending.equal?(original_failure.recovery)
|
|
243
|
+
observed = recover_parent_dispatch(parent: parent, recovery: pending,
|
|
244
|
+
retry_confirmed_pre: retry_confirmed_pre)
|
|
245
|
+
return observed if observed.fetch(:state) == :recovery_pending
|
|
246
|
+
begin
|
|
247
|
+
task.wait_result(timeout: 5)
|
|
248
|
+
raise "The earlier failed observation reopened"
|
|
249
|
+
rescue Phronomy::Agent::DispatchRecoveryError => repeated
|
|
250
|
+
raise "The earlier failure changed" unless repeated.equal?(original_failure)
|
|
251
|
+
end
|
|
252
|
+
recoveries << {outcome: observed.fetch(:receipt).outcome, original_closed: true,
|
|
253
|
+
continuation_state: observed.fetch(:receipt).continuation_state}
|
|
254
|
+
begin
|
|
255
|
+
{state: :completed, result: observed.fetch(:task).wait_result(timeout: 5)}
|
|
256
|
+
rescue Phronomy::ExecutionRehydrationRequiredError
|
|
257
|
+
{state: :child_approval_wait}
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
<!-- example: recovery-function -->
|
|
263
|
+
```ruby
|
|
264
|
+
# Both dispatch boundaries use the same original parent and retained capability.
|
|
265
|
+
# Approval is still an application decision, supplied exactly once for the child.
|
|
266
|
+
def run_report_with_recovery(fault:, retry_confirmed_pre: false)
|
|
267
|
+
adapter, stores, approvals, parent = build_report_service
|
|
268
|
+
parent_id = "child-report-execution"
|
|
269
|
+
fault.call(stores.agent, parent_id)
|
|
270
|
+
reservation = Phronomy::Agent::ReservedExecution.new(agent_id: parent.agent_id, execution_id: parent_id)
|
|
271
|
+
recoveries = []
|
|
272
|
+
original = parent.start_hosted(reservation: reservation, input: "Prepare the report")
|
|
273
|
+
first = await_parent(parent: parent, task: original,
|
|
274
|
+
retry_confirmed_pre: retry_confirmed_pre, recoveries: recoveries)
|
|
275
|
+
if first.fetch(:state) == :recovery_pending
|
|
276
|
+
return first.merge(stores: stores, parent_execution_id: parent_id).freeze
|
|
277
|
+
end
|
|
278
|
+
raise "Expected the report child's approval wait" unless first.fetch(:state) == :child_approval_wait
|
|
279
|
+
request = Timeout.timeout(5) { approvals.pop }
|
|
280
|
+
child = Phronomy::Agent::Base.live_for_execution(request.execution_id)
|
|
281
|
+
child_result = child.approve_async(request.execution_id,
|
|
282
|
+
approval_request_id: request.id, approved: true).wait_result(timeout: 5)
|
|
283
|
+
resumed = parent.resume_async(parent_id)
|
|
284
|
+
last = await_parent(parent: parent, task: resumed,
|
|
285
|
+
retry_confirmed_pre: retry_confirmed_pre, recoveries: recoveries)
|
|
286
|
+
if last.fetch(:state) == :recovery_pending
|
|
287
|
+
return last.merge(stores: stores, child: child, parent_execution_id: parent_id).freeze
|
|
288
|
+
end
|
|
289
|
+
raise "Expected the completed report" unless last.fetch(:state) == :completed
|
|
290
|
+
parent_result = last.fetch(:result)
|
|
291
|
+
released = parent.unload_with_completed_child!(parent_id, execution_id: request.execution_id)
|
|
292
|
+
{
|
|
293
|
+
state: :observed, child_output: child_result.fetch(:output), parent_output: parent_result.fetch(:output),
|
|
294
|
+
tool_effects: G3gReviewTool.effects, provider_calls: adapter.calls, released: released,
|
|
295
|
+
statuses: [parent_id, request.execution_id].map { |id| stores.agent.executions.load(id).status },
|
|
296
|
+
history_holds: [parent.agent_id, child.agent_id].map { |id| stores.agent.retained_references(agent_id: id).size },
|
|
297
|
+
recoveries: recoveries
|
|
298
|
+
}
|
|
299
|
+
end
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
| Observable behavior | G3f baseline | G3g intentional change |
|
|
303
|
+
| --- | --- | --- |
|
|
304
|
+
| Ordinary successful report | Four Provider calls, one Tool effect, same child/parent outputs and completed statuses, pair release | Equivalent complete normal function and behavior |
|
|
305
|
+
| Parent captured prerequisite loses its response and immediate readback | Characterized cases leave the parent admitted and the observer times out without pending dispatch recovery | The original parent exposes its retained capability; read-only reconciliation or explicit captured-write retry can authorize the same continuation |
|
|
306
|
+
| Original failed observation | Ends without becoming a new successful observation | Remains closed; the returned execution task is a distinct observation of the same job |
|
|
307
|
+
| Unresolved native authority | No new acceptance claim | No new dispatch, replacement child or request; host retains the parent/capability |
|
|
308
|
+
| Approval and cleanup policy | Host decides approval and releases the exact completed pair | Preserved; recovery does not auto-approve or release unresolved work |
|
|
309
|
+
|
|
310
|
+
The application benefit is a supported public recovery branch with exact framework-owned proof and continuation custody. Phronomy removes the need for application code to interpret extension JSON, reconstruct reservations or devise persistence replay. Approval, observation timing, retry permission, unresolved-owner retention and final cleanup remain explicit application responsibilities.
|
|
311
|
+
|
|
312
|
+
For example, the report host can choose `retry_confirmed_pre: false`, retain the `recovery_pending` value, and later call the same helper after an operator decision. It must not rerun `run_report_with_recovery` for that unresolved request.
|
|
313
|
+
|
|
314
|
+
### Shared driver and fault fixture
|
|
315
|
+
|
|
316
|
+
The normal driver ends its Runtime only after the complete normal flow. The fault fixture is optional validation infrastructure that loses a selected parent dispatch save response and its immediate readback; it deliberately instruments internal boundaries and is separate from the public application source.
|
|
317
|
+
|
|
318
|
+
For example, `parent_reply_loss(kind: :tool, mode: :pre)` rolls back the parent Tool prerequisite, whereas `mode: :post` preserves its committed records. The same `run_report_with_recovery` function is exercised for Provider and Tool boundaries. A long-running host keeps an unresolved Runtime alive instead of copying the one-shot normal driver's `ensure` into a pending recovery path.
|
|
319
|
+
|
|
320
|
+
<!-- example: shared-driver -->
|
|
321
|
+
```ruby
|
|
322
|
+
# A long-running service retains recovery_pending and its Runtime for a later
|
|
323
|
+
# operator decision. This one-shot driver runs only the normal completed flow.
|
|
324
|
+
if $PROGRAM_NAME == __FILE__
|
|
325
|
+
begin
|
|
326
|
+
puts JSON.pretty_generate(run_report)
|
|
327
|
+
ensure
|
|
328
|
+
Phronomy.reset_runtime!
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
<details>
|
|
334
|
+
<summary>Complete optional response-loss fixture used by validation</summary>
|
|
335
|
+
|
|
336
|
+
<!-- example: fault-fixture -->
|
|
337
|
+
```ruby
|
|
338
|
+
# Optional response-loss fixture; the application below uses public APIs only.
|
|
339
|
+
module G3gChangeFaultScope
|
|
340
|
+
def perform
|
|
341
|
+
fault = coordinator.instance_variable_get(:@g3g_parent_fault)
|
|
342
|
+
previous = Thread.current[:g3g_parent_fault]
|
|
343
|
+
selected = fault && execution_id == fault.fetch(:execution_id) && kind == :dispatch &&
|
|
344
|
+
@updated&.phase == ((fault.fetch(:kind) == :tool) ? :dispatching_tools : :calling_llm)
|
|
345
|
+
Thread.current[:g3g_parent_fault] = selected ? fault : nil
|
|
346
|
+
super
|
|
347
|
+
ensure
|
|
348
|
+
Thread.current[:g3g_parent_fault] = previous
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
module G3gAtomicFault
|
|
353
|
+
def atomic(*args, &transaction)
|
|
354
|
+
fault = Thread.current[:g3g_parent_fault]
|
|
355
|
+
return super unless fault
|
|
356
|
+
if fault[:readback]
|
|
357
|
+
fault[:readback] = false
|
|
358
|
+
raise IOError, "Immediate parent readback unavailable"
|
|
359
|
+
end
|
|
360
|
+
return super unless fault[:armed]
|
|
361
|
+
fault[:armed] = false
|
|
362
|
+
fault[:attempts] += 1
|
|
363
|
+
if fault.fetch(:mode) == :pre
|
|
364
|
+
super do |scope|
|
|
365
|
+
transaction.call(scope)
|
|
366
|
+
fault[:readback] = true
|
|
367
|
+
raise IOError, "Parent dispatch transaction rolled back; response lost"
|
|
368
|
+
end
|
|
369
|
+
else
|
|
370
|
+
super
|
|
371
|
+
fault[:readback] = true
|
|
372
|
+
raise IOError, "Parent dispatch transaction committed; response lost"
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
Phronomy::Agent::ExecutionChange.prepend(G3gChangeFaultScope)
|
|
378
|
+
|
|
379
|
+
def parent_reply_loss(kind:, mode:)
|
|
380
|
+
raise ArgumentError, "Unsupported parent dispatch boundary" unless %i[provider tool].include?(kind)
|
|
381
|
+
raise ArgumentError, "Unsupported save outcome" unless %i[pre post].include?(mode)
|
|
382
|
+
lambda do |store, execution_id|
|
|
383
|
+
store.coordinator.singleton_class.prepend(G3gAtomicFault)
|
|
384
|
+
store.coordinator.instance_variable_set(:@g3g_parent_fault,
|
|
385
|
+
{kind: kind, mode: mode, execution_id: execution_id, armed: true, readback: false, attempts: 0})
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
</details>
|
|
391
|
+
|
|
392
|
+
The recorded normal baseline and candidate reports are identical. All four candidate Provider/Tool pre/post fault flows complete with four Provider calls, one Tool effect, closed original observations, both executions completed, successful pair release and retained history holds. Both explicit no-retry pre-state flows remain `confirmed_pre` with the original owner retained. The four baseline fault flows time out without a pending dispatch capability, and their incomplete process cleanup preserves the retained responsibility. The validation driver selects the baseline or candidate source, applies the fixture, runs the complete source and records loaded Ruby source locations and observed effects. The delivery includes those reports separately; the fixture's expected JSON or syntax check alone is not behavioral equivalence evidence.
|
|
393
|
+
|
|
394
|
+
For example, the baseline source must resolve into its isolated G3f checkout and the candidate source into the changed checkout. A successful candidate report is not evidence of baseline behavior unless both actual runs and their loaded-source provenance are recorded.
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
## Apply recovery policy to the original parent
|
|
398
|
+
|
|
399
|
+
The existing Agent dispatch APIs address the exact live owner and its captured operation. Every asynchronous observation is independent; a later receipt does not reopen the failed original invocation or hosted observation. Applications retain their parent and capability while unresolved, choose whether to retry captured persistence, and observe the returned execution task after continuation handoff.
|
|
400
|
+
|
|
401
|
+
For example, the report host receives a parent `DispatchRecoveryError`, reconciles once, and explicitly retries only a confirmed pre-state according to its own policy. A Tool continuation reaches the same child's approval boundary; a Provider continuation after child completion reaches the parent's final report. Neither path starts a replacement report request.
|
|
402
|
+
|
|
403
|
+
| Public surface | Native parent behavior |
|
|
404
|
+
| --- | --- |
|
|
405
|
+
| `pending_dispatch_recovery(execution_id:)` | Existing local lookup on the original parent; no Store access or replacement owner |
|
|
406
|
+
| `reconcile_dispatch[_async](recovery:)` | Read and classify captured parent evidence; freshly check native child authority before first continuation; no persistence retry |
|
|
407
|
+
| `retry_dispatch[_async](recovery:)` | Explicit captured-write retry only for exact pre-state with native authority; known post-state is read-only |
|
|
408
|
+
| `DispatchRecoveryResult` | Existing saved-outcome, application, continuation and physical-completion fields; a continuation error does not revoke known committed history |
|
|
409
|
+
| `execution_task` | Fresh observation of the same parent's continued execution after handoff; its later result/error is separate from save proof |
|
|
410
|
+
| Existing execution cancellation | Authoritative control of the execution; cancelling a recovery observation alone does not cancel the retained operation |
|
|
411
|
+
|
|
412
|
+
The ordinary invocation, streaming and hosted-entry contracts remain distinct. A closed stream subscriber is not resumed by dispatch recovery, and a recovered execution task does not invent a hosted handle or another approval observer. Existing application approval listeners remain the source of the child's public identity.
|
|
413
|
+
|
|
414
|
+
For example, a report child that requests approval after a recovered Tool prerequisite is identified by its actual approval event. The application must not extract an internal child slot or guess an execution ID from error prose. The complete application comparison demonstrates the public route used by this increment.
|
|
415
|
+
|
|
416
|
+
## Assess compatibility and symmetry
|
|
417
|
+
|
|
418
|
+
The native extension uses the same dispatch capability and receipt as ordinary and correlated-child dispatch recovery. Different domain facts justify different proof adapters, while observation, retry naming and physical-work accounting remain shared. Actual-terminal and approval operations retain their own continuation and release semantics.
|
|
419
|
+
|
|
420
|
+
For example, resolving a parent dispatch barrier allows the same parent job to continue; it does not release that active parent's execution admission. Reusing terminal release behavior at this point would discard the responsibility that the recovered Provider or Tool still needs.
|
|
421
|
+
|
|
422
|
+
| Dimension | Ordinary/participant-free child dispatch | Native parent dispatch | Terminal or approval peers |
|
|
423
|
+
| --- | --- | --- | --- |
|
|
424
|
+
| Names and arguments | Existing reconcile/retry methods with `recovery:` | Adopt the same methods and defaults | Preserve operation-specific names and policy; no universal Job API |
|
|
425
|
+
| Public values | Existing immutable capability and receipt | Adopt the same shape | Retain distinct result meanings and continuation/release rules |
|
|
426
|
+
| Saved proof | Complete Agent footprint, including opaque child correlation where present | Add native parent plan/evidence without teaching Agent the native schema | Keep each operation's domain write set |
|
|
427
|
+
| Current authority | Original owner/session and supported child checks | Add exact affected-child authority under ordered guards | Approval authorizes protected work; actual terminal establishes final custody/release |
|
|
428
|
+
| Sync/async and invoke/stream | Existing paired observation methods and closed-observer rules | Adopt the same rules | Preserve existing host-thread restrictions and observation independence |
|
|
429
|
+
| Creation and recovery | No replacement Agent or new invocation | No replacement parent or child reservation | No capability-based process takeover |
|
|
430
|
+
| Cleanup | Resolve barrier custody; continuing job remains owned | Same, with native history holds unchanged | Terminal may release only when its own conditions hold |
|
|
431
|
+
|
|
432
|
+
Decision: adopt the existing public dispatch API and shared retained-operation machinery; add a private native persistence/authority adapter; defer Handoff, generic custom participants and nonterminal/final-operation policy. Reject repeating `participant.commit`, constructing new child identities, using known post-state as unconditional permission to continue, or introducing a native-only convenience recovery facade.
|
|
433
|
+
|
|
434
|
+
For example, a convenience method that invoked the parent again after a timeout would appear to shorten application code while starting a different execution. The retained capability already expresses the required same-owner relationship without that behavioral change.
|
|
435
|
+
|
|
436
|
+
## Bound acceptance and remaining work
|
|
437
|
+
|
|
438
|
+
Acceptance distinguishes demonstrated baseline behavior, the candidate's new native dispatch behavior and remaining operation-specific work. The finite completion groups stay unchanged. A passing dispatch matrix does not certify native true-final, coordination-wait, Handoff, participant approval, crash recovery or every durable backend.
|
|
439
|
+
|
|
440
|
+
For example, four baseline native failed-child terminal cases already preserve acknowledgement atomicity: a pre-state can resume to failed without repeating the child effect, and a post-state is already failed. Two Handoff post-state probes also recover through exact Target continuation or result observation. Those existing paths should be preserved, not described as uniformly broken to justify dispatch changes.
|
|
441
|
+
|
|
442
|
+
| Acceptance boundary | Required observable result |
|
|
443
|
+
| --- | --- |
|
|
444
|
+
| Native Provider/Tool pre/post uncertainty | Recover the original parent through its existing public capability; preserve Provider/Tool effect counts and exact child identities |
|
|
445
|
+
| Unavailable or conflicting evidence | Retain responsibility and block continuation without a replacement request or arbitrary writes |
|
|
446
|
+
| Exact pre-state retry | Save only captured native content/hold/execution effects under ordered guards; do not repeat preparation, Policy or participant commit |
|
|
447
|
+
| Known-post reconciliation/retry | Preserve committed history; freshly check child authority; do not rewrite post-state or dispatch twice |
|
|
448
|
+
| Child authority changes | Reject active, suspended, replaced, partially absent or unheld histories according to the finite authority table |
|
|
449
|
+
| Observation and physical-work races | Keep old observations closed; prevent stale/duplicate application and release while physical work remains |
|
|
450
|
+
| Cancellation | Respect authoritative cancellation before external continuation; do not turn recovered permission into uncancelled work |
|
|
451
|
+
| Ordinary application and final lifetime | Preserve public report behavior, exact approval identity and existing pair-release/retained-history policy |
|
|
452
|
+
| Model and architecture | Check the finite safety/conditional-progress model and its mutations; preserve Contract ownership and dependency directions |
|
|
453
|
+
|
|
454
|
+
At the G3g boundary, native true-final and coordination-wait disposition required one coherent follow-up design around saved facts, public observation closure/publication and owner release. Native/Handoff own approval decisions and wait establishment were reachable separate writes. G3h addresses the supported native final/wait and own approval portion through its [outcome contract](native-parent-outcome-recovery.md). Handoff transfer still needs historical lineage and current-routing authority; generic custom participants still require explicit supported capability and unsupported disposition. These remain bounded checklist items within the existing completion groups.
|
|
455
|
+
|
|
456
|
+
For example, an active Handoff Agent can use an ordinary approval-requiring Tool. Its approval-decision fallback is not automatically protected by the dispatch plan or the synchronous participant readback. Leaving that row explicit prevents a narrower successful dispatch increment from becoming an unsupported whole-system coverage claim.
|
|
457
|
+
|
|
458
|
+
The finite [native parent dispatch model](../../spec/models/native_parent_dispatch_recovery/README.md) separates parent-owner, child-authority and client-observer state views and checks safety plus conditional progress. Its deliberate mutations and missing-premise cases must produce their specified counterexamples; those expected detections are not unresolved violations of the positive model. The delivery separately records exact source provenance, baseline characterization, Runtime faults, complete application reports and the English-file gate. Model checking is not a refinement proof of all Ruby behavior, and the in-memory fault fixture does not establish remote transaction settlement or external exactly-once effects.
|
|
459
|
+
|
|
460
|
+
For example, a model mutation that removes the current-child check must violate continuation safety. The Runtime acceptance must independently reproduce that changed child state and demonstrate that no protected Provider or Tool call was admitted.
|