MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / generate_task_id

Function generate_task_id

src/tasks_core.py:85–96  ·  view source on GitHub ↗

Generate a prefixed task id of the form `` <8 base36 chars>``. ``secrets.choice`` (CSPRNG) — NOT ``random.choice`` — to mirror TS's ``crypto.randomInt`` at ``typescript/src/Task.ts:102``. The chapter explains the rationale: 36^8 combinations resists brute-forcing of task outp

(task_type: TaskType)

Source from the content-addressed store, hash-verified

83
84
85def generate_task_id(task_type: TaskType) -> str:
86 """Generate a prefixed task id of the form ``<prefix><8 base36 chars>``.
87
88 ``secrets.choice`` (CSPRNG) — NOT ``random.choice`` — to mirror TS&#x27;s
89 ``crypto.randomInt`` at ``typescript/src/Task.ts:102``. The chapter
90 explains the rationale: 36^8 combinations resists brute-forcing of task
91 output filenames written under predictable paths. ``random.choice`` is
92 seeded from process state and would weaken that guarantee.
93 """
94 prefix = _TASK_ID_PREFIXES.get(task_type, "x")
95 body = "".join(secrets.choice(_TASK_ID_ALPHABET) for _ in range(_TASK_ID_BODY_LEN))
96 return prefix + body
97
98
99# ---------------------------------------------------------------------------

Calls 2

joinMethod · 0.80
getMethod · 0.45