Files
prop-ai-hr/backend/script/sql/update/aihr_20260804_pending_clarification_mysql8.sql
T
admin 6cc2ac73e5 feat(aihr): add evidence grading, clarification loop and route exits to ask agent
- narrow amount-semantics clarification to adjudicative intents only
- persist pending clarification on conversation and resolve follow-up
  replies as ANSWERED/GAVE_UP/NEW_TOPIC (max one round per field)
- add AihrEvidenceGradingService: FULL/PARTIAL/GUIDANCE/ROUTE arbitration,
  policy-claim post-validation, reference answers labeled as non-formal
- unblock retrieval source gating; tag citations with evidence tier,
  keep PUBLISHED/HUMAN_VERIFIED/effective-date authorization gates
- replace operator-facing no-evidence copy with actionable route exits
  (human help, direct finance channel, web research)
- allow fragment-less down feedback for own NO_EVIDENCE queries so
  ROUTE answers can escalate to human help (fragment_id nullable)
- migrations: aihr_20260804_pending_clarification_mysql8.sql,
  aihr_20260804_feedback_fragment_nullable_mysql8.sql
2026-08-05 00:52:52 +08:00

31 lines
1.3 KiB
SQL

-- Pending clarification state for the knowledge Q&A clarification loop. Additive and idempotent on MySQL 8.
-- The conversation row keeps at most one suspended clarification; it is resolved (answered,
-- given up or replaced by a new topic) on the next turn and never survives the 30-minute expiry.
SET @aihr_pending_conversation_exists := (
SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name = 'aihr_knowledge_conversation'
);
SET @aihr_pending_clarification_exists := (
SELECT COUNT(*)
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'aihr_knowledge_conversation'
AND column_name = 'pending_clarification_json'
);
SET @aihr_pending_clarification_ddl := IF(
@aihr_pending_conversation_exists = 1 AND @aihr_pending_clarification_exists = 0,
'ALTER TABLE `aihr_knowledge_conversation` ADD COLUMN `pending_clarification_json` varchar(1000) DEFAULT NULL COMMENT ''挂起的澄清'' AFTER `state_json`',
'SELECT 1'
);
PREPARE aihr_pending_clarification_stmt FROM @aihr_pending_clarification_ddl;
EXECUTE aihr_pending_clarification_stmt;
DEALLOCATE PREPARE aihr_pending_clarification_stmt;
SET @aihr_pending_conversation_exists := NULL;
SET @aihr_pending_clarification_exists := NULL;
SET @aihr_pending_clarification_ddl := NULL;