The Lesson Standard
Every lesson in this repository conforms to this specification. python3 -m tools.lesson_lint mechanically enforces directory layout, heading order, runnable examples, and solution test parity.
1. Directory Shape
Every executable lesson folder (NN-slug/) contains:
NN-slug/
├── README.md # Complete lesson text
├── examples/
│ ├── 01_<name>.py # Runnable demonstration script
│ └── 02_<name>.py # Demonstrates a common failure/trap (runs cleanly and prints the diagnostic)
├── exercises.py # Starter code with 5 exercise rungs (learner edits this)
├── test_exercises.py # Automated test suite (runs against exercises.py)
└── solution/
├── exercises.py # Complete, verified solution passing test_exercises.py
└── SOLUTION.md # Trade-off analysis, complexity proof & interview answers
2. Required Headings in README.md (In Exact Order)
Every lesson README.md must contain these exact nine H2 headings in this order:
| # | Required Heading | Purpose |
|---|---|---|
| 1 | ## At a glance | 3 capability bullets starting with action verbs, time estimate, and prerequisite links |
| 2 | ## Reading Companion | Exact book title, chapter, and focus points for deeper study |
| 3 | ## Why this matters in production | Real-world failure mode when engineers misunderstand this concept |
| 4 | ## Deep dive | Exhaustive, first-principles architectural explanation assuming ~10% prior recall, with detailed ASCII architecture diagrams, kernel/runtime mechanics, memory layout proofs, and step-by-step traces |
| 5 | ## Hands on | Step-by-step instructions to execute the scripts in examples/ and what to observe |
| 6 | ## AI Trap & Code Review | Realistic snippet of broken AI-generated code, why it fails in production, and how to review it |
| 7 | ## Exercises | Specification for the 5-rung ladder in exercises.py (Rung 1 through Rung 5) |
| 8 | ## Wrapping up | ### Can you explain? self-check interview prompts and forward links |
| 9 | ## Further Reading & References | Verified external links: official Python/Linux documentation, standard RFCs, PEPs, and engineering blog case studies (Netflix TechBlog, Cloudflare, Uber Eng, Meta) |
3. The 5-Rung Exercise Ladder
Every exercises.py is structured into 5 progressive rungs:
- Rung 1 — Warm-up: Verify foundational syntax and data flow.
- Rung 2 — Fix the AI Bug: A pre-written function with a subtle bug (memory leak, race condition, edge-case crash, $O(n^2)$ trap) that the learner must diagnose and repair.
- Rung 3 — Implement: Build a clean, well-typed component from docstring specifications.
- Rung 4 — Refactor / Compose: Combine components or refactor procedural code into a maintainable abstraction.
- Rung 5 — Production Edge-Case: Harden the implementation against malformed inputs, partial failures, resource exhaustion, or concurrency edge cases.
4. Verification Rule
python3 -m tools.lesson_lint verifies that:
- Every completed lesson has all required files and headings in order.
- Every script in
examples/*.pyexecutes with exit code0. - Swapping
solution/exercises.pyintotest_exercises.pypasses 100% of unit tests.