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
|
@@ -11,3 +11,27 @@ See [r8 unit 7](r8-unit7.md) and [ADR-067](../decisions/067-agent-progress-and-e
|
|
|
11
11
|
Existing event source validation, callback failure priority, short-circuiting,
|
|
12
12
|
Tool outcome priority, suspended/wait/terminal boundaries and session incarnation
|
|
13
13
|
rules are preserved. Agent's Tool child FSM is still a separate remaining task.
|
|
14
|
+
|
|
15
|
+
## Initial execution registration
|
|
16
|
+
|
|
17
|
+
An Agent's coordinator owns the registration and terminal delivery of that
|
|
18
|
+
Agent's execution. A rejected registration does not acquire an existing
|
|
19
|
+
execution merely because both requests use the same execution ID. Agent
|
|
20
|
+
admission, durable outcome and completion delivery remain separate boundaries.
|
|
21
|
+
|
|
22
|
+
For example, if a second Agent in another Store reserves an ID already active
|
|
23
|
+
in the Runtime, its failed start must not release the first Agent, settle the
|
|
24
|
+
first Agent's waiters or alter its physical-work accounting. The second Agent
|
|
25
|
+
records its own failure when persistence confirms it, and receives only its own
|
|
26
|
+
operation result. The first Agent can continue and finish normally.
|
|
27
|
+
|
|
28
|
+
If registration installed this Agent's live state before session startup failed,
|
|
29
|
+
the coordinator uses its normal owned terminal path, including physical-work
|
|
30
|
+
quiescence and waiter delivery. If no state was installed, the terminal operation
|
|
31
|
+
uses only its own request task and admission; it does not read or drain another
|
|
32
|
+
owner's live state or waiter collection by ID.
|
|
33
|
+
|
|
34
|
+
An unconfirmed durable outcome stays recovery-required. A failure to commit or
|
|
35
|
+
submit a terminal write for an unregistered start settles that start's own
|
|
36
|
+
operation with the error; it does not fabricate a confirmed failed execution.
|
|
37
|
+
Registered executions retain their existing recovery behavior.
|
|
@@ -150,6 +150,12 @@ and Tool now own their shared operations, not merely value/error declarations.
|
|
|
150
150
|
The former G59/M78 split is retired. See [r8 unit 1](r8-unit1.md) for the exact
|
|
151
151
|
implemented scope, API removals and incomplete Persistence/domain work.
|
|
152
152
|
|
|
153
|
+
As of 2026-11-28, G58/C13 also contains the private `RetainedAttempts` manager
|
|
154
|
+
and `AttemptCompletion` evidence record used by four Agent/Workflow recovery
|
|
155
|
+
owners. They consume an injected submitter and the existing owner mutex; domain
|
|
156
|
+
proof, application and release remain outside the shared layer. See
|
|
157
|
+
[shared retained-attempt management](retained-attempts.md).
|
|
158
|
+
|
|
153
159
|
The full architecture still contains existing cycles outside the checked scope.
|
|
154
160
|
The recorded graph is not an ideal final r8 diagram.
|
|
155
161
|
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# G3l: keep semantic ownership separate from persistence proof
|
|
2
|
+
|
|
3
|
+
## Framework decision
|
|
4
|
+
|
|
5
|
+
Agent owns the accepted execution and its full semantic outcome. Persistence evidence owns the captured record/content facts needed to classify and replay a save. Keeping those responsibilities distinct avoids converting application values merely to populate an unused proof mirror.
|
|
6
|
+
|
|
7
|
+
For example, a report has already encoded its output text. Its original output is a String subclass whose copying method raises. G3k unnecessarily copies that original output into detached proof data, so an otherwise complete save can become unavailable. The repair removes the unused copy; it does not ask for another report, invent replacement text or reduce the original outcome.
|
|
8
|
+
|
|
9
|
+
The baseline is applied G3k `5dc527ed82638d42f3aa8d7d00216fdebc239480`, tree `f4fbf854e00dc4671f664d5da62027f9e14dace9`. Contract concept v55 and foundation v48 are the diagram baseline. Final implementation acceptance and exact delivery identity are recorded separately.
|
|
10
|
+
|
|
11
|
+
**Decision:** remove private detached proof fields `result`, `error_diagnostic` and `approval_request` and the conversions used only to populate them. Keep the original semantic Outcome in `CapturedInput.values[:result]` and the retained owner's `@intended`; keep `execution_observation` decoded from exact captured content. No public API, recovery subject, result-abandonment action or new ownership state is introduced.
|
|
12
|
+
|
|
13
|
+
## Representation and consumer evidence
|
|
14
|
+
|
|
15
|
+
A representation is required only when a real consumer needs its facts. Similar names do not make the semantic Outcome used by the coordinator and the detached Outcome used by persistence the same contract.
|
|
16
|
+
|
|
17
|
+
For the report, the coordinator needs the complete messages, original output identity, usage and original error or approval object. Persistence replay needs the chosen root, execution and records. Public recovered execution observation needs the durable bytes, not a second copy of the live output object.
|
|
18
|
+
|
|
19
|
+
| Representation | Owner and consumer | Preserved contract |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `ExecutionOutcomeCommitter::Outcome` | Committer, retained recovery owner and coordinator | Full semantic outcome, ordinary result identity, messages/usage, original error and exact approval request |
|
|
22
|
+
| `TerminalPersistenceEvidence::Outcome` | Evidence replay and recovered execution observation | Exact root/execution/appended records and captured-byte `execution_observation` |
|
|
23
|
+
| `OutcomeRecoveryResult` | Application's new recovery observer | Persistence disposition, application/ownership states and the established saved-outcome shape |
|
|
24
|
+
|
|
25
|
+
At the baseline, no production reader of detached `result`, `error_diagnostic` or `approval_request` was found. Their consumers were private representation tests. `TerminalPersistenceEvidence#replay` reads records/execution/root; `OutcomeRecoveryOperation#remember_post` reads the proof's execution observation while retaining the original semantic Outcome. `apply_confirmation` sends that original Outcome to the coordinator. Tests must continue to assert the real contracts, rather than retain unused mirrors solely because a private test inspected them.
|
|
26
|
+
|
|
27
|
+
## Changed and unchanged behavior
|
|
28
|
+
|
|
29
|
+
Removing an unnecessary conversion removes an unnecessary failure point. It must not alter legitimate conversion, stored records or the responsibilities retained after genuinely incomplete preparation.
|
|
30
|
+
|
|
31
|
+
For the report, output encoding still happens once. A failed copy that existed only for the unused mirror now happens zero times. The Tool and Provider still execute their original counts, and ordinary publication still returns the original output object. A transient transcript read or a lost write response still uses the existing recovery APIs.
|
|
32
|
+
|
|
33
|
+
| Condition | G3k baseline | G3l behavior |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| Ordinary supported result | Complete semantic result and captured persistence facts | Same public result and saved facts |
|
|
36
|
+
| Application-defined copy fails only in unused proof mirror | Complete encoded intent can remain unavailable | No unnecessary copy is invoked; the supported save can proceed |
|
|
37
|
+
| Duplicate diagnostic or approval conversion used only by proof mirror | Can run beyond the real semantic/encoding requirement | Removed; original error/request and captured observations remain with their actual consumers |
|
|
38
|
+
| Transcript hydration or persistence response fails | Existing retained preparation/proof recovery | Same APIs and guards; no additional business replay |
|
|
39
|
+
| Required encoder or genuine original diagnostic conversion fails | Preparation may be incomplete | Remains a separate group-1 issue; no forced terminalization |
|
|
40
|
+
| Wrong Store, stale owner, active physical attempt, conflicting state or revoked native authority | Responsibility remains retained | Same restrictions |
|
|
41
|
+
|
|
42
|
+
## Complete application comparison
|
|
43
|
+
|
|
44
|
+
The application requests and observes the same report through existing public APIs. It owns its persistence-retry policy and retains unresolved responsibility; it does not repair framework proof values. The before and after functions are byte-identical, while the explicitly identified copy-sensitive fault behavior changes.
|
|
45
|
+
|
|
46
|
+
For this example, a native-configured report parent makes two offline Provider calls and one Tool call. The Tool and Provider are counted fixtures, while the Agent, Runtime, transaction and retained owner are real. A declared child is not dispatched. The output can be a String whose custom copy method raises; its required text conversion still succeeds. The candidate should not call that copy solely to construct an unused mirror.
|
|
47
|
+
|
|
48
|
+
Copy shared setup, common observation helpers, one normal-function column, one recovery-function column, the fault fixture and shared driver into one Ruby file in that order. Run each case in a fresh process because the fault fixture instruments that process. This is an executable design example, not a separate application repository.
|
|
49
|
+
|
|
50
|
+
### Shared setup and observation
|
|
51
|
+
|
|
52
|
+
Both versions use the same report definitions, output object, storage and observations. The counters expose repeated business work and unnecessary copying; the observation helpers report real storage and retained responsibility rather than replacing the proof.
|
|
53
|
+
|
|
54
|
+
For the report, the full normal result can be compared with stored output and transcript, while a retained recovery error remains visible and prevents successful-cleanup claims.
|
|
55
|
+
|
|
56
|
+
<!-- g3l-code:shared-setup -->
|
|
57
|
+
```ruby
|
|
58
|
+
require "phronomy"
|
|
59
|
+
require "json"
|
|
60
|
+
|
|
61
|
+
class G3lReportError < Phronomy::Error
|
|
62
|
+
def initialize
|
|
63
|
+
super("The report source is unavailable", code: "report.source_unavailable")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class G3lReportOutput
|
|
68
|
+
def initialize(counts)
|
|
69
|
+
@counts = counts
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_s
|
|
73
|
+
@counts[:output_conversion] += 1
|
|
74
|
+
"Report completed"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# This caller-owned value can be serialized but deliberately cannot be copied.
|
|
79
|
+
# A persistence proof needs its already encoded text, not another semantic copy.
|
|
80
|
+
class G3lUncopyableOutput < String
|
|
81
|
+
def initialize(counts)
|
|
82
|
+
super("Report completed")
|
|
83
|
+
@counts = counts
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def to_s
|
|
87
|
+
@counts[:output_conversion] += 1
|
|
88
|
+
super
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def initialize_copy(_source)
|
|
92
|
+
@counts[:custom_copy] += 1
|
|
93
|
+
raise IOError, "The application output must not be copied"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class G3lReportTool < Phronomy::Tool::Base
|
|
98
|
+
tool_name "read_report_source"
|
|
99
|
+
description "Read the report source once"
|
|
100
|
+
param :topic, type: :string, desc: "Report topic"
|
|
101
|
+
class << self
|
|
102
|
+
attr_accessor :counts
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def execute(topic:)
|
|
106
|
+
self.class.counts[:tool] += 1
|
|
107
|
+
raise "Unexpected repeated Tool work" if self.class.counts[:tool] > 1
|
|
108
|
+
"Source facts for #{topic}"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
class G3lReportWorker < Phronomy::Agent::Base
|
|
113
|
+
agent_definition id: "detached-proof-report-worker", version: 1
|
|
114
|
+
model "offline-model"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
class G3lReportParent < Phronomy::MultiAgent::Orchestrator
|
|
118
|
+
agent_definition id: "detached-proof-report-parent", version: 1
|
|
119
|
+
model "offline-model"
|
|
120
|
+
tools G3lReportTool => nil
|
|
121
|
+
subagent :reviewer, G3lReportWorker
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
class G3lReportAdapter < Phronomy::LLMAdapter::Base
|
|
125
|
+
def initialize(counts, error: nil)
|
|
126
|
+
@counts, @error = counts, error
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def perform_complete(_request, cancellation_token:)
|
|
130
|
+
cancellation_token&.raise_if_cancelled!
|
|
131
|
+
@counts[:provider] += 1
|
|
132
|
+
case @counts[:provider]
|
|
133
|
+
when 1
|
|
134
|
+
Phronomy::LLMAdapter::Response.new(finish_reason: :tool_calls, tool_calls: [
|
|
135
|
+
Phronomy::Tool::CallRequest.new(id: "report-source-call", name: "read_report_source", arguments: {topic: "retained outcomes"})
|
|
136
|
+
])
|
|
137
|
+
when 2
|
|
138
|
+
raise @error if @error
|
|
139
|
+
Phronomy::LLMAdapter::Response.new(content: "Report source text", finish_reason: :stop)
|
|
140
|
+
else
|
|
141
|
+
raise "Unexpected repeated Provider work"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def build_report_service(failure: false, copy_sensitive: false)
|
|
147
|
+
counts = Hash.new(0)
|
|
148
|
+
error = failure ? G3lReportError.new : nil
|
|
149
|
+
G3lReportTool.counts = counts
|
|
150
|
+
adapter = G3lReportAdapter.new(counts, error: error)
|
|
151
|
+
Phronomy.configure { |configuration| configuration.llm_adapter = adapter }
|
|
152
|
+
stores = Phronomy::PersistenceComposition.in_memory
|
|
153
|
+
parent = G3lReportParent.create(agent_id: "detached-proof-report-parent", persistence: stores.agent,
|
|
154
|
+
coordination_store: stores.multi_agent)
|
|
155
|
+
output = copy_sensitive ? G3lUncopyableOutput.new(counts) : G3lReportOutput.new(counts)
|
|
156
|
+
parent.add_output_filter(->(_text) { output }) unless failure
|
|
157
|
+
{counts: counts, stores: stores, parent: parent, output: output, error: error}
|
|
158
|
+
end
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
<!-- g3l-code:common-observation -->
|
|
162
|
+
```ruby
|
|
163
|
+
def report_messages(messages)
|
|
164
|
+
messages.map do |message|
|
|
165
|
+
message.to_h.reject { |key, _value| key == "metadata" }
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def stored_report(service)
|
|
170
|
+
parent = service.fetch(:parent)
|
|
171
|
+
fact = service.fetch(:stores).agent.observe_execution(agent_id: parent.agent_id,
|
|
172
|
+
execution_id: service.fetch(:execution_id))
|
|
173
|
+
{status: fact.status, result: fact.result, raw_output: fact.raw_output, error: fact.error}
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def report_receipt(receipt)
|
|
177
|
+
execution = receipt.execution
|
|
178
|
+
{outcome: receipt.outcome, application_state: receipt.application_state,
|
|
179
|
+
ownership_state: receipt.ownership_state, saved_outcome: receipt.saved_outcome,
|
|
180
|
+
execution: execution && {status: execution.status, result: execution.result,
|
|
181
|
+
raw_output: execution.raw_output, error: execution.error}}
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def release_report(service)
|
|
185
|
+
service.fetch(:parent).unload!
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def start_report(service)
|
|
189
|
+
service.fetch(:parent).invoke_async("Prepare one report")
|
|
190
|
+
end
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Ordinary call and copy-sensitive completion
|
|
194
|
+
|
|
195
|
+
The ordinary call waits for its existing result and performs cleanup only when the existing ownership contract permits it. Its use of the original output object and complete messages is the same on both sides.
|
|
196
|
+
|
|
197
|
+
For the report, ordinary success and source failure are compatibility controls. A copy-sensitive output is an intentional failure-behavior change: the baseline may retain responsibility because of the unnecessary mirror copy, whereas the candidate can finish without invoking it. This is not a claim that baseline and candidate fault outcomes are equivalent.
|
|
198
|
+
|
|
199
|
+
<table>
|
|
200
|
+
<thead><tr><th>Before: applied G3k</th><th>After: G3l</th></tr></thead>
|
|
201
|
+
<tbody><tr>
|
|
202
|
+
<td><pre><code><!-- g3l-code:normal-function:before -->def run_report(failure: false, copy_sensitive: false)
|
|
203
|
+
service = build_report_service(failure: failure, copy_sensitive: copy_sensitive)
|
|
204
|
+
report_fault(read_failure: :none, save_loss: :none).call(service)
|
|
205
|
+
original = start_report(service)
|
|
206
|
+
result = nil
|
|
207
|
+
original_error = nil
|
|
208
|
+
recovery_error = nil
|
|
209
|
+
begin
|
|
210
|
+
result = original.wait_result(timeout: 8)
|
|
211
|
+
rescue G3lReportError => error
|
|
212
|
+
original_error = error
|
|
213
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
214
|
+
recovery_error = error
|
|
215
|
+
end
|
|
216
|
+
if recovery_error
|
|
217
|
+
recovery = recovery_error.recovery
|
|
218
|
+
raise "Unexpected retained owner" unless service.fetch(:parent)
|
|
219
|
+
.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
|
|
220
|
+
return {state: :retained, stored: stored_report(service), counts: service.fetch(:counts),
|
|
221
|
+
original_output_preserved: nil, complete_result_messages_match_transcript: nil,
|
|
222
|
+
original_business_error_preserved: nil, released: false,
|
|
223
|
+
retained_service: service, retained_recovery: recovery}
|
|
224
|
+
end
|
|
225
|
+
transcript = service.fetch(:parent).transcript_messages
|
|
226
|
+
messages_match = result && result.fetch(:messages).map(&:to_h) == transcript.map(&:to_h)
|
|
227
|
+
{state: :ordinary, stored: stored_report(service),
|
|
228
|
+
original_business_error_preserved: failure ? original_error.equal?(service.fetch(:error)) : nil,
|
|
229
|
+
original_output_preserved: result && result.fetch(:output).equal?(service.fetch(:output)),
|
|
230
|
+
complete_result_messages_match_transcript: messages_match,
|
|
231
|
+
transcript: report_messages(transcript), counts: service.fetch(:counts),
|
|
232
|
+
released: release_report(service)}
|
|
233
|
+
end
|
|
234
|
+
</code></pre></td>
|
|
235
|
+
<td><pre><code><!-- g3l-code:normal-function:after -->def run_report(failure: false, copy_sensitive: false)
|
|
236
|
+
service = build_report_service(failure: failure, copy_sensitive: copy_sensitive)
|
|
237
|
+
report_fault(read_failure: :none, save_loss: :none).call(service)
|
|
238
|
+
original = start_report(service)
|
|
239
|
+
result = nil
|
|
240
|
+
original_error = nil
|
|
241
|
+
recovery_error = nil
|
|
242
|
+
begin
|
|
243
|
+
result = original.wait_result(timeout: 8)
|
|
244
|
+
rescue G3lReportError => error
|
|
245
|
+
original_error = error
|
|
246
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
247
|
+
recovery_error = error
|
|
248
|
+
end
|
|
249
|
+
if recovery_error
|
|
250
|
+
recovery = recovery_error.recovery
|
|
251
|
+
raise "Unexpected retained owner" unless service.fetch(:parent)
|
|
252
|
+
.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
|
|
253
|
+
return {state: :retained, stored: stored_report(service), counts: service.fetch(:counts),
|
|
254
|
+
original_output_preserved: nil, complete_result_messages_match_transcript: nil,
|
|
255
|
+
original_business_error_preserved: nil, released: false,
|
|
256
|
+
retained_service: service, retained_recovery: recovery}
|
|
257
|
+
end
|
|
258
|
+
transcript = service.fetch(:parent).transcript_messages
|
|
259
|
+
messages_match = result && result.fetch(:messages).map(&:to_h) == transcript.map(&:to_h)
|
|
260
|
+
{state: :ordinary, stored: stored_report(service),
|
|
261
|
+
original_business_error_preserved: failure ? original_error.equal?(service.fetch(:error)) : nil,
|
|
262
|
+
original_output_preserved: result && result.fetch(:output).equal?(service.fetch(:output)),
|
|
263
|
+
complete_result_messages_match_transcript: messages_match,
|
|
264
|
+
transcript: report_messages(transcript), counts: service.fetch(:counts),
|
|
265
|
+
released: release_report(service)}
|
|
266
|
+
end
|
|
267
|
+
</code></pre></td>
|
|
268
|
+
</tr></tbody>
|
|
269
|
+
</table>
|
|
270
|
+
|
|
271
|
+
### Recovery policy after a failed observation
|
|
272
|
+
|
|
273
|
+
The recovery policy treats a fresh reconciliation as observation of retained responsibility. Only the explicit flag permits a captured-write retry after confirmed pre-state; the original Provider, Tool and closed invocation are never restarted.
|
|
274
|
+
|
|
275
|
+
For the report, a transient transcript read can be followed by the same existing reconciliation and explicit retry. A lost write response can instead be recognized as committed. Declining the retry remains a retained outcome and is reported as such.
|
|
276
|
+
|
|
277
|
+
<table>
|
|
278
|
+
<thead><tr><th>Before: applied G3k</th><th>After: G3l</th></tr></thead>
|
|
279
|
+
<tbody><tr>
|
|
280
|
+
<td><pre><code><!-- g3l-code:recovery-function:before --># Retrying a confirmed pre-state is an explicit persistence policy. It does not
|
|
281
|
+
# authorize repeating the report, output conversion or native preparation.
|
|
282
|
+
def run_report_with_recovery(fault:, retry_confirmed_pre: false, late_observer: false, copy_sensitive: false)
|
|
283
|
+
service = build_report_service(copy_sensitive: copy_sensitive)
|
|
284
|
+
fault.call(service)
|
|
285
|
+
parent = service.fetch(:parent)
|
|
286
|
+
original = start_report(service)
|
|
287
|
+
original_failure = nil
|
|
288
|
+
begin
|
|
289
|
+
original.wait_result(timeout: 8)
|
|
290
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
291
|
+
original_failure = error
|
|
292
|
+
end
|
|
293
|
+
raise "Expected an ambiguous report observation" unless original_failure
|
|
294
|
+
recovery = original_failure.recovery
|
|
295
|
+
raise "Unexpected retained owner" unless parent.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
|
|
296
|
+
counts_after_failure = service.fetch(:counts).dup
|
|
297
|
+
resumed = late_observer ? parent.resume_async(service.fetch(:execution_id)) : nil
|
|
298
|
+
reconciled = parent.reconcile_outcome(recovery: recovery)
|
|
299
|
+
after_reconcile = stored_report(service)
|
|
300
|
+
first = reconciled
|
|
301
|
+
if first.outcome == :confirmed_pre && retry_confirmed_pre
|
|
302
|
+
first = parent.retry_outcome(recovery: recovery)
|
|
303
|
+
end
|
|
304
|
+
second = parent.reconcile_outcome(recovery: recovery)
|
|
305
|
+
begin
|
|
306
|
+
original.wait_result(timeout: 8)
|
|
307
|
+
raise "Original failed observation reopened"
|
|
308
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
309
|
+
raise "Original observation changed" unless error.equal?(original_failure)
|
|
310
|
+
end
|
|
311
|
+
released = first.ownership_state == :released
|
|
312
|
+
resumed_result = resumed.wait_result(timeout: 8) if resumed && released
|
|
313
|
+
transcript = released ? parent.transcript_messages : nil
|
|
314
|
+
release_report(service) if released
|
|
315
|
+
{state: released ? :recovered : :retained, stored: stored_report(service),
|
|
316
|
+
reconciliation: report_receipt(reconciled), after_reconciliation: after_reconcile,
|
|
317
|
+
observations: [report_receipt(first), report_receipt(second)],
|
|
318
|
+
late_observer: resumed ? {requested: true, completed: resumed.done?,
|
|
319
|
+
result: resumed_result && resumed_result.slice(:status, :result, :output)} : {requested: false},
|
|
320
|
+
transcript: transcript && report_messages(transcript), counts: service.fetch(:counts),
|
|
321
|
+
counts_after_failure: counts_after_failure, released: released,
|
|
322
|
+
original_observation_closed: true,
|
|
323
|
+
retained_service: released ? nil : service, retained_recovery: released ? nil : recovery,
|
|
324
|
+
retained_observer: released ? nil : resumed}
|
|
325
|
+
end
|
|
326
|
+
</code></pre></td>
|
|
327
|
+
<td><pre><code><!-- g3l-code:recovery-function:after --># Retrying a confirmed pre-state is an explicit persistence policy. It does not
|
|
328
|
+
# authorize repeating the report, output conversion or native preparation.
|
|
329
|
+
def run_report_with_recovery(fault:, retry_confirmed_pre: false, late_observer: false, copy_sensitive: false)
|
|
330
|
+
service = build_report_service(copy_sensitive: copy_sensitive)
|
|
331
|
+
fault.call(service)
|
|
332
|
+
parent = service.fetch(:parent)
|
|
333
|
+
original = start_report(service)
|
|
334
|
+
original_failure = nil
|
|
335
|
+
begin
|
|
336
|
+
original.wait_result(timeout: 8)
|
|
337
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
338
|
+
original_failure = error
|
|
339
|
+
end
|
|
340
|
+
raise "Expected an ambiguous report observation" unless original_failure
|
|
341
|
+
recovery = original_failure.recovery
|
|
342
|
+
raise "Unexpected retained owner" unless parent.pending_outcome_recovery(execution_id: service.fetch(:execution_id)).equal?(recovery)
|
|
343
|
+
counts_after_failure = service.fetch(:counts).dup
|
|
344
|
+
resumed = late_observer ? parent.resume_async(service.fetch(:execution_id)) : nil
|
|
345
|
+
reconciled = parent.reconcile_outcome(recovery: recovery)
|
|
346
|
+
after_reconcile = stored_report(service)
|
|
347
|
+
first = reconciled
|
|
348
|
+
if first.outcome == :confirmed_pre && retry_confirmed_pre
|
|
349
|
+
first = parent.retry_outcome(recovery: recovery)
|
|
350
|
+
end
|
|
351
|
+
second = parent.reconcile_outcome(recovery: recovery)
|
|
352
|
+
begin
|
|
353
|
+
original.wait_result(timeout: 8)
|
|
354
|
+
raise "Original failed observation reopened"
|
|
355
|
+
rescue Phronomy::Agent::OutcomeRecoveryError => error
|
|
356
|
+
raise "Original observation changed" unless error.equal?(original_failure)
|
|
357
|
+
end
|
|
358
|
+
released = first.ownership_state == :released
|
|
359
|
+
resumed_result = resumed.wait_result(timeout: 8) if resumed && released
|
|
360
|
+
transcript = released ? parent.transcript_messages : nil
|
|
361
|
+
release_report(service) if released
|
|
362
|
+
{state: released ? :recovered : :retained, stored: stored_report(service),
|
|
363
|
+
reconciliation: report_receipt(reconciled), after_reconciliation: after_reconcile,
|
|
364
|
+
observations: [report_receipt(first), report_receipt(second)],
|
|
365
|
+
late_observer: resumed ? {requested: true, completed: resumed.done?,
|
|
366
|
+
result: resumed_result && resumed_result.slice(:status, :result, :output)} : {requested: false},
|
|
367
|
+
transcript: transcript && report_messages(transcript), counts: service.fetch(:counts),
|
|
368
|
+
counts_after_failure: counts_after_failure, released: released,
|
|
369
|
+
original_observation_closed: true,
|
|
370
|
+
retained_service: released ? nil : service, retained_recovery: released ? nil : recovery,
|
|
371
|
+
retained_observer: released ? nil : resumed}
|
|
372
|
+
end
|
|
373
|
+
</code></pre></td>
|
|
374
|
+
</tr></tbody>
|
|
375
|
+
</table>
|
|
376
|
+
|
|
377
|
+
### Fault fixture and complete driver
|
|
378
|
+
|
|
379
|
+
The fixture injects bounded failures into the real content/transaction path and supplies deterministic input objects. It leaves the real persistence proof, owner fencing and result publication in control of the outcome.
|
|
380
|
+
|
|
381
|
+
For the report, the copy-sensitive post-response case does not even reach the planned write fault on the baseline: the earlier redundant copy blocks it. The candidate can reach that fault and recover the actual committed result. The driver checks the expected behavior for the selected version and reports held responsibility rather than treating process exit as cleanup.
|
|
382
|
+
|
|
383
|
+
<!-- g3l-code:fault-fixture -->
|
|
384
|
+
```ruby
|
|
385
|
+
# The fixture counts actual terminal preparation and fails an actual immutable
|
|
386
|
+
# content read or a real transaction response. It never supplies an outcome.
|
|
387
|
+
module G3lReportFault
|
|
388
|
+
class << self
|
|
389
|
+
attr_accessor :current
|
|
390
|
+
|
|
391
|
+
def report
|
|
392
|
+
return {enabled: false} unless current
|
|
393
|
+
current.slice(:read_failure, :save_loss, :read_failures, :save_failures,
|
|
394
|
+
:committer_calls, :encoder_calls, :materialization_calls)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
module G3lCommitScope
|
|
400
|
+
def commit_outcome(command, **options)
|
|
401
|
+
fault = G3lReportFault.current
|
|
402
|
+
selected = fault && command.root.agent_id == fault.fetch(:service).fetch(:parent).agent_id
|
|
403
|
+
previous = Thread.current[:g3l_report_outcome]
|
|
404
|
+
Thread.current[:g3l_report_outcome] = selected ? fault : nil
|
|
405
|
+
if selected
|
|
406
|
+
fault.fetch(:service)[:execution_id] = command.execution_id
|
|
407
|
+
fault[:committer_calls] += 1
|
|
408
|
+
end
|
|
409
|
+
super
|
|
410
|
+
ensure
|
|
411
|
+
Thread.current[:g3l_report_outcome] = previous
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
module G3lEncodingCount
|
|
416
|
+
def encode(*args, **options)
|
|
417
|
+
fault = Thread.current[:g3l_report_outcome]
|
|
418
|
+
fault[:encoder_calls] += 1 if fault
|
|
419
|
+
super
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
module G3lTranscriptScope
|
|
424
|
+
def materialize_transcript(root:, records:)
|
|
425
|
+
fault = G3lReportFault.current
|
|
426
|
+
selected = fault && root.agent_id == fault.fetch(:service).fetch(:parent).agent_id
|
|
427
|
+
previous = Thread.current[:g3l_report_transcript]
|
|
428
|
+
Thread.current[:g3l_report_transcript] = selected ? fault : nil
|
|
429
|
+
fault[:materialization_calls] += 1 if selected
|
|
430
|
+
super
|
|
431
|
+
ensure
|
|
432
|
+
Thread.current[:g3l_report_transcript] = previous
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
module G3lTranscriptRead
|
|
437
|
+
def fetch(reference)
|
|
438
|
+
fault = Thread.current[:g3l_report_transcript]
|
|
439
|
+
should_fail = fault && fault.fetch(:service).fetch(:counts)[:output_conversion] > 0 &&
|
|
440
|
+
(fault[:read_failure] == :permanent || (fault[:read_failure] == :once && fault[:read_failures].zero?))
|
|
441
|
+
if should_fail
|
|
442
|
+
fault[:read_failures] += 1
|
|
443
|
+
raise IOError, "Immutable report transcript content is unavailable"
|
|
444
|
+
end
|
|
445
|
+
super
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
module G3lSaveResponse
|
|
450
|
+
def atomic(*args, &transaction)
|
|
451
|
+
fault = Thread.current[:g3l_report_outcome]
|
|
452
|
+
return super unless fault && fault[:save_loss] != :none
|
|
453
|
+
if fault[:readback_loss]
|
|
454
|
+
fault[:readback_loss] = false
|
|
455
|
+
raise IOError, "Immediate report save readback unavailable"
|
|
456
|
+
end
|
|
457
|
+
return super unless fault[:save_armed]
|
|
458
|
+
fault[:save_armed] = false
|
|
459
|
+
if fault[:save_loss] == :pre
|
|
460
|
+
super(*args) do |scope|
|
|
461
|
+
transaction.call(scope)
|
|
462
|
+
fault[:save_failures] += 1
|
|
463
|
+
fault[:readback_loss] = true
|
|
464
|
+
raise IOError, "Report save rolled back and response lost"
|
|
465
|
+
end
|
|
466
|
+
else
|
|
467
|
+
super(*args, &transaction)
|
|
468
|
+
fault[:save_failures] += 1
|
|
469
|
+
fault[:readback_loss] = true
|
|
470
|
+
raise IOError, "Report save committed and response lost"
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
Phronomy::Agent::ExecutionOutcomeCommitter.prepend(G3lCommitScope)
|
|
476
|
+
Phronomy::Agent::RuntimeRecordEncoder.singleton_class.prepend(G3lEncodingCount)
|
|
477
|
+
Phronomy::Agent::RuntimeInput.prepend(G3lTranscriptScope)
|
|
478
|
+
Phronomy::Persistence::ContentRepository.prepend(G3lTranscriptRead)
|
|
479
|
+
|
|
480
|
+
def report_fault(read_failure:, save_loss:)
|
|
481
|
+
raise ArgumentError, "Unknown read failure" unless %i[none once permanent].include?(read_failure)
|
|
482
|
+
raise ArgumentError, "Unknown response loss" unless %i[none pre post].include?(save_loss)
|
|
483
|
+
lambda do |service|
|
|
484
|
+
service.fetch(:stores).agent.coordinator.singleton_class.prepend(G3lSaveResponse)
|
|
485
|
+
G3lReportFault.current = {service: service, read_failure: read_failure, save_loss: save_loss,
|
|
486
|
+
save_armed: true, readback_loss: false, read_failures: 0, save_failures: 0,
|
|
487
|
+
committer_calls: 0, encoder_calls: 0, materialization_calls: 0}
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
<!-- g3l-code:shared-driver -->
|
|
493
|
+
```ruby
|
|
494
|
+
# An unresolved result retains the live owner and exact capability. A service
|
|
495
|
+
# must keep these values; process exit is not a handoff or recovery mechanism.
|
|
496
|
+
def run_report_example(normal: false, failure: false, read_failure: :none,
|
|
497
|
+
save_loss: :none, retry_confirmed_pre: false, late_observer: false, copy_sensitive: false)
|
|
498
|
+
begin
|
|
499
|
+
report = if normal
|
|
500
|
+
run_report(failure: failure, copy_sensitive: copy_sensitive)
|
|
501
|
+
else
|
|
502
|
+
run_report_with_recovery(fault: report_fault(read_failure: read_failure, save_loss: save_loss),
|
|
503
|
+
retry_confirmed_pre: retry_confirmed_pre, late_observer: late_observer, copy_sensitive: copy_sensitive)
|
|
504
|
+
end
|
|
505
|
+
report = report.reject { |key, _value| %i[retained_service retained_recovery retained_observer].include?(key) }
|
|
506
|
+
ensure
|
|
507
|
+
fixture = G3lReportFault.report
|
|
508
|
+
Phronomy::Runtime.instance.shutdown(timeout: 0.03, cancel_grace: 0.2)
|
|
509
|
+
begin
|
|
510
|
+
Phronomy.reset_runtime!
|
|
511
|
+
cleanup_incomplete = false
|
|
512
|
+
rescue Phronomy::RuntimeShutdownError
|
|
513
|
+
cleanup_incomplete = true
|
|
514
|
+
end
|
|
515
|
+
end
|
|
516
|
+
report.merge(cleanup_incomplete: cleanup_incomplete, fixture: fixture)
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
if $PROGRAM_NAME == __FILE__
|
|
520
|
+
puts JSON.pretty_generate(run_report_example(normal: ENV["G3L_NORMAL"] == "true",
|
|
521
|
+
failure: ENV["G3L_FAILURE"] == "true", read_failure: ENV.fetch("G3L_READ_FAILURE", "none").to_sym,
|
|
522
|
+
save_loss: ENV.fetch("G3L_SAVE_LOSS", "none").to_sym,
|
|
523
|
+
retry_confirmed_pre: ENV["G3L_RETRY_CAPTURED_OUTCOME"] == "true",
|
|
524
|
+
late_observer: ENV["G3L_LATE_OBSERVER"] == "true",
|
|
525
|
+
copy_sensitive: ENV["G3L_COPY_SENSITIVE"] == "true"))
|
|
526
|
+
end
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## Minimal implementation and architecture
|
|
530
|
+
|
|
531
|
+
The implementation should narrow the private proof representation and remove only its redundant work. It should not add normalization machinery, reconstruct semantic output from stored text or relax immutable persistence evidence.
|
|
532
|
+
|
|
533
|
+
For the report, using captured output text as a replacement for the original semantic output would change ordinary identity and possibly the result shape. That substitution is unnecessary because the semantic Outcome is already retained. The proof's captured execution observation remains a separate public projection.
|
|
534
|
+
|
|
535
|
+
Required source changes are the private Data fields and their construction, matching RBS declarations, and tests that previously asserted unused mirrors. Runtime tests must demonstrate the removed callback, complete normal results, actual recovered observations and retained guards. The current owner/preparation lifecycle and existing one-shot protections need not be broadened. Final source review must confirm no production dynamic use of the removed fields.
|
|
536
|
+
|
|
537
|
+
No domain responsibility moves between Agent, MultiAgent, Persistence and Execution. Native child authority, retained holds and transaction guards stay with their current owners. Both Contract SVGs require final-source dependency review; the expected decision is no revision because this removes private Agent work rather than introducing a new contract or dependency direction.
|
|
538
|
+
|
|
539
|
+
## Symmetry and alternatives
|
|
540
|
+
|
|
541
|
+
Recovery operations are symmetric when their authority is the same, not merely when they have similar names. This change preserves existing operations because no new authority is needed.
|
|
542
|
+
|
|
543
|
+
For the report, reconciliation still classifies captured facts and explicit retry still writes them. A new API asking the application to resupply known text would add work for the caller and obscure an internal duplication defect.
|
|
544
|
+
|
|
545
|
+
| Peer or alternative | Decision | Reason |
|
|
546
|
+
| --- | --- | --- |
|
|
547
|
+
| Ordinary invoke versus recovered publication | Preserve their existing distinct shapes | Ordinary semantic output and exact durable observation are not interchangeable |
|
|
548
|
+
| Sync versus async outcome recovery | Unchanged | Both use the same original owner and physical lane |
|
|
549
|
+
| Terminal versus approval/coordination outcome | Preserve their domain-specific owner values | Unused mirrors do not justify repeating diagnostics or request conversion |
|
|
550
|
+
| Generic deep-copy rewrite | Reject for this change | Shared copy behavior has other consumers; remove work with no consumer first |
|
|
551
|
+
| Data supplied by application | Unnecessary for this defect | The useful facts already exist |
|
|
552
|
+
| Automatic failure/abandonment | Reject as a consequence of this cleanup | It would select new job semantics and could discard effect/child obligations |
|
|
553
|
+
| New state diagram or model family | Not needed for this change | No new actor, state or permitted transition is introduced |
|
|
554
|
+
|
|
555
|
+
## Validation and residual closure
|
|
556
|
+
|
|
557
|
+
Validation must show actual observable preservation and removal of the needless failure. A passing private constructor test alone does not show that the complete result is still published correctly.
|
|
558
|
+
|
|
559
|
+
For the report, use a String subclass whose copy method raises or records a call, while its required text encoding succeeds. Compare the exact baseline and candidate through real Runtime, original invocation, recovery and Store. Count actual callbacks and compare original identity, messages, durable observation and cleanup responsibility.
|
|
560
|
+
|
|
561
|
+
Required checks include normal success/failure, copy-sensitive normal completion, recovery after transcript-read or write-response loss, original closed-observer behavior, exact late-observer shape, no-retry retention, and unchanged current-authority/physical/store guards. Direct proof tests must verify captured observation immutability and preserve complete original semantic values. Diagnostic and approval cases must distinguish a genuinely required first conversion from the removed redundant one.
|
|
562
|
+
|
|
563
|
+
The complete application comparison ran six cases on each exact source version, with all six matching each version's expected behavior. The three copy-sensitive baseline cases retained responsibility; the candidate completed normal save or the applicable recovery path, with the unnecessary custom-copy count changing from one to zero. Ordinary success and source-failure control reports match exactly, and the explicit no-retry case remains retained. The runs bind 408 production source files per version and record actual loaded paths. Executing the same twelve combinations directly from the published eight code units produced the same reports; those twelve runs establish document correspondence, not twelve additional scenarios. Independent Runtime and complete regression evidence are recorded separately. These are local candidate results; hosted application and CI acceptance remain separate.
|
|
564
|
+
|
|
565
|
+
The existing finite model remains an abstract model of preparation, proof, original ownership, physical work and guarded persistence. Removing a redundant representation does not add a model transition. Any rerun/reuse is recorded with exact model inputs; neither the model nor the test counts prove Ruby refinement. The old copy-failure example remains historical evidence of the baseline, not a required permanent failure of the repaired candidate.
|
|
566
|
+
|
|
567
|
+
| Group-1 class | G3l effect | Remaining closure requirement |
|
|
568
|
+
| --- | --- | --- |
|
|
569
|
+
| Unused semantic proof copies/conversions | Eliminated where source and runtime evidence establish no consumer | Preserve actual owner semantics and exact proof facts |
|
|
570
|
+
| Fixed hydration after encoded intent | Existing G3k route retained | Preserve its guards and accepted evidence |
|
|
571
|
+
| Genuine pre-capsule encoding, output conversion or diagnostic failure | Not solved by removing mirrors | Define exact missing information and a supported completion/disposition contract |
|
|
572
|
+
| Partial encoding | Not made replayable | Preserve completed pieces/identities before permitting any later work |
|
|
573
|
+
| Pre-conversion framework reads/native planning | No new whole-stage retry | Define where fixed reads end and one-time semantic selection starts |
|
|
574
|
+
| Handoff/custom participants | No generalized guarantee | Audit actual existing guarantees and repair justified gaps |
|
|
575
|
+
|
|
576
|
+
Intentional abandonment and application-authoritative completion remain separate policy work. A separate deferred policy design explores those choices; no proposed completion or abandonment API is part of G3l. Group 1 and G3 overall remain incomplete. The existing six-group closure plan is unchanged; unfinished preparation work must not be moved into stopped-Runtime or backend acceptance merely to close G3.
|
|
@@ -5,6 +5,11 @@ This candidate supersedes the unapplied Results split. It is based on main
|
|
|
5
5
|
record of application to main. The historical D02 reports describe their original
|
|
6
6
|
revisions; the control ownership decision below supersedes them for this candidate.
|
|
7
7
|
|
|
8
|
+
> Historical review: the 2026-09-29 ownership split below was superseded by
|
|
9
|
+
> [r8 unit 1](r8-unit1.md), which unified the Execution framework in C13. The
|
|
10
|
+
> 2026-11-28 [retained-attempt implementation](retained-attempts.md) follows that
|
|
11
|
+
> current boundary. The original candidate comparison is preserved below.
|
|
12
|
+
|
|
8
13
|
## Responsibilities
|
|
9
14
|
|
|
10
15
|
| Owner | Owns | Consumers should know |
|