Class: Engram::Decision

Inherits:
Object
  • Object
show all
Defined in:
lib/engram/decision.rb

Overview

The outcome of consolidating one candidate fact against existing memory.

action     - :add | :update | :forget | :noop
candidate  - the Record produced by extraction
target_id  - id of the existing memory to update/forget (nil for add/noop)
reason     - optional human-readable rationale (useful for audit/eval)

Constant Summary collapse

ACTIONS =
%i[add update forget noop].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, candidate:, target_id: nil, reason: nil) ⇒ Decision

Returns a new instance of Decision.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/engram/decision.rb', line 15

def initialize(action:, candidate:, target_id: nil, reason: nil)
  action = action.to_sym
  unless ACTIONS.include?(action)
    raise ArgumentError, "unknown action #{action.inspect}; expected one of #{ACTIONS.inspect}"
  end

  @action = action
  @candidate = candidate
  @target_id = target_id
  @reason = reason
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



13
14
15
# File 'lib/engram/decision.rb', line 13

def action
  @action
end

#candidateObject (readonly)

Returns the value of attribute candidate.



13
14
15
# File 'lib/engram/decision.rb', line 13

def candidate
  @candidate
end

#reasonObject (readonly)

Returns the value of attribute reason.



13
14
15
# File 'lib/engram/decision.rb', line 13

def reason
  @reason
end

#target_idObject (readonly)

Returns the value of attribute target_id.



13
14
15
# File 'lib/engram/decision.rb', line 13

def target_id
  @target_id
end