{"record":{"id":"8e372fefbed23c69","repo":"HKUDS/Vibe-Trading","slug":"run-bench-strict-requires-random-control-to-be-pas","errorCode":null,"errorMessage":"run_bench_strict requires random_control to be passed explicitly (True or False). This rail is borrowed from Soli22de/Bili_Stock's foundation engine after a 9-month audit where every accidental random_control=None call inflated alpha by 3-8 percentage points.","messagePattern":"run_bench_strict requires random_control to be passed explicitly \\(True or False\\)\\. This rail is borrowed from Soli22de/Bili_Stock's foundation engine after a 9-month audit where every accidental random_control=None call inflated alpha by 3-8 percentage points\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/bench_runner_strict.py","lineNumber":372,"sourceCode":"        registry: Optional pre-built registry for tests.\n\n    Returns:\n        Dict containing all the keys ``run_bench()`` returns, plus:\n\n        - ``random_control`` (bool)\n        - ``n_random_seeds`` (int)\n        - ``oos_split`` (str | None)\n        - ``alpha_t_threshold`` (float)\n        - ``confirmed_alive`` / ``train_only`` / ``reversed_strict`` /\n          ``noise`` count keys\n        - Each row carries ``alpha_t_full``, ``alpha_t_train`` (when OOS),\n          ``alpha_t_test`` (when OOS), ``random_ic_mean``.\n\n    Raises:\n        TypeError: If ``random_control`` is omitted (keyword-only, no default).\n    \"\"\"\n    if random_control is None:  # pragma: no cover — guarded by signature\n        raise TypeError(\n            \"run_bench_strict requires random_control to be passed explicitly \"\n            \"(True or False). This rail is borrowed from \"\n            \"Soli22de/Bili_Stock's foundation engine after a 9-month audit \"\n            \"where every accidental random_control=None call inflated alpha \"\n            \"by 3-8 percentage points.\"\n        )\n\n    start = time.monotonic()\n    thresholds = thresholds or StrictThresholds()\n    # Clamp n_random_seeds once and store the actual value used so the\n    # wire response doesn't lie about the seed count when callers pass 0\n    # (e.g. from a JSON-config import).\n    effective_seeds = max(1, int(n_random_seeds))\n\n    # Initialise the full schema up-front so even early-error returns\n    # carry zeroed counters and empty lists — downstream consumers can\n    # depend on the keys always being present.\n    entry: dict[str, Any] = {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/bench_runner_strict.py#L354-L390","documentation":"run_bench_strict takes random_control as a keyword-only parameter with no default; passing None (or omitting it) raises TypeError. This rail exists because accidental random_control=None calls silently inflated alpha by 3-8 percentage points in a past audit, so the API forces an explicit True/False choice.","triggerScenarios":"Calling run_bench_strict(...) without random_control=True/False, or explicitly passing random_control=None, or forwarding a None default from a wrapper function.","commonSituations":"Wrapping run_bench_strict in a convenience function whose own default is None and forwarding it; older call sites written before the parameter became mandatory; test helpers that omit kwargs.","solutions":["Pass random_control=True or random_control=False explicitly as a keyword","In wrappers, require the parameter yourself instead of defaulting to None","Read the docstring: the strictness is intentional (prevents silent benchmark inflation)"],"exampleFix":"# before\nrun_bench_strict(registry, **kwargs)  # random_control missing\n# after\nrun_bench_strict(registry, random_control=True, **kwargs)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def has_explicit_random_control(kwargs: dict) -> bool:\n    v = kwargs.get('random_control')\n    return v is True or v is False","tryCatchPattern":"try:\n    run_bench_strict(reg, random_control=True, **kw)\nexcept TypeError as e:\n    if 'random_control' in str(e): raise ValueError('caller must set random_control') from e\n    raise","preventionTips":["Never forward random_control=None from wrappers — make your wrapper require it too","Add a lint/test that every run_bench_strict call site passes random_control explicitly"],"tags":["strict-api","benchmark","keyword-only","explicit-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}