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:
@@ -310,6 +310,39 @@ def tool_parse_gge_file(*, filename: str, max_positions: int = 30) -> dict:
|
||||
return data
|
||||
|
||||
|
||||
def tool_verify_estimate_file(*, filename: str) -> dict:
|
||||
"""Детерминированная проверка загруженной .gge сметы на сходимость (fail-loud):
|
||||
существование кодов расценок, самосогласованность итогов (ФОТ=ЗПраб+ЗПмаш),
|
||||
возможные дубли. Возвращает errors/warnings с числами «ожидалось/фактически».
|
||||
Полную попозиционную арифметику даёт движок при СОСТАВЛЕНИИ сметы (материалы/
|
||||
лимитированные в .gge живут отдельно, реконструкции итога из позиций тут нет)."""
|
||||
user, tab = _user_tab()
|
||||
work_dir = _work_dir(user, tab)
|
||||
candidate = work_dir / filename
|
||||
if not candidate.exists():
|
||||
matches = list(work_dir.rglob(Path(filename).name))
|
||||
if not matches:
|
||||
return {"error": f"«{filename}» не найден в {user}/{tab}"}
|
||||
candidate = matches[0]
|
||||
if candidate.suffix.lower() != ".gge":
|
||||
return {"error": f"проверка сметы пока для .gge (получен {candidate.suffix or '?'})"}
|
||||
from gge_tools import parse_gge_file
|
||||
import estimate_verify as ev
|
||||
parsed = parse_gge_file(candidate)
|
||||
if "error" in parsed:
|
||||
return parsed
|
||||
if not parsed.get("positions"):
|
||||
return {"error": "не распознано как смета с позициями (возможно ВОР/ОСР/другая схема)"}
|
||||
r = ev.verify(ev.from_gge_parsed(parsed))
|
||||
sm = ev.verify_gge_summary(parsed.get("totals") or {})
|
||||
r["errors"].extend(sm["errors"])
|
||||
r["ok"] = not r["errors"]
|
||||
r["checked"] += sm["checked"]
|
||||
r["file"] = candidate.name
|
||||
r["positions_count"] = len(parsed["positions"])
|
||||
return r
|
||||
|
||||
|
||||
def tool_parse_gsfx_file(*, filename: str, max_positions: int = 30) -> dict:
|
||||
"""Распарсить одну .gsfx смету (ГРАНД-Смета, новый формат). filename —
|
||||
относительный путь в work_dir или внутри распакованной папки.
|
||||
@@ -581,6 +614,21 @@ TOOLS: dict[str, dict] = {
|
||||
"required": ["filename"],
|
||||
},
|
||||
},
|
||||
"verify_estimate_file": {
|
||||
"fn": tool_verify_estimate_file,
|
||||
"description": (
|
||||
"Детерминированная проверка загруженной .gge сметы на сходимость: "
|
||||
"существование кодов расценок, самосогласованность итогов, дубли. "
|
||||
"Вызывай при просьбе «проверь смету / сходится ли итог / нет ли ошибок»."
|
||||
),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"filename": {"type": "string", "description": "Имя загруженного .gge файла"},
|
||||
},
|
||||
"required": ["filename"],
|
||||
},
|
||||
},
|
||||
"parse_gsfx_file": {
|
||||
"fn": tool_parse_gsfx_file,
|
||||
"description": (
|
||||
|
||||
Reference in New Issue
Block a user