phronomy 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +76 -0
  3. data/README.md +7 -2
  4. data/docs/architecture/agent-tool-child-lifetime.md +141 -0
  5. data/docs/architecture/dx05-agent-scope.md +4 -2
  6. data/docs/architecture/r8-unit1.md +68 -68
  7. data/docs/architecture/r8-unit2.md +34 -34
  8. data/docs/architecture/structured-output-and-scope.md +73 -13
  9. data/docs/decisions/029-semantic-completion-and-application-effect-boundary.md +1 -1
  10. data/docs/decisions/044-agent-default-and-one-shot-composition.md +5 -0
  11. data/docs/design/durable-semantic-coordination/CHANGELOG_V2_REVISION_2.md +23 -23
  12. data/docs/design/durable-semantic-coordination/IMPLEMENTATION_REPORT.md +99 -99
  13. data/docs/design/durable-semantic-coordination/RECOVERY_CONTRACT_CLARIFICATIONS.md +135 -136
  14. data/docs/getting-started.md +26 -0
  15. data/docs/migrations/0.31.md +72 -0
  16. data/lib/phronomy/agent/async_event_api.rb +17 -8
  17. data/lib/phronomy/agent/base.rb +27 -2
  18. data/lib/phronomy/agent/composition/run_once.rb +11 -10
  19. data/lib/phronomy/agent/context_preparation.rb +1 -0
  20. data/lib/phronomy/agent/execution/dispatch_preparation.rb +1 -1
  21. data/lib/phronomy/agent/execution/exact_execution.rb +5 -3
  22. data/lib/phronomy/agent/execution/execution_coordinator.rb +6 -0
  23. data/lib/phronomy/agent/execution/execution_outcome_committer.rb +1 -6
  24. data/lib/phronomy/agent/execution/initial_preparation.rb +1 -1
  25. data/lib/phronomy/agent/execution/invocation_actions.rb +17 -15
  26. data/lib/phronomy/agent/execution_change.rb +4 -0
  27. data/lib/phronomy/agent/output_contract.rb +47 -5
  28. data/lib/phronomy/agent/persistence/codec.rb +16 -2
  29. data/lib/phronomy/agent/recovery/recovery_coordinator/continuation.rb +1 -0
  30. data/lib/phronomy/agent/runtime_binding/engine_session_builder.rb +2 -2
  31. data/lib/phronomy/agent/runtime_input.rb +7 -0
  32. data/lib/phronomy/engine/fsm_session.rb +7 -0
  33. data/lib/phronomy/execution/async_operation.rb +16 -0
  34. data/lib/phronomy/execution/concurrency/result_finalization.rb +106 -0
  35. data/lib/phronomy/generation/generator_verifier/agent_operation.rb +3 -3
  36. data/lib/phronomy/generation/generator_verifier.rb +6 -3
  37. data/lib/phronomy/llm_adapter/backends/ruby_llm.rb +1 -1
  38. data/lib/phronomy/llm_adapter/backends/structured_response_capture.rb +3 -1
  39. data/lib/phronomy/tools/agent.rb +58 -22
  40. data/lib/phronomy/version.rb +1 -1
  41. data/sig/phronomy/agent.rbs +7 -5
  42. data/sig/phronomy/execution/async_operation.rbs +1 -0
  43. data/sig/phronomy/generation/generator_verifier.rbs +1 -1
  44. data/sig/phronomy/tools/agent.rbs +14 -0
  45. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46b13a1255f5821e321de0e3817f9fc2335ae2eba81dc7142a01295ffffcdd05
4
- data.tar.gz: c268bfd441361880ce4c6c6a84f03e7e0530b5e1ca8736e87bfba78756a69c89
3
+ metadata.gz: e7eb1f72acaa35f02d5f848dac344ea971e6ef190544d2b200fe367409e48e92
4
+ data.tar.gz: 26b2de048b30845bdbf973a5e26a6d5fa4b734295d31b81cec2530e9dd896dc8
5
5
  SHA512:
6
- metadata.gz: 9f53504e27f5cefedb2370ed495387c17cf98ae850b847497090b17fe1971545a565bfe4533368f47646c5953352aebc4f29801afdb3a2691a54927f60ec1df4
7
- data.tar.gz: 4f9dace274b6a09ad4096569cd8a459dc74df63263c8d4fdc1455d6628e70c93464490a971c638a24aea844d09eb85f9f4ceafa64e9c9e39f5345daa6b83fffb
6
+ metadata.gz: eaf92481864d37b545ccf7507541fbd64777eb6ff6369e2f8a674f31341bc2ec439883dfa2964d410c1becc2adc92c2794c9a7a2e6a7a2e5050a78e2ae4fa181
7
+ data.tar.gz: 6ca6f91cc3bf270a2694cb5a8a194cc1f4fe8270440ada751a4082f0ae27489c0798743a351d8850e1fbf4e81eb0aac207bee563995e8aa821d2008b2b6916e2
data/CHANGELOG.md CHANGED
@@ -12,6 +12,80 @@ Release history for 0.14.0 and earlier is archived in
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [0.31.0] - 2026-10-25
16
+
17
+ ### Added
18
+
19
+ - Add explicit Agent `schema_delivery: :native | :none` across execution entry
20
+ points and GeneratorVerifier. Local structured-output validation is identical
21
+ in both modes; existing calls retain native delivery.
22
+ - Add `Agent#transcript_messages` and its async counterpart to read immutable
23
+ Message values without application knowledge of Journal storage.
24
+ - Add `Tools::Agent::CleanupError` (`tool.agent_cleanup_failed`) with the child
25
+ Agent, successful result and primary/cleanup failures needed to diagnose failed
26
+ release and retry `child_agent.unload_async` without repeating the invocation.
27
+
28
+ ### Persistence
29
+
30
+ - Save new output contracts as version 2 with the delivery choice and retain their
31
+ schemas even when no schema is sent. These executions use envelope 0.3, rejected
32
+ by older readers. Existing version-1 contracts remain native and readable.
33
+
34
+ ### Fixed
35
+
36
+ - Preserve streamed refusal facts even when native schema delivery is omitted.
37
+ - Release the one-shot Agent owned by `Agent.run_once` through `Agent.open_scope`.
38
+ Preserve the invocation value or original exception when release succeeds;
39
+ report unsafe or failed release through `Agent::ScopeCleanupError` with the
40
+ result, primary error and scope needed for a release-only retry.
41
+ - Give each Agent-backed Tool call explicit ownership of its fresh child and
42
+ ephemeral Store. Complete release after logical and physical invocation
43
+ completion, without occupying a worker merely to wait. Preserve approval,
44
+ cancellation, independent leases, retention and recovery restrictions.
45
+ - Acknowledge terminal execution waiters before publishing their result while
46
+ retaining each operation's physical lease until its work actually finishes.
47
+ - Stop completed Agent Tool handles from retaining released children through
48
+ generated callback owners, temporary state-machine tracker context or completed
49
+ `ExecutionChange` wiring. Clear execution-only references after commit and any
50
+ ambiguous-outcome readback, including failure paths. Keep single-use guards,
51
+ saved results, session ownership and recovery behavior intact.
52
+
53
+ ### Changed
54
+
55
+ - Both synchronous and asynchronous Agent Tool calls now use the child's
56
+ `invoke_async`. An override of only `invoke` no longer changes synchronous
57
+ Agent Tool execution; update custom child subclasses accordingly.
58
+ - Agent Tool cleanup failures are surfaced and diagnosed, including after an
59
+ outer observer cancels. A general Tool error-suppression policy cannot hide
60
+ failed child release.
61
+
62
+ ### Verification and migration
63
+
64
+ - Read the [0.31 migration notes](docs/migrations/0.31.md) before upgrading stored
65
+ executions or custom Agent Tool subclasses. Deploy readers that support
66
+ AgentExecution 0.3 before writing new structured executions; older readers
67
+ cannot read these records, including completed executions. Existing 0.2 records
68
+ and version-1 native output contracts remain readable without a read-time rewrite.
69
+ - LM Studio/gpt-oss PEG output parsing remains an unresolved external limitation.
70
+ Existing known-error identification and bounded retry are not a root-cause fix.
71
+ The DX1/DX2 live normal path, streaming, Tool use and history restoration remain
72
+ unverified in that environment. This release relies on source review, offline
73
+ regressions and CI; it does not claim completion of live LLM acceptance.
74
+ Historical initial success and bounded retry/stop evidence retain their limited
75
+ scope; retry recovery and recurrence resolution remain unverified.
76
+
77
+
78
+ ## [0.30.1] - 2026-10-24
79
+
80
+ ### Documentation
81
+
82
+ - Translate historical r8 unit 1/2 architecture notes and durable semantic
83
+ coordination records into English, preserving API names, executable commands,
84
+ requirement IDs, dates and the original validation limits.
85
+ - Repair ADR-029's link to the recovery-contract document and its English heading.
86
+
87
+ Runtime behavior, public APIs and dependency requirements match 0.30.0.
88
+
15
89
  ## [0.30.0] - 2026-10-24
16
90
 
17
91
  ### Added
@@ -29,6 +103,8 @@ Release history for 0.14.0 and earlier is archived in
29
103
 
30
104
  ### Changed
31
105
 
106
+ - Generate architecture SVG metadata in English, including repeated formatting.
107
+
32
108
  - GeneratorVerifier owns immutable evaluation Results, explicit approval routing
33
109
  and Agent lifetime. Use `accepted?`, `termination_reason` and
34
110
  `raise_if_unaccepted`; `output_failed` distinguishes invalid output from a
data/README.md CHANGED
@@ -37,14 +37,18 @@ tracking `main` directly.
37
37
 
38
38
  See [Features and Application Programming Interface (API) stability](docs/features.md) for the full feature matrix.
39
39
 
40
- The following application APIs are available as Beta in v0.30.0:
40
+ The following table describes the application APIs available in v0.31.0.
41
+ Review the [0.31 migration notes](docs/migrations/0.31.md) before upgrading
42
+ persistent applications or custom Agent Tool subclasses.
41
43
 
42
44
  | API | Stability | Contract |
43
45
  |---|---|---|
44
46
  | `Phronomy::LLMAdapter::LMStudio` | Beta | Explicit known-output-error identification and bounded opt-in retry; [policy and evidence limits](docs/architecture/lm-studio-output-failures.md) |
45
- | Agent `output_schema:`, `Agent::OutputError` and `OutputParser::JsonSchemaParser` | Beta | Agent returns validated immutable JSON or an explicit output failure; [contract and migration](docs/architecture/structured-output-and-scope.md) |
47
+ | Agent `output_schema:`, `schema_delivery:`, `Agent::OutputError` and `OutputParser::JsonSchemaParser` | Beta | Agent returns validated immutable JSON or an explicit output failure; [contract and migration](docs/architecture/structured-output-and-scope.md) |
48
+ | Agent `transcript_messages` / `transcript_messages_async` | Beta | Read immutable conversation Message values with the same restoration rules as execution results; [reading conversation state](docs/getting-started.md) |
46
49
  | `Phronomy::GeneratorVerifier`, its approval/lifetime operations and immutable `Result` with output-failure diagnostics | Beta | [Generation and structured-output contract](docs/architecture/structured-output-and-scope.md) |
47
50
  | `Agent.open_scope`, `Agent::Scope`, `Agent::Base#unload_async / #unload!`, `AgentUnloadedError` and `Agent::ScopeCleanupError` | Beta | Runtime-bound ownership and safe release of idle Agent incarnations without changing saved history or closing the Store; [contract](docs/architecture/dx05-agent-scope.md) |
51
+ | `Tools::Agent::CleanupError` | Beta | Added in v0.31.0. Preserves the child, result and failure causes when safe release fails; retry `child_agent.unload_async` for release only; [contract](docs/architecture/agent-tool-child-lifetime.md) |
48
52
  | `Workflow::Builder#task_state` and `WorkflowTaskResumeError` | Beta | State-entry-scoped Task completion, live cancellation and explicit restart rejection; [contract](docs/architecture/dx05-workflow-task-state.md) |
49
53
  | `Phronomy::Integrations::OrderedEventDelivery` | Beta | Optional ordered delivery with bounded admission and explicit drain lifetime; [usage](docs/ordered-event-delivery.md) |
50
54
  | `Phronomy::Error#code` and error constructor `code:` | Beta | Optional reason codes and bounded causes retained in saved failure diagnostics; [meaning and compatibility](docs/architecture/error-api-review.md) |
@@ -189,6 +193,7 @@ contracts, timeout/cancellation semantics, metrics, and callback rules.
189
193
  - [Persistence failure contract migration](docs/migrations/persistence-failure-contracts.md) — domain rescue clauses and unchanged raw backend errors.
190
194
  - [0.19 unified Persistence migration](docs/migrations/0.19.md).
191
195
  - [0.22 semantic Multi-Agent Handoff migration](docs/migrations/0.22.md).
196
+ - [0.31 persistence and Agent lifetime migration](docs/migrations/0.31.md).
192
197
  - [Architecture Decision Records](docs/decisions/) — design rationale and superseding decisions.
193
198
  - [CHANGELOG](CHANGELOG.md) — current development and recent release history.
194
199
  - [Changelog archive: 0.14.0 and earlier](docs/changelog/0.14-and-earlier.md).
@@ -0,0 +1,141 @@
1
+ # Agent Tool child lifetime
2
+
3
+ `Tools::Agent.from_agent` owns one fresh Agent and ephemeral Store per call.
4
+ The Tool releases its private live child after the invocation and its physical
5
+ work finish. Ordinary application-owned Agents and durable MultiAgent children
6
+ retain their own explicit lifetime and recovery policies.
7
+
8
+ ## Public behavior
9
+
10
+ `from_agent`, `call`, `call_async` and `execute` keep their arguments. Successful
11
+ output remains `result[:output].to_s`, including the empty String for nil. Tool
12
+ validation, cancellation-token precedence, error policy, truncation and configured
13
+ result-transform order remain in their existing owners.
14
+
15
+ The synchronous `execute` now waits for the same internal asynchronous operation
16
+ used by `call_async`. Both invoke the child's `invoke_async` implementation.
17
+ An application override of only `invoke` no longer changes the synchronous Tool
18
+ path; there is no legacy dispatch branch. Synchronous EventLoop entry is rejected
19
+ before creating a Store or child.
20
+
21
+ Normal Tool completion includes release. No OffloadPool worker or new Thread is
22
+ used merely to wait for the child or its release. The existing Agent release can
23
+ perform its ordinary asynchronous persistence checks. Records are not purged,
24
+ and unrelated Agents or shared stores are not shut down.
25
+
26
+ ## Cancellation and approval
27
+
28
+ Logical result settlement does not prove that physical work has ended. The
29
+ operation keeps ownership until both source boundaries are complete, then calls
30
+ the existing `unload_async`. Cancelling an observation handle does not cancel
31
+ this finalization or silently release an active child. Use the accepted
32
+ CancellationToken to request operation-wide cancellation.
33
+
34
+ Pending approval is not terminal. This Tool neither auto-approves nor adds a
35
+ child-event forwarding API. A child requiring external approval still needs an
36
+ application-defined way to deliver that approval. Active work, other accepted
37
+ operations, retention and unresolved recovery continue to prevent release.
38
+
39
+ When several Agent calls observe the same terminal execution, C04 acknowledges
40
+ all of those finished operations before publishing any logical result. Otherwise
41
+ the first result callback could request release before a sibling approval waiter
42
+ has acknowledged completion. Each OperationResult still waits for its own tracked
43
+ physical work. Independent operations and synchronous caller leases remain live;
44
+ they are not force-released by this batching.
45
+
46
+ ## Cleanup failure
47
+
48
+ On successful cleanup, the operation preserves its output or original exception.
49
+ Ordinary Tool error policy is applied afterward. A cleanup failure instead raises
50
+ `Tools::Agent::CleanupError`, a `ToolError` with code
51
+ `tool.agent_cleanup_failed`, even when the Tool suppresses ordinary failures.
52
+
53
+ | Reader | Meaning |
54
+ | --- | --- |
55
+ | `child_agent` | The exact child instance whose release failed |
56
+ | `agent_id` | That child's identity |
57
+ | `result` | The successful String before Tool truncation, or nil |
58
+ | `primary_error` | Invocation or conversion failure, when present |
59
+ | `cleanup_error` | Release failure |
60
+ | `cause` | The primary error when present, otherwise the cleanup error |
61
+
62
+ The application may retry `error.child_agent.unload_async` when the release
63
+ condition has been resolved. This retries release only: it never invokes the
64
+ Agent, model or Tool again. The error and live child reference are process-local;
65
+ persisted error diagnostics do not reconstruct an owner or retry capability.
66
+
67
+ Every cleanup failure is also reported with its child identity, stable code and
68
+ both available failure diagnostics. This includes failures after an outer
69
+ observer has already cancelled its handle. The settled observer is not overwritten.
70
+ The owner remains registered for inspection through the existing Agent API.
71
+ Diagnostic failures do not replace the operation error or repeat work.
72
+
73
+ ## Responsibility boundaries
74
+
75
+ | Owner | Responsibility |
76
+ | --- | --- |
77
+ | I04, concrete Agent Tool | Fresh child acquisition, invocation, output conversion, release request and child-specific failure information |
78
+ | C04, Agent | Admission, physical-operation leases, approval, recovery, retention, unload safety and terminal waiter acknowledgment |
79
+ | C06, Tool | Input validation, general error policy, truncation and result transformations |
80
+ | C13, Execution | Neutral logical/physical completion and asynchronous finalization composition |
81
+
82
+ The private `AsyncOperation.finalize` captures startup failure, observes a
83
+ TaskResult's logical and physical completion, starts one supplied cleanup
84
+ operation and observes its completion. The owner supplies error combination.
85
+ It is independent of application Execution cancellation and contains no Agent,
86
+ Store, Tool or provider policy. A callback-only source is not accepted by this
87
+ private finalization API; the start and cleanup functions must return TaskResults.
88
+
89
+ This does not add a public finally, async scope or one-shot Agent API. The
90
+ concrete Tool does not regain a dependency on the application `run_once`
91
+ composition, and does not manually settle TaskResults. Agent release decisions
92
+ are not moved into Execution or Engine.
93
+
94
+ ## Runtime reference lifetime
95
+
96
+ Agent entry actions resolve their owner from the invocation being processed.
97
+ They do not curry a live Agent into the generated state-machine class. This
98
+ prevents VM method caches for generated callbacks from extending Agent lifetime.
99
+
100
+ FSMSession owns its context between events. The state-machine tracker receives
101
+ that context while an event is dispatched, then drops its temporary reference
102
+ when dispatch returns, including on errors. Later events rebind the same live
103
+ session context. This does not clear the session's context, end pending work,
104
+ change approval handling, or relax Agent unload admission.
105
+
106
+ For example, retaining a completed Tool handle must not retain the child through
107
+ either generated callbacks or a completed state-machine transition. Ruby 3.2.3
108
+ can retain those execution objects through method caches after the logical
109
+ operation ends. Separating their temporary references from session ownership
110
+ allows the released child to be collected without changing the Ruby or
111
+ state_machines dependency versions.
112
+
113
+ Completed synchronous `ExecutionChange` objects can also remain reachable from
114
+ an idle worker's Fiber/stack, including on the Ubuntu build of Ruby 3.2.3. After
115
+ commit and any ambiguous-outcome readback finish, the change drops its live Agent,
116
+ write callback and participant references. It keeps its result and descriptive
117
+ data. This cleanup runs after success or failure, never before the participant's
118
+ commit, evidence collection or recovery guards have finished. A completed change
119
+ remains single-use; it does not grant a new opportunity to commit or replay work.
120
+
121
+ These changes stay inside Agent execution/participation and Engine dispatch
122
+ lifetime; they introduce no new Contract dependency or public API. In particular,
123
+ OffloadPool does not acquire Agent-specific cleanup policy, replace worker
124
+ threads, or create a new Fiber to make collection happen.
125
+
126
+ ## Verification
127
+
128
+ Offline tests use real Agent operations and a fixed local LLMAdapter. They cover
129
+ sync/async success and failure, startup and conversion errors, repeated calls,
130
+ single-worker parent Tool dispatch, approval, independent leases, parallel
131
+ children, observer and token cancellation, cleanup failure and retry, shutdown,
132
+ result transforms and collectability while one or several completed handles
133
+ remain live. The original single-child GC assertion is retained unchanged.
134
+ Participation tests retain completed changes while checking collection of their
135
+ execution-only wiring after success, rollback and lost commit response. The
136
+ last case also verifies that readback runs once and returns the committed result.
137
+ Neutral completion tests exercise both boundary orders, duplicate/concurrent
138
+ notifications, cancellation, startup/cleanup errors and invalid handles.
139
+
140
+ These tests do not establish real-provider availability or resolve LM Studio's
141
+ separate PEG output-parse failure.
@@ -113,8 +113,10 @@ removal is performed.
113
113
  blocks release.
114
114
 
115
115
  For notifications, finish child processing, drain notifications, then exit the
116
- Agent scope. `run_once` retains its existing Store and lifetime behavior; merely
117
- calling it does not opt into scope cleanup.
116
+ Agent scope. `run_once` owns a fresh ephemeral Store and an Agent scope. It releases
117
+ the Agent before returning or propagating an invocation failure, using the same
118
+ release and cleanup-error rules. Use an explicit scope when ownership must extend
119
+ past the invocation, for example until final notification delivery has drained.
118
120
 
119
121
  This is P5 (core). P6 migrates application examples and performs cross-repository
120
122
  acceptance against the published or pinned candidate core.
@@ -1,4 +1,4 @@
1
- # r8第1適用版:Context/ToolとExecutionの共通基盤
1
+ # r8 unit 1: Shared Context, Tool, and Execution foundations
2
2
 
3
3
  > Current boundary: r8 unit 6 supersedes the historical Chat/SDK ownership and
4
4
  > adapter extension SPI below. Agent uses LLMAdapter values; the backend owns SDK
@@ -6,99 +6,99 @@
6
6
  > `docs/architecture/r8-unit6.md` and `docs/migrations/r8-unit6.md`.
7
7
 
8
8
 
9
- 対象は2026-09-30に確認したmain `653e255a34fe4062d4beca47530e084fdd3a6ba9`。設計基準は同日更新のr8修正仕様・directory配置資料である。本変更はその第1適用単位であり、r8全体、S1全項目、S2/S3全受入条件の完了を意味しない。互換alias・転送だけの旧APIは残さない。
9
+ The baseline is main `653e255a34fe4062d4beca47530e084fdd3a6ba9`, checked on 2026-09-30. The design references are the revised r8 specification and directory layout documents updated that day. This change is the first implementation unit; it does not mean that all of r8, every S1 item, or every S2/S3 acceptance condition is complete. Compatibility aliases and old APIs that only forward calls are not retained.
10
10
 
11
- ## 実装した責務と操作
11
+ ## Implemented responsibilities and operations
12
12
 
13
- | 所有者 | 共通基盤が実行すること | 利用側に残すこと |
13
+ | Owner | What the shared foundation does | What remains with the caller |
14
14
  |---|---|---|
15
- | `Context::Assembly` | Policyを一度呼びPlanを検証する。内容を正規化し、最終予算を検査してManifestを保存する | Agentはsnapshotを取得し、保存直前のwatermark再確認とAgent実行記録更新を行う |
16
- | `Tool::DefinitionSet` | Tool定義の正規化、名前重複と保存済み定義の整合性を検証する | Agentは自身のTool alias・decorator・runtime実体を準備する |
17
- | `Tool::Authorization` | 不変の引数・認可contextでfacts→requirement→policy→decisionを評価する | Agentは対象実行の照合、承認状態、受付結果、supervisionを管理する |
18
- | `Tool::ToolExecutor` | cooperative/offloadedの実行規則と結果を扱う | Engineのpool選択はExecutionの機構接続へ委ねる |
19
- | `LLMAdapter::Base` / `RubyLLM` | 同期生成とchat構築・設定・message/tool-call構築。RubyLLM実装がSDK失敗を変換する | Agentは自身の保存データ・Tool定義を検証してadapterへ渡す |
20
- | `Execution` | submitの入口、fan-out/fan-in、結果合成、取消・期限・待機規則 | Engineはpool・timer・RuntimeとFSMの機構を実装する |
21
- | `Tracing::Observation` | 明示的な観測とPII秘匿。実際の返り値は変えない | Runnableはinvoke/stream/batchの実行契約を持つ |
15
+ | `Context::Assembly` | Calls the Policy once and validates the Plan; normalizes content, checks the final budget, and stores the Manifest | Agent obtains the snapshot, rechecks the watermark immediately before persistence, and updates the Agent execution record |
16
+ | `Tool::DefinitionSet` | Normalizes Tool definitions and validates name uniqueness and consistency with persisted definitions | Agent prepares its own Tool aliases, decorators, and runtime instances |
17
+ | `Tool::Authorization` | Evaluates facts -> requirement -> policy -> decision using immutable arguments and authorization context | Agent manages execution matching, approval state, admission results, and supervision |
18
+ | `Tool::ToolExecutor` | Handles cooperative/offloaded execution rules and results | Pool selection in Engine is delegated to the Execution mechanism binding |
19
+ | `LLMAdapter::Base` / `RubyLLM` | Handles synchronous generation and chat construction/configuration, message construction, and tool-call construction; the RubyLLM implementation translates SDK failures | Agent validates its persisted data and Tool definitions before passing them to the adapter |
20
+ | `Execution` | Owns the submit entry point, fan-out/fan-in, result composition, and cancellation/deadline/waiting rules | Engine implements pools, timers, Runtime, and FSM mechanisms |
21
+ | `Tracing::Observation` | Provides explicit observation and PII redaction without changing the actual return value | Runnable owns the invoke/stream/batch execution contract |
22
22
 
23
- ContextとToolはAgentの薄い型定義の置場ではなく、実際の共通手順を所有する。ただし、Contextの現在の入力にはAgent由来の識別情報や由来情報が残る。完全に汎用の新domainモデルまで設計し直したものではない。ToolのDSL基底は引き続きRubyLLM::Toolを使用する。
23
+ Context and Tool own real shared procedures, rather than merely housing thin Agent type definitions. However, current Context inputs still contain Agent-derived identifiers and provenance. This is not a redesign into a fully generic domain model. The Tool DSL base continues to use RubyLLM::Tool.
24
24
 
25
- `Context::Assembly#prepare(input:, policy:, adapter_identity:)` は保存transaction外でPolicyを呼ぶ。`#store(prepared, contents:)` は呼出側が渡す同じtransactionのcontents repositoryだけを使い、自分では独立transactionを開始しない。初回とfollow-upのAgent commitは既存transaction内でManifestとAgentExecutionの参照を保存する。後続書込に失敗したときManifestもrollbackされ、Policyは再実行されない。live projectionをcommit後に適用する既存順序を維持する。これはP02のAgent/Context部分の検証であり、任意domainの外側transaction参加を完成させたものではない。
25
+ `Context::Assembly#prepare(input:, policy:, adapter_identity:)` calls the Policy outside the persistence transaction. `#store(prepared, contents:)` uses only the contents repository supplied by the caller from the same transaction; it does not start an independent transaction. Initial and follow-up Agent commits store the Manifest and the AgentExecution reference within the existing transaction. If a later write fails, the Manifest is rolled back too, and the Policy is not executed again. The existing ordering, which applies the live projection after commit, is preserved. This validates the Agent/Context part of P02; it does not complete participation in outer transactions for arbitrary domains.
26
26
 
27
- Executionは`_ExecutionBackend`の操作に依存する。構成処理が遅延providerを設定し、Engineの`ExecutionBinding`がsubmit/afterを実装する。settled TaskResultの生成・map/flat_map/all_settled・待機制約の確認ではEngineを読み込まない。Runtime取得は実際のsubmit/タイマー登録時に行う。単なる名義移管に留めず、機構参照をここへ集約した。
27
+ Execution depends on the operations of `_ExecutionBackend`. Composition configures a deferred provider, and Engine's `ExecutionBinding` implements submit/after. Creating settled TaskResults, using map/flat_map/all_settled, and checking waiting constraints do not load Engine. Runtime is obtained only when work is actually submitted or a timer is registered. Mechanism references are consolidated here, rather than merely being renamed or nominally reassigned.
28
28
 
29
- WorkflowのFINISHと終了値は`Workflow::Completion`が所有し、WorkflowRunnerがFSM側へ変換する。FSMSession専用のEvent/FSMProtocol/TerminalDecisionはEngineに置く。Agent・MultiAgentのFSM専用接続の全面分離は残っている。
29
+ `Workflow::Completion` owns Workflow FINISH and completion values, and WorkflowRunner translates them into the FSM representation. Event/FSMProtocol/TerminalDecision, which are specific to FSMSession, live in Engine. Full separation of Agent and MultiAgent FSM-specific bindings remains outstanding.
30
30
 
31
- ## 公開名・配置の変更
31
+ ## Public names and layout changes
32
32
 
33
- | 旧配置・API | 新配置・API | 判断 |
33
+ | Previous location/API | New location/API | Rationale |
34
34
  |---|---|---|
35
- | `agent/context_contract/` と `Agent::ContextPolicy` 等 | `context/`、`Context::ContextPolicy` 等 | Policy・Plan・Manifest・検証を共通操作と同じ所有者へ統合 |
36
- | `agent/context_policies/default.rb` | `context/default_policy.rb`、`Context::DefaultPolicy` | 具体Policyも同domainに配置 |
37
- | `Agent::Context::Instruction::PromptTemplate` | `Context::PromptTemplate` | Agent内の旧公開名を削除 |
38
- | `Agent::Selection::{Candidate,Constraint}` | `Context::{Candidate,Constraint}` | 薄いSelection下位区分を削除 |
39
- | `Agent::LLMInputPatch` / `LLMInputBuildContext` | `Context::LLMInputPatch` / `LLMInputBuildContext` | hook入力・返却値の所有を統一 |
40
- | `ContextBudgetExceededError` | `Context::BudgetExceededError` | LLMのprovider失敗ではなくContext予算失敗 |
41
- | `agent/context_assembly/` | `context/assembly.rb` とAgent直下の準備・状態・入力処理 | Context共通手順、Agent snapshot/state、LLM SDK処理を分離 |
42
- | `Agent::Context::Capability::Base` | 実装本体の `Tool::Base` | 旧名とaliasを削除 |
43
- | `agent/tool_execution/tool_definition_set.rb` | `tool/definition_set.rb` | 共通定義処理を移管。Agent固有生成はAgent内 |
44
- | `execution_contract/` と `execution_services/` | `execution/` と必要な `execution/concurrency/` | 操作・値・共通規則を統合。`execution_result`等の薄い別分割を追加しない |
45
- | `WorkerSubmission` | `Execution.submit` | 転送専用moduleを削除 |
46
- | `Runnable#trace` | `Tracing::Observation.trace` | 実行基盤から観測への依存を除去 |
47
- | `tool/contract`、`filter/contract`、`output_parser/contract`、`agent/lifecycle_contract` | 各所有domain配下の例外ファイル | 例外だけのdirectoryを削除。既存の意味を持つ例外定数名は実体として保持 |
48
-
49
- 独自LLM adapterはcomplete/streamだけでなく、`build_chat`、`configure_chat`、`message`、`tool_call`を実装する。`identity`には基底の既定値、`input_budget`にはnilの既定値がある。正確なkeywordと返却契約は`sig/phronomy/llm_adapter/base.rbs`を参照する。SDK固有例外はadapter操作の境界でLLM失敗へ変換し、元のcauseを保持する。アプリ例外・取消は無関係なprovider失敗へ変換しない。
50
-
51
- 既存設定APIの`tool_result_max_size`/loggerはアプリ構成から中立RuntimeSettingsへ供給する。Toolから構成factoryへの参照を除き、default・nil・scoped copyの意味を維持する。RBSは`sig/`と`sig/_private/`に置き、実装定数・宣言所有者に基づいて依存を解析する。
52
-
53
- ## r8項目別の到達点
54
-
55
- | 項目 | この適用版 | 未完了部分 |
35
+ | `agent/context_contract/` and APIs such as `Agent::ContextPolicy` | `context/` and APIs such as `Context::ContextPolicy` | Consolidate Policy, Plan, Manifest, and validation under the owner of the shared operations |
36
+ | `agent/context_policies/default.rb` | `context/default_policy.rb`, `Context::DefaultPolicy` | Keep the concrete Policy in the same domain |
37
+ | `Agent::Context::Instruction::PromptTemplate` | `Context::PromptTemplate` | Remove the old public name under Agent |
38
+ | `Agent::Selection::{Candidate,Constraint}` | `Context::{Candidate,Constraint}` | Remove the thin Selection subdivision |
39
+ | `Agent::LLMInputPatch` / `LLMInputBuildContext` | `Context::LLMInputPatch` / `LLMInputBuildContext` | Unify ownership of hook inputs and return values |
40
+ | `ContextBudgetExceededError` | `Context::BudgetExceededError` | Represent a Context budget failure, not an LLM provider failure |
41
+ | `agent/context_assembly/` | `context/assembly.rb` plus preparation, state, and input handling directly under Agent | Separate shared Context procedures, Agent snapshot/state handling, and LLM SDK handling |
42
+ | `Agent::Context::Capability::Base` | The actual implementation, `Tool::Base` | Remove the old name and alias |
43
+ | `agent/tool_execution/tool_definition_set.rb` | `tool/definition_set.rb` | Transfer shared definition handling; keep Agent-specific construction in Agent |
44
+ | `execution_contract/` and `execution_services/` | `execution/` and the necessary `execution/concurrency/` | Consolidate operations, values, and shared rules; do not add thin subdivisions such as `execution_result` |
45
+ | `WorkerSubmission` | `Execution.submit` | Remove the forwarding-only module |
46
+ | `Runnable#trace` | `Tracing::Observation.trace` | Remove the execution foundation's dependency on observation |
47
+ | `tool/contract`, `filter/contract`, `output_parser/contract`, `agent/lifecycle_contract` | Exception files under their owning domains | Remove exception-only directories; retain existing meaningful exception constant names as actual definitions |
48
+
49
+ Custom LLM adapters implement `build_chat`, `configure_chat`, `message`, and `tool_call` in addition to complete/stream. The base class supplies a default `identity` and a nil default for `input_budget`. See `sig/phronomy/llm_adapter/base.rbs` for exact keywords and return contracts. Translate SDK-specific exceptions into LLM failures at adapter operation boundaries, preserving the original cause. Do not translate application exceptions or cancellation into unrelated provider failures.
50
+
51
+ The existing `tool_result_max_size` configuration API and logger are supplied by application composition to neutral RuntimeSettings. Remove references from Tool to the composition factory while preserving default, nil, and scoped-copy semantics. Place RBS in `sig/` and `sig/_private/`, and analyze dependencies based on implementation constants and declaration ownership.
52
+
53
+ ## Progress by r8 item
54
+
55
+ | Item | This implementation unit | Outstanding work |
56
56
  |---|---|---|
57
- | DP01 Context集約 | 主対象を実装 | より広いdomain入力・公開操作レビューは残る |
58
- | DP02 Tool共通基盤 | 定義・認可評価・呼出しの共通部分を実装 | Agent側FSM接続と全親子認可の整理はDP12/P04 |
59
- | DP03 Execution統合 | 実装 | domain全体のFSM利用整理を完了としない |
60
- | DP04 Persistence | 未着手 | facade除去、共通transaction/参加/成否照合API |
61
- | DP05 domain保存schema | 未着手 | MultiAgent/Workflowのstorage_contract統合 |
62
- | DP06 LLM集約 | 前提部分のみ | llm_contractとllm_adapterの全面統合 |
63
- | DP07 薄い失敗directory統合 | 実装 | domainごとの失敗語彙全体の再設計ではない |
64
- | DP08 composition集約 | 接続追加のみ | runtime/persistence/agent構成の物理統合 |
65
- | DP09 Embeddings独立 | 未着手 | vector_storeからの独立配置 |
66
- | DP10 Documents | 未着手 | loader/splitter再配置 |
67
- | DP11 assembly/concerns分解 | 主対象を実装 | Agent固有処理はAgent直下に保持 |
68
- | DP12 domain実行接続 | Workflow終了境界など一部 | Agent/ToolInvocation/Teamのdomain判断とFSM接続の全面分離 |
69
- | DP13 Recovery/Handoff | 未着手 | domain復旧・Persistence成否照合・親子操作の所有整理 |
70
- | P02保存参加 | Agent/Contextの既存transactionで検証 | 外側scope、savepoint、複数domainの公開参加API |
71
- | P01/P03〜P06保存・親子連携 | 未着手 | 下記の原子性条件を確定する必要がある |
72
- | 155組・393件の三角形レビュー | 再判定未完了 | 図の再解析は判定完了の代わりにはならない |
57
+ | DP01 Context consolidation | Main scope implemented | Broader domain inputs and public operations still require review |
58
+ | DP02 Shared Tool foundation | Shared definition, authorization evaluation, and invocation implemented | Agent FSM bindings and all parent/child authorization rules remain under DP12/P04 |
59
+ | DP03 Execution consolidation | Implemented | This does not complete the review of FSM use across all domains |
60
+ | DP04 Persistence | Not started | Facade removal and shared transaction/participation/outcome-reconciliation APIs |
61
+ | DP05 Domain persistence schemas | Not started | Consolidation of MultiAgent/Workflow storage_contract |
62
+ | DP06 LLM consolidation | Prerequisites only | Full consolidation of llm_contract and llm_adapter |
63
+ | DP07 Consolidation of thin failure directories | Implemented | This is not a redesign of every domain's failure vocabulary |
64
+ | DP08 Composition consolidation | Bindings added only | Physical consolidation of runtime/persistence/agent composition |
65
+ | DP09 Independent Embeddings domain | Not started | Placement independent of vector_store |
66
+ | DP10 Documents | Not started | Loader/splitter relocation |
67
+ | DP11 Decomposition of assembly/concerns | Main scope implemented | Agent-specific processing remains directly under Agent |
68
+ | DP12 Domain execution bindings | Partial, including the Workflow completion boundary | Full separation of Agent/ToolInvocation/Team domain decisions from FSM bindings |
69
+ | DP13 Recovery/Handoff | Not started | Ownership of domain recovery, Persistence outcome reconciliation, and parent/child operations |
70
+ | P02 Persistence participation | Validated in the existing Agent/Context transaction | Outer scopes, savepoints, and public participation APIs across multiple domains |
71
+ | P01/P03-P06 Persistence and parent/child coordination | Not started | The atomicity conditions below must be established |
72
+ | Triangle review: 155 pairs, 393 cases | Reassessment incomplete | Regenerating the diagrams does not substitute for completing the assessment |
73
73
 
74
- NC/F/RMの全項目を「対応済み」とする資料は作成していない。受入可否はこの表の実装単位と同梱テスト証拠に限定する。
74
+ No document claims that every NC/F/RM item has been addressed. Acceptance claims are limited to the implementation units in this table and the accompanying test evidence.
75
75
 
76
- ## Persistenceをこの適用単位から外した理由
76
+ ## Why Persistence is outside this implementation unit
77
77
 
78
- 現在のAgent初回受付は保存transaction内でTeam予約を読む。AgentからTeam内部への参照は最終設計では解消すべきだが、検証を単純に先行呼出へ移すと次の競合が生じる。
78
+ Initial Agent admission currently reads the Team reservation inside the persistence transaction. The final design should eliminate Agent's reference to Team internals, but simply moving validation to an earlier call creates this race:
79
79
 
80
- 1. 親側が予約の有効性を確認する。
81
- 2. 別の処理が予約を取り消す。
82
- 3. Agentが新しいtransactionで受付記録を保存し、取消済みの子を開始してしまう。
80
+ 1. The parent checks that the reservation is valid.
81
+ 2. Another operation cancels the reservation.
82
+ 3. Agent saves its admission record in a new transaction and starts the cancelled child.
83
83
 
84
- 次の適用単位では、親が所有する予約確認とAgent受付記録を同一scopeで行う参加APIが必要である。親は予約規則、Agentは受付規則、Persistenceは参加とcommit境界を所有する。Agentが親kindをswitchしてTeamを選ぶ現在の逆依存を、新しいcallbackの裏へ隠すだけでは解決にならない。
84
+ The next implementation unit needs a participation API that performs the parent-owned reservation check and records Agent admission within the same scope. The parent owns reservation rules, Agent owns admission rules, and Persistence owns participation and commit boundaries. Merely hiding the current reverse dependency, where Agent switches on parent kind to select Team, behind a new callback would not resolve it.
85
85
 
86
- 具体的に未確定なのは、参加操作の公開keyword/返却値、取消との競合条件、commit後のRuntime admission、停止後の同じ子IDによる照会・再開である。Workflowのhalt/finish snapshotだけで任意action内の子実行が耐障害化されるとは扱わない。Workflow→Agent/Teamの具体経路、checkpoint、結果取込一回性をP05で定める。成否不明は単一record一致だけで成功にせず、複数domainの証拠をP06で定める。
86
+ The unresolved details are public participation keywords/return values, races with cancellation, post-commit Runtime admission, and querying/resuming with the same child ID after interruption. Workflow halt/finish snapshots alone do not make child execution inside arbitrary actions durable. P05 must define the concrete Workflow-to-Agent/Team paths, checkpoints, and one-time result incorporation. Unknown outcomes must not be treated as success based on a single matching record; P06 must define evidence across multiple domains.
87
87
 
88
- そのため既存Persistence facade、Team受付検証、予約・子記録のtransaction境界を本変更では改変しない。保証を弱めた仮実装を入れず、次の仕様・実装単位として残す。
88
+ Therefore this change does not alter the existing Persistence facade, Team admission validation, or transaction boundaries for reservations and child records. These remain for the next specification and implementation unit, rather than introducing provisional code with weaker guarantees.
89
89
 
90
- ## 解析図の読み方
90
+ ## Reading the analysis diagrams
91
91
 
92
- 実ソースとRBSから再生成する。従来の水平帯・グループ色・個別module枠を維持し、文字の背景は透過。M33/M41/M44への矢印は表示のみ省略し、JSON・行列・境界判定にはすべて残す。旧IDは再利用せず退役させる。
92
+ Regenerate the diagrams from actual source and RBS. Preserve the existing horizontal bands, group colors, individual module boxes, and transparent text backgrounds. Arrows to M33/M41/M44 are omitted only from the display; retain them in JSON, matrices, and boundary assessments. Retire old IDs instead of reusing them.
93
93
 
94
- これは修正版candidateの実測図であり、全r8完了時の構想図ではない。残る循環・逆依存もそのまま出力する。静的解析で見えない注入先・動的dispatchはRBSだけで完全に証明できない。Engine機構接続とdomain保存の実行テストを併用する。
94
+ These are measured diagrams of the revised candidate, not conceptual diagrams of a completed r8. Include remaining cycles and reverse dependencies. RBS alone cannot fully prove injected targets or dynamic dispatch that static analysis cannot observe. Combine it with execution tests for Engine mechanism bindings and domain persistence.
95
95
 
96
96
  ```bash
97
97
  bundle exec rbs -I sig validate
98
98
  python -m pip install -r tools/architecture/tools/requirements.txt
99
99
  python -m unittest discover -s tools/architecture/tests -v
100
- # lib/sigをcommitした後、未公開candidateでは次の指定を用いる
100
+ # After committing lib/sig, use this option for an unpublished candidate.
101
101
  python tools/architecture/refresh_diagram.py . tmp/architecture-r8-unit1 --candidate
102
102
  ```
103
103
 
104
- 同梱SVGのSHAは作成用のローカルcandidateを示す。利用者が適用してcommitしたSHAとは異なるため、適用後の図はそのcheckoutで再生成する。Rubyの検証環境、件数、skip理由、未検証環境と適用手順は配布パッケージの検証報告を参照する。
104
+ The SHA in the supplied SVG identifies the local candidate used to generate it. It differs from the SHA created when the user applies and commits the changes, so regenerate the post-application diagrams from that checkout. See the distribution package's verification report for the Ruby environment, test counts, skip reasons, unverified environments, and application procedure.
@@ -1,55 +1,55 @@
1
- # r8 unit 2:親の予約確認とAgent受付
1
+ # r8 unit 2: Parent reservation checks and Agent admission
2
2
 
3
- この単位はP02/P03の受付境界を実装する。基準はcore `16e6fcb2dd49836735598525114abfc256d0773e`。r8全体やPersistenceの全面整理の完了ではない。
3
+ This unit implements the P02/P03 admission boundary. The core baseline is `16e6fcb2dd49836735598525114abfc256d0773e`. It does not complete all of r8 or the entire Persistence reorganization.
4
4
 
5
- ## 責務と操作
5
+ ## Responsibilities and operations
6
6
 
7
- | 担当 | 公開操作・共通規則 | 依存と内部実装 |
7
+ | Owner | Public operations and shared rules | Dependencies and internal implementation |
8
8
  |---|---|---|
9
- | 共通Persistence | `atomic`、`Transaction#participate`、`committed?`。同じPersistence、同期thread、有効scope、savepoint、commit応答を検証 | Storageの公開transaction・scope規則を利用。Agent/Team/Workflowや構成担当を選ばない |
10
- | Agent | `Admission#accept_in`。入力記録・実行ID・Agentの受付とrevision更新を同一scopeへ保存 | Agentの保存担当を使用。親のkind・Team割当・subagent snapshot・Handoff予約を解釈しない |
11
- | MultiAgent | `ReservedChildAdmission#admit`。親の取消・slot・子IDを検証し、Agent受付を同じscopeへ参加させる | 自分の保存担当が予約の根拠を読み、必要なguardを取得する |
12
- | 保存担当 | `Agent::Persistence::Admission`、`MultiAgent::Persistence::Reservation` | raw Storage viewはこの境界で使用。ドメイン操作へraw viewを渡さない |
9
+ | Shared Persistence | `atomic`, `Transaction#participate`, and `committed?`; validates the same Persistence instance, synchronous thread, active scope, savepoints, and commit acknowledgements | Uses Storage's public transaction/scope rules; does not select Agent, Team, Workflow, or composition components |
10
+ | Agent | `Admission#accept_in`; persists input records, execution identity, Agent admission, and revision updates in the same scope | Uses Agent's persistence component; does not interpret parent kind, Team assignments, subagent snapshots, or Handoff reservations |
11
+ | MultiAgent | `ReservedChildAdmission#admit`; validates parent cancellation, slot, and child ID, and has Agent admission participate in the same scope | Its own persistence component reads the reservation evidence and acquires the required guards |
12
+ | Persistence components | `Agent::Persistence::Admission`, `MultiAgent::Persistence::Reservation` | Uses raw Storage views at this boundary; does not pass raw views to domain operations |
13
13
 
14
- AgentのRuntime admission取得、FSM開始、live状態の反映は既存のExecutionCoordinatorが引き続き所有する。新しいAdmissionはその短い保存フェーズだけであり、Agent実行全体を親のDB transactionへ入れない。通常のアプリは新しい参加クラスを実装・生成する必要がない。
14
+ The existing ExecutionCoordinator continues to own acquiring Agent Runtime admission, starting the FSM, and applying live state. The new Admission covers only the short persistence phase; it does not place the entire Agent execution inside the parent's database transaction. Ordinary applications do not need to implement or instantiate the new participation classes.
15
15
 
16
- `phronomy_admission` は内部の現在の配線であり、Procやオブジェクトを保存しない。永続化するのは従来の相関情報と親子IDだけ。Team/subagent/Handoffの開始・再開担当が現在の参加者を渡す。保存済み実行への再接続はExactExecutionの同一ID照合と復旧規則を維持する。
16
+ `phronomy_admission` is current internal wiring; no Proc or object is persisted. Only the existing correlation information and parent/child IDs are stored. The Team/subagent/Handoff start and resume components supply the current participant. Reconnecting to a persisted execution preserves ExactExecution's same-ID matching and recovery rules.
17
17
 
18
- ## 保存順序と失敗
18
+ ## Persistence ordering and failures
19
19
 
20
- 1. Agentが既存のRuntime受付を取得し、同期workerで保存操作を開始する。
21
- 2. MultiAgentが短い`atomic` scopeを開き、親のguardを取得してから予約を読み直す。
22
- 3. 親の取消・割当・子の識別子を検証する。Agentは同じscopeで入力内容・AgentExecution・AgentRootを保存する。
23
- 4. commit応答が成功した後に、Agent実行担当だけが受付結果を取得し、準備・FSM・live反映を進める。
20
+ 1. Agent acquires the existing Runtime admission and begins the persistence operation on a synchronous worker.
21
+ 2. MultiAgent opens a short `atomic` scope, acquires the parent guard, and then rereads the reservation.
22
+ 3. It validates parent cancellation, assignment, and child identity. Agent stores the input content, AgentExecution, and AgentRoot in the same scope.
23
+ 4. Only after a successful commit acknowledgement does the Agent execution component obtain the admission result and continue preparation, FSM execution, and live-state updates.
24
24
 
25
- 参加操作の戻り値はcommit成功を意味しない。`accept_in`はnilを返し、Agent内部の`result`は外側のcommitまで利用できない。二重参加、別Persistence、別thread、終了後scopeは拒否する。同じbackendを包む別Persistenceも同一scopeと扱わない。raw backend transactionの中から新しくcommit所有者を名乗ることも拒否する。
25
+ A participation operation's return value does not mean that commit succeeded. `accept_in` returns nil, and the Agent-internal `result` is unavailable until the outer commit. Duplicate participation, a different Persistence instance, a different thread, or an expired scope is rejected. Separate Persistence instances wrapping the same backend are not treated as the same scope. Code inside a raw backend transaction cannot claim to be a new commit owner.
26
26
 
27
- 明示的な入れ子はsavepointとして動く。内側が成功しても外側がrollbackした場合は未成立。参加処理中の例外を内側で捕捉しても、失敗したscopeの先行変更をcommitできない。LLM、Tool、scheduler、外部callback、非同期待機を参加処理へ入れない。
27
+ Explicit nesting uses savepoints. Inner success is not committed if the outer transaction rolls back. Even if an exception during participation is caught inside the scope, earlier changes in that failed scope cannot be committed. Do not perform LLM calls, Tool calls, scheduling, external callbacks, or asynchronous waits inside participation operations.
28
28
 
29
- Storageのscope違反は`Persistence::TransactionError`へcause・backtraceを保持して変換する。この名前の変更は、保存成否が既知であるとの宣言ではない。IOError等の成否不明な保存失敗は変換・自動retryせず、既存のAgent復旧規則へ渡す。今回、一般化した保存成否照合APIは追加していない。
29
+ Storage scope violations are translated into `Persistence::TransactionError`, preserving cause and backtrace. This naming change does not assert that the persistence outcome is known. Persistence failures with unknown outcomes, such as IOError, are neither translated nor automatically retried; they pass to existing Agent recovery rules. This unit does not add a generalized persistence-outcome reconciliation API.
30
30
 
31
- ## 取消との競合
31
+ ## Races with cancellation
32
32
 
33
- TeamはTeamRoot、subagentは親AgentRoot、Handoffはrouting recordをguardとする。PostgreSQLではそのguardの行ロックと既存の条件付き更新によって、取消・変更と子受付を順序付ける。子受付側の通常readだけでは、この保証は成立しなかった。
33
+ Team uses TeamRoot as its guard, subagents use the parent AgentRoot, and Handoff uses the routing record. On PostgreSQL, row locks on the guard and existing conditional updates order cancellation/changes against child admission. Ordinary reads on the child admission path alone did not provide this guarantee.
34
34
 
35
- Handoff取消側は最初に子の状態を観測し、未完了/不在ならroutingをロックして**子の状態を再取得**する。待機中に子受付がcommitした場合、古い「不在」の判断を捨て、受付済みの子へ公開取消を送る。既に終端の実行への取消は従来どおり結果参照として扱う。
35
+ The Handoff cancellation path first observes the child state. If the child is incomplete or absent, it locks routing and **reads the child state again**. If child admission committed while it was waiting, it discards the stale absence observation and sends public cancellation to the admitted child. Cancellation of an already terminal execution continues to act as result access.
36
36
 
37
- InMemoryは共有Monitor、SQLiteはtransactionと書込競合検出、PostgreSQLは行ロックを使用する。SQLiteで競合したtransactionは成功とみなさず、backendの失敗を扱う。分散leaseや外部副作用のexactly-onceは追加しない。実PostgreSQLでの待機順序はexamplesの新しい3件の並行テストで確認する対象であり、InMemory/SQLiteの成功から推定して済ませない。
37
+ InMemory uses a shared Monitor, SQLite uses transactions and write-conflict detection, and PostgreSQL uses row locks. A conflicting SQLite transaction is not considered successful; its backend failure is handled. No distributed lease or exactly-once guarantee for external effects is added. Actual PostgreSQL waiting order is to be checked by the three new concurrency tests in examples; it must not be inferred from successful InMemory/SQLite tests.
38
38
 
39
- ## API・ファイル変更
39
+ ## API and file changes
40
40
 
41
- - Agent::InitialPreparationの`build_admitted_execution`と3種の親検証・kind分岐を削除。Agent自身の受付共通処理とMultiAgentの予約判断へ分離した。
42
- - 共通の参加frameworkを`persistence/transaction.rb`、Agent受付を`agent/admission.rb`、保存接続を既存の各domainの`persistence/`へ置いた。新しいディレクトリや独立Contractは増やしていない。
43
- - Storage SPIに同期contextの`transaction_open?`を追加。Storage::Backendの継承実装には共通実装が提供される。継承しない独自SPI実装はこの操作も提供する必要がある。RBS・SPI snapshot・duck-typed backendの検証を更新した。
44
- - Persistenceの既知scope失敗の公開型を`Persistence::TransactionError`へ統一し、旧Storage例外のaliasは設けない。Storageを直接使う処理では従来のStorage例外を使用する。
45
- - RBSはsigに配置し、参加者factory、Agent受付、MultiAgentの依存を宣言する。動的な`phronomy_admission`注入も本書と利用箇所で追跡する。
46
- - 依存解析のExecution境界規則を図のrevision表示名から分離した。unit名の更新で同期backendからExecutionへの禁止規則が解除されないことを回帰テストする。
47
- - 保存recordの形式、ID、revision規則は変更していない。データ移行は不要。
41
+ - Remove Agent::InitialPreparation's `build_admitted_execution`, its three kinds of parent validation, and its parent-kind branches. Separate shared Agent admission handling from MultiAgent reservation decisions.
42
+ - Place the shared participation framework in `persistence/transaction.rb`, Agent admission in `agent/admission.rb`, and persistence bindings in each domain's existing `persistence/`. No new directory or independent Contract is added.
43
+ - Add synchronous-context `transaction_open?` to the Storage SPI. Implementations inheriting Storage::Backend receive a shared implementation. Custom SPI implementations that do not inherit it must also provide this operation. Update RBS, the SPI snapshot, and duck-typed backend validation.
44
+ - Unify the public type for known Persistence scope failures as `Persistence::TransactionError`; do not add an alias for the old Storage exception. Code using Storage directly continues to use the existing Storage exception.
45
+ - Place RBS in sig and declare participant factories, Agent admission, and MultiAgent dependencies. Track dynamic `phronomy_admission` injection in this document and at its use sites.
46
+ - Separate dependency analysis rules for the Execution boundary from the diagram's revision display name. Add a regression test ensuring that changing the unit name does not disable the prohibition on synchronous-backend dependencies on Execution.
47
+ - Preserve persisted record formats, IDs, and revision rules. No data migration is required.
48
48
 
49
- ## 残る課題
49
+ ## Outstanding work
50
50
 
51
- `Persistence#transaction`とdomain repositoryの一括窓口は現行利用箇所が残るため、この単位では全面削除していない。互換維持のために新しい旧名aliasを追加したものではないが、P01/DP04の完了条件は未達である。次にdomain照会・保存構成を移し、不要な窓口を利用側と同時に削除する。
51
+ `Persistence#transaction` and the combined domain-repository facade still have callers and are not fully removed in this unit. This does not add new aliases for old names to preserve compatibility, but the P01/DP04 completion conditions remain unmet. Next, move domain queries and persistence composition, then remove unnecessary entry points together with their callers.
52
52
 
53
- MultiAgentの保存担当にはAgentのexecution/Handoff repositoryへの参照が残る。予約検証の所有者は整理したが、親子の公開投影・認可照会・結果取込まで隠蔽したとは扱わない。P04/F02/F03の残課題として、Agentが公開する操作と、MultiAgentが所有すべき保存形式を確定する。一般的なmetadata getterを足すだけの解決にはしない。
53
+ MultiAgent's persistence component still references Agent execution/Handoff repositories. Ownership of reservation validation has been clarified, but this does not mean that public parent/child projections, authorization queries, and result incorporation have all been encapsulated. Under the remaining P04/F02/F03 work, establish the operations Agent should expose and the persistence formats MultiAgent should own. Adding a generic metadata getter alone is not a solution.
54
54
 
55
- Agent/TeamのFSM接続、Workflowのdurableな子連携(P05)、複数記録の保存成否照合(P06)、残りの配置整理、155組・393件の意味的再判定も残る。今回のSVGは実装候補を描き、全体の循環解消を示す構想図にはしない。
55
+ Agent/Team FSM bindings, durable Workflow child coordination (P05), reconciliation of persistence outcomes across multiple records (P06), the remaining layout reorganization, and semantic reassessment of 155 pairs/393 cases also remain outstanding. The SVG for this unit depicts the implementation candidate, not a conceptual graph claiming that all cycles have been eliminated.