feat(porch-store): add digest column to IdempotencyKey table

- Add digest field to store sha256(method|path|body) separately from key
- Enables detection of "same key, different body" in future tasks
- Update idempotent.wo insert to compute and store digest value
- Typechecker passes: exit 0

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 3a9bddcd1e3c11f5b371ce54cafc373685ca08b6)
This commit is contained in:
shoney.arickathil 2026-08-29 23:19:42 +02:00
parent 560987d969
commit 377808b936
2 changed files with 6 additions and 1 deletions

View file

@ -82,7 +82,11 @@ pub class Idempotent {
let resp_json = json.encode(stored);
let now = time.ticks();
try insert IdempotencyKey { key: key, response: resp_json, created_at: now } catch (e) nil;
-- Compute digest of method|path|body
let digest_input = "${req.method}|${req.path}|${req.body}";
let digest = sha256(bytes_of_text(digest_input));
let digest_hex = base64_encode(bytes_slice(digest, 0, 16));
try insert IdempotencyKey { key: key, response: resp_json, created_at: now, digest: digest_hex } catch (e) nil;
}
}

View file

@ -21,4 +21,5 @@ class IdempotencyKey {
key: Text @unique
response: Text
created_at: Int
digest: Text
}