feat: add assessment, privacy and support flows

This commit is contained in:
TakuyaYagam1 committed 2026-10-08 08:08:25 +03:00
1 parent ee3738ee73
commit e4f24fa202
339 files changed
+56454 -1126

No files matched your search

@@ -2,9 +2,12 @@ package outbound
import (
"context"
"crypto/sha256"
"errors"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/domain"
)
@@ -51,6 +54,13 @@ var (
// ErrAssessmentCatalogBindingImmutable reports an attempt to edit or remove
// an immutable reviewed catalog binding.
ErrAssessmentCatalogBindingImmutable = errors.New("assessment catalog binding is immutable")
// ErrAssessmentSelectionUnavailable reports that no current reviewed
// category exactly matches the requested public selection.
ErrAssessmentSelectionUnavailable = errors.New("assessment selection is unavailable")
// ErrAssessmentSelectionAmbiguous reports more than one current category
// matching the same public selection; the server never chooses arbitrarily.
ErrAssessmentSelectionAmbiguous = errors.New("assessment selection is ambiguous")
)
// MaxAssessmentFamilyPageSize is the largest page that ListFamilies returns.
@@ -64,6 +74,42 @@ type AssessmentFamilyCursor struct {
Version int32
}
// AssessmentBankSelection is the exact reviewed category manifest used to
// build one real attempt. Families are the entries from the pinned manifest,
// not an inferred snapshot of current rows.
type AssessmentBankSelection struct {
Opening domain.AssessmentCategoryOpening
ProductPolicyVersionID domain.PolicyVersionID
ProductPolicyVersion int32
ManifestSHA [sha256.Size]byte
Families []domain.AssessmentFamily
}
// AssessmentTrainingBankSelection is an explicitly reviewed, non-qualification
// family set pinned to one product policy version.
type AssessmentTrainingBankSelection struct {
BindingID uuid.UUID
Category domain.AssessmentCategory
ProductPolicyVersionID domain.PolicyVersionID
ProductPolicyVersion int32
ManifestSHA [sha256.Size]byte
Families []domain.AssessmentFamily
}
// AssessmentAvailabilitySelection is one current, reviewed specialization,
// grade, and language binding with the family keys from its verified live
// published manifest. It exposes no task content.
type AssessmentAvailabilitySelection struct {
OpeningID uuid.UUID
Category domain.AssessmentCategory
ProductPolicyVersionID domain.PolicyVersionID
ProductPolicyVersion int32
Specialization domain.SpecializationCode
Grade domain.GradeCode
TaskLanguages []domain.TaskLanguageCode
FamilyKeys []domain.AssessmentFamilyKey
}
// AssessmentBankRepositories exposes the assessment bank. UnitOfWork binds it
// to one transaction; an adapter may also provide it outside a transaction,
// where every call is its own statement. A returned family passed
@@ -139,6 +185,12 @@ type AssessmentBankRepository interface {
// coverage, or published-family manifest changed are omitted.
ListCurrentSpecializationAvailability(ctx context.Context) ([]domain.SpecializationAvailability, error)
// ListCurrentAssessmentAvailabilitySelections returns current, reviewed
// selection metadata pinned to the effective product policy at asOf. The
// implementation validates each live published-family manifest and does
// not take category locks or load task content.
ListCurrentAssessmentAvailabilitySelections(ctx context.Context, asOf time.Time) ([]AssessmentAvailabilitySelection, error)
// DatabaseTime returns the database clock. It stamps the effective time
// of a policy version, so the version in force now is judged against it
// and not against the application clock.
@@ -147,4 +199,22 @@ type AssessmentBankRepository interface {
// GetCurrentCategoryOpening returns the newest opening of the category,
// or ErrAssessmentCategoryNotOpen.
GetCurrentCategoryOpening(ctx context.Context, category domain.AssessmentCategory) (domain.AssessmentCategoryOpening, error)
// ResolveCurrentSelection finds exactly one current catalog binding for
// the public request, locks its category, and rechecks the opening, product
// policy, live manifest, and exact family versions under that lock.
ResolveCurrentSelection(
ctx context.Context,
specialization domain.SpecializationCode,
grade domain.GradeCode,
language *domain.TaskLanguageCode,
) (AssessmentBankSelection, error)
// ResolveCurrentTrainingSelection returns exactly one reviewed training
// binding whose policy pin and published family manifest remain current.
ResolveCurrentTrainingSelection(
ctx context.Context,
productPolicyID domain.PolicyVersionID,
productPolicyVersion int32,
) (AssessmentTrainingBankSelection, error)
}