refs #739: document DB-owned task and few-shot policy

This commit is contained in:
devmrko
2026-07-30 16:41:28 +09:00
parent 7bf8199343
commit 022ae7f9d2
16 changed files with 737 additions and 4 deletions

View File

@@ -0,0 +1,90 @@
-- Reusable SINGLE-scope pattern: two AU populations must be aggregated
-- independently before comparison. A user-master LEFT JOIN may erase valid
-- business-user rows and must not define the business population.
UPDATE sg_ai_qa_question
SET expected_focus = 'Compare standard AU and business AU as two independent single-row aggregates for the same as-of date. '
|| 'Standard AU uses the resolved game user master with AU_FLAG=1 and EXPT_USER_YN=''N''. '
|| 'Business AU uses the resolved game business-user fact with BIZ_AU_FLAG=1 and EXPT_USER_YN=''N''. '
|| 'Do not make the business count depend on a LEFT JOIN from the user-master population. '
|| 'STD_USER_YN=''Y'' is an allowed optional cohort filter, not a reason to reject the result.',
evaluation_rule_json = '{"required_sql_terms":["CZN_COMN_USER_MST","CZN_CUSTOM_BIZ_USER_TXN","AU_FLAG","BIZ_AU_FLAG","EXPT_USER_YN","COUNT"],"recommended_sql_terms":["BASE_DT","STD_USER_YN"],"optional_sql_terms":["STD_USER_YN"],"required_result_shape":"SINGLE_COMPARISON"}',
updated_at = SYSTIMESTAMP
WHERE question_code = 'CZN-03';
/
DECLARE
v_input CLOB;
v_embedding VECTOR;
v_exists NUMBER;
BEGIN
v_input := TO_CLOB('Question pattern: compare daily standard active users and business active users for one resolved game and one business date.')
|| CHR(10) || 'Question pattern Korean: 한 게임의 기준일 일간 표준 AU와 사업 AU를 비교해줘.'
|| CHR(10) || 'Logical object role: USER_BUSINESS_AU_COMPARISON'
|| CHR(10) || 'Required result shape: one row with two independent aggregate metrics.'
|| CHR(10) || 'Business population must be aggregated independently; a LEFT JOIN from the user-master population may not define it.';
v_embedding := DBMS_VECTOR.UTL_TO_EMBEDDING(
v_input, JSON(sg_qa_vector_params('search_document'))
);
SELECT COUNT(*) INTO v_exists
FROM sg_qa_vector_example
WHERE source_type = 'POLICY_TEMPLATE'
AND source_case_id = 'STD_BIZ_AU_COMPARE';
IF v_exists = 0 THEN
INSERT INTO sg_qa_vector_example (
question, answer_sql, answer_text, embedding_input, embedding, embedding_model,
reference_status, reference_kind, target_type, object_role,
inspection_status, inspection_note, verified_at, verified_by,
source_case_id, source_type
) VALUES (
'한 게임의 기준일 일간 표준 AU와 사업 AU를 비교해줘.',
TO_CLOB('SELECT' || CHR(10)
|| ' (SELECT COUNT(DISTINCT u."GUID")' || CHR(10)
|| ' FROM <RESOLVED_GAME_USER_MASTER> u' || CHR(10)
|| ' WHERE u."BASE_DT" = <BUSINESS_DATE>' || CHR(10)
|| ' AND u."AU_FLAG" = 1' || CHR(10)
|| ' AND u."EXPT_USER_YN" = ''N'') AS "STANDARD_AU_COUNT",' || CHR(10)
|| ' (SELECT COUNT(DISTINCT b."GUID")' || CHR(10)
|| ' FROM <RESOLVED_GAME_BUSINESS_USER> b' || CHR(10)
|| ' WHERE b."BASE_DT" = <BUSINESS_DATE>' || CHR(10)
|| ' AND b."BIZ_AU_FLAG" = 1' || CHR(10)
|| ' AND b."EXPT_USER_YN" = ''N'') AS "BUSINESS_AU_COUNT"' || CHR(10)
|| 'FROM DUAL'),
'Applicable metric reference: for this daily AU comparison, the standard metric must use AU_FLAG=1 and EXPT_USER_YN=''N''; do not replace it with LAST_CONN_DT period logic or STD_USER_YN alone. The business metric must use BIZ_AU_FLAG=1 and EXPT_USER_YN=''N''. Produce one row from two independent aggregate subqueries, and do not count business users through a LEFT JOIN from the standard-user population. STD_USER_YN may be added only as an optional cohort filter.',
v_input, v_embedding, 'cohere.embed-v4.0',
'APPROVED', 'SQL_TEMPLATE', 'SINGLE', 'USER_BUSINESS_AU_COMPARISON',
'VERIFIED',
'Reusable comparison pattern with logical placeholders only; no customer game, date, result, or physical object is embedded.',
SYSTIMESTAMP, 'SGMP_POC_METADATA_REVIEW',
'STD_BIZ_AU_COMPARE', 'POLICY_TEMPLATE'
);
ELSE
UPDATE sg_qa_vector_example
SET question = '한 게임의 기준일 일간 표준 AU와 사업 AU를 비교해줘.',
answer_sql = TO_CLOB('SELECT' || CHR(10)
|| ' (SELECT COUNT(DISTINCT u."GUID")' || CHR(10)
|| ' FROM <RESOLVED_GAME_USER_MASTER> u' || CHR(10)
|| ' WHERE u."BASE_DT" = <BUSINESS_DATE>' || CHR(10)
|| ' AND u."AU_FLAG" = 1' || CHR(10)
|| ' AND u."EXPT_USER_YN" = ''N'') AS "STANDARD_AU_COUNT",' || CHR(10)
|| ' (SELECT COUNT(DISTINCT b."GUID")' || CHR(10)
|| ' FROM <RESOLVED_GAME_BUSINESS_USER> b' || CHR(10)
|| ' WHERE b."BASE_DT" = <BUSINESS_DATE>' || CHR(10)
|| ' AND b."BIZ_AU_FLAG" = 1' || CHR(10)
|| ' AND b."EXPT_USER_YN" = ''N'') AS "BUSINESS_AU_COUNT"' || CHR(10)
|| 'FROM DUAL'),
answer_text = 'Applicable metric reference: for this daily AU comparison, the standard metric must use AU_FLAG=1 and EXPT_USER_YN=''N''; do not replace it with LAST_CONN_DT period logic or STD_USER_YN alone. The business metric must use BIZ_AU_FLAG=1 and EXPT_USER_YN=''N''. Produce one row from two independent aggregate subqueries, and do not count business users through a LEFT JOIN from the standard-user population. STD_USER_YN may be added only as an optional cohort filter.',
embedding_input = v_input,
embedding = v_embedding,
reference_status = 'APPROVED', inspection_status = 'VERIFIED',
verified_at = SYSTIMESTAMP, verified_by = 'SGMP_POC_METADATA_REVIEW'
WHERE source_type = 'POLICY_TEMPLATE'
AND source_case_id = 'STD_BIZ_AU_COMPARE';
END IF;
COMMIT;
END;
/