Delegate wearer boundary semantics to review

This commit is contained in:
Xin Wang
2026-09-15 02:12:18 +08:00
parent 71dfd8808a
commit 3a127a3f9f
12 changed files with 596 additions and 404 deletions

View File

@@ -8,7 +8,8 @@ import json
import tempfile
from adjudicate_easycom_eot_int_candidates import (
PROMPT_VERSION, SYSTEM_PROMPT, _progress_line, _transport_rows, build_user_prompt, read_candidates,
PROMPT_VERSION, SYSTEM_PROMPT, _progress_line, _transport_rows, build_user_prompt,
exclude_reason_group, read_candidates,
requires_semantic_adjudication, validate_decisions,
)
@@ -32,9 +33,10 @@ class EntryINTAdjudicationTests(unittest.TestCase):
self.assertIn("Yes.", prompt)
def test_system_prompt_treats_laughter_as_nonlexical_floor_feedback(self) -> None:
self.assertEqual(PROMPT_VERSION, "easycom-wearer-entry-int-prelabel-v12")
self.assertEqual(PROMPT_VERSION, "easycom-wearer-boundary-semantic-prelabel-v14")
self.assertIn("opportunity_options", SYSTEM_PROMPT)
self.assertIn("t_w < t_o < t_y", SYSTEM_PROMPT)
self.assertIn("t_w < t_o < t_y never proves takeover", SYSTEM_PROMPT)
self.assertIn("Every supplied WEARER_ONSET and WEARER_OFFSET is a raw observed", SYSTEM_PROMPT)
self.assertIn("a transcription consisting of [L] denotes laughter-only vocalization", SYSTEM_PROMPT)
self.assertIn("ENTRY_WEARER_BACKCHANNEL", SYSTEM_PROMPT)
self.assertIn("INT_OTHER_BACKCHANNEL", SYSTEM_PROMPT)
@@ -45,11 +47,13 @@ class EntryINTAdjudicationTests(unittest.TestCase):
self.assertIn('"Nope." beginning 0.15 s after an addressed question ends', SYSTEM_PROMPT)
self.assertIn("does not require a preceding non-wearer release", SYSTEM_PROMPT)
self.assertIn("duration alone never determines floor function", SYSTEM_PROMPT)
self.assertIn("out-of-scope normal completion", SYSTEM_PROMPT)
self.assertIn("same incoming non-wearer actually takes", SYSTEM_PROMPT)
self.assertIn("normal wearer completion", SYSTEM_PROMPT)
self.assertIn("relevant non-wearer actually takes", SYSTEM_PROMPT)
self.assertIn("must not retroactively invalidate the preceding INT_YIELD", SYSTEM_PROMPT)
self.assertIn("do not infer that a visible smile occurred", SYSTEM_PROMPT)
self.assertIn("POSITIVE / INT_YIELD: subtype=null; selected_opportunity_uid=null", SYSTEM_PROMPT)
self.assertIn("POSITIVE / INT_YIELD: subtype=null; exclude_reason=null", SYSTEM_PROMPT)
self.assertIn("OUT_OF_SCOPE_WITHIN_TURN_CONTINUATION", SYSTEM_PROMPT)
self.assertIn("DATA_TIMESTAMP_CORRUPTION", SYSTEM_PROMPT)
self.assertNotIn("NOT_APPLICABLE", SYSTEM_PROMPT)
self.assertNotIn("UNSURE", SYSTEM_PROMPT)
self.assertNotIn('"needs_human_review"', SYSTEM_PROMPT)
@@ -78,7 +82,8 @@ class EntryINTAdjudicationTests(unittest.TestCase):
payload = {
"items": [{
"uid": "u1", "verdict": "EXCLUDE", "event_type": None,
"subtype": None, "confidence": 0.4, "reason": "Ambiguous context.",
"subtype": None, "exclude_reason": "INSUFFICIENT_EVIDENCE",
"confidence": 0.4, "reason": "Ambiguous context.",
"needs_human_review": "true",
}]
}
@@ -128,6 +133,9 @@ class EntryINTAdjudicationTests(unittest.TestCase):
"verdict": verdict,
"event_type": event_type,
"subtype": subtype,
"exclude_reason": (
"INSUFFICIENT_EVIDENCE" if verdict == "EXCLUDE" else None
),
"selected_opportunity_uid": "copied-release",
"confidence": 0.8,
"reason": "Evidence-based decision.",
@@ -139,6 +147,28 @@ class EntryINTAdjudicationTests(unittest.TestCase):
)[0]
self.assertIsNone(decision["selected_opportunity_uid"])
def test_exclude_reason_taxonomy_separates_scope_evidence_and_data(self) -> None:
self.assertEqual(
exclude_reason_group("OUT_OF_SCOPE_NORMAL_COMPLETION"), "OUT_OF_SCOPE"
)
self.assertEqual(
exclude_reason_group("INSUFFICIENT_EVIDENCE"), "INSUFFICIENT_EVIDENCE"
)
self.assertEqual(
exclude_reason_group("DATA_ANNOTATION_ERROR"), "DATA_QUALITY"
)
base = {
"uid": "u1", "verdict": "EXCLUDE", "event_type": None,
"subtype": None, "selected_opportunity_uid": None,
"confidence": 0.4, "reason": "Not a scored event.",
}
with self.assertRaisesRegex(ValueError, "valid exclude_reason"):
validate_decisions({"items": [base]}, ["u1"])
with self.assertRaisesRegex(ValueError, "valid exclude_reason"):
validate_decisions(
{"items": [{**base, "exclude_reason": "ANNOTATION_ERROR"}]}, ["u1"]
)
def test_event_and_hard_negative_subtypes_match_candidate_family(self) -> None:
positive = {
"uid": "u1", "verdict": "POSITIVE", "event_type": "INT_YIELD",
@@ -195,7 +225,7 @@ class EntryINTAdjudicationTests(unittest.TestCase):
self.assertEqual([row["uid"] for row in transported], ["item-0000", "item-0001"])
self.assertEqual(mapping["item-0001"], rows[1]["uid"])
def test_old_nonoverlap_wearer_offset_is_not_sent_for_adjudication(self) -> None:
def test_every_current_wearer_offset_is_sent_for_adjudication(self) -> None:
control = {
"candidate_source": "WEARER_OFFSET",
"temporal_evidence": {
@@ -217,9 +247,9 @@ class EntryINTAdjudicationTests(unittest.TestCase):
"active_other_ids_after_offset": [4],
},
}
self.assertFalse(requires_semantic_adjudication(control))
self.assertTrue(requires_semantic_adjudication(control))
self.assertTrue(requires_semantic_adjudication(crossing))
self.assertFalse(requires_semantic_adjudication(speaker_change))
self.assertTrue(requires_semantic_adjudication(speaker_change))
self.assertFalse(requires_semantic_adjudication({"candidate_source": "WEARER_OFFSET_CONTROL"}))
self.assertFalse(requires_semantic_adjudication({"candidate_source": "WEARER_ONSET_CONTROL"}))
self.assertFalse(requires_semantic_adjudication({"candidate_source": "WEARER_RESUME"}))