Module: Legion::Gaia::Disclosure

Defined in:
lib/legion/gaia/disclosure.rb

Class Method Summary collapse

Class Method Details

.fetch_behavioral_synapses(identity) ⇒ Object



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

def fetch_behavioral_synapses(identity)
  all = Legion::Gaia::BehavioralSynapse.all_for(identity: identity)
  return nil if all.empty?

  all.map do |entry|
    {
      id: entry[:id],
      domain: entry[:domain],
      directive: entry[:directive],
      confidence: entry[:confidence],
      autonomy_mode: Legion::Gaia::BehavioralSynapse::Math.autonomy_mode(entry[:confidence].to_f),
      status: entry[:status],
      origin: entry[:origin],
      consecutive_successes: entry[:consecutive_successes],
      consecutive_failures: entry[:consecutive_failures],
      last_reinforced_at: entry[:last_reinforced_at]
    }
  end
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_behavioral_synapses')
  nil
end

.fetch_bond_state(identity) ⇒ Object

--- private section ---



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/legion/gaia/disclosure.rb', line 31

def fetch_bond_state(identity)
  entry = Legion::Gaia::BondRegistry.instance_variable_get(:@bonds)[identity]
  return nil unless entry

  {
    bond: entry[:bond],
    strength: entry[:strength],
    origin: entry[:origin],
    reinforcement_count: entry[:reinforcement_count],
    since: entry[:since],
    preferred_channel: entry[:preferred_channel],
    lifecycle_state: Legion::Gaia::BondRegistry.bond_state(identity)
  }
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_bond_state')
  nil
end

.fetch_calibration_weights(identity) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/legion/gaia/disclosure.rb', line 84

def fetch_calibration_weights(identity)
  return nil unless defined?(Legion::Extensions::Agentic::Social::Calibration::Runners::Calibration)

  runner = Object.new
  runner.extend(Legion::Extensions::Agentic::Social::Calibration::Runners::Calibration)
  result = runner.respond_to?(:calibration_weights_for) ? runner.calibration_weights_for(identity: identity) : nil
  result.is_a?(Hash) ? result : nil
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_calibration_weights')
  nil
end

.fetch_imprint_stateObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/legion/gaia/disclosure.rb', line 96

def fetch_imprint_state
  return nil unless defined?(Legion::Extensions::Coldstart)
  return nil unless Legion::Extensions::Coldstart.respond_to?(:connected?) &&
                    Legion::Extensions::Coldstart.connected?

  bootstrap = Legion::Extensions::Coldstart::Helpers::Bootstrap.instance
  {
    layer: bootstrap.respond_to?(:current_layer) ? bootstrap.current_layer : nil,
    observations_count: bootstrap.respond_to?(:observation_count) ? bootstrap.observation_count : nil,
    active: bootstrap.respond_to?(:imprint_active?) ? bootstrap.imprint_active? : nil
  }
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_imprint_state')
  nil
end

.fetch_prediction_accuracy(identity) ⇒ Object



112
113
114
115
116
117
118
119
120
# File 'lib/legion/gaia/disclosure.rb', line 112

def fetch_prediction_accuracy(identity)
  return nil unless defined?(Legion::Extensions::AgenticInference)
  return nil unless Legion::Extensions::AgenticInference.respond_to?(:accuracy_for)

  Legion::Extensions::AgenticInference.accuracy_for(identity: identity)
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_prediction_accuracy')
  nil
end

.fetch_preferences(identity) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/legion/gaia/disclosure.rb', line 72

def fetch_preferences(identity)
  return nil unless defined?(Legion::Extensions::Mesh::Helpers::PreferenceProfile)

  result = Legion::Extensions::Mesh::Helpers::PreferenceProfile.for_owner(owner_id: identity)
  return nil unless result.is_a?(Hash) && result[:directives].is_a?(Array)

  result[:directives]
rescue StandardError => e
  Legion::Gaia::Disclosure.handle_exception_quietly(e, 'disclosure.fetch_preferences')
  nil
end

.handle_exception_quietly(exception, operation) ⇒ Object



122
123
124
125
126
# File 'lib/legion/gaia/disclosure.rb', line 122

def handle_exception_quietly(exception, operation)
  return unless defined?(Legion::Logging)

  Legion::Logging.debug("[gaia] #{operation} soft-guarded: #{exception.class}: #{exception.message}")
end

.report(identity:) ⇒ Hash

Full partner model report — what the agent knows, how it was earned, what stays local. Principal-bound: caller reads ONLY their own partner model.

Parameters:

  • identity (String)

    the partner identity key

Returns:

  • (Hash)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/gaia/disclosure.rb', line 13

def report(identity:)
  identity_str = identity.to_s

  {
    identity: identity_str,
    bond_state: fetch_bond_state(identity_str),
    behavioral_synapses: fetch_behavioral_synapses(identity_str),
    preferences: fetch_preferences(identity_str),
    calibration_weights: fetch_calibration_weights(identity_str),
    imprint_state: fetch_imprint_state,
    prediction_accuracy: fetch_prediction_accuracy(identity_str),
    data_locality: 'All data is stored locally on this node. Nothing leaves this machine.',
    termination_available: true
  }
end