fix: grade_level fallback should be 0 (Kindergarten) not 1, handle empty metadata dict - #87
Open
clates wants to merge 4 commits into
Open
fix: grade_level fallback should be 0 (Kindergarten) not 1, handle empty metadata dict#87clates wants to merge 4 commits into
clates wants to merge 4 commits into
Conversation
… fp precision, cascade deletes - Add null guards for progress_blob/plan_rules_blob in logic.py, main.py, agent.py (issues #77, #78, #79) — new students with NULL blobs no longer crash - Fix generate_weekly_plan to use datetime.now(UTC) instead of local time (issue #80) — prevents off-by-one day in week_of on non-UTC servers - Fix _get_grade_level to fall back to student metadata instead of literal 0 (issue #81) — first-time plan generation no longer fails with no-standards error - Round activity_bias in process/reverse_quantity_feedback to 6 decimal places (issue #82) — prevents floating-point drift across feedback cycles - Replace delete-then-insert with INSERT OR REPLACE in save_weekly_packet (issue #83) — eliminates duplicate-packet race condition under concurrent saves - Cascade-delete weekly_packets before deleting student profile in delete_student (issue #84) — packet_feedback no longer left as orphans after student deletion Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds two rules to prevent direct commits to main: - All changes must go through a PR, no exceptions - Automated analysis/fix workflows must create a branch before making changes, then open a PR rather than committing directly Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…l test - delete_student() now catches OperationalError when weekly_packets table doesn't exist (minimal test DBs only have student_profiles) - Update test_get_grade_level_defaults_to_zero to expect 1 (the new safe default) and add a second test covering the metadata_fallback path Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…pty metadata dict
- Change `if metadata_fallback:` to `if metadata_fallback is not None:` so an
empty metadata dict `{}` (falsy in Python) no longer skips the fallback branch
- Change all default-fallback values from 1 to 0: Kindergarten (grade 0) is the
safest default for a student with no packet history
- Update test name and assertion for the no-packets case (1 -> 0)
- Add two new tests: empty-dict fallback and explicit Kindergarten metadata
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1caused new Kindergarten students (who have no weekly packets yet) to receive grade-1 lesson plans.{}was falsy, soif metadata_fallback:skipped the fallback branch entirely for students whosemetadata_blobdeserialized to{}. This meant_get_grade_levelfell straight through toreturn 1even when a fallback dict was provided.Changes
src/trio_generator.py:if metadata_fallback:→if metadata_fallback is not None:to correctly handle the empty-dict casesrc/trio_generator.py: all default/fallback values changed from1to0(Kindergarten is the safe default)src/trio_generator.py: docstring updated to reflect new fallback valuetests/test_trio_generator.py: renamedtest_get_grade_level_defaults_to_one_when_no_packets→test_get_grade_level_defaults_to_zero_when_no_packetsand updated assertion to== 0tests/test_trio_generator.py: addedtest_get_grade_level_empty_metadata_dict_falls_back_to_zero— exercises the empty-dict falsy bugtests/test_trio_generator.py: addedtest_get_grade_level_kindergarten_metadata_returns_zero— ensuresgrade_level=0in metadata is preserved and not overriddenTest plan
tests/test_trio_generator.pypasses on Python 3.11 CI (local Python 3.10 cannot importdatetime.UTCfromagent.py, a pre-existing environment limitation)test_get_grade_level_defaults_to_zero_when_no_packetsasserts== 0test_get_grade_level_empty_metadata_dict_falls_back_to_zeropasses (new test)test_get_grade_level_kindergarten_metadata_returns_zeropasses (new test)🤖 Generated with Claude Code