Unit 5 of 10 · about 5 hours · implement
A bounded change hypothesis with contract, integration and migration tests
A small change in an adapter can alter budgets, stored evidence and release decisions. Design the checks before implementation so that green tests cannot merely restate the new code.
You'll be able to
- State a falsifiable hypothesis for one LLM code change, including its expected benefit and losing regime.
- Implement contract, integration and migration fixtures with independent expected outcomes.
- Define old-data, old-reader and rollback compatibility before changing persistent state.
Covers
Read
In this order, only the parts listed
0 of 3 done
- LLM 0.36: usage and persistence seamsLLM (command-line tool and library), pinned
Commit 2465dfc:
_Shared.set_usage,Chat.execute;llm/models.pymethodsset_usageandlog_to_db;llm/migrations.pyfunctionmigrateand migrationm023_message_storeUse these as candidate seams for versioned usage provenance. A tool-budget change is also valid, but keep one hypothesis. At this commit,
log_to_dbwrites throughLogStoreto the message-store and turn tables; legacy response tables remain readable but are no longer written. Test both current writes and old-history reads if persistence changes. - Upgrade and endpoint test patternsLLM (command-line tool and library), pinned
test_migrate_blank,test_migrate_from_original_schema,test_migrations_with_legacy_alter_table;tests/test_openai_endpoint.pyhelper_add_chat_responseand the unlogged endpoint testUse the dependency pins from Reconstructing an unfamiliar AI application. The existing upgrade tests are examples, not downgrade protection for your change.
- Protection required for a real changeAI Engineering and Agentic Systems Checkpoint
Pass condition: contract, migration, adversarial, fault, canary/rollback and observability protection
Focus on
- Write the chain from changed code to changed observable behavior and product decision. Name a falsifier and a case where the added work may lose.
- The Programming unit on test design, oracles and doubles supplies test levels. Here, make independent fixtures for missing usage, malformed model output, partial streams and persisted old records.
- The Programming unit on dependency locks and run manifests supplies the environment contract. Keep the unmodified baseline and candidate under the same lock and task set.
- An additive column is not automatically rollback-safe. Test whether the old reader tolerates the new schema and values; decide what to do with in-flight work and new-only records.
Common mistakes · 3
- Computing expected values with the helper being tested. Use hand-specified fixture outcomes or a separate reference model.
- Filling unknown historical usage with zero in a migration. That converts missing evidence into a false measurement.
- Claiming rollback because a feature switch exists. The old binary, schema, records and policy must still work together.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.A stream produces text but no usage chunk. What should a usage-provenance fixture expect?Answer
An explicitly unknown usage state, not zero tokens or a fabricated complete bill. Partial output and accounting completeness are separate facts.
2.What should be tested beyond migration from an empty database?Answer
A populated old database, preserved values and identities, repeated migration, old-reader compatibility and reversal after candidate writes. Each has a distinct failure mode.
3.Your new assertion fails because the server is unavailable. Is that the desired baseline failure?Answer
No. Use a controlled fake or fixture so the test reaches the missing behavior. Infrastructure failure does not falsify the change contract.
You're done when
The baseline suite is green, the new behavior has a purposeful failing assertion, and every cell of the compatibility matrix has a fixture or a documented unsupported boundary.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 8 more in the section
- AI Engineering and Agentic Systems CheckpointRoadmap-Final · primary
Execute the complete checkpoint now: explain ownership, derive budgets and contracts, pass versioned evaluation, prove tenant isolation and replay safety, red-team the system, measure the joint frontier, then reconstruct and modify a production-like application.
- LLM (command-line tool and library), pinnedSimon Willison · required
At commit 2465dfc (version 0.36), trace the path from
llm.cli:clithrough the OpenAI-compatible adapter inllm/default_plugins/openai_models.pytollm/models.py,llm/logs.pyandllm/migrations.py. Runtests/test_openai_endpoint.py,test_migrate.py,test_pause_resume.pyandtest_tools.pyon CPU, pointllm openai endpointat your local server, then make one bounded, tested change such as versioned usage normalization or a tool-chain budget, with a migration and a secret-free replay fixture.
Also in this section
- Evidence-Grounded Retrieval SystemRoadmap-Final · required
Close the deferred clauses: Milestones B (instrumentation), D (injected failure attribution), E (paired optimization) and F (blinded query and delete campaign with a clean rebuild), the correctness requirements and the rubric. Index rollback and an honest negative result are this track's additions, not project headings.
- Durable Tool-Using WorkflowRoadmap-Final · required
Close Milestones B, D, E and F and the correctness requirements: crash-window replay, approval bound to the exact effect, fencing, ambiguous outcomes surfaced instead of claimed exactly-once, the matched deterministic, routed and agentic comparison, and clean reproduction. Finish the existing system rather than rebuilding it; delegation stays optional.
- AI Product Architecture Case StudiesEngineering Handbook · support
Pick two of case studies 8.30 to 8.33 (ChatGPT, Enterprise RAG, Coding Agent, Perplexity Search; slugs
chatgpt-conversational-ai,enterprise-rag,coding-agent,perplexity-ai-search), reconstruct each decomposition, identify its hidden assumptions and compare it with yours. Recompute the capacity tables before trusting a number: several are wrong (8.31's per-tenant index cost, 8.33's daily query volume). - AI and ML System Design HandbookEngineering Handbook · reference
Part 9 chapters 0 to 8 are overview-depth architecture notes for serving, RAG, vector search, agents, evaluation, LLMOps, cost and safety. Use them as a checklist for omissions in the integrated design; serving (00, 02) belongs to the Inference track.
- Managing Incidents and Incident ResponseGoogle SRE · support
Read SRE book Chapter 14 (elements of incident management, when to declare an incident) and Workbook Chapter 9 Incident Response with its case studies. Write the incident procedure for the integrated system and run it once against an injected fault.
- AI Agents in Depth - Integration ReviewBojie Li · support
Use 5.1.4 harness engineering, 7.9 and 7.10 and Chapter 9 (9.3.2 safety boundaries for continual evolution, Experiment 9-6 canary and rollback) as a final review. The offline
chapter9/harness-safety-gatetests (no API key) show a release gate that rejects a seeded bad candidate. - The Hitchhiker's Guide to Agentic AI - ProductionHaggai Roitman · support
Use v3 Chapter 27 (27.5 testing, 27.6 observability, 27.7 deployment) and 28.7 human-in-the-loop UI to audit the integrated system. Verify claims against official documentation.
- AI Engineering Handbook - AI Product EngineeringHandbook Academy · support
Use Part 11 to connect evaluation and system evidence to product decisions, feedback and iteration. Finish with a decision memo that distinguishes model capability, orchestration, retrieval, tool, evaluator and user-experience effects.