intentumdiff-python 0.0.1__py3-none-win_amd64.whl → 0.0.3b1__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- intentumdiff/__init__.py +9 -0
- intentumdiff/__main__.py +12 -0
- intentumdiff/_differ_gate.py +0 -136
- intentumdiff/_differ_presentation.py +17 -735
- intentumdiff/_differ_runtime.py +13 -64
- intentumdiff/analysis/compile_commands.py +26 -141
- intentumdiff/analysis/cross_file.py +23 -25
- intentumdiff/analysis/diagnostics.py +1 -164
- intentumdiff/analysis/guardrail_reports.py +31 -33
- intentumdiff/analysis/guardrails.py +111 -188
- intentumdiff/analysis/schema_resolver.py +72 -360
- intentumdiff/analysis/user_schemas.py +57 -254
- intentumdiff/api.py +21 -0
- intentumdiff/cache/sqlite_store.py +5 -23
- intentumdiff/cli/__init__.py +59 -0
- intentumdiff/cli/_commands.py +243 -137
- intentumdiff/cli/_parser.py +51 -56
- intentumdiff/cli/_shared.py +151 -116
- intentumdiff/content_type.py +13 -30
- intentumdiff/core/commit_differ.py +137 -286
- intentumdiff/core/diffignore.py +28 -34
- intentumdiff/core/index.py +16 -18
- intentumdiff/core/indexer.py +148 -169
- intentumdiff/core/models.py +279 -83
- intentumdiff/differ.py +366 -1000
- intentumdiff/github_app.py +40 -27
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +197 -34
- intentumdiff/lsp/client.py +49 -43
- intentumdiff/lsp/enricher.py +19 -119
- intentumdiff/lsp/exceptions.py +6 -7
- intentumdiff/lsp/servers.py +10 -11
- intentumdiff/lsp_server/_codelens.py +24 -57
- intentumdiff/lsp_server/_diagnostics.py +23 -51
- intentumdiff/lsp_server/_handlers.py +67 -9
- intentumdiff/lsp_server/server.py +28 -8
- intentumdiff/plugins/adapter.py +5 -0
- intentumdiff/plugins/builtins.py +7 -14
- intentumdiff/plugins/exceptions.py +28 -0
- intentumdiff/plugins/hub.py +39 -43
- intentumdiff/plugins/loader.py +229 -215
- intentumdiff/plugins/registry.py +259 -207
- intentumdiff/plugins/registry.schema.json +156 -15
- intentumdiff/plugins/registry_schema.py +47 -140
- intentumdiff/rust_core.py +623 -1326
- intentumdiff/serve/_app.py +26 -35
- intentumdiff/sources/base.py +24 -0
- intentumdiff/sources/file_source.py +15 -2
- intentumdiff/sources/git_source.py +64 -185
- 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 +0 -27
- 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/watcher.py +15 -17
- intentumdiff_python-0.0.3b1.dist-info/METADATA +188 -0
- intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +1 -1
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +905 -379
- intentumdiff/analysis/invariances.py +0 -1207
- intentumdiff/analysis/keyed_profiles.py +0 -25
- intentumdiff/analysis/resource_profiles.py +0 -14
- intentumdiff/analysis/text_review.py +0 -46
- intentumdiff/core/cst_serializer.py +0 -101
- intentumdiff/invariances/__init__.py +0 -2
- intentumdiff/invariances/rules.schema.json +0 -283
- intentumdiff/invariances/rules.yaml +0 -349
- 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.3b1.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.1.dist-info → intentumdiff_python-0.0.3b1.dist-info}/licenses/LICENSE +0 -0
intentumdiff/core/models.py
CHANGED
|
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|
|
11
11
|
import os
|
|
12
12
|
from collections.abc import Mapping
|
|
13
13
|
from enum import Enum, IntEnum
|
|
14
|
-
from pathlib import Path
|
|
14
|
+
from pathlib import Path
|
|
15
15
|
from types import MappingProxyType
|
|
16
16
|
from typing import NamedTuple, Any, Literal
|
|
17
17
|
|
|
@@ -21,6 +21,7 @@ from pydantic import (
|
|
|
21
21
|
Field,
|
|
22
22
|
PrivateAttr,
|
|
23
23
|
field_serializer,
|
|
24
|
+
model_serializer,
|
|
24
25
|
field_validator,
|
|
25
26
|
model_validator,
|
|
26
27
|
)
|
|
@@ -78,8 +79,8 @@ class DetectionResult(BaseModel, frozen=True):
|
|
|
78
79
|
ge=0.0,
|
|
79
80
|
le=1.0,
|
|
80
81
|
description=(
|
|
81
|
-
"
|
|
82
|
-
"1.0 for the
|
|
82
|
+
"Reciprocal rank from Rust content detection order, rounded to three decimals. "
|
|
83
|
+
"1.0 for the first match; this is not a measured probability."
|
|
83
84
|
),
|
|
84
85
|
)
|
|
85
86
|
|
|
@@ -123,14 +124,23 @@ class LanguageInfoGroup(BaseModel, frozen=True):
|
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
class NodeFacts(BaseModel, frozen=True):
|
|
127
|
+
# Unknown Rust-authored facts must fail validation rather than disappear
|
|
128
|
+
# through Pydantic's extra=ignore (0.0.2 thin-wrapper contract, #226).
|
|
129
|
+
model_config = ConfigDict(extra="forbid")
|
|
130
|
+
|
|
126
131
|
"""
|
|
127
|
-
Privacy-safe structural facts about
|
|
132
|
+
Privacy-safe structural facts about an entity or keyed/resource node,
|
|
128
133
|
computed by the Rust parser from the full CST before pruning. Only counts,
|
|
129
134
|
enums, and flags — never source text, identifiers, or literals — so they can
|
|
130
135
|
describe a change's shape ("no parameters", "returns nothing", "no-op body")
|
|
131
136
|
without revealing code. The host carries this through unchanged.
|
|
132
137
|
"""
|
|
133
138
|
|
|
139
|
+
#: Which derivation passes produced these facts, e.g. ``"cst,enrich(derived=14,added=5)"``.
|
|
140
|
+
#: Populated only when ``INTENTUMDIFF_TRACE_FACTS=1``; ``None`` in normal operation.
|
|
141
|
+
#: Diagnostic provenance, never source — safe to paste into a bug report.
|
|
142
|
+
facts_trace: str | None = None
|
|
143
|
+
|
|
134
144
|
param_count: int | None = None
|
|
135
145
|
#: ``"none"`` | ``"value"`` | ``"literal"`` (constant) | ``"unknown"``.
|
|
136
146
|
returns: str | None = None
|
|
@@ -148,6 +158,20 @@ class NodeFacts(BaseModel, frozen=True):
|
|
|
148
158
|
has_error_handling: bool | None = None
|
|
149
159
|
#: The body raises/throws an exception. Flag only.
|
|
150
160
|
throws: bool | None = None
|
|
161
|
+
#: Cross-language structural facts, derived from the pruned canonical tree (#9) rather
|
|
162
|
+
#: than from any one grammar — so they are available for EVERY language, not just the
|
|
163
|
+
#: ones with a bespoke fact extractor.
|
|
164
|
+
#:
|
|
165
|
+
#: These are counts and flags only, in keeping with the rest of NodeFacts: no source, no
|
|
166
|
+
#: identifiers, no literals.
|
|
167
|
+
#:
|
|
168
|
+
#: `has_guard_clause` is deliberately tri-state. The pruned tree can prove a guard is
|
|
169
|
+
#: present, but cannot prove one is absent — statement order survives pruning, operators
|
|
170
|
+
#: do not. So `None` means "not determinable here", NOT "no guard". Omitting beats
|
|
171
|
+
#: claiming; see uast.rs for the reasoning.
|
|
172
|
+
early_exit_count: int | None = None
|
|
173
|
+
negated_condition_count: int | None = None
|
|
174
|
+
has_guard_clause: bool | None = None
|
|
151
175
|
#: The body mutates state — an augmented assignment or an assignment to an
|
|
152
176
|
#: attribute/subscript (``self.x = …``, ``a[i] = …``). Flag only, no target name.
|
|
153
177
|
mutates: bool | None = None
|
|
@@ -195,6 +219,31 @@ class NodeFacts(BaseModel, frozen=True):
|
|
|
195
219
|
call_count: int | None = None
|
|
196
220
|
recursive: bool | None = None
|
|
197
221
|
|
|
222
|
+
# Rust-owned keyed/collection/resource NodeFacts (#179, Core #203,
|
|
223
|
+
# Python #226). These are DTO fields only: the Python host must preserve
|
|
224
|
+
# Rust's privacy-safe counts, flags and shape categories without deriving
|
|
225
|
+
# them or silently dropping them through Pydantic's extra=ignore.
|
|
226
|
+
shape: str | None = None
|
|
227
|
+
child_count: int | None = None
|
|
228
|
+
value_kind: str | None = None
|
|
229
|
+
item_count: int | None = None
|
|
230
|
+
nesting: int | None = None
|
|
231
|
+
is_leaf: bool | None = None
|
|
232
|
+
attribute_count: int | None = None
|
|
233
|
+
nested_block_count: int | None = None
|
|
234
|
+
has_nested_block: bool | None = None
|
|
235
|
+
|
|
236
|
+
# Declaration facts (Core #308, for vscode#132). Closed enums only, never source text.
|
|
237
|
+
#: Declared visibility, decided by core's per-language rules; ``"unknown"`` when the
|
|
238
|
+
#: rules cannot decide.
|
|
239
|
+
visibility: Literal[
|
|
240
|
+
"public", "internal", "private", "protected", "special", "unknown"
|
|
241
|
+
] | None = None
|
|
242
|
+
#: What makes a ``body == "stub"`` body a placeholder; set only for stub bodies.
|
|
243
|
+
stub_sentinel: Literal[
|
|
244
|
+
"pass", "ellipsis", "not_implemented", "docstring_only", "todo_macro", "panic"
|
|
245
|
+
] | None = None
|
|
246
|
+
|
|
198
247
|
|
|
199
248
|
class SemanticNode(BaseModel, frozen=True):
|
|
200
249
|
"""
|
|
@@ -401,14 +450,12 @@ class ChangeGroup(BaseModel, frozen=True):
|
|
|
401
450
|
class ChangeStreamEvent(BaseModel, frozen=True):
|
|
402
451
|
"""A single event emitted by ``SemanticDiffer.diff_stream_progressive``.
|
|
403
452
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
453
|
+
The 0.0.2 Python adapter emits FINAL add events only, after Rust has
|
|
454
|
+
produced a complete diff. STRUCTURAL, REFINED, revise and remove remain in
|
|
455
|
+
the DTO schema for compatibility but are not synthesized by Python.
|
|
407
456
|
|
|
408
|
-
``replaced_ids``
|
|
409
|
-
|
|
410
|
-
consumer should look up prior events by these IDs and replace them. When
|
|
411
|
-
``action="remove"`` there is no replacement — the change was absorbed.
|
|
457
|
+
``replaced_ids`` carries identifiers supplied by a backend for revising or
|
|
458
|
+
removing earlier events; the 0.0.2 adapter leaves it empty.
|
|
412
459
|
"""
|
|
413
460
|
|
|
414
461
|
phase: ChangeStreamPhase
|
|
@@ -417,6 +464,122 @@ class ChangeStreamEvent(BaseModel, frozen=True):
|
|
|
417
464
|
replaced_ids: list[str] = Field(default_factory=list)
|
|
418
465
|
|
|
419
466
|
|
|
467
|
+
# ---------------------------------------------------------------------------
|
|
468
|
+
# Review completeness (core #252 / #312)
|
|
469
|
+
# ---------------------------------------------------------------------------
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
class _CoreDto(BaseModel):
|
|
473
|
+
"""A core-authored DTO marshalled verbatim: strict types, unknown fields kept.
|
|
474
|
+
|
|
475
|
+
Serialisation emits exactly the keys core sent (absent optional keys stay absent),
|
|
476
|
+
so JSON output passes core's DTO through unchanged.
|
|
477
|
+
"""
|
|
478
|
+
|
|
479
|
+
model_config = ConfigDict(frozen=True, strict=True, extra="allow")
|
|
480
|
+
|
|
481
|
+
@model_serializer(mode="wrap")
|
|
482
|
+
def _verbatim(self, handler: Any) -> dict[str, Any]:
|
|
483
|
+
data = handler(self)
|
|
484
|
+
sent = self.model_fields_set
|
|
485
|
+
aliases = {name: field.alias for name, field in type(self).model_fields.items()
|
|
486
|
+
if field.alias}
|
|
487
|
+
keys = sent | {aliases[name] for name in sent if name in aliases}
|
|
488
|
+
return {aliases.get(key, key): value for key, value in data.items() if key in keys}
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
class IncompleteSourceRange(_CoreDto):
|
|
492
|
+
"""A changed line hunk (zero-based lines, exclusive end bytes)."""
|
|
493
|
+
|
|
494
|
+
old_start_byte: int = Field(ge=0)
|
|
495
|
+
old_end_byte: int = Field(ge=0)
|
|
496
|
+
new_start_byte: int = Field(ge=0)
|
|
497
|
+
new_end_byte: int = Field(ge=0)
|
|
498
|
+
old_start_line: int = Field(ge=0)
|
|
499
|
+
old_end_line: int = Field(ge=0)
|
|
500
|
+
new_start_line: int = Field(ge=0)
|
|
501
|
+
new_end_line: int = Field(ge=0)
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
class ReproRegionSide(_CoreDto):
|
|
505
|
+
start_line: int = Field(ge=0)
|
|
506
|
+
start_col: int = Field(ge=0)
|
|
507
|
+
end_line: int = Field(ge=0)
|
|
508
|
+
end_col: int = Field(ge=0)
|
|
509
|
+
bytes: int = Field(ge=0)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
class ReproRegion(_CoreDto):
|
|
513
|
+
index: int = Field(ge=0)
|
|
514
|
+
old: ReproRegionSide
|
|
515
|
+
new: ReproRegionSide
|
|
516
|
+
old_skeleton: str | None = None
|
|
517
|
+
old_shape: str | None = None
|
|
518
|
+
new_skeleton: str | None = None
|
|
519
|
+
new_shape: str | None = None
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
class ReproPlugin(_CoreDto):
|
|
523
|
+
id: str | None
|
|
524
|
+
version: str | None
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
class ReproSuppressedKind(_CoreDto):
|
|
528
|
+
change_type: str
|
|
529
|
+
node_type: str
|
|
530
|
+
count: int = Field(ge=0)
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
class ReproSuppression(_CoreDto):
|
|
534
|
+
# ``pass`` is a Python keyword; the DTO key is kept verbatim through the alias.
|
|
535
|
+
pass_: str = Field(alias="pass")
|
|
536
|
+
removed: list[ReproSuppressedKind]
|
|
537
|
+
added: list[ReproSuppressedKind]
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
class ReproOutline(_CoreDto):
|
|
541
|
+
"""Core's sanitised structural outline: no source text, filenames or paths."""
|
|
542
|
+
|
|
543
|
+
schema_version: int
|
|
544
|
+
reason: str
|
|
545
|
+
core_version: str
|
|
546
|
+
language: str
|
|
547
|
+
plugin: ReproPlugin | None
|
|
548
|
+
regions: list[ReproRegion]
|
|
549
|
+
regions_truncated: bool
|
|
550
|
+
structure_available: bool
|
|
551
|
+
suppressions: list[ReproSuppression] | None
|
|
552
|
+
placeholder_count: int = Field(ge=0)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
class IncompleteReport(_CoreDto):
|
|
556
|
+
"""Core's pre-built bug report. Bindings preview it and open ``issue_url`` only on
|
|
557
|
+
explicit user confirmation; ``truncated`` means the URL carries a shortened body."""
|
|
558
|
+
|
|
559
|
+
title: str
|
|
560
|
+
body_markdown: str
|
|
561
|
+
truncated: bool
|
|
562
|
+
issue_url: str
|
|
563
|
+
outline: ReproOutline
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
class IncompleteReview(_CoreDto):
|
|
567
|
+
"""Why core could not explain a source delta; ``message`` is shown verbatim."""
|
|
568
|
+
|
|
569
|
+
reason: str
|
|
570
|
+
message: str
|
|
571
|
+
report_url: str
|
|
572
|
+
language: str
|
|
573
|
+
core_version: str
|
|
574
|
+
source_ranges: list[IncompleteSourceRange]
|
|
575
|
+
source_ranges_truncated: bool
|
|
576
|
+
source_ranges_available: bool
|
|
577
|
+
report: IncompleteReport
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
ReviewCompleteness = Literal["complete", "equivalent", "incomplete"]
|
|
581
|
+
|
|
582
|
+
|
|
420
583
|
# ---------------------------------------------------------------------------
|
|
421
584
|
# Diff result
|
|
422
585
|
# ---------------------------------------------------------------------------
|
|
@@ -444,6 +607,15 @@ class SemanticDiff(BaseModel, frozen=True):
|
|
|
444
607
|
# "unstaged" = saved but not staged, "staged" = git-add'd, "unpushed" = committed but not
|
|
445
608
|
# yet pushed to the remote. None for an ordinary commit-to-commit diff.
|
|
446
609
|
staging_status: str | None = None
|
|
610
|
+
#: The coarse kind of content core reviewed (Core #308, for vscode#133), from core's
|
|
611
|
+
#: closed table keyed on the routed language. States what was reviewed, never a risk.
|
|
612
|
+
content_class: Literal["code", "docs", "config", "data", "text"] | None = None
|
|
613
|
+
#: Core's completeness verdict (core #252): ``complete``, ``equivalent`` (proved, see
|
|
614
|
+
#: ``metadata.equivalence_proof``) or ``incomplete``. Never derived in Python; ``None``
|
|
615
|
+
#: only on a DTO that did not come from core.
|
|
616
|
+
completeness: ReviewCompleteness | None = None
|
|
617
|
+
#: Set by core exactly when ``completeness == "incomplete"``; not a clean review.
|
|
618
|
+
incomplete: IncompleteReview | None = None
|
|
447
619
|
metadata: Mapping[str, Any] = Field(default_factory=dict)
|
|
448
620
|
|
|
449
621
|
@field_validator("metadata", mode="before")
|
|
@@ -468,44 +640,13 @@ class SemanticDiff(BaseModel, frozen=True):
|
|
|
468
640
|
raise ValueError(
|
|
469
641
|
"is_style_only and has_semantic_changes cannot both be True"
|
|
470
642
|
)
|
|
643
|
+
# Shape check only: core sends ``incomplete`` exactly for an incomplete review.
|
|
644
|
+
if (self.completeness == "incomplete") != (self.incomplete is not None):
|
|
645
|
+
raise ValueError(
|
|
646
|
+
"incomplete must be an object exactly when completeness is 'incomplete'"
|
|
647
|
+
)
|
|
471
648
|
return self
|
|
472
649
|
|
|
473
|
-
@classmethod
|
|
474
|
-
def style_only(
|
|
475
|
-
cls,
|
|
476
|
-
old_filename: str,
|
|
477
|
-
new_filename: str,
|
|
478
|
-
language: str,
|
|
479
|
-
*,
|
|
480
|
-
change_groups: list[ChangeGroup] | None = None,
|
|
481
|
-
metadata: Mapping[str, Any] | None = None,
|
|
482
|
-
) -> SemanticDiff:
|
|
483
|
-
"""Convenience constructor for the style-only shortcut."""
|
|
484
|
-
return cls(
|
|
485
|
-
old_filename=old_filename,
|
|
486
|
-
new_filename=new_filename,
|
|
487
|
-
language=language,
|
|
488
|
-
change_groups=change_groups or [],
|
|
489
|
-
has_semantic_changes=False,
|
|
490
|
-
is_style_only=True,
|
|
491
|
-
metadata=metadata or {},
|
|
492
|
-
)
|
|
493
|
-
|
|
494
|
-
@property
|
|
495
|
-
def file_renamed(self) -> bool:
|
|
496
|
-
"""True when the file was renamed in-place (same directory, different basename)."""
|
|
497
|
-
old = PurePosixPath(self.old_filename)
|
|
498
|
-
new = PurePosixPath(self.new_filename)
|
|
499
|
-
return old.name != new.name and old.parent == new.parent
|
|
500
|
-
|
|
501
|
-
@property
|
|
502
|
-
def file_moved(self) -> bool:
|
|
503
|
-
"""True when the file was moved to a different directory (with or without rename)."""
|
|
504
|
-
return (
|
|
505
|
-
PurePosixPath(self.old_filename).parent
|
|
506
|
-
!= PurePosixPath(self.new_filename).parent
|
|
507
|
-
)
|
|
508
|
-
|
|
509
650
|
|
|
510
651
|
# ---------------------------------------------------------------------------
|
|
511
652
|
# Incremental parse hint
|
|
@@ -537,21 +678,33 @@ class EditDelta(BaseModel, frozen=True):
|
|
|
537
678
|
# ---------------------------------------------------------------------------
|
|
538
679
|
|
|
539
680
|
|
|
681
|
+
_RUST_CORE_ENV_VARS = ("INTENTUMDIFF_RUST_CORE", "INTENTUMDIFF_EXPERIMENTAL_RUST_CORE")
|
|
682
|
+
_RUST_CORE_ON_VALUES = frozenset({"1", "true", "yes", "on", "auto", "native"})
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
class RustCoreRequiredError(ValueError):
|
|
686
|
+
"""The configuration asked to run without the Rust core, which is mandatory."""
|
|
687
|
+
|
|
688
|
+
|
|
540
689
|
def _native_rust_core_default() -> bool:
|
|
541
|
-
"""
|
|
690
|
+
"""Validate the legacy Rust-core environment switches; the core is mandatory.
|
|
542
691
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
692
|
+
``INTENTUMDIFF_RUST_CORE`` (and the legacy ``INTENTUMDIFF_EXPERIMENTAL_RUST_CORE``)
|
|
693
|
+
may be unset, empty or an "on" value. There is no Python engine to fall back to, so
|
|
694
|
+
a disable value (``0``/``false``/``off``/...) or any unrecognised value raises
|
|
695
|
+
instead of silently routing every file to a fallback review.
|
|
547
696
|
"""
|
|
548
697
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
raw
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
698
|
+
for name in _RUST_CORE_ENV_VARS:
|
|
699
|
+
raw = os.getenv(name)
|
|
700
|
+
if raw is None or raw.strip() == "" or raw.strip().lower() in _RUST_CORE_ON_VALUES:
|
|
701
|
+
continue
|
|
702
|
+
raise RustCoreRequiredError(
|
|
703
|
+
f"{name}={raw.strip()!r} is not supported: the Rust core is mandatory and cannot "
|
|
704
|
+
f"be disabled (there is no Python engine). Unset {name} or set it to one of "
|
|
705
|
+
f"{sorted(_RUST_CORE_ON_VALUES)}."
|
|
706
|
+
)
|
|
707
|
+
return True
|
|
555
708
|
|
|
556
709
|
|
|
557
710
|
class Match(NamedTuple):
|
|
@@ -570,6 +723,11 @@ class DiffConfig(BaseModel):
|
|
|
570
723
|
|
|
571
724
|
Unlike result models, this is NOT frozen — callers may update it freely
|
|
572
725
|
before passing to ``SemanticDiffer``.
|
|
726
|
+
|
|
727
|
+
Compatibility-only fields in 0.0.2: ``ignore_style``, ``detect_refactorings``,
|
|
728
|
+
``approx_move_threshold``, ``leaf_text_diff`` and ``extra_trivia_types``.
|
|
729
|
+
Rust accepts their existing defaults but rejects unsupported overrides.
|
|
730
|
+
Configurable semantics are tracked in Core issues #220–#224.
|
|
573
731
|
"""
|
|
574
732
|
|
|
575
733
|
# GumTree tuning
|
|
@@ -589,7 +747,17 @@ class DiffConfig(BaseModel):
|
|
|
589
747
|
experimental_rust_core: bool = Field(
|
|
590
748
|
default_factory=_native_rust_core_default,
|
|
591
749
|
)
|
|
592
|
-
"""
|
|
750
|
+
"""Compatibility field: the Rust core is mandatory, so only ``True`` is accepted."""
|
|
751
|
+
|
|
752
|
+
@field_validator("experimental_rust_core")
|
|
753
|
+
@classmethod
|
|
754
|
+
def _rust_core_is_mandatory(cls, value: bool) -> bool:
|
|
755
|
+
if value is not True:
|
|
756
|
+
raise RustCoreRequiredError(
|
|
757
|
+
"experimental_rust_core=False is not supported: the Rust core is mandatory "
|
|
758
|
+
"(there is no Python engine)."
|
|
759
|
+
)
|
|
760
|
+
return value
|
|
593
761
|
diagnostics_max_events: int = Field(default=500, ge=0)
|
|
594
762
|
guardrails_enabled: bool = True
|
|
595
763
|
guardrails_strict: bool = False
|
|
@@ -607,7 +775,8 @@ class DiffConfig(BaseModel):
|
|
|
607
775
|
# Extra CST node types to treat as trivia (merged with plugin defaults)
|
|
608
776
|
extra_trivia_types: list[str] = Field(default_factory=list)
|
|
609
777
|
|
|
610
|
-
# Plugin control
|
|
778
|
+
# Plugin control. allowed_plugins follows core's parser_allowlist_matches rule (#311):
|
|
779
|
+
# None = every parser, [] = none, else exact grammar / plugin / alias / language ids.
|
|
611
780
|
allowed_plugins: list[str] | None = None
|
|
612
781
|
strict_plugins: bool = False
|
|
613
782
|
|
|
@@ -697,11 +866,10 @@ class DiffConfig(BaseModel):
|
|
|
697
866
|
``SemanticDiff`` will have ``is_fallback=True``."""
|
|
698
867
|
|
|
699
868
|
stream_analysis: bool = False
|
|
700
|
-
"""
|
|
869
|
+
"""Legacy stream-analysis configuration flag.
|
|
701
870
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
rather than waiting for the entire pipeline to finish."""
|
|
871
|
+
In 0.0.2, ``diff_stream_progressive`` only adapts a completed Rust diff to
|
|
872
|
+
FINAL add events. This flag does not enable partial Rust phase snapshots."""
|
|
705
873
|
|
|
706
874
|
|
|
707
875
|
# ---------------------------------------------------------------------------
|
|
@@ -759,6 +927,22 @@ class CrossFileChange(BaseModel, frozen=True):
|
|
|
759
927
|
description: str = ""
|
|
760
928
|
|
|
761
929
|
|
|
930
|
+
class CommitIndexError(BaseModel, frozen=True):
|
|
931
|
+
"""One changed file core could not index for cross-file analysis (#298).
|
|
932
|
+
|
|
933
|
+
``code`` is core's stable machine code (``fuel_exceeded``, ``output_limit_exceeded``,
|
|
934
|
+
``malformed_tree``, ``parser_error``); ``reason`` is the human-readable text.
|
|
935
|
+
"""
|
|
936
|
+
|
|
937
|
+
path: str
|
|
938
|
+
old_filename: str = ""
|
|
939
|
+
new_filename: str = ""
|
|
940
|
+
language: str = ""
|
|
941
|
+
side: Literal["old", "new", "both"]
|
|
942
|
+
code: str
|
|
943
|
+
reason: str = ""
|
|
944
|
+
|
|
945
|
+
|
|
762
946
|
class GuardrailViolation(BaseModel, frozen=True):
|
|
763
947
|
"""A project policy rule matched a protected semantic change."""
|
|
764
948
|
|
|
@@ -777,17 +961,22 @@ class GuardrailViolation(BaseModel, frozen=True):
|
|
|
777
961
|
|
|
778
962
|
|
|
779
963
|
class GuardrailCheckResult(BaseModel, frozen=True):
|
|
780
|
-
"""CI-friendly summary of protected semantic guardrail evaluation.
|
|
964
|
+
"""CI-friendly summary of protected semantic guardrail evaluation.
|
|
965
|
+
|
|
966
|
+
The gate (``strict``/``passed``) and the counts are evidence supplied by the producer and
|
|
967
|
+
carried as given (#296): the DTO never recomputes or overrides them. Absent gate fields,
|
|
968
|
+
or counts that disagree with ``violations``, are rejected.
|
|
969
|
+
"""
|
|
781
970
|
|
|
782
971
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
783
972
|
|
|
784
973
|
violations: list[GuardrailViolation] = Field(default_factory=list)
|
|
785
|
-
violation_count: int = 0
|
|
786
|
-
immutable_count: int = 0
|
|
787
|
-
important_count: int = 0
|
|
788
|
-
checked_files: int = 0
|
|
789
|
-
strict: bool =
|
|
790
|
-
passed: bool = True
|
|
974
|
+
violation_count: int = Field(ge=0, strict=True)
|
|
975
|
+
immutable_count: int = Field(ge=0, strict=True)
|
|
976
|
+
important_count: int = Field(ge=0, strict=True)
|
|
977
|
+
checked_files: int = Field(ge=0, strict=True)
|
|
978
|
+
strict: bool = Field(strict=True)
|
|
979
|
+
passed: bool = Field(strict=True)
|
|
791
980
|
metadata: Mapping[str, Any] = Field(default_factory=dict)
|
|
792
981
|
|
|
793
982
|
@field_validator("metadata", mode="before")
|
|
@@ -807,19 +996,19 @@ class GuardrailCheckResult(BaseModel, frozen=True):
|
|
|
807
996
|
return dict(v)
|
|
808
997
|
|
|
809
998
|
@model_validator(mode="after")
|
|
810
|
-
def
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
for violation in self.violations
|
|
999
|
+
def _reject_inconsistent_counts(self) -> GuardrailCheckResult:
|
|
1000
|
+
# Structural evidence check only: reject, never repair. The gate is not checked here.
|
|
1001
|
+
supplied = (self.violation_count, self.immutable_count, self.important_count)
|
|
1002
|
+
carried = (
|
|
1003
|
+
len(self.violations),
|
|
1004
|
+
sum(v.severity == GuardrailSeverity.IMMUTABLE for v in self.violations),
|
|
1005
|
+
sum(v.severity == GuardrailSeverity.IMPORTANT for v in self.violations),
|
|
818
1006
|
)
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1007
|
+
if supplied != carried:
|
|
1008
|
+
raise ValueError(
|
|
1009
|
+
"guardrail check counts (violation, immutable, important) "
|
|
1010
|
+
f"{supplied} disagree with the carried violations {carried}"
|
|
1011
|
+
)
|
|
823
1012
|
return self
|
|
824
1013
|
|
|
825
1014
|
|
|
@@ -835,3 +1024,10 @@ class CommitDiff(BaseModel, frozen=True):
|
|
|
835
1024
|
file_diffs: list[SemanticDiff] = Field(default_factory=list)
|
|
836
1025
|
cross_file_changes: list[CrossFileChange] = Field(default_factory=list)
|
|
837
1026
|
parse_errors: list[str] = Field(default_factory=list)
|
|
1027
|
+
# Commit cross-file index completeness, as reported by core (#298). ``None`` when the
|
|
1028
|
+
# producer did not run core's commit index (the fields are core's, never inferred here).
|
|
1029
|
+
# ``cross_file_changes`` proves "no cross-file change" only when the status is "complete".
|
|
1030
|
+
cross_file_index_status: Literal["complete", "partial"] | None = None
|
|
1031
|
+
cross_file_index_complete: bool | None = None
|
|
1032
|
+
indexed_file_count: int | None = None
|
|
1033
|
+
index_errors: list[CommitIndexError] = Field(default_factory=list)
|