Require name-first extension preflight smoke

This commit is contained in:
2026-07-26 17:48:04 +03:00
parent ef2a94a3d0
commit d99d57eaf9
5 changed files with 333 additions and 5 deletions
+62 -1
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import argparse
import json
import os
import re
import sys
import tempfile
import time
@@ -15,6 +16,10 @@ ROOT = Path(__file__).resolve().parents[1]
DEFAULT_REPORTS_ROOT = ROOT / "reports" / "1c-sql"
SAVED_STATE_TABLES = {"ConfigSave", "ConfigCASSave"}
SAVED_STATE_SOURCE_BY_TARGET = {"ConfigSave": "Config", "ConfigCASSave": "ConfigCAS"}
EXTENSION_GUID_LAYER_RE = re.compile(
r"^extension:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
re.IGNORECASE,
)
def safe_path_segment(value: str) -> str:
@@ -396,7 +401,7 @@ def validate_write_preflight(
failures.append({"code": "write_preflight_not_ok", "label": label, "path": str(path), "status": report.get("status")})
if report.get("failures"):
failures.append({"code": "write_preflight_failures_present", "label": label, "path": str(path), "failures": report.get("failures")})
for check in ("method_exposed", "effective_path_preflight", "concrete_saved_state_preflight"):
for check in ("method_exposed", "effective_path_preflight", "concrete_saved_state_preflight", "name_first_extension_form_preflight"):
if check not in checks:
failures.append({"code": "write_preflight_check_missing", "label": label, "check": check, "path": str(path)})
expect_check(checks, failures, label, path, "method_exposed", {"status": "ok"}, failure_code="write_preflight_check_field_unexpected")
@@ -420,6 +425,51 @@ def validate_write_preflight(
{"schema": "onec_metadata_write_preflight.v1", "writer": "metadata.module.write_apply"},
failure_code="write_preflight_check_field_unexpected",
)
name_first_form = checks.get("name_first_extension_form_preflight") if isinstance(checks.get("name_first_extension_form_preflight"), dict) else {}
require_name_first_form = bool(
(report.get("requirements") or {}).get("name_first_extension_form")
if isinstance(report.get("requirements"), dict)
else False
)
if name_first_form.get("status") == "skipped_no_public_extension_form_target":
if require_name_first_form:
failures.append({
"code": "write_preflight_name_first_extension_form_required",
"label": label,
"path": str(path),
})
else:
expect_check(
checks,
failures,
label,
path,
"name_first_extension_form_preflight",
{
"schema": "onec_metadata_write_preflight.v1",
"plan_status": "planned",
"plan_allowed": True,
"name_first": True,
},
failure_code="write_preflight_check_field_unexpected",
)
repository_layer = str(name_first_form.get("repository_layer_id") or "")
support_layer = str(name_first_form.get("support_layer_id") or "")
if not EXTENSION_GUID_LAYER_RE.fullmatch(repository_layer):
failures.append({
"code": "write_preflight_extension_layer_unresolved",
"label": label,
"path": str(path),
"repository_layer_id": repository_layer or None,
})
if repository_layer != support_layer:
failures.append({
"code": "write_preflight_extension_layer_mismatch",
"label": label,
"path": str(path),
"repository_layer_id": repository_layer or None,
"support_layer_id": support_layer or None,
})
if require_mcp_initialize:
if "mcp.initialize" not in checks:
failures.append({"code": "write_preflight_check_missing", "label": label, "check": "mcp.initialize", "path": str(path)})
@@ -1572,6 +1622,17 @@ def write_self_test_reports(report_dir: Path, *, base_id: str, composed: bool, s
"freshness": "live_sql_verified",
"writer": "metadata.module.write_apply",
},
"name_first_extension_form_preflight": {
"schema": "onec_metadata_write_preflight.v1",
"status": "ready",
"allowed": True,
"plan_status": "planned",
"plan_allowed": True,
"repository_layer_id": "extension:11111111-1111-1111-1111-111111111111",
"support_layer_id": "extension:11111111-1111-1111-1111-111111111111",
"name_first": True,
"extension": "test2",
},
},
"failures": [],
}