No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!122
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/120-slice1-postgres-otp-store"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#120 slice 1 / ADR-011 / #89 re-scoped: the OTP store moves into the database, and the #89 production race ceases to exist rather than being patched.
The atomicity design (why this beats the planned INCR/Lua hardening): every mutation is a single-statement atomic operation against the new
otp_codestable:DELETE … WHERE Key/Code/Attempts < max/ExpiresAt > now— delete IS the consume; two concurrent correct codes can never both passUPDATE … SET attempts = attempts + 1 WHERE Attempts < max— the counter can never walk past the ceiling and can never lose a bump between read and writeThe SQL is provider-neutral — the SQLite test harness runs the identical statements production Postgres will (ADR-011's no-dual-store-test-surface principle).
Changes: OtpCode entity (string PK = store key, Data.Entities) +
AddOtpCodesmigration;IOtpStorenow alwaysPostgresOtpStore(scoped — the redis-conditional DI branch is gone);RedisOtpStoredeleted;InMemoryOtpStorekept but unregistered (barrier-race harness for AuthConsistencyTests).Tests: 7 new (PostgresOtpStoreTests): single-use consume, bump-to-max-then-lock-and-burn with the correct code verified dead after burn, attempts-never-exceed-max over 12 wrong codes, expired rejection regardless of code, regenerate-overwrite resets attempts, GetAsync expiry visibility, and an end-to-end OtpService verify through DI asserting the Postgres store is what's wired. The full existing OTP/registration suite doubles as the regression net for the swap.
Suite 939/0/39 (Release+Debug), coverage gate 87.57%. First slice of #120; closes #89.