fix(aihr): gate case learning pii

This commit is contained in:
2026-07-14 23:51:24 +08:00
parent 6cebf0193d
commit e37590dd25
3 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ check_pilot_samples() {
hire_date_schema_count="$(pilot_sql_scalar "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'aihr_org_snapshot' AND column_name = 'hire_date'")"
sop_document_count="$(pilot_sql_scalar "SELECT COUNT(*) FROM aihr_knowledge_attach WHERE tenant_id = '$pilot_tenant' AND type = 'sop' AND status = 2")"
case_stored_count="$(pilot_sql_scalar "SELECT COUNT(*) FROM aihr_case_record WHERE tenant_id = '$pilot_tenant' AND status = '已入库'")"
case_unmasked_count="$(pilot_sql_scalar "SELECT COUNT(*) FROM aihr_case_record WHERE tenant_id = '$pilot_tenant' AND status = '已入库' AND CONCAT_WS(' ', title, transcript, summary) REGEXP '1[3-9][0-9]{9}|[[:alnum:]._%+-]+@[[:alnum:].-]+\\.[[:alpha:]]{2,}|[0-9]{1,2}(栋|幢|号楼|单元)[0-9]{3,4}|[0-9]{1,2}[--][0-9]{3,4}'")"
case_unmasked_count="$(pilot_sql_scalar "SELECT COUNT(*) FROM aihr_case_record WHERE tenant_id = '$pilot_tenant' AND status = '已入库' AND CONCAT_WS(' ', title, transcript, summary, learning_points, supervisor_comment) REGEXP '1[3-9][0-9]{9}|[[:alnum:]._%+-]+@[[:alnum:].-]+\\.[[:alpha:]]{2,}|[0-9]{1,2}(栋|幢|号楼|单元)[0-9]{3,4}|[0-9]{1,2}[--][0-9]{3,4}'")"
completed_people="$(pilot_sql_scalar "
SELECT COUNT(*)
FROM (
@@ -194,6 +194,14 @@ pilot_sql_scalar "UPDATE aihr_case_record SET transcript = '手机号13900000000
pilot_output="$(AIHR_PILOT_START_DATE=2026-07-07 AIHR_PILOT_END_DATE=2026-07-10 check_pilot_samples)"
[[ "$pilot_output" == *'case_unmasked=1'* ]] || { echo "FAIL: unmasked case PII was not detected: $pilot_output" >&2; exit 1; }
pilot_sql_scalar "UPDATE aihr_case_record SET transcript = '已完成回访', learning_points = '[\"手机号13900000000\"]' WHERE tenant_id = '000000' AND status = '已入库' LIMIT 1" >/dev/null
pilot_output="$(AIHR_PILOT_START_DATE=2026-07-07 AIHR_PILOT_END_DATE=2026-07-10 check_pilot_samples)"
[[ "$pilot_output" == *'case_unmasked=1'* ]] || { echo "FAIL: unmasked learning point PII was not detected: $pilot_output" >&2; exit 1; }
pilot_sql_scalar "UPDATE aihr_case_record SET learning_points = '[\"已完成回访\"]', supervisor_comment = '请联系13900000000复核' WHERE tenant_id = '000000' AND status = '已入库' LIMIT 1" >/dev/null
pilot_output="$(AIHR_PILOT_START_DATE=2026-07-07 AIHR_PILOT_END_DATE=2026-07-10 check_pilot_samples)"
[[ "$pilot_output" == *'case_unmasked=1'* ]] || { echo "FAIL: unmasked supervisor comment PII was not detected: $pilot_output" >&2; exit 1; }
if (AIHR_PILOT_STRICT=true AIHR_PILOT_START_DATE= AIHR_PILOT_END_DATE= check_pilot_samples) >/tmp/wygj-pilot-strict-test.log 2>&1; then
echo "FAIL: strict mode accepted an implicit date window" >&2
exit 1