intentumdiff-python 0.0.2b2__py3-none-win_amd64.whl → 0.0.3b1__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- intentumdiff/__init__.py +7 -0
- intentumdiff/_differ_gate.py +0 -136
- intentumdiff/_differ_presentation.py +1 -72
- intentumdiff/_differ_runtime.py +0 -17
- intentumdiff/analysis/cross_file.py +21 -21
- intentumdiff/analysis/diagnostics.py +1 -164
- intentumdiff/analysis/guardrail_reports.py +24 -28
- intentumdiff/analysis/guardrails.py +2 -67
- intentumdiff/analysis/schema_resolver.py +23 -87
- intentumdiff/analysis/user_schemas.py +2 -17
- intentumdiff/cli/_commands.py +70 -71
- intentumdiff/cli/_parser.py +40 -55
- intentumdiff/cli/_shared.py +55 -4
- intentumdiff/core/commit_differ.py +65 -99
- intentumdiff/core/indexer.py +0 -1
- intentumdiff/core/models.py +226 -69
- intentumdiff/differ.py +125 -432
- intentumdiff/github_app.py +5 -8
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +17 -17
- intentumdiff/lsp/client.py +42 -42
- intentumdiff/lsp/servers.py +10 -11
- intentumdiff/lsp_server/_handlers.py +1 -1
- intentumdiff/lsp_server/server.py +0 -1
- intentumdiff/plugins/exceptions.py +24 -0
- intentumdiff/plugins/hub.py +38 -41
- intentumdiff/plugins/registry.py +10 -10
- intentumdiff/plugins/registry.schema.json +156 -15
- intentumdiff/plugins/registry_schema.py +47 -140
- intentumdiff/rust_core.py +112 -775
- intentumdiff/serve/_app.py +23 -25
- intentumdiff/sources/git_source.py +0 -183
- intentumdiff/vcs/git_cli.py +0 -47
- intentumdiff/wasm/abap_parser.wasm +0 -0
- intentumdiff/wasm/adf_parser.wasm +0 -0
- intentumdiff/wasm/asciidoc_parser.wasm +0 -0
- intentumdiff/wasm/asm_parser.wasm +0 -0
- intentumdiff/wasm/assemblyscript_parser.wasm +0 -0
- intentumdiff/wasm/astro_parser.wasm +0 -0
- intentumdiff/wasm/bash_parser.wasm +0 -0
- intentumdiff/wasm/cpp_parser.wasm +0 -0
- intentumdiff/wasm/csharp_parser.wasm +0 -0
- intentumdiff/wasm/databricks_parser.wasm +0 -0
- intentumdiff/wasm/dax_parser.wasm +0 -0
- intentumdiff/wasm/dockerfile_parser.wasm +0 -0
- intentumdiff/wasm/freebasic_parser.wasm +0 -0
- intentumdiff/wasm/generic_parser.wasm +0 -0
- intentumdiff/wasm/gitignore_parser.wasm +0 -0
- intentumdiff/wasm/graphql_parser.wasm +0 -0
- intentumdiff/wasm/groovy_parser.wasm +0 -0
- intentumdiff/wasm/js_ts_parser.wasm +0 -0
- intentumdiff/wasm/json_parser.wasm +0 -0
- intentumdiff/wasm/kotlin_parser.wasm +0 -0
- intentumdiff/wasm/latex_parser.wasm +0 -0
- intentumdiff/wasm/make_parser.wasm +0 -0
- intentumdiff/wasm/mdx_parser.wasm +0 -0
- intentumdiff/wasm/ocaml_parser.wasm +0 -0
- intentumdiff/wasm/odin_parser.wasm +0 -0
- intentumdiff/wasm/perl_parser.wasm +0 -0
- intentumdiff/wasm/php_parser.wasm +0 -0
- intentumdiff/wasm/plsql_parser.wasm +0 -0
- intentumdiff/wasm/postscript_parser.wasm +0 -0
- intentumdiff/wasm/powershell_parser.wasm +0 -0
- intentumdiff/wasm/python_parser.wasm +0 -0
- intentumdiff/wasm/qsharp_parser.wasm +0 -0
- intentumdiff/wasm/reasonml_parser.wasm +0 -0
- intentumdiff/wasm/rust_parser.wasm +0 -0
- intentumdiff/wasm/sas_parser.wasm +0 -0
- intentumdiff/wasm/sql_parser.wasm +0 -0
- intentumdiff/wasm/svelte_parser.wasm +0 -0
- intentumdiff/wasm/swift_parser.wasm +0 -0
- intentumdiff/wasm/tsql_parser.wasm +0 -0
- intentumdiff/wasm/vbnet_parser.wasm +0 -0
- intentumdiff/wasm/vue_parser.wasm +0 -0
- intentumdiff/wasm/wasm_provenance.json +219 -219
- intentumdiff/wasm/wat_parser.wasm +0 -0
- intentumdiff/wasm/yaml_parser.wasm +0 -0
- intentumdiff/watcher.py +15 -17
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/METADATA +38 -6
- intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +2 -2
- intentumdiff/analysis/invariances.py +0 -208
- intentumdiff/analysis/keyed_profiles.py +0 -25
- intentumdiff/analysis/resource_profiles.py +0 -14
- intentumdiff/analysis/text_review.py +0 -47
- intentumdiff/invariances/__init__.py +0 -2
- intentumdiff/invariances/rules.schema.json +0 -283
- intentumdiff/invariances/rules.yaml +0 -349
- intentumdiff_python-0.0.2b2.dist-info/RECORD +0 -171
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +0 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/licenses/LICENSE +0 -0
intentumdiff/rust_core.py
CHANGED
|
@@ -6,18 +6,17 @@ shared decisions belong to Rust, never a Python fallback correctness engine.
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
-
import importlib
|
|
10
9
|
import json
|
|
11
10
|
import logging
|
|
12
11
|
import os
|
|
13
12
|
import time
|
|
14
13
|
from dataclasses import dataclass, field
|
|
15
|
-
from pathlib import Path
|
|
16
14
|
from typing import Any
|
|
17
15
|
|
|
18
16
|
from pydantic import ValidationError
|
|
19
17
|
|
|
20
18
|
from intentumdiff.core.models import (
|
|
19
|
+
FUEL_UNLIMITED,
|
|
21
20
|
Change,
|
|
22
21
|
ChangeGroup,
|
|
23
22
|
ChangeType,
|
|
@@ -30,64 +29,6 @@ logger = logging.getLogger(__name__)
|
|
|
30
29
|
|
|
31
30
|
_COMPLETE_STATUS = "complete"
|
|
32
31
|
_BATCH_ENGINE = "rust_core_batch_v4"
|
|
33
|
-
_PYTHON_NATIVE_CERTIFICATION = "python_native_v4kb"
|
|
34
|
-
_CANONICAL_PYTHON_PLUGIN_ID = "intentumdiff:python:python"
|
|
35
|
-
_PYTHON_PLUGIN_IDS = frozenset(
|
|
36
|
-
{
|
|
37
|
-
"",
|
|
38
|
-
"python",
|
|
39
|
-
"python-parser",
|
|
40
|
-
"python_parser",
|
|
41
|
-
_CANONICAL_PYTHON_PLUGIN_ID,
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
#: Distributions that ship the FIRST-PARTY Python parser. The plugin id is qualified by the
|
|
45
|
-
#: distribution name, and this package is published as ``intentumdiff-python`` while the import
|
|
46
|
-
#: package is ``intentumdiff`` — so the same certified parser is spelled two ways depending on
|
|
47
|
-
#: how it was catalogued. Deliberately an allowlist, not a prefix match: canonicalising an
|
|
48
|
-
#: arbitrary ``<dist>:python:python`` would let a third-party plugin claim the certified path.
|
|
49
|
-
_PYTHON_PLUGIN_DISTRIBUTIONS = frozenset(
|
|
50
|
-
{"intentumdiff", "intentumdiff-python", "intentumdiff_python"}
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def _canonical_python_plugin_id(parser_plugin_id: str | None) -> str | None:
|
|
55
|
-
"""Normalise a first-party Python parser id to the certified spelling.
|
|
56
|
-
|
|
57
|
-
This was a no-op returning its argument, which meant the certified batch path rejected
|
|
58
|
-
the parser as an "unsupported parser plugin" and silently fell through to routed
|
|
59
|
-
finalize. The diff was still correct and still Rust — so no gate fired and nothing looked
|
|
60
|
-
broken — but the certified path was never taken, and the facts that only it derives went
|
|
61
|
-
missing.
|
|
62
|
-
|
|
63
|
-
Invisible until parser plugins could be catalogued at all: before that the id was absent
|
|
64
|
-
and the ``is not None`` guard let everything through.
|
|
65
|
-
"""
|
|
66
|
-
if not parser_plugin_id:
|
|
67
|
-
return parser_plugin_id
|
|
68
|
-
parts = parser_plugin_id.split(":")
|
|
69
|
-
if (
|
|
70
|
-
len(parts) == 3
|
|
71
|
-
and parts[0] in _PYTHON_PLUGIN_DISTRIBUTIONS
|
|
72
|
-
and parts[1] == "python"
|
|
73
|
-
and parts[2] == "python"
|
|
74
|
-
):
|
|
75
|
-
return _CANONICAL_PYTHON_PLUGIN_ID
|
|
76
|
-
return parser_plugin_id
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def _canonicalize_file_plugin_ids(files: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|
80
|
-
normalized: list[dict[str, Any]] = []
|
|
81
|
-
for file in files:
|
|
82
|
-
item = dict(file)
|
|
83
|
-
if "parser_plugin_id" in item:
|
|
84
|
-
item["parser_plugin_id"] = _canonical_python_plugin_id(item["parser_plugin_id"])
|
|
85
|
-
if "parserPluginId" in item:
|
|
86
|
-
item["parserPluginId"] = _canonical_python_plugin_id(item["parserPluginId"])
|
|
87
|
-
normalized.append(item)
|
|
88
|
-
return normalized
|
|
89
|
-
|
|
90
|
-
|
|
91
32
|
@dataclass(frozen=True)
|
|
92
33
|
class RustCoreBatchAttempt:
|
|
93
34
|
diff: SemanticDiff | None = None
|
|
@@ -115,47 +56,6 @@ class RustCoreBatchDiffsAttempt:
|
|
|
115
56
|
return bool(self.diffs)
|
|
116
57
|
|
|
117
58
|
|
|
118
|
-
@dataclass(frozen=True)
|
|
119
|
-
class RustCoreCandidateBatchAttempt:
|
|
120
|
-
payload: dict[str, Any] | None = None
|
|
121
|
-
fallback_reason: str = ""
|
|
122
|
-
backend_version: str = ""
|
|
123
|
-
|
|
124
|
-
@property
|
|
125
|
-
def used(self) -> bool:
|
|
126
|
-
return self.payload is not None
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
@dataclass(frozen=True)
|
|
130
|
-
class RustCoreCommitJsonAttempt:
|
|
131
|
-
control: dict[str, Any] = field(default_factory=dict)
|
|
132
|
-
commit_diff_json: bytes = b""
|
|
133
|
-
adapter_phase_timings: list[dict[str, Any]] = field(default_factory=list)
|
|
134
|
-
backend_version: str = ""
|
|
135
|
-
fallback_reason: str = ""
|
|
136
|
-
|
|
137
|
-
@property
|
|
138
|
-
def used(self) -> bool:
|
|
139
|
-
return bool(self.commit_diff_json)
|
|
140
|
-
|
|
141
|
-
def to_model(self) -> Any:
|
|
142
|
-
"""Lazily validate the certified JSON into the public CommitDiff model."""
|
|
143
|
-
from intentumdiff.core.models import CommitDiff
|
|
144
|
-
|
|
145
|
-
return CommitDiff.model_validate_json(self.commit_diff_json)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
@dataclass(frozen=True)
|
|
149
|
-
class RustInvarianceResult:
|
|
150
|
-
changes: list[Change]
|
|
151
|
-
change_groups: list[ChangeGroup] = field(default_factory=list)
|
|
152
|
-
ignored_style_changes: list[dict[str, Any]] = field(default_factory=list)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def rust_core_enabled(config: DiffConfig) -> bool:
|
|
156
|
-
return bool(config.experimental_rust_core)
|
|
157
|
-
|
|
158
|
-
|
|
159
59
|
def _pyo3_extension_module_name() -> str | None:
|
|
160
60
|
"""Return the importable name of the compiled PyO3 extension, or ``None``.
|
|
161
61
|
|
|
@@ -287,12 +187,23 @@ class _NativeCAbiInternalError(RuntimeError, _NativeCAbiOperationFailure):
|
|
|
287
187
|
"""Native internal/panic error with its existing RuntimeError contract."""
|
|
288
188
|
|
|
289
189
|
|
|
190
|
+
class CoreSizeLimitError(_NativeCAbiValueError):
|
|
191
|
+
"""Core refused an input, tree or parser output over a configured byte limit.
|
|
192
|
+
|
|
193
|
+
Core reports these as ``error_type: "size_limit"`` and its message names the diff-config
|
|
194
|
+
setting that raises the limit (``max_cst_bytes`` / ``max_plugin_output_bytes``). It
|
|
195
|
+
subclasses the ``ValueError`` these errors raised before core #308, so existing
|
|
196
|
+
``except ValueError`` callers keep working.
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
|
|
290
200
|
def _c_abi_call(name: str, *args: Any) -> Any:
|
|
291
201
|
"""Invoke a C-ABI handler by name; return its ``result`` or re-raise the classified error.
|
|
292
202
|
|
|
293
203
|
`error_type` maps to the exception the PyO3 wrappers raised: ``not_found`` →
|
|
294
|
-
``FileNotFoundError`` (the git readers' only non-``ValueError``),
|
|
295
|
-
``ValueError
|
|
204
|
+
``FileNotFoundError`` (the git readers' only non-``ValueError``), ``size_limit`` →
|
|
205
|
+
``CoreSizeLimitError`` (a ``ValueError``), everything else → ``ValueError``. Panics
|
|
206
|
+
surface as ``RuntimeError``.
|
|
296
207
|
"""
|
|
297
208
|
import ctypes # noqa: PLC0415
|
|
298
209
|
|
|
@@ -335,7 +246,7 @@ def _c_abi_call(name: str, *args: Any) -> Any:
|
|
|
335
246
|
message = envelope.get("error")
|
|
336
247
|
kind = envelope.get("error_type")
|
|
337
248
|
if not isinstance(message, str) or not isinstance(kind, str) or kind not in (
|
|
338
|
-
"not_found", "internal", "value_error", "bad_request"
|
|
249
|
+
"not_found", "internal", "value_error", "bad_request", "size_limit"
|
|
339
250
|
):
|
|
340
251
|
raise _InvalidNativeCAbiEnvelope(
|
|
341
252
|
f"invalid C ABI envelope for {name!r}: malformed error fields"
|
|
@@ -344,6 +255,8 @@ def _c_abi_call(name: str, *args: Any) -> Any:
|
|
|
344
255
|
raise _NativeCAbiNotFoundError(message)
|
|
345
256
|
if kind == "internal":
|
|
346
257
|
raise _NativeCAbiInternalError(message)
|
|
258
|
+
if kind == "size_limit":
|
|
259
|
+
raise CoreSizeLimitError(message)
|
|
347
260
|
raise _NativeCAbiValueError(message)
|
|
348
261
|
|
|
349
262
|
|
|
@@ -354,9 +267,7 @@ class _CtypesBackend:
|
|
|
354
267
|
stateless pyfunction surface.
|
|
355
268
|
|
|
356
269
|
Naming: the C-ABI handler names dropped the Python-transport ``_json`` suffix (``finalize_review``
|
|
357
|
-
for the pyfunction ``finalize_review_json``), so a trailing ``_json`` is stripped
|
|
358
|
-
commit handlers, which keep the suffix AND return the ``(control_json, commit_bytes)`` binary tuple
|
|
359
|
-
the callers expect (the C ABI marshals it as a ``{control, commit_diff_json}`` envelope).
|
|
270
|
+
for the pyfunction ``finalize_review_json``), so a trailing ``_json`` is stripped.
|
|
360
271
|
|
|
361
272
|
Result encoding: ``_c_abi_call`` returns the *parsed* ``result``. The PyO3 pyfunctions were
|
|
362
273
|
heterogeneous — some returned native values used directly (``supports_language`` -> bool,
|
|
@@ -366,7 +277,6 @@ class _CtypesBackend:
|
|
|
366
277
|
with ``json.dumps`` so the caller's parse still works. ``_RAW_HANDLERS`` is the (small) native set.
|
|
367
278
|
"""
|
|
368
279
|
|
|
369
|
-
_COMMIT_TUPLE = frozenset({"diff_batch_commit_json", "diff_working_tree_python_commit_json"})
|
|
370
280
|
_RAW_HANDLERS = frozenset({
|
|
371
281
|
"version",
|
|
372
282
|
"supports_language",
|
|
@@ -385,31 +295,6 @@ class _CtypesBackend:
|
|
|
385
295
|
def __getattr__(self, name: str) -> Any:
|
|
386
296
|
if name.startswith("__"):
|
|
387
297
|
raise AttributeError(name)
|
|
388
|
-
if name in self._COMMIT_TUPLE:
|
|
389
|
-
def _commit(request_json: str, _name: str = name) -> tuple[str, bytes | None]:
|
|
390
|
-
envelope = _c_abi_call(_name, request_json)
|
|
391
|
-
# A malformed claimed-success C ABI result must not raise a
|
|
392
|
-
# generic AttributeError here: the commit adapters would treat
|
|
393
|
-
# it as a normal backend failure and silently reroute (#207).
|
|
394
|
-
# Check transport types before encoding; Rust owns the control
|
|
395
|
-
# status and CommitDiff semantics, which the callers validate.
|
|
396
|
-
if not isinstance(envelope, dict) or not isinstance(
|
|
397
|
-
envelope.get("control"), dict
|
|
398
|
-
):
|
|
399
|
-
raise _InvalidNativeCommitDto(
|
|
400
|
-
f"Rust {_name} returned malformed C ABI commit envelope"
|
|
401
|
-
)
|
|
402
|
-
payload = envelope.get("commit_diff_json")
|
|
403
|
-
if payload is not None and not isinstance(payload, str):
|
|
404
|
-
raise _InvalidNativeCommitDto(
|
|
405
|
-
f"Rust {_name} returned non-string commit_diff_json in C ABI envelope"
|
|
406
|
-
)
|
|
407
|
-
return (
|
|
408
|
-
json.dumps(envelope["control"]),
|
|
409
|
-
payload.encode("utf-8") if payload is not None else None,
|
|
410
|
-
)
|
|
411
|
-
|
|
412
|
-
return _commit
|
|
413
298
|
handler = name[:-5] if name.endswith("_json") else name
|
|
414
299
|
if handler == "vcs_backend_get_blob":
|
|
415
300
|
# The C ABI wraps blob content in {"content": …} so JSON-valued content is not
|
|
@@ -460,218 +345,6 @@ def enrich_node_facts(tree: SemanticNode) -> SemanticNode:
|
|
|
460
345
|
raise RuntimeError(f"Rust node facts enrichment failed: {exc}") from exc
|
|
461
346
|
|
|
462
347
|
|
|
463
|
-
def apply_invariances(
|
|
464
|
-
changes: list[Change],
|
|
465
|
-
*,
|
|
466
|
-
old_tree: SemanticNode,
|
|
467
|
-
new_tree: SemanticNode,
|
|
468
|
-
old_source: str,
|
|
469
|
-
new_source: str,
|
|
470
|
-
language: str,
|
|
471
|
-
) -> RustInvarianceResult:
|
|
472
|
-
"""Apply built-in invariance rules in the Rust engine."""
|
|
473
|
-
|
|
474
|
-
return _run_invariance_request(
|
|
475
|
-
{
|
|
476
|
-
"mode": "apply",
|
|
477
|
-
"changes": [change.model_dump(mode="json") for change in changes],
|
|
478
|
-
"old_tree": old_tree.model_dump(mode="json"),
|
|
479
|
-
"new_tree": new_tree.model_dump(mode="json"),
|
|
480
|
-
"old_source": old_source,
|
|
481
|
-
"new_source": new_source,
|
|
482
|
-
"language": language,
|
|
483
|
-
}
|
|
484
|
-
)
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
def build_style_only_evidence(
|
|
488
|
-
*,
|
|
489
|
-
old_source: str,
|
|
490
|
-
new_source: str,
|
|
491
|
-
language: str,
|
|
492
|
-
old_cst_json: str | None = None,
|
|
493
|
-
new_cst_json: str | None = None,
|
|
494
|
-
) -> RustInvarianceResult:
|
|
495
|
-
"""Build source-span style-only evidence in the Rust engine."""
|
|
496
|
-
|
|
497
|
-
return _run_invariance_request(
|
|
498
|
-
{
|
|
499
|
-
"mode": "style_only",
|
|
500
|
-
"old_source": old_source,
|
|
501
|
-
"new_source": new_source,
|
|
502
|
-
"language": language,
|
|
503
|
-
"old_cst_json": old_cst_json,
|
|
504
|
-
"new_cst_json": new_cst_json,
|
|
505
|
-
}
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
def build_zero_change_literal_evidence(
|
|
510
|
-
*,
|
|
511
|
-
old_tree: SemanticNode,
|
|
512
|
-
new_tree: SemanticNode,
|
|
513
|
-
old_source: str,
|
|
514
|
-
new_source: str,
|
|
515
|
-
language: str,
|
|
516
|
-
) -> RustInvarianceResult:
|
|
517
|
-
"""Build zero-change literal evidence in the Rust engine."""
|
|
518
|
-
|
|
519
|
-
return _run_invariance_request(
|
|
520
|
-
{
|
|
521
|
-
"mode": "zero_change_literal",
|
|
522
|
-
"old_tree": old_tree.model_dump(mode="json"),
|
|
523
|
-
"new_tree": new_tree.model_dump(mode="json"),
|
|
524
|
-
"old_source": old_source,
|
|
525
|
-
"new_source": new_source,
|
|
526
|
-
"language": language,
|
|
527
|
-
}
|
|
528
|
-
)
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
def build_scope_trails(
|
|
532
|
-
*,
|
|
533
|
-
old_tree: SemanticNode,
|
|
534
|
-
new_tree: SemanticNode,
|
|
535
|
-
changes: list[Change],
|
|
536
|
-
) -> dict[str, Any]:
|
|
537
|
-
"""Build hunk scope breadcrumb metadata in the Rust engine."""
|
|
538
|
-
|
|
539
|
-
try:
|
|
540
|
-
backend = _load_backend()
|
|
541
|
-
scope_fn = getattr(backend, "scope_trails_json", None)
|
|
542
|
-
if not callable(scope_fn):
|
|
543
|
-
raise RuntimeError("backend does not expose scope_trails_json")
|
|
544
|
-
payload = scope_fn(
|
|
545
|
-
json.dumps(
|
|
546
|
-
{
|
|
547
|
-
"old_tree": old_tree.model_dump(mode="json"),
|
|
548
|
-
"new_tree": new_tree.model_dump(mode="json"),
|
|
549
|
-
"changes": [change.model_dump(mode="json") for change in changes],
|
|
550
|
-
}
|
|
551
|
-
)
|
|
552
|
-
)
|
|
553
|
-
data = json.loads(payload)
|
|
554
|
-
except Exception as exc: # noqa: BLE001 - scope computation belongs to Rust.
|
|
555
|
-
raise RuntimeError(f"Rust scope trail engine unavailable: {exc}") from exc
|
|
556
|
-
|
|
557
|
-
scope_trails = data.get("scope_trails") if isinstance(data, dict) else None
|
|
558
|
-
if not isinstance(scope_trails, dict):
|
|
559
|
-
raise RuntimeError("Rust scope trail response requires scope_trails object")
|
|
560
|
-
if any(not isinstance(scope_trails.get(side), list) for side in ("old", "new")):
|
|
561
|
-
raise RuntimeError("Rust scope trail response requires old/new arrays")
|
|
562
|
-
if any(
|
|
563
|
-
not isinstance(entry, dict)
|
|
564
|
-
for side in ("old", "new")
|
|
565
|
-
for entry in scope_trails[side]
|
|
566
|
-
):
|
|
567
|
-
raise RuntimeError("Rust scope trail response contains non-object entry")
|
|
568
|
-
return dict(scope_trails)
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
def try_rust_generic_text_review(
|
|
572
|
-
old_source: str,
|
|
573
|
-
new_source: str,
|
|
574
|
-
raw_change_count: int,
|
|
575
|
-
) -> tuple[list[Change], list[ChangeGroup]] | None:
|
|
576
|
-
"""Decode Rust-owned generic text review or an explicit Rust size-cap decline.
|
|
577
|
-
|
|
578
|
-
Only Rust may decline this stage. Missing handlers, invalid envelopes and
|
|
579
|
-
engine failures cannot silently become successful Python pass-throughs.
|
|
580
|
-
"""
|
|
581
|
-
try:
|
|
582
|
-
backend = _load_backend()
|
|
583
|
-
review_fn = getattr(backend, "generic_text_review_json", None)
|
|
584
|
-
if not callable(review_fn):
|
|
585
|
-
raise RuntimeError("required Rust generic-text review handler is unavailable")
|
|
586
|
-
data = json.loads(review_fn(old_source, new_source, raw_change_count))
|
|
587
|
-
if not isinstance(data, dict):
|
|
588
|
-
raise ValueError("Rust generic-text review must return a JSON object")
|
|
589
|
-
used = data.get("used")
|
|
590
|
-
if used is False:
|
|
591
|
-
if data.get("reason") != "input too large for LCS table":
|
|
592
|
-
raise ValueError("uncertified Rust generic-text review decline")
|
|
593
|
-
return None
|
|
594
|
-
if used is not True:
|
|
595
|
-
raise ValueError("Rust generic-text review missing explicit used=true")
|
|
596
|
-
if not isinstance(data.get("changes"), list):
|
|
597
|
-
raise ValueError("Rust generic-text review missing changes list")
|
|
598
|
-
if "group" not in data:
|
|
599
|
-
raise ValueError("Rust generic-text review missing group field")
|
|
600
|
-
group = data["group"]
|
|
601
|
-
if group is not None and not isinstance(group, dict):
|
|
602
|
-
raise ValueError("Rust generic-text review group must be an object or null")
|
|
603
|
-
changes = [Change.model_validate(item) for item in
|
|
604
|
-
_require_source_anchored_changes(data["changes"], "Rust generic-text review")]
|
|
605
|
-
groups = [ChangeGroup.model_validate(group)] if group is not None else []
|
|
606
|
-
return changes, groups
|
|
607
|
-
except Exception as exc: # noqa: BLE001 - fail closed on native/DTO failures.
|
|
608
|
-
raise RuntimeError(f"Rust generic-text review failed: {exc}") from exc
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
def try_rust_markdown_section_review(
|
|
612
|
-
old_source: str,
|
|
613
|
-
new_source: str,
|
|
614
|
-
) -> dict[str, object] | None:
|
|
615
|
-
"""Run required Rust Markdown section review; malformed native data must fail closed.
|
|
616
|
-
|
|
617
|
-
Engine-side port of the markdown post-presentation rules (issue #36): section
|
|
618
|
-
identity by content hash, LIS insertion-shift discrimination for moves, and
|
|
619
|
-
unique-body-hash heading renames.
|
|
620
|
-
"""
|
|
621
|
-
try:
|
|
622
|
-
backend = _load_backend()
|
|
623
|
-
review_fn = getattr(backend, "markdown_section_review_json", None)
|
|
624
|
-
if not callable(review_fn):
|
|
625
|
-
raise RuntimeError("required Rust markdown section review handler is unavailable")
|
|
626
|
-
data = json.loads(review_fn(old_source, new_source))
|
|
627
|
-
# The Rust markdown_section_review_impl always emits used=true and the
|
|
628
|
-
# complete DTO envelope, including real empty arrays for no-op reviews.
|
|
629
|
-
# Missing fields are engine-contract failures, never a Python decline.
|
|
630
|
-
if not isinstance(data, dict) or data.get("used") is not True:
|
|
631
|
-
raise ValueError("Rust markdown section review requires used=true")
|
|
632
|
-
for key in ("moves", "renames", "moved_labels", "old_heading_lines", "new_heading_lines"):
|
|
633
|
-
if not isinstance(data.get(key), list):
|
|
634
|
-
raise ValueError(f"Rust markdown section review requires {key} array")
|
|
635
|
-
if any(not isinstance(label, str) for label in data["moved_labels"]):
|
|
636
|
-
raise ValueError("Rust markdown section review has invalid moved_labels")
|
|
637
|
-
for key in ("old_heading_lines", "new_heading_lines"):
|
|
638
|
-
if any(type(line) is not int or line < 0 for line in data[key]):
|
|
639
|
-
raise ValueError(f"Rust markdown section review has invalid {key}")
|
|
640
|
-
for key in ("move_group", "rename_group"):
|
|
641
|
-
if key not in data or (data[key] is not None and not isinstance(data[key], dict)):
|
|
642
|
-
raise ValueError(f"Rust markdown section review requires {key} object or null")
|
|
643
|
-
return {
|
|
644
|
-
"moves": [Change.model_validate(item) for item in
|
|
645
|
-
_require_source_anchored_changes(data["moves"], "Rust Markdown moves")],
|
|
646
|
-
"moved_labels": set(data["moved_labels"]),
|
|
647
|
-
"move_group": (
|
|
648
|
-
ChangeGroup.model_validate(data["move_group"])
|
|
649
|
-
if data["move_group"] is not None else None
|
|
650
|
-
),
|
|
651
|
-
"renames": [Change.model_validate(item) for item in
|
|
652
|
-
_require_source_anchored_changes(data["renames"], "Rust Markdown renames")],
|
|
653
|
-
"old_heading_lines": set(data["old_heading_lines"]),
|
|
654
|
-
"new_heading_lines": set(data["new_heading_lines"]),
|
|
655
|
-
"rename_group": (
|
|
656
|
-
ChangeGroup.model_validate(data["rename_group"])
|
|
657
|
-
if data["rename_group"] is not None else None
|
|
658
|
-
),
|
|
659
|
-
}
|
|
660
|
-
except Exception as exc: # noqa: BLE001 - an engine failure is not an unsupported decline.
|
|
661
|
-
raise RuntimeError(f"Rust markdown section review failed: {exc}") from exc
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
def try_rust_collect_hover_targets(root: SemanticNode) -> list[tuple[str, int, int]]:
|
|
665
|
-
"""Decode Rust-owned hover targets; required engine failures propagate.
|
|
666
|
-
|
|
667
|
-
The historical name is retained for compatibility. There is no Python walker.
|
|
668
|
-
"""
|
|
669
|
-
data = _required_engine_json(
|
|
670
|
-
"lsp_collect_hover_targets_json", root.model_dump_json(), result_type=list,
|
|
671
|
-
)
|
|
672
|
-
return _hover_target_dtos(data)
|
|
673
|
-
|
|
674
|
-
|
|
675
348
|
def collect_lsp_hover_targets(root: SemanticNode, source: str) -> list[tuple[str, int, int]]:
|
|
676
349
|
"""Rust-owned selection and UTF-8 byte to UTF-16 protocol conversion."""
|
|
677
350
|
data = _required_engine_json(
|
|
@@ -779,6 +452,14 @@ def try_rust_finalize_review(
|
|
|
779
452
|
fallback_diff = data.get("fallback_diff")
|
|
780
453
|
if fallback_diff is not None and not isinstance(fallback_diff, dict):
|
|
781
454
|
raise ValueError("invalid Rust finalize response: malformed fallback_diff")
|
|
455
|
+
# Core #252: the proof rule and the suppression record go back to
|
|
456
|
+
# complete_routed_review verbatim, so core (not Python) states completeness.
|
|
457
|
+
proof = data.get("equivalence_proof")
|
|
458
|
+
if proof is not None and not isinstance(proof, str):
|
|
459
|
+
raise ValueError("invalid Rust finalize response: malformed equivalence_proof")
|
|
460
|
+
suppression_trace = data.get("suppression_trace")
|
|
461
|
+
if suppression_trace is not None and not isinstance(suppression_trace, list):
|
|
462
|
+
raise ValueError("invalid Rust finalize response: malformed suppression_trace")
|
|
782
463
|
|
|
783
464
|
return {
|
|
784
465
|
"fallback_diff": (
|
|
@@ -792,6 +473,8 @@ def try_rust_finalize_review(
|
|
|
792
473
|
"no_surviving_changes": data["no_surviving_changes"],
|
|
793
474
|
"ignored_style_changes": [dict(item) for item in ignored],
|
|
794
475
|
"trace": [dict(item) for item in trace],
|
|
476
|
+
"equivalence_proof": proof,
|
|
477
|
+
"suppression_trace": suppression_trace,
|
|
795
478
|
}
|
|
796
479
|
except Exception as exc: # noqa: BLE001 - an engine failure is not an unsupported decline.
|
|
797
480
|
raise RuntimeError(f"Rust finalize review failed: {exc}") from exc
|
|
@@ -908,6 +591,22 @@ def render_cli_review(diff: SemanticDiff, *, width: int, color: bool) -> str:
|
|
|
908
591
|
return _required_engine_json("render_cli_review", json.dumps(request), result_type=str)
|
|
909
592
|
|
|
910
593
|
|
|
594
|
+
def fuel_budget(plugin_fuel: int, content_len: int) -> int:
|
|
595
|
+
"""Transport core's content-scaled Wasm fuel policy (``fuel_budget``, #308).
|
|
596
|
+
|
|
597
|
+
Core answers ``{"fuel": u64}`` or ``{"fuel": null}`` (unlimited, a negative
|
|
598
|
+
``plugin_fuel``); ``null`` is returned as the binding's ``FUEL_UNLIMITED`` (-1).
|
|
599
|
+
"""
|
|
600
|
+
config_json = json.dumps({"plugin_fuel": plugin_fuel})
|
|
601
|
+
result = _required_engine_json("fuel_budget", config_json, content_len, result_type=dict)
|
|
602
|
+
fuel = result.get("fuel", ...)
|
|
603
|
+
if fuel is None:
|
|
604
|
+
return FUEL_UNLIMITED
|
|
605
|
+
if type(fuel) is not int or fuel < 0:
|
|
606
|
+
raise RuntimeError(f"Rust engine operation fuel_budget returned invalid {result!r}")
|
|
607
|
+
return fuel
|
|
608
|
+
|
|
609
|
+
|
|
911
610
|
def try_rust_build_symbol_table(files_json: str) -> str:
|
|
912
611
|
"""Extract a symbol table in Rust, raising on unavailable or invalid results.
|
|
913
612
|
|
|
@@ -926,9 +625,16 @@ def try_rust_diff_symbol_tables(old_json: str, new_json: str) -> list[dict[str,
|
|
|
926
625
|
return _required_engine_json("diff_symbol_tables_json", old_json, new_json, result_type=list)
|
|
927
626
|
|
|
928
627
|
|
|
929
|
-
def
|
|
930
|
-
"""
|
|
931
|
-
|
|
628
|
+
def commit_cross_file_index(files: list[dict[str, Any]]) -> dict[str, Any]:
|
|
629
|
+
"""Core's commit-wide cross-file index over host-parsed trees (core #298).
|
|
630
|
+
|
|
631
|
+
Each file is ``{old_filename, new_filename, language, old_tree, new_tree, old_error,
|
|
632
|
+
new_error}``. Core decides which files are indexable, reports the rest in
|
|
633
|
+
``index_errors`` and owns ``cross_file_index_status``.
|
|
634
|
+
"""
|
|
635
|
+
return _required_engine_json(
|
|
636
|
+
"commit_cross_file_index_json", json.dumps(files), result_type=dict
|
|
637
|
+
)
|
|
932
638
|
|
|
933
639
|
|
|
934
640
|
def load_project_diff_config_data(
|
|
@@ -1215,6 +921,50 @@ def validate_dep_hashes(
|
|
|
1215
921
|
return fn(dep_hashes, allowed_dependencies, package_name, install_target)
|
|
1216
922
|
|
|
1217
923
|
|
|
924
|
+
def validate_registry_manifest(manifest_json: str) -> list[dict[str, str]]:
|
|
925
|
+
"""Transport core's registry-manifest validator (``validate_registry_manifest``, #329).
|
|
926
|
+
|
|
927
|
+
Returns core's errors unchanged (``[]`` = valid), each ``{"path", "message"}``. A response
|
|
928
|
+
whose ``ok`` disagrees with its errors, or any other shape, raises.
|
|
929
|
+
"""
|
|
930
|
+
result = _required_engine_json(
|
|
931
|
+
"validate_registry_manifest", manifest_json, result_type=dict
|
|
932
|
+
)
|
|
933
|
+
errors = result.get("errors")
|
|
934
|
+
if (
|
|
935
|
+
type(result.get("ok")) is not bool
|
|
936
|
+
or not isinstance(errors, list)
|
|
937
|
+
or result["ok"] is not (not errors)
|
|
938
|
+
or not all(
|
|
939
|
+
isinstance(e, dict) and set(e) == {"path", "message"}
|
|
940
|
+
and all(isinstance(v, str) for v in e.values())
|
|
941
|
+
for e in errors
|
|
942
|
+
)
|
|
943
|
+
):
|
|
944
|
+
raise RuntimeError(f"Rust engine operation validate_registry_manifest returned {result!r}")
|
|
945
|
+
return errors
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
def parser_allowlist_matches(
|
|
949
|
+
allowed_plugins: list[str] | None, identity: dict[str, Any]
|
|
950
|
+
) -> dict[str, Any]:
|
|
951
|
+
"""Transport core's parser-allowlist rule (``parser_allowlist_matches``, #311).
|
|
952
|
+
|
|
953
|
+
*identity* is ``{"plugin_id", "grammar_id", "languages", "aliases"}`` (all optional).
|
|
954
|
+
Returns core's ``{"matches": bool, "matched_by": str | None}`` unchanged; core's rule is
|
|
955
|
+
``None`` = every parser, ``[]`` = none, else an exact grammar/plugin/alias/language id.
|
|
956
|
+
"""
|
|
957
|
+
result = _required_engine_json(
|
|
958
|
+
"parser_allowlist_matches", allowed_plugins, json.dumps(identity), result_type=dict
|
|
959
|
+
)
|
|
960
|
+
matches, matched_by = result.get("matches"), result.get("matched_by", ...)
|
|
961
|
+
if type(matches) is not bool or not (
|
|
962
|
+
isinstance(matched_by, str) if matches else matched_by is None
|
|
963
|
+
):
|
|
964
|
+
raise RuntimeError(f"Rust engine operation parser_allowlist_matches returned {result!r}")
|
|
965
|
+
return result
|
|
966
|
+
|
|
967
|
+
|
|
1218
968
|
# ── Git source-collection read ops (Rust-authoritative, #98, A2.4) ──────────
|
|
1219
969
|
|
|
1220
970
|
|
|
@@ -1260,21 +1010,6 @@ def git_repo_toplevel(repo_path: str) -> str:
|
|
|
1260
1010
|
return fn(repo_path)
|
|
1261
1011
|
|
|
1262
1012
|
|
|
1263
|
-
def changed_commit_sources(
|
|
1264
|
-
repo_path: str, old_ref: str, new_ref: str
|
|
1265
|
-
) -> list[tuple[str, str, str, str, str | None]]:
|
|
1266
|
-
"""Yield changed-source rows for a commit-to-commit diff via the Rust core.
|
|
1267
|
-
|
|
1268
|
-
Each row is ``(old_content, new_content, old_path, new_path, staging_status)`` with
|
|
1269
|
-
``staging_status`` always ``None`` for commit-to-commit. Binary files are skipped.
|
|
1270
|
-
"""
|
|
1271
|
-
backend = _load_backend()
|
|
1272
|
-
fn = getattr(backend, "changed_commit_sources_json", None)
|
|
1273
|
-
if not callable(fn):
|
|
1274
|
-
raise RuntimeError("backend does not expose changed_commit_sources_json")
|
|
1275
|
-
return [tuple(row) for row in json.loads(fn(repo_path, old_ref, new_ref))]
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
1013
|
def changed_sources(
|
|
1279
1014
|
repo_path: str, old_ref: str, new_ref: str
|
|
1280
1015
|
) -> list[tuple[str, str, str, str, str | None]]:
|
|
@@ -1422,16 +1157,11 @@ def live_handle_review(
|
|
|
1422
1157
|
|
|
1423
1158
|
Rust resolves changed files via the bundled-parser manifest in *wasm_dir*.
|
|
1424
1159
|
Missing or non-certified results are declines, not permission for a live
|
|
1425
|
-
transport to manufacture a successful Python-path review.
|
|
1426
|
-
signature compatibility does not relax result certification.
|
|
1160
|
+
transport to manufacture a successful Python-path review.
|
|
1427
1161
|
"""
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
except TypeError:
|
|
1432
|
-
# Older core: no wasm_dir parameter -> Python-only certified commit (non-Python falls back).
|
|
1433
|
-
raw = backend.live_handle_review_json(repo_path, old_ref, new_ref, config_json)
|
|
1434
|
-
return json.loads(raw)
|
|
1162
|
+
return json.loads(
|
|
1163
|
+
_load_backend().live_handle_review_json(repo_path, old_ref, new_ref, config_json, wasm_dir)
|
|
1164
|
+
)
|
|
1435
1165
|
|
|
1436
1166
|
|
|
1437
1167
|
def live_handle_asset_diff(
|
|
@@ -1474,37 +1204,6 @@ def try_register_user_xml_dialects(dialects: list[dict[str, Any]]) -> bool:
|
|
|
1474
1204
|
return True
|
|
1475
1205
|
|
|
1476
1206
|
|
|
1477
|
-
def _run_invariance_request(request: dict[str, Any]) -> RustInvarianceResult:
|
|
1478
|
-
try:
|
|
1479
|
-
backend = _load_backend()
|
|
1480
|
-
apply_fn = getattr(backend, "apply_invariances_json", None)
|
|
1481
|
-
if not callable(apply_fn):
|
|
1482
|
-
raise RuntimeError("backend does not expose apply_invariances_json")
|
|
1483
|
-
payload = apply_fn(json.dumps(request))
|
|
1484
|
-
data = json.loads(payload)
|
|
1485
|
-
except Exception as exc: # noqa: BLE001 - public engine boundary requires Rust here.
|
|
1486
|
-
raise RuntimeError(f"Rust invariance engine unavailable: {exc}") from exc
|
|
1487
|
-
|
|
1488
|
-
if not isinstance(data, dict):
|
|
1489
|
-
raise RuntimeError("Rust invariance engine returned a non-object payload")
|
|
1490
|
-
# Every Rust invariance mode returns all three arrays, even for genuinely
|
|
1491
|
-
# empty results. Missing/null/mistyped fields cannot certify a style-only
|
|
1492
|
-
# or no-change result and must not be silently replaced with empty lists.
|
|
1493
|
-
for field in ("changes", "change_groups", "ignored_style_changes"):
|
|
1494
|
-
if not isinstance(data.get(field), list):
|
|
1495
|
-
raise RuntimeError(f"invalid Rust invariance result: {field} must be an array")
|
|
1496
|
-
if any(not isinstance(item, dict) for item in data["ignored_style_changes"]):
|
|
1497
|
-
raise RuntimeError(
|
|
1498
|
-
"invalid Rust invariance result: ignored_style_changes entries must be objects"
|
|
1499
|
-
)
|
|
1500
|
-
return RustInvarianceResult(
|
|
1501
|
-
changes=[Change.model_validate(item) for item in
|
|
1502
|
-
_require_source_anchored_changes(data["changes"], "Rust invariance review")],
|
|
1503
|
-
change_groups=[ChangeGroup.model_validate(item) for item in data["change_groups"]],
|
|
1504
|
-
ignored_style_changes=[dict(item) for item in data["ignored_style_changes"]],
|
|
1505
|
-
)
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
1207
|
def try_rust_core_batch_diff(
|
|
1509
1208
|
*,
|
|
1510
1209
|
old_source: str,
|
|
@@ -1518,13 +1217,8 @@ def try_rust_core_batch_diff(
|
|
|
1518
1217
|
file_lifecycle: str | None = None,
|
|
1519
1218
|
) -> RustCoreBatchAttempt:
|
|
1520
1219
|
"""Try the planned Rust V4 batch boundary and fall back unless final output is ready."""
|
|
1521
|
-
if not rust_core_enabled(config):
|
|
1522
|
-
return RustCoreBatchAttempt(fallback_reason="disabled")
|
|
1523
1220
|
if language != "python":
|
|
1524
1221
|
return RustCoreBatchAttempt(fallback_reason="unsupported language")
|
|
1525
|
-
parser_plugin_id = _canonical_python_plugin_id(parser_plugin_id)
|
|
1526
|
-
if parser_plugin_id is not None and parser_plugin_id not in _PYTHON_PLUGIN_IDS:
|
|
1527
|
-
return RustCoreBatchAttempt(fallback_reason="unsupported parser plugin")
|
|
1528
1222
|
if config.diagnostics:
|
|
1529
1223
|
return RustCoreBatchAttempt(fallback_reason="diagnostics require Python pipeline")
|
|
1530
1224
|
|
|
@@ -1630,6 +1324,15 @@ def _require_complete_batch_diff_dto(payload: Any) -> dict[str, Any]:
|
|
|
1630
1324
|
raise ValueError(f"Rust complete batch diff requires {field} boolean")
|
|
1631
1325
|
if not isinstance(payload.get("metadata"), dict):
|
|
1632
1326
|
raise ValueError("Rust complete batch diff requires metadata object")
|
|
1327
|
+
# Core #252: a stated completeness verdict travels with its `incomplete` field (object
|
|
1328
|
+
# or null); the typed DTO checks both. Echo ops given a DTO without a verdict (one not
|
|
1329
|
+
# served by core) return none, which stays None rather than being invented here.
|
|
1330
|
+
if payload.get("completeness") is not None:
|
|
1331
|
+
if payload["completeness"] not in ("complete", "equivalent", "incomplete"):
|
|
1332
|
+
raise ValueError("Rust complete batch diff requires completeness "
|
|
1333
|
+
"'complete', 'equivalent' or 'incomplete'")
|
|
1334
|
+
if "incomplete" not in payload:
|
|
1335
|
+
raise ValueError("Rust complete batch diff requires incomplete (object or null)")
|
|
1633
1336
|
return payload
|
|
1634
1337
|
|
|
1635
1338
|
|
|
@@ -1660,8 +1363,6 @@ def try_rust_core_batch_diffs(
|
|
|
1660
1363
|
python_parser_backend: str = "native",
|
|
1661
1364
|
) -> RustCoreBatchDiffsAttempt:
|
|
1662
1365
|
"""Try the Rust V4 batch boundary for multiple certified Python file pairs."""
|
|
1663
|
-
if not rust_core_enabled(config):
|
|
1664
|
-
return RustCoreBatchDiffsAttempt(fallback_reason="disabled")
|
|
1665
1366
|
if config.diagnostics:
|
|
1666
1367
|
return RustCoreBatchDiffsAttempt(
|
|
1667
1368
|
fallback_reason="diagnostics require Python pipeline"
|
|
@@ -1706,7 +1407,6 @@ def try_rust_core_batch_diffs(
|
|
|
1706
1407
|
backend_version=backend_version,
|
|
1707
1408
|
)
|
|
1708
1409
|
phase_started = time.perf_counter()
|
|
1709
|
-
normalized_files = _canonicalize_file_plugin_ids(files)
|
|
1710
1410
|
request = {
|
|
1711
1411
|
"schema_version": 1,
|
|
1712
1412
|
"mode": "commit_batch",
|
|
@@ -1714,7 +1414,7 @@ def try_rust_core_batch_diffs(
|
|
|
1714
1414
|
"config": config.model_dump(mode="json"),
|
|
1715
1415
|
"parallel": parallel,
|
|
1716
1416
|
"max_workers": max_workers,
|
|
1717
|
-
"files":
|
|
1417
|
+
"files": files,
|
|
1718
1418
|
}
|
|
1719
1419
|
_record_adapter_phase("rust_core_request_construction", phase_started)
|
|
1720
1420
|
phase_started = time.perf_counter()
|
|
@@ -1886,54 +1586,6 @@ class _InvalidNativeCommitDto(RuntimeError):
|
|
|
1886
1586
|
"""Native claimed complete output but sent an invalid public commit DTO."""
|
|
1887
1587
|
|
|
1888
1588
|
|
|
1889
|
-
def _decode_native_commit_control(raw: Any, operation: str) -> dict[str, Any]:
|
|
1890
|
-
"""Reject malformed Rust control transport; only an explicit decline can fall back."""
|
|
1891
|
-
try:
|
|
1892
|
-
control = json.loads(raw)
|
|
1893
|
-
except (TypeError, ValueError) as exc:
|
|
1894
|
-
raise _InvalidNativeCommitDto(
|
|
1895
|
-
f"Rust {operation} returned malformed control JSON: {exc}"
|
|
1896
|
-
) from exc
|
|
1897
|
-
if not isinstance(control, dict) or not isinstance(control.get("status"), str):
|
|
1898
|
-
raise _InvalidNativeCommitDto(
|
|
1899
|
-
f"Rust {operation} requires a control object with status string"
|
|
1900
|
-
)
|
|
1901
|
-
if not control["status"]:
|
|
1902
|
-
raise _InvalidNativeCommitDto(f"Rust {operation} returned empty control status")
|
|
1903
|
-
# Rust commit_json_control emits only these two statuses. Unknown statuses
|
|
1904
|
-
# are malformed transport, never a valid explicit Rust decline.
|
|
1905
|
-
if control["status"] not in (_COMPLETE_STATUS, "fallback"):
|
|
1906
|
-
raise _InvalidNativeCommitDto(
|
|
1907
|
-
f"Rust {operation} returned unknown control status: {control['status']!r}"
|
|
1908
|
-
)
|
|
1909
|
-
return control
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
def _require_claimed_complete_commit_bytes(
|
|
1913
|
-
control: dict[str, Any], payload: Any, operation: str
|
|
1914
|
-
) -> bytes:
|
|
1915
|
-
"""Do not reinterpret an invalid claimed-complete result as a Rust decline."""
|
|
1916
|
-
if control.get("certification") != _PYTHON_NATIVE_CERTIFICATION:
|
|
1917
|
-
raise _InvalidNativeCommitDto(
|
|
1918
|
-
f"Rust {operation} claimed complete with invalid certification: "
|
|
1919
|
-
f"{control.get('certification')!r}"
|
|
1920
|
-
)
|
|
1921
|
-
if not isinstance(payload, (bytes, bytearray, memoryview)):
|
|
1922
|
-
raise _InvalidNativeCommitDto(
|
|
1923
|
-
f"Rust {operation} claimed complete without valid commit JSON bytes"
|
|
1924
|
-
)
|
|
1925
|
-
commit_json = bytes(payload)
|
|
1926
|
-
if not commit_json:
|
|
1927
|
-
raise _InvalidNativeCommitDto(f"Rust {operation} claimed complete with empty commit JSON")
|
|
1928
|
-
declared_size = control.get("commit_diff_byte_size")
|
|
1929
|
-
if type(declared_size) is not int or declared_size != len(commit_json):
|
|
1930
|
-
raise _InvalidNativeCommitDto(
|
|
1931
|
-
f"Rust {operation} commit JSON byte size mismatch: "
|
|
1932
|
-
f"control={declared_size!r}, payload={len(commit_json)}"
|
|
1933
|
-
)
|
|
1934
|
-
return commit_json
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
1589
|
def _require_native_commit_diff_json(payload: bytes, operation: str) -> None:
|
|
1938
1590
|
"""Validate Rust-authored commit bytes before exposing a successful adapter attempt."""
|
|
1939
1591
|
from intentumdiff.core.models import CommitDiff
|
|
@@ -2001,321 +1653,6 @@ def _require_native_commit_diff_json(payload: bytes, operation: str) -> None:
|
|
|
2001
1653
|
raise _InvalidNativeCommitDto(f"Rust {operation} returned malformed CommitDiff JSON: {exc}") from exc
|
|
2002
1654
|
|
|
2003
1655
|
|
|
2004
|
-
def try_rust_core_commit_json(
|
|
2005
|
-
*,
|
|
2006
|
-
files: list[dict[str, Any]],
|
|
2007
|
-
old_ref: str,
|
|
2008
|
-
new_ref: str,
|
|
2009
|
-
config: DiffConfig,
|
|
2010
|
-
parallel: bool = False,
|
|
2011
|
-
max_workers: int | None = None,
|
|
2012
|
-
python_parser_backend: str = "native",
|
|
2013
|
-
) -> RustCoreCommitJsonAttempt:
|
|
2014
|
-
"""Return certified Rust CommitDiff JSON bytes without Pydantic hot-path validation."""
|
|
2015
|
-
if not rust_core_enabled(config):
|
|
2016
|
-
return RustCoreCommitJsonAttempt(fallback_reason="disabled")
|
|
2017
|
-
if config.diagnostics:
|
|
2018
|
-
return RustCoreCommitJsonAttempt(
|
|
2019
|
-
fallback_reason="diagnostics require Python pipeline"
|
|
2020
|
-
)
|
|
2021
|
-
if python_parser_backend != "native":
|
|
2022
|
-
return RustCoreCommitJsonAttempt(
|
|
2023
|
-
fallback_reason="certified commit JSON requires native Python backend"
|
|
2024
|
-
)
|
|
2025
|
-
if not files:
|
|
2026
|
-
return RustCoreCommitJsonAttempt()
|
|
2027
|
-
|
|
2028
|
-
adapter_phase_timings: list[dict[str, Any]] = []
|
|
2029
|
-
|
|
2030
|
-
def _record_adapter_phase(
|
|
2031
|
-
name: str, started: float, *, summary_exclude: bool = False
|
|
2032
|
-
) -> None:
|
|
2033
|
-
phase = {
|
|
2034
|
-
"name": name,
|
|
2035
|
-
"duration_ms": round((time.perf_counter() - started) * 1000, 3),
|
|
2036
|
-
"shared": True,
|
|
2037
|
-
}
|
|
2038
|
-
if summary_exclude:
|
|
2039
|
-
phase["summary_exclude"] = True
|
|
2040
|
-
adapter_phase_timings.append(phase)
|
|
2041
|
-
|
|
2042
|
-
try:
|
|
2043
|
-
backend = _load_backend()
|
|
2044
|
-
except (RuntimeError, OSError):
|
|
2045
|
-
# Missing Rust runtime is not an explicit Rust decline.
|
|
2046
|
-
raise
|
|
2047
|
-
except Exception as exc: # noqa: BLE001 - optional accelerator must never break diffing.
|
|
2048
|
-
logger.debug("Rust core unavailable: %s", exc)
|
|
2049
|
-
return RustCoreCommitJsonAttempt(fallback_reason=f"unavailable: {exc}")
|
|
2050
|
-
|
|
2051
|
-
try:
|
|
2052
|
-
supports = getattr(backend, "supports_language", None)
|
|
2053
|
-
if callable(supports) and not supports("python"):
|
|
2054
|
-
return RustCoreCommitJsonAttempt(
|
|
2055
|
-
fallback_reason="backend does not support python"
|
|
2056
|
-
)
|
|
2057
|
-
backend_version = str(getattr(backend, "version", lambda: "")())
|
|
2058
|
-
diff_batch_commit_json = getattr(backend, "diff_batch_commit_json", None)
|
|
2059
|
-
if not callable(diff_batch_commit_json):
|
|
2060
|
-
return RustCoreCommitJsonAttempt(
|
|
2061
|
-
fallback_reason="backend does not expose diff_batch_commit_json",
|
|
2062
|
-
backend_version=backend_version,
|
|
2063
|
-
)
|
|
2064
|
-
phase_started = time.perf_counter()
|
|
2065
|
-
normalized_files = _canonicalize_file_plugin_ids(files)
|
|
2066
|
-
request = {
|
|
2067
|
-
"schema_version": 1,
|
|
2068
|
-
"mode": "commit_json",
|
|
2069
|
-
"old_ref": old_ref,
|
|
2070
|
-
"new_ref": new_ref,
|
|
2071
|
-
"python_parser_backend": python_parser_backend,
|
|
2072
|
-
"config": config.model_dump(mode="json"),
|
|
2073
|
-
"parallel": parallel,
|
|
2074
|
-
"max_workers": max_workers,
|
|
2075
|
-
"files": normalized_files,
|
|
2076
|
-
}
|
|
2077
|
-
_record_adapter_phase("rust_core_commit_request_construction", phase_started)
|
|
2078
|
-
phase_started = time.perf_counter()
|
|
2079
|
-
request_json = json.dumps(request)
|
|
2080
|
-
_record_adapter_phase("rust_core_commit_request_json_encode", phase_started)
|
|
2081
|
-
phase_started = time.perf_counter()
|
|
2082
|
-
control_json, commit_payload = diff_batch_commit_json(request_json)
|
|
2083
|
-
_record_adapter_phase(
|
|
2084
|
-
"rust_core_commit_pyo3_call",
|
|
2085
|
-
phase_started,
|
|
2086
|
-
summary_exclude=True,
|
|
2087
|
-
)
|
|
2088
|
-
phase_started = time.perf_counter()
|
|
2089
|
-
control = _decode_native_commit_control(control_json, "certified commit")
|
|
2090
|
-
_record_adapter_phase("rust_core_commit_control_decode", phase_started)
|
|
2091
|
-
phase_started = time.perf_counter()
|
|
2092
|
-
status = str(control.get("status") or "")
|
|
2093
|
-
if status != _COMPLETE_STATUS:
|
|
2094
|
-
reason = str(control.get("reason") or status or "commit JSON incomplete")
|
|
2095
|
-
_record_adapter_phase("rust_core_commit_control_validation", phase_started)
|
|
2096
|
-
return RustCoreCommitJsonAttempt(
|
|
2097
|
-
control=control,
|
|
2098
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2099
|
-
backend_version=backend_version,
|
|
2100
|
-
fallback_reason=reason,
|
|
2101
|
-
)
|
|
2102
|
-
commit_json = _require_claimed_complete_commit_bytes(
|
|
2103
|
-
control, commit_payload, "certified commit"
|
|
2104
|
-
)
|
|
2105
|
-
_record_adapter_phase("rust_core_commit_control_validation", phase_started)
|
|
2106
|
-
# The C ABI control status and matching byte count are not proof that
|
|
2107
|
-
# the bytes constitute a valid CommitDiff. Validate every successful
|
|
2108
|
-
# native response, even when the legacy debug env flag is unset.
|
|
2109
|
-
phase_started = time.perf_counter()
|
|
2110
|
-
_require_native_commit_diff_json(commit_json, "certified commit")
|
|
2111
|
-
_record_adapter_phase("rust_core_commit_pydantic_validation", phase_started)
|
|
2112
|
-
return RustCoreCommitJsonAttempt(
|
|
2113
|
-
control=control,
|
|
2114
|
-
commit_diff_json=commit_json,
|
|
2115
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2116
|
-
backend_version=backend_version,
|
|
2117
|
-
)
|
|
2118
|
-
except (_InvalidNativeCommitDto, _InvalidNativeCAbiEnvelope, _NativeCAbiOperationFailure):
|
|
2119
|
-
raise
|
|
2120
|
-
except (ValidationError, ValueError, TypeError) as exc:
|
|
2121
|
-
logger.debug("Rust core certified commit JSON rejected: %s", exc)
|
|
2122
|
-
return RustCoreCommitJsonAttempt(
|
|
2123
|
-
fallback_reason=f"invalid output: {exc}",
|
|
2124
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2125
|
-
)
|
|
2126
|
-
except (RuntimeError, OSError):
|
|
2127
|
-
# Rust failures cannot be treated as successful alternate routes.
|
|
2128
|
-
raise
|
|
2129
|
-
except Exception as exc: # noqa: BLE001 - optional accelerator must fall back.
|
|
2130
|
-
logger.debug("Rust core certified commit JSON failed: %s", exc, exc_info=True)
|
|
2131
|
-
return RustCoreCommitJsonAttempt(
|
|
2132
|
-
fallback_reason=f"failed: {exc}",
|
|
2133
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2134
|
-
)
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
def try_rust_core_working_tree_commit_json(
|
|
2138
|
-
*,
|
|
2139
|
-
repo_path: str | Path,
|
|
2140
|
-
old_ref: str,
|
|
2141
|
-
config: DiffConfig,
|
|
2142
|
-
parallel: bool = False,
|
|
2143
|
-
max_workers: int | None = None,
|
|
2144
|
-
python_parser_backend: str = "native",
|
|
2145
|
-
) -> RustCoreCommitJsonAttempt:
|
|
2146
|
-
"""Return Rust-certified CommitDiff JSON with Rust-side source collection."""
|
|
2147
|
-
if not rust_core_enabled(config):
|
|
2148
|
-
return RustCoreCommitJsonAttempt(fallback_reason="disabled")
|
|
2149
|
-
if config.diagnostics:
|
|
2150
|
-
return RustCoreCommitJsonAttempt(
|
|
2151
|
-
fallback_reason="diagnostics require Python pipeline"
|
|
2152
|
-
)
|
|
2153
|
-
|
|
2154
|
-
adapter_phase_timings: list[dict[str, Any]] = []
|
|
2155
|
-
|
|
2156
|
-
def _record_adapter_phase(
|
|
2157
|
-
name: str, started: float, *, summary_exclude: bool = False
|
|
2158
|
-
) -> None:
|
|
2159
|
-
phase = {
|
|
2160
|
-
"name": name,
|
|
2161
|
-
"duration_ms": round((time.perf_counter() - started) * 1000, 3),
|
|
2162
|
-
"shared": True,
|
|
2163
|
-
}
|
|
2164
|
-
if summary_exclude:
|
|
2165
|
-
phase["summary_exclude"] = True
|
|
2166
|
-
adapter_phase_timings.append(phase)
|
|
2167
|
-
|
|
2168
|
-
try:
|
|
2169
|
-
backend = _load_backend()
|
|
2170
|
-
except (RuntimeError, OSError):
|
|
2171
|
-
# Missing Rust runtime is not an explicit Rust decline.
|
|
2172
|
-
raise
|
|
2173
|
-
except Exception as exc: # noqa: BLE001 - optional accelerator must fall back.
|
|
2174
|
-
logger.debug("Rust core unavailable: %s", exc)
|
|
2175
|
-
return RustCoreCommitJsonAttempt(fallback_reason=f"unavailable: {exc}")
|
|
2176
|
-
|
|
2177
|
-
try:
|
|
2178
|
-
backend_version = str(getattr(backend, "version", lambda: "")())
|
|
2179
|
-
entrypoint = getattr(backend, "diff_working_tree_python_commit_json", None)
|
|
2180
|
-
if not callable(entrypoint):
|
|
2181
|
-
return RustCoreCommitJsonAttempt(
|
|
2182
|
-
fallback_reason="backend does not expose diff_working_tree_python_commit_json",
|
|
2183
|
-
backend_version=backend_version,
|
|
2184
|
-
)
|
|
2185
|
-
|
|
2186
|
-
phase_started = time.perf_counter()
|
|
2187
|
-
request = {
|
|
2188
|
-
"schema_version": 1,
|
|
2189
|
-
"mode": "working_tree_commit_json",
|
|
2190
|
-
"repo_path": str(repo_path),
|
|
2191
|
-
"old_ref": old_ref,
|
|
2192
|
-
"new_ref": "",
|
|
2193
|
-
"python_parser_backend": python_parser_backend,
|
|
2194
|
-
"config": config.model_dump(mode="json"),
|
|
2195
|
-
"parallel": parallel,
|
|
2196
|
-
"max_workers": max_workers,
|
|
2197
|
-
}
|
|
2198
|
-
_record_adapter_phase("rust_core_working_tree_request_construction", phase_started)
|
|
2199
|
-
phase_started = time.perf_counter()
|
|
2200
|
-
request_json = json.dumps(request)
|
|
2201
|
-
_record_adapter_phase("rust_core_working_tree_request_json_encode", phase_started)
|
|
2202
|
-
phase_started = time.perf_counter()
|
|
2203
|
-
control_json, commit_payload = entrypoint(request_json)
|
|
2204
|
-
_record_adapter_phase(
|
|
2205
|
-
"rust_core_working_tree_pyo3_call",
|
|
2206
|
-
phase_started,
|
|
2207
|
-
summary_exclude=True,
|
|
2208
|
-
)
|
|
2209
|
-
phase_started = time.perf_counter()
|
|
2210
|
-
control = _decode_native_commit_control(control_json, "working-tree commit")
|
|
2211
|
-
_record_adapter_phase("rust_core_working_tree_control_decode", phase_started)
|
|
2212
|
-
|
|
2213
|
-
phase_started = time.perf_counter()
|
|
2214
|
-
status = str(control.get("status") or "")
|
|
2215
|
-
if status != _COMPLETE_STATUS:
|
|
2216
|
-
reason = str(control.get("reason") or status or "working-tree JSON incomplete")
|
|
2217
|
-
_record_adapter_phase("rust_core_working_tree_control_validation", phase_started)
|
|
2218
|
-
return RustCoreCommitJsonAttempt(
|
|
2219
|
-
control=control,
|
|
2220
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2221
|
-
backend_version=backend_version,
|
|
2222
|
-
fallback_reason=reason,
|
|
2223
|
-
)
|
|
2224
|
-
commit_json = _require_claimed_complete_commit_bytes(
|
|
2225
|
-
control, commit_payload, "working-tree commit"
|
|
2226
|
-
)
|
|
2227
|
-
_record_adapter_phase("rust_core_working_tree_control_validation", phase_started)
|
|
2228
|
-
phase_started = time.perf_counter()
|
|
2229
|
-
_require_native_commit_diff_json(commit_json, "working-tree commit")
|
|
2230
|
-
_record_adapter_phase("rust_core_working_tree_pydantic_validation", phase_started)
|
|
2231
|
-
return RustCoreCommitJsonAttempt(
|
|
2232
|
-
control=control,
|
|
2233
|
-
commit_diff_json=commit_json,
|
|
2234
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2235
|
-
backend_version=backend_version,
|
|
2236
|
-
)
|
|
2237
|
-
except (_InvalidNativeCommitDto, _InvalidNativeCAbiEnvelope, _NativeCAbiOperationFailure):
|
|
2238
|
-
raise
|
|
2239
|
-
except (ValidationError, ValueError, TypeError) as exc:
|
|
2240
|
-
logger.debug("Rust core working-tree commit JSON rejected: %s", exc)
|
|
2241
|
-
return RustCoreCommitJsonAttempt(
|
|
2242
|
-
fallback_reason=f"invalid output: {exc}",
|
|
2243
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2244
|
-
)
|
|
2245
|
-
except (RuntimeError, OSError):
|
|
2246
|
-
# Rust failures cannot be treated as successful alternate routes.
|
|
2247
|
-
raise
|
|
2248
|
-
except Exception as exc: # noqa: BLE001 - optional accelerator must fall back.
|
|
2249
|
-
logger.debug("Rust core working-tree commit JSON failed: %s", exc, exc_info=True)
|
|
2250
|
-
return RustCoreCommitJsonAttempt(
|
|
2251
|
-
fallback_reason=f"failed: {exc}",
|
|
2252
|
-
adapter_phase_timings=adapter_phase_timings,
|
|
2253
|
-
)
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
def run_rust_core_candidate_batch(
|
|
2257
|
-
*,
|
|
2258
|
-
files: list[dict[str, Any]],
|
|
2259
|
-
config: DiffConfig,
|
|
2260
|
-
python_parser_backend: str = "wasm",
|
|
2261
|
-
) -> RustCoreCandidateBatchAttempt:
|
|
2262
|
-
"""Run the internal V4-A candidate lane without making it product-visible."""
|
|
2263
|
-
if not rust_core_enabled(config):
|
|
2264
|
-
return RustCoreCandidateBatchAttempt(fallback_reason="disabled")
|
|
2265
|
-
|
|
2266
|
-
try:
|
|
2267
|
-
backend = _load_backend()
|
|
2268
|
-
except Exception as exc: # noqa: BLE001 - optional benchmark lane records failures.
|
|
2269
|
-
logger.debug("Rust core unavailable for candidate batch: %s", exc)
|
|
2270
|
-
return RustCoreCandidateBatchAttempt(fallback_reason=f"unavailable: {exc}")
|
|
2271
|
-
|
|
2272
|
-
try:
|
|
2273
|
-
backend_version = str(getattr(backend, "version", lambda: "")())
|
|
2274
|
-
diff_batch = getattr(backend, "diff_batch", None)
|
|
2275
|
-
if not callable(diff_batch):
|
|
2276
|
-
return RustCoreCandidateBatchAttempt(
|
|
2277
|
-
fallback_reason="backend does not expose diff_batch",
|
|
2278
|
-
backend_version=backend_version,
|
|
2279
|
-
)
|
|
2280
|
-
request = {
|
|
2281
|
-
"schema_version": 1,
|
|
2282
|
-
"mode": "candidate_batch",
|
|
2283
|
-
"candidate": True,
|
|
2284
|
-
"python_parser_backend": python_parser_backend,
|
|
2285
|
-
"config": config.model_dump(mode="json"),
|
|
2286
|
-
"files": _canonicalize_file_plugin_ids(files),
|
|
2287
|
-
}
|
|
2288
|
-
data = _load_tree_payload(diff_batch(json.dumps(request)))
|
|
2289
|
-
engine = str(data.get("engine") or "")
|
|
2290
|
-
if engine != _BATCH_ENGINE:
|
|
2291
|
-
return RustCoreCandidateBatchAttempt(
|
|
2292
|
-
fallback_reason=f"unexpected engine: {engine or '<missing>'}",
|
|
2293
|
-
backend_version=backend_version,
|
|
2294
|
-
)
|
|
2295
|
-
for item in data.get("diffs") or []:
|
|
2296
|
-
if not isinstance(item, dict):
|
|
2297
|
-
continue
|
|
2298
|
-
candidate_diff = item.get("candidate_diff")
|
|
2299
|
-
if candidate_diff is not None:
|
|
2300
|
-
SemanticDiff.model_validate(candidate_diff)
|
|
2301
|
-
return RustCoreCandidateBatchAttempt(
|
|
2302
|
-
payload=data if isinstance(data, dict) else None,
|
|
2303
|
-
backend_version=backend_version,
|
|
2304
|
-
)
|
|
2305
|
-
except (ValidationError, ValueError, TypeError) as exc:
|
|
2306
|
-
logger.debug("Rust core candidate output rejected: %s", exc)
|
|
2307
|
-
return RustCoreCandidateBatchAttempt(
|
|
2308
|
-
fallback_reason=f"invalid output: {exc}",
|
|
2309
|
-
backend_version=locals().get("backend_version", ""),
|
|
2310
|
-
)
|
|
2311
|
-
except Exception as exc: # noqa: BLE001 - benchmark lane must report failures.
|
|
2312
|
-
logger.debug("Rust core candidate batch failed: %s", exc, exc_info=True)
|
|
2313
|
-
return RustCoreCandidateBatchAttempt(
|
|
2314
|
-
fallback_reason=f"failed: {exc}",
|
|
2315
|
-
backend_version=locals().get("backend_version", ""),
|
|
2316
|
-
)
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
1656
|
def _load_tree_payload(payload: Any) -> dict[str, Any]:
|
|
2320
1657
|
if isinstance(payload, str):
|
|
2321
1658
|
import json
|