class LittleGhost::Subagents::AgentPath
AgentPath gives every delegated conversation a stable place beneath its parent. Paths begin at /root, keeping nested delegation visible in logs and metadata.
Child task names contain only lowercase letters, digits, and underscores, are limited to 40 characters, and must be unique among siblings when reserved by a manager.
AgentPath.join("/root", "review_api") # => "/root/review_api"
Public Class Methods
# File lib/little_ghost/subagents/agent_path.rb, line 54 def immediate_child?(path, parent) value = validate!(path) ancestor = validate!(parent) value.start_with?("#{ancestor}/") && !value.delete_prefix("#{ancestor}/").include?("/") end
Checks whether path is exactly one level beneath parent.
Source
# File lib/little_ghost/subagents/agent_path.rb, line 36 def join(parent, name) validate!("#{validate!(parent)}/#{validate_name!(name)}") end
Validates both parts and returns a direct child path.
Source
# File lib/little_ghost/subagents/agent_path.rb, line 22 def validate!(path) value = String(path) raise ArgumentError, "agent path must start with /root" unless value == ROOT || value.start_with?("#{ROOT}/") raise ArgumentError, "agent path must not end with /" if value.end_with?("/") raise ArgumentError, "agent path is too long" if value.length > MAX_PATH_LENGTH segments = value.split("/").drop(2) raise ArgumentError, "agent path must not contain empty segments" if segments.any?(&:empty?) segments.each { |segment| validate_name!(segment) } value end
Validates an absolute agent path and returns it unchanged.
Source
# File lib/little_ghost/subagents/agent_path.rb, line 41 def validate_name!(name) value = String(name) if value.length > MAX_NAME_LENGTH raise ArgumentError, "task_name must be at most #{MAX_NAME_LENGTH} characters" end if value == "root" || !value.match?(NAME_PATTERN) raise ArgumentError, "task_name must use lowercase letters, digits, and underscores" end value end
Validates and returns one model-chosen task name.