Module: Textus::Role

Defined in:
lib/textus/role.rb

Constant Summary collapse

HUMAN =

The three role archetypes, each string sourced exactly once: human curates canon, agent proposes, automation fetches/builds (explanation/concepts.md). Reference these constants instead of bare literals (ADR 0044).

"human".freeze
AGENT =
"agent".freeze
AUTOMATION =
"automation".freeze
NAMES =

The closed set of legal role names (ADR 0045), built FROM the archetypes above so it stays the single source of truth — a manifest declaring any other name is rejected at load, and DEFAULT ∈ NAMES holds structurally. Capabilities (‘can:`) remain freely tunable per role.

[HUMAN, AGENT, AUTOMATION].freeze
DEFAULT =

Default acting identity (ADR 0040): a choice over the vocabulary, not a new name. CLI callers act as the human; an agent over stdio proposes and does not inherit the human’s authority (it defaults to AGENT per transport).

HUMAN

Class Method Summary collapse

Class Method Details

.read_file(root) ⇒ Object



28
29
30
31
32
33
# File 'lib/textus/role.rb', line 28

def self.read_file(root)
  path = File.join(root, "role")
  return nil unless File.exist?(path)

  File.read(path).strip.then { |s| s.empty? ? nil : s }
end

.resolve(root:, flag: nil, env: ENV, default: DEFAULT) ⇒ Object

Raises:



21
22
23
24
25
26
# File 'lib/textus/role.rb', line 21

def self.resolve(root:, flag: nil, env: ENV, default: DEFAULT)
  candidate = flag || env["TEXTUS_ROLE"] || read_file(root) || default
  raise InvalidRole.new(candidate) unless NAMES.include?(candidate)

  candidate
end