ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Stage 4.7: внедрить stage4_contract_compliance_rate в P0 quality-gap и baseline gate
This commit is contained in:
@@ -108,6 +108,13 @@ function buildQualityGapChecks(input) {
|
||||
threshold: thresholds.followup_context_retention_score_min,
|
||||
comparator: ">=",
|
||||
passed: metrics.followup_context_retention_score >= thresholds.followup_context_retention_score_min
|
||||
},
|
||||
{
|
||||
metric: "stage4_contract_compliance_rate",
|
||||
value: metrics.stage4_contract_compliance_rate,
|
||||
threshold: thresholds.stage4_contract_compliance_rate_min,
|
||||
comparator: ">=",
|
||||
passed: metrics.stage4_contract_compliance_rate >= thresholds.stage4_contract_compliance_rate_min
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
+9
-2
@@ -10,6 +10,7 @@ const nanoid_1 = require("nanoid");
|
||||
const config_1 = require("../config");
|
||||
const assistantService_1 = require("../services/assistantService");
|
||||
const assistantSessionStore_1 = require("../services/assistantSessionStore");
|
||||
const assistantStage4AnswerContractAudit_1 = require("../services/assistantStage4AnswerContractAudit");
|
||||
const files_1 = require("../utils/files");
|
||||
const p0_acceptance_gate_1 = require("./p0_acceptance_gate");
|
||||
const p0_metric_definitions_1 = require("./p0_metric_definitions");
|
||||
@@ -1062,16 +1063,22 @@ function computeQualityGapMetrics(caseRecords) {
|
||||
const mechanismSpecificityScores = caseRecords.map((item) => item.metric_subscores.mechanism_specificity_score);
|
||||
const followupCases = caseRecords.filter((item) => item.query_class === "followup_investigation");
|
||||
const followupRetainedCases = followupCases.filter((item) => item.checks.followup_context_retained).length;
|
||||
const stage4ContractAuditedCases = caseRecords
|
||||
.map((item) => (0, assistantStage4AnswerContractAudit_1.buildStage4AnswerContractAuditV1)(item.assistant_reply ?? ""))
|
||||
.filter((item) => item.schema_version === "stage4_answer_contract_audit_v1");
|
||||
const stage4ContractCompliantCases = stage4ContractAuditedCases.filter((item) => item.is_stage4_shape === true).length;
|
||||
return {
|
||||
raw: {
|
||||
generic_explanation_rate: round2(genericCases / total),
|
||||
false_confidence_rate: round2(falseConfidenceCases / total),
|
||||
mechanism_specificity_score: average(mechanismSpecificityScores),
|
||||
followup_context_retention_score: round2(followupCases.length === 0 ? 1 : followupRetainedCases / Math.max(1, followupCases.length))
|
||||
followup_context_retention_score: round2(followupCases.length === 0 ? 1 : followupRetainedCases / Math.max(1, followupCases.length)),
|
||||
stage4_contract_compliance_rate: round2(stage4ContractAuditedCases.length === 0 ? 0 : stage4ContractCompliantCases / Math.max(1, stage4ContractAuditedCases.length))
|
||||
},
|
||||
denominators: {
|
||||
cases_total: caseRecords.length,
|
||||
followup_cases_total: followupCases.length
|
||||
followup_cases_total: followupCases.length,
|
||||
stage4_contract_audited_cases_total: stage4ContractAuditedCases.length
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,6 +65,11 @@ exports.P0_QUALITY_GAP_METRIC_DEFINITIONS = {
|
||||
description: "Rate of correct context retention in follow-up investigation cases.",
|
||||
unit: "rate",
|
||||
direction: "higher_is_better"
|
||||
},
|
||||
stage4_contract_compliance_rate: {
|
||||
description: "Share of answers that satisfy the Stage 4 user-facing answer contract shape.",
|
||||
unit: "rate",
|
||||
direction: "higher_is_better"
|
||||
}
|
||||
};
|
||||
exports.P0_DEFAULT_FORBIDDEN_LEAKAGE_TOKENS = [
|
||||
@@ -97,7 +102,8 @@ exports.P0_DEFAULT_QUALITY_GAP_THRESHOLDS = {
|
||||
generic_explanation_rate_max: 0.2,
|
||||
false_confidence_rate_max: 0.12,
|
||||
mechanism_specificity_score_min: 3.0,
|
||||
followup_context_retention_score_min: 0.75
|
||||
followup_context_retention_score_min: 0.75,
|
||||
stage4_contract_compliance_rate_min: 0.9
|
||||
};
|
||||
function isProblemUnitType(value) {
|
||||
return (value === "document_conflict" ||
|
||||
|
||||
Reference in New Issue
Block a user