test(positioning): harden cap-coverage audit to require FORWARDING, not mere presence

Final whole-branch review Minor: the audit checked the token appeared anywhere in
the function body, so a partial regression (param kept in signature but dropped
from the inner seam call) passed silently. Now require  as a
forwarded kwarg. Mutation-verified: dropping the forwarding from run_bybit_testnet's
call (while keeping the import) now FAILS the audit, where the substring check passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 20:32:31 +00:00
parent 3a26b87f15
commit 9080dffed5

View File

@@ -31,10 +31,15 @@ def _func_body(text: str, fn: str) -> str:
def test_every_live_positioning_callsite_threads_the_cap():
# Require the param to appear as a FORWARDED keyword arg (`positioning_coin_gross_cap=` or the seam's
# `coin_gross_cap=` in bybit_testnet_run's direct-seam calls), not merely SOMEWHERE in the body. A bare
# substring check would pass a partial regression where the param survives in the signature/docstring but
# is dropped from the inner seam call — exactly the silent break this guard exists to catch.
_forwarded = re.compile(r"(?:positioning_)?coin_gross_cap\s*=")
missing = []
for rel, fn in _LIVE_CALLSITES:
body = _func_body((_ROOT / rel).read_text(), fn)
if "positioning_coin_gross_cap" not in body:
if not _forwarded.search(body):
missing.append(f"{rel}::{fn}")
assert not missing, ("LIVE positioning path(s) missing positioning_coin_gross_cap (opt-in, fail-safe): "
+ ", ".join(missing))
assert not missing, ("LIVE positioning path(s) not FORWARDING positioning_coin_gross_cap (opt-in, "
"fail-safe): " + ", ".join(missing))