How Phase Prerequisites Are Tracked and Enforced in the AI Engineering Curriculum
The curriculum tracks prerequisites through declarative front-matter metadata in each lesson's documentation and enforces them automatically via a Python audit script that runs during CI/CD, blocking merges that violate the learning path sequence.
The rohitg00/ai-engineering-from-scratch repository implements a structured learning path where advanced lessons cannot be attempted until foundational phases are completed. This system relies on a two-layer validation approach that combines human-readable documentation with programmatic enforcement to ensure curriculum integrity.
Declarative Tracking in Lesson Front-Matter
Each lesson stores its dependencies in a Prerequisites: field within the markdown documentation of its docs/en.md file. This metadata explicitly lists the required phases and specific lesson ranges that must be completed first, creating a machine-readable contract that defines the curriculum's directed acyclic graph structure.
For example, the End-to-End Safety Gate lesson located at phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md declares its dependencies as follows:
---
# End‑to‑End Safety Gate
> Verify that an entire pipeline respects safety constraints.
**Type:** Build
**Languages:** Python
**Prerequisites:** Phase 18 safety lessons, Phase 19 Track A lessons 25‑29
---
This declarative approach makes dependencies transparent to both learners and automated tooling, establishing clear completion requirements before a student can engage with advanced capstone material.
Automated Enforcement via CI Audit Scripts
While the front-matter tracks requirements, the scripts/audit_lessons.py script enforces them by validating the entire curriculum during continuous integration. This prevents repository updates that would introduce logical gaps in the learning progression or allow lessons to reference non-existent prerequisites.
Parsing Prerequisite Declarations
The audit script extracts prerequisite strings using regular expressions that target the Prerequisites: field in lesson documentation. The extract_prereqs() function locates these declarations within each docs/en.md file throughout the repository:
def extract_prereqs(doc_path):
text = pathlib.Path(doc_path).read_text()
m = re.search(r'^\*\*Prerequisites:\*\*\s+(.*)$', text, re.MULTILINE)
return m.group(1).strip() if m else None
Build Failure on Violation
The verify_all() function traverses the phases directory structure, resolving prerequisite references against the actual repository state. If any lesson references a missing prerequisite or violates the sequential ordering defined in AGENTS.md, the script exits with a non-zero status:
def verify_all():
missing = []
for doc in pathlib.Path('phases').rglob('docs/en.md'):
prereq = extract_prereqs(doc)
if prereq and not prereq_satisfied(prereq):
missing.append((doc, prereq))
if missing:
for doc, prereq in missing:
print(f'❌ {doc} missing prerequisite: {prereq}')
sys.exit(1)
print('✅ All prerequisites satisfied')
This execution runs on every push event and pull request, making a failing prerequisite check a merge-blocking error that maintains curriculum coherence according to the policies defined in AGENTS.md.
Visual Curriculum Mapping in Documentation
The repository's README.md complements the automated enforcement with human-readable phase tables that illustrate the prerequisite relationships. Learners can consult these tables to visualize the required completion order before encountering the CI validation, reducing friction for legitimate progression paths while maintaining strict technical controls.
Summary
- Front-matter metadata in
docs/en.mdfiles declaratively tracks phase prerequisites using explicit Prerequisites: text fields. - Regular expression parsing in
scripts/audit_lessons.pyextracts these requirements for programmatic validation using theextract_prereqs()function. - CI enforcement via the
verify_all()function blocks merges that violate prerequisite ordering, ensuring the curriculum graph remains acyclic and traversable. - The AGENTS.md policy document defines the lesson contract standards that both human authors and automated auditors must follow.
Frequently Asked Questions
Where are prerequisite dependencies declared in the repository?
Prerequisites are declared in the front-matter section of each lesson's docs/en.md file using a Prerequisites: field that lists required phases and lesson ranges, such as "Phase 18 safety lessons, Phase 19 Track A lessons 25-29".
What happens if a lesson references a prerequisite that does not exist?
The scripts/audit_lessons.py CI script detects the unresolved reference during the build process, prints a failure message identifying the missing dependency, and exits with status code 1, preventing the pull request from merging.
Can learners bypass the prerequisite checks when studying locally?
Local study is not restricted by the CI validation; the enforcement only blocks repository changes. However, the README.md phase tables and lesson front-matter provide clear guidance on the intended learning path sequence.
Which file defines the policy for lesson prerequisites?
The AGENTS.md file contains the "Lesson contract" section that establishes the policy for how prerequisites must be formatted and validated across the curriculum.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →