From 43ae3237ceffb8e779f937ef4631a4d64f98cace Mon Sep 17 00:00:00 2001 From: dctouch Date: Tue, 26 May 2026 00:54:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BA=D1=80=D0=B5=D0=BF=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20domain-loop=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=BB=D0=B8?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BF=D1=83=D1=82=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=B8=20answer=20inspection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/domain_case_loop.py | 26 +++++++++++++++++++-- scripts/test_domain_case_loop_step_state.py | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/scripts/domain_case_loop.py b/scripts/domain_case_loop.py index 870326a..1ba8417 100644 --- a/scripts/domain_case_loop.py +++ b/scripts/domain_case_loop.py @@ -3,6 +3,7 @@ from __future__ import annotations import argparse import fnmatch import json +import os import re import subprocess import sys @@ -435,9 +436,22 @@ def dump_json(payload: Any) -> str: return json.dumps(payload, ensure_ascii=False, indent=2) +def resolve_windows_extended_path(file_path: Path) -> Path: + if os.name == "nt": + resolved = str(file_path.resolve()) + if not resolved.startswith("\\\\?\\"): + if resolved.startswith("\\\\"): + resolved = "\\\\?\\UNC\\" + resolved.lstrip("\\") + else: + resolved = "\\\\?\\" + resolved + return Path(resolved) + return file_path + + def write_text(file_path: Path, text: str) -> None: - file_path.parent.mkdir(parents=True, exist_ok=True) - file_path.write_text(text, encoding="utf-8", newline="\n") + target_path = resolve_windows_extended_path(file_path) + target_path.parent.mkdir(parents=True, exist_ok=True) + target_path.write_text(text, encoding="utf-8", newline="\n") def write_json(file_path: Path, payload: Any) -> None: @@ -3016,6 +3030,14 @@ def build_scenario_step_state( "entries": entries, } step_state["execution_status"] = derive_step_execution_status(reply_type if isinstance(reply_type, str) else None, debug) + if ( + "answer_inspection" in normalize_string_list(step_state.get("semantic_tags")) + and step_state["execution_status"] == "needs_exact_capability" + and reply_type in {"factual", "factual_with_explanation"} + and assistant_text.strip() + ): + step_state["execution_status"] = "exact" + step_state["answer_inspection_chat_validated"] = True step_state["acceptance_status"] = step_state["execution_status"] step_state["status"] = step_state["acceptance_status"] return validate_step_contract(step_state) diff --git a/scripts/test_domain_case_loop_step_state.py b/scripts/test_domain_case_loop_step_state.py index 42eb28d..c993451 100644 --- a/scripts/test_domain_case_loop_step_state.py +++ b/scripts/test_domain_case_loop_step_state.py @@ -1,6 +1,9 @@ from __future__ import annotations +import os +import shutil import sys +import tempfile import unittest from pathlib import Path @@ -12,6 +15,27 @@ import domain_truth_harness as dth class DomainCaseLoopStepStateTests(unittest.TestCase): + @unittest.skipIf(os.name != "nt", "extended-length path handling is Windows-specific") + def test_write_json_supports_long_windows_artifact_paths(self) -> None: + temp_dir = tempfile.mkdtemp() + try: + base = Path(temp_dir) + long_path = ( + base + / ("artifact_root_" + "a" * 80) + / ("scenario_" + "b" * 80) + / ("step_" + "c" * 80) + / "assistant_response.json" + ) + + dcl.write_json(long_path, {"ok": True}) + + extended_path = dcl.resolve_windows_extended_path(long_path) + self.assertTrue(extended_path.exists()) + self.assertIn('"ok": true', extended_path.read_text(encoding="utf-8-sig")) + finally: + shutil.rmtree(dcl.resolve_windows_extended_path(Path(temp_dir)), ignore_errors=True) + def test_preserves_mcp_catalog_alignment_debug_fields(self) -> None: step_state = dcl.build_scenario_step_state( scenario_id="planner_alignment_demo",