{"record":{"id":"9861c10c805200a3","repo":"HKUDS/Vibe-Trading","slug":"path-name-alpha-meta-not-a-literal-exc","errorCode":null,"errorMessage":"{path.name}: __alpha_meta__ not a literal: {exc}","messagePattern":"(.+?): __alpha_meta__ not a literal: (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":175,"sourceCode":"    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\n\n    size = path.stat().st_size\n    if size > _MAX_YAML_BYTES:\n        raise RegistryError(f\"{path.name}: {size}B exceeds {_MAX_YAML_BYTES}B YAML cap\")\n    text = path.read_text(encoding=\"utf-8\")","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L157-L193","documentation":"After finding __alpha_meta__, the loader calls ast.literal_eval on the assigned expression so metadata stays purely static. If the value is not a literal (e.g. a function call, name reference, or concatenation of variables), literal_eval raises and it is wrapped in RegistryError.","triggerScenarios":"Writing __alpha_meta__ = build_meta() or __alpha_meta__ = {**BASE, 'alpha_id': 'x'} — any non-literal expression.","commonSituations":"Trying to reuse shared meta constants across alphas, f-strings or .format() in meta values, or copy-pasting code-style dict construction into a data-only context.","solutions":["Inline the full dict literally in each module","Use only str/int/bool/list/dict literal values","Generate the literal with a script if sharing content across many alphas"],"exampleFix":"# before\n__alpha_meta__ = {**BASE_META, 'alpha_id': 'x'}\n# after\n__alpha_meta__ = {'alpha_id': 'x', 'theme': 'momentum', ...}","handlingStrategy":"validation","validationCode":"import ast\nnode = ...  # meta value node\nassert isinstance(node, (ast.Dict,)) or _is_literal(node), 'must be a literal'","typeGuard":null,"tryCatchPattern":"try:\n    load_alpha_meta_from_py(path)\nexcept RegistryError as e:\n    if 'not a literal' in str(e): inline_the_dict(path)","preventionTips":["Never build __alpha_meta__ from variables or function calls","Generate literal metadata with a script when sharing content"],"tags":["registry","ast-parsing","literal-eval"],"backgroundTag":"non-literal-metadata-expression","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}