fix(server): fix SQLite enum serialization causing failing test_schedule_lifecycle - #1
Conversation
…cycle failure
serde_json::to_string() wraps enum variants in quotes (e.g. '"pending"'),
but SQL queries use bare string comparisons (WHERE status = 'pending').
This mismatch caused save_schedule to succeed but list_pending_schedules
to return 0 rows.
Added enum_to_str/str_to_enum helpers that strip/re-add quotes for
SQLite string columns. Applied to unit-variant enum columns: format,
workflow_state, schedule status.
Platform has a data-carrying Other(String) variant that breaks the
generic helpers (serde_json serializes it as {"other":"x"}), so
Platform gets dedicated to_db_key/from_db_key methods that handle
all variants correctly including Other.
Also applied cargo fmt to fix pre-existing formatting violations in
main.rs and api.rs that would fail CI.
Co-authored-by: Archon <archon@purelymail.com>
🤖 Automated Review PanelGPT-5.5 (openai/gpt-5.5)Goal alignment: ✅ The fix correctly addresses the root cause — Correctness bug found: 🔴 Fix applied: Added dedicated Verdict after fix: ✅ Approve. All variants round-trip correctly. Gemini 3 Flash (google/gemini-3-flash-preview)Goal alignment: ✅ Primary fix is correct and the failing test now passes. Critical issue found: 🔴 Same Fix applied: Additional note: The Verdict after fix: ✅ Approve. All 8 tests pass, CI gates green. Both reviewers initially flagged the same critical bug ( |
Auto-Merge Gate — ApprovedConfidence: 0.93 Rationale: This PR fixes a clear, well-understood bug: Both reviewers (GPT-5.5, Gemini 3 Flash) independently caught a critical Checks observed: ✅ Formatting, ✅ Clippy, ✅ Tests (8 passed), ✅ Build, ✅ Secret Scanning — all green. Scope limits: This PR fixes the build only — COD-366 (content pipeline implementation) remains pending. — Auto-Merge Gate (squash) |
Summary
Fixes a failing test on
main:test_schedule_lifecycleexpected 1 pending schedule but got 0.Root cause:
SqliteStorageusedserde_json::to_string()to serialize enum values into SQLite string columns. serde_json wraps enum variants in quotes (e.g."pending"becomes"\\"pending\\""in the DB), but SQL queries use bare string comparisons (WHERE status = 'pending'). Writes succeeded but filtered reads returned nothing.Changes
enum_to_str()/str_to_enum()helpers — strip/re-add JSON quotes for SQLite string columns. Applied to unit-variant enum columns:format,workflow_state,schedule status.Platform::to_db_key()/from_db_key()— Platform has a data-carryingOther(String)variant that breaks the generic helpers (serde_json serializes it as{"other":"x"}). Platform gets dedicated DB methods with an"other:<name>"format that round-trips correctly for all variants.cargo fmt— applied to fix pre-existing formatting violations inmain.rsandapi.rsthat would fail CI'scargo fmt --check.Verification
New tests added:
test_enum_round_trip— verifies unit-variant enum serializationtest_platform_db_key_round_trip— verifies all Platform variants round-trip, includingOther("mastodon")andOther("custom:with:colons")Review Panel
Both reviewers (GPT-5.5, Gemini 3 Flash) initially caught a critical bug:
Platform::Other(String)was corrupted by the genericenum_to_strhelper. Fixed by adding dedicatedPlatform::to_db_key/from_db_keymethods.🤖 Generated by Project Runner