Module: Phronomy::Agent::AgentInvocationRegistry Private
- Defined in:
- lib/phronomy/agent/agent_invocation_registry.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
In-process registry for suspended AgentInvocation aggregates.
The registry is the single in-process source for pending Human approval. Cross-process persistence remains outside the scope of this implementation.
Defined Under Namespace
Classes: Entry
Class Method Summary collapse
- .clear! ⇒ Object private
-
.consume_approval(agent_invocation_id, approval_request_id) ⇒ Object
private
Atomically removes and returns one pending approval aggregate.
- .exists?(agent_invocation_id) ⇒ Boolean private
- .lookup(agent_invocation_id) ⇒ Object private
- .remove_terminal(agent_invocation_id) ⇒ Object private
- .store_suspended(invocation, approval_request) ⇒ Object private
Class Method Details
.clear! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 71 72 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 67 def self.clear! @mutex.synchronize do @entries.clear @approval_index.clear end end |
.consume_approval(agent_invocation_id, approval_request_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Atomically removes and returns one pending approval aggregate. Duplicate approval commands therefore cannot execute the Tool twice.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 38 def self.consume_approval(agent_invocation_id, approval_request_id) @mutex.synchronize do indexed_invocation_id = @approval_index[approval_request_id.to_s] return nil unless indexed_invocation_id == agent_invocation_id.to_s entry = @entries.delete(indexed_invocation_id) return nil unless entry @approval_index.delete(entry.approval_request.id) entry end end |
.exists?(agent_invocation_id) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 55 def self.exists?(agent_invocation_id) @mutex.synchronize { @entries.key?(agent_invocation_id.to_s) } end |
.lookup(agent_invocation_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 51 def self.lookup(agent_invocation_id) @mutex.synchronize { @entries[agent_invocation_id.to_s] } end |
.remove_terminal(agent_invocation_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 63 64 65 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 59 def self.remove_terminal(agent_invocation_id) @mutex.synchronize do entry = @entries.delete(agent_invocation_id.to_s) @approval_index.delete(entry.approval_request.id) if entry entry end end |
.store_suspended(invocation, approval_request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/phronomy/agent/agent_invocation_registry.rb', line 18 def self.store_suspended(invocation, approval_request) @mutex.synchronize do invocation_id = invocation.id request_id = approval_request.id if @entries.key?(invocation_id) || @approval_index.key?(request_id) raise Phronomy::Error, "Suspended AgentInvocation is already registered: #{invocation_id}" end @entries[invocation_id] = Entry.new( invocation: invocation, approval_request: approval_request ) @approval_index[request_id] = invocation_id end approval_request end |