feat(practice): store code submissions and practice states apart from attempts

This commit is contained in:
shira committed 2026-10-11 14:58:04 +03:00
1 parent d5e169e71b
commit 51770eea6c
61 files changed
+8584 -135

No files matched your search

@@ -277,6 +277,9 @@ type Querier interface {
// NULL retry_at. due_at keeps the deadline. The same guard as the
// completion applies.
FailScheduledJob(ctx context.Context, arg FailScheduledJobParams) (int64, error)
// Finds the latest submission of the owner under an idempotency scope, which
// a replay returns.
FindAssessmentPracticeSubmissionByScope(ctx context.Context, arg FindAssessmentPracticeSubmissionByScopeParams) (FindAssessmentPracticeSubmissionByScopeRow, error)
// The unmarked statements of real attempts whose text, with runs of white space
// collapsed, contains the fragment. The fragment is matched literally: position
// is not a pattern. The scan reads the stored variant of every item, which is
@@ -314,6 +317,8 @@ type Querier interface {
GetAssessmentClientSignalTotals(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentClientSignalTotalsRow, error)
GetAssessmentFamilyByID(ctx context.Context, id pgtype.UUID) (AssessmentFamily, error)
GetAssessmentFamilyVersion(ctx context.Context, arg GetAssessmentFamilyVersionParams) (AssessmentFamily, error)
// Reads a debug run of the owner's attempt with the state of its job.
GetAssessmentPracticeRun(ctx context.Context, arg GetAssessmentPracticeRunParams) (GetAssessmentPracticeRunRow, error)
// The attempt a review job works on: real attempts only.
GetAssessmentReviewSubject(ctx context.Context, attemptID pgtype.UUID) (pgtype.UUID, error)
// Counts eligible root attempts in a policy window and computes the instant
@@ -390,6 +395,9 @@ type Querier interface {
// for the account's own view of its mail. It selects no address and no
// content. The recipient index narrows the scan to the account's rows.
GetLatestDeliveryStatus(ctx context.Context, arg GetLatestDeliveryStatusParams) (GetLatestDeliveryStatusRow, error)
// The latest final submission of a practice: the solution the practice
// state describes.
GetLatestFinalPracticeSubmission(ctx context.Context, practiceID pgtype.UUID) (GetLatestFinalPracticeSubmissionRow, error)
// The pending credentials of the newest token of a registration, for a
// resend, which issues its token with the same credentials.
GetLatestPendingRegistration(ctx context.Context, arg GetLatestPendingRegistrationParams) (GetLatestPendingRegistrationRow, error)
@@ -487,6 +495,11 @@ type Querier interface {
InsertAssessmentFamily(ctx context.Context, arg InsertAssessmentFamilyParams) (AssessmentFamily, error)
InsertAssessmentLeakTrace(ctx context.Context, arg InsertAssessmentLeakTraceParams) error
InsertAssessmentOriginMark(ctx context.Context, arg InsertAssessmentOriginMarkParams) error
InsertAssessmentPractice(ctx context.Context, arg InsertAssessmentPracticeParams) error
// Queues the execution job of a submission in the transaction that stores
// the submission.
InsertAssessmentPracticeJob(ctx context.Context, arg InsertAssessmentPracticeJobParams) error
InsertAssessmentPracticeSubmission(ctx context.Context, arg InsertAssessmentPracticeSubmissionParams) error
InsertAssessmentReviewRead(ctx context.Context, arg InsertAssessmentReviewReadParams) error
// The attempt row is already locked by the caller. Store a parent before its
// bounded child events, in the same transaction as the immutable receipt.
@@ -829,6 +842,14 @@ type Querier interface {
LockActiveMembership(ctx context.Context, arg LockActiveMembershipParams) (LockActiveMembershipRow, error)
// Locks one owner-scoped attempt while a session command performs its CAS.
LockAssessmentAttemptForCandidate(ctx context.Context, arg LockAssessmentAttemptForCandidateParams) (AssessmentAttempt, error)
// Lock order of a practice command: the idempotency record, the attempt in
// share mode, then the practice row. The attempt flows lock the attempt
// first as well, so a practice command never waits for them in the opposite
// order.
// Locks the owner's attempt in share mode, so its state cannot change while
// a practice command decides on it, and reads the database time after the
// lock.
LockAssessmentAttemptForPractice(ctx context.Context, arg LockAssessmentAttemptForPracticeParams) (LockAssessmentAttemptForPracticeRow, error)
// Serializes root quota checks for one candidate before taking its optional
// specialization or training lock. All callers acquire these locks in order.
LockAssessmentAttemptScope(ctx context.Context, arg LockAssessmentAttemptScopeParams) error
@@ -836,6 +857,8 @@ type Querier interface {
// published or open the category, until the transaction ends. The key is
// namespaced, so it cannot collide with another use of advisory locks.
LockAssessmentCategory(ctx context.Context, category string) error
// Locks one practice of the owner's attempt for a state change.
LockAssessmentPractice(ctx context.Context, arg LockAssessmentPracticeParams) (LockAssessmentPracticeRow, error)
// Serializes the evaluations of one review. A job takes these locks for every
// attempt it will write, in ascending attempt order, before it reads any fact,
// so what it reads is what the previous writer committed.
@@ -1220,6 +1243,7 @@ type Querier interface {
// Applies an answer, expiry, or finalization transition after the attempt row
// is locked. Session limits and all immutable pins remain unchanged.
UpdateAssessmentAttemptTransition(ctx context.Context, arg UpdateAssessmentAttemptTransitionParams) (AssessmentAttempt, error)
UpdateAssessmentPracticeState(ctx context.Context, arg UpdateAssessmentPracticeStateParams) (int64, error)
// Replaces the publication over the version the caller read and advances the
// version in the same statement. No row returns for a stale version, which
// the caller answers as a version conflict. The update time never moves back,