Fix Pydantic JSON types in strict evidence serialization - #59
Open
ereinach wants to merge 1 commit into
Open
Conversation
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.
Rationale
Typed Pydantic inputs containing JSON-specific values such as
HttpUrlfail before RLM execution withStrict evidence serialization failed for run.started. This violates the established plain-data normalization and strict-evidence contract: supported Pydantic inputs must become JSON-serializable evidence.Reproduction: emit a
run.startedevidence event whose inputs contain a Pydantic model with anHttpUrl.to_plain_data()usedmodel_dump(mode="python"), which preserved theHttpUrl; the subsequentjson.dumps()raisedTypeError.The root cause is that Pydantic v2 normalization selected Python mode even though its result is used for JSON transport and evidence.
Summary
model_dump(mode="json").HttpUrlnested in run inputs.Test Plan
uv run pytest tests/test_small_kernel.py::test_strict_evidence_serializes_pydantic_json_types -quv run pytest tests/test_small_kernel.py -m "not sbx" -q(101 passed, 4 optional SBX tests deselected)uv run ruff check src/predict_rlm/serialization.py tests/test_small_kernel.py