Skip to content

fix(flow): keep record identity across the JSON baseline - #1482

Merged
abrichr merged 1 commit into
mainfrom
fix/stable-id-survives-json-baseline
Oct 21, 2026
Merged

abrichr merged 1 commit into
mainfrom
fix/stable-id-survives-json-baseline

Conversation

@abrichr

@abrichr abrichr commented Oct 21, 2026

Copy link
Copy Markdown
Member

Problem

stable_id (runtime/effects/effect.py) identifies a record by its raw id, or by str() of each field. verify_run stores the pre-action baseline with model_dump(mode="json"). Postgres, MSSQL and Oracle drivers return UUID, Decimal and datetime values, and those come back from JSON as strings, so they no longer equal the live row's values.

As a result, every row that already existed counts as new, and a count_new_only record check confirms a write that never happened. This is a silent fail-open. The realism audit found it (#1467, rank 6). The tests use SQLite ints and strings, so they never hit it.

Fix

stable_id now compares values in their JSON form, using pydantic_core.to_jsonable_python, the same conversion the baseline goes through. A value with no JSON form, such as non-UTF-8 bytes, is left unchanged.

Tests

  • New tests/test_stable_id_json_baseline.py: a Hypothesis round trip over UUID, Decimal, datetime (aware and naive), date, int and text values, plus an unchanged UUID table that must show no new rows. These fail on main and pass here.
  • Effect, verify_run, record-check, list-source and frame test files: 299 passed, 1 skipped.

🤖 Generated with Claude Code

stable_id compared a record's raw id, or str() of each field. verify_run
stores the pre-action baseline with model_dump(mode="json"), so a UUID,
Decimal or datetime from a Postgres, MSSQL or Oracle driver came back as a
string and no longer matched the live row. Every pre-existing row then
counted as new, and count_new_only confirmed a write that never happened.

stable_id now compares values in their JSON form (pydantic_core's
to_jsonable_python, the same conversion the baseline uses), and leaves a
value with no JSON form unchanged.

Adds a Hypothesis round-trip over UUID, Decimal, datetime, date, int and
text values. It fails on main and passes here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@abrichr
abrichr enabled auto-merge October 21, 2026 03:47
@abrichr
abrichr added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 718cd61 Oct 21, 2026
61 of 63 checks passed
@abrichr
abrichr deleted the fix/stable-id-survives-json-baseline branch October 21, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant