Class: Insika::Harvest::Criterion

Inherits:
Object
  • Object
show all
Defined in:
lib/insika/harvest/criterion.rb

Overview

C4 — the frozen conversion criterion, parsed from the deployment's criterion file. The parity shape (Parity::Criterion) copied: one file, one ```yaml fence, the WHOLE bytes hashed (an edit to the rationale invalidates the frozen rule too), strict keys, no defaults. A skill may land only when the store's ruler is not measurably worse than the accepted state — the FILE is the criterion; a profile carries no thresholds, and GateHarvest/PromoteHarvest receive the loaded criterion (with its sha) at boot.

Defined Under Namespace

Classes: Rule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule:, path:, sha:) ⇒ Criterion

Returns a new instance of Criterion.



21
22
23
24
25
# File 'lib/insika/harvest/criterion.rb', line 21

def initialize(rule:, path:, sha:)
  @rule = rule
  @path = path
  @sha = sha
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'lib/insika/harvest/criterion.rb', line 19

def path
  @path
end

#ruleObject (readonly)

Returns the value of attribute rule.



19
20
21
# File 'lib/insika/harvest/criterion.rb', line 19

def rule
  @rule
end

#shaObject (readonly)

Returns the value of attribute sha.



19
20
21
# File 'lib/insika/harvest/criterion.rb', line 19

def sha
  @sha
end

Class Method Details

.load(path) ⇒ Object

Reads the file, extracts the FIRST ```yaml fence, validates STRICTLY. Raises Insika::ConfigError when the file is absent or has no block; Insika::ValidationError on an unknown or missing key, or a malformed value — every defect named.



31
32
33
34
35
36
37
# File 'lib/insika/harvest/criterion.rb', line 31

def self.load(path)
  bytes = read_bytes(path)
  block = extract_yaml_block(bytes)
  parsed = YAML.safe_load(block, permitted_classes: [], aliases: false)
  rule = build_rule(parsed)
  new(rule: rule, path: path, sha: "sha256:#{Digest::SHA256.hexdigest(bytes)}")
end

Instance Method Details

#to_hObject



39
# File 'lib/insika/harvest/criterion.rb', line 39

def to_h = @rule.to_h