Class: OllamaAgent::Security::OwnershipCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/security/ownership_compiler.rb

Overview

Parses and validates owners rules, then builds an OwnershipIndex.

Instance Method Summary collapse

Instance Method Details

#compile(yaml_string: nil, path: nil) ⇒ OwnershipIndex

Parameters:

  • yaml_string (String, nil) (defaults to: nil)
  • path (String, nil) (defaults to: nil)

Returns:



17
18
19
20
21
22
23
# File 'lib/ollama_agent/security/ownership_compiler.rb', line 17

def compile(yaml_string: nil, path: nil)
  @source_bytes = read_source(yaml_string: yaml_string, path: path)
  rules = rules_from_tree(parse_yaml(@source_bytes))
  flat = OwnershipRuleTreeFlattener.new.flatten(rules)
  OwnershipCompileValidators.validate!(flat)
  index_from_flat(flat)
end

#source_sha256String

Returns hex SHA256 of the last compiled source bytes.

Returns:

  • (String)

    hex SHA256 of the last compiled source bytes

Raises:



26
27
28
29
30
# File 'lib/ollama_agent/security/ownership_compiler.rb', line 26

def source_sha256
  raise OwnershipCompileError, "compile first" unless @source_bytes

  Digest::SHA256.hexdigest(@source_bytes)
end