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,247 @@
|
|
|
1
|
+
# Retain recovery responsibility across uncertain submission
|
|
2
|
+
|
|
3
|
+
Agent and Workflow must retain their original owner while a terminal save or recovery worker may still execute. A caller losing its submission response does not prove that the worker was rejected. G3b-4 applies the existing execution rejection evidence to Workflow initial saves and readback, and to Agent readback and captured-save retry.
|
|
4
|
+
|
|
5
|
+
For example, a custom execution adapter can enqueue a Workflow save and then lose the returned task handle. Releasing that Workflow would admit a replacement owner while the old save could still write. The corrected operation fails the caller observation with a recovery reference and retains the original responsibility.
|
|
6
|
+
|
|
7
|
+
## Distinguish mechanism facts from caller observations
|
|
8
|
+
|
|
9
|
+
The execution mechanism supplies admission and physical completion facts. The domain owner uses those facts to serialize its retained operation and to decide whether confirmed persistence can be applied. A closed caller observation does not release that obligation.
|
|
10
|
+
|
|
11
|
+
For example, a reconciliation read that is still queued may have no usable returned handle. Another explicit reconciliation request returns unavailable instead of starting a second read. A late value from the hidden worker does not establish physical completion of the executor task.
|
|
12
|
+
|
|
13
|
+
| Observed submission facts | Physical responsibility | Subsequent request |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| Positive synchronous rejection, no returned handle, no worker entry | No worker obligation for this submission | Domain policy may end this failed attempt; a later explicit attempt can be considered. |
|
|
16
|
+
| Returned task handle, including a queued task | Retain until physical completion is observed | Join the same compatible attempt or inspect the retained handle; do not resubmit. |
|
|
17
|
+
| Worker entered but handle was lost | Retain without physical completion proof | Return unavailable; do not infer completion from a mailbox value. |
|
|
18
|
+
| Exception without positive rejection or a handle | Admission and physical completion are unresolved | Retain the operation and refuse another physical attempt. |
|
|
19
|
+
|
|
20
|
+
A returned handle or observed worker entry overrides a contradictory rejection notification. A backend must truthfully honor its opted-in rejection contract. A false notification followed by hidden future execution cannot be made safe by checking the current state of an unstarted block.
|
|
21
|
+
|
|
22
|
+
Agent's public `submission_state` continues to describe its terminal-work submission. It does not change when a later readback or captured-save retry is accepted or refused. Workflow does not acquire that public field or a new retry API.
|
|
23
|
+
|
|
24
|
+
## Preserve the domain-specific outcomes
|
|
25
|
+
|
|
26
|
+
The shared execution capability reports only whether work was refused. Agent and Workflow retain their different persistence, live-state and release policies. This change does not move their domain state into the execution pool.
|
|
27
|
+
|
|
28
|
+
For example, a positively rejected initial Workflow terminal save preserves its ordinary known-failure cleanup, whereas an Agent whose job has already completed its provider work retains that job for its existing explicit terminal-submission retry.
|
|
29
|
+
|
|
30
|
+
| Path | Positive refusal | Unknown admission |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| Workflow initial terminal save | Original submission failure and ordinary known-failure cleanup | Typed terminal recovery failure; original owner and immutable save command retained. |
|
|
33
|
+
| Workflow reconciliation read | End this observation as unavailable; later explicit observation may submit again | Keep the current attempt; no second read or owner release. |
|
|
34
|
+
| Agent reconciliation read | End this observation as unavailable; later explicit observation may submit again | Keep the current attempt and original Agent owner. |
|
|
35
|
+
| Agent captured-save retry | End this observation as unavailable; later explicit retry may submit again | Keep the current attempt; no additional write or parser/encoder replay. |
|
|
36
|
+
| Agent initial save / first-submission recovery | Existing G3b-3 policy | Existing G3b-3 policy. |
|
|
37
|
+
|
|
38
|
+
Observer cancellation, timeout or failed callback registration does not invent rejection evidence. A returned task remains retained. Where its snapshot or completion callbacks can still establish physical completion, a fresh observation may finish the same attempt. Lost handles remain unavailable even after a worker publishes a value.
|
|
39
|
+
|
|
40
|
+
## Keep ordinary application source unchanged
|
|
41
|
+
|
|
42
|
+
The public operations and their arguments do not change. Applications still choose when to observe or explicitly retry, inspect the saved job status, and retain unresolved recovery references. The safety benefit is internal serialization and ownership retention rather than shorter application code.
|
|
43
|
+
|
|
44
|
+
For example, the same application can run an Agent analysis and a Workflow task before and after this change. Both normal runs produce the same normalized result and call counts. Failure behavior is intentionally different when a submission exception supplies no non-admission evidence.
|
|
45
|
+
|
|
46
|
+
<table class="source-comparison"><thead><tr><th>G3b-3</th><th>G3b-4</th></tr></thead><tbody><tr><td><pre><code>def run_report_application
|
|
47
|
+
adapter = G3b4ReportAdapter.new
|
|
48
|
+
Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
|
|
49
|
+
stores = Phronomy::PersistenceComposition.in_memory
|
|
50
|
+
agent = G3b4ReportAgent.create(agent_id: "g3b4-report", persistence: stores.agent)
|
|
51
|
+
answer_task = agent.invoke_async("Prepare the report", output_schema: {
|
|
52
|
+
type: "object", properties: {answer: {type: "string"}},
|
|
53
|
+
required: ["answer"], additionalProperties: false
|
|
54
|
+
})
|
|
55
|
+
answer = answer_task.wait_result(timeout: 5)
|
|
56
|
+
resumed = agent.resume(answer.fetch(:execution_id))
|
|
57
|
+
|
|
58
|
+
actions = {start: 0, apply: 0}
|
|
59
|
+
workflow = Phronomy::Workflow.define(G3b4ReportContext, persistence: stores.workflow) do
|
|
60
|
+
initial :formatting
|
|
61
|
+
task_state :formatting,
|
|
62
|
+
start: ->(context) {
|
|
63
|
+
actions[:start] += 1
|
|
64
|
+
Phronomy::TaskResult.completed(context.answer.upcase)
|
|
65
|
+
},
|
|
66
|
+
apply: ->(context, text) {
|
|
67
|
+
actions[:apply] += 1
|
|
68
|
+
context.merge(published_text: text)
|
|
69
|
+
}
|
|
70
|
+
transition from: :formatting, to: :__finish__
|
|
71
|
+
end
|
|
72
|
+
workflow_id = "g3b4-report-publication"
|
|
73
|
+
publication_task = workflow.invoke_async({answer: answer.fetch(:output).fetch("answer")},
|
|
74
|
+
config: {workflow_instance_id: workflow_id})
|
|
75
|
+
publication = publication_task.wait_result(timeout: 5)
|
|
76
|
+
|
|
77
|
+
{
|
|
78
|
+
agent: agent, agent_task: answer_task, answer: answer, resumed: resumed,
|
|
79
|
+
workflow: workflow, workflow_id: workflow_id, workflow_task: publication_task,
|
|
80
|
+
publication: publication, stores: stores, adapter: adapter, actions: actions
|
|
81
|
+
}
|
|
82
|
+
end</code></pre></td><td><pre><code>def run_report_application
|
|
83
|
+
adapter = G3b4ReportAdapter.new
|
|
84
|
+
Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
|
|
85
|
+
stores = Phronomy::PersistenceComposition.in_memory
|
|
86
|
+
agent = G3b4ReportAgent.create(agent_id: "g3b4-report", persistence: stores.agent)
|
|
87
|
+
answer_task = agent.invoke_async("Prepare the report", output_schema: {
|
|
88
|
+
type: "object", properties: {answer: {type: "string"}},
|
|
89
|
+
required: ["answer"], additionalProperties: false
|
|
90
|
+
})
|
|
91
|
+
answer = answer_task.wait_result(timeout: 5)
|
|
92
|
+
resumed = agent.resume(answer.fetch(:execution_id))
|
|
93
|
+
|
|
94
|
+
actions = {start: 0, apply: 0}
|
|
95
|
+
workflow = Phronomy::Workflow.define(G3b4ReportContext, persistence: stores.workflow) do
|
|
96
|
+
initial :formatting
|
|
97
|
+
task_state :formatting,
|
|
98
|
+
start: ->(context) {
|
|
99
|
+
actions[:start] += 1
|
|
100
|
+
Phronomy::TaskResult.completed(context.answer.upcase)
|
|
101
|
+
},
|
|
102
|
+
apply: ->(context, text) {
|
|
103
|
+
actions[:apply] += 1
|
|
104
|
+
context.merge(published_text: text)
|
|
105
|
+
}
|
|
106
|
+
transition from: :formatting, to: :__finish__
|
|
107
|
+
end
|
|
108
|
+
workflow_id = "g3b4-report-publication"
|
|
109
|
+
publication_task = workflow.invoke_async({answer: answer.fetch(:output).fetch("answer")},
|
|
110
|
+
config: {workflow_instance_id: workflow_id})
|
|
111
|
+
publication = publication_task.wait_result(timeout: 5)
|
|
112
|
+
|
|
113
|
+
{
|
|
114
|
+
agent: agent, agent_task: answer_task, answer: answer, resumed: resumed,
|
|
115
|
+
workflow: workflow, workflow_id: workflow_id, workflow_task: publication_task,
|
|
116
|
+
publication: publication, stores: stores, adapter: adapter, actions: actions
|
|
117
|
+
}
|
|
118
|
+
end</code></pre></td></tr></tbody></table>
|
|
119
|
+
|
|
120
|
+
The shared setup precedes the complete function above; the measurement and execution block follows it. Together these three units are the complete executable normal_application.rb. Run it from a checkout with dependencies installed and set both report paths. The deterministic adapter performs no network requests.
|
|
121
|
+
|
|
122
|
+
```ruby
|
|
123
|
+
# frozen_string_literal: true
|
|
124
|
+
|
|
125
|
+
# A deterministic report application. The fixture adapter performs no network
|
|
126
|
+
# request; the Agent and Workflow use the real Runtime and persistence stores.
|
|
127
|
+
require "phronomy"
|
|
128
|
+
require "json"
|
|
129
|
+
|
|
130
|
+
class G3b4ReportAdapter < Phronomy::LLMAdapter::Base
|
|
131
|
+
attr_reader :requests
|
|
132
|
+
|
|
133
|
+
def initialize
|
|
134
|
+
@requests = 0
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def perform_complete(_request, cancellation_token:)
|
|
138
|
+
cancellation_token&.raise_if_cancelled!
|
|
139
|
+
@requests += 1
|
|
140
|
+
Phronomy::LLMAdapter::Response.new(
|
|
141
|
+
content: '{"answer":"report ready"}', finish_reason: :stop,
|
|
142
|
+
usage: Phronomy::LLMAdapter::TokenUsage.new(input: 4, output: 2)
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
class G3b4ReportAgent < Phronomy::Agent::Base
|
|
148
|
+
agent_definition id: "g3b4-report-agent", version: 1
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
class G3b4ReportContext
|
|
152
|
+
include Phronomy::WorkflowContext
|
|
153
|
+
|
|
154
|
+
field :answer, default: ""
|
|
155
|
+
field :published_text, default: ""
|
|
156
|
+
end
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```ruby
|
|
160
|
+
# Measurement is separate from the application operation. Repository reads here
|
|
161
|
+
# are evidence of persisted results; the application does not repair ownership.
|
|
162
|
+
def measure_report_application(run)
|
|
163
|
+
answer = run.fetch(:answer)
|
|
164
|
+
execution = run.fetch(:stores).agent.executions.load(answer.fetch(:execution_id))
|
|
165
|
+
saved = run.fetch(:stores).workflow.load(run.fetch(:workflow_id))
|
|
166
|
+
{
|
|
167
|
+
agent: {
|
|
168
|
+
output: answer.fetch(:output), resumed_output: run.fetch(:resumed).fetch(:output),
|
|
169
|
+
raw_output: answer.fetch(:raw_output), usage: answer.fetch(:usage).to_h,
|
|
170
|
+
durable_status: execution.status, durable_phase: execution.phase,
|
|
171
|
+
durable_revision: execution.execution_revision,
|
|
172
|
+
stored_result: run.fetch(:stores).agent.contents.fetch_text(execution.result_ref),
|
|
173
|
+
root_status: run.fetch(:agent).agent_root.lifecycle_status,
|
|
174
|
+
logical_complete: run.fetch(:agent_task).done?,
|
|
175
|
+
physical_complete: run.fetch(:agent_task).physical_complete?,
|
|
176
|
+
provider_calls: run.fetch(:adapter).requests
|
|
177
|
+
},
|
|
178
|
+
workflow: {
|
|
179
|
+
answer: run.fetch(:publication).answer,
|
|
180
|
+
published_text: run.fetch(:publication).published_text,
|
|
181
|
+
revision: saved.fetch(:revision), snapshot: saved.fetch(:snapshot),
|
|
182
|
+
logical_complete: run.fetch(:workflow_task).done?,
|
|
183
|
+
physical_observation_available: run.fetch(:workflow_task).respond_to?(:physical_complete?),
|
|
184
|
+
actions: run.fetch(:actions),
|
|
185
|
+
pending_recovery: !run.fetch(:workflow).pending_terminal_recovery(
|
|
186
|
+
workflow_instance_id: run.fetch(:workflow_id)
|
|
187
|
+
).nil?
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
if $PROGRAM_NAME == __FILE__
|
|
193
|
+
begin
|
|
194
|
+
run = run_report_application
|
|
195
|
+
report = measure_report_application(run)
|
|
196
|
+
raise "Unexpected Agent output" unless report[:agent][:output] == {"answer" => "report ready"}
|
|
197
|
+
raise "Unexpected Workflow output" unless report[:workflow][:published_text] == "REPORT READY"
|
|
198
|
+
raise "The provider was replayed" unless report[:agent][:provider_calls] == 1
|
|
199
|
+
raise "The Workflow action was replayed" unless report[:workflow][:actions] == {start: 1, apply: 1}
|
|
200
|
+
File.write(ENV.fetch("G3B4_APPLICATION_REPORT"), JSON.pretty_generate(report) + "\n")
|
|
201
|
+
loaded_source = {
|
|
202
|
+
application: method(:run_report_application).source_location,
|
|
203
|
+
agent_operation: Phronomy::Agent::TerminalRecoveryOperation.instance_method(:start).source_location,
|
|
204
|
+
workflow_operation: Phronomy::WorkflowTerminalOperation.instance_method(:start).source_location,
|
|
205
|
+
gem: Gem.loaded_specs.fetch("phronomy").full_gem_path
|
|
206
|
+
}
|
|
207
|
+
File.write(ENV.fetch("G3B4_APPLICATION_SOURCE_REPORT"), JSON.pretty_generate(loaded_source) + "\n")
|
|
208
|
+
ensure
|
|
209
|
+
Phronomy.reset_runtime!
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
G3B4_APPLICATION_REPORT=/absolute/path/to/report.json \
|
|
216
|
+
G3B4_APPLICATION_SOURCE_REPORT=/absolute/path/to/source.json \
|
|
217
|
+
bundle exec ruby /absolute/path/to/normal_application.rb
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
The comparison claims equivalence only for the described normal inputs, outputs, ordering, persistence and cleanup. It does not claim equivalence for lost-response faults. Those faults are covered separately by real Runtime tests with blocked workers and counted storage/provider/Tool calls.
|
|
222
|
+
|
|
223
|
+
## Preserve supported submission contracts
|
|
224
|
+
|
|
225
|
+
The built-in pool synchronously reports definite queue rejection through the existing optional capability. A legacy custom submitter receives its original keyword set and is called once. A submitter that cannot prove non-admission can still run ordinary work, but its ambiguous exception no longer permits Workflow release or forgetting a recovery attempt.
|
|
226
|
+
|
|
227
|
+
For example, the acceptance fixture wraps a real submitter, lets it accept work, then raises instead of returning its handle. This deliberately injects a failure beyond the built-in pool's normal return contract. It proves the owner safety behavior under that fault; it is not evidence that the built-in pool normally loses handles.
|
|
228
|
+
|
|
229
|
+
The inherited capability declaration is not a substitute for truthfulness. Custom wrappers that change submission semantics must preserve the synchronous rejection guarantee or opt out. No retry-on-ArgumentError is used to discover supported keywords.
|
|
230
|
+
|
|
231
|
+
## Reuse the mechanism without merging domain owners
|
|
232
|
+
|
|
233
|
+
Execution owns the optional rejection dispatcher and pool evidence. Agent and Workflow own their terminal commands, result interpretation, exact owner checks and release rules. As of 2026-11-28, initial/recovery slots, admission facts and observation membership are managed by C13 `RetainedAttempts`; `AttemptCompletion` retains completion evidence. The domain owners use explicit commands and frozen snapshots without selecting a universal lifecycle policy.
|
|
234
|
+
|
|
235
|
+
For example, Workflow confirmed pre-state can permit release after retirement and application, while an Agent with an accepted job must retain responsibility for its explicit saved-byte retry. A shared manager that chose either policy would cross the domain boundary; a manager parameterized with every policy would still require the same decisions in both domains.
|
|
236
|
+
|
|
237
|
+
The common specification is the admission/observation/physical-completion protocol. Its neutral capability remains shared. The four-owner implementation and its lock rationale are documented in [shared retained-attempt management](retained-attempts.md). That extraction preserves the separate domain lifecycles; similar method names alone do not justify moving their business decisions. Both canonical Contract SVGs and the source dependency graph are checked in the delivery evidence.
|
|
238
|
+
|
|
239
|
+
## Validate safety and bounded progress
|
|
240
|
+
|
|
241
|
+
Runtime tests and a finite state model distinguish actual queued/running work, the owner's knowledge, independent caller closure and physical completion. Progress is promised only with the explicit executor, owner and caller premises needed to observe completion; unknown lost handles have no automatic recovery promise.
|
|
242
|
+
|
|
243
|
+
For example, a model mutation that treats an absent handle as rejection must produce a counterexample in which another attempt is admitted while the old worker remains possible. Separate mutations treat mailbox publication as physical completion or discard an unknown attempt. Their expected violations check that the positive invariants are meaningful.
|
|
244
|
+
|
|
245
|
+
The model and reproduction instructions are under `spec/models/recovery_submission_custody/`. The delivery includes actual baseline defect probes, repaired acceptance results, ordinary application comparison, full local checks and the previous G3b-3 application/CI review. Focused counts overlap the full suites and must not be added to their totals.
|
|
246
|
+
|
|
247
|
+
The original G3b-4 unit did not implement approval-resume or dispatch recovery. Their later contracts are documented in [approval recovery](agent-approval-recovery.md) and [dispatch recovery](agent-dispatch-recovery.md); both now use the shared attempt manager. Replacement-Runtime takeover and process-crash recovery remain outside this contract. Worker completion still does not prove remote transaction settlement; existing authoritative persistence ordering premises apply.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Shared retained-attempt management
|
|
2
|
+
|
|
3
|
+
Agent and Workflow share the management of asynchronous attempts and their
|
|
4
|
+
observations. Their domain owners still authorize work, classify persistence,
|
|
5
|
+
apply live state and decide when responsibility can end. The shared execution
|
|
6
|
+
framework maintains facts that those owners need without selecting their policy.
|
|
7
|
+
|
|
8
|
+
For example, a report's save response can be lost while its worker continues.
|
|
9
|
+
Ending the first caller's observation must not allow a second save or release the
|
|
10
|
+
job. Agent and Workflow can use the same attempt and observation machinery even
|
|
11
|
+
though Agent retains an accepted job after confirmed noncommit, while Workflow
|
|
12
|
+
may end its execution segment with a known save failure.
|
|
13
|
+
|
|
14
|
+
The implementation baseline is `2d470b6065515f948de8f17f21f810606967bbf6`.
|
|
15
|
+
The architecture references are Contract concept v55 and foundation v48, both
|
|
16
|
+
reviewed against `9a4cc09c6e1fed2546c142b7a19b94158f71577c`. Those diagrams are
|
|
17
|
+
responsibility references, not measurements of this later source. This document
|
|
18
|
+
records the shared implementation introduced on 2026-11-28; delivery evidence
|
|
19
|
+
identifies the exact tested source and actual validation results.
|
|
20
|
+
|
|
21
|
+
## Responsibilities and actual consumers
|
|
22
|
+
|
|
23
|
+
The execution framework manages one retained operation's initial attempt, one
|
|
24
|
+
recovery lane and independent observers. Each completion record describes one
|
|
25
|
+
attempt's worker result and logical and physical observations. The domain owner
|
|
26
|
+
combines those facts with its own authority and state.
|
|
27
|
+
|
|
28
|
+
For example, approval recovery may restore the same approval wait, while dispatch
|
|
29
|
+
recovery may authorize one continuation of a captured invocation. Neither action
|
|
30
|
+
is performed by the common attempt manager, even when both reuse its refusal,
|
|
31
|
+
worker-result and observer bookkeeping.
|
|
32
|
+
|
|
33
|
+
| Responsibility | Implementation owner |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| Initial attempt, reserved recovery lane, identity, admission facts and observer membership | C13 `RetainedAttempts` |
|
|
36
|
+
| Task handle, worker result, logical and physical evidence, notification binding and refresh | C13 `AttemptCompletion` |
|
|
37
|
+
| Terminal or saved-wait proof, retry permission, live application and accepted-job release | C04 `Agent::OutcomeRecoveryOperation` and its terminal specialization |
|
|
38
|
+
| Approval proof, original wait restoration and continuation transfer | C04 `Agent::ApprovalRecoveryOperation` |
|
|
39
|
+
| Dispatch preparation proof, cancellation and once-only continuation permission | C04 `Agent::DispatchRecoveryOperation` |
|
|
40
|
+
| Terminal save classification, context reconstruction and execution-segment release | C02 `WorkflowTerminalOperation` |
|
|
41
|
+
| Scheduling, worker threads and serial owner delivery | The existing injected execution environment and Engine binding |
|
|
42
|
+
|
|
43
|
+
`RetainedAttempts` and `AttemptCompletion` live directly in `execution/`, whose
|
|
44
|
+
directory is collapsed by the existing loader. Their Ruby constants are
|
|
45
|
+
`Phronomy::RetainedAttempts` and `Phronomy::AttemptCompletion`. Both are private
|
|
46
|
+
framework implementation. The old `Agent::PhysicalAttempt` class and source path
|
|
47
|
+
are removed; no alias points the common layer back into Agent. Public recovery
|
|
48
|
+
operations, receipt types and application responsibilities do not change.
|
|
49
|
+
|
|
50
|
+
Team cancellation continues to retain intent and wake its synchronous host. It
|
|
51
|
+
does not acquire an asynchronous worker merely to consume this component.
|
|
52
|
+
Native-parent and Handoff connections continue to supply their own exact
|
|
53
|
+
authority, routing and persistence proof to the existing Agent owners. Sharing
|
|
54
|
+
attempt management does not establish missing adapter applicability.
|
|
55
|
+
|
|
56
|
+
The later [synchronous participant custody contract](synchronous-participant-contract.md)
|
|
57
|
+
connects more dispatch and outcome phases to those same Agent owners, including
|
|
58
|
+
ordinary participants without private replay proof. The common classes and their
|
|
59
|
+
mutex construction sites do not change, but additional owner instances allocate
|
|
60
|
+
their existing mutexes. That cost is distinct from this extraction's code reduction.
|
|
61
|
+
|
|
62
|
+
## Management commands and evidence views
|
|
63
|
+
|
|
64
|
+
The common manager exposes explicit operations on the recovery lane and returns
|
|
65
|
+
read-only views of facts. Owners cannot obtain its mutable slot, completion
|
|
66
|
+
record or observer collection through a snapshot. Opaque result and error
|
|
67
|
+
payloads retain their existing domain ownership.
|
|
68
|
+
|
|
69
|
+
For example, an owner first checks whether a persistence retry is allowed, then
|
|
70
|
+
reserves the lane for that exact attempt. Later it may retire the lane after its
|
|
71
|
+
own completion decision. Retirement removes the lane's bookkeeping; it does not
|
|
72
|
+
cancel a worker, settle a TaskResult or release the Agent job.
|
|
73
|
+
|
|
74
|
+
| Internal operation | Meaning |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| `reserve_locked` | Install one explicit recovery identity and its first observer after owner authorization; do not submit work. |
|
|
77
|
+
| `join_locked` | Add an observer to the identified attempt; the owner checks compatible operation kind and observability. |
|
|
78
|
+
| `snapshot_locked`, `active_snapshot_locked` | Return frozen fact views without completion records or mutable observer arrays. |
|
|
79
|
+
| `worker_started_locked`, `submission_rejected_locked`, `task_returned_locked` | Record distinct evidence about an identified submission. |
|
|
80
|
+
| `record_worker_locked`, `submission_failed_locked` | Publish worker facts or the owner's supported refusal/uncertainty conclusion. |
|
|
81
|
+
| `take_observers_locked`, `retire_locked`, `retire` | Transfer the relevant observers for owner notification and remove the exact lane when the owner permits it. |
|
|
82
|
+
| `release_task_locked`, `release_references_locked` | Preserve the owner's existing distinction between dropping only the handle and clearing heavier completion references. |
|
|
83
|
+
|
|
84
|
+
The methods ending in `_locked` require the existing owner mutex; they do not
|
|
85
|
+
acquire it again. This permits a domain guard and its corresponding attempt
|
|
86
|
+
change to remain one atomic decision. Other methods acquire that mutex only for
|
|
87
|
+
their documented shared-state access. There is no second mutable ledger, new
|
|
88
|
+
lock, executor or thread inside either shared class.
|
|
89
|
+
|
|
90
|
+
## Why these state accesses need synchronization
|
|
91
|
+
|
|
92
|
+
Owner delivery is serial, but worker facts and observer changes also originate
|
|
93
|
+
outside that owner thread. Synchronization protects those actual shared facts
|
|
94
|
+
and the compound decisions that consume them. An inherited lock or a lower count
|
|
95
|
+
of lock statements does not establish necessity or minimality.
|
|
96
|
+
|
|
97
|
+
For example, a worker can publish its successful result while another thread
|
|
98
|
+
settles its logical observation as cancelled. Updating the result together with
|
|
99
|
+
the worker-recorded marker prevents the later logical snapshot from replacing
|
|
100
|
+
that success with the cancellation. A separate owner decision may simultaneously
|
|
101
|
+
need the physical-completion fact and the current custody state.
|
|
102
|
+
|
|
103
|
+
| Protected state or operation | Actual readers and writers | Required atomic relationship |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| Worker result, error and recorded marker | Worker publication; Task completion callbacks; owner snapshots | Record the tuple together; observation fallback must test the latest marker before replacing values. |
|
|
106
|
+
| Physical/logical completion and watch error | Completion callbacks; polling owner; release/resolution decisions | Keep physical evidence monotonic and snapshots coherent; combine completion with domain guards under the same mutex. |
|
|
107
|
+
| Started, returned handle, positive rejection and admission uncertainty | Worker entry; submitter rejection callback; submission caller; owner | Classify refusal from the same attempt's evidence without confusing a missing handle with non-admission. |
|
|
108
|
+
| Active identity and observer membership | Owner reserve/join/retire; caller registration; completion-driven observer removal; shutdown reporting | Keep membership changes and exact-attempt removal consistent; closing one observer must not discard physical custody. |
|
|
109
|
+
| Domain state combined with completion | Serial owner writes; caller-side receipt reads; worker/callback fact publication | Keep each owner's application, continuation and release preconditions consistent with the shared facts it observes. |
|
|
110
|
+
| Original worker diagnostic | Worker publication and receipt construction | Preserve the original diagnostic with its worker fact; the internal hook performs only bounded bookkeeping. |
|
|
111
|
+
|
|
112
|
+
The concrete concurrency routes are visible in `engine/concurrency/offload_pool.rb`
|
|
113
|
+
(worker threads), `execution/task_result.rb` (callbacks on the settling or
|
|
114
|
+
registering thread), and `execution/concurrency/physical_completion_task.rb`
|
|
115
|
+
(physical callbacks). The public recovery APIs call `observe` before posting
|
|
116
|
+
owner work. Agent and Workflow registries assert serial EventLoop delivery for
|
|
117
|
+
the subsequent domain decisions; they do not serialize every earlier observer
|
|
118
|
+
or worker callback.
|
|
119
|
+
|
|
120
|
+
The manager receives the operation's existing mutex and passes the same object
|
|
121
|
+
to its completion records. That choice preserves compound owner/fact decisions
|
|
122
|
+
without introducing a new lock order. Immutable attempt identities and kinds do
|
|
123
|
+
not need independent locks. This responsibility analysis does not certify every
|
|
124
|
+
unrelated synchronization site in the surrounding owners as minimal.
|
|
125
|
+
|
|
126
|
+
## Submission, notification and refresh boundaries
|
|
127
|
+
|
|
128
|
+
The shared protocol separates protected fact changes from calls that can execute
|
|
129
|
+
callbacks or access external task state. Submission attaches its returned handle
|
|
130
|
+
once; notification binding uses that retained handle. Refresh captures the exact
|
|
131
|
+
completion record and handle together before consulting the task.
|
|
132
|
+
|
|
133
|
+
For example, registering on an already completed task can invoke its callback
|
|
134
|
+
before registration returns. The callback can safely publish facts and notify
|
|
135
|
+
an owner because registration is outside the owner mutex. If a task snapshot is
|
|
136
|
+
read while a worker records success, the later merge honors the newer worker
|
|
137
|
+
record instead of overwriting it with the older logical observation.
|
|
138
|
+
|
|
139
|
+
1. The owner authorizes and reserves work under its mutex. Submission and the
|
|
140
|
+
worker body run outside it. Entry, rejection, returned handle and worker facts
|
|
141
|
+
are recorded through the shared mutation commands.
|
|
142
|
+
2. `RetainedAttempts#watch` captures the completion record and retained handle
|
|
143
|
+
under one lock. `AttemptCompletion#watch` binds callbacks without reattaching
|
|
144
|
+
the handle. Task calls and owner notifications remain outside the mutex.
|
|
145
|
+
3. `RetainedAttempts#refresh` captures the record and handle under one lock.
|
|
146
|
+
`AttemptCompletion#refresh` reads the task outside the lock, then merges the
|
|
147
|
+
observation with current completion facts under the same owner mutex only if
|
|
148
|
+
that handle is still retained. A release during polling prevents the old poll
|
|
149
|
+
from repopulating cleared result/error references.
|
|
150
|
+
4. Callback-registration failure retains the handle and registration error.
|
|
151
|
+
A callback already installed before an exception remains valid. A callback
|
|
152
|
+
retaining an old completion record cannot publish into a replacement attempt;
|
|
153
|
+
owner delivery still uses the original attempt identity.
|
|
154
|
+
|
|
155
|
+
The former preparation-time reattachment in `PhysicalAttempt#watch` and the
|
|
156
|
+
separate slot/handle capture locks in refresh are removed from this protocol.
|
|
157
|
+
This is a simplification of the protection boundary, not a runtime performance
|
|
158
|
+
claim. Task reads must not be moved inside the owner mutex to merge critical
|
|
159
|
+
sections: task methods can acquire their own locks or trigger immediate callbacks.
|
|
160
|
+
|
|
161
|
+
The optional worker-recorded hook preserves the Approval and Dispatch owners'
|
|
162
|
+
original error bookkeeping inside the existing atomic update. Its current
|
|
163
|
+
implementation is a conditional assignment. It must not perform I/O, call tasks,
|
|
164
|
+
submit work, acquire the owner mutex again or make domain transitions.
|
|
165
|
+
|
|
166
|
+
## Implementation and model correspondence
|
|
167
|
+
|
|
168
|
+
The finite models describe owner, worker and observer transitions independently
|
|
169
|
+
of the Ruby object layout. The shared classes implement common facts; the domain
|
|
170
|
+
owners retain the model actions that interpret proof, apply state and continue
|
|
171
|
+
or release work. A model run does not establish a Ruby refinement proof.
|
|
172
|
+
|
|
173
|
+
For example, a model can forbid releasing custody before physical completion.
|
|
174
|
+
Ruby tests must still force a logical callback and a worker publication to race,
|
|
175
|
+
or make callback registration fail after installation, to establish how the
|
|
176
|
+
implementation preserves the modeled facts.
|
|
177
|
+
|
|
178
|
+
| Existing model family | Settings | Current implementation correspondence |
|
|
179
|
+
| --- | ---: | --- |
|
|
180
|
+
| [Workflow terminal reconciliation](../../spec/models/workflow_terminal_reconciliation/README.md) | 44 | Request/read identity and worker observations use `RetainedAttempts`/`AttemptCompletion`; custody acceptance, classification, application and segment release stay in Workflow. |
|
|
181
|
+
| [Agent terminal recovery](../../spec/models/agent_terminal_recovery/README.md) | 27 | One recovery lane and `CaptureWorker` facts use the shared classes; `ApplyPost` and `ReleasePost` remain with the Agent coordinator/registry. |
|
|
182
|
+
| [Agent terminal submission](../../spec/models/agent_terminal_submission/README.md) | 28 | Common attempt facts support the original owner's separate submission knowledge; accepted first-work authority and retry mode remain Agent decisions. |
|
|
183
|
+
| [Approval decision recovery](../../spec/models/approval_decision_recovery/README.md) | 29 | Save/read facts and independent receipt observers use the common manager; wait restoration, partial continuation and handoff remain Approval decisions. |
|
|
184
|
+
| [Dispatch preparation recovery](../../spec/models/dispatch_preparation_recovery/README.md) | 59 | Save/recovery worker facts and observers use the common manager; exact proposal, cancellation and once-only dispatch continuation remain Dispatch decisions. |
|
|
185
|
+
| [Recovery submission custody](../../spec/models/recovery_submission_custody/README.md) | 14 | `Enter`/`Record`, `ReturnHandle`/`ObservePhysical` and exact-lane retention map to the shared protocol; domain `Apply`/`Release` stay outside it. |
|
|
186
|
+
|
|
187
|
+
These 201 configurations include positive properties, intentionally defective
|
|
188
|
+
variants, witnesses and missing-premise checks. Success means each expected
|
|
189
|
+
outcome is matched, including the named counterexamples. Existing model inputs
|
|
190
|
+
remain unchanged by the object-layout and lock-boundary cleanup. Delivery
|
|
191
|
+
evidence records any fresh execution and exact hashes separately.
|
|
192
|
+
|
|
193
|
+
The released-handle guard tightens internal reference cleanup when a poll is
|
|
194
|
+
already in flight. It does not introduce a new domain state or change the
|
|
195
|
+
modeled release authority; its concrete interleaving is covered in Ruby tests.
|
|
196
|
+
|
|
197
|
+
The models do not enumerate mutex acquisition, Ruby callback registration order,
|
|
198
|
+
partial registration or payload aliasing. Deterministic implementation tests
|
|
199
|
+
cover inline callbacks, worker-result precedence, monotonic physical evidence,
|
|
200
|
+
old-attempt isolation, observer cancellation, partial notification installation,
|
|
201
|
+
returned/unknown/refused submission and reference release. A future change to
|
|
202
|
+
admission, application or release linearization must revisit the affected model
|
|
203
|
+
transition and its progress premises before relying on the old results.
|
|
204
|
+
|
|
205
|
+
## Compatibility and architecture acceptance
|
|
206
|
+
|
|
207
|
+
The common implementation follows existing Agent-to-Execution and
|
|
208
|
+
Workflow-to-Execution dependencies. Domain authority remains with the consumer;
|
|
209
|
+
the common code receives an execution connection instead of selecting Runtime,
|
|
210
|
+
Store or an Engine implementation. Applications retain the existing public APIs.
|
|
211
|
+
|
|
212
|
+
For example, the complete application functions in
|
|
213
|
+
[Agent terminal recovery](agent-terminal-recovery.md) and
|
|
214
|
+
[Workflow terminal reconciliation](workflow-terminal-reconciliation.md) require
|
|
215
|
+
no new manager object or callback. Their recovery policies remain explicit; the
|
|
216
|
+
maintenance benefit is one implementation of attempt and observation rules
|
|
217
|
+
inside the framework.
|
|
218
|
+
|
|
219
|
+
Acceptance uses actual source/RBS dependency extraction, boundary checks, source
|
|
220
|
+
cycle differences, loader/API checks and real owner/Runtime tests. Existing
|
|
221
|
+
conceptual arrows do not prove a new candidate passes those checks. Contract
|
|
222
|
+
diagram labels or metadata must be reviewed if adopted responsibilities change;
|
|
223
|
+
private class movement alone is not a reason to claim a new architectural layer.
|
|
224
|
+
|
|
225
|
+
The shared protocol replaces duplicated bookkeeping in four actual owners. It
|
|
226
|
+
does not unify their business state machines, create a public Job API, establish
|
|
227
|
+
arbitrary backend settlement, complete Handoff applicability or implement
|
|
228
|
+
post-stop takeover. The original Agent-only extraction and its measured cost
|
|
229
|
+
remain documented as history in [recovery physical facts](recovery-physical-attempt.md).
|