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
@@ -4,7 +4,10 @@
4
4
  "title": "IntentumDiff plugin registry manifest",
5
5
  "description": "Schema for the official plugin registry (buchochelliq-labs/intentumdiff-registry/registry.yaml) that `intentumdiff.plugins.hub` fetches. The registry is the root of trust: adding a plugin is a PR whose CI vets it against this schema plus checksum/capability/provenance verification (#95). The known fields mirror the RegistryEntry the client already parses; `trust_tier`, `capabilities`, `abi_target` (#94), and `provenance_manifest_ref` (#89) formalise the trust/compat surface.",
6
6
  "type": "object",
7
- "required": ["version", "plugins"],
7
+ "required": [
8
+ "version",
9
+ "plugins"
10
+ ],
8
11
  "additionalProperties": false,
9
12
  "properties": {
10
13
  "version": {
@@ -15,8 +18,59 @@
15
18
  "plugins": {
16
19
  "type": "object",
17
20
  "description": "Plugins keyed by their package-safe registry name (matches the RegistryEntry name).",
18
- "propertyNames": { "$ref": "#/$defs/plugin_name" },
19
- "additionalProperties": { "$ref": "#/$defs/entry" }
21
+ "propertyNames": {
22
+ "$ref": "#/$defs/plugin_name"
23
+ },
24
+ "additionalProperties": {
25
+ "$ref": "#/$defs/entry"
26
+ }
27
+ },
28
+ "renderer_components": {
29
+ "type": "object",
30
+ "description": "Immutable reviewed rendering Wasm bundle (not an installable parser plugin). Pins exact core commit and exact four internal component hashes.",
31
+ "required": [
32
+ "repository",
33
+ "ref",
34
+ "artifact",
35
+ "wasm_checksums"
36
+ ],
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "repository": {
40
+ "const": "intentumdiff-core"
41
+ },
42
+ "ref": {
43
+ "type": "string",
44
+ "pattern": "^[a-f0-9]{40}$"
45
+ },
46
+ "artifact": {
47
+ "const": "renderer-components"
48
+ },
49
+ "wasm_checksums": {
50
+ "type": "object",
51
+ "required": [
52
+ "html_renderer.wasm",
53
+ "llm_renderer.wasm",
54
+ "patch_renderer.wasm",
55
+ "terminal_renderer.wasm"
56
+ ],
57
+ "additionalProperties": false,
58
+ "properties": {
59
+ "html_renderer.wasm": {
60
+ "$ref": "#/$defs/sha256"
61
+ },
62
+ "llm_renderer.wasm": {
63
+ "$ref": "#/$defs/sha256"
64
+ },
65
+ "patch_renderer.wasm": {
66
+ "$ref": "#/$defs/sha256"
67
+ },
68
+ "terminal_renderer.wasm": {
69
+ "$ref": "#/$defs/sha256"
70
+ }
71
+ }
72
+ }
73
+ }
20
74
  }
21
75
  },
22
76
  "$defs": {
@@ -38,10 +92,13 @@
38
92
  "entry": {
39
93
  "type": "object",
40
94
  "additionalProperties": false,
41
- "description": "One plugin's registry metadata. All fields are optional — the plugin name is the mapping key. Trust is asserted here: an entry with wasm_checksums (and trust_tier 'official') installs verified; an entry without warns as unverified.",
95
+ "description": "One plugin's registry metadata. The plugin name is the mapping key. Community entries may omit any field; official entries (the default tier) must pin an immutable ref, checksums, capabilities and abi_target (see allOf). Core's validate_registry_manifest enforces this schema. Trust is asserted here: an entry with wasm_checksums (and trust_tier 'official') installs verified; an entry without warns as unverified.",
42
96
  "properties": {
43
97
  "source": {
44
- "enum": ["git", "pypi"],
98
+ "enum": [
99
+ "git",
100
+ "pypi"
101
+ ],
45
102
  "default": "git",
46
103
  "description": "Install source. git: tag/branch/commit ref. pypi: version string."
47
104
  },
@@ -60,40 +117,124 @@
60
117
  "wasm_checksums": {
61
118
  "type": "object",
62
119
  "description": "Expected SHA-256 of each bundled .wasm, keyed by filename. Verified on every install. Absent = unverified (install warns).",
63
- "propertyNames": { "pattern": "^[A-Za-z0-9._-]+\\.wasm$" },
64
- "additionalProperties": { "$ref": "#/$defs/sha256" }
120
+ "propertyNames": {
121
+ "pattern": "^[A-Za-z0-9._-]+\\.wasm$"
122
+ },
123
+ "additionalProperties": {
124
+ "$ref": "#/$defs/sha256"
125
+ }
65
126
  },
66
127
  "dep_hashes": {
67
128
  "type": "object",
68
129
  "description": "Approved dependency hashes for plugins that cannot be fully self-contained, keyed by 'package==version'. Passed to pip as --require-hashes; the main package wheel must be included.",
69
- "propertyNames": { "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*==[^=\\s]+$" },
70
- "additionalProperties": { "$ref": "#/$defs/dep_hash" }
130
+ "propertyNames": {
131
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*==[^=\\s]+$"
132
+ },
133
+ "additionalProperties": {
134
+ "$ref": "#/$defs/dep_hash"
135
+ }
71
136
  },
72
137
  "allowed_dependencies": {
73
138
  "type": "array",
74
139
  "description": "Reviewed package names (no version) that may appear in dep_hashes besides the main plugin package.",
75
- "items": { "type": "string" }
140
+ "items": {
141
+ "type": "string"
142
+ }
76
143
  },
77
144
  "trust_tier": {
78
- "enum": ["official", "community"],
145
+ "enum": [
146
+ "official",
147
+ "community"
148
+ ],
79
149
  "default": "official",
80
150
  "description": "official = org-built/scanned, checksums present, installs verified. community = listed but unverified; install warns. Wired to hub.py's is_official / checksum-present-or-warn logic (#95)."
81
151
  },
82
152
  "capabilities": {
83
153
  "type": "array",
84
- "description": "Declared plugin capabilities (e.g. the WIT interfaces implemented), scanned at vetting time.",
85
- "items": { "type": "string" },
154
+ "description": "Declared plugin capabilities: the WIT world exports the plugin implements (core's closed vocabulary), each at most once. Required (non-empty) for official entries.",
155
+ "items": {
156
+ "enum": [
157
+ "diff-analyzer",
158
+ "enricher",
159
+ "index-engine",
160
+ "parser",
161
+ "renderer"
162
+ ]
163
+ },
86
164
  "uniqueItems": true
87
165
  },
88
166
  "abi_target": {
89
167
  "type": "string",
90
- "description": "The plugin contract / host-utils version the plugin implements (#94). The host refuses a plugin whose abi_target is incompatible with the engine's contract version — caught at resolve time, not instantiation."
168
+ "description": "The plugin contract / host-utils version the plugin implements (#94). The host refuses a plugin whose abi_target is incompatible with the engine's contract version — caught at resolve time, not instantiation. MAJOR.MINOR.PATCH in every tier; required for official entries.",
169
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
91
170
  },
92
171
  "provenance_manifest_ref": {
93
172
  "type": "string",
94
173
  "description": "Reference to the plugin's Wasm provenance manifest (#89): filename -> SHA-256 + source commit for every bundled artifact, so downstream consumers can verify provenance."
95
174
  }
96
- }
175
+ },
176
+ "allOf": [
177
+ {
178
+ "description": "Official tier (the default): immutable ref, pinned components, declared capabilities and ABI target (core validate_registry_manifest, #329). Community entries keep these optional.",
179
+ "if": {
180
+ "properties": {
181
+ "trust_tier": {
182
+ "const": "official"
183
+ }
184
+ }
185
+ },
186
+ "then": {
187
+ "required": [
188
+ "ref",
189
+ "wasm_checksums",
190
+ "capabilities",
191
+ "abi_target"
192
+ ],
193
+ "properties": {
194
+ "wasm_checksums": {
195
+ "minProperties": 1
196
+ },
197
+ "capabilities": {
198
+ "minItems": 1
199
+ }
200
+ },
201
+ "not": {
202
+ "required": [
203
+ "repo"
204
+ ],
205
+ "properties": {
206
+ "repo": {
207
+ "minLength": 1
208
+ }
209
+ }
210
+ },
211
+ "if": {
212
+ "properties": {
213
+ "source": {
214
+ "const": "pypi"
215
+ }
216
+ },
217
+ "required": [
218
+ "source"
219
+ ]
220
+ },
221
+ "then": {
222
+ "properties": {
223
+ "ref": {
224
+ "pattern": "^[0-9][A-Za-z0-9.+!-]{0,63}$"
225
+ }
226
+ }
227
+ },
228
+ "else": {
229
+ "properties": {
230
+ "ref": {
231
+ "pattern": "^[a-f0-9]{40}$"
232
+ }
233
+ }
234
+ }
235
+ }
236
+ }
237
+ ]
97
238
  }
98
239
  }
99
240
  }
@@ -1,14 +1,11 @@
1
- """Validate the plugin registry manifest against its published schema (#95).
1
+ """Validate the plugin registry manifest (#95) by transporting core's validator (#329).
2
2
 
3
3
  The JSON Schema (``registry.schema.json``, packaged alongside this module) is the documented
4
- contract. This module is its dependency-free ENFORCEMENT: :func:`validate_registry` checks the
5
- security-load-bearing subset (required top-level shape, name/checksum/dep-hash patterns, the
6
- trust-tier and source enums, no unknown fields) so the #95 CI vetting pipeline can block a
7
- malformed or untrusted registry entry BEFORE it is published — the registry is the root of
8
- trust. Stdlib-only (no ``jsonschema`` dependency), matching the thin-binding rule.
9
-
10
- Returns a list of human-readable error strings (empty == valid) rather than raising, so a
11
- vetting run can report every problem in one pass.
4
+ contract. Its enforcement is core's ``validate_registry_manifest`` operation: field types,
5
+ enums, patterns, the official-tier policy (immutable refs, checksums, capabilities and
6
+ ``abi_target`` required) and the capability vocabulary. This module only marshals the parsed
7
+ manifest to core and formats core's ``{"path", "message"}`` errors; it returns every error
8
+ (empty == valid) rather than raising, so a vetting run can report every problem in one pass.
12
9
  """
13
10
 
14
11
  from __future__ import annotations
@@ -16,16 +13,10 @@ from __future__ import annotations
16
13
  import json
17
14
  import re
18
15
  from importlib import resources
16
+ from pathlib import Path
19
17
  from typing import Any
20
18
 
21
- _NAME_RE = re.compile(r"^(?:intentumdiff-)?[A-Za-z0-9][A-Za-z0-9._-]{0,127}$")
22
- _WASM_FILE_RE = re.compile(r"^[A-Za-z0-9._-]+\.wasm$")
23
- _SHA256_RE = re.compile(r"^[a-f0-9]{64}$")
24
- _DEP_HASH_RE = re.compile(r"^sha256:[a-f0-9]{64}$")
25
- _DEP_KEY_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*==[^=\s]+$")
26
-
27
- _SOURCE_VALUES = frozenset({"git", "pypi"})
28
- _TRUST_TIERS = frozenset({"official", "community"})
19
+ from intentumdiff.plugins.exceptions import RegistryManifestError
29
20
 
30
21
  #: The plugin-contract ABI version this host implements. Mirrors ``package
31
22
  #: intentdiff:plugin@X`` in ``plugins/wit/plugin.wit``; the drift-guard test
@@ -38,9 +29,7 @@ _VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)$")
38
29
 
39
30
  def _parse_version(value: str) -> tuple[int, int, int] | None:
40
31
  match = _VERSION_RE.match(value.strip())
41
- if match is None:
42
- return None
43
- return (int(match.group(1)), int(match.group(2)), int(match.group(3)))
32
+ return None if match is None else (int(match[1]), int(match[2]), int(match[3]))
44
33
 
45
34
 
46
35
  def abi_compatible(target: str, host: str = HOST_CONTRACT_VERSION) -> bool:
@@ -58,106 +47,45 @@ def abi_compatible(target: str, host: str = HOST_CONTRACT_VERSION) -> bool:
58
47
  return False
59
48
  return parsed_target[0] == parsed_host[0] and parsed_target[1] <= parsed_host[1]
60
49
 
61
- _ENTRY_FIELDS = frozenset(
62
- {
63
- "source",
64
- "ref",
65
- "repo",
66
- "description",
67
- "wasm_checksums",
68
- "dep_hashes",
69
- "allowed_dependencies",
70
- "trust_tier",
71
- "capabilities",
72
- "abi_target",
73
- "provenance_manifest_ref",
74
- }
75
- )
76
- _TOP_LEVEL_FIELDS = frozenset({"version", "plugins"})
77
-
78
50
 
79
51
  def load_schema() -> dict[str, Any]:
80
52
  """Return the packaged registry JSON Schema."""
81
- text = resources.files("intentumdiff.plugins").joinpath("registry.schema.json").read_text(
82
- encoding="utf-8"
83
- )
84
- return json.loads(text)
53
+ schema = resources.files("intentumdiff.plugins").joinpath("registry.schema.json")
54
+ return json.loads(schema.read_text(encoding="utf-8"))
85
55
 
86
56
 
87
- def _validate_entry(name: str, entry: Any, errors: list[str]) -> None:
88
- where = f"plugins[{name!r}]"
89
- if not isinstance(entry, dict):
90
- errors.append(f"{where}: entry must be a mapping")
91
- return
92
-
93
- unknown = set(entry) - _ENTRY_FIELDS
94
- if unknown:
95
- errors.append(f"{where}: unknown field(s): {', '.join(sorted(unknown))}")
96
-
97
- source = entry.get("source", "git")
98
- if source not in _SOURCE_VALUES:
99
- errors.append(f"{where}.source: {source!r} not in {sorted(_SOURCE_VALUES)}")
100
-
101
- trust = entry.get("trust_tier", "official")
102
- if trust not in _TRUST_TIERS:
103
- errors.append(f"{where}.trust_tier: {trust!r} not in {sorted(_TRUST_TIERS)}")
104
-
105
- for str_field in ("ref", "repo", "description", "abi_target", "provenance_manifest_ref"):
106
- if str_field in entry and not isinstance(entry[str_field], str):
107
- errors.append(f"{where}.{str_field}: must be a string")
108
-
109
- checksums = entry.get("wasm_checksums", {})
110
- if not isinstance(checksums, dict):
111
- errors.append(f"{where}.wasm_checksums: must be a mapping")
112
- else:
113
- for fname, digest in checksums.items():
114
- if not _WASM_FILE_RE.match(str(fname)):
115
- errors.append(f"{where}.wasm_checksums: {fname!r} is not a .wasm filename")
116
- if not (isinstance(digest, str) and _SHA256_RE.match(digest)):
117
- errors.append(f"{where}.wasm_checksums[{fname!r}]: not a lowercase SHA-256 hex")
118
-
119
- dep_hashes = entry.get("dep_hashes", {})
120
- if not isinstance(dep_hashes, dict):
121
- errors.append(f"{where}.dep_hashes: must be a mapping")
122
- else:
123
- for key, value in dep_hashes.items():
124
- if not _DEP_KEY_RE.match(str(key)):
125
- errors.append(f"{where}.dep_hashes: {key!r} is not 'package==version'")
126
- if not (isinstance(value, str) and _DEP_HASH_RE.match(value)):
127
- errors.append(f"{where}.dep_hashes[{key!r}]: not 'sha256:<hex>'")
128
-
129
- for list_field in ("allowed_dependencies", "capabilities"):
130
- if list_field in entry:
131
- value = entry[list_field]
132
- if not (isinstance(value, list) and all(isinstance(i, str) for i in value)):
133
- errors.append(f"{where}.{list_field}: must be a list of strings")
57
+ def registry_manifest_errors(data: Any) -> list[dict[str, str]]:
58
+ """Core's errors for the parsed manifest *data*, unchanged (``[]`` == valid).
134
59
 
60
+ Raises :class:`RegistryManifestError` when *data* has no JSON form (for example a YAML
61
+ date or a NaN), since core validates the JSON document.
62
+ """
63
+ from intentumdiff.rust_core import validate_registry_manifest
64
+
65
+ try:
66
+ manifest_json = json.dumps(data, allow_nan=False)
67
+ except (TypeError, ValueError) as exc:
68
+ message = f"plugin registry manifest is not JSON-representable: {exc}"
69
+ raise RegistryManifestError(message) from exc
70
+ return validate_registry_manifest(manifest_json)
135
71
 
136
- def validate_registry(data: Any) -> list[str]:
137
- """Return every schema violation in *data* (empty list == a valid registry manifest)."""
138
- errors: list[str] = []
139
- if not isinstance(data, dict):
140
- return ["registry: top level must be a mapping"]
141
72
 
142
- unknown = set(data) - _TOP_LEVEL_FIELDS
143
- if unknown:
144
- errors.append(f"registry: unknown top-level field(s): {', '.join(sorted(unknown))}")
73
+ def format_manifest_error(error: dict[str, str]) -> str:
74
+ """``"<json pointer>: <message>"``; the document root is shown as ``/``."""
75
+ return f"{error['path'] or '/'}: {error['message']}"
145
76
 
146
- version = data.get("version")
147
- if not isinstance(version, int) or isinstance(version, bool) or version < 1:
148
- errors.append("registry.version: required integer >= 1")
149
77
 
150
- plugins = data.get("plugins")
151
- if not isinstance(plugins, dict):
152
- errors.append("registry.plugins: required mapping of name -> entry")
153
- return errors
78
+ def check_registry_manifest(data: Any) -> None:
79
+ """Raise :class:`RegistryManifestError` carrying core's errors when *data* is invalid."""
80
+ errors = registry_manifest_errors(data)
81
+ if errors:
82
+ text = "; ".join(map(format_manifest_error, errors))
83
+ raise RegistryManifestError(f"invalid plugin registry manifest: {text}", errors)
154
84
 
155
- for name, entry in plugins.items():
156
- if not _NAME_RE.match(str(name)):
157
- errors.append(f"plugins: {name!r} is not a package-safe plugin name")
158
- _validate_entry(str(name), entry, errors)
159
85
 
160
- return errors
86
+ def validate_registry(data: Any) -> list[str]:
87
+ """Return every violation core reports for *data* (empty list == a valid manifest)."""
88
+ return [format_manifest_error(error) for error in registry_manifest_errors(data)]
161
89
 
162
90
 
163
91
  def _effective_tier(entry: dict) -> str:
@@ -187,28 +115,18 @@ def render_catalog_markdown(registry: Any, *, title: str = "IntentumDiff plugin
187
115
  official = sorted(n for n, e in plugins.items() if _effective_tier(e) == "official")
188
116
  community = sorted(n for n, e in plugins.items() if _effective_tier(e) == "community")
189
117
 
190
- lines: list[str] = [f"# {title}", ""]
191
- lines.append(f"_{len(plugins)} plugins — generated from the registry manifest._")
192
- lines.append("")
118
+ count = f"_{len(plugins)} plugins — generated from the registry manifest._"
119
+ lines = [f"# {title}", "", count, ""]
193
120
 
194
121
  def _section(heading: str, names: list[str], note: str) -> None:
195
- lines.append(f"## {heading} ({len(names)})")
196
- lines.append("")
197
- if note:
198
- lines.append(f"> {note}")
199
- lines.append("")
122
+ lines.extend([f"## {heading} ({len(names)})", ""] + ([f"> {note}", ""] if note else []))
200
123
  if not names:
201
- lines.append("_None._")
202
- lines.append("")
203
- return
124
+ return lines.extend(["_None._", ""])
204
125
  for name in names:
205
126
  entry = plugins[name]
206
127
  lines.append(f"### {name}")
207
128
  desc = entry.get("description")
208
- if desc:
209
- lines.append("")
210
- lines.append(str(desc))
211
- lines.append("")
129
+ lines.extend((["", str(desc)] if desc else []) + [""])
212
130
  lines.append(f"- **Source**: {entry.get('source', 'git')} `{entry.get('ref', 'main')}`")
213
131
  if entry.get("abi_target"):
214
132
  lines.append(f"- **ABI target**: `{entry['abi_target']}`")
@@ -219,41 +137,30 @@ def render_catalog_markdown(registry: Any, *, title: str = "IntentumDiff plugin
219
137
  lines.append("")
220
138
 
221
139
  _section("Official", official, "Org-built and scanned; checksums verified on install.")
222
- _section(
223
- "Community",
224
- community,
225
- "Listed but unverified (custom source or no checksums). "
226
- "Install only if you trust the source.",
227
- )
140
+ _section("Community", community, "Listed but unverified (custom source or no checksums). "
141
+ "Install only if you trust the source.")
228
142
  return "\n".join(lines).rstrip() + "\n"
229
143
 
230
144
 
231
145
  def _load_registry_document(path: str) -> Any:
232
146
  """Parse a registry manifest from a ``.yaml``/``.json`` file."""
233
- from pathlib import Path
234
-
235
147
  text = Path(path).read_text(encoding="utf-8")
236
148
  if path.endswith((".yaml", ".yml")):
237
149
  import yaml # pyyaml is already a runtime dep (hub.py)
238
-
239
150
  return yaml.safe_load(text)
240
151
  return json.loads(text)
241
152
 
242
153
 
243
154
  def main(argv: list[str] | None = None) -> int:
244
155
  """CLI for the #95 vetting pipeline: validate a registry manifest, exit non-zero on any
245
- violation. The plugins-repo PR gate runs ``python -m intentumdiff.plugins.registry_schema
246
- registry.yaml`` (alongside the checksum/capability/provenance checks) to block a bad entry
247
- before merge."""
156
+ violation. The registry PR gate runs ``python -m intentumdiff.plugins.registry_schema
157
+ registry.yaml`` (with the checksum/capability/provenance checks) before merge."""
248
158
  import argparse
249
159
 
250
160
  parser = argparse.ArgumentParser(description=main.__doc__)
251
161
  parser.add_argument("manifest", help="path to registry.yaml (or .json)")
252
- parser.add_argument(
253
- "--catalog",
254
- action="store_true",
255
- help="after validating, print the Markdown discovery catalog to stdout (#95)",
256
- )
162
+ parser.add_argument("--catalog", action="store_true",
163
+ help="print the Markdown discovery catalog after validating (#95)")
257
164
  args = parser.parse_args(argv)
258
165
 
259
166
  try: