Class: RailVerdict::MCP::Tools::Verify

Inherits:
Object
  • Object
show all
Defined in:
lib/rail_verdict/mcp/tools/verify.rb

Instance Method Summary collapse

Constructor Details

#initialize(server:) ⇒ Verify

Returns a new instance of Verify.



7
8
9
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 7

def initialize(server:)
  @server = server
end

Instance Method Details

#call(changed: nil, base: nil, config_path: nil, baseline_path: nil, waiver_path: nil, **_rest) ⇒ Object



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
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 58

def call(changed: nil, base: nil, config_path: nil, baseline_path: nil, waiver_path: nil, **_rest)
  begin
    changed = changed == true
    base_validated = Validators.validate_base_revision(base)
    if base_validated && !changed
      return Serializers.error_response("--base requires --changed", code: "invalid_arguments")
    end
    config_file = resolve_config_path(config_path)
    if changed
      base_for_check = base_validated || configuration_git_base(config_file)
      if base_for_check.nil? || base_for_check.strip.empty?
        # Let Check handle git_scope_failed as INCOMPLETE — still need a base, but we try check anyway
      end
    end

    outcome = @server.synchronized_verification { run_check(changed: changed, base: base_validated, config_path: config_file, baseline_path: baseline_path, waiver_path: waiver_path) }
    @server.cache.store_outcome(outcome)
    structured = Serializers.gate_result_to_structured(outcome)
    structured = Validators.scrub_text(structured) if structured.is_a?(String)
    structured = Serializers.scrub(structured)
    Serializers.tool_response(structured, error: false)
  rescue ArgumentError => e
    Serializers.error_response(e.message, code: "invalid_arguments")
  rescue StandardError => e
    Serializers.error_response("verify failed: #{e.message}", code: "internal_error")
  end
end

#tool_annotationsObject



54
55
56
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 54

def tool_annotations
  { read_only_hint: true, destructive_hint: false, idempotent_hint: true, open_world_hint: false, title: tool_title }
end

#tool_descriptionObject



19
20
21
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 19

def tool_description
  "Deterministic read-only verification. Runs RailVerdict Check and returns GateResult (PASS/WARN/FAIL/INCOMPLETE). FAIL is a successful result (isError false) — not a protocol error. Works offline with no network. Requires no AI."
end

#tool_input_schemaObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 23

def tool_input_schema
  {
    type: "object",
    properties: {
      changed: { type: "boolean", description: "Use Git changed scope (--changed)" },
      base: { type: "string", description: "Base revision for --changed (hex SHA 7..64)" },
      config_path: { type: "string", description: "Path to .railverdict.yml relative to repository root" },
      baseline_path: { type: "string", description: "Override baseline path" },
      waiver_path: { type: "string", description: "Override waivers path" }
    },
    additionalProperties: false
  }
end

#tool_nameObject



11
12
13
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 11

def tool_name
  "verify"
end

#tool_output_schemaObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 37

def tool_output_schema
  {
    type: "object",
    properties: {
      schema_version: { type: "string" },
      completion_status: { type: "string" },
      gate: { type: "string" },
      policy_status: { type: "string" },
      findings: { type: "array" },
      analyzer_results: { type: "array" },
      operational_failures: { type: "array" },
      decision_reasons: { type: "array" }
    },
    required: %w[schema_version completion_status gate policy_status findings]
  }
end

#tool_titleObject



15
16
17
# File 'lib/rail_verdict/mcp/tools/verify.rb', line 15

def tool_title
  "Verify repository"
end