Class: Moult::GateReport

Inherits:
Object
  • Object
show all
Defined in:
lib/moult/gate_report.rb

Overview

The serialized result model for moult gate (schema/gate.schema.json), sibling to HealthReport and BoundariesReport. It owns its own JSON envelope and leaves every signal contract — and the two protected APIs — untouched.

This is the FIRST and ONLY Moult contract that renders a VERDICT. Every other analysis emits a confidence-graded / classified SIGNAL with no pass/fail; the gate consumes those signals, applies an explicit recorded Moult::Gate::Policy, and reports one top-level verdict. The verdict is an auditable application of that policy over confidence-graded candidates — never a claim that code is certainly wrong or dead. The words "verdict"/"pass"/"fail" live here and nowhere else.

Defined Under Namespace

Classes: Component

Constant Summary collapse

SCHEMA_VERSION =

Bump only on a breaking change to the serialized shape.

1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, base_ref:, merge_base:, scope:, components:, policy:, evaluation:, git_ref: nil, generated_at: nil) ⇒ GateReport

Returns a new instance of GateReport.

Parameters:

  • root (String)

    absolute analysis root

  • base_ref (String, nil)

    requested base ref (nil under :all scope)

  • merge_base (String, nil)

    resolved merge-base sha (nil under :all scope)

  • scope (Symbol)

    :diff or :all

  • components (Array<Component>)

    which signal analyses ran/were skipped

  • policy (Gate::Policy)

    the applied policy (recorded in full)

  • evaluation (Gate::Evaluation::Verdict)

    verdict + per-rule outcomes



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/moult/gate_report.rb', line 36

def initialize(root:, base_ref:, merge_base:, scope:, components:, policy:, evaluation:,
  git_ref: nil, generated_at: nil)
  @root = root
  @base_ref = base_ref
  @merge_base = merge_base
  @scope = scope
  @components = components
  @policy = policy
  @evaluation = evaluation
  @git_ref = git_ref
  @generated_at = generated_at
end

Instance Attribute Details

#base_refObject (readonly)

Returns the value of attribute base_ref.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def base_ref
  @base_ref
end

#componentsObject (readonly)

Returns the value of attribute components.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def components
  @components
end

#evaluationObject (readonly)

Returns the value of attribute evaluation.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def evaluation
  @evaluation
end

#generated_atObject (readonly)

Returns the value of attribute generated_at.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def generated_at
  @generated_at
end

#git_refObject (readonly)

Returns the value of attribute git_ref.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def git_ref
  @git_ref
end

#merge_baseObject (readonly)

Returns the value of attribute merge_base.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def merge_base
  @merge_base
end

#policyObject (readonly)

Returns the value of attribute policy.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def policy
  @policy
end

#rootObject (readonly)

Returns the value of attribute root.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def root
  @root
end

#scopeObject (readonly)

Returns the value of attribute scope.



26
27
28
# File 'lib/moult/gate_report.rb', line 26

def scope
  @scope
end

Instance Method Details

#findingsObject

Contributing findings flattened across all rules (for CI projections).



63
64
65
# File 'lib/moult/gate_report.rb', line 63

def findings
  rules.flat_map(&:findings)
end

#reasonsObject



58
59
60
# File 'lib/moult/gate_report.rb', line 58

def reasons
  evaluation.reasons
end

#rulesObject



54
55
56
# File 'lib/moult/gate_report.rb', line 54

def rules
  evaluation.rules
end

#summaryObject



67
68
69
70
71
72
73
74
# File 'lib/moult/gate_report.rb', line 67

def summary
  {
    rules: rules.size,
    evaluated: rules.count(&:evaluated),
    failed: rules.count { |r| r.evaluated && r.passed == false },
    findings: findings.size
  }
end

#to_hObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/moult/gate_report.rb', line 76

def to_h
  {
    schema_version: SCHEMA_VERSION,
    tool: {name: "moult", version: Moult::VERSION},
    analysis: {
      root: root,
      git_ref: git_ref,
      generated_at: generated_at,
      base_ref: base_ref,
      merge_base: merge_base,
      scope: scope.to_s,
      components: components.map(&:to_h)
    },
    policy: policy.to_h,
    verdict: verdict,
    reasons: reasons.map(&:to_h),
    summary: summary,
    rules: rules.map(&:to_h)
  }
end

#verdictObject

The top-level verdict, "pass" or "fail". The CLI maps this to its exit code.



50
51
52
# File 'lib/moult/gate_report.rb', line 50

def verdict
  evaluation.verdict
end