16de3c3f1b
The #83202 heal path zip-stamped _row_id onto live-memory dicts purely by position whenever the durable and live lists had equal length, and the DB fallback mapped durable user-ordinals onto live indices with only a bounds check. Equal length is not proof of alignment: the durable copy is loaded with repair_alternation=True (merges user;user pairs, collapses consecutive assistants, drops orphan tool rows) while live memory is unrepaired and can carry optimistic/marker rows — the two can coincide in length while position-shifted. A misaligned stamp is sticky: it permanently attaches the wrong durable id to a live dict and re-aims every later rewind (E2E probes showed a wrong-content cut and a persisted alternation break). _mem_db_pair_agrees() now gates both paths: the heal loop stamps only when EVERY zip pair agrees on role, display-marker status, and (for addressable user turns) content; the ordinal fallback verifies the mapped live turn shows the durable target's content, else refuses via the existing fail-closed 4018. Regression tests derived from the review probes (content swap, role shift, repaired-merge ordinal shift); the misalignment guards fail on the pre-fix code. Surfaced during review of PR #83202 for #82959.