zoomy_core.symbolic.auto_eval_guard module#
Context manager that bans sympy auto-evaluation inside its block.
Used in tests + the slim walkthrough to verify the primitive layer
never silently fires a math rule. When the guard is active, calling
.doit() on any sympy Basic object raises
AutoEvalForbidden with a stack trace pointing at the offender.
Usage:
from zoomy_core.symbolic.auto_eval_guard import AutoEvalGuard
with AutoEvalGuard():
# Any .doit() call here will raise.
...
The guard also bans sp.simplify, sp.cancel, sp.together,
sp.factor, sp.collect, sp.diff, sp.integrate — the
non-structural calls the redesign forbids inside the symbolic
package. sp.expand is permitted (Canonicalise uses it) — restrict
its kwargs at call sites instead.
- exception zoomy_core.symbolic.auto_eval_guard.AutoEvalForbidden#
Bases:
RuntimeErrorRaised when a forbidden sympy auto-evaluation call fires.
The redesign’s invariant is: every math rule is invoked by an explicit primitive. Sympy’s auto-evaluation calls (
.doit(),sp.simplify, etc.) bypass that surface and cause subtle order-of-operations bugs. The guard makes any such call a hard failure.
- class zoomy_core.symbolic.auto_eval_guard.AutoEvalGuard#
Bases:
objectMonkeypatch
sympy.Basic.doitand the eval-style sympy helpers to raise. Restored on exit.