{"record":{"id":"bd375a7fd9b57bef","repo":"HKUDS/Vibe-Trading","slug":"unknown-hypothesis-status-status-allowed-al","errorCode":null,"errorMessage":"unknown hypothesis status '{status}'. Allowed: {allowed}","messagePattern":"unknown hypothesis status '(.+?)'\\. Allowed: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/hypotheses/registry.py","lineNumber":78,"sourceCode":"    return set(_TOKEN_RE.findall(text.lower()))\n\n\ndef _new_hypothesis_id(title: str, created_at: str, existing_ids: set[str]) -> str:\n    seed = f\"{title.strip().lower()}|{created_at}\"\n    base = \"hyp_\" + hashlib.sha256(seed.encode(\"utf-8\")).hexdigest()[:12]\n    if base not in existing_ids:\n        return base\n    idx = 2\n    while f\"{base}_{idx}\" in existing_ids:\n        idx += 1\n    return f\"{base}_{idx}\"\n\n\ndef _validate_status(status: str) -> str:\n    normalized = str(status).strip().lower()\n    if normalized not in _STATUS_SET:\n        allowed = \", \".join(HYPOTHESIS_STATUSES)\n        raise ValueError(f\"unknown hypothesis status '{status}'. Allowed: {allowed}\")\n    return normalized\n\n\n@dataclass\nclass Hypothesis:\n    \"\"\"A research hypothesis tracked across analysis and backtests.\n\n    Attributes:\n        hypothesis_id: Stable registry identifier.\n        title: Short human-readable title.\n        thesis: Research thesis or rationale.\n        status: Lifecycle status.\n        universe: Target universe, market, or asset set.\n        signal_definition: Signal logic in plain text.\n        data_sources: Data sources expected or used.\n        skills: Relevant Vibe-Trading skills.\n        run_cards: Linked backtest/run-card artifacts.\n        invalidation_notes: Notes describing rejection or invalidation logic.","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/hypotheses/registry.py#L60-L96","documentation":"Raised by HypothesisRegistry when a hypothesis status string does not normalize (strip+lowercase) to one of the allowed HYPOTHESIS_STATUSES values. It is a whitelist validation on an enum-like field enforced at every entry point that touches status (from_dict, create, update, search).","triggerScenarios":"Calling registry.create(..., status='archieve'), update(id, status='dropped'), Hypothesis.from_dict({'status': 'Active '}) with a typo/case-mismatch, or search(status='bogus') where the string is not in the allowed status set after lowercasing.","commonSituations":"Hand-editing the hypotheses JSON storage with a wrong status, upgrading code where new statuses were added but stale data uses old names, or passing an unvalidated UI/API value straight into the registry.","solutions":["Check the allowed list in the error message and correct the status string (values come from HYPOTHESIS_STATUSES, e.g. active/validated/invalidated)","Normalize before calling: status.strip().lower()","If introducing a new status, add it to HYPOTHESIS_STATUSES in agent/src/hypotheses/registry.py and migrate stored records"],"exampleFix":"# before\nregistry.update(hid, status=\"Archieved\")\n# after\nregistry.update(hid, status=\"archived\")","handlingStrategy":"validation","validationCode":"from agent.src.hypotheses.registry import HYPOTHESIS_STATUSES\nstatus = (status or '').strip().lower()\nif status not in HYPOTHESIS_STATUSES:\n    raise ValueError(f'pick one of {sorted(HYPOTHESIS_STATUSES)}')","typeGuard":"def is_valid_status(s: str) -> bool:\n    return isinstance(s, str) and s.strip().lower() in HYPOTHESIS_STATUSES","tryCatchPattern":"try:\n    registry.update(hid, status=status)\nexcept ValueError as exc:\n    if 'unknown hypothesis status' in str(exc):\n        status = 'active'  # fallback; surface to user in UI code","preventionTips":["Normalize status strings with .strip().lower() before passing them in","Expose HYPOTHESIS_STATUSES as the source of truth in UI dropdowns","Validate API payloads against the status whitelist at the boundary"],"tags":["python","validation","enum","hypotheses"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}