Class: RubyCoded::Tools::ExecutionPipeline
- Inherits:
-
Object
- Object
- RubyCoded::Tools::ExecutionPipeline
- Defined in:
- lib/ruby_coded/tools/execution_pipeline.rb
Overview
Standardizes the internal execution flow shared by side-effecting tools:
1. validate input (project-relative path if given)
2. resolve to an absolute path inside the project root
3. optionally forbid operating on the project root itself
4. execute the tool's business logic (via block)
5. normalize filesystem errors into a structured response
Policy, risk assessment and user approval intentionally live outside this pipeline: they are handled by Tools::ExecutionPolicy and by the bridges (BridgeCommon::ToolFlow), which sit above tool execution.
Instance Method Summary collapse
-
#call(path: nil, forbid_root: false) ⇒ Object
Runs the pipeline.
-
#initialize(project_root:) ⇒ ExecutionPipeline
constructor
A new instance of ExecutionPipeline.
Constructor Details
#initialize(project_root:) ⇒ ExecutionPipeline
Returns a new instance of ExecutionPipeline.
16 17 18 |
# File 'lib/ruby_coded/tools/execution_pipeline.rb', line 16 def initialize(project_root:) @project_root = File.realpath(project_root) end |
Instance Method Details
#call(path: nil, forbid_root: false) ⇒ Object
Runs the pipeline. Yields the resolved full_path (or nil if path
was not provided) to the caller-supplied block, which returns the
tool result — either a success value (string/hash without :error)
or an error hash of the form { error: "..." }.
Any SystemCallError raised inside the block is normalized to an error hash.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_coded/tools/execution_pipeline.rb', line 27 def call(path: nil, forbid_root: false) full_path = nil if path full_path = resolve_and_validate(path) return full_path if full_path.is_a?(Hash) return { error: "Cannot operate on the project root" } if forbid_root && full_path == @project_root end yield(full_path) rescue SystemCallError => e { error: "Filesystem error: #{e.}" } end |