feat(срез 2.2): инструмент verify_estimate_file (проверь смету) + агентный путь; bump 2026-07-17e
smeta_mcp.tool_verify_estimate_file: parse .gge → estimate_verify + verify_gge_summary (ФОТ=ЗПраб+ЗПмаш, точное тождество Summary). Калибровка показала: реконструкция итога из позиций .gge невозможна (материалы отдельно) — честно проверяем коды+самосогласов.+дубли. claude_bridge: +verify_estimate_file и +find_expertise_remarks в allowedTools, mount estimate_verify.py+code_validator.py в Docker. Фикстура broken_totals.gge, 3 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Construction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LocalEstimate.xsd">
|
||||
<Estimate>
|
||||
<Num>ЛСР-99-01</Num>
|
||||
<Name>Тестовая смета (битый итог + несуществующий код)</Name>
|
||||
<EstimatePrice>
|
||||
<Summary>
|
||||
<Salary>100.00</Salary>
|
||||
<WorkersSalary>60.00</WorkersSalary>
|
||||
<MachinistSalary>30.00</MachinistSalary>
|
||||
<Total>1000.00</Total>
|
||||
</Summary>
|
||||
</EstimatePrice>
|
||||
<Item>
|
||||
<Cost>
|
||||
<Code>99-01-001-01</Code>
|
||||
<Name>Несуществующая расценка</Name>
|
||||
<Quantity>2</Quantity>
|
||||
<Unit>м3</Unit>
|
||||
<PriceTotalCur>500</PriceTotalCur>
|
||||
</Cost>
|
||||
</Item>
|
||||
</Estimate>
|
||||
</Construction>
|
||||
@@ -0,0 +1,45 @@
|
||||
"""Срез 2.2: инструмент verify_estimate_file (проверка загруженной .gge).
|
||||
|
||||
Гоняет tool_verify_estimate_file на фикстуре с несуществующим кодом (99-…) и
|
||||
рассогласованным ФОТ (Salary≠ЗПраб+ЗПмаш). SMETA_WORK_DIR указывает на fixtures.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
_FIX = Path(__file__).resolve().parent / "fixtures"
|
||||
|
||||
|
||||
def _tool():
|
||||
os.environ["SMETA_WORK_DIR"] = str(_FIX)
|
||||
import importlib
|
||||
import smeta_mcp
|
||||
importlib.reload(smeta_mcp) # чтобы _work_dir увидел SMETA_WORK_DIR
|
||||
return smeta_mcp
|
||||
|
||||
|
||||
def test_broken_gge_reports_errors():
|
||||
sm = _tool()
|
||||
r = sm.tool_verify_estimate_file(filename="broken_totals.gge")
|
||||
assert "error" not in r, r
|
||||
assert r["ok"] is False
|
||||
rules = " ".join(e["rule"] for e in r["errors"])
|
||||
assert "не существует" in rules # код 99-01-001-01
|
||||
assert "ФОТ ≠" in rules # 100 ≠ 60+30
|
||||
fot = [e for e in r["errors"] if "ФОТ ≠" in e["rule"]][0]
|
||||
assert fot["expected"] == 90.0 and fot["actual"] == 100.0
|
||||
|
||||
|
||||
def test_missing_file():
|
||||
sm = _tool()
|
||||
r = sm.tool_verify_estimate_file(filename="net_takogo.gge")
|
||||
assert "error" in r
|
||||
|
||||
|
||||
def test_non_gge_rejected():
|
||||
sm = _tool()
|
||||
(_FIX / "dummy.txt").write_text("x", encoding="utf-8")
|
||||
r = sm.tool_verify_estimate_file(filename="dummy.txt")
|
||||
assert "error" in r and ".gge" in r["error"]
|
||||
(_FIX / "dummy.txt").unlink()
|
||||
Reference in New Issue
Block a user