Class: Karst::CLI::Verification

Inherits:
Object
  • Object
show all
Defined in:
lib/karst/cli/verification.rb

Overview

Presentation-only adapter for Access::Search. It deliberately receives Search's result and converts only its public evidence values to stable, privacy-bounded primitives. Formatting necessarily enumerates the complete public schema in one place, keeping the versioned contract auditable. rubocop:disable Metrics/ClassLength, Metrics/MethodLength, Metrics/AbcSize

Constant Summary collapse

SCHEMA_VERSION =
1

Instance Method Summary collapse

Constructor Details

#initialize(path:, http_method: "GET", output: $stdout, json: false) ⇒ Verification

Returns a new instance of Verification.



17
18
19
20
21
22
# File 'lib/karst/cli/verification.rb', line 17

def initialize(path:, http_method: "GET", output: $stdout, json: false)
  @path = path
  @http_method = http_method
  @output = output
  @json = json
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
# File 'lib/karst/cli/verification.rb', line 24

def call
  result = run_search
  @output.puts(@json ? JSON.generate(document(result)) : human(result))
  result.verified_outcome ? 0 : 1
rescue Access::Error, Identity::Error, ArgumentError => e
  @output.puts(@json ? JSON.generate(error_document(e)) : "Karst cannot verify this route:\n#{e.message}")
  2
end

#evidenceObject

The same schema-versioned evidence document --json prints, without any dependency on @output/stdout -- the shared entry point every other adapter (currently only the MCP server) calls instead of duplicating Access::Search invocation or result serialization. Always returns a Hash: either the success document or, on any of the same errors #call rescues, error_document(e) -- never raises.



39
40
41
42
43
# File 'lib/karst/cli/verification.rb', line 39

def evidence
  document(run_search)
rescue Access::Error, Identity::Error, ArgumentError => e
  error_document(e)
end