naming
naming
¶
Task name sanitization, validation, and random-name generation.
TASK_NAME_MAX_LEN = 60
module-attribute
¶
Maximum length of a sanitized task name.
__all__ = ['TASK_NAME_MAX_LEN', 'generate_task_name', 'sanitize_task_name', 'validate_task_name']
module-attribute
¶
sanitize_task_name(raw)
¶
Sanitize a raw task name into a slug-style identifier.
Strips whitespace, lowercases, replaces spaces with hyphens,
removes characters outside [a-z0-9_-], collapses consecutive
hyphens, strips trailing hyphens, and truncates to
TASK_NAME_MAX_LEN. Returns None if the result is empty.
Leading hyphens are preserved so callers can detect and reject them
(a name starting with - looks like a CLI flag).
Source code in src/terok/lib/orchestration/tasks/naming.py
validate_task_name(sanitized)
¶
Return an error message if sanitized is not a valid task name, else None.
A name is invalid if it starts with a hyphen (looks like a CLI flag).
Callers should first check for None from sanitize_task_name
(which indicates the name was empty after sanitization).
Source code in src/terok/lib/orchestration/tasks/naming.py
generate_task_name(project_name=None)
¶
Generate a random human-readable task name (e.g. talented-toucan).
When project_name is given, name categories are resolved from config:
project tasks.name_categories → global tasks.name_categories
→ deterministic 3-category selection based on project name hash.