Skip to content

Replay-Safe SLA Ledger: Deterministic Idempotency + Saturating Monetary Math#332

Merged
mxllv merged 1 commit into
OpSoll:mainfrom
nottherealalanturing:codex/replay-integrity-sat-arith
May 31, 2026
Merged

Replay-Safe SLA Ledger: Deterministic Idempotency + Saturating Monetary Math#332
mxllv merged 1 commit into
OpSoll:mainfrom
nottherealalanturing:codex/replay-integrity-sat-arith

Conversation

@nottherealalanturing
Copy link
Copy Markdown
Contributor

@nottherealalanturing nottherealalanturing commented May 30, 2026

Summary

This PR applies a minimal hardening patch to make SLA execution replay-safe and payment arithmetic resilient under extreme inputs, while preserving existing behavior for normal flows.

What changed

  • Added idempotent replay guard in calculate_sla:
    • repeated submissions for the same outage_id now return the existing latest result
    • no duplicate history append, no duplicate stats mutation, no duplicate event emission
  • Hardened arithmetic in result + stats paths:
    • replaced risky multiplication/addition with saturating operations
    • normalized reward division using deterministic Euclidean division
  • Fixed audit/view calculation call path argument mismatch to keep deterministic parity and build correctness

Why this closes the assigned issues

  • Closes replay/idempotency invariants and repeated-submission history behavior
  • Closes sequence/replay safety expectations by making repeated backend submits no-op deterministic
  • Closes overflow hardening for penalty/reward/stat aggregation at extreme input ranges
  • Closes payout rounding consistency via canonical integer division semantics

Verification

  • cargo test could not be run in this environment because Rust/Cargo is not installed here.
  • Patch was validated by static inspection against existing replay, event-state, and extreme-value test intent already present in the repository.

Closes #210
Closes #211
Closes #212
Closes #213

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@nottherealalanturing Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mxllv mxllv merged commit 994dfdd into OpSoll:main May 31, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants