Class: PromptObjects::Operations::RunTraceBuilder
- Inherits:
-
Object
- Object
- PromptObjects::Operations::RunTraceBuilder
- Defined in:
- lib/prompt_objects/operations/run_trace_builder.rb
Overview
Projects the durable runtime records for one execution tree into a debugger-friendly read model. The projection deliberately labels model context as reconstructed until exact provider exchanges are persisted.
Constant Summary collapse
- CATEGORY_BY_KIND =
{ "model_started" => "model", "model_completed" => "model", "tool_batch_started" => "tool_batch", "tool_started" => "tool", "tool_completed" => "tool", "tool_failed" => "tool", "tool_cancelled" => "tool", "delegation_started" => "delegation", "delegation_completed" => "delegation", "artifact_upserted" => "state", "env_data_changed" => "state" }.freeze
Instance Method Summary collapse
- #build(run_id) ⇒ Object
-
#initialize(store) ⇒ RunTraceBuilder
constructor
A new instance of RunTraceBuilder.
Constructor Details
#initialize(store) ⇒ RunTraceBuilder
Returns a new instance of RunTraceBuilder.
23 24 25 26 27 28 29 30 |
# File 'lib/prompt_objects/operations/run_trace_builder.rb', line 23 def initialize(store) @runs = Repositories::RunRepository.new(store) @definitions = Repositories::DefinitionRepository.new(store) @messages = Repositories::MessageRepository.new(store) @events = Repositories::EventRepository.new(store) @tools = Repositories::ToolExecutionRepository.new(store) @artifacts = Repositories::ArtifactRepository.new(store) end |
Instance Method Details
#build(run_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/prompt_objects/operations/run_trace_builder.rb', line 32 def build(run_id) requested = @runs.get(run_id) raise ArgumentError, "unknown run: #{run_id}" unless requested root_run_id = requested.root_run_id || requested.id = @runs.tree(root_run_id: root_run_id) workspace_artifacts = @artifacts.list(workspace_session_id: requested.workspace_session_id) { requested_run_id: requested.id, root_run_id: root_run_id, workspace_session_id: requested.workspace_session_id, completeness: { run_records: "exact", definitions: "exact_when_available", messages: "exact", tools: "exact", model_context: "reconstructed", state_history: "current_revision_only" }, runs: .map { |run| build_run(run, , workspace_artifacts) } } end |