Task · MDE-0037

Strengthen the static gate against direct SDK call bypasses

Description

Wave 3 found that the current AST gate detects only a restricted asyncio.to_thread direct-call form. Direct SDK references in other production roots, run_in_executor, or local aliases can bypass the shared facade without failing the gate.

Acceptance Criteria

Definition of Done

Implementation Plan

Wave 2 L4 phase 1: inventory every production self.api controller-method reference, freeze the documented exemption list, add failing run_in_executor and alias bypass fixtures first, then strengthen the AST gate and run focused checks.

Implementation Notes

Wave 3 reproduced the coverage gap. This is parked because a whole-production AST policy and its exemption list are a high-blast enforcement change outside the fresh-audit low-blast fix rule.

Wave 2 red: the new run_in_executor and local-method-alias fixtures failed before the gate helpers existed; the first complete inventory then exposed ten stored-facade references, all classified into the three frozen documented exemptions. Integration review added a self.api root-alias regression after CodeRabbit found that remaining shape. Green: focused facade gates passed and just check completed with 2913 passed, 5 deselected, 91.22% coverage.

Final Summary

Parked after audit. Resume by inventorying every production SDK reference, freezing the explicit exemptions, then extend the AST gate with negative fixtures for aliases and run_in_executor.

Wave 2: strengthened the production AST gate to inventory direct SDK method references, admit only facade calls or three documented exemptions, and reject executor, method-alias, and self.api root-alias bypasses. Verified by focused regressions and just check.

View the source file on GitHub