From 6c2e9d404b5d11e2dcd2cc680e3eb498ae1d047d Mon Sep 17 00:00:00 2001 From: DavidHLP Date: Sun, 11 Oct 2026 08:12:01 -0700 Subject: [PATCH 1/3] test: cover equivalent array range adjective definitions --- services/agent/tests/test_boundary_evaluation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/agent/tests/test_boundary_evaluation.py b/services/agent/tests/test_boundary_evaluation.py index 6272d78d8..dc22a8d11 100644 --- a/services/agent/tests/test_boundary_evaluation.py +++ b/services/agent/tests/test_boundary_evaluation.py @@ -1001,6 +1001,8 @@ def test_case_records_provider_response_identity_unknown_when_absent() -> None: "数组越界指下标不在数组的有效范围内。", "Array out of bounds means an index outside the array's valid range.", "数组越界指访问超出数组长度的索引。", + "数组越界是访问数组时使用超出有效索引范围的下标。", + "数组越界指访问超过其合法下标范围的索引。", ]) def test_no_tool_equivalent_range_definitions(text): script = _all_met_script() @@ -1017,6 +1019,9 @@ def test_no_tool_equivalent_range_definitions(text): "数组是一种结构。索引超出有效范围。", "数组越界不是指访问超出该数组有效下标范围。", "数组越界不意味着索引超出有效范围。", + "数组越界不是指访问数组时使用超出有效索引范围的下标。", + "数组越界是不意味着访问超过其合法下标范围的索引。", + "访问数组时使用超出有效索引范围的下标是合法操作。", ]) def test_no_tool_rejects_wrong_denied_and_unrelated_definitions(text): script = _all_met_script() From b2c30d680b764c7ddebb20598f546204bdf70c51 Mon Sep 17 00:00:00 2001 From: DavidHLP Date: Sun, 11 Oct 2026 08:17:34 -0700 Subject: [PATCH 2/3] fix: recognize equivalent array range adjective definitions --- services/agent/src/boundary_evaluation.py | 1 + services/agent/tests/test_boundary_evaluation.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/agent/src/boundary_evaluation.py b/services/agent/src/boundary_evaluation.py index 2402d6f45..195c5d2e8 100644 --- a/services/agent/src/boundary_evaluation.py +++ b/services/agent/src/boundary_evaluation.py @@ -1005,6 +1005,7 @@ def _array_range_definition(text: str) -> bool: """ lowered = text.casefold() patterns = ( + r"(?:超出|超过)(?:了)?(?:数组(?:的)?|其)?(?:有效|合法)(?:索引|下标)?范围的(?:索引|下标)", r"(?:索引|下标)(?:落在)?(?:超出|超过|不在)[^。;;!??]{0,16}(?:有效|合法)[^。;;!??]{0,8}范围(?:内)?", r"(?:索引|下标)落在(?:有效|合法)范围(?:之外|以外)", r"(?:访问)?(?:超出|超过)[^。;;!??]{0,12}数组(?:的)?(?:有效|合法)?(?:索引|下标)?(?:范围|边界|长度)", diff --git a/services/agent/tests/test_boundary_evaluation.py b/services/agent/tests/test_boundary_evaluation.py index dc22a8d11..8d637306f 100644 --- a/services/agent/tests/test_boundary_evaluation.py +++ b/services/agent/tests/test_boundary_evaluation.py @@ -1020,7 +1020,7 @@ def test_no_tool_equivalent_range_definitions(text): "数组越界不是指访问超出该数组有效下标范围。", "数组越界不意味着索引超出有效范围。", "数组越界不是指访问数组时使用超出有效索引范围的下标。", - "数组越界是不意味着访问超过其合法下标范围的索引。", + "数组越界不意味着访问超过其合法下标范围的索引。", "访问数组时使用超出有效索引范围的下标是合法操作。", ]) def test_no_tool_rejects_wrong_denied_and_unrelated_definitions(text): From 129cec10fc67a70ca563251cb77410e71321ccfd Mon Sep 17 00:00:00 2001 From: DavidHLP Date: Sun, 11 Oct 2026 08:19:27 -0700 Subject: [PATCH 3/3] fix: preserve negation adjacency in array range grammar --- services/agent/src/boundary_evaluation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/agent/src/boundary_evaluation.py b/services/agent/src/boundary_evaluation.py index 195c5d2e8..acceecf7e 100644 --- a/services/agent/src/boundary_evaluation.py +++ b/services/agent/src/boundary_evaluation.py @@ -1005,7 +1005,7 @@ def _array_range_definition(text: str) -> bool: """ lowered = text.casefold() patterns = ( - r"(?:超出|超过)(?:了)?(?:数组(?:的)?|其)?(?:有效|合法)(?:索引|下标)?范围的(?:索引|下标)", + r"(?:访问数组时(?:使用)?|访问)?(?:超出|超过)(?:了)?(?:数组(?:的)?|其)?(?:有效|合法)(?:索引|下标)?范围的(?:索引|下标)", r"(?:索引|下标)(?:落在)?(?:超出|超过|不在)[^。;;!??]{0,16}(?:有效|合法)[^。;;!??]{0,8}范围(?:内)?", r"(?:索引|下标)落在(?:有效|合法)范围(?:之外|以外)", r"(?:访问)?(?:超出|超过)[^。;;!??]{0,12}数组(?:的)?(?:有效|合法)?(?:索引|下标)?(?:范围|边界|长度)",