Generates a complete maths learning module anchored in physics and/or finance: lecture, tiered exercises, misconception-driven trick questions, Python implementation scaffold with pytest tests, and a compact solution manual. Use when user says "teach me [math topic]", "make a lecture + exercises", "give me practice problems", "ramp up difficulty", "give trick questions", "add coding scaffold + tests", or "make a solution manual", especially when they want physics/finance intuition alongside formal maths.
If topic is ambiguous, choose the most standard interpretation and note it in README.md as "Assumption: …".
Output these files using === /module/<path> === headers. No code fences around markdown; use code fences for Python files.
/module/README.md
/module/lecture.md
/module/exercises.md
/module/trick_questions.md
/module/solution_manual.md
/module/rubric.md
/module/implementation/scaffold.py
/module/implementation/tests/test_scaffold.py
Every core idea must be anchored in the selected track(s) using concrete applications, not analogies.
Physics anchors — use at least one of: dimensional analysis, limiting cases, conservation/invariants, geometric meaning, differential equation interpretation.
Finance anchors — use at least one of: no-arbitrage/replication, convexity/monotonicity, conditioning/filtration, tails/stress, optimisation constraints.
Structure: motivation → core definitions → two key properties/theorems (with proof sketches appropriate to level) → worked example(s) per track → failure modes + invariant checks.
Keep concise (~900 words max).
Three tiers (A/B/C) with monotonically increasing difficulty. Each exercise states expected answer format.
Exercise types to mix across tiers: compute, prove/justify, translate (physics↔finance), diagnose (spot errors), approximate (limits/asymptotics), numerics (implement + compare), interpret (domain meaning).
Each includes the question, "Most people do wrong:" (1 sentence), and "Minimal correction:" (1 sentence). No duplicates; each maps to a distinct failure mode.
scaffold.py: core functions/classes with TODO markers + runnable __main__ demo.
test_scaffold.py: tests that fail before TODOs are completed. Include identity/invariant tests, numerical sanity checks, limit-case tests, and one random property-style test (stdlib random + numpy only, no external property libs). Use pytest.
Compact (~1200 words max). Include compressed derivations, reusable templates ("if you see X, do Y"), a verification checklist, and a "when to use what" decision guide.
Mastery gates per tier: A = mechanical competence, B = conceptual transfer, C = synthesis/novel problems.
Adjust along 1–2 axes only and state them in README.md:
Regenerate only affected files.
Topic too broad: pick a standard slice, state it in assumptions, list "next slices."
Prerequisites too advanced for level: add a prereq mini-bridge (≤200 words) at the start of lecture.md.
Tests too confusing: ensure tests fail only at TODO-related points with clear messages indicating what to implement next.
Validate a generated module bundle: python scripts/validate_bundle.py