Class: Textus::Domain::Policy::Predicates::TargetIsCanon

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/domain/policy/predicates/target_is_canon.rb

Overview

Predicate: a proposal may only target a ‘canon` zone (ADR 0035). Runs on the `accept` floor, where Evaluation#target is the proposal’s resolved target_key. Refuses promotion into workspace/derived/ quarantine/queue — the queue→canon path is the only coherent one. No bespoke #error; failures accumulate into GuardFailed (ADR 0031).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



13
14
15
# File 'lib/textus/domain/policy/predicates/target_is_canon.rb', line 13

def reason
  @reason
end

Instance Method Details

#call(eval) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/textus/domain/policy/predicates/target_is_canon.rb', line 17

def call(eval)
  zone = eval.manifest.resolver.resolve(eval.target).entry.zone
  kind = eval.manifest.policy.declared_kind(zone.to_s)
  return true if kind == :canon

  @reason = "proposal target '#{eval.target}' is in zone '#{zone}' " \
            "(kind: #{kind || "none"}); proposals may only target a canon zone"
  false
rescue Textus::UnknownKey
  @reason = "proposal target '#{eval.target}' resolves to no declared entry"
  false
end

#nameObject



15
# File 'lib/textus/domain/policy/predicates/target_is_canon.rb', line 15

def name = "target_is_canon"