identity
identity
¶
Task ID generation, validation, and prefix resolution.
Task IDs are Crockford-base32 with a structural signature: a 16-letter non-hex head + a digit + three full-alphabet chars. The shape makes a terok task ID unmistakable from a podman container ID or git SHA at a glance.
__all__ = ['is_task_id', 'normalize_task_id_input', 'resolve_task_id']
module-attribute
¶
normalize_task_id_input(raw)
¶
Collapse user-input variants to the canonical lowercase form.
Strips hyphens, lowercases, and applies the Crockford
I/L → 1, O → 0 substitutions. The result is still subject
to _TASK_ID_PREFIX_RE downstream — this only widens what
we accept, never what we emit.
Call-site discipline: only call this at user-interactive CLI
boundaries — argparse dispatch handlers and argcomplete completers.
Internal code paths (lib/*, tui/*, TUI pickers, clearance,
anything reading task IDs from disk, OCI annotations, or runtime
state) always work with canonical lowercase IDs and must never
re-normalise. Leaking this tolerance inward quietly defeats the
"we encode only in canonical form" invariant.
Source code in src/terok/lib/orchestration/tasks/identity.py
is_task_id(text)
¶
resolve_task_id(project_name, prefix)
¶
Resolve a (possibly partial) task ID to its full form.
The prefix is first run through normalize_task_id_input,
so callers may pass uppercase, hyphenated, or ambiguous-letter
variants (K3-V8H, k3v8I) — they collapse to the canonical
lowercase form before validation and lookup.
Raises SystemExit with an actionable message on zero or multiple matches.