Class: Parse::Agent::ApprovalDecision

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/agent/approval_gate.rb

Overview

Result of an approval review: approved, denied, or unavailable.

unavailable is distinct from deny on purpose: it means the approver could not be reached (no elicitation capability, no open listening stream, non-streaming transport, or a timeout) rather than "a human said no." Both fail closed — the destructive op does not run — but the distinction is preserved in the refusal reason so operators can tell a rejection from an unreachable approver.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outcome, reason = nil) ⇒ ApprovalDecision

Returns a new instance of ApprovalDecision.



23
24
25
26
# File 'lib/parse/agent/approval_gate.rb', line 23

def initialize(outcome, reason = nil)
  @outcome = outcome
  @reason = reason
end

Instance Attribute Details

#outcomeSymbol (readonly)

Returns :approve, :deny, or :unavailable.

Returns:

  • (Symbol)

    :approve, :deny, or :unavailable



19
20
21
# File 'lib/parse/agent/approval_gate.rb', line 19

def outcome
  @outcome
end

#reasonString? (readonly)

Returns human-readable reason (always set for non-approve).

Returns:

  • (String, nil)

    human-readable reason (always set for non-approve).



21
22
23
# File 'lib/parse/agent/approval_gate.rb', line 21

def reason
  @reason
end

Class Method Details

.approveObject



28
29
30
# File 'lib/parse/agent/approval_gate.rb', line 28

def self.approve
  new(:approve)
end

.deny(reason) ⇒ Object



32
33
34
# File 'lib/parse/agent/approval_gate.rb', line 32

def self.deny(reason)
  new(:deny, reason)
end

.unavailable(reason) ⇒ Object



36
37
38
# File 'lib/parse/agent/approval_gate.rb', line 36

def self.unavailable(reason)
  new(:unavailable, reason)
end

Instance Method Details

#approved?Boolean

Returns true only for an explicit approval.

Returns:

  • (Boolean)

    true only for an explicit approval.



41
42
43
# File 'lib/parse/agent/approval_gate.rb', line 41

def approved?
  @outcome == :approve
end