intentumdiff-python 0.0.1__py3-none-win_amd64.whl → 0.0.2b2__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 +2 -0
- intentumdiff/__main__.py +12 -0
- intentumdiff/_differ_presentation.py +35 -682
- intentumdiff/_differ_runtime.py +13 -47
- intentumdiff/analysis/compile_commands.py +26 -141
- intentumdiff/analysis/cross_file.py +2 -4
- intentumdiff/analysis/guardrail_reports.py +7 -5
- intentumdiff/analysis/guardrails.py +110 -122
- intentumdiff/analysis/invariances.py +4 -1003
- intentumdiff/analysis/schema_resolver.py +49 -273
- intentumdiff/analysis/text_review.py +4 -3
- intentumdiff/analysis/user_schemas.py +55 -237
- intentumdiff/api.py +21 -0
- intentumdiff/cache/sqlite_store.py +5 -23
- intentumdiff/cli/__init__.py +59 -0
- intentumdiff/cli/_commands.py +174 -67
- intentumdiff/cli/_parser.py +11 -1
- intentumdiff/cli/_shared.py +96 -112
- intentumdiff/content_type.py +13 -30
- intentumdiff/core/commit_differ.py +105 -220
- intentumdiff/core/diffignore.py +28 -34
- intentumdiff/core/index.py +16 -18
- intentumdiff/core/indexer.py +148 -168
- intentumdiff/core/models.py +53 -14
- intentumdiff/differ.py +278 -605
- intentumdiff/github_app.py +35 -19
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +180 -17
- intentumdiff/lsp/client.py +7 -1
- intentumdiff/lsp/enricher.py +19 -119
- intentumdiff/lsp/exceptions.py +6 -7
- intentumdiff/lsp_server/_codelens.py +24 -57
- intentumdiff/lsp_server/_diagnostics.py +23 -51
- intentumdiff/lsp_server/_handlers.py +66 -8
- intentumdiff/lsp_server/server.py +28 -7
- intentumdiff/plugins/adapter.py +5 -0
- intentumdiff/plugins/builtins.py +7 -14
- intentumdiff/plugins/exceptions.py +4 -0
- intentumdiff/plugins/hub.py +1 -2
- intentumdiff/plugins/loader.py +229 -215
- intentumdiff/plugins/registry.py +249 -197
- intentumdiff/rust_core.py +744 -784
- intentumdiff/serve/_app.py +3 -10
- intentumdiff/sources/base.py +24 -0
- intentumdiff/sources/file_source.py +15 -2
- intentumdiff/sources/git_source.py +120 -58
- intentumdiff/sources/live_buffer_source.py +45 -5
- intentumdiff/sources/patch_source.py +36 -109
- intentumdiff/vcs/_safe_path.py +7 -0
- intentumdiff/vcs/base.py +6 -0
- intentumdiff/vcs/git_backend.py +1 -1
- intentumdiff/vcs/git_cli.py +38 -18
- intentumdiff/vcs/hg_backend.py +1 -1
- intentumdiff/vcs/perforce_backend.py +7 -1
- intentumdiff/vcs/svn_backend.py +1 -1
- 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/clojure_parser.wasm +0 -0
- intentumdiff/wasm/cmake_parser.wasm +0 -0
- intentumdiff/wasm/cpp_parser.wasm +0 -0
- intentumdiff/wasm/csharp_parser.wasm +0 -0
- intentumdiff/wasm/css_parser.wasm +0 -0
- intentumdiff/wasm/dart_parser.wasm +0 -0
- intentumdiff/wasm/databricks_parser.wasm +0 -0
- intentumdiff/wasm/dax_parser.wasm +0 -0
- intentumdiff/wasm/delphi_parser.wasm +0 -0
- intentumdiff/wasm/dockerfile_parser.wasm +0 -0
- intentumdiff/wasm/elixir_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/go_parser.wasm +0 -0
- intentumdiff/wasm/gomod_parser.wasm +0 -0
- intentumdiff/wasm/graphql_parser.wasm +0 -0
- intentumdiff/wasm/groovy_parser.wasm +0 -0
- intentumdiff/wasm/haskell_parser.wasm +0 -0
- intentumdiff/wasm/html_parser.wasm +0 -0
- intentumdiff/wasm/html_renderer.wasm +0 -0
- intentumdiff/wasm/ini_parser.wasm +0 -0
- intentumdiff/wasm/java_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/llm_renderer.wasm +0 -0
- intentumdiff/wasm/lua_parser.wasm +0 -0
- intentumdiff/wasm/make_parser.wasm +0 -0
- intentumdiff/wasm/markdown_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/parser_manifest.json +81 -2
- intentumdiff/wasm/patch_renderer.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/po_parser.wasm +0 -0
- intentumdiff/wasm/postscript_parser.wasm +0 -0
- intentumdiff/wasm/powershell_parser.wasm +0 -0
- intentumdiff/wasm/proto_parser.wasm +0 -0
- intentumdiff/wasm/puppet_parser.wasm +0 -0
- intentumdiff/wasm/python_parser.wasm +0 -0
- intentumdiff/wasm/qsharp_parser.wasm +0 -0
- intentumdiff/wasm/r_parser.wasm +0 -0
- intentumdiff/wasm/reasonml_parser.wasm +0 -0
- intentumdiff/wasm/ruby_parser.wasm +0 -0
- intentumdiff/wasm/rust_parser.wasm +0 -0
- intentumdiff/wasm/sas_parser.wasm +0 -0
- intentumdiff/wasm/scala_parser.wasm +0 -0
- intentumdiff/wasm/scss_parser.wasm +0 -0
- intentumdiff/wasm/sql_parser.wasm +0 -0
- intentumdiff/wasm/squirrel_parser.wasm +0 -0
- intentumdiff/wasm/svelte_parser.wasm +0 -0
- intentumdiff/wasm/swift_parser.wasm +0 -0
- intentumdiff/wasm/terminal_renderer.wasm +0 -0
- intentumdiff/wasm/terraform_parser.wasm +0 -0
- intentumdiff/wasm/toml_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 +884 -0
- intentumdiff/wasm/wat_parser.wasm +0 -0
- intentumdiff/wasm/xml_parser.wasm +0 -0
- intentumdiff/wasm/yaml_parser.wasm +0 -0
- intentumdiff/wasm/zig_parser.wasm +0 -0
- intentumdiff_python-0.0.2b2.dist-info/METADATA +156 -0
- intentumdiff_python-0.0.2b2.dist-info/RECORD +171 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/WHEEL +1 -1
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +905 -379
- intentumdiff/core/cst_serializer.py +0 -101
- intentumdiff_python-0.0.1.dist-info/METADATA +0 -112
- intentumdiff_python-0.0.1.dist-info/RECORD +0 -165
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,7 +7,6 @@ import ipaddress
|
|
|
7
7
|
import json
|
|
8
8
|
import logging
|
|
9
9
|
import os
|
|
10
|
-
import re
|
|
11
10
|
import socket
|
|
12
11
|
import ssl
|
|
13
12
|
import subprocess
|
|
@@ -17,12 +16,15 @@ import urllib.parse
|
|
|
17
16
|
import urllib.request
|
|
18
17
|
from collections.abc import Callable, Mapping
|
|
19
18
|
from dataclasses import dataclass
|
|
19
|
+
from functools import partial
|
|
20
20
|
from pathlib import Path
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
23
|
+
from intentumdiff.rust_core import _c_abi_call
|
|
24
|
+
|
|
23
25
|
from intentumdiff.analysis.user_schemas import (
|
|
24
26
|
load_user_schema_profiles,
|
|
25
|
-
|
|
27
|
+
_profile_payload,
|
|
26
28
|
)
|
|
27
29
|
|
|
28
30
|
logger = logging.getLogger(__name__)
|
|
@@ -152,33 +154,19 @@ def resolve_schema(
|
|
|
152
154
|
) -> SchemaResolution:
|
|
153
155
|
values = env or os.environ
|
|
154
156
|
mode = _schema_fetch_mode(values)
|
|
155
|
-
declared = discover_declared_schema(content, language)
|
|
156
|
-
# User-registered profiles (issue #63) outrank the embedded fetch and the
|
|
157
|
-
# built-in provider registry: a claimed $schema URL or a filename/marker
|
|
158
|
-
# match resolves OFFLINE from the local descriptor — no fetch, no logging
|
|
159
|
-
# of proprietary schema content.
|
|
160
157
|
user_profiles, _user_errors = load_user_schema_profiles(values)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
filename=filename,
|
|
165
|
-
content=content,
|
|
166
|
-
declared_url=declared,
|
|
167
|
-
)
|
|
168
|
-
if profile is not None:
|
|
169
|
-
return SchemaResolution(
|
|
170
|
-
provider_id=profile.provider_id,
|
|
171
|
-
status="user-profile",
|
|
172
|
-
source_url=profile.schema_path,
|
|
173
|
-
schema=profile.schema,
|
|
174
|
-
identity_fields=profile.identity_fields,
|
|
175
|
-
cache_fingerprint=profile.fingerprint,
|
|
176
|
-
)
|
|
177
|
-
candidate = (
|
|
178
|
-
SchemaCandidate("embedded", declared)
|
|
179
|
-
if declared
|
|
180
|
-
else provider_schema_candidate(filename, language, content)
|
|
158
|
+
decision = _schema_operation(
|
|
159
|
+
"resolve", profiles=[_profile_payload(p) for p in user_profiles],
|
|
160
|
+
filename=filename, language=language, content=content,
|
|
181
161
|
)
|
|
162
|
+
if decision["profile_index"] is not None:
|
|
163
|
+
profile = user_profiles[decision["profile_index"]]
|
|
164
|
+
return SchemaResolution(
|
|
165
|
+
provider_id=profile.provider_id, status="user-profile",
|
|
166
|
+
source_url=profile.schema_path, schema=profile.schema,
|
|
167
|
+
identity_fields=profile.identity_fields, cache_fingerprint=profile.fingerprint,
|
|
168
|
+
)
|
|
169
|
+
candidate = _candidate_from_payload(decision["candidate"])
|
|
182
170
|
if candidate is None:
|
|
183
171
|
return SchemaResolution(provider_id="none", status="not_found")
|
|
184
172
|
if candidate.status:
|
|
@@ -263,7 +251,7 @@ def resolve_schema(
|
|
|
263
251
|
ttl,
|
|
264
252
|
current_time,
|
|
265
253
|
values,
|
|
266
|
-
fetcher or _fetch_https,
|
|
254
|
+
fetcher or partial(_fetch_https, env=values),
|
|
267
255
|
)
|
|
268
256
|
except Exception as exc:
|
|
269
257
|
logger.debug("Schema fetch failed for %s", candidate.url, exc_info=True)
|
|
@@ -278,135 +266,31 @@ def resolve_schema(
|
|
|
278
266
|
)
|
|
279
267
|
|
|
280
268
|
|
|
269
|
+
def _schema_operation(operation: str, **payload: Any) -> Any:
|
|
270
|
+
return _c_abi_call("schema_profiles", json.dumps({"operation": operation, **payload}))
|
|
271
|
+
|
|
272
|
+
|
|
281
273
|
def discover_declared_schema(content: str, language: str | None = None) -> str | None:
|
|
282
|
-
|
|
283
|
-
if language_id in {"json", "adf"} or _looks_like_json(content):
|
|
284
|
-
try:
|
|
285
|
-
parsed = json.loads(content)
|
|
286
|
-
except json.JSONDecodeError:
|
|
287
|
-
parsed = None
|
|
288
|
-
if isinstance(parsed, dict):
|
|
289
|
-
value = parsed.get("$schema")
|
|
290
|
-
if isinstance(value, str) and value.strip():
|
|
291
|
-
return value.strip()
|
|
292
|
-
|
|
293
|
-
for line in content.splitlines()[:5]:
|
|
294
|
-
match = re.match(r"\s*#\s*yaml-language-server:\s*\$schema=(\S+)\s*$", line)
|
|
295
|
-
if match:
|
|
296
|
-
return match.group(1).strip()
|
|
297
|
-
return None
|
|
274
|
+
return _schema_operation("discover", content=content, language=language)
|
|
298
275
|
|
|
299
276
|
|
|
300
277
|
def provider_schema_candidate(
|
|
301
|
-
filename: str,
|
|
302
|
-
language: str | None,
|
|
303
|
-
content: str = "",
|
|
278
|
+
filename: str, language: str | None, content: str = "",
|
|
304
279
|
) -> SchemaCandidate | None:
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
language_id = (language or "").lower()
|
|
308
|
-
|
|
309
|
-
if url := _openapi_schema_url(basename, content):
|
|
310
|
-
version = "3.1" if url == OPENAPI_31_SCHEMA_URL else "3.0"
|
|
311
|
-
return SchemaCandidate(
|
|
312
|
-
f"openapi:{version}",
|
|
313
|
-
url,
|
|
314
|
-
identity_fields=frozenset({"operationId", "name"}),
|
|
315
|
-
)
|
|
316
|
-
if _looks_like_kubernetes_manifest(basename, content):
|
|
317
|
-
return SchemaCandidate(
|
|
318
|
-
"kubernetes:manifest",
|
|
319
|
-
KUBERNETES_SCHEMA_URL,
|
|
320
|
-
identity_fields=frozenset({"name"}),
|
|
321
|
-
)
|
|
322
|
-
if _looks_like_github_workflow(normalized_path, content):
|
|
323
|
-
return SchemaCandidate(
|
|
324
|
-
"github-actions:workflow",
|
|
325
|
-
GITHUB_WORKFLOW_SCHEMA_URL,
|
|
326
|
-
identity_fields=frozenset({"id", "name", "run", "runs-on", "uses"}),
|
|
327
|
-
)
|
|
328
|
-
if _looks_like_azure_pipeline(normalized_path, content):
|
|
329
|
-
return SchemaCandidate(
|
|
330
|
-
"azure-pipelines:pipeline",
|
|
331
|
-
AZURE_PIPELINES_SCHEMA_URL,
|
|
332
|
-
identity_fields=frozenset({"job", "stage", "task", "script", "displayName"}),
|
|
333
|
-
)
|
|
280
|
+
value = _schema_operation("provider", filename=filename, language=language, content=content)
|
|
281
|
+
return _candidate_from_payload(value)
|
|
334
282
|
|
|
335
|
-
dbt_url = _dbt_schema_url(basename, language_id, content)
|
|
336
|
-
if dbt_url:
|
|
337
|
-
key = dbt_url.rsplit("/", 1)[-1].replace("-latest.json", "")
|
|
338
|
-
return SchemaCandidate(
|
|
339
|
-
f"dbt:{key}",
|
|
340
|
-
dbt_url,
|
|
341
|
-
identity_fields=DBT_IDENTITY_FIELDS,
|
|
342
|
-
)
|
|
343
283
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
"databricks.yaml",
|
|
347
|
-
}:
|
|
348
|
-
return SchemaCandidate(
|
|
349
|
-
"databricks:bundle",
|
|
350
|
-
DATABRICKS_BUNDLE_SCHEMA_URL,
|
|
351
|
-
command=("databricks", "bundle", "schema"),
|
|
352
|
-
identity_fields=frozenset(
|
|
353
|
-
{
|
|
354
|
-
"depends_on",
|
|
355
|
-
"job_cluster_key",
|
|
356
|
-
"library",
|
|
357
|
-
"libraries",
|
|
358
|
-
"task_key",
|
|
359
|
-
}
|
|
360
|
-
),
|
|
361
|
-
)
|
|
362
|
-
|
|
363
|
-
if language_id in {"adf"} or _looks_like_adf_path(basename):
|
|
364
|
-
return SchemaCandidate(
|
|
365
|
-
"adf:no_raw_schema",
|
|
366
|
-
None,
|
|
367
|
-
status="no_raw_schema",
|
|
368
|
-
advisory_url=ADVISORY_ADF_NO_RAW_SCHEMA_URL,
|
|
369
|
-
)
|
|
370
|
-
if language_id in {"hcl", "terraform"} or basename.endswith((".tf", ".hcl")):
|
|
284
|
+
def _candidate_from_payload(value: dict[str, Any] | None) -> SchemaCandidate | None:
|
|
285
|
+
if value is None:
|
|
371
286
|
return None
|
|
372
|
-
|
|
287
|
+
value["command"] = tuple(value["command"])
|
|
288
|
+
value["identity_fields"] = frozenset(value["identity_fields"])
|
|
289
|
+
return SchemaCandidate(**value)
|
|
373
290
|
|
|
374
291
|
|
|
375
292
|
def derive_identity_fields(schema: dict[str, Any] | None) -> frozenset[str]:
|
|
376
|
-
|
|
377
|
-
return frozenset()
|
|
378
|
-
found: set[str] = set()
|
|
379
|
-
stack: list[Any] = [schema]
|
|
380
|
-
seen: set[int] = set()
|
|
381
|
-
while stack:
|
|
382
|
-
current = stack.pop()
|
|
383
|
-
current_id = id(current)
|
|
384
|
-
if current_id in seen:
|
|
385
|
-
continue
|
|
386
|
-
seen.add(current_id)
|
|
387
|
-
if isinstance(current, dict):
|
|
388
|
-
properties = current.get("properties")
|
|
389
|
-
if isinstance(properties, dict):
|
|
390
|
-
for key, value in properties.items():
|
|
391
|
-
normalized = _normalize_identity_field(key)
|
|
392
|
-
if normalized in IDENTITY_FIELD_CANDIDATES:
|
|
393
|
-
found.add(normalized)
|
|
394
|
-
stack.append(value)
|
|
395
|
-
for key in (
|
|
396
|
-
"items",
|
|
397
|
-
"anyOf",
|
|
398
|
-
"oneOf",
|
|
399
|
-
"allOf",
|
|
400
|
-
"$defs",
|
|
401
|
-
"definitions",
|
|
402
|
-
"patternProperties",
|
|
403
|
-
):
|
|
404
|
-
value = current.get(key)
|
|
405
|
-
if value is not None:
|
|
406
|
-
stack.append(value)
|
|
407
|
-
elif isinstance(current, list):
|
|
408
|
-
stack.extend(current)
|
|
409
|
-
return frozenset(found)
|
|
293
|
+
return frozenset(_schema_operation("derive", schema=schema))
|
|
410
294
|
|
|
411
295
|
|
|
412
296
|
def _identity_fields_for(
|
|
@@ -571,11 +455,13 @@ def _cache_file(candidate: SchemaCandidate, root: Path) -> Path:
|
|
|
571
455
|
return root / f"{digest}.json"
|
|
572
456
|
|
|
573
457
|
|
|
574
|
-
def _fetch_https(
|
|
458
|
+
def _fetch_https(
|
|
459
|
+
url: str, headers: Mapping[str, str], *, env: Mapping[str, str] | None = None
|
|
460
|
+
) -> FetchResponse:
|
|
575
461
|
request = urllib.request.Request(url, headers=dict(headers)) # noqa: S310
|
|
576
462
|
context = ssl.create_default_context()
|
|
577
463
|
opener = urllib.request.build_opener(
|
|
578
|
-
_HttpsOnlyRedirectHandler,
|
|
464
|
+
_HttpsOnlyRedirectHandler(env),
|
|
579
465
|
urllib.request.HTTPSHandler(context=context),
|
|
580
466
|
)
|
|
581
467
|
with opener.open( # noqa: S310 - URL and redirects are validated before fetch.
|
|
@@ -593,6 +479,10 @@ def _fetch_https(url: str, headers: Mapping[str, str]) -> FetchResponse:
|
|
|
593
479
|
|
|
594
480
|
|
|
595
481
|
class _HttpsOnlyRedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
482
|
+
def __init__(self, env: Mapping[str, str] | None = None) -> None:
|
|
483
|
+
super().__init__()
|
|
484
|
+
self._schema_env = env or {}
|
|
485
|
+
|
|
596
486
|
def redirect_request(
|
|
597
487
|
self,
|
|
598
488
|
req: urllib.request.Request,
|
|
@@ -610,6 +500,11 @@ class _HttpsOnlyRedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
|
610
500
|
dict(headers),
|
|
611
501
|
fp,
|
|
612
502
|
)
|
|
503
|
+
# Every HTTPS redirect is a new network target. Check it before
|
|
504
|
+
# urllib opens the redirected request, not only after receiving bytes
|
|
505
|
+
# from its final_url (#256). Honour the same explicit private-host
|
|
506
|
+
# override as the initial request.
|
|
507
|
+
_validate_schema_url(newurl, self._schema_env)
|
|
613
508
|
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
614
509
|
|
|
615
510
|
|
|
@@ -674,8 +569,12 @@ def _validate_schema_url(url: str, env: Mapping[str, str]) -> None:
|
|
|
674
569
|
def _is_private_host(host: str) -> bool:
|
|
675
570
|
try:
|
|
676
571
|
addresses = {info[4][0] for info in socket.getaddrinfo(host, None)}
|
|
677
|
-
except OSError:
|
|
678
|
-
|
|
572
|
+
except OSError as exc:
|
|
573
|
+
# DNS failure must not certify a host as public: urllib would perform
|
|
574
|
+
# its own later lookup, which could resolve to a private address (#255).
|
|
575
|
+
raise ValueError(f"schema URL host could not be resolved: {host}") from exc
|
|
576
|
+
if not addresses:
|
|
577
|
+
raise ValueError(f"schema URL host returned no addresses: {host}")
|
|
679
578
|
for address in addresses:
|
|
680
579
|
try:
|
|
681
580
|
ip = ipaddress.ip_address(address)
|
|
@@ -691,126 +590,3 @@ def _is_private_host(host: str) -> bool:
|
|
|
691
590
|
):
|
|
692
591
|
return True
|
|
693
592
|
return False
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
def _dbt_schema_url(basename: str, language_id: str, content: str) -> str | None:
|
|
697
|
-
if basename in {"dbt_project.yml", "dbt_project.yaml"}:
|
|
698
|
-
return DBT_SCHEMA_URLS["dbt_project"]
|
|
699
|
-
if basename in {"packages.yml", "packages.yaml"}:
|
|
700
|
-
return DBT_SCHEMA_URLS["packages"]
|
|
701
|
-
if basename in {"dependencies.yml", "dependencies.yaml"}:
|
|
702
|
-
return DBT_SCHEMA_URLS["dependencies"]
|
|
703
|
-
if basename in {"selectors.yml", "selectors.yaml"}:
|
|
704
|
-
return DBT_SCHEMA_URLS["selectors"]
|
|
705
|
-
if basename in {"dbt_cloud.yml", "dbt_cloud.yaml"}:
|
|
706
|
-
return DBT_SCHEMA_URLS["dbt_cloud"]
|
|
707
|
-
if language_id in {"dbt-yaml", "dbt-config", "dbt-packages"}:
|
|
708
|
-
if language_id == "dbt-config":
|
|
709
|
-
return DBT_SCHEMA_URLS["dbt_project"]
|
|
710
|
-
if language_id == "dbt-packages":
|
|
711
|
-
return DBT_SCHEMA_URLS["packages"]
|
|
712
|
-
return DBT_SCHEMA_URLS["dbt_yml_files"]
|
|
713
|
-
markers = ("version", "models", "sources", "exposures", "seeds", "snapshots")
|
|
714
|
-
if basename.endswith((".yml", ".yaml")) and any(
|
|
715
|
-
re.search(rf"(?m)^\s*{re.escape(marker)}\s*:", content) for marker in markers
|
|
716
|
-
):
|
|
717
|
-
return DBT_SCHEMA_URLS["dbt_yml_files"]
|
|
718
|
-
return None
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
def _openapi_schema_url(basename: str, content: str) -> str | None:
|
|
722
|
-
if not basename.endswith((".json", ".yaml", ".yml")):
|
|
723
|
-
return None
|
|
724
|
-
lowered = basename.lower()
|
|
725
|
-
named_like_openapi = lowered in {
|
|
726
|
-
"openapi.json",
|
|
727
|
-
"openapi.yaml",
|
|
728
|
-
"openapi.yml",
|
|
729
|
-
"swagger.json",
|
|
730
|
-
"swagger.yaml",
|
|
731
|
-
"swagger.yml",
|
|
732
|
-
}
|
|
733
|
-
version = _top_level_scalar(content, "openapi")
|
|
734
|
-
if version:
|
|
735
|
-
if version.startswith("3.1"):
|
|
736
|
-
return OPENAPI_31_SCHEMA_URL
|
|
737
|
-
return OPENAPI_30_SCHEMA_URL
|
|
738
|
-
if _top_level_scalar(content, "swagger") or named_like_openapi:
|
|
739
|
-
return OPENAPI_30_SCHEMA_URL
|
|
740
|
-
return None
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
def _looks_like_kubernetes_manifest(basename: str, content: str) -> bool:
|
|
744
|
-
if not basename.endswith((".json", ".yaml", ".yml")):
|
|
745
|
-
return False
|
|
746
|
-
return bool(
|
|
747
|
-
_top_level_scalar(content, "apiVersion")
|
|
748
|
-
and _top_level_scalar(content, "kind")
|
|
749
|
-
and re.search(r"(?m)^\s*metadata\s*:", content)
|
|
750
|
-
)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
def _looks_like_github_workflow(path: str, content: str) -> bool:
|
|
754
|
-
if not path.endswith((".yaml", ".yml")):
|
|
755
|
-
return False
|
|
756
|
-
if "/.github/workflows/" in f"/{path}":
|
|
757
|
-
return True
|
|
758
|
-
return bool(
|
|
759
|
-
re.search(r"(?m)^\s*on\s*:", content)
|
|
760
|
-
and re.search(r"(?m)^\s*jobs\s*:", content)
|
|
761
|
-
and (
|
|
762
|
-
re.search(r"(?m)^\s*uses\s*:", content)
|
|
763
|
-
or re.search(r"(?m)^\s*runs-on\s*:", content)
|
|
764
|
-
)
|
|
765
|
-
)
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
def _looks_like_azure_pipeline(path: str, content: str) -> bool:
|
|
769
|
-
basename = path.rsplit("/", 1)[-1]
|
|
770
|
-
if not path.endswith((".yaml", ".yml")):
|
|
771
|
-
return False
|
|
772
|
-
if basename in {"azure-pipelines.yml", "azure-pipelines.yaml"}:
|
|
773
|
-
return True
|
|
774
|
-
return bool(
|
|
775
|
-
re.search(r"(?m)^\s*(trigger|pr)\s*:", content)
|
|
776
|
-
and re.search(r"(?m)^\s*(stages|jobs|steps)\s*:", content)
|
|
777
|
-
and (
|
|
778
|
-
re.search(r"(?m)^\s*pool\s*:", content)
|
|
779
|
-
or re.search(r"(?m)^\s*vmImage\s*:", content)
|
|
780
|
-
or re.search(r"(?m)^\s*task\s*:", content)
|
|
781
|
-
)
|
|
782
|
-
)
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
def _top_level_scalar(content: str, key: str) -> str:
|
|
786
|
-
try:
|
|
787
|
-
parsed = json.loads(content)
|
|
788
|
-
except json.JSONDecodeError:
|
|
789
|
-
parsed = None
|
|
790
|
-
if isinstance(parsed, dict):
|
|
791
|
-
value = parsed.get(key)
|
|
792
|
-
return str(value).strip() if value is not None else ""
|
|
793
|
-
match = re.search(rf"(?m)^{re.escape(key)}\s*:\s*['\"]?([^'\"\n#]+)", content)
|
|
794
|
-
return match.group(1).strip() if match else ""
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
def _looks_like_adf_path(basename: str) -> bool:
|
|
798
|
-
direct_names = {"pipeline.json", "dataset.json", "linkedservice.json", "factory.json"}
|
|
799
|
-
return basename in direct_names or any(
|
|
800
|
-
basename.endswith(suffix)
|
|
801
|
-
for suffix in (
|
|
802
|
-
".pipeline.json",
|
|
803
|
-
".dataset.json",
|
|
804
|
-
".linkedservice.json",
|
|
805
|
-
".trigger.json",
|
|
806
|
-
)
|
|
807
|
-
)
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
def _normalize_identity_field(name: str) -> str:
|
|
811
|
-
return name.strip().lower().replace("-", "_")
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
def _looks_like_json(content: str) -> bool:
|
|
815
|
-
stripped = content.lstrip()
|
|
816
|
-
return stripped.startswith("{")
|
|
@@ -33,9 +33,10 @@ def normalize_generic_text_for_review(
|
|
|
33
33
|
"""Replace generic parser token churn with line/character text spans.
|
|
34
34
|
|
|
35
35
|
Rust-authoritative (readiness #90/#91): the Rust generic-text review is the
|
|
36
|
-
only implementation.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
only implementation. Only an explicit Rust-certified LCS size-cap decline
|
|
37
|
+
passes through the existing change DTOs. An unavailable Rust handler or
|
|
38
|
+
malformed response raises rather than manufacturing a successful review.
|
|
39
|
+
The implementation lives in ``text_review_generic.rs``.
|
|
39
40
|
"""
|
|
40
41
|
from intentumdiff.rust_core import try_rust_generic_text_review
|
|
41
42
|
|