Class: Ibex::VerifiableGenerationBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/verifiable_generation_bundle.rb,
sig/ibex/verifiable_generation_bundle.rbs

Overview

Explicitly renders and publishes one manifest-bound verification bundle.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(automaton, wrapper_path:, wrapper_source:, table_path:, report_path:, manifest_path:, source_records:, manifest_options: {}, wrapper_mode: nil, representation: :compact, cst_trivia: nil, omit_action_call: nil, strict: false, max_states: VerificationReport::DEFAULT_MAX_STATES, max_items: VerificationReport::DEFAULT_MAX_ITEMS) ⇒ VerifiableGenerationBundle

rubocop:disable Metrics/ParameterLists -- persisted artifact paths and verification bounds are explicit inputs.

RBS:

  • (IR::Automaton automaton, wrapper_path: String, wrapper_source: String, table_path: String, report_path: String, manifest_path: String, source_records: Array[GenerationInput], ?manifest_options: Hash[String, Object?], ?wrapper_mode: Integer?, ?representation: Symbol | String, ?cst_trivia: Symbol | String?, ?omit_action_call: bool?, ?strict: bool, ?max_states: Integer, ?max_items: Integer) -> void

Parameters:

  • automaton (IR::Automaton)
  • wrapper_path: (String)
  • wrapper_source: (String)
  • table_path: (String)
  • report_path: (String)
  • manifest_path: (String)
  • source_records: (Array[GenerationInput])
  • manifest_options: (Hash[String, Object?]) (defaults to: {})
  • wrapper_mode: (Integer, nil) (defaults to: nil)
  • representation: (Symbol, String) (defaults to: :compact)
  • cst_trivia: (Symbol, String, nil) (defaults to: nil)
  • omit_action_call: (Boolean, nil) (defaults to: nil)
  • strict: (Boolean) (defaults to: false)
  • max_states: (Integer) (defaults to: VerificationReport::DEFAULT_MAX_STATES)
  • max_items: (Integer) (defaults to: VerificationReport::DEFAULT_MAX_ITEMS)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ibex/verifiable_generation_bundle.rb', line 19

def initialize(automaton, wrapper_path:, wrapper_source:, table_path:, report_path:, manifest_path:,
               source_records:, manifest_options: {}, wrapper_mode: nil, representation: :compact,
               cst_trivia: nil, omit_action_call: nil, strict: false,
               max_states: VerificationReport::DEFAULT_MAX_STATES,
               max_items: VerificationReport::DEFAULT_MAX_ITEMS)
  @automaton = automaton
  @wrapper_path = wrapper_path
  @wrapper_source = wrapper_source
  @table_path = table_path
  VerificationReport::LogicalPath.table(table_path)
  if source_records.length > VerificationReport::LogicalPath::MAX_INPUT_FILES
    raise ArgumentError,
          "verification reports support at most #{VerificationReport::LogicalPath::MAX_INPUT_FILES} input files"
  end
  @report_path = report_path
  @manifest_path = manifest_path
  @source_records = source_records
  @manifest_options = manifest_options
  @wrapper_mode = wrapper_mode
  @representation = representation
  @cst_trivia = cst_trivia
  @omit_action_call = omit_action_call
  @strict = strict
  @max_states = max_states
  @max_items = max_items
end

Class Method Details

.validate_file(manifest_path) ⇒ Hash[String, VerificationReport::Validator::json_value]

RBS:

  • (String manifest_path) -> Hash[String, VerificationReport::Validator::json_value]

Parameters:

  • manifest_path (String)

Returns:

  • (Hash[String, VerificationReport::Validator::json_value])


82
83
84
# File 'lib/ibex/verifiable_generation_bundle.rb', line 82

def self.validate_file(manifest_path)
  VerificationReport.validate_bundle_file(manifest_path)
end

Instance Method Details

#publish(warning: ->(_message) {}, stability_check: -> { @source_records.all?(&:current?) }) ⇒ ArtifactSet

RBS:

  • (?warning: ^(String) -> void, ?stability_check: ^() -> bool) -> ArtifactSet

Parameters:

  • warning: (^(String) -> void) (defaults to: ->(_message) {})
  • stability_check: (^() -> bool) (defaults to: -> { @source_records.all?(&:current?) })

Returns:



73
74
75
76
77
78
79
# File 'lib/ibex/verifiable_generation_bundle.rb', line 73

def publish(warning: ->(_message) {}, stability_check: -> { @source_records.all?(&:current?) })
  artifacts = render
  GenerationTransaction.new(
    artifacts, warning: warning, stability_check: stability_check, source_records: @source_records
  ).commit
  artifacts
end

#renderArtifactSet

Render table, wrapper, and report before the non-cyclic manifest marker.

RBS:

  • () -> ArtifactSet

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ibex/verifiable_generation_bundle.rb', line 49

def render
  canonical_automaton = VerificationReport.canonical_automaton(
    @automaton, source_records: @source_records
  )
  table = TableArtifact.build(
    canonical_automaton, representation: @representation, cst_trivia: @cst_trivia,
                         omit_action_call: @omit_action_call
  )
  artifacts = ArtifactSet.new
  artifacts.add(kind: :parser_table, path: @table_path, content: table.dump)
  artifacts.add(kind: :parser, path: @wrapper_path, content: @wrapper_source, mode: @wrapper_mode)
  report = VerificationReport.render(
    canonical_automaton, table: table, source_records: @source_records, table_path: @table_path,
                         strict: @strict, max_states: @max_states, max_items: @max_items
  )
  artifacts.add(kind: :verification_report, path: @report_path, content: report)
  manifest = GenerationManifest.render(
    artifacts, source_records: @source_records, options: @manifest_options
  )
  artifacts.add(kind: :manifest, path: @manifest_path, content: manifest)
  artifacts
end