package outbound import ( "context" "time" "github.com/google/uuid" "lincodex/backend/internal/domain" ) // MaxEvidencePageSize bounds one page of the candidate's own facts. const MaxEvidencePageSize = 100 // EvidencePosition is the descending key of the candidate's fact list. type EvidencePosition struct { OccurredAt time.Time ID uuid.UUID } // EvidenceListQuery selects one owner-scoped page of facts. type EvidenceListQuery struct { CandidateID uuid.UUID After *EvidencePosition Limit int32 } // EvidenceFactPage is one page of the candidate's facts, newest event first. type EvidenceFactPage struct { Items []domain.EvidenceFact HasMore bool } // EvidencePositionOf creates the continuation key for a fact. func EvidencePositionOf(fact domain.EvidenceFact) EvidencePosition { snapshot := fact.Snapshot() return EvidencePosition{OccurredAt: snapshot.OccurredAt, ID: snapshot.ID} } // EvidenceCandidateCategories names the categories that the card of one // candidate shows, which are the categories whose supporting facts a batch // read may return. type EvidenceCandidateCategories struct { CandidateID uuid.UUID Categories []domain.CandidateViewCategory } // CategoryKey is a specialization and a grade. type CategoryKey struct { Specialization domain.SpecializationCode Grade domain.GradeCode } // EvidenceRepository reads the skill evidence projection. It never reads an // assessment result, answer, attempt, or review: the projection is the only // source, so no answer, failure, or anti-cheat datum can reach a caller. type EvidenceRepository interface { // ListCandidateFacts returns one page of the facts that belong to the // candidate, hidden ones included. ListCandidateFacts(ctx context.Context, query EvidenceListQuery) (EvidenceFactPage, error) // ListOrganizationFacts returns the evidence that one organization may read // about one candidate: for each category of the card, the one fact that // supports its confirmed grade. The adapter must select from // candidate_effective_publications, exclude the candidates that hide the // organization in the same statement, require the published card to carry // the categories field, and return only visible measurements. The caller // has already authorized the active organization membership and passes the // categories that the card just projected. ListOrganizationFacts( ctx context.Context, organizationID, candidateID uuid.UUID, categories []domain.CandidateViewCategory, ) ([]domain.EvidenceOrganizationFact, error) // ListOrganizationFactsBatch is ListOrganizationFacts for many candidates in // one statement, with the same barriers: the effective publication view, // the exclusion of the candidates that hide the organization, the // categories field, and only visible measurements. A candidate with no // permitted fact has no entry in the result. The result is for the caller's // grouping and is never returned as it is. ListOrganizationFactsBatch( ctx context.Context, organizationID uuid.UUID, requests []EvidenceCandidateCategories, ) (map[uuid.UUID][]domain.EvidenceOrganizationFact, error) // CountComparableRealCategories returns, for each given category, how many // candidates hold it from a source that is not a synthetic demonstration: // the size of the comparable real cohort. A category nobody holds from a // real source is absent. It returns counts only. CountComparableRealCategories(ctx context.Context, categories []CategoryKey) (map[CategoryKey]int64, error) // ListPreviewFacts returns the same selection for the candidate's own card // preview. It applies no organization and no cohort, and the caller has // locked the effective C2 and publication. ListPreviewFacts( ctx context.Context, candidateID uuid.UUID, categories []domain.CandidateViewCategory, ) ([]domain.EvidenceOrganizationFact, error) }