feat(assessment): record capture hints and keep one window per attempt

This commit is contained in:
shira committed 2026-10-11 13:16:52 +03:00
1 parent c975a0d506
commit bb917bf62e
108 files changed
+6649 -139

No files matched your search

@@ -65,6 +65,7 @@ type AttemptService struct {
clock func() time.Time
categoryDecisions AssessmentCategoryDecisionService
signalObserver *SignalObserver
workSessions *WorkSessions
}
// NewAttemptService fails at startup when a required dependency is missing.
@@ -538,6 +539,10 @@ type StartAttemptSessionCommand struct {
AttemptID domain.AssessmentAttemptID
ExpectedVersion int64
IdempotencyKey string
// Client is the identifier of the open page, or empty when the request has
// none. It is not part of the idempotency fingerprint: the refusal that it
// can cause is not stored.
Client string
}
type canonicalAttemptSessionBody struct {
@@ -651,6 +656,9 @@ func (service *AttemptService) startNewSession(
if err != nil {
return outbound.AssessmentAttemptSessionResult{}, fmt.Errorf("%s - read database time after attempt lock: %w", location, err)
}
if err := service.workSessions.requireHolder(ctx, unit, current, command.Client, databaseTime.UTC().Truncate(time.Microsecond)); err != nil {
return outbound.AssessmentAttemptSessionResult{}, fmt.Errorf("%s - check the holder of the work session: %w", location, err)
}
updated, _, err := repository.StartOrResumeSession(ctx, command.ActorID, command.AttemptID, command.ExpectedVersion, databaseTime)
if errors.Is(err, outbound.ErrAssessmentAttemptVersionConflict) || errors.Is(err, domain.ErrAssessmentAttemptVersionConflict) {
return outbound.AssessmentAttemptSessionResult{}, fmt.Errorf("%s - check expected version: %w", location, ErrAttemptVersionConflict)