Укрепить domain-loop для длинных путей и answer inspection

This commit is contained in:
dctouch 2026-05-26 00:54:11 +03:00
parent e3e17ac7db
commit 43ae3237ce
2 changed files with 48 additions and 2 deletions

View File

@ -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)

View File

@ -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",