Class: RailVerdict::MCP::Tools::VerifyRepair

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

Instance Method Summary collapse

Constructor Details

#initialize(server:) ⇒ VerifyRepair

Returns a new instance of VerifyRepair.



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

def initialize(server:)
  @server = server
end

Instance Method Details

#call(packet_id: nil, changed: nil, base: nil, **_rest) ⇒ Object



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

def call(packet_id: nil, changed: nil, base: nil, **_rest)
  begin
    pid = Validators.validate_packet_id(packet_id)
    changed_v = changed == true
    base_v = Validators.validate_base_revision(base)
    if base_v && !changed_v
      return Serializers.error_response("--base requires --changed", code: "invalid_arguments")
    end

    packet_h = @server.cache.fetch_packet(pid)
    unless packet_h
      return Serializers.error_response("packet not found for packet_id: #{pid}; call build_repair_packet first", code: "stale_target")
    end

    fresh_outcome = @server.synchronized_verification { fresh_check(changed: changed_v, base: base_v) }
    result = Repair::Verifier.verify(packet: packet_h, new_outcome: fresh_outcome)

    structured = {
      "target_status" => result.target_status,
      "gate" => result.gate,
      "completion_status" => result.completion_status,
      "overall_status" => result.overall_status,
      "new_blocking_findings" => result.new_blocking_findings,
      "verification_boundary_changed" => result.verification_boundary_changed,
      "regressed" => result.regressed,
      "gate_result" => fresh_outcome.result.to_schema_h
    }
    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_repair failed: #{e.message}", code: "internal_error")
  end
end

#tool_annotationsObject



53
54
55
# File 'lib/rail_verdict/mcp/tools/verify_repair.rb', line 53

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_repair.rb', line 19

def tool_description
  "Verify whether a prior RepairPacket target is fixed. Re-runs verification and classifies target_status (fixed/still_present/changed/moved/regressed/incomplete) plus verification_boundary_changed and gate. Never trusts agent-provided fixed claim."
end

#tool_input_schemaObject



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

def tool_input_schema
  {
    type: "object",
    properties: {
      packet_id: { type: "string", description: "Packet id (sha256:...); must match a prior build_repair_packet packet_id in this server session" },
      changed: { type: "boolean", description: "Re-verify with Git changed scope" },
      base: { type: "string", description: "Base revision for re-verify (hex SHA) when changed is true" }
    },
    required: ["packet_id"],
    additionalProperties: false
  }
end

#tool_nameObject



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

def tool_name
  "verify_repair"
end

#tool_output_schemaObject



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

def tool_output_schema
  {
    type: "object",
    properties: {
      target_status: { type: "string" },
      gate: { type: "string" },
      completion_status: { type: "string" },
      overall_status: { type: "string" },
      new_blocking_findings: { type: "integer" },
      verification_boundary_changed: { type: ["object", "boolean"] },
      regressed: { type: "boolean" },
      gate_result: { type: "object" }
    },
    required: %w[target_status gate completion_status]
  }
end

#tool_titleObject



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

def tool_title
  "Verify repair"
end