{"record":{"id":"e4dd215ad30491f4","repo":"HKUDS/Vibe-Trading","slug":"path-name-alpha-meta-assignment-not-found","errorCode":null,"errorMessage":"{path.name}: __alpha_meta__ assignment not found","messagePattern":"(.+?): __alpha_meta__ assignment not found","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":170,"sourceCode":"    \"\"\"\n    size = path.stat().st_size\n    if size > _MAX_PY_BYTES:\n        raise RegistryError(f\"{path.name}: {size}B exceeds {_MAX_PY_BYTES}B cap\")\n\n    source = path.read_text(encoding=\"utf-8\")\n    tree = ast.parse(source, filename=str(path))\n\n    meta_node: ast.expr | None = None\n    for stmt in tree.body:\n        if not isinstance(stmt, ast.Assign):\n            continue\n        targets = [t for t in stmt.targets if isinstance(t, ast.Name)]\n        if any(t.id == \"__alpha_meta__\" for t in targets):\n            meta_node = stmt.value\n            break\n\n    if meta_node is None:\n        raise RegistryError(f\"{path.name}: __alpha_meta__ assignment not found\")\n\n    try:\n        raw = ast.literal_eval(meta_node)\n    except (ValueError, SyntaxError) as exc:\n        raise RegistryError(f\"{path.name}: __alpha_meta__ not a literal: {exc}\") from exc\n\n    if not isinstance(raw, dict):\n        raise RegistryError(f\"{path.name}: __alpha_meta__ must be dict, got {type(raw).__name__}\")\n\n    try:\n        return AlphaMeta(**raw)\n    except ValidationError as exc:\n        raise RegistryError(f\"{path.name}: AlphaMeta validation failed: {exc}\") from exc\n\n\ndef _safe_yaml_load(path: Path) -> Any:\n    \"\"\"yaml.safe_load with hard 5 MB size cap (defence in depth).\"\"\"\n    import yaml  # local import keeps registry import-light","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L152-L188","documentation":"load_alpha_meta_from_py scans top-level statements for an assignment to __alpha_meta__. If no such assignment exists in the module, RegistryError is raised because there is no metadata to extract (the module is never imported, only parsed).","triggerScenarios":"A zoo .py file without a module-level __alpha_meta__ = {...} statement, e.g. a helper module accidentally placed in the zoo dir, or a meta dict defined via function call or inside a class body.","commonSituations":"Placing utility modules in the zoo directory, building __alpha_meta__ dynamically (loops/conditionals) instead of a literal, or the statement being nested inside if TYPE_CHECKING or similar.","solutions":["Add a module-level __alpha_meta__ = {...} dict literal to the file","Move helper modules out of the zoo directory","Make the assignment unconditional and top-level"],"exampleFix":"# before\n# alpha.py: no meta\n# after\n__alpha_meta__ = {'alpha_id': 'my_alpha', ...}","handlingStrategy":"validation","validationCode":"import ast\ntree = ast.parse(path.read_text())\nassert any(isinstance(s, ast.Assign) and any(getattr(t, 'id', None) == '__alpha_meta__' for t in s.targets) for s in tree.body), 'missing __alpha_meta__'","typeGuard":null,"tryCatchPattern":"try:\n    load_alpha_meta_from_py(path)\nexcept RegistryError as e:\n    if 'assignment not found' in str(e): add_meta_literal(path)","preventionTips":["Use a template that always includes a top-level __alpha_meta__ literal","Keep helpers out of the zoo directory"],"tags":["registry","missing-metadata","ast-parsing"],"backgroundTag":"missing-required-metadata","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}