name: source-tracker
description: 來源追蹤器,使用 MCP 工具驗證題目來源真實性。Triggers: 來源追蹤, 追蹤出處, source, 出處, citation, 引用, 來源驗證.
version: 2.0.0
category: quality-control
compatibility:
- crush
- claude-code
allowed-tools:
- asset-aware__search_source_location
- asset-aware__get_section_content
- asset-aware__fetch_document_asset
- asset-aware__inspect_document_manifest
- exam-generator__exam_get_question
- exam-generator__exam_update_question
- exam-generator__exam_mark_validated
來源追蹤器 (Source Tracker)
描述
使用 MCP 工具精準追蹤和驗證題目的出處資訊:
- 驗證頁碼和行號是否真實存在
- 比對原文引用與 PDF 內容
- 標記驗證狀態
重要:本工具用於驗證已存在的題目,不用於生成題目時的來源追蹤。
觸發條件
- 「來源追蹤」「追蹤出處」
- 「source」「出處」「citation」
- 「來源驗證」「驗證來源」
🔧 驗證流程
Step 1: 取得題目資訊
question = exam-generator__exam_get_question(question_id="abc123")
source = question["source"]
Step 2: 驗證來源存在
result = asset-aware__search_source_location(
doc_id="miller9",
query=source["original_text"][:50],
block_types=["Text"]
)
if result["matches"]:
match = result["matches"][0]
if match["page"] == source["page"]:
verified = True
Step 3: 取得完整內容比對
content = asset-aware__get_section_content(
doc_id="miller9",
section_id="sec_chapter15"
)
if source["original_text"] in content:
text_verified = True
Step 4: 更新驗證狀態
exam-generator__exam_mark_validated(
question_id="abc123",
passed=True,
notes="來源已驗證:P.156 內容正確"
)
📊 來源結構
Source Entity(Domain 層定義)
@dataclass
class SourceLocation:
page: int
line_start: int
line_end: int
bbox: tuple | None
original_text: str
@dataclass
class Source:
document: str
chapter: str | None
section: str | None
stem_source: SourceLocation | None
answer_source: SourceLocation | None
explanation_sources: list[SourceLocation]
is_verified: bool = False
pdf_hash: str | None = None
📝 驗證報告輸出
📚 來源驗證報告
題目 ID: abc123
"Propofol 的主要作用機轉是?"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 驗證項目
✅ 文件存在
doc_id: miller9
title: Miller's Anesthesia 9th Ed
✅ 頁碼正確
聲明: P.156
實際: P.156
✅ 原文比對
聲明: "Propofol exerts its effects primarily..."
實際: "Propofol exerts its effects primarily through..."
匹配度: 100%
✅ 行號範圍
聲明: L.12-18
BBox: [72, 340, 520, 380]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 驗證結果: ✅ VERIFIED
已更新 exam-generator__exam_mark_validated(passed=True)
⚠️ 驗證失敗處理
❌ 來源驗證失敗
題目 ID: xyz789
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ 問題發現:
1. 頁碼不符
聲明: P.156
搜尋結果: 內容位於 P.158
2. 原文不匹配
聲明: "Propofol is water soluble..."
實際: 找不到相符內容
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 建議動作:
- [ ] 修正來源頁碼
- [ ] 重新查詢正確來源
- [ ] 標記為待人工審核
已更新 exam-generator__exam_mark_validated(passed=False, notes="...")
🔍 批次驗證
questions = exam-generator__exam_list_questions(limit=100)
results = {
"verified": [],
"failed": [],
"no_source": []
}
for q in questions:
if not q.get("source"):
results["no_source"].append(q["id"])
continue
if verified:
results["verified"].append(q["id"])
else:
results["failed"].append(q["id"])
print(f"✅ 已驗證: {len(results['verified'])}")
print(f"❌ 驗證失敗: {len(results['failed'])}")
print(f"⚠️ 無來源: {len(results['no_source'])}")