Skip to content

feat: replay checksum + input canonicalization (soundness guard) - #36

Open
tishachawla-jg wants to merge 1 commit into
mainfrom
feat/replay-checksum
Open

feat: replay checksum + input canonicalization (soundness guard)#36
tishachawla-jg wants to merge 1 commit into
mainfrom
feat/replay-checksum

Conversation

@tishachawla-jg

Copy link
Copy Markdown
Contributor

Implements item 4 of the paper plan and backs the paper's replay-soundness claim: replay either reproduces the recorded subsequence of stubbed crossings exactly or raises.

  • chronicle/envelope/canonical.py: canonicalize/digest drop volatile fields (timestamps, ids) and key-sort before hashing, so a faithful replay does not false-fire.
  • chronicle/replay/checksum.py: order-sensitive trace_checksum, ChecksumMismatch, ReplayVerifier.
  • Two guards: fixture integrity on load (a recorded input edited after commit is detected; a volatile edit is not) and stubbed-crossing order on replay (insertion/removal/reorder raises).
  • verify_checksum session flag (default on); exports ChecksumMismatch.

tests/test_checksum.py (9 cases); full suite 124 green; ruff 0.15.22 clean; no em/en dashes. Matches the green Replay-soundness paragraph in chronicle.tex.

Backs the paper's replay-soundness claim: replay either reproduces the recorded
subsequence of stubbed crossings exactly or raises, so a control-flow change
cannot silently pair a stub with an envelope recorded for a different crossing.

- chronicle/envelope/canonical.py: canonicalize()/digest() drop volatile fields
  (timestamps, generated ids) and key-sort before hashing, so a faithful replay
  does not false-fire on an incidental field.
- chronicle/replay/checksum.py: crossing_key + order-sensitive trace_checksum,
  ChecksumMismatch, and ReplayVerifier (build_verifier) that checks stubbed
  crossings against the recorded stubbed subsequence in request order.
- execution_graph: stores the trace checksum in graph.json at save and recomputes
  it on load, so a committed fixture edited after recording is detected (a volatile
  edit is not, by canonicalization).
- session: verify_checksum flag (default on); _fixture_for verifies each stubbed
  crossing via the verifier, catching insertion, removal, and reordering.
- Export ChecksumMismatch.

Tests (tests/test_checksum.py): canonicalization ignores volatile changes and not
real ones; a non-volatile fixture edit raises on load while a volatile edit does
not; the verifier flags out-of-order and extra stubs; a clean full replay passes.
Full suite green; ruff 0.15.22 clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Tisha Chawla <tisha.chawla2020@vitalum.ac.in>
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