phronomy 0.29.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +107 -1
  3. data/README.md +17 -6
  4. data/docs/architecture/agent-configuration-and-tool-binding.md +8 -0
  5. data/docs/architecture/agent-iteration-budget.md +81 -0
  6. data/docs/architecture/dx05-agent-scope.md +9 -2
  7. data/docs/architecture/error-api-review.md +4 -4
  8. data/docs/architecture/generator-verifier-lifecycle-result.md +126 -0
  9. data/docs/architecture/generator-verifier-ownership.md +18 -109
  10. data/docs/architecture/llm-continuation-metadata.md +88 -0
  11. data/docs/architecture/lm-studio-output-failures.md +111 -0
  12. data/docs/architecture/r8-unit1.md +68 -68
  13. data/docs/architecture/r8-unit15.md +3 -0
  14. data/docs/architecture/r8-unit2.md +34 -34
  15. data/docs/architecture/r8-unit7.md +2 -1
  16. data/docs/architecture/structured-output-and-scope.md +183 -0
  17. data/docs/architecture/tracing.md +22 -4
  18. data/docs/architecture/transport-error-boundaries.md +103 -0
  19. data/docs/architecture/trust-acceptance-followup.md +87 -0
  20. data/docs/decisions/029-semantic-completion-and-application-effect-boundary.md +1 -1
  21. data/docs/design/durable-semantic-coordination/CHANGELOG_V2_REVISION_2.md +23 -23
  22. data/docs/design/durable-semantic-coordination/IMPLEMENTATION_REPORT.md +99 -99
  23. data/docs/design/durable-semantic-coordination/RECOVERY_CONTRACT_CLARIFICATIONS.md +135 -136
  24. data/docs/features.md +10 -1
  25. data/docs/migrations/r8-unit15.md +3 -0
  26. data/gemfiles/http_minimum.gemfile +6 -1
  27. data/lib/phronomy/agent/admission.rb +1 -1
  28. data/lib/phronomy/agent/async_event_api.rb +16 -7
  29. data/lib/phronomy/agent/base.rb +8 -1
  30. data/lib/phronomy/agent/context_importer.rb +4 -0
  31. data/lib/phronomy/agent/execution/agent_invocation.rb +6 -2
  32. data/lib/phronomy/agent/execution/dispatch_preparation.rb +6 -1
  33. data/lib/phronomy/agent/execution/exact_execution.rb +9 -0
  34. data/lib/phronomy/agent/execution/execution_cancellation.rb +1 -1
  35. data/lib/phronomy/agent/execution/execution_coordinator.rb +63 -5
  36. data/lib/phronomy/agent/execution/execution_outcome_committer.rb +24 -4
  37. data/lib/phronomy/agent/execution/execution_registry.rb +5 -1
  38. data/lib/phronomy/agent/execution/initial_preparation.rb +10 -1
  39. data/lib/phronomy/agent/execution/invocation_actions.rb +1 -1
  40. data/lib/phronomy/agent/execution/invocation_transitions.rb +4 -4
  41. data/lib/phronomy/agent/execution/iteration_budget.rb +35 -0
  42. data/lib/phronomy/agent/execution/runtime_record_encoder.rb +3 -0
  43. data/lib/phronomy/agent/execution_observation.rb +5 -5
  44. data/lib/phronomy/agent/lifecycle/scope.rb +33 -23
  45. data/lib/phronomy/agent/lifecycle/scope_cleanup_error.rb +4 -2
  46. data/lib/phronomy/agent/output_contract.rb +64 -0
  47. data/lib/phronomy/agent/output_error.rb +53 -0
  48. data/lib/phronomy/agent/recovery/recovery_coordinator/continuation.rb +3 -3
  49. data/lib/phronomy/agent/recovery/recovery_coordinator/installation.rb +1 -0
  50. data/lib/phronomy/agent/recovery/recovery_coordinator.rb +1 -1
  51. data/lib/phronomy/agent/recovery/recovery_support.rb +5 -1
  52. data/lib/phronomy/agent/runtime_binding/engine_session_builder.rb +2 -1
  53. data/lib/phronomy/agent/runtime_input.rb +15 -4
  54. data/lib/phronomy/agent/saved_context_reader.rb +2 -1
  55. data/lib/phronomy/agent/store.rb +10 -2
  56. data/lib/phronomy/common/values/immutable.rb +33 -0
  57. data/lib/phronomy/context/assembly.rb +7 -4
  58. data/lib/phronomy/embeddings/backends/ruby_llm_embeddings.rb +3 -1
  59. data/lib/phronomy/engine/fsm_session.rb +16 -1
  60. data/lib/phronomy/generation/generator_verifier/agent_operation.rb +28 -5
  61. data/lib/phronomy/generation/generator_verifier/agent_result_receiver.rb +14 -27
  62. data/lib/phronomy/generation/generator_verifier/approval.rb +30 -0
  63. data/lib/phronomy/generation/generator_verifier/cleanup_error.rb +15 -0
  64. data/lib/phronomy/generation/generator_verifier/invocation.rb +147 -0
  65. data/lib/phronomy/generation/generator_verifier/pipeline_state.rb +16 -0
  66. data/lib/phronomy/generation/generator_verifier/protocol.rb +55 -0
  67. data/lib/phronomy/generation/generator_verifier/result.rb +121 -0
  68. data/lib/phronomy/generation/generator_verifier/unaccepted_result_error.rb +14 -0
  69. data/lib/phronomy/generation/generator_verifier/workflow_builder.rb +13 -11
  70. data/lib/phronomy/generation/generator_verifier.rb +170 -85
  71. data/lib/phronomy/llm_adapter/backends/lm_studio.rb +139 -0
  72. data/lib/phronomy/llm_adapter/backends/ruby_llm.rb +134 -12
  73. data/lib/phronomy/llm_adapter/backends/structured_response_capture.rb +41 -0
  74. data/lib/phronomy/llm_adapter/message.rb +4 -0
  75. data/lib/phronomy/llm_adapter/request.rb +17 -2
  76. data/lib/phronomy/llm_adapter/response.rb +11 -4
  77. data/lib/phronomy/llm_adapter/structured_output_unsupported_error.rb +14 -0
  78. data/lib/phronomy/llm_adapter/transport_error.rb +4 -0
  79. data/lib/phronomy/multi_agent/shared_state.rb +1 -0
  80. data/lib/phronomy/output_parser/json_schema_parser.rb +113 -0
  81. data/lib/phronomy/output_parser/parse_error.rb +10 -1
  82. data/lib/phronomy/runtime_composition/agent_defaults.rb +4 -0
  83. data/lib/phronomy/tracing/automatic.rb +14 -8
  84. data/lib/phronomy/tracing/base.rb +2 -1
  85. data/lib/phronomy/tracing/langfuse_tracer.rb +3 -3
  86. data/lib/phronomy/tracing/observation.rb +2 -1
  87. data/lib/phronomy/tracing/open_telemetry_tracer.rb +3 -3
  88. data/lib/phronomy/version.rb +1 -1
  89. data/lib/phronomy.rb +1 -2
  90. data/scripts/api_snapshot.rb +3 -0
  91. data/scripts/migrate_generator_verifier_result.rb +18 -0
  92. data/sig/phronomy/agent/execution_contract.rbs +4 -3
  93. data/sig/phronomy/agent.rbs +20 -7
  94. data/sig/phronomy/extensions.rbs +8 -3
  95. data/sig/phronomy/generation/generator_verifier.rbs +70 -0
  96. data/sig/phronomy/llm_adapter/backends/lm_studio.rbs +8 -0
  97. data/sig/phronomy/llm_adapter/backends/ruby_llm.rbs +1 -0
  98. data/sig/phronomy/llm_adapter/values.rbs +8 -2
  99. data/sig/phronomy/tracing/observation.rbs +1 -1
  100. data/sig/phronomy.rbs +2 -0
  101. metadata +59 -8
  102. data/lib/phronomy/generation/generator_verifier/default_parser.rb +0 -27
  103. data/lib/phronomy/generation/low_confidence_error.rb +0 -14
  104. data/lib/phronomy/runtime_composition/generation_defaults.rb +0 -6
  105. data/sig/phronomy/generation/low_confidence_error.rbs +0 -6
@@ -6,107 +6,107 @@
6
6
  > [ADR-034](../../decisions/034-handoff-runner-coordination-ownership.md).
7
7
  > Handoff and HandoffPolicy remain in Agent at this stage.
8
8
 
9
- 作成日: 2026-09-07。設計承認日: 2026-09-06。
10
- 対象baseline: `5472116cd99a63ec27875024c955ea82be612d6b`。
11
- 承認済みADR-029/030/031とRC-01〜05に対する新規実装です。
12
- 旧Complete Durability overlay、既存の作業ZIP、synthetic fan-out executionは使用しません。
9
+ Created: 2026-09-07. Design approved: 2026-09-06.
10
+ Baseline: `5472116cd99a63ec27875024c955ea82be612d6b`.
11
+ This is a new implementation of the approved ADR-029/030/031 and RC-01 through RC-05.
12
+ It does not use the old Complete Durability overlay, existing work ZIPs, or synthetic fan-out executions.
13
13
 
14
- ## 実装範囲
14
+ ## Implementation scope
15
15
 
16
- | 対象 | 実装した動作 |
16
+ | Area | Implemented behavior |
17
17
  |---|---|
18
- | Persistence | root/transaction viewともに8 repository。新しい3 recordはcurrent format `0.1`。Backendはopaque DurableRecordと明示的なidentity/revision/index metadataを扱う |
19
- | Handoff | Agent-domain APIへ移設。Source terminal・Context・exact Target予約・責務移転を同じtransactionで保存。Target terminalとrouting安定化も同一transaction |
20
- | Orchestrator | 既存parent AgentExecutionのstatic subagent Toolにchild ID/input/knowledge/config/outcomeを保存。直接の`dispatch_parallel`/`fan_out`にはsynthetic parentを作らない |
21
- | Team | TeamRoot/TeamExecution、task、worker slot、exact assignment/outcomeをCASで保存。coordinator/workerは既存Agent engineを使用。スケジューリングは既存の逐次方式 |
22
- | Team内部操作 | 保存済みのauthorized Tool batchをProvider順に適用。各`tool_invocation_id`の結果を保持し、`enqueue_task`/`finalize`を自動照合 |
23
- | Aggregate | pure/replay-safeな計算。canonical JSON結果またはエラーをterminal commit。保存前のクラッシュでは再計算可能、保存済みterminalでは再計算しない |
24
- | Runtime | Teamのprocess-local所有・admission・drainを追加。新しいTeam FSM/Workflow engineは追加しない |
25
- | Recovery | framework-owned操作はexact factから再開。外部Toolと混在したbatchでは外部の事実だけを既存Recovery APIで解決する |
26
- | 終了・削除 | exact子のcancel/reconciliation情報を保持。idle main Agentの`purge!`はHandoff anchorも同時削除。未完了turnのanchor削除は拒否 |
27
-
28
- Handoff graphは同じPersistence **instance**を使います。元main Agent IDがrouting anchorです。
29
- 保存済みContextを新しいpolicyで再投影せず、保存済みworker割当を現在のschedulerで選び直しません。
30
- RuntimeのClass/Proc、listener、Task、CancellationTokenは永続化しません。
31
-
32
- ## 公開経路
33
-
34
- | 目的 | API / 返却値 |
18
+ | Persistence | Eight repositories in both root and transaction views; the three new records use current format `0.1`. Backend handles opaque DurableRecords and explicit identity/revision/index metadata |
19
+ | Handoff | Moved to the Agent-domain API. Source terminal state, Context, exact Target reservation, and responsibility transfer are persisted in one transaction. Target terminal state and routing stabilization also share one transaction |
20
+ | Orchestrator | Stores child ID/input/knowledge/config/outcome for static subagent Tools in the existing parent AgentExecution. Direct `dispatch_parallel`/`fan_out` calls do not create synthetic parents |
21
+ | Team | Persists TeamRoot/TeamExecution, tasks, worker slots, and exact assignments/outcomes using CAS. Coordinators/workers use the existing Agent engine. Scheduling retains the existing sequential approach |
22
+ | Internal Team operations | Applies persisted authorized Tool batches in Provider order. Retains the result of each `tool_invocation_id` and automatically reconciles `enqueue_task`/`finalize` |
23
+ | Aggregate | Pure/replay-safe computation. Commits canonical JSON results or errors as terminal outcomes. Recalculation is possible after a crash before persistence, but not for a persisted terminal outcome |
24
+ | Runtime | Adds process-local Team ownership, admission, and draining. Does not add a new Team FSM/Workflow engine |
25
+ | Recovery | Resumes framework-owned operations from exact facts. In batches mixed with external Tools, only external facts are resolved through the existing Recovery API |
26
+ | Termination and deletion | Retains cancellation/reconciliation information for exact children. `purge!` on an idle main Agent also deletes the Handoff anchor; deleting an anchor for an incomplete turn is rejected |
27
+
28
+ A Handoff graph uses the same Persistence **instance**. The original main Agent ID is the routing anchor.
29
+ Persisted Context is not reprojected using a new policy, and persisted worker assignments are not reselected using the current scheduler.
30
+ Runtime Classes/Procs, listeners, Tasks, and CancellationTokens are not persisted.
31
+
32
+ ## Public entry points
33
+
34
+ | Purpose | API / return value |
35
35
  |---|---|
36
- | Agent結果参照 | `store.execution_result(execution_id)`。owner、status、phase、result/errorと参照IDの凍結Hash |
37
- | Handoff結果参照 | `store.handoff_result(source_execution_id)`。そのturnのexact Targetまで辿る。graph/Agent hydration不要 |
38
- | Agent実行発見 | `store.list_executions(agent_id, after: nil, limit: 100)`。immutable execution records。active/terminal双方 |
39
- | Team結果参照 | `store.team_execution_result(run_id)` または `team.result(run_id)` |
40
- | Team実行発見 | `store.list_team_executions(team_id, after: nil, limit: 100)` または `team.executions(...)` |
41
- | Handoffの実行/復旧 | `Agent::HandoffRunner.new(main_agent:, handoffs:).invoke(input, config: {})`。未完了turnがあれば保存済み予約・入力を使用 |
42
- | static childの復旧 | `Orchestrator#resume(execution_id, config: {})` |
43
- | Teamの作成/復旧 | `team_definition id:, version:`、`create(team_id:, persistence:)`、`load(team_id, persistence:, on_event:)`、`resume(run_id)` |
44
- | 明示cancel | `team.cancel(run_id)` / `handoff_runner.cancel(execution_id)`。Orchestratorを含むAgentの既存操作は`config[:cancellation_token]` |
45
-
46
- 一覧順はsemantic IDの辞書順、`after`は排他的ID cursor、`limit`は正の整数です。
47
- 時刻順やリクエスト一意対応を意味しません。Applicationは候補を自身の相関情報と照合します。
48
-
49
- Agentの結果statusは既存Symbol、Teamの結果statusはcanonical Stringです。
50
- Teamのdefault aggregate結果もcanonical JSONのためHash keyはString、errorは例外オブジェクトではなく
51
- `class`/`message`等のデータです。aggregateに渡すassignmentのトップレベルとtask keyはSymbolです。
52
-
53
- Handoffの未開始Target予約は`status: :active, phase: :target_pending, reserved: true`で識別します。
54
- 明示cancelした未開始Targetは予約IDを保持し、過去turnの結果に後続turnを代用しません。
55
- 不存在は`Persistence::NotFoundError`、読み取り/復号失敗はそのエラーを返します。
56
- 削除された結果を復元する機能や無期限retentionは追加していません。
57
-
58
- `Team.load`はTeam factsのhydrationのみです。子の実行/復旧は`resume`で開始します。
59
- Agentの`load`は既存Recovery契約を維持します。結果だけが必要なら上記Persistence参照APIを使います。
60
- Teamの`on_event`はhidden Agentsへ渡し、必要なRecovery/approval eventを受け取ります。
61
- `Team.stream`はcommit済みassignmentのRuntime通知です。新しい通知配送保証はありません。
62
-
63
- ## RC対応表
64
-
65
- パスはリポジトリroot相対です。共通の追加障害specは
66
- `spec/phronomy/multi_agent/durable_coordination_spec.rb`です。
67
-
68
- | 要件 | 主な実装 | 検証根拠 |
36
+ | Agent result access | `store.execution_result(execution_id)`; a frozen Hash containing owner, status, phase, result/error, and reference IDs |
37
+ | Handoff result access | `store.handoff_result(source_execution_id)`; follows the exact Target of that turn. No graph/Agent hydration is required |
38
+ | Agent execution discovery | `store.list_executions(agent_id, after: nil, limit: 100)`; immutable execution records, both active and terminal |
39
+ | Team result access | `store.team_execution_result(run_id)` or `team.result(run_id)` |
40
+ | Team execution discovery | `store.list_team_executions(team_id, after: nil, limit: 100)` or `team.executions(...)` |
41
+ | Handoff execution/recovery | `Agent::HandoffRunner.new(main_agent:, handoffs:).invoke(input, config: {})`; uses the persisted reservation and input if an incomplete turn exists |
42
+ | Static child recovery | `Orchestrator#resume(execution_id, config: {})` |
43
+ | Team creation/recovery | `team_definition id:, version:`, `create(team_id:, persistence:)`, `load(team_id, persistence:, on_event:)`, `resume(run_id)` |
44
+ | Explicit cancellation | `team.cancel(run_id)` / `handoff_runner.cancel(execution_id)`; existing Agent operations, including Orchestrator, use `config[:cancellation_token]` |
45
+
46
+ Lists are ordered lexicographically by semantic ID; `after` is an exclusive ID cursor, and `limit` is a positive integer.
47
+ This does not imply chronological ordering or unique correspondence to a request. Applications match candidates against their own correlation information.
48
+
49
+ Agent result status uses existing Symbols; Team result status uses canonical Strings.
50
+ The default Team aggregate result is also canonical JSON: Hash keys are Strings, and errors are data such as
51
+ `class`/`message`, not exception objects. Top-level assignment keys and task keys passed to aggregate are Symbols.
52
+
53
+ An unstarted Handoff Target reservation is identified by `status: :active, phase: :target_pending, reserved: true`.
54
+ Explicit cancellation of an unstarted Target preserves its reserved ID; a later turn never substitutes for the result of an earlier turn.
55
+ Absence produces `Persistence::NotFoundError`; read/decode failures produce their actual errors.
56
+ No facility to restore deleted results or retain them indefinitely has been added.
57
+
58
+ `Team.load` hydrates Team facts only. Child execution/recovery starts through `resume`.
59
+ Agent `load` retains its existing Recovery contract. Use the Persistence access APIs above when only results are needed.
60
+ Team's `on_event` is passed to hidden Agents to receive required Recovery/approval events.
61
+ `Team.stream` provides Runtime notifications of committed assignments; it adds no notification-delivery guarantee.
62
+
63
+ ## RC mapping
64
+
65
+ Paths are relative to the repository root. The shared additional fault specs are in
66
+ `spec/phronomy/multi_agent/durable_coordination_spec.rb`.
67
+
68
+ | Requirement | Main implementation | Validation evidence |
69
69
  |---|---|---|
70
- | RC-01-A/B | `Persistence#execution_result` / `list_executions`、Team対応API | owner未loadの再構築環境でactive/terminal候補・ページング・結果を読み、Provider/所有登録を増やさない |
71
- | RC-01-C | `Persistence#handoff_result`、読み取り専用materialization | graph/ownerなしの予約参照、read障害、purge済み結果のNotFound。callback政策は既存`stream_callback_error_policy_spec.rb`でも検証 |
72
- | RC-02-A | Agent準備の既存F1 readback、`reconcile_terminal_error`、Team `admit`/`update` | Teamの各revision commit直後の応答喪失、Source移転の応答喪失、確定worker/child outcomeの再利用 |
73
- | RC-02-B/C | exact予約照合・atomic admission/CAS・bounded readback | read失敗と不存在を区別。Team admission後のreadback失敗ではdispatchなし。Backend契約はstale CAS、active重複、8 repository rollbackを検証 |
74
- | RC-03-A | Team definition snapshot、static child slot定義、Handoff graph/Target照合 | worker version不一致とTarget/graph不足でfail closed。既存Handoff統合specで別Persistenceを拒否 |
75
- | RC-03-B | immutable Context/input/knowledge/assignment/outcome | 現在policyを変更しても保存済みHandoffContextを使用。worker結果・static child結果・knowledge metadataを保持 |
76
- | RC-04-A | 既存Task待機/Runtime shutdown契約 | `task_spec.rb`、`agent/acs16_task_quiescence_spec.rb`、Runtime/admission specs。Runtime再構築テストで暗黙cancelを追加しない |
77
- | RC-04-B/C/D | Team cancel flag、Handoff exact cancellation、Agent子admission条件、既存terminal barrier | 予約worker/Targetを起動せずID保持。外部fact待ちのactive childを持つparentはactiveのままcancel情報を保存し再起動後も保持。既存admission/physical-quiescence specsと合わせて確認 |
78
- | RC-04-E | Source terminal linkとTarget cancel。責務はTargetのまま | transfer後cancel→再起動→後続turnでもSourceへ戻らず、過去の予約IDとcancel結果を維持 |
79
- | RC-05 | callback/外部効果とsemantic recordの分離 | mixed external/framework Tool batchは外部factだけresolveし、完了childを再実行しない。内部`finalize`の事実をApplicationへ問い合わせない |
80
-
81
- `lib/phronomy/testing/persistence_contract/coordination_repositories.rb`の新shared examplesは、
82
- 外部backendにも公開される`phronomy/testing/persistence_contract`経由で実行されます。
83
- raw SPI/API snapshot/RBS、旧Handoff定数削除、EventLoop単一writer/causal barrier、
84
- logical-operation tracingの既存guardも維持しています。
85
-
86
- ## 検証の範囲と限界
87
-
88
- 実測環境はRuby 3.3.6。使用gemは配布ZIPの`verification/gems.txt`に記録します。
89
- 配布対象に対する実測コマンド、結果、ログは同梱の検証記録を参照してください。
90
-
91
- - 通常RSpecは外部LLMへの接続を要するintegration tagを除外します。
92
- - 選択したHandoff/Orchestrator/Team integrationはWebMockで実行します。
93
- - 追加F4テストは、commit済みDurableRecordを複製し、新Backendと新Runtimeで復旧するモデルです。
94
- これは実OSプロセスの強制終了や物理ディスクへのfsyncの実証ではありません。
95
- - 実LLM、Redis、PostgreSQL、OpenTelemetry等を使う別スイートは今回の実測対象外です。
96
- optional依存/service未設定59件と既存obsolete2件の計61件がpendingです。
97
- - 外部backendのF4保存性と複数processの排他は、そのbackendとdeploymentの契約に依存します。
98
- InMemory自身はプロセス終了後の保存を保証しません。
99
- - semantic cancellationは外部効果のrollbackではありません。TokenオブジェクトはRuntime-onlyです。
100
- durable cancel flag/factがcommitした後は保持し、未確定外部処理は既存Recoveryで照合します。
101
- fact/approval待ちをfailedにして子を忘れず、`ExecutionRehydrationRequiredError`で制御を返します。
102
-
103
- Frameworkが実施するのは、確定outcomeの再利用と未完了実行の同じsemantic identityでの復旧です。
104
- callback outbox/ACK、global generic class registry、Proc/Class永続化、distributed transaction、
105
- Team専用の第二execution engineは追加していません。
106
-
107
- ## パッケージ
108
-
109
- 完全版ファイルと削除manifestを同梱します。baseline/適用前後のハッシュを検査して適用します。
110
- 新しいClassの配置をZeitwerkの命名規則に合わせ、旧overlayのdecorator ignoreは不要です。
111
- 旧`MultiAgent::Handoff*`、`Runner`、`Coordinator`、`CoordinationState`の実装を削除します。
112
- 適用・依存関係・VERIFY手順は配布rootの`README_APPLY_JA.md`を参照してください。
70
+ | RC-01-A/B | `Persistence#execution_result` / `list_executions`, and corresponding Team APIs | Reads active/terminal candidates, pagination, and results in a reconstructed environment without loading the owner; does not invoke Providers or add ownership registrations |
71
+ | RC-01-C | `Persistence#handoff_result`, read-only materialization | Reservation access without graph/owner, read failures, and NotFound for purged results. Callback policy is also covered by the existing `stream_callback_error_policy_spec.rb` |
72
+ | RC-02-A | Existing F1 readback during Agent preparation, `reconcile_terminal_error`, Team `admit`/`update` | Lost acknowledgements immediately after each Team revision commit and Source transfer; reuse of committed worker/child outcomes |
73
+ | RC-02-B/C | Exact reservation reconciliation, atomic admission/CAS, bounded readback | Distinguishes read failure from absence. No dispatch after a failed readback following Team admission. Backend contracts check stale CAS, duplicate active records, and rollback across eight repositories |
74
+ | RC-03-A | Team definition snapshots, static child slot definitions, Handoff graph/Target matching | Fails closed on worker-version mismatch or missing Target/graph. Existing Handoff integration specs reject a different Persistence instance |
75
+ | RC-03-B | Immutable Context/input/knowledge/assignment/outcome | Uses persisted HandoffContext even when the current policy changes. Preserves worker results, static child results, and knowledge metadata |
76
+ | RC-04-A | Existing Task waiting/Runtime shutdown contracts | `task_spec.rb`, `agent/acs16_task_quiescence_spec.rb`, and Runtime/admission specs. Runtime reconstruction tests introduce no implicit cancellation |
77
+ | RC-04-B/C/D | Team cancellation flags, exact Handoff cancellation, Agent child-admission conditions, existing terminal barriers | Preserves reserved worker/Target IDs without starting them. A parent with an active child awaiting external facts remains active, persists cancellation information, and retains it after restart. Checked together with existing admission/physical-quiescence specs |
78
+ | RC-04-E | Source terminal link and Target cancellation; responsibility remains with Target | Cancellation after transfer, restart, and a later turn do not return responsibility to Source; historical reserved IDs and cancellation results are preserved |
79
+ | RC-05 | Separation of callbacks/external effects from semantic records | Mixed external/framework Tool batches resolve only external facts and do not rerun completed children. Application is not asked to determine facts about internal `finalize` |
80
+
81
+ The new shared examples in `lib/phronomy/testing/persistence_contract/coordination_repositories.rb`
82
+ run through `phronomy/testing/persistence_contract`, which is also exposed to external backends.
83
+ Existing guards for raw SPI/API snapshots/RBS, removal of old Handoff constants, the EventLoop single writer/causal barrier,
84
+ and logical-operation tracing are preserved.
85
+
86
+ ## Validation scope and limitations
87
+
88
+ The measured environment is Ruby 3.3.6. Gem versions are recorded in the distribution ZIP's `verification/gems.txt`.
89
+ See the accompanying verification records for commands, results, and logs measured against the distributed files.
90
+
91
+ - Ordinary RSpec runs exclude integration tags requiring connections to external LLMs.
92
+ - Selected Handoff/Orchestrator/Team integration tests run with WebMock.
93
+ - Added F4 tests model recovery by copying committed DurableRecords and using a new Backend and Runtime.
94
+ They do not demonstrate forced termination of a real OS process or fsync to physical storage.
95
+ - Separate suites using live LLMs, Redis, PostgreSQL, OpenTelemetry, and similar dependencies are outside this measurement.
96
+ There are 61 pending cases: 59 with optional dependencies/services unconfigured and two existing obsolete cases.
97
+ - F4 durability and exclusion across multiple processes for external backends depend on the backend and deployment contracts.
98
+ InMemory itself does not guarantee persistence after process termination.
99
+ - Semantic cancellation does not roll back external effects. Token objects are Runtime-only.
100
+ Committed durable cancellation flags/facts are retained, and uncertain external operations are reconciled through existing Recovery.
101
+ Waiting for facts/approval is not converted into failure that forgets a child; control returns through `ExecutionRehydrationRequiredError`.
102
+
103
+ The framework reuses committed outcomes and recovers incomplete executions with the same semantic identity.
104
+ It adds no callback outbox/ACK, global generic class registry, Proc/Class persistence, distributed transaction,
105
+ or second execution engine dedicated to Team.
106
+
107
+ ## Package
108
+
109
+ The package includes complete files and a deletion manifest. Application checks the baseline and pre/post-application hashes.
110
+ New Class locations follow Zeitwerk naming conventions; the old overlay's decorator ignore is unnecessary.
111
+ The old `MultiAgent::Handoff*`, `Runner`, `Coordinator`, and `CoordinationState` implementations are removed.
112
+ See `README_APPLY_JA.md` at the distribution root for application, dependencies, and VERIFY procedures.
@@ -1,179 +1,178 @@
1
- # V2復旧契約の明確化 — 承認済み追補
1
+ # V2 Recovery Contract Clarifications - Approved Addendum
2
2
 
3
- 更新日: 2026-09-06 / 文書改訂: V2 revision 2
3
+ Updated: 2026-09-06 / Document revision: V2 revision 2
4
4
 
5
- ## 0. 位置づけ
5
+ ## 0. Purpose and authority
6
6
 
7
- 本追補は、V2への追加提案5点に対するユーザーの承認を反映した規範的な実装契約である。
8
- ADR-029/030/031およびImplementation Design V2と合わせて適用する。
9
- 元のV2責務境界を維持し、結果参照・保存成否不明・wiring互換性・キャンセル・保証表現を明確化する。
10
- 同じ論点の旧記述と差がある場合、本改訂の明確化を優先する。それ以外の既存ADRの契約を置き換えない。
7
+ This addendum is a normative implementation contract reflecting the user's approval of five additions to V2.
8
+ Apply it together with ADR-029/030/031 and Implementation Design V2.
9
+ It preserves the original V2 responsibility boundaries while clarifying result access, unknown persistence outcomes, wiring compatibility, cancellation, and guarantee wording.
10
+ Where an earlier statement on the same issue differs, these clarifications take precedence. They do not otherwise replace existing ADR contracts.
11
11
 
12
- 対象baselineは `5472116cd99a63ec27875024c955ea82be612d6b` のままとする。
13
- これは仕様の承認であり、実装完了やテスト成功を意味しない。
14
- 公開メソッド名・例外名・既存キャンセル実装への対応付けはbaseline確認後に確定する。
15
- 本書の要件IDは追跡用の文書上のIDであり、新しいRuntime ID・永続ID・APIではない。
12
+ The baseline remains `5472116cd99a63ec27875024c955ea82be612d6b`.
13
+ This is specification approval, not evidence of implementation completion or successful tests.
14
+ Public method names, exception names, and mappings to the existing cancellation implementation will be finalized after inspecting the baseline.
15
+ Requirement IDs in this document are for traceability; they are not new Runtime IDs, persistent IDs, or APIs.
16
16
 
17
- ## 1. RC-01 — 確定結果の参照と実行の発見
17
+ ## 1. RC-01: Accessing final results and discovering executions
18
18
 
19
- ### 必須契約
19
+ ### Required contract
20
20
 
21
- - Applicationはsemantic execution IDを指定して、owner identity、実行状態、確定結果またはエラーを読み取り専用で取得できる。
22
- - 対象はAgentExecutionとTeamExecution。Handoff/Orchestratorは既存のrouting anchor・parent execution・予約済みchild/Target IDを使用し、参照のための新しい実行entityを作らない。
23
- - Handoffでは指定した実行に結び付いたTarget outcomeを識別する。後続ターンの「最新のactive Agentの結果」を過去の呼び出し結果として代用しない。
24
- - admissionがcommitした後、Applicationが実行IDを受け取る前に停止する場合に備え、既知のagent_id/team_idから実行候補を発見できる公開経路を用意する。activeだけでなくterminalとなった実行も対象とする。
25
- - 結果参照・候補列挙はProvider/Tool起動、Agent continuation、callback再配送、ownership取得を伴わない。復旧を起動する操作とは区別する。
26
- - 結果が未確定、不存在、参照不能を区別する。Persistence障害やresult materialization失敗を「実行なし」「処理中」「成功で結果なし」に変換しない。
27
- - 基本状態と確定結果は保存済みrecordから取得する。継続実行に必要なgraph/Procを結果参照だけのために要求しない。既存codec/schemaの互換性要件は維持する。
21
+ - Application can obtain the owner identity, execution state, and committed result or error by semantic execution ID through read-only access.
22
+ - This covers AgentExecution and TeamExecution. Handoff/Orchestrator use existing routing anchors, parent executions, and reserved child/Target IDs; they do not create a new execution entity just for result access.
23
+ - Handoff identifies the Target outcome associated with the specified execution. The latest active Agent result from a later turn must not substitute for an earlier invocation's result.
24
+ - Provide a public path to discover execution candidates from a known agent_id/team_id, covering an interruption after admission commits but before Application receives the execution ID. Include terminal as well as active executions.
25
+ - Result access and candidate enumeration must not invoke Providers/Tools, continue Agent execution, redeliver callbacks, or acquire ownership. Distinguish these operations from operations that initiate recovery.
26
+ - Distinguish an unresolved result, absence, and inability to read. Do not translate Persistence failures or result-materialization failures into no execution, in progress, or successful completion without a result.
27
+ - Read basic state and committed results from persisted records. Do not require the graph/Procs needed for continuation merely to access results. Preserve existing codec/schema compatibility requirements.
28
28
 
29
- ### 範囲の制限
29
+ ### Scope limitations
30
30
 
31
- 候補の発見は、Applicationのリクエストとの自動一意対応やsubmissionのexactly-onceを保証しない。
32
- 複数候補がある場合、時刻が最新という理由だけで対象と断定せず、Applicationが保持する相関情報と照合する。
33
- Application固有のrequest ID・outbox・dedupはApplication責務であり、参照要件だけを理由に汎用idempotency基盤を追加しない。
31
+ Candidate discovery does not guarantee automatic unique correspondence to an Application request or exactly-once submission.
32
+ When multiple candidates exist, do not select one merely because it has the latest timestamp; Application must match its own correlation information.
33
+ Application-specific request IDs, outboxes, and deduplication remain Application responsibilities. Do not add generic idempotency infrastructure solely to meet result-access requirements.
34
34
 
35
- 既存のretention/delete契約を維持する。削除済み結果の復元、無期限保存、新しい履歴管理サービスは要求しない。
36
- 一覧の範囲・順序・ページング等は既存API/SPIを確認して最小限の公開経路に対応付ける。
37
- 既存APIで満たせない箇所のみ追加し、内部repositoryをそのまま公開契約として露出させない。
35
+ Preserve existing retention/deletion contracts. Restoring deleted results, indefinite retention, and a new history-management service are not required.
36
+ Inspect existing API/SPI behavior and map list scope, ordering, pagination, and similar concerns to the smallest necessary public path.
37
+ Add only capabilities that existing APIs cannot provide; do not expose internal repositories directly as the public contract.
38
38
 
39
- ## 2. RC-02 — 不存在・競合・保存成否不明の区別
39
+ ## 2. RC-02: Distinguishing absence, conflicts, and unknown persistence outcomes
40
40
 
41
- ### 共通判断規則
41
+ ### Shared decision rules
42
42
 
43
- | 観測 | 許可する判断・動作 |
43
+ | Observation | Permitted decision or action |
44
44
  |---|---|
45
- | 正常なauthoritative readで予約済みIDの不存在を確認 | 親の最新状態・予約・キャンセル条件を確認し、同じ予約済みIDでadmissionを試みる |
46
- | exact IDのnonterminalを確認 | 同じ実行の既存Recovery契約へ進む |
47
- | exact IDのterminalを確認 | 保存済みoutcomeを利用する。replacement executionを作らない |
48
- | read timeout / I/O failure / record decode failure | 不存在とみなさず、状態を保持して既存のerror/retry契約へ進む |
49
- | write応答消失などでcommit成否不明 | 同じoperation identity・予約済みIDを保持してreadbackする。確認前に別IDや別assignmentを作らない |
50
- | 明確なrevision/admission競合 | 最新のauthoritative factsを再読し、予約・owner・入力との整合を検証する。競合を単純な成功とみなさない |
45
+ | A successful authoritative read confirms that the reserved ID is absent | Check the parent's latest state, reservation, and cancellation conditions, then attempt admission with the same reserved ID |
46
+ | The exact ID is confirmed nonterminal | Follow the existing Recovery contract for the same execution |
47
+ | The exact ID is confirmed terminal | Use the persisted outcome; do not create a replacement execution |
48
+ | Read timeout / I/O failure / record decode failure | Preserve state and follow existing error/retry contracts; do not treat the failure as absence |
49
+ | Commit outcome is unknown, for example after a lost write acknowledgement | Retain the same operation identity and reserved ID for readback; do not create another ID or assignment before confirmation |
50
+ | A definite revision/admission conflict | Reread the latest authoritative facts and validate consistency with the reservation, owner, and input; do not treat the conflict as success by itself |
51
51
 
52
- readbackが利用する整合性は、admission/CASを保護する既存Persistence契約を満たすこと。
53
- cache/indexの不一致や読み取り障害を新規admissionの根拠にしない。
54
- 不存在確認とadmissionの間の競合は既存のatomic admission/CASで防ぐ。
55
- 外部semantic workはadmissionの成功が確定した後にのみ開始する。
52
+ Readback consistency must satisfy the existing Persistence contract that protects admission/CAS.
53
+ Cache/index discrepancies and read failures must not justify new admission.
54
+ Use existing atomic admission/CAS to prevent races between confirming absence and admission.
55
+ Start external semantic work only after admission success is confirmed.
56
56
 
57
- 適用対象: Source Handoff transfer、Target admission/stabilization、parent child reservation/outcome、
58
- Team admission/enqueue/finalize/assignment/worker outcome/terminal。
59
- Team-owned enqueue/finalizeは既存方針のstable tool_invocation_idによるfact照合を維持する。
57
+ Scope: Source Handoff transfer, Target admission/stabilization, parent child reservation/outcome,
58
+ and Team admission/enqueue/finalize/assignment/worker outcome/terminal state.
59
+ Team-owned enqueue/finalize retain the existing policy of fact reconciliation using a stable tool_invocation_id.
60
60
 
61
- 成否不明を解決できない間は、確定していないローカル推測で次のsemantic処理へ進まない。
62
- 無期限に同期待機せず、既存のPersistence error/retry経路へ制御を返す。
63
- Applicationにストレージ上の事実を創作させるmanual resolutionは追加しない。
64
- 既存Agent/Persistenceの成否不明処理を再利用し、coordination専用の第二transaction engineを作らない。
61
+ While an unknown outcome remains unresolved, do not advance to the next semantic operation based on unconfirmed local assumptions.
62
+ Return control through existing Persistence error/retry paths instead of waiting synchronously without a bound.
63
+ Do not add manual resolution that requires Application to invent storage facts.
64
+ Reuse existing Agent/Persistence handling of unknown outcomes; do not create a second transaction engine dedicated to coordination.
65
65
 
66
- ## 3. RC-03 — 復旧時wiringの最低互換性
66
+ ## 3. RC-03: Minimum wiring compatibility for recovery
67
67
 
68
- ### 照合対象
68
+ ### Required checks
69
69
 
70
- | 対象 | 継続前に必要な照合 |
70
+ | Subject | Checks required before continuation |
71
71
  |---|---|
72
- | Agent/Team定義 | 保存されたdefinition id/versionと現在の定義。既存の明示的な互換・移行契約がなければ一致を要求 |
73
- | Orchestrator child | 保存済みslotとstatic subagent登録から解決した定義、予約済みagent_id/execution_id、ownerとの一致 |
74
- | Handoff | original main anchor、保存済みactive/Target ID、必要なgraph接続、同じPersistence instance/domain |
75
- | Team worker/coordinator | Team lineage、保存済みworker slotと定義、予約済みAgent/実行ID、保存済みassignmentとの一致 |
72
+ | Agent/Team definition | Compare the persisted definition id/version with the current definition; require equality unless an existing explicit compatibility/migration contract permits otherwise |
73
+ | Orchestrator child | Match the persisted slot, the definition resolved from static subagent registration, reserved agent_id/execution_id, and owner |
74
+ | Handoff | Match the original main anchor, persisted active/Target IDs, required graph connections, and the same Persistence instance/domain |
75
+ | Team worker/coordinator | Match Team lineage, the persisted worker slot and definition, reserved Agent/execution IDs, and the persisted assignment |
76
76
 
77
- 必要な登録やTargetがない、定義が不一致、Persistence境界が異なる場合は、semantic workを開始せずfail closedとする。
78
- エラーから対象identityと不足・不整合の種類が分かるようにする。既存のconfiguration/rehydration error契約を使う。
79
- 結果の読み取りだけに不要な実行wiringを要求しない(RC-01)。
77
+ If a required registration or Target is missing, a definition is incompatible, or the Persistence boundary differs, fail closed without starting semantic work.
78
+ Use existing configuration/rehydration error contracts and make the affected identity and type of missing/inconsistent information clear from the error.
79
+ Do not require execution wiring unnecessary for read-only result access (RC-01).
80
80
 
81
- ### 確定済みfactの優先
81
+ ### Committed facts take precedence
82
82
 
83
- - 確定済みHandoffContextを現在のHandoffPolicyで再投影しない。
84
- - 確定済みchild input/configを現在のデフォルトで置き換えない。
85
- - 確定済みassignmentを現在のschedulerで選び直さない。
86
- - 確定済みchild/worker/final aggregate outcomeを再計算しない。
87
- - 未確定のscheduler/aggregateは既存V2のreplay-safe契約に従って再実行できる。保存済み入力に対する意味の互換性をApplicationが保つ。
83
+ - Do not reproject committed HandoffContext using the current HandoffPolicy.
84
+ - Do not replace committed child input/config with current defaults.
85
+ - Do not reselect committed assignments using the current scheduler.
86
+ - Do not recompute committed child/worker/final aggregate outcomes.
87
+ - Uncommitted scheduler/aggregate computations may rerun under the existing V2 replay-safe contract. Application must preserve semantic compatibility with the persisted inputs.
88
88
 
89
- Phronomyが検査できるのは宣言されたidentity/versionと構造であり、Rubyコードの意味の同一性ではない。
90
- 同じversionのまま非互換な実装に変更しないことはApplication責務。
91
- versionを上げるだけで旧実行の復旧が自動的に可能になるわけではなく、対応する定義または既存の明示的移行契約が必要。
92
- Proc/Classの永続化、ソースハッシュ、policy descriptor、global generic class registryは追加しない。
89
+ Phronomy can check declared identity/version and structure, not semantic equivalence of Ruby code.
90
+ Application is responsible for not introducing incompatible implementations under an unchanged version.
91
+ Increasing a version alone does not automatically enable recovery of old executions; the corresponding definition or an existing explicit migration contract is required.
92
+ Do not add Proc/Class persistence, source hashes, policy descriptors, or a global generic class registry.
93
93
 
94
- ## 4. RC-04 — 待機終了とsemantic cancellation
94
+ ## 4. RC-04: Ending observation and semantic cancellation
95
95
 
96
- ### 操作の区別
96
+ ### Distinguish operations
97
97
 
98
- | 操作・状態 | 契約 |
98
+ | Operation or state | Contract |
99
99
  |---|---|
100
- | Applicationが待機をやめる・接続が切れる・観測timeout | それだけではdurable executionへのsemantic cancellationとしない |
101
- | Runtime shutdown / process loss | それだけではsemantic cancellationを確定しない。既存shutdown/draining契約で実行を保存・復旧可能に保つ |
102
- | 明示的なsemantic cancellation要求 | 既存Agent cancellation契約に従い、対象owner/runと予約済み実行に対応付ける |
103
- | recovery resolution / approval待ち | failureや自動cancelへ変換せず、既存V2のrehydration経路を維持する |
100
+ | Application stops waiting, a connection is lost, or observation times out | This alone is not semantic cancellation of the durable execution |
101
+ | Runtime shutdown / process loss | This alone does not establish semantic cancellation; preserve execution and recoverability under existing shutdown/draining contracts |
102
+ | Explicit semantic cancellation request | Map it to the target owner/run and reserved executions under the existing Agent cancellation contract |
103
+ | Waiting for recovery resolution / approval | Preserve existing V2 rehydration paths; do not convert waiting into failure or automatic cancellation |
104
104
 
105
- 既存Taskの明示cancelなど、もともとsemantic cancellationを要求するAPIはその契約を維持する。
106
- 単なる観測終了と同じ操作として扱わない。具体的な公開API対応はbaseline確認時に記載する。
105
+ APIs that already request semantic cancellation, such as explicit cancellation of an existing Task, retain that contract.
106
+ Do not treat them as equivalent to merely ending observation. Record concrete public API mappings when inspecting the baseline.
107
107
 
108
- ### 子実行への適用
108
+ ### Applying cancellation to child executions
109
109
 
110
- | 子の状態 | 親runへのsemantic cancellationが受理された場合 |
110
+ | Child state | Behavior after semantic cancellation of the parent run is accepted |
111
111
  |---|---|
112
- | 予約済み・未開始 | 現在の親runに属する新規dispatchを止める。予約情報を失わず、キャンセルのために子を起動しない |
113
- | 実行中・admission競合中 | exact reserved IDの状態を確認し、既存Agent cancellationを適用する。単にローカルTaskを破棄して処理済みとみなさない |
114
- | terminal | durable outcomeを維持する。過去の成功・失敗をキャンセル済みに書き換えたり補償再実行したりしない |
112
+ | Reserved, not started | Stop new dispatch owned by the current parent run; retain reservation information and do not start a child just to cancel it |
113
+ | Running, or racing with admission | Check the exact reserved ID's state and apply existing Agent cancellation; discarding a local Task alone does not complete cancellation handling |
114
+ | Terminal | Preserve the durable outcome; do not rewrite historical success/failure as cancellation or rerun it for compensation |
115
115
 
116
- 親cancelと子admissionの競合は、最新の親run状態・既存admission契約で処理する。
117
- 既にadmitされた子は実行中の規則で照合し、別IDの子を作らない。
118
- 親terminalizationと子settlementの順序は既存Agentのcancel/terminal barrier契約へ対応付ける。
119
- 未完了の子がある場合、そのexact IDと必要なcancel/reconciliation状態を失ってはならない。
120
- restart後にも既存の復旧経路から対象を発見できることを必須とし、未対応の子を忘れたまま親の全処理完了を主張しない。
121
- 新規の公開terminal statusや別のcancel schedulerを本追補だけで追加しない。
116
+ Handle races between parent cancellation and child admission using the latest parent-run state and existing admission contracts.
117
+ Reconcile an already admitted child under the running-child rules; do not create a child with a different ID.
118
+ Map the ordering of parent terminalization and child settlement to existing Agent cancellation/terminal-barrier contracts.
119
+ If a child is incomplete, retain its exact ID and required cancellation/reconciliation state.
120
+ Require rediscovery through existing recovery paths after restart; do not claim that all parent work is complete while forgetting an unhandled child.
121
+ Do not add a new public terminal status or a separate cancellation scheduler solely for this addendum.
122
122
 
123
- キャンセルの範囲は当該親runが所有する子に限定し、共有Agentの別実行・後続Team runへ波及させない。
124
- HandoffのSourceはtransfer commit後にhanded_offであり、後からSourceをcancelしてtransferを取り消したことにしない。
125
- 現在のHandoff turnに対する明示cancelは、保存済みrouting/予約から該当Target実行へ対応付ける。
126
- 観測終了・cancelを理由にactive responsibilityを元のmain Agentへ戻さない。
123
+ Limit cancellation to children owned by the affected parent run; it must not affect other executions of a shared Agent or later Team runs.
124
+ A Handoff Source is handed_off after transfer commits. Cancelling Source later must not be treated as reversing the transfer.
125
+ Map explicit cancellation of the current Handoff turn to the relevant Target execution using persisted routing/reservations.
126
+ Do not return active responsibility to the original main Agent because observation ends or cancellation occurs.
127
127
 
128
- 外部Provider/Toolのcancelは副作用の取り消しを保証しない。成否不明は既存Agent Recovery契約で解決する。
129
- 既存機構で上記の順序・再発見を満たせず第二実行エンジン等が必要なら、Stop Conditionとして報告する。
128
+ Cancellation of external Providers/Tools does not guarantee reversal of side effects. Resolve uncertain outcomes through the existing Agent Recovery contract.
129
+ If existing mechanisms cannot satisfy the required ordering and rediscovery without a second execution engine or similar addition, report a Stop Condition.
130
130
 
131
- ## 5. RC-05 — durability保証の統一表現
131
+ ## 5. RC-05: Consistent durability guarantee wording
132
132
 
133
- > 確定済みのdurable outcomeは再利用する。未完了の実行は同じsemantic identityで復旧する。
134
- > 外部Provider/Tool処理の成否不明は既存Agent Recovery契約に従って解決する。
133
+ > Reuse committed durable outcomes. Recover incomplete executions with the same semantic identity.
134
+ > Resolve uncertain outcomes of external Provider/Tool operations under the existing Agent Recovery contract.
135
135
 
136
- 「開始していないと確認できた場合だけ開始」はframework-owned execution admissionの判断を指す。
137
- 外部システムへのリクエストが一度も届いていないことや、外部副作用のexactly-onceを意味しない。
138
- 未完了実行を同じIDで復旧することも、内部の全Provider/Tool呼び出しの無条件再送を意味しない。
139
- callback喪失、ローカルTask喪失、観測timeoutをsemantic work再実行の理由にしない。
136
+ Starting only when execution is confirmed not to have started refers to framework-owned execution admission.
137
+ It does not mean that no request ever reached an external system, nor does it guarantee exactly-once external side effects.
138
+ Recovering an incomplete execution with the same ID also does not mean unconditionally resending every internal Provider/Tool call.
139
+ Loss of a callback or local Task, or an observation timeout, must not justify rerunning semantic work.
140
140
 
141
- ## 6. 検証条件・対応付け
141
+ ## 6. Validation conditions and implementation mapping
142
142
 
143
- 以下は必要な振る舞いの検証条件であり、新しいspecファイルの本数指定ではない。
144
- 既存specが契約を検証している場合はその根拠を記録し、不足ケースのみ追加する。
143
+ The following are behavioral validation conditions, not a required count of new spec files.
144
+ Where existing specs verify a contract, record that evidence and add only missing cases.
145
145
 
146
- | ID | 検証シナリオ | 必須結果 |
146
+ | ID | Validation scenario | Required outcome |
147
147
  |---|---|---|
148
- | RC-01-A | terminal commit後、callback前にprocess loss | exact IDで同じ結果を読み取れ、semantic work/callbackを再実行しない |
149
- | RC-01-B | admission応答前にcallerを失い、実行はterminalになる | owner identityから候補を発見できる。複数候補を勝手に一つへ決めない |
150
- | RC-01-C | graph/listenerなしで結果参照、または結果のread/decode失敗 | 不要なwiringを要求しない。参照失敗を成功・不存在に偽装しない |
151
- | RC-02-A | 各semantic commitの成功直後に応答を喪失 | readbackで既存factを採用し、別ID・二重assignmentを作らない |
152
- | RC-02-B | read障害、authoritative不存在、CAS競合を別々に注入 | 状態を混同せず、成功が確定したadmission後だけ実行する |
153
- | RC-02-C | 成否不明後のreadbackも失敗 | 状態を保ち制御を返す。無期限の同期待機・新規実行をしない |
154
- | RC-03-A | subagent登録削除、定義version不一致、Target不足 | 継続前にfail closed。別定義・別Targetに置き換えない |
155
- | RC-03-B | 互換な現在のwiringで復旧 | 確定済みContext/input/assignment/outcomeを再計算しない |
156
- | RC-04-A | 待機終了・shutdown・process loss | 暗黙のsemantic cancellationを確定しない |
157
- | RC-04-B | 親cancel時に子が未開始/active/terminal | 状態別規則を守り、exact ID・確定outcomeを維持する |
158
- | RC-04-C | 親cancelとchild admission/terminalを競合させる | 子を紛失せず、既存cancel/terminal barrierへ整合する |
159
- | RC-04-D | cancel要求後の各commit境界でprocess loss | 同じrunの未完了子を復旧経路から発見・照合できる |
160
- | RC-04-E | Handoff transfer後の観測終了・明示cancel | Sourceへ巻き戻さず、当該Target実行にだけ適用する |
161
- | RC-05-A | 外部Tool効果の成否不明とcallback喪失を別々に注入 | 前者は既存Recovery、後者は確定結果参照。盲目的再実行なし |
162
-
163
- baseline統合時には、各RC IDについて「公開API/SPI・実装箇所・既存/追加spec」を対応表に記録する。
164
- 特に結果発見API、互換version扱い、cancel/terminal barrierは未確認のメソッド名で完了扱いにしない。
165
- focused・backend・fault・full suiteの実行成功は、target checkoutでの実測が必要。
166
- 本資料改訂時点では実行していない。
167
-
168
- ## 7. 増やさない責務
169
-
170
- callback outbox/ACK、terminal-delivery index、standalone fan-out用synthetic execution、
171
- Proc/Class serialization、global generic registry、独立Persistence間のdistributed transaction、
172
- Team専用の第二execution engineは引き続き対象外。
173
- 公開結果参照はApplicationの通知配送・外部副作用dedupを代替しない。
174
-
175
- ## 8. 実装との対応
176
-
177
- 2026-09-07の実装・公開API/SPI・検証範囲は
178
- [IMPLEMENTATION_REPORT.md](IMPLEMENTATION_REPORT.md)を参照する。
179
- 本追補の責務境界と必須契約は変更しない。
148
+ | RC-01-A | Process loss after terminal commit and before callback | Read the same result by exact ID without rerunning semantic work or callbacks |
149
+ | RC-01-B | Caller is lost before the admission acknowledgement; execution later becomes terminal | Discover candidates from owner identity; do not arbitrarily choose one when multiple candidates exist |
150
+ | RC-01-C | Access results without a graph/listener, or inject result read/decode failure | Require no unnecessary wiring; do not disguise an access failure as success or absence |
151
+ | RC-02-A | Lose the acknowledgement immediately after each successful semantic commit | Adopt the existing fact through readback; create neither another ID nor duplicate assignments |
152
+ | RC-02-B | Independently inject read failure, authoritative absence, and CAS conflict | Keep the states distinct; execute only after admission success is confirmed |
153
+ | RC-02-C | Readback also fails after an unknown outcome | Preserve state and return control; do not wait synchronously without a bound or create a new execution |
154
+ | RC-03-A | Remove subagent registration, mismatch definition version, or omit Target | Fail closed before continuation; do not substitute another definition or Target |
155
+ | RC-03-B | Recover with compatible current wiring | Do not recompute committed Context/input/assignment/outcome |
156
+ | RC-04-A | End waiting, shut down Runtime, or lose the process | Do not establish implicit semantic cancellation |
157
+ | RC-04-B | Parent cancellation with an unstarted/active/terminal child | Follow state-specific rules and preserve exact IDs and committed outcomes |
158
+ | RC-04-C | Race parent cancellation against child admission/terminal state | Do not lose the child; remain consistent with existing cancellation/terminal barriers |
159
+ | RC-04-D | Lose the process at each commit boundary after a cancellation request | Rediscover and reconcile incomplete children of the same run through recovery paths |
160
+ | RC-04-E | End observation or explicitly cancel after Handoff transfer | Do not roll responsibility back to Source; apply cancellation only to the relevant Target execution |
161
+ | RC-05-A | Independently inject an uncertain external Tool effect and a lost callback | Use existing Recovery for the former and committed-result access for the latter; never rerun blindly |
162
+
163
+ When integrating with the baseline, record the public API/SPI, implementation locations, and existing/additional specs for each RC ID in a mapping table.
164
+ In particular, do not mark result-discovery APIs, compatible-version handling, or cancellation/terminal barriers complete using unverified method names.
165
+ Successful focused, backend, fault, and full-suite runs require actual measurement on the target checkout.
166
+ They have not been run at the time of this document revision.
167
+
168
+ ## 7. Responsibilities that remain out of scope
169
+
170
+ Callback outbox/ACK, a terminal-delivery index, synthetic executions for standalone fan-out,
171
+ Proc/Class serialization, a global generic registry, distributed transactions across independent Persistence instances,
172
+ and a second execution engine dedicated to Team remain out of scope.
173
+ Public result access does not replace Application notification delivery or deduplication of external effects.
174
+
175
+ ## 8. Implementation mapping
176
+
177
+ See [IMPLEMENTATION_REPORT.md](IMPLEMENTATION_REPORT.md) for the implementation, public API/SPI, and validation scope as of 2026-09-07.
178
+ The responsibility boundaries and required contracts in this addendum remain unchanged.