intentumdiff-python 0.0.1__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 (165) hide show
  1. intentumdiff/__init__.py +134 -0
  2. intentumdiff/_differ_gate.py +210 -0
  3. intentumdiff/_differ_presentation.py +786 -0
  4. intentumdiff/_differ_runtime.py +320 -0
  5. intentumdiff/analysis/__init__.py +1 -0
  6. intentumdiff/analysis/compile_commands.py +151 -0
  7. intentumdiff/analysis/cross_file.py +71 -0
  8. intentumdiff/analysis/diagnostics.py +309 -0
  9. intentumdiff/analysis/guardrail_reports.py +254 -0
  10. intentumdiff/analysis/guardrails.py +318 -0
  11. intentumdiff/analysis/invariances.py +1207 -0
  12. intentumdiff/analysis/keyed_profiles.py +25 -0
  13. intentumdiff/analysis/resource_profiles.py +14 -0
  14. intentumdiff/analysis/schema_resolver.py +816 -0
  15. intentumdiff/analysis/text_review.py +46 -0
  16. intentumdiff/analysis/user_schemas.py +430 -0
  17. intentumdiff/assets.py +45 -0
  18. intentumdiff/cache/__init__.py +37 -0
  19. intentumdiff/cache/duckdb_store.py +98 -0
  20. intentumdiff/cache/sqlite_store.py +149 -0
  21. intentumdiff/cache/store.py +190 -0
  22. intentumdiff/cli/__init__.py +199 -0
  23. intentumdiff/cli/_commands.py +2141 -0
  24. intentumdiff/cli/_parser.py +1061 -0
  25. intentumdiff/cli/_shared.py +644 -0
  26. intentumdiff/content_type.py +59 -0
  27. intentumdiff/core/__init__.py +1 -0
  28. intentumdiff/core/commit_differ.py +599 -0
  29. intentumdiff/core/config.py +51 -0
  30. intentumdiff/core/cst_serializer.py +101 -0
  31. intentumdiff/core/diffignore.py +87 -0
  32. intentumdiff/core/index.py +189 -0
  33. intentumdiff/core/indexer.py +792 -0
  34. intentumdiff/core/models.py +837 -0
  35. intentumdiff/differ.py +2195 -0
  36. intentumdiff/github_app.py +287 -0
  37. intentumdiff/intentumdiff_rust_core/__init__.py +7 -0
  38. intentumdiff/intentumdiff_rust_core/ffi.py +8 -0
  39. intentumdiff/intentumdiff_rust_core/intentumdiff_rust_core.dll +0 -0
  40. intentumdiff/invariances/__init__.py +2 -0
  41. intentumdiff/invariances/rules.schema.json +283 -0
  42. intentumdiff/invariances/rules.yaml +349 -0
  43. intentumdiff/live_server.py +1314 -0
  44. intentumdiff/lsp/__init__.py +67 -0
  45. intentumdiff/lsp/client.py +544 -0
  46. intentumdiff/lsp/config.py +96 -0
  47. intentumdiff/lsp/enricher.py +227 -0
  48. intentumdiff/lsp/exceptions.py +27 -0
  49. intentumdiff/lsp/launcher.py +273 -0
  50. intentumdiff/lsp/servers.py +356 -0
  51. intentumdiff/lsp_server/__init__.py +14 -0
  52. intentumdiff/lsp_server/_codelens.py +67 -0
  53. intentumdiff/lsp_server/_diagnostics.py +62 -0
  54. intentumdiff/lsp_server/_handlers.py +175 -0
  55. intentumdiff/lsp_server/server.py +205 -0
  56. intentumdiff/plugins/__init__.py +1 -0
  57. intentumdiff/plugins/adapter.py +397 -0
  58. intentumdiff/plugins/builtins.py +323 -0
  59. intentumdiff/plugins/exceptions.py +93 -0
  60. intentumdiff/plugins/hub.py +1155 -0
  61. intentumdiff/plugins/language_metadata.py +250 -0
  62. intentumdiff/plugins/loader.py +1252 -0
  63. intentumdiff/plugins/registry.py +1079 -0
  64. intentumdiff/plugins/registry.schema.json +99 -0
  65. intentumdiff/plugins/registry_schema.py +280 -0
  66. intentumdiff/plugins/wit/plugin.wit +351 -0
  67. intentumdiff/rust_core.py +2370 -0
  68. intentumdiff/serve/__init__.py +19 -0
  69. intentumdiff/serve/_app.py +485 -0
  70. intentumdiff/serve/_static/index.html +326 -0
  71. intentumdiff/serve/_static/playground.js +567 -0
  72. intentumdiff/sources/__init__.py +1 -0
  73. intentumdiff/sources/base.py +28 -0
  74. intentumdiff/sources/file_source.py +48 -0
  75. intentumdiff/sources/git_source.py +375 -0
  76. intentumdiff/sources/live_buffer_source.py +113 -0
  77. intentumdiff/sources/patch_source.py +126 -0
  78. intentumdiff/sources/string_source.py +44 -0
  79. intentumdiff/testing.py +165 -0
  80. intentumdiff/vcs/__init__.py +37 -0
  81. intentumdiff/vcs/_safe_path.py +50 -0
  82. intentumdiff/vcs/base.py +136 -0
  83. intentumdiff/vcs/git_backend.py +97 -0
  84. intentumdiff/vcs/git_cli.py +100 -0
  85. intentumdiff/vcs/hg_backend.py +94 -0
  86. intentumdiff/vcs/perforce_backend.py +109 -0
  87. intentumdiff/vcs/svn_backend.py +105 -0
  88. intentumdiff/wasm/.gitkeep +2 -0
  89. intentumdiff/wasm/abap_parser.wasm +0 -0
  90. intentumdiff/wasm/adf_parser.wasm +0 -0
  91. intentumdiff/wasm/asciidoc_parser.wasm +0 -0
  92. intentumdiff/wasm/asm_parser.wasm +0 -0
  93. intentumdiff/wasm/assemblyscript_parser.wasm +0 -0
  94. intentumdiff/wasm/astro_parser.wasm +0 -0
  95. intentumdiff/wasm/bash_parser.wasm +0 -0
  96. intentumdiff/wasm/clojure_parser.wasm +0 -0
  97. intentumdiff/wasm/cmake_parser.wasm +0 -0
  98. intentumdiff/wasm/cpp_parser.wasm +0 -0
  99. intentumdiff/wasm/csharp_parser.wasm +0 -0
  100. intentumdiff/wasm/css_parser.wasm +0 -0
  101. intentumdiff/wasm/dart_parser.wasm +0 -0
  102. intentumdiff/wasm/databricks_parser.wasm +0 -0
  103. intentumdiff/wasm/dax_parser.wasm +0 -0
  104. intentumdiff/wasm/delphi_parser.wasm +0 -0
  105. intentumdiff/wasm/dockerfile_parser.wasm +0 -0
  106. intentumdiff/wasm/elixir_parser.wasm +0 -0
  107. intentumdiff/wasm/freebasic_parser.wasm +0 -0
  108. intentumdiff/wasm/generic_parser.wasm +0 -0
  109. intentumdiff/wasm/gitignore_parser.wasm +0 -0
  110. intentumdiff/wasm/go_parser.wasm +0 -0
  111. intentumdiff/wasm/gomod_parser.wasm +0 -0
  112. intentumdiff/wasm/graphql_parser.wasm +0 -0
  113. intentumdiff/wasm/groovy_parser.wasm +0 -0
  114. intentumdiff/wasm/haskell_parser.wasm +0 -0
  115. intentumdiff/wasm/html_parser.wasm +0 -0
  116. intentumdiff/wasm/ini_parser.wasm +0 -0
  117. intentumdiff/wasm/java_parser.wasm +0 -0
  118. intentumdiff/wasm/js_ts_parser.wasm +0 -0
  119. intentumdiff/wasm/json_parser.wasm +0 -0
  120. intentumdiff/wasm/kotlin_parser.wasm +0 -0
  121. intentumdiff/wasm/latex_parser.wasm +0 -0
  122. intentumdiff/wasm/lua_parser.wasm +0 -0
  123. intentumdiff/wasm/make_parser.wasm +0 -0
  124. intentumdiff/wasm/markdown_parser.wasm +0 -0
  125. intentumdiff/wasm/mdx_parser.wasm +0 -0
  126. intentumdiff/wasm/ocaml_parser.wasm +0 -0
  127. intentumdiff/wasm/odin_parser.wasm +0 -0
  128. intentumdiff/wasm/parser_manifest.json +590 -0
  129. intentumdiff/wasm/perl_parser.wasm +0 -0
  130. intentumdiff/wasm/php_parser.wasm +0 -0
  131. intentumdiff/wasm/plsql_parser.wasm +0 -0
  132. intentumdiff/wasm/po_parser.wasm +0 -0
  133. intentumdiff/wasm/postscript_parser.wasm +0 -0
  134. intentumdiff/wasm/powershell_parser.wasm +0 -0
  135. intentumdiff/wasm/proto_parser.wasm +0 -0
  136. intentumdiff/wasm/puppet_parser.wasm +0 -0
  137. intentumdiff/wasm/python_parser.wasm +0 -0
  138. intentumdiff/wasm/qsharp_parser.wasm +0 -0
  139. intentumdiff/wasm/r_parser.wasm +0 -0
  140. intentumdiff/wasm/reasonml_parser.wasm +0 -0
  141. intentumdiff/wasm/ruby_parser.wasm +0 -0
  142. intentumdiff/wasm/rust_parser.wasm +0 -0
  143. intentumdiff/wasm/sas_parser.wasm +0 -0
  144. intentumdiff/wasm/scala_parser.wasm +0 -0
  145. intentumdiff/wasm/scss_parser.wasm +0 -0
  146. intentumdiff/wasm/sql_parser.wasm +0 -0
  147. intentumdiff/wasm/squirrel_parser.wasm +0 -0
  148. intentumdiff/wasm/svelte_parser.wasm +0 -0
  149. intentumdiff/wasm/swift_parser.wasm +0 -0
  150. intentumdiff/wasm/terraform_parser.wasm +0 -0
  151. intentumdiff/wasm/toml_parser.wasm +0 -0
  152. intentumdiff/wasm/tsql_parser.wasm +0 -0
  153. intentumdiff/wasm/vbnet_parser.wasm +0 -0
  154. intentumdiff/wasm/vue_parser.wasm +0 -0
  155. intentumdiff/wasm/wat_parser.wasm +0 -0
  156. intentumdiff/wasm/xml_parser.wasm +0 -0
  157. intentumdiff/wasm/yaml_parser.wasm +0 -0
  158. intentumdiff/wasm/zig_parser.wasm +0 -0
  159. intentumdiff/watcher.py +259 -0
  160. intentumdiff_python-0.0.1.dist-info/METADATA +112 -0
  161. intentumdiff_python-0.0.1.dist-info/RECORD +165 -0
  162. intentumdiff_python-0.0.1.dist-info/WHEEL +4 -0
  163. intentumdiff_python-0.0.1.dist-info/entry_points.txt +80 -0
  164. intentumdiff_python-0.0.1.dist-info/licenses/LICENSE +21 -0
  165. intentumdiff_python-0.0.1.dist-info/sboms/intentumdiff-rust-core.cyclonedx.json +10968 -0
@@ -0,0 +1,134 @@
1
+ """
2
+ intentumdiff
3
+ ~~~~~~~~~~~~~~~~
4
+
5
+ IntentumDiff public API package.
6
+
7
+ Quick start::
8
+
9
+ from intentumdiff import SemanticDiffer, GitSource, DiffConfig
10
+
11
+ differ = SemanticDiffer(DiffConfig(detect_refactorings=True))
12
+ diff = differ.diff(GitSource("/path/to/repo", "src/main.py"))
13
+
14
+ print(diff.has_semantic_changes)
15
+ for change in diff.changes:
16
+ print(change.change_type, change.description)
17
+ """
18
+
19
+ from intentumdiff.core.models import (
20
+ Change,
21
+ ChangeGroup,
22
+ ChangeGroupKind,
23
+ ChangeStreamEvent,
24
+ ChangeStreamPhase,
25
+ ChangeType,
26
+ CommitDiff,
27
+ CrossFileChange,
28
+ DetectionResult,
29
+ DiffConfig,
30
+ EditDelta,
31
+ FUEL_UNLIMITED,
32
+ GuardrailCheckResult,
33
+ GuardrailSeverity,
34
+ GuardrailViolation,
35
+ NodePosition,
36
+ RefactoringKind,
37
+ ReferenceKind,
38
+ ReferenceUsage,
39
+ SemanticDiff,
40
+ SemanticNode,
41
+ SymbolDefinition,
42
+ )
43
+ from intentumdiff.core.index import SemanticIndex
44
+ from intentumdiff.core.commit_differ import CommitDiffer
45
+ from intentumdiff.core.config import find_intentumdiff_config, load_project_diff_config
46
+ from intentumdiff.core.indexer import IndexProgress, IndexResult, Indexer
47
+ from intentumdiff.differ import SemanticDiffer
48
+ from intentumdiff.sources.file_source import FileSource
49
+ from intentumdiff.sources.git_source import GitSource, WorkingTreeSource
50
+ from intentumdiff.sources.live_buffer_source import LiveBufferSource
51
+ from intentumdiff.sources.patch_source import PatchSource
52
+ from intentumdiff.sources.string_source import StringSource
53
+ from intentumdiff.cache.store import CacheStore
54
+ from intentumdiff.cache.sqlite_store import SqliteCacheStore
55
+ from intentumdiff.live_server import LiveServer
56
+
57
+ __all__ = [
58
+ # Differ
59
+ "SemanticDiffer",
60
+ # Cross-file analysis
61
+ "CommitDiffer",
62
+ "SemanticIndex",
63
+ # Project config
64
+ "find_intentumdiff_config",
65
+ "load_project_diff_config",
66
+ # Indexing
67
+ "Indexer",
68
+ "IndexProgress",
69
+ "IndexResult",
70
+ # Sources
71
+ "GitSource",
72
+ "WorkingTreeSource",
73
+ "FileSource",
74
+ "LiveBufferSource",
75
+ "StringSource",
76
+ "PatchSource",
77
+ # Models
78
+ "DiffConfig",
79
+ "DetectionResult",
80
+ "FUEL_UNLIMITED",
81
+ "SemanticDiff",
82
+ "Change",
83
+ "ChangeGroup",
84
+ "ChangeGroupKind",
85
+ "ChangeStreamEvent",
86
+ "ChangeStreamPhase",
87
+ "ChangeType",
88
+ "EditDelta",
89
+ "GuardrailCheckResult",
90
+ "GuardrailSeverity",
91
+ "GuardrailViolation",
92
+ "RefactoringKind",
93
+ "SemanticNode",
94
+ "NodePosition",
95
+ "CommitDiff",
96
+ "CrossFileChange",
97
+ "SymbolDefinition",
98
+ "ReferenceKind",
99
+ "ReferenceUsage",
100
+ # Cache
101
+ "CacheStore",
102
+ "SqliteCacheStore",
103
+ # Indexing
104
+ "Indexer",
105
+ # Live server
106
+ "LiveServer",
107
+ # Testing
108
+ "PluginTestHarness",
109
+ ]
110
+
111
+ def _installed_version() -> str:
112
+ from importlib import metadata as importlib_metadata
113
+
114
+ # The distribution is "intentumdiff-python"; the import package is "intentumdiff".
115
+ # Looking up the import name finds no metadata once this is installed from a release
116
+ # wheel, which silently pinned __version__ to the literal below. "intentumdiff" is
117
+ # kept as a second candidate so pre-rename installs still report their real version.
118
+ for distribution in ("intentumdiff-python", "intentumdiff"):
119
+ try:
120
+ return importlib_metadata.version(distribution)
121
+ except importlib_metadata.PackageNotFoundError:
122
+ continue
123
+ return "0.0.1"
124
+
125
+
126
+ __version__ = _installed_version()
127
+
128
+
129
+ def __getattr__(name: str) -> object:
130
+ if name == "PluginTestHarness":
131
+ from intentumdiff.testing import PluginTestHarness
132
+
133
+ return PluginTestHarness
134
+ raise AttributeError(f"module 'intentumdiff' has no attribute {name!r}")
@@ -0,0 +1,210 @@
1
+ """Rust-engine certification gate helpers for intentumdiff.differ."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+ STRICT_RUST_GATE_ENV = "INTENTUMDIFF_ENFORCE_RUST_ONLY_ENGINE"
11
+
12
+
13
+ def _validate_git_ref(ref: str) -> None:
14
+ """Reject a git ref that could be mis-read as a ``git`` command-line option
15
+ (argument injection — e.g. ``--output=<path>`` turns ``git diff <ref>`` into
16
+ an arbitrary file write) or inject extra ``cat-file --batch`` request lines.
17
+
18
+ A ref starting with ``-`` is invalid per git's own ref-format rules, so this
19
+ never rejects a legitimate ref. The empty ref (working tree) is allowed.
20
+ This guards the public ``diff_commit`` boundary; the Rust native path and the
21
+ GitPython path both consume refs downstream. Security review: issue #88.
22
+ """
23
+ if not ref:
24
+ return
25
+ if ref.startswith("-"):
26
+ raise ValueError(
27
+ f"Invalid git ref {ref!r}: must not start with '-' "
28
+ "(argument-injection guard)."
29
+ )
30
+ if any(ch in ref for ch in ("\n", "\r", "\0")):
31
+ raise ValueError(
32
+ f"Invalid git ref {ref!r}: must not contain a newline or NUL."
33
+ )
34
+
35
+
36
+ # Languages whose single-file live diffs are served by the CERTIFIED Rust batch path.
37
+ # This set grows one ported slice at a time (migration plan Phase 2, issue #40) — adding a
38
+ # language here asserts the Rust core reproduces its full acceptance contract.
39
+ # INTENTUMDIFF_FORCE_RUST_CERTIFIED (comma-separated language ids) force-adds languages during
40
+ # port development: combined with INTENTUMDIFF_ENFORCE_RUST_ONLY_ENGINE=1, the raised gate
41
+ # errors for a forced language are that port's concrete checklist.
42
+ RUST_CERTIFIED_LANGUAGES: frozenset[str] = frozenset({"python"})
43
+
44
+
45
+ def _rust_certified_languages() -> frozenset[str]:
46
+ forced = os.environ.get("INTENTUMDIFF_FORCE_RUST_CERTIFIED", "")
47
+ if not forced:
48
+ return RUST_CERTIFIED_LANGUAGES
49
+ return RUST_CERTIFIED_LANGUAGES | {
50
+ part.strip().lower() for part in forced.split(",") if part.strip()
51
+ }
52
+
53
+
54
+ # Languages whose per-stage draft FINALIZATION routes through the Rust core (issue #57 —
55
+ # the retirement path for python refinement/presentation). Grows per parity-verified
56
+ # language; INTENTUMDIFF_RUST_FINALIZE_LANGS (comma-separated) adds pilots.
57
+ RUST_FINALIZE_LANGUAGES: frozenset[str] = frozenset(
58
+ {
59
+ "go", "kotlin", "ruby", "swift", "java", "c", "cpp", "gitignore",
60
+ "csharp", "elixir", "perl", "scala", "xml", "haskell",
61
+ # Structured-language batch (issue #57): parity-verified clean under routing —
62
+ # no engine change, per-language contracts + cross-cutting infra all green.
63
+ "adf", "asciidoc", "assemblyscript", "clojure", "databricks",
64
+ "databricks-workflow", "dax", "groovy", "latex", "lua", "ocaml", "odin",
65
+ "php", "plsql", "po", "postscript", "qsharp", "reasonml",
66
+ "sas", "squirrel", "tsql", "vbnet", "wast", "wat",
67
+ "puppet", "hcl",
68
+ # Body-reference variable renames corroborated by an anchored callable's param rename
69
+ # (promote_corroborated_variable_renames) — the routed analogue of refactoring.py's
70
+ # inferred_rename_pairs, which the default path used for dart's single-letter renames.
71
+ "dart",
72
+ # Structured/markup batch (#57): parity-verified clean under routing (full-suite gated).
73
+ # generic was piloted too but breaks the generic-text/markdown/text fallback path
74
+ # (#35/#36/#44) — deferred to its own fix.
75
+ "svelte", "astro", "vue", "mdx", "scss",
76
+ # dockerfile: needs the resource-profile shell-command identity keying (dockerfile_key),
77
+ # now ported to Rust so an inserted RUN doesn't cross-pair positionally.
78
+ "dockerfile",
79
+ # asm (experimental, #57): statement-profile language — instructions key by mnemonic +
80
+ # first-operand identity (asm_key) so an operand-value edit is a MODIFICATION, not churn.
81
+ "asm",
82
+ # css (#57): unblocked by applying semantic invariances in the routed short-circuit —
83
+ # the color-canonicalization equivalence (red≡#ff0000, blue≡#0000ff) now fires under
84
+ # routing. (yaml/json graceful-xfail shape + python dedent still gap-blocked.)
85
+ "css",
86
+ # bash (#57): bash_key ported (commands key by NAME) + the cross-key MODIFICATION split —
87
+ # `:` -> `echo Hello` unpaires into DELETE+ADD with descendant scaffold folded.
88
+ "bash",
89
+ # delphi (#57): delphi_key ported (statements keyed by call/assign identity) + statement
90
+ # review containers anchor in suppress_parent_modifications — the WriteLn edit presents
91
+ # as ONE statement MODIFICATION with descendant mods folded.
92
+ "delphi",
93
+ # m / Power Query (#57): served by the dax parser (dax routed-green); the step-edit
94
+ # contract reformulated to anti-swallowing (routed pairs the predicate edit as ONE
95
+ # MODIFICATION carrying both sides — honest, not the default's DELETE+ADD split).
96
+ "m",
97
+ # powershell (#57/#66): unblocked by the entity-anchored matching port — reordered
98
+ # functions pair by identity and surface as MOVEs (31/31 force-routed).
99
+ "powershell",
100
+ # json/yaml (#57): keyed-data profile port — pairs/items key by ancestor key path; array
101
+ # scalars/items by CONTENT identity (not position labels), so an inserted element never
102
+ # cross-pairs later unchanged values; identical-content positional churn suppresses with
103
+ # evidence; yaml block↔flow representation equivalence (YAML 1.2 §3) is style, not change.
104
+ "json", "yaml",
105
+ # html (#57/#64): path-profile keying port — elements key by their element PATH with
106
+ # identity attributes (id/name/key/…) beating same-tag ordinals, and relocated
107
+ # identical-content elements keep their match (stable-same-label escape) — a text edit
108
+ # inside an id-bearing or restructured element survives sibling inserts.
109
+ "html",
110
+ # rust (#57/#60): unlocked by the entity-anchored matching port (augment_entity_matching)
111
+ # — match→if-let now surfaces as a statement-rewrite MODIFICATION instead of losing the
112
+ # relocated arm bodies to DELETE+ADD churn. Full rust suite 112/112 force-routed.
113
+ "rust",
114
+ # abap (#57): entity-anchored grouping ported (entity_child_content_groups) — a child
115
+ # modification under a same-identity form groups as "GREET changed", not a free leaf edit.
116
+ "abap",
117
+ # r (#57): unblocked by the any→all truthiness fix in the signature-coverage suppression —
118
+ # a NEW function sharing param labels with a rename is no longer erased.
119
+ "r",
120
+ # zig (#57): parity-verified clean under routing post-anchors (14/14 force-routed) —
121
+ # pure routing, no engine change.
122
+ "zig",
123
+ # sql (#57): query-profile port (sql_key + matching/changes augmentation) — clauses,
124
+ # relations, and fields pair by role + normalized identity within their statement, so an
125
+ # added JOIN doesn't shift FROM into a bogus MOVE and unchanged SELECT fields never churn.
126
+ # The dax half of the profile is deliberately NOT ported (dax routed green without it).
127
+ "sql",
128
+ # freebasic/terraform (#57): parity-verified clean under routing (dedicated tests +
129
+ # the cross-cutting suites in the full gate) — pure routing, no engine change.
130
+ "freebasic", "terraform",
131
+ # graphql (#57/#67): unblocked by porting surface_changed_in_place_entity — a matched
132
+ # named entity (type/query/fragment) whose body changed carries its label into a group.
133
+ "graphql",
134
+ # javascript/typescript/tsx (#57): three ports close the js-family gap — (1) the
135
+ # function-valued-declaration profile (const f = () => … pairs with function f(…) as
136
+ # one entity) in the anchors code, (2) the style rule relabelling suppression residue
137
+ # as an IGNORED_STYLE group (provenance "suppression"), and (3) moved-pair literal
138
+ # update recovery (the #37 leaf score, move-pair scoped): edit-script pruning of
139
+ # unmatched leaves under moved subtrees was swallowing md5→sha256 inside a hoisted
140
+ # calc_hash. Same-label DELETE+ADD container churn around reported renames suppresses
141
+ # under a rename-coverage truthiness guard (tighter than the python pass it ports).
142
+ "javascript", "typescript", "tsx",
143
+ # generic (#57): the text review and both markdown section passes were already
144
+ # Rust-first; the routed short-circuit now mirrors the stage-12 orchestration
145
+ # (token churn replaced wholesale by Rust line spans, markdown section passes for
146
+ # .md filenames, stage-12 style-only resolution for empty results).
147
+ "generic",
148
+ # python (#57): the flagship, last. The certified BATCH path (sources->final in
149
+ # Rust, semantic_contract rust_finalized_v1) still serves default configs FIRST;
150
+ # the tier behind it is the full-Rust 9-fin routing (the stage-11 hybrid and the
151
+ # transitional python stages were deleted in the stage-4b payoff).
152
+ "python",
153
+ # markdown (#44): the tree-sitter markdown parser takes .md off the generic
154
+ # fallback — sections/headings/fences are REAL nodes (the corpus "section"
155
+ # entity vocabulary and the reorder→MOVE promotion consume them natively).
156
+ "markdown",
157
+ # toml (#48): keyed config format — tables/pairs are labeled by header/key
158
+ # identity in the parser itself, so the routed finalize pairs value edits
159
+ # under stable keys natively.
160
+ "toml",
161
+ # ini (#48): keyed config — sections by header, settings by key, same identity
162
+ # model as toml; certified on the same template.
163
+ "ini",
164
+ # gomod (#48): keyed dependency manifest — specs by module path, versions as
165
+ # semantic children; a version bump is ONE modification under stable identity.
166
+ "gomod",
167
+ # make (#48): rules by target identity, assignments by variable name, recipe
168
+ # lines as semantic children — a recipe edit pairs under its target.
169
+ "make",
170
+ # proto (#48): messages/services/enums/rpcs by name, fields by identifier with
171
+ # type + field number as semantic children — the wire-compat review story.
172
+ "proto",
173
+ # cmake (#48): commands labeled identifier(first-arg) so target identity is
174
+ # part of the command; function/macro defs by their defined name.
175
+ "cmake",
176
+ }
177
+ )
178
+
179
+
180
+ def _rust_finalize_languages() -> frozenset[str]:
181
+ # The set is TOTAL (all 67 supported languages, issue #57 2026-07-15), so it now
182
+ # serves as the certified-language allowlist. The INTENTUMDIFF_RUST_FINALIZE_LANGS
183
+ # pilot escape hatch is retired with the campaign: it existed to force-route
184
+ # candidates during per-language certification, and every candidate is routed.
185
+ # New languages certify by joining RUST_FINALIZE_LANGUAGES in code, behind the
186
+ # same protocol (force-routed probe -> Rust pin -> full gate -> flip).
187
+ return RUST_FINALIZE_LANGUAGES
188
+
189
+
190
+ def _strict_rust_only_enabled() -> bool:
191
+ return os.getenv(STRICT_RUST_GATE_ENV, "").strip() == "1"
192
+
193
+
194
+ class RustOnlyGateError(RuntimeError):
195
+ """Raised when the RUST_ONLY gate blocks a genuine token-level fallback.
196
+
197
+ Subclasses ``RuntimeError`` so existing ``pytest.raises(RuntimeError, …)``
198
+ assertions still match, but its distinct type lets the commit-path fan-out
199
+ (``diff_commit``'s per-file executor) tell a fatal gate trip apart from the
200
+ ordinary per-file ``RuntimeError`` it deliberately swallows-and-skips. A
201
+ swallowed gate error would silently drop a file instead of failing loudly,
202
+ defeating the whole point of the gate — so the executor re-raises this type.
203
+ """
204
+
205
+
206
+ def _raise_rust_only_gate_error(reason: str | None) -> None:
207
+ if reason is not None and _strict_rust_only_enabled():
208
+ raise RustOnlyGateError(f"Rust-only engine gate prevented fallback: {reason}")
209
+
210
+