phronomy 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mutant.yml +9 -9
- data/CHANGELOG.md +52 -0
- data/CONTRIBUTING.md +8 -8
- data/README.md +9 -3
- data/benchmark/bench_agent_invoke.rb +25 -50
- data/benchmark/bench_context_assembler.rb +14 -11
- data/benchmark/bench_regression.rb +1 -1
- data/benchmark/bench_tool_schema.rb +1 -1
- data/docs/architecture/agent-chat-and-state-ownership.md +7 -1
- data/docs/architecture/agent-transition-ownership.md +13 -89
- data/docs/architecture/backend-groups.md +152 -0
- data/docs/architecture/before-llm-input.md +3 -3
- data/docs/architecture/context-management.md +1 -1
- data/docs/architecture/execution-abstraction-review.md +88 -0
- data/docs/architecture/execution-boundaries.md +28 -0
- data/docs/architecture/execution-metadata-and-values.md +6 -0
- data/docs/architecture/multi-agent-handoff.md +6 -5
- data/docs/architecture/persistence.md +27 -9
- data/docs/architecture/r8-unit1.md +104 -0
- data/docs/architecture/r8-unit10.md +72 -0
- data/docs/architecture/r8-unit11.md +71 -0
- data/docs/architecture/r8-unit12.md +67 -0
- data/docs/architecture/r8-unit13.md +61 -0
- data/docs/architecture/r8-unit14.md +72 -0
- data/docs/architecture/r8-unit15.md +65 -0
- data/docs/architecture/r8-unit16.md +54 -0
- data/docs/architecture/r8-unit17.md +73 -0
- data/docs/architecture/r8-unit18.md +92 -0
- data/docs/architecture/r8-unit19.md +61 -0
- data/docs/architecture/r8-unit2.md +55 -0
- data/docs/architecture/r8-unit20.md +51 -0
- data/docs/architecture/r8-unit21.md +79 -0
- data/docs/architecture/r8-unit22.md +74 -0
- data/docs/architecture/r8-unit23.md +81 -0
- data/docs/architecture/r8-unit3.md +130 -0
- data/docs/architecture/r8-unit4.md +79 -0
- data/docs/architecture/r8-unit5.md +115 -0
- data/docs/architecture/r8-unit6.md +71 -0
- data/docs/architecture/r8-unit7.md +70 -0
- data/docs/architecture/r8-unit8.md +78 -0
- data/docs/architecture/r8-unit9.md +73 -0
- data/docs/architecture/refactoring-closure.md +10 -1
- data/docs/architecture/remaining-refactoring-plan.md +16 -0
- data/docs/architecture/storage-execution-boundaries.md +54 -0
- data/docs/architecture/tool-schema-recording-gap.md +6 -0
- data/docs/architecture/tracing.md +1 -1
- data/docs/architecture/workflow-terminal-ownership-design.md +2 -2
- data/docs/architecture.md +24 -11
- data/docs/decisions/015-tool-public-facade-and-rbs-boundary.md +3 -3
- data/docs/decisions/027-llm-adapter-provider-boundary.md +2 -0
- data/docs/decisions/030-agent-handoff-domain-and-durable-responsibility.md +2 -0
- data/docs/decisions/031-durable-multi-agent-coordination.md +2 -0
- data/docs/decisions/032-storage-backend-composition.md +5 -0
- data/docs/decisions/034-handoff-runner-coordination-ownership.md +2 -0
- data/docs/decisions/035-tool-executor-capability-ownership.md +1 -1
- data/docs/decisions/038-responsibility-based-source-layout.md +14 -0
- data/docs/decisions/039-runtime-configuration-lifecycle-ownership.md +8 -0
- data/docs/decisions/040-configuration-default-composition.md +12 -1
- data/docs/decisions/045-worker-input-restriction-ownership.md +4 -0
- data/docs/decisions/051-execution-outcome-worker-ownership.md +2 -0
- data/docs/decisions/056-workflow-terminal-policy-ownership.md +1 -1
- data/docs/decisions/058-neutral-storage-primitives.md +5 -0
- data/docs/decisions/059-backend-contracts-and-async-clients.md +74 -0
- data/docs/decisions/060-runtime-settings-and-application-configuration.md +86 -0
- data/docs/decisions/061-persistence-failure-contracts.md +89 -0
- data/docs/decisions/062-content-store-service.md +52 -0
- data/docs/decisions/063-execution-contracts-and-services.md +88 -0
- data/docs/decisions/064-agent-execution-and-multi-agent-responsibility.md +36 -0
- data/docs/decisions/065-vector-and-embeddings-common-operations.md +38 -0
- data/docs/decisions/066-llm-and-tool-operation-contracts.md +20 -0
- data/docs/decisions/067-agent-progress-and-engine-connection.md +29 -0
- data/docs/decisions/068-agent-tool-child-progress-and-tool-operation.md +36 -0
- data/docs/decisions/README.md +18 -1
- data/docs/execution-boundaries-preview.md +45 -0
- data/docs/features.md +8 -3
- data/docs/getting-started.md +9 -6
- data/docs/migrations/0.22.md +2 -2
- data/docs/migrations/durable-semantic-coordination-v2.md +2 -0
- data/docs/migrations/handoff-runner-multi-agent.md +2 -0
- data/docs/migrations/persistence-failure-contracts.md +67 -0
- data/docs/migrations/r8-unit10.md +36 -0
- data/docs/migrations/r8-unit11.md +33 -0
- data/docs/migrations/r8-unit12.md +31 -0
- data/docs/migrations/r8-unit13.md +36 -0
- data/docs/migrations/r8-unit14.md +31 -0
- data/docs/migrations/r8-unit15.md +31 -0
- data/docs/migrations/r8-unit16.md +26 -0
- data/docs/migrations/r8-unit17.md +28 -0
- data/docs/migrations/r8-unit18.md +29 -0
- data/docs/migrations/r8-unit19.md +28 -0
- data/docs/migrations/r8-unit20.md +24 -0
- data/docs/migrations/r8-unit21.md +28 -0
- data/docs/migrations/r8-unit22.md +29 -0
- data/docs/migrations/r8-unit23.md +20 -0
- data/docs/migrations/r8-unit4.md +67 -0
- data/docs/migrations/r8-unit5.md +75 -0
- data/docs/migrations/r8-unit6.md +109 -0
- data/docs/migrations/r8-unit7.md +31 -0
- data/docs/migrations/r8-unit8.md +33 -0
- data/docs/migrations/r8-unit9.md +28 -0
- data/docs/migrations/storage-async-client.md +103 -0
- data/docs/migrations/vector-async-clients.md +110 -0
- data/docs/persistence-backends.md +38 -21
- data/docs/runtime-and-concurrency.md +26 -1
- data/lib/phronomy/agent/admission.rb +78 -0
- data/lib/phronomy/agent/{lifecycle_contract/agent_already_exists_error.rb → agent_already_exists_error.rb} +1 -1
- data/lib/phronomy/agent/{lifecycle_contract/agent_busy_error.rb → agent_busy_error.rb} +1 -1
- data/lib/phronomy/agent/{lifecycle_contract/agent_purged_error.rb → agent_purged_error.rb} +1 -1
- data/lib/phronomy/{recovery → agent/api}/execution_rehydration_required_error.rb +1 -1
- data/lib/phronomy/agent/async_event_api.rb +37 -32
- data/lib/phronomy/agent/base.rb +74 -72
- data/lib/phronomy/agent/before_llm_input.rb +64 -0
- data/lib/phronomy/agent/composition/run_once.rb +1 -1
- data/lib/phronomy/agent/{context_assembly/context_candidate_resolver.rb → context_candidate_resolver.rb} +2 -2
- data/lib/phronomy/agent/{context_assembly/context_assembler.rb → context_preparation.rb} +35 -221
- data/lib/phronomy/agent/control_request.rb +21 -0
- data/lib/phronomy/agent/execution/agent_execution.rb +1 -1
- data/lib/phronomy/agent/execution/agent_invocation.rb +27 -53
- data/lib/phronomy/agent/execution/approval_resume_commit.rb +1 -1
- data/lib/phronomy/agent/execution/dispatch_preparation.rb +17 -127
- data/lib/phronomy/agent/execution/exact_execution.rb +44 -23
- data/lib/phronomy/agent/execution/execution_cancellation.rb +8 -4
- data/lib/phronomy/agent/execution/execution_coordinator.rb +214 -395
- data/lib/phronomy/agent/execution/execution_metadata.rb +1 -0
- data/lib/phronomy/agent/execution/execution_outcome_committer.rb +70 -126
- data/lib/phronomy/agent/execution/execution_registry.rb +6 -2
- data/lib/phronomy/agent/execution/execution_session_runner.rb +22 -27
- data/lib/phronomy/agent/execution/initial_preparation.rb +18 -116
- data/lib/phronomy/agent/execution/{agent_invocation_session_builder.rb → invocation_actions.rb} +54 -194
- data/lib/phronomy/agent/execution/invocation_transitions.rb +39 -1
- data/lib/phronomy/agent/execution/runtime_record_encoder.rb +7 -7
- data/lib/phronomy/agent/execution_change.rb +161 -0
- data/lib/phronomy/agent/execution_environment.rb +36 -0
- data/lib/phronomy/agent/execution_extension_state.rb +21 -0
- data/lib/phronomy/agent/execution_observation.rb +35 -0
- data/lib/phronomy/agent/filterable.rb +182 -0
- data/lib/phronomy/agent/handoff/{handoff_context.rb → transfer_context.rb} +4 -4
- data/lib/phronomy/agent/handoff/{handoff_projection.rb → transfer_projection.rb} +14 -33
- data/lib/phronomy/{llm_contract/transport_error.rb → agent/handoff_error.rb} +1 -1
- data/lib/phronomy/agent/journal/journal_projection.rb +1 -1
- data/lib/phronomy/agent/knowledge_item.rb +13 -0
- data/lib/phronomy/agent/lifecycle/agent_root.rb +1 -1
- data/lib/phronomy/agent/lifecycle/ownership_registry.rb +18 -23
- data/lib/phronomy/agent/persistence/agent_repository.rb +29 -21
- data/lib/phronomy/agent/persistence/cancellation_repository.rb +51 -0
- data/lib/phronomy/agent/persistence/codec.rb +1 -21
- data/lib/phronomy/agent/persistence/execution_repository.rb +57 -41
- data/lib/phronomy/agent/persistence/journal_repository.rb +27 -18
- data/lib/phronomy/agent/persistence/records.rb +33 -0
- data/lib/phronomy/agent/persistence/retention_repository.rb +70 -0
- data/lib/phronomy/agent/persistence/storage_schema.rb +7 -2
- data/lib/phronomy/agent/persistence/watermark.rb +13 -11
- data/lib/phronomy/agent/recovery/invocation_restorer.rb +13 -21
- data/lib/phronomy/agent/recovery/recovery_coordinator/continuation.rb +10 -9
- data/lib/phronomy/agent/recovery/recovery_coordinator/installation.rb +27 -27
- data/lib/phronomy/agent/recovery/recovery_coordinator/resolution.rb +19 -21
- data/lib/phronomy/agent/recovery/recovery_coordinator.rb +23 -16
- data/lib/phronomy/agent/recovery/recovery_rules.rb +119 -0
- data/lib/phronomy/agent/recovery/recovery_support.rb +8 -11
- data/lib/phronomy/agent/reserved_execution.rb +16 -0
- data/lib/phronomy/agent/retention.rb +17 -0
- data/lib/phronomy/agent/runtime_binding/engine_environment.rb +60 -0
- data/lib/phronomy/agent/runtime_binding/engine_session_builder.rb +34 -0
- data/lib/phronomy/agent/runtime_binding/phase_machine_builder.rb +64 -0
- data/lib/phronomy/agent/runtime_binding/tool_session_builder.rb +34 -0
- data/lib/phronomy/agent/{context_assembly/ruby_llm_materializer.rb → runtime_input.rb} +18 -35
- data/lib/phronomy/agent/{context_assembly/saved_context_reader.rb → saved_context_reader.rb} +6 -4
- data/lib/phronomy/agent/settings.rb +47 -0
- data/lib/phronomy/agent/{context_assembly/state_writer.rb → state_writer.rb} +4 -3
- data/lib/phronomy/agent/store.rb +253 -0
- data/lib/phronomy/agent/{lifecycle_contract/stream_callback_error.rb → stream_callback_error.rb} +1 -1
- data/lib/phronomy/agent/tool_execution/tool_binding.rb +4 -64
- data/lib/phronomy/agent/tool_execution/tool_invocation.rb +50 -219
- data/lib/phronomy/agent/tool_execution/tool_invocation_actions.rb +107 -0
- data/lib/phronomy/agent/tool_execution/tool_invocation_transitions.rb +70 -0
- data/lib/phronomy/configuration/runtime_settings.rb +49 -0
- data/lib/phronomy/content_store/storage_schema.rb +1 -0
- data/lib/phronomy/content_store/stored_contents.rb +2 -1
- data/lib/phronomy/context/assembly.rb +202 -0
- data/lib/phronomy/{llm_contract/context_budget_exceeded_error.rb → context/budget_exceeded_error.rb} +3 -1
- data/lib/phronomy/context/candidate.rb +51 -0
- data/lib/phronomy/context/constraint.rb +47 -0
- data/lib/phronomy/{agent/context_contract → context}/context_plan.rb +1 -1
- data/lib/phronomy/{agent/context_contract → context}/context_plan_validator.rb +3 -3
- data/lib/phronomy/{agent/context_contract → context}/context_policy.rb +1 -1
- data/lib/phronomy/{agent/context_contract → context}/context_policy_input.rb +1 -1
- data/lib/phronomy/{agent/context_assembly → context}/context_policy_input_builder.rb +1 -1
- data/lib/phronomy/context/default_policy.rb +140 -0
- data/lib/phronomy/context/final_budget_validator.rb +33 -0
- data/lib/phronomy/{agent/context_contract → context}/llm_input_build_context.rb +1 -1
- data/lib/phronomy/{agent/context_contract → context}/llm_input_manifest.rb +19 -19
- data/lib/phronomy/{agent/context_contract → context}/llm_input_patch.rb +1 -1
- data/lib/phronomy/context/manifest_error.rb +10 -0
- data/lib/phronomy/context/prompt_template.rb +98 -0
- data/lib/phronomy/{vector_store → documents}/loader/base.rb +1 -1
- data/lib/phronomy/{vector_store → documents}/loader/csv_loader.rb +2 -2
- data/lib/phronomy/{vector_store → documents}/loader/markdown_loader.rb +3 -3
- data/lib/phronomy/{vector_store → documents}/loader/plain_text_loader.rb +2 -2
- data/lib/phronomy/{vector_store → documents}/splitter/base.rb +1 -1
- data/lib/phronomy/{vector_store → documents}/splitter/fixed_size_splitter.rb +2 -2
- data/lib/phronomy/{vector_store → documents}/splitter/recursive_splitter.rb +2 -2
- data/lib/phronomy/embeddings/async/async_client.rb +44 -0
- data/lib/phronomy/embeddings/backends/ruby_llm_embeddings.rb +48 -0
- data/lib/phronomy/embeddings/base.rb +43 -0
- data/lib/phronomy/embeddings/invalid_result_error.rb +11 -0
- data/lib/phronomy/embeddings/transport_error.rb +11 -0
- data/lib/phronomy/engine/concurrency/offload_pool.rb +36 -21
- data/lib/phronomy/engine/concurrency/pool_registry.rb +47 -12
- data/lib/phronomy/engine/diagnostics.rb +1 -1
- data/lib/phronomy/engine/event_loop.rb +7 -7
- data/lib/phronomy/engine/execution_binding.rb +23 -0
- data/lib/phronomy/engine/execution_receiver_binding.rb +43 -0
- data/lib/phronomy/engine/fsm_protocol.rb +1 -6
- data/lib/phronomy/engine/fsm_session.rb +3 -3
- data/lib/phronomy/engine/metrics.rb +16 -14
- data/lib/phronomy/engine/runtime/timer_queue.rb +1 -1
- data/lib/phronomy/engine/runtime.rb +25 -12
- data/lib/phronomy/engine/terminal_decision.rb +7 -0
- data/lib/phronomy/execution/async_operation.rb +41 -0
- data/lib/phronomy/{engine → execution}/blocking.rb +2 -2
- data/lib/phronomy/{engine → execution}/concurrency/cancellation_token.rb +1 -1
- data/lib/phronomy/{engine → execution}/concurrency/deadline.rb +0 -17
- data/lib/phronomy/{engine → execution}/concurrency/physical_completion_task.rb +1 -1
- data/lib/phronomy/{engine → execution}/concurrency/result_collector.rb +1 -1
- data/lib/phronomy/{engine → execution}/concurrency/result_composition.rb +33 -12
- data/lib/phronomy/{engine/concurrency/subscriptions.rb → execution/concurrency/result_subscriptions.rb} +14 -18
- data/lib/phronomy/execution/concurrency/subscriptions.rb +25 -0
- data/lib/phronomy/{engine → execution}/execution.rb +61 -27
- data/lib/phronomy/execution/execution_receiver.rb +78 -0
- data/lib/phronomy/execution/execution_scope_state.rb +35 -0
- data/lib/phronomy/{engine → execution}/invocation_context.rb +0 -15
- data/lib/phronomy/execution/invocation_controls.rb +73 -0
- data/lib/phronomy/execution/runnable.rb +24 -0
- data/lib/phronomy/{engine → execution}/task_result.rb +3 -3
- data/lib/phronomy/execution/wait_policy.rb +24 -0
- data/lib/phronomy/filter/{contract/filter_block_error.rb → filter_block_error.rb} +1 -1
- data/lib/phronomy/generation/generator_verifier/agent_operation.rb +65 -0
- data/lib/phronomy/generation/generator_verifier/default_parser.rb +27 -0
- data/lib/phronomy/generation/generator_verifier/workflow_builder.rb +2 -2
- data/lib/phronomy/generation/generator_verifier.rb +7 -7
- data/lib/phronomy/llm_adapter/async/async_client.rb +47 -0
- data/lib/phronomy/{llm_contract → llm_adapter}/authentication_error.rb +3 -1
- data/lib/phronomy/llm_adapter/backends/ruby_llm.rb +183 -0
- data/lib/phronomy/llm_adapter/base.rb +49 -68
- data/lib/phronomy/{llm_contract → llm_adapter}/context_length_error.rb +3 -1
- data/lib/phronomy/llm_adapter/invalid_result_error.rb +10 -0
- data/lib/phronomy/llm_adapter/message.rb +62 -0
- data/lib/phronomy/{llm_contract → llm_adapter}/rate_limit_error.rb +3 -1
- data/lib/phronomy/llm_adapter/request.rb +79 -0
- data/lib/phronomy/llm_adapter/response.rb +36 -0
- data/lib/phronomy/llm_adapter/stream_chunk.rb +18 -0
- data/lib/phronomy/llm_adapter/token_usage.rb +64 -0
- data/lib/phronomy/llm_adapter/transport_error.rb +9 -0
- data/lib/phronomy/llm_adapter.rb +3 -16
- data/lib/phronomy/multi_agent/admission_registry.rb +1 -8
- data/lib/phronomy/multi_agent/durable_subagent_coordinator.rb +108 -84
- data/lib/phronomy/multi_agent/execution_environment.rb +29 -0
- data/lib/phronomy/{agent/handoff → multi_agent}/handoff.rb +2 -2
- data/lib/phronomy/{agent/handoff → multi_agent}/handoff_capability_factory.rb +21 -2
- data/lib/phronomy/multi_agent/handoff_participant.rb +79 -0
- data/lib/phronomy/{agent/handoff → multi_agent}/handoff_policy.rb +1 -1
- data/lib/phronomy/multi_agent/handoff_runner.rb +77 -100
- data/lib/phronomy/{agent/handoff → multi_agent}/handoff_state.rb +1 -1
- data/lib/phronomy/multi_agent/orchestrator.rb +61 -75
- data/lib/phronomy/multi_agent/persistence/codec.rb +20 -0
- data/lib/phronomy/multi_agent/persistence/handoff_state_repository.rb +77 -0
- data/lib/phronomy/multi_agent/persistence/records.rb +27 -0
- data/lib/phronomy/multi_agent/persistence/storage_schema.rb +21 -0
- data/lib/phronomy/multi_agent/persistence/team_execution_repository.rb +58 -42
- data/lib/phronomy/multi_agent/persistence/team_repository.rb +29 -21
- data/lib/phronomy/multi_agent/reserved_child_admission.rb +88 -0
- data/lib/phronomy/multi_agent/runtime_binding/engine_environment.rb +35 -0
- data/lib/phronomy/multi_agent/shared_state.rb +2 -2
- data/lib/phronomy/multi_agent/store.rb +156 -0
- data/lib/phronomy/multi_agent/team_coordinator.rb +83 -74
- data/lib/phronomy/multi_agent/team_ownership_registry.rb +2 -12
- data/lib/phronomy/output_parser/parse_error.rb +7 -0
- data/lib/phronomy/persistence/content_repository.rb +26 -0
- data/lib/phronomy/persistence/errors.rb +16 -0
- data/lib/phronomy/persistence/migration/initial_format_migration.rb +2 -2
- data/lib/phronomy/persistence/persistence.rb +23 -0
- data/lib/phronomy/persistence/save_outcome.rb +24 -0
- data/lib/phronomy/persistence/snapshot_comparison.rb +81 -0
- data/lib/phronomy/persistence/storage_boundary.rb +32 -0
- data/lib/phronomy/persistence/transaction.rb +86 -0
- data/lib/phronomy/persistence_composition/storage_schema.rb +9 -4
- data/lib/phronomy/persistence_composition/stores.rb +34 -0
- data/lib/phronomy/persistence_composition/unit4_migration.rb +276 -0
- data/lib/phronomy/runtime_composition/agent_defaults.rb +5 -1
- data/lib/phronomy/runtime_composition/configuration.rb +146 -0
- data/lib/phronomy/runtime_composition/evaluation_defaults.rb +7 -0
- data/lib/phronomy/runtime_composition/execution_defaults.rb +5 -0
- data/lib/phronomy/runtime_composition/generation_defaults.rb +6 -0
- data/lib/phronomy/runtime_composition/global_configuration.rb +38 -0
- data/lib/phronomy/runtime_composition/multi_agent_defaults.rb +9 -0
- data/lib/phronomy/runtime_composition/workflow_defaults.rb +4 -0
- data/lib/phronomy/storage/async/async_client.rb +60 -0
- data/lib/phronomy/storage/backend.rb +8 -2
- data/lib/phronomy/testing/eval/metrics.rb +1 -1
- data/lib/phronomy/testing/eval/scorer/llm_judge.rb +19 -3
- data/lib/phronomy/testing/persistence_contract/a_content_store.rb +2 -2
- data/lib/phronomy/testing/persistence_contract/a_journal_repository.rb +6 -6
- data/lib/phronomy/testing/persistence_contract/a_persistence_backend.rb +55 -52
- data/lib/phronomy/testing/persistence_contract/a_workflow_state_repository.rb +3 -3
- data/lib/phronomy/testing/persistence_contract/an_agent_repository.rb +7 -7
- data/lib/phronomy/testing/persistence_contract/an_execution_repository.rb +11 -11
- data/lib/phronomy/testing/persistence_contract/coordination_repositories.rb +57 -51
- data/lib/phronomy/testing/persistence_contract/neutral_storage_primitives.rb +1 -1
- data/lib/phronomy/testing/persistence_contract/storage_transaction_boundaries.rb +23 -22
- data/lib/phronomy/tool/authorization.rb +77 -0
- data/lib/phronomy/tool/base.rb +549 -9
- data/lib/phronomy/tool/call_request.rb +40 -0
- data/lib/phronomy/{agent/tool_execution/tool_definition_set.rb → tool/definition_set.rb} +7 -8
- data/lib/phronomy/tool/operation.rb +88 -0
- data/lib/phronomy/tool/schema.rb +214 -0
- data/lib/phronomy/tool/settings.rb +31 -0
- data/lib/phronomy/tool/tool_error.rb +7 -0
- data/lib/phronomy/tool/tool_executor.rb +58 -0
- data/lib/phronomy/tools/agent.rb +22 -90
- data/lib/phronomy/tools/mcp.rb +21 -14
- data/lib/phronomy/tools/vector_search.rb +4 -4
- data/lib/phronomy/tracing/automatic.rb +11 -6
- data/lib/phronomy/tracing/base.rb +1 -1
- data/lib/phronomy/tracing/observation.rb +37 -0
- data/lib/phronomy/tracing/settings.rb +36 -0
- data/lib/phronomy/vector_store/{async_backend.rb → async/async_client.rb} +35 -29
- data/lib/phronomy/vector_store/{in_memory.rb → backends/in_memory.rb} +12 -10
- data/lib/phronomy/vector_store/{pgvector.rb → backends/pgvector.rb} +44 -16
- data/lib/phronomy/vector_store/{redis_search.rb → backends/redis_search.rb} +74 -37
- data/lib/phronomy/vector_store/base.rb +118 -49
- data/lib/phronomy/vector_store/invalid_result_error.rb +12 -0
- data/lib/phronomy/vector_store.rb +2 -17
- data/lib/phronomy/version.rb +1 -1
- data/lib/phronomy/workflow/completion.rb +11 -0
- data/lib/phronomy/workflow/execution/workflow.rb +7 -7
- data/lib/phronomy/workflow/execution/workflow_action_rules.rb +67 -0
- data/lib/phronomy/workflow/execution/workflow_context.rb +2 -2
- data/lib/phronomy/workflow/execution/workflow_execution_environment.rb +27 -0
- data/lib/phronomy/workflow/execution/workflow_execution_registry.rb +3 -5
- data/lib/phronomy/workflow/execution/workflow_runner.rb +58 -79
- data/lib/phronomy/workflow/execution/workflow_settings.rb +28 -0
- data/lib/phronomy/workflow/persistence/state_repository.rb +28 -22
- data/lib/phronomy/workflow/persistence/storage_schema.rb +13 -0
- data/lib/phronomy/workflow/runtime_binding/workflow_engine_environment.rb +38 -0
- data/lib/phronomy/workflow/runtime_binding/workflow_phase_machine_builder.rb +156 -0
- data/lib/phronomy/workflow/{execution → runtime_binding}/workflow_terminal_policy.rb +4 -4
- data/lib/phronomy.rb +57 -16
- data/scripts/api_snapshot.rb +35 -15
- data/sig/_private/phronomy/agent/settings.rbs +19 -0
- data/sig/_private/phronomy/configuration/runtime_settings.rbs +20 -0
- data/sig/_private/phronomy/llm_adapter/async/async_client.rbs +10 -0
- data/sig/_private/phronomy/multi_agent/store.rbs +8 -0
- data/sig/_private/phronomy/persistence/storage_boundary.rbs +7 -0
- data/sig/_private/phronomy/tool/settings.rbs +13 -0
- data/sig/_private/phronomy/tracing/settings.rbs +15 -0
- data/sig/_private/phronomy/workflow/execution/workflow_settings.rbs +13 -0
- data/sig/phronomy/agent/admission.rbs +19 -0
- data/sig/phronomy/agent/execution_contract.rbs +132 -0
- data/sig/phronomy/agent/execution_environment.rbs +20 -0
- data/sig/phronomy/agent/store.rbs +73 -0
- data/sig/phronomy/agent.rbs +14 -138
- data/sig/phronomy/common.rbs +7 -0
- data/sig/phronomy/content_store/contracts.rbs +13 -0
- data/sig/phronomy/context.rbs +152 -0
- data/sig/phronomy/embeddings/async/async_client.rbs +9 -0
- data/sig/phronomy/embeddings/base.rbs +17 -0
- data/sig/phronomy/engine/concurrency/timer_bindings.rbs +22 -0
- data/sig/phronomy/engine/control_bindings.rbs +11 -0
- data/sig/phronomy/engine/control_protocols.rbs +23 -0
- data/sig/phronomy/engine/execution_binding.rbs +6 -0
- data/sig/phronomy/engine/execution_receiver.rbs +15 -0
- data/sig/phronomy/engine/observability.rbs +13 -0
- data/sig/phronomy/execution/async_operation.rbs +7 -0
- data/sig/phronomy/execution/blocking.rbs +5 -0
- data/sig/phronomy/execution/concurrency/cancellation_token.rbs +13 -0
- data/sig/phronomy/execution/concurrency/deadline.rbs +10 -0
- data/sig/phronomy/execution/concurrency/result_composition.rbs +7 -0
- data/sig/phronomy/execution/control_protocols.rbs +18 -0
- data/sig/phronomy/execution/errors.rbs +7 -0
- data/sig/phronomy/execution/execution.rbs +41 -0
- data/sig/phronomy/execution/execution_receiver.rbs +40 -0
- data/sig/phronomy/execution/execution_scope_state.rbs +9 -0
- data/sig/phronomy/execution/invocation_context.rbs +18 -0
- data/sig/phronomy/execution/invocation_controls.rbs +13 -0
- data/sig/phronomy/execution/task_result.rbs +29 -0
- data/sig/phronomy/extensions.rbs +0 -21
- data/sig/phronomy/handoff.rbs +10 -4
- data/sig/phronomy/llm_adapter/backends/ruby_llm.rbs +6 -0
- data/sig/phronomy/llm_adapter/base.rbs +14 -0
- data/sig/phronomy/llm_adapter/usage.rbs +14 -0
- data/sig/phronomy/llm_adapter/values.rbs +43 -0
- data/sig/phronomy/llm_context_window.rbs +10 -0
- data/sig/phronomy/multi_agent/reserved_child_admission.rbs +8 -0
- data/sig/phronomy/multi_agent/store.rbs +54 -0
- data/sig/phronomy/multi_agent.rbs +6 -3
- data/sig/phronomy/persistence/errors.rbs +18 -0
- data/sig/phronomy/persistence/migration.rbs +13 -0
- data/sig/phronomy/persistence/transaction.rbs +19 -0
- data/sig/phronomy/persistence.rbs +1 -99
- data/sig/phronomy/persistence_composition.rbs +19 -0
- data/sig/phronomy/runtime_composition/configuration.rbs +36 -0
- data/sig/phronomy/storage/async/async_client.rbs +8 -0
- data/sig/phronomy/storage/backends/in_memory.rbs +9 -0
- data/sig/phronomy/{storage.rbs → storage/contracts.rbs} +2 -16
- data/sig/phronomy/tool.rbs +48 -4
- data/sig/phronomy/tracing/observation.rbs +7 -0
- data/sig/phronomy/vector_store/async/async_client.rbs +13 -0
- data/sig/phronomy/vector_store/base.rbs +23 -0
- data/sig/phronomy/workflow/execution/workflow_execution_environment.rbs +14 -0
- data/sig/phronomy/workflow/runtime_binding/workflow_terminal_policy.rbs +7 -0
- data/sig/phronomy/workflow/store.rbs +8 -0
- data/sig/phronomy/workflow.rbs +1 -1
- data/sig/phronomy.rbs +0 -49
- metadata +318 -117
- data/lib/phronomy/agent/concerns/before_llm_input.rb +0 -66
- data/lib/phronomy/agent/concerns/error_translation.rb +0 -45
- data/lib/phronomy/agent/concerns/filterable.rb +0 -184
- data/lib/phronomy/agent/context/capability/base.rb +0 -548
- data/lib/phronomy/agent/context/capability/tool_executor.rb +0 -62
- data/lib/phronomy/agent/context/instruction/prompt_template.rb +0 -102
- data/lib/phronomy/agent/context_assembly/runtime_chat_builder.rb +0 -36
- data/lib/phronomy/agent/context_assembly/token_budget_resolver.rb +0 -22
- data/lib/phronomy/agent/context_parts/validators/final_budget_validator.rb +0 -37
- data/lib/phronomy/agent/context_policies/default.rb +0 -142
- data/lib/phronomy/agent/execution/phase_machine_builder.rb +0 -101
- data/lib/phronomy/agent/execution/provider_call_outcome.rb +0 -106
- data/lib/phronomy/agent/handoff/handoff_execution_coordinator.rb +0 -15
- data/lib/phronomy/agent/handoff/handoff_outcome_committer.rb +0 -131
- data/lib/phronomy/agent/handoff/handoff_request.rb +0 -45
- data/lib/phronomy/agent/lifecycle_contract/handoff_error.rb +0 -7
- data/lib/phronomy/agent/persistence/handoff_state_repository.rb +0 -58
- data/lib/phronomy/agent/persistence/queries.rb +0 -61
- data/lib/phronomy/agent/selection/candidate.rb +0 -53
- data/lib/phronomy/agent/selection/constraint.rb +0 -49
- data/lib/phronomy/agent/tool_execution/tool_call_intercepted.rb +0 -29
- data/lib/phronomy/agent/tool_execution/tool_invocation_session_builder.rb +0 -276
- data/lib/phronomy/configuration/configuration.rb +0 -68
- data/lib/phronomy/configuration/global_configuration.rb +0 -26
- data/lib/phronomy/engine/concurrency/cancellation_scope.rb +0 -124
- data/lib/phronomy/engine/concurrency/operation_binding.rb +0 -43
- data/lib/phronomy/engine/execution_receiver.rb +0 -65
- data/lib/phronomy/engine/runnable.rb +0 -54
- data/lib/phronomy/llm_adapter/ruby_llm.rb +0 -47
- data/lib/phronomy/llm_contract/token_usage.rb +0 -85
- data/lib/phronomy/multi_agent/persistence/queries.rb +0 -30
- data/lib/phronomy/multi_agent/storage_contract/team_storage_schema.rb +0 -15
- data/lib/phronomy/output_parser/contract/parse_error.rb +0 -7
- data/lib/phronomy/persistence/api/persistence.rb +0 -140
- data/lib/phronomy/persistence_composition/repositories.rb +0 -77
- data/lib/phronomy/recovery/recovery.rb +0 -186
- data/lib/phronomy/tool/contract/tool_error.rb +0 -7
- data/lib/phronomy/vector_store/embeddings/base.rb +0 -44
- data/lib/phronomy/vector_store/embeddings/ruby_llm_embeddings.rb +0 -47
- data/lib/phronomy/workflow/phase_machine_builder.rb +0 -205
- data/lib/phronomy/workflow/storage_contract/workflow_storage_schema.rb +0 -9
- data/sig/phronomy/execution_receiver.rbs +0 -34
- data/sig/phronomy/llm_adapter.rbs +0 -11
- data/sig/phronomy/runtime.rbs +0 -76
- /data/lib/phronomy/agent/{context_assembly/context_importer.rb → context_importer.rb} +0 -0
- /data/lib/phronomy/{engine → execution}/backpressure_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/cancellation_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/concurrency/worker_input_restricted.rb +0 -0
- /data/lib/phronomy/{engine → execution}/event_loop_reentrancy_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/execution_cancellation_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/execution_timeout_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/invalid_async_entry_action_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/invalid_async_transition_action_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/invalid_async_workflow_action_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/pool_shutdown_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/recursion_limit_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/runtime_shutdown_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/runtime_shutdown_reentrancy_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/scheduler_reentrancy_error.rb +0 -0
- /data/lib/phronomy/{engine → execution}/timeout_error.rb +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Backend responsibilities and asynchronous execution clients
|
|
2
|
+
|
|
3
|
+
The diagram distinguishes responsibility **groups** from its display layers.
|
|
4
|
+
The earlier B1-B6 horizontal bands and topical columns are restored for
|
|
5
|
+
readability. `G14`, `G46`, `G47` and `G48` remain stable responsibility identifiers;
|
|
6
|
+
boundary permissions follow those responsibilities, not B/G numbers or positions.
|
|
7
|
+
Each source directory keeps its own module box and stable module ID. Restoring
|
|
8
|
+
the display does not undo the separation of backend contracts and execution.
|
|
9
|
+
|
|
10
|
+
The restored display puts separated Backend Contracts in B5, alongside but
|
|
11
|
+
distinct from Engine Internals and Execution Contracts. B4 holds Async Clients and separately grouped Implementations. Execution
|
|
12
|
+
operations and values now share G58; the former G59 service split is removed. Backend directories awaiting separation remain visibly mixed
|
|
13
|
+
in B4; their contracts move to B5 in their implemented phase. These are display
|
|
14
|
+
positions, not a shared architectural level or namespace.
|
|
15
|
+
|
|
16
|
+
| Group | Responsibility | Dependency rule |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| G14 Engine Internals | Runtime, workers, FSM and EventLoop | No feature-specific backend or client dependencies |
|
|
19
|
+
| G58 Execution Framework | Submission protocol, TaskResult, Execution, Blocking, controls and common rules | Only Execution and Common, including neutral settings; Engine implements the mechanism |
|
|
20
|
+
| G46 Async Clients | Execute synchronous backend operations through Execution | Use Backend and Execution contracts; no direct Engine or concrete backend selection |
|
|
21
|
+
| G47 Backend Contracts | Synchronous SPI, values, errors and shared rules | No Engine, Execution Services, Async Client or concrete implementation dependencies |
|
|
22
|
+
| G48 Backend Implementations | Implement the synchronous backend SPI | Depend on the corresponding Contracts; no Engine, Execution Services or client dependencies |
|
|
23
|
+
| G57 Content Service | Content IDs, canonical text/JSON and digest integrity over Storage | Uses neutral Storage and Common; no physical backend, Engine or domain orchestration dependencies |
|
|
24
|
+
|
|
25
|
+
Composition chooses concrete backends and supplies them to consumers. These
|
|
26
|
+
are source-ownership groups, not shared Ruby namespaces. Synchronous APIs can
|
|
27
|
+
be called directly. Diagram links represent source references; calls through
|
|
28
|
+
injected objects require separate runtime review.
|
|
29
|
+
|
|
30
|
+
## Implemented phase: P1/P2/P3/P4 (`storage`)
|
|
31
|
+
|
|
32
|
+
P3 adds public VectorStore and Embeddings AsyncClients. Their synchronous
|
|
33
|
+
contracts and implementations have no Engine dependencies. See the
|
|
34
|
+
[public receiver migration](../migrations/vector-async-clients.md).
|
|
35
|
+
|
|
36
|
+
### P2: LLM
|
|
37
|
+
|
|
38
|
+
- Install the AST analyzer, group annotations, SVG formatter and boundary gate
|
|
39
|
+
in `tools/architecture/`. The Architecture workflow checks the committed
|
|
40
|
+
phase and generates evidence for its actual checkout SHA.
|
|
41
|
+
- `LLMAdapter::Base` now defines synchronous generation plus chat construction,
|
|
42
|
+
configuration, message/tool-call values, identity and optional input budget.
|
|
43
|
+
RubyLLM-specific construction and error translation belong to its backend.
|
|
44
|
+
Adapter extensions must implement the new operations; no legacy wrapper remains.
|
|
45
|
+
- `LLMAdapter::AsyncClient` owns the internal `complete_async` and `stream_async`
|
|
46
|
+
operations in `llm_adapter/async/`. It is not a public extension API.
|
|
47
|
+
- `LLMAdapter::RubyLLM` lives in `llm_adapter/backends/` and still inherits Base.
|
|
48
|
+
Its public name, synchronous signatures and default configuration are unchanged.
|
|
49
|
+
- Zeitwerk collapses these two new directories. Neither `Phronomy::Async` nor
|
|
50
|
+
`LLMAdapter::Async` / `LLMAdapter::Backends` is introduced.
|
|
51
|
+
- Agent constructs the framework client around the configured synchronous
|
|
52
|
+
adapter. Custom adapters implement no async methods and need no pool logic.
|
|
53
|
+
|
|
54
|
+
The client preserves `on_full: :raise`, the original pool TaskResult, token
|
|
55
|
+
forwarding and per-chunk cancellation. Transport timeout/retry stays with the
|
|
56
|
+
adapter/provider. Construction starts no Runtime, and the default pool is
|
|
57
|
+
resolved again on each operation; an injected pool stays caller-owned. Only an
|
|
58
|
+
internal lightweight sink runs on the worker; application event callbacks
|
|
59
|
+
continue to run on EventLoop.
|
|
60
|
+
|
|
61
|
+
Use `require "phronomy"` and the public constants. The old implementation path
|
|
62
|
+
`phronomy/llm_adapter/ruby_llm` moves to
|
|
63
|
+
`phronomy/llm_adapter/backends/ruby_llm`; arbitrary partial-load paths are not the
|
|
64
|
+
public loading contract. No shim in the contract directory reintroduces an
|
|
65
|
+
implementation dependency. No public RBS or Stable/Beta API snapshot changes
|
|
66
|
+
are needed in this phase; both are verified unchanged.
|
|
67
|
+
|
|
68
|
+
### P3: VectorStore and Embeddings
|
|
69
|
+
|
|
70
|
+
- `VectorStore::AsyncClient` owns public add/search/remove/clear async operations;
|
|
71
|
+
`VectorStore::Embeddings::AsyncClient` owns public `embed_async`.
|
|
72
|
+
- Backends implement only synchronous methods. The old `AsyncBackend` mixin
|
|
73
|
+
and inherited async methods are removed; application callers change receiver.
|
|
74
|
+
- InMemory, Pgvector, RedisSearch and RubyLLMEmbeddings move into `backends/`
|
|
75
|
+
directories. Their public constants, synchronous signatures and bodies stay
|
|
76
|
+
unchanged. Zeitwerk explicitly collapses the new `async/` and `backends/` paths.
|
|
77
|
+
- Synchronous RBS uses structural `_CancellationSignal`; async signatures keep
|
|
78
|
+
TaskResult and the execution token. The public API snapshot records the new
|
|
79
|
+
receivers and the intentional removals from Base/InMemory.
|
|
80
|
+
- All three original backend-to-Engine edges are removed. In the measured view,
|
|
81
|
+
M28/M29 join G47 Contracts in B5. M67/M68 are clients in B4 and M71/M72 are
|
|
82
|
+
separately grouped implementations. No pending Storage clients are drawn.
|
|
83
|
+
|
|
84
|
+
### P4: Storage execution
|
|
85
|
+
|
|
86
|
+
- Public `Storage::AsyncClient#transaction_async` opens the raw backend transaction
|
|
87
|
+
on a worker and yields its scoped Storage::View. Backends stay synchronous.
|
|
88
|
+
- Private `Storage::AsyncClient.submit(pool:)` executes existing domain units
|
|
89
|
+
without adding a transaction, timeout or token. All 16 durable submission sites
|
|
90
|
+
are recorded in the [execution inventory](storage-execution-boundaries.md).
|
|
91
|
+
- M69 is an Async Client and M35 a concrete Storage backend in B4.
|
|
92
|
+
Existing `Storage::Backends` is not collapsed.
|
|
93
|
+
- See the [public API and transaction rules](../migrations/storage-async-client.md).
|
|
94
|
+
|
|
95
|
+
### ContentStore service ownership
|
|
96
|
+
|
|
97
|
+
ContentStore is a content management service using Storage, not a peer physical
|
|
98
|
+
backend. Its API, canonicalization, StoredContents implementation and owned
|
|
99
|
+
StorageSchema live in `content_store/`. Base remains shared by StoredContents
|
|
100
|
+
and the Persistence exception facade. The unnecessary `backends/` subdivision
|
|
101
|
+
and Zeitwerk collapse are removed without a forwarding file or alias.
|
|
102
|
+
|
|
103
|
+
M10 belongs to G57 Content Service in the persistence column of display band B3.
|
|
104
|
+
M73 is retired, not reused. G47/G48 contain no ContentStore modules. The real
|
|
105
|
+
M10-to-Storage dependency remains in both the drawing and the full graph.
|
|
106
|
+
The boundary gate rejects reverse Storage-to-ContentStore dependencies and any
|
|
107
|
+
service path to a physical backend, Engine, client or domain orchestration.
|
|
108
|
+
Public constants, signatures, content IDs, exceptions and transaction behavior
|
|
109
|
+
remain unchanged. See [ADR-062](../decisions/062-content-store-service.md).
|
|
110
|
+
|
|
111
|
+
## r8 unit 1 framework boundaries
|
|
112
|
+
|
|
113
|
+
G58/M76/M77 now owns the common Execution framework under `execution/`.
|
|
114
|
+
Engine owns FSM-specific values and the pool/timer/runtime binding, while
|
|
115
|
+
composition selects that binding. Tracing owns explicit observation. Context
|
|
116
|
+
and Tool now own their shared operations, not merely value/error declarations.
|
|
117
|
+
The former G59/M78 split is retired. See [r8 unit 1](r8-unit1.md) for the exact
|
|
118
|
+
implemented scope, API removals and incomplete Persistence/domain work.
|
|
119
|
+
|
|
120
|
+
The full architecture still contains existing cycles outside the checked scope.
|
|
121
|
+
The recorded graph is not an ideal final r8 diagram.
|
|
122
|
+
|
|
123
|
+
## Pending phase
|
|
124
|
+
|
|
125
|
+
P5 completes the final cross-repository/API/docs review after application.
|
|
126
|
+
All retained P2-P4 responsibilities exist in source; the unnecessary M73 split
|
|
127
|
+
is superseded by G57 service ownership. The measured SVG still comes from
|
|
128
|
+
actual Ruby analysis; the target concept is a separate explanatory artifact.
|
|
129
|
+
|
|
130
|
+
## Regenerate and review
|
|
131
|
+
|
|
132
|
+
See [tool instructions](../../tools/architecture/README.md). The normal command
|
|
133
|
+
reads `tools/architecture/phase.json`:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
python tools/architecture/refresh_diagram.py . tmp/architecture
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The output includes the matrix, source hashes, boundary report, module/file
|
|
140
|
+
cycles and the delta from baseline 84668606. Source/module/group changes require
|
|
141
|
+
matching annotation updates. No up/down rule or coordinate controls the gate.
|
|
142
|
+
Ruby loader, RBS, cancellation, admission, streaming and configuration tests
|
|
143
|
+
remain necessary: static analysis does not replace them.
|
|
144
|
+
|
|
145
|
+
An unpublished local candidate must use `--candidate`. Its SVG states that it
|
|
146
|
+
is unapplied and disables GitHub source links. Applied commits and CI output
|
|
147
|
+
use actual source links. CI artifacts are generated after the source commit;
|
|
148
|
+
there is no self-referential SVG commit hash or automatic commit/push.
|
|
149
|
+
|
|
150
|
+
Text panels are transparent and module outlines/group colors remain intact.
|
|
151
|
+
Arrows into M33/M41/M44 are hidden by presentation settings; their AST edges,
|
|
152
|
+
source evidence and matrix cells are preserved. Boundary rules inspect all edges.
|
|
@@ -28,10 +28,10 @@ candidates are accumulated in hook order.
|
|
|
28
28
|
|
|
29
29
|
## 3. Input and result
|
|
30
30
|
|
|
31
|
-
Hooks receive immutable `Phronomy::
|
|
31
|
+
Hooks receive immutable `Phronomy::Context::LLMInputBuildContext` metadata. They do
|
|
32
32
|
not receive a mutable Provider chat/message array.
|
|
33
33
|
|
|
34
|
-
A hook returns `Phronomy::
|
|
34
|
+
A hook returns `Phronomy::Context::LLMInputPatch` or `nil`.
|
|
35
35
|
|
|
36
36
|
These two types live in the shared `agent/context_contract/` implementation
|
|
37
37
|
directory together with the Policy input and result contracts. Zeitwerk
|
|
@@ -40,7 +40,7 @@ names. Hook registration, invocation, and result handling are unchanged; see
|
|
|
40
40
|
[ADR-036](../decisions/036-context-contract-ownership.md).
|
|
41
41
|
|
|
42
42
|
```ruby
|
|
43
|
-
Phronomy::
|
|
43
|
+
Phronomy::Context::LLMInputPatch.new(
|
|
44
44
|
model_config_patch: {temperature: 0.2},
|
|
45
45
|
segment_candidates: [
|
|
46
46
|
{
|
|
@@ -85,7 +85,7 @@ same abstraction level.
|
|
|
85
85
|
Application code supplies an ordinary reusable Ruby strategy object:
|
|
86
86
|
|
|
87
87
|
```ruby
|
|
88
|
-
class SearchContextPolicy < Phronomy::
|
|
88
|
+
class SearchContextPolicy < Phronomy::Context::ContextPolicy
|
|
89
89
|
def initialize(search:)
|
|
90
90
|
@search = search
|
|
91
91
|
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Execution abstraction revision (local review candidate, 2026-09-29)
|
|
2
|
+
|
|
3
|
+
This candidate supersedes the unapplied Results split. It is based on main
|
|
4
|
+
653e255a, with the earlier execution-boundary prototype included. It is not a
|
|
5
|
+
record of application to main. The historical D02 reports describe their original
|
|
6
|
+
revisions; the control ownership decision below supersedes them for this candidate.
|
|
7
|
+
|
|
8
|
+
## Responsibilities
|
|
9
|
+
|
|
10
|
+
| Owner | Owns | Consumers should know |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| Execution Contracts (G58, B5) | Context, TaskResult/Outcome, cancellation/deadline values, shared errors, neutral scope/result implementation | Public inputs, result handles and errors |
|
|
13
|
+
| Execution Services (G59, B4) | Fan-out, child control lifetime, invocation admission checks, completion adaptation, worker submission and deadline registration | Start/observe APIs and domain value/error policies |
|
|
14
|
+
| Engine Internals (G14, B5) | Runtime resources, EventLoop, FSMSession | Only runner/lifecycle/composition owners connect here |
|
|
15
|
+
| Engine Concurrency (G61, B5) | Pools and queues | Engine supplies scheduling and wait-policy context |
|
|
16
|
+
|
|
17
|
+
Bands are visual organization, not a dependency order. Backend Contracts remain
|
|
18
|
+
in B5. `execution_contract/errors`, `execution_result` and
|
|
19
|
+
`execution_result/concurrency` are removed. Their neutral implementation is
|
|
20
|
+
integrated into the existing `execution_contract` and its `concurrency` child.
|
|
21
|
+
M79/M80/M81 and G60 are retired. TaskResult is not returned to Services: doing so
|
|
22
|
+
would recreate Engine→Services. The two contract directories remain mutually
|
|
23
|
+
referencing within G58; the design does not claim zero cycles or pure declarations.
|
|
24
|
+
|
|
25
|
+
## Actual hiding, beyond renaming dependency hubs
|
|
26
|
+
|
|
27
|
+
| Consumer | Previous knowledge | Current entry point |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| Agent::ExecutionCoordinator | Extracted context scope, checked open/cancelled state, selected scope error | InvocationControls.attach + check_start!; Agent still owns admission and its result production |
|
|
30
|
+
| MultiAgent::Orchestrator | Called Execution's private fan-out, constructed OperationBinding, linked tokens, selected context, closed subscriptions | Execution.run_async(max_concurrency:) + start_child; supplies child invocation |
|
|
31
|
+
| Tools::Agent / generated subagent tools | Created deferred result and relayed completion/failure callbacks | AsyncOperation.call/capture; supplies output/error policy |
|
|
32
|
+
| Agent::ToolBinding | Called TaskResult.__map_completion, a special internal composition path | AsyncOperation.map; supplies filters |
|
|
33
|
+
| Workflow builder (earlier included change) | Used FSM's finish vocabulary | Workflow::Completion; runner translates to FSM |
|
|
34
|
+
|
|
35
|
+
InvocationControls extends the existing service helper and absorbs the removed
|
|
36
|
+
OperationBinding's lifetime logic. It is not a pass-through factory that still
|
|
37
|
+
forces callers to manage cleanup. AsyncOperation encapsulates notification
|
|
38
|
+
multiplicity, startup/transformation failure, and physical completion. Domain
|
|
39
|
+
consumers still legitimately depend on TaskResult return types and cancellation
|
|
40
|
+
inputs; hiding those via aliases would not improve the abstraction.
|
|
41
|
+
|
|
42
|
+
ExecutionCoordinator, WorkflowRunner and durable reconciliation coordinators
|
|
43
|
+
remain result producers. Their lifecycle, registry and terminal policy code has
|
|
44
|
+
not all been turned into a generic facade. The public user-facing async APIs and
|
|
45
|
+
backend contracts retain their namespaces.
|
|
46
|
+
|
|
47
|
+
## Investigation heuristic
|
|
48
|
+
|
|
49
|
+
Detect each M0→M1, M1→M2, M0→M2 triangle in the complete Ruby + RBS graph.
|
|
50
|
+
Prioritize adjacent descending display bands, then other descending bands, then
|
|
51
|
+
all remaining graph triangles. Keep sidebar modules and visually hidden arrows.
|
|
52
|
+
Do not remove edges or make a triangle a CI violation solely on that basis.
|
|
53
|
+
|
|
54
|
+
For M0's direct M2 usage, inspect its actual source operation:
|
|
55
|
+
|
|
56
|
+
- Internal detail: Orchestrator linked child tokens and closed subscriptions;
|
|
57
|
+
Execution now owns this through start_child.
|
|
58
|
+
- Connection: a runner registers its session with Runtime; this can belong to
|
|
59
|
+
that runner. Move it only if its current owner mixes unrelated responsibilities.
|
|
60
|
+
- Shared/public contract: AsyncClient returns TaskResult and callers handle its
|
|
61
|
+
result. Keep the declared RBS dependency instead of erasing the type.
|
|
62
|
+
|
|
63
|
+
Multiple M1 paths may identify the same direct edge. Reports include both the
|
|
64
|
+
triangle count and the number of distinct M0→M2 pairs. RBS-only direct edges are
|
|
65
|
+
marked, not automatically accepted. Directory aggregation can combine different
|
|
66
|
+
classes/functions, so a graph path is not proof of a call chain. Dynamic dispatch
|
|
67
|
+
can also leak details without any constant-reference triangle.
|
|
68
|
+
|
|
69
|
+
`dependency_triangles.json` preserves all three edges' source evidence;
|
|
70
|
+
`dependency_triangles.csv` is the review queue. Entries start as unreviewed.
|
|
71
|
+
A separate narrow AST regression gate rejects the already-corrected private
|
|
72
|
+
scope methods and selected consumers' manual result settlement. It does not
|
|
73
|
+
purport to detect every possible abstraction leak.
|
|
74
|
+
|
|
75
|
+
## Compatibility and verification scope
|
|
76
|
+
|
|
77
|
+
Execution.run/run_async accept additive max_concurrency. No new backend methods
|
|
78
|
+
are required from application authors. The included earlier candidate removes
|
|
79
|
+
InvocationContext#effective_timeout_token/#effective_cancellation_token and the
|
|
80
|
+
internal Deadline#attach_to, CancellationScope, old FSM vocabulary ownership.
|
|
81
|
+
This revision removes internal OperationBinding and TaskResult.__map_completion.
|
|
82
|
+
There are no backward aliases that point neutral contracts back at services.
|
|
83
|
+
|
|
84
|
+
Tests cover bounded admission, cancellation before queued start, explicit child
|
|
85
|
+
context identity, cleanup after completion/start failure, duplicate callback
|
|
86
|
+
notifications, original error identity, recovery errors, and physical completion.
|
|
87
|
+
Existing Agent, Tool, Workflow, persistence/recovery and async tests remain gates.
|
|
88
|
+
The delivered evidence report records actual execution results and limitations.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Execution dependency ownership
|
|
2
|
+
|
|
3
|
+
Use the highest existing operation that expresses the caller's responsibility.
|
|
4
|
+
A facade is useful when it owns real coordination, not just because it reduces
|
|
5
|
+
arrows. These cases distinguish shared contracts from executable machinery.
|
|
6
|
+
|
|
7
|
+
| Caller / operation | Dependency after this change | Decision |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| ToolBinding result filter | TaskResult private completion mapping | Remove duplicate physical-completion handling; source completion alone must not finish the filtered result |
|
|
10
|
+
| Tracing span finish | Blocking.call_async | Generic default-pool work; observe rejection in the returned result |
|
|
11
|
+
| Approval listener dispatch | Blocking.call_async | Generic default-pool work; log admission and later callback errors |
|
|
12
|
+
| Agent/Workflow synchronous entry guard | Runtime.in_event_loop_context? | Query context without creating Runtime |
|
|
13
|
+
| Prompt parser, Runnable users | Execution Contracts | Public callable/value contract, not pool internals |
|
|
14
|
+
| Agent lifecycle/state, capability and journal input markers | Execution Contracts | Methodless classification; preserve direct include and validation |
|
|
15
|
+
| Tool and async-client RBS token/result references | Execution Contracts / Execution Services | Keep real public type use in the graph; do not invent a domain facade for a token |
|
|
16
|
+
| LLM, VectorStore, Embeddings and Storage AsyncClients | Contracts + TaskResult + Runtime/pools | Intended bridge; keep specialized submission, token and admission rules |
|
|
17
|
+
| Agent ExecutionCoordinator / MultiAgent binding | Concurrency operation binding | Own cancellation/deadline scope across an operation; generic Blocking is not equivalent |
|
|
18
|
+
| Agent and Workflow runners / execution registries | Runtime, FSM session and control delivery | Framework connection and single-writer ownership; retain these explicit dependencies |
|
|
19
|
+
| Engine worker pool | TaskResult and execution errors | Produces shared results; the service/Engine relationship is not acyclic |
|
|
20
|
+
|
|
21
|
+
The full dependency graph still includes references through shared error classes,
|
|
22
|
+
markers and RBS. Moving their source owners changes the interpretation of the
|
|
23
|
+
old Engine fan-in; it does not remove their actual use. The architecture gate
|
|
24
|
+
enforces Contracts-to-Contracts/Common only and rejects domain/backend/client
|
|
25
|
+
dependencies from Services or Engine. Layout is independent of those rules.
|
|
26
|
+
|
|
27
|
+
See [ADR-063](../decisions/063-execution-contracts-and-services.md) for the source
|
|
28
|
+
layout, behavior change and compatibility boundary.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Shared execution metadata and value conversion
|
|
2
2
|
|
|
3
|
+
> Current boundary: r8 unit 6 supersedes the historical Chat/SDK ownership and
|
|
4
|
+
> adapter extension SPI below. Agent uses LLMAdapter values; the backend owns SDK
|
|
5
|
+
> construction/interception; Tool owns canonical schema validation. See
|
|
6
|
+
> `docs/architecture/r8-unit6.md` and `docs/migrations/r8-unit6.md`.
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
Refactor 38 addresses the remaining R03 and R11 responsibilities against core
|
|
4
10
|
`e7e6618493df03c2eb386d78a9303796e1e13cdc`. The candidate must be applied and
|
|
5
11
|
verified before those items are closed. Tool restoration itself was completed
|
|
@@ -24,14 +24,14 @@ Normative Handoff intent is
|
|
|
24
24
|
with the Runner ownership amendment in
|
|
25
25
|
[ADR-034](../decisions/034-handoff-runner-coordination-ownership.md).
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
Agent
|
|
29
|
-
|
|
27
|
+
MultiAgent owns the cross-Agent turn, Handoff edges, Policy, routing and reservations.
|
|
28
|
+
Agent owns generic control requests, finalized Context projection and its own
|
|
29
|
+
execution commits. See [r8 unit 4](r8-unit4.md).
|
|
30
30
|
|
|
31
31
|
## 2. Public API
|
|
32
32
|
|
|
33
33
|
```ruby
|
|
34
|
-
handoff = Phronomy::
|
|
34
|
+
handoff = Phronomy::MultiAgent::Handoff.new(
|
|
35
35
|
source_agent: triage,
|
|
36
36
|
target_agent: billing,
|
|
37
37
|
description: "Transfer billing responsibility",
|
|
@@ -40,6 +40,7 @@ handoff = Phronomy::Agent::Handoff.new(
|
|
|
40
40
|
|
|
41
41
|
runner = Phronomy::MultiAgent::HandoffRunner.new(
|
|
42
42
|
main_agent: triage,
|
|
43
|
+
persistence: stores.multi_agent,
|
|
43
44
|
handoffs: [handoff]
|
|
44
45
|
)
|
|
45
46
|
|
|
@@ -56,7 +57,7 @@ schemas. The generated Tool name is private transport encoding, not Handoff
|
|
|
56
57
|
identity or public semantic contract.
|
|
57
58
|
|
|
58
59
|
Phronomy intercepts the Provider Tool Call into a typed private
|
|
59
|
-
`
|
|
60
|
+
`Agent::ControlRequest`. It does not execute an ordinary `ToolInvocation` or emit a
|
|
60
61
|
sentinel Tool result.
|
|
61
62
|
|
|
62
63
|
## 4. Handoff Policy
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
## 1. Durable boundary
|
|
11
11
|
|
|
12
|
-
`Phronomy::Persistence`
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
`Phronomy::Persistence` owns domain-neutral atomic scopes over a `Storage::Backend`.
|
|
13
|
+
`Agent::Store` and `MultiAgent::Store` own domain operations and result queries;
|
|
14
|
+
Workflow consumes its checkpoint repository directly. These roles share a
|
|
15
|
+
coordinator when operations must commit together. Storage implementations do not
|
|
16
|
+
inherit a domain service. See [r8 unit 3](r8-unit3.md) for construction and migration.
|
|
15
17
|
|
|
16
18
|
The `storage/` directory owns record carriers, portable errors, repository views,
|
|
17
19
|
and the Backend contract. `storage/backends/` owns physical storage implementations.
|
|
@@ -20,13 +22,29 @@ directories own their domain codecs and repositories. Agent and Team result
|
|
|
20
22
|
queries live with those domains. `storage/record_codec.rb` contains only shared
|
|
21
23
|
record-envelope and scalar validation; it does not select a domain schema.
|
|
22
24
|
`persistence_composition/` assembles the domain repositories over one raw view.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
`content_store/` is a content management service over Storage, not a physical
|
|
26
|
+
backend family. Its Base shares text/JSON conversion with StoredContents and
|
|
27
|
+
the Persistence content facade. StoredContents generates content IDs, verifies
|
|
28
|
+
digest identity and uses the injected view's Blobs. Its StorageSchema belongs
|
|
29
|
+
to this service. Storage owns byte immutability, transactions and physical I/O.
|
|
30
|
+
The service and its schema live together; there is no `content_store/backends/`
|
|
31
|
+
directory or backend-selection API. See [ADR-062](../decisions/062-content-store-service.md).
|
|
32
|
+
Domain stores receive their record adapters from `PersistenceComposition` and
|
|
33
|
+
retain their observation-thread guards. The common Persistence does not select
|
|
34
|
+
domains, assemble repositories, or delegate domain result queries. Domain-only
|
|
35
|
+
record protocols bind to the exact scope when participating; there is no shared
|
|
36
|
+
all-domain repository facade.
|
|
27
37
|
See [ADR-032](../decisions/032-storage-backend-composition.md) and
|
|
28
38
|
[ADR-033](../decisions/033-domain-persistence-ownership.md).
|
|
29
39
|
|
|
40
|
+
`persistence/errors.rb` owns the shared domain-facing failure classes. Repository
|
|
41
|
+
boundaries translate four known raw Storage categories to Persistence categories,
|
|
42
|
+
retaining the original exception as `cause`. Upper domain state contradictions
|
|
43
|
+
use `Persistence::StateConflictError < Persistence::ConflictError`. Unknown and
|
|
44
|
+
commit-outcome-uncertain exceptions are not reclassified. Backend contracts never
|
|
45
|
+
depend on these upper errors. See [ADR-061](../decisions/061-persistence-failure-contracts.md)
|
|
46
|
+
and the [rescue-clause migration](../migrations/persistence-failure-contracts.md).
|
|
47
|
+
|
|
30
48
|
Shared value copying belongs to `Values::Immutable` in `values/`. Agent records,
|
|
31
49
|
Team records, Recovery classifications, and Persistence result views use this
|
|
32
50
|
internal helper without borrowing an Agent implementation. It copies and freezes
|
|
@@ -41,7 +59,7 @@ does not change record formats, transaction ownership, or recovery guarantees.
|
|
|
41
59
|
| `agents` | AgentRoot |
|
|
42
60
|
| `journals` | Append-only Agent journal |
|
|
43
61
|
| `executions` | AgentExecution and owned child coordination |
|
|
44
|
-
|
|
|
62
|
+
| Workflow checkpoint repository | Workflow snapshots |
|
|
45
63
|
| `handoff_states` | Active responsibility and exact Target reservation |
|
|
46
64
|
| `teams` | TeamRoot |
|
|
47
65
|
| `team_executions` | Team tasks, assignments and outcomes |
|
|
@@ -93,7 +111,7 @@ Defined semantic durable transitions are atomic according to the Persistence
|
|
|
93
111
|
transaction contract and conforming backend.
|
|
94
112
|
|
|
95
113
|
Revision/watermark/CAS checks reject stale durable transitions with
|
|
96
|
-
`
|
|
114
|
+
`Persistence::ConflictError` rather than silently merging/reloading competing
|
|
97
115
|
state.
|
|
98
116
|
|
|
99
117
|
Conflict detection is not competing-execution exclusion and cannot undo an
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# r8第1適用版:Context/ToolとExecutionの共通基盤
|
|
2
|
+
|
|
3
|
+
> Current boundary: r8 unit 6 supersedes the historical Chat/SDK ownership and
|
|
4
|
+
> adapter extension SPI below. Agent uses LLMAdapter values; the backend owns SDK
|
|
5
|
+
> construction/interception; Tool owns canonical schema validation. See
|
|
6
|
+
> `docs/architecture/r8-unit6.md` and `docs/migrations/r8-unit6.md`.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
対象は2026-09-30に確認したmain `653e255a34fe4062d4beca47530e084fdd3a6ba9`。設計基準は同日更新のr8修正仕様・directory配置資料である。本変更はその第1適用単位であり、r8全体、S1全項目、S2/S3全受入条件の完了を意味しない。互換alias・転送だけの旧APIは残さない。
|
|
10
|
+
|
|
11
|
+
## 実装した責務と操作
|
|
12
|
+
|
|
13
|
+
| 所有者 | 共通基盤が実行すること | 利用側に残すこと |
|
|
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の実行契約を持つ |
|
|
22
|
+
|
|
23
|
+
ContextとToolはAgentの薄い型定義の置場ではなく、実際の共通手順を所有する。ただし、Contextの現在の入力にはAgent由来の識別情報や由来情報が残る。完全に汎用の新domainモデルまで設計し直したものではない。ToolのDSL基底は引き続きRubyLLM::Toolを使用する。
|
|
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参加を完成させたものではない。
|
|
26
|
+
|
|
27
|
+
Executionは`_ExecutionBackend`の操作に依存する。構成処理が遅延providerを設定し、Engineの`ExecutionBinding`がsubmit/afterを実装する。settled TaskResultの生成・map/flat_map/all_settled・待機制約の確認ではEngineを読み込まない。Runtime取得は実際のsubmit/タイマー登録時に行う。単なる名義移管に留めず、機構参照をここへ集約した。
|
|
28
|
+
|
|
29
|
+
WorkflowのFINISHと終了値は`Workflow::Completion`が所有し、WorkflowRunnerがFSM側へ変換する。FSMSession専用のEvent/FSMProtocol/TerminalDecisionはEngineに置く。Agent・MultiAgentのFSM専用接続の全面分離は残っている。
|
|
30
|
+
|
|
31
|
+
## 公開名・配置の変更
|
|
32
|
+
|
|
33
|
+
| 旧配置・API | 新配置・API | 判断 |
|
|
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
|
+
| 項目 | この適用版 | 未完了部分 |
|
|
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件の三角形レビュー | 再判定未完了 | 図の再解析は判定完了の代わりにはならない |
|
|
73
|
+
|
|
74
|
+
NC/F/RMの全項目を「対応済み」とする資料は作成していない。受入可否はこの表の実装単位と同梱テスト証拠に限定する。
|
|
75
|
+
|
|
76
|
+
## Persistenceをこの適用単位から外した理由
|
|
77
|
+
|
|
78
|
+
現在のAgent初回受付は保存transaction内でTeam予約を読む。AgentからTeam内部への参照は最終設計では解消すべきだが、検証を単純に先行呼出へ移すと次の競合が生じる。
|
|
79
|
+
|
|
80
|
+
1. 親側が予約の有効性を確認する。
|
|
81
|
+
2. 別の処理が予約を取り消す。
|
|
82
|
+
3. Agentが新しいtransactionで受付記録を保存し、取消済みの子を開始してしまう。
|
|
83
|
+
|
|
84
|
+
次の適用単位では、親が所有する予約確認とAgent受付記録を同一scopeで行う参加APIが必要である。親は予約規則、Agentは受付規則、Persistenceは参加とcommit境界を所有する。Agentが親kindをswitchしてTeamを選ぶ現在の逆依存を、新しいcallbackの裏へ隠すだけでは解決にならない。
|
|
85
|
+
|
|
86
|
+
具体的に未確定なのは、参加操作の公開keyword/返却値、取消との競合条件、commit後のRuntime admission、停止後の同じ子IDによる照会・再開である。Workflowのhalt/finish snapshotだけで任意action内の子実行が耐障害化されるとは扱わない。Workflow→Agent/Teamの具体経路、checkpoint、結果取込一回性をP05で定める。成否不明は単一record一致だけで成功にせず、複数domainの証拠をP06で定める。
|
|
87
|
+
|
|
88
|
+
そのため既存Persistence facade、Team受付検証、予約・子記録のtransaction境界を本変更では改変しない。保証を弱めた仮実装を入れず、次の仕様・実装単位として残す。
|
|
89
|
+
|
|
90
|
+
## 解析図の読み方
|
|
91
|
+
|
|
92
|
+
実ソースとRBSから再生成する。従来の水平帯・グループ色・個別module枠を維持し、文字の背景は透過。M33/M41/M44への矢印は表示のみ省略し、JSON・行列・境界判定にはすべて残す。旧IDは再利用せず退役させる。
|
|
93
|
+
|
|
94
|
+
これは修正版candidateの実測図であり、全r8完了時の構想図ではない。残る循環・逆依存もそのまま出力する。静的解析で見えない注入先・動的dispatchはRBSだけで完全に証明できない。Engine機構接続とdomain保存の実行テストを併用する。
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
bundle exec rbs -I sig validate
|
|
98
|
+
python -m pip install -r tools/architecture/tools/requirements.txt
|
|
99
|
+
python -m unittest discover -s tools/architecture/tests -v
|
|
100
|
+
# lib/sigをcommitした後、未公開candidateでは次の指定を用いる
|
|
101
|
+
python tools/architecture/refresh_diagram.py . tmp/architecture-r8-unit1 --candidate
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
同梱SVGのSHAは作成用のローカルcandidateを示す。利用者が適用してcommitしたSHAとは異なるため、適用後の図はそのcheckoutで再生成する。Rubyの検証環境、件数、skip理由、未検証環境と適用手順は配布パッケージの検証報告を参照する。
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# r8 unit 10: C01 MultiAgent execution connection
|
|
2
|
+
|
|
3
|
+
Contract placement follows ownership of meaning and invariants, not reuse.
|
|
4
|
+
AdmissionRegistry and TeamOwnershipRegistry already existed in MultiAgent.
|
|
5
|
+
They remain there; neither moves to Engine and no generic Registry is added.
|
|
6
|
+
|
|
7
|
+
| Owner | Responsibility |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| MultiAgent AdmissionRegistry | One synchronous coordination call per live owner; close admission and wait for admitted calls |
|
|
10
|
+
| MultiAgent TeamOwnershipRegistry | One live Team per ID and environment; class/store consistency, construction exclusion, shutdown cleanup |
|
|
11
|
+
| MultiAgent TeamCoordinator / HandoffRunner | Coordination, durable reservations, child operations, scheduling, aggregation, recovery and outcomes |
|
|
12
|
+
| MultiAgent ExecutionEnvironment | Private process-local connection needed by C01: registry access, owning-environment validity and submission |
|
|
13
|
+
| MultiAgent EngineEnvironment in runtime_binding | Runtime selection, participant registration/lookup, Runtime identity comparison and Execution submission to the captured Runtime |
|
|
14
|
+
| Engine Runtime | Generic participant lifecycle: close, wait under one deadline, stop resources, then finalize |
|
|
15
|
+
| runtime_composition/multi_agent_defaults.rb | Lazy selection of the environment and default persistence factory |
|
|
16
|
+
|
|
17
|
+
There are two registrations. Recording a Team or an active coordination call
|
|
18
|
+
inside a Registry is a MultiAgent operation. Registering that Registry as a
|
|
19
|
+
Runtime shutdown participant is an implementation connection. Previously the
|
|
20
|
+
Registry class methods and their callers mixed these two responsibilities.
|
|
21
|
+
Team/Handoff also selected Runtime directly, and Team cancellation submitted
|
|
22
|
+
work directly to it. The environment port separates those concrete connections.
|
|
23
|
+
|
|
24
|
+
Runtime's existing begin_draining / wait_until_idle / optional
|
|
25
|
+
after_runtime_shutdown protocol remains unchanged. Registry methods define
|
|
26
|
+
what those callbacks mean for MultiAgent. The admission registry waits for
|
|
27
|
+
active coordination calls; Team ownership waits for in-progress construction,
|
|
28
|
+
not for every retained Team to disappear. Live Team references are cleared
|
|
29
|
+
only after successful resource shutdown. Runtime acquires no Team/Handoff rules.
|
|
30
|
+
The shared callback protocol alone is not a reason to add a new logical Contract.
|
|
31
|
+
|
|
32
|
+
The default adapter shares registries by their existing class keys within each
|
|
33
|
+
Runtime. Concurrent adapters get the same registered instance. Lookup does not
|
|
34
|
+
register a participant, including after draining starts. Admission acquisition
|
|
35
|
+
continues to reject a stopped/failed Runtime; a retained ownership registry can
|
|
36
|
+
still be looked up, while its own construction gate rejects new work.
|
|
37
|
+
|
|
38
|
+
Team and Handoff capture their environment on construction. Existing objects do
|
|
39
|
+
not switch registry or cancellation destination when the provider changes.
|
|
40
|
+
The default adapter compares the captured Runtime with the current default to
|
|
41
|
+
preserve stale-owner rejection. Cancellation submission uses the captured
|
|
42
|
+
Runtime explicitly. The environment itself is neither persisted nor authority
|
|
43
|
+
for a durable execution. This is an internal composition extension, not a new
|
|
44
|
+
supported application plugin API.
|
|
45
|
+
|
|
46
|
+
Public Team/Handoff signatures, exception classes, durable IDs, record schemas,
|
|
47
|
+
CAS rules, parent/child atomic participation and recovery semantics are unchanged.
|
|
48
|
+
ReservedChildAdmission still validates domain reservations within the shared
|
|
49
|
+
persistence scope. It is distinct from the process-local AdmissionRegistry.
|
|
50
|
+
Engine lifecycle and Execution completion/cancellation rules are unchanged.
|
|
51
|
+
|
|
52
|
+
## Evidence and remaining scope
|
|
53
|
+
|
|
54
|
+
Standalone tests use both registries without loading Engine. Connection tests
|
|
55
|
+
exercise Team identity and store consistency, duplicate Handoff calls, release
|
|
56
|
+
on failure, stale-owner rejection, original-environment cancellation, callback
|
|
57
|
+
cleanup and real worker submission after default Runtime replacement. Existing
|
|
58
|
+
shutdown tests cover concurrent registration, construction during draining,
|
|
59
|
+
failed EventLoop closure, deadlines and finalization. Durable coordination and
|
|
60
|
+
recovery suites remain acceptance gates.
|
|
61
|
+
|
|
62
|
+
The dependency model adds M89/G63 for multi_agent/runtime_binding. AST guards
|
|
63
|
+
reject Runtime/Engine selection and private shutdown registration/lookup inside
|
|
64
|
+
MultiAgent domain files. Graph guards reject direct domain-to-Engine/binding
|
|
65
|
+
dependencies while retaining lower-level reverse-dependency restrictions.
|
|
66
|
+
Measured Ruby/RBS references remain visible; these are scoped rules, not proof
|
|
67
|
+
that the complete dependency graph is acyclic or every Contract is complete.
|
|
68
|
+
|
|
69
|
+
Remaining work includes Workflow connections and durable child outcomes,
|
|
70
|
+
MultiAgent's existing global/default persistence selection, broader semantic
|
|
71
|
+
dependency review, and live-service/additional persistence acceptance gates.
|
|
72
|
+
This unit completes the proposed C01 Runtime connection split, not all C01 work.
|