feat(assessment): add the review band of attempt signals and the disclosed collector

This commit is contained in:
shira committed 2026-10-08 23:04:57 +03:00
1 parent 68286af8b7
commit b3c6dc870b
124 files changed
+13522 -633

No files matched your search

+10 -1
View File
@@ -24,6 +24,9 @@ type SubmitAttemptAnswerCommand struct {
ExpectedVersion int64
IdempotencyKey string
Answer json.RawMessage
// Origin is the sender of the request. It feeds the server signals only and
// is not part of the idempotency fingerprint.
Origin RequestOrigin
}
type canonicalAttemptAnswerBody struct {
@@ -132,7 +135,7 @@ func (service *AttemptService) submitNewAnswer(
return fmt.Errorf("%s - read database time after consent and attempt locks: %w", location, err)
}
databaseTime = databaseTime.UTC().Truncate(time.Microsecond)
return service.persistSubmittedAnswer(ctx, repository, scope, command, current, databaseTime, result)
return service.persistSubmittedAnswer(ctx, unit, repository, scope, command, current, databaseTime, result)
}
func lockAttemptForAnswer(
@@ -168,6 +171,7 @@ func lockAttemptForAnswer(
func (service *AttemptService) persistSubmittedAnswer(
ctx context.Context,
unit outbound.UnitOfWork,
repository outbound.AssessmentAttemptRepository,
scope outbound.AssessmentAttemptIdempotencyScope,
command SubmitAttemptAnswerCommand,
@@ -199,6 +203,11 @@ func (service *AttemptService) persistSubmittedAnswer(
if err := repository.SaveAnswer(ctx, current, updated, command.ItemID); err != nil {
return fmt.Errorf("%s - persist answer and attempt transition: %w", location, err)
}
if err := service.signalObserver.observeAnswer(
ctx, unit, current, updated, command.ItemID, command.Origin,
); err != nil {
return fmt.Errorf("%s - observe accepted answer: %w", location, err)
}
}
outcome := outbound.AssessmentAttemptCommandOutcome{StatusCode: 200, Response: updated.PublicSnapshot()}
if err := repository.SaveAnswerOutcome(ctx, scope, outcome); err != nil {