Commit 4bee59e
fix(quiz): close 2 remaining review issues from PR #71
1. All-drift cascade test (TestQuizAgentFallback)
New `test_falls_back_to_legacy_when_all_questions_drift` pins the
path the 3 contract tests don't cover directly: agent returns a
schema-valid Quiz where every question's correct_answer doesn't
appear in its options → _quiz_via_agent's wire-format filter drops
all of them → raises RuntimeError → bare-Exception catch in
generate_quiz routes to _legacy_generate_quiz. Asserts the legacy
gemini path actually runs and the legacy fallback question is
what reaches the client.
2. Drift warning no longer leaks student content to local logs
_agent_question_to_wire's drift warning was using %r to dump the
raw correct_answer, options, and concept text. Logfire's egress
scrubber (PR #67) handled remote ingestion, but Railway's local
stdout still saw the unredacted strings. Now we log:
n_options=4, canonical_len=18, fp=<sha256[:12]>
The fingerprint is stable across recurrences of the same drift,
so we still get correlation; the actual content stays out of
stdout. Hashlib import hoisted to module scope.
Pre-existing transient: tests/test_ocr_pipeline.py::test_gemini_parse
that flickered red in the previous review run cleared on re-run
(skipped in isolation, passing in full suite). Confirmed transient
live-Gemini hiccup, not caused by this branch.
Tests
- tests/test_quiz_routes.py: 23/23 (the previous "24" was a miscount;
net +1 from the new cascade test).
- Full backend suite: 443 passed, 3 pre-existing live-Supabase
failures unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0bcc664 commit 4bee59e
2 files changed
Lines changed: 67 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
| 3 | + | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
82 | 94 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
86 | 98 | | |
87 | 99 | | |
88 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
495 | 545 | | |
496 | 546 | | |
497 | 547 | | |
| |||
0 commit comments