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.
- intentumdiff/__init__.py +7 -0
- intentumdiff/_differ_gate.py +0 -136
- intentumdiff/_differ_presentation.py +1 -72
- intentumdiff/_differ_runtime.py +0 -17
- intentumdiff/analysis/cross_file.py +21 -21
- intentumdiff/analysis/diagnostics.py +1 -164
- intentumdiff/analysis/guardrail_reports.py +24 -28
- intentumdiff/analysis/guardrails.py +2 -67
- intentumdiff/analysis/schema_resolver.py +23 -87
- intentumdiff/analysis/user_schemas.py +2 -17
- intentumdiff/cli/_commands.py +70 -71
- intentumdiff/cli/_parser.py +40 -55
- intentumdiff/cli/_shared.py +55 -4
- intentumdiff/core/commit_differ.py +65 -99
- intentumdiff/core/indexer.py +0 -1
- intentumdiff/core/models.py +226 -69
- intentumdiff/differ.py +125 -432
- intentumdiff/github_app.py +5 -8
- intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
- intentumdiff/live_server.py +17 -17
- intentumdiff/lsp/client.py +42 -42
- intentumdiff/lsp/servers.py +10 -11
- intentumdiff/lsp_server/_handlers.py +1 -1
- intentumdiff/lsp_server/server.py +0 -1
- intentumdiff/plugins/exceptions.py +24 -0
- intentumdiff/plugins/hub.py +38 -41
- intentumdiff/plugins/registry.py +10 -10
- intentumdiff/plugins/registry.schema.json +156 -15
- intentumdiff/plugins/registry_schema.py +47 -140
- intentumdiff/rust_core.py +112 -775
- intentumdiff/serve/_app.py +23 -25
- intentumdiff/sources/git_source.py +0 -183
- intentumdiff/vcs/git_cli.py +0 -47
- 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/cpp_parser.wasm +0 -0
- intentumdiff/wasm/csharp_parser.wasm +0 -0
- intentumdiff/wasm/databricks_parser.wasm +0 -0
- intentumdiff/wasm/dax_parser.wasm +0 -0
- intentumdiff/wasm/dockerfile_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/graphql_parser.wasm +0 -0
- intentumdiff/wasm/groovy_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/make_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/perl_parser.wasm +0 -0
- intentumdiff/wasm/php_parser.wasm +0 -0
- intentumdiff/wasm/plsql_parser.wasm +0 -0
- intentumdiff/wasm/postscript_parser.wasm +0 -0
- intentumdiff/wasm/powershell_parser.wasm +0 -0
- intentumdiff/wasm/python_parser.wasm +0 -0
- intentumdiff/wasm/qsharp_parser.wasm +0 -0
- intentumdiff/wasm/reasonml_parser.wasm +0 -0
- intentumdiff/wasm/rust_parser.wasm +0 -0
- intentumdiff/wasm/sas_parser.wasm +0 -0
- intentumdiff/wasm/sql_parser.wasm +0 -0
- intentumdiff/wasm/svelte_parser.wasm +0 -0
- intentumdiff/wasm/swift_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 +219 -219
- intentumdiff/wasm/wat_parser.wasm +0 -0
- intentumdiff/wasm/yaml_parser.wasm +0 -0
- intentumdiff/watcher.py +15 -17
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/METADATA +38 -6
- intentumdiff_python-0.0.3b1.dist-info/RECORD +164 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/sboms/intentumdiff-rust-core.cyclonedx.json +2 -2
- intentumdiff/analysis/invariances.py +0 -208
- intentumdiff/analysis/keyed_profiles.py +0 -25
- intentumdiff/analysis/resource_profiles.py +0 -14
- intentumdiff/analysis/text_review.py +0 -47
- intentumdiff/invariances/__init__.py +0 -2
- intentumdiff/invariances/rules.schema.json +0 -283
- intentumdiff/invariances/rules.yaml +0 -349
- intentumdiff_python-0.0.2b2.dist-info/RECORD +0 -171
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/WHEEL +0 -0
- {intentumdiff_python-0.0.2b2.dist-info → intentumdiff_python-0.0.3b1.dist-info}/entry_points.txt +0 -0
- {intentumdiff_python-0.0.2b2.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
|
)
|
|
@@ -232,6 +233,17 @@ class NodeFacts(BaseModel, frozen=True):
|
|
|
232
233
|
nested_block_count: int | None = None
|
|
233
234
|
has_nested_block: bool | None = None
|
|
234
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
|
+
|
|
235
247
|
|
|
236
248
|
class SemanticNode(BaseModel, frozen=True):
|
|
237
249
|
"""
|
|
@@ -452,6 +464,122 @@ class ChangeStreamEvent(BaseModel, frozen=True):
|
|
|
452
464
|
replaced_ids: list[str] = Field(default_factory=list)
|
|
453
465
|
|
|
454
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
|
+
|
|
455
583
|
# ---------------------------------------------------------------------------
|
|
456
584
|
# Diff result
|
|
457
585
|
# ---------------------------------------------------------------------------
|
|
@@ -479,6 +607,15 @@ class SemanticDiff(BaseModel, frozen=True):
|
|
|
479
607
|
# "unstaged" = saved but not staged, "staged" = git-add'd, "unpushed" = committed but not
|
|
480
608
|
# yet pushed to the remote. None for an ordinary commit-to-commit diff.
|
|
481
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
|
|
482
619
|
metadata: Mapping[str, Any] = Field(default_factory=dict)
|
|
483
620
|
|
|
484
621
|
@field_validator("metadata", mode="before")
|
|
@@ -503,44 +640,13 @@ class SemanticDiff(BaseModel, frozen=True):
|
|
|
503
640
|
raise ValueError(
|
|
504
641
|
"is_style_only and has_semantic_changes cannot both be True"
|
|
505
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
|
+
)
|
|
506
648
|
return self
|
|
507
649
|
|
|
508
|
-
@classmethod
|
|
509
|
-
def style_only(
|
|
510
|
-
cls,
|
|
511
|
-
old_filename: str,
|
|
512
|
-
new_filename: str,
|
|
513
|
-
language: str,
|
|
514
|
-
*,
|
|
515
|
-
change_groups: list[ChangeGroup] | None = None,
|
|
516
|
-
metadata: Mapping[str, Any] | None = None,
|
|
517
|
-
) -> SemanticDiff:
|
|
518
|
-
"""Convenience constructor for the style-only shortcut."""
|
|
519
|
-
return cls(
|
|
520
|
-
old_filename=old_filename,
|
|
521
|
-
new_filename=new_filename,
|
|
522
|
-
language=language,
|
|
523
|
-
change_groups=change_groups or [],
|
|
524
|
-
has_semantic_changes=False,
|
|
525
|
-
is_style_only=True,
|
|
526
|
-
metadata=metadata or {},
|
|
527
|
-
)
|
|
528
|
-
|
|
529
|
-
@property
|
|
530
|
-
def file_renamed(self) -> bool:
|
|
531
|
-
"""True when the file was renamed in-place (same directory, different basename)."""
|
|
532
|
-
old = PurePosixPath(self.old_filename)
|
|
533
|
-
new = PurePosixPath(self.new_filename)
|
|
534
|
-
return old.name != new.name and old.parent == new.parent
|
|
535
|
-
|
|
536
|
-
@property
|
|
537
|
-
def file_moved(self) -> bool:
|
|
538
|
-
"""True when the file was moved to a different directory (with or without rename)."""
|
|
539
|
-
return (
|
|
540
|
-
PurePosixPath(self.old_filename).parent
|
|
541
|
-
!= PurePosixPath(self.new_filename).parent
|
|
542
|
-
)
|
|
543
|
-
|
|
544
650
|
|
|
545
651
|
# ---------------------------------------------------------------------------
|
|
546
652
|
# Incremental parse hint
|
|
@@ -572,21 +678,33 @@ class EditDelta(BaseModel, frozen=True):
|
|
|
572
678
|
# ---------------------------------------------------------------------------
|
|
573
679
|
|
|
574
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
|
+
|
|
575
689
|
def _native_rust_core_default() -> bool:
|
|
576
|
-
"""
|
|
690
|
+
"""Validate the legacy Rust-core environment switches; the core is mandatory.
|
|
577
691
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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.
|
|
582
696
|
"""
|
|
583
697
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
raw
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
|
590
708
|
|
|
591
709
|
|
|
592
710
|
class Match(NamedTuple):
|
|
@@ -629,7 +747,17 @@ class DiffConfig(BaseModel):
|
|
|
629
747
|
experimental_rust_core: bool = Field(
|
|
630
748
|
default_factory=_native_rust_core_default,
|
|
631
749
|
)
|
|
632
|
-
"""
|
|
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
|
|
633
761
|
diagnostics_max_events: int = Field(default=500, ge=0)
|
|
634
762
|
guardrails_enabled: bool = True
|
|
635
763
|
guardrails_strict: bool = False
|
|
@@ -647,7 +775,8 @@ class DiffConfig(BaseModel):
|
|
|
647
775
|
# Extra CST node types to treat as trivia (merged with plugin defaults)
|
|
648
776
|
extra_trivia_types: list[str] = Field(default_factory=list)
|
|
649
777
|
|
|
650
|
-
# 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.
|
|
651
780
|
allowed_plugins: list[str] | None = None
|
|
652
781
|
strict_plugins: bool = False
|
|
653
782
|
|
|
@@ -798,6 +927,22 @@ class CrossFileChange(BaseModel, frozen=True):
|
|
|
798
927
|
description: str = ""
|
|
799
928
|
|
|
800
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
|
+
|
|
801
946
|
class GuardrailViolation(BaseModel, frozen=True):
|
|
802
947
|
"""A project policy rule matched a protected semantic change."""
|
|
803
948
|
|
|
@@ -816,17 +961,22 @@ class GuardrailViolation(BaseModel, frozen=True):
|
|
|
816
961
|
|
|
817
962
|
|
|
818
963
|
class GuardrailCheckResult(BaseModel, frozen=True):
|
|
819
|
-
"""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
|
+
"""
|
|
820
970
|
|
|
821
971
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
822
972
|
|
|
823
973
|
violations: list[GuardrailViolation] = Field(default_factory=list)
|
|
824
|
-
violation_count: int = 0
|
|
825
|
-
immutable_count: int = 0
|
|
826
|
-
important_count: int = 0
|
|
827
|
-
checked_files: int = 0
|
|
828
|
-
strict: bool =
|
|
829
|
-
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)
|
|
830
980
|
metadata: Mapping[str, Any] = Field(default_factory=dict)
|
|
831
981
|
|
|
832
982
|
@field_validator("metadata", mode="before")
|
|
@@ -846,19 +996,19 @@ class GuardrailCheckResult(BaseModel, frozen=True):
|
|
|
846
996
|
return dict(v)
|
|
847
997
|
|
|
848
998
|
@model_validator(mode="after")
|
|
849
|
-
def
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
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),
|
|
857
1006
|
)
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1007
|
+
if supplied != carried:
|
|
1008
|
+
raise ValueError(
|
|
1009
|
+
"guardrail check counts (violation, immutable, important) "
|
|
1010
|
+
f"{supplied} disagree with the carried violations {carried}"
|
|
1011
|
+
)
|
|
862
1012
|
return self
|
|
863
1013
|
|
|
864
1014
|
|
|
@@ -874,3 +1024,10 @@ class CommitDiff(BaseModel, frozen=True):
|
|
|
874
1024
|
file_diffs: list[SemanticDiff] = Field(default_factory=list)
|
|
875
1025
|
cross_file_changes: list[CrossFileChange] = Field(default_factory=list)
|
|
876
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)
|