chore: checkpoint assessment and inbox integration
This commit is contained in:
1 parent
88a31ba0d5
commit
5c52fd8b91
31 files changed
+4608
-181
No files matched your search
@@ -26,6 +26,9 @@ var (
|
||||
// ErrAssessmentAttemptResultNotFound reports a completed attempt with no
|
||||
// persisted immutable decision snapshot.
|
||||
ErrAssessmentAttemptResultNotFound = errors.New("assessment attempt result not found")
|
||||
// ErrAssessmentCategoryConflict reports a current category that could not
|
||||
// be advanced under its owner and specialization lock.
|
||||
ErrAssessmentCategoryConflict = errors.New("assessment category changed concurrently")
|
||||
)
|
||||
|
||||
// AssessmentAttemptIdempotencyScope is the server HMAC of the operation,
|
||||
@@ -108,6 +111,26 @@ type AssessmentRootQuotaSnapshot struct {
|
||||
AvailableAt *time.Time
|
||||
}
|
||||
|
||||
// AssessmentAttemptResultCursor is the keyset boundary for owner history.
|
||||
// It is internal to the repository; the usecase wraps it in an owner-bound
|
||||
// authenticated token before accepting it from HTTP.
|
||||
type AssessmentAttemptResultCursor struct {
|
||||
DecidedAt time.Time
|
||||
AttemptID domain.AssessmentAttemptID
|
||||
}
|
||||
|
||||
// AssessmentAttemptResultRecord contains one immutable result and the owner
|
||||
// returned by the scoped query. The usecase rechecks ownership and eligibility.
|
||||
type AssessmentAttemptResultRecord struct {
|
||||
UserID uuid.UUID
|
||||
Entry domain.AssessmentAttemptResultHistoryEntry
|
||||
}
|
||||
|
||||
type AssessmentAttemptResultPage struct {
|
||||
Records []AssessmentAttemptResultRecord
|
||||
HasMore bool
|
||||
}
|
||||
|
||||
// AssessmentAttemptRepositories exposes the repository bound to a UnitOfWork
|
||||
// transaction.
|
||||
type AssessmentAttemptRepositories interface {
|
||||
@@ -223,6 +246,52 @@ type AssessmentAttemptRepository interface {
|
||||
// GetResult returns the immutable owner-scoped result snapshot.
|
||||
GetResult(ctx context.Context, userID uuid.UUID, attemptID domain.AssessmentAttemptID) (domain.AssessmentAttemptResultSnapshot, error)
|
||||
|
||||
// SaveResultHistoryEntry stores a typed v1 or v2 immutable result. V1 keeps
|
||||
// the original result document; v2 carries category decision columns.
|
||||
SaveResultHistoryEntry(ctx context.Context, userID uuid.UUID, entry domain.AssessmentAttemptResultHistoryEntry) error
|
||||
|
||||
// GetResultHistoryEntry returns the exact stored v1/v2 record without
|
||||
// reconstructing category information from current state.
|
||||
GetResultHistoryEntry(ctx context.Context, userID uuid.UUID, attemptID domain.AssessmentAttemptID) (domain.AssessmentAttemptResultHistoryEntry, error)
|
||||
|
||||
// ListCandidateAssessmentResults returns an owner-scoped keyset page and at
|
||||
// most limit entries. HasMore indicates that the repository found one more.
|
||||
ListCandidateAssessmentResults(
|
||||
ctx context.Context,
|
||||
userID uuid.UUID,
|
||||
cursor *AssessmentAttemptResultCursor,
|
||||
limit int32,
|
||||
) (AssessmentAttemptResultPage, error)
|
||||
|
||||
// LockCandidateCategory serializes one candidate/specialization upgrade.
|
||||
// Call only after consent, candidate/specialization, and attempt locks.
|
||||
LockCandidateCategory(ctx context.Context, candidateID uuid.UUID, specialization domain.SpecializationCode) error
|
||||
|
||||
GetCandidateCategory(
|
||||
ctx context.Context,
|
||||
candidateID uuid.UUID,
|
||||
specialization domain.SpecializationCode,
|
||||
) (domain.CandidateAssessmentCategory, bool, error)
|
||||
|
||||
// GetSyntheticCategoryReview requires the complete immutable opening and
|
||||
// product-policy pins; gradingPolicyID must match the opening's policy.
|
||||
GetSyntheticCategoryReview(
|
||||
ctx context.Context,
|
||||
openingID uuid.UUID,
|
||||
category domain.AssessmentCategory,
|
||||
openingManifestHash [32]byte,
|
||||
productPolicyID domain.PolicyVersionID,
|
||||
productPolicyVersion int32,
|
||||
gradingPolicyID domain.PolicyVersionID,
|
||||
) (domain.AssessmentSyntheticCategoryReview, bool, error)
|
||||
|
||||
// CreateSyntheticCategoryReview stores an operator-attributed immutable
|
||||
// attestation after the domain has validated its explicit synthetic source.
|
||||
CreateSyntheticCategoryReview(ctx context.Context, review domain.AssessmentSyntheticCategoryReview) error
|
||||
|
||||
// SaveCandidateAssessmentCategory writes only an assigned category upgrade.
|
||||
SaveCandidateAssessmentCategory(ctx context.Context, category domain.CandidateAssessmentCategory) error
|
||||
|
||||
// SaveSessionOutcome records the original 200 public projection for the
|
||||
// already-reserved idempotency scope. It shares the transaction and expiry
|
||||
// of the generic idempotency record.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package outbound
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNotificationInboxEntryNotFound covers a missing event and an event
|
||||
// owned by a different recipient or organization context.
|
||||
ErrNotificationInboxEntryNotFound = errors.New("notification inbox entry not found")
|
||||
// ErrNotificationInboxEventConflict reports an event ID reused with
|
||||
// different immutable recipient or source metadata.
|
||||
ErrNotificationInboxEventConflict = errors.New("notification inbox event metadata conflicts")
|
||||
)
|
||||
|
||||
const MaxNotificationInboxPageSize = 100
|
||||
|
||||
// NotificationInboxRepository stores recipient-scoped event references and
|
||||
// read state. Implementations can bind these methods to a transaction; the
|
||||
// standalone PostgreSQL store uses one SQL statement per operation.
|
||||
type NotificationInboxRepository interface {
|
||||
// Store inserts one recipient-specific event. It returns false for an
|
||||
// identical event already stored under the same recipient and event ID.
|
||||
Store(ctx context.Context, entry domain.NotificationInboxEntry) (created bool, err error)
|
||||
|
||||
// List returns one newest-first page for the exact recipient. A nil
|
||||
// OrganizationID means all organization contexts of that recipient.
|
||||
List(ctx context.Context, query NotificationInboxListQuery) (NotificationInboxPage, error)
|
||||
|
||||
// MarkRead records the first read time in exact recipient and organization
|
||||
// context. Missing and unauthorized identities share one not-found result.
|
||||
MarkRead(
|
||||
ctx context.Context,
|
||||
recipientUserID uuid.UUID,
|
||||
organizationID uuid.UUID,
|
||||
eventID uuid.UUID,
|
||||
at time.Time,
|
||||
) (domain.NotificationInboxEntry, error)
|
||||
}
|
||||
|
||||
// NotificationInboxListQuery selects a bounded recipient-owned page.
|
||||
type NotificationInboxListQuery struct {
|
||||
RecipientUserID uuid.UUID
|
||||
OrganizationID *uuid.UUID
|
||||
After *NotificationInboxPosition
|
||||
Limit int32
|
||||
}
|
||||
|
||||
// NotificationInboxPosition continues a newest-first inbox page.
|
||||
type NotificationInboxPosition struct {
|
||||
OccurredAt time.Time
|
||||
EventID uuid.UUID
|
||||
}
|
||||
|
||||
// NotificationInboxPage is a bounded page plus whether another row exists.
|
||||
type NotificationInboxPage struct {
|
||||
Items []domain.NotificationInboxEntry
|
||||
HasMore bool
|
||||
}
|
||||
|
||||
// NotificationInboxPositionOf returns the continuation key for an entry.
|
||||
func NotificationInboxPositionOf(entry domain.NotificationInboxEntry) NotificationInboxPosition {
|
||||
return NotificationInboxPosition{OccurredAt: entry.OccurredAt(), EventID: entry.EventID()}
|
||||
}
|
||||
Reference in new issue
Block a user