Documentation Index
Fetch the complete documentation index at: https://ahvn.top/llms.txt
Use this file to discover all available pages before exploring further.
Function utilities help with the runtime actions that are easy to get subtly wrong: reproducible random data, bounded parallel work, and command execution with explicit outputs.
Callable persistence and function-schema metadata are planned for the Capsule and prompt surfaces. They are not part of the general-purpose utility API yet.
1. Deterministic data with StableRNG
Use StableRNG for tests, demos, and benchmarks that generate mock data. A seed and a step path produce the same data every time.
step(...) to derive independent child streams from one seed without mutating the parent generator:
n:
rnd,rnd_int,rnd_float, andrnd_normalfor scalar or batched numeric values.rnd_strfor deterministic IDs or compact tokens.choice,perm, andshuffledfor sampled or reordered data.hash_sampleandhash_splitfor stable samples that do not depend on input order.rnd_vecfor unit-length synthetic vector embeddings.abmandabm_pathfor simple Arithmetic Brownian Motion fixtures.
Benchmarks in HeavenBase use
StableRNG(seed=42) by default so generated rows, samples, and vectors can be reproduced.2. Bounded parallel work
Usepmap when work can run concurrently but the result order must match the input order.
pforeach for side-effect work where no result list is needed. Set max_workers=1 for an explicit serial path. max_workers=None reads heavenbase.parallel.max_workers; when that config is unset, HeavenBase uses a CPU-based bounded default capped by heavenbase.parallel.fallback_max_workers.
Use batch when you need per-item status, captured exceptions, elapsed time, or progress callbacks. It returns TaskResult records with index, item, ok, value, error, and elapsed_ms.
batch_stream yields TaskResult records as work finishes. Its default is ordered=False for completion order; pass ordered=True when consumers require input order. Ordered streaming still runs concurrently, but a later result can be held until earlier indexes are ready.
on_error="capture"keeps failed tasks asTaskResult(ok=False, error=...).on_error="raise"raises the first observed task error and stops submitting more work; already-running thread tasks may finish during executor cleanup.on_error="skip"omits failed task records from the output.
abatch and abatch_stream. Async helpers accept async callables directly; sync callables run through the event loop’s executor.
3. Command execution
Usecmd when a script needs to call a local command and inspect stdout, stderr, and the exit code.
include=["stdout", "stderr", "returncode"] returns a small dictionary. A single include="out" returns just that value.
check=True when a non-zero exit code should raise subprocess.CalledProcessError. Use browse(path) to open a local path with the platform default app, and clipboard(text) to copy text when the host provides a clipboard command.
Command helpers use Python’s
subprocess under the hood and do not invoke a shell for sequence commands unless shell=True is explicitly passed.
