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.
Files changed (139) hide show
  1. intentumdiff/__init__.py +2 -0
  2. intentumdiff/__main__.py +12 -0
  3. intentumdiff/_differ_presentation.py +35 -682
  4. intentumdiff/_differ_runtime.py +13 -47
  5. intentumdiff/analysis/compile_commands.py +26 -141
  6. intentumdiff/analysis/cross_file.py +2 -4
  7. intentumdiff/analysis/guardrail_reports.py +7 -5
  8. intentumdiff/analysis/guardrails.py +110 -122
  9. intentumdiff/analysis/invariances.py +4 -1003
  10. intentumdiff/analysis/schema_resolver.py +49 -273
  11. intentumdiff/analysis/text_review.py +4 -3
  12. intentumdiff/analysis/user_schemas.py +55 -237
  13. intentumdiff/api.py +21 -0
  14. intentumdiff/cache/sqlite_store.py +5 -23
  15. intentumdiff/cli/__init__.py +59 -0
  16. intentumdiff/cli/_commands.py +174 -67
  17. intentumdiff/cli/_parser.py +11 -1
  18. intentumdiff/cli/_shared.py +96 -112
  19. intentumdiff/content_type.py +13 -30
  20. intentumdiff/core/commit_differ.py +105 -220
  21. intentumdiff/core/diffignore.py +28 -34
  22. intentumdiff/core/index.py +16 -18
  23. intentumdiff/core/indexer.py +148 -168
  24. intentumdiff/core/models.py +53 -14
  25. intentumdiff/differ.py +278 -605
  26. intentumdiff/github_app.py +35 -19
  27. intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
  28. intentumdiff/live_server.py +180 -17
  29. intentumdiff/lsp/client.py +7 -1
  30. intentumdiff/lsp/enricher.py +19 -119
  31. intentumdiff/lsp/exceptions.py +6 -7
  32. intentumdiff/lsp_server/_codelens.py +24 -57
  33. intentumdiff/lsp_server/_diagnostics.py +23 -51
  34. intentumdiff/lsp_server/_handlers.py +66 -8
  35. intentumdiff/lsp_server/server.py +28 -7
  36. intentumdiff/plugins/adapter.py +5 -0
  37. intentumdiff/plugins/builtins.py +7 -14
  38. intentumdiff/plugins/exceptions.py +4 -0
  39. intentumdiff/plugins/hub.py +1 -2
  40. intentumdiff/plugins/loader.py +229 -215
  41. intentumdiff/plugins/registry.py +249 -197
  42. intentumdiff/rust_core.py +744 -784
  43. intentumdiff/serve/_app.py +3 -10
  44. intentumdiff/sources/base.py +24 -0
  45. intentumdiff/sources/file_source.py +15 -2
  46. intentumdiff/sources/git_source.py +120 -58
  47. intentumdiff/sources/live_buffer_source.py +45 -5
  48. intentumdiff/sources/patch_source.py +36 -109
  49. intentumdiff/vcs/_safe_path.py +7 -0
  50. intentumdiff/vcs/base.py +6 -0
  51. intentumdiff/vcs/git_backend.py +1 -1
  52. intentumdiff/vcs/git_cli.py +38 -18
  53. intentumdiff/vcs/hg_backend.py +1 -1
  54. intentumdiff/vcs/perforce_backend.py +7 -1
  55. intentumdiff/vcs/svn_backend.py +1 -1
  56. intentumdiff/wasm/abap_parser.wasm +0 -0
  57. intentumdiff/wasm/adf_parser.wasm +0 -0
  58. intentumdiff/wasm/asciidoc_parser.wasm +0 -0
  59. intentumdiff/wasm/asm_parser.wasm +0 -0
  60. intentumdiff/wasm/assemblyscript_parser.wasm +0 -0
  61. intentumdiff/wasm/astro_parser.wasm +0 -0
  62. intentumdiff/wasm/bash_parser.wasm +0 -0
  63. intentumdiff/wasm/clojure_parser.wasm +0 -0
  64. intentumdiff/wasm/cmake_parser.wasm +0 -0
  65. intentumdiff/wasm/cpp_parser.wasm +0 -0
  66. intentumdiff/wasm/csharp_parser.wasm +0 -0
  67. intentumdiff/wasm/css_parser.wasm +0 -0
  68. intentumdiff/wasm/dart_parser.wasm +0 -0
  69. intentumdiff/wasm/databricks_parser.wasm +0 -0
  70. intentumdiff/wasm/dax_parser.wasm +0 -0
  71. intentumdiff/wasm/delphi_parser.wasm +0 -0
  72. intentumdiff/wasm/dockerfile_parser.wasm +0 -0
  73. intentumdiff/wasm/elixir_parser.wasm +0 -0
  74. intentumdiff/wasm/freebasic_parser.wasm +0 -0
  75. intentumdiff/wasm/generic_parser.wasm +0 -0
  76. intentumdiff/wasm/gitignore_parser.wasm +0 -0
  77. intentumdiff/wasm/go_parser.wasm +0 -0
  78. intentumdiff/wasm/gomod_parser.wasm +0 -0
  79. intentumdiff/wasm/graphql_parser.wasm +0 -0
  80. intentumdiff/wasm/groovy_parser.wasm +0 -0
  81. intentumdiff/wasm/haskell_parser.wasm +0 -0
  82. intentumdiff/wasm/html_parser.wasm +0 -0
  83. intentumdiff/wasm/html_renderer.wasm +0 -0
  84. intentumdiff/wasm/ini_parser.wasm +0 -0
  85. intentumdiff/wasm/java_parser.wasm +0 -0
  86. intentumdiff/wasm/js_ts_parser.wasm +0 -0
  87. intentumdiff/wasm/json_parser.wasm +0 -0
  88. intentumdiff/wasm/kotlin_parser.wasm +0 -0
  89. intentumdiff/wasm/latex_parser.wasm +0 -0
  90. intentumdiff/wasm/llm_renderer.wasm +0 -0
  91. intentumdiff/wasm/lua_parser.wasm +0 -0
  92. intentumdiff/wasm/make_parser.wasm +0 -0
  93. intentumdiff/wasm/markdown_parser.wasm +0 -0
  94. intentumdiff/wasm/mdx_parser.wasm +0 -0
  95. intentumdiff/wasm/ocaml_parser.wasm +0 -0
  96. intentumdiff/wasm/odin_parser.wasm +0 -0
  97. intentumdiff/wasm/parser_manifest.json +81 -2
  98. intentumdiff/wasm/patch_renderer.wasm +0 -0
  99. intentumdiff/wasm/perl_parser.wasm +0 -0
  100. intentumdiff/wasm/php_parser.wasm +0 -0
  101. intentumdiff/wasm/plsql_parser.wasm +0 -0
  102. intentumdiff/wasm/po_parser.wasm +0 -0
  103. intentumdiff/wasm/postscript_parser.wasm +0 -0
  104. intentumdiff/wasm/powershell_parser.wasm +0 -0
  105. intentumdiff/wasm/proto_parser.wasm +0 -0
  106. intentumdiff/wasm/puppet_parser.wasm +0 -0
  107. intentumdiff/wasm/python_parser.wasm +0 -0
  108. intentumdiff/wasm/qsharp_parser.wasm +0 -0
  109. intentumdiff/wasm/r_parser.wasm +0 -0
  110. intentumdiff/wasm/reasonml_parser.wasm +0 -0
  111. intentumdiff/wasm/ruby_parser.wasm +0 -0
  112. intentumdiff/wasm/rust_parser.wasm +0 -0
  113. intentumdiff/wasm/sas_parser.wasm +0 -0
  114. intentumdiff/wasm/scala_parser.wasm +0 -0
  115. intentumdiff/wasm/scss_parser.wasm +0 -0
  116. intentumdiff/wasm/sql_parser.wasm +0 -0
  117. intentumdiff/wasm/squirrel_parser.wasm +0 -0
  118. intentumdiff/wasm/svelte_parser.wasm +0 -0
  119. intentumdiff/wasm/swift_parser.wasm +0 -0
  120. intentumdiff/wasm/terminal_renderer.wasm +0 -0
  121. intentumdiff/wasm/terraform_parser.wasm +0 -0
  122. intentumdiff/wasm/toml_parser.wasm +0 -0
  123. intentumdiff/wasm/tsql_parser.wasm +0 -0
  124. intentumdiff/wasm/vbnet_parser.wasm +0 -0
  125. intentumdiff/wasm/vue_parser.wasm +0 -0
  126. intentumdiff/wasm/wasm_provenance.json +884 -0
  127. intentumdiff/wasm/wat_parser.wasm +0 -0
  128. intentumdiff/wasm/xml_parser.wasm +0 -0
  129. intentumdiff/wasm/yaml_parser.wasm +0 -0
  130. intentumdiff/wasm/zig_parser.wasm +0 -0
  131. intentumdiff_python-0.0.2b2.dist-info/METADATA +156 -0
  132. intentumdiff_python-0.0.2b2.dist-info/RECORD +171 -0
  133. {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/WHEEL +1 -1
  134. {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +905 -379
  135. intentumdiff/core/cst_serializer.py +0 -101
  136. intentumdiff_python-0.0.1.dist-info/METADATA +0 -112
  137. intentumdiff_python-0.0.1.dist-info/RECORD +0 -165
  138. {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.2b2.dist-info}/entry_points.txt +0 -0
  139. {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
- match_user_profile,
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
- if user_profiles:
162
- profile = match_user_profile(
163
- user_profiles,
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
- language_id = (language or "").lower()
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
- normalized_path = filename.replace("\\", "/").lower()
306
- basename = normalized_path.rsplit("/", 1)[-1]
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
- if language_id in {"databricks", "databricks-workflow"} or basename in {
345
- "databricks.yml",
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
- return None
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
- if not schema:
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(url: str, headers: Mapping[str, str]) -> FetchResponse:
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
- addresses = {host}
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. When it declines (backend unavailable, or the input
37
- exceeds its size cap), the changes pass through unchanged — "if Python didn't
38
- exist, IntentumDiff still works". The full port lives in ``text_review_generic.rs``.
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