feat(assessment): assign the demonstration category and keep result history

This commit is contained in:
shira committed 2026-10-09 00:35:13 +03:00
1 parent b3c6dc870b
commit 8277133712
61 files changed
+4338 -268

No files matched your search

+22 -26
View File
@@ -292,40 +292,36 @@ func newRealCategoryDecision(
}
func eligibleSyntheticCategoryPolicy(policy PolicyVersion, result AssessmentAttemptResultSnapshot) bool {
product := policy.Policy()
return policy.Kind() == PolicyKindDemo && policy.Key() == ProductPolicyKey &&
sameAssessmentPolicy(product.Assessment, DemoProductPolicyV2().Assessment) &&
return completeDemoBasicPolicy(policy) &&
result.Attempt.Mode == AssessmentAttemptModeDemoBasic && result.Rationale.Rule == assessmentResultRuleBasicPassMark &&
int32(product.Assessment.Attempt.BasicPassMark) == result.Rationale.PassMarkBasisPoints &&
int32(policy.Policy().Assessment.Attempt.BasicPassMark) == result.Rationale.PassMarkBasisPoints &&
(result.Outcome == AssessmentAttemptOutcomeConfirmed || result.Outcome == AssessmentAttemptOutcomeNotConfirmed)
}
func sameAssessmentPolicy(left, right AssessmentPolicy) bool {
return sameAssessmentPolicyRules(left, right) &&
sameOptionalAssessmentAttemptPolicy(left.Attempt, right.Attempt) &&
sameOptionalAssessmentTrainingPolicy(left.Training, right.Training)
}
func sameAssessmentPolicyRules(left, right AssessmentPolicy) bool {
return left.Calibration == right.Calibration && left.SameGradeRetryAfter == right.SameGradeRetryAfter &&
left.MaxAttemptsPerWindow == right.MaxAttemptsPerWindow && left.AttemptWindow == right.AttemptWindow &&
left.PromotionMinInterval == right.PromotionMinInterval && left.ConfirmationThreshold == right.ConfirmationThreshold &&
left.HighStrengthThreshold == right.HighStrengthThreshold && left.PracticeRequired == right.PracticeRequired &&
left.StopRule == right.StopRule
}
func sameOptionalAssessmentAttemptPolicy(left, right *AssessmentAttemptPolicy) bool {
if left == nil || right == nil {
return left == right
// completeDemoBasicPolicy reports whether a stored policy version is a demo
// policy whose assessment section is complete for the demo_basic mode: explicit
// attempt and training settings and an uncalibrated method. The stored version
// has already passed policy validation, so its own pass mark is the threshold;
// no fixed value is compared.
func completeDemoBasicPolicy(policy PolicyVersion) bool {
if policy.IsZero() || policy.Key() != ProductPolicyKey || policy.Kind() != PolicyKindDemo {
return false
}
return *left == *right
assessment := policy.Policy().Assessment
return assessment.Calibration == AssessmentCalibrationUncalibratedInitial &&
assessment.Attempt != nil && assessment.Attempt.RealMode == AssessmentRealModeDemoBasic &&
assessment.Training != nil
}
func sameOptionalAssessmentTrainingPolicy(left, right *AssessmentTrainingPolicy) bool {
if left == nil || right == nil {
return left == right
// ValidateSyntheticCategoryPolicy reports whether a policy version is a
// complete demonstration policy with the demo_basic mode, the only kind of
// policy under which a synthetic demonstration category may be attested.
func ValidateSyntheticCategoryPolicy(policy PolicyVersion) error {
const location = "domain.ValidateSyntheticCategoryPolicy"
if !completeDemoBasicPolicy(policy) {
return fmt.Errorf("%s - the policy is not a complete demo_basic demonstration policy: %w", location, ErrInvalidAssessmentCategory)
}
return *left == *right
return nil
}
func reviewMatchesCategoryAttempt(