Package com.tnsai.idempotency
Class IdempotencyKey
java.lang.Object
com.tnsai.idempotency.IdempotencyKey
Derives stable idempotency keys from tool / action input maps per
KeyStrategy (issue #91).
The KeyStrategy.HASH_INPUT path computes SHA-256 over a
canonical JSON-like rendering of the input map: keys are sorted
alphabetically at every level of nesting, lists keep their insertion
order, scalars are stringified with locale-independent rules. Two
inputs that differ only in map iteration order produce the same key —
which is the property the dedup cache needs for the JVM's
non-deterministic HashMap.entrySet() ordering not to
accidentally split cache slots.
The KeyStrategy.UUID path returns a fresh random key every
call. The KeyStrategy.NONE path returns null — the
caller MUST short-circuit before invoking and must not pass null
onward to the store.
- Since:
- 0.5.0 (issue #91)
-
Method Summary
-
Method Details
-
derive
Compute the idempotency key for the given input understrategy.- Parameters:
strategy- how to deriveinput- the call's argument map; treated as empty when nulltoolName- identifies the tool — incorporated into the key so different tools with identical-shaped inputs don't collide on the same hash- Returns:
- the key, or
nullwhenstrategy == NONE
-