feat(detector): 扩展空字段检测到 L2 event_description / L1 scene_summary

断点续跑判据需要 L2/L1 层的 empty_field 检测。零 LLM 成本。
This commit is contained in:
2026-07-09 00:12:55 -04:00
parent f733c13dd1
commit 8182cb86b1
2 changed files with 75 additions and 1 deletions
+51 -1
View File
@@ -14,7 +14,7 @@ from app.tree.index import (
L3Node,
TreeIndex,
)
from app.tree.repair.detector import detect_issues
from app.tree.repair.detector import NodeIssue, detect_issues
if TYPE_CHECKING:
from pathlib import Path
@@ -185,3 +185,53 @@ class TestDetectIssues:
index = TreeIndex(metadata=IndexMeta("/t.mp4", "video"), roots=[l1])
issues = detect_issues(index)
assert any(i.issue_type == "time_gap" for i in issues)
def test_detects_l2_empty_event_description(self) -> None:
"""L2 event_description 为空应报 empty_field。"""
l3 = L3Node(
id="l1_0_l2_0_l3_0",
card=L3Card("正常帧", ["实体"], ["动作"], [], "居中", {}),
timestamp=1.0,
)
l2 = L2Node(
id="l1_0_l2_0",
card=L2Card("", [], [], [], [], "", None),
time_range=(0.0, 10.0),
children=[l3],
)
l1 = L1Node(
id="l1_0",
card=L1Card("正常场景", "", [], [], [], [], ""),
time_range=(0.0, 10.0),
children=[l2],
)
index = TreeIndex(metadata=IndexMeta("/t.mp4", "video"), roots=[l1])
issues = detect_issues(index)
l2_empties = [i for i in issues if i.level == 2 and i.issue_type == "empty_field"]
assert len(l2_empties) == 1
assert "event_description" in l2_empties[0].details
def test_detects_l1_empty_scene_summary(self) -> None:
"""L1 scene_summary 为空应报 empty_field。"""
l3 = L3Node(
id="l1_0_l2_0_l3_0",
card=L3Card("正常帧", ["实体"], ["动作"], [], "居中", {}),
timestamp=1.0,
)
l2 = L2Node(
id="l1_0_l2_0",
card=L2Card("正常事件", [], [], [], [], "", None),
time_range=(0.0, 10.0),
children=[l3],
)
l1 = L1Node(
id="l1_0",
card=L1Card("", "", [], [], [], [], ""),
time_range=(0.0, 10.0),
children=[l2],
)
index = TreeIndex(metadata=IndexMeta("/t.mp4", "video"), roots=[l1])
issues = detect_issues(index)
l1_empties = [i for i in issues if i.level == 1 and i.issue_type == "empty_field"]
assert len(l1_empties) == 1
assert "scene_summary" in l1_empties[0].details