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.
Files changed (92) hide show
  1. intentumdiff/__init__.py +7 -0
  2. intentumdiff/_differ_gate.py +0 -136
  3. intentumdiff/_differ_presentation.py +1 -72
  4. intentumdiff/_differ_runtime.py +0 -17
  5. intentumdiff/analysis/cross_file.py +21 -21
  6. intentumdiff/analysis/diagnostics.py +1 -164
  7. intentumdiff/analysis/guardrail_reports.py +24 -28
  8. intentumdiff/analysis/guardrails.py +2 -67
  9. intentumdiff/analysis/schema_resolver.py +23 -87
  10. intentumdiff/analysis/user_schemas.py +2 -17
  11. intentumdiff/cli/_commands.py +70 -71
  12. intentumdiff/cli/_parser.py +40 -55
  13. intentumdiff/cli/_shared.py +55 -4
  14. intentumdiff/core/commit_differ.py +65 -99
  15. intentumdiff/core/indexer.py +0 -1
  16. intentumdiff/core/models.py +226 -69
  17. intentumdiff/differ.py +125 -432
  18. intentumdiff/github_app.py +5 -8
  19. intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
  20. intentumdiff/live_server.py +17 -17
  21. intentumdiff/lsp/client.py +42 -42
  22. intentumdiff/lsp/servers.py +10 -11
  23. intentumdiff/lsp_server/_handlers.py +1 -1
  24. intentumdiff/lsp_server/server.py +0 -1
  25. intentumdiff/plugins/exceptions.py +24 -0
  26. intentumdiff/plugins/hub.py +38 -41
  27. intentumdiff/plugins/registry.py +10 -10
  28. intentumdiff/plugins/registry.schema.json +156 -15
  29. intentumdiff/plugins/registry_schema.py +47 -140
  30. intentumdiff/rust_core.py +112 -775
  31. intentumdiff/serve/_app.py +23 -25
  32. intentumdiff/sources/git_source.py +0 -183
  33. intentumdiff/vcs/git_cli.py +0 -47
  34. intentumdiff/wasm/abap_parser.wasm +0 -0
  35. intentumdiff/wasm/adf_parser.wasm +0 -0
  36. intentumdiff/wasm/asciidoc_parser.wasm +0 -0
  37. intentumdiff/wasm/asm_parser.wasm +0 -0
  38. intentumdiff/wasm/assemblyscript_parser.wasm +0 -0
  39. intentumdiff/wasm/astro_parser.wasm +0 -0
  40. intentumdiff/wasm/bash_parser.wasm +0 -0
  41. intentumdiff/wasm/cpp_parser.wasm +0 -0
  42. intentumdiff/wasm/csharp_parser.wasm +0 -0
  43. intentumdiff/wasm/databricks_parser.wasm +0 -0
  44. intentumdiff/wasm/dax_parser.wasm +0 -0
  45. intentumdiff/wasm/dockerfile_parser.wasm +0 -0
  46. intentumdiff/wasm/freebasic_parser.wasm +0 -0
  47. intentumdiff/wasm/generic_parser.wasm +0 -0
  48. intentumdiff/wasm/gitignore_parser.wasm +0 -0
  49. intentumdiff/wasm/graphql_parser.wasm +0 -0
  50. intentumdiff/wasm/groovy_parser.wasm +0 -0
  51. intentumdiff/wasm/js_ts_parser.wasm +0 -0
  52. intentumdiff/wasm/json_parser.wasm +0 -0
  53. intentumdiff/wasm/kotlin_parser.wasm +0 -0
  54. intentumdiff/wasm/latex_parser.wasm +0 -0
  55. intentumdiff/wasm/make_parser.wasm +0 -0
  56. intentumdiff/wasm/mdx_parser.wasm +0 -0
  57. intentumdiff/wasm/ocaml_parser.wasm +0 -0
  58. intentumdiff/wasm/odin_parser.wasm +0 -0
  59. intentumdiff/wasm/perl_parser.wasm +0 -0
  60. intentumdiff/wasm/php_parser.wasm +0 -0
  61. intentumdiff/wasm/plsql_parser.wasm +0 -0
  62. intentumdiff/wasm/postscript_parser.wasm +0 -0
  63. intentumdiff/wasm/powershell_parser.wasm +0 -0
  64. intentumdiff/wasm/python_parser.wasm +0 -0
  65. intentumdiff/wasm/qsharp_parser.wasm +0 -0
  66. intentumdiff/wasm/reasonml_parser.wasm +0 -0
  67. intentumdiff/wasm/rust_parser.wasm +0 -0
  68. intentumdiff/wasm/sas_parser.wasm +0 -0
  69. intentumdiff/wasm/sql_parser.wasm +0 -0
  70. intentumdiff/wasm/svelte_parser.wasm +0 -0
  71. intentumdiff/wasm/swift_parser.wasm +0 -0
  72. intentumdiff/wasm/tsql_parser.wasm +0 -0
  73. intentumdiff/wasm/vbnet_parser.wasm +0 -0
  74. intentumdiff/wasm/vue_parser.wasm +0 -0
  75. intentumdiff/wasm/wasm_provenance.json +219 -219
  76. intentumdiff/wasm/wat_parser.wasm +0 -0
  77. intentumdiff/wasm/yaml_parser.wasm +0 -0
  78. intentumdiff/watcher.py +15 -17
  79. {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/METADATA +38 -6
  80. intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
  81. {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +2 -2
  82. intentumdiff/analysis/invariances.py +0 -208
  83. intentumdiff/analysis/keyed_profiles.py +0 -25
  84. intentumdiff/analysis/resource_profiles.py +0 -14
  85. intentumdiff/analysis/text_review.py +0 -47
  86. intentumdiff/invariances/__init__.py +0 -2
  87. intentumdiff/invariances/rules.schema.json +0 -283
  88. intentumdiff/invariances/rules.yaml +0 -349
  89. intentumdiff_python-0.0.2b2.dist-info/RECORD +0 -171
  90. {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +0 -0
  91. {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/entry_points.txt +0 -0
  92. {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/licenses/LICENSE +0 -0
@@ -50,7 +50,7 @@ def verify_webhook_signature(secret: str, body: bytes, signature_header: str | N
50
50
  if not secret or not signature_header or not signature_header.startswith("sha256="):
51
51
  return False
52
52
  expected = "sha256=" + hmac.new(secret.encode("utf-8"), body, hashlib.sha256).hexdigest()
53
- return hmac.compare_digest(expected, signature_header)
53
+ return hmac.compare_digest(expected.encode("ascii"), signature_header.encode("utf-8"))
54
54
 
55
55
 
56
56
  def parse_pull_request_url(url: str) -> PullRequestRef:
@@ -94,16 +94,13 @@ def parse_pull_request_event(payload: Mapping[str, Any]) -> PullRequestRef:
94
94
  full_name = str(repository.get("full_name") or "")
95
95
  if "/" not in full_name:
96
96
  raise GitHubAppError("Webhook repository.full_name must be OWNER/REPO")
97
- number = pull_request.get("number") or payload.get("number")
98
- try:
99
- pr_number = int(number)
100
- except (TypeError, ValueError) as exc:
101
- raise GitHubAppError("Webhook pull request number must be an integer") from exc
97
+ pr_number = pull_request.get("number") or payload.get("number")
98
+ # Exact int only: int() coerced True and 1.5 to pull request 1 (#322); bool is excluded.
99
+ if type(pr_number) is not int or pr_number <= 0:
100
+ raise GitHubAppError("Webhook pull request number must be a positive integer")
102
101
  owner, repo = full_name.split("/", 1)
103
102
  if not owner or not repo:
104
103
  raise GitHubAppError("Webhook repository.full_name must be OWNER/REPO")
105
- if pr_number <= 0:
106
- raise GitHubAppError("Webhook pull request number must be positive")
107
104
  return PullRequestRef(owner=owner, repo=repo, number=pr_number)
108
105
 
109
106
 
@@ -327,19 +327,12 @@ if sys.platform == "win32": # pragma: no cover
327
327
  DACL when the module-level struct could not be built.
328
328
  """
329
329
  handle = ctypes.windll.kernel32.CreateNamedPipeW(
330
- name,
331
- _PIPE_ACCESS_DUPLEX,
332
- _PIPE_TYPE_BYTE | _PIPE_WAIT,
333
- _PIPE_UNLIMITED_INSTANCES,
334
- 65536,
335
- 65536,
336
- 0,
330
+ name, _PIPE_ACCESS_DUPLEX, _PIPE_TYPE_BYTE | _PIPE_WAIT, _PIPE_UNLIMITED_INSTANCES,
331
+ 65536, 65536, 0,
337
332
  ctypes.byref(_pipe_sa) if _pipe_sa is not None else None, # type: ignore[name-defined]
338
333
  )
339
334
  if handle == _INVALID_HANDLE:
340
- raise OSError(
341
- f"CreateNamedPipeW failed (error {ctypes.GetLastError()})"
342
- )
335
+ raise OSError(f"CreateNamedPipeW failed (error {ctypes.GetLastError()})")
343
336
  return handle
344
337
 
345
338
  def _open_pipe_client(name: str) -> None:
@@ -386,9 +379,7 @@ if sys.platform == "win32": # pragma: no cover
386
379
  server stop-event is set."""
387
380
  avail = _wt.DWORD(0)
388
381
  while not self._stop_event.is_set():
389
- ok = _PeekNamedPipe(
390
- self._handle, None, 0, None, ctypes.byref(avail), None
391
- )
382
+ ok = _PeekNamedPipe(self._handle, None, 0, None, ctypes.byref(avail), None)
392
383
  if not ok:
393
384
  return b"" # pipe broken
394
385
  if avail.value > 0:
@@ -403,10 +394,9 @@ if sys.platform == "win32": # pragma: no cover
403
394
  return b"" # stop requested
404
395
 
405
396
  def sendall(self, data: bytes) -> None:
406
- n_written = _wt.DWORD(0)
407
- ctypes.windll.kernel32.WriteFile(
408
- self._handle, data, len(data), ctypes.byref(n_written), None
409
- )
397
+ n, kernel32 = _wt.DWORD(0), ctypes.windll.kernel32 # a failed WriteFile counts 0
398
+ _write_all(lambda chunk: kernel32.WriteFile(
399
+ self._handle, chunk, len(chunk), ctypes.byref(n), None) and n.value, data)
410
400
 
411
401
  def close(self) -> None:
412
402
  if not self._closed:
@@ -1468,6 +1458,16 @@ def _write_line(stream: "Any", obj: dict[str, Any]) -> None:
1468
1458
  pass
1469
1459
 
1470
1460
 
1461
+ def _write_all(write: Any, data: bytes) -> None:
1462
+ """Send all of *data* via ``write(chunk) -> bytes written`` (0 = failed), or raise (#327)."""
1463
+ view = memoryview(data)
1464
+ while view:
1465
+ written = write(bytes(view))
1466
+ if not written: # WriteFile failed, or wrote nothing: the peer is gone
1467
+ raise BrokenPipeError("named-pipe write failed before the whole response was sent")
1468
+ view = view[written:]
1469
+
1470
+
1471
1471
  def _write_line_bytes(sock: socket.socket, obj: dict[str, Any]) -> None:
1472
1472
  """Write *obj* as a JSON line to a socket."""
1473
1473
  try:
@@ -175,7 +175,11 @@ class AsyncLspClient:
175
175
  await self._cleanup_start_failure()
176
176
  raise
177
177
  except asyncio.CancelledError as exc:
178
- # The server closed its connection during the initialize handshake.
178
+ current = asyncio.current_task()
179
+ if current is not None and current.cancelling(): # the caller cancelled: keep that
180
+ await self._cleanup_start_failure()
181
+ raise
182
+ # Otherwise the server closed its connection during the initialize handshake.
179
183
  # Yield once so _drain_stderr can read any buffered output.
180
184
  await asyncio.sleep(0)
181
185
  hint = self._stderr_hint()
@@ -194,24 +198,27 @@ class AsyncLspClient:
194
198
  logger.debug("LSP client connected to %s", self._config)
195
199
 
196
200
  async def _cleanup_start_failure(self) -> None:
197
- """Cancel reader task and release resources after a failed :meth:`start`."""
198
- if self._stderr_task is not None:
199
- self._stderr_task.cancel()
200
- with suppress(Exception):
201
- await self._stderr_task
202
- self._stderr_task = None
203
- if self._reader_task is not None:
204
- self._reader_task.cancel()
205
- with suppress(Exception):
206
- await self._reader_task
207
- self._reader_task = None
208
- if self._writer is not None:
209
- with suppress(Exception):
210
- self._writer.close()
211
- if self._process is not None:
212
- with suppress(Exception):
213
- self._process.terminate()
214
- self._process = None
201
+ """Release every resource a failed :meth:`start` owns, even when cancelled (#313).
202
+
203
+ Awaiting a cancelled task raises CancelledError, a BaseException, which used to escape
204
+ ``suppress(Exception)`` before the writer was closed and the process was terminated.
205
+ """
206
+ tasks = [task for task in (self._stderr_task, self._reader_task) if task is not None]
207
+ self._stderr_task = self._reader_task = None
208
+ process, self._process = self._process, None
209
+ for task in tasks:
210
+ task.cancel()
211
+ try:
212
+ await asyncio.gather(*tasks, return_exceptions=True)
213
+ finally:
214
+ if self._writer is not None:
215
+ with suppress(Exception):
216
+ self._writer.close()
217
+ if process is not None:
218
+ with suppress(ProcessLookupError):
219
+ process.kill() # it never finished initialize; reap it
220
+ with suppress(Exception):
221
+ await asyncio.wait_for(process.wait(), timeout=3.0)
215
222
 
216
223
  async def _start_tcp(self) -> None:
217
224
  """Establish a TCP connection to an already-running server."""
@@ -411,31 +418,24 @@ class AsyncLspClient:
411
418
 
412
419
  async def _send_request(self, method: str, params: Any) -> Any:
413
420
  rid = self._next_request_id()
414
- loop = asyncio.get_running_loop()
415
- fut: asyncio.Future[Any] = loop.create_future()
421
+ fut: asyncio.Future[Any] = asyncio.get_running_loop().create_future()
416
422
  self._pending[rid] = fut
417
- self._send_raw(_request(method, params, rid))
418
- # Drain the write buffer
419
- writer = self._writer
420
- if writer is None:
421
- self._pending.pop(rid, None)
422
- raise LspConnectionError(f"LSP client for {self._config} is not connected")
423
- try:
424
- await asyncio.wait_for(writer.drain(), timeout=self._timeout)
425
- except asyncio.TimeoutError as exc:
426
- self._pending.pop(rid, None)
427
- raise LspTimeoutError(
428
- f"Write timeout sending {method!r} to {self._config}"
429
- ) from exc
430
- try:
431
- return await asyncio.wait_for(
432
- asyncio.shield(fut), timeout=self._timeout
433
- )
434
- except asyncio.TimeoutError as exc:
423
+ try: # the registration never outlives this call, however it ends (#313)
424
+ self._send_raw(_request(method, params, rid)) # raises when not connected
425
+ writer: Any = self._writer
426
+ try:
427
+ await asyncio.wait_for(writer.drain(), timeout=self._timeout)
428
+ except asyncio.TimeoutError as exc:
429
+ message = f"Write timeout sending {method!r} to {self._config}"
430
+ raise LspTimeoutError(message) from exc
431
+ try:
432
+ return await asyncio.wait_for(asyncio.shield(fut), timeout=self._timeout)
433
+ except asyncio.TimeoutError as exc:
434
+ raise LspTimeoutError(
435
+ f"No response to {method!r} from {self._config} within {self._timeout}s"
436
+ ) from exc
437
+ finally:
435
438
  self._pending.pop(rid, None)
436
- raise LspTimeoutError(
437
- f"No response to {method!r} from {self._config} within {self._timeout}s"
438
- ) from exc
439
439
 
440
440
  async def _drain_stderr(self) -> None:
441
441
  """Background task: drain subprocess stderr into a capped ring buffer."""
@@ -26,7 +26,7 @@ from __future__ import annotations
26
26
 
27
27
  import json
28
28
  import logging
29
- from dataclasses import dataclass, field
29
+ from dataclasses import dataclass
30
30
  from pathlib import Path
31
31
  from typing import TYPE_CHECKING, Literal
32
32
 
@@ -305,9 +305,9 @@ treated as already-running and IntentumDiff simply connects to
305
305
  def load_lsp_servers_json(path: "Path | str") -> dict[str, LspServerEntry]:
306
306
  """Load user-defined LSP server entries from an ``lsp_servers.json`` file.
307
307
 
308
- Returns a mapping of **language → entry**. If multiple entries share the
309
- same language the last one in the file wins. Returns an empty dict if the
310
- file does not exist.
308
+ Returns a mapping of **language → entry** in file order. Two entries for the
309
+ same language are rejected (ValueError naming both) rather than one silently
310
+ shadowing the other (#312). Returns an empty dict if the file does not exist.
311
311
 
312
312
  Parameters
313
313
  ----------
@@ -333,6 +333,7 @@ def load_lsp_servers_json(path: "Path | str") -> dict[str, LspServerEntry]:
333
333
  raise ValueError(f"{p}: expected a JSON object at the top level")
334
334
 
335
335
  result: dict[str, LspServerEntry] = {}
336
+ names: dict[str, str] = {}
336
337
  for server_name, data in raw.items():
337
338
  if not isinstance(data, dict):
338
339
  raise ValueError(
@@ -344,13 +345,11 @@ def load_lsp_servers_json(path: "Path | str") -> dict[str, LspServerEntry]:
344
345
  raise ValueError(
345
346
  f"{p}: invalid entry {server_name!r}: {exc}"
346
347
  ) from exc
347
- # Key by language; first entry for a language wins.
348
- if entry.language not in result:
349
- result[entry.language] = entry
350
- else:
351
- logger.debug(
352
- "lsp_servers.json: skipping %r — language %r already registered",
353
- server_name, entry.language,
348
+ if entry.language in result:
349
+ raise ValueError(
350
+ f"{p}: entries {server_name!r} and {names[entry.language]!r} both serve "
351
+ f"language {entry.language!r}; keep one"
354
352
  )
353
+ result[entry.language], names[entry.language] = entry, server_name
355
354
 
356
355
  return result
@@ -20,7 +20,7 @@ from intentumdiff.differ import SemanticDiffer
20
20
  try:
21
21
  from pygls.lsp.server import LanguageServer # pygls >= 2.x
22
22
  except ImportError:
23
- from pygls.server import LanguageServer # type: ignore[assignment] # pygls 1.x
23
+ pass # type: ignore[assignment] # pygls 1.x
24
24
 
25
25
  log = logging.getLogger(__name__)
26
26
 
@@ -30,7 +30,6 @@ except ImportError:
30
30
  from intentumdiff.core.models import DiffConfig
31
31
  from intentumdiff.differ import SemanticDiffer
32
32
  from intentumdiff.lsp_server._codelens import semantic_diff_to_codelens
33
- from intentumdiff.lsp_server._diagnostics import semantic_diff_to_diagnostics
34
33
  from intentumdiff.lsp_server._handlers import (
35
34
  _ServerState,
36
35
  _do_diff,
@@ -95,3 +95,27 @@ class PluginLoadError(PluginError):
95
95
 
96
96
  class PluginSecurityError(PluginLoadError):
97
97
  """A security gate denied loading; parser fallback must not bypass the denial."""
98
+
99
+
100
+ class RegistryManifestError(RuntimeError):
101
+ """The plugin registry manifest is not valid YAML or fails core's validator (#309, #329).
102
+
103
+ A ``RuntimeError``, the error :func:`~intentumdiff.plugins.hub.fetch_official_registry`
104
+ documents for a registry it cannot fetch or parse. The message lists every violation;
105
+ ``errors`` carries core's ``validate_registry_manifest`` errors unchanged, each a
106
+ ``{"path": <RFC 6901 pointer>, "message": str}`` dict (empty for a YAML/JSON error).
107
+ """
108
+
109
+ def __init__(self, message: str, errors: list[dict[str, str]] | None = None) -> None:
110
+ super().__init__(message)
111
+ self.errors: list[dict[str, str]] = list(errors or [])
112
+
113
+
114
+ class RegistryManifestWarning(UserWarning):
115
+ """Core's validator rejected part of the plugin registry manifest; loading continued (#309).
116
+
117
+ Entries core reports under ``/plugins/<name>`` are skipped and every other entry loads; a
118
+ manifest whose top level is unusable (core errors at ``/`` or ``/plugins``) loads none. The
119
+ message lists core's ``"<pointer>: <message>"`` errors and names the entries not loaded.
120
+ Strict tooling uses :func:`~intentumdiff.plugins.registry_schema.check_registry_manifest`.
121
+ """
@@ -76,6 +76,7 @@ from __future__ import annotations
76
76
 
77
77
  import hashlib
78
78
  import importlib.metadata as _meta
79
+ import json
79
80
  import logging
80
81
  import re
81
82
  import ssl
@@ -83,10 +84,14 @@ import subprocess
83
84
  import sys
84
85
  import urllib.error
85
86
  import urllib.request
87
+ import warnings
86
88
  from dataclasses import dataclass, field
87
89
  from pathlib import Path, PurePosixPath, PureWindowsPath
88
90
  from typing import Any
89
91
 
92
+ from intentumdiff.plugins.exceptions import RegistryManifestError, RegistryManifestWarning
93
+ from intentumdiff.plugins.registry_schema import format_manifest_error, registry_manifest_errors
94
+
90
95
  logger = logging.getLogger(__name__)
91
96
 
92
97
  # ---------------------------------------------------------------------------
@@ -386,32 +391,12 @@ def fetch_official_registry(
386
391
  strict: bool = False,
387
392
  timeout: int = 15,
388
393
  ) -> dict[str, RegistryEntry]:
389
- """
390
- Fetch and parse the official plugin registry manifest.
391
-
392
- Parameters
393
- ----------
394
- ref:
395
- Git ref (branch, tag, or commit SHA) of the registry repo to fetch
396
- from. Default ``"main"``. **Pin to a commit SHA in production for
397
- reproducible, tamper-evident installs.**
398
- strict:
399
- When ``True``, *ref* must be a full 40-character commit SHA. This
400
- enforces the production/CI policy: mutable refs (branch names, tags)
401
- are rejected. Pass ``strict=True`` via the ``--strict-registry`` CLI
402
- flag.
403
- timeout:
404
- HTTP timeout in seconds.
405
-
406
- Returns
407
- -------
408
- dict[str, RegistryEntry]
409
- Mapping of short plugin name → registry entry.
394
+ """Fetch the official registry manifest at *ref* and parse it into ``{name -> entry}``.
410
395
 
411
- Raises
412
- ------
413
- RuntimeError
414
- If the registry cannot be fetched or parsed.
396
+ Pin *ref* to a commit SHA in production; ``strict=True`` (``--strict-registry``) requires a
397
+ full 40-character SHA. Raises ``RuntimeError`` when the registry cannot be fetched and
398
+ :class:`RegistryManifestError` when it is not YAML or has no JSON form; core-rejected
399
+ entries are skipped with a :class:`RegistryManifestWarning` (#309).
415
400
  """
416
401
  _validate_registry_ref(ref, strict=strict)
417
402
  url = f"{OFFICIAL_REGISTRY_RAW_URL}/{ref}/registry.yaml"
@@ -423,26 +408,41 @@ def fetch_official_registry(
423
408
  with urllib.request.urlopen(url, timeout=timeout, context=ctx) as resp: # nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected -- scheme asserted https above; base is a fixed constant + validated ref. noqa: S310 # nosec B310 - https scheme asserted above
424
409
  content = resp.read().decode("utf-8")
425
410
  except urllib.error.URLError as exc:
426
- raise RuntimeError(
427
- f"Could not fetch the official plugin registry from {url}.\n"
428
- f"Check your internet connection. Detail: {exc}"
429
- ) from exc
430
-
411
+ raise RuntimeError(f"Could not fetch the official plugin registry from {url}.\n"
412
+ f"Check your internet connection. Detail: {exc}") from exc
431
413
  return parse_registry_manifest(content)
432
414
 
433
415
 
434
416
  def parse_registry_manifest(content: str) -> dict[str, RegistryEntry]:
435
417
  """Parse a registry manifest (YAML text) into ``{short name -> RegistryEntry}``.
436
418
 
437
- Split out from :func:`fetch_official_registry` so the parse (including the #94
438
- ``abi_target``) is testable without the network fetch.
419
+ Core's validator judges every entry (#309, #329) without blocking the load: entries it
420
+ rejects are skipped (none load if the top level is) with a :class:`RegistryManifestWarning`.
439
421
  """
440
422
  yaml = _require_yaml()
441
- data: dict[str, Any] = yaml.safe_load(content) or {}
442
-
423
+ try:
424
+ data = yaml.safe_load(content)
425
+ except yaml.YAMLError as exc:
426
+ raise RegistryManifestError(f"plugin registry manifest is not YAML: {exc}") from exc
427
+ errors = registry_manifest_errors(data)
428
+ data = json.loads(json.dumps(data)) # the document core judged (keys are JSON strings)
429
+ tokens = [error["path"].split("/")[1:] for error in errors] # RFC 6901 reference tokens
430
+ skipped = {t[1].replace("~1", "/").replace("~0", "~") for t in tokens if len(t) > 1
431
+ and t[0] == "plugins"}
432
+ plugins = data.get("plugins") if isinstance(data, dict) else None
433
+ unusable = not isinstance(plugins, dict) or any(t in ([], [""], ["plugins"]) for t in tokens)
434
+ if unusable:
435
+ skipped, plugins = set(), {}
436
+ if errors or unusable:
437
+ names = ", ".join(sorted(skipped & set(plugins))) or "none"
438
+ outcome = "no entries were loaded" if unusable else f"skipped entries: {names}"
439
+ problems = "; ".join(map(format_manifest_error, errors)) or "no usable plugins mapping"
440
+ message = f"invalid plugin registry manifest ({problems}); {outcome}"
441
+ logger.warning("%s", message)
442
+ warnings.warn(message, RegistryManifestWarning, stacklevel=2)
443
443
  entries: dict[str, RegistryEntry] = {}
444
- for plugin_name, entry_data in data.get("plugins", {}).items():
445
- if not isinstance(entry_data, dict):
444
+ for plugin_name, entry_data in plugins.items():
445
+ if plugin_name in skipped:
446
446
  continue
447
447
  entries[plugin_name] = RegistryEntry(
448
448
  name=plugin_name,
@@ -470,10 +470,8 @@ def _require_yaml() -> Any:
470
470
  import yaml # type: ignore[import-untyped]
471
471
  return yaml
472
472
  except ImportError as exc:
473
- raise ImportError(
474
- "pyyaml is required to read/write intentumdiff_plugins.yaml. "
475
- "Install it with: pip install pyyaml"
476
- ) from exc
473
+ raise ImportError("pyyaml is required to read/write intentumdiff_plugins.yaml. "
474
+ "Install it with: pip install pyyaml") from exc
477
475
 
478
476
 
479
477
  def load_plugins_file(path: Path) -> list[PluginSpec]:
@@ -986,7 +984,6 @@ def inspect_wasm_in_wheel(
986
984
 
987
985
  The wheel is not installed — no Python code from the plugin is executed.
988
986
  """
989
- import io
990
987
  import zipfile
991
988
 
992
989
  checksums: dict[str, str] = {}
@@ -20,7 +20,7 @@ non-empty string wins.
20
20
 
21
21
  Allowed-list filtering
22
22
  ──────────────────────
23
- If ``DiffConfig.allowed_plugins`` is set, only those grammar IDs are consulted.
23
+ ``DiffConfig.allowed_plugins`` follows core's ``parser_allowlist_matches`` rule (#311).
24
24
  If ``DiffConfig.strict_plugins`` is True, an error is raised for any language
25
25
  not handled by the allowed list.
26
26
  """
@@ -49,7 +49,7 @@ from intentumdiff.plugins.adapter import (
49
49
  )
50
50
  from intentumdiff.plugins.exceptions import PluginFuelExhausted, PluginNotFoundError, PluginLoadError, PluginSandboxViolation, PluginSecurityError
51
51
  from intentumdiff.plugins.language_metadata import fallback_language_info
52
- from intentumdiff.plugins.loader import LoadedPlugin, load_plugin
52
+ from intentumdiff.plugins.loader import load_plugin
53
53
 
54
54
  logger = logging.getLogger(__name__)
55
55
 
@@ -445,23 +445,23 @@ class PluginRegistry:
445
445
  f"{sample}"
446
446
  )
447
447
 
448
+ def _allowed_parsers(self) -> list[ParserAdapter]: # core's allowlist rule (#311)
449
+ from intentumdiff.rust_core import parser_allowlist_matches as allows
450
+ return [p for p in self.parsers if allows(self._config.allowed_plugins, {
451
+ "plugin_id": p.plugin_id, "grammar_id": p.grammar_id,
452
+ "languages": list(p.language_ids)})["matches"]]
453
+
448
454
  def language_ids(self) -> list[str]:
449
455
  """Return parser language IDs reported by loaded parser plugins."""
450
- allowed = set(self._config.allowed_plugins or [])
451
456
  ids: set[str] = set()
452
- for parser in self.parsers:
453
- if allowed and parser.grammar_id not in allowed:
454
- continue
457
+ for parser in self._allowed_parsers():
455
458
  ids.update(parser.language_ids)
456
459
  return sorted(ids)
457
460
 
458
461
  def language_info(self) -> list[LanguageInfoGroup]:
459
462
  """Return parser metadata grouped by language ID."""
460
- allowed = set(self._config.allowed_plugins or [])
461
463
  grouped: dict[str, list] = {}
462
- for parser in self.parsers:
463
- if allowed and parser.grammar_id not in allowed:
464
- continue
464
+ for parser in self._allowed_parsers():
465
465
  for info in parser.language_info:
466
466
  grouped.setdefault(info.language_id, []).append(info)
467
467