Skip to content

unaiverse.custom

What this module does 🟢

Defines the Custom base class for user-extensible agent components and the GenException error type used across the framework.

custom

Custom

Global configuration constants and shared sentinel values for the UNaIVERSE framework.

Custom is a namespace-only class (never instantiated) that groups every tunable constant, environment-variable override, state-machine wildcard, action argument sentinel, and interaction limit used across the framework. Organising them here in a single place makes it straightforward to adjust timing parameters (e.g. SEND_DYNAMIC_PROFILE_EVERY), networking flags (e.g. ENV_USE_TLS), or reserved argument names without hunting through multiple modules.

The class is divided into sections delimited by comments:

  • NODE CONFIGURATION - timing intervals governing background tasks such as keep-alive messages, stats persistence, and checkpoint saves.
  • ENVIRONMENT VARIABLES - runtime overrides read from the process environment at import time. Each attribute documents its controlling variable name.
  • STATE MACHINE - wildcard tokens used inside behaviour JSON files to address the world, the agent itself, or its current partner without hard-coding IDs.
  • ACTIONS - sentinel argument-name sets (STREAM_ARG_NAMES, AGENT_ARG_NAMES, etc.) that the @action decorator and the HSM engine inspect to inject or strip special arguments before calling action bodies.
  • INTERACTIONS - capacity limits and reserved identifiers for the interaction subsystem.

Attributes:

Name Type Description
SEND_DYNAMIC_PROFILE_EVERY

Interval in seconds between successive dynamic profile broadcasts.

GET_NEW_TOKEN_EVERY

Interval in seconds between successive token renewals (set to 23 h 30 min to stay safely below the server-side 24 h limit).

PUBLISH_RENDEZVOUS_EVERY

Interval in seconds between rendezvous-point publications.

INTERVIEW_TIMEOUT

Maximum seconds to wait for an interview to complete before considering it timed out.

CONNECT_WITHOUT_ACK_RETRY_TIMEOUT

Seconds to wait before retrying a connection attempt that did not receive an acknowledgement.

CONNECT_WITHOUT_ACK_TOTAL_TIMEOUT

Total seconds before abandoning a connection attempt that never received an acknowledgement.

SEND_ALIVE_EVERY

Interval in seconds between keep-alive messages sent to peers.

SAVE_STATS_EVERY

Interval in seconds between successive stats persistence operations.

SEND_STATS_EVERY

Interval in seconds between successive stats transmissions to the world. Note that the Node constructor may override this value at runtime.

SAVE_CHECKPOINT_EVERY

Interval in seconds between checkpoint saves. A negative value disables checkpointing. Note that the Node constructor may override this value at runtime.

SLOW_DOWN_CLOCK_AFTER

Idle seconds (no network exchanges and no interactions) after which the event-loop clock switches to slow mode.

SLOW_CLOCK_DELTA

Clock delta in seconds used when the loop runs in slow mode.

PRINT_LEVEL

Verbosity level for console output, read from NODE_PRINT (0 = silent, 1 = verbose).

LOG_TO_FILE

Whether to write log output to a file, read from NODE_LOG.

PRINT_SCREEN_BASIC_ONLY

Whether to restrict screen output to basic messages only, read from NODE_SCREEN_BASIC_PRINT.

SKIP_WAS_ALIVE_CHECK

Whether to bypass the alive-check guard on incoming messages, read from NODE_IGNORE_ALIVE.

LIBP2PLOG

Whether to enable libp2p-level logging, read from NODE_LIBP2PLOG.

ENV_IS_ISOLATED

Whether the node runs in isolated mode (no external connections), read from NODE_IS_ISOLATED.

ENV_IS_PUBLIC

Whether the node advertises itself as publicly reachable, read from NODE_IS_PUBLIC.

ENV_IS_PUBLIC_RELAY

Whether the node acts as a public relay, read from NODE_IS_PUBLIC_RELAY.

ENV_USE_TLS

Whether TLS is enabled for transport, read from NODE_USE_TLS.

ENV_START_PORT

Starting port number for listener sockets, read from NODE_STARTING_PORT (0 lets the OS pick).

ENV_DOMAIN

Public domain name for the node, read from DOMAIN (None if not set).

ENV_CERT_PATH

Path to the TLS certificate file, read from TLS_CERT_PATH (None if not set).

ENV_KEY_PATH

Path to the TLS private key file, read from TLS_KEY_PATH (None if not set).

PATH_TO_APPEND_ADDRESSES

File path to which the node appends its running addresses, read from NODE_SAVE_RUNNING_ADDRESSES (None if not set).

ROLE_WILDCARD

Token used in behaviour JSON to match any role.

WORLD_WILDCARD

Token used in behaviour JSON to address the world.

AGENT_WILDCARD

Token used in behaviour JSON to address the agent itself.

PARTNER_WILDCARD

Token used in behaviour JSON to address the current partner.

DEFAULT_WILDCARDS

Mapping from each wildcard token to itself, used as the baseline substitution table before real IDs are filled in.

ACTION_TICKS_PER_STATUS

Three-element list of tick strings printed next to a logged action name to indicate success, in-progress, or failure.

STREAM_ARG_NAMES

Set of action-body parameter names that the framework treats as stream selectors.

AGENT_ARG_NAMES

Set of action-body parameter names that the framework treats as agent/partner selectors.

SECONDS_ARG_NAMES

Ordered list of parameter names that carry the maximum duration for a transition (first entry is the canonical name).

TIMEOUT_ARG_NAMES

Ordered list of parameter names that carry the retry timeout for a transition (first entry is the canonical name).

DELAY_ARG_NAMES

Ordered list of parameter names that carry the pre-action delay for a transition (first entry is the canonical name).

TIME_TO_WAIT_BEFORE_ACTING_ARG_NAMES

Ordered list of parameter names that carry the wait period before a state begins acting (state-level only).

INTERACTION_INJECT_NAMES

Parameter names for which the framework injects the live Interaction object at call time. Must appear in the action body signature to opt in; forbidden in action.args and wire action_kwargs.

INTERACTION_FIELD_NAMES

Parameter names that are promoted from Action.args to fields of the Interaction object by the system interaction builder.

HSM_TRANSIT_META_NAMES

Parameter names consumed by the HSM transition guessing logic and stripped before the action body is called. Forbidden in body signatures and wire action_kwargs.

WIRE_SENTINEL_NAMES

Framework-private container name used inside send body signatures; forbidden everywhere else.

SPECIAL_ACTION_NAMES

Names of built-in framework actions that receive special dispatch treatment (currently only "send").

RESERVED_IN_BODY_SIGNATURE

Union of name sets that must not appear in a regular action body signature.

RESERVED_IN_ACTION_KWARGS

Union of name sets that must not appear in wire action_kwargs.

DEFAULT_TIMEOUT

Default timeout in seconds for an action when none is specified.

ALL_STATES_NAME

Reserved state name that matches all states in transition tables.

NOT_ALLOWED_STATE_NAMES

Set of state names that user-defined states must not use.

SYSTEM_INTERACTION_ID

Short identifier for the implicit system interaction.

SYSTEM_INTERACTION_LABEL

Human-readable label for the system interaction.

SYSTEM_INTERACTION_UUID

Composite UUID for the system interaction, formed as SYSTEM_INTERACTION_ID + "_" + SYSTEM_INTERACTION_LABEL.

MAX_INTERACTIONS

Maximum number of concurrent interactions allowed per agent.

MAX_STREAM_DATA_WITHOUT_INTERACTIONS

Maximum number of stream data items that may be buffered when no interaction is active.

DEFAULT_INTER_TIMEOUT

Default interaction timeout in seconds (5 minutes).

DRAIN_TIMEOUT

Timeout in seconds used when draining interaction queues (0 means non-blocking).

FAKE_INTERACTION_UUID

UUID string used as a placeholder for synthetic interactions that do not correspond to real network exchanges.

SEND_DYNAMIC_PROFILE_EVERY class-attribute instance-attribute

SEND_DYNAMIC_PROFILE_EVERY = 10.0

GET_NEW_TOKEN_EVERY class-attribute instance-attribute

GET_NEW_TOKEN_EVERY = 23 * 60.0 * 60.0 + 30 * 60.0

PUBLISH_RENDEZVOUS_EVERY class-attribute instance-attribute

PUBLISH_RENDEZVOUS_EVERY = 10.0

INTERVIEW_TIMEOUT class-attribute instance-attribute

INTERVIEW_TIMEOUT = 60.0

CONNECT_WITHOUT_ACK_RETRY_TIMEOUT class-attribute instance-attribute

CONNECT_WITHOUT_ACK_RETRY_TIMEOUT = 30.0

CONNECT_WITHOUT_ACK_TOTAL_TIMEOUT class-attribute instance-attribute

CONNECT_WITHOUT_ACK_TOTAL_TIMEOUT = 60.0

SEND_ALIVE_EVERY class-attribute instance-attribute

SEND_ALIVE_EVERY = 2.5 * 60.0

SAVE_STATS_EVERY class-attribute instance-attribute

SAVE_STATS_EVERY = 10.0

SEND_STATS_EVERY class-attribute instance-attribute

SEND_STATS_EVERY = 30.0

SAVE_CHECKPOINT_EVERY class-attribute instance-attribute

SAVE_CHECKPOINT_EVERY = -1.0

SLOW_DOWN_CLOCK_AFTER class-attribute instance-attribute

SLOW_DOWN_CLOCK_AFTER = 10.0

SLOW_CLOCK_DELTA class-attribute instance-attribute

SLOW_CLOCK_DELTA = 2.0

PRINT_LEVEL class-attribute instance-attribute

PRINT_LEVEL = int(getenv('NODE_PRINT', '0'))

LOG_TO_FILE class-attribute instance-attribute

LOG_TO_FILE = int(getenv('NODE_LOG', '0')) == 1

PRINT_SCREEN_BASIC_ONLY class-attribute instance-attribute

PRINT_SCREEN_BASIC_ONLY = int(getenv('NODE_SCREEN_BASIC_PRINT', '0')) == 1

SKIP_WAS_ALIVE_CHECK class-attribute instance-attribute

SKIP_WAS_ALIVE_CHECK = getenv('NODE_IGNORE_ALIVE', '0') == '1'

LIBP2PLOG class-attribute instance-attribute

LIBP2PLOG = getenv('NODE_LIBP2PLOG', '0') == '1'

ENV_IS_ISOLATED class-attribute instance-attribute

ENV_IS_ISOLATED = getenv('NODE_IS_ISOLATED', '0') == '1'

ENV_IS_PUBLIC class-attribute instance-attribute

ENV_IS_PUBLIC = getenv('NODE_IS_PUBLIC', '0') == '1'

ENV_IS_PUBLIC_RELAY class-attribute instance-attribute

ENV_IS_PUBLIC_RELAY = getenv('NODE_IS_PUBLIC_RELAY', '0') == '1'

ENV_USE_TLS class-attribute instance-attribute

ENV_USE_TLS = getenv('NODE_USE_TLS', '0') == '1'

ENV_START_PORT class-attribute instance-attribute

ENV_START_PORT = int(getenv('NODE_STARTING_PORT', '0'))

ENV_DOMAIN class-attribute instance-attribute

ENV_DOMAIN = getenv('DOMAIN', None)

ENV_CERT_PATH class-attribute instance-attribute

ENV_CERT_PATH = getenv('TLS_CERT_PATH', None)

ENV_KEY_PATH class-attribute instance-attribute

ENV_KEY_PATH = getenv('TLS_KEY_PATH', None)

PATH_TO_APPEND_ADDRESSES class-attribute instance-attribute

PATH_TO_APPEND_ADDRESSES = getenv('NODE_SAVE_RUNNING_ADDRESSES')

ROLE_WILDCARD class-attribute instance-attribute

ROLE_WILDCARD = '<role>'

WORLD_WILDCARD class-attribute instance-attribute

WORLD_WILDCARD = '<world>'

AGENT_WILDCARD class-attribute instance-attribute

AGENT_WILDCARD = '<agent>'

PARTNER_WILDCARD class-attribute instance-attribute

PARTNER_WILDCARD = '<partner>'

DEFAULT_WILDCARDS class-attribute instance-attribute

ACTION_TICKS_PER_STATUS class-attribute instance-attribute

ACTION_TICKS_PER_STATUS = ['   ✅ ', '   🔄 ', '   ❌ ']

STREAM_ARG_NAMES class-attribute instance-attribute

STREAM_ARG_NAMES = {'stream', 'streams'}

AGENT_ARG_NAMES class-attribute instance-attribute

AGENT_ARG_NAMES = {'agent', 'agents', 'partner', 'partners', 'targets', 'target'}

SECONDS_ARG_NAMES class-attribute instance-attribute

SECONDS_ARG_NAMES = ['max_duration']

TIMEOUT_ARG_NAMES class-attribute instance-attribute

TIMEOUT_ARG_NAMES = ['retry_timeout']

DELAY_ARG_NAMES class-attribute instance-attribute

DELAY_ARG_NAMES = ['delay']

TIME_TO_WAIT_BEFORE_ACTING_ARG_NAMES class-attribute instance-attribute

TIME_TO_WAIT_BEFORE_ACTING_ARG_NAMES = ['time_to_wait_before_acting']
Role Names Semantics

INTERACTION_INJECT {'interaction'} Framework injects the Interaction object at call time. Must be declarable in body sig (that's how injection opts in). Forbidden in action.args and in wire action_kwargs. INTERACTION_FIELD {streams, num_steps, target, timeout, Promoted from Action.args to a field of the Interaction copy_sys, forced_uuid, id, volatile, object by __build_system_interaction. Allowed in body data_samples, callback} sig (then stays in action_kwargs). Allowed in wire action_kwargs iff value equals the matching Interaction field. HSM_TRANSIT_META {max_duration, retry_timeout, delay} Per-transit scalars consumed by __guess_* then stripped from Action.args. Forbidden in body sig and in wire action_kwargs. WIRE_SENTINEL {'action_kwargs'} Framework-private container name. Forbidden everywhere
except send's body sig. REGULAR everything else Validated only against the body sig.


INTERACTION_INJECT_NAMES class-attribute instance-attribute

INTERACTION_INJECT_NAMES = {'interaction'}

INTERACTION_FIELD_NAMES class-attribute instance-attribute

INTERACTION_FIELD_NAMES = {'streams', 'num_steps', 'target', 'timeout', 'copy_sys', 'forced_uuid', 'id', 'volatile', 'data_samples', 'callback'}

HSM_TRANSIT_META_NAMES class-attribute instance-attribute

HSM_TRANSIT_META_NAMES = {SECONDS_ARG_NAMES[0], TIMEOUT_ARG_NAMES[0], DELAY_ARG_NAMES[0]}

WIRE_SENTINEL_NAMES class-attribute instance-attribute

WIRE_SENTINEL_NAMES = {'action_kwargs'}

SPECIAL_ACTION_NAMES class-attribute instance-attribute

SPECIAL_ACTION_NAMES = {'send'}

RESERVED_IN_BODY_SIGNATURE class-attribute instance-attribute

RESERVED_IN_BODY_SIGNATURE = HSM_TRANSIT_META_NAMES | WIRE_SENTINEL_NAMES

RESERVED_IN_ACTION_KWARGS class-attribute instance-attribute

DEFAULT_TIMEOUT class-attribute instance-attribute

DEFAULT_TIMEOUT = 10.0

ALL_STATES_NAME class-attribute instance-attribute

ALL_STATES_NAME = 'all'

NOT_ALLOWED_STATE_NAMES class-attribute instance-attribute

NOT_ALLOWED_STATE_NAMES = {ALL_STATES_NAME}

SYSTEM_INTERACTION_ID class-attribute instance-attribute

SYSTEM_INTERACTION_ID = 'sys'

SYSTEM_INTERACTION_LABEL class-attribute instance-attribute

SYSTEM_INTERACTION_LABEL = 'system'

SYSTEM_INTERACTION_UUID class-attribute instance-attribute

SYSTEM_INTERACTION_UUID = SYSTEM_INTERACTION_ID + '_' + SYSTEM_INTERACTION_LABEL

MAX_INTERACTIONS class-attribute instance-attribute

MAX_INTERACTIONS = 100

MAX_STREAM_DATA_WITHOUT_INTERACTIONS class-attribute instance-attribute

MAX_STREAM_DATA_WITHOUT_INTERACTIONS = 10

DEFAULT_INTER_TIMEOUT class-attribute instance-attribute

DEFAULT_INTER_TIMEOUT = 60.0 * 5.0

DRAIN_TIMEOUT class-attribute instance-attribute

DRAIN_TIMEOUT = 0.0

FAKE_INTERACTION_UUID class-attribute instance-attribute

FAKE_INTERACTION_UUID = 'fake_system'

GenException

Bases: Exception

Base exception class for the UNaIVERSE framework.

All framework-specific exceptions inherit from GenException so that callers can catch the entire UNaIVERSE exception hierarchy with a single except GenException clause while still being able to distinguish individual sub-types when finer-grained handling is needed.

Because GenException does not override Exception's constructor or add any attributes, it can be raised with any positional arguments accepted by the built-in Exception:

raise GenException("Unexpected state reached.")