Class: RailVerdict::MCP::Tools::GetVerificationReceipt
- Inherits:
-
Object
- Object
- RailVerdict::MCP::Tools::GetVerificationReceipt
- Defined in:
- lib/rail_verdict/mcp/tools/get_verification_receipt.rb
Instance Method Summary collapse
- #call(**_rest) ⇒ Object
-
#initialize(server:) ⇒ GetVerificationReceipt
constructor
A new instance of GetVerificationReceipt.
- #tool_annotations ⇒ Object
- #tool_description ⇒ Object
- #tool_input_schema ⇒ Object
- #tool_name ⇒ Object
- #tool_output_schema ⇒ Object
- #tool_title ⇒ Object
Constructor Details
#initialize(server:) ⇒ GetVerificationReceipt
Returns a new instance of GetVerificationReceipt.
9 10 11 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 9 def initialize(server:) @server = server end |
Instance Method Details
#call(**_rest) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 50 def call(**_rest) root = @server.repository_root effective_paths = begin RailVerdict::Check.effective_input_paths(root: File.realpath(root), config_path: File.join(File.realpath(root), ".railverdict.yml")) rescue StandardError nil end current_state = RailVerdict::RepositoryState.capture(repository_root: root, configuration_paths: effective_paths) current_env = begin # Use cached outcome config if available for relevant probing outcome = @server.cache.fetch_outcome config = outcome&.configuration RailVerdict::VerificationEnvironment.capture(repository_root: root, configuration: config) rescue StandardError nil end case @server.cache.verification_state(current_state, current_env) when "fresh" entry = @server.cache.fresh_entry(current_state, current_env) receipt = entry&.receipt_document if receipt.is_a?(Hash) && receipt["receipt_id"] payload = { "status" => "fresh", "receipt" => Serializers.scrub(receipt) } else payload = { "status" => "state_unavailable", "code" => receipt.is_a?(Hash) ? receipt["code"] : "repository_state_unavailable", "message" => "last verification could not be bound to a stable repository state; run verify again" } end Serializers.tool_response(payload, error: false) when "stale" Serializers.tool_response( { "status" => "verification_required", "code" => "stale_receipt", "message" => "repository state changed since the last verify; the previous receipt is stale and must not be used as current evidence" }, error: false ) when "state_unavailable" Serializers.tool_response( { "status" => "state_unavailable", "code" => "repository_state_unavailable", "message" => "current repository state could not be determined fail-closed" }, error: false ) else Serializers.tool_response( { "status" => "verification_required", "code" => "no_verification_yet", "message" => "run verify before requesting a receipt" }, error: false ) end rescue StandardError => e Serializers.error_response("get_verification_receipt failed: #{e.}", code: "internal_error") end |
#tool_annotations ⇒ Object
46 47 48 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 46 def tool_annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: true, open_world_hint: false, title: tool_title } end |
#tool_description ⇒ Object
21 22 23 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 21 def tool_description "Return the Verification Receipt from the most recent verify, WITHOUT rerunning analyzers. Fresh receipts bind the exact repository state that was verified. If the repository changed after verify, returns verification_required/stale instead of stale evidence." end |
#tool_input_schema ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 25 def tool_input_schema { type: "object", properties: {}, additionalProperties: false } end |
#tool_name ⇒ Object
13 14 15 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 13 def tool_name "get_verification_receipt" end |
#tool_output_schema ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 33 def tool_output_schema { type: "object", properties: { status: { type: "string", enum: %w[fresh stale verification_required state_unavailable] }, receipt: { type: ["object", "null"] }, code: { type: "string" }, message: { type: "string" } }, required: %w[status] } end |
#tool_title ⇒ Object
17 18 19 |
# File 'lib/rail_verdict/mcp/tools/get_verification_receipt.rb', line 17 def tool_title "Get verification receipt" end |