Generated study material is JSON on disk, and packages/studyloop/src/studyloop/content/schemas.py
is the only place that says what that JSON may contain. Change the schema first, make the schema
tests fail and pass, then follow the change through the generators and the write path with
just test-content.
- Three deck models --
FlashcardDeck,QuizDeck,PracticeDeck-- and their items are Pydantic models withmodel_config = {"extra": "forbid"}. An unknown key is a validation error, not a silently dropped field; that is what lets a generator trust what it wrote. - Field names are camelCase on disk and snake_case in Python. The alias bridges them:
is_correct: bool = Field(alias="isCorrect"),answer_options,successCriteria,setupCommand. Models that take aliased input also set"populate_by_name": True, so tests can build them with either spelling.write_json()always dumpsby_alias=True. - Each deck writes itself:
FlashcardDeck.write_json(directory, slug)lands at<slug>-flashcards.json, quizzes at<slug>-quiz.json, practice at<slug>-practice.json. The suffixes are the globs the read side (review_loader.py) looks for; do not change one without the other. flashcard_deck_json_schema()and friends hand the same model to a provider as a JSON schema, so a schema change changes what the model is asked to produce.
Add a field with an alias and a default; extra: forbid means a field you add is accepted
nowhere until every generator and fixture that builds the model knows it. Prove the change in
packages/studyloop/tests/test_content_schemas.py (rejection tests sit beside the parse tests):
uv run --group dev pytest packages/studyloop/tests/test_content_schemas.py -qcontent/generators/__init__.py-- theCardGeneratorProtocol andget_generator(config), which selects a backend bysettings.card_generator.backend. Every backend raisesCardGenerationError; callers show its message and never see an HTTP or Pydantic exception.content/generators/ollama.py,bedrock.py,openai_compat.py,anthropic_compat.py-- the backends. The two_compatadapters are generic; a new OpenAI- or Anthropic-compatible provider is aProviderProfilerow incontent/generators/provider_profiles.py, not a new class.content/generators/prompts.py-- the prompt templates;runner.py-- the thread pool that generates several sources at once.content/job.py-- one web generation job: builds tasks, runs the generator, writes decks under the right root, emits progress;content/active_gen.py-- the single-flight guard behind the web panel's HTTP 409.- The deterministic generator used by the tests is not packaged: it is
packages/studyloop/tests/_content_generator.py(DeterministicTestGenerator), injected at the Protocol seam. No default-tier test reaches a network.
The content-generation spec (openspec/specs/content-generation/spec.md) fixes the roots:
- CLI generation writes under
content.base_path/<course>/{flashcards,quizzes,practice}/(content/storage.py::get_course_dir). - Web generation with a
publisherwrites undercontent.base_path/<publisher>/<course>/...(content/job.py::_course_output_dir); with no publisher it falls back to the CLI layout. - The review surface reads through
settings.resolve_study_dirs()--review.directorieswhen set, elsecontent.base_path-- andreview_loader.discover_directories()walks both layouts.
So a change to a write path must be checked against the read path in the same pull request, and
tests write only under tmp_path: the autouse fixtures in packages/studyloop/tests/conftest.py
fail any test that touches the real config directory or vault.
just test-content runs the nine content suites (CLI, generators, runner, stub, job runner, scope,
storage, storage merge, workflow) in the default tier:
just test-contentIt does not include test_content_schemas.py; run that one explicitly, as above. Tests marked
live_provider call a real model and are deselected by default (F7) -- never make a default-tier
test depend on one. If your change touches the Generate panel's routes or JavaScript, follow
A Web Route and UI as well.