HKUDS/Vibe-Trading · error · RegistryError
{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap
Error message
{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap What it means
load_alpha_meta_from_py statically AST-parses zoo modules and refuses any .py file larger than _MAX_PY_BYTES as a defence against bloated or malicious modules. Exceeding the cap raises RegistryError before reading/parsing.
Source
Thrown at agent/src/factors/registry.py:155
class _LoadError:
alpha_id: str
reason: str
def _validate_id_token(token: str, kind: str) -> None:
if not _ID_RE.fullmatch(token):
raise RegistryError(f"invalid {kind} {token!r}: must match {_ID_RE.pattern}")
def load_alpha_meta_from_py(path: Path) -> AlphaMeta:
"""AST-extract the ``__alpha_meta__`` dict literal from a zoo module.
No import is performed — purely static parsing. Raises ``RegistryError`` on
malformed metadata.
"""
size = path.stat().st_size
if size > _MAX_PY_BYTES:
raise RegistryError(f"{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap")
source = path.read_text(encoding="utf-8")
tree = ast.parse(source, filename=str(path))
meta_node: ast.expr | None = None
for stmt in tree.body:
if not isinstance(stmt, ast.Assign):
continue
targets = [t for t in stmt.targets if isinstance(t, ast.Name)]
if any(t.id == "__alpha_meta__" for t in targets):
meta_node = stmt.value
break
if meta_node is None:
raise RegistryError(f"{path.name}: __alpha_meta__ assignment not found")
try:
raw = ast.literal_eval(meta_node)View on GitHub (pinned to 80ffdda44c)
Solutions
- Move large data out of the module into a data file the alpha loads separately
- Split the module or remove embedded blobs/dead code
- If genuinely needed and you accept the risk, raise _MAX_PY_BYTES in your fork
Example fix
# before # alpha_big.py contains a 2MB inline price table # after # alpha loads table from data/prices.parq at runtime; module stays small
Defensive patterns
Strategy: validation
Validate before calling
from factors.registry import _MAX_PY_BYTES
assert path.stat().st_size <= _MAX_PY_BYTES, f'{path} too large' Try / catch
try:
load_alpha_meta_from_py(path)
except RegistryError as e:
if 'exceeds' in str(e): log.error('move embedded data out of module') Prevention
- Keep data blobs out of zoo modules; load from data files at runtime
- Monitor zoo file sizes in CI
When it happens
Trigger: Registering a zoo module whose file size exceeds _MAX_PY_BYTES (oversized generated alphas, embedded data blobs, or accidentally concatenated files).
Common situations: Embedding large lookup tables or payloads inside an alpha module, code generation tools appending duplicate code until the file grows past the cap, or committing generated artifacts into the zoo directory.
Related errors
- {path.name}: {size}B exceeds {_MAX_YAML_BYTES}B YAML cap
- unknown panel column: {column}
- invalid {kind} {token!r}: must match {_ID_RE.pattern}
- {path.name}: __alpha_meta__ assignment not found
- {path.name}: __alpha_meta__ not a literal: {exc}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/07b90b01c3bc8a4a.
Report an issue: GitHub.