feat(consent): add versioned append-only consent ledger C1-C5

This commit is contained in:
shira committed 2026-10-06 14:52:33 +03:00
1 parent 008254e44a
commit de49f93b0b
64 files changed
+9244 -132

No files matched your search

+15 -5
View File
@@ -88,6 +88,13 @@ type UserRepository interface {
// RegistrationVersion by one, so callers never choose the registration
// version; the returned account carries the new values. Otherwise it
// returns ErrUserVersionConflict.
//
// The same statement deletes the C1 records with the source
// registration that the earlier registration of this account stored,
// because the earlier registrant's consent must never stand for the new
// one. The registration usecase (TASK-053) must record the new C1 with
// ConsentLedger().Grant in the same transaction; a version conflict
// deletes nothing.
UpdateRegistration(ctx context.Context, user domain.User) (domain.User, error)
// MarkEmailVerified sets the verification time when the account is still
@@ -99,11 +106,14 @@ type UserRepository interface {
// DeleteUnverifiedRegisteredBefore deletes at most limit accounts that are
// unverified and were last registered before cutoff, oldest first, with
// their tokens, sessions, and mail deliveries, and returns how many it
// deleted. It never waits for a lock: an account whose row, token,
// session, or delivery is locked by another transaction is skipped and
// stays for the next run. A cleanup job
// repeats it until the result is below limit and runs again later.
// their tokens, sessions, mail deliveries, and consent records, and
// returns how many it deleted. It never waits for a lock: an account
// whose row, token, session, delivery, or consent record is locked by
// another transaction is skipped and stays for the next run. A consent
// recorded for a candidate account after the statement started fails the
// restricting foreign key; the run then returns an error matching
// ErrTransactionConflict, deletes nothing, and may be repeated. A cleanup
// job repeats it until the result is below limit and runs again later.
DeleteUnverifiedRegisteredBefore(ctx context.Context, cutoff time.Time, limit int32) (int64, error)
}